@wordpress/media-editor 0.18.0 → 0.19.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +7 -7
  3. package/build/components/media-editor/index.cjs.map +2 -2
  4. package/build/components/media-editor/use-save-media-editor.cjs.map +2 -2
  5. package/build/components/media-editor-crop-panel/index.cjs.map +3 -3
  6. package/build/image-editor/core/interaction-controller.cjs.map +2 -2
  7. package/build/image-editor/core/setter-helpers.cjs.map +2 -2
  8. package/build/image-editor/react/components/overlays/dimensions-overlay.cjs.map +2 -2
  9. package/build-module/components/media-editor/index.mjs.map +2 -2
  10. package/build-module/components/media-editor/use-save-media-editor.mjs.map +2 -2
  11. package/build-module/components/media-editor-crop-panel/index.mjs +2 -2
  12. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  13. package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
  14. package/build-module/image-editor/core/setter-helpers.mjs.map +2 -2
  15. package/build-module/image-editor/react/components/overlays/dimensions-overlay.mjs.map +2 -2
  16. package/build-style/style-rtl.css +21 -22
  17. package/build-style/style.css +6 -0
  18. package/global.d.ts +0 -1
  19. package/package.json +23 -24
  20. package/src/components/media-editor/index.tsx +2 -2
  21. package/src/components/media-editor/use-save-media-editor.ts +5 -5
  22. package/src/components/media-editor-crop-panel/index.tsx +2 -2
  23. package/src/components/media-editor-modal/test/index.jsdom.test.tsx +7 -7
  24. package/src/components/rotation-ruler/stories/index.story.tsx +2 -2
  25. package/src/components/rotation-ruler/style.scss +9 -0
  26. package/src/image-editor/core/interaction-controller.ts +2 -2
  27. package/src/image-editor/core/setter-helpers.ts +1 -1
  28. package/src/image-editor/react/components/cropper.scss +6 -0
  29. package/src/image-editor/react/components/overlays/dimensions-overlay.tsx +1 -1
  30. package/src/image-editor/react/components/stencils/test/{rectangle-stencil.jsdom.test.tsx → rectangle-stencil.browser.test.tsx} +80 -98
  31. package/src/image-editor/react/components/test/{cropper.jsdom.test.tsx → cropper.browser.test.tsx} +230 -221
  32. package/src/image-editor/react/hooks/test/use-aria-announcer.jsdom.test.ts +1 -1
  33. package/src/image-editor/stories/rectangle-crop.story.tsx +24 -23
  34. package/src/image-editor/stories/{style.css → style.module.css} +8 -37
  35. package/tsconfig.build.json +1 -1
  36. package/tsconfig.build.tsbuildinfo +1 -1
  37. package/tsconfig.json +1 -2
@@ -18,7 +18,7 @@ vi.mock(
18
18
  () =>
19
19
  ( {
20
20
  speak: vi.fn(),
21
- } ) as unknown as typeof import('@wordpress/a11y')
21
+ } ) as unknown as typeof import( '@wordpress/a11y' )
22
22
  );
23
23
 
