@wordpress/media-editor 0.21.0 → 0.23.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/CHANGELOG.md +30 -0
- package/build/components/media-editor/index.cjs +586 -686
- package/build/components/media-editor/index.cjs.map +1 -7
- package/build/components/media-editor/use-crop-options.cjs +42 -57
- package/build/components/media-editor/use-crop-options.cjs.map +1 -7
- package/build/components/media-editor/use-save-media-editor.cjs +131 -185
- package/build/components/media-editor/use-save-media-editor.cjs.map +1 -7
- package/build/components/media-editor-canvas/index.cjs +117 -124
- package/build/components/media-editor-canvas/index.cjs.map +1 -7
- package/build/components/media-editor-crop-panel/index.cjs +81 -72
- package/build/components/media-editor-crop-panel/index.cjs.map +1 -7
- package/build/components/media-editor-fine-rotation/index.cjs +61 -72
- package/build/components/media-editor-fine-rotation/index.cjs.map +1 -7
- package/build/components/media-editor-image-controls/index.cjs +181 -257
- package/build/components/media-editor-image-controls/index.cjs.map +1 -7
- package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +120 -157
- package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -7
- package/build/components/media-editor-modal/index.cjs +112 -155
- package/build/components/media-editor-modal/index.cjs.map +1 -7
- package/build/components/media-editor-provider/index.cjs +32 -55
- package/build/components/media-editor-provider/index.cjs.map +1 -7
- package/build/components/media-form/index.cjs +82 -77
- package/build/components/media-form/index.cjs.map +1 -7
- package/build/components/media-preview/index.cjs +113 -114
- package/build/components/media-preview/index.cjs.map +1 -7
- package/build/components/rotation-ruler/index.cjs +181 -188
- package/build/components/rotation-ruler/index.cjs.map +1 -7
- package/build/components/rotation-ruler/use-ruler-drag.cjs +132 -149
- package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -7
- package/build/hooks/use-crop-gesture-handlers.cjs +82 -76
- package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -7
- package/build/index.cjs +45 -39
- package/build/lock-unlock.cjs +9 -35
- package/build/lock-unlock.cjs.map +1 -7
- package/build/private-apis.cjs +16 -37
- package/build/private-apis.cjs.map +1 -7
- package/build/state/aspect-ratio-presets.cjs +59 -0
- package/build/state/aspect-ratio-presets.cjs.map +1 -0
- package/build/state/composite-reducer.cjs +100 -113
- package/build/state/composite-reducer.cjs.map +1 -7
- package/build/state/index.cjs +22 -45
- package/build/state/media-editor-state-provider.cjs +35 -48
- package/build/state/media-editor-state-provider.cjs.map +1 -7
- package/build/state/types.cjs +11 -31
- package/build/state/types.cjs.map +1 -7
- package/build/state/use-media-editor-state.cjs +227 -296
- package/build/state/use-media-editor-state.cjs.map +1 -7
- package/build/store/actions.cjs +17 -44
- package/build/store/actions.cjs.map +1 -7
- package/build/store/constants.cjs +8 -29
- package/build/store/constants.cjs.map +1 -7
- package/build/store/index.cjs +33 -40
- package/build/store/index.cjs.map +1 -7
- package/build/store/reducer.cjs +28 -50
- package/build/store/reducer.cjs.map +1 -7
- package/build/store/selectors.cjs +16 -41
- package/build/store/selectors.cjs.map +1 -7
- package/build/utils/get-media-type.cjs +18 -41
- package/build/utils/get-media-type.cjs.map +1 -7
- package/build/utils/index.cjs +9 -28
- package/build-module/components/media-editor/index.mjs +545 -675
- package/build-module/components/media-editor/index.mjs.map +1 -7
- package/build-module/components/media-editor/use-crop-options.mjs +37 -32
- package/build-module/components/media-editor/use-crop-options.mjs.map +1 -7
- package/build-module/components/media-editor/use-save-media-editor.mjs +109 -157
- package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -7
- package/build-module/components/media-editor-canvas/index.mjs +95 -98
- package/build-module/components/media-editor-canvas/index.mjs.map +1 -7
- package/build-module/components/media-editor-crop-panel/index.mjs +59 -46
- package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -7
- package/build-module/components/media-editor-fine-rotation/index.mjs +39 -46
- package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -7
- package/build-module/components/media-editor-image-controls/index.mjs +171 -238
- package/build-module/components/media-editor-image-controls/index.mjs.map +1 -7
- package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +113 -137
- package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -7
- package/build-module/components/media-editor-modal/index.mjs +88 -124
- package/build-module/components/media-editor-modal/index.mjs.map +1 -7
- package/build-module/components/media-editor-provider/index.mjs +26 -29
- package/build-module/components/media-editor-provider/index.mjs.map +1 -7
- package/build-module/components/media-form/index.mjs +74 -56
- package/build-module/components/media-form/index.mjs.map +1 -7
- package/build-module/components/media-preview/index.mjs +105 -90
- package/build-module/components/media-preview/index.mjs.map +1 -7
- package/build-module/components/rotation-ruler/index.mjs +161 -164
- package/build-module/components/rotation-ruler/index.mjs.map +1 -7
- package/build-module/components/rotation-ruler/use-ruler-drag.mjs +125 -122
- package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +1 -7
- package/build-module/hooks/use-crop-gesture-handlers.mjs +76 -50
- package/build-module/hooks/use-crop-gesture-handlers.mjs.map +1 -7
- package/build-module/index.mjs +3 -10
- package/build-module/lock-unlock.mjs +5 -10
- package/build-module/lock-unlock.mjs.map +1 -7
- package/build-module/private-apis.mjs +8 -9
- package/build-module/private-apis.mjs.map +1 -7
- package/build-module/state/aspect-ratio-presets.mjs +53 -0
- package/build-module/state/aspect-ratio-presets.mjs.map +1 -0
- package/build-module/state/composite-reducer.mjs +80 -91
- package/build-module/state/composite-reducer.mjs.map +1 -7
- package/build-module/state/index.mjs +3 -26
- package/build-module/state/media-editor-state-provider.mjs +29 -24
- package/build-module/state/media-editor-state-provider.mjs.map +1 -7
- package/build-module/state/types.mjs +7 -7
- package/build-module/state/types.mjs.map +1 -7
- package/build-module/state/use-media-editor-state.mjs +223 -288
- package/build-module/state/use-media-editor-state.mjs.map +1 -7
- package/build-module/store/actions.mjs +12 -19
- package/build-module/store/actions.mjs.map +1 -7
- package/build-module/store/constants.mjs +4 -5
- package/build-module/store/constants.mjs.map +1 -7
- package/build-module/store/index.mjs +8 -9
- package/build-module/store/index.mjs.map +1 -7
- package/build-module/store/reducer.mjs +23 -26
- package/build-module/store/reducer.mjs.map +1 -7
- package/build-module/store/selectors.mjs +8 -13
- package/build-module/store/selectors.mjs.map +1 -7
- package/build-module/utils/get-media-type.mjs +14 -17
- package/build-module/utils/get-media-type.mjs.map +1 -7
- package/build-module/utils/index.mjs +1 -6
- package/build-style/style-rtl.css +145 -61
- package/build-style/style.css +144 -61
- package/build-types/components/media-editor/index.d.ts +20 -2
- package/build-types/components/media-editor/index.d.ts.map +1 -1
- package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
- package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
- package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
- package/build-types/components/media-editor-canvas/index.d.ts +3 -3
- 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-fine-rotation/index.d.ts.map +1 -1
- package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
- package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
- package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
- package/build-types/components/media-editor-modal/index.d.ts +1 -1
- package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
- package/build-types/components/media-form/index.d.ts.map +1 -1
- package/build-types/components/media-preview/index.d.ts.map +1 -1
- package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -1
- package/build-types/state/aspect-ratio-presets.d.ts +24 -0
- package/build-types/state/aspect-ratio-presets.d.ts.map +1 -0
- package/build-types/state/composite-reducer.d.ts +17 -19
- package/build-types/state/composite-reducer.d.ts.map +1 -1
- package/build-types/state/index.d.ts +2 -4
- package/build-types/state/index.d.ts.map +1 -1
- package/build-types/state/types.d.ts +20 -63
- package/build-types/state/types.d.ts.map +1 -1
- package/build-types/state/use-media-editor-state.d.ts +33 -52
- package/build-types/state/use-media-editor-state.d.ts.map +1 -1
- package/package.json +22 -23
- package/src/components/media-editor/index.tsx +355 -167
- package/src/components/media-editor/style.scss +19 -0
- package/src/components/media-editor/use-crop-options.ts +9 -10
- package/src/components/media-editor/use-save-media-editor.ts +48 -10
- package/src/components/media-editor-canvas/index.tsx +30 -51
- package/src/components/media-editor-canvas/style.scss +6 -6
- package/src/components/media-editor-crop-panel/index.tsx +38 -2
- package/src/components/media-editor-crop-panel/style.scss +21 -0
- package/src/components/media-editor-fine-rotation/index.tsx +6 -6
- package/src/components/media-editor-image-controls/index.tsx +15 -11
- package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +1 -0
- package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
- package/src/components/media-editor-modal/index.tsx +1 -1
- package/src/components/media-editor-modal/style.scss +1 -1
- package/src/components/media-form/index.tsx +7 -1
- package/src/components/media-preview/index.tsx +65 -23
- package/src/components/media-preview/style.scss +16 -2
- package/src/components/rotation-ruler/style.scss +9 -5
- package/src/components/rotation-ruler/use-ruler-drag.ts +6 -11
- package/src/state/README.md +32 -0
- package/src/state/aspect-ratio-presets.ts +37 -0
- package/src/state/composite-reducer.ts +42 -80
- package/src/state/index.ts +2 -17
- package/src/state/types.ts +18 -72
- package/src/state/use-media-editor-state.ts +155 -238
- package/src/style.scss +2 -1
- package/build/components/media-editor-modal/build-modifiers.cjs +0 -91
- package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -7
- package/build/image-editor/core/camera.cjs +0 -225
- package/build/image-editor/core/camera.cjs.map +0 -7
- package/build/image-editor/core/constants.cjs +0 -108
- package/build/image-editor/core/constants.cjs.map +0 -7
- package/build/image-editor/core/containment.cjs +0 -276
- package/build/image-editor/core/containment.cjs.map +0 -7
- package/build/image-editor/core/crop-rect.cjs +0 -48
- package/build/image-editor/core/crop-rect.cjs.map +0 -7
- package/build/image-editor/core/export/canvas-renderer.cjs +0 -151
- package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -7
- package/build/image-editor/core/index.cjs +0 -62
- package/build/image-editor/core/index.cjs.map +0 -7
- package/build/image-editor/core/interaction-controller.cjs +0 -654
- package/build/image-editor/core/interaction-controller.cjs.map +0 -7
- package/build/image-editor/core/math/rotation.cjs +0 -41
- package/build/image-editor/core/math/rotation.cjs.map +0 -7
- package/build/image-editor/core/math/sanitize.cjs +0 -92
- package/build/image-editor/core/math/sanitize.cjs.map +0 -7
- package/build/image-editor/core/setter-helpers.cjs +0 -64
- package/build/image-editor/core/setter-helpers.cjs.map +0 -7
- package/build/image-editor/core/source-region.cjs +0 -206
- package/build/image-editor/core/source-region.cjs.map +0 -7
- package/build/image-editor/core/state.cjs +0 -283
- package/build/image-editor/core/state.cjs.map +0 -7
- package/build/image-editor/core/stencil-math.cjs +0 -216
- package/build/image-editor/core/stencil-math.cjs.map +0 -7
- package/build/image-editor/core/transform-style.cjs +0 -52
- package/build/image-editor/core/transform-style.cjs.map +0 -7
- package/build/image-editor/core/transforms/pipeline.cjs +0 -43
- package/build/image-editor/core/transforms/pipeline.cjs.map +0 -7
- package/build/image-editor/core/types.cjs +0 -19
- package/build/image-editor/core/types.cjs.map +0 -7
- package/build/image-editor/core/viewport-state.cjs +0 -50
- package/build/image-editor/core/viewport-state.cjs.map +0 -7
- package/build/image-editor/index.cjs +0 -67
- package/build/image-editor/index.cjs.map +0 -7
- package/build/image-editor/react/components/cropper-provider.cjs +0 -50
- package/build/image-editor/react/components/cropper-provider.cjs.map +0 -7
- package/build/image-editor/react/components/cropper.cjs +0 -722
- package/build/image-editor/react/components/cropper.cjs.map +0 -7
- package/build/image-editor/react/components/index.cjs +0 -36
- package/build/image-editor/react/components/index.cjs.map +0 -7
- package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -172
- package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -7
- package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -62
- package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -7
- package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -91
- package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -7
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -426
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -7
- package/build/image-editor/react/components/viewport-provider.cjs +0 -51
- package/build/image-editor/react/components/viewport-provider.cjs.map +0 -7
- package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -71
- package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -7
- package/build/image-editor/react/hooks/index.cjs +0 -34
- package/build/image-editor/react/hooks/index.cjs.map +0 -7
- package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -160
- package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -7
- package/build/image-editor/react/hooks/use-cropper-reducer.cjs +0 -113
- package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +0 -7
- package/build/image-editor/react/hooks/use-interaction.cjs +0 -213
- package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -7
- package/build/image-editor/react/hooks/use-transform-style.cjs +0 -38
- package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -7
- package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -51
- package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -7
- package/build/image-editor/react/visually-hidden-style.cjs +0 -41
- package/build/image-editor/react/visually-hidden-style.cjs.map +0 -7
- package/build/index.cjs.map +0 -7
- package/build/state/index.cjs.map +0 -7
- package/build/utils/index.cjs.map +0 -7
- package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -66
- package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -7
- package/build-module/image-editor/core/camera.mjs +0 -198
- package/build-module/image-editor/core/camera.mjs.map +0 -7
- package/build-module/image-editor/core/constants.mjs +0 -69
- package/build-module/image-editor/core/constants.mjs.map +0 -7
- package/build-module/image-editor/core/containment.mjs +0 -253
- package/build-module/image-editor/core/containment.mjs.map +0 -7
- package/build-module/image-editor/core/crop-rect.mjs +0 -23
- package/build-module/image-editor/core/crop-rect.mjs.map +0 -7
- package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -120
- package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -7
- package/build-module/image-editor/core/index.mjs +0 -36
- package/build-module/image-editor/core/index.mjs.map +0 -7
- package/build-module/image-editor/core/interaction-controller.mjs +0 -635
- package/build-module/image-editor/core/interaction-controller.mjs.map +0 -7
- package/build-module/image-editor/core/math/rotation.mjs +0 -15
- package/build-module/image-editor/core/math/rotation.mjs.map +0 -7
- package/build-module/image-editor/core/math/sanitize.mjs +0 -63
- package/build-module/image-editor/core/math/sanitize.mjs.map +0 -7
- package/build-module/image-editor/core/setter-helpers.mjs +0 -39
- package/build-module/image-editor/core/setter-helpers.mjs.map +0 -7
- package/build-module/image-editor/core/source-region.mjs +0 -178
- package/build-module/image-editor/core/source-region.mjs.map +0 -7
- package/build-module/image-editor/core/state.mjs +0 -260
- package/build-module/image-editor/core/state.mjs.map +0 -7
- package/build-module/image-editor/core/stencil-math.mjs +0 -187
- package/build-module/image-editor/core/stencil-math.mjs.map +0 -7
- package/build-module/image-editor/core/transform-style.mjs +0 -27
- package/build-module/image-editor/core/transform-style.mjs.map +0 -7
- package/build-module/image-editor/core/transforms/pipeline.mjs +0 -17
- package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -7
- package/build-module/image-editor/core/types.mjs +0 -1
- package/build-module/image-editor/core/types.mjs.map +0 -7
- package/build-module/image-editor/core/viewport-state.mjs +0 -24
- package/build-module/image-editor/core/viewport-state.mjs.map +0 -7
- package/build-module/image-editor/index.mjs +0 -39
- package/build-module/image-editor/index.mjs.map +0 -7
- package/build-module/image-editor/react/components/cropper-provider.mjs +0 -26
- package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -7
- package/build-module/image-editor/react/components/cropper.mjs +0 -704
- package/build-module/image-editor/react/components/cropper.mjs.map +0 -7
- package/build-module/image-editor/react/components/index.mjs +0 -9
- package/build-module/image-editor/react/components/index.mjs.map +0 -7
- package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -147
- package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -7
- package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -37
- package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -7
- package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -66
- package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -7
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -414
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -7
- package/build-module/image-editor/react/components/viewport-provider.mjs +0 -27
- package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -7
- package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -46
- package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -7
- package/build-module/image-editor/react/hooks/index.mjs +0 -8
- package/build-module/image-editor/react/hooks/index.mjs.map +0 -7
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -135
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -7
- package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +0 -100
- package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +0 -7
- package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -190
- package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -7
- package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -13
- package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -7
- package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -29
- package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -7
- package/build-module/image-editor/react/visually-hidden-style.mjs +0 -16
- package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -7
- package/build-module/index.mjs.map +0 -7
- package/build-module/state/index.mjs.map +0 -7
- package/build-module/utils/index.mjs.map +0 -7
- package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -80
- package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
- package/build-types/image-editor/core/camera.d.ts +0 -128
- package/build-types/image-editor/core/camera.d.ts.map +0 -1
- package/build-types/image-editor/core/constants.d.ts +0 -99
- package/build-types/image-editor/core/constants.d.ts.map +0 -1
- package/build-types/image-editor/core/containment.d.ts +0 -72
- package/build-types/image-editor/core/containment.d.ts.map +0 -1
- package/build-types/image-editor/core/crop-rect.d.ts +0 -16
- package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
- package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
- package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
- package/build-types/image-editor/core/index.d.ts +0 -10
- package/build-types/image-editor/core/index.d.ts.map +0 -1
- package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
- package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
- package/build-types/image-editor/core/math/rotation.d.ts +0 -18
- package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
- package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
- package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
- package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
- package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
- package/build-types/image-editor/core/source-region.d.ts +0 -94
- package/build-types/image-editor/core/source-region.d.ts.map +0 -1
- package/build-types/image-editor/core/state.d.ts +0 -51
- package/build-types/image-editor/core/state.d.ts.map +0 -1
- package/build-types/image-editor/core/stencil-math.d.ts +0 -102
- package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
- package/build-types/image-editor/core/transform-style.d.ts +0 -20
- package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
- package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
- package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
- package/build-types/image-editor/core/types.d.ts +0 -269
- package/build-types/image-editor/core/types.d.ts.map +0 -1
- package/build-types/image-editor/core/viewport-state.d.ts +0 -4
- package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
- package/build-types/image-editor/index.d.ts +0 -16
- package/build-types/image-editor/index.d.ts.map +0 -1
- package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
- package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
- package/build-types/image-editor/react/components/cropper.d.ts +0 -63
- package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
- package/build-types/image-editor/react/components/index.d.ts +0 -4
- package/build-types/image-editor/react/components/index.d.ts.map +0 -1
- package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
- package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
- package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
- package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
- package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
- package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
- package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
- package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
- package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
- package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
- package/build-types/image-editor/react/hooks/index.d.ts +0 -5
- package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
- package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +0 -55
- package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +0 -1
- package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
- package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
- package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
- package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
- package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
- package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
- package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
- package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
- package/src/components/media-editor-modal/build-modifiers.ts +0 -161
- package/src/image-editor/README.md +0 -61
- package/src/image-editor/core/camera.ts +0 -429
- package/src/image-editor/core/constants.ts +0 -150
- package/src/image-editor/core/containment.ts +0 -469
- package/src/image-editor/core/crop-rect.ts +0 -42
- package/src/image-editor/core/export/canvas-renderer.ts +0 -250
- package/src/image-editor/core/index.ts +0 -47
- package/src/image-editor/core/interaction-controller.ts +0 -976
- package/src/image-editor/core/math/rotation.ts +0 -26
- package/src/image-editor/core/math/sanitize.ts +0 -155
- package/src/image-editor/core/setter-helpers.ts +0 -63
- package/src/image-editor/core/source-region.ts +0 -367
- package/src/image-editor/core/state.ts +0 -484
- package/src/image-editor/core/stencil-math.ts +0 -379
- package/src/image-editor/core/transform-style.ts +0 -56
- package/src/image-editor/core/transforms/pipeline.ts +0 -40
- package/src/image-editor/core/types.ts +0 -230
- package/src/image-editor/core/viewport-state.ts +0 -30
- package/src/image-editor/docs/architecture.md +0 -63
- package/src/image-editor/docs/recipes.md +0 -184
- package/src/image-editor/index.ts +0 -52
- package/src/image-editor/react/components/cropper-provider.tsx +0 -70
- package/src/image-editor/react/components/cropper.scss +0 -259
- package/src/image-editor/react/components/cropper.tsx +0 -1116
- package/src/image-editor/react/components/index.ts +0 -3
- package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
- package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
- package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
- package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
- package/src/image-editor/react/components/viewport-provider.tsx +0 -32
- package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
- package/src/image-editor/react/hooks/index.ts +0 -4
- package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
- package/src/image-editor/react/hooks/use-cropper-reducer.ts +0 -197
- package/src/image-editor/react/hooks/use-interaction.ts +0 -294
- package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
- package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
- package/src/image-editor/react/visually-hidden-style.ts +0 -15
- package/src/image-editor/style.scss +0 -1
|
@@ -1,135 +1,128 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
// \0rolldown/runtime.js
|
|
2
7
|
var __create = Object.create;
|
|
3
8
|
var __defProp = Object.defineProperty;
|
|
4
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
13
|
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
|
+
key = keys[i];
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
19
22
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
let clsx = require("clsx");
|
|
28
|
+
clsx = __toESM(clsx);
|
|
29
|
+
let _wordpress_element = require("@wordpress/element");
|
|
30
|
+
let _wordpress_components = require("@wordpress/components");
|
|
31
|
+
let _wordpress_i18n = require("@wordpress/i18n");
|
|
32
|
+
let _wordpress_image_editor = require("@wordpress/image-editor");
|
|
33
|
+
let ___media_editor_provider_index_tsx = require("../media-editor-provider/index.cjs");
|
|
34
|
+
let ______utils_index_ts = require("../../utils/index.cjs");
|
|
35
|
+
let ______state_index_ts = require("../../state/index.cjs");
|
|
36
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
30
37
|
// packages/media-editor/src/components/media-editor-canvas/index.tsx
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
function MediaEditorCanvas({
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
import_image_editor.Cropper,
|
|
119
|
-
{
|
|
120
|
-
src: mediaUrl,
|
|
121
|
-
controller: session.cropper,
|
|
122
|
-
aspectRatio,
|
|
123
|
-
freeformCrop: true,
|
|
124
|
-
showGrid: "interactive",
|
|
125
|
-
isPlacementActive,
|
|
126
|
-
onGestureStart: handleGestureStart,
|
|
127
|
-
onGestureEnd: handleGestureEnd,
|
|
128
|
-
disabled
|
|
129
|
-
}
|
|
130
|
-
)
|
|
131
|
-
}
|
|
132
|
-
)
|
|
133
|
-
] });
|
|
38
|
+
/**
|
|
39
|
+
* Editing surface for image media in the media editor modal. Pulls
|
|
40
|
+
* its image editor controller from the surrounding `<MediaEditorStateProvider>`
|
|
41
|
+
* so the bottom bar and Crop sidebar tab share the same state.
|
|
42
|
+
*
|
|
43
|
+
* Returns `null` for missing or non-image media so the modal's outer
|
|
44
|
+
* guards can render a spinner or fall through to `<MediaPreview>`.
|
|
45
|
+
*
|
|
46
|
+
* @param props
|
|
47
|
+
* @param props.isPlacementActive
|
|
48
|
+
* @param props.onGestureStart
|
|
49
|
+
* @param props.onGestureEnd
|
|
50
|
+
* @param props.disabled
|
|
51
|
+
*/
|
|
52
|
+
function MediaEditorCanvas({ isPlacementActive = false, onGestureStart, onGestureEnd, disabled = false }) {
|
|
53
|
+
const { media } = (0, ___media_editor_provider_index_tsx.useMediaEditorContext)();
|
|
54
|
+
const session = (0, ______state_index_ts.useMediaEditor)();
|
|
55
|
+
const { beginGesture, endGesture, setSourceImage } = session;
|
|
56
|
+
const [settled, setSettled] = (0, _wordpress_element.useState)();
|
|
57
|
+
const handleGestureStart = (0, _wordpress_element.useCallback)(() => {
|
|
58
|
+
beginGesture();
|
|
59
|
+
onGestureStart?.();
|
|
60
|
+
}, [beginGesture, onGestureStart]);
|
|
61
|
+
const handleGestureEnd = (0, _wordpress_element.useCallback)(() => {
|
|
62
|
+
endGesture();
|
|
63
|
+
onGestureEnd?.();
|
|
64
|
+
}, [endGesture, onGestureEnd]);
|
|
65
|
+
const mediaUrl = media?.source_url;
|
|
66
|
+
const mediaType = (0, ______utils_index_ts.getMediaTypeFromMimeType)(media?.mime_type);
|
|
67
|
+
const mediaWidth = Number(media?.media_details?.width);
|
|
68
|
+
const mediaHeight = Number(media?.media_details?.height);
|
|
69
|
+
(0, _wordpress_element.useEffect)(() => {
|
|
70
|
+
if (!mediaUrl || !Number.isFinite(mediaWidth) || !Number.isFinite(mediaHeight) || mediaWidth <= 0 || mediaHeight <= 0) return;
|
|
71
|
+
setSourceImage({
|
|
72
|
+
src: mediaUrl,
|
|
73
|
+
naturalWidth: mediaWidth,
|
|
74
|
+
naturalHeight: mediaHeight
|
|
75
|
+
});
|
|
76
|
+
}, [
|
|
77
|
+
mediaUrl,
|
|
78
|
+
mediaWidth,
|
|
79
|
+
mediaHeight,
|
|
80
|
+
setSourceImage
|
|
81
|
+
]);
|
|
82
|
+
const isImage = mediaType.type === "image";
|
|
83
|
+
const status = settled && settled.url === mediaUrl ? settled.status : "loading";
|
|
84
|
+
const handleImageLoaded = (0, _wordpress_element.useCallback)(() => {
|
|
85
|
+
setSettled({
|
|
86
|
+
url: mediaUrl,
|
|
87
|
+
status: "loaded"
|
|
88
|
+
});
|
|
89
|
+
}, [mediaUrl]);
|
|
90
|
+
const handleImageError = (0, _wordpress_element.useCallback)(() => {
|
|
91
|
+
setSettled({
|
|
92
|
+
url: mediaUrl,
|
|
93
|
+
status: "error"
|
|
94
|
+
});
|
|
95
|
+
}, [mediaUrl]);
|
|
96
|
+
if (!mediaUrl || !isImage) return null;
|
|
97
|
+
if (status === "error") return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
98
|
+
className: "media-editor-canvas",
|
|
99
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
100
|
+
className: "media-editor-canvas__error",
|
|
101
|
+
role: "alert",
|
|
102
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("p", { children: (0, _wordpress_i18n.__)("Failed to load image.") })
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
106
|
+
className: "media-editor-canvas",
|
|
107
|
+
children: [status === "loading" && /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
108
|
+
className: "media-editor-canvas__spinner",
|
|
109
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Spinner, {})
|
|
110
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
111
|
+
className: (0, clsx.default)("media-editor-canvas__image-editor", { "is-loaded": status === "loaded" }),
|
|
112
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_image_editor.ImageEditorCanvas, {
|
|
113
|
+
src: mediaUrl,
|
|
114
|
+
controller: session.imageEditor,
|
|
115
|
+
freeformCrop: true,
|
|
116
|
+
showGrid: isPlacementActive ? true : "interactive",
|
|
117
|
+
onGestureStart: handleGestureStart,
|
|
118
|
+
onGestureEnd: handleGestureEnd,
|
|
119
|
+
onImageLoaded: handleImageLoaded,
|
|
120
|
+
onImageError: handleImageError,
|
|
121
|
+
disabled
|
|
122
|
+
})
|
|
123
|
+
})]
|
|
124
|
+
});
|
|
134
125
|
}
|
|
135
|
-
|
|
126
|
+
exports.default = MediaEditorCanvas;
|
|
127
|
+
|
|
128
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/media-editor-canvas/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport { useCallback, useEffect, useMemo, useState } from '@wordpress/element';\nimport { Spinner as WCSpinner } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useMediaEditorContext } from '../media-editor-provider';\nimport { getMediaTypeFromMimeType } from '../../utils';\nimport { Cropper } from '../../image-editor';\nimport { useMediaEditor, resolveAspectRatio } from '../../state';\n\nexport interface MediaEditorCanvasProps {\n\t/** Whether external placement activity should reveal the grid. */\n\tisPlacementActive?: boolean;\n\t/** Fires when a canvas cropper gesture begins. */\n\tonGestureStart?: () => void;\n\t/** Fires when a canvas cropper gesture ends. */\n\tonGestureEnd?: () => void;\n\t/**\n\t * Disable crop interaction on the canvas. Set while the edit is saving,\n\t * so a drag cannot change the crop after the request was built.\n\t */\n\tdisabled?: boolean;\n}\n\n/**\n * Editing surface for image media in the media editor modal. Pulls\n * its cropper controller from the surrounding `<MediaEditorStateProvider>`\n * so the bottom bar and Crop sidebar tab share the same state.\n *\n * Returns `null` for missing or non-image media so the modal's outer\n * guards can render a spinner or fall through to `<MediaPreview>`.\n *\n * @param props\n * @param props.isPlacementActive\n * @param props.onGestureStart\n * @param props.onGestureEnd\n * @param props.disabled\n */\nexport default function MediaEditorCanvas( {\n\tisPlacementActive = false,\n\tonGestureStart,\n\tonGestureEnd,\n\tdisabled = false,\n}: MediaEditorCanvasProps ) {\n\tconst { media } = useMediaEditorContext();\n\tconst session = useMediaEditor();\n\tconst { aspectRatioValue } = session.cropOptions;\n\tconst cropperImage = session.cropper.state.image;\n\tconst { beginGesture, endGesture, setSourceImage } = session;\n\n\t// Tracks whether the image pixels have actually loaded. The cropper's\n\t// geometry is driven by the known media dimensions, so its handles and\n\t// overlays would otherwise appear before the image finishes streaming in.\n\tconst [ status, setStatus ] = useState< 'loading' | 'loaded' | 'error' >(\n\t\t'loading'\n\t);\n\n\t// Resolved aspect ratio is derived from the preset key + the\n\t// loaded image (for the \"Original\" preset). The reducer doesn't\n\t// store this number — only the preset key — so it's a render-time\n\t// derivation here.\n\tconst aspectRatio = useMemo(\n\t\t() => resolveAspectRatio( aspectRatioValue, cropperImage ),\n\t\t[ aspectRatioValue, cropperImage ]\n\t);\n\n\tconst handleGestureStart = useCallback( () => {\n\t\tbeginGesture();\n\t\tonGestureStart?.();\n\t}, [ beginGesture, onGestureStart ] );\n\n\tconst handleGestureEnd = useCallback( () => {\n\t\tendGesture();\n\t\tonGestureEnd?.();\n\t}, [ endGesture, onGestureEnd ] );\n\n\tconst mediaUrl = media?.source_url;\n\tconst mediaType = getMediaTypeFromMimeType( media?.mime_type );\n\tconst mediaWidth = Number( media?.media_details?.width );\n\tconst mediaHeight = Number( media?.media_details?.height );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! mediaUrl ||\n\t\t\t! Number.isFinite( mediaWidth ) ||\n\t\t\t! Number.isFinite( mediaHeight ) ||\n\t\t\tmediaWidth <= 0 ||\n\t\t\tmediaHeight <= 0\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tsetSourceImage( {\n\t\t\tsrc: mediaUrl,\n\t\t\tnaturalWidth: mediaWidth,\n\t\t\tnaturalHeight: mediaHeight,\n\t\t} );\n\t}, [ mediaUrl, mediaWidth, mediaHeight, setSourceImage ] );\n\n\tconst isImage = mediaType.type === 'image';\n\n\t// Probe the image to know when its pixels have loaded (or failed),\n\t// independent of the cropper. The browser shares one fetch/cache with the\n\t// cropper's own `<img>`, so this adds no network cost. The cropper stays\n\t// framework-pure — load/error handling lives here in the wrapper layer.\n\tuseEffect( () => {\n\t\tif ( ! mediaUrl || ! isImage ) {\n\t\t\treturn;\n\t\t}\n\t\tsetStatus( 'loading' );\n\t\tconst probe = new window.Image();\n\t\tprobe.onload = () => setStatus( 'loaded' );\n\t\tprobe.onerror = () => setStatus( 'error' );\n\t\tprobe.src = mediaUrl;\n\t\t// Cached images may already be complete before listeners attach.\n\t\tif ( probe.complete ) {\n\t\t\tsetStatus( probe.naturalWidth > 0 ? 'loaded' : 'error' );\n\t\t}\n\t\treturn () => {\n\t\t\tprobe.onload = null;\n\t\t\tprobe.onerror = null;\n\t\t};\n\t}, [ mediaUrl, isImage ] );\n\n\tif ( ! mediaUrl || ! isImage ) {\n\t\treturn null;\n\t}\n\n\tif ( status === 'error' ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-canvas\">\n\t\t\t\t<div className=\"media-editor-canvas__error\" role=\"alert\">\n\t\t\t\t\t<p>{ __( 'Failed to load image.' ) }</p>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div className=\"media-editor-canvas\">\n\t\t\t{ status === 'loading' && (\n\t\t\t\t<div className=\"media-editor-canvas__spinner\">\n\t\t\t\t\t<WCSpinner />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ /*\n\t\t\t * The cropper stays mounted while loading (hidden behind the\n\t\t\t * spinner) so the image decodes off-screen and reveals in one paint\n\t\t\t * instead of streaming in top-to-bottom. Until it's revealed it's\n\t\t\t * non-interactive (`pointer-events: none` in CSS).\n\t\t\t *\n\t\t\t * The crop area is never focused programmatically: the modal keeps\n\t\t\t * initial focus on the dialog frame, and users reach the crop area\n\t\t\t * by tabbing to it.\n\t\t\t */ }\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'media-editor-canvas__cropper', {\n\t\t\t\t\t'is-loaded': status === 'loaded',\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<Cropper\n\t\t\t\t\tsrc={ mediaUrl }\n\t\t\t\t\tcontroller={ session.cropper }\n\t\t\t\t\taspectRatio={ aspectRatio }\n\t\t\t\t\tfreeformCrop\n\t\t\t\t\tshowGrid=\"interactive\"\n\t\t\t\t\tisPlacementActive={ isPlacementActive }\n\t\t\t\t\tonGestureStart={ handleGestureStart }\n\t\t\t\t\tonGestureEnd={ handleGestureEnd }\n\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,qBAA0D;AAC1D,wBAAqC;AACrC,kBAAmB;AACnB,mCAAsC;AACtC,mBAAyC;AACzC,0BAAwB;AACxB,mBAAmD;AA2H9C;AA7FU,SAAR,kBAAoC;AAAA,EAC1C,oBAAoB;AAAA,EACpB;AAAA,EACA;AAAA,EACA,WAAW;AACZ,GAA4B;AAC3B,QAAM,EAAE,MAAM,QAAI,oDAAsB;AACxC,QAAM,cAAU,6BAAe;AAC/B,QAAM,EAAE,iBAAiB,IAAI,QAAQ;AACrC,QAAM,eAAe,QAAQ,QAAQ,MAAM;AAC3C,QAAM,EAAE,cAAc,YAAY,eAAe,IAAI;AAKrD,QAAM,CAAE,QAAQ,SAAU,QAAI;AAAA,IAC7B;AAAA,EACD;AAMA,QAAM,kBAAc;AAAA,IACnB,UAAM,iCAAoB,kBAAkB,YAAa;AAAA,IACzD,CAAE,kBAAkB,YAAa;AAAA,EAClC;AAEA,QAAM,yBAAqB,4BAAa,MAAM;AAC7C,iBAAa;AACb,qBAAiB;AAAA,EAClB,GAAG,CAAE,cAAc,cAAe,CAAE;AAEpC,QA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ACZ,4CAAC,SAAI,WAAU,gCACd,sDAAC,kBAAAA,SAAA,EAAU,GACZ;AAAA,IAYD;AAAA,MAAC;AAAA;AAAA,QACA,eAAY,YAAAC,SAAM,gCAAgC;AAAA,UACjD,aAAa,WAAW;AAAA,QACzB,CAAE;AAAA,QAEF;AAAA,UAAC;AAAA;AAAA,YACA,KAAM;AAAA,YACN,YAAa,QAAQ;AAAA,YACrB;AAAA,YACA,cAAY;AAAA,YACZ,UAAS;AAAA,YACT;AAAA,YACA,gBAAiB;AAAA,YACjB,cAAe;AAAA,YACf;AAAA;AAAA,QACD;AAAA;AAAA,IACD;AAAA,KACD;AAEF;",
|
|
6
|
-
"names": ["WCSpinner", "clsx"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useMediaEditorContext","useMediaEditor","useState","useCallback","getMediaTypeFromMimeType","__","WCSpinner","ImageEditorCanvas"],"sources":["../../../src/components/media-editor-canvas/index.tsx"],"sourcesContent":["import clsx from 'clsx';\nimport { useCallback, useEffect, useState } from '@wordpress/element';\nimport { Spinner as WCSpinner } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { ImageEditorCanvas } from '@wordpress/image-editor';\nimport { useMediaEditorContext } from '../media-editor-provider';\nimport { getMediaTypeFromMimeType } from '../../utils';\nimport { useMediaEditor } from '../../state';\n\nexport interface MediaEditorCanvasProps {\n\t/** Whether external placement activity should reveal the grid. */\n\tisPlacementActive?: boolean;\n\t/** Fires when a canvas gesture begins. */\n\tonGestureStart?: () => void;\n\t/** Fires when a canvas gesture ends. */\n\tonGestureEnd?: () => void;\n\t/**\n\t * Disable crop interaction on the canvas. Set while the edit is saving,\n\t * so a drag cannot change the crop after the request was built.\n\t */\n\tdisabled?: boolean;\n}\n\n/**\n * Editing surface for image media in the media editor modal. Pulls\n * its image editor controller from the surrounding `<MediaEditorStateProvider>`\n * so the bottom bar and Crop sidebar tab share the same state.\n *\n * Returns `null` for missing or non-image media so the modal's outer\n * guards can render a spinner or fall through to `<MediaPreview>`.\n *\n * @param props\n * @param props.isPlacementActive\n * @param props.onGestureStart\n * @param props.onGestureEnd\n * @param props.disabled\n */\nexport default function MediaEditorCanvas( {\n\tisPlacementActive = false,\n\tonGestureStart,\n\tonGestureEnd,\n\tdisabled = false,\n}: MediaEditorCanvasProps ) {\n\tconst { media } = useMediaEditorContext();\n\tconst session = useMediaEditor();\n\tconst { beginGesture, endGesture, setSourceImage } = session;\n\n\t// Tracks whether the image pixels have actually loaded. The image editor's\n\t// geometry is driven by the known media dimensions, so its handles and\n\t// overlays would otherwise appear before the image finishes streaming in.\n\t// Stored with the URL it is for, so a new URL (restoring the original\n\t// swaps it in place) counts as loading until the image editor reports back.\n\tconst [ settled, setSettled ] = useState< {\n\t\turl: string | undefined;\n\t\tstatus: 'loaded' | 'error';\n\t} >();\n\n\tconst handleGestureStart = useCallback( () => {\n\t\tbeginGesture();\n\t\tonGestureStart?.();\n\t}, [ beginGesture, onGestureStart ] );\n\n\tconst handleGestureEnd = useCallback( () => {\n\t\tendGesture();\n\t\tonGestureEnd?.();\n\t}, [ endGesture, onGestureEnd ] );\n\n\tconst mediaUrl = media?.source_url;\n\tconst mediaType = getMediaTypeFromMimeType( media?.mime_type );\n\tconst mediaWidth = Number( media?.media_details?.width );\n\tconst mediaHeight = Number( media?.media_details?.height );\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t! mediaUrl ||\n\t\t\t! Number.isFinite( mediaWidth ) ||\n\t\t\t! Number.isFinite( mediaHeight ) ||\n\t\t\tmediaWidth <= 0 ||\n\t\t\tmediaHeight <= 0\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tsetSourceImage( {\n\t\t\tsrc: mediaUrl,\n\t\t\tnaturalWidth: mediaWidth,\n\t\t\tnaturalHeight: mediaHeight,\n\t\t} );\n\t}, [ mediaUrl, mediaWidth, mediaHeight, setSourceImage ] );\n\n\tconst isImage = mediaType.type === 'image';\n\tconst status =\n\t\tsettled && settled.url === mediaUrl ? settled.status : 'loading';\n\tconst handleImageLoaded = useCallback( () => {\n\t\tsetSettled( { url: mediaUrl, status: 'loaded' } );\n\t}, [ mediaUrl ] );\n\tconst handleImageError = useCallback( () => {\n\t\tsetSettled( { url: mediaUrl, status: 'error' } );\n\t}, [ mediaUrl ] );\n\n\tif ( ! mediaUrl || ! isImage ) {\n\t\treturn null;\n\t}\n\n\tif ( status === 'error' ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-canvas\">\n\t\t\t\t<div className=\"media-editor-canvas__error\" role=\"alert\">\n\t\t\t\t\t<p>{ __( 'Failed to load image.' ) }</p>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div className=\"media-editor-canvas\">\n\t\t\t{ status === 'loading' && (\n\t\t\t\t<div className=\"media-editor-canvas__spinner\">\n\t\t\t\t\t<WCSpinner />\n\t\t\t\t</div>\n\t\t\t) }\n\t\t\t{ /*\n\t\t\t * The image editor stays mounted while loading (hidden behind the\n\t\t\t * spinner) so the image decodes off-screen and reveals in one paint\n\t\t\t * instead of streaming in top-to-bottom. Until it's revealed it's\n\t\t\t * non-interactive (`pointer-events: none` in CSS).\n\t\t\t *\n\t\t\t * The crop area is never focused programmatically: the modal keeps\n\t\t\t * initial focus on the dialog frame, and users reach the crop area\n\t\t\t * by tabbing to it.\n\t\t\t */ }\n\t\t\t<div\n\t\t\t\tclassName={ clsx( 'media-editor-canvas__image-editor', {\n\t\t\t\t\t'is-loaded': status === 'loaded',\n\t\t\t\t} ) }\n\t\t\t>\n\t\t\t\t<ImageEditorCanvas\n\t\t\t\t\tsrc={ mediaUrl }\n\t\t\t\t\tcontroller={ session.imageEditor }\n\t\t\t\t\tfreeformCrop\n\t\t\t\t\t// Keep the grid up while a sidebar placement control is in\n\t\t\t\t\t// use; otherwise show it only while the crop is changing.\n\t\t\t\t\tshowGrid={ isPlacementActive ? true : 'interactive' }\n\t\t\t\t\tonGestureStart={ handleGestureStart }\n\t\t\t\t\ton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(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
// \0rolldown/runtime.js
|
|
2
7
|
var __create = Object.create;
|
|
3
8
|
var __defProp = Object.defineProperty;
|
|
4
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
13
|
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
|
+
key = keys[i];
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
19
22
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
let _wordpress_ui = require("@wordpress/ui");
|
|
28
|
+
let _wordpress_i18n = require("@wordpress/i18n");
|
|
29
|
+
let _wordpress_icons = require("@wordpress/icons");
|
|
30
|
+
let ______hooks_use_crop_gesture_handlers_ts = require("../../hooks/use-crop-gesture-handlers.cjs");
|
|
31
|
+
let ___media_editor_image_controls_index_tsx = require("../media-editor-image-controls/index.cjs");
|
|
32
|
+
___media_editor_image_controls_index_tsx = __toESM(___media_editor_image_controls_index_tsx);
|
|
33
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
30
34
|
// packages/media-editor/src/components/media-editor-crop-panel/index.tsx
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Sidebar panel for crop controls: rotate, flip and zoom above the
|
|
37
|
+
* aspect-ratio selector. Rendered where the panel docks; below that the
|
|
38
|
+
* transform controls sit under the canvas instead, placed by the editor.
|
|
39
|
+
* @param props
|
|
40
|
+
* @param props.aspectRatioValue
|
|
41
|
+
* @param props.onAspectRatioChange
|
|
42
|
+
* @param props.aspectRatioOptions
|
|
43
|
+
* @param props.disabled
|
|
44
|
+
*/
|
|
45
|
+
function MediaEditorCropPanel({ aspectRatioValue, onAspectRatioChange, aspectRatioOptions, disabled = false }) {
|
|
46
|
+
const items = aspectRatioOptions.map((preset) => ({
|
|
47
|
+
label: preset.label,
|
|
48
|
+
value: preset.value.toString()
|
|
49
|
+
}));
|
|
50
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Stack, {
|
|
51
|
+
direction: "column",
|
|
52
|
+
gap: "xl",
|
|
53
|
+
[______hooks_use_crop_gesture_handlers_ts.CROP_CONTROL_ATTR]: true,
|
|
54
|
+
children: [
|
|
55
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.VisuallyHidden, {
|
|
56
|
+
render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {}),
|
|
57
|
+
children: (0, _wordpress_i18n.__)("Crop options")
|
|
58
|
+
}),
|
|
59
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_image_controls_index_tsx.default, {
|
|
60
|
+
withLabels: true,
|
|
61
|
+
disabled
|
|
62
|
+
}),
|
|
63
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.SelectControl, {
|
|
64
|
+
label: (0, _wordpress_i18n.__)("Aspect ratio"),
|
|
65
|
+
value: items.find((item) => item.value === aspectRatioValue) ?? null,
|
|
66
|
+
onValueChange: (item) => {
|
|
67
|
+
if (item && item.value !== null) onAspectRatioChange(item.value);
|
|
68
|
+
},
|
|
69
|
+
disabled,
|
|
70
|
+
items,
|
|
71
|
+
trigger: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.SelectControl.Trigger, { children: (item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
72
|
+
className: "media-editor-crop-panel__aspect-ratio-option",
|
|
73
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_icons.Icon, { icon: (0, _wordpress_icons.getAspectRatioIcon)(Number(item.value)) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
74
|
+
className: "media-editor-crop-panel__aspect-ratio-label",
|
|
75
|
+
children: item.label
|
|
76
|
+
})]
|
|
77
|
+
}) }),
|
|
78
|
+
children: items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.SelectControl.Item, {
|
|
79
|
+
value: item,
|
|
80
|
+
label: item.label,
|
|
81
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.SelectControl.ItemLabel, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
82
|
+
className: "media-editor-crop-panel__aspect-ratio-option",
|
|
83
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_icons.Icon, { icon: (0, _wordpress_icons.getAspectRatioIcon)(Number(item.value)) }), item.label]
|
|
84
|
+
}) })
|
|
85
|
+
}, item.value))
|
|
86
|
+
})
|
|
87
|
+
]
|
|
88
|
+
});
|
|
82
89
|
}
|
|
83
|
-
|
|
90
|
+
exports.default = MediaEditorCropPanel;
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/media-editor-crop-panel/index.tsx"],
|
|
4
|
-
"sourcesContent": ["import { SelectControl, Stack, VisuallyHidden } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';\nimport MediaEditorImageControls from '../media-editor-image-controls';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\nexport interface MediaEditorCropPanelProps {\n\t/**\n\t * Selected aspect-ratio preset value as a string (so it round-trips\n\t * through `<SelectControl>`). `'0'` = free, `'-1'` = original, any\n\t * positive number = fixed ratio.\n\t */\n\taspectRatioValue: string;\n\t/** Setter for the aspect-ratio preset value. */\n\tonAspectRatioChange: ( value: string ) => void;\n\t/** Aspect-ratio presets to display in the selector. */\n\taspectRatioOptions: AspectRatioPreset[];\n\t/** Disable every control in the panel while the edit is saving. */\n\tdisabled?: boolean;\n}\n\n/**\n * Sidebar panel for crop controls: rotate, flip and zoom above the\n * aspect-ratio selector. Rendered where the panel docks; below that the\n * transform controls sit under the canvas instead, placed by the editor.\n * @param props\n * @param props.aspectRatioValue\n * @param props.onAspectRatioChange\n * @param props.aspectRatioOptions\n * @param props.disabled\n */\nexport default function MediaEditorCropPanel( {\n\taspectRatioValue,\n\tonAspectRatioChange,\n\taspectRatioOptions,\n\tdisabled = false,\n}: MediaEditorCropPanelProps ) {\n\tconst items = aspectRatioOptions.map( ( preset ) => ( {\n\t\tlabel: preset.label,\n\t\tvalue: preset.value.toString(),\n\t} ) );\n\n\treturn (\n\t\t// Tag the whole panel as a crop-control region so the modal's\n\t\t// Cmd+Z handler doesn't mistake the SelectControl input for a\n\t\t// metadata field (which would suppress undo).\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"xl\"\n\t\t\t{ ...{ [ CROP_CONTROL_ATTR ]: true } }\n\t\t>\n\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t{ __( 'Crop options' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<MediaEditorImageControls withLabels disabled={ disabled } />\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\tvalue={\n\t\t\t\t\titems.find( ( item ) => item.value === aspectRatioValue ) ??\n\t\t\t\t\tnull\n\t\t\t\t}\n\t\t\t\tonValueChange={ ( item ) => {\n\t\t\t\t\tif ( item && item.value !== null ) {\n\t\t\t\t\t\tonAspectRatioChange( item.value );\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\titems={ items }\n\t\t\t/>\n\t\t</Stack>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,gBAAqD;AACrD,kBAAmB;AACnB,uCAAkC;AAClC,yCAAqC;AA2CnC;AAAA;AAAA;AAAA;AAAA;AAAA;AAfa,SAAR,qBAAuC;AAAA,EAC7C;AAAA,EACA;AAAA,EACA;AAAA,EACA,WAAW;AACZ,GAA+B;AAC9B,QAAM,QAAQ,mBAAmB,IAAK,CAAE,YAAc;AAAA,IACrD,OAAO,OAAO;AAAA,IACd,OAAO,OAAO,MAAM,SAAS;AAAA,EAC9B,EAAI;AAEJ,SAIC;AAAA,IAAC;AAAA;AAAA,MACA,WAAU;AAAA,MACV,KAAI;AAAA,MACF,GAAG,EAAE,CAAE,kDAAkB,GAAG,KAAK;AAAA,MAEnC;AAAA,oDAAC,4BAAe,QAAS,4CAAC,QAAG,GAC1B,8BAAI,cAAe,GACtB;AAAA,QACA,4CAAC,mCAAAA,SAAA,EAAyB,YAAU,MAAC,UAAsB;AAAA,QAC3D;AAAA,UAAC;AAAA;AAAA,YACA,WAAQ,gBAAI,cAAe;AAAA,YAC3B,OACC,MAAM,KAAM,CAAE,SAAU,KAAK,UAAU,gBAAiB,KACxD;AAAA,YAED,eAAgB,CAAE,SAAU;AAC3B,kBAAK,QAAQ,KAAK,UAAU,MAAO;AAClC,oCAAqB,KAAK,KAAM;AAAA,cACjC;AAAA,YACD;AAAA,YACA;AAAA,YACA;AAAA;AAAA,QACD;AAAA;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
-
"names": ["MediaEditorImageControls"]
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["Stack","CROP_CONTROL_ATTR","VisuallyHidden","__","MediaEditorImageControls","SelectControl","Icon","getAspectRatioIcon"],"sources":["../../../src/components/media-editor-crop-panel/index.tsx"],"sourcesContent":["import { SelectControl, Stack, VisuallyHidden } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, getAspectRatioIcon } from '@wordpress/icons';\nimport type { AspectRatioPreset } from '../../state/aspect-ratio-presets';\nimport { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';\nimport MediaEditorImageControls from '../media-editor-image-controls';\n\nexport interface MediaEditorCropPanelProps {\n\t/**\n\t * Selected aspect-ratio preset value as a string (so it round-trips\n\t * through `<SelectControl>`). `'0'` = free, `'-1'` = original, any\n\t * positive number = fixed ratio.\n\t */\n\taspectRatioValue: string;\n\t/** Setter for the aspect-ratio preset value. */\n\tonAspectRatioChange: ( value: string ) => void;\n\t/** Aspect-ratio presets to display in the selector. */\n\taspectRatioOptions: AspectRatioPreset[];\n\t/** Disable every control in the panel while the edit is saving. */\n\tdisabled?: boolean;\n}\n\n/**\n * Sidebar panel for crop controls: rotate, flip and zoom above the\n * aspect-ratio selector. Rendered where the panel docks; below that the\n * transform controls sit under the canvas instead, placed by the editor.\n * @param props\n * @param props.aspectRatioValue\n * @param props.onAspectRatioChange\n * @param props.aspectRatioOptions\n * @param props.disabled\n */\nexport default function MediaEditorCropPanel( {\n\taspectRatioValue,\n\tonAspectRatioChange,\n\taspectRatioOptions,\n\tdisabled = false,\n}: MediaEditorCropPanelProps ) {\n\tconst items = aspectRatioOptions.map( ( preset ) => ( {\n\t\tlabel: preset.label,\n\t\tvalue: preset.value.toString(),\n\t} ) );\n\n\treturn (\n\t\t// Tag the whole panel as a crop-control region so the modal's\n\t\t// Cmd+Z handler doesn't mistake the SelectControl input for a\n\t\t// metadata field (which would suppress undo).\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"xl\"\n\t\t\t{ ...{ [ CROP_CONTROL_ATTR ]: true } }\n\t\t>\n\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t{ __( 'Crop options' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<MediaEditorImageControls withLabels disabled={ disabled } />\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\tvalue={\n\t\t\t\t\titems.find( ( item ) => item.value === aspectRatioValue ) ??\n\t\t\t\t\tnull\n\t\t\t\t}\n\t\t\t\tonValueChange={ ( item ) => {\n\t\t\t\t\tif ( item && item.value !== null ) {\n\t\t\t\t\t\tonAspectRatioChange( item.value );\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\titems={ items }\n\t\t\t\ttrigger={\n\t\t\t\t\t<SelectControl.Trigger>\n\t\t\t\t\t\t{ ( item ) => (\n\t\t\t\t\t\t\t<span className=\"media-editor-crop-panel__aspect-ratio-option\">\n\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\ticon={ getAspectRatioIcon(\n\t\t\t\t\t\t\t\t\t\tNumber( item.value )\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<span className=\"media-editor-crop-panel__aspect-ratio-label\">\n\t\t\t\t\t\t\t\t\t{ item.label }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</SelectControl.Trigger>\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ items.map( ( item ) => (\n\t\t\t\t\t<SelectControl.Item\n\t\t\t\t\t\tkey={ item.value }\n\t\t\t\t\t\tvalue={ item }\n\t\t\t\t\t\tlabel={ item.label }\n\t\t\t\t\t>\n\t\t\t\t\t\t<SelectControl.ItemLabel>\n\t\t\t\t\t\t\t<span className=\"media-editor-crop-panel__aspect-ratio-option\">\n\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\ticon={ getAspectRatioIcon(\n\t\t\t\t\t\t\t\t\t\tNumber( item.value )\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ item.label }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t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