@wordpress/media-editor 0.20.0 → 0.21.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 (116) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/README.md +2 -1
  3. package/build/components/media-editor/index.cjs +7 -16
  4. package/build/components/media-editor/index.cjs.map +3 -3
  5. package/build/components/media-editor/use-crop-options.cjs +1 -2
  6. package/build/components/media-editor/use-crop-options.cjs.map +2 -2
  7. package/build/components/media-editor-canvas/index.cjs.map +3 -3
  8. package/build/components/media-editor-crop-panel/index.cjs +12 -8
  9. package/build/components/media-editor-crop-panel/index.cjs.map +3 -3
  10. package/build/components/media-editor-modal/index.cjs +2 -0
  11. package/build/components/media-editor-modal/index.cjs.map +2 -2
  12. package/build/components/media-editor-provider/index.cjs +2 -1
  13. package/build/components/media-editor-provider/index.cjs.map +2 -2
  14. package/build/components/media-form/index.cjs +28 -28
  15. package/build/components/media-form/index.cjs.map +3 -3
  16. package/build/components/media-preview/index.cjs.map +3 -3
  17. package/build/image-editor/react/components/cropper.cjs +1 -11
  18. package/build/image-editor/react/components/cropper.cjs.map +2 -2
  19. package/build/state/composite-reducer.cjs +33 -8
  20. package/build/state/composite-reducer.cjs.map +3 -3
  21. package/build/state/index.cjs.map +1 -1
  22. package/build/state/types.cjs.map +1 -1
  23. package/build/state/use-media-editor-state.cjs +20 -7
  24. package/build/state/use-media-editor-state.cjs.map +2 -2
  25. package/build-module/components/media-editor/index.mjs +9 -18
  26. package/build-module/components/media-editor/index.mjs.map +2 -2
  27. package/build-module/components/media-editor/use-crop-options.mjs +1 -2
  28. package/build-module/components/media-editor/use-crop-options.mjs.map +2 -2
  29. package/build-module/components/media-editor-canvas/index.mjs +2 -2
  30. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  31. package/build-module/components/media-editor-crop-panel/index.mjs +13 -9
  32. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  33. package/build-module/components/media-editor-modal/index.mjs +2 -0
  34. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  35. package/build-module/components/media-editor-provider/index.mjs +2 -1
  36. package/build-module/components/media-editor-provider/index.mjs.map +2 -2
  37. package/build-module/components/media-form/index.mjs +33 -30
  38. package/build-module/components/media-form/index.mjs.map +2 -2
  39. package/build-module/components/media-preview/index.mjs +2 -2
  40. package/build-module/components/media-preview/index.mjs.map +2 -2
  41. package/build-module/image-editor/react/components/cropper.mjs +1 -11
  42. package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
  43. package/build-module/state/composite-reducer.mjs +23 -8
  44. package/build-module/state/composite-reducer.mjs.map +2 -2
  45. package/build-module/state/index.mjs.map +1 -1
  46. package/build-module/state/types.mjs.map +1 -1
  47. package/build-module/state/use-media-editor-state.mjs +20 -7
  48. package/build-module/state/use-media-editor-state.mjs.map +2 -2
  49. package/build-types/components/media-editor/index.d.ts +2 -1
  50. package/build-types/components/media-editor/index.d.ts.map +1 -1
  51. package/build-types/components/media-editor/use-crop-options.d.ts +0 -1
  52. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  53. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  54. package/build-types/components/media-editor-modal/index.d.ts +7 -2
  55. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  56. package/build-types/components/media-editor-provider/index.d.ts +7 -1
  57. package/build-types/components/media-editor-provider/index.d.ts.map +1 -1
  58. package/build-types/components/media-form/index.d.ts +5 -2
  59. package/build-types/components/media-form/index.d.ts.map +1 -1
  60. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  61. package/build-types/state/composite-reducer.d.ts +1 -1
  62. package/build-types/state/composite-reducer.d.ts.map +1 -1
  63. package/build-types/state/index.d.ts +1 -1
  64. package/build-types/state/index.d.ts.map +1 -1
  65. package/build-types/state/types.d.ts +34 -5
  66. package/build-types/state/types.d.ts.map +1 -1
  67. package/build-types/state/use-media-editor-state.d.ts +16 -5
  68. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  69. package/package.json +33 -22
  70. package/src/components/media-editor/index.tsx +12 -22
  71. package/src/components/media-editor/use-crop-options.ts +0 -2
  72. package/src/components/media-editor-canvas/index.tsx +2 -2
  73. package/src/components/media-editor-crop-panel/index.tsx +17 -9
  74. package/src/components/media-editor-image-controls/style.scss +1 -1
  75. package/src/components/media-editor-modal/index.tsx +8 -1
  76. package/src/components/media-editor-provider/index.tsx +8 -1
  77. package/src/components/media-form/index.tsx +48 -42
  78. package/src/components/media-preview/index.tsx +2 -2
  79. package/src/image-editor/docs/architecture.md +4 -0
  80. package/src/image-editor/react/components/cropper.tsx +1 -15
  81. package/src/state/composite-reducer.ts +24 -11
  82. package/src/state/index.ts +2 -0
  83. package/src/state/types.ts +37 -5
  84. package/src/state/use-media-editor-state.ts +46 -11
  85. package/global.d.ts +0 -5
  86. package/src/components/media-editor/test/restore-original.browser.test.tsx +0 -227
  87. package/src/components/media-editor/test/use-crop-options.jsdom.test.tsx +0 -106
  88. package/src/components/media-editor-crop-panel/test/index.jsdom.test.tsx +0 -72
  89. package/src/components/media-editor-image-controls/test/index.jsdom.test.tsx +0 -186
  90. package/src/components/media-editor-modal/test/build-modifiers.test.ts +0 -359
  91. package/src/components/media-editor-modal/test/index.jsdom.test.tsx +0 -182
  92. package/src/components/rotation-ruler/stories/index.story.tsx +0 -43
  93. package/src/components/rotation-ruler/test/index.jsdom.test.tsx +0 -140
  94. package/src/image-editor/core/export/test/canvas-renderer.jsdom.test.ts +0 -823
  95. package/src/image-editor/core/math/test/sanitize.ts +0 -242
  96. package/src/image-editor/core/test/camera.ts +0 -1218
  97. package/src/image-editor/core/test/interaction-controller.ts +0 -1299
  98. package/src/image-editor/core/test/preview-export-parity.ts +0 -249
  99. package/src/image-editor/core/test/render-camera-bridge.ts +0 -349
  100. package/src/image-editor/core/test/state.ts +0 -876
  101. package/src/image-editor/core/test/stencil-math.ts +0 -665
  102. package/src/image-editor/core/transforms/test/pipeline.ts +0 -267
  103. package/src/image-editor/react/components/stencils/test/rectangle-stencil.browser.test.tsx +0 -438
  104. package/src/image-editor/react/components/test/cropper.browser.test.tsx +0 -1462
  105. package/src/image-editor/react/hooks/test/use-aria-announcer.jsdom.test.ts +0 -491
  106. package/src/image-editor/react/hooks/test/use-cropper-reducer.jsdom.test.ts +0 -1049
  107. package/src/image-editor/react/hooks/test/use-interaction.jsdom.test.ts +0 -213
  108. package/src/image-editor/react/hooks/test/use-transform-style.jsdom.test.ts +0 -140
  109. package/src/image-editor/stories/rectangle-crop.story.tsx +0 -1073
  110. package/src/image-editor/stories/style.module.css +0 -65
  111. package/src/state/test/use-media-editor-state.browser.test.tsx +0 -79
  112. package/src/state/test/use-media-editor-state.jsdom.test.ts +0 -386
  113. package/src/store/test/reducer.ts +0 -64
  114. package/tsconfig.build.json +0 -26
  115. package/tsconfig.build.tsbuildinfo +0 -1
  116. package/tsconfig.json +0 -37
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor/index.tsx"],"names":[],"mappings":"AAuCA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EACX,aAAa,IAAI,kBAAkB,EACnC,YAAY,EACZ,SAAS,EACT,MAAM,OAAO,CAAC;AAEf,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAStD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAG3E,OAAO,EAGN,KAAK,qBAAqB,EAC1B,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AA0BrE,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;OAKG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;IAC1B,cAAc,EAAE,MAAM,IAAI,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AI,CAAC;IACtC,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC3B;AAiID,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,eAAe,CAAC,EAAE,OAAO,CAAC;CAC1B;AAED,iBAAS,aAAa,CAAE,EAAE,eAAuB,EAAE,EAAE,kBAAkB,+BAiGtE;AAED,iBAAS,cAAc,uCAiFtB;AAED,MAAM,WAAW,gBAAgB;IAChC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAC7B;AAED,iBAAS,WAAW,CAAE,EAAE,IAAgB,EAAE,EAAE,gBAAgB,+BAkC3D;AAigBD,wBAAgB,WAAW,CAAE,KAAK,EAAE,gBAAgB,+BAMnD;yBANe,WAAW;;;;;eAeZ,WAAW"}
@@ -7,7 +7,6 @@ interface UseCropOptionsReturn {
7
7
  setAspectRatioValue: (value: string) => void;
8
8
  aspectRatioOptions: AspectRatioPreset[];
9
9
  resolvedAspectRatio: number | undefined;
10
- resetCropOptions: () => void;
11
10
  }