24
24
  function makeState( overrides: Partial< CropperState > = {} ): CropperState {
@@ -2,7 +2,7 @@ import type { Meta, StoryObj } from '@storybook/react-vite';
2
2
  import { useState, useCallback, useEffect, useRef } from '@wordpress/element';
3
3
  import {
4
4
  Button,
5
- SelectControl,
5
+ SelectControl as WCSelectControl,
6
6
  RangeControl,
7
7
  ToggleControl,
8
8
  Flex,
@@ -40,7 +40,7 @@ import {
40
40
  getVisibleBounds,
41
41
  } from '../core/camera';
42
42
  import { getSourceRegion } from '../core/source-region';
43
- import './style.css';
43
+ import styles from './style.module.css';
44
44
 
45
45
  const SAMPLE_IMAGE = 'image-editor-demo.jpeg';
46
46
 
@@ -118,7 +118,8 @@ function resolveAspectRatio(
118
118
  }
119
119
 
120
120
  const meta: Meta< typeof Cropper > = {
121
- title: 'MediaEditor/ImageEditor',
121
+ id: 'mediaeditor-imageeditor',
122
+ title: 'Editor/Media Editor/ImageEditor',
122
123
  component: Cropper,
123
124
  tags: [ 'status-experimental' ],
124
125
  };
@@ -135,7 +136,7 @@ const DefaultComponent = () => {
135
136
 
136
137
  return (
137
138
  <div>
138
- <div className="image-editor-story__container">
139
+ <div className={ styles.container }>
139
140
  <Cropper
140
141
  src={ SAMPLE_IMAGE }
141
142
  controller={ controller }
@@ -198,7 +199,7 @@ const WithControlsComponent = () => {
198
199
  ? getSourceRegion( state, {
199
200
  width: state.image.naturalWidth,
200
201
  height: state.image.naturalHeight,
201
- } )
202
+ } )
202
203
  : null;
203
204
 
204
205
  // The base cardinal angle (nearest 90° step) and the fine offset.
@@ -320,9 +321,9 @@ const WithControlsComponent = () => {
320
321
  type="file"
321
322
  accept="image/*"
322
323
  onChange={ handleFileChange }
323
- className="image-editor-story__hidden-file"
324
+ className={ styles[ 'hidden-file' ] }
324
325
  />
325
- <div className="image-editor-story__toolbar">
326
+ <div className={ styles.toolbar }>
326
327
  <Flex align="center" gap={ 2 } wrap>
327
328
  <FlexItem>
328
329
  <Button
@@ -388,7 +389,7 @@ const WithControlsComponent = () => {
388
389
  />
389
390
  </FlexItem>
390
391
  <FlexItem>
391
- <SelectControl
392
+ <WCSelectControl
392
393
  label="Aspect ratio"
393
394
  hideLabelFromVision
394
395
  value={ aspectRatioValue }
@@ -409,7 +410,7 @@ const WithControlsComponent = () => {
409
410
  />
410
411
  </FlexItem>
411
412
  <FlexItem>
412
- <SelectControl
413
+ <WCSelectControl
413
414
  label="Grid"
414
415
  hideLabelFromVision
415
416
  value={ gridMode }
@@ -440,7 +441,7 @@ const WithControlsComponent = () => {
440
441
  </Button>
441
442
  </FlexItem>
442
443
  </Flex>
443
- <div className="image-editor-story__sliders">
444
+ <div className={ styles.sliders }>
444
445
  <RangeControl
445
446
  label="Fine rotation"
446
447
  min={ -MAX_ROTATION_OFFSET }
@@ -460,7 +461,7 @@ const WithControlsComponent = () => {
460
461
  </div>
461
462
  </div>
462
463
 
463
- <div className="image-editor-story__resizable">
464
+ <div className={ styles.resizable }>
464
465
  <Cropper
465
466
  src={ src }
466
467
  controller={ controller }
@@ -491,7 +492,7 @@ const WithControlsComponent = () => {
491
492
 
492
493
  <div style={ { marginTop: 16 } }>
493
494
  <strong>Current State:</strong>
494
- <pre className="image-editor-story__state">
495
+ <pre className={ styles.state }>
495
496
  { JSON.stringify(
496
497
  {
497
498
  rotation: state.rotation,
@@ -503,7 +504,7 @@ const WithControlsComponent = () => {
503
504
  naturalWidth: state.image.naturalWidth,
504
505
  naturalHeight:
505
506
  state.image.naturalHeight,
506
- }
507
+ }
507
508
  : null,
508
509
  },
509
510
  null,
@@ -615,7 +616,7 @@ const DebugComponent = () => {
615
616
  : {
616
617
  elementSize: { width: 0, height: 0 },
617
618
  visualSize: { width: 0, height: 0 },
618
- };
619
+ };
619
620
 
620
621
  // Camera and restriction.
621
622
  const camera = hasImage
@@ -626,7 +627,7 @@ const DebugComponent = () => {
626
627
  { ...state, pan: { x: 0, y: 0 }, zoom: 1 },
627
628
  containerSize,
628
629
  imageSize
629
- )
630
+ )
630
631
  : null;
631
632
  const vb = baseCamera ? getVisibleBounds( baseCamera ) : null;
632
633
 
@@ -648,7 +649,7 @@ const DebugComponent = () => {
648
649
  ( state.cropRect.y + state.cropRect.height ) *
649
650
  vb.height,
650
651
  } ),
651
- ]
652
+ ]
652
653
  : null;
653
654
 
654
655
  // Restriction result.
@@ -737,9 +738,9 @@ const DebugComponent = () => {
737
738
  type="file"
738
739
  accept="image/*"
739
740
  onChange={ handleFileChange }
740
- className="image-editor-story__hidden-file"
741
+ className={ styles[ 'hidden-file' ] }
741
742
  />
742
- <div className="image-editor-story__toolbar">
743
+ <div className={ styles.toolbar }>
743
744
  <Flex align="center" gap={ 2 } wrap>
744
745
  <FlexItem>
745
746
  <Button
@@ -825,7 +826,7 @@ const DebugComponent = () => {
825
826
  </Button>
826
827
  </FlexItem>
827
828
  <FlexItem>
828
- <SelectControl
829
+ <WCSelectControl
829
830
  label="Format"
830
831
  hideLabelFromVision
831
832
  value={ exportFormat as 'image/jpeg' }
@@ -858,7 +859,7 @@ const DebugComponent = () => {
858
859
  </Button>
859
860
  </FlexItem>
860
861
  </Flex>
861
- <div className="image-editor-story__sliders">
862
+ <div className={ styles.sliders }>
862
863
  <RangeControl
863
864
  label="Fine rotation"
864
865
  min={ -MAX_ROTATION_OFFSET }
@@ -885,7 +886,7 @@ const DebugComponent = () => {
885
886
  ref={ containerRef }
886
887
  style={ { flex: '1 1 60%', minWidth: 0 } }
887
888
  >
888
- <div className="image-editor-story__container">
889
+ <div className={ styles.container }>
889
890
  <Cropper
890
891
  src={ src }
891
892
  controller={ controller }
@@ -907,10 +908,10 @@ const DebugComponent = () => {
907
908
  maxHeight: 500,
908
909
  } }
909
910
  >
910
- <div className="image-editor-story__export-preview">
911
+ <div className={ styles[ 'export-preview' ] }>
911
912
  { previewSrc ? (
912
913
  <img
913
- className="image-editor-story__export-image"
914
+ className={ styles[ 'export-image' ] }
914
915
  src={ previewSrc }
915
916
  alt="Crop preview"
916
917
  />
@@ -1,4 +1,4 @@
1
- .image-editor-story__container {
1
+ .container {
2
2
  width: 100%;
3
3
  max-width: 600px;
4
4
  aspect-ratio: 3 / 2;
@@ -6,7 +6,7 @@
6
6
  position: relative;
7
7
  }
8
8
 
9
- .image-editor-story__resizable {
9
+ .resizable {
10
10
  width: 600px;
11
11
  height: 400px;
12
12
  max-width: 100%;
@@ -18,7 +18,7 @@
18
18
  position: relative;
19
19
  }
20
20
 
21
- .image-editor-story__toolbar {
21
+ .toolbar {
22
22
  display: flex;
23
23
  flex-direction: column;
24
24
  gap: 12px;
@@ -29,25 +29,18 @@
29
29
  background: #fafafa;
30
30
  }
31
31
 
32
- .image-editor-story__sliders {
32
+ .sliders {
33
33
  display: grid;
34
34
  grid-template-columns: 1fr 1fr;
35
35
  gap: 16px;
36
36
  padding: 0 4px;
37
37
  }
38
38
 
39
- .image-editor-story__hidden-file {
39
+ .hidden-file {
40
40
  display: none;
41
41
  }
42
42
 
43
- .image-editor-story__json {
44
- width: 100%;
45
- min-height: 80px;
46
- font-family: monospace;
47
- font-size: 12px;
48
- }
49
-
50
- .image-editor-story__state {
43
+ .state {
51
44
  font-family: monospace;
52
45
  font-size: 11px;
53
46
  background: #f5f5f5;
@@ -58,34 +51,12 @@
58
51
  overflow: auto;
59
52
  }
60
53
 
61
- .image-editor-story__vertex-count {
62
- font-variant-numeric: tabular-nums;
63
- min-width: 120px;
64
- }
65
-
66
- .image-editor-story__instructions {
67
- background: #f9f9f9;
68
- border: 1px solid #e0e0e0;
69
- border-radius: 4px;
70
- padding: 12px;
71
- font-size: 13px;
72
- line-height: 1.5;
73
- }
74
-
75
- .image-editor-story__instructions p {
76
- margin: 0 0 4px;
77
- }
78
-
79
- .image-editor-story__instructions p:last-child {
80
- margin-bottom: 0;
81
- }
82
-
83
- .image-editor-story__export-preview {
54
+ .export-preview {
84
55
  margin-bottom: 16px;
85
56
  max-width: 200px;
86
57
  }
87
58
 
88
- .image-editor-story__export-image {
59
+ .export-image {
89
60
  display: block;
90
61
  max-width: 100%;
91
62
  border: 1px solid #ccc;
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/tsconfig.json",
3
- "extends": "../../tsconfig.base.json",
3
+ "extends": "@wordpress/monorepo-tools/tsconfig/base.json",
4
4
  "compilerOptions": {
5
5
  "types": [ "gutenberg-env", "style-imports" ],
6
6
  "checkJs": false