@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
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,39 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 0.24.0 (2026-12-02)
|
|
6
|
+
|
|
7
|
+
### Enhancements
|
|
8
|
+
|
|
9
|
+
- `MediaEditor` builds its sidebar tabs from mounted `MediaEditorPanel` components and mounts plugins registered with `registerPlugin` in the `media-editor` scope inside the editor's session provider. Core's Crop and Details are two such panels. A panel's content renders in the panel's own React tree, a panel that throws keeps the failure inside its tab, and common mistakes warn in development ([#84664](https://github.com/WordPress/gutenberg/pull/84664)).
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
- `MediaEditor`: Ignore keyboard shortcuts and Escape-to-close handling during IME composition ([#87354](https://github.com/WordPress/gutenberg/pull/87354)).
|
|
14
|
+
- Expose readable text for shortcut keycaps, including arrow groups and the Plus and Minus zoom keys ([#85490](https://github.com/WordPress/gutenberg/pull/85490)).
|
|
15
|
+
|
|
16
|
+
### Internal
|
|
17
|
+
|
|
18
|
+
- Add `@wordpress/plugins`, `@wordpress/react-inert-value` and `@wordpress/warning` as dependencies ([#84664](https://github.com/WordPress/gutenberg/pull/84664)).
|
|
19
|
+
|
|
20
|
+
## 0.23.0 (2026-11-18)
|
|
21
|
+
|
|
22
|
+
### Enhancements
|
|
23
|
+
|
|
24
|
+
- `MediaEditor.MoreMenu` takes `actions` and `item` props, and lists the actions eligible for the item, such as "Permanently delete". It now also shows for media other than images when it has actions ([#86349](https://github.com/WordPress/gutenberg/pull/86349)).
|
|
25
|
+
- Show the shape of each aspect ratio in the aspect ratio dropdown of the crop panel and in the aspect ratio menu used on narrow screens ([#86348](https://github.com/WordPress/gutenberg/pull/86348)).
|
|
26
|
+
- `MediaPreview` shows media without a preview, such as a zip file, with its filename, file type and size, and Download and Copy URL buttons. Its empty and error states also use `EmptyState` from `@wordpress/ui` ([#86490](https://github.com/WordPress/gutenberg/pull/86490)).
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
- Keyboard shortcuts modal: Show key combinations left to right on right-to-left pages ([#86606](https://github.com/WordPress/gutenberg/pull/86606)).
|
|
31
|
+
- Keep the fine-rotation ruler's ticks and labels visible when the browser forces dark colors ([#86402](https://github.com/WordPress/gutenberg/pull/86402)).
|
|
32
|
+
|
|
33
|
+
### Internal
|
|
34
|
+
|
|
35
|
+
- Update the Storybook development dependencies to 10.6.6 ([#86507](https://github.com/WordPress/gutenberg/pull/86507)).
|
|
36
|
+
- Use the image cropper from the new `@wordpress/image-editor` package ([#86223](https://github.com/WordPress/gutenberg/pull/86223)).
|
|
37
|
+
|
|
5
38
|
## 0.22.0 (2026-11-04)
|
|
6
39
|
|
|
7
40
|
### Enhancements
|
|
@@ -9,6 +42,7 @@
|
|
|
9
42
|
- Use the design system focus ring for the rotation ruler ([#85535](https://github.com/WordPress/gutenberg/pull/85535)).
|
|
10
43
|
- Animate the details/crop sidebar when it opens or closes beside the canvas ([#85889](https://github.com/WordPress/gutenberg/pull/85889)).
|
|
11
44
|
- `MediaPreview` shows an inline preview of PDF files when the browser has a built-in PDF viewer, and falls back to the file info otherwise ([#86002](https://github.com/WordPress/gutenberg/pull/86002)).
|
|
45
|
+
- Add an `onEditOriginal` prop to `MediaEditor`. When set, the history menu reads "Edit original" and hands the original's id to the caller instead of loading it into the cropper, so a frame can open it on its own ([#86281](https://github.com/WordPress/gutenberg/pull/86281)).
|
|
12
46
|
|
|
13
47
|
### Bug Fixes
|
|
14
48
|
|
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -25,9 +27,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
27
|
enumerable: true
|
|
26
28
|
}) : target, mod));
|
|
27
29
|
let clsx = require("clsx");
|
|
28
|
-
clsx = __toESM(clsx);
|
|
29
30
|
let _wordpress_components = require("@wordpress/components");
|
|
30
31
|
let _wordpress_ui = require("@wordpress/ui");
|
|
32
|
+
let _wordpress_plugins = require("@wordpress/plugins");
|
|
31
33
|
let _wordpress_compose = require("@wordpress/compose");
|
|
32
34
|
let _wordpress_data = require("@wordpress/data");
|
|
33
35
|
let _wordpress_core_data = require("@wordpress/core-data");
|
|
@@ -37,39 +39,45 @@ let _wordpress_i18n = require("@wordpress/i18n");
|
|
|
37
39
|
let _wordpress_icons = require("@wordpress/icons");
|
|
38
40
|
let _wordpress_keycodes = require("@wordpress/keycodes");
|
|
39
41
|
let _wordpress_notices = require("@wordpress/notices");
|
|
42
|
+
let _wordpress_react_inert_value = require("@wordpress/react-inert-value");
|
|
40
43
|
let ___media_editor_provider_index_tsx = require("../media-editor-provider/index.cjs");
|
|
41
44
|
let ___media_preview_index_tsx = require("../media-preview/index.cjs");
|
|
42
|
-
___media_preview_index_tsx = __toESM(___media_preview_index_tsx);
|
|
43
45
|
let ___media_editor_canvas_index_tsx = require("../media-editor-canvas/index.cjs");
|
|
44
|
-
___media_editor_canvas_index_tsx = __toESM(___media_editor_canvas_index_tsx);
|
|
45
46
|
let ___media_editor_fine_rotation_index_tsx = require("../media-editor-fine-rotation/index.cjs");
|
|
46
|
-
___media_editor_fine_rotation_index_tsx = __toESM(___media_editor_fine_rotation_index_tsx);
|
|
47
47
|
let ___media_editor_crop_panel_index_tsx = require("../media-editor-crop-panel/index.cjs");
|
|
48
|
-
___media_editor_crop_panel_index_tsx = __toESM(___media_editor_crop_panel_index_tsx);
|
|
49
48
|
let ___media_editor_image_controls_index_tsx = require("../media-editor-image-controls/index.cjs");
|
|
50
|
-
___media_editor_image_controls_index_tsx = __toESM(___media_editor_image_controls_index_tsx);
|
|
51
49
|
let ___media_form_index_tsx = require("../media-form/index.cjs");
|
|
52
|
-
|
|
50
|
+
let ___media_editor_panel_index_tsx = require("../media-editor-panel/index.cjs");
|
|
53
51
|
let ______utils_index_ts = require("../../utils/index.cjs");
|
|
54
52
|
let ______state_index_ts = require("../../state/index.cjs");
|
|
55
53
|
let ______hooks_use_crop_gesture_handlers_ts = require("../../hooks/use-crop-gesture-handlers.cjs");
|
|
56
54
|
let ___media_editor_keyboard_shortcuts_modal_index_tsx = require("../media-editor-keyboard-shortcuts-modal/index.cjs");
|
|
57
|
-
___media_editor_keyboard_shortcuts_modal_index_tsx = __toESM(___media_editor_keyboard_shortcuts_modal_index_tsx);
|
|
58
55
|
let __use_save_media_editor_ts = require("./use-save-media-editor.cjs");
|
|
59
56
|
let __use_crop_options_ts = require("./use-crop-options.cjs");
|
|
60
57
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
58
|
+
clsx = __toESM(clsx);
|
|
59
|
+
___media_preview_index_tsx = __toESM(___media_preview_index_tsx);
|
|
60
|
+
___media_editor_canvas_index_tsx = __toESM(___media_editor_canvas_index_tsx);
|
|
61
|
+
___media_editor_fine_rotation_index_tsx = __toESM(___media_editor_fine_rotation_index_tsx);
|
|
62
|
+
___media_editor_crop_panel_index_tsx = __toESM(___media_editor_crop_panel_index_tsx);
|
|
63
|
+
___media_editor_image_controls_index_tsx = __toESM(___media_editor_image_controls_index_tsx);
|
|
64
|
+
___media_form_index_tsx = __toESM(___media_form_index_tsx);
|
|
65
|
+
___media_editor_panel_index_tsx = __toESM(___media_editor_panel_index_tsx);
|
|
66
|
+
___media_editor_keyboard_shortcuts_modal_index_tsx = __toESM(___media_editor_keyboard_shortcuts_modal_index_tsx);
|
|
61
67
|
// packages/media-editor/src/components/media-editor/index.tsx
|
|
62
68
|
const ATTACHMENT_EMBED_QUERY = { _embed: "author,wp:attached-to" };
|
|
63
69
|
const PLACEMENT_CONTROL_IDLE_MS = 300;
|
|
64
70
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
71
|
+
* The Details panel's id. Every media type has this panel, so the sidebar
|
|
72
|
+
* shows it when the requested panel doesn't exist.
|
|
73
|
+
*
|
|
74
|
+
* The sidebar stores the open panel's id, so adding a panel only needs a new
|
|
75
|
+
* id and a new tab.
|
|
69
76
|
*/
|
|
70
|
-
const DETAILS_PANEL = "details";
|
|
77
|
+
const DETAILS_PANEL = "core/details";
|
|
71
78
|
/** Identifier for the crop panel. Images only; other media has nothing to crop. */
|
|
72
|
-
const CROP_PANEL = "crop";
|
|
79
|
+
const CROP_PANEL = "core/crop";
|
|
80
|
+
const CROP_MEDIA_TYPES = ["image"];
|
|
73
81
|
const SIDEBAR_ANIMATION_DURATION = .3;
|
|
74
82
|
const sidebarVariants = {
|
|
75
83
|
open: { width: "auto" },
|
|
@@ -103,6 +111,7 @@ function MediaEditorSidebar({ tabs, activeTab, onSelectTab, disabled = false })
|
|
|
103
111
|
value: tab.id,
|
|
104
112
|
tabIndex: -1,
|
|
105
113
|
className: "media-editor__panel",
|
|
114
|
+
inert: (0, _wordpress_react_inert_value.inertValue)(disabled),
|
|
106
115
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Stack, {
|
|
107
116
|
direction: "column",
|
|
108
117
|
gap: "lg",
|
|
@@ -125,6 +134,16 @@ function useMediaEditorFrameContext() {
|
|
|
125
134
|
if (!context) throw new Error("useMediaEditorFrameContext must be used within MediaEditor");
|
|
126
135
|
return context;
|
|
127
136
|
}
|
|
137
|
+
function CropPanelContent({ disabled }) {
|
|
138
|
+
const { aspectRatioPresets } = useMediaEditorFrameContext();
|
|
139
|
+
const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = (0, __use_crop_options_ts.useCropOptions)({ aspectRatioPresets });
|
|
140
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_crop_panel_index_tsx.default, {
|
|
141
|
+
aspectRatioValue,
|
|
142
|
+
onAspectRatioChange: setAspectRatioValue,
|
|
143
|
+
aspectRatioOptions,
|
|
144
|
+
disabled
|
|
145
|
+
});
|
|
146
|
+
}
|
|
128
147
|
function PanelToggle() {
|
|
129
148
|
const { isWide, activePanel, onTogglePanel } = useMediaEditorFrameContext();
|
|
130
149
|
const isPanelOpen = !!activePanel;
|
|
@@ -137,24 +156,71 @@ function PanelToggle() {
|
|
|
137
156
|
onClick: onTogglePanel
|
|
138
157
|
});
|
|
139
158
|
}
|
|
140
|
-
function
|
|
141
|
-
|
|
159
|
+
function getActionLabel(action, items) {
|
|
160
|
+
return typeof action.label === "string" ? action.label : action.label(items);
|
|
161
|
+
}
|
|
162
|
+
function MediaActionModal({ action, items, closeModal }) {
|
|
163
|
+
const header = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
|
|
164
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Modal, {
|
|
165
|
+
title: header || getActionLabel(action, items),
|
|
166
|
+
__experimentalHideHeader: !!action.hideModalHeader,
|
|
167
|
+
onRequestClose: closeModal,
|
|
168
|
+
focusOnMount: action.modalFocusOnMount ?? true,
|
|
169
|
+
size: action.modalSize || "medium",
|
|
170
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(action.RenderModal, {
|
|
171
|
+
items,
|
|
172
|
+
closeModal
|
|
173
|
+
})
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
function MoreMenu({ actions = [], item }) {
|
|
177
|
+
const { isImage, isSaving } = useMediaEditorFrameContext();
|
|
178
|
+
const registry = (0, _wordpress_data.useRegistry)();
|
|
142
179
|
const [isShortcutsModalOpen, setIsShortcutsModalOpen] = (0, _wordpress_element.useState)(false);
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
icon: _wordpress_icons.
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
180
|
+
const [activeModalAction, setActiveModalAction] = (0, _wordpress_element.useState)(null);
|
|
181
|
+
const items = item ? [item] : [];
|
|
182
|
+
const eligibleActions = (0, _wordpress_element.useMemo)(() => item ? actions.filter((action) => !action.isEligible || action.isEligible(item)) : [], [actions, item]);
|
|
183
|
+
if (!isImage && !eligibleActions.length) return null;
|
|
184
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
185
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.DropdownMenu, {
|
|
186
|
+
icon: _wordpress_icons.moreVertical,
|
|
187
|
+
label: (0, _wordpress_i18n.__)("More options"),
|
|
188
|
+
toggleProps: { size: "compact" },
|
|
189
|
+
children: ({ onClose: closeMenu }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [isImage && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuGroup, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuItem, {
|
|
190
|
+
icon: _wordpress_icons.keyboard,
|
|
191
|
+
iconPosition: "left",
|
|
192
|
+
onClick: () => {
|
|
193
|
+
setIsShortcutsModalOpen(true);
|
|
194
|
+
closeMenu();
|
|
195
|
+
},
|
|
196
|
+
children: (0, _wordpress_i18n.__)("Keyboard shortcuts")
|
|
197
|
+
}) }), !!eligibleActions.length && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuGroup, { children: eligibleActions.map((action) => {
|
|
198
|
+
const label = getActionLabel(action, items);
|
|
199
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuItem, {
|
|
200
|
+
disabled: isSaving || action.disabled,
|
|
201
|
+
onClick: () => {
|
|
202
|
+
closeMenu();
|
|
203
|
+
if ("RenderModal" in action) {
|
|
204
|
+
setActiveModalAction(action);
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
action.callback(items, { registry });
|
|
208
|
+
},
|
|
209
|
+
children: "RenderModal" in action ? (0, _wordpress_i18n.sprintf)(
|
|
210
|
+
/** translators: %s: Action label. Use the ellipsis and spacing appropriate for your language. */
|
|
211
|
+
(0, _wordpress_i18n._x)("%s…", "menu item requiring further input"),
|
|
212
|
+
label
|
|
213
|
+
) : label
|
|
214
|
+
}, action.id);
|
|
215
|
+
}) })] })
|
|
216
|
+
}),
|
|
217
|
+
isShortcutsModalOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_keyboard_shortcuts_modal_index_tsx.default, { onClose: () => setIsShortcutsModalOpen(false) }),
|
|
218
|
+
activeModalAction && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaActionModal, {
|
|
219
|
+
action: activeModalAction,
|
|
220
|
+
items,
|
|
221
|
+
closeModal: () => setActiveModalAction(null)
|
|
222
|
+
})
|
|
223
|
+
] });
|
|
158
224
|
}
|
|
159
225
|
function HeaderActions({ showCloseButton = false }) {
|
|
160
226
|
const { isSaving, onCancel } = useMediaEditorFrameContext();
|
|
@@ -178,7 +244,7 @@ function HeaderActions({ showCloseButton = false }) {
|
|
|
178
244
|
});
|
|
179
245
|
}
|
|
180
246
|
function HistoryActions() {
|
|
181
|
-
const { isImage, isSaving, isUndoRedoDisabled, isWide, activePanel, canRestoreOriginal, isSourceReplaced, onRestoreOriginal } = useMediaEditorFrameContext();
|
|
247
|
+
const { isImage, isSaving, isUndoRedoDisabled, isWide, activePanel, canRestoreOriginal, isSourceReplaced, opensOriginal, onRestoreOriginal } = useMediaEditorFrameContext();
|
|
182
248
|
const { reset, isDirty, hasUndo, hasRedo, undo: undoCrop, redo: redoCrop } = (0, ______state_index_ts.useMediaEditor)();
|
|
183
249
|
if (!isImage || !isWide && !!activePanel) return null;
|
|
184
250
|
const handleUndo = () => {
|
|
@@ -241,7 +307,7 @@ function HistoryActions() {
|
|
|
241
307
|
onRestoreOriginal();
|
|
242
308
|
closeMenu();
|
|
243
309
|
},
|
|
244
|
-
children: (0, _wordpress_i18n.__)("Restore original")
|
|
310
|
+
children: opensOriginal ? (0, _wordpress_i18n.__)("Edit original") : (0, _wordpress_i18n.__)("Restore original")
|
|
245
311
|
}) })] })
|
|
246
312
|
})
|
|
247
313
|
]
|
|
@@ -275,7 +341,7 @@ function SaveActions({ size = "default" }) {
|
|
|
275
341
|
})]
|
|
276
342
|
});
|
|
277
343
|
}
|
|
278
|
-
function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose, onSaved, renderFrame, noticesClassName = "media-editor__snackbar", noticesPortalElement, shouldCloseOnEsc = false }) {
|
|
344
|
+
function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose, onSaved, onEditOriginal, renderFrame, noticesClassName = "media-editor__snackbar", noticesPortalElement, shouldCloseOnEsc = false, defaultPanel = DETAILS_PANEL }) {
|
|
279
345
|
const session = (0, ______state_index_ts.useMediaEditor)();
|
|
280
346
|
const isWide = (0, _wordpress_compose.useViewportMatch)("small");
|
|
281
347
|
const sidebarTransition = {
|
|
@@ -293,7 +359,17 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
|
|
|
293
359
|
const layout = isWide ? "wide" : "narrow";
|
|
294
360
|
const sourceMedia = (0, _wordpress_data.useSelect)((select) => select(_wordpress_core_data.store).getEntityRecord("postType", "attachment", id), [id]);
|
|
295
361
|
const { clearEntityRecordEdits, editEntityRecord, invalidateResolution } = (0, _wordpress_data.useDispatch)(_wordpress_core_data.store);
|
|
296
|
-
const { removeAllNotices } = (0, _wordpress_data.useDispatch)(_wordpress_notices.store);
|
|
362
|
+
const { createErrorNotice, removeAllNotices } = (0, _wordpress_data.useDispatch)(_wordpress_notices.store);
|
|
363
|
+
const handlePluginError = (0, _wordpress_element.useCallback)((name) => {
|
|
364
|
+
createErrorNotice((0, _wordpress_i18n.sprintf)(
|
|
365
|
+
/** translators: %s: plugin name */
|
|
366
|
+
(0, _wordpress_i18n.__)("The \"%s\" plugin has encountered an error and cannot be rendered."),
|
|
367
|
+
name
|
|
368
|
+
), {
|
|
369
|
+
type: "snackbar",
|
|
370
|
+
context: __use_save_media_editor_ts.MEDIA_EDITOR_NOTICES_CONTEXT
|
|
371
|
+
});
|
|
372
|
+
}, [createErrorNotice]);
|
|
297
373
|
const [isDiscardDialogOpen, setIsDiscardDialogOpen] = (0, _wordpress_element.useState)(false);
|
|
298
374
|
const [isPlacementActive, setIsPlacementActive] = (0, _wordpress_element.useState)(false);
|
|
299
375
|
const [isCanvasGestureActive, setIsCanvasGestureActive] = (0, _wordpress_element.useState)(false);
|
|
@@ -353,12 +429,21 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
|
|
|
353
429
|
}, [activeId, invalidateResolution]);
|
|
354
430
|
const handleRestoreOriginal = (0, _wordpress_element.useCallback)(() => {
|
|
355
431
|
clearEntityRecordEdits("postType", "attachment", id);
|
|
432
|
+
if (onEditOriginal && originalId) {
|
|
433
|
+
onEditOriginal(originalId);
|
|
434
|
+
return;
|
|
435
|
+
}
|
|
356
436
|
setIsSourceReplaced(true);
|
|
357
|
-
}, [
|
|
437
|
+
}, [
|
|
438
|
+
clearEntityRecordEdits,
|
|
439
|
+
id,
|
|
440
|
+
onEditOriginal,
|
|
441
|
+
originalId
|
|
442
|
+
]);
|
|
358
443
|
const hasChanges = session.hasOutputEdits || hasEdits || isSourceReplaced;
|
|
359
444
|
const mediaType = (0, ______utils_index_ts.getMediaTypeFromMimeType)(media?.mime_type).type;
|
|
360
445
|
const isImage = !!media && mediaType === "image";
|
|
361
|
-
const currentTab = chosenTab ?? (isWide
|
|
446
|
+
const currentTab = chosenTab ?? (isWide ? defaultPanel : DETAILS_PANEL);
|
|
362
447
|
let activePanel = chosenPanel;
|
|
363
448
|
if (activePanel === void 0) activePanel = isWide ? currentTab : null;
|
|
364
449
|
const selectPanel = (0, _wordpress_element.useCallback)((panel) => {
|
|
@@ -368,7 +453,6 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
|
|
|
368
453
|
const togglePanel = (0, _wordpress_element.useCallback)(() => {
|
|
369
454
|
setChosenPanel(activePanel ? null : currentTab);
|
|
370
455
|
}, [activePanel, currentTab]);
|
|
371
|
-
const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = (0, __use_crop_options_ts.useCropOptions)({ aspectRatioPresets });
|
|
372
456
|
const { isSaving, save: saveMediaEditor } = (0, __use_save_media_editor_ts.useSaveMediaEditor)({
|
|
373
457
|
session,
|
|
374
458
|
id,
|
|
@@ -395,7 +479,7 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
|
|
|
395
479
|
}
|
|
396
480
|
discardAndClose();
|
|
397
481
|
};
|
|
398
|
-
const handleKeyDown = (event) => {
|
|
482
|
+
const handleKeyDown = (0, _wordpress_keycodes.withIgnoreIMEEvents)((event) => {
|
|
399
483
|
const isUndoShortcut = _wordpress_keycodes.isKeyboardEvent.primary(event, "z");
|
|
400
484
|
const isRedoShortcut = _wordpress_keycodes.isKeyboardEvent.primaryShift(event, "z") || !(0, _wordpress_keycodes.isAppleOS)() && _wordpress_keycodes.isKeyboardEvent.primary(event, "y");
|
|
401
485
|
if ((isUndoShortcut || isRedoShortcut) && isImage) {
|
|
@@ -418,7 +502,7 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
|
|
|
418
502
|
setIsDiscardDialogOpen(true);
|
|
419
503
|
}
|
|
420
504
|
}
|
|
421
|
-
};
|
|
505
|
+
});
|
|
422
506
|
const snackbar = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_notices.SnackbarNotices, {
|
|
423
507
|
className: noticesClassName,
|
|
424
508
|
context: __use_save_media_editor_ts.MEDIA_EDITOR_NOTICES_CONTEXT
|
|
@@ -428,91 +512,78 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
|
|
|
428
512
|
aspectRatioPresets,
|
|
429
513
|
disabled: isSaving
|
|
430
514
|
}) : null;
|
|
431
|
-
const
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
disabled: isSaving
|
|
515
|
+
const { panels, contextValue: panelsContextValue } = (0, ___media_editor_panel_index_tsx.useMediaEditorPanels)();
|
|
516
|
+
const availableTabs = panels.filter((panel) => !panel.mediaTypes || panel.mediaTypes.includes(mediaType)).map((panel) => ({
|
|
517
|
+
id: panel.name,
|
|
518
|
+
title: panel.title,
|
|
519
|
+
render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Slot, {
|
|
520
|
+
bubblesVirtually: true,
|
|
521
|
+
name: (0, ___media_editor_panel_index_tsx.getPanelSlotName)(panel.name),
|
|
522
|
+
fillProps: { disabled: isSaving }
|
|
439
523
|
})
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_form_index_tsx.default, {})
|
|
444
|
-
}];
|
|
524
|
+
}));
|
|
525
|
+
const defaultTab = availableTabs.find((tab) => tab.id === defaultPanel);
|
|
526
|
+
const tabs = defaultTab ? [defaultTab, ...availableTabs.filter((tab) => tab !== defaultTab)] : availableTabs;
|
|
445
527
|
const ruler = isImage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_fine_rotation_index_tsx.default, {
|
|
446
528
|
onPlacementControlInteraction: signalPlacementControlInteraction,
|
|
447
529
|
disabled: isSaving
|
|
448
530
|
}) : null;
|
|
449
|
-
const children = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
children: [
|
|
471
|
-
className: "media-editor__canvas-area",
|
|
472
|
-
children: isImage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_canvas_index_tsx.default, {
|
|
473
|
-
isPlacementActive,
|
|
474
|
-
onGestureStart: handleCanvasGestureStart,
|
|
475
|
-
onGestureEnd: handleCanvasGestureEnd,
|
|
476
|
-
disabled: isSaving
|
|
477
|
-
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_preview_index_tsx.default, {})
|
|
478
|
-
}), isImage && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
479
|
-
className: "media-editor__canvas-toolbar",
|
|
480
|
-
children: [ruler, imageControls]
|
|
481
|
-
})]
|
|
482
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__unstableAnimatePresence, {
|
|
483
|
-
initial: false,
|
|
484
|
-
custom: sidebarTransition,
|
|
485
|
-
children: !!activePanel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__unstableMotion.div, {
|
|
486
|
-
className: "media-editor__sidebar-container",
|
|
487
|
-
variants: sidebarVariants,
|
|
488
|
-
initial: "closed",
|
|
489
|
-
animate: "open",
|
|
490
|
-
exit: "closed",
|
|
491
|
-
transition: sidebarTransition,
|
|
492
|
-
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaEditorSidebar, {
|
|
493
|
-
tabs,
|
|
494
|
-
activeTab: tabs.some((tab) => tab.id === activePanel) ? activePanel : DETAILS_PANEL,
|
|
495
|
-
onSelectTab: selectPanel,
|
|
496
|
-
disabled: isSaving
|
|
497
|
-
})
|
|
498
|
-
})
|
|
531
|
+
const children = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
532
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
533
|
+
className: "media-editor",
|
|
534
|
+
children: !media ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
535
|
+
className: "media-editor__loading",
|
|
536
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Spinner, {})
|
|
537
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
538
|
+
className: (0, clsx.default)("media-editor__body", { "has-panel-open": !!activePanel }),
|
|
539
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_admin_ui.NavigableRegion, {
|
|
540
|
+
className: "media-editor__content",
|
|
541
|
+
ariaLabel: isImage ? (0, _wordpress_i18n.__)("Image editor") : (0, _wordpress_i18n.__)("Media preview"),
|
|
542
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
543
|
+
className: "media-editor__canvas-area",
|
|
544
|
+
children: isImage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_canvas_index_tsx.default, {
|
|
545
|
+
isPlacementActive,
|
|
546
|
+
onGestureStart: handleCanvasGestureStart,
|
|
547
|
+
onGestureEnd: handleCanvasGestureEnd,
|
|
548
|
+
disabled: isSaving
|
|
549
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_preview_index_tsx.default, {})
|
|
550
|
+
}), isImage && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
551
|
+
className: "media-editor__canvas-toolbar",
|
|
552
|
+
children: [ruler, imageControls]
|
|
499
553
|
})]
|
|
500
|
-
})
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
554
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__unstableAnimatePresence, {
|
|
555
|
+
initial: false,
|
|
556
|
+
custom: sidebarTransition,
|
|
557
|
+
children: !!activePanel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__unstableMotion.div, {
|
|
558
|
+
className: "media-editor__sidebar-container",
|
|
559
|
+
variants: sidebarVariants,
|
|
560
|
+
initial: "closed",
|
|
561
|
+
animate: "open",
|
|
562
|
+
exit: "closed",
|
|
563
|
+
transition: sidebarTransition,
|
|
564
|
+
children: tabs.length > 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaEditorSidebar, {
|
|
565
|
+
tabs,
|
|
566
|
+
activeTab: tabs.some((tab) => tab.id === activePanel) ? activePanel : DETAILS_PANEL,
|
|
567
|
+
onSelectTab: selectPanel,
|
|
568
|
+
disabled: isSaving
|
|
569
|
+
})
|
|
570
|
+
})
|
|
571
|
+
})]
|
|
572
|
+
})
|
|
573
|
+
}),
|
|
574
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__experimentalConfirmDialog, {
|
|
575
|
+
isOpen: isDiscardDialogOpen,
|
|
576
|
+
confirmButtonText: (0, _wordpress_i18n.__)("Discard"),
|
|
577
|
+
cancelButtonText: (0, _wordpress_i18n.__)("Keep editing"),
|
|
578
|
+
onCancel: () => setIsDiscardDialogOpen(false),
|
|
579
|
+
onConfirm: () => {
|
|
580
|
+
setIsDiscardDialogOpen(false);
|
|
581
|
+
discardAndClose();
|
|
582
|
+
},
|
|
583
|
+
children: (0, _wordpress_i18n.__)("Are you sure you want to discard your unsaved changes?")
|
|
584
|
+
}),
|
|
585
|
+
noticesPortalElement ? (0, _wordpress_element.createPortal)(snackbar, noticesPortalElement) : snackbar
|
|
586
|
+
] });
|
|
516
587
|
const contextValue = {
|
|
517
588
|
isImage,
|
|
518
589
|
isSaving,
|
|
@@ -527,12 +598,44 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
|
|
|
527
598
|
onSave: saveMediaEditor,
|
|
528
599
|
canRestoreOriginal,
|
|
529
600
|
isSourceReplaced,
|
|
601
|
+
opensOriginal: !!onEditOriginal,
|
|
530
602
|
onRestoreOriginal: handleRestoreOriginal
|
|
531
603
|
};
|
|
532
604
|
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaEditorFrameContext.Provider, {
|
|
533
605
|
value: contextValue,
|
|
534
606
|
children: renderFrame({
|
|
535
|
-
children,
|
|
607
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_provider_index_tsx.MediaEditorProvider, {
|
|
608
|
+
value: media ?? void 0,
|
|
609
|
+
onChange: handleChange,
|
|
610
|
+
settings: {
|
|
611
|
+
fields: isSaving ? fields.map((field) => ({
|
|
612
|
+
...field,
|
|
613
|
+
isDisabled: true
|
|
614
|
+
})) : fields,
|
|
615
|
+
form
|
|
616
|
+
},
|
|
617
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.SlotFillProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(___media_editor_panel_index_tsx.MediaEditorPanelsProvider, {
|
|
618
|
+
value: panelsContextValue,
|
|
619
|
+
children: [
|
|
620
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_panel_index_tsx.default, {
|
|
621
|
+
name: CROP_PANEL,
|
|
622
|
+
title: (0, _wordpress_i18n.__)("Crop"),
|
|
623
|
+
mediaTypes: CROP_MEDIA_TYPES,
|
|
624
|
+
children: ({ disabled }) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CropPanelContent, { disabled })
|
|
625
|
+
}),
|
|
626
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_panel_index_tsx.default, {
|
|
627
|
+
name: DETAILS_PANEL,
|
|
628
|
+
title: (0, _wordpress_i18n.__)("Details"),
|
|
629
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_form_index_tsx.default, {})
|
|
630
|
+
}),
|
|
631
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_plugins.PluginArea, {
|
|
632
|
+
scope: ___media_editor_panel_index_tsx.MEDIA_EDITOR_PLUGIN_SCOPE,
|
|
633
|
+
onError: handlePluginError
|
|
634
|
+
}),
|
|
635
|
+
children
|
|
636
|
+
]
|
|
637
|
+
}) })
|
|
638
|
+
}),
|
|
536
639
|
isImage,
|
|
537
640
|
layout,
|
|
538
641
|
onRequestClose: handleRequestClose,
|