@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
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
import clsx from "clsx";
|
|
2
|
-
import { Button, DropdownMenu, MenuGroup, MenuItem, Spinner, __experimentalConfirmDialog, __unstableAnimatePresence, __unstableMotion } from "@wordpress/components";
|
|
2
|
+
import { Button, DropdownMenu, MenuGroup, MenuItem, Modal, Slot, SlotFillProvider, Spinner, __experimentalConfirmDialog, __unstableAnimatePresence, __unstableMotion } from "@wordpress/components";
|
|
3
3
|
import { Stack, Tabs, VisuallyHidden } from "@wordpress/ui";
|
|
4
|
+
import { PluginArea } from "@wordpress/plugins";
|
|
4
5
|
import { useReducedMotion, useViewportMatch } from "@wordpress/compose";
|
|
5
|
-
import { useDispatch, useSelect } from "@wordpress/data";
|
|
6
|
+
import { useDispatch, useRegistry, useSelect } from "@wordpress/data";
|
|
6
7
|
import { store } from "@wordpress/core-data";
|
|
7
8
|
import { NavigableRegion } from "@wordpress/admin-ui";
|
|
8
|
-
import { createContext, createPortal, useCallback, useContext, useEffect, useRef, useState } from "@wordpress/element";
|
|
9
|
-
import { __ } from "@wordpress/i18n";
|
|
9
|
+
import { createContext, createPortal, useCallback, useContext, useEffect, useMemo, useRef, useState } from "@wordpress/element";
|
|
10
|
+
import { __, _x, sprintf } from "@wordpress/i18n";
|
|
10
11
|
import { backup, close, drawerRight, keyboard, moreVertical, redo, undo } from "@wordpress/icons";
|
|
11
|
-
import { displayShortcut, isAppleOS, isKeyboardEvent } from "@wordpress/keycodes";
|
|
12
|
+
import { displayShortcut, isAppleOS, isKeyboardEvent, withIgnoreIMEEvents } from "@wordpress/keycodes";
|
|
12
13
|
import { SnackbarNotices, store as store$1 } from "@wordpress/notices";
|
|
14
|
+
import { inertValue } from "@wordpress/react-inert-value";
|
|
13
15
|
import { MediaEditorProvider } from "../media-editor-provider/index.mjs";
|
|
14
16
|
import MediaPreview from "../media-preview/index.mjs";
|
|
15
17
|
import MediaEditorCanvas from "../media-editor-canvas/index.mjs";
|
|
@@ -17,6 +19,7 @@ import MediaEditorFineRotation from "../media-editor-fine-rotation/index.mjs";
|
|
|
17
19
|
import MediaEditorCropPanel from "../media-editor-crop-panel/index.mjs";
|
|
18
20
|
import MediaEditorImageControls from "../media-editor-image-controls/index.mjs";
|
|
19
21
|
import MediaForm from "../media-form/index.mjs";
|
|
22
|
+
import MediaEditorPanel, { MEDIA_EDITOR_PLUGIN_SCOPE, MediaEditorPanelsProvider, getPanelSlotName, useMediaEditorPanels } from "../media-editor-panel/index.mjs";
|
|
20
23
|
import { getMediaTypeFromMimeType } from "../../utils/index.mjs";
|
|
21
24
|
import { MediaEditorStateProvider, useMediaEditor } from "../../state/index.mjs";
|
|
22
25
|
import { CROP_CONTROL_ATTR } from "../../hooks/use-crop-gesture-handlers.mjs";
|
|
@@ -28,14 +31,16 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
28
31
|
const ATTACHMENT_EMBED_QUERY = { _embed: "author,wp:attached-to" };
|
|
29
32
|
const PLACEMENT_CONTROL_IDLE_MS = 300;
|
|
30
33
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
34
|
+
* The Details panel's id. Every media type has this panel, so the sidebar
|
|
35
|
+
* shows it when the requested panel doesn't exist.
|
|
36
|
+
*
|
|
37
|
+
* The sidebar stores the open panel's id, so adding a panel only needs a new
|
|
38
|
+
* id and a new tab.
|
|
35
39
|
*/
|
|
36
|
-
const DETAILS_PANEL = "details";
|
|
40
|
+
const DETAILS_PANEL = "core/details";
|
|
37
41
|
/** Identifier for the crop panel. Images only; other media has nothing to crop. */
|
|
38
|
-
const CROP_PANEL = "crop";
|
|
42
|
+
const CROP_PANEL = "core/crop";
|
|
43
|
+
const CROP_MEDIA_TYPES = ["image"];
|
|
39
44
|
const SIDEBAR_ANIMATION_DURATION = .3;
|
|
40
45
|
const sidebarVariants = {
|
|
41
46
|
open: { width: "auto" },
|
|
@@ -69,6 +74,7 @@ function MediaEditorSidebar({ tabs, activeTab, onSelectTab, disabled = false })
|
|
|
69
74
|
value: tab.id,
|
|
70
75
|
tabIndex: -1,
|
|
71
76
|
className: "media-editor__panel",
|
|
77
|
+
inert: inertValue(disabled),
|
|
72
78
|
children: /* @__PURE__ */ jsx(Stack, {
|
|
73
79
|
direction: "column",
|
|
74
80
|
gap: "lg",
|
|
@@ -91,6 +97,16 @@ function useMediaEditorFrameContext() {
|
|
|
91
97
|
if (!context) throw new Error("useMediaEditorFrameContext must be used within MediaEditor");
|
|
92
98
|
return context;
|
|
93
99
|
}
|
|
100
|
+
function CropPanelContent({ disabled }) {
|
|
101
|
+
const { aspectRatioPresets } = useMediaEditorFrameContext();
|
|
102
|
+
const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = useCropOptions({ aspectRatioPresets });
|
|
103
|
+
return /* @__PURE__ */ jsx(MediaEditorCropPanel, {
|
|
104
|
+
aspectRatioValue,
|
|
105
|
+
onAspectRatioChange: setAspectRatioValue,
|
|
106
|
+
aspectRatioOptions,
|
|
107
|
+
disabled
|
|
108
|
+
});
|
|
109
|
+
}
|
|
94
110
|
function PanelToggle() {
|
|
95
111
|
const { isWide, activePanel, onTogglePanel } = useMediaEditorFrameContext();
|
|
96
112
|
const isPanelOpen = !!activePanel;
|
|
@@ -103,24 +119,71 @@ function PanelToggle() {
|
|
|
103
119
|
onClick: onTogglePanel
|
|
104
120
|
});
|
|
105
121
|
}
|
|
106
|
-
function
|
|
107
|
-
|
|
122
|
+
function getActionLabel(action, items) {
|
|
123
|
+
return typeof action.label === "string" ? action.label : action.label(items);
|
|
124
|
+
}
|
|
125
|
+
function MediaActionModal({ action, items, closeModal }) {
|
|
126
|
+
const header = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
|
|
127
|
+
return /* @__PURE__ */ jsx(Modal, {
|
|
128
|
+
title: header || getActionLabel(action, items),
|
|
129
|
+
__experimentalHideHeader: !!action.hideModalHeader,
|
|
130
|
+
onRequestClose: closeModal,
|
|
131
|
+
focusOnMount: action.modalFocusOnMount ?? true,
|
|
132
|
+
size: action.modalSize || "medium",
|
|
133
|
+
children: /* @__PURE__ */ jsx(action.RenderModal, {
|
|
134
|
+
items,
|
|
135
|
+
closeModal
|
|
136
|
+
})
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
function MoreMenu({ actions = [], item }) {
|
|
140
|
+
const { isImage, isSaving } = useMediaEditorFrameContext();
|
|
141
|
+
const registry = useRegistry();
|
|
108
142
|
const [isShortcutsModalOpen, setIsShortcutsModalOpen] = useState(false);
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
icon:
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
143
|
+
const [activeModalAction, setActiveModalAction] = useState(null);
|
|
144
|
+
const items = item ? [item] : [];
|
|
145
|
+
const eligibleActions = useMemo(() => item ? actions.filter((action) => !action.isEligible || action.isEligible(item)) : [], [actions, item]);
|
|
146
|
+
if (!isImage && !eligibleActions.length) return null;
|
|
147
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
148
|
+
/* @__PURE__ */ jsx(DropdownMenu, {
|
|
149
|
+
icon: moreVertical,
|
|
150
|
+
label: __("More options"),
|
|
151
|
+
toggleProps: { size: "compact" },
|
|
152
|
+
children: ({ onClose: closeMenu }) => /* @__PURE__ */ jsxs(Fragment, { children: [isImage && /* @__PURE__ */ jsx(MenuGroup, { children: /* @__PURE__ */ jsx(MenuItem, {
|
|
153
|
+
icon: keyboard,
|
|
154
|
+
iconPosition: "left",
|
|
155
|
+
onClick: () => {
|
|
156
|
+
setIsShortcutsModalOpen(true);
|
|
157
|
+
closeMenu();
|
|
158
|
+
},
|
|
159
|
+
children: __("Keyboard shortcuts")
|
|
160
|
+
}) }), !!eligibleActions.length && /* @__PURE__ */ jsx(MenuGroup, { children: eligibleActions.map((action) => {
|
|
161
|
+
const label = getActionLabel(action, items);
|
|
162
|
+
return /* @__PURE__ */ jsx(MenuItem, {
|
|
163
|
+
disabled: isSaving || action.disabled,
|
|
164
|
+
onClick: () => {
|
|
165
|
+
closeMenu();
|
|
166
|
+
if ("RenderModal" in action) {
|
|
167
|
+
setActiveModalAction(action);
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
action.callback(items, { registry });
|
|
171
|
+
},
|
|
172
|
+
children: "RenderModal" in action ? sprintf(
|
|
173
|
+
/** translators: %s: Action label. Use the ellipsis and spacing appropriate for your language. */
|
|
174
|
+
_x("%s…", "menu item requiring further input"),
|
|
175
|
+
label
|
|
176
|
+
) : label
|
|
177
|
+
}, action.id);
|
|
178
|
+
}) })] })
|
|
179
|
+
}),
|
|
180
|
+
isShortcutsModalOpen && /* @__PURE__ */ jsx(MediaEditorKeyboardShortcutsModal, { onClose: () => setIsShortcutsModalOpen(false) }),
|
|
181
|
+
activeModalAction && /* @__PURE__ */ jsx(MediaActionModal, {
|
|
182
|
+
action: activeModalAction,
|
|
183
|
+
items,
|
|
184
|
+
closeModal: () => setActiveModalAction(null)
|
|
185
|
+
})
|
|
186
|
+
] });
|
|
124
187
|
}
|
|
125
188
|
function HeaderActions({ showCloseButton = false }) {
|
|
126
189
|
const { isSaving, onCancel } = useMediaEditorFrameContext();
|
|
@@ -144,7 +207,7 @@ function HeaderActions({ showCloseButton = false }) {
|
|
|
144
207
|
});
|
|
145
208
|
}
|
|
146
209
|
function HistoryActions() {
|
|
147
|
-
const { isImage, isSaving, isUndoRedoDisabled, isWide, activePanel, canRestoreOriginal, isSourceReplaced, onRestoreOriginal } = useMediaEditorFrameContext();
|
|
210
|
+
const { isImage, isSaving, isUndoRedoDisabled, isWide, activePanel, canRestoreOriginal, isSourceReplaced, opensOriginal, onRestoreOriginal } = useMediaEditorFrameContext();
|
|
148
211
|
const { reset, isDirty, hasUndo, hasRedo, undo: undoCrop, redo: redoCrop } = useMediaEditor();
|
|
149
212
|
if (!isImage || !isWide && !!activePanel) return null;
|
|
150
213
|
const handleUndo = () => {
|
|
@@ -207,7 +270,7 @@ function HistoryActions() {
|
|
|
207
270
|
onRestoreOriginal();
|
|
208
271
|
closeMenu();
|
|
209
272
|
},
|
|
210
|
-
children: __("Restore original")
|
|
273
|
+
children: opensOriginal ? __("Edit original") : __("Restore original")
|
|
211
274
|
}) })] })
|
|
212
275
|
})
|
|
213
276
|
]
|
|
@@ -241,7 +304,7 @@ function SaveActions({ size = "default" }) {
|
|
|
241
304
|
})]
|
|
242
305
|
});
|
|
243
306
|
}
|
|
244
|
-
function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose, onSaved, renderFrame, noticesClassName = "media-editor__snackbar", noticesPortalElement, shouldCloseOnEsc = false }) {
|
|
307
|
+
function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose, onSaved, onEditOriginal, renderFrame, noticesClassName = "media-editor__snackbar", noticesPortalElement, shouldCloseOnEsc = false, defaultPanel = DETAILS_PANEL }) {
|
|
245
308
|
const session = useMediaEditor();
|
|
246
309
|
const isWide = useViewportMatch("small");
|
|
247
310
|
const sidebarTransition = {
|
|
@@ -259,7 +322,17 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
|
|
|
259
322
|
const layout = isWide ? "wide" : "narrow";
|
|
260
323
|
const sourceMedia = useSelect((select) => select(store).getEntityRecord("postType", "attachment", id), [id]);
|
|
261
324
|
const { clearEntityRecordEdits, editEntityRecord, invalidateResolution } = useDispatch(store);
|
|
262
|
-
const { removeAllNotices } = useDispatch(store$1);
|
|
325
|
+
const { createErrorNotice, removeAllNotices } = useDispatch(store$1);
|
|
326
|
+
const handlePluginError = useCallback((name) => {
|
|
327
|
+
createErrorNotice(sprintf(
|
|
328
|
+
/** translators: %s: plugin name */
|
|
329
|
+
__("The \"%s\" plugin has encountered an error and cannot be rendered."),
|
|
330
|
+
name
|
|
331
|
+
), {
|
|
332
|
+
type: "snackbar",
|
|
333
|
+
context: MEDIA_EDITOR_NOTICES_CONTEXT
|
|
334
|
+
});
|
|
335
|
+
}, [createErrorNotice]);
|
|
263
336
|
const [isDiscardDialogOpen, setIsDiscardDialogOpen] = useState(false);
|
|
264
337
|
const [isPlacementActive, setIsPlacementActive] = useState(false);
|
|
265
338
|
const [isCanvasGestureActive, setIsCanvasGestureActive] = useState(false);
|
|
@@ -319,12 +392,21 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
|
|
|
319
392
|
}, [activeId, invalidateResolution]);
|
|
320
393
|
const handleRestoreOriginal = useCallback(() => {
|
|
321
394
|
clearEntityRecordEdits("postType", "attachment", id);
|
|
395
|
+
if (onEditOriginal && originalId) {
|
|
396
|
+
onEditOriginal(originalId);
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
322
399
|
setIsSourceReplaced(true);
|
|
323
|
-
}, [
|
|
400
|
+
}, [
|
|
401
|
+
clearEntityRecordEdits,
|
|
402
|
+
id,
|
|
403
|
+
onEditOriginal,
|
|
404
|
+
originalId
|
|
405
|
+
]);
|
|
324
406
|
const hasChanges = session.hasOutputEdits || hasEdits || isSourceReplaced;
|
|
325
407
|
const mediaType = getMediaTypeFromMimeType(media?.mime_type).type;
|
|
326
408
|
const isImage = !!media && mediaType === "image";
|
|
327
|
-
const currentTab = chosenTab ?? (isWide
|
|
409
|
+
const currentTab = chosenTab ?? (isWide ? defaultPanel : DETAILS_PANEL);
|
|
328
410
|
let activePanel = chosenPanel;
|
|
329
411
|
if (activePanel === void 0) activePanel = isWide ? currentTab : null;
|
|
330
412
|
const selectPanel = useCallback((panel) => {
|
|
@@ -334,7 +416,6 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
|
|
|
334
416
|
const togglePanel = useCallback(() => {
|
|
335
417
|
setChosenPanel(activePanel ? null : currentTab);
|
|
336
418
|
}, [activePanel, currentTab]);
|
|
337
|
-
const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = useCropOptions({ aspectRatioPresets });
|
|
338
419
|
const { isSaving, save: saveMediaEditor } = useSaveMediaEditor({
|
|
339
420
|
session,
|
|
340
421
|
id,
|
|
@@ -361,7 +442,7 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
|
|
|
361
442
|
}
|
|
362
443
|
discardAndClose();
|
|
363
444
|
};
|
|
364
|
-
const handleKeyDown = (event) => {
|
|
445
|
+
const handleKeyDown = withIgnoreIMEEvents((event) => {
|
|
365
446
|
const isUndoShortcut = isKeyboardEvent.primary(event, "z");
|
|
366
447
|
const isRedoShortcut = isKeyboardEvent.primaryShift(event, "z") || !isAppleOS() && isKeyboardEvent.primary(event, "y");
|
|
367
448
|
if ((isUndoShortcut || isRedoShortcut) && isImage) {
|
|
@@ -384,7 +465,7 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
|
|
|
384
465
|
setIsDiscardDialogOpen(true);
|
|
385
466
|
}
|
|
386
467
|
}
|
|
387
|
-
};
|
|
468
|
+
});
|
|
388
469
|
const snackbar = /* @__PURE__ */ jsx(SnackbarNotices, {
|
|
389
470
|
className: noticesClassName,
|
|
390
471
|
context: MEDIA_EDITOR_NOTICES_CONTEXT
|
|
@@ -394,91 +475,78 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
|
|
|
394
475
|
aspectRatioPresets,
|
|
395
476
|
disabled: isSaving
|
|
396
477
|
}) : null;
|
|
397
|
-
const
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
disabled: isSaving
|
|
478
|
+
const { panels, contextValue: panelsContextValue } = useMediaEditorPanels();
|
|
479
|
+
const availableTabs = panels.filter((panel) => !panel.mediaTypes || panel.mediaTypes.includes(mediaType)).map((panel) => ({
|
|
480
|
+
id: panel.name,
|
|
481
|
+
title: panel.title,
|
|
482
|
+
render: () => /* @__PURE__ */ jsx(Slot, {
|
|
483
|
+
bubblesVirtually: true,
|
|
484
|
+
name: getPanelSlotName(panel.name),
|
|
485
|
+
fillProps: { disabled: isSaving }
|
|
405
486
|
})
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
render: () => /* @__PURE__ */ jsx(MediaForm, {})
|
|
410
|
-
}];
|
|
487
|
+
}));
|
|
488
|
+
const defaultTab = availableTabs.find((tab) => tab.id === defaultPanel);
|
|
489
|
+
const tabs = defaultTab ? [defaultTab, ...availableTabs.filter((tab) => tab !== defaultTab)] : availableTabs;
|
|
411
490
|
const ruler = isImage ? /* @__PURE__ */ jsx(MediaEditorFineRotation, {
|
|
412
491
|
onPlacementControlInteraction: signalPlacementControlInteraction,
|
|
413
492
|
disabled: isSaving
|
|
414
493
|
}) : null;
|
|
415
|
-
const children = /* @__PURE__ */ jsxs(
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
children: [
|
|
437
|
-
className: "media-editor__canvas-area",
|
|
438
|
-
children: isImage ? /* @__PURE__ */ jsx(MediaEditorCanvas, {
|
|
439
|
-
isPlacementActive,
|
|
440
|
-
onGestureStart: handleCanvasGestureStart,
|
|
441
|
-
onGestureEnd: handleCanvasGestureEnd,
|
|
442
|
-
disabled: isSaving
|
|
443
|
-
}) : /* @__PURE__ */ jsx(MediaPreview, {})
|
|
444
|
-
}), isImage && /* @__PURE__ */ jsxs("div", {
|
|
445
|
-
className: "media-editor__canvas-toolbar",
|
|
446
|
-
children: [ruler, imageControls]
|
|
447
|
-
})]
|
|
448
|
-
}), /* @__PURE__ */ jsx(__unstableAnimatePresence, {
|
|
449
|
-
initial: false,
|
|
450
|
-
custom: sidebarTransition,
|
|
451
|
-
children: !!activePanel && /* @__PURE__ */ jsx(__unstableMotion.div, {
|
|
452
|
-
className: "media-editor__sidebar-container",
|
|
453
|
-
variants: sidebarVariants,
|
|
454
|
-
initial: "closed",
|
|
455
|
-
animate: "open",
|
|
456
|
-
exit: "closed",
|
|
457
|
-
transition: sidebarTransition,
|
|
458
|
-
children: /* @__PURE__ */ jsx(MediaEditorSidebar, {
|
|
459
|
-
tabs,
|
|
460
|
-
activeTab: tabs.some((tab) => tab.id === activePanel) ? activePanel : DETAILS_PANEL,
|
|
461
|
-
onSelectTab: selectPanel,
|
|
462
|
-
disabled: isSaving
|
|
463
|
-
})
|
|
464
|
-
})
|
|
494
|
+
const children = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
495
|
+
/* @__PURE__ */ jsx("div", {
|
|
496
|
+
className: "media-editor",
|
|
497
|
+
children: !media ? /* @__PURE__ */ jsx("div", {
|
|
498
|
+
className: "media-editor__loading",
|
|
499
|
+
children: /* @__PURE__ */ jsx(Spinner, {})
|
|
500
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
501
|
+
className: clsx("media-editor__body", { "has-panel-open": !!activePanel }),
|
|
502
|
+
children: [/* @__PURE__ */ jsxs(NavigableRegion, {
|
|
503
|
+
className: "media-editor__content",
|
|
504
|
+
ariaLabel: isImage ? __("Image editor") : __("Media preview"),
|
|
505
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
506
|
+
className: "media-editor__canvas-area",
|
|
507
|
+
children: isImage ? /* @__PURE__ */ jsx(MediaEditorCanvas, {
|
|
508
|
+
isPlacementActive,
|
|
509
|
+
onGestureStart: handleCanvasGestureStart,
|
|
510
|
+
onGestureEnd: handleCanvasGestureEnd,
|
|
511
|
+
disabled: isSaving
|
|
512
|
+
}) : /* @__PURE__ */ jsx(MediaPreview, {})
|
|
513
|
+
}), isImage && /* @__PURE__ */ jsxs("div", {
|
|
514
|
+
className: "media-editor__canvas-toolbar",
|
|
515
|
+
children: [ruler, imageControls]
|
|
465
516
|
})]
|
|
466
|
-
})
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
517
|
+
}), /* @__PURE__ */ jsx(__unstableAnimatePresence, {
|
|
518
|
+
initial: false,
|
|
519
|
+
custom: sidebarTransition,
|
|
520
|
+
children: !!activePanel && /* @__PURE__ */ jsx(__unstableMotion.div, {
|
|
521
|
+
className: "media-editor__sidebar-container",
|
|
522
|
+
variants: sidebarVariants,
|
|
523
|
+
initial: "closed",
|
|
524
|
+
animate: "open",
|
|
525
|
+
exit: "closed",
|
|
526
|
+
transition: sidebarTransition,
|
|
527
|
+
children: tabs.length > 0 && /* @__PURE__ */ jsx(MediaEditorSidebar, {
|
|
528
|
+
tabs,
|
|
529
|
+
activeTab: tabs.some((tab) => tab.id === activePanel) ? activePanel : DETAILS_PANEL,
|
|
530
|
+
onSelectTab: selectPanel,
|
|
531
|
+
disabled: isSaving
|
|
532
|
+
})
|
|
533
|
+
})
|
|
534
|
+
})]
|
|
535
|
+
})
|
|
536
|
+
}),
|
|
537
|
+
/* @__PURE__ */ jsx(__experimentalConfirmDialog, {
|
|
538
|
+
isOpen: isDiscardDialogOpen,
|
|
539
|
+
confirmButtonText: __("Discard"),
|
|
540
|
+
cancelButtonText: __("Keep editing"),
|
|
541
|
+
onCancel: () => setIsDiscardDialogOpen(false),
|
|
542
|
+
onConfirm: () => {
|
|
543
|
+
setIsDiscardDialogOpen(false);
|
|
544
|
+
discardAndClose();
|
|
545
|
+
},
|
|
546
|
+
children: __("Are you sure you want to discard your unsaved changes?")
|
|
547
|
+
}),
|
|
548
|
+
noticesPortalElement ? createPortal(snackbar, noticesPortalElement) : snackbar
|
|
549
|
+
] });
|
|
482
550
|
const contextValue = {
|
|
483
551
|
isImage,
|
|
484
552
|
isSaving,
|
|
@@ -493,12 +561,44 @@ function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose
|
|
|
493
561
|
onSave: saveMediaEditor,
|
|
494
562
|
canRestoreOriginal,
|
|
495
563
|
isSourceReplaced,
|
|
564
|
+
opensOriginal: !!onEditOriginal,
|
|
496
565
|
onRestoreOriginal: handleRestoreOriginal
|
|
497
566
|
};
|
|
498
567
|
return /* @__PURE__ */ jsx(MediaEditorFrameContext.Provider, {
|
|
499
568
|
value: contextValue,
|
|
500
569
|
children: renderFrame({
|
|
501
|
-
children,
|
|
570
|
+
children: /* @__PURE__ */ jsx(MediaEditorProvider, {
|
|
571
|
+
value: media ?? void 0,
|
|
572
|
+
onChange: handleChange,
|
|
573
|
+
settings: {
|
|
574
|
+
fields: isSaving ? fields.map((field) => ({
|
|
575
|
+
...field,
|
|
576
|
+
isDisabled: true
|
|
577
|
+
})) : fields,
|
|
578
|
+
form
|
|
579
|
+
},
|
|
580
|
+
children: /* @__PURE__ */ jsx(SlotFillProvider, { children: /* @__PURE__ */ jsxs(MediaEditorPanelsProvider, {
|
|
581
|
+
value: panelsContextValue,
|
|
582
|
+
children: [
|
|
583
|
+
/* @__PURE__ */ jsx(MediaEditorPanel, {
|
|
584
|
+
name: CROP_PANEL,
|
|
585
|
+
title: __("Crop"),
|
|
586
|
+
mediaTypes: CROP_MEDIA_TYPES,
|
|
587
|
+
children: ({ disabled }) => /* @__PURE__ */ jsx(CropPanelContent, { disabled })
|
|
588
|
+
}),
|
|
589
|
+
/* @__PURE__ */ jsx(MediaEditorPanel, {
|
|
590
|
+
name: DETAILS_PANEL,
|
|
591
|
+
title: __("Details"),
|
|
592
|
+
children: /* @__PURE__ */ jsx(MediaForm, {})
|
|
593
|
+
}),
|
|
594
|
+
/* @__PURE__ */ jsx(PluginArea, {
|
|
595
|
+
scope: MEDIA_EDITOR_PLUGIN_SCOPE,
|
|
596
|
+
onError: handlePluginError
|
|
597
|
+
}),
|
|
598
|
+
children
|
|
599
|
+
]
|
|
600
|
+
}) })
|
|
601
|
+
}),
|
|
502
602
|
isImage,
|
|
503
603
|
layout,
|
|
504
604
|
onRequestClose: handleRequestClose,
|