12
11
  /**
13
12
  * Build the preset list shown in the dropdown — always include the
@@ -1 +1 @@
1
- {"version":3,"file":"use-crop-options.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor/use-crop-options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAG3E,UAAU,kBAAkB;IAC3B,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACzC;AAED,UAAU,oBAAoB;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,CAAE,KAAK,EAAE,MAAM,KAAM,IAAI,CAAC;IAC/C,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;IACxC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,gBAAgB,EAAE,MAAM,IAAI,CAAC;CAC7B;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACpC,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,GACtC,iBAAiB,EAAE,CAMrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAE,EAC/B,kBAAkB,GAClB,GAAE,kBAAuB,GAAI,oBAAoB,CAsBjD"}
1
+ {"version":3,"file":"use-crop-options.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor/use-crop-options.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAG3E,UAAU,kBAAkB;IAC3B,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACzC;AAED,UAAU,oBAAoB;IAC7B,gBAAgB,EAAE,MAAM,CAAC;IACzB,mBAAmB,EAAE,CAAE,KAAK,EAAE,MAAM,KAAM,IAAI,CAAC;IAC/C,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;IACxC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;CACxC;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACpC,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,GACtC,iBAAiB,EAAE,CAMrB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,cAAc,CAAE,EAC/B,kBAAkB,GAClB,GAAE,kBAAuB,GAAI,oBAAoB,CAqBjD"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-crop-panel/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,MAAM,WAAW,yBAAyB;IACzC;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,mBAAmB,EAAE,CAAE,KAAK,EAAE,MAAM,KAAM,IAAI,CAAC;IAC/C,uDAAuD;IACvD,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;IACxC,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAE,EAC7C,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,QAAgB,GAChB,EAAE,yBAAyB,+BA0B3B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-crop-panel/index.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,MAAM,WAAW,yBAAyB;IACzC;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;IACzB,gDAAgD;IAChD,mBAAmB,EAAE,CAAE,KAAK,EAAE,MAAM,KAAM,IAAI,CAAC;IAC/C,uDAAuD;IACvD,kBAAkB,EAAE,iBAAiB,EAAE,CAAC;IACxC,mEAAmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAE,EAC7C,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAClB,QAAgB,GAChB,EAAE,yBAAyB,+BAmC3B"}
@@ -1,4 +1,4 @@
1
- import type { Field } from '@wordpress/dataviews';
1
+ import type { Field, Form } from '@wordpress/dataviews';
2
2
  import type { Media } from '../media-editor-provider';
3
3
  import type { AspectRatioPreset } from '../../image-editor/core/constants';
4
4
  interface MediaEditorModalProps {
@@ -9,12 +9,17 @@ interface MediaEditorModalProps {
9
9
  * since `@wordpress/media-editor` cannot depend on `@wordpress/editor`.
10
10
  */
