@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,131 +1,134 @@
|
|
|
1
|
-
// packages/media-editor/src/components/rotation-ruler/use-ruler-drag.ts
|
|
2
1
|
import { useCallback, useEffect, useRef } from "@wordpress/element";
|
|
2
|
+
// packages/media-editor/src/components/rotation-ruler/use-ruler-drag.ts
|
|
3
|
+
/**
|
|
4
|
+
* Convert a horizontal pointer delta (px) into a value delta.
|
|
5
|
+
*
|
|
6
|
+
* Negative because dragging the ruler to the right should expose
|
|
7
|
+
* smaller values to the left of the fixed center pointer (and vice
|
|
8
|
+
* versa) — the ruler scrubs *under* the pointer.
|
|
9
|
+
*
|
|
10
|
+
* @param deltaPx Pointer movement in CSS pixels.
|
|
11
|
+
* @param pixelsPerStep CSS pixels of pointer travel per `step`.
|
|
12
|
+
* @param step Value units per step.
|
|
13
|
+
*/
|
|
3
14
|
function pxToValueDelta(deltaPx, pixelsPerStep, step) {
|
|
4
|
-
|
|
15
|
+
return -deltaPx / pixelsPerStep * step;
|
|
5
16
|
}
|
|
17
|
+
/**
|
|
18
|
+
* Clamp `value` to the inclusive `[min, max]` interval.
|
|
19
|
+
*
|
|
20
|
+
* @param value Value to clamp.
|
|
21
|
+
* @param min Lower bound (inclusive).
|
|
22
|
+
* @param max Upper bound (inclusive).
|
|
23
|
+
*/
|
|
6
24
|
function clampValue(value, min, max) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (value > max) {
|
|
11
|
-
return max;
|
|
12
|
-
}
|
|
13
|
-
return value;
|
|
25
|
+
if (value < min) return min;
|
|
26
|
+
if (value > max) return max;
|
|
27
|
+
return value;
|
|
14
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Round `value` to the nearest multiple of `step`.
|
|
31
|
+
*
|
|
32
|
+
* @param value Value to quantize.
|
|
33
|
+
* @param step Step granularity (must be > 0).
|
|
34
|
+
*/
|
|
15
35
|
function quantize(value, step) {
|
|
16
|
-
|
|
36
|
+
return Math.round(value / step) * step;
|
|
17
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Drag-the-ruler gesture for a horizontal slider. Translates pointer
|
|
40
|
+
* movement into value changes quantized to `step`; the caller renders
|
|
41
|
+
* the visuals and holds the value.
|
|
42
|
+
*
|
|
43
|
+
* The hook owns no state of its own — every value change is reported
|
|
44
|
+
* through the supplied `onChange`. The "current value" is read from a
|
|
45
|
+
* ref so closure staleness during a drag is impossible. Drag continues
|
|
46
|
+
* past the wrapper's bounds (standard slider behaviour); a window-level
|
|
47
|
+
* `pointerup` listener guarantees the drag ends and pointer capture
|
|
48
|
+
* releases even if the underlying captured event never fires on the
|
|
49
|
+
* wrapper.
|
|
50
|
+
*
|
|
51
|
+
* @param options Ruler-drag configuration. See `UseRulerDragOptions`.
|
|
52
|
+
*/
|
|
18
53
|
function useRulerDrag(options) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
const requestedStep = event.shiftKey ? step / 2 : step;
|
|
97
|
-
if (requestedStep !== state.activeStep) {
|
|
98
|
-
state.startX = event.clientX;
|
|
99
|
-
state.startValue = state.value;
|
|
100
|
-
state.activeStep = requestedStep;
|
|
101
|
-
}
|
|
102
|
-
const deltaPx = event.clientX - state.startX;
|
|
103
|
-
const deltaValue = pxToValueDelta(
|
|
104
|
-
deltaPx,
|
|
105
|
-
pixelsPerStep,
|
|
106
|
-
state.activeStep
|
|
107
|
-
);
|
|
108
|
-
const raw = state.startValue + deltaValue;
|
|
109
|
-
const stepped = quantize(raw, state.activeStep);
|
|
110
|
-
const next = clampValue(stepped, min, max);
|
|
111
|
-
if (next !== state.value) {
|
|
112
|
-
state.value = next;
|
|
113
|
-
onChange(next);
|
|
114
|
-
}
|
|
115
|
-
},
|
|
116
|
-
[disabled, onChange, min, max, step, pixelsPerStep]
|
|
117
|
-
);
|
|
118
|
-
return {
|
|
119
|
-
onPointerDown,
|
|
120
|
-
onPointerMove,
|
|
121
|
-
onPointerUp: endDrag,
|
|
122
|
-
onPointerCancel: endDrag
|
|
123
|
-
};
|
|
54
|
+
const { value, onChange, min, max, step, pixelsPerStep, disabled, onPointerDownStart } = options;
|
|
55
|
+
const latestRef = useRef({
|
|
56
|
+
value,
|
|
57
|
+
startX: 0,
|
|
58
|
+
startValue: 0,
|
|
59
|
+
activeStep: step,
|
|
60
|
+
dragging: false,
|
|
61
|
+
captureElement: null,
|
|
62
|
+
capturePointerId: 0,
|
|
63
|
+
windowPointerUp: null
|
|
64
|
+
});
|
|
65
|
+
const endDrag = useCallback(() => {
|
|
66
|
+
const state = latestRef.current;
|
|
67
|
+
if (!state.dragging) return;
|
|
68
|
+
state.dragging = false;
|
|
69
|
+
if (state.captureElement && state.captureElement.hasPointerCapture(state.capturePointerId)) state.captureElement.releasePointerCapture(state.capturePointerId);
|
|
70
|
+
state.captureElement = null;
|
|
71
|
+
if (state.windowPointerUp) {
|
|
72
|
+
window.removeEventListener("pointerup", state.windowPointerUp);
|
|
73
|
+
window.removeEventListener("pointercancel", state.windowPointerUp);
|
|
74
|
+
state.windowPointerUp = null;
|
|
75
|
+
}
|
|
76
|
+
}, []);
|
|
77
|
+
useEffect(() => endDrag, [endDrag]);
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (disabled) endDrag();
|
|
80
|
+
}, [disabled, endDrag]);
|
|
81
|
+
return {
|
|
82
|
+
onPointerDown: useCallback((event) => {
|
|
83
|
+
if (disabled || event.button !== 0) return;
|
|
84
|
+
const state = latestRef.current;
|
|
85
|
+
event.currentTarget.setPointerCapture(event.pointerId);
|
|
86
|
+
state.captureElement = event.currentTarget;
|
|
87
|
+
state.capturePointerId = event.pointerId;
|
|
88
|
+
state.startX = event.clientX;
|
|
89
|
+
state.value = value;
|
|
90
|
+
state.startValue = value;
|
|
91
|
+
state.activeStep = event.shiftKey ? step / 2 : step;
|
|
92
|
+
state.dragging = true;
|
|
93
|
+
onPointerDownStart?.();
|
|
94
|
+
const onWindowUp = () => endDrag();
|
|
95
|
+
state.windowPointerUp = onWindowUp;
|
|
96
|
+
window.addEventListener("pointerup", onWindowUp);
|
|
97
|
+
window.addEventListener("pointercancel", onWindowUp);
|
|
98
|
+
}, [
|
|
99
|
+
disabled,
|
|
100
|
+
onPointerDownStart,
|
|
101
|
+
endDrag,
|
|
102
|
+
step,
|
|
103
|
+
value
|
|
104
|
+
]),
|
|
105
|
+
onPointerMove: useCallback((event) => {
|
|
106
|
+
const state = latestRef.current;
|
|
107
|
+
if (disabled || !state.dragging) return;
|
|
108
|
+
const requestedStep = event.shiftKey ? step / 2 : step;
|
|
109
|
+
if (requestedStep !== state.activeStep) {
|
|
110
|
+
state.startX = event.clientX;
|
|
111
|
+
state.startValue = state.value;
|
|
112
|
+
state.activeStep = requestedStep;
|
|
113
|
+
}
|
|
114
|
+
const deltaValue = pxToValueDelta(event.clientX - state.startX, pixelsPerStep, state.activeStep);
|
|
115
|
+
const next = clampValue(quantize(state.startValue + deltaValue, state.activeStep), min, max);
|
|
116
|
+
if (next !== state.value) {
|
|
117
|
+
state.value = next;
|
|
118
|
+
onChange(next);
|
|
119
|
+
}
|
|
120
|
+
}, [
|
|
121
|
+
disabled,
|
|
122
|
+
onChange,
|
|
123
|
+
min,
|
|
124
|
+
max,
|
|
125
|
+
step,
|
|
126
|
+
pixelsPerStep
|
|
127
|
+
]),
|
|
128
|
+
onPointerUp: endDrag,
|
|
129
|
+
onPointerCancel: endDrag
|
|
130
|
+
};
|
|
124
131
|
}
|
|
125
|
-
export {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
quantize,
|
|
129
|
-
useRulerDrag
|
|
130
|
-
};
|
|
131
|
-
//# sourceMappingURL=use-ruler-drag.mjs.map
|
|
132
|
+
export { clampValue, pxToValueDelta, quantize, useRulerDrag };
|
|
133
|
+
|
|
134
|
+
//# sourceMappingURL=use-ruler-drag.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/components/rotation-ruler/use-ruler-drag.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Convert a horizontal pointer delta (px) into a value delta.\n *\n * Negative because dragging the ruler to the right should expose\n * smaller values to the left of the fixed center pointer (and vice\n * versa) — the ruler scrubs *under* the pointer.\n *\n * @param deltaPx Pointer movement in CSS pixels.\n * @param pixelsPerStep CSS pixels of pointer travel per `step`.\n * @param step Value units per step.\n */\nexport function pxToValueDelta(\n\tdeltaPx: number,\n\tpixelsPerStep: number,\n\tstep: number\n): number {\n\treturn ( -deltaPx / pixelsPerStep ) * step;\n}\n\n/**\n * Clamp `value` to the inclusive `[min, max]` interval.\n *\n * @param value Value to clamp.\n * @param min Lower bound (inclusive).\n * @param max Upper bound (inclusive).\n */\nexport function clampValue( value: number, min: number, max: number ): number {\n\tif ( value < min ) {\n\t\treturn min;\n\t}\n\tif ( value > max ) {\n\t\treturn max;\n\t}\n\treturn value;\n}\n\n/**\n * Round `value` to the nearest multiple of `step`.\n *\n * @param value Value to quantize.\n * @param step Step granularity (must be > 0).\n */\nexport function quantize( value: number, step: number ): number {\n\treturn Math.round( value / step ) * step;\n}\n\nexport interface UseRulerDragOptions {\n\tvalue: number;\n\tonChange: ( next: number ) => void;\n\tmin: number;\n\tmax: number;\n\tstep: number;\n\tpixelsPerStep: number;\n\tdisabled: boolean;\n\t/** Called once on pointerdown so the caller can focus the input. */\n\tonPointerDownStart?: () => void;\n}\n\nexport interface RulerDragHandlers {\n\tonPointerDown: ( event: React.PointerEvent< HTMLElement > ) => void;\n\tonPointerMove: ( event: React.PointerEvent< HTMLElement > ) => void;\n\tonPointerUp: ( event: React.PointerEvent< HTMLElement > ) => void;\n\tonPointerCancel: ( event: React.PointerEvent< HTMLElement > ) => void;\n}\n\n/**\n * Drag-the-ruler gesture for a horizontal slider. Translates pointer\n * movement into value changes quantized to `step`; the caller renders\n * the visuals and holds the value.\n *\n * The hook owns no state of its own — every value change is reported\n * through the supplied `onChange`. The \"current value\" is read from a\n * ref so closure staleness during a drag is impossible. Drag continues\n * past the wrapper's bounds (standard slider behaviour); a window-level\n * `pointerup` listener guarantees the drag ends and pointer capture\n * releases even if the underlying captured event never fires on the\n * wrapper.\n *\n * @param options Ruler-drag configuration. See `UseRulerDragOptions`.\n */\nexport function useRulerDrag(\n\toptions: UseRulerDragOptions\n): RulerDragHandlers {\n\tconst {\n\t\tvalue,\n\t\tonChange,\n\t\tmin,\n\t\tmax,\n\t\tstep,\n\t\tpixelsPerStep,\n\t\tdisabled,\n\t\tonPointerDownStart,\n\t} = options;\n\n\t// Mutable mirror of the latest committed value plus per-drag state.\n\t// Pointermove handlers fire far faster than React commits, so we\n\t// cannot read `value` from closure. The `value` write happens in an\n\t// effect (not at render time) to satisfy `react-hooks/refs`; the\n\t// effect flushes after commit, so by the time any pointer handler\n\t// runs, the ref reflects the latest committed `value`.\n\tconst latestRef = useRef< {\n\t\tvalue: number;\n\t\tstartX: number;\n\t\tstartValue: number;\n\t\tactiveStep: number;\n\t\tdragging: boolean;\n\t\tcaptureElement: HTMLElement | null;\n\t\tcapturePointerId: number;\n\t\twindowPointerUp: ( () => void ) | null;\n\t} >( {\n\t\tvalue,\n\t\tstartX: 0,\n\t\tstartValue: 0,\n\t\tactiveStep: step,\n\t\tdragging: false,\n\t\tcaptureElement: null,\n\t\tcapturePointerId: 0,\n\t\twindowPointerUp: null,\n\t} );\n\tuseEffect( () => {\n\t\tlatestRef.current.value = value;\n\t}, [ value ] );\n\n\tconst endDrag = useCallback( () => {\n\t\tconst state = latestRef.current;\n\t\tif ( ! state.dragging ) {\n\t\t\treturn;\n\t\t}\n\t\tstate.dragging = false;\n\t\tif (\n\t\t\tstate.captureElement &&\n\t\t\tstate.captureElement.hasPointerCapture( state.capturePointerId )\n\t\t) {\n\t\t\tstate.captureElement.releasePointerCapture(\n\t\t\t\tstate.capturePointerId\n\t\t\t);\n\t\t}\n\t\tstate.captureElement = null;\n\t\tif ( state.windowPointerUp ) {\n\t\t\twindow.removeEventListener( 'pointerup', state.windowPointerUp );\n\t\t\twindow.removeEventListener(\n\t\t\t\t'pointercancel',\n\t\t\t\tstate.windowPointerUp\n\t\t\t);\n\t\t\tstate.windowPointerUp = null;\n\t\t}\n\t}, [] );\n\n\t// Cleanup any in-flight drag on unmount so we never leak window\n\t// listeners or stale pointer capture.\n\tuseEffect( () => endDrag, [ endDrag ] );\n\n\t// Becoming disabled mid-drag ends it, so a rotation cannot keep\n\t// changing after a save has read it.\n\tuseEffect( () => {\n\t\tif ( disabled ) {\n\t\t\tendDrag();\n\t\t}\n\t}, [ disabled, endDrag ] );\n\n\tconst onPointerDown = useCallback(\n\t\t( event: React.PointerEvent< HTMLElement > ) => {\n\t\t\tif ( disabled || event.button !== 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst state = latestRef.current;\n\t\t\tevent.currentTarget.setPointerCapture( event.pointerId );\n\t\t\tstate.captureElement = event.currentTarget;\n\t\t\tstate.capturePointerId = event.pointerId;\n\t\t\tstate.startX = event.clientX;\n\t\t\tstate.startValue = state.value;\n\t\t\tstate.activeStep = event.shiftKey ? step / 2 : step;\n\t\t\tstate.dragging = true;\n\t\t\tonPointerDownStart?.();\n\n\t\t\t// Window-level backstop. With `setPointerCapture`, the\n\t\t\t// element should always receive `pointerup` even when the\n\t\t\t// cursor is released outside its bounds — but in practice\n\t\t\t// some browsers / window-blur sequences drop the event. The\n\t\t\t// window listener guarantees the drag ends and capture\n\t\t\t// releases.\n\t\t\tconst onWindowUp = () => endDrag();\n\t\t\tstate.windowPointerUp = onWindowUp;\n\t\t\twindow.addEventListener( 'pointerup', onWindowUp );\n\t\t\twindow.addEventListener( 'pointercancel', onWindowUp );\n\t\t},\n\t\t[ disabled, onPointerDownStart, endDrag, step ]\n\t);\n\n\tconst onPointerMove = useCallback(\n\t\t( event: React.PointerEvent< HTMLElement > ) => {\n\t\t\tconst state = latestRef.current;\n\t\t\tif ( disabled || ! state.dragging ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Shift toggles fine mode mid-drag. The drag math computes\n\t\t\t// from `startX` / `startValue`, so naively swapping `step`\n\t\t\t// would yank the value backward. Rebase to the current\n\t\t\t// pointer + value so the granularity changes without a\n\t\t\t// jump.\n\t\t\tconst requestedStep = event.shiftKey ? step / 2 : step;\n\t\t\tif ( requestedStep !== state.activeStep ) {\n\t\t\t\tstate.startX = event.clientX;\n\t\t\t\tstate.startValue = state.value;\n\t\t\t\tstate.activeStep = requestedStep;\n\t\t\t}\n\t\t\tconst deltaPx = event.clientX - state.startX;\n\t\t\tconst deltaValue = pxToValueDelta(\n\t\t\t\tdeltaPx,\n\t\t\t\tpixelsPerStep,\n\t\t\t\tstate.activeStep\n\t\t\t);\n\t\t\tconst raw = state.startValue + deltaValue;\n\t\t\tconst stepped = quantize( raw, state.activeStep );\n\t\t\tconst next = clampValue( stepped, min, max );\n\t\t\tif ( next !== state.value ) {\n\t\t\t\t// Update the ref synchronously so consecutive pointermove\n\t\t\t\t// events that fire before React commits still see the\n\t\t\t\t// last *emitted* value as `previous` for the next math.\n\t\t\t\tstate.value = next;\n\t\t\t\tonChange( next );\n\t\t\t}\n\t\t},\n\t\t[ disabled, onChange, min, max, step, pixelsPerStep ]\n\t);\n\n\treturn {\n\t\tonPointerDown,\n\t\tonPointerMove,\n\t\tonPointerUp: endDrag,\n\t\tonPointerCancel: endDrag,\n\t};\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,aAAa,WAAW,cAAc;AAaxC,SAAS,eACf,SACA,eACA,MACS;AACT,SAAS,CAAC,UAAU,gBAAkB;AACvC;AASO,SAAS,WAAY,OAAe,KAAa,KAAsB;AAC7E,MAAK,QAAQ,KAAM;AAClB,WAAO;AAAA,EACR;AACA,MAAK,QAAQ,KAAM;AAClB,WAAO;AAAA,EACR;AACA,SAAO;AACR;AAQO,SAAS,SAAU,OAAe,MAAuB;AAC/D,SAAO,KAAK,MAAO,QAAQ,IAAK,IAAI;AACrC;AAoCO,SAAS,aACf,SACoB;AACpB,QAAM;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACD,IAAI;AAQJ,QAAM,YAAY,OASb;AAAA,IACJ;AAAA,IACA,QAAQ;AAAA,IACR,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,UAAU;AAAA,IACV,gBAAgB;AAAA,IAChB,kBAAkB;AAAA,IAClB,iBAAiB;AAAA,EAClB,CAAE;AACF,YAAW,MAAM;AAChB,cAAU,QAAQ,QAAQ;AAAA,EAC3B,GAAG,CAAE,KAAM,CAAE;AAEb,QAAM,UAAU,YAAa,MAAM;AAClC,UAAM,QAAQ,UAAU;AACxB,QAAK,CAAE,MAAM,UAAW;AACvB;AAAA,IACD;AACA,UAAM,WAAW;AACjB,QACC,MAAM,kBACN,MAAM,eAAe,kBAAmB,MAAM,gBAAiB,GAC9D;AACD,YAAM,eAAe;AAAA,QACpB,MAAM;AAAA,MACP;AAAA,IACD;AACA,UAAM,iBAAiB;AACvB,QAAK,MAAM,iBAAkB;AAC5B,aAAO,oBAAqB,aAAa,MAAM,eAAgB;AAC/D,aAAO;AAAA,QACN;AAAA,QACA,MAAM;AAAA,MACP;AACA,YAAM,kBAAkB;AAAA,IACzB;AAAA,EACD,GAAG,CAAC,CAAE;AAIN,YAAW,MAAM,SAAS,CAAE,OAAQ,CAAE;AAItC,YAAW,MAAM;AAChB,QAAK,UAAW;AACf,cAAQ;AAAA,IACT;AAAA,EACD,GAAG,CAAE,UAAU,OAAQ,CAAE;AAEzB,QAAM,gBAAgB;AAAA,IACrB,CAAE,UAA8C;AAC/C,UAAK,YAAY,MAAM,WAAW,GAAI;AACrC;AAAA,MACD;AACA,YAAM,QAAQ,UAAU;AACxB,YAAM,cAAc,kBAAmB,MAAM,SAAU;AACvD,YAAM,iBAAiB,MAAM;AAC7B,YAAM,mBAAmB,MAAM;AAC/B,YAAM,SAAS,MAAM;AACrB,YAAM,aAAa,MAAM;AACzB,YAAM,aAAa,MAAM,WAAW,OAAO,IAAI;AAC/C,YAAM,WAAW;AACjB,2BAAqB;AAQrB,YAAM,aAAa,MAAM,QAAQ;AACjC,YAAM,kBAAkB;AACxB,aAAO,iBAAkB,aAAa,UAAW;AACjD,aAAO,iBAAkB,iBAAiB,UAAW;AAAA,IACtD;AAAA,IACA,CAAE,UAAU,oBAAoB,SAAS,IAAK;AAAA,EAC/C;AAEA,QAAM,gBAAgB;AAAA,IACrB,CAAE,UAA8C;AAC/C,YAAM,QAAQ,UAAU;AACxB,UAAK,YAAY,CAAE,MAAM,UAAW;AACnC;AAAA,MACD;AAMA,YAAM,gBAAgB,MAAM,WAAW,OAAO,IAAI;AAClD,UAAK,kBAAkB,MAAM,YAAa;AACzC,cAAM,SAAS,MAAM;AACrB,cAAM,aAAa,MAAM;AACzB,cAAM,aAAa;AAAA,MACpB;AACA,YAAM,UAAU,MAAM,UAAU,MAAM;AACtC,YAAM,aAAa;AAAA,QAClB;AAAA,QACA;AAAA,QACA,MAAM;AAAA,MACP;AACA,YAAM,MAAM,MAAM,aAAa;AAC/B,YAAM,UAAU,SAAU,KAAK,MAAM,UAAW;AAChD,YAAM,OAAO,WAAY,SAAS,KAAK,GAAI;AAC3C,UAAK,SAAS,MAAM,OAAQ;AAI3B,cAAM,QAAQ;AACd,iBAAU,IAAK;AAAA,MAChB;AAAA,IACD;AAAA,IACA,CAAE,UAAU,UAAU,KAAK,KAAK,MAAM,aAAc;AAAA,EACrD;AAEA,SAAO;AAAA,IACN;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb,iBAAiB;AAAA,EAClB;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"use-ruler-drag.mjs","names":[],"sources":["../../../src/components/rotation-ruler/use-ruler-drag.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Convert a horizontal pointer delta (px) into a value delta.\n *\n * Negative because dragging the ruler to the right should expose\n * smaller values to the left of the fixed center pointer (and vice\n * versa) — the ruler scrubs *under* the pointer.\n *\n * @param deltaPx Pointer movement in CSS pixels.\n * @param pixelsPerStep CSS pixels of pointer travel per `step`.\n * @param step Value units per step.\n */\nexport function pxToValueDelta(\n\tdeltaPx: number,\n\tpixelsPerStep: number,\n\tstep: number\n): number {\n\treturn ( -deltaPx / pixelsPerStep ) * step;\n}\n\n/**\n * Clamp `value` to the inclusive `[min, max]` interval.\n *\n * @param value Value to clamp.\n * @param min Lower bound (inclusive).\n * @param max Upper bound (inclusive).\n */\nexport function clampValue( value: number, min: number, max: number ): number {\n\tif ( value < min ) {\n\t\treturn min;\n\t}\n\tif ( value > max ) {\n\t\treturn max;\n\t}\n\treturn value;\n}\n\n/**\n * Round `value` to the nearest multiple of `step`.\n *\n * @param value Value to quantize.\n * @param step Step granularity (must be > 0).\n */\nexport function quantize( value: number, step: number ): number {\n\treturn Math.round( value / step ) * step;\n}\n\nexport interface UseRulerDragOptions {\n\tvalue: number;\n\tonChange: ( next: number ) => void;\n\tmin: number;\n\tmax: number;\n\tstep: number;\n\tpixelsPerStep: number;\n\tdisabled: boolean;\n\t/** Called once on pointerdown so the caller can focus the input. */\n\tonPointerDownStart?: () => void;\n}\n\nexport interface RulerDragHandlers {\n\tonPointerDown: ( event: React.PointerEvent< HTMLElement > ) => void;\n\tonPointerMove: ( event: React.PointerEvent< HTMLElement > ) => void;\n\tonPointerUp: ( event: React.PointerEvent< HTMLElement > ) => void;\n\tonPointerCancel: ( event: React.PointerEvent< HTMLElement > ) => void;\n}\n\n/**\n * Drag-the-ruler gesture for a horizontal slider. Translates pointer\n * movement into value changes quantized to `step`; the caller renders\n * the visuals and holds the value.\n *\n * The hook owns no state of its own — every value change is reported\n * through the supplied `onChange`. The \"current value\" is read from a\n * ref so closure staleness during a drag is impossible. Drag continues\n * past the wrapper's bounds (standard slider behaviour); a window-level\n * `pointerup` listener guarantees the drag ends and pointer capture\n * releases even if the underlying captured event never fires on the\n * wrapper.\n *\n * @param options Ruler-drag configuration. See `UseRulerDragOptions`.\n */\nexport function useRulerDrag(\n\toptions: UseRulerDragOptions\n): RulerDragHandlers {\n\tconst {\n\t\tvalue,\n\t\tonChange,\n\t\tmin,\n\t\tmax,\n\t\tstep,\n\t\tpixelsPerStep,\n\t\tdisabled,\n\t\tonPointerDownStart,\n\t} = options;\n\n\t// Per-drag state, including the last emitted value. Pointermove\n\t// handlers fire far faster than React commits, so they cannot read\n\t// `value` from closure. Pointerdown seeds it from the committed `value`.\n\tconst latestRef = useRef< {\n\t\tvalue: number;\n\t\tstartX: number;\n\t\tstartValue: number;\n\t\tactiveStep: number;\n\t\tdragging: boolean;\n\t\tcaptureElement: HTMLElement | null;\n\t\tcapturePointerId: number;\n\t\twindowPointerUp: ( () => void ) | null;\n\t} >( {\n\t\tvalue,\n\t\tstartX: 0,\n\t\tstartValue: 0,\n\t\tactiveStep: step,\n\t\tdragging: false,\n\t\tcaptureElement: null,\n\t\tcapturePointerId: 0,\n\t\twindowPointerUp: null,\n\t} );\n\n\tconst endDrag = useCallback( () => {\n\t\tconst state = latestRef.current;\n\t\tif ( ! state.dragging ) {\n\t\t\treturn;\n\t\t}\n\t\tstate.dragging = false;\n\t\tif (\n\t\t\tstate.captureElement &&\n\t\t\tstate.captureElement.hasPointerCapture( state.capturePointerId )\n\t\t) {\n\t\t\tstate.captureElement.releasePointerCapture(\n\t\t\t\tstate.capturePointerId\n\t\t\t);\n\t\t}\n\t\tstate.captureElement = null;\n\t\tif ( state.windowPointerUp ) {\n\t\t\twindow.removeEventListener( 'pointerup', state.windowPointerUp );\n\t\t\twindow.removeEventListener(\n\t\t\t\t'pointercancel',\n\t\t\t\tstate.windowPointerUp\n\t\t\t);\n\t\t\tstate.windowPointerUp = null;\n\t\t}\n\t}, [] );\n\n\t// Cleanup any in-flight drag on unmount so we never leak window\n\t// listeners or stale pointer capture.\n\tuseEffect( () => endDrag, [ endDrag ] );\n\n\t// Becoming disabled mid-drag ends it, so a rotation cannot keep\n\t// changing after a save has read it.\n\tuseEffect( () => {\n\t\tif ( disabled ) {\n\t\t\tendDrag();\n\t\t}\n\t}, [ disabled, endDrag ] );\n\n\tconst onPointerDown = useCallback(\n\t\t( event: React.PointerEvent< HTMLElement > ) => {\n\t\t\tif ( disabled || event.button !== 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst state = latestRef.current;\n\t\t\tevent.currentTarget.setPointerCapture( event.pointerId );\n\t\t\tstate.captureElement = event.currentTarget;\n\t\t\tstate.capturePointerId = event.pointerId;\n\t\t\tstate.startX = event.clientX;\n\t\t\tstate.value = value;\n\t\t\tstate.startValue = value;\n\t\t\tstate.activeStep = event.shiftKey ? step / 2 : step;\n\t\t\tstate.dragging = true;\n\t\t\tonPointerDownStart?.();\n\n\t\t\t// Window-level backstop. With `setPointerCapture`, the\n\t\t\t// element should always receive `pointerup` even when the\n\t\t\t// cursor is released outside its bounds — but in practice\n\t\t\t// some browsers / window-blur sequences drop the event. The\n\t\t\t// window listener guarantees the drag ends and capture\n\t\t\t// releases.\n\t\t\tconst onWindowUp = () => endDrag();\n\t\t\tstate.windowPointerUp = onWindowUp;\n\t\t\twindow.addEventListener( 'pointerup', onWindowUp );\n\t\t\twindow.addEventListener( 'pointercancel', onWindowUp );\n\t\t},\n\t\t[ disabled, onPointerDownStart, endDrag, step, value ]\n\t);\n\n\tconst onPointerMove = useCallback(\n\t\t( event: React.PointerEvent< HTMLElement > ) => {\n\t\t\tconst state = latestRef.current;\n\t\t\tif ( disabled || ! state.dragging ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\t// Shift toggles fine mode mid-drag. The drag math computes\n\t\t\t// from `startX` / `startValue`, so naively swapping `step`\n\t\t\t// would yank the value backward. Rebase to the current\n\t\t\t// pointer + value so the granularity changes without a\n\t\t\t// jump.\n\t\t\tconst requestedStep = event.shiftKey ? step / 2 : step;\n\t\t\tif ( requestedStep !== state.activeStep ) {\n\t\t\t\tstate.startX = event.clientX;\n\t\t\t\tstate.startValue = state.value;\n\t\t\t\tstate.activeStep = requestedStep;\n\t\t\t}\n\t\t\tconst deltaPx = event.clientX - state.startX;\n\t\t\tconst deltaValue = pxToValueDelta(\n\t\t\t\tdeltaPx,\n\t\t\t\tpixelsPerStep,\n\t\t\t\tstate.activeStep\n\t\t\t);\n\t\t\tconst raw = state.startValue + deltaValue;\n\t\t\tconst stepped = quantize( raw, state.activeStep );\n\t\t\tconst next = clampValue( stepped, min, max );\n\t\t\tif ( next !== state.value ) {\n\t\t\t\t// Update the ref synchronously so consecutive pointermove\n\t\t\t\t// events that fire before React commits still see the\n\t\t\t\t// last *emitted* value as `previous` for the next math.\n\t\t\t\tstate.value = next;\n\t\t\t\tonChange( next );\n\t\t\t}\n\t\t},\n\t\t[ disabled, onChange, min, max, step, pixelsPerStep ]\n\t);\n\n\treturn {\n\t\tonPointerDown,\n\t\tonPointerMove,\n\t\tonPointerUp: endDrag,\n\t\tonPointerCancel: endDrag,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,SAAgB,eACf,SACA,eACA,MACS;CACT,OAAS,CAAC,UAAU,gBAAkB;AACvC;;;;;;;;AASA,SAAgB,WAAY,OAAe,KAAa,KAAsB;CAC7E,IAAK,QAAQ,KACZ,OAAO;CAER,IAAK,QAAQ,KACZ,OAAO;CAER,OAAO;AACR;;;;;;;AAQA,SAAgB,SAAU,OAAe,MAAuB;CAC/D,OAAO,KAAK,MAAO,QAAQ,IAAK,IAAI;AACrC;;;;;;;;;;;;;;;;AAoCA,SAAgB,aACf,SACoB;CACpB,MAAM,EACL,OACA,UACA,KACA,KACA,MACA,eACA,UACA,uBACG;CAKJ,MAAM,YAAY,OASb;EACJ;EACA,QAAQ;EACR,YAAY;EACZ,YAAY;EACZ,UAAU;EACV,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;CAClB,CAAE;CAEF,MAAM,UAAU,kBAAmB;EAClC,MAAM,QAAQ,UAAU;EACxB,IAAK,CAAE,MAAM,UACZ;EAED,MAAM,WAAW;EACjB,IACC,MAAM,kBACN,MAAM,eAAe,kBAAmB,MAAM,gBAAiB,GAE/D,MAAM,eAAe,sBACpB,MAAM,gBACP;EAED,MAAM,iBAAiB;EACvB,IAAK,MAAM,iBAAkB;GAC5B,OAAO,oBAAqB,aAAa,MAAM,eAAgB;GAC/D,OAAO,oBACN,iBACA,MAAM,eACP;GACA,MAAM,kBAAkB;EACzB;CACD,GAAG,CAAC,CAAE;CAIN,gBAAiB,SAAS,CAAE,OAAQ,CAAE;CAItC,gBAAiB;EAChB,IAAK,UACJ,QAAQ;CAEV,GAAG,CAAE,UAAU,OAAQ,CAAE;CAqEzB,OAAO;EACN,eApEqB,aACnB,UAA8C;GAC/C,IAAK,YAAY,MAAM,WAAW,GACjC;GAED,MAAM,QAAQ,UAAU;GACxB,MAAM,cAAc,kBAAmB,MAAM,SAAU;GACvD,MAAM,iBAAiB,MAAM;GAC7B,MAAM,mBAAmB,MAAM;GAC/B,MAAM,SAAS,MAAM;GACrB,MAAM,QAAQ;GACd,MAAM,aAAa;GACnB,MAAM,aAAa,MAAM,WAAW,OAAO,IAAI;GAC/C,MAAM,WAAW;GACjB,qBAAqB;GAQrB,MAAM,mBAAmB,QAAQ;GACjC,MAAM,kBAAkB;GACxB,OAAO,iBAAkB,aAAa,UAAW;GACjD,OAAO,iBAAkB,iBAAiB,UAAW;EACtD,GACA;GAAE;GAAU;GAAoB;GAAS;GAAM;EAAM,CAyCzC;EACZ,eAvCqB,aACnB,UAA8C;GAC/C,MAAM,QAAQ,UAAU;GACxB,IAAK,YAAY,CAAE,MAAM,UACxB;GAOD,MAAM,gBAAgB,MAAM,WAAW,OAAO,IAAI;GAClD,IAAK,kBAAkB,MAAM,YAAa;IACzC,MAAM,SAAS,MAAM;IACrB,MAAM,aAAa,MAAM;IACzB,MAAM,aAAa;GACpB;GAEA,MAAM,aAAa,eADH,MAAM,UAAU,MAAM,QAGrC,eACA,MAAM,UACP;GAGA,MAAM,OAAO,WADG,SADJ,MAAM,aAAa,YACA,MAAM,UACN,GAAG,KAAK,GAAI;GAC3C,IAAK,SAAS,MAAM,OAAQ;IAI3B,MAAM,QAAQ;IACd,SAAU,IAAK;GAChB;EACD,GACA;GAAE;GAAU;GAAU;GAAK;GAAK;GAAM;EAAc,CAKxC;EACZ,aAAa;EACb,iBAAiB;CAClB;AACD"}
|
|
@@ -1,54 +1,80 @@
|
|
|
1
|
-
// packages/media-editor/src/hooks/use-crop-gesture-handlers.ts
|
|
2
1
|
import { useCallback, useEffect, useRef } from "@wordpress/element";
|
|
3
2
|
import { useMediaEditor } from "../state/index.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
// packages/media-editor/src/hooks/use-crop-gesture-handlers.ts
|
|
4
|
+
/**
|
|
5
|
+
* Data attribute applied to crop control wrappers. The modal's keyboard
|
|
6
|
+
* shortcut handler uses this to distinguish crop controls (where custom
|
|
7
|
+
* undo/redo should fire) from metadata text fields (where the browser's
|
|
8
|
+
* native undo should be preserved).
|
|
9
|
+
*/
|
|
10
|
+
const CROP_CONTROL_ATTR = "data-crop-control";
|
|
11
|
+
/** Idle window used to group repeated keyboard input into one gesture. */
|
|
12
|
+
const KEYBOARD_GESTURE_IDLE_MS = 300;
|
|
13
|
+
/**
|
|
14
|
+
* Event handler props to spread onto a wrapper element around a crop
|
|
15
|
+
* control. Marks the wrapper as a crop control (via `data-crop-control`)
|
|
16
|
+
* so the modal's Cmd+Z handler can identify it, and wires gesture
|
|
17
|
+
* boundaries on the composite store so a slider drag becomes a single
|
|
18
|
+
* undo entry rather than one per tick.
|
|
19
|
+
*
|
|
20
|
+
* Usage:
|
|
21
|
+
* const gestureHandlers = useCropGestureHandlers();
|
|
22
|
+
* <div role="presentation" { ...gestureHandlers }>
|
|
23
|
+
* <RangeControl ... />
|
|
24
|
+
* </div>
|
|
25
|
+
*
|
|
26
|
+
* @param options Optional behavior flags.
|
|
27
|
+
*/
|
|
6
28
|
function useCropGestureHandlers(options = {}) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
29
|
+
const { commitOnKeyUp = true } = options;
|
|
30
|
+
const { beginGesture, endGesture } = useMediaEditor();
|
|
31
|
+
const keyboardTimerRef = useRef(void 0);
|
|
32
|
+
const clearKeyboardTimer = useCallback(() => {
|
|
33
|
+
clearTimeout(keyboardTimerRef.current);
|
|
34
|
+
}, []);
|
|
35
|
+
const scheduleKeyboardEnd = useCallback(() => {
|
|
36
|
+
clearKeyboardTimer();
|
|
37
|
+
keyboardTimerRef.current = setTimeout(() => {
|
|
38
|
+
endGesture();
|
|
39
|
+
}, KEYBOARD_GESTURE_IDLE_MS);
|
|
40
|
+
}, [clearKeyboardTimer, endGesture]);
|
|
41
|
+
useEffect(() => clearKeyboardTimer, [clearKeyboardTimer]);
|
|
42
|
+
const handlePointerDownCapture = useCallback(() => {
|
|
43
|
+
clearKeyboardTimer();
|
|
44
|
+
beginGesture();
|
|
45
|
+
}, [beginGesture, clearKeyboardTimer]);
|
|
46
|
+
const handlePointerEnd = useCallback(() => {
|
|
47
|
+
clearKeyboardTimer();
|
|
48
|
+
endGesture();
|
|
49
|
+
}, [clearKeyboardTimer, endGesture]);
|
|
50
|
+
const handleKeyDownCapture = useCallback(() => {
|
|
51
|
+
beginGesture();
|
|
52
|
+
if (!commitOnKeyUp) scheduleKeyboardEnd();
|
|
53
|
+
}, [
|
|
54
|
+
beginGesture,
|
|
55
|
+
commitOnKeyUp,
|
|
56
|
+
scheduleKeyboardEnd
|
|
57
|
+
]);
|
|
58
|
+
const handleKeyUp = useCallback(() => {
|
|
59
|
+
if (commitOnKeyUp) {
|
|
60
|
+
endGesture();
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
scheduleKeyboardEnd();
|
|
64
|
+
}, [
|
|
65
|
+
commitOnKeyUp,
|
|
66
|
+
endGesture,
|
|
67
|
+
scheduleKeyboardEnd
|
|
68
|
+
]);
|
|
69
|
+
return {
|
|
70
|
+
[CROP_CONTROL_ATTR]: true,
|
|
71
|
+
onPointerDownCapture: handlePointerDownCapture,
|
|
72
|
+
onPointerUp: handlePointerEnd,
|
|
73
|
+
onPointerCancel: handlePointerEnd,
|
|
74
|
+
onKeyDownCapture: handleKeyDownCapture,
|
|
75
|
+
onKeyUp: handleKeyUp
|
|
76
|
+
};
|
|
49
77
|
}
|
|
50
|
-
export {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
//# sourceMappingURL=use-crop-gesture-handlers.mjs.map
|
|
78
|
+
export { CROP_CONTROL_ATTR, useCropGestureHandlers };
|
|
79
|
+
|
|
80
|
+
//# sourceMappingURL=use-crop-gesture-handlers.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/hooks/use-crop-gesture-handlers.ts"],
|
|
4
|
-
"sourcesContent": ["import { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { useMediaEditor } from '../state';\n\n/**\n * Data attribute applied to crop control wrappers. The modal's keyboard\n * shortcut handler uses this to distinguish crop controls (where custom\n * undo/redo should fire) from metadata text fields (where the browser's\n * native undo should be preserved).\n */\nexport const CROP_CONTROL_ATTR = 'data-crop-control';\n\n/** Idle window used to group repeated keyboard input into one gesture. */\nconst KEYBOARD_GESTURE_IDLE_MS = 300;\n\nexport interface UseCropGestureHandlersOptions {\n\t/**\n\t * When `true` (default), key-up closes the gesture so each\n\t * discrete keypress becomes its own undo step. Set to `false` for\n\t * continuous-input controls (e.g. the rotation ruler) where rapid\n\t * keypresses should coalesce into a single history entry across\n\t * the whole gesture.\n\t */\n\tcommitOnKeyUp?: boolean;\n}\n\n/**\n * Event handler props to spread onto a wrapper element around a crop\n * control. Marks the wrapper as a crop control (via `data-crop-control`)\n * so the modal's Cmd+Z handler can identify it, and wires gesture\n * boundaries on the composite store so a slider drag becomes a single\n * undo entry rather than one per tick.\n *\n * Usage:\n * const gestureHandlers = useCropGestureHandlers();\n * <div role=\"presentation\" { ...gestureHandlers }>\n * <RangeControl ... />\n * </div>\n *\n * @param options Optional behavior flags.\n */\nexport function useCropGestureHandlers(\n\toptions: UseCropGestureHandlersOptions = {}\n) {\n\tconst { commitOnKeyUp = true } = options;\n\tconst { beginGesture, endGesture } = useMediaEditor();\n\tconst keyboardTimerRef = useRef<\n\t\tReturnType< typeof setTimeout > | undefined\n\t>( undefined );\n\n\tconst clearKeyboardTimer = useCallback( () => {\n\t\tclearTimeout( keyboardTimerRef.current );\n\t}, [] );\n\n\tconst scheduleKeyboardEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tkeyboardTimerRef.current = setTimeout( () => {\n\t\t\tendGesture();\n\t\t}, KEYBOARD_GESTURE_IDLE_MS );\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tuseEffect( () => clearKeyboardTimer, [ clearKeyboardTimer ] );\n\n\tconst handlePointerDownCapture = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tbeginGesture();\n\t}, [ beginGesture, clearKeyboardTimer ] );\n\n\tconst handlePointerEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tendGesture();\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tconst handleKeyDownCapture = useCallback( () => {\n\t\tbeginGesture();\n\t\tif ( ! commitOnKeyUp ) {\n\t\t\tscheduleKeyboardEnd();\n\t\t}\n\t}, [ beginGesture, commitOnKeyUp, scheduleKeyboardEnd ] );\n\n\tconst handleKeyUp = useCallback( () => {\n\t\tif ( commitOnKeyUp ) {\n\t\t\tendGesture();\n\t\t\treturn;\n\t\t}\n\t\tscheduleKeyboardEnd();\n\t}, [ commitOnKeyUp, endGesture, scheduleKeyboardEnd ] );\n\n\treturn {\n\t\t[ CROP_CONTROL_ATTR ]: true,\n\t\tonPointerDownCapture: handlePointerDownCapture,\n\t\tonPointerUp: handlePointerEnd,\n\t\tonPointerCancel: handlePointerEnd,\n\t\tonKeyDownCapture: handleKeyDownCapture,\n\t\tonKeyUp: handleKeyUp,\n\t};\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,aAAa,WAAW,cAAc;AAC/C,SAAS,sBAAsB;AAQxB,IAAM,oBAAoB;AAGjC,IAAM,2BAA2B;AA4B1B,SAAS,uBACf,UAAyC,CAAC,GACzC;AACD,QAAM,EAAE,gBAAgB,KAAK,IAAI;AACjC,QAAM,EAAE,cAAc,WAAW,IAAI,eAAe;AACpD,QAAM,mBAAmB,OAEtB,MAAU;AAEb,QAAM,qBAAqB,YAAa,MAAM;AAC7C,iBAAc,iBAAiB,OAAQ;AAAA,EACxC,GAAG,CAAC,CAAE;AAEN,QAAM,sBAAsB,YAAa,MAAM;AAC9C,uBAAmB;AACnB,qBAAiB,UAAU,WAAY,MAAM;AAC5C,iBAAW;AAAA,IACZ,GAAG,wBAAyB;AAAA,EAC7B,GAAG,CAAE,oBAAoB,UAAW,CAAE;AAEtC,YAAW,MAAM,oBAAoB,CAAE,kBAAmB,CAAE;AAE5D,QAAM,2BAA2B,YAAa,MAAM;AACnD,uBAAmB;AACnB,iBAAa;AAAA,EACd,GAAG,CAAE,cAAc,kBAAmB,CAAE;AAExC,QAAM,mBAAmB,YAAa,MAAM;AAC3C,uBAAmB;AACnB,eAAW;AAAA,EACZ,GAAG,CAAE,oBAAoB,UAAW,CAAE;AAEtC,QAAM,uBAAuB,YAAa,MAAM;AAC/C,iBAAa;AACb,QAAK,CAAE,eAAgB;AACtB,0BAAoB;AAAA,IACrB;AAAA,EACD,GAAG,CAAE,cAAc,eAAe,mBAAoB,CAAE;AAExD,QAAM,cAAc,YAAa,MAAM;AACtC,QAAK,eAAgB;AACpB,iBAAW;AACX;AAAA,IACD;AACA,wBAAoB;AAAA,EACrB,GAAG,CAAE,eAAe,YAAY,mBAAoB,CAAE;AAEtD,SAAO;AAAA,IACN,CAAE,iBAAkB,GAAG;AAAA,IACvB,sBAAsB;AAAA,IACtB,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,SAAS;AAAA,EACV;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"use-crop-gesture-handlers.mjs","names":[],"sources":["../../src/hooks/use-crop-gesture-handlers.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from '@wordpress/element';\nimport { useMediaEditor } from '../state';\n\n/**\n * Data attribute applied to crop control wrappers. The modal's keyboard\n * shortcut handler uses this to distinguish crop controls (where custom\n * undo/redo should fire) from metadata text fields (where the browser's\n * native undo should be preserved).\n */\nexport const CROP_CONTROL_ATTR = 'data-crop-control';\n\n/** Idle window used to group repeated keyboard input into one gesture. */\nconst KEYBOARD_GESTURE_IDLE_MS = 300;\n\nexport interface UseCropGestureHandlersOptions {\n\t/**\n\t * When `true` (default), key-up closes the gesture so each\n\t * discrete keypress becomes its own undo step. Set to `false` for\n\t * continuous-input controls (e.g. the rotation ruler) where rapid\n\t * keypresses should coalesce into a single history entry across\n\t * the whole gesture.\n\t */\n\tcommitOnKeyUp?: boolean;\n}\n\n/**\n * Event handler props to spread onto a wrapper element around a crop\n * control. Marks the wrapper as a crop control (via `data-crop-control`)\n * so the modal's Cmd+Z handler can identify it, and wires gesture\n * boundaries on the composite store so a slider drag becomes a single\n * undo entry rather than one per tick.\n *\n * Usage:\n * const gestureHandlers = useCropGestureHandlers();\n * <div role=\"presentation\" { ...gestureHandlers }>\n * <RangeControl ... />\n * </div>\n *\n * @param options Optional behavior flags.\n */\nexport function useCropGestureHandlers(\n\toptions: UseCropGestureHandlersOptions = {}\n) {\n\tconst { commitOnKeyUp = true } = options;\n\tconst { beginGesture, endGesture } = useMediaEditor();\n\tconst keyboardTimerRef = useRef<\n\t\tReturnType< typeof setTimeout > | undefined\n\t>( undefined );\n\n\tconst clearKeyboardTimer = useCallback( () => {\n\t\tclearTimeout( keyboardTimerRef.current );\n\t}, [] );\n\n\tconst scheduleKeyboardEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tkeyboardTimerRef.current = setTimeout( () => {\n\t\t\tendGesture();\n\t\t}, KEYBOARD_GESTURE_IDLE_MS );\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tuseEffect( () => clearKeyboardTimer, [ clearKeyboardTimer ] );\n\n\tconst handlePointerDownCapture = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tbeginGesture();\n\t}, [ beginGesture, clearKeyboardTimer ] );\n\n\tconst handlePointerEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tendGesture();\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tconst handleKeyDownCapture = useCallback( () => {\n\t\tbeginGesture();\n\t\tif ( ! commitOnKeyUp ) {\n\t\t\tscheduleKeyboardEnd();\n\t\t}\n\t}, [ beginGesture, commitOnKeyUp, scheduleKeyboardEnd ] );\n\n\tconst handleKeyUp = useCallback( () => {\n\t\tif ( commitOnKeyUp ) {\n\t\t\tendGesture();\n\t\t\treturn;\n\t\t}\n\t\tscheduleKeyboardEnd();\n\t}, [ commitOnKeyUp, endGesture, scheduleKeyboardEnd ] );\n\n\treturn {\n\t\t[ CROP_CONTROL_ATTR ]: true,\n\t\tonPointerDownCapture: handlePointerDownCapture,\n\t\tonPointerUp: handlePointerEnd,\n\t\tonPointerCancel: handlePointerEnd,\n\t\tonKeyDownCapture: handleKeyDownCapture,\n\t\tonKeyUp: handleKeyUp,\n\t};\n}\n"],"mappings":";;;;;;;;;AASA,MAAa,oBAAoB;;AAGjC,MAAM,2BAA2B;;;;;;;;;;;;;;;;AA4BjC,SAAgB,uBACf,UAAyC,CAAC,GACzC;CACD,MAAM,EAAE,gBAAgB,SAAS;CACjC,MAAM,EAAE,cAAc,eAAe,eAAe;CACpD,MAAM,mBAAmB,OAEtB,KAAA,CAAU;CAEb,MAAM,qBAAqB,kBAAmB;EAC7C,aAAc,iBAAiB,OAAQ;CACxC,GAAG,CAAC,CAAE;CAEN,MAAM,sBAAsB,kBAAmB;EAC9C,mBAAmB;EACnB,iBAAiB,UAAU,iBAAkB;GAC5C,WAAW;EACZ,GAAG,wBAAyB;CAC7B,GAAG,CAAE,oBAAoB,UAAW,CAAE;CAEtC,gBAAiB,oBAAoB,CAAE,kBAAmB,CAAE;CAE5D,MAAM,2BAA2B,kBAAmB;EACnD,mBAAmB;EACnB,aAAa;CACd,GAAG,CAAE,cAAc,kBAAmB,CAAE;CAExC,MAAM,mBAAmB,kBAAmB;EAC3C,mBAAmB;EACnB,WAAW;CACZ,GAAG,CAAE,oBAAoB,UAAW,CAAE;CAEtC,MAAM,uBAAuB,kBAAmB;EAC/C,aAAa;EACb,IAAK,CAAE,eACN,oBAAoB;CAEtB,GAAG;EAAE;EAAc;EAAe;CAAoB,CAAE;CAExD,MAAM,cAAc,kBAAmB;EACtC,IAAK,eAAgB;GACpB,WAAW;GACX;EACD;EACA,oBAAoB;CACrB,GAAG;EAAE;EAAe;EAAY;CAAoB,CAAE;CAEtD,OAAO;GACJ,oBAAqB;EACvB,sBAAsB;EACtB,aAAa;EACb,iBAAiB;EACjB,kBAAkB;EAClB,SAAS;CACV;AACD"}
|
package/build-module/index.mjs
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
// packages/media-editor/src/index.ts
|
|
2
1
|
import { MediaEditorProvider } from "./components/media-editor-provider/index.mjs";
|
|
3
|
-
import
|
|
4
|
-
import
|
|
2
|
+
import MediaPreview from "./components/media-preview/index.mjs";
|
|
3
|
+
import MediaForm from "./components/media-form/index.mjs";
|
|
5
4
|
import { privateApis } from "./private-apis.mjs";
|
|
6
|
-
export {
|
|
7
|
-
MediaEditorProvider,
|
|
8
|
-
default3 as MediaForm,
|
|
9
|
-
default2 as MediaPreview,
|
|
10
|
-
privateApis
|
|
11
|
-
};
|
|
12
|
-
//# sourceMappingURL=index.mjs.map
|
|
5
|
+
export { MediaEditorProvider, MediaForm, MediaPreview, privateApis };
|
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
// packages/media-editor/src/lock-unlock.ts
|
|
2
1
|
import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from "@wordpress/private-apis";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
lock,
|
|
9
|
-
unlock
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=lock-unlock.mjs.map
|
|
2
|
+
// packages/media-editor/src/lock-unlock.ts
|
|
3
|
+
const { lock, unlock } = __dangerousOptInToUnstableAPIsOnlyForCoreModules("I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.", "@wordpress/media-editor");
|
|
4
|
+
export { lock, unlock };
|
|
5
|
+
|
|
6
|
+
//# sourceMappingURL=lock-unlock.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/lock-unlock.ts"],
|
|
4
|
-
"sourcesContent": ["import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/media-editor'\n\t);\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,wDAAwD;AAE1D,IAAM,EAAE,MAAM,OAAO,IAC3B;AAAA,EACC;AAAA,EACA;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"lock-unlock.mjs","names":[],"sources":["../src/lock-unlock.ts"],"sourcesContent":["import { __dangerousOptInToUnstableAPIsOnlyForCoreModules } from '@wordpress/private-apis';\n\nexport const { lock, unlock } =\n\t__dangerousOptInToUnstableAPIsOnlyForCoreModules(\n\t\t'I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.',\n\t\t'@wordpress/media-editor'\n\t);\n"],"mappings":";;AAEA,MAAa,EAAE,MAAM,WACpB,iDACC,iIACA,yBACD"}
|
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
// packages/media-editor/src/private-apis.ts
|
|
2
1
|
import { lock } from "./lock-unlock.mjs";
|
|
3
2
|
import { store } from "./store/index.mjs";
|
|
4
3
|
import { MediaEditorModal } from "./components/media-editor-modal/index.mjs";
|
|
5
4
|
import { MediaEditor } from "./components/media-editor/index.mjs";
|
|
6
|
-
|
|
5
|
+
// packages/media-editor/src/private-apis.ts
|
|
6
|
+
const privateApis = {};
|
|
7
7
|
lock(privateApis, {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
store,
|
|
9
|
+
MediaEditor,
|
|
10
|
+
MediaEditorModal
|
|
11
11
|
});
|
|
12
|
-
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
//# sourceMappingURL=private-apis.mjs.map
|
|
12
|
+
export { privateApis };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=private-apis.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/private-apis.ts"],
|
|
4
|
-
"sourcesContent": ["import { lock } from './lock-unlock';\nimport { store } from './store';\nimport { MediaEditorModal } from './components/media-editor-modal';\nimport { MediaEditor } from './components/media-editor';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tstore,\n\tMediaEditor,\n\tMediaEditorModal,\n} );\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,YAAY;AACrB,SAAS,aAAa;AACtB,SAAS,wBAAwB;AACjC,SAAS,mBAAmB;AAErB,IAAM,cAAc,CAAC;AAC5B,KAAM,aAAa;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AACD,CAAE;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"private-apis.mjs","names":[],"sources":["../src/private-apis.ts"],"sourcesContent":["import { lock } from './lock-unlock';\nimport { store } from './store';\nimport { MediaEditorModal } from './components/media-editor-modal';\nimport { MediaEditor } from './components/media-editor';\n\nexport const privateApis = {};\nlock( privateApis, {\n\tstore,\n\tMediaEditor,\n\tMediaEditorModal,\n} );\n"],"mappings":";;;;;AAKA,MAAa,cAAc,CAAC;AAC5B,KAAM,aAAa;CAClB;CACA;CACA;AACD,CAAE"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { __ } from "@wordpress/i18n";
|
|
2
|
+
// packages/media-editor/src/state/aspect-ratio-presets.ts
|
|
3
|
+
/**
|
|
4
|
+
* Sentinel value for "Original" aspect ratio — resolved at runtime
|
|
5
|
+
* to the image's natural width / height.
|
|
6
|
+
*/
|
|
7
|
+
const ORIGINAL_ASPECT_RATIO = -1;
|
|
8
|
+
/**
|
|
9
|
+
* The presets the editor offers by default. They live here rather than
|
|
10
|
+
* in the image editor package, because which ratios to offer, and what
|
|
11
|
+
* to call them, is a product choice. The package takes a plain number.
|
|
12
|
+
*/
|
|
13
|
+
const DEFAULT_ASPECT_RATIOS = [
|
|
14
|
+
{
|
|
15
|
+
label: __("Free"),
|
|
16
|
+
value: 0
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
label: __("Original"),
|
|
20
|
+
value: -1
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
label: __("Square (1:1)"),
|
|
24
|
+
value: 1
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
label: __("Landscape (16:9)"),
|
|
28
|
+
value: 16 / 9
|
|
29
|
+
},
|
|
30
|
+
{
|
|
31
|
+
label: __("Portrait (9:16)"),
|
|
32
|
+
value: 9 / 16
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
label: __("Classic (4:3)"),
|
|
36
|
+
value: 4 / 3
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
label: __("Classic portrait (3:4)"),
|
|
40
|
+
value: 3 / 4
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
label: __("Photo (3:2)"),
|
|
44
|
+
value: 3 / 2
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: __("Photo portrait (2:3)"),
|
|
48
|
+
value: 2 / 3
|
|
49
|
+
}
|
|
50
|
+
];
|
|
51
|
+
export { DEFAULT_ASPECT_RATIOS, ORIGINAL_ASPECT_RATIO };
|
|
52
|
+
|
|
53
|
+
//# sourceMappingURL=aspect-ratio-presets.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aspect-ratio-presets.mjs","names":[],"sources":["../../src/state/aspect-ratio-presets.ts"],"sourcesContent":["import { __ } from '@wordpress/i18n';\n\n/**\n * An aspect ratio preset with a human-readable label.\n */\nexport interface AspectRatioPreset {\n\t/** Display label (e.g., \"Square (1:1)\"). */\n\tlabel: string;\n\t/**\n\t * The aspect ratio value (width / height). 0 = free,\n\t * `ORIGINAL_ASPECT_RATIO` = the image's own ratio.\n\t */\n\tvalue: number;\n}\n\n/**\n * Sentinel value for \"Original\" aspect ratio — resolved at runtime\n * to the image's natural width / height.\n */\nexport const ORIGINAL_ASPECT_RATIO = -1;\n\n/**\n * The presets the editor offers by default. They live here rather than\n * in the image editor package, because which ratios to offer, and what\n * to call them, is a product choice. The package takes a plain number.\n */\nexport const DEFAULT_ASPECT_RATIOS: AspectRatioPreset[] = [\n\t{ label: __( 'Free' ), value: 0 },\n\t{ label: __( 'Original' ), value: ORIGINAL_ASPECT_RATIO },\n\t{ label: __( 'Square (1:1)' ), value: 1 },\n\t{ label: __( 'Landscape (16:9)' ), value: 16 / 9 },\n\t{ label: __( 'Portrait (9:16)' ), value: 9 / 16 },\n\t{ label: __( 'Classic (4:3)' ), value: 4 / 3 },\n\t{ label: __( 'Classic portrait (3:4)' ), value: 3 / 4 },\n\t{ label: __( 'Photo (3:2)' ), value: 3 / 2 },\n\t{ label: __( 'Photo portrait (2:3)' ), value: 2 / 3 },\n];\n"],"mappings":";;;;;;AAmBA,MAAa,wBAAwB;;;;;;AAOrC,MAAa,wBAA6C;CACzD;EAAE,OAAO,GAAI,MAAO;EAAG,OAAO;CAAE;CAChC;EAAE,OAAO,GAAI,UAAW;EAAG,OAAA;CAA6B;CACxD;EAAE,OAAO,GAAI,cAAe;EAAG,OAAO;CAAE;CACxC;EAAE,OAAO,GAAI,kBAAmB;EAAG,OAAO,KAAK;CAAE;CACjD;EAAE,OAAO,GAAI,iBAAkB;EAAG,OAAO,IAAI;CAAG;CAChD;EAAE,OAAO,GAAI,eAAgB;EAAG,OAAO,IAAI;CAAE;CAC7C;EAAE,OAAO,GAAI,wBAAyB;EAAG,OAAO,IAAI;CAAE;CACtD;EAAE,OAAO,GAAI,aAAc;EAAG,OAAO,IAAI;CAAE;CAC3C;EAAE,OAAO,GAAI,sBAAuB;EAAG,OAAO,IAAI;CAAE;AACrD"}
|