@wordpress/media-editor 0.22.0 → 0.24.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 +34 -0
- package/build/components/media-editor/index.cjs +229 -126
- 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 +41 -11
- package/build/components/media-editor/use-save-media-editor.cjs.map +1 -1
- package/build/components/media-editor-canvas/index.cjs +15 -18
- package/build/components/media-editor-canvas/index.cjs.map +1 -1
- package/build/components/media-editor-crop-panel/index.cjs +26 -8
- package/build/components/media-editor-crop-panel/index.cjs.map +1 -1
- package/build/components/media-editor-fine-rotation/index.cjs +13 -12
- 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 +33 -33
- package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -1
- package/build/components/media-editor-modal/index.cjs +10 -7
- package/build/components/media-editor-modal/index.cjs.map +1 -1
- package/build/components/media-editor-panel/error-boundary.cjs +68 -0
- package/build/components/media-editor-panel/error-boundary.cjs.map +1 -0
- package/build/components/media-editor-panel/index.cjs +158 -0
- package/build/components/media-editor-panel/index.cjs.map +1 -0
- 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 +143 -37
- package/build/components/media-preview/index.cjs.map +1 -1
- package/build/components/rotation-ruler/index.cjs +9 -7
- package/build/components/rotation-ruler/index.cjs.map +1 -1
- package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -1
- package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -1
- package/build/index.cjs +10 -8
- package/build/private-apis.cjs.map +1 -1
- package/build/state/aspect-ratio-presets.cjs +12 -6
- package/build/state/aspect-ratio-presets.cjs.map +1 -1
- package/build/state/composite-reducer.cjs +41 -74
- 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/store/index.cjs +11 -9
- package/build/store/index.cjs.map +1 -1
- package/build/utils/get-media-type.cjs +8 -0
- package/build/utils/get-media-type.cjs.map +1 -1
- package/build/utils/index.cjs +6 -0
- package/build-module/components/media-editor/index.mjs +217 -117
- 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 +32 -4
- 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 +33 -33
- package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -1
- package/build-module/components/media-editor-modal/index.mjs +1 -0
- package/build-module/components/media-editor-modal/index.mjs.map +1 -1
- package/build-module/components/media-editor-panel/error-boundary.mjs +63 -0
- package/build-module/components/media-editor-panel/error-boundary.mjs.map +1 -0
- package/build-module/components/media-editor-panel/index.mjs +123 -0
- package/build-module/components/media-editor-panel/index.mjs.map +1 -0
- 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 +123 -41
- package/build-module/components/media-preview/index.mjs.map +1 -1
- package/build-module/state/aspect-ratio-presets.mjs +12 -7
- 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-module/utils/get-media-type.mjs +8 -1
- package/build-module/utils/get-media-type.mjs.map +1 -1
- package/build-module/utils/index.mjs +1 -1
- package/build-style/style-rtl.css +122 -87
- package/build-style/style.css +121 -87
- package/build-types/components/media-editor/index.d.ts +25 -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-editor-panel/error-boundary.d.ts +23 -0
- package/build-types/components/media-editor-panel/error-boundary.d.ts.map +1 -0
- package/build-types/components/media-editor-panel/index.d.ts +46 -0
- package/build-types/components/media-editor-panel/index.d.ts.map +1 -0
- 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 +40 -54
- package/build-types/state/use-media-editor-state.d.ts.map +1 -1
- package/build-types/utils/get-media-type.d.ts +3 -1
- package/build-types/utils/get-media-type.d.ts.map +1 -1
- package/build-types/utils/index.d.ts +1 -1
- package/build-types/utils/index.d.ts.map +1 -1
- package/package.json +27 -24
- package/src/components/media-editor/index.tsx +372 -142
- package/src/components/media-editor/style.scss +21 -1
- 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 +56 -63
- package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
- package/src/components/media-editor-modal/index.tsx +4 -1
- package/src/components/media-editor-panel/error-boundary.tsx +88 -0
- package/src/components/media-editor-panel/index.tsx +211 -0
- package/src/components/media-form/index.tsx +7 -1
- package/src/components/media-preview/index.tsx +195 -37
- package/src/components/media-preview/style.scss +11 -32
- package/src/components/rotation-ruler/style.scss +3 -3
- package/src/state/README.md +34 -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 +162 -242
- package/src/style.scss +2 -1
- package/src/utils/get-media-type.ts +9 -1
- package/src/utils/index.ts +1 -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
|
@@ -120,6 +120,13 @@
|
|
|
120
120
|
height: 100%;
|
|
121
121
|
}
|
|
122
122
|
|
|
123
|
+
// The grey stage is for previewing media. Without a preview, e.g. for
|
|
124
|
+
// a zip file or a file that failed to load, the placeholder sits on
|
|
125
|
+
// the surface instead.
|
|
126
|
+
&:has(.media-editor-preview.is-placeholder) {
|
|
127
|
+
background: none;
|
|
128
|
+
}
|
|
129
|
+
|
|
123
130
|
img,
|
|
124
131
|
video {
|
|
125
132
|
max-width: 100%;
|
|
@@ -168,6 +175,18 @@
|
|
|
168
175
|
}
|
|
169
176
|
}
|
|
170
177
|
|
|
178
|
+
// The grey stage normally marks the panel's edge. Without it, e.g. for a
|
|
179
|
+
// file without a preview, the panel takes a border instead.
|
|
180
|
+
.media-editor__body:has(.media-editor-preview.is-placeholder)
|
|
181
|
+
.media-editor__sidebar {
|
|
182
|
+
@include break-small() {
|
|
183
|
+
// Matches the page header's bottom border in the route.
|
|
184
|
+
border-inline-start:
|
|
185
|
+
var(--wpds-border-width-xs) solid
|
|
186
|
+
var(--wpds-color-stroke-surface-neutral-weak);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
|
|
171
190
|
// The strip and the open pane, stacked. No inline padding: the pane below
|
|
172
191
|
// scrolls, and a gutter here would inset its scrollbar from the sidebar
|
|
173
192
|
// edge. The strip and the pane carry their own instead.
|
|
@@ -222,9 +241,10 @@
|
|
|
222
241
|
.media-editor__body.has-panel-open .media-editor__content {
|
|
223
242
|
display: none;
|
|
224
243
|
|
|
244
|
+
// Only remove the right margin, so the route's bottom margin still applies.
|
|
225
245
|
@include break-small() {
|
|
226
246
|
display: flex;
|
|
227
|
-
margin: 0
|
|
247
|
+
margin-right: 0;
|
|
228
248
|
}
|
|
229
249
|
}
|
|
230
250
|
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { useMemo } from '@wordpress/element';
|
|
2
|
-
import type { AspectRatioPreset } from '../../image-editor/core/constants';
|
|
3
2
|
import {
|
|
4
3
|
DEFAULT_ASPECT_RATIOS,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
} from '../../state';
|
|
4
|
+
type AspectRatioPreset,
|
|
5
|
+
} from '../../state/aspect-ratio-presets';
|
|
6
|
+
import { useMediaEditor } from '../../state';
|
|
8
7
|
|
|
9
8
|
interface UseCropOptionsArgs {
|
|
10
9
|
aspectRatioPresets?: AspectRatioPreset[];
|
|
@@ -38,8 +37,7 @@ export function getAspectRatioOptions(
|
|
|
38
37
|
/**
|
|
39
38
|
* Thin selector over the composite media-editor store for the Crop
|
|
40
39
|
* sidebar tab. Reads the cropOptions slice (preset key) and exposes
|
|
41
|
-
* the corresponding setters plus
|
|
42
|
-
* derivation.
|
|
40
|
+
* the corresponding setters plus the ratio the image editor has locked.
|
|
43
41
|
*
|
|
44
42
|
* No local React state, no refs, no synchronization effects — the
|
|
45
43
|
* composite store is the single source of truth.
|
|
@@ -52,17 +50,15 @@ export function useCropOptions( {
|
|
|
52
50
|
}: UseCropOptionsArgs = {} ): UseCropOptionsReturn {
|
|
53
51
|
const controller = useMediaEditor();
|
|
54
52
|
const { aspectRatioValue } = controller.cropOptions;
|
|
55
|
-
const cropperImage = controller.cropper.state.image;
|
|
56
53
|
|
|
57
54
|
const aspectRatioOptions = useMemo(
|
|
58
55
|
() => getAspectRatioOptions( aspectRatioPresets ),
|
|
59
56
|
[ aspectRatioPresets ]
|
|
60
57
|
);
|
|
61
58
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
);
|
|
59
|
+
// The image editor owns the locked ratio; the preset is what the
|
|
60
|
+
// dropdown shows.
|
|
61
|
+
const resolvedAspectRatio = controller.imageEditor.state.aspectRatio;
|
|
66
62
|
|
|
67
63
|
return {
|
|
68
64
|
aspectRatioValue,
|
|
@@ -4,12 +4,36 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
4
4
|
import { useCallback, useState } from '@wordpress/element';
|
|
5
5
|
import { __, sprintf } from '@wordpress/i18n';
|
|
6
6
|
import { store as noticesStore } from '@wordpress/notices';
|
|
7
|
+
import { getImageEdit, mapImageEdit } from '@wordpress/image-editor';
|
|
7
8
|
import type { Media } from '../media-editor-provider';
|
|
8
9
|
import type { MediaEditorSession } from '../../state';
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* A single modifier in the Core REST `/edit` payload. Order is
|
|
13
|
+
* significant — the server applies modifiers sequentially (see
|
|
14
|
+
* `WP_REST_Attachments_Controller::edit_media_item`).
|
|
15
|
+
*
|
|
16
|
+
* Shape/units:
|
|
17
|
+
* - `flip`: booleans per axis.
|
|
18
|
+
* - `rotate`: `angle` in degrees, clockwise-positive (matches the
|
|
19
|
+
* image editor's own convention; Core negates it internally for
|
|
20
|
+
* `WP_Image_Editor::rotate`, which is counterclockwise-positive).
|
|
21
|
+
* - `crop`: percentages (0–100) of the image's dimensions **at the
|
|
22
|
+
* moment the crop is applied**. Because modifiers are applied in
|
|
23
|
+
* order, after a preceding `rotate` the server's
|
|
24
|
+
* `WP_Image_Editor::get_size()` reports the full post-rotate AABB,
|
|
25
|
+
* so the percentages are of that AABB. Origin is top-left.
|
|
26
|
+
*/
|
|
27
|
+
type Modifier =
|
|
28
|
+
| {
|
|
29
|
+
type: 'flip';
|
|
30
|
+
args: { flip: { horizontal: boolean; vertical: boolean } };
|
|
31
|
+
}
|
|
32
|
+
| { type: 'rotate'; args: { angle: number } }
|
|
33
|
+
| {
|
|
34
|
+
type: 'crop';
|
|
35
|
+
args: { left: number; top: number; width: number; height: number };
|
|
36
|
+
};
|
|
13
37
|
|
|
14
38
|
// Details-tab edits are bundled into transformed `/edit` requests. Core's
|
|
15
39
|
// endpoint only accepts this whitelist.
|
|
@@ -65,7 +89,25 @@ function getCropModifiers( session: MediaEditorSession ): Modifier[] {
|
|
|
65
89
|
if ( ! session.hasOutputEdits ) {
|
|
66
90
|
return [];
|
|
67
91
|
}
|
|
68
|
-
|
|
92
|
+
const edit = getImageEdit( session.imageEditor.state );
|
|
93
|
+
if ( ! edit ) {
|
|
94
|
+
return [];
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Core applies modifiers in the order they arrive.
|
|
98
|
+
return mapImageEdit< Modifier >( edit, {
|
|
99
|
+
flip: ( flip ) => ( { type: 'flip', args: { flip } } ),
|
|
100
|
+
rotation: ( angle ) => ( { type: 'rotate', args: { angle } } ),
|
|
101
|
+
crop: ( { x, y, width, height } ) => ( {
|
|
102
|
+
type: 'crop',
|
|
103
|
+
args: {
|
|
104
|
+
left: x * 100,
|
|
105
|
+
top: y * 100,
|
|
106
|
+
width: width * 100,
|
|
107
|
+
height: height * 100,
|
|
108
|
+
},
|
|
109
|
+
} ),
|
|
110
|
+
} );
|
|
69
111
|
}
|
|
70
112
|
|
|
71
113
|
function getMetadataEdits(
|
|
@@ -190,7 +232,7 @@ export function useSaveMediaEditor( {
|
|
|
190
232
|
|
|
191
233
|
if ( next && next.id ) {
|
|
192
234
|
if ( next.id === id ) {
|
|
193
|
-
session.
|
|
235
|
+
session.reset();
|
|
194
236
|
}
|
|
195
237
|
onSaved?.( {
|
|
196
238
|
id: next.id,
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
|
-
import { useCallback, useEffect,
|
|
2
|
+
import { useCallback, useEffect, useState } from '@wordpress/element';
|
|
3
3
|
import { Spinner as WCSpinner } from '@wordpress/components';
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
+
import { ImageEditorCanvas } from '@wordpress/image-editor';
|
|
5
6
|
import { useMediaEditorContext } from '../media-editor-provider';
|
|
6
7
|
import { getMediaTypeFromMimeType } from '../../utils';
|
|
7
|
-
import {
|
|
8
|
-
import { useMediaEditor, resolveAspectRatio } from '../../state';
|
|
8
|
+
import { useMediaEditor } from '../../state';
|
|
9
9
|
|
|
10
10
|
export interface MediaEditorCanvasProps {
|
|
11
11
|
/** Whether external placement activity should reveal the grid. */
|
|
12
12
|
isPlacementActive?: boolean;
|
|
13
|
-
/** Fires when a canvas
|
|
13
|
+
/** Fires when a canvas gesture begins. */
|
|
14
14
|
onGestureStart?: () => void;
|
|
15
|
-
/** Fires when a canvas
|
|
15
|
+
/** Fires when a canvas gesture ends. */
|
|
16
16
|
onGestureEnd?: () => void;
|
|
17
17
|
/**
|
|
18
18
|
* Disable crop interaction on the canvas. Set while the edit is saving,
|
|
@@ -23,7 +23,7 @@ export interface MediaEditorCanvasProps {
|
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* Editing surface for image media in the media editor modal. Pulls
|
|
26
|
-
* its
|
|
26
|
+
* its image editor controller from the surrounding `<MediaEditorStateProvider>`
|
|
27
27
|
* so the bottom bar and Crop sidebar tab share the same state.
|
|
28
28
|
*
|
|
29
29
|
* Returns `null` for missing or non-image media so the modal's outer
|
|
@@ -43,29 +43,18 @@ export default function MediaEditorCanvas( {
|
|
|
43
43
|
}: MediaEditorCanvasProps ) {
|
|
44
44
|
const { media } = useMediaEditorContext();
|
|
45
45
|
const session = useMediaEditor();
|
|
46
|
-
const { aspectRatioValue } = session.cropOptions;
|
|
47
|
-
const cropperImage = session.cropper.state.image;
|
|
48
46
|
const { beginGesture, endGesture, setSourceImage } = session;
|
|
49
47
|
|
|
50
|
-
// Tracks whether the image pixels have actually loaded. The
|
|
48
|
+
// Tracks whether the image pixels have actually loaded. The image editor's
|
|
51
49
|
// geometry is driven by the known media dimensions, so its handles and
|
|
52
50
|
// overlays would otherwise appear before the image finishes streaming in.
|
|
53
51
|
// Stored with the URL it is for, so a new URL (restoring the original
|
|
54
|
-
// swaps it in place) counts as loading until the
|
|
52
|
+
// swaps it in place) counts as loading until the image editor reports back.
|
|
55
53
|
const [ settled, setSettled ] = useState< {
|
|
56
54
|
url: string | undefined;
|
|
57
55
|
status: 'loaded' | 'error';
|
|
58
56
|
} >();
|
|
59
57
|
|
|
60
|
-
// Resolved aspect ratio is derived from the preset key + the
|
|
61
|
-
// loaded image (for the "Original" preset). The reducer doesn't
|
|
62
|
-
// store this number — only the preset key — so it's a render-time
|
|
63
|
-
// derivation here.
|
|
64
|
-
const aspectRatio = useMemo(
|
|
65
|
-
() => resolveAspectRatio( aspectRatioValue, cropperImage ),
|
|
66
|
-
[ aspectRatioValue, cropperImage ]
|
|
67
|
-
);
|
|
68
|
-
|
|
69
58
|
const handleGestureStart = useCallback( () => {
|
|
70
59
|
beginGesture();
|
|
71
60
|
onGestureStart?.();
|
|
@@ -130,7 +119,7 @@ export default function MediaEditorCanvas( {
|
|
|
130
119
|
</div>
|
|
131
120
|
) }
|
|
132
121
|
{ /*
|
|
133
|
-
* The
|
|
122
|
+
* The image editor stays mounted while loading (hidden behind the
|
|
134
123
|
* spinner) so the image decodes off-screen and reveals in one paint
|
|
135
124
|
* instead of streaming in top-to-bottom. Until it's revealed it's
|
|
136
125
|
* non-interactive (`pointer-events: none` in CSS).
|
|
@@ -140,17 +129,17 @@ export default function MediaEditorCanvas( {
|
|
|
140
129
|
* by tabbing to it.
|
|
141
130
|
*/ }
|
|
142
131
|
<div
|
|
143
|
-
className={ clsx( 'media-editor-
|
|
132
|
+
className={ clsx( 'media-editor-canvas__image-editor', {
|
|
144
133
|
'is-loaded': status === 'loaded',
|
|
145
134
|
} ) }
|
|
146
135
|
>
|
|
147
|
-
<
|
|
136
|
+
<ImageEditorCanvas
|
|
148
137
|
src={ mediaUrl }
|
|
149
|
-
controller={ session.
|
|
150
|
-
aspectRatio={ aspectRatio }
|
|
138
|
+
controller={ session.imageEditor }
|
|
151
139
|
freeformCrop
|
|
152
|
-
|
|
153
|
-
|
|
140
|
+
// Keep the grid up while a sidebar placement control is in
|
|
141
|
+
// use; otherwise show it only while the crop is changing.
|
|
142
|
+
showGrid={ isPlacementActive ? true : 'interactive' }
|
|
154
143
|
onGestureStart={ handleGestureStart }
|
|
155
144
|
onGestureEnd={ handleGestureEnd }
|
|
156
145
|
onImageLoaded={ handleImageLoaded }
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
@use "@wordpress/base-styles/animations" as *;
|
|
2
2
|
@use "@wordpress/base-styles/colors" as *;
|
|
3
3
|
|
|
4
|
-
// The canvas wrapper fills the modal's canvas area so the
|
|
5
|
-
// sized parent (the
|
|
4
|
+
// The canvas wrapper fills the modal's canvas area so the image editor has a
|
|
5
|
+
// sized parent (the image editor uses 100% width/height of its container).
|
|
6
6
|
// `position: relative` establishes a stacking context for any future
|
|
7
7
|
// overlays rendered inside the canvas.
|
|
8
8
|
.media-editor-canvas {
|
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
width: 100%;
|
|
11
11
|
height: 100%;
|
|
12
12
|
|
|
13
|
-
// The
|
|
13
|
+
// The image editor stays mounted while loading so the image decodes behind the
|
|
14
14
|
// spinner and reveals in one paint. It's hidden and non-interactive until
|
|
15
15
|
// the image has loaded, then fades in.
|
|
16
|
-
&
|
|
16
|
+
&__image-editor {
|
|
17
17
|
width: 100%;
|
|
18
18
|
height: 100%;
|
|
19
19
|
opacity: 0;
|
|
20
20
|
pointer-events: none;
|
|
21
21
|
|
|
22
22
|
// Explicit `opacity: 1` (not just the animation's fill mode) keeps the
|
|
23
|
-
//
|
|
23
|
+
// image editor visible for reduced-motion users, since `animation__fade-in`
|
|
24
24
|
// is gated behind `@media not (prefers-reduced-motion)`.
|
|
25
25
|
&.is-loaded {
|
|
26
26
|
opacity: 1;
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
transform: translate(-50%, -50%);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
// Centered fallback shown in place of the
|
|
39
|
+
// Centered fallback shown in place of the image editor when the image
|
|
40
40
|
// fails to load.
|
|
41
41
|
&__error {
|
|
42
42
|
display: flex;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { SelectControl, Stack, VisuallyHidden } from '@wordpress/ui';
|
|
2
2
|
import { __ } from '@wordpress/i18n';
|
|
3
|
+
import { Icon, getAspectRatioIcon } from '@wordpress/icons';
|
|
4
|
+
import type { AspectRatioPreset } from '../../state/aspect-ratio-presets';
|
|
3
5
|
import { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';
|
|
4
6
|
import MediaEditorImageControls from '../media-editor-image-controls';
|
|
5
|
-
import type { AspectRatioPreset } from '../../image-editor/core/constants';
|
|
6
7
|
|
|
7
8
|
export interface MediaEditorCropPanelProps {
|
|
8
9
|
/**
|
|
@@ -66,7 +67,42 @@ export default function MediaEditorCropPanel( {
|
|
|
66
67
|
} }
|
|
67
68
|
disabled={ disabled }
|
|
68
69
|
items={ items }
|
|
69
|
-
|
|
70
|
+
trigger={
|
|
71
|
+
<SelectControl.Trigger>
|
|
72
|
+
{ ( item ) => (
|
|
73
|
+
<span className="media-editor-crop-panel__aspect-ratio-option">
|
|
74
|
+
<Icon
|
|
75
|
+
icon={ getAspectRatioIcon(
|
|
76
|
+
Number( item.value )
|
|
77
|
+
) }
|
|
78
|
+
/>
|
|
79
|
+
<span className="media-editor-crop-panel__aspect-ratio-label">
|
|
80
|
+
{ item.label }
|
|
81
|
+
</span>
|
|
82
|
+
</span>
|
|
83
|
+
) }
|
|
84
|
+
</SelectControl.Trigger>
|
|
85
|
+
}
|
|
86
|
+
>
|
|
87
|
+
{ items.map( ( item ) => (
|
|
88
|
+
<SelectControl.Item
|
|
89
|
+
key={ item.value }
|
|
90
|
+
value={ item }
|
|
91
|
+
label={ item.label }
|
|
92
|
+
>
|
|
93
|
+
<SelectControl.ItemLabel>
|
|
94
|
+
<span className="media-editor-crop-panel__aspect-ratio-option">
|
|
95
|
+
<Icon
|
|
96
|
+
icon={ getAspectRatioIcon(
|
|
97
|
+
Number( item.value )
|
|
98
|
+
) }
|
|
99
|
+
/>
|
|
100
|
+
{ item.label }
|
|
101
|
+
</span>
|
|
102
|
+
</SelectControl.ItemLabel>
|
|
103
|
+
</SelectControl.Item>
|
|
104
|
+
) ) }
|
|
105
|
+
</SelectControl>
|
|
70
106
|
</Stack>
|
|
71
107
|
);
|
|
72
108
|
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
@use "@wordpress/base-styles/variables" as *;
|
|
2
|
+
|
|
3
|
+
.media-editor-crop-panel__aspect-ratio-option {
|
|
4
|
+
display: flex;
|
|
5
|
+
align-items: center;
|
|
6
|
+
gap: $grid-unit-10;
|
|
7
|
+
// Allow the label to shrink so that it can be truncated.
|
|
8
|
+
min-width: 0;
|
|
9
|
+
|
|
10
|
+
svg {
|
|
11
|
+
flex-shrink: 0;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
// The trigger truncates its value with an ellipsis, which doesn't apply
|
|
16
|
+
// through the flex wrapper, so truncate the label itself.
|
|
17
|
+
.media-editor-crop-panel__aspect-ratio-label {
|
|
18
|
+
overflow: hidden;
|
|
19
|
+
text-overflow: ellipsis;
|
|
20
|
+
white-space: nowrap;
|
|
21
|
+
}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { __ } from '@wordpress/i18n';
|
|
2
2
|
import { useMediaEditor } from '../../state';
|
|
3
3
|
import { useCropGestureHandlers } from '../../hooks/use-crop-gesture-handlers';
|
|
4
|
-
import { MAX_ROTATION_OFFSET } from '../../image-editor/core/constants';
|
|
5
4
|
import RotationRuler from '../rotation-ruler';
|
|
6
5
|
|
|
7
6
|
export interface MediaEditorFineRotationProps {
|
|
@@ -28,7 +27,8 @@ export default function MediaEditorFineRotation( {
|
|
|
28
27
|
onPlacementControlInteraction,
|
|
29
28
|
disabled = false,
|
|
30
29
|
}: MediaEditorFineRotationProps ) {
|
|
31
|
-
const { state, setRotation } =
|
|
30
|
+
const { state, setRotation, maxRotationOffset } =
|
|
31
|
+
useMediaEditor().imageEditor;
|
|
32
32
|
// `commitOnKeyUp: false` lets rapid arrow-key adjustments coalesce
|
|
33
33
|
// into one undo entry via the gesture idle window. Pointer-up still
|
|
34
34
|
// closes pointer drags immediately.
|
|
@@ -50,8 +50,8 @@ export default function MediaEditorFineRotation( {
|
|
|
50
50
|
// causing subsequent events to spiral.
|
|
51
51
|
const EPS = 0.01;
|
|
52
52
|
const clamped = Math.max(
|
|
53
|
-
-
|
|
54
|
-
Math.min(
|
|
53
|
+
-maxRotationOffset + EPS,
|
|
54
|
+
Math.min( maxRotationOffset - EPS, value )
|
|
55
55
|
);
|
|
56
56
|
onPlacementControlInteraction?.();
|
|
57
57
|
setRotation( baseAngle + clamped * visualDir );
|
|
@@ -65,8 +65,8 @@ export default function MediaEditorFineRotation( {
|
|
|
65
65
|
>
|
|
66
66
|
<RotationRuler
|
|
67
67
|
label={ __( 'Fine rotation' ) }
|
|
68
|
-
min={ -
|
|
69
|
-
max={
|
|
68
|
+
min={ -maxRotationOffset }
|
|
69
|
+
max={ maxRotationOffset }
|
|
70
70
|
value={ fineOffset }
|
|
71
71
|
onChange={ handleRotationSlider }
|
|
72
72
|
disabled={ disabled }
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
import {
|
|
8
8
|
aspectRatio as aspectRatioIcon,
|
|
9
|
+
getAspectRatioIcon,
|
|
9
10
|
rotateLeft,
|
|
10
11
|
rotateRight,
|
|
11
12
|
flipHorizontal,
|
|
@@ -14,11 +15,7 @@ import {
|
|
|
14
15
|
plus,
|
|
15
16
|
} from '@wordpress/icons';
|
|
16
17
|
import { useMediaEditor } from '../../state';
|
|
17
|
-
import {
|
|
18
|
-
MAX_ZOOM,
|
|
19
|
-
type AspectRatioPreset,
|
|
20
|
-
} from '../../image-editor/core/constants';
|
|
21
|
-
import { getMinZoom } from '../../image-editor/core/containment';
|
|
18
|
+
import type { AspectRatioPreset } from '../../state/aspect-ratio-presets';
|
|
22
19
|
import { useCropOptions } from '../media-editor/use-crop-options';
|
|
23
20
|
|
|
24
21
|
/**
|
|
@@ -79,14 +76,14 @@ export default function MediaEditorImageControls( {
|
|
|
79
76
|
zoomFactor = DEFAULT_ZOOM_FACTOR,
|
|
80
77
|
disabled = false,
|
|
81
78
|
}: MediaEditorImageControlsProps ) {
|
|
82
|
-
const { state, setFlip, snapRotate90, setZoom } =
|
|
79
|
+
const { state, setFlip, snapRotate90, setZoom, minZoom, maxZoom } =
|
|
80
|
+
useMediaEditor().imageEditor;
|
|
83
81
|
const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } =
|
|
84
82
|
useCropOptions( { aspectRatioPresets } );
|
|
85
83
|
const hasAspectRatioControl = ! withLabels && showAspectRatioControl;
|
|
86
|
-
const minZoom = getMinZoom( state );
|
|
87
84
|
const zoomByFactor = ( factor: number ) => {
|
|
88
85
|
setZoom(
|
|
89
|
-
Math.min(
|
|
86
|
+
Math.min( maxZoom, Math.max( minZoom, state.zoom * factor ) )
|
|
90
87
|
);
|
|
91
88
|
};
|
|
92
89
|
|
|
@@ -155,7 +152,7 @@ export default function MediaEditorImageControls( {
|
|
|
155
152
|
icon={ plus }
|
|
156
153
|
label={ __( 'Zoom in' ) }
|
|
157
154
|
showTooltip
|
|
158
|
-
disabled={ disabled || state.zoom >=
|
|
155
|
+
disabled={ disabled || state.zoom >= maxZoom }
|
|
159
156
|
accessibleWhenDisabled
|
|
160
157
|
onClick={ () => zoomByFactor( zoomFactor ) }
|
|
161
158
|
/>
|
|
@@ -202,6 +199,11 @@ export default function MediaEditorImageControls( {
|
|
|
202
199
|
value={ preset.value.toString() }
|
|
203
200
|
closeOnClick
|
|
204
201
|
disabled={ disabled }
|
|
202
|
+
prefix={
|
|
203
|
+
<Menu.PrefixIcon
|
|
204
|
+
icon={ getAspectRatioIcon( preset.value ) }
|
|
205
|
+
/>
|
|
206
|
+
}
|
|
205
207
|
>
|
|
206
208
|
<Menu.ItemLabel>{ preset.label }</Menu.ItemLabel>
|
|
207
209
|
</Menu.RadioItem>
|
|
@@ -6,20 +6,27 @@ import {
|
|
|
6
6
|
shortcutAriaLabel,
|
|
7
7
|
type WPKeycodeModifier,
|
|
8
8
|
} from '@wordpress/keycodes';
|
|
9
|
+
import { VisuallyHidden } from '@wordpress/ui';
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
11
|
+
type KeyCombinationDisplayProps =
|
|
12
|
+
| {
|
|
13
|
+
keyCombination: {
|
|
14
|
+
character: string;
|
|
15
|
+
modifier?: WPKeycodeModifier | null;
|
|
16
|
+
};
|
|
17
|
+
label?: string;
|
|
18
|
+
}
|
|
19
|
+
| {
|
|
20
|
+
keyCombination: {
|
|
21
|
+
character: string[];
|
|
22
|
+
modifier?: WPKeycodeModifier | null;
|
|
23
|
+
};
|
|
24
|
+
label: string;
|
|
25
|
+
};
|
|
18
26
|
|
|
19
|
-
|
|
27
|
+
type ShortcutEntry = KeyCombinationDisplayProps & {
|
|
20
28
|
description: string;
|
|
21
|
-
|
|
22
|
-
}
|
|
29
|
+
};
|
|
23
30
|
|
|
24
31
|
const SHORTCUTS: ShortcutEntry[] = [
|
|
25
32
|
{
|
|
@@ -34,8 +41,8 @@ const SHORTCUTS: ShortcutEntry[] = [
|
|
|
34
41
|
description: __( 'Pan' ),
|
|
35
42
|
keyCombination: {
|
|
36
43
|
character: [ '↑', '↓', '←', '→' ],
|
|
37
|
-
ariaLabel: __( 'Arrow keys' ),
|
|
38
44
|
},
|
|
45
|
+
label: __( 'Arrow keys' ),
|
|
39
46
|
},
|
|
40
47
|
{
|
|
41
48
|
description: __( 'Zoom in' ),
|
|
@@ -66,63 +73,51 @@ const SHORTCUTS: ShortcutEntry[] = [
|
|
|
66
73
|
keyCombination: {
|
|
67
74
|
modifier: 'shift',
|
|
68
75
|
character: [ '↑', '↓', '←', '→' ],
|
|
69
|
-
ariaLabel: __( 'Shift + Arrow keys' ),
|
|
70
76
|
},
|
|
77
|
+
label: __( 'Shift + Arrow keys' ),
|
|
71
78
|
},
|
|
72
79
|
];
|
|
73
80
|
|
|
74
81
|
function KeyCombinationDisplay( {
|
|
75
82
|
keyCombination,
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
} else {
|
|
89
|
-
keys = character;
|
|
90
|
-
}
|
|
91
|
-
} else {
|
|
92
|
-
keys = modifier
|
|
93
|
-
? displayShortcutList[ modifier ]( character )
|
|
94
|
-
: [ character ];
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const charString = Array.isArray( character )
|
|
98
|
-
? character.join( '' )
|
|
99
|
-
: character;
|
|
100
|
-
let label: string;
|
|
101
|
-
if ( ariaLabel ) {
|
|
102
|
-
label = ariaLabel;
|
|
103
|
-
} else if ( modifier ) {
|
|
104
|
-
label = shortcutAriaLabel[ modifier ]( charString );
|
|
105
|
-
} else {
|
|
106
|
-
label = charString;
|
|
107
|
-
}
|
|
83
|
+
label,
|
|
84
|
+
}: KeyCombinationDisplayProps ) {
|
|
85
|
+
const { character, modifier } = keyCombination;
|
|
86
|
+
const normalizedModifier = modifier ?? 'undefined';
|
|
87
|
+
const characters = Array.isArray( character ) ? character : [ character ];
|
|
88
|
+
const formatted = displayShortcutList[ normalizedModifier ](
|
|
89
|
+
characters[ 0 ] ?? ''
|
|
90
|
+
);
|
|
91
|
+
const prefix = formatted.slice( 0, -1 );
|
|
92
|
+
const keys = Array.isArray( character )
|
|
93
|
+
? [ ...prefix, ...character ]
|
|
94
|
+
: formatted;
|
|
108
95
|
|
|
109
96
|
return (
|
|
110
97
|
<kbd
|
|
111
98
|
className="media-editor-keyboard-shortcuts-modal__shortcut-term"
|
|
112
|
-
|
|
99
|
+
dir="ltr"
|
|
113
100
|
>
|
|
114
|
-
{
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
101
|
+
<VisuallyHidden render={ <span /> }>
|
|
102
|
+
{ label ||
|
|
103
|
+
shortcutAriaLabel[ normalizedModifier ](
|
|
104
|
+
characters.join( '' )
|
|
105
|
+
) }
|
|
106
|
+
</VisuallyHidden>
|
|
107
|
+
<span aria-hidden="true">
|
|
108
|
+
{ keys.map( ( key, keyIndex ) =>
|
|
109
|
+
key === '+' && keyIndex < prefix.length ? (
|
|
110
|
+
<Fragment key={ keyIndex }>{ key }</Fragment>
|
|
111
|
+
) : (
|
|
112
|
+
<kbd
|
|
113
|
+
key={ keyIndex }
|
|
114
|
+
className="media-editor-keyboard-shortcuts-modal__shortcut-key"
|
|
115
|
+
>
|
|
116
|
+
{ key }
|
|
117
|
+
</kbd>
|
|
118
|
+
)
|
|
119
|
+
) }
|
|
120
|
+
</span>
|
|
126
121
|
</kbd>
|
|
127
122
|
);
|
|
128
123
|
}
|
|
@@ -154,17 +149,15 @@ export default function MediaEditorKeyboardShortcutsModal( {
|
|
|
154
149
|
className="media-editor-keyboard-shortcuts-modal__shortcut-list"
|
|
155
150
|
role="list"
|
|
156
151
|
>
|
|
157
|
-
{ SHORTCUTS.map( (
|
|
152
|
+
{ SHORTCUTS.map( ( shortcut, index ) => (
|
|
158
153
|
<li
|
|
159
154
|
key={ index }
|
|
160
155
|
className="media-editor-keyboard-shortcuts-modal__shortcut"
|
|
161
156
|
>
|
|
162
157
|
<span className="media-editor-keyboard-shortcuts-modal__shortcut-description">
|
|
163
|
-
{ description }
|
|
158
|
+
{ shortcut.description }
|
|
164
159
|
</span>
|
|
165
|
-
<KeyCombinationDisplay
|
|
166
|
-
keyCombination={ keyCombination }
|
|
167
|
-
/>
|
|
160
|
+
<KeyCombinationDisplay { ...shortcut } />
|
|
168
161
|
</li>
|
|
169
162
|
) ) }
|
|
170
163
|
</ul>
|