@wordpress/media-editor 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (87) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/build/components/media-editor/index.cjs +157 -107
  3. package/build/components/media-editor/index.cjs.map +1 -1
  4. package/build/components/media-editor/use-save-media-editor.cjs +18 -8
  5. package/build/components/media-editor/use-save-media-editor.cjs.map +1 -1
  6. package/build/components/media-editor-canvas/index.cjs +9 -7
  7. package/build/components/media-editor-canvas/index.cjs.map +1 -1
  8. package/build/components/media-editor-crop-panel/index.cjs +9 -7
  9. package/build/components/media-editor-crop-panel/index.cjs.map +1 -1
  10. package/build/components/media-editor-fine-rotation/index.cjs +9 -7
  11. package/build/components/media-editor-fine-rotation/index.cjs.map +1 -1
  12. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +32 -33
  13. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +1 -1
  14. package/build/components/media-editor-modal/index.cjs +10 -7
  15. package/build/components/media-editor-modal/index.cjs.map +1 -1
  16. package/build/components/media-editor-panel/error-boundary.cjs +68 -0
  17. package/build/components/media-editor-panel/error-boundary.cjs.map +1 -0
  18. package/build/components/media-editor-panel/index.cjs +158 -0
  19. package/build/components/media-editor-panel/index.cjs.map +1 -0
  20. package/build/components/media-preview/index.cjs +143 -36
  21. package/build/components/media-preview/index.cjs.map +1 -1
  22. package/build/components/rotation-ruler/index.cjs +9 -7
  23. package/build/components/rotation-ruler/index.cjs.map +1 -1
  24. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +1 -1
  25. package/build/hooks/use-crop-gesture-handlers.cjs.map +1 -1
  26. package/build/index.cjs +10 -8
  27. package/build/private-apis.cjs.map +1 -1
  28. package/build/state/aspect-ratio-presets.cjs +2 -2
  29. package/build/state/aspect-ratio-presets.cjs.map +1 -1
  30. package/build/state/composite-reducer.cjs +9 -7
  31. package/build/state/composite-reducer.cjs.map +1 -1
  32. package/build/state/use-media-editor-state.cjs.map +1 -1
  33. package/build/store/index.cjs +11 -9
  34. package/build/store/index.cjs.map +1 -1
  35. package/build/utils/get-media-type.cjs +8 -0
  36. package/build/utils/get-media-type.cjs.map +1 -1
  37. package/build/utils/index.cjs +6 -0
  38. package/build-module/components/media-editor/index.mjs +142 -95
  39. package/build-module/components/media-editor/index.mjs.map +1 -1
  40. package/build-module/components/media-editor/use-save-media-editor.mjs +9 -1
  41. package/build-module/components/media-editor/use-save-media-editor.mjs.map +1 -1
  42. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +32 -33
  43. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +1 -1
  44. package/build-module/components/media-editor-modal/index.mjs +1 -0
  45. package/build-module/components/media-editor-modal/index.mjs.map +1 -1
  46. package/build-module/components/media-editor-panel/error-boundary.mjs +63 -0
  47. package/build-module/components/media-editor-panel/error-boundary.mjs.map +1 -0
  48. package/build-module/components/media-editor-panel/index.mjs +123 -0
  49. package/build-module/components/media-editor-panel/index.mjs.map +1 -0
  50. package/build-module/components/media-preview/index.mjs +123 -40
  51. package/build-module/components/media-preview/index.mjs.map +1 -1
  52. package/build-module/state/aspect-ratio-presets.mjs +2 -2
  53. package/build-module/state/aspect-ratio-presets.mjs.map +1 -1
  54. package/build-module/state/use-media-editor-state.mjs.map +1 -1
  55. package/build-module/utils/get-media-type.mjs +8 -1
  56. package/build-module/utils/get-media-type.mjs.map +1 -1
  57. package/build-module/utils/index.mjs +1 -1
  58. package/build-style/style-rtl.css +18 -30
  59. package/build-style/style.css +18 -30
  60. package/build-types/components/media-editor/index.d.ts +8 -0
  61. package/build-types/components/media-editor/index.d.ts.map +1 -1
  62. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -1
  63. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  64. package/build-types/components/media-editor-panel/error-boundary.d.ts +23 -0
  65. package/build-types/components/media-editor-panel/error-boundary.d.ts.map +1 -0
  66. package/build-types/components/media-editor-panel/index.d.ts +46 -0
  67. package/build-types/components/media-editor-panel/index.d.ts.map +1 -0
  68. package/build-types/components/media-preview/index.d.ts.map +1 -1
  69. package/build-types/state/use-media-editor-state.d.ts +7 -2
  70. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  71. package/build-types/utils/get-media-type.d.ts +3 -1
  72. package/build-types/utils/get-media-type.d.ts.map +1 -1
  73. package/build-types/utils/index.d.ts +1 -1
  74. package/build-types/utils/index.d.ts.map +1 -1
  75. package/package.json +26 -22
  76. package/src/components/media-editor/index.tsx +209 -114
  77. package/src/components/media-editor/style.scss +21 -1
  78. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +55 -63
  79. package/src/components/media-editor-modal/index.tsx +3 -0
  80. package/src/components/media-editor-panel/error-boundary.tsx +88 -0
  81. package/src/components/media-editor-panel/index.tsx +211 -0
  82. package/src/components/media-preview/index.tsx +195 -36
  83. package/src/components/media-preview/style.scss +11 -32
  84. package/src/state/README.md +3 -1
  85. package/src/state/use-media-editor-state.ts +7 -2
  86. package/src/utils/get-media-type.ts +9 -1
  87. package/src/utils/index.ts +1 -1
