@wordpress/media-editor 0.22.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 +18 -0
- package/build/components/media-editor/index.cjs +74 -21
- package/build/components/media-editor/index.cjs.map +1 -1
- package/build/components/media-editor/use-crop-options.cjs +4 -5
- package/build/components/media-editor/use-crop-options.cjs.map +1 -1
- package/build/components/media-editor/use-save-media-editor.cjs +23 -3
- package/build/components/media-editor/use-save-media-editor.cjs.map +1 -1
- package/build/components/media-editor-canvas/index.cjs +6 -11
- package/build/components/media-editor-canvas/index.cjs.map +1 -1
- package/build/components/media-editor-crop-panel/index.cjs +17 -1
- package/build/components/media-editor-crop-panel/index.cjs.map +1 -1
- package/build/components/media-editor-fine-rotation/index.cjs +4 -5
- package/build/components/media-editor-fine-rotation/index.cjs.map +1 -1
- package/build/components/media-editor-image-controls/index.cjs +4 -6
- package/build/components/media-editor-image-controls/index.cjs.map +1 -1
- package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +1 -0
- package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -1
- package/build/components/media-editor-modal/index.cjs.map +1 -1
- package/build/components/media-form/index.cjs +7 -1
- package/build/components/media-form/index.cjs.map +1 -1
- package/build/components/media-preview/index.cjs +0 -1
- package/build/components/media-preview/index.cjs.map +1 -1
- package/build/state/aspect-ratio-presets.cjs +10 -4
- package/build/state/aspect-ratio-presets.cjs.map +1 -1
- package/build/state/composite-reducer.cjs +32 -67
- package/build/state/composite-reducer.cjs.map +1 -1
- package/build/state/index.cjs +0 -39
- package/build/state/types.cjs +1 -2
- package/build/state/types.cjs.map +1 -1
- package/build/state/use-media-editor-state.cjs +70 -106
- package/build/state/use-media-editor-state.cjs.map +1 -1
- package/build-module/components/media-editor/index.mjs +78 -25
- package/build-module/components/media-editor/index.mjs.map +1 -1
- package/build-module/components/media-editor/use-crop-options.mjs +4 -5
- package/build-module/components/media-editor/use-crop-options.mjs.map +1 -1
- package/build-module/components/media-editor/use-save-media-editor.mjs +23 -3
- package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -1
- package/build-module/components/media-editor-canvas/index.mjs +8 -13
- package/build-module/components/media-editor-canvas/index.mjs.map +1 -1
- package/build-module/components/media-editor-crop-panel/index.mjs +17 -1
- package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -1
- package/build-module/components/media-editor-fine-rotation/index.mjs +4 -5
- package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -1
- package/build-module/components/media-editor-image-controls/index.mjs +5 -7
- package/build-module/components/media-editor-image-controls/index.mjs.map +1 -1
- package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +1 -0
- package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -1
- package/build-module/components/media-editor-modal/index.mjs.map +1 -1
- package/build-module/components/media-form/index.mjs +7 -1
- package/build-module/components/media-form/index.mjs.map +1 -1
- package/build-module/components/media-preview/index.mjs +0 -1
- package/build-module/components/media-preview/index.mjs.map +1 -1
- package/build-module/state/aspect-ratio-presets.mjs +10 -5
- package/build-module/state/aspect-ratio-presets.mjs.map +1 -1
- package/build-module/state/composite-reducer.mjs +32 -67
- package/build-module/state/composite-reducer.mjs.map +1 -1
- package/build-module/state/index.mjs +2 -5
- package/build-module/state/types.mjs +1 -2
- package/build-module/state/types.mjs.map +1 -1
- package/build-module/state/use-media-editor-state.mjs +70 -105
- package/build-module/state/use-media-editor-state.mjs.map +1 -1
- package/build-style/style-rtl.css +104 -57
- package/build-style/style.css +103 -57
- package/build-types/components/media-editor/index.d.ts +17 -3
- 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/state/aspect-ratio-presets.d.ts +20 -3
- package/build-types/state/aspect-ratio-presets.d.ts.map +1 -1
- 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 -5
- package/build-types/state/index.d.ts.map +1 -1
- package/build-types/state/types.d.ts +20 -64
- 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 +163 -28
- package/src/components/media-editor/use-crop-options.ts +7 -11
- package/src/components/media-editor/use-save-media-editor.ts +48 -6
- package/src/components/media-editor-canvas/index.tsx +15 -26
- 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 +11 -9
- 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-form/index.tsx +7 -1
- package/src/components/media-preview/index.tsx +0 -1
- package/src/components/rotation-ruler/style.scss +3 -3
- package/src/state/README.md +32 -0
- package/src/state/aspect-ratio-presets.ts +22 -3
- package/src/state/composite-reducer.ts +42 -80
- package/src/state/index.ts +2 -18
- package/src/state/types.ts +18 -68
- package/src/state/use-media-editor-state.ts +155 -240
- package/src/style.scss +2 -1
- package/build/components/media-editor-modal/build-modifiers.cjs +0 -110
- package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -1
- package/build/image-editor/core/camera.cjs +0 -277
- package/build/image-editor/core/camera.cjs.map +0 -1
- package/build/image-editor/core/constants.cjs +0 -133
- package/build/image-editor/core/constants.cjs.map +0 -1
- package/build/image-editor/core/containment.cjs +0 -289
- package/build/image-editor/core/containment.cjs.map +0 -1
- package/build/image-editor/core/crop-rect.cjs +0 -37
- package/build/image-editor/core/crop-rect.cjs.map +0 -1
- package/build/image-editor/core/export/canvas-renderer.cjs +0 -181
- package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -1
- package/build/image-editor/core/index.cjs +0 -89
- package/build/image-editor/core/interaction-controller.cjs +0 -591
- package/build/image-editor/core/interaction-controller.cjs.map +0 -1
- package/build/image-editor/core/math/rotation.cjs +0 -32
- package/build/image-editor/core/math/rotation.cjs.map +0 -1
- package/build/image-editor/core/math/sanitize.cjs +0 -136
- package/build/image-editor/core/math/sanitize.cjs.map +0 -1
- package/build/image-editor/core/setter-helpers.cjs +0 -61
- package/build/image-editor/core/setter-helpers.cjs.map +0 -1
- package/build/image-editor/core/source-region.cjs +0 -236
- package/build/image-editor/core/source-region.cjs.map +0 -1
- package/build/image-editor/core/state.cjs +0 -296
- package/build/image-editor/core/state.cjs.map +0 -1
- package/build/image-editor/core/stencil-math.cjs +0 -203
- package/build/image-editor/core/stencil-math.cjs.map +0 -1
- package/build/image-editor/core/transform-style.cjs +0 -43
- package/build/image-editor/core/transform-style.cjs.map +0 -1
- package/build/image-editor/core/transforms/pipeline.cjs +0 -41
- package/build/image-editor/core/transforms/pipeline.cjs.map +0 -1
- package/build/image-editor/core/types.cjs +0 -5
- package/build/image-editor/core/viewport-state.cjs +0 -36
- package/build/image-editor/core/viewport-state.cjs.map +0 -1
- package/build/image-editor/index.cjs +0 -68
- package/build/image-editor/react/components/cropper-provider.cjs +0 -49
- package/build/image-editor/react/components/cropper-provider.cjs.map +0 -1
- package/build/image-editor/react/components/cropper.cjs +0 -595
- package/build/image-editor/react/components/cropper.cjs.map +0 -1
- package/build/image-editor/react/components/index.cjs +0 -25
- package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -147
- package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -1
- package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -31
- package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -1
- package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -61
- package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -1
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -367
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -1
- package/build/image-editor/react/components/viewport-provider.cjs +0 -26
- package/build/image-editor/react/components/viewport-provider.cjs.map +0 -1
- package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -80
- package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -1
- package/build/image-editor/react/hooks/index.cjs +0 -19
- package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -104
- package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -1
- package/build/image-editor/react/hooks/use-cropper-controller.cjs +0 -80
- package/build/image-editor/react/hooks/use-cropper-controller.cjs.map +0 -1
- package/build/image-editor/react/hooks/use-interaction.cjs +0 -187
- package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -1
- package/build/image-editor/react/hooks/use-transform-style.cjs +0 -24
- package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -1
- package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -40
- package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -1
- package/build/image-editor/react/visually-hidden-style.cjs +0 -24
- package/build/image-editor/react/visually-hidden-style.cjs.map +0 -1
- package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -105
- package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -1
- package/build-module/image-editor/core/camera.mjs +0 -265
- package/build-module/image-editor/core/camera.mjs.map +0 -1
- package/build-module/image-editor/core/constants.mjs +0 -115
- package/build-module/image-editor/core/constants.mjs.map +0 -1
- package/build-module/image-editor/core/containment.mjs +0 -281
- package/build-module/image-editor/core/containment.mjs.map +0 -1
- package/build-module/image-editor/core/crop-rect.mjs +0 -32
- package/build-module/image-editor/core/crop-rect.mjs.map +0 -1
- package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -170
- package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -1
- package/build-module/image-editor/core/index.mjs +0 -7
- package/build-module/image-editor/core/interaction-controller.mjs +0 -586
- package/build-module/image-editor/core/interaction-controller.mjs.map +0 -1
- package/build-module/image-editor/core/math/rotation.mjs +0 -26
- package/build-module/image-editor/core/math/rotation.mjs.map +0 -1
- package/build-module/image-editor/core/math/sanitize.mjs +0 -127
- package/build-module/image-editor/core/math/sanitize.mjs.map +0 -1
- package/build-module/image-editor/core/setter-helpers.mjs +0 -56
- package/build-module/image-editor/core/setter-helpers.mjs.map +0 -1
- package/build-module/image-editor/core/source-region.mjs +0 -228
- package/build-module/image-editor/core/source-region.mjs.map +0 -1
- package/build-module/image-editor/core/state.mjs +0 -288
- package/build-module/image-editor/core/state.mjs.map +0 -1
- package/build-module/image-editor/core/stencil-math.mjs +0 -194
- package/build-module/image-editor/core/stencil-math.mjs.map +0 -1
- package/build-module/image-editor/core/transform-style.mjs +0 -38
- package/build-module/image-editor/core/transform-style.mjs.map +0 -1
- package/build-module/image-editor/core/transforms/pipeline.mjs +0 -35
- package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -1
- package/build-module/image-editor/core/types.mjs +0 -0
- package/build-module/image-editor/core/viewport-state.mjs +0 -30
- package/build-module/image-editor/core/viewport-state.mjs.map +0 -1
- package/build-module/image-editor/index.mjs +0 -4
- package/build-module/image-editor/react/components/cropper-provider.mjs +0 -43
- package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -1
- package/build-module/image-editor/react/components/cropper.mjs +0 -568
- package/build-module/image-editor/react/components/cropper.mjs.map +0 -1
- package/build-module/image-editor/react/components/index.mjs +0 -3
- package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -142
- package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -1
- package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -26
- package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -1
- package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -56
- package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -1
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -362
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -1
- package/build-module/image-editor/react/components/viewport-provider.mjs +0 -20
- package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -1
- package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -75
- package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -1
- package/build-module/image-editor/react/hooks/index.mjs +0 -3
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -99
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -1
- package/build-module/image-editor/react/hooks/use-cropper-controller.mjs +0 -75
- package/build-module/image-editor/react/hooks/use-cropper-controller.mjs.map +0 -1
- package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -182
- package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -1
- package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -19
- package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -1
- package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -35
- package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -1
- package/build-module/image-editor/react/visually-hidden-style.mjs +0 -19
- package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -1
- package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -81
- 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 -98
- 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 -17
- 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 -54
- 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-controller.d.ts +0 -55
- package/build-types/image-editor/react/hooks/use-cropper-controller.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 -167
- 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 -137
- 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 -43
- 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 -43
- 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 -1108
- 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-controller.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,262 +0,0 @@
|
|
|
1
|
-
import { useLayoutEffect, useRef, useState } from '@wordpress/element';
|
|
2
|
-
import type { HandlePosition, NormalizedRect, Size } from '../../../core/types';
|
|
3
|
-
|
|
4
|
-
const HANDLE_GAP_PX = 12;
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Which side of the handle a tooltip axis sits on. `before` places the
|
|
8
|
-
* tooltip on the negative side of the handle (above for Y, left for X),
|
|
9
|
-
* `after` on the positive side, `center` keeps it aligned with the handle.
|
|
10
|
-
*/
|
|
11
|
-
type AxisSide = 'before' | 'center' | 'after';
|
|
12
|
-
|
|
13
|
-
interface Anchor {
|
|
14
|
-
x: AxisSide;
|
|
15
|
-
y: AxisSide;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const TRANSLATE_PERCENT: Record< AxisSide, string > = {
|
|
19
|
-
before: '-100%',
|
|
20
|
-
center: '-50%',
|
|
21
|
-
after: '0',
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
const GAP_DIRECTION: Record< AxisSide, number > = {
|
|
25
|
-
before: -1,
|
|
26
|
-
center: 0,
|
|
27
|
-
after: 1,
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
const OPPOSITE_SIDE: Record< AxisSide, AxisSide > = {
|
|
31
|
-
before: 'after',
|
|
32
|
-
center: 'center',
|
|
33
|
-
after: 'before',
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Preferred anchor for a handle, before edge-clipping is considered:
|
|
38
|
-
* tooltip sits outward from the crop rectangle's center.
|
|
39
|
-
*
|
|
40
|
-
* @param handle
|
|
41
|
-
*/
|
|
42
|
-
function preferredAnchor( handle: HandlePosition ): Anchor {
|
|
43
|
-
let x: AxisSide = 'center';
|
|
44
|
-
if ( handle.includes( 'w' ) ) {
|
|
45
|
-
x = 'before';
|
|
46
|
-
} else if ( handle.includes( 'e' ) ) {
|
|
47
|
-
x = 'after';
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
let y: AxisSide = 'center';
|
|
51
|
-
if ( handle.includes( 'n' ) ) {
|
|
52
|
-
y = 'before';
|
|
53
|
-
} else if ( handle.includes( 's' ) ) {
|
|
54
|
-
y = 'after';
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
return { x, y };
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Start coordinate of a tooltip placed on the given side of `handlePos`,
|
|
62
|
-
* accounting for the per-side handle gap and the tooltip's own length.
|
|
63
|
-
*
|
|
64
|
-
* @param side
|
|
65
|
-
* @param handlePos
|
|
66
|
-
* @param length
|
|
67
|
-
*/
|
|
68
|
-
function sideStart(
|
|
69
|
-
side: AxisSide,
|
|
70
|
-
handlePos: number,
|
|
71
|
-
length: number
|
|
72
|
-
): number {
|
|
73
|
-
if ( side === 'before' ) {
|
|
74
|
-
return handlePos - HANDLE_GAP_PX - length;
|
|
75
|
-
}
|
|
76
|
-
if ( side === 'after' ) {
|
|
77
|
-
return handlePos + HANDLE_GAP_PX;
|
|
78
|
-
}
|
|
79
|
-
return handlePos - length / 2;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Picks a side that keeps the tooltip inside the container along one
|
|
84
|
-
* axis, preferring the supplied side and falling back to its opposite,
|
|
85
|
-
* then center.
|
|
86
|
-
*
|
|
87
|
-
* @param preferred
|
|
88
|
-
* @param handlePos
|
|
89
|
-
* @param length
|
|
90
|
-
* @param containerLength
|
|
91
|
-
*/
|
|
92
|
-
function fittingSide(
|
|
93
|
-
preferred: AxisSide,
|
|
94
|
-
handlePos: number,
|
|
95
|
-
length: number,
|
|
96
|
-
containerLength: number
|
|
97
|
-
): AxisSide {
|
|
98
|
-
const fits = ( side: AxisSide ) => {
|
|
99
|
-
const start = sideStart( side, handlePos, length );
|
|
100
|
-
return start >= 0 && start + length <= containerLength;
|
|
101
|
-
};
|
|
102
|
-
|
|
103
|
-
if ( fits( preferred ) ) {
|
|
104
|
-
return preferred;
|
|
105
|
-
}
|
|
106
|
-
const opposite = OPPOSITE_SIDE[ preferred ];
|
|
107
|
-
if ( opposite !== preferred && fits( opposite ) ) {
|
|
108
|
-
return opposite;
|
|
109
|
-
}
|
|
110
|
-
if ( preferred !== 'center' && fits( 'center' ) ) {
|
|
111
|
-
return 'center';
|
|
112
|
-
}
|
|
113
|
-
// None of the candidates fully fit — pick the one that pushes the
|
|
114
|
-
// least past the container edge. Without this, the chain falls back
|
|
115
|
-
// to `preferred`, which is the off-canvas side that triggered the
|
|
116
|
-
// flip in the first place, so the tooltip ends up clipped.
|
|
117
|
-
const overflow = ( side: AxisSide ) => {
|
|
118
|
-
const start = sideStart( side, handlePos, length );
|
|
119
|
-
return (
|
|
120
|
-
Math.max( 0, -start ) +
|
|
121
|
-
Math.max( 0, start + length - containerLength )
|
|
122
|
-
);
|
|
123
|
-
};
|
|
124
|
-
const candidates: AxisSide[] = [ preferred, opposite, 'center' ];
|
|
125
|
-
return candidates.reduce( ( best, side ) =>
|
|
126
|
-
overflow( side ) < overflow( best ) ? side : best
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
interface DimensionsOverlayProps {
|
|
131
|
-
/** Crop rectangle in normalized coordinates. */
|
|
132
|
-
cropRect: NormalizedRect;
|
|
133
|
-
/** Container element dimensions in pixels. */
|
|
134
|
-
containerSize: Size;
|
|
135
|
-
/** Rendered image dimensions in pixels within the container. */
|
|
136
|
-
imageSize: Size;
|
|
137
|
-
/** Currently-dragged handle, or null when no pointer drag is active. */
|
|
138
|
-
activeHandle: HandlePosition | null;
|
|
139
|
-
/** Output crop width in source pixels. */
|
|
140
|
-
outputWidth: number;
|
|
141
|
-
/** Output crop height in source pixels. */
|
|
142
|
-
outputHeight: number;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* Tooltip that follows the active resize handle during a pointer drag,
|
|
147
|
-
* showing the current output dimensions of the crop in source pixels.
|
|
148
|
-
*
|
|
149
|
-
* Renders nothing outside of a pointer-driven resize, so keyboard
|
|
150
|
-
* arrow-key adjustments and pan/zoom gestures stay quiet.
|
|
151
|
-
*
|
|
152
|
-
* @param props
|
|
153
|
-
* @param props.cropRect
|
|
154
|
-
* @param props.containerSize
|
|
155
|
-
* @param props.imageSize
|
|
156
|
-
* @param props.activeHandle
|
|
157
|
-
* @param props.outputWidth
|
|
158
|
-
* @param props.outputHeight
|
|
159
|
-
*/
|
|
160
|
-
export function DimensionsOverlay( {
|
|
161
|
-
cropRect,
|
|
162
|
-
containerSize,
|
|
163
|
-
imageSize,
|
|
164
|
-
activeHandle,
|
|
165
|
-
outputWidth,
|
|
166
|
-
outputHeight,
|
|
167
|
-
}: DimensionsOverlayProps ) {
|
|
168
|
-
const tooltipRef = useRef< HTMLDivElement >( null );
|
|
169
|
-
const [ tooltipSize, setTooltipSize ] = useState< Size | null >( null );
|
|
170
|
-
|
|
171
|
-
// Measure the rendered tooltip so we can flip its anchor when it
|
|
172
|
-
// would otherwise be clipped by the cropper's `overflow: hidden`
|
|
173
|
-
// root. Runs synchronously before paint, so the user never sees
|
|
174
|
-
// the un-flipped position. Tracks `outputWidth`/`outputHeight`
|
|
175
|
-
// because they drive the digit count, the only thing that changes
|
|
176
|
-
// the tooltip's intrinsic size during a drag.
|
|
177
|
-
useLayoutEffect( () => {
|
|
178
|
-
if ( ! tooltipRef.current ) {
|
|
179
|
-
return;
|
|
180
|
-
}
|
|
181
|
-
const rect = tooltipRef.current.getBoundingClientRect();
|
|
182
|
-
setTooltipSize( ( prev ) => {
|
|
183
|
-
if (
|
|
184
|
-
prev &&
|
|
185
|
-
prev.width === rect.width &&
|
|
186
|
-
prev.height === rect.height
|
|
187
|
-
) {
|
|
188
|
-
return prev;
|
|
189
|
-
}
|
|
190
|
-
return { width: rect.width, height: rect.height };
|
|
191
|
-
} );
|
|
192
|
-
}, [ outputWidth, outputHeight ] );
|
|
193
|
-
|
|
194
|
-
if (
|
|
195
|
-
! activeHandle ||
|
|
196
|
-
containerSize.width === 0 ||
|
|
197
|
-
containerSize.height === 0
|
|
198
|
-
) {
|
|
199
|
-
return null;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
const offsetX = ( containerSize.width - imageSize.width ) / 2;
|
|
203
|
-
const offsetY = ( containerSize.height - imageSize.height ) / 2;
|
|
204
|
-
const left = offsetX + cropRect.x * imageSize.width;
|
|
205
|
-
const top = offsetY + cropRect.y * imageSize.height;
|
|
206
|
-
const width = cropRect.width * imageSize.width;
|
|
207
|
-
const height = cropRect.height * imageSize.height;
|
|
208
|
-
|
|
209
|
-
// Handle pixel position within the container. Same math as the
|
|
210
|
-
// stencil's handle layout, just keyed by direction here so the
|
|
211
|
-
// tooltip can anchor to any of the eight.
|
|
212
|
-
let handleX = left + width / 2;
|
|
213
|
-
if ( activeHandle.includes( 'w' ) ) {
|
|
214
|
-
handleX = left;
|
|
215
|
-
} else if ( activeHandle.includes( 'e' ) ) {
|
|
216
|
-
handleX = left + width;
|
|
217
|
-
}
|
|
218
|
-
let handleY = top + height / 2;
|
|
219
|
-
if ( activeHandle.includes( 'n' ) ) {
|
|
220
|
-
handleY = top;
|
|
221
|
-
} else if ( activeHandle.includes( 's' ) ) {
|
|
222
|
-
handleY = top + height;
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const preferred = preferredAnchor( activeHandle );
|
|
226
|
-
const anchor: Anchor = tooltipSize
|
|
227
|
-
? {
|
|
228
|
-
x: fittingSide(
|
|
229
|
-
preferred.x,
|
|
230
|
-
handleX,
|
|
231
|
-
tooltipSize.width,
|
|
232
|
-
containerSize.width
|
|
233
|
-
),
|
|
234
|
-
y: fittingSide(
|
|
235
|
-
preferred.y,
|
|
236
|
-
handleY,
|
|
237
|
-
tooltipSize.height,
|
|
238
|
-
containerSize.height
|
|
239
|
-
),
|
|
240
|
-
}
|
|
241
|
-
: preferred;
|
|
242
|
-
|
|
243
|
-
return (
|
|
244
|
-
<div
|
|
245
|
-
ref={ tooltipRef }
|
|
246
|
-
className="wp-media-editor-image-editor__dimensions-tooltip"
|
|
247
|
-
data-testid="cropper-dimensions-tooltip"
|
|
248
|
-
style={ {
|
|
249
|
-
left: handleX + GAP_DIRECTION[ anchor.x ] * HANDLE_GAP_PX,
|
|
250
|
-
top: handleY + GAP_DIRECTION[ anchor.y ] * HANDLE_GAP_PX,
|
|
251
|
-
transform: `translate(${ TRANSLATE_PERCENT[ anchor.x ] }, ${
|
|
252
|
-
TRANSLATE_PERCENT[ anchor.y ]
|
|
253
|
-
})`,
|
|
254
|
-
} }
|
|
255
|
-
aria-hidden="true"
|
|
256
|
-
>
|
|
257
|
-
{ `W: ${ Math.round( outputWidth ) }px H: ${ Math.round(
|
|
258
|
-
outputHeight
|
|
259
|
-
) }px` }
|
|
260
|
-
</div>
|
|
261
|
-
);
|
|
262
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import type { NormalizedRect, Size } from '../../../core/types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Props for the DimmingOverlay component.
|
|
5
|
-
*/
|
|
6
|
-
interface DimmingOverlayProps {
|
|
7
|
-
/** The crop rectangle in normalized coordinates. */
|
|
8
|
-
cropRect: NormalizedRect;
|
|
9
|
-
/** The container element dimensions in pixels. */
|
|
10
|
-
containerSize: Size;
|
|
11
|
-
/** The rendered image dimensions in pixels within the container. */
|
|
12
|
-
imageSize: Size;
|
|
13
|
-
/** CSS transition string, e.g. during settle animation. */
|
|
14
|
-
transition?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Renders a semi-transparent overlay outside the crop rectangle using a
|
|
18
|
-
// box-shadow that dims everything outside the crop rect position.
|
|
19
|
-
export function DimmingOverlay( {
|
|
20
|
-
cropRect,
|
|
21
|
-
containerSize,
|
|
22
|
-
imageSize,
|
|
23
|
-
transition,
|
|
24
|
-
}: DimmingOverlayProps ) {
|
|
25
|
-
if ( containerSize.width === 0 || containerSize.height === 0 ) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const offsetX = ( containerSize.width - imageSize.width ) / 2;
|
|
30
|
-
const offsetY = ( containerSize.height - imageSize.height ) / 2;
|
|
31
|
-
const left = offsetX + cropRect.x * imageSize.width;
|
|
32
|
-
const top = offsetY + cropRect.y * imageSize.height;
|
|
33
|
-
const width = cropRect.width * imageSize.width;
|
|
34
|
-
const height = cropRect.height * imageSize.height;
|
|
35
|
-
|
|
36
|
-
// Compose any incoming transition with the stylesheet's box-shadow
|
|
37
|
-
// transition so the drag-dimming effect isn't overwritten.
|
|
38
|
-
const composedTransition = transition
|
|
39
|
-
? `${ transition }, box-shadow 0.15s ease`
|
|
40
|
-
: undefined;
|
|
41
|
-
|
|
42
|
-
return (
|
|
43
|
-
<div
|
|
44
|
-
className="wp-media-editor-image-editor__dimming"
|
|
45
|
-
data-testid="cropper-dimming"
|
|
46
|
-
style={ {
|
|
47
|
-
left,
|
|
48
|
-
top,
|
|
49
|
-
width,
|
|
50
|
-
height,
|
|
51
|
-
transition: composedTransition,
|
|
52
|
-
} }
|
|
53
|
-
/>
|
|
54
|
-
);
|
|
55
|
-
}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import type { NormalizedRect, Size } from '../../../core/types';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Props for the GridOverlay component.
|
|
5
|
-
*/
|
|
6
|
-
interface GridOverlayProps {
|
|
7
|
-
/** The crop rectangle in normalized coordinates. */
|
|
8
|
-
cropRect: NormalizedRect;
|
|
9
|
-
/** The container element dimensions in pixels. */
|
|
10
|
-
containerSize: Size;
|
|
11
|
-
/** The rendered image dimensions in pixels within the container. */
|
|
12
|
-
imageSize: Size;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Renders a rule-of-thirds grid inside the crop rectangle.
|
|
17
|
-
*
|
|
18
|
-
* Displays 2 horizontal and 2 vertical lines at 1/3 and 2/3
|
|
19
|
-
* positions within the crop area.
|
|
20
|
-
*
|
|
21
|
-
* @param props Component props.
|
|
22
|
-
* @param props.cropRect The crop rectangle in normalized coordinates.
|
|
23
|
-
* @param props.containerSize The container element dimensions in pixels.
|
|
24
|
-
* @param props.imageSize The rendered image dimensions in pixels.
|
|
25
|
-
* @return The grid overlay element.
|
|
26
|
-
*/
|
|
27
|
-
export function GridOverlay( {
|
|
28
|
-
cropRect,
|
|
29
|
-
containerSize,
|
|
30
|
-
imageSize,
|
|
31
|
-
}: GridOverlayProps ) {
|
|
32
|
-
if ( containerSize.width === 0 || containerSize.height === 0 ) {
|
|
33
|
-
return null;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const offsetX = ( containerSize.width - imageSize.width ) / 2;
|
|
37
|
-
const offsetY = ( containerSize.height - imageSize.height ) / 2;
|
|
38
|
-
const left = offsetX + cropRect.x * imageSize.width;
|
|
39
|
-
const top = offsetY + cropRect.y * imageSize.height;
|
|
40
|
-
const width = cropRect.width * imageSize.width;
|
|
41
|
-
const height = cropRect.height * imageSize.height;
|
|
42
|
-
|
|
43
|
-
const thirdW = width / 3;
|
|
44
|
-
const thirdH = height / 3;
|
|
45
|
-
|
|
46
|
-
return (
|
|
47
|
-
<div
|
|
48
|
-
className="wp-media-editor-image-editor__grid"
|
|
49
|
-
data-testid="cropper-grid"
|
|
50
|
-
style={ {
|
|
51
|
-
left,
|
|
52
|
-
top,
|
|
53
|
-
width,
|
|
54
|
-
height,
|
|
55
|
-
} }
|
|
56
|
-
>
|
|
57
|
-
{ /* Horizontal lines at 1/3 and 2/3 */ }
|
|
58
|
-
<div
|
|
59
|
-
className="wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal"
|
|
60
|
-
style={ { top: thirdH } }
|
|
61
|
-
/>
|
|
62
|
-
<div
|
|
63
|
-
className="wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--horizontal"
|
|
64
|
-
style={ { top: thirdH * 2 } }
|
|
65
|
-
/>
|
|
66
|
-
{ /* Vertical lines at 1/3 and 2/3 */ }
|
|
67
|
-
<div
|
|
68
|
-
className="wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical"
|
|
69
|
-
style={ { left: thirdW } }
|
|
70
|
-
/>
|
|
71
|
-
<div
|
|
72
|
-
className="wp-media-editor-image-editor__grid-line wp-media-editor-image-editor__grid-line--vertical"
|
|
73
|
-
style={ { left: thirdW * 2 } }
|
|
74
|
-
/>
|
|
75
|
-
</div>
|
|
76
|
-
);
|
|
77
|
-
}
|