11
11
  fields?: Field<Media>[];
12
+ /**
13
+ * Form the fields are laid out with in the Details tab. When omitted,
14
+ * a default layout of the core attachment fields is used.
15
+ */
16
+ form?: Form;
12
17
  /**
13
18
  * Fixed aspect-ratio presets for image cropping. Free and Original are
14
19
  * always provided by the media editor.
15
20
  */
16
21
  aspectRatioPresets?: AspectRatioPreset[];
17
22
  }
18
- export declare function MediaEditorModal({ fields, aspectRatioPresets, }: MediaEditorModalProps): import("react").JSX.Element | null;
23
+ export declare function MediaEditorModal({ fields, form, aspectRatioPresets, }: MediaEditorModalProps): import("react").JSX.Element | null;
19
24
  export default MediaEditorModal;
20
25
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-modal/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAGlD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAGtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,UAAU,qBAAqB;IAC9B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,KAAK,CAAE,KAAK,CAAE,EAAE,CAAC;IAC1B;;;OAGG;IACH,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACzC;AAqBD,wBAAgB,gBAAgB,CAAE,EACjC,MAAW,EACX,kBAAkB,GAClB,EAAE,qBAAqB,sCAgHvB;eAEc,gBAAgB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-modal/index.tsx"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAGtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mCAAmC,CAAC;AAE3E,UAAU,qBAAqB;IAC9B;;;;;OAKG;IACH,MAAM,CAAC,EAAE,KAAK,CAAE,KAAK,CAAE,EAAE,CAAC;IAC1B;;;OAGG;IACH,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ;;;OAGG;IACH,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;CACzC;AAqBD,wBAAgB,gBAAgB,CAAE,EACjC,MAAW,EACX,IAAI,EACJ,kBAAkB,GAClB,EAAE,qBAAqB,sCAiHvB;eAEc,gBAAgB"}
@@ -1,4 +1,4 @@
1
- import type { Field } from '@wordpress/dataviews';
1
+ import type { Field, Form } from '@wordpress/dataviews';
2
2
  import type { ReactNode } from 'react';
3
3
  /**
4
4
  * Media object from WordPress REST API.
@@ -29,6 +29,7 @@ export interface MediaEditorContextValue {
29
29
  media?: Media;
30
30
  onChange?: (updates: Partial<Media>) => void;
31
31
  fields: Field<Media>[];
32
+ form?: Form;
32
33
  }
33
34
  /**
34
35
  * Props for MediaEditorProvider.
@@ -46,6 +47,11 @@ export interface MediaEditorProviderProps {
46
47
  /** Configuration settings for the media editor. */
47
48
  settings?: {
48
49
  fields?: Field<Media>[];
50
+ /**
51
+ * The form the fields are laid out with. When omitted, `MediaForm`
52
+ * uses a default layout of the core attachment fields.
53
+ */
54
+ form?: Form;
49
55
  };
50
56
  /** Child components. */
51
57
  children: ReactNode;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-provider/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,KAAK;IACrB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,OAAO,CAAC,EAAE,MAAM,GAAG;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,GAAG,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACvD,WAAW,CAAC,EAAE,MAA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ACH,wBAAgB,qBAAqB,IAAI,uBAAuB,CAQ/D"}
