@wordpress/media-editor 0.13.0 → 0.14.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 +9 -0
- package/build/components/media-editor/index.cjs +38 -39
- package/build/components/media-editor/index.cjs.map +3 -3
- package/build/components/media-editor-crop-panel/index.cjs +0 -1
- package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
- package/build/image-editor/react/components/cropper.cjs +1 -11
- package/build/image-editor/react/components/cropper.cjs.map +2 -2
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +8 -8
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-aria-announcer.cjs +75 -32
- package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
- package/build-module/components/media-editor/index.mjs +40 -43
- package/build-module/components/media-editor/index.mjs.map +2 -2
- package/build-module/components/media-editor-crop-panel/index.mjs +0 -1
- package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
- package/build-module/image-editor/react/components/cropper.mjs +1 -11
- package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +8 -8
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +76 -38
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
- package/build-style/style-rtl.css +12 -6
- package/build-style/style.css +12 -6
- package/build-types/components/media-editor/index.d.ts.map +1 -1
- package/build-types/components/media-editor/use-crop-options.d.ts +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 +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 +1 -1
- 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 +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 +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-provider/index.d.ts +1 -1
- package/build-types/components/media-editor-provider/index.d.ts.map +1 -1
- package/build-types/components/media-form/index.d.ts +1 -1
- package/build-types/components/media-form/index.d.ts.map +1 -1
- package/build-types/image-editor/react/components/cropper-provider.d.ts +1 -1
- package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- 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 +1 -1
- package/build-types/image-editor/react/components/viewport-provider.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts +5 -4
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -1
- package/build-types/state/media-editor-state-provider.d.ts +1 -1
- package/build-types/state/media-editor-state-provider.d.ts.map +1 -1
- package/build-types/store/actions.d.ts +1 -1
- package/build-types/store/actions.d.ts.map +1 -1
- package/package.json +23 -21
- package/src/components/media-editor/index.tsx +75 -74
- package/src/components/media-editor/style.scss +9 -10
- package/src/components/media-editor-crop-panel/index.tsx +0 -1
- package/src/components/media-editor-image-controls/style.scss +1 -1
- package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +1 -1
- package/src/components/media-preview/style.scss +1 -1
- package/src/components/rotation-ruler/style.scss +2 -2
- package/src/image-editor/react/components/cropper.tsx +3 -12
- package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +8 -8
- package/src/image-editor/react/components/stencils/test/rectangle-stencil.tsx +17 -15
- package/src/image-editor/react/components/test/cropper.tsx +17 -17
- package/src/image-editor/react/hooks/test/use-aria-announcer.ts +413 -5
- package/src/image-editor/react/hooks/use-aria-announcer.ts +120 -47
- package/src/image-editor/stories/rectangle-crop.story.tsx +0 -7
- package/tsconfig.json +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -6,16 +6,14 @@ import {
|
|
|
6
6
|
Flex,
|
|
7
7
|
Spinner,
|
|
8
8
|
__experimentalConfirmDialog as ConfirmDialog,
|
|
9
|
-
privateApis as componentsPrivateApis,
|
|
10
9
|
} from '@wordpress/components';
|
|
11
|
-
import { Stack } from '@wordpress/ui';
|
|
10
|
+
import { Stack, Tabs } from '@wordpress/ui';
|
|
12
11
|
import { useViewportMatch } from '@wordpress/compose';
|
|
13
12
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
14
13
|
import { store as coreStore } from '@wordpress/core-data';
|
|
15
14
|
import {
|
|
16
15
|
createPortal,
|
|
17
16
|
useCallback,
|
|
18
|
-
useContext,
|
|
19
17
|
useEffect,
|
|
20
18
|
useMemo,
|
|
21
19
|
useRef,
|
|
@@ -50,7 +48,6 @@ import MediaEditorFineRotation from '../media-editor-fine-rotation';
|
|
|
50
48
|
import MediaEditorImageControls from '../media-editor-image-controls';
|
|
51
49
|
import MediaEditorCropPanel from '../media-editor-crop-panel';
|
|
52
50
|
import MediaForm from '../media-form';
|
|
53
|
-
import { unlock } from '../../lock-unlock';
|
|
54
51
|
import { getMediaTypeFromMimeType } from '../../utils';
|
|
55
52
|
import { MediaEditorStateProvider, useMediaEditor } from '../../state';
|
|
56
53
|
import type { AspectRatioPreset } from '../../image-editor/core/constants';
|
|
@@ -72,8 +69,6 @@ const ATTACHMENT_EMBED_QUERY = { _embed: 'author,wp:attached-to' } as const;
|
|
|
72
69
|
|
|
73
70
|
const PLACEMENT_CONTROL_IDLE_MS = 300;
|
|
74
71
|
|
|
75
|
-
const { Tabs } = unlock( componentsPrivateApis );
|
|
76
|
-
|
|
77
72
|
interface EditorTab {
|
|
78
73
|
id: string;
|
|
79
74
|
title: string;
|
|
@@ -116,7 +111,10 @@ export interface MediaEditorProps {
|
|
|
116
111
|
}
|
|
117
112
|
|
|
118
113
|
function MediaEditorSidebar( { tabs }: { tabs: EditorTab[] } ) {
|
|
119
|
-
|
|
114
|
+
// The tab list and panels must share one `<Tabs.Root>`, but they render in
|
|
115
|
+
// separate `ComplementaryArea` regions (header vs body). A non-virtual Slot
|
|
116
|
+
// reconciles both inline at the Slot, so the `Root` is lifted to wrap this
|
|
117
|
+
// Fill and that Slot together — see `MediaEditorContent`.
|
|
120
118
|
return (
|
|
121
119
|
<ComplementaryArea
|
|
122
120
|
scope="media-editor"
|
|
@@ -129,28 +127,20 @@ function MediaEditorSidebar( { tabs }: { tabs: EditorTab[] } ) {
|
|
|
129
127
|
headerClassName="media-editor__sidebar-header"
|
|
130
128
|
closeLabel={ __( 'Close media panel' ) }
|
|
131
129
|
header={
|
|
132
|
-
<Tabs.
|
|
133
|
-
|
|
134
|
-
{
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
</Tabs.TabList>
|
|
140
|
-
</Tabs.Context.Provider>
|
|
130
|
+
<Tabs.List variant="minimal">
|
|
131
|
+
{ tabs.map( ( tab ) => (
|
|
132
|
+
<Tabs.Tab key={ tab.id } value={ tab.id }>
|
|
133
|
+
{ tab.title }
|
|
134
|
+
</Tabs.Tab>
|
|
135
|
+
) ) }
|
|
136
|
+
</Tabs.List>
|
|
141
137
|
}
|
|
142
138
|
>
|
|
143
|
-
|
|
144
|
-
{
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
focusable={ false }
|
|
149
|
-
>
|
|
150
|
-
{ tab.panel }
|
|
151
|
-
</Tabs.TabPanel>
|
|
152
|
-
) ) }
|
|
153
|
-
</Tabs.Context.Provider>
|
|
139
|
+
{ tabs.map( ( tab ) => (
|
|
140
|
+
<Tabs.Panel key={ tab.id } value={ tab.id } tabIndex={ -1 }>
|
|
141
|
+
{ tab.panel }
|
|
142
|
+
</Tabs.Panel>
|
|
143
|
+
) ) }
|
|
154
144
|
</ComplementaryArea>
|
|
155
145
|
);
|
|
156
146
|
}
|
|
@@ -501,6 +491,13 @@ function MediaEditorContent( {
|
|
|
501
491
|
isPanelLayout,
|
|
502
492
|
] );
|
|
503
493
|
|
|
494
|
+
// Control the active tab from state here so the selection survives the
|
|
495
|
+
// sidebar closing (which unmounts the `ComplementaryArea` Fill and its
|
|
496
|
+
// tabs). Fall back to the first tab until one is picked, so images open on
|
|
497
|
+
// Crop.
|
|
498
|
+
const [ selectedTabId, setSelectedTabId ] = useState< string >();
|
|
499
|
+
const activeTabId = selectedTabId ?? tabs[ 0 ]?.id;
|
|
500
|
+
|
|
504
501
|
const handleChange = ( updates: Partial< Media > ) => {
|
|
505
502
|
editEntityRecord( 'postType', 'attachment', id, updates );
|
|
506
503
|
};
|
|
@@ -581,58 +578,62 @@ function MediaEditorContent( {
|
|
|
581
578
|
onChange={ handleChange }
|
|
582
579
|
settings={ { fields } }
|
|
583
580
|
>
|
|
584
|
-
|
|
585
|
-
|
|
581
|
+
{ ! media ? (
|
|
582
|
+
<div className="media-editor">
|
|
586
583
|
<div className="media-editor__loading">
|
|
587
584
|
<Spinner />
|
|
588
585
|
</div>
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
</div>
|
|
586
|
+
</div>
|
|
587
|
+
) : (
|
|
588
|
+
<Tabs.Root
|
|
589
|
+
className="media-editor"
|
|
590
|
+
value={ activeTabId }
|
|
591
|
+
onValueChange={ ( value ) =>
|
|
592
|
+
setSelectedTabId( value as string )
|
|
593
|
+
}
|
|
594
|
+
>
|
|
595
|
+
<MediaEditorSidebar tabs={ tabs } />
|
|
596
|
+
<InterfaceSkeleton
|
|
597
|
+
className="media-editor__skeleton"
|
|
598
|
+
labels={ {
|
|
599
|
+
body: isImage
|
|
600
|
+
? __( 'Image editor' )
|
|
601
|
+
: __( 'Media preview' ),
|
|
602
|
+
sidebar: __( 'Media details' ),
|
|
603
|
+
} }
|
|
604
|
+
content={
|
|
605
|
+
<div className="media-editor__content">
|
|
606
|
+
<div className="media-editor__canvas-area">
|
|
607
|
+
{ isImage ? (
|
|
608
|
+
<MediaEditorCanvas
|
|
609
|
+
focusOnMount
|
|
610
|
+
isPlacementActive={
|
|
611
|
+
isPlacementActive
|
|
612
|
+
}
|
|
613
|
+
onGestureStart={
|
|
614
|
+
handleCanvasGestureStart
|
|
615
|
+
}
|
|
616
|
+
onGestureEnd={
|
|
617
|
+
handleCanvasGestureEnd
|
|
618
|
+
}
|
|
619
|
+
/>
|
|
620
|
+
) : (
|
|
621
|
+
<MediaPreview />
|
|
626
622
|
) }
|
|
627
623
|
</div>
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
624
|
+
{ isImage && (
|
|
625
|
+
<div className="media-editor__canvas-toolbar">
|
|
626
|
+
{ ruler }
|
|
627
|
+
</div>
|
|
628
|
+
) }
|
|
629
|
+
</div>
|
|
630
|
+
}
|
|
631
|
+
sidebar={
|
|
632
|
+
<ComplementaryArea.Slot scope="media-editor" />
|
|
633
|
+
}
|
|
634
|
+
/>
|
|
635
|
+
</Tabs.Root>
|
|
636
|
+
) }
|
|
636
637
|
<ConfirmDialog
|
|
637
638
|
isOpen={ isDiscardDialogOpen }
|
|
638
639
|
confirmButtonText={ __( 'Discard' ) }
|
|
@@ -30,15 +30,14 @@
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
// The skeleton must always sit in the modal's flow (`top: auto`). The reset
|
|
33
|
-
// above sets that, but
|
|
34
|
-
// the
|
|
35
|
-
//
|
|
36
|
-
//
|
|
37
|
-
// the editor (and the fine-rotation ruler under the canvas) down
|
|
38
|
-
// full-screen modal that already overlays the admin bar.
|
|
39
|
-
// specificity that beats
|
|
40
|
-
// (`.media-editor` only ever renders inside `.media-editor-modal`)
|
|
41
|
-
// than on the experiment's class, which may change if it ever graduates.
|
|
33
|
+
// above sets that, but `@wordpress/interface` offsets every
|
|
34
|
+
// `.interface-interface-skeleton` below the admin bar in fullscreen mode via
|
|
35
|
+
// `.is-fullscreen-mode .interface-interface-skeleton { top: ... }`. That
|
|
36
|
+
// selector ties the reset's specificity, so source order lets it win and
|
|
37
|
+
// pushes the editor (and the fine-rotation ruler under the canvas) down
|
|
38
|
+
// inside our full-screen modal that already overlays the admin bar.
|
|
39
|
+
// Re-assert `top` at a specificity that beats it, anchored on the modal
|
|
40
|
+
// frame (`.media-editor` only ever renders inside `.media-editor-modal`).
|
|
42
41
|
.media-editor-modal & .interface-interface-skeleton.interface-interface-skeleton {
|
|
43
42
|
top: auto;
|
|
44
43
|
}
|
|
@@ -133,7 +132,7 @@
|
|
|
133
132
|
padding: $grid-unit-20;
|
|
134
133
|
|
|
135
134
|
@include break-small() {
|
|
136
|
-
padding: $grid-unit-
|
|
135
|
+
padding: $grid-unit-30 $grid-unit-30 0 0;
|
|
137
136
|
}
|
|
138
137
|
}
|
|
139
138
|
|
|
@@ -61,7 +61,6 @@ export default function MediaEditorCropPanel( {
|
|
|
61
61
|
</VisuallyHidden>
|
|
62
62
|
{ showTransformControls && <MediaEditorImageControls withLabels /> }
|
|
63
63
|
<SelectControl
|
|
64
|
-
__next40pxDefaultSize
|
|
65
64
|
label={ __( 'Aspect ratio' ) }
|
|
66
65
|
value={ aspectRatioValue }
|
|
67
66
|
onChange={ onAspectRatioChange }
|
|
@@ -18,7 +18,7 @@ $rotation-ruler-accent: var(--wp-admin-theme-color, #3858e9);
|
|
|
18
18
|
padding: 0 $grid-unit-10;
|
|
19
19
|
box-sizing: border-box;
|
|
20
20
|
color: $gray-900;
|
|
21
|
-
font-family: -
|
|
21
|
+
font-family: $font-family-body;
|
|
22
22
|
user-select: none;
|
|
23
23
|
touch-action: none;
|
|
24
24
|
cursor: ew-resize;
|
|
@@ -134,7 +134,7 @@ $rotation-ruler-accent: var(--wp-admin-theme-color, #3858e9);
|
|
|
134
134
|
height: 14px;
|
|
135
135
|
transform: translateX(-50%);
|
|
136
136
|
font-size: 12px;
|
|
137
|
-
font-weight:
|
|
137
|
+
font-weight: var(--wpds-typography-font-weight-emphasis);
|
|
138
138
|
line-height: 14px;
|
|
139
139
|
color: $gray-900;
|
|
140
140
|
pointer-events: none;
|
|
@@ -276,8 +276,9 @@ function CropperInner(
|
|
|
276
276
|
onStateChange?.( state );
|
|
277
277
|
}, [ state, onStateChange ] );
|
|
278
278
|
|
|
279
|
-
// ARIA
|
|
280
|
-
|
|
279
|
+
// ARIA announcements: announce significant state changes for screen readers
|
|
280
|
+
// via the centralized @wordpress/a11y speak() API called inside the hook.
|
|
281
|
+
useAriaAnnouncer( state );
|
|
281
282
|
|
|
282
283
|
// Compute fitted image dimensions and visual bounds from camera math.
|
|
283
284
|
const naturalWidth = state.image?.naturalWidth ?? 0;
|
|
@@ -1107,16 +1108,6 @@ function CropperInner(
|
|
|
1107
1108
|
/>
|
|
1108
1109
|
) }
|
|
1109
1110
|
</div>
|
|
1110
|
-
|
|
1111
|
-
{ /* ARIA live region for screen reader announcements */ }
|
|
1112
|
-
<div
|
|
1113
|
-
aria-live="polite"
|
|
1114
|
-
aria-atomic="true"
|
|
1115
|
-
className="wp-media-editor-image-editor__aria-live"
|
|
1116
|
-
style={ VISUALLY_HIDDEN_STYLE }
|
|
1117
|
-
>
|
|
1118
|
-
{ ariaMessage }
|
|
1119
|
-
</div>
|
|
1120
1111
|
</div>
|
|
1121
1112
|
</div>
|
|
1122
1113
|
);
|
|
@@ -59,21 +59,21 @@ const ALL_POSITIONS: HandlePosition[] = [
|
|
|
59
59
|
function getHandleLabel( pos: HandlePosition ): string {
|
|
60
60
|
switch ( pos ) {
|
|
61
61
|
case 'n':
|
|
62
|
-
return __( 'Resize top edge' );
|
|
62
|
+
return __( 'Resize from top edge' );
|
|
63
63
|
case 's':
|
|
64
|
-
return __( 'Resize bottom edge' );
|
|
64
|
+
return __( 'Resize from bottom edge' );
|
|
65
65
|
case 'e':
|
|
66
|
-
return __( 'Resize right edge' );
|
|
66
|
+
return __( 'Resize from right edge' );
|
|
67
67
|
case 'w':
|
|
68
|
-
return __( 'Resize left edge' );
|
|
68
|
+
return __( 'Resize from left edge' );
|
|
69
69
|
case 'nw':
|
|
70
|
-
return __( 'Resize top-left corner' );
|
|
70
|
+
return __( 'Resize from top-left corner' );
|
|
71
71
|
case 'ne':
|
|
72
|
-
return __( 'Resize top-right corner' );
|
|
72
|
+
return __( 'Resize from top-right corner' );
|
|
73
73
|
case 'sw':
|
|
74
|
-
return __( 'Resize bottom-left corner' );
|
|
74
|
+
return __( 'Resize from bottom-left corner' );
|
|
75
75
|
case 'se':
|
|
76
|
-
return __( 'Resize bottom-right corner' );
|
|
76
|
+
return __( 'Resize from bottom-right corner' );
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
|
|
@@ -94,21 +94,23 @@ describe( 'RectangleStencil', () => {
|
|
|
94
94
|
.map( ( b ) => b.getAttribute( 'aria-label' ) );
|
|
95
95
|
|
|
96
96
|
expect( labels ).toEqual( [
|
|
97
|
-
'Resize top-left corner',
|
|
98
|
-
'Resize top edge',
|
|
99
|
-
'Resize top-right corner',
|
|
100
|
-
'Resize right edge',
|
|
101
|
-
'Resize bottom-right corner',
|
|
102
|
-
'Resize bottom edge',
|
|
103
|
-
'Resize bottom-left corner',
|
|
104
|
-
'Resize left edge',
|
|
97
|
+
'Resize from top-left corner',
|
|
98
|
+
'Resize from top edge',
|
|
99
|
+
'Resize from top-right corner',
|
|
100
|
+
'Resize from right edge',
|
|
101
|
+
'Resize from bottom-right corner',
|
|
102
|
+
'Resize from bottom edge',
|
|
103
|
+
'Resize from bottom-left corner',
|
|
104
|
+
'Resize from left edge',
|
|
105
105
|
] );
|
|
106
106
|
} );
|
|
107
107
|
|
|
108
108
|
it( 'describes keyboard resizing on resize handles', () => {
|
|
109
109
|
renderStencil();
|
|
110
110
|
expect(
|
|
111
|
-
screen.getByRole( 'button', {
|
|
111
|
+
screen.getByRole( 'button', {
|
|
112
|
+
name: 'Resize from top-left corner',
|
|
113
|
+
} )
|
|
112
114
|
).toHaveAccessibleDescription(
|
|
113
115
|
'Use arrow keys to resize the crop area. Hold Shift for larger steps.'
|
|
114
116
|
);
|
|
@@ -121,10 +123,10 @@ describe( 'RectangleStencil', () => {
|
|
|
121
123
|
.map( ( b ) => b.getAttribute( 'aria-label' ) );
|
|
122
124
|
|
|
123
125
|
expect( labels ).toEqual( [
|
|
124
|
-
'Resize top-left corner',
|
|
125
|
-
'Resize top-right corner',
|
|
126
|
-
'Resize bottom-right corner',
|
|
127
|
-
'Resize bottom-left corner',
|
|
126
|
+
'Resize from top-left corner',
|
|
127
|
+
'Resize from top-right corner',
|
|
128
|
+
'Resize from bottom-right corner',
|
|
129
|
+
'Resize from bottom-left corner',
|
|
128
130
|
] );
|
|
129
131
|
} );
|
|
130
132
|
} );
|
|
@@ -252,7 +254,7 @@ describe( 'RectangleStencil', () => {
|
|
|
252
254
|
imageSize: { width: 500, height: 500 },
|
|
253
255
|
} );
|
|
254
256
|
const nwHandle = screen.getByRole( 'button', {
|
|
255
|
-
name: 'Resize top-left corner',
|
|
257
|
+
name: 'Resize from top-left corner',
|
|
256
258
|
} );
|
|
257
259
|
|
|
258
260
|
fireEvent.keyDown( nwHandle, {
|
|
@@ -319,7 +321,7 @@ describe( 'RectangleStencil', () => {
|
|
|
319
321
|
const snapCropRect = jest.fn( ( rect: NormalizedRect ) => rect );
|
|
320
322
|
renderStencil( { aspectRatio: 1, snapCropRect } );
|
|
321
323
|
const nwHandle = screen.getByRole( 'button', {
|
|
322
|
-
name: 'Resize top-left corner',
|
|
324
|
+
name: 'Resize from top-left corner',
|
|
323
325
|
} );
|
|
324
326
|
|
|
325
327
|
fireEvent.keyDown( nwHandle, {
|
|
@@ -165,7 +165,7 @@ describe( 'Cropper', () => {
|
|
|
165
165
|
|
|
166
166
|
const canvas = screen.getByRole( 'group', { name: 'Crop area' } );
|
|
167
167
|
const handle = await screen.findByRole( 'button', {
|
|
168
|
-
name: 'Resize top-left corner',
|
|
168
|
+
name: 'Resize from top-left corner',
|
|
169
169
|
} );
|
|
170
170
|
|
|
171
171
|
fireEvent.blur( canvas, { relatedTarget: handle } );
|
|
@@ -192,7 +192,7 @@ describe( 'Cropper', () => {
|
|
|
192
192
|
|
|
193
193
|
const canvas = screen.getByRole( 'group', { name: 'Crop area' } );
|
|
194
194
|
const handle = await screen.findByRole( 'button', {
|
|
195
|
-
name: 'Resize top-left corner',
|
|
195
|
+
name: 'Resize from top-left corner',
|
|
196
196
|
} );
|
|
197
197
|
const focusVisibleClass =
|
|
198
198
|
'wp-media-editor-image-editor__canvas--focus-visible';
|
|
@@ -232,7 +232,7 @@ describe( 'Cropper', () => {
|
|
|
232
232
|
|
|
233
233
|
const canvas = screen.getByRole( 'group', { name: 'Crop area' } );
|
|
234
234
|
const handle = await screen.findByRole( 'button', {
|
|
235
|
-
name: 'Resize top-left corner',
|
|
235
|
+
name: 'Resize from top-left corner',
|
|
236
236
|
} );
|
|
237
237
|
|
|
238
238
|
act( () => {
|
|
@@ -294,7 +294,7 @@ describe( 'Cropper', () => {
|
|
|
294
294
|
);
|
|
295
295
|
|
|
296
296
|
await screen.findByRole( 'button', {
|
|
297
|
-
name: 'Resize top-left corner',
|
|
297
|
+
name: 'Resize from top-left corner',
|
|
298
298
|
} );
|
|
299
299
|
( controller.setCropRect as jest.Mock ).mockClear();
|
|
300
300
|
( controller.adjustCropRectForViewport as jest.Mock ).mockClear();
|
|
@@ -310,7 +310,7 @@ describe( 'Cropper', () => {
|
|
|
310
310
|
|
|
311
311
|
expect(
|
|
312
312
|
screen.queryByRole( 'button', {
|
|
313
|
-
name: 'Resize top-left corner',
|
|
313
|
+
name: 'Resize from top-left corner',
|
|
314
314
|
} )
|
|
315
315
|
).not.toBeInTheDocument();
|
|
316
316
|
expect( controller.setCropRect ).not.toHaveBeenCalled();
|
|
@@ -358,7 +358,7 @@ describe( 'Cropper', () => {
|
|
|
358
358
|
);
|
|
359
359
|
|
|
360
360
|
const handle = await screen.findByRole( 'button', {
|
|
361
|
-
name: 'Resize top-left corner',
|
|
361
|
+
name: 'Resize from top-left corner',
|
|
362
362
|
} );
|
|
363
363
|
// The settle transition and viewport pan live on the stage, not the
|
|
364
364
|
// canvas (which stays fixed so the root background is never exposed).
|
|
@@ -414,7 +414,7 @@ describe( 'Cropper', () => {
|
|
|
414
414
|
);
|
|
415
415
|
|
|
416
416
|
const handle = await screen.findByRole( 'button', {
|
|
417
|
-
name: 'Resize top-left corner',
|
|
417
|
+
name: 'Resize from top-left corner',
|
|
418
418
|
} );
|
|
419
419
|
const stage = screen.getByTestId( 'cropper-stage' );
|
|
420
420
|
|
|
@@ -462,7 +462,7 @@ describe( 'Cropper', () => {
|
|
|
462
462
|
);
|
|
463
463
|
|
|
464
464
|
const handle = await screen.findByRole( 'button', {
|
|
465
|
-
name: 'Resize top-left corner',
|
|
465
|
+
name: 'Resize from top-left corner',
|
|
466
466
|
} );
|
|
467
467
|
const stage = screen.getByTestId( 'cropper-stage' );
|
|
468
468
|
|
|
@@ -502,7 +502,7 @@ describe( 'Cropper', () => {
|
|
|
502
502
|
);
|
|
503
503
|
|
|
504
504
|
const handle = await screen.findByRole( 'button', {
|
|
505
|
-
name: 'Resize top-left corner',
|
|
505
|
+
name: 'Resize from top-left corner',
|
|
506
506
|
} );
|
|
507
507
|
const stage = screen.getByTestId( 'cropper-stage' );
|
|
508
508
|
|
|
@@ -549,7 +549,7 @@ describe( 'Cropper', () => {
|
|
|
549
549
|
|
|
550
550
|
// East handle (4th button clockwise: nw, n, ne, e).
|
|
551
551
|
const eHandle = await screen.findByRole( 'button', {
|
|
552
|
-
name: 'Resize right edge',
|
|
552
|
+
name: 'Resize from right edge',
|
|
553
553
|
} );
|
|
554
554
|
const stage = screen.getByTestId( 'cropper-stage' );
|
|
555
555
|
|
|
@@ -582,7 +582,7 @@ describe( 'Cropper', () => {
|
|
|
582
582
|
);
|
|
583
583
|
|
|
584
584
|
const resizeHandle = await screen.findByRole( 'button', {
|
|
585
|
-
name: 'Resize top-left corner',
|
|
585
|
+
name: 'Resize from top-left corner',
|
|
586
586
|
} );
|
|
587
587
|
const canvas = screen.getByRole( 'group', { name: 'Crop area' } );
|
|
588
588
|
|
|
@@ -622,7 +622,7 @@ describe( 'Cropper', () => {
|
|
|
622
622
|
);
|
|
623
623
|
|
|
624
624
|
await screen.findByRole( 'button', {
|
|
625
|
-
name: 'Resize top-left corner',
|
|
625
|
+
name: 'Resize from top-left corner',
|
|
626
626
|
} );
|
|
627
627
|
const canvas = screen.getByRole( 'group', { name: 'Crop area' } );
|
|
628
628
|
|
|
@@ -670,7 +670,7 @@ describe( 'Cropper', () => {
|
|
|
670
670
|
);
|
|
671
671
|
|
|
672
672
|
const resizeHandle = await screen.findByRole( 'button', {
|
|
673
|
-
name: 'Resize top-left corner',
|
|
673
|
+
name: 'Resize from top-left corner',
|
|
674
674
|
} );
|
|
675
675
|
const canvas = screen.getByRole( 'group', {
|
|
676
676
|
name: 'Crop area',
|
|
@@ -892,7 +892,7 @@ describe( 'Cropper', () => {
|
|
|
892
892
|
expect( imageScale() ).toBeCloseTo( 2.4, 2 );
|
|
893
893
|
|
|
894
894
|
const handle = await screen.findByRole( 'button', {
|
|
895
|
-
name: 'Resize top-left corner',
|
|
895
|
+
name: 'Resize from top-left corner',
|
|
896
896
|
} );
|
|
897
897
|
fireEvent.pointerDown( handle, {
|
|
898
898
|
button: 0,
|
|
@@ -926,7 +926,7 @@ describe( 'Cropper', () => {
|
|
|
926
926
|
);
|
|
927
927
|
|
|
928
928
|
const handle = await screen.findByRole( 'button', {
|
|
929
|
-
name: 'Resize right edge',
|
|
929
|
+
name: 'Resize from right edge',
|
|
930
930
|
} );
|
|
931
931
|
fireEvent.keyDown( handle, { key: 'ArrowRight' } );
|
|
932
932
|
|
|
@@ -968,7 +968,7 @@ describe( 'Cropper', () => {
|
|
|
968
968
|
);
|
|
969
969
|
|
|
970
970
|
const handle = await screen.findByRole( 'button', {
|
|
971
|
-
name: 'Resize right edge',
|
|
971
|
+
name: 'Resize from right edge',
|
|
972
972
|
} );
|
|
973
973
|
( controller.setCropRect as jest.Mock ).mockClear();
|
|
974
974
|
fireEvent.keyDown( handle, { key: 'ArrowRight' } );
|
|
@@ -1003,7 +1003,7 @@ describe( 'Cropper', () => {
|
|
|
1003
1003
|
);
|
|
1004
1004
|
|
|
1005
1005
|
const handle = await screen.findByRole( 'button', {
|
|
1006
|
-
name: 'Resize right edge',
|
|
1006
|
+
name: 'Resize from right edge',
|
|
1007
1007
|
} );
|
|
1008
1008
|
fireEvent.keyDown( handle, { key: 'ArrowRight' } );
|
|
1009
1009
|
|