@@ -1,6 +1,3 @@
1
- /**
2
- * Colors
3
- */
4
1
  /**
5
2
  * SCSS Variables.
6
3
  *
@@ -8,6 +5,9 @@
8
5
  * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
9
6
  * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
10
7
  */
8
+ /**
9
+ * Colors
10
+ */
11
11
  /**
12
12
  * Fonts & basic variables.
13
13
  */
@@ -109,34 +109,14 @@
109
109
  border: 0;
110
110
  border-radius: 2px;
111
111
  }
112
- .media-editor-preview__file-info {
113
- text-align: center;
114
- background: #f0f0f0;
115
- padding: 24px;
116
- border-radius: 2px;
117
- }
118
112
  .media-editor-preview__file-name {
119
- font-weight: var(--wpds-typography-font-weight-emphasis, 600);
120
- margin-bottom: 8px;
121
- }
122
- .media-editor-preview__mime-type {
123
- color: #757575;
124
- font-size: 0.9em;
125
- margin-bottom: 16px;
113
+ overflow-wrap: anywhere;
126
114
  }
127
- .media-editor-preview__download-link {
128
- display: inline-block;
129
- margin-top: 8px;
130
- }
131
- .media-editor-preview--error, .media-editor-preview--empty {
132
- color: #757575;
133
- text-align: center;
134
- }
135
- .media-editor-preview__url {
136
- font-size: 0.9em;
137
- color: #949494;
138
- word-break: break-all;
139
- margin-top: 8px;
115
+ .media-editor-preview__actions {
116
+ flex-direction: row;
117
+ flex-wrap: wrap;
118
+ justify-content: center;
119
+ gap: var(--wpds-dimension-gap-sm, 8px);
140
120
  }
141
121
 
142
122
  /* stylelint-disable plugin-wpds/no-token-fallback-values -- This SCSS also works when the design tokens are not loaded. */
@@ -483,6 +463,9 @@
483
463
  .media-editor .media-editor__canvas-area .media-editor-preview {
484
464
  height: 100%;
485
465
  }
466
+ .media-editor .media-editor__canvas-area:has(.media-editor-preview.is-placeholder) {
467
+ background: none;
468
+ }
486
469
  .media-editor .media-editor__canvas-area img,
487
470
  .media-editor .media-editor__canvas-area video {
488
471
  max-width: 100%;
@@ -515,6 +498,11 @@
515
498
  width: var(--wpds-dimension-surface-width-sm, 320px);
516
499
  }
517
500
  }