@@ -11,10 +11,13 @@ export interface MediaFormProps {
11
11
  * MediaForm component for editing media metadata.
12
12
  *
13
13
  * Renders a DataForm with fields for editing media properties like
14
- * title, alt text, caption, description, etc.
14
+ * title, alt text, caption, description, etc. The fields are laid out with
15
+ * the `form` prop, else the form of the provider settings, else a default
16
+ * form of the core attachment fields.
15
17
  *
16
18
  * @param props - Component props.
17
- * @param props.form - Optional form configuration.
19
+ * @param props.form - Optional form configuration, which takes precedence
20
+ * over the form of the provider settings.
18
21
  * @param props.header - Optional header content to display above the form.
19
22
  * @return The MediaForm component.
20
23
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-form/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAS,MAAM,sBAAsB,CAAC;AAIxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIvC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,SAAS,CAAC;CACnB;AAED;;;;;;;;;;GAUG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,EAClC,IAAI,EAAE,aAAa,EACnB,MAAM,GACN,EAAE,cAAc,+BA+DhB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-form/index.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAOjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAiCvC;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,IAAI,CAAC,EAAE,IAAI,CAAC;IACZ,MAAM,CAAC,EAAE,SAAS,CAAC;CACnB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAAE,EAClC,IAAI,EAAE,aAAa,EACnB,MAAM,GACN,EAAE,cAAc,+BAkChB"}
@@ -1 +1 @@
1
- {"version":3,"file":"cropper.d.ts","sourceRoot":"","sources":["../../../../src/image-editor/react/components/cropper.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACX,YAAY,EAEZ,YAAY,EACZ,IAAI,EAEJ,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AA2CtE;;GAEG;AACH,MAAM,WAAW,YAAY;IAC5B,wBAAwB;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,4EAA4E;IAC5E,UAAU,EAAE,iBAAiB,CAAC;IAC9B,yEAAyE;IACzE,OAAO,CAAC,EAAE,KAAK,CAAC,aAAa,CAAE,YAAY,CAAE,CAAC;IAC9C,yEAAyE;IACzE,QAAQ,CAAC,EAAE,OAAO,GAAG,aAAa,CAAC;IACnC,wEAAwE;IACxE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,sDAAsD;IACtD,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,+DAA+D;IAC/D,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,0BAA0B;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4EAA4E;IAC5E,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mDAAmD;IACnD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+CAA+C;IAC/C,aAAa,CAAC,EAAE,CAAE,IAAI,EAAE,IAAI,KAAM,IAAI,CAAC;IACvC;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,CAAE,KAAK,EAAE,YAAY,KAAM,IAAI,CAAC;IAChD,oFAAoF;IACpF,cAAc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,IAAI,CAAC;IACvC;;;;;;;;;OASG;IACH,aAAa,CAAC,EAAE,CAAE,KAAK,EAAE,YAAY,KAAM,IAAI,CAAC;IAChD,oFAAoF;IACpF,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,uEAAuE;IACvE,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;CACnB;AA69BD,eAAO,MAAM,OAAO,yGAMnB,CAAC"}
@@ -27,7 +27,7 @@ export declare function mediaEditorReducer(state: MediaEditorState, action: Medi
27
27
  export declare function areMediaEditorStatesEqual(a: MediaEditorState, b: MediaEditorState): boolean;
28
28
  /**
29
29
  * Build the composite state a session starts from: the given cropper
30
- * slice and default crop options.
30
+ * slice, default crop options, and no edits.
31
31
  *
32
32
  * @param cropper The cropper slice.
33
33
  * @return Composite initial state.
@@ -1 +1 @@
1
- {"version":3,"file":"composite-reducer.d.ts","sourceRoot":"","sources":["../../src/state/composite-reducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAIN,KAAK,YAAY,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,iBAAiB,GACvB,gBAAgB,CAgElB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACxC,CAAC,EAAE,gBAAgB,EACnB,CAAC,EAAE,gBAAgB,GACjB,OAAO,CAQT;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC3C,OAAO,EAAE,YAAY,GACnB,gBAAgB,CAKlB"}
1
+ {"version":3,"file":"composite-reducer.d.ts","sourceRoot":"","sources":["../../src/state/composite-reducer.ts"],"names":[],"mappings":"AACA,OAAO,EAIN,KAAK,YAAY,EACjB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EAGN,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,EACrB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,kBAAkB,CACjC,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,iBAAiB,GACvB,gBAAgB,CA0ElB;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CACxC,CAAC,EAAE,gBAAgB,EACnB,CAAC,EAAE,gBAAgB,GACjB,OAAO,CAST;AAED;;;;;;GAMG;AACH,wBAAgB,4BAA4B,CAC3C,OAAO,EAAE,YAAY,GACnB,gBAAgB,CAMlB"}
@@ -3,5 +3,5 @@ export type { MediaEditorSession } from './use-media-editor-state';
3
3
  export { MediaEditorStateProvider, useMediaEditor, } from './media-editor-state-provider';
4
4
  export { mediaEditorReducer, areMediaEditorStatesEqual, buildInitialMediaEditorState, } from './composite-reducer';
5
5
  export { DEFAULT_CROP_OPTIONS } from './types';
6
- export type { CropOptionsSlice, MediaEditorState, MediaEditorAction, } from './types';
6
+ export type { CropOptionsSlice, EditsSlice, EditValue, MediaEditorState, MediaEditorAction, } from './types';
7
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,kBAAkB,GAClB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EACN,wBAAwB,EACxB,cAAc,GACd,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,kBAAkB,EAClB,yBAAyB,EACzB,4BAA4B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,YAAY,EACX,gBAAgB,EAChB,gBAAgB,EAChB,iBAAiB,GACjB,MAAM,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/state/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACN,mBAAmB,EACnB,kBAAkB,GAClB,MAAM,0BAA0B,CAAC;AAClC,YAAY,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACnE,OAAO,EACN,wBAAwB,EACxB,cAAc,GACd,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACN,kBAAkB,EAClB,yBAAyB,EACzB,4BAA4B,GAC5B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAC/C,YAAY,EACX,gBAAgB,EAChB,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,iBAAiB,GACjB,MAAM,SAAS,CAAC"}
@@ -17,9 +17,25 @@ export interface CropOptionsSlice {
17
17
  */
18
18
  export declare const DEFAULT_CROP_OPTIONS: CropOptionsSlice;
19
19
  /**
20
- * The full composite state for the media editor — cropper geometry
21
- * plus the sidebar control slice. Future feature slices (text
22
- * overlays, filters, …) extend this object.
20
+ * A value an edit can hold: plain data only, because the session
21
+ * compares values by content to tell a real change from a no-op.
22
+ * Anything else, such as a `Blob`, would compare equal to any other
23
+ * and the change would be dropped — keep bytes behind a URL instead.
24
+ *
25
+ * Objects must satisfy the index signature, so type a value with a
26
+ * `type` alias rather than an `interface`.
27
+ */
28
+ export type EditValue = string | number | boolean | null | EditValue[] | {
29
+ [key: string]: EditValue;
30
+ };
31
+ /**
32
+ * Named edits other than crop, keyed by edit name (for example
33
+ * `my-plugin/vignette`). An edit that is not present means "no edit".
34
+ */
35
+ export type EditsSlice = Record<string, EditValue>;
36
+ /**
37
+ * The full composite state for the media editor — cropper geometry,
38
+ * the sidebar control slice, and named edits.
23
39
  *
24
40
  * Every undo/redo snapshot is a full `MediaEditorState`. Slices stay
25
41
  * referentially equal across actions that don't touch them.
@@ -27,6 +43,7 @@ export declare const DEFAULT_CROP_OPTIONS: CropOptionsSlice;
27
43
  export interface MediaEditorState {
28
44
  cropper: CropperState;
29
45
  cropOptions: CropOptionsSlice;
46
+ edits: EditsSlice;
30
47
  }
31
48
  /**
32
49
  * Composite reducer action union.
@@ -68,9 +85,21 @@ export type MediaEditorAction =
68
85
  visualSize: Size;
69
86
  };
70
87
  }
71
- /** Reset cropOptions to defaults. */
88
+ /**
89
+ * Put every slice back to its starting state, keeping the image:
90
+ * default geometry, default crop options, no edits. One action,
91
+ * so one undo entry.
92
+ */
93
+ | {
94
+ type: 'RESET';
95
+ }
96
+ /** Set a named edit, or remove it when `value` is `undefined`. */
72
97
  | {
73
- type: 'RESET_CROP_OPTIONS';
98
+ type: 'SET_EDIT';
99
+ payload: {
100
+ name: string;
101
+ value: EditValue | undefined;
102
+ };
74
103
  }
75
104
  /**
76
105
  * Replace the entire composite state with `payload`. Used by
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/state/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,aAAa,EACb,YAAY,EACZ,cAAc,EACd,IAAI,EACJ,MAAM,iBAAiB,CAAC;AAEzB;;;GAGG;AACH,MAAM,WAAW,gBAAgB;IAChC;;;;OAIG;IACH,gBAAgB,EAAE,MAAM,CAAC;CACzB;AAED;;;GAGG;AACH,eAAO,MAAM,oBAAoB,EAAE,gBAElC,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAChC,OAAO,EAAE,YAAY,CAAC;IACtB,WAAW,EAAE,gBAAgB,CAAC;CAC9B;AAED;;;;;;GAMG;AACH,MAAM,MAAM,iBAAiB;AAC5B;;;;GAIG;AACD;IACA,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,aAAa,CAAC;CACrB;AACH;;;;GAIG;GACD;IACA,IAAI,EAAE,wBAAwB,CAAC;IAC/B,OAAO,EAAE;QACR,gDAAgD;QAChD,SAAS,EAAE,MAAM,CAAC;QAClB;;;WAGG;QACH,QAAQ,EAAE,MAAM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E;QACR,gDAAgD;QAChD,SAAS,EAAE,MAAM,CAAC;QAClB;;;WAGG;QACH,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;QAC7B;;;;WAIG;QACH,UAAU,EAAE,IAAI,CAAC;KACjB,CAAC;CACD;AACH;;;;GAIG;GACD;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE;AACnB,kEAAkE;GAChE;IACA,IAAI,EAAE,UAAU,CAAC;IACjB,OAAO,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAA;KAAE,CAAC;CACvD;AACH;;;GAGG;GACD;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE;AACzD;;;;;GAKG;GACD;IACA,IAAI,EAAE,2BAA2B,CAAC;IAClC,OAAO,EAAE,cAAc,CAAC;CACvB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  import { type CropperController, type CropperState } from '../image-editor';
2
- import type { CropOptionsSlice } from './types';
2
+ import type { CropOptionsSlice, EditsSlice, EditValue } from './types';
3
3
  /**
4
4
  * Resolve an aspect-ratio preset value (the string the dropdown
5
5
  * round-trips) into a numeric width/height ratio for the cropper.
@@ -39,8 +39,19 @@ export interface MediaEditorSession {
39
39
  cropOptions: CropOptionsSlice;
40
40
  /** Set the aspect-ratio preset. Atomic with the cropRect reshape. */
41
41
  setAspectRatioValue: (presetKey: string) => void;
42
- /** Reset cropOptions to defaults. */
43
- resetCropOptions: () => void;
42
+ /**
43
+ * Put every slice back to its starting state in one undo entry:
44
+ * default geometry and crop options, no edits. Keeps the image.
45
+ */
46
+ reset: () => void;
47
+ /** The named edits other than crop, keyed by edit name. */
48
+ edits: EditsSlice;
49
+ /**
50
+ * Set a named edit, or remove it by passing `undefined`. Recorded
51
+ * in the session history like any crop change. Setting a value
52
+ * equal in content to the current one is a no-op.
53
+ */
54
+ setEdit: (name: string, value: EditValue | undefined) => void;
44
55
  /**
45
56
  * Replace the image being edited. A different image starts a
46
57
  * fresh session: default geometry and crop options, a clean
@@ -79,8 +90,8 @@ export interface MediaEditorSession {
79
90
  * The media editor session.
80
91
  *
81
92
  * Owns the only undo/redo history for the editor. Cropper geometry
82
- * actions and sidebar cropOptions actions flow through the same
83
- * reducer and the same history stack.
93
+ * actions, sidebar cropOptions actions and named edits flow through
94
+ * the same reducer and the same history stack.
84
95
  *
85
96
  * History semantics:
86
97
  * - Each action's pre-state is pushed to the undo stack before the
@@ -1 +1 @@
1
- {"version":3,"file":"use-media-editor-state.d.ts","sourceRoot":"","sources":["../../src/state/use-media-editor-state.ts"],"names":[],"mappings":"AAOA,OAAO,EAQN,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAGjB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,KAAK,EACX,gBAAgB,EAGhB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,CAAE,OAAO,CAAE,GAAG,IAAI,GAC1C,MAAM,GAAG,SAAS,CAmBpB;AAaD;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,OAAO,EAAE,iBAAiB,CAAC;IAC3B,6BAA6B;IAC7B,WAAW,EAAE,gBAAgB,CAAC;IAC9B,qEAAqE;IACrE,mBAAmB,EAAE,CAAE,SAAS,EAAE,MAAM,KAAM,IAAI,CAAC;IACnD,qCAAqC;IACrC,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B;;;;;OAKG;IACH,cAAc,EAAE,CAAE,KAAK,EAAE,YAAY,CAAE,OAAO,CAAE,KAAM,IAAI,CAAC;IAC3D;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;IACxB,qDAAqD;IACrD,OAAO,EAAE,OAAO,CAAC;IACjB,oDAAoD;IACpD,OAAO,EAAE,OAAO,CAAC;IACjB,wDAAwD;IACxD,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,qDAAqD;IACrD,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB;;;;OAIG;IACH,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,oEAAoE;IACpE,UAAU,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB,IAAI,kBAAkB,CAoTxD"}
1
+ {"version":3,"file":"use-media-editor-state.d.ts","sourceRoot":"","sources":["../../src/state/use-media-editor-state.ts"],"names":[],"mappings":"AAOA,OAAO,EAQN,KAAK,iBAAiB,EACtB,KAAK,YAAY,EAGjB,MAAM,iBAAiB,CAAC;AAMzB,OAAO,KAAK,EACX,gBAAgB,EAChB,UAAU,EACV,SAAS,EAGT,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CACjC,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,YAAY,CAAE,OAAO,CAAE,GAAG,IAAI,GAC1C,MAAM,GAAG,SAAS,CAmBpB;AAaD;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,OAAO,EAAE,iBAAiB,CAAC;IAC3B,6BAA6B;IAC7B,WAAW,EAAE,gBAAgB,CAAC;IAC9B,qEAAqE;IACrE,mBAAmB,EAAE,CAAE,SAAS,EAAE,MAAM,KAAM,IAAI,CAAC;IACnD;;;OAGG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,2DAA2D;IAC3D,KAAK,EAAE,UAAU,CAAC;IAClB;;;;OAIG;IACH,OAAO,EAAE,CAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,SAAS,KAAM,IAAI,CAAC;IAChE;;;;;OAKG;IACH,cAAc,EAAE,CAAE,KAAK,EAAE,YAAY,CAAE,OAAO,CAAE,KAAM,IAAI,CAAC;IAC3D;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;OAGG;IACH,cAAc,EAAE,OAAO,CAAC;IACxB,qDAAqD;IACrD,OAAO,EAAE,OAAO,CAAC;IACjB,oDAAoD;IACpD,OAAO,EAAE,OAAO,CAAC;IACjB,wDAAwD;IACxD,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB,qDAAqD;IACrD,IAAI,EAAE,MAAM,IAAI,CAAC;IACjB;;;;OAIG;IACH,YAAY,EAAE,MAAM,IAAI,CAAC;IACzB,oEAAoE;IACpE,UAAU,EAAE,MAAM,IAAI,CAAC;CACvB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,mBAAmB,IAAI,kBAAkB,CA0UxD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/media-editor",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "description": "Media editor components for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -21,8 +21,18 @@
21
21
  "url": "https://github.com/WordPress/gutenberg/issues"
22
22
  },
23
23
  "engines": {
24
- "node": ">=18.12.0"
24
+ "node": ">=22.13.0"
25
25
  },
26
+ "files": [
27
+ "build",
28
+ "build-module",
29
+ "build-style",
30
+ "build-types",
31
+ "src",
32
+ "*.md",
33
+ "!**/stories/**",
34
+ "!**/test/**"
35
+ ],
26
36
  "main": "build/index.cjs",
27
37
  "module": "build-module/index.mjs",
28
38
  "exports": {
@@ -33,7 +43,7 @@
33
43
  },
34
44
  "./package.json": "./package.json"
35
45
  },
36
- "types": "build-types",
46
+ "types": "build-types/index.d.ts",
37
47
  "sideEffects": [
38
48
  "build-style/**",
39
49
  "src/**/*.scss",
@@ -42,24 +52,25 @@
42
52
  "build-module/store/index.mjs"
43
53
  ],
44
54
  "dependencies": {
45
- "@wordpress/a11y": "^4.57.0",
46
- "@wordpress/admin-ui": "^2.12.0",
47
- "@wordpress/api-fetch": "^7.57.0",
48
- "@wordpress/base-styles": "^13.3.0",
49
- "@wordpress/components": "^42.0.0",
50
- "@wordpress/compose": "^8.10.0",
51
- "@wordpress/core-data": "^8.2.0",
52
- "@wordpress/data": "^10.57.0",
53
- "@wordpress/dataviews": "^20.0.0",
54
- "@wordpress/element": "^9.0.0",
55
- "@wordpress/i18n": "^6.30.0",
56
- "@wordpress/icons": "^18.0.0",
57
- "@wordpress/keyboard-shortcuts": "^5.57.0",
58
- "@wordpress/keycodes": "^4.57.0",
59
- "@wordpress/notices": "^5.57.0",
60
- "@wordpress/private-apis": "^2.0.0",
61
- "@wordpress/ui": "^0.24.0",
55
+ "@wordpress/a11y": "^5.0.0",
56
+ "@wordpress/admin-ui": "^3.0.0",
57
+ "@wordpress/api-fetch": "^8.0.0",
58
+ "@wordpress/base-styles": "^14.0.0",
59
+ "@wordpress/components": "^43.0.0",
60
+ "@wordpress/compose": "^9.0.0",
61
+ "@wordpress/core-data": "^9.0.0",
62
+ "@wordpress/data": "^11.0.0",
63
+ "@wordpress/dataviews": "^21.0.0",
64
+ "@wordpress/element": "^10.0.0",
65
+ "@wordpress/i18n": "^7.0.0",
66
+ "@wordpress/icons": "^19.0.0",
67
+ "@wordpress/keyboard-shortcuts": "^6.0.0",
68
+ "@wordpress/keycodes": "^5.0.0",
69
+ "@wordpress/notices": "^6.0.0",
70
+ "@wordpress/private-apis": "^3.0.0",
71
+ "@wordpress/ui": "^0.25.0",
62
72
  "clsx": "^2.1.1",
73
+ "fast-deep-equal": "^3.1.3",
63
74
  "gl-matrix": "^3.4.3"
64
75
  },
65
76
  "devDependencies": {
@@ -67,7 +78,7 @@
67
78
  "@testing-library/dom": "^10.4.2",
68
79
  "@testing-library/jest-dom": "^7.0.1",
69
80
  "@testing-library/react": "^16.3.3",
70
- "@testing-library/user-event": "^14.6.1",
81
+ "@testing-library/user-event": "^14.6.8",
71
82
  "vitest": "^5.0.3",
72
83
  "vitest-browser-react": "^2.3.0"
73
84
  },
@@ -88,5 +99,5 @@
88
99
  "publishConfig": {
89
100
  "access": "public"
90
101
  },
91
- "gitHead": "12441e2520c78b2254a792a8cba40c34110be060"
102
+ "gitHead": "8d30f92cbbde3ddf781c8799443c649befbbcb88"
92
103
  }
@@ -4,7 +4,7 @@ import {
4
4
  DropdownMenu,
5
5
  MenuGroup,
6
6
  MenuItem,
7
- Spinner,
7
+ Spinner as WCSpinner,
8
8
  __experimentalConfirmDialog as ConfirmDialog,
9
9
  } from '@wordpress/components';
10
10
  import { Stack, Tabs, VisuallyHidden } from '@wordpress/ui';
@@ -37,7 +37,7 @@ import {
37
37
  isKeyboardEvent,
38
38
  } from '@wordpress/keycodes';
39
39
  import { SnackbarNotices, store as noticesStore } from '@wordpress/notices';
40
- import type { Field } from '@wordpress/dataviews';
40
+ import type { Field, Form } from '@wordpress/dataviews';
41
41
  import type {
42
42
  KeyboardEvent as ReactKeyboardEvent,
43
43
  ReactElement,
@@ -116,6 +116,7 @@ export interface MediaEditorFrameProps {
116
116
 
117
117
  export interface MediaEditorProps {
118
118
  fields?: Field< Media >[];
119
+ form?: Form;
119
120
  id: number;
120
121
  aspectRatioPresets?: AspectRatioPreset[];
121
122
  onClose?: () => void;
@@ -218,7 +219,6 @@ interface MediaEditorFrameContextValue {
218
219
  onTogglePanel: () => void;
219
220
  onCancel: () => void;
220
221
  onSave: () => void;
221
- onReset: () => void;
222
222
  /**
223
223
  * When `true`, the media has a lineage root to restore to, so the
224
224
  * "Restore original image" menu item is shown.
@@ -364,20 +364,18 @@ function HeaderActions( { showCloseButton = false }: HeaderActionsProps ) {
364
364
  }
365
365
 
366
366
  function HistoryActions() {
367
- const { isImage, isUndoRedoDisabled, onReset, isWide, activePanel } =
367
+ const { isImage, isUndoRedoDisabled, isWide, activePanel } =
368
368
  useMediaEditorFrameContext();
369
369
  const {
370
- cropper: { reset },
370
+ reset,
371
371
  isDirty,
372
372
  hasUndo,
373
373
  hasRedo,
374
374
  undo: undoCrop,
375
375
  redo: redoCrop,
376
- beginGesture,
377
- endGesture,
378
376
  } = useMediaEditor();
379
- // Reset, undo and redo act on the cropper, so they only appear where the
380
- // canvas does. Non-image media has no edit history at all; below the dock
377
+ // Reset, undo and redo act on the image edits, so they only appear where
378
+ // the canvas does. Non-image media has no edit history at all; below the dock
381
379
  // breakpoint an open panel replaces the canvas, and leaving these behind
382
380
  // would put an enabled, destructive Reset next to metadata fields it does
383
381
  // not touch — clicking it would discard a crop the user cannot see.
@@ -403,10 +401,7 @@ function HistoryActions() {
403
401
  if ( isUndoRedoDisabled ) {
404
402
  return;
405
403
  }
406
- beginGesture();
407
404
  reset();
408
- onReset();
409
- endGesture();
410
405
  };
411
406
  return (
412
407
  <Stack
@@ -499,6 +494,7 @@ function SaveActions( { size = 'default' }: SaveActionsProps ) {
499
494
 
500
495
  function MediaEditorContent( {
501
496
  fields = [],
497
+ form,
502
498
  id,
503
499
  aspectRatioPresets,
504
500
  onClose,
@@ -732,14 +728,8 @@ function MediaEditorContent( {
732
728
  setActivePanel( isWide ? lastPanelRef.current : null );
733
729
  }
734
730
  }, [ isWide, isImage ] );
735
- // Only `resetCropOptions` is needed here, for the Reset button; the
736
- // aspect-ratio members are read by `MediaEditorImageControls` itself.
737
- const {
738
- aspectRatioValue,
739
- setAspectRatioValue,
740
- aspectRatioOptions,
741
- resetCropOptions,
742
- } = useCropOptions( { aspectRatioPresets } );
731
+ const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } =
732
+ useCropOptions( { aspectRatioPresets } );
743
733
  const { isSaving, save: saveMediaEditor } = useSaveMediaEditor( {
744
734
  session,
745
735
  id,
@@ -889,12 +879,13 @@ function MediaEditorContent( {
889
879
  isDisabled: true,
890
880
  } ) )
891
881
  : fields,
882
+ form,
892
883
  } }
893
884
  >
894
885
  <div className="media-editor">
895
886
  { ! media ? (
896
887
  <div className="media-editor__loading">
897
- <Spinner />
888
+ <WCSpinner />
898
889
  </div>
899
890
  ) : (
900
891
  <div
@@ -990,7 +981,6 @@ function MediaEditorContent( {
990
981
  onTogglePanel: togglePanel,
991
982
  onCancel: handleRequestClose,
992
983
  onSave: saveMediaEditor,
993
- onReset: resetCropOptions,
994
984
  canRestoreOriginal,
995
985
  isSourceReplaced,
996
986
  onRestoreOriginal: handleRestoreOriginal,
@@ -12,7 +12,6 @@ interface UseCropOptionsReturn {
12
12
  setAspectRatioValue: ( value: string ) => void;
13
13
  aspectRatioOptions: AspectRatioPreset[];
14
14
  resolvedAspectRatio: number | undefined;
15
- resetCropOptions: () => void;
16
15
  }
17
16
 
18
17
  /**
@@ -67,6 +66,5 @@ export function useCropOptions( {
67
66
  setAspectRatioValue: controller.setAspectRatioValue,
68
67
  aspectRatioOptions,
69
68
  resolvedAspectRatio,
70
- resetCropOptions: controller.resetCropOptions,
71
69
  };
72
70
  }
@@ -1,6 +1,6 @@
1
1
  import clsx from 'clsx';
2
2
  import { useCallback, useEffect, useMemo, useState } from '@wordpress/element';
3
- import { Spinner } from '@wordpress/components';
3
+ import { Spinner as WCSpinner } from '@wordpress/components';
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { useMediaEditorContext } from '../media-editor-provider';
6
6
  import { getMediaTypeFromMimeType } from '../../utils';
@@ -138,7 +138,7 @@ export default function MediaEditorCanvas( {
138
138
  <div className="media-editor-canvas">
139
139
  { status === 'loading' && (
140
140
  <div className="media-editor-canvas__spinner">
141
- <Spinner />
141
+ <WCSpinner />
142
142
  </div>
143
143
  ) }
144
144
  { /*
@@ -1,5 +1,4 @@
1
- import { SelectControl as WCSelectControl } from '@wordpress/components';
2
- import { Stack, VisuallyHidden } from '@wordpress/ui';
1
+ import { SelectControl, Stack, VisuallyHidden } from '@wordpress/ui';
3
2
  import { __ } from '@wordpress/i18n';
4
3
  import { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';
5
4
  import MediaEditorImageControls from '../media-editor-image-controls';
@@ -36,6 +35,11 @@ export default function MediaEditorCropPanel( {
36
35
  aspectRatioOptions,
37
36
  disabled = false,
38
37
  }: MediaEditorCropPanelProps ) {
38
+ const items = aspectRatioOptions.map( ( preset ) => ( {
39
+ label: preset.label,
40
+ value: preset.value.toString(),
41
+ } ) );
42
+
39
43
  return (
40
44
  // Tag the whole panel as a crop-control region so the modal's
41
45
  // Cmd+Z handler doesn't mistake the SelectControl input for a
@@ -49,15 +53,19 @@ export default function MediaEditorCropPanel( {
49
53
  { __( 'Crop options' ) }
50
54
  </VisuallyHidden>
51
55
  <MediaEditorImageControls withLabels disabled={ disabled } />
52
- <WCSelectControl
56
+ <SelectControl
53
57
  label={ __( 'Aspect ratio' ) }
54
- value={ aspectRatioValue }
55
- onChange={ onAspectRatioChange }
58
+ value={
59
+ items.find( ( item ) => item.value === aspectRatioValue ) ??
60
+ null
61
+ }
62
+ onValueChange={ ( item ) => {
63
+ if ( item && item.value !== null ) {
64
+ onAspectRatioChange( item.value );
65
+ }
66
+ } }
56
67
  disabled={ disabled }
57
- options={ aspectRatioOptions.map( ( preset ) => ( {
58
- label: preset.label,
59
- value: preset.value.toString(),
60
- } ) ) }
68
+ items={ items }
61
69
  />
62
70
  </Stack>
63
71
  );
@@ -30,7 +30,7 @@
30
30
 
31
31
  // Match the uppercase 11px heading the panel's other controls use for
32
32
  // their labels (Zoom, Aspect ratio) so the groups read as section
33
- // headings. Mirrors `baseLabelTypography` from `@wordpress/components`.
33
+ // headings. Matches InputControl's label typography in `@wordpress/components`.
34
34
  &__label {
35
35
  font-size: 11px;
36
36
  font-weight: var(--wpds-typography-font-weight-emphasis);
@@ -3,7 +3,7 @@ import { useDispatch, useSelect } from '@wordpress/data';
3
3
  import { __ } from '@wordpress/i18n';
4
4
  import { ShortcutProvider } from '@wordpress/keyboard-shortcuts';
5
5
  import { store as noticesStore } from '@wordpress/notices';
6
- import type { Field } from '@wordpress/dataviews';
6
+ import type { Field, Form } from '@wordpress/dataviews';
7
7
  import type { KeyboardEvent as ReactKeyboardEvent } from 'react';
8
8
  import MediaEditor from '../media-editor';
9
9
  import type { Media } from '../media-editor-provider';
@@ -19,6 +19,11 @@ interface MediaEditorModalProps {
19
19
  * since `@wordpress/media-editor` cannot depend on `@wordpress/editor`.
20
20
  */
21
21
  fields?: Field< Media >[];
22
+ /**
23
+ * Form the fields are laid out with in the Details tab. When omitted,
24
+ * a default layout of the core attachment fields is used.
25
+ */
26
+ form?: Form;
22
27
  /**
23
28
  * Fixed aspect-ratio presets for image cropping. Free and Original are
24
29
  * always provided by the media editor.
@@ -47,6 +52,7 @@ function ModalFooter() {
47
52
 
48
53
  export function MediaEditorModal( {
49
54
  fields = [],
55
+ form,
50
56
  aspectRatioPresets,
51
57
  }: MediaEditorModalProps ) {
52
58
  const { isModalOpen, id, onUpdate, onUndo, onClose } = useSelect(
@@ -93,6 +99,7 @@ export function MediaEditorModal( {
93
99
  <MediaEditor
94
100
  id={ id }
95
101
  fields={ fields }
102
+ form={ form }
96
103
  aspectRatioPresets={ aspectRatioPresets }
97
104
  shouldCloseOnEsc
98
105
  noticesClassName="media-editor-modal__snackbar"