@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
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -26,10 +28,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
26
28
|
}) : target, mod));
|
|
27
29
|
let _wordpress_ui = require("@wordpress/ui");
|
|
28
30
|
let _wordpress_i18n = require("@wordpress/i18n");
|
|
31
|
+
let _wordpress_icons = require("@wordpress/icons");
|
|
29
32
|
let ______hooks_use_crop_gesture_handlers_ts = require("../../hooks/use-crop-gesture-handlers.cjs");
|
|
30
33
|
let ___media_editor_image_controls_index_tsx = require("../media-editor-image-controls/index.cjs");
|
|
31
|
-
___media_editor_image_controls_index_tsx = __toESM(___media_editor_image_controls_index_tsx);
|
|
32
34
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
35
|
+
___media_editor_image_controls_index_tsx = __toESM(___media_editor_image_controls_index_tsx);
|
|
33
36
|
// packages/media-editor/src/components/media-editor-crop-panel/index.tsx
|
|
34
37
|
/**
|
|
35
38
|
* Sidebar panel for crop controls: rotate, flip and zoom above the
|
|
@@ -66,7 +69,22 @@ function MediaEditorCropPanel({ aspectRatioValue, onAspectRatioChange, aspectRat
|
|
|
66
69
|
if (item && item.value !== null) onAspectRatioChange(item.value);
|
|
67
70
|
},
|
|
68
71
|
disabled,
|
|
69
|
-
items
|
|
72
|
+
items,
|
|
73
|
+
trigger: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.SelectControl.Trigger, { children: (item) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
74
|
+
className: "media-editor-crop-panel__aspect-ratio-option",
|
|
75
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_icons.Icon, { icon: (0, _wordpress_icons.getAspectRatioIcon)(Number(item.value)) }), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
76
|
+
className: "media-editor-crop-panel__aspect-ratio-label",
|
|
77
|
+
children: item.label
|
|
78
|
+
})]
|
|
79
|
+
}) }),
|
|
80
|
+
children: items.map((item) => /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.SelectControl.Item, {
|
|
81
|
+
value: item,
|
|
82
|
+
label: item.label,
|
|
83
|
+
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.SelectControl.ItemLabel, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
84
|
+
className: "media-editor-crop-panel__aspect-ratio-option",
|
|
85
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_icons.Icon, { icon: (0, _wordpress_icons.getAspectRatioIcon)(Number(item.value)) }), item.label]
|
|
86
|
+
}) })
|
|
87
|
+
}, item.value))
|
|
70
88
|
})
|
|
71
89
|
]
|
|
72
90
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["Stack","CROP_CONTROL_ATTR","VisuallyHidden","__","MediaEditorImageControls","SelectControl"],"sources":["../../../src/components/media-editor-crop-panel/index.tsx"],"sourcesContent":["import { SelectControl, Stack, VisuallyHidden } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';\nimport MediaEditorImageControls from '../media-editor-image-controls';\
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["Stack","CROP_CONTROL_ATTR","VisuallyHidden","__","MediaEditorImageControls","SelectControl","Icon","getAspectRatioIcon"],"sources":["../../../src/components/media-editor-crop-panel/index.tsx"],"sourcesContent":["import { SelectControl, Stack, VisuallyHidden } from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport { Icon, getAspectRatioIcon } from '@wordpress/icons';\nimport type { AspectRatioPreset } from '../../state/aspect-ratio-presets';\nimport { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';\nimport MediaEditorImageControls from '../media-editor-image-controls';\n\nexport interface MediaEditorCropPanelProps {\n\t/**\n\t * Selected aspect-ratio preset value as a string (so it round-trips\n\t * through `<SelectControl>`). `'0'` = free, `'-1'` = original, any\n\t * positive number = fixed ratio.\n\t */\n\taspectRatioValue: string;\n\t/** Setter for the aspect-ratio preset value. */\n\tonAspectRatioChange: ( value: string ) => void;\n\t/** Aspect-ratio presets to display in the selector. */\n\taspectRatioOptions: AspectRatioPreset[];\n\t/** Disable every control in the panel while the edit is saving. */\n\tdisabled?: boolean;\n}\n\n/**\n * Sidebar panel for crop controls: rotate, flip and zoom above the\n * aspect-ratio selector. Rendered where the panel docks; below that the\n * transform controls sit under the canvas instead, placed by the editor.\n * @param props\n * @param props.aspectRatioValue\n * @param props.onAspectRatioChange\n * @param props.aspectRatioOptions\n * @param props.disabled\n */\nexport default function MediaEditorCropPanel( {\n\taspectRatioValue,\n\tonAspectRatioChange,\n\taspectRatioOptions,\n\tdisabled = false,\n}: MediaEditorCropPanelProps ) {\n\tconst items = aspectRatioOptions.map( ( preset ) => ( {\n\t\tlabel: preset.label,\n\t\tvalue: preset.value.toString(),\n\t} ) );\n\n\treturn (\n\t\t// Tag the whole panel as a crop-control region so the modal's\n\t\t// Cmd+Z handler doesn't mistake the SelectControl input for a\n\t\t// metadata field (which would suppress undo).\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"xl\"\n\t\t\t{ ...{ [ CROP_CONTROL_ATTR ]: true } }\n\t\t>\n\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t{ __( 'Crop options' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<MediaEditorImageControls withLabels disabled={ disabled } />\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\tvalue={\n\t\t\t\t\titems.find( ( item ) => item.value === aspectRatioValue ) ??\n\t\t\t\t\tnull\n\t\t\t\t}\n\t\t\t\tonValueChange={ ( item ) => {\n\t\t\t\t\tif ( item && item.value !== null ) {\n\t\t\t\t\t\tonAspectRatioChange( item.value );\n\t\t\t\t\t}\n\t\t\t\t} }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\titems={ items }\n\t\t\t\ttrigger={\n\t\t\t\t\t<SelectControl.Trigger>\n\t\t\t\t\t\t{ ( item ) => (\n\t\t\t\t\t\t\t<span className=\"media-editor-crop-panel__aspect-ratio-option\">\n\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\ticon={ getAspectRatioIcon(\n\t\t\t\t\t\t\t\t\t\tNumber( item.value )\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t<span className=\"media-editor-crop-panel__aspect-ratio-label\">\n\t\t\t\t\t\t\t\t\t{ item.label }\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</SelectControl.Trigger>\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ items.map( ( item ) => (\n\t\t\t\t\t<SelectControl.Item\n\t\t\t\t\t\tkey={ item.value }\n\t\t\t\t\t\tvalue={ item }\n\t\t\t\t\t\tlabel={ item.label }\n\t\t\t\t\t>\n\t\t\t\t\t\t<SelectControl.ItemLabel>\n\t\t\t\t\t\t\t<span className=\"media-editor-crop-panel__aspect-ratio-option\">\n\t\t\t\t\t\t\t\t<Icon\n\t\t\t\t\t\t\t\t\ticon={ getAspectRatioIcon(\n\t\t\t\t\t\t\t\t\t\tNumber( item.value )\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t{ item.label }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t</SelectControl.ItemLabel>\n\t\t\t\t\t</SelectControl.Item>\n\t\t\t\t) ) }\n\t\t\t</SelectControl>\n\t\t</Stack>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCA,SAAwB,qBAAsB,EAC7C,kBACA,qBACA,oBACA,WAAW,SACmB;CAC9B,MAAM,QAAQ,mBAAmB,KAAO,YAAc;EACrD,OAAO,OAAO;EACd,OAAO,OAAO,MAAM,SAAS;CAC9B,EAAI;CAEJ,OAIC,iBAAA,GAAA,kBAAA,KAAA,CAACA,cAAAA,OAAD;EACC,WAAU;EACV,KAAI;GACKC,yCAAAA,oBAAqB;EAH/B,UAAA;GAKC,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA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C,KAAK,KACF;KACkB,CAAA,EAAA,CAAA;IACN,GAdb,KAAK,KAcQ,CACnB;GACY,CAAA;EACT;;AAET"}
|
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -27,10 +29,9 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
27
29
|
let _wordpress_i18n = require("@wordpress/i18n");
|
|
28
30
|
let ______state_index_ts = require("../../state/index.cjs");
|
|
29
31
|
let ______hooks_use_crop_gesture_handlers_ts = require("../../hooks/use-crop-gesture-handlers.cjs");
|
|
30
|
-
let ______image_editor_core_constants_ts = require("../../image-editor/core/constants.cjs");
|
|
31
32
|
let ___rotation_ruler_index_tsx = require("../rotation-ruler/index.cjs");
|
|
32
|
-
___rotation_ruler_index_tsx = __toESM(___rotation_ruler_index_tsx);
|
|
33
33
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
___rotation_ruler_index_tsx = __toESM(___rotation_ruler_index_tsx);
|
|
34
35
|
// packages/media-editor/src/components/media-editor-fine-rotation/index.tsx
|
|
35
36
|
/**
|
|
36
37
|
* Fine-rotation slider for the media editor. It renders under the canvas so it
|
|
@@ -43,14 +44,14 @@ let react_jsx_runtime = require("react/jsx-runtime");
|
|
|
43
44
|
* @param props.disabled
|
|
44
45
|
*/
|
|
45
46
|
function MediaEditorFineRotation({ onPlacementControlInteraction, disabled = false }) {
|
|
46
|
-
const { state, setRotation } = (0, ______state_index_ts.useMediaEditor)().
|
|
47
|
+
const { state, setRotation, maxRotationOffset } = (0, ______state_index_ts.useMediaEditor)().imageEditor;
|
|
47
48
|
const rotationGestureHandlers = (0, ______hooks_use_crop_gesture_handlers_ts.useCropGestureHandlers)({ commitOnKeyUp: false });
|
|
48
49
|
const baseAngle = Math.round(state.rotation / 90) * 90;
|
|
49
50
|
const visualDir = state.flip.horizontal !== state.flip.vertical ? -1 : 1;
|
|
50
51
|
const fineOffset = (state.rotation - baseAngle) * visualDir;
|
|
51
52
|
const handleRotationSlider = (value) => {
|
|
52
53
|
const EPS = .01;
|
|
53
|
-
const clamped = Math.max(-
|
|
54
|
+
const clamped = Math.max(-maxRotationOffset + EPS, Math.min(maxRotationOffset - EPS, value));
|
|
54
55
|
onPlacementControlInteraction?.();
|
|
55
56
|
setRotation(baseAngle + clamped * visualDir);
|
|
56
57
|
};
|
|
@@ -60,8 +61,8 @@ function MediaEditorFineRotation({ onPlacementControlInteraction, disabled = fal
|
|
|
60
61
|
...rotationGestureHandlers,
|
|
61
62
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(___rotation_ruler_index_tsx.default, {
|
|
62
63
|
label: (0, _wordpress_i18n.__)("Fine rotation"),
|
|
63
|
-
min: -
|
|
64
|
-
max:
|
|
64
|
+
min: -maxRotationOffset,
|
|
65
|
+
max: maxRotationOffset,
|
|
65
66
|
value: fineOffset,
|
|
66
67
|
onChange: handleRotationSlider,
|
|
67
68
|
disabled
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useMediaEditor","useCropGestureHandlers","
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useMediaEditor","useCropGestureHandlers","RotationRuler","__"],"sources":["../../../src/components/media-editor-fine-rotation/index.tsx"],"sourcesContent":["import { __ } from '@wordpress/i18n';\nimport { useMediaEditor } from '../../state';\nimport { useCropGestureHandlers } from '../../hooks/use-crop-gesture-handlers';\nimport RotationRuler from '../rotation-ruler';\n\nexport interface MediaEditorFineRotationProps {\n\t/** Signal that a placement-oriented control is being adjusted. */\n\tonPlacementControlInteraction?: () => void;\n\t/**\n\t * Disable the ruler. Set while the edit is saving; `RotationRuler`\n\t * cancels an in-flight drag when this flips.\n\t */\n\tdisabled?: boolean;\n}\n\n/**\n * Fine-rotation slider for the media editor. It renders under the canvas so it\n * stays constrained to the canvas column at all viewport sizes. Lives\n * separately from the snap-rotate / flip buttons so the two can be placed\n * independently per viewport.\n *\n * @param props\n * @param props.onPlacementControlInteraction\n * @param props.disabled\n */\nexport default function MediaEditorFineRotation( {\n\tonPlacementControlInteraction,\n\tdisabled = false,\n}: MediaEditorFineRotationProps ) {\n\tconst { state, setRotation, maxRotationOffset } =\n\t\tuseMediaEditor().imageEditor;\n\t// `commitOnKeyUp: false` lets rapid arrow-key adjustments coalesce\n\t// into one undo entry via the gesture idle window. Pointer-up still\n\t// closes pointer drags immediately.\n\tconst rotationGestureHandlers = useCropGestureHandlers( {\n\t\tcommitOnKeyUp: false,\n\t} );\n\n\t// `setRotation` is an absolute-angle setter. When a single flip is active\n\t// the visual direction inverts, so slider input must flip sign to match\n\t// what the user sees. `snapRotate90` already handles this internally.\n\tconst baseAngle = Math.round( state.rotation / 90 ) * 90;\n\tconst singleFlip = state.flip.horizontal !== state.flip.vertical;\n\tconst visualDir = singleFlip ? -1 : 1;\n\tconst fineOffset = ( state.rotation - baseAngle ) * visualDir;\n\n\tconst handleRotationSlider = ( value: number ) => {\n\t\t// Clamp strictly inside [-MAX, MAX). Exactly ±MAX lands state on a\n\t\t// 90° midpoint and flips the derived baseAngle on the next render,\n\t\t// causing subsequent events to spiral.\n\t\tconst EPS = 0.01;\n\t\tconst clamped = Math.max(\n\t\t\t-maxRotationOffset + EPS,\n\t\t\tMath.min( maxRotationOffset - EPS, value )\n\t\t);\n\t\tonPlacementControlInteraction?.();\n\t\tsetRotation( baseAngle + clamped * visualDir );\n\t};\n\n\treturn (\n\t\t<div\n\t\t\trole=\"presentation\"\n\t\t\tclassName=\"media-editor-fine-rotation\"\n\t\t\t{ ...rotationGestureHandlers }\n\t\t>\n\t\t\t<RotationRuler\n\t\t\t\tlabel={ __( 'Fine rotation' ) }\n\t\t\t\tmin={ -maxRotationOffset }\n\t\t\t\tmax={ maxRotationOffset }\n\t\t\t\tvalue={ fineOffset }\n\t\t\t\tonChange={ handleRotationSlider }\n\t\t\t\tdisabled={ disabled }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAwB,wBAAyB,EAChD,+BACA,WAAW,SACsB;CACjC,MAAM,EAAE,OAAO,aAAa,uBAAA,GAC3BA,qBAAAA,eAAAA,CAAe,CAAC,CAAC;CAIlB,MAAM,2BAAA,GAA0BC,yCAAAA,uBAAAA,CAAwB,EACvD,eAAe,MAChB,CAAE;CAKF,MAAM,YAAY,KAAK,MAAO,MAAM,WAAW,EAAG,IAAI;CAEtD,MAAM,YADa,MAAM,KAAK,eAAe,MAAM,KAAK,WACzB,KAAK;CACpC,MAAM,cAAe,MAAM,WAAW,aAAc;CAEpD,MAAM,wBAAyB,UAAmB;EAIjD,MAAM,MAAM;EACZ,MAAM,UAAU,KAAK,IACpB,CAAC,oBAAoB,KACrB,KAAK,IAAK,oBAAoB,KAAK,KAAM,CAC1C;EACA,gCAAgC;EAChC,YAAa,YAAY,UAAU,SAAU;CAC9C;CAEA,OACC,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;EACC,MAAK;EACL,WAAU;EACV,GAAK;EAEL,UAAA,iBAAA,GAAA,kBAAA,IAAA,CAACC,4BAAAA,SAAD;GACC,QAAA,GAAQC,gBAAAA,GAAAA,CAAI,eAAgB;GAC5B,KAAM,CAAC;GACP,KAAM;GACN,OAAQ;GACR,UAAW;GACA;EACX,CAAA;CACG,CAAA;AAEP"}
|
|
@@ -8,8 +8,6 @@ let _wordpress_ui = require("@wordpress/ui");
|
|
|
8
8
|
let _wordpress_i18n = require("@wordpress/i18n");
|
|
9
9
|
let _wordpress_icons = require("@wordpress/icons");
|
|
10
10
|
let ______state_index_ts = require("../../state/index.cjs");
|
|
11
|
-
let ______image_editor_core_constants_ts = require("../../image-editor/core/constants.cjs");
|
|
12
|
-
let ______image_editor_core_containment_ts = require("../../image-editor/core/containment.cjs");
|
|
13
11
|
let ___media_editor_use_crop_options_ts = require("../media-editor/use-crop-options.cjs");
|
|
14
12
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
15
13
|
// packages/media-editor/src/components/media-editor-image-controls/index.tsx
|
|
@@ -35,12 +33,11 @@ const DEFAULT_ZOOM_FACTOR = 1.2;
|
|
|
35
33
|
* @param props.disabled
|
|
36
34
|
*/
|
|
37
35
|
function MediaEditorImageControls({ withLabels = false, showAspectRatioControl = false, aspectRatioPresets, zoomFactor = DEFAULT_ZOOM_FACTOR, disabled = false }) {
|
|
38
|
-
const { state, setFlip, snapRotate90, setZoom } = (0, ______state_index_ts.useMediaEditor)().
|
|
36
|
+
const { state, setFlip, snapRotate90, setZoom, minZoom, maxZoom } = (0, ______state_index_ts.useMediaEditor)().imageEditor;
|
|
39
37
|
const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } = (0, ___media_editor_use_crop_options_ts.useCropOptions)({ aspectRatioPresets });
|
|
40
38
|
const hasAspectRatioControl = !withLabels && showAspectRatioControl;
|
|
41
|
-
const minZoom = (0, ______image_editor_core_containment_ts.getMinZoom)(state);
|
|
42
39
|
const zoomByFactor = (factor) => {
|
|
43
|
-
setZoom(Math.min(
|
|
40
|
+
setZoom(Math.min(maxZoom, Math.max(minZoom, state.zoom * factor)));
|
|
44
41
|
};
|
|
45
42
|
const rotateButtons = /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
|
|
46
43
|
size: "compact",
|
|
@@ -89,7 +86,7 @@ function MediaEditorImageControls({ withLabels = false, showAspectRatioControl =
|
|
|
89
86
|
icon: _wordpress_icons.plus,
|
|
90
87
|
label: (0, _wordpress_i18n.__)("Zoom in"),
|
|
91
88
|
showTooltip: true,
|
|
92
|
-
disabled: disabled || state.zoom >=
|
|
89
|
+
disabled: disabled || state.zoom >= maxZoom,
|
|
93
90
|
accessibleWhenDisabled: true,
|
|
94
91
|
onClick: () => zoomByFactor(zoomFactor)
|
|
95
92
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_components.Button, {
|
|
@@ -123,6 +120,7 @@ function MediaEditorImageControls({ withLabels = false, showAspectRatioControl =
|
|
|
123
120
|
value: preset.value.toString(),
|
|
124
121
|
closeOnClick: true,
|
|
125
122
|
disabled,
|
|
123
|
+
prefix: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.PrefixIcon, { icon: (0, _wordpress_icons.getAspectRatioIcon)(preset.value) }),
|
|
126
124
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Menu.ItemLabel, { children: preset.label })
|
|
127
125
|
}, preset.value))]
|
|
128
126
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["useMediaEditor","useCropOptions","getMinZoom","MAX_ZOOM","Button","rotateLeft","__","rotateRight","flipHorizontal","flipVertical","plus","lineSolid","Menu","aspectRatioIcon"],"sources":["../../../src/components/media-editor-image-controls/index.tsx"],"sourcesContent":["import { Button } from '@wordpress/components';\nimport {\n\t// eslint-disable-next-line @wordpress/use-recommended-components -- Intentional early adoption of the new Menu, pending WordPress/gutenberg#76135.\n\tMenu,\n} from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport {\n\taspectRatio as aspectRatioIcon,\n\trotateLeft,\n\trotateRight,\n\tflipHorizontal,\n\tflipVertical,\n\tlineSolid,\n\tplus,\n} from '@wordpress/icons';\nimport { useMediaEditor } from '../../state';\nimport {\n\tMAX_ZOOM,\n\ttype AspectRatioPreset,\n} from '../../image-editor/core/constants';\nimport { getMinZoom } from '../../image-editor/core/containment';\nimport { useCropOptions } from '../media-editor/use-crop-options';\n\n/**\n * Default zoom factor per +/- click. Zooming is geometric, so a fixed\n * multiplier — rather than an additive step — makes each click feel like the\n * same amount of zoom at any level (an additive `+0.1` is a 10% jump at 1× but\n * a ~1% nudge at 10×). `1.2` is ~+20% per click. Overridable via the\n * `zoomFactor` prop.\n */\nexport const DEFAULT_ZOOM_FACTOR = 1.2;\n\nexport interface MediaEditorImageControlsProps {\n\t/**\n\t * When `true`, render rotate, flip and zoom as labelled groups — the Crop\n\t * panel layout used on wide viewports. When `false` (default), render a\n\t * single flat row of icon buttons — the footer layout used at narrower\n\t * widths.\n\t */\n\twithLabels?: boolean;\n\t/**\n\t * When `true`, include an aspect-ratio dropdown in the flat toolbar.\n\t * Omitted from the labelled panel layout because the Crop panel already\n\t * renders the full aspect-ratio select control.\n\t */\n\tshowAspectRatioControl?: boolean;\n\t/** Optional caller-supplied aspect-ratio presets. */\n\taspectRatioPresets?: AspectRatioPreset[];\n\t/**\n\t * Multiplier applied to the zoom per +/- click — zoom in multiplies by it,\n\t * zoom out divides by it. Must be greater than 1. Defaults to\n\t * `DEFAULT_ZOOM_FACTOR` (1.2).\n\t */\n\tzoomFactor?: number;\n\t/**\n\t * Disable every control. Set while the edit is saving, so the crop the\n\t * request was built from cannot change under it.\n\t */\n\tdisabled?: boolean;\n}\n\n/**\n * Image editing controls placed independently per viewport: on wide viewports\n * rotate/flip/zoom render inside the Crop panel (`withLabels`), and at narrower\n * widths they fall back into the footer toolbar (flat row), where the\n * aspect-ratio dropdown can also be shown.\n *\n * @param props\n * @param props.withLabels\n * @param props.showAspectRatioControl\n * @param props.aspectRatioPresets\n * @param props.zoomFactor\n * @param props.disabled\n */\nexport default function MediaEditorImageControls( {\n\twithLabels = false,\n\tshowAspectRatioControl = false,\n\taspectRatioPresets,\n\tzoomFactor = DEFAULT_ZOOM_FACTOR,\n\tdisabled = false,\n}: MediaEditorImageControlsProps ) {\n\tconst { state, setFlip, snapRotate90, setZoom } = useMediaEditor().cropper;\n\tconst { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } =\n\t\tuseCropOptions( { aspectRatioPresets } );\n\tconst hasAspectRatioControl = ! withLabels && showAspectRatioControl;\n\tconst minZoom = getMinZoom( state );\n\tconst zoomByFactor = ( factor: number ) => {\n\t\tsetZoom(\n\t\t\tMath.min( MAX_ZOOM, Math.max( minZoom, state.zoom * factor ) )\n\t\t);\n\t};\n\n\tconst rotateButtons = (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateLeft }\n\t\t\t\tlabel={ __( 'Rotate 90° counter-clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => snapRotate90( -1 ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateRight }\n\t\t\t\tlabel={ __( 'Rotate 90° clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => snapRotate90( 1 ) }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst flipButtons = (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipHorizontal }\n\t\t\t\tlabel={ __( 'Flip horizontal' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.horizontal }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: ! state.flip.horizontal,\n\t\t\t\t\t\tvertical: state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipVertical }\n\t\t\t\tlabel={ __( 'Flip vertical' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.vertical }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: state.flip.horizontal,\n\t\t\t\t\t\tvertical: ! state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst zoomButtons = (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ plus }\n\t\t\t\tlabel={ __( 'Zoom in' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled || state.zoom >= MAX_ZOOM }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => zoomByFactor( zoomFactor ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ lineSolid }\n\t\t\t\tlabel={ __( 'Zoom out' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled || state.zoom <= minZoom }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => zoomByFactor( 1 / zoomFactor ) }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst aspectRatioDropdown = hasAspectRatioControl ? (\n\t\t<Menu.Root>\n\t\t\t<Menu.Trigger\n\t\t\t\tdisabled={ disabled }\n\t\t\t\trender={\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\ticon={ aspectRatioIcon }\n\t\t\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Menu.Popup\n\t\t\t\tpositioner={ <Menu.Positioner side=\"top\" align=\"center\" /> }\n\t\t\t>\n\t\t\t\t<Menu.RadioGroup\n\t\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\t\tonValueChange={ ( value ) => {\n\t\t\t\t\t\tif ( ! disabled ) {\n\t\t\t\t\t\t\tsetAspectRatioValue( value );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<Menu.GroupLabel>{ __( 'Aspect ratio' ) }</Menu.GroupLabel>\n\t\t\t\t\t{ aspectRatioOptions.map( ( preset ) => (\n\t\t\t\t\t\t<Menu.RadioItem\n\t\t\t\t\t\t\tkey={ preset.value }\n\t\t\t\t\t\t\tvalue={ preset.value.toString() }\n\t\t\t\t\t\t\tcloseOnClick\n\t\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Menu.ItemLabel>{ preset.label }</Menu.ItemLabel>\n\t\t\t\t\t\t</Menu.RadioItem>\n\t\t\t\t\t) ) }\n\t\t\t\t</Menu.RadioGroup>\n\t\t\t</Menu.Popup>\n\t\t</Menu.Root>\n\t) : null;\n\n\tif ( withLabels ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-image-controls is-stacked\">\n\t\t\t\t<div className=\"media-editor-image-controls__transforms\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"media-editor-image-controls__group\"\n\t\t\t\t\t\trole=\"group\"\n\t\t\t\t\t\taria-label={ __( 'Rotate' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"media-editor-image-controls__label\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Rotate' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<div className=\"media-editor-image-controls__buttons\">\n\t\t\t\t\t\t\t{ rotateButtons }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"media-editor-image-controls__group\"\n\t\t\t\t\t\trole=\"group\"\n\t\t\t\t\t\taria-label={ __( 'Flip' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"media-editor-image-controls__label\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Flip' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<div className=\"media-editor-image-controls__buttons\">\n\t\t\t\t\t\t\t{ flipButtons }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"media-editor-image-controls__group\"\n\t\t\t\t\trole=\"group\"\n\t\t\t\t\taria-label={ __( 'Zoom' ) }\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName=\"media-editor-image-controls__label\"\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Zoom' ) }\n\t\t\t\t\t</span>\n\t\t\t\t\t<div className=\"media-editor-image-controls__buttons\">\n\t\t\t\t\t\t{ zoomButtons }\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div className=\"media-editor-image-controls\">\n\t\t\t{ rotateButtons }\n\t\t\t{ flipButtons }\n\t\t\t{ zoomButtons }\n\t\t\t{ aspectRatioDropdown }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA8BA,MAAa,sBAAsB;;;;;;;;;;;;;;AA4CnC,SAAwB,yBAA0B,EAC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A,CAAC,OAAD;IACC,WAAU;IACV,MAAK;IACL,eAAA,GAAaA,gBAAAA,GAAAA,CAAI,MAAO;IAHzB,UAAA,CAKC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;KACC,WAAU;KACV,eAAY;KAEVA,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,MAAO;IACR,CAAA,GACN,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;KAAK,WAAU;KACZ,UAAA;IACE,CAAA,CACD;GACD,CAAA,CAAA;EACL,CAAA,GAAA,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;GACC,WAAU;GACV,MAAK;GACL,eAAA,GAAaA,gBAAAA,GAAAA,CAAI,MAAO;GAHzB,UAAA,CAKC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;IACC,WAAU;IACV,eAAY;IAEVA,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,MAAO;GACR,CAAA,GACN,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,WAAU;IACZ,UAAA;GACE,CAAA,CACD;EACD,CAAA,CAAA;;CAIP,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACG;GACA;GACA;GACA;EACE;;AAEP"}
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["useMediaEditor","useCropOptions","Button","rotateLeft","__","rotateRight","flipHorizontal","flipVertical","plus","lineSolid","Menu","aspectRatioIcon","getAspectRatioIcon"],"sources":["../../../src/components/media-editor-image-controls/index.tsx"],"sourcesContent":["import { Button } from '@wordpress/components';\nimport {\n\t// eslint-disable-next-line @wordpress/use-recommended-components -- Intentional early adoption of the new Menu, pending WordPress/gutenberg#76135.\n\tMenu,\n} from '@wordpress/ui';\nimport { __ } from '@wordpress/i18n';\nimport {\n\taspectRatio as aspectRatioIcon,\n\tgetAspectRatioIcon,\n\trotateLeft,\n\trotateRight,\n\tflipHorizontal,\n\tflipVertical,\n\tlineSolid,\n\tplus,\n} from '@wordpress/icons';\nimport { useMediaEditor } from '../../state';\nimport type { AspectRatioPreset } from '../../state/aspect-ratio-presets';\nimport { useCropOptions } from '../media-editor/use-crop-options';\n\n/**\n * Default zoom factor per +/- click. Zooming is geometric, so a fixed\n * multiplier — rather than an additive step — makes each click feel like the\n * same amount of zoom at any level (an additive `+0.1` is a 10% jump at 1× but\n * a ~1% nudge at 10×). `1.2` is ~+20% per click. Overridable via the\n * `zoomFactor` prop.\n */\nexport const DEFAULT_ZOOM_FACTOR = 1.2;\n\nexport interface MediaEditorImageControlsProps {\n\t/**\n\t * When `true`, render rotate, flip and zoom as labelled groups — the Crop\n\t * panel layout used on wide viewports. When `false` (default), render a\n\t * single flat row of icon buttons — the footer layout used at narrower\n\t * widths.\n\t */\n\twithLabels?: boolean;\n\t/**\n\t * When `true`, include an aspect-ratio dropdown in the flat toolbar.\n\t * Omitted from the labelled panel layout because the Crop panel already\n\t * renders the full aspect-ratio select control.\n\t */\n\tshowAspectRatioControl?: boolean;\n\t/** Optional caller-supplied aspect-ratio presets. */\n\taspectRatioPresets?: AspectRatioPreset[];\n\t/**\n\t * Multiplier applied to the zoom per +/- click — zoom in multiplies by it,\n\t * zoom out divides by it. Must be greater than 1. Defaults to\n\t * `DEFAULT_ZOOM_FACTOR` (1.2).\n\t */\n\tzoomFactor?: number;\n\t/**\n\t * Disable every control. Set while the edit is saving, so the crop the\n\t * request was built from cannot change under it.\n\t */\n\tdisabled?: boolean;\n}\n\n/**\n * Image editing controls placed independently per viewport: on wide viewports\n * rotate/flip/zoom render inside the Crop panel (`withLabels`), and at narrower\n * widths they fall back into the footer toolbar (flat row), where the\n * aspect-ratio dropdown can also be shown.\n *\n * @param props\n * @param props.withLabels\n * @param props.showAspectRatioControl\n * @param props.aspectRatioPresets\n * @param props.zoomFactor\n * @param props.disabled\n */\nexport default function MediaEditorImageControls( {\n\twithLabels = false,\n\tshowAspectRatioControl = false,\n\taspectRatioPresets,\n\tzoomFactor = DEFAULT_ZOOM_FACTOR,\n\tdisabled = false,\n}: MediaEditorImageControlsProps ) {\n\tconst { state, setFlip, snapRotate90, setZoom, minZoom, maxZoom } =\n\t\tuseMediaEditor().imageEditor;\n\tconst { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } =\n\t\tuseCropOptions( { aspectRatioPresets } );\n\tconst hasAspectRatioControl = ! withLabels && showAspectRatioControl;\n\tconst zoomByFactor = ( factor: number ) => {\n\t\tsetZoom(\n\t\t\tMath.min( maxZoom, Math.max( minZoom, state.zoom * factor ) )\n\t\t);\n\t};\n\n\tconst rotateButtons = (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateLeft }\n\t\t\t\tlabel={ __( 'Rotate 90° counter-clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => snapRotate90( -1 ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateRight }\n\t\t\t\tlabel={ __( 'Rotate 90° clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => snapRotate90( 1 ) }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst flipButtons = (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipHorizontal }\n\t\t\t\tlabel={ __( 'Flip horizontal' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.horizontal }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: ! state.flip.horizontal,\n\t\t\t\t\t\tvertical: state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipVertical }\n\t\t\t\tlabel={ __( 'Flip vertical' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.vertical }\n\t\t\t\tdisabled={ disabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: state.flip.horizontal,\n\t\t\t\t\t\tvertical: ! state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst zoomButtons = (\n\t\t<>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ plus }\n\t\t\t\tlabel={ __( 'Zoom in' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled || state.zoom >= maxZoom }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => zoomByFactor( zoomFactor ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ lineSolid }\n\t\t\t\tlabel={ __( 'Zoom out' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tdisabled={ disabled || state.zoom <= minZoom }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tonClick={ () => zoomByFactor( 1 / zoomFactor ) }\n\t\t\t/>\n\t\t</>\n\t);\n\n\tconst aspectRatioDropdown = hasAspectRatioControl ? (\n\t\t<Menu.Root>\n\t\t\t<Menu.Trigger\n\t\t\t\tdisabled={ disabled }\n\t\t\t\trender={\n\t\t\t\t\t<Button\n\t\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\t\ticon={ aspectRatioIcon }\n\t\t\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Menu.Popup\n\t\t\t\tpositioner={ <Menu.Positioner side=\"top\" align=\"center\" /> }\n\t\t\t>\n\t\t\t\t<Menu.RadioGroup\n\t\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\t\tonValueChange={ ( value ) => {\n\t\t\t\t\t\tif ( ! disabled ) {\n\t\t\t\t\t\t\tsetAspectRatioValue( value );\n\t\t\t\t\t\t}\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<Menu.GroupLabel>{ __( 'Aspect ratio' ) }</Menu.GroupLabel>\n\t\t\t\t\t{ aspectRatioOptions.map( ( preset ) => (\n\t\t\t\t\t\t<Menu.RadioItem\n\t\t\t\t\t\t\tkey={ preset.value }\n\t\t\t\t\t\t\tvalue={ preset.value.toString() }\n\t\t\t\t\t\t\tcloseOnClick\n\t\t\t\t\t\t\tdisabled={ disabled }\n\t\t\t\t\t\t\tprefix={\n\t\t\t\t\t\t\t\t<Menu.PrefixIcon\n\t\t\t\t\t\t\t\t\ticon={ getAspectRatioIcon( preset.value ) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<Menu.ItemLabel>{ preset.label }</Menu.ItemLabel>\n\t\t\t\t\t\t</Menu.RadioItem>\n\t\t\t\t\t) ) }\n\t\t\t\t</Menu.RadioGroup>\n\t\t\t</Menu.Popup>\n\t\t</Menu.Root>\n\t) : null;\n\n\tif ( withLabels ) {\n\t\treturn (\n\t\t\t<div className=\"media-editor-image-controls is-stacked\">\n\t\t\t\t<div className=\"media-editor-image-controls__transforms\">\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"media-editor-image-controls__group\"\n\t\t\t\t\t\trole=\"group\"\n\t\t\t\t\t\taria-label={ __( 'Rotate' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"media-editor-image-controls__label\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Rotate' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<div className=\"media-editor-image-controls__buttons\">\n\t\t\t\t\t\t\t{ rotateButtons }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t\t<div\n\t\t\t\t\t\tclassName=\"media-editor-image-controls__group\"\n\t\t\t\t\t\trole=\"group\"\n\t\t\t\t\t\taria-label={ __( 'Flip' ) }\n\t\t\t\t\t>\n\t\t\t\t\t\t<span\n\t\t\t\t\t\t\tclassName=\"media-editor-image-controls__label\"\n\t\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Flip' ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<div className=\"media-editor-image-controls__buttons\">\n\t\t\t\t\t\t\t{ flipButtons }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t\t<div\n\t\t\t\t\tclassName=\"media-editor-image-controls__group\"\n\t\t\t\t\trole=\"group\"\n\t\t\t\t\taria-label={ __( 'Zoom' ) }\n\t\t\t\t>\n\t\t\t\t\t<span\n\t\t\t\t\t\tclassName=\"media-editor-image-controls__label\"\n\t\t\t\t\t\taria-hidden=\"true\"\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Zoom' ) }\n\t\t\t\t\t</span>\n\t\t\t\t\t<div className=\"media-editor-image-controls__buttons\">\n\t\t\t\t\t\t{ zoomButtons }\n\t\t\t\t\t</div>\n\t\t\t\t</div>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div className=\"media-editor-image-controls\">\n\t\t\t{ rotateButtons }\n\t\t\t{ flipButtons }\n\t\t\t{ zoomButtons }\n\t\t\t{ aspectRatioDropdown }\n\t\t</div>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2BA,MAAa,sBAAsB;;;;;;;;;;;;;;AA4CnC,SAAwB,yBAA0B,EACjD,aAAa,OACb,yBAAyB,OACzB,oBACA,aAAa,qBACb,WAAW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A,GAAA,kBAAA,KAAA,CAAC,OAAD;IACC,WAAU;IACV,MAAK;IACL,eAAA,GAAaA,gBAAAA,GAAAA,CAAI,MAAO;IAHzB,UAAA,CAKC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;KACC,WAAU;KACV,eAAY;KAEVA,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,MAAO;IACR,CAAA,GACN,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;KAAK,WAAU;KACZ,UAAA;IACE,CAAA,CACD;GACD,CAAA,CAAA;EACL,CAAA,GAAA,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;GACC,WAAU;GACV,MAAK;GACL,eAAA,GAAaA,gBAAAA,GAAAA,CAAI,MAAO;GAHzB,UAAA,CAKC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;IACC,WAAU;IACV,eAAY;IAEVA,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,MAAO;GACR,CAAA,GACN,iBAAA,GAAA,kBAAA,IAAA,CAAC,OAAD;IAAK,WAAU;IACZ,UAAA;GACE,CAAA,CACD;EACD,CAAA,CAAA;;CAIP,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EAAK,WAAU;EAAf,UAAA;GACG;GACA;GACA;GACA;EACE;;AAEP"}
|
|
@@ -7,6 +7,7 @@ let _wordpress_components = require("@wordpress/components");
|
|
|
7
7
|
let _wordpress_element = require("@wordpress/element");
|
|
8
8
|
let _wordpress_i18n = require("@wordpress/i18n");
|
|
9
9
|
let _wordpress_keycodes = require("@wordpress/keycodes");
|
|
10
|
+
let _wordpress_ui = require("@wordpress/ui");
|
|
10
11
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
11
12
|
// packages/media-editor/src/components/media-editor-keyboard-shortcuts-modal/index.tsx
|
|
12
13
|
const SHORTCUTS = [
|
|
@@ -26,15 +27,13 @@ const SHORTCUTS = [
|
|
|
26
27
|
},
|
|
27
28
|
{
|
|
28
29
|
description: (0, _wordpress_i18n.__)("Pan"),
|
|
29
|
-
keyCombination: {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
ariaLabel: (0, _wordpress_i18n.__)("Arrow keys")
|
|
37
|
-
}
|
|
30
|
+
keyCombination: { character: [
|
|
31
|
+
"↑",
|
|
32
|
+
"↓",
|
|
33
|
+
"←",
|
|
34
|
+
"→"
|
|
35
|
+
] },
|
|
36
|
+
label: (0, _wordpress_i18n.__)("Arrow keys")
|
|
38
37
|
},
|
|
39
38
|
{
|
|
40
39
|
description: (0, _wordpress_i18n.__)("Zoom in"),
|
|
@@ -72,30 +71,31 @@ const SHORTCUTS = [
|
|
|
72
71
|
"↓",
|
|
73
72
|
"←",
|
|
74
73
|
"→"
|
|
75
|
-
]
|
|
76
|
-
|
|
77
|
-
|
|
74
|
+
]
|
|
75
|
+
},
|
|
76
|
+
label: (0, _wordpress_i18n.__)("Shift + Arrow keys")
|
|
78
77
|
}
|
|
79
78
|
];
|
|
80
|
-
function KeyCombinationDisplay({ keyCombination }) {
|
|
81
|
-
const {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
let label;
|
|
89
|
-
if (ariaLabel) label = ariaLabel;
|
|
90
|
-
else if (modifier) label = _wordpress_keycodes.shortcutAriaLabel[modifier](charString);
|
|
91
|
-
else label = charString;
|
|
92
|
-
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)("kbd", {
|
|
79
|
+
function KeyCombinationDisplay({ keyCombination, label }) {
|
|
80
|
+
const { character, modifier } = keyCombination;
|
|
81
|
+
const normalizedModifier = modifier ?? "undefined";
|
|
82
|
+
const characters = Array.isArray(character) ? character : [character];
|
|
83
|
+
const formatted = _wordpress_keycodes.displayShortcutList[normalizedModifier](characters[0] ?? "");
|
|
84
|
+
const prefix = formatted.slice(0, -1);
|
|
85
|
+
const keys = Array.isArray(character) ? [...prefix, ...character] : formatted;
|
|
86
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("kbd", {
|
|
93
87
|
className: "media-editor-keyboard-shortcuts-modal__shortcut-term",
|
|
94
|
-
"
|
|
95
|
-
children:
|
|
96
|
-
|
|
97
|
-
children:
|
|
98
|
-
},
|
|
88
|
+
dir: "ltr",
|
|
89
|
+
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.VisuallyHidden, {
|
|
90
|
+
render: /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {}),
|
|
91
|
+
children: label || _wordpress_keycodes.shortcutAriaLabel[normalizedModifier](characters.join(""))
|
|
92
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
93
|
+
"aria-hidden": "true",
|
|
94
|
+
children: keys.map((key, keyIndex) => key === "+" && keyIndex < prefix.length ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_element.Fragment, { children: key }, keyIndex) : /* @__PURE__ */ (0, react_jsx_runtime.jsx)("kbd", {
|
|
95
|
+
className: "media-editor-keyboard-shortcuts-modal__shortcut-key",
|
|
96
|
+
children: key
|
|
97
|
+
}, keyIndex))
|
|
98
|
+
})]
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
function MediaEditorKeyboardShortcutsModal({ onClose }) {
|
|
@@ -109,12 +109,12 @@ function MediaEditorKeyboardShortcutsModal({ onClose }) {
|
|
|
109
109
|
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)("ul", {
|
|
110
110
|
className: "media-editor-keyboard-shortcuts-modal__shortcut-list",
|
|
111
111
|
role: "list",
|
|
112
|
-
children: SHORTCUTS.map((
|
|
112
|
+
children: SHORTCUTS.map((shortcut, index) => /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("li", {
|
|
113
113
|
className: "media-editor-keyboard-shortcuts-modal__shortcut",
|
|
114
114
|
children: [/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
115
115
|
className: "media-editor-keyboard-shortcuts-modal__shortcut-description",
|
|
116
|
-
children: description
|
|
117
|
-
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(KeyCombinationDisplay, {
|
|
116
|
+
children: shortcut.description
|
|
117
|
+
}), /* @__PURE__ */ (0, react_jsx_runtime.jsx)(KeyCombinationDisplay, { ...shortcut })]
|
|
118
118
|
}, index))
|
|
119
119
|
})]
|
|
120
120
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["__","displayShortcutList","shortcutAriaLabel","Fragment","Modal"],"sources":["../../../src/components/media-editor-keyboard-shortcuts-modal/index.tsx"],"sourcesContent":["import { Modal } from '@wordpress/components';\nimport { Fragment } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tdisplayShortcutList,\n\tshortcutAriaLabel,\n\ttype WPKeycodeModifier,\n} from '@wordpress/keycodes';\n\
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["__","displayShortcutList","VisuallyHidden","shortcutAriaLabel","Fragment","Modal"],"sources":["../../../src/components/media-editor-keyboard-shortcuts-modal/index.tsx"],"sourcesContent":["import { Modal } from '@wordpress/components';\nimport { Fragment } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tdisplayShortcutList,\n\tshortcutAriaLabel,\n\ttype WPKeycodeModifier,\n} from '@wordpress/keycodes';\nimport { VisuallyHidden } from '@wordpress/ui';\n\ntype KeyCombinationDisplayProps =\n\t| {\n\t\t\tkeyCombination: {\n\t\t\t\tcharacter: string;\n\t\t\t\tmodifier?: WPKeycodeModifier | null;\n\t\t\t};\n\t\t\tlabel?: string;\n\t }\n\t| {\n\t\t\tkeyCombination: {\n\t\t\t\tcharacter: string[];\n\t\t\t\tmodifier?: WPKeycodeModifier | null;\n\t\t\t};\n\t\t\tlabel: string;\n\t };\n\ntype ShortcutEntry = KeyCombinationDisplayProps & {\n\tdescription: string;\n};\n\nconst SHORTCUTS: ShortcutEntry[] = [\n\t{\n\t\tdescription: __( 'Undo' ),\n\t\tkeyCombination: { modifier: 'primary', character: 'z' },\n\t},\n\t{\n\t\tdescription: __( 'Redo' ),\n\t\tkeyCombination: { modifier: 'primaryShift', character: 'z' },\n\t},\n\t{\n\t\tdescription: __( 'Pan' ),\n\t\tkeyCombination: {\n\t\t\tcharacter: [ '↑', '↓', '←', '→' ],\n\t\t},\n\t\tlabel: __( 'Arrow keys' ),\n\t},\n\t{\n\t\tdescription: __( 'Zoom in' ),\n\t\tkeyCombination: { character: '+' },\n\t},\n\t{\n\t\tdescription: __( 'Zoom out' ),\n\t\tkeyCombination: { character: '-' },\n\t},\n\t{\n\t\tdescription: __( 'Rotate 90° clockwise' ),\n\t\tkeyCombination: { character: 'R' },\n\t},\n\t{\n\t\tdescription: __( 'Rotate 90° counter-clockwise' ),\n\t\tkeyCombination: { modifier: 'shift', character: 'R' },\n\t},\n\t{\n\t\tdescription: __( 'Flip horizontal' ),\n\t\tkeyCombination: { character: 'H' },\n\t},\n\t{\n\t\tdescription: __( 'Flip vertical' ),\n\t\tkeyCombination: { character: 'V' },\n\t},\n\t{\n\t\tdescription: __( 'Pan or resize crop (large step)' ),\n\t\tkeyCombination: {\n\t\t\tmodifier: 'shift',\n\t\t\tcharacter: [ '↑', '↓', '←', '→' ],\n\t\t},\n\t\tlabel: __( 'Shift + Arrow keys' ),\n\t},\n];\n\nfunction KeyCombinationDisplay( {\n\tkeyCombination,\n\tlabel,\n}: KeyCombinationDisplayProps ) {\n\tconst { character, modifier } = keyCombination;\n\tconst normalizedModifier = modifier ?? 'undefined';\n\tconst characters = Array.isArray( character ) ? character : [ character ];\n\tconst formatted = displayShortcutList[ normalizedModifier ](\n\t\tcharacters[ 0 ] ?? ''\n\t);\n\tconst prefix = formatted.slice( 0, -1 );\n\tconst keys = Array.isArray( character )\n\t\t? [ ...prefix, ...character ]\n\t\t: formatted;\n\n\treturn (\n\t\t<kbd\n\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut-term\"\n\t\t\tdir=\"ltr\"\n\t\t>\n\t\t\t<VisuallyHidden render={ <span /> }>\n\t\t\t\t{ label ||\n\t\t\t\t\tshortcutAriaLabel[ normalizedModifier ](\n\t\t\t\t\t\tcharacters.join( '' )\n\t\t\t\t\t) }\n\t\t\t</VisuallyHidden>\n\t\t\t<span aria-hidden=\"true\">\n\t\t\t\t{ keys.map( ( key, keyIndex ) =>\n\t\t\t\t\tkey === '+' && keyIndex < prefix.length ? (\n\t\t\t\t\t\t<Fragment key={ keyIndex }>{ key }</Fragment>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<kbd\n\t\t\t\t\t\t\tkey={ keyIndex }\n\t\t\t\t\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut-key\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ key }\n\t\t\t\t\t\t</kbd>\n\t\t\t\t\t)\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</kbd>\n\t);\n}\n\ninterface MediaEditorKeyboardShortcutsModalProps {\n\tonClose: () => void;\n}\n\nexport default function MediaEditorKeyboardShortcutsModal( {\n\tonClose,\n}: MediaEditorKeyboardShortcutsModalProps ) {\n\treturn (\n\t\t<Modal\n\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal\"\n\t\t\ttitle={ __( 'Keyboard shortcuts' ) }\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<p className=\"media-editor-keyboard-shortcuts-modal__note\">\n\t\t\t\t{ __(\n\t\t\t\t\t'These shortcuts work when the image editor has focus.'\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t{ /*\n\t\t\t * Disable reason: The `list` ARIA role is redundant but\n\t\t\t * Safari+VoiceOver won't announce the list otherwise.\n\t\t\t */ }\n\t\t\t{ /* eslint-disable jsx-a11y/no-redundant-roles */ }\n\t\t\t<ul\n\t\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut-list\"\n\t\t\t\trole=\"list\"\n\t\t\t>\n\t\t\t\t{ SHORTCUTS.map( ( shortcut, index ) => (\n\t\t\t\t\t<li\n\t\t\t\t\t\tkey={ index }\n\t\t\t\t\t\tclassName=\"media-editor-keyboard-shortcuts-modal__shortcut\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<span className=\"media-editor-keyboard-shortcuts-modal__shortcut-description\">\n\t\t\t\t\t\t\t{ shortcut.description }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t<KeyCombinationDisplay { ...shortcut } />\n\t\t\t\t\t</li>\n\t\t\t\t) ) }\n\t\t\t</ul>\n\t\t\t{ /* eslint-enable jsx-a11y/no-redundant-roles */ }\n\t\t</Modal>\n\t);\n}\n"],"mappings":";;;;;;;;;;;;AA8BA,MAAM,YAA6B;CAClC;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,MAAO;EACxB,gBAAgB;GAAE,UAAU;GAAW,WAAW;EAAI;CACvD;CACA;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,MAAO;EACxB,gBAAgB;GAAE,UAAU;GAAgB,WAAW;EAAI;CAC5D;CACA;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,KAAM;EACvB,gBAAgB,EACf,WAAW;GAAE;GAAK;GAAK;GAAK;EAAI,EACjC;EACA,QAAA,GAAOA,gBAAAA,GAAAA,CAAI,YAAa;CACzB;CACA;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,SAAU;EAC3B,gBAAgB,EAAE,WAAW,IAAI;CAClC;CACA;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,UAAW;EAC5B,gBAAgB,EAAE,WAAW,IAAI;CAClC;CACA;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,sBAAuB;EACxC,gBAAgB,EAAE,WAAW,IAAI;CAClC;CACA;EACC,cAAA,GAAaA,gBAAAA,GAAAA,CAAI,8BAA+B;EAChD,gBAAgB;GAAE,UAAU;GAAS,WAAW;EAAI;CACrD;CACA;EACC,cAAA,GAAaA,g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WAAU;IAER,UAAA;GACE,GAJE,QAIF,CAEP;EACK,CAAA,CACF;;AAEP;AAMA,SAAwB,kCAAmC,EAC1D,WAC2C;CAC3C,OACC,iBAAA,GAAA,kBAAA,KAAA,CAACC,sBAAAA,OAAD;EACC,WAAU;EACV,QAAA,GAAQL,gBAAAA,GAAAA,CAAI,oBAAqB;EACjC,gBAAiB;EAHlB,UAAA,CAKC,iBAAA,GAAA,kBAAA,IAAA,CAAC,KAAD;GAAG,WAAU;GACVA,WAAAA,GAAAA,gBAAAA,GAAAA,CACD,uDACD;EACE,CAAA,GAMH,iBAAA,GAAA,kBAAA,IAAA,CAAC,MAAD;GACC,WAAU;GACV,MAAK;GAEH,UAAA,UAAU,KAAO,UAAU,UAC5B,iBAAA,GAAA,kBAAA,KAAA,CAAC,MAAD;IAEC,WAAU;IAFX,UAAA,CAIC,iBAAA,GAAA,kBAAA,IAAA,CAAC,QAAD;KAAM,WAAU;KACb,UAAA,SAAS;IACN,CAAA,GACN,iBAAA,GAAA,kBAAA,IAAA,CAAC,uBAAD,EAAuB,GAAK,SAAY,CAAA,CACrC;GAPG,GAAA,KAOH,CACH;EACC,CAAA,CAEE;;AAET"}
|
|
@@ -11,12 +11,14 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
11
11
|
var __getProtoOf = Object.getPrototypeOf;
|
|
12
12
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
13
|
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
15
|
-
key
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
+
for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) {
|
|
16
|
+
desc = __getOwnPropDesc(from, key);
|
|
17
|
+
__defProp(to, key, {
|
|
18
|
+
get: desc && desc.get && !desc.configurable ? desc.get : () => from[key],
|
|
19
|
+
enumerable: !desc || desc.enumerable
|
|
20
|
+
});
|
|
21
|
+
}
|
|
20
22
|
}
|
|
21
23
|
return to;
|
|
22
24
|
};
|
|
@@ -30,9 +32,9 @@ let _wordpress_i18n = require("@wordpress/i18n");
|
|
|
30
32
|
let _wordpress_keyboard_shortcuts = require("@wordpress/keyboard-shortcuts");
|
|
31
33
|
let _wordpress_notices = require("@wordpress/notices");
|
|
32
34
|
let ___media_editor_index_tsx = require("../media-editor/index.cjs");
|
|
33
|
-
___media_editor_index_tsx = __toESM(___media_editor_index_tsx);
|
|
34
35
|
let ______store_index_ts = require("../../store/index.cjs");
|
|
35
36
|
let react_jsx_runtime = require("react/jsx-runtime");
|
|
37
|
+
___media_editor_index_tsx = __toESM(___media_editor_index_tsx);
|
|
36
38
|
// packages/media-editor/src/components/media-editor-modal/index.tsx
|
|
37
39
|
/**
|
|
38
40
|
* The modal's footer chrome. The fine-rotation ruler and the image controls
|
|
@@ -78,6 +80,7 @@ function MediaEditorModal({ fields = [], form, aspectRatioPresets }) {
|
|
|
78
80
|
shouldCloseOnEsc: true,
|
|
79
81
|
noticesClassName: "media-editor-modal__snackbar",
|
|
80
82
|
noticesPortalElement: portalElement,
|
|
83
|
+
defaultPanel: "core/crop",
|
|
81
84
|
onClose: handleClose,
|
|
82
85
|
onSaved: ({ id: savedId, url, previous }) => {
|
|
83
86
|
if (savedId && onUpdate) onUpdate({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["__","MediaEditor","useSelect","mediaEditorStore","useDispatch","noticesStore","ShortcutProvider","Modal"],"sources":["../../../src/components/media-editor-modal/index.tsx"],"sourcesContent":["import { Modal } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Field, Form } from '@wordpress/dataviews';\nimport type { KeyboardEvent as ReactKeyboardEvent } from 'react';\nimport MediaEditor from '../media-editor';\nimport type { Media } from '../media-editor-provider';\nimport { store as mediaEditorStore } from '../../store';\nimport type { MediaEditorModalUpdate } from '../../store/actions';\
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["__","MediaEditor","useSelect","mediaEditorStore","useDispatch","noticesStore","ShortcutProvider","Modal"],"sources":["../../../src/components/media-editor-modal/index.tsx"],"sourcesContent":["import { Modal } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Field, Form } from '@wordpress/dataviews';\nimport type { KeyboardEvent as ReactKeyboardEvent } from 'react';\nimport type { AspectRatioPreset } from '../../state/aspect-ratio-presets';\nimport MediaEditor from '../media-editor';\nimport type { Media } from '../media-editor-provider';\nimport { store as mediaEditorStore } from '../../store';\nimport type { MediaEditorModalUpdate } from '../../store/actions';\n\ninterface MediaEditorModalProps {\n\t/**\n\t * Attachment fields to render in the Details tab.\n\t *\n\t * Passed from the editor layer (which owns the `usePostFields` hook),\n\t * since `@wordpress/media-editor` cannot depend on `@wordpress/editor`.\n\t */\n\tfields?: Field< Media >[];\n\t/**\n\t * Form the fields are laid out with in the Details tab. When omitted,\n\t * a default layout of the core attachment fields is used.\n\t */\n\tform?: Form;\n\t/**\n\t * Fixed aspect-ratio presets for image cropping. Free and Original are\n\t * always provided by the media editor.\n\t */\n\taspectRatioPresets?: AspectRatioPreset[];\n}\n\n/**\n * The modal's footer chrome. The fine-rotation ruler and the image controls\n * both live under the canvas (in `media-editor__content`), never here, so the\n * footer has one layout at every width: History on the left, Cancel/Save on\n * the right.\n */\nfunction ModalFooter() {\n\treturn (\n\t\t<div\n\t\t\tclassName=\"media-editor-modal__footer\"\n\t\t\trole=\"region\"\n\t\t\taria-label={ __( 'Editor actions' ) }\n\t\t>\n\t\t\t<MediaEditor.HistoryActions />\n\t\t\t<MediaEditor.SaveActions />\n\t\t</div>\n\t);\n}\n\nexport function MediaEditorModal( {\n\tfields = [],\n\tform,\n\taspectRatioPresets,\n}: MediaEditorModalProps ) {\n\tconst { isModalOpen, id, onUpdate, onUndo, onClose } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { isOpen, getId, getOnUpdate, getOnUndo, getOnClose } =\n\t\t\t\tselect( mediaEditorStore );\n\t\t\treturn {\n\t\t\t\tisModalOpen: isOpen(),\n\t\t\t\tid: getId(),\n\t\t\t\tonUpdate: getOnUpdate(),\n\t\t\t\tonUndo: getOnUndo(),\n\t\t\t\tonClose: getOnClose(),\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst { closeMediaEditorModal } = useDispatch( mediaEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tif ( ! isModalOpen || ! id ) {\n\t\treturn null;\n\t}\n\n\tconst portalElement =\n\t\ttypeof document === 'undefined' ? null : document.body;\n\n\t// React synthetic events bubble through the React tree, not the DOM tree,\n\t// so a host `ShortcutProvider` higher up still receives keydown events\n\t// from inside this portaled modal. Stop propagation at the modal boundary\n\t// so host shortcuts (undo/redo, save, etc.) don't fire from within.\n\tconst stopKeyDownPropagation = (\n\t\tevent: ReactKeyboardEvent< HTMLDivElement >\n\t) => {\n\t\tevent.stopPropagation();\n\t};\n\n\tconst handleClose = () => {\n\t\tcloseMediaEditorModal();\n\t\tonClose?.();\n\t};\n\n\treturn (\n\t\t<MediaEditor\n\t\t\tid={ id }\n\t\t\tfields={ fields }\n\t\t\tform={ form }\n\t\t\taspectRatioPresets={ aspectRatioPresets }\n\t\t\tshouldCloseOnEsc\n\t\t\tnoticesClassName=\"media-editor-modal__snackbar\"\n\t\t\tnoticesPortalElement={ portalElement }\n\t\t\t// Rotate, flip and aspect ratio are only in the Crop panel for now.\n\t\t\t// This can go once they move under the canvas (#87282).\n\t\t\tdefaultPanel=\"core/crop\"\n\t\t\tonClose={ handleClose }\n\t\t\tonSaved={ ( { id: savedId, url, previous } ) => {\n\t\t\t\tif ( savedId && onUpdate ) {\n\t\t\t\t\tconst update: MediaEditorModalUpdate = {\n\t\t\t\t\t\tid: savedId,\n\t\t\t\t\t\turl,\n\t\t\t\t\t};\n\t\t\t\t\tonUpdate( update );\n\t\t\t\t}\n\t\t\t\thandleClose();\n\t\t\t\tif ( previous && savedId !== previous.id && onUpdate ) {\n\t\t\t\t\t// Intentionally unscoped: the modal is closing, so the\n\t\t\t\t\t// snackbar surfaces in the host editor (not the media\n\t\t\t\t\t// editor's `MEDIA_EDITOR_NOTICES_CONTEXT` region).\n\t\t\t\t\tcreateSuccessNotice( __( 'Image edited.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\tif ( onUndo ) {\n\t\t\t\t\t\t\t\t\t\tonUndo();\n\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tonUpdate( {\n\t\t\t\t\t\t\t\t\t\tid: previous.id,\n\t\t\t\t\t\t\t\t\t\turl: previous.url,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} }\n\t\t\trenderFrame={ ( {\n\t\t\t\tchildren,\n\t\t\t\tonRequestClose,\n\t\t\t\tonKeyDown,\n\t\t\t\tshouldCloseOnClickOutside,\n\t\t\t} ) => (\n\t\t\t\t<ShortcutProvider\n\t\t\t\t\tclassName=\"media-editor-modal__shortcut-scope\"\n\t\t\t\t\tonKeyDown={ stopKeyDownPropagation }\n\t\t\t\t>\n\t\t\t\t\t<Modal\n\t\t\t\t\t\tclassName=\"media-editor-modal\"\n\t\t\t\t\t\ttitle={ __( 'Edit media' ) }\n\t\t\t\t\t\tsize=\"fill\"\n\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\tshouldCloseOnClickOutside={ shouldCloseOnClickOutside }\n\t\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t\t\tonRequestClose={ onRequestClose }\n\t\t\t\t\t\theaderActions={\n\t\t\t\t\t\t\t<MediaEditor.HeaderActions showCloseButton />\n\t\t\t\t\t\t}\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t<ModalFooter />\n\t\t\t\t\t</Modal>\n\t\t\t\t</ShortcutProvider>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default MediaEditorModal;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAS,cAAc;CACtB,OACC,iBAAA,GAAA,kBAAA,KAAA,CAAC,OAAD;EACC,WAAU;EACV,MAAK;EACL,eAAA,GAAaA,gBAAAA,GAAAA,CAAI,gBAAiB;EAHnC,UAAA,CAKC,iBAAA,GAAA,kBAAA,IAAA,CAACC,0BAAAA,QAAY,gBAAb,CAA6B,CAAA,GAC7B,iBAAA,GAAA,kBAAA,IAAA,CAACA,0BAAAA,QAAY,aAAb,CAA0B,CAAA,CACtB;;AAEP;AAEA,SAAgB,iBAAkB,EACjC,SAAS,CAAC,GACV,MACA,sBAC0B;CAC1B,MAAM,EAAE,aAAa,IAAI,UAAU,QAAQ,aAAA,GAAYC,gBAAAA,UAAAA,EACpD,WAAY;EACb,MAAM,EAAE,QAAQ,OAAO,aAAa,WAAW,eAC9C,OAAQC,qBAAAA,KAAiB;EAC1B,OAAO;GACN,aAAa,OAAO;GACpB,IAAI,MAAM;GACV,UAAU,YAAY;GACtB,QAAQ,UAAU;GAClB,SAAS,WAAW;EACrB;CACD,GACA,CAAC,CACF;CAEA,MAAM,EAAE,2BAAA,GAA0BC,gBAAAA,YAAAA,CAAaD,qBAAAA,KAAiB;CAChE,MAAM,E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AD,CAAc,CAAA,CACR;;EACU,CAAA;CAEnB,CAAA;AAEH"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperties(exports, {
|
|
3
|
+
__esModule: { value: true },
|
|
4
|
+
[Symbol.toStringTag]: { value: "Module" }
|
|
5
|
+
});
|
|
6
|
+
let _wordpress_element = require("@wordpress/element");
|
|
7
|
+
let _wordpress_a11y = require("@wordpress/a11y");
|
|
8
|
+
let _wordpress_compose = require("@wordpress/compose");
|
|
9
|
+
let _wordpress_i18n = require("@wordpress/i18n");
|
|
10
|
+
let _wordpress_ui = require("@wordpress/ui");
|
|
11
|
+
let react_jsx_runtime = require("react/jsx-runtime");
|
|
12
|
+
// packages/media-editor/src/components/media-editor-panel/error-boundary.tsx
|
|
13
|
+
function getMessage(title) {
|
|
14
|
+
return {
|
|
15
|
+
title: (0, _wordpress_i18n.sprintf)(
|
|
16
|
+
/** translators: %s: the panel's title. */
|
|
17
|
+
(0, _wordpress_i18n.__)("The \"%s\" panel could not be shown"),
|
|
18
|
+
title
|
|
19
|
+
),
|
|
20
|
+
description: (0, _wordpress_i18n.__)("An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.")
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function CopyErrorButton({ error }) {
|
|
24
|
+
const ref = (0, _wordpress_compose.useCopyToClipboard)(() => {
|
|
25
|
+
const { message, stack } = error ?? {};
|
|
26
|
+
return [[error, message].find((part) => typeof part === "string" && part) ?? "An unknown error occurred.", stack].filter((part) => typeof part === "string" && part).join("\n\n");
|
|
27
|
+
});
|
|
28
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Notice.ActionButton, {
|
|
29
|
+
variant: "outline",
|
|
30
|
+
ref,
|
|
31
|
+
children: (0, _wordpress_i18n._x)("Copy error", "button label")
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Keeps a panel's failure inside its tab, so the rest of the editor stays
|
|
36
|
+
* usable.
|
|
37
|
+
*/
|
|
38
|
+
var MediaEditorPanelErrorBoundary = class extends _wordpress_element.Component {
|
|
39
|
+
state = {
|
|
40
|
+
hasError: false,
|
|
41
|
+
error: null
|
|
42
|
+
};
|
|
43
|
+
static getDerivedStateFromError(error) {
|
|
44
|
+
return {
|
|
45
|
+
hasError: true,
|
|
46
|
+
error
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
componentDidCatch() {
|
|
50
|
+
const { title, description } = getMessage(this.props.title);
|
|
51
|
+
(0, _wordpress_a11y.speak)(`${title}. ${description}`, "assertive");
|
|
52
|
+
}
|
|
53
|
+
render() {
|
|
54
|
+
if (!this.state.hasError) return this.props.children;
|
|
55
|
+
const { title, description } = getMessage(this.props.title);
|
|
56
|
+
return /* @__PURE__ */ (0, react_jsx_runtime.jsxs)(_wordpress_ui.Notice.Root, {
|
|
57
|
+
intent: "error",
|
|
58
|
+
children: [
|
|
59
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Notice.Title, { children: title }),
|
|
60
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Notice.Description, { children: description }),
|
|
61
|
+
/* @__PURE__ */ (0, react_jsx_runtime.jsx)(_wordpress_ui.Notice.Actions, { children: /* @__PURE__ */ (0, react_jsx_runtime.jsx)(CopyErrorButton, { error: this.state.error }) })
|
|
62
|
+
]
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
exports.default = MediaEditorPanelErrorBoundary;
|
|
67
|
+
|
|
68
|
+
//# sourceMappingURL=error-boundary.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error-boundary.cjs","names":["sprintf","__","useCopyToClipboard","Notice","_x","Component","speak"],"sources":["../../../src/components/media-editor-panel/error-boundary.tsx"],"sourcesContent":["import { Component } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\nimport { useCopyToClipboard } from '@wordpress/compose';\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { Notice } from '@wordpress/ui';\nimport type { ReactNode } from 'react';\n\ninterface Props {\n\ttitle: string;\n\tchildren: ReactNode;\n}\n\ninterface State {\n\t/** Separate from `error`: a panel can throw a falsy value. */\n\thasError: boolean;\n\terror: unknown;\n}\n\nfunction getMessage( title: string ) {\n\treturn {\n\t\ttitle: sprintf(\n\t\t\t/* translators: %s: the panel's title. */\n\t\t\t__( 'The \"%s\" panel could not be shown' ),\n\t\t\ttitle\n\t\t),\n\t\tdescription: __(\n\t\t\t'An unknown error occurred. Reload your browser to try again, or copy the error to report the problem or search.'\n\t\t),\n\t};\n}\n\n// A component, because the copy hook cannot run in the class below.\nfunction CopyErrorButton( { error }: { error: unknown } ) {\n\tconst ref = useCopyToClipboard< HTMLButtonElement >( () => {\n\t\t// A boundary catches whatever was thrown, which is not always an `Error`.\n\t\tconst { message, stack } = ( error ?? {} ) as {\n\t\t\tmessage?: unknown;\n\t\t\tstack?: unknown;\n\t\t};\n\t\tconst text = [ error, message ].find(\n\t\t\t( part ) => typeof part === 'string' && part\n\t\t);\n\t\treturn [ text ?? 'An unknown error occurred.', stack ]\n\t\t\t.filter( ( part ) => typeof part === 'string' && part )\n\t\t\t.join( '\\n\\n' );\n\t} );\n\treturn (\n\t\t<Notice.ActionButton variant=\"outline\" ref={ ref }>\n\t\t\t{ _x( 'Copy error', 'button label' ) }\n\t\t</Notice.ActionButton>\n\t);\n}\n\n/**\n * Keeps a panel's failure inside its tab, so the rest of the editor stays\n * usable.\n */\nexport default class MediaEditorPanelErrorBoundary extends Component<\n\tProps,\n\tState\n> {\n\tstate: State = { hasError: false, error: null };\n\n\tstatic getDerivedStateFromError( error: unknown ): State {\n\t\treturn { hasError: true, error };\n\t}\n\n\tcomponentDidCatch() {\n\t\tconst { title, description } = getMessage( this.props.title );\n\t\tspeak( `${ title }. ${ description }`, 'assertive' );\n\t}\n\n\trender() {\n\t\tif ( ! this.state.hasError ) {\n\t\t\treturn this.props.children;\n\t\t}\n\t\tconst { title, description } = getMessage( this.props.title );\n\t\treturn (\n\t\t\t<Notice.Root intent=\"error\">\n\t\t\t\t<Notice.Title>{ title }</Notice.Title>\n\t\t\t\t<Notice.Description>{ description }</Notice.Description>\n\t\t\t\t<Notice.Actions>\n\t\t\t\t\t<CopyErrorButton error={ this.state.error } />\n\t\t\t\t</Notice.Actions>\n\t\t\t</Notice.Root>\n\t\t);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAS,WAAY,OAAgB;CACpC,OAAO;EACN,QAAA,GAAOA,gBAAAA,QAAAA;;IAENC,GAAAA,gBAAAA,GAAAA,CAAI,qCAAoC;GACxC;EACD;EACA,cAAA,GAAaA,gBAAAA,GAAAA,CACZ,iHACD;CACD;AACD;AAGA,SAAS,gBAAiB,EAAE,SAA8B;CACzD,MAAM,OAAA,GAAMC,mBAAAA,mBAAAA,OAA+C;EAE1D,MAAM,EAAE,SAAS,UAAY,SAAS,CAAC;EAOvC,OAAO,CAHM,CAAE,OAAO,OAAQ,CAAC,CAAC,MAC7B,SAAU,OAAO,SAAS,YAAY,IAEhC,KAAQ,8BAA8B,KAAM,CAAA,CACnD,QAAU,SAAU,OAAO,SAAS,YAAY,IAAK,CAAA,CACrD,KAAM,MAAO;CAChB,CAAE;CACF,OACC,iBAAA,GAAA,kBAAA,IAAA,CAACC,cAAAA,OAAO,cAAR;EAAqB,SAAQ;EAAgB;EAC1CC,WAAAA,GAAAA,gBAAAA,GAAAA,CAAI,cAAc,cAAe;CACf,CAAA;AAEvB;;;;;AAMA,IAAqB,gCAArB,cAA2DC,mBAAAA,UAGzD;CACD,QAAe;EAAE,UAAU;EAAO,OAAO;CAAK;CAE9C,OAAO,yBAA0B,OAAwB;EACxD,OAAO;GAAE,UAAU;GAAM;EAAM;CAChC;CAEA,oBAAoB;EACnB,MAAM,EAAE,OAAO,gBAAgB,WAAY,KAAK,MAAM,KAAM;EAC5DC,CA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