501
+ @media (min-width: 600px) {
502
+ .media-editor .media-editor__body:has(.media-editor-preview.is-placeholder) .media-editor__sidebar {
503
+ border-inline-start: var(--wpds-border-width-xs, 1px) solid var(--wpds-color-stroke-surface-neutral-weak, #f0f0f0);
504
+ }
505
+ }
518
506
  .media-editor .media-editor__tabs {
519
507
  display: flex;
520
508
  flex: 1;
@@ -544,7 +532,7 @@
544
532
  @media (min-width: 600px) {
545
533
  .media-editor .media-editor__body.has-panel-open .media-editor__content {
546
534
  display: flex;
547
- margin: 0 24px 0 0;
535
+ margin-left: 0;
548
536
  }
549
537
  }
550
538
 
@@ -1,6 +1,3 @@
1
- /**
2
- * Colors
3
- */
4
1
  /**
5
2
  * SCSS Variables.
6
3
  *
@@ -8,6 +5,9 @@
8
5
  * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
9
6
  * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
10
7
  */
8
+ /**
9
+ * Colors
10
+ */
11
11
  /**
12
12
  * Fonts & basic variables.
13
13
  */
@@ -109,34 +109,14 @@
109
109
  border: 0;
110
110
  border-radius: 2px;
111
111
  }
112
- .media-editor-preview__file-info {
113
- text-align: center;
114
- background: #f0f0f0;
115
- padding: 24px;
116
- border-radius: 2px;
117
- }
118
112
  .media-editor-preview__file-name {
119
- font-weight: var(--wpds-typography-font-weight-emphasis, 600);
120
- margin-bottom: 8px;
121
- }
122
- .media-editor-preview__mime-type {
123
- color: #757575;
124
- font-size: 0.9em;
125
- margin-bottom: 16px;
113
+ overflow-wrap: anywhere;
126
114
  }
127
- .media-editor-preview__download-link {
128
- display: inline-block;
129
- margin-top: 8px;
130
- }
131
- .media-editor-preview--error, .media-editor-preview--empty {
132
- color: #757575;
133
- text-align: center;
134
- }
135
- .media-editor-preview__url {
136
- font-size: 0.9em;
137
- color: #949494;
138
- word-break: break-all;
139
- margin-top: 8px;
115
+ .media-editor-preview__actions {
116
+ flex-direction: row;
117
+ flex-wrap: wrap;
118
+ justify-content: center;
119
+ gap: var(--wpds-dimension-gap-sm, 8px);
140
120
  }
141
121
 
142
122
  /* stylelint-disable plugin-wpds/no-token-fallback-values -- This SCSS also works when the design tokens are not loaded. */
@@ -486,6 +466,9 @@
486
466
  .media-editor .media-editor__canvas-area .media-editor-preview {
487
467
  height: 100%;
488
468
  }
469
+ .media-editor .media-editor__canvas-area:has(.media-editor-preview.is-placeholder) {
470
+ background: none;
471
+ }
489
472
  .media-editor .media-editor__canvas-area img,
490
473
  .media-editor .media-editor__canvas-area video {
491
474
  max-width: 100%;
@@ -518,6 +501,11 @@
518
501
  width: var(--wpds-dimension-surface-width-sm, 320px);
519
502
  }
520
503
  }
504
+ @media (min-width: 600px) {
505
+ .media-editor .media-editor__body:has(.media-editor-preview.is-placeholder) .media-editor__sidebar {
506
+ border-inline-start: var(--wpds-border-width-xs, 1px) solid var(--wpds-color-stroke-surface-neutral-weak, #f0f0f0);
507
+ }
508
+ }
521
509
  .media-editor .media-editor__tabs {
522
510
  display: flex;
523
511
  flex: 1;
@@ -547,7 +535,7 @@
547
535
  @media (min-width: 600px) {
548
536
  .media-editor .media-editor__body.has-panel-open .media-editor__content {
549
537
  display: flex;
550
- margin: 0 0 0 24px;
538
+ margin-right: 0;
551
539
  }
552
540
  }
553
541
 
@@ -41,6 +41,14 @@ export interface MediaEditorProps {
41
41
  noticesClassName?: string;
42
42
  noticesPortalElement?: Element | null;
43
43
  shouldCloseOnEsc?: boolean;
44
+ /**
45
+ * The id of the panel to open on, which is also shown as the first tab.
46
+ * Below `small`, or when no tab has this id, the sidebar opens on
47
+ * Details.
48
+ *
49
+ * @default 'core/details'
50
+ */
51
+ defaultPanel?: string;
44
52
  }
45
53
  export interface HeaderActionsProps {
46
54
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor/index.tsx"],"names":[],"mappings":"AA2CA,OAAO,KAAK,EAAE,MAAM,EAAe,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EACX,aAAa,IAAI,kBAAkB,EACnC,YAAY,EACZ,SAAS,EACT,MAAM,OAAO,CAAC;AACf,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAWtD,OAAO,EAGN,KAAK,qBAAqB,EAC1B,MAAM,yBAAyB,CAAC;AAGjC,YAAY,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AA8CrE,MAAM,WAAW,qBAAqB;IACrC,QAAQ,EAAE,SAAS,CAAC;IACpB;;;;;OAKG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;;;;OAMG;IACH,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC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BAAgB,WAAW,CAAE,KAAK,EAAE,gBAAgB,+BAMnD;yBANe,WAAW;;;;;;;eAiBZ,WAAW"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-keyboard-shortcuts-modal/index.tsx"],"names":[],"mappings":"AAkIA,UAAU,sCAAsC;IAC/C,OAAO,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,UAAU,iCAAiC,CAAE,EAC1D,OAAO,GACP,EAAE,sCAAsC,+BAsCxC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-keyboard-shortcuts-modal/index.tsx"],"names":[],"mappings":"AA4HA,UAAU,sCAAsC;IAC/C,OAAO,EAAE,MAAM,IAAI,CAAC;CACpB;AAED,MAAM,CAAC,OAAO,UAAU,iCAAiC,CAAE,EAC1D,OAAO,GACP,EAAE,sCAAsC,+BAoCxC"}
@@ -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,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAItD,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
+ {"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;AAExD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AAE1E,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAItD,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,sCAoHvB;eAEc,gBAAgB"}
@@ -0,0 +1,23 @@
1
+ import { Component } from '@wordpress/element';
2
+ import type { ReactNode } from 'react';
3
+ interface Props {
4
+ title: string;
5
+ children: ReactNode;
6
+ }
7
+ interface State {
8
+ /** Separate from `error`: a panel can throw a falsy value. */
9
+ hasError: boolean;
10
+ error: unknown;
11
+ }
12
+ /**
13
+ * Keeps a panel's failure inside its tab, so the rest of the editor stays
14
+ * usable.
15
+ */
16
+ export default class MediaEditorPanelErrorBoundary extends Component<Props, State> {
17
+ state: State;
18
+ static getDerivedStateFromError(error: unknown): State;
19
+ componentDidCatch(): void;
20
+ render(): string | number | bigint | boolean | import("react").JSX.Element | Iterable<ReactNode> | Promise<string | number | bigint | boolean | Iterable<ReactNode> | import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>> | import("react").ReactPortal | null | undefined> | null | undefined;
21
+ }
22
+ export {};
23
+ //# sourceMappingURL=error-boundary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error-boundary.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-panel/error-boundary.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAK/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAEvC,UAAU,KAAK;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,SAAS,CAAC;CACpB;AAED,UAAU,KAAK;IACd,8DAA8D;IAC9D,QAAQ,EAAE,OAAO,CAAC;IAClB,KAAK,EAAE,OAAO,CAAC;CACf;AAqCD;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,6BAA8B,SAAQ,SAAS,CACnE,KAAK,EACL,KAAK,CACL;IACA,KAAK,EAAE,KAAK,CAAoC;IAEhD,MAAM,CAAC,wBAAwB,CAAE,KAAK,EAAE,OAAO,GAAI,KAAK,CAEvD;IAED,iBAAiB,SAGhB;IAED,MAAM,gUAcL;CACD"}
@@ -0,0 +1,46 @@
1
+ import type { ReactNode } from 'react';
2
+ import { type MediaType } from '../../utils';
3
+ export interface MediaEditorPanelFillProps {
4
+ /** `true` while a save is running. */
5
+ disabled: boolean;
6
+ }
7
+ export interface MediaEditorPanelRegistration {
8
+ /** Unique, namespaced name, for example `core/crop`. */
9
+ name: string;
10
+ /** Tab label. */
11
+ title: string;
12
+ /** Omitted means every type. */
13
+ mediaTypes?: readonly MediaType['type'][];
14
+ }
15
+ export interface MediaEditorPanelProps extends MediaEditorPanelRegistration {
16
+ children: ReactNode | ((fillProps: MediaEditorPanelFillProps) => ReactNode);
17
+ }
18
+ interface MediaEditorPanelsContextValue {
19
+ register: (panel: MediaEditorPanelRegistration, instance: object) => void;
20
+ unregister: (name: string, instance: object) => void;
21
+ /** Panel name to the mounted panel that has it. */
22
+ owners: Record<string, object>;
23
+ }
24
+ export declare const MediaEditorPanelsProvider: import("react").Provider<MediaEditorPanelsContextValue | null>;
25
+ /** The `registerPlugin` scope the editor mounts. */
26
+ export declare const MEDIA_EDITOR_PLUGIN_SCOPE = "media-editor";
27
+ export declare function getPanelSlotName(name: string): string;
28
+ /**
29
+ * The mounted panels of one editor.
30
+ *
31
+ * @return The panels, in the order they mounted, and the context value to provide to them.
32
+ */
33
+ export declare function useMediaEditorPanels(): {
34
+ panels: MediaEditorPanelRegistration[];
35
+ contextValue: {
36
+ register: (panel: MediaEditorPanelRegistration, instance: object) => void;
37
+ unregister: (name: string, instance: object) => void;
38
+ owners: {
39
+ [k: string]: object;
40
+ };
41
+ };
42
+ };
43
+ /** A tab in the media editor's sidebar, filled with its children. */
44
+ export default function MediaEditorPanel({ name, title, mediaTypes, children, }: MediaEditorPanelProps): import("react").JSX.Element | null;
45
+ export {};
46
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-panel/index.tsx"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAe,KAAK,SAAS,EAAE,MAAM,aAAa,CAAC;AAG1D,MAAM,WAAW,yBAAyB;IACzC,sCAAsC;IACtC,QAAQ,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,4BAA4B;IAC5C,wDAAwD;IACxD,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,gCAAgC;IAChC,UAAU,CAAC,EAAE,SAAS,SAAS,CAAE,MAAM,CAAE,EAAE,CAAC;CAC5C;AAED,MAAM,WAAW,qBAAsB,SAAQ,4BAA4B;IAC1E,QAAQ,EACP,SAAS,GAAG,CAAE,CAAE,SAAS,EAAE,yBAAyB,KAAM,SAAS,CAAE,CAAC;CACvE;AAED,UAAU,6BAA6B;IACtC,QAAQ,EAAE,CAAE,KAAK,EAAE,4BAA4B,EAAE,QAAQ,EAAE,MAAM,KAAM,IAAI,CAAC;IAC5E,UAAU,EAAE,CAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAM,IAAI,CAAC;IACvD,mDAAmD;IACnD,MAAM,EAAE,MAAM,CAAE,MAAM,EAAE,MAAM,CAAE,CAAC;CACjC;AAKD,eAAO,MAAM,yBAAyB,gEAAoC,CAAC;AAE3E,oDAAoD;AACpD,eAAO,MAAM,yBAAyB,iBAAiB,CAAC;AAKxD,wBAAgB,gBAAgB,CAAE,IAAI,EAAE,MAAM,UAE7C;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB;;;0BAWzB,4BAA4B,YAAY,MAAM;2BA2BhB,MAAM,YAAY,MAAM;;;;;EAkChE;AAED,qEAAqE;AACrE,MAAM,CAAC,OAAO,UAAU,gBAAgB,CAAE,EACzC,IAAI,EACJ,KAAK,EACL,UAAU,EACV,QAAQ,GACR,EAAE,qBAAqB,sCAsDvB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-preview/index.tsx"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,CAAE,GAAG,EAAE,MAAM,GAAI,GAAG,CAAC;CACrB;AA2GD;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,KAAK,EAAE,iBAAiB,+BAgE7D"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-preview/index.tsx"],"names":[],"mappings":"AAkBA;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,CAAE,GAAG,EAAE,MAAM,GAAI,GAAG,CAAC;CACrB;AAsND;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,YAAY,CAAE,KAAK,EAAE,iBAAiB,+BAwG7D"}
@@ -27,7 +27,11 @@ export interface MediaEditorSession {
27
27
  * default crop and crop options, no edits. Keeps the image.
28
28
  */
29
29
  reset: () => void;
30
- /** The named edits other than crop, keyed by edit name. */
30
+ /**
31
+ * The named edits other than crop, keyed by edit name. Not an
32
+ * extension API: undoable and cleared by `reset`, but not counted by
33
+ * `hasOutputEdits` and not saved.
34
+ */
31
35
  edits: EditsSlice;
32
36
  /**
33
37
  * Set a named edit, or remove it by passing `undefined`. Recorded
@@ -48,7 +52,8 @@ export interface MediaEditorSession {
48
52
  isDirty: boolean;
49
53
  /**
50
54
  * Whether the edits change the saved image, so saving has to
51
- * produce new image output rather than only metadata.
55
+ * produce new image output rather than only metadata. Geometry
56
+ * counts; named edits do not.
52
57
  */
53
58
  hasOutputEdits: boolean;
54
59
  /** Whether there's an undoable change in history. */
@@ -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,EAGN,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,MAAM,yBAAyB,CAAC;AAOjC,OAAO,KAAK,EACX,gBAAgB,EAChB,UAAU,EACV,SAAS,EAGT,MAAM,SAAS,CAAC;AA8CjB;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,WAAW,EAAE,qBAAqB,CAAC;IACnC,6BAA6B;IAC7B,WAAW,EAAE,gBAAgB,CAAC;IAC9B,0EAA0E;IAC1E,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;;;;OAIG;IACH,cAAc,EAAE,CAAE,KAAK,EAAE,gBAAgB,CAAE,OAAO,CAAE,KAAM,IAAI,CAAC;IAC/D;;;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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,IAAI,kBAAkB,CAsQxD"}
1
+ {"version":3,"file":"use-media-editor-state.d.ts","sourceRoot":"","sources":["../../src/state/use-media-editor-state.ts"],"names":[],"mappings":"AAOA,OAAO,EAGN,KAAK,qBAAqB,EAC1B,KAAK,gBAAgB,EACrB,MAAM,yBAAyB,CAAC;AAOjC,OAAO,KAAK,EACX,gBAAgB,EAChB,UAAU,EACV,SAAS,EAGT,MAAM,SAAS,CAAC;AA8CjB;;;;;;;;;GASG;AACH,MAAM,WAAW,kBAAkB;IAClC;;;;;OAKG;IACH,WAAW,EAAE,qBAAqB,CAAC;IACnC,6BAA6B;IAC7B,WAAW,EAAE,gBAAgB,CAAC;IAC9B,0EAA0E;IAC1E,mBAAmB,EAAE,CAAE,SAAS,EAAE,MAAM,KAAM,IAAI,CAAC;IACnD;;;OAGG;IACH,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB;;;;OAIG;IACH,KAAK,EAAE,UAAU,CAAC;IAClB;;;;OAIG;IACH,OAAO,EAAE,CAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,SAAS,GAAG,SAAS,KAAM,IAAI,CAAC;IAChE;;;;OAIG;IACH,cAAc,EAAE,CAAE,KAAK,EAAE,gBAAgB,CAAE,OAAO,CAAE,KAAM,IAAI,CAAC;IAC/D;;;OAGG;IACH,OAAO,EAAE,OAAO,CAAC;IACjB;;;;OAIG;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;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,mBAAmB,IAAI,kBAAkB,CAsQxD"}
@@ -1,8 +1,10 @@
1
+ /** The media types the editor tells apart, by MIME type prefix. */
2
+ export declare const MEDIA_TYPES: readonly ['image', 'video', 'audio', 'application'];
1
3
  /**
2
4
  * Media type result.
3
5
  */
4
6
  export interface MediaType {
5
- type: 'image' | 'video' | 'audio' | 'application';
7
+ type: (typeof MEDIA_TYPES)[number];
6
8
  }
7
9
  /**
8
10
  * Determines the media type from a MIME type string.
@@ -1 +1 @@
1
- {"version":3,"file":"get-media-type.d.ts","sourceRoot":"","sources":["../../src/utils/get-media-type.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,OAAO,GAAG,OAAO,GAAG,OAAO,GAAG,aAAa,CAAC;CAClD;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAE,QAAQ,CAAC,EAAE,MAAM,GAAI,SAAS,CAevE"}
1
+ {"version":3,"file":"get-media-type.d.ts","sourceRoot":"","sources":["../../src/utils/get-media-type.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,eAAO,MAAM,WAAW,YACvB,OAAO,EACP,OAAO,EACP,OAAO,EACP,aAAa,CACJ,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,CAAE,OAAO,WAAW,CAAE,CAAE,MAAM,CAAE,CAAC;CACvC;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CAAE,QAAQ,CAAC,EAAE,MAAM,GAAI,SAAS,CAevE"}
@@ -1,3 +1,3 @@
1
- export { getMediaTypeFromMimeType } from './get-media-type';
1
+ export { getMediaTypeFromMimeType, MEDIA_TYPES } from './get-media-type';
2
2
  export type { MediaType } from './get-media-type';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAC5D,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACzE,YAAY,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/media-editor",
3
- "version": "0.23.0",
3
+ "version": "0.24.0",
4
4
  "description": "Media editor components for WordPress.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -52,33 +52,37 @@
52
52
  "build-module/store/index.mjs"
53
53
  ],
54
54
  "dependencies": {
55
- "@wordpress/admin-ui": "^3.2.0",
56
- "@wordpress/api-fetch": "^8.2.0",
57
- "@wordpress/base-styles": "^15.1.0",
58
- "@wordpress/components": "^45.0.0",
59
- "@wordpress/compose": "^9.2.0",
60
- "@wordpress/core-data": "^9.2.0",
61
- "@wordpress/data": "^11.2.0",
62
- "@wordpress/dataviews": "^22.1.0",
63
- "@wordpress/element": "^10.2.0",
64
- "@wordpress/i18n": "^7.2.0",
65
- "@wordpress/icons": "^21.0.0",
66
- "@wordpress/image-editor": "^0.1.0",
67
- "@wordpress/keyboard-shortcuts": "^6.2.0",
68
- "@wordpress/keycodes": "^5.2.0",
69
- "@wordpress/notices": "^6.2.0",
70
- "@wordpress/private-apis": "^3.2.0",
71
- "@wordpress/ui": "^0.27.0",
55
+ "@wordpress/a11y": "^5.3.0",
56
+ "@wordpress/admin-ui": "^3.3.0",
57
+ "@wordpress/api-fetch": "^8.3.0",
58
+ "@wordpress/base-styles": "^15.2.0",
59
+ "@wordpress/components": "^45.1.0",
60
+ "@wordpress/compose": "^9.3.0",
61
+ "@wordpress/core-data": "^9.3.0",
62
+ "@wordpress/data": "^11.3.0",
63
+ "@wordpress/dataviews": "^22.2.0",
64
+ "@wordpress/element": "^10.3.0",
65
+ "@wordpress/i18n": "^7.3.0",
66
+ "@wordpress/icons": "^21.1.0",
67
+ "@wordpress/image-editor": "^0.2.0",
68
+ "@wordpress/keyboard-shortcuts": "^6.3.0",
69
+ "@wordpress/keycodes": "^5.3.0",
70
+ "@wordpress/notices": "^6.3.0",
71
+ "@wordpress/plugins": "^8.3.0",
72
+ "@wordpress/private-apis": "^3.3.0",
73
+ "@wordpress/react-inert-value": "^2.3.0",
74
+ "@wordpress/ui": "^0.28.0",
75
+ "@wordpress/warning": "^4.3.0",
72
76
  "clsx": "^2.1.1",
73
77
  "fast-deep-equal": "^3.1.3"
74
78
  },
75
79
  "devDependencies": {
76
- "@storybook/react-vite": "^10.6.6",
80
+ "@storybook/react-vite": "^10.6.8",
77
81
  "@testing-library/dom": "^10.4.2",
78
82
  "@testing-library/jest-dom": "^7.0.1",
79
83
  "@testing-library/react": "^16.3.3",
80
- "@testing-library/user-event": "^14.6.8",
81
- "vitest": "^5.1.0",
84
+ "@testing-library/user-event": "^14.6.13",
85
+ "vitest": "^5.1.1",
82
86
  "vitest-browser-react": "^2.3.0"
83
87
  },
84
88
  "peerDependencies": {
@@ -98,5 +102,5 @@
98
102
  "publishConfig": {
99
103
  "access": "public"
100
104
  },
101
- "gitHead": "1000cdf1dffd5b5e69f75cc4360aa76db8252264"
105
+ "gitHead": "7f19202f61aeba8f4bdce892a1a0df485ad76e2b"
102
106
  }