@wordpress/media-editor 0.15.0 → 0.17.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 +18 -0
- package/build/components/media-editor/index.cjs +115 -119
- package/build/components/media-editor/index.cjs.map +3 -3
- package/build/components/media-editor/use-crop-options.cjs.map +2 -2
- package/build/components/media-editor/use-save-media-editor.cjs.map +2 -2
- package/build/components/media-editor-canvas/index.cjs +0 -2
- package/build/components/media-editor-canvas/index.cjs.map +2 -2
- package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
- package/build/components/media-editor-fine-rotation/index.cjs.map +2 -2
- package/build/components/media-editor-image-controls/index.cjs.map +2 -2
- package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +2 -2
- package/build/components/media-editor-modal/build-modifiers.cjs.map +2 -2
- package/build/components/media-editor-modal/index.cjs +31 -15
- package/build/components/media-editor-modal/index.cjs.map +3 -3
- package/build/components/media-editor-provider/index.cjs.map +2 -2
- package/build/components/media-form/index.cjs.map +2 -2
- package/build/components/media-preview/index.cjs.map +2 -2
- package/build/components/rotation-ruler/index.cjs.map +2 -2
- package/build/components/rotation-ruler/use-ruler-drag.cjs.map +2 -2
- package/build/hooks/use-crop-gesture-handlers.cjs.map +2 -2
- package/build/image-editor/core/camera.cjs.map +2 -2
- package/build/image-editor/core/constants.cjs.map +2 -2
- package/build/image-editor/core/containment.cjs.map +2 -2
- package/build/image-editor/core/crop-rect.cjs.map +2 -2
- package/build/image-editor/core/export/canvas-renderer.cjs.map +2 -2
- package/build/image-editor/core/interaction-controller.cjs.map +2 -2
- package/build/image-editor/core/math/sanitize.cjs.map +2 -2
- package/build/image-editor/core/setter-helpers.cjs.map +2 -2
- package/build/image-editor/core/source-region.cjs.map +2 -2
- package/build/image-editor/core/state.cjs.map +2 -2
- package/build/image-editor/core/stencil-math.cjs.map +2 -2
- package/build/image-editor/core/transform-style.cjs.map +2 -2
- package/build/image-editor/core/transforms/pipeline.cjs.map +2 -2
- package/build/image-editor/core/viewport-state.cjs.map +2 -2
- package/build/image-editor/react/components/cropper-provider.cjs.map +2 -2
- package/build/image-editor/react/components/cropper.cjs.map +2 -2
- package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +2 -2
- package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +2 -2
- package/build/image-editor/react/components/overlays/grid-overlay.cjs.map +2 -2
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
- package/build/image-editor/react/components/viewport-provider.cjs.map +2 -2
- package/build/image-editor/react/hooks/build-cropper-setters.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-cropper-reducer.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-transform-style.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-viewport-state.cjs.map +2 -2
- package/build/lock-unlock.cjs.map +2 -2
- package/build/private-apis.cjs.map +2 -2
- package/build/state/composite-reducer.cjs.map +2 -2
- package/build/state/media-editor-state-provider.cjs.map +2 -2
- package/build/state/types.cjs.map +2 -2
- package/build/state/use-media-editor-state.cjs.map +2 -2
- package/build/store/index.cjs.map +2 -2
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/components/media-editor/index.mjs +117 -120
- package/build-module/components/media-editor/index.mjs.map +2 -2
- package/build-module/components/media-editor/use-crop-options.mjs.map +2 -2
- package/build-module/components/media-editor/use-save-media-editor.mjs.map +2 -2
- package/build-module/components/media-editor-canvas/index.mjs +0 -2
- package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
- package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
- package/build-module/components/media-editor-fine-rotation/index.mjs.map +2 -2
- package/build-module/components/media-editor-image-controls/index.mjs.map +2 -2
- package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +2 -2
- package/build-module/components/media-editor-modal/build-modifiers.mjs.map +2 -2
- package/build-module/components/media-editor-modal/index.mjs +31 -15
- package/build-module/components/media-editor-modal/index.mjs.map +2 -2
- package/build-module/components/media-editor-provider/index.mjs.map +2 -2
- package/build-module/components/media-form/index.mjs.map +2 -2
- package/build-module/components/media-preview/index.mjs.map +2 -2
- package/build-module/components/rotation-ruler/index.mjs.map +2 -2
- package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +2 -2
- package/build-module/hooks/use-crop-gesture-handlers.mjs.map +2 -2
- package/build-module/image-editor/core/camera.mjs.map +2 -2
- package/build-module/image-editor/core/constants.mjs.map +2 -2
- package/build-module/image-editor/core/containment.mjs.map +2 -2
- package/build-module/image-editor/core/crop-rect.mjs.map +2 -2
- package/build-module/image-editor/core/export/canvas-renderer.mjs.map +2 -2
- package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
- package/build-module/image-editor/core/math/sanitize.mjs.map +2 -2
- package/build-module/image-editor/core/setter-helpers.mjs.map +2 -2
- package/build-module/image-editor/core/source-region.mjs.map +2 -2
- package/build-module/image-editor/core/state.mjs.map +2 -2
- package/build-module/image-editor/core/stencil-math.mjs.map +2 -2
- package/build-module/image-editor/core/transform-style.mjs.map +2 -2
- package/build-module/image-editor/core/transforms/pipeline.mjs.map +2 -2
- package/build-module/image-editor/core/viewport-state.mjs.map +2 -2
- package/build-module/image-editor/react/components/cropper-provider.mjs.map +2 -2
- package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
- package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +2 -2
- package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +2 -2
- package/build-module/image-editor/react/components/overlays/grid-overlay.mjs.map +2 -2
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
- package/build-module/image-editor/react/components/viewport-provider.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/build-cropper-setters.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-cropper-reducer.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-transform-style.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +2 -2
- package/build-module/lock-unlock.mjs.map +2 -2
- package/build-module/private-apis.mjs.map +2 -2
- package/build-module/state/composite-reducer.mjs.map +2 -2
- package/build-module/state/media-editor-state-provider.mjs.map +2 -2
- package/build-module/state/types.mjs.map +2 -2
- package/build-module/state/use-media-editor-state.mjs.map +2 -2
- package/build-module/store/index.mjs.map +2 -2
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/style-rtl.css +6 -6
- package/build-style/style.css +6 -6
- package/build-types/components/media-editor/index.d.ts +46 -11
- package/build-types/components/media-editor/index.d.ts.map +1 -1
- 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 +0 -3
- 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 +1 -4
- package/build-types/components/media-editor-canvas/index.d.ts.map +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.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/build-modifiers.d.ts +0 -3
- package/build-types/components/media-editor-modal/build-modifiers.d.ts.map +1 -1
- package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
- package/build-types/components/media-editor-provider/index.d.ts.map +1 -1
- package/build-types/components/media-form/index.d.ts.map +1 -1
- package/build-types/components/media-preview/index.d.ts.map +1 -1
- package/build-types/components/rotation-ruler/index.d.ts.map +1 -1
- package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -1
- package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -1
- package/build-types/image-editor/core/camera.d.ts +0 -3
- package/build-types/image-editor/core/camera.d.ts.map +1 -1
- package/build-types/image-editor/core/constants.d.ts +0 -3
- package/build-types/image-editor/core/constants.d.ts.map +1 -1
- package/build-types/image-editor/core/containment.d.ts +0 -3
- package/build-types/image-editor/core/containment.d.ts.map +1 -1
- package/build-types/image-editor/core/crop-rect.d.ts +0 -3
- package/build-types/image-editor/core/crop-rect.d.ts.map +1 -1
- package/build-types/image-editor/core/export/canvas-renderer.d.ts +0 -3
- package/build-types/image-editor/core/export/canvas-renderer.d.ts.map +1 -1
- package/build-types/image-editor/core/interaction-controller.d.ts +0 -3
- package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -1
- package/build-types/image-editor/core/math/sanitize.d.ts +0 -3
- package/build-types/image-editor/core/math/sanitize.d.ts.map +1 -1
- package/build-types/image-editor/core/setter-helpers.d.ts +0 -3
- package/build-types/image-editor/core/setter-helpers.d.ts.map +1 -1
- package/build-types/image-editor/core/source-region.d.ts +0 -3
- package/build-types/image-editor/core/source-region.d.ts.map +1 -1
- package/build-types/image-editor/core/state.d.ts +0 -3
- package/build-types/image-editor/core/state.d.ts.map +1 -1
- package/build-types/image-editor/core/stencil-math.d.ts.map +1 -1
- package/build-types/image-editor/core/transform-style.d.ts +0 -3
- package/build-types/image-editor/core/transform-style.d.ts.map +1 -1
- package/build-types/image-editor/core/transforms/pipeline.d.ts +0 -3
- package/build-types/image-editor/core/transforms/pipeline.d.ts.map +1 -1
- package/build-types/image-editor/core/viewport-state.d.ts +0 -3
- package/build-types/image-editor/core/viewport-state.d.ts.map +1 -1
- package/build-types/image-editor/react/components/cropper-provider.d.ts +0 -3
- package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
- package/build-types/image-editor/react/components/cropper.d.ts +0 -6
- package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
- package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts +0 -3
- package/build-types/image-editor/react/components/overlays/dimensions-overlay.d.ts.map +1 -1
- package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +0 -3
- package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +1 -1
- package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +0 -3
- package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +1 -1
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +0 -3
- package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
- package/build-types/image-editor/react/components/viewport-provider.d.ts +0 -3
- package/build-types/image-editor/react/components/viewport-provider.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts +0 -3
- package/build-types/image-editor/react/hooks/build-cropper-setters.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +0 -3
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts +0 -3
- package/build-types/image-editor/react/hooks/use-cropper-reducer.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-interaction.d.ts +0 -3
- package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-transform-style.d.ts +0 -3
- package/build-types/image-editor/react/hooks/use-transform-style.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +0 -3
- package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +1 -1
- package/build-types/lock-unlock.d.ts.map +1 -1
- package/build-types/private-apis.d.ts.map +1 -1
- package/build-types/state/composite-reducer.d.ts +0 -3
- package/build-types/state/composite-reducer.d.ts.map +1 -1
- package/build-types/state/media-editor-state-provider.d.ts +0 -3
- package/build-types/state/media-editor-state-provider.d.ts.map +1 -1
- package/build-types/state/types.d.ts +0 -3
- package/build-types/state/types.d.ts.map +1 -1
- package/build-types/state/use-media-editor-state.d.ts +0 -3
- package/build-types/state/use-media-editor-state.d.ts.map +1 -1
- package/build-types/store/index.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +0 -3
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +0 -3
- package/build-types/store/selectors.d.ts.map +1 -1
- package/global.d.ts +5 -0
- package/package.json +24 -22
- package/src/components/media-editor/index.tsx +233 -194
- package/src/components/media-editor/style.scss +6 -3
- package/src/components/media-editor/test/use-crop-options.tsx +0 -7
- package/src/components/media-editor/use-crop-options.ts +0 -7
- package/src/components/media-editor/use-save-media-editor.ts +0 -7
- package/src/components/media-editor-canvas/index.tsx +5 -20
- package/src/components/media-editor-crop-panel/index.tsx +0 -7
- package/src/components/media-editor-crop-panel/test/index.tsx +0 -7
- package/src/components/media-editor-fine-rotation/index.tsx +0 -7
- package/src/components/media-editor-image-controls/index.tsx +0 -7
- package/src/components/media-editor-image-controls/test/index.tsx +0 -7
- package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +0 -3
- package/src/components/media-editor-modal/build-modifiers.ts +0 -3
- package/src/components/media-editor-modal/index.tsx +43 -19
- package/src/components/media-editor-modal/style.scss +8 -4
- package/src/components/media-editor-modal/test/build-modifiers.test.ts +0 -8
- package/src/components/media-editor-modal/test/index.tsx +0 -11
- package/src/components/media-editor-provider/index.tsx +0 -3
- package/src/components/media-form/index.tsx +0 -7
- package/src/components/media-preview/index.tsx +0 -7
- package/src/components/rotation-ruler/index.tsx +0 -11
- package/src/components/rotation-ruler/stories/index.story.tsx +0 -11
- package/src/components/rotation-ruler/test/index.tsx +0 -7
- package/src/components/rotation-ruler/use-ruler-drag.ts +0 -3
- package/src/hooks/use-crop-gesture-handlers.ts +0 -7
- package/src/image-editor/core/camera.ts +0 -7
- package/src/image-editor/core/constants.ts +0 -7
- package/src/image-editor/core/containment.ts +0 -7
- package/src/image-editor/core/crop-rect.ts +0 -3
- package/src/image-editor/core/export/canvas-renderer.ts +0 -3
- package/src/image-editor/core/export/test/canvas-renderer.ts +0 -3
- package/src/image-editor/core/interaction-controller.ts +0 -3
- package/src/image-editor/core/math/sanitize.ts +0 -3
- package/src/image-editor/core/math/test/sanitize.ts +0 -3
- package/src/image-editor/core/setter-helpers.ts +0 -3
- package/src/image-editor/core/source-region.ts +0 -7
- package/src/image-editor/core/state.ts +0 -3
- package/src/image-editor/core/stencil-math.ts +0 -3
- package/src/image-editor/core/test/interaction-controller.ts +0 -3
- package/src/image-editor/core/test/preview-export-parity.ts +0 -1
- package/src/image-editor/core/test/stencil-math.ts +0 -3
- package/src/image-editor/core/transform-style.ts +0 -3
- package/src/image-editor/core/transforms/pipeline.ts +0 -3
- package/src/image-editor/core/transforms/test/pipeline.ts +0 -3
- package/src/image-editor/core/viewport-state.ts +0 -3
- package/src/image-editor/react/components/cropper-provider.tsx +0 -7
- package/src/image-editor/react/components/cropper.tsx +0 -12
- package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +0 -7
- package/src/image-editor/react/components/overlays/dimming-overlay.tsx +0 -3
- package/src/image-editor/react/components/overlays/grid-overlay.tsx +0 -3
- package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +0 -7
- package/src/image-editor/react/components/stencils/test/rectangle-stencil.tsx +0 -7
- package/src/image-editor/react/components/test/cropper.tsx +0 -7
- package/src/image-editor/react/components/viewport-provider.tsx +0 -7
- package/src/image-editor/react/hooks/build-cropper-setters.ts +0 -3
- package/src/image-editor/react/hooks/test/use-aria-announcer.ts +0 -11
- package/src/image-editor/react/hooks/test/use-cropper-reducer.ts +0 -7
- package/src/image-editor/react/hooks/test/use-interaction.ts +0 -7
- package/src/image-editor/react/hooks/test/use-transform-style.ts +0 -7
- package/src/image-editor/react/hooks/use-aria-announcer.ts +0 -7
- package/src/image-editor/react/hooks/use-cropper-reducer.ts +0 -7
- package/src/image-editor/react/hooks/use-interaction.ts +0 -7
- package/src/image-editor/react/hooks/use-transform-style.ts +0 -7
- package/src/image-editor/react/hooks/use-viewport-state.ts +0 -7
- package/src/image-editor/stories/rectangle-crop.story.tsx +15 -11
- package/src/lock-unlock.ts +0 -3
- package/src/private-apis.ts +0 -3
- package/src/state/composite-reducer.ts +0 -3
- package/src/state/media-editor-state-provider.tsx +0 -7
- package/src/state/test/use-media-editor-state.ts +0 -7
- package/src/state/types.ts +0 -3
- package/src/state/use-media-editor-state.ts +0 -7
- package/src/store/index.ts +0 -7
- package/src/store/reducer.ts +0 -3
- package/src/store/selectors.ts +0 -3
- package/src/store/test/reducer.ts +0 -3
- package/tsconfig.build.json +26 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +22 -15
- package/build-types/components/media-editor-toolbar/index.d.ts +0 -24
- package/build-types/components/media-editor-toolbar/index.d.ts.map +0 -1
- package/build-types/components/media-editor-transform-controls/index.d.ts +0 -21
- package/build-types/components/media-editor-transform-controls/index.d.ts.map +0 -1
- package/build-types/components/media-form/sidebar-datetime-view.d.ts +0 -10
- package/build-types/components/media-form/sidebar-datetime-view.d.ts.map +0 -1
- package/build-types/components/rotation-ruler/stories/index.story.d.ts +0 -14
- package/build-types/components/rotation-ruler/stories/index.story.d.ts.map +0 -1
- package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +0 -108
- package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +0 -1
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts +0 -16
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +0 -1
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,26 +1,13 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import clsx from 'clsx';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
2
|
import { useCallback, useEffect, useMemo, useState } from '@wordpress/element';
|
|
10
3
|
import { Spinner } from '@wordpress/components';
|
|
11
4
|
import { __ } from '@wordpress/i18n';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
5
|
import { useMediaEditorContext } from '../media-editor-provider';
|
|
17
6
|
import { getMediaTypeFromMimeType } from '../../utils';
|
|
18
7
|
import { Cropper } from '../../image-editor';
|
|
19
8
|
import { useMediaEditor, resolveAspectRatio } from '../../state';
|
|
20
9
|
|
|
21
10
|
export interface MediaEditorCanvasProps {
|
|
22
|
-
/** Focus the crop area when the canvas mounts. */
|
|
23
|
-
focusOnMount?: boolean;
|
|
24
11
|
/** Whether external placement activity should reveal the grid. */
|
|
25
12
|
isPlacementActive?: boolean;
|
|
26
13
|
/** Fires when a canvas cropper gesture begins. */
|
|
@@ -38,13 +25,11 @@ export interface MediaEditorCanvasProps {
|
|
|
38
25
|
* guards can render a spinner or fall through to `<MediaPreview>`.
|
|
39
26
|
*
|
|
40
27
|
* @param props
|
|
41
|
-
* @param props.focusOnMount
|
|
42
28
|
* @param props.isPlacementActive
|
|
43
29
|
* @param props.onGestureStart
|
|
44
30
|
* @param props.onGestureEnd
|
|
45
31
|
*/
|
|
46
32
|
export default function MediaEditorCanvas( {
|
|
47
|
-
focusOnMount,
|
|
48
33
|
isPlacementActive = false,
|
|
49
34
|
onGestureStart,
|
|
50
35
|
onGestureEnd,
|
|
@@ -154,10 +139,11 @@ export default function MediaEditorCanvas( {
|
|
|
154
139
|
* The cropper stays mounted while loading (hidden behind the
|
|
155
140
|
* spinner) so the image decodes off-screen and reveals in one paint
|
|
156
141
|
* instead of streaming in top-to-bottom. Until it's revealed it's
|
|
157
|
-
* non-interactive (`pointer-events: none` in CSS)
|
|
158
|
-
*
|
|
159
|
-
*
|
|
160
|
-
*
|
|
142
|
+
* non-interactive (`pointer-events: none` in CSS).
|
|
143
|
+
*
|
|
144
|
+
* The crop area is never focused programmatically: the modal keeps
|
|
145
|
+
* initial focus on the dialog frame, and users reach the crop area
|
|
146
|
+
* by tabbing to it.
|
|
161
147
|
*/ }
|
|
162
148
|
<div
|
|
163
149
|
className={ clsx( 'media-editor-canvas__cropper', {
|
|
@@ -169,7 +155,6 @@ export default function MediaEditorCanvas( {
|
|
|
169
155
|
controller={ controller }
|
|
170
156
|
aspectRatio={ aspectRatio }
|
|
171
157
|
freeformCrop
|
|
172
|
-
focusOnMount={ focusOnMount && status === 'loaded' }
|
|
173
158
|
showGrid="interactive"
|
|
174
159
|
isPlacementActive={ isPlacementActive }
|
|
175
160
|
onGestureStart={ handleGestureStart }
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { SelectControl } from '@wordpress/components';
|
|
5
2
|
import { Stack, VisuallyHidden } from '@wordpress/ui';
|
|
6
3
|
import { __ } from '@wordpress/i18n';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
4
|
import { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';
|
|
12
5
|
import MediaEditorImageControls from '../media-editor-image-controls';
|
|
13
6
|
import type { AspectRatioPreset } from '../../image-editor/core/constants';
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
2
|
import MediaEditorCropPanel from '..';
|
|
10
3
|
import type { MediaEditorCropPanelProps } from '..';
|
|
11
4
|
import { MediaEditorStateProvider } from '../../../state';
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
2
|
import { useMediaEditor } from '../../state';
|
|
10
3
|
import { useCropGestureHandlers } from '../../hooks/use-crop-gesture-handlers';
|
|
11
4
|
import { MAX_ROTATION_OFFSET } from '../../image-editor/core/constants';
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import {
|
|
5
2
|
Button,
|
|
6
3
|
DropdownMenu,
|
|
@@ -18,10 +15,6 @@ import {
|
|
|
18
15
|
lineSolid,
|
|
19
16
|
plus,
|
|
20
17
|
} from '@wordpress/icons';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Internal dependencies
|
|
24
|
-
*/
|
|
25
18
|
import { useMediaEditor } from '../../state';
|
|
26
19
|
import {
|
|
27
20
|
MAX_ZOOM,
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { fireEvent, render, screen, waitFor } from '@testing-library/react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
2
|
import MediaEditorImageControls from '..';
|
|
10
3
|
import type { MediaEditorImageControlsProps } from '..';
|
|
11
4
|
import { MediaEditorStateProvider, useMediaEditor } from '../../../state';
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { Modal } from '@wordpress/components';
|
|
5
2
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
6
3
|
import { __ } from '@wordpress/i18n';
|
|
@@ -8,10 +5,6 @@ import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
|
|
|
8
5
|
import { store as noticesStore } from '@wordpress/notices';
|
|
9
6
|
import type { Field } from '@wordpress/dataviews';
|
|
10
7
|
import type { KeyboardEvent as ReactKeyboardEvent } from 'react';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
8
|
import MediaEditor from '../media-editor';
|
|
16
9
|
import type { Media } from '../media-editor-provider';
|
|
17
10
|
import { store as mediaEditorStore } from '../../store';
|
|
@@ -33,6 +26,44 @@ interface MediaEditorModalProps {
|
|
|
33
26
|
aspectRatioPresets?: AspectRatioPreset[];
|
|
34
27
|
}
|
|
35
28
|
|
|
29
|
+
interface ModalFooterProps {
|
|
30
|
+
layout: 'wide' | 'narrow';
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* The modal's footer chrome. The fine-rotation ruler always lives under the
|
|
35
|
+
* canvas (in `media-editor__content`), never here, so it stays constrained to
|
|
36
|
+
* the canvas column at every viewport. One JSX tree per layout; DOM order
|
|
37
|
+
* matches visual order.
|
|
38
|
+
*/
|
|
39
|
+
function ModalFooter( { layout }: ModalFooterProps ) {
|
|
40
|
+
return (
|
|
41
|
+
<div
|
|
42
|
+
className={ `media-editor-modal__footer is-${ layout }` }
|
|
43
|
+
role="region"
|
|
44
|
+
aria-label={ __( 'Editor actions' ) }
|
|
45
|
+
>
|
|
46
|
+
{ layout === 'wide' ? (
|
|
47
|
+
// Sidebar is a column: the image controls live in the Crop
|
|
48
|
+
// panel, so the footer is just History + Cancel/Save.
|
|
49
|
+
<>
|
|
50
|
+
<MediaEditor.HistoryActions />
|
|
51
|
+
<MediaEditor.SaveActions />
|
|
52
|
+
</>
|
|
53
|
+
) : (
|
|
54
|
+
// Sidebar collapsed: the image controls drop into the footer.
|
|
55
|
+
<>
|
|
56
|
+
<MediaEditor.ImageControls />
|
|
57
|
+
<div className="media-editor-modal__footer-row">
|
|
58
|
+
<MediaEditor.HistoryActions />
|
|
59
|
+
<MediaEditor.SaveActions />
|
|
60
|
+
</div>
|
|
61
|
+
</>
|
|
62
|
+
) }
|
|
63
|
+
</div>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
36
67
|
export function MediaEditorModal( {
|
|
37
68
|
fields = [],
|
|
38
69
|
aspectRatioPresets,
|
|
@@ -78,7 +109,6 @@ export function MediaEditorModal( {
|
|
|
78
109
|
id={ id }
|
|
79
110
|
fields={ fields }
|
|
80
111
|
aspectRatioPresets={ aspectRatioPresets }
|
|
81
|
-
showCloseButton
|
|
82
112
|
shouldCloseOnEsc
|
|
83
113
|
noticesClassName="media-editor-modal__snackbar"
|
|
84
114
|
noticesPortalElement={ portalElement }
|
|
@@ -114,9 +144,7 @@ export function MediaEditorModal( {
|
|
|
114
144
|
} }
|
|
115
145
|
renderFrame={ ( {
|
|
116
146
|
children,
|
|
117
|
-
|
|
118
|
-
footerActions,
|
|
119
|
-
footerLayout,
|
|
147
|
+
layout,
|
|
120
148
|
onRequestClose,
|
|
121
149
|
onKeyDown,
|
|
122
150
|
shouldCloseOnClickOutside,
|
|
@@ -133,16 +161,12 @@ export function MediaEditorModal( {
|
|
|
133
161
|
shouldCloseOnClickOutside={ shouldCloseOnClickOutside }
|
|
134
162
|
onKeyDown={ onKeyDown }
|
|
135
163
|
onRequestClose={ onRequestClose }
|
|
136
|
-
headerActions={
|
|
164
|
+
headerActions={
|
|
165
|
+
<MediaEditor.HeaderActions showCloseButton />
|
|
166
|
+
}
|
|
137
167
|
>
|
|
138
168
|
{ children }
|
|
139
|
-
<
|
|
140
|
-
className={ `media-editor-modal__footer is-${ footerLayout }` }
|
|
141
|
-
role="region"
|
|
142
|
-
aria-label={ __( 'Editor actions' ) }
|
|
143
|
-
>
|
|
144
|
-
{ footerActions }
|
|
145
|
-
</div>
|
|
169
|
+
<ModalFooter layout={ layout } />
|
|
146
170
|
</Modal>
|
|
147
171
|
</ShortcutProvider>
|
|
148
172
|
) }
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
// Panel mode: the footer holds only History (left) and
|
|
47
47
|
// Cancel/Save (right). `margin-left: auto` pins the actions to the
|
|
48
48
|
// right edge whether or not History renders (e.g. non-image
|
|
49
|
-
// attachments show only `
|
|
50
|
-
.media-
|
|
49
|
+
// attachments show only `SaveActions`).
|
|
50
|
+
.media-editor__save-actions {
|
|
51
51
|
margin-left: auto;
|
|
52
52
|
}
|
|
53
53
|
}
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
gap: $grid-unit-20;
|
|
77
77
|
|
|
78
78
|
.media-editor-image-controls,
|
|
79
|
-
.media-
|
|
79
|
+
.media-editor__save-actions {
|
|
80
80
|
margin-left: auto;
|
|
81
81
|
}
|
|
82
82
|
}
|
|
@@ -85,9 +85,13 @@
|
|
|
85
85
|
// they read as live alongside the Reset/Cancel/Save actions. Disabled
|
|
86
86
|
// buttons (rendered with `aria-disabled` via `accessibleWhenDisabled`)
|
|
87
87
|
// keep the default muted icon colour.
|
|
88
|
+
// Scoped to the modal: the package ships one stylesheet, so an unscoped
|
|
89
|
+
// selector would also colour the history cluster in frames that place it in
|
|
90
|
+
// their own chrome (the wp-admin route puts it in the page header, where the
|
|
91
|
+
// neutral icon colour matches the header's other buttons).
|
|
88
92
|
// NOTE: overrides @wordpress/components Button internals (`.components-button`,
|
|
89
93
|
// `.has-icon`), scoped to our history-actions wrapper. Update if renamed.
|
|
90
|
-
.media-editor__history-actions .components-button.has-icon:not([aria-disabled="true"]) {
|
|
94
|
+
.media-editor-modal .media-editor__history-actions .components-button.has-icon:not([aria-disabled="true"]) {
|
|
91
95
|
color: var(--wp-admin-theme-color);
|
|
92
96
|
}
|
|
93
97
|
|
|
@@ -52,15 +52,7 @@
|
|
|
52
52
|
* `serverSourcePixel` to undo it, and add values to the grid in
|
|
53
53
|
* `buildRows`. The probes don't need to change.
|
|
54
54
|
*/
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* External dependencies
|
|
58
|
-
*/
|
|
59
55
|
import { mat2d, vec2 } from 'gl-matrix';
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Internal dependencies
|
|
63
|
-
*/
|
|
64
56
|
import { buildModifiers } from '../build-modifiers';
|
|
65
57
|
import type { Modifier } from '../build-modifiers';
|
|
66
58
|
import {
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { fireEvent, render, screen } from '@testing-library/react';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
2
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
10
3
|
import { store as noticesStore } from '@wordpress/notices';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
4
|
import { MediaEditorModal } from '../index';
|
|
16
5
|
|
|
17
6
|
let mockSaveResult = {
|
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { DataForm } from '@wordpress/dataviews';
|
|
5
2
|
import type { Form, Field } from '@wordpress/dataviews';
|
|
6
3
|
import { Spinner, __experimentalVStack as VStack } from '@wordpress/components';
|
|
7
4
|
import { VisuallyHidden } from '@wordpress/ui';
|
|
8
5
|
import { __ } from '@wordpress/i18n';
|
|
9
6
|
import type { ReactNode } from 'react';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Internal dependencies
|
|
13
|
-
*/
|
|
14
7
|
import { useMediaEditorContext } from '../media-editor-provider';
|
|
15
8
|
import type { Media } from '../media-editor-provider';
|
|
16
9
|
|
|
@@ -1,13 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { Spinner } from '@wordpress/components';
|
|
5
2
|
import { useState } from '@wordpress/element';
|
|
6
3
|
import { __ } from '@wordpress/i18n';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Internal dependencies
|
|
10
|
-
*/
|
|
11
4
|
import { useMediaEditorContext } from '../media-editor-provider';
|
|
12
5
|
import { getMediaTypeFromMimeType } from '../../utils';
|
|
13
6
|
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import clsx from 'clsx';
|
|
5
2
|
import type { CSSProperties, KeyboardEvent } from 'react';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
3
|
import { useId, useMemo, useRef } from '@wordpress/element';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
4
|
import { useRulerDrag, clampValue } from './use-ruler-drag';
|
|
16
5
|
|
|
17
6
|
export interface RotationRulerProps {
|
|
@@ -1,17 +1,6 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import type { Meta, StoryObj } from '@storybook/react-vite';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
2
|
import { useState } from '@wordpress/element';
|
|
10
3
|
import { __ } from '@wordpress/i18n';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
4
|
import RotationRuler from '../index';
|
|
16
5
|
import '../style.scss';
|
|
17
6
|
|
|
@@ -1,12 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { render, screen } from '@testing-library/react';
|
|
5
2
|
import userEvent from '@testing-library/user-event';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
3
|
import { pxToValueDelta, clampValue, quantize } from '../use-ruler-drag';
|
|
11
4
|
import RotationRuler from '../index';
|
|
12
5
|
|
|
@@ -1,11 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
1
|
import { mat2d, vec2 } from 'gl-matrix';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Internal dependencies
|
|
8
|
-
*/
|
|
9
2
|
import type { CropperState, NormalizedRect, Size } from './types';
|
|
10
3
|
import { ABSOLUTE_MIN_ZOOM, MAX_ZOOM, MIN_ZOOM } from './constants';
|
|
11
4
|
import { degreesToRadians } from './math/rotation';
|
|
@@ -1,12 +1,4 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
1
|
import clsx from 'clsx';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
2
|
import {
|
|
11
3
|
useState,
|
|
12
4
|
useCallback,
|
|
@@ -18,10 +10,6 @@ import {
|
|
|
18
10
|
forwardRef,
|
|
19
11
|
} from '@wordpress/element';
|
|
20
12
|
import { __ } from '@wordpress/i18n';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Internal dependencies
|
|
24
|
-
*/
|
|
25
13
|
import type {
|
|
26
14
|
CropperState,
|
|
27
15
|
HandlePosition,
|