@wordpress/media-editor 0.21.0 → 0.23.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/build/components/media-editor/index.cjs +586 -686
- package/build/components/media-editor/index.cjs.map +1 -7
- package/build/components/media-editor/use-crop-options.cjs +42 -57
- package/build/components/media-editor/use-crop-options.cjs.map +1 -7
- package/build/components/media-editor/use-save-media-editor.cjs +131 -185
- package/build/components/media-editor/use-save-media-editor.cjs.map +1 -7
- package/build/components/media-editor-canvas/index.cjs +117 -124
- package/build/components/media-editor-canvas/index.cjs.map +1 -7
- package/build/components/media-editor-crop-panel/index.cjs +81 -72
- package/build/components/media-editor-crop-panel/index.cjs.map +1 -7
- package/build/components/media-editor-fine-rotation/index.cjs +61 -72
- package/build/components/media-editor-fine-rotation/index.cjs.map +1 -7
- package/build/components/media-editor-image-controls/index.cjs +181 -257
- package/build/components/media-editor-image-controls/index.cjs.map +1 -7
- package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +120 -157
- package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -7
- package/build/components/media-editor-modal/index.cjs +112 -155
- package/build/components/media-editor-modal/index.cjs.map +1 -7
- package/build/components/media-editor-provider/index.cjs +32 -55
- package/build/components/media-editor-provider/index.cjs.map +1 -7
- package/build/components/media-form/index.cjs +82 -77
- package/build/components/media-form/index.cjs.map +1 -7
- package/build/components/media-preview/index.cjs +113 -114
- package/build/components/media-preview/index.cjs.map +1 -7
- package/build/components/rotation-ruler/index.cjs +181 -188
- package/build/components/rotation-ruler/index.cjs.map +1 -7
- package/build/components/rotation-ruler/use-ruler-drag.cjs +132 -149
- package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -7
- package/build/hooks/use-crop-gesture-handlers.cjs +82 -76
- package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -7
- package/build/index.cjs +45 -39
- package/build/lock-unlock.cjs +9 -35
- package/build/lock-unlock.cjs.map +1 -7
- package/build/private-apis.cjs +16 -37
- package/build/private-apis.cjs.map +1 -7
- package/build/state/aspect-ratio-presets.cjs +59 -0
- package/build/state/aspect-ratio-presets.cjs.map +1 -0
- package/build/state/composite-reducer.cjs +100 -113
- package/build/state/composite-reducer.cjs.map +1 -7
- package/build/state/index.cjs +22 -45
- package/build/state/media-editor-state-provider.cjs +35 -48
- package/build/state/media-editor-state-provider.cjs.map +1 -7
- package/build/state/types.cjs +11 -31
- package/build/state/types.cjs.map +1 -7
- package/build/state/use-media-editor-state.cjs +227 -296
- package/build/state/use-media-editor-state.cjs.map +1 -7
- package/build/store/actions.cjs +17 -44
- package/build/store/actions.cjs.map +1 -7
- package/build/store/constants.cjs +8 -29
- package/build/store/constants.cjs.map +1 -7
- package/build/store/index.cjs +33 -40
- package/build/store/index.cjs.map +1 -7
- package/build/store/reducer.cjs +28 -50
- package/build/store/reducer.cjs.map +1 -7
- package/build/store/selectors.cjs +16 -41
- package/build/store/selectors.cjs.map +1 -7
- package/build/utils/get-media-type.cjs +18 -41
- package/build/utils/get-media-type.cjs.map +1 -7
- package/build/utils/index.cjs +9 -28
- package/build-module/components/media-editor/index.mjs +545 -675
- package/build-module/components/media-editor/index.mjs.map +1 -7
- package/build-module/components/media-editor/use-crop-options.mjs +37 -32
- package/build-module/components/media-editor/use-crop-options.mjs.map +1 -7
- package/build-module/components/media-editor/use-save-media-editor.mjs +109 -157
- package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -7
- package/build-module/components/media-editor-canvas/index.mjs +95 -98
- package/build-module/components/media-editor-canvas/index.mjs.map +1 -7
- package/build-module/components/media-editor-crop-panel/index.mjs +59 -46
- package/build-module/components/media-editor-crop-panel/index.mjs.map +1 -7
- package/build-module/components/media-editor-fine-rotation/index.mjs +39 -46
- package/build-module/components/media-editor-fine-rotation/index.mjs.map +1 -7
- package/build-module/components/media-editor-image-controls/index.mjs +171 -238
- package/build-module/components/media-editor-image-controls/index.mjs.map +1 -7
- package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +113 -137
- package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -7
- package/build-module/components/media-editor-modal/index.mjs +88 -124
- package/build-module/components/media-editor-modal/index.mjs.map +1 -7
- package/build-module/components/media-editor-provider/index.mjs +26 -29
- package/build-module/components/media-editor-provider/index.mjs.map +1 -7
- package/build-module/components/media-form/index.mjs +74 -56
- package/build-module/components/media-form/index.mjs.map +1 -7
- package/build-module/components/media-preview/index.mjs +105 -90
- package/build-module/components/media-preview/index.mjs.map +1 -7
- package/build-module/components/rotation-ruler/index.mjs +161 -164
- package/build-module/components/rotation-ruler/index.mjs.map +1 -7
- package/build-module/components/rotation-ruler/use-ruler-drag.mjs +125 -122
- package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +1 -7
- package/build-module/hooks/use-crop-gesture-handlers.mjs +76 -50
- package/build-module/hooks/use-crop-gesture-handlers.mjs.map +1 -7
- package/build-module/index.mjs +3 -10
- package/build-module/lock-unlock.mjs +5 -10
- package/build-module/lock-unlock.mjs.map +1 -7
- package/build-module/private-apis.mjs +8 -9
- package/build-module/private-apis.mjs.map +1 -7
- package/build-module/state/aspect-ratio-presets.mjs +53 -0
- package/build-module/state/aspect-ratio-presets.mjs.map +1 -0
- package/build-module/state/composite-reducer.mjs +80 -91
- package/build-module/state/composite-reducer.mjs.map +1 -7
- package/build-module/state/index.mjs +3 -26
- package/build-module/state/media-editor-state-provider.mjs +29 -24
- package/build-module/state/media-editor-state-provider.mjs.map +1 -7
- package/build-module/state/types.mjs +7 -7
- package/build-module/state/types.mjs.map +1 -7
- package/build-module/state/use-media-editor-state.mjs +223 -288
- package/build-module/state/use-media-editor-state.mjs.map +1 -7
- package/build-module/store/actions.mjs +12 -19
- package/build-module/store/actions.mjs.map +1 -7
- package/build-module/store/constants.mjs +4 -5
- package/build-module/store/constants.mjs.map +1 -7
- package/build-module/store/index.mjs +8 -9
- package/build-module/store/index.mjs.map +1 -7
- package/build-module/store/reducer.mjs +23 -26
- package/build-module/store/reducer.mjs.map +1 -7
- package/build-module/store/selectors.mjs +8 -13
- package/build-module/store/selectors.mjs.map +1 -7
- package/build-module/utils/get-media-type.mjs +14 -17
- package/build-module/utils/get-media-type.mjs.map +1 -7
- package/build-module/utils/index.mjs +1 -6
- package/build-style/style-rtl.css +145 -61
- package/build-style/style.css +144 -61
- package/build-types/components/media-editor/index.d.ts +20 -2
- package/build-types/components/media-editor/index.d.ts.map +1 -1
- package/build-types/components/media-editor/use-crop-options.d.ts +2 -3
- package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
- package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
- package/build-types/components/media-editor-canvas/index.d.ts +3 -3
- package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
- package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
- package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
- package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -1
- package/build-types/components/media-editor-image-controls/index.d.ts +1 -1
- package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
- package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
- package/build-types/components/media-editor-modal/index.d.ts +1 -1
- package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
- package/build-types/components/media-form/index.d.ts.map +1 -1
- package/build-types/components/media-preview/index.d.ts.map +1 -1
- package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -1
- package/build-types/state/aspect-ratio-presets.d.ts +24 -0
- package/build-types/state/aspect-ratio-presets.d.ts.map +1 -0
- package/build-types/state/composite-reducer.d.ts +17 -19
- package/build-types/state/composite-reducer.d.ts.map +1 -1
- package/build-types/state/index.d.ts +2 -4
- package/build-types/state/index.d.ts.map +1 -1
- package/build-types/state/types.d.ts +20 -63
- package/build-types/state/types.d.ts.map +1 -1
- package/build-types/state/use-media-editor-state.d.ts +33 -52
- package/build-types/state/use-media-editor-state.d.ts.map +1 -1
- package/package.json +22 -23
- package/src/components/media-editor/index.tsx +355 -167
- package/src/components/media-editor/style.scss +19 -0
- package/src/components/media-editor/use-crop-options.ts +9 -10
- package/src/components/media-editor/use-save-media-editor.ts +48 -10
- package/src/components/media-editor-canvas/index.tsx +30 -51
- package/src/components/media-editor-canvas/style.scss +6 -6
- package/src/components/media-editor-crop-panel/index.tsx +38 -2
- package/src/components/media-editor-crop-panel/style.scss +21 -0
- package/src/components/media-editor-fine-rotation/index.tsx +6 -6
- package/src/components/media-editor-image-controls/index.tsx +15 -11
- package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +1 -0
- package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
- package/src/components/media-editor-modal/index.tsx +1 -1
- package/src/components/media-editor-modal/style.scss +1 -1
- package/src/components/media-form/index.tsx +7 -1
- package/src/components/media-preview/index.tsx +65 -23
- package/src/components/media-preview/style.scss +16 -2
- package/src/components/rotation-ruler/style.scss +9 -5
- package/src/components/rotation-ruler/use-ruler-drag.ts +6 -11
- package/src/state/README.md +32 -0
- package/src/state/aspect-ratio-presets.ts +37 -0
- package/src/state/composite-reducer.ts +42 -80
- package/src/state/index.ts +2 -17
- package/src/state/types.ts +18 -72
- package/src/state/use-media-editor-state.ts +155 -238
- package/src/style.scss +2 -1
- package/build/components/media-editor-modal/build-modifiers.cjs +0 -91
- package/build/components/media-editor-modal/build-modifiers.cjs.map +0 -7
- package/build/image-editor/core/camera.cjs +0 -225
- package/build/image-editor/core/camera.cjs.map +0 -7
- package/build/image-editor/core/constants.cjs +0 -108
- package/build/image-editor/core/constants.cjs.map +0 -7
- package/build/image-editor/core/containment.cjs +0 -276
- package/build/image-editor/core/containment.cjs.map +0 -7
- package/build/image-editor/core/crop-rect.cjs +0 -48
- package/build/image-editor/core/crop-rect.cjs.map +0 -7
- package/build/image-editor/core/export/canvas-renderer.cjs +0 -151
- package/build/image-editor/core/export/canvas-renderer.cjs.map +0 -7
- package/build/image-editor/core/index.cjs +0 -62
- package/build/image-editor/core/index.cjs.map +0 -7
- package/build/image-editor/core/interaction-controller.cjs +0 -654
- package/build/image-editor/core/interaction-controller.cjs.map +0 -7
- package/build/image-editor/core/math/rotation.cjs +0 -41
- package/build/image-editor/core/math/rotation.cjs.map +0 -7
- package/build/image-editor/core/math/sanitize.cjs +0 -92
- package/build/image-editor/core/math/sanitize.cjs.map +0 -7
- package/build/image-editor/core/setter-helpers.cjs +0 -64
- package/build/image-editor/core/setter-helpers.cjs.map +0 -7
- package/build/image-editor/core/source-region.cjs +0 -206
- package/build/image-editor/core/source-region.cjs.map +0 -7
- package/build/image-editor/core/state.cjs +0 -283
- package/build/image-editor/core/state.cjs.map +0 -7
- package/build/image-editor/core/stencil-math.cjs +0 -216
- package/build/image-editor/core/stencil-math.cjs.map +0 -7
- package/build/image-editor/core/transform-style.cjs +0 -52
- package/build/image-editor/core/transform-style.cjs.map +0 -7
- package/build/image-editor/core/transforms/pipeline.cjs +0 -43
- package/build/image-editor/core/transforms/pipeline.cjs.map +0 -7
- package/build/image-editor/core/types.cjs +0 -19
- package/build/image-editor/core/types.cjs.map +0 -7
- package/build/image-editor/core/viewport-state.cjs +0 -50
- package/build/image-editor/core/viewport-state.cjs.map +0 -7
- package/build/image-editor/index.cjs +0 -67
- package/build/image-editor/index.cjs.map +0 -7
- package/build/image-editor/react/components/cropper-provider.cjs +0 -50
- package/build/image-editor/react/components/cropper-provider.cjs.map +0 -7
- package/build/image-editor/react/components/cropper.cjs +0 -722
- package/build/image-editor/react/components/cropper.cjs.map +0 -7
- package/build/image-editor/react/components/index.cjs +0 -36
- package/build/image-editor/react/components/index.cjs.map +0 -7
- package/build/image-editor/react/components/overlays/dimensions-overlay.cjs +0 -172
- package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +0 -7
- package/build/image-editor/react/components/overlays/dimming-overlay.cjs +0 -62
- package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +0 -7
- package/build/image-editor/react/components/overlays/grid-overlay.cjs +0 -91
- package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +0 -7
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +0 -426
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +0 -7
- package/build/image-editor/react/components/viewport-provider.cjs +0 -51
- package/build/image-editor/react/components/viewport-provider.cjs.map +0 -7
- package/build/image-editor/react/hooks/build-cropper-setters.cjs +0 -71
- package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +0 -7
- package/build/image-editor/react/hooks/index.cjs +0 -34
- package/build/image-editor/react/hooks/index.cjs.map +0 -7
- package/build/image-editor/react/hooks/use-aria-announcer.cjs +0 -160
- package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +0 -7
- package/build/image-editor/react/hooks/use-cropper-reducer.cjs +0 -113
- package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +0 -7
- package/build/image-editor/react/hooks/use-interaction.cjs +0 -213
- package/build/image-editor/react/hooks/use-interaction.cjs.map +0 -7
- package/build/image-editor/react/hooks/use-transform-style.cjs +0 -38
- package/build/image-editor/react/hooks/use-transform-style.cjs.map +0 -7
- package/build/image-editor/react/hooks/use-viewport-state.cjs +0 -51
- package/build/image-editor/react/hooks/use-viewport-state.cjs.map +0 -7
- package/build/image-editor/react/visually-hidden-style.cjs +0 -41
- package/build/image-editor/react/visually-hidden-style.cjs.map +0 -7
- package/build/index.cjs.map +0 -7
- package/build/state/index.cjs.map +0 -7
- package/build/utils/index.cjs.map +0 -7
- package/build-module/components/media-editor-modal/build-modifiers.mjs +0 -66
- package/build-module/components/media-editor-modal/build-modifiers.mjs.map +0 -7
- package/build-module/image-editor/core/camera.mjs +0 -198
- package/build-module/image-editor/core/camera.mjs.map +0 -7
- package/build-module/image-editor/core/constants.mjs +0 -69
- package/build-module/image-editor/core/constants.mjs.map +0 -7
- package/build-module/image-editor/core/containment.mjs +0 -253
- package/build-module/image-editor/core/containment.mjs.map +0 -7
- package/build-module/image-editor/core/crop-rect.mjs +0 -23
- package/build-module/image-editor/core/crop-rect.mjs.map +0 -7
- package/build-module/image-editor/core/export/canvas-renderer.mjs +0 -120
- package/build-module/image-editor/core/export/canvas-renderer.mjs.map +0 -7
- package/build-module/image-editor/core/index.mjs +0 -36
- package/build-module/image-editor/core/index.mjs.map +0 -7
- package/build-module/image-editor/core/interaction-controller.mjs +0 -635
- package/build-module/image-editor/core/interaction-controller.mjs.map +0 -7
- package/build-module/image-editor/core/math/rotation.mjs +0 -15
- package/build-module/image-editor/core/math/rotation.mjs.map +0 -7
- package/build-module/image-editor/core/math/sanitize.mjs +0 -63
- package/build-module/image-editor/core/math/sanitize.mjs.map +0 -7
- package/build-module/image-editor/core/setter-helpers.mjs +0 -39
- package/build-module/image-editor/core/setter-helpers.mjs.map +0 -7
- package/build-module/image-editor/core/source-region.mjs +0 -178
- package/build-module/image-editor/core/source-region.mjs.map +0 -7
- package/build-module/image-editor/core/state.mjs +0 -260
- package/build-module/image-editor/core/state.mjs.map +0 -7
- package/build-module/image-editor/core/stencil-math.mjs +0 -187
- package/build-module/image-editor/core/stencil-math.mjs.map +0 -7
- package/build-module/image-editor/core/transform-style.mjs +0 -27
- package/build-module/image-editor/core/transform-style.mjs.map +0 -7
- package/build-module/image-editor/core/transforms/pipeline.mjs +0 -17
- package/build-module/image-editor/core/transforms/pipeline.mjs.map +0 -7
- package/build-module/image-editor/core/types.mjs +0 -1
- package/build-module/image-editor/core/types.mjs.map +0 -7
- package/build-module/image-editor/core/viewport-state.mjs +0 -24
- package/build-module/image-editor/core/viewport-state.mjs.map +0 -7
- package/build-module/image-editor/index.mjs +0 -39
- package/build-module/image-editor/index.mjs.map +0 -7
- package/build-module/image-editor/react/components/cropper-provider.mjs +0 -26
- package/build-module/image-editor/react/components/cropper-provider.mjs.map +0 -7
- package/build-module/image-editor/react/components/cropper.mjs +0 -704
- package/build-module/image-editor/react/components/cropper.mjs.map +0 -7
- package/build-module/image-editor/react/components/index.mjs +0 -9
- package/build-module/image-editor/react/components/index.mjs.map +0 -7
- package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs +0 -147
- package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +0 -7
- package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +0 -37
- package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +0 -7
- package/build-module/image-editor/react/components/overlays/grid-overlay.mjs +0 -66
- package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +0 -7
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +0 -414
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +0 -7
- package/build-module/image-editor/react/components/viewport-provider.mjs +0 -27
- package/build-module/image-editor/react/components/viewport-provider.mjs.map +0 -7
- package/build-module/image-editor/react/hooks/build-cropper-setters.mjs +0 -46
- package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +0 -7
- package/build-module/image-editor/react/hooks/index.mjs +0 -8
- package/build-module/image-editor/react/hooks/index.mjs.map +0 -7
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +0 -135
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +0 -7
- package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs +0 -100
- package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +0 -7
- package/build-module/image-editor/react/hooks/use-interaction.mjs +0 -190
- package/build-module/image-editor/react/hooks/use-interaction.mjs.map +0 -7
- package/build-module/image-editor/react/hooks/use-transform-style.mjs +0 -13
- package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +0 -7
- package/build-module/image-editor/react/hooks/use-viewport-state.mjs +0 -29
- package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +0 -7
- package/build-module/image-editor/react/visually-hidden-style.mjs +0 -16
- package/build-module/image-editor/react/visually-hidden-style.mjs.map +0 -7
- package/build-module/index.mjs.map +0 -7
- package/build-module/state/index.mjs.map +0 -7
- package/build-module/utils/index.mjs.map +0 -7
- package/build-types/components/media-editor-modal/build-modifiers.d.ts +0 -80
- package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +0 -1
- package/build-types/image-editor/core/camera.d.ts +0 -128
- package/build-types/image-editor/core/camera.d.ts.map +0 -1
- package/build-types/image-editor/core/constants.d.ts +0 -99
- package/build-types/image-editor/core/constants.d.ts.map +0 -1
- package/build-types/image-editor/core/containment.d.ts +0 -72
- package/build-types/image-editor/core/containment.d.ts.map +0 -1
- package/build-types/image-editor/core/crop-rect.d.ts +0 -16
- package/build-types/image-editor/core/crop-rect.d.ts.map +0 -1
- package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -103
- package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +0 -1
- package/build-types/image-editor/core/index.d.ts +0 -10
- package/build-types/image-editor/core/index.d.ts.map +0 -1
- package/build-types/image-editor/core/interaction-controller.d.ts +0 -191
- package/build-types/image-editor/core/interaction-controller.d.ts.map +0 -1
- package/build-types/image-editor/core/math/rotation.d.ts +0 -18
- package/build-types/image-editor/core/math/rotation.d.ts.map +0 -1
- package/build-types/image-editor/core/math/sanitize.d.ts +0 -67
- package/build-types/image-editor/core/math/sanitize.d.ts.map +0 -1
- package/build-types/image-editor/core/setter-helpers.d.ts +0 -21
- package/build-types/image-editor/core/setter-helpers.d.ts.map +0 -1
- package/build-types/image-editor/core/source-region.d.ts +0 -94
- package/build-types/image-editor/core/source-region.d.ts.map +0 -1
- package/build-types/image-editor/core/state.d.ts +0 -51
- package/build-types/image-editor/core/state.d.ts.map +0 -1
- package/build-types/image-editor/core/stencil-math.d.ts +0 -102
- package/build-types/image-editor/core/stencil-math.d.ts.map +0 -1
- package/build-types/image-editor/core/transform-style.d.ts +0 -20
- package/build-types/image-editor/core/transform-style.d.ts.map +0 -1
- package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -24
- package/build-types/image-editor/core/transforms/pipeline.d.ts.map +0 -1
- package/build-types/image-editor/core/types.d.ts +0 -269
- package/build-types/image-editor/core/types.d.ts.map +0 -1
- package/build-types/image-editor/core/viewport-state.d.ts +0 -4
- package/build-types/image-editor/core/viewport-state.d.ts.map +0 -1
- package/build-types/image-editor/index.d.ts +0 -16
- package/build-types/image-editor/index.d.ts.map +0 -1
- package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -38
- package/build-types/image-editor/react/components/cropper-provider.d.ts.map +0 -1
- package/build-types/image-editor/react/components/cropper.d.ts +0 -63
- package/build-types/image-editor/react/components/cropper.d.ts.map +0 -1
- package/build-types/image-editor/react/components/index.d.ts +0 -4
- package/build-types/image-editor/react/components/index.d.ts.map +0 -1
- package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -33
- package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +0 -1
- package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -17
- package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +0 -1
- package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -27
- package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +0 -1
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -33
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +0 -1
- package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -6
- package/build-types/image-editor/react/components/viewport-provider.d.ts.map +0 -1
- package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -44
- package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +0 -1
- package/build-types/image-editor/react/hooks/index.d.ts +0 -5
- package/build-types/image-editor/react/hooks/index.d.ts.map +0 -1
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -14
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +0 -1
- package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +0 -55
- package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +0 -1
- package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -65
- package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +0 -1
- package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -13
- package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +0 -1
- package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -16
- package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +0 -1
- package/build-types/image-editor/react/visually-hidden-style.d.ts +0 -6
- package/build-types/image-editor/react/visually-hidden-style.d.ts.map +0 -1
- package/src/components/media-editor-modal/build-modifiers.ts +0 -161
- package/src/image-editor/README.md +0 -61
- package/src/image-editor/core/camera.ts +0 -429
- package/src/image-editor/core/constants.ts +0 -150
- package/src/image-editor/core/containment.ts +0 -469
- package/src/image-editor/core/crop-rect.ts +0 -42
- package/src/image-editor/core/export/canvas-renderer.ts +0 -250
- package/src/image-editor/core/index.ts +0 -47
- package/src/image-editor/core/interaction-controller.ts +0 -976
- package/src/image-editor/core/math/rotation.ts +0 -26
- package/src/image-editor/core/math/sanitize.ts +0 -155
- package/src/image-editor/core/setter-helpers.ts +0 -63
- package/src/image-editor/core/source-region.ts +0 -367
- package/src/image-editor/core/state.ts +0 -484
- package/src/image-editor/core/stencil-math.ts +0 -379
- package/src/image-editor/core/transform-style.ts +0 -56
- package/src/image-editor/core/transforms/pipeline.ts +0 -40
- package/src/image-editor/core/types.ts +0 -230
- package/src/image-editor/core/viewport-state.ts +0 -30
- package/src/image-editor/docs/architecture.md +0 -63
- package/src/image-editor/docs/recipes.md +0 -184
- package/src/image-editor/index.ts +0 -52
- package/src/image-editor/react/components/cropper-provider.tsx +0 -70
- package/src/image-editor/react/components/cropper.scss +0 -259
- package/src/image-editor/react/components/cropper.tsx +0 -1116
- package/src/image-editor/react/components/index.ts +0 -3
- package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -262
- package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -55
- package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -77
- package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -623
- package/src/image-editor/react/components/viewport-provider.tsx +0 -32
- package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -102
- package/src/image-editor/react/hooks/index.ts +0 -4
- package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -193
- package/src/image-editor/react/hooks/use-cropper-reducer.ts +0 -197
- package/src/image-editor/react/hooks/use-interaction.ts +0 -294
- package/src/image-editor/react/hooks/use-transform-style.ts +0 -23
- package/src/image-editor/react/hooks/use-viewport-state.ts +0 -41
- package/src/image-editor/react/visually-hidden-style.ts +0 -15
- package/src/image-editor/style.scss +0 -1
|
@@ -1,711 +1,611 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
// \0rolldown/runtime.js
|
|
2
7
|
var __create = Object.create;
|
|
3
8
|
var __defProp = Object.defineProperty;
|
|
4
9
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
10
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __export = (target, all) => {
|
|
9
|
-
for (var name in all)
|
|
10
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
-
};
|
|
12
13
|
var __copyProps = (to, from, except, desc) => {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
15
|
+
key = keys[i];
|
|
16
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
17
|
+
get: ((k) => from[k]).bind(null, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
return to;
|
|
19
22
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
24
|
+
value: mod,
|
|
25
|
+
enumerable: true
|
|
26
|
+
}) : target, mod));
|
|
27
|
+
let clsx = require("clsx");
|
|
28
|
+
clsx = __toESM(clsx);
|
|
29
|
+
let _wordpress_components = require("@wordpress/components");
|
|
30
|
+
let _wordpress_ui = require("@wordpress/ui");
|
|
31
|
+
let _wordpress_compose = require("@wordpress/compose");
|
|
32
|
+
let _wordpress_data = require("@wordpress/data");
|
|
33
|
+
let _wordpress_core_data = require("@wordpress/core-data");
|
|
34
|
+
let _wordpress_admin_ui = require("@wordpress/admin-ui");
|
|
35
|
+
let _wordpress_element = require("@wordpress/element");
|
|
36
|
+
let _wordpress_i18n = require("@wordpress/i18n");
|
|
37
|
+
let _wordpress_icons = require("@wordpress/icons");
|
|
38
|
+
let _wordpress_keycodes = require("@wordpress/keycodes");
|
|
39
|
+
let _wordpress_notices = require("@wordpress/notices");
|
|
40
|
+
let ___media_editor_provider_index_tsx = require("../media-editor-provider/index.cjs");
|
|
41
|
+
let ___media_preview_index_tsx = require("../media-preview/index.cjs");
|
|
42
|
+
___media_preview_index_tsx = __toESM(___media_preview_index_tsx);
|
|
43
|
+
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
|
+
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
|
+
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
|
+
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
|
+
let ___media_form_index_tsx = require("../media-form/index.cjs");
|
|
52
|
+
___media_form_index_tsx = __toESM(___media_form_index_tsx);
|
|
53
|
+
let ______utils_index_ts = require("../../utils/index.cjs");
|
|
54
|
+
let ______state_index_ts = require("../../state/index.cjs");
|
|
55
|
+
let ______hooks_use_crop_gesture_handlers_ts = require("../../hooks/use-crop-gesture-handlers.cjs");
|
|
56
|
+
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
|
+
let __use_save_media_editor_ts = require("./use-save-media-editor.cjs");
|
|
59
|
+
let __use_crop_options_ts = require("./use-crop-options.cjs");
|
|
60
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
30
61
|
// packages/media-editor/src/components/media-editor/index.tsx
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
className: "media-editor__tabs",
|
|
84
|
-
value: activeTab,
|
|
85
|
-
onValueChange: onSelectTab,
|
|
86
|
-
children: [
|
|
87
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor__tablist", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Tabs.List, { variant: "minimal", children: tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
88
|
-
import_ui.Tabs.Tab,
|
|
89
|
-
{
|
|
90
|
-
value: tab.id,
|
|
91
|
-
disabled,
|
|
92
|
-
children: tab.title
|
|
93
|
-
},
|
|
94
|
-
tab.id
|
|
95
|
-
)) }) }),
|
|
96
|
-
tabs.map((tab) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
97
|
-
import_ui.Tabs.Panel,
|
|
98
|
-
{
|
|
99
|
-
value: tab.id,
|
|
100
|
-
tabIndex: -1,
|
|
101
|
-
className: "media-editor__panel",
|
|
102
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.Stack, { direction: "column", gap: "lg", children: tab.render() })
|
|
103
|
-
},
|
|
104
|
-
tab.id
|
|
105
|
-
))
|
|
106
|
-
]
|
|
107
|
-
}
|
|
108
|
-
)
|
|
109
|
-
]
|
|
110
|
-
}
|
|
111
|
-
);
|
|
62
|
+
const ATTACHMENT_EMBED_QUERY = { _embed: "author,wp:attached-to" };
|
|
63
|
+
const PLACEMENT_CONTROL_IDLE_MS = 300;
|
|
64
|
+
/**
|
|
65
|
+
* Identifier for the details panel, and the panel the sidebar opens on before
|
|
66
|
+
* the user picks another. The sidebar tracks which panel is open rather than
|
|
67
|
+
* whether one is, so a further panel is a new id here and a new entry in the
|
|
68
|
+
* tab list — not a change to the state's shape.
|
|
69
|
+
*/
|
|
70
|
+
const DETAILS_PANEL = "details";
|
|
71
|
+
/** Identifier for the crop panel. Images only; other media has nothing to crop. */
|
|
72
|
+
const CROP_PANEL = "crop";
|
|
73
|
+
const SIDEBAR_ANIMATION_DURATION = .3;
|
|
74
|
+
const sidebarVariants = {
|
|
75
|
+
open: { width: "auto" },
|
|
76
|
+
closed: (transition) => ({
|
|
77
|
+
width: 0,
|
|
78
|
+
transition
|
|
79
|
+
})
|
|
80
|
+
};
|
|
81
|
+
function MediaEditorSidebar({ tabs, activeTab, onSelectTab, disabled = false }) {
|
|
82
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_admin_ui.NavigableRegion, {
|
|
83
|
+
className: "media-editor__sidebar",
|
|
84
|
+
ariaLabel: (0, _wordpress_i18n.__)("Media settings"),
|
|
85
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.VisuallyHidden, {
|
|
86
|
+
render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("h2", {}),
|
|
87
|
+
children: (0, _wordpress_i18n.__)("Media settings")
|
|
88
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Tabs.Root, {
|
|
89
|
+
className: "media-editor__tabs",
|
|
90
|
+
value: activeTab,
|
|
91
|
+
onValueChange: onSelectTab,
|
|
92
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
93
|
+
className: "media-editor__tablist",
|
|
94
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Tabs.List, {
|
|
95
|
+
variant: "minimal",
|
|
96
|
+
children: tabs.map((tab) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Tabs.Tab, {
|
|
97
|
+
value: tab.id,
|
|
98
|
+
disabled,
|
|
99
|
+
children: tab.title
|
|
100
|
+
}, tab.id))
|
|
101
|
+
})
|
|
102
|
+
}), tabs.map((tab) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Tabs.Panel, {
|
|
103
|
+
value: tab.id,
|
|
104
|
+
tabIndex: -1,
|
|
105
|
+
className: "media-editor__panel",
|
|
106
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Stack, {
|
|
107
|
+
direction: "column",
|
|
108
|
+
gap: "lg",
|
|
109
|
+
children: tab.render()
|
|
110
|
+
})
|
|
111
|
+
}, tab.id))]
|
|
112
|
+
})]
|
|
113
|
+
});
|
|
112
114
|
}
|
|
113
|
-
|
|
115
|
+
const MediaEditorFrameContext = (0, _wordpress_element.createContext)(null);
|
|
116
|
+
/**
|
|
117
|
+
* Hook to access the media editor's frame context.
|
|
118
|
+
*
|
|
119
|
+
* Must be used within a MediaEditor component.
|
|
120
|
+
*
|
|
121
|
+
* @return MediaEditorFrameContextValue the action clusters render from.
|
|
122
|
+
*/
|
|
114
123
|
function useMediaEditorFrameContext() {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
124
|
+
const context = (0, _wordpress_element.useContext)(MediaEditorFrameContext);
|
|
125
|
+
if (!context) throw new Error("useMediaEditorFrameContext must be used within MediaEditor");
|
|
126
|
+
return context;
|
|
127
|
+
}
|
|
128
|
+
function PanelToggle() {
|
|
129
|
+
const { isWide, activePanel, onTogglePanel } = useMediaEditorFrameContext();
|
|
130
|
+
const isPanelOpen = !!activePanel;
|
|
131
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
|
|
132
|
+
size: "compact",
|
|
133
|
+
icon: _wordpress_icons.drawerRight,
|
|
134
|
+
label: (0, _wordpress_i18n.__)("Media settings"),
|
|
135
|
+
isPressed: isPanelOpen,
|
|
136
|
+
"aria-expanded": isWide ? isPanelOpen : void 0,
|
|
137
|
+
onClick: onTogglePanel
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
function getActionLabel(action, items) {
|
|
141
|
+
return typeof action.label === "string" ? action.label : action.label(items);
|
|
142
|
+
}
|
|
143
|
+
function MediaActionModal({ action, items, closeModal }) {
|
|
144
|
+
const header = typeof action.modalHeader === "function" ? action.modalHeader(items) : action.modalHeader;
|
|
145
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Modal, {
|
|
146
|
+
title: header || getActionLabel(action, items),
|
|
147
|
+
__experimentalHideHeader: !!action.hideModalHeader,
|
|
148
|
+
onRequestClose: closeModal,
|
|
149
|
+
focusOnMount: action.modalFocusOnMount ?? true,
|
|
150
|
+
size: action.modalSize || "medium",
|
|
151
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(action.RenderModal, {
|
|
152
|
+
items,
|
|
153
|
+
closeModal
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
function MoreMenu({ actions = [], item }) {
|
|
158
|
+
const { isImage, isSaving } = useMediaEditorFrameContext();
|
|
159
|
+
const registry = (0, _wordpress_data.useRegistry)();
|
|
160
|
+
const [isShortcutsModalOpen, setIsShortcutsModalOpen] = (0, _wordpress_element.useState)(false);
|
|
161
|
+
const [activeModalAction, setActiveModalAction] = (0, _wordpress_element.useState)(null);
|
|
162
|
+
const items = item ? [item] : [];
|
|
163
|
+
const eligibleActions = (0, _wordpress_element.useMemo)(() => item ? actions.filter((action) => !action.isEligible || action.isEligible(item)) : [], [actions, item]);
|
|
164
|
+
if (!isImage && !eligibleActions.length) return null;
|
|
165
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [
|
|
166
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.DropdownMenu, {
|
|
167
|
+
icon: _wordpress_icons.moreVertical,
|
|
168
|
+
label: (0, _wordpress_i18n.__)("More options"),
|
|
169
|
+
toggleProps: { size: "compact" },
|
|
170
|
+
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, {
|
|
171
|
+
icon: _wordpress_icons.keyboard,
|
|
172
|
+
iconPosition: "left",
|
|
173
|
+
onClick: () => {
|
|
174
|
+
setIsShortcutsModalOpen(true);
|
|
175
|
+
closeMenu();
|
|
176
|
+
},
|
|
177
|
+
children: (0, _wordpress_i18n.__)("Keyboard shortcuts")
|
|
178
|
+
}) }), !!eligibleActions.length && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuGroup, { children: eligibleActions.map((action) => {
|
|
179
|
+
const label = getActionLabel(action, items);
|
|
180
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuItem, {
|
|
181
|
+
disabled: isSaving || action.disabled,
|
|
182
|
+
onClick: () => {
|
|
183
|
+
closeMenu();
|
|
184
|
+
if ("RenderModal" in action) {
|
|
185
|
+
setActiveModalAction(action);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
action.callback(items, { registry });
|
|
189
|
+
},
|
|
190
|
+
children: "RenderModal" in action ? (0, _wordpress_i18n.sprintf)((0, _wordpress_i18n._x)("%s…", "menu item requiring further input"), label) : label
|
|
191
|
+
}, action.id);
|
|
192
|
+
}) })] })
|
|
193
|
+
}),
|
|
194
|
+
isShortcutsModalOpen && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_keyboard_shortcuts_modal_index_tsx.default, { onClose: () => setIsShortcutsModalOpen(false) }),
|
|
195
|
+
activeModalAction && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaActionModal, {
|
|
196
|
+
action: activeModalAction,
|
|
197
|
+
items,
|
|
198
|
+
closeModal: () => setActiveModalAction(null)
|
|
199
|
+
})
|
|
200
|
+
] });
|
|
122
201
|
}
|
|
123
202
|
function HeaderActions({ showCloseButton = false }) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
gap: "sm",
|
|
144
|
-
children: [
|
|
145
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
146
|
-
import_components.Button,
|
|
147
|
-
{
|
|
148
|
-
size: "compact",
|
|
149
|
-
icon: import_icons.drawerRight,
|
|
150
|
-
label: (0, import_i18n.__)("Media settings"),
|
|
151
|
-
isPressed: isPanelOpen,
|
|
152
|
-
"aria-expanded": isWide ? isPanelOpen : void 0,
|
|
153
|
-
onClick: onTogglePanel
|
|
154
|
-
}
|
|
155
|
-
),
|
|
156
|
-
isImage && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
157
|
-
import_components.DropdownMenu,
|
|
158
|
-
{
|
|
159
|
-
icon: import_icons.moreVertical,
|
|
160
|
-
label: (0, import_i18n.__)("More options"),
|
|
161
|
-
toggleProps: { size: "compact" },
|
|
162
|
-
children: ({ onClose: closeMenu }) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
163
|
-
canRestoreOriginal && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
164
|
-
import_components.MenuItem,
|
|
165
|
-
{
|
|
166
|
-
icon: import_icons.backup,
|
|
167
|
-
iconPosition: "left",
|
|
168
|
-
disabled: isSourceReplaced || isSaving,
|
|
169
|
-
info: (0, import_i18n.__)(
|
|
170
|
-
"Discards unsaved changes and loads the original image."
|
|
171
|
-
),
|
|
172
|
-
onClick: () => {
|
|
173
|
-
onRestoreOriginal();
|
|
174
|
-
closeMenu();
|
|
175
|
-
},
|
|
176
|
-
children: (0, import_i18n.__)("Restore original image")
|
|
177
|
-
}
|
|
178
|
-
) }),
|
|
179
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_components.MenuGroup, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
180
|
-
import_components.MenuItem,
|
|
181
|
-
{
|
|
182
|
-
icon: import_icons.keyboard,
|
|
183
|
-
iconPosition: "left",
|
|
184
|
-
onClick: () => {
|
|
185
|
-
setIsShortcutsModalOpen(true);
|
|
186
|
-
closeMenu();
|
|
187
|
-
},
|
|
188
|
-
children: (0, import_i18n.__)("Keyboard shortcuts")
|
|
189
|
-
}
|
|
190
|
-
) })
|
|
191
|
-
] })
|
|
192
|
-
}
|
|
193
|
-
),
|
|
194
|
-
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
195
|
-
import_components.Button,
|
|
196
|
-
{
|
|
197
|
-
size: "compact",
|
|
198
|
-
icon: import_icons.close,
|
|
199
|
-
label: (0, import_i18n.__)("Close"),
|
|
200
|
-
onClick: onCancel,
|
|
201
|
-
disabled: isSaving,
|
|
202
|
-
accessibleWhenDisabled: true
|
|
203
|
-
}
|
|
204
|
-
),
|
|
205
|
-
isShortcutsModalOpen && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
206
|
-
import_media_editor_keyboard_shortcuts_modal.default,
|
|
207
|
-
{
|
|
208
|
-
onClose: () => setIsShortcutsModalOpen(false)
|
|
209
|
-
}
|
|
210
|
-
)
|
|
211
|
-
]
|
|
212
|
-
}
|
|
213
|
-
);
|
|
203
|
+
const { isSaving, onCancel } = useMediaEditorFrameContext();
|
|
204
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Stack, {
|
|
205
|
+
className: "media-editor__header-actions",
|
|
206
|
+
justify: "flex-end",
|
|
207
|
+
align: "center",
|
|
208
|
+
gap: "sm",
|
|
209
|
+
children: [
|
|
210
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(PanelToggle, {}),
|
|
211
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(MoreMenu, {}),
|
|
212
|
+
showCloseButton && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
|
|
213
|
+
size: "compact",
|
|
214
|
+
icon: _wordpress_icons.close,
|
|
215
|
+
label: (0, _wordpress_i18n.__)("Close"),
|
|
216
|
+
onClick: onCancel,
|
|
217
|
+
disabled: isSaving,
|
|
218
|
+
accessibleWhenDisabled: true
|
|
219
|
+
})
|
|
220
|
+
]
|
|
221
|
+
});
|
|
214
222
|
}
|
|
215
223
|
function HistoryActions() {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
shortcut: (0, import_keycodes.isAppleOS)() ? import_keycodes.displayShortcut.primaryShift("z") : import_keycodes.displayShortcut.primary("y"),
|
|
285
|
-
disabled: isUndoRedoDisabled || !hasRedo,
|
|
286
|
-
accessibleWhenDisabled: true,
|
|
287
|
-
onClick: handleRedo
|
|
288
|
-
}
|
|
289
|
-
)
|
|
290
|
-
]
|
|
291
|
-
}
|
|
292
|
-
);
|
|
224
|
+
const { isImage, isSaving, isUndoRedoDisabled, isWide, activePanel, canRestoreOriginal, isSourceReplaced, opensOriginal, onRestoreOriginal } = useMediaEditorFrameContext();
|
|
225
|
+
const { reset, isDirty, hasUndo, hasRedo, undo: undoCrop, redo: redoCrop } = (0, ______state_index_ts.useMediaEditor)();
|
|
226
|
+
if (!isImage || !isWide && !!activePanel) return null;
|
|
227
|
+
const handleUndo = () => {
|
|
228
|
+
if (isUndoRedoDisabled) return;
|
|
229
|
+
undoCrop();
|
|
230
|
+
};
|
|
231
|
+
const handleRedo = () => {
|
|
232
|
+
if (isUndoRedoDisabled) return;
|
|
233
|
+
redoCrop();
|
|
234
|
+
};
|
|
235
|
+
const handleReset = () => {
|
|
236
|
+
if (isUndoRedoDisabled) return;
|
|
237
|
+
reset();
|
|
238
|
+
};
|
|
239
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Stack, {
|
|
240
|
+
className: "media-editor__history-actions",
|
|
241
|
+
align: "center",
|
|
242
|
+
gap: "sm",
|
|
243
|
+
children: [
|
|
244
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
|
|
245
|
+
size: "compact",
|
|
246
|
+
icon: _wordpress_icons.undo,
|
|
247
|
+
label: (0, _wordpress_i18n.__)("Undo"),
|
|
248
|
+
showTooltip: true,
|
|
249
|
+
shortcut: _wordpress_keycodes.displayShortcut.primary("z"),
|
|
250
|
+
disabled: isUndoRedoDisabled || !hasUndo,
|
|
251
|
+
accessibleWhenDisabled: true,
|
|
252
|
+
onClick: handleUndo
|
|
253
|
+
}),
|
|
254
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
|
|
255
|
+
size: "compact",
|
|
256
|
+
icon: _wordpress_icons.redo,
|
|
257
|
+
label: (0, _wordpress_i18n.__)("Redo"),
|
|
258
|
+
showTooltip: true,
|
|
259
|
+
shortcut: (0, _wordpress_keycodes.isAppleOS)() ? _wordpress_keycodes.displayShortcut.primaryShift("z") : _wordpress_keycodes.displayShortcut.primary("y"),
|
|
260
|
+
disabled: isUndoRedoDisabled || !hasRedo,
|
|
261
|
+
accessibleWhenDisabled: true,
|
|
262
|
+
onClick: handleRedo
|
|
263
|
+
}),
|
|
264
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.DropdownMenu, {
|
|
265
|
+
icon: _wordpress_icons.backup,
|
|
266
|
+
label: (0, _wordpress_i18n.__)("History"),
|
|
267
|
+
popoverProps: { placement: "top-start" },
|
|
268
|
+
toggleProps: {
|
|
269
|
+
size: "compact",
|
|
270
|
+
disabled: isUndoRedoDisabled || !isDirty && !canRestoreOriginal,
|
|
271
|
+
accessibleWhenDisabled: true
|
|
272
|
+
},
|
|
273
|
+
children: ({ onClose: closeMenu }) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuGroup, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuItem, {
|
|
274
|
+
disabled: isUndoRedoDisabled || !isDirty,
|
|
275
|
+
onClick: () => {
|
|
276
|
+
handleReset();
|
|
277
|
+
closeMenu();
|
|
278
|
+
},
|
|
279
|
+
children: (0, _wordpress_i18n.__)("Reset image edits")
|
|
280
|
+
}) }), canRestoreOriginal && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuGroup, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.MenuItem, {
|
|
281
|
+
disabled: isSourceReplaced || isSaving,
|
|
282
|
+
info: (0, _wordpress_i18n.__)("Discards unsaved changes."),
|
|
283
|
+
onClick: () => {
|
|
284
|
+
onRestoreOriginal();
|
|
285
|
+
closeMenu();
|
|
286
|
+
},
|
|
287
|
+
children: opensOriginal ? (0, _wordpress_i18n.__)("Edit original") : (0, _wordpress_i18n.__)("Restore original")
|
|
288
|
+
}) })] })
|
|
289
|
+
})
|
|
290
|
+
]
|
|
291
|
+
});
|
|
293
292
|
}
|
|
294
293
|
function SaveActions({ size = "default" }) {
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
size,
|
|
322
|
-
variant: "primary",
|
|
323
|
-
onClick: onSave,
|
|
324
|
-
isBusy: isSaving,
|
|
325
|
-
disabled: saveDisabled,
|
|
326
|
-
accessibleWhenDisabled: true,
|
|
327
|
-
children: (0, import_i18n.__)("Save")
|
|
328
|
-
}
|
|
329
|
-
)
|
|
330
|
-
]
|
|
331
|
-
}
|
|
332
|
-
);
|
|
294
|
+
const { isSaving, hasMedia, hasChanges, onCancel, onSave } = useMediaEditorFrameContext();
|
|
295
|
+
const saveDisabled = isSaving || !hasMedia || !hasChanges;
|
|
296
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Stack, {
|
|
297
|
+
className: "media-editor__save-actions",
|
|
298
|
+
justify: "flex-end",
|
|
299
|
+
align: "center",
|
|
300
|
+
gap: "sm",
|
|
301
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
|
|
302
|
+
__next40pxDefaultSize: true,
|
|
303
|
+
size,
|
|
304
|
+
variant: "tertiary",
|
|
305
|
+
onClick: onCancel,
|
|
306
|
+
disabled: isSaving,
|
|
307
|
+
accessibleWhenDisabled: true,
|
|
308
|
+
children: (0, _wordpress_i18n.__)("Cancel")
|
|
309
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
|
|
310
|
+
__next40pxDefaultSize: true,
|
|
311
|
+
size,
|
|
312
|
+
variant: "primary",
|
|
313
|
+
onClick: onSave,
|
|
314
|
+
isBusy: isSaving,
|
|
315
|
+
disabled: saveDisabled,
|
|
316
|
+
accessibleWhenDisabled: true,
|
|
317
|
+
children: (0, _wordpress_i18n.__)("Save")
|
|
318
|
+
})]
|
|
319
|
+
});
|
|
333
320
|
}
|
|
334
|
-
function MediaEditorContent({
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
children: [
|
|
613
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
614
|
-
import_admin_ui.NavigableRegion,
|
|
615
|
-
{
|
|
616
|
-
className: "media-editor__content",
|
|
617
|
-
ariaLabel: isImage ? (0, import_i18n.__)("Image editor") : (0, import_i18n.__)("Media preview"),
|
|
618
|
-
children: [
|
|
619
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { className: "media-editor__canvas-area", children: isImage ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
620
|
-
import_media_editor_canvas.default,
|
|
621
|
-
{
|
|
622
|
-
isPlacementActive,
|
|
623
|
-
onGestureStart: handleCanvasGestureStart,
|
|
624
|
-
onGestureEnd: handleCanvasGestureEnd,
|
|
625
|
-
disabled: isSaving
|
|
626
|
-
}
|
|
627
|
-
) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_media_preview.default, {}) }),
|
|
628
|
-
isImage && /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "media-editor__canvas-toolbar", children: [
|
|
629
|
-
ruler,
|
|
630
|
-
imageControls
|
|
631
|
-
] })
|
|
632
|
-
]
|
|
633
|
-
}
|
|
634
|
-
),
|
|
635
|
-
!!activePanel && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
636
|
-
MediaEditorSidebar,
|
|
637
|
-
{
|
|
638
|
-
tabs,
|
|
639
|
-
activeTab: tabs.some(
|
|
640
|
-
(tab) => tab.id === activePanel
|
|
641
|
-
) ? activePanel : DETAILS_PANEL,
|
|
642
|
-
onSelectTab: selectPanel,
|
|
643
|
-
disabled: isSaving
|
|
644
|
-
}
|
|
645
|
-
)
|
|
646
|
-
]
|
|
647
|
-
}
|
|
648
|
-
) }),
|
|
649
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
650
|
-
import_components.__experimentalConfirmDialog,
|
|
651
|
-
{
|
|
652
|
-
isOpen: isDiscardDialogOpen,
|
|
653
|
-
confirmButtonText: (0, import_i18n.__)("Discard"),
|
|
654
|
-
cancelButtonText: (0, import_i18n.__)("Keep editing"),
|
|
655
|
-
onCancel: () => setIsDiscardDialogOpen(false),
|
|
656
|
-
onConfirm: () => {
|
|
657
|
-
setIsDiscardDialogOpen(false);
|
|
658
|
-
discardAndClose();
|
|
659
|
-
},
|
|
660
|
-
children: (0, import_i18n.__)(
|
|
661
|
-
"Are you sure you want to discard your unsaved changes?"
|
|
662
|
-
)
|
|
663
|
-
}
|
|
664
|
-
),
|
|
665
|
-
noticesPortalElement ? (0, import_element.createPortal)(snackbar, noticesPortalElement) : snackbar
|
|
666
|
-
]
|
|
667
|
-
}
|
|
668
|
-
);
|
|
669
|
-
const contextValue = {
|
|
670
|
-
isImage,
|
|
671
|
-
isSaving,
|
|
672
|
-
hasMedia: !!media,
|
|
673
|
-
hasChanges,
|
|
674
|
-
// Saving freezes the whole edit surface: `save()` reads the
|
|
675
|
-
// modifiers once and then awaits, so anything changed after that
|
|
676
|
-
// would be silently dropped when the save resolves.
|
|
677
|
-
isUndoRedoDisabled: isCropInteractionActive || isSaving,
|
|
678
|
-
aspectRatioPresets,
|
|
679
|
-
isWide,
|
|
680
|
-
activePanel,
|
|
681
|
-
onTogglePanel: togglePanel,
|
|
682
|
-
onCancel: handleRequestClose,
|
|
683
|
-
onSave: saveMediaEditor,
|
|
684
|
-
canRestoreOriginal,
|
|
685
|
-
isSourceReplaced,
|
|
686
|
-
onRestoreOriginal: handleRestoreOriginal
|
|
687
|
-
};
|
|
688
|
-
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MediaEditorFrameContext.Provider, { value: contextValue, children: renderFrame({
|
|
689
|
-
children,
|
|
690
|
-
isImage,
|
|
691
|
-
layout,
|
|
692
|
-
onRequestClose: handleRequestClose,
|
|
693
|
-
onKeyDown: handleKeyDown,
|
|
694
|
-
shouldCloseOnClickOutside: !hasChanges && !isSaving,
|
|
695
|
-
isSaving,
|
|
696
|
-
hasChanges,
|
|
697
|
-
hasMedia: !!media
|
|
698
|
-
}) });
|
|
321
|
+
function MediaEditorContent({ fields = [], form, id, aspectRatioPresets, onClose, onSaved, onEditOriginal, renderFrame, noticesClassName = "media-editor__snackbar", noticesPortalElement, shouldCloseOnEsc = false }) {
|
|
322
|
+
const session = (0, ______state_index_ts.useMediaEditor)();
|
|
323
|
+
const isWide = (0, _wordpress_compose.useViewportMatch)("small");
|
|
324
|
+
const sidebarTransition = {
|
|
325
|
+
type: "tween",
|
|
326
|
+
duration: (0, _wordpress_compose.useReducedMotion)() || !isWide ? 0 : SIDEBAR_ANIMATION_DURATION,
|
|
327
|
+
ease: [
|
|
328
|
+
.6,
|
|
329
|
+
0,
|
|
330
|
+
.4,
|
|
331
|
+
1
|
|
332
|
+
]
|
|
333
|
+
};
|
|
334
|
+
const [chosenPanel, setChosenPanel] = (0, _wordpress_element.useState)();
|
|
335
|
+
const [chosenTab, setChosenTab] = (0, _wordpress_element.useState)(null);
|
|
336
|
+
const layout = isWide ? "wide" : "narrow";
|
|
337
|
+
const sourceMedia = (0, _wordpress_data.useSelect)((select) => select(_wordpress_core_data.store).getEntityRecord("postType", "attachment", id), [id]);
|
|
338
|
+
const { clearEntityRecordEdits, editEntityRecord, invalidateResolution } = (0, _wordpress_data.useDispatch)(_wordpress_core_data.store);
|
|
339
|
+
const { removeAllNotices } = (0, _wordpress_data.useDispatch)(_wordpress_notices.store);
|
|
340
|
+
const [isDiscardDialogOpen, setIsDiscardDialogOpen] = (0, _wordpress_element.useState)(false);
|
|
341
|
+
const [isPlacementActive, setIsPlacementActive] = (0, _wordpress_element.useState)(false);
|
|
342
|
+
const [isCanvasGestureActive, setIsCanvasGestureActive] = (0, _wordpress_element.useState)(false);
|
|
343
|
+
const [isSourceReplaced, setIsSourceReplaced] = (0, _wordpress_element.useState)(false);
|
|
344
|
+
const placementControlTimerRef = (0, _wordpress_element.useRef)(void 0);
|
|
345
|
+
const signalPlacementControlInteraction = (0, _wordpress_element.useCallback)(() => {
|
|
346
|
+
setIsPlacementActive(true);
|
|
347
|
+
clearTimeout(placementControlTimerRef.current);
|
|
348
|
+
placementControlTimerRef.current = setTimeout(() => {
|
|
349
|
+
setIsPlacementActive(false);
|
|
350
|
+
}, PLACEMENT_CONTROL_IDLE_MS);
|
|
351
|
+
}, []);
|
|
352
|
+
const handleCanvasGestureStart = (0, _wordpress_element.useCallback)(() => {
|
|
353
|
+
setIsCanvasGestureActive(true);
|
|
354
|
+
}, []);
|
|
355
|
+
const handleCanvasGestureEnd = (0, _wordpress_element.useCallback)(() => {
|
|
356
|
+
setIsCanvasGestureActive(false);
|
|
357
|
+
}, []);
|
|
358
|
+
const isCropInteractionActive = isPlacementActive || isCanvasGestureActive;
|
|
359
|
+
(0, _wordpress_element.useEffect)(() => {
|
|
360
|
+
return () => {
|
|
361
|
+
clearTimeout(placementControlTimerRef.current);
|
|
362
|
+
};
|
|
363
|
+
}, []);
|
|
364
|
+
const originalId = sourceMedia?.edit_root;
|
|
365
|
+
const originalRecord = (0, _wordpress_data.useSelect)((select) => originalId ? select(_wordpress_core_data.store).getEntityRecord("postType", "attachment", originalId) : void 0, [originalId]);
|
|
366
|
+
const originalWidth = Number(originalRecord?.media_details?.width);
|
|
367
|
+
const originalHeight = Number(originalRecord?.media_details?.height);
|
|
368
|
+
const originalUrl = originalRecord?.source_url;
|
|
369
|
+
const originalSource = originalId && originalRecord && typeof originalUrl === "string" && originalUrl.length > 0 && Number.isFinite(originalWidth) && originalWidth > 0 && Number.isFinite(originalHeight) && originalHeight > 0 ? {
|
|
370
|
+
id: originalId,
|
|
371
|
+
url: originalUrl,
|
|
372
|
+
media: originalRecord
|
|
373
|
+
} : void 0;
|
|
374
|
+
const canRestoreOriginal = !!originalSource;
|
|
375
|
+
const replacementSource = isSourceReplaced && originalSource ? {
|
|
376
|
+
id: originalSource.id,
|
|
377
|
+
url: originalSource.url,
|
|
378
|
+
media: originalSource.media
|
|
379
|
+
} : void 0;
|
|
380
|
+
const activeId = replacementSource?.id ?? id;
|
|
381
|
+
const { media, hasEdits } = (0, _wordpress_data.useSelect)((select) => {
|
|
382
|
+
const { getEditedEntityRecord, getEntityRecord, hasEditsForEntityRecord } = select(_wordpress_core_data.store);
|
|
383
|
+
getEntityRecord("postType", "attachment", activeId, ATTACHMENT_EMBED_QUERY);
|
|
384
|
+
return {
|
|
385
|
+
media: getEditedEntityRecord("postType", "attachment", activeId),
|
|
386
|
+
hasEdits: hasEditsForEntityRecord("postType", "attachment", activeId)
|
|
387
|
+
};
|
|
388
|
+
}, [activeId]);
|
|
389
|
+
(0, _wordpress_element.useEffect)(() => {
|
|
390
|
+
invalidateResolution("getEntityRecord", [
|
|
391
|
+
"postType",
|
|
392
|
+
"attachment",
|
|
393
|
+
activeId,
|
|
394
|
+
ATTACHMENT_EMBED_QUERY
|
|
395
|
+
]);
|
|
396
|
+
}, [activeId, invalidateResolution]);
|
|
397
|
+
const handleRestoreOriginal = (0, _wordpress_element.useCallback)(() => {
|
|
398
|
+
clearEntityRecordEdits("postType", "attachment", id);
|
|
399
|
+
if (onEditOriginal && originalId) {
|
|
400
|
+
onEditOriginal(originalId);
|
|
401
|
+
return;
|
|
402
|
+
}
|
|
403
|
+
setIsSourceReplaced(true);
|
|
404
|
+
}, [
|
|
405
|
+
clearEntityRecordEdits,
|
|
406
|
+
id,
|
|
407
|
+
onEditOriginal,
|
|
408
|
+
originalId
|
|
409
|
+
]);
|
|
410
|
+
const hasChanges = session.hasOutputEdits || hasEdits || isSourceReplaced;
|
|
411
|
+
const mediaType = (0, ______utils_index_ts.getMediaTypeFromMimeType)(media?.mime_type).type;
|
|
412
|
+
const isImage = !!media && mediaType === "image";
|
|
413
|
+
const currentTab = chosenTab ?? (isWide && isImage ? CROP_PANEL : DETAILS_PANEL);
|
|
414
|
+
let activePanel = chosenPanel;
|
|
415
|
+
if (activePanel === void 0) activePanel = isWide ? currentTab : null;
|
|
416
|
+
const selectPanel = (0, _wordpress_element.useCallback)((panel) => {
|
|
417
|
+
setChosenTab(panel);
|
|
418
|
+
setChosenPanel((chosen) => chosen === void 0 ? chosen : panel);
|
|
419
|
+
}, []);
|
|
420
|
+
const togglePanel = (0, _wordpress_element.useCallback)(() => {
|
|
421
|
+
setChosenPanel(activePanel ? null : currentTab);
|
|
422
|
+
}, [activePanel, currentTab]);
|
|
423
|
+
const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = (0, __use_crop_options_ts.useCropOptions)({ aspectRatioPresets });
|
|
424
|
+
const { isSaving, save: saveMediaEditor } = (0, __use_save_media_editor_ts.useSaveMediaEditor)({
|
|
425
|
+
session,
|
|
426
|
+
id,
|
|
427
|
+
isImage,
|
|
428
|
+
media: sourceMedia,
|
|
429
|
+
onSaved,
|
|
430
|
+
replacementSource
|
|
431
|
+
});
|
|
432
|
+
const handleChange = (updates) => {
|
|
433
|
+
if (isSaving) return;
|
|
434
|
+
editEntityRecord("postType", "attachment", activeId, updates);
|
|
435
|
+
};
|
|
436
|
+
const discardAndClose = () => {
|
|
437
|
+
removeAllNotices("snackbar", __use_save_media_editor_ts.MEDIA_EDITOR_NOTICES_CONTEXT);
|
|
438
|
+
clearEntityRecordEdits("postType", "attachment", activeId);
|
|
439
|
+
setIsSourceReplaced(false);
|
|
440
|
+
onClose?.();
|
|
441
|
+
};
|
|
442
|
+
const handleRequestClose = () => {
|
|
443
|
+
if (isSaving) return;
|
|
444
|
+
if (hasChanges) {
|
|
445
|
+
setIsDiscardDialogOpen(true);
|
|
446
|
+
return;
|
|
447
|
+
}
|
|
448
|
+
discardAndClose();
|
|
449
|
+
};
|
|
450
|
+
const handleKeyDown = (event) => {
|
|
451
|
+
const isUndoShortcut = _wordpress_keycodes.isKeyboardEvent.primary(event, "z");
|
|
452
|
+
const isRedoShortcut = _wordpress_keycodes.isKeyboardEvent.primaryShift(event, "z") || !(0, _wordpress_keycodes.isAppleOS)() && _wordpress_keycodes.isKeyboardEvent.primary(event, "y");
|
|
453
|
+
if ((isUndoShortcut || isRedoShortcut) && isImage) {
|
|
454
|
+
const target = event.target;
|
|
455
|
+
if (!((target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable) && !target.closest(`[${______hooks_use_crop_gesture_handlers_ts.CROP_CONTROL_ATTR}]`))) {
|
|
456
|
+
event.preventDefault();
|
|
457
|
+
if (isCropInteractionActive || isSaving) return;
|
|
458
|
+
if (isRedoShortcut) session.redo();
|
|
459
|
+
else session.undo();
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
if (shouldCloseOnEsc) {
|
|
463
|
+
if (event.code !== "Escape" && event.key !== "Escape") return;
|
|
464
|
+
if (isSaving) {
|
|
465
|
+
event.preventDefault();
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
if (hasChanges) {
|
|
469
|
+
event.preventDefault();
|
|
470
|
+
setIsDiscardDialogOpen(true);
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
};
|
|
474
|
+
const snackbar = /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_notices.SnackbarNotices, {
|
|
475
|
+
className: noticesClassName,
|
|
476
|
+
context: __use_save_media_editor_ts.MEDIA_EDITOR_NOTICES_CONTEXT
|
|
477
|
+
});
|
|
478
|
+
const imageControls = isImage && !isWide ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_image_controls_index_tsx.default, {
|
|
479
|
+
showAspectRatioControl: true,
|
|
480
|
+
aspectRatioPresets,
|
|
481
|
+
disabled: isSaving
|
|
482
|
+
}) : null;
|
|
483
|
+
const tabs = [...isImage ? [{
|
|
484
|
+
id: CROP_PANEL,
|
|
485
|
+
title: (0, _wordpress_i18n.__)("Crop"),
|
|
486
|
+
render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_crop_panel_index_tsx.default, {
|
|
487
|
+
aspectRatioValue,
|
|
488
|
+
onAspectRatioChange: setAspectRatioValue,
|
|
489
|
+
aspectRatioOptions,
|
|
490
|
+
disabled: isSaving
|
|
491
|
+
})
|
|
492
|
+
}] : [], {
|
|
493
|
+
id: DETAILS_PANEL,
|
|
494
|
+
title: (0, _wordpress_i18n.__)("Details"),
|
|
495
|
+
render: () => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_form_index_tsx.default, {})
|
|
496
|
+
}];
|
|
497
|
+
const ruler = isImage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_fine_rotation_index_tsx.default, {
|
|
498
|
+
onPlacementControlInteraction: signalPlacementControlInteraction,
|
|
499
|
+
disabled: isSaving
|
|
500
|
+
}) : null;
|
|
501
|
+
const children = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(___media_editor_provider_index_tsx.MediaEditorProvider, {
|
|
502
|
+
value: media ?? void 0,
|
|
503
|
+
onChange: handleChange,
|
|
504
|
+
settings: {
|
|
505
|
+
fields: isSaving ? fields.map((field) => ({
|
|
506
|
+
...field,
|
|
507
|
+
isDisabled: true
|
|
508
|
+
})) : fields,
|
|
509
|
+
form
|
|
510
|
+
},
|
|
511
|
+
children: [
|
|
512
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
513
|
+
className: "media-editor",
|
|
514
|
+
children: !media ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
515
|
+
className: "media-editor__loading",
|
|
516
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Spinner, {})
|
|
517
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
518
|
+
className: (0, clsx.default)("media-editor__body", { "has-panel-open": !!activePanel }),
|
|
519
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_admin_ui.NavigableRegion, {
|
|
520
|
+
className: "media-editor__content",
|
|
521
|
+
ariaLabel: isImage ? (0, _wordpress_i18n.__)("Image editor") : (0, _wordpress_i18n.__)("Media preview"),
|
|
522
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
523
|
+
className: "media-editor__canvas-area",
|
|
524
|
+
children: isImage ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_editor_canvas_index_tsx.default, {
|
|
525
|
+
isPlacementActive,
|
|
526
|
+
onGestureStart: handleCanvasGestureStart,
|
|
527
|
+
onGestureEnd: handleCanvasGestureEnd,
|
|
528
|
+
disabled: isSaving
|
|
529
|
+
}) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___media_preview_index_tsx.default, {})
|
|
530
|
+
}), isImage && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
531
|
+
className: "media-editor__canvas-toolbar",
|
|
532
|
+
children: [ruler, imageControls]
|
|
533
|
+
})]
|
|
534
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__unstableAnimatePresence, {
|
|
535
|
+
initial: false,
|
|
536
|
+
custom: sidebarTransition,
|
|
537
|
+
children: !!activePanel && /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__unstableMotion.div, {
|
|
538
|
+
className: "media-editor__sidebar-container",
|
|
539
|
+
variants: sidebarVariants,
|
|
540
|
+
initial: "closed",
|
|
541
|
+
animate: "open",
|
|
542
|
+
exit: "closed",
|
|
543
|
+
transition: sidebarTransition,
|
|
544
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaEditorSidebar, {
|
|
545
|
+
tabs,
|
|
546
|
+
activeTab: tabs.some((tab) => tab.id === activePanel) ? activePanel : DETAILS_PANEL,
|
|
547
|
+
onSelectTab: selectPanel,
|
|
548
|
+
disabled: isSaving
|
|
549
|
+
})
|
|
550
|
+
})
|
|
551
|
+
})]
|
|
552
|
+
})
|
|
553
|
+
}),
|
|
554
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.__experimentalConfirmDialog, {
|
|
555
|
+
isOpen: isDiscardDialogOpen,
|
|
556
|
+
confirmButtonText: (0, _wordpress_i18n.__)("Discard"),
|
|
557
|
+
cancelButtonText: (0, _wordpress_i18n.__)("Keep editing"),
|
|
558
|
+
onCancel: () => setIsDiscardDialogOpen(false),
|
|
559
|
+
onConfirm: () => {
|
|
560
|
+
setIsDiscardDialogOpen(false);
|
|
561
|
+
discardAndClose();
|
|
562
|
+
},
|
|
563
|
+
children: (0, _wordpress_i18n.__)("Are you sure you want to discard your unsaved changes?")
|
|
564
|
+
}),
|
|
565
|
+
noticesPortalElement ? (0, _wordpress_element.createPortal)(snackbar, noticesPortalElement) : snackbar
|
|
566
|
+
]
|
|
567
|
+
});
|
|
568
|
+
const contextValue = {
|
|
569
|
+
isImage,
|
|
570
|
+
isSaving,
|
|
571
|
+
hasMedia: !!media,
|
|
572
|
+
hasChanges,
|
|
573
|
+
isUndoRedoDisabled: isCropInteractionActive || isSaving,
|
|
574
|
+
aspectRatioPresets,
|
|
575
|
+
isWide,
|
|
576
|
+
activePanel,
|
|
577
|
+
onTogglePanel: togglePanel,
|
|
578
|
+
onCancel: handleRequestClose,
|
|
579
|
+
onSave: saveMediaEditor,
|
|
580
|
+
canRestoreOriginal,
|
|
581
|
+
isSourceReplaced,
|
|
582
|
+
opensOriginal: !!onEditOriginal,
|
|
583
|
+
onRestoreOriginal: handleRestoreOriginal
|
|
584
|
+
};
|
|
585
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaEditorFrameContext.Provider, {
|
|
586
|
+
value: contextValue,
|
|
587
|
+
children: renderFrame({
|
|
588
|
+
children,
|
|
589
|
+
isImage,
|
|
590
|
+
layout,
|
|
591
|
+
onRequestClose: handleRequestClose,
|
|
592
|
+
onKeyDown: handleKeyDown,
|
|
593
|
+
shouldCloseOnClickOutside: !hasChanges && !isSaving,
|
|
594
|
+
isSaving,
|
|
595
|
+
hasChanges,
|
|
596
|
+
hasMedia: !!media
|
|
597
|
+
})
|
|
598
|
+
});
|
|
699
599
|
}
|
|
700
600
|
function MediaEditor(props) {
|
|
701
|
-
|
|
601
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(______state_index_ts.MediaEditorStateProvider, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(MediaEditorContent, { ...props }) }, props.id);
|
|
702
602
|
}
|
|
703
603
|
MediaEditor.HeaderActions = HeaderActions;
|
|
604
|
+
MediaEditor.PanelToggle = PanelToggle;
|
|
605
|
+
MediaEditor.MoreMenu = MoreMenu;
|
|
704
606
|
MediaEditor.HistoryActions = HistoryActions;
|
|
705
607
|
MediaEditor.SaveActions = SaveActions;
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
});
|
|
711
|
-
//# sourceMappingURL=index.cjs.map
|
|
608
|
+
exports.MediaEditor = MediaEditor;
|
|
609
|
+
exports.default = MediaEditor;
|
|
610
|
+
|
|
611
|
+
//# sourceMappingURL=index.cjs.map
|