@wordpress/media-editor 0.19.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.
- package/CHANGELOG.md +34 -0
- package/README.md +2 -1
- package/build/components/media-editor/index.cjs +136 -63
- package/build/components/media-editor/index.cjs.map +3 -3
- package/build/components/media-editor/use-crop-options.cjs +2 -3
- package/build/components/media-editor/use-crop-options.cjs.map +2 -2
- package/build/components/media-editor/use-save-media-editor.cjs +36 -20
- package/build/components/media-editor/use-save-media-editor.cjs.map +2 -2
- package/build/components/media-editor-canvas/index.cjs +8 -8
- package/build/components/media-editor-canvas/index.cjs.map +3 -3
- package/build/components/media-editor-crop-panel/index.cjs +12 -8
- package/build/components/media-editor-crop-panel/index.cjs.map +3 -3
- package/build/components/media-editor-fine-rotation/index.cjs +1 -1
- package/build/components/media-editor-fine-rotation/index.cjs.map +2 -2
- package/build/components/media-editor-image-controls/index.cjs +46 -29
- package/build/components/media-editor-image-controls/index.cjs.map +2 -2
- package/build/components/media-editor-modal/index.cjs +19 -9
- package/build/components/media-editor-modal/index.cjs.map +2 -2
- package/build/components/media-editor-provider/index.cjs +2 -1
- package/build/components/media-editor-provider/index.cjs.map +2 -2
- package/build/components/media-form/index.cjs +28 -28
- package/build/components/media-form/index.cjs.map +3 -3
- package/build/components/media-preview/index.cjs.map +3 -3
- package/build/hooks/use-crop-gesture-handlers.cjs +1 -1
- package/build/hooks/use-crop-gesture-handlers.cjs.map +2 -2
- package/build/image-editor/core/interaction-controller.cjs +5 -0
- package/build/image-editor/core/interaction-controller.cjs.map +2 -2
- package/build/image-editor/react/components/cropper.cjs +4 -14
- package/build/image-editor/react/components/cropper.cjs.map +2 -2
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +1 -1
- package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-aria-announcer.cjs +3 -1
- package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
- package/build/image-editor/react/hooks/use-interaction.cjs +1 -1
- package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
- package/build/state/composite-reducer.cjs +35 -10
- package/build/state/composite-reducer.cjs.map +3 -3
- package/build/state/index.cjs.map +1 -1
- package/build/state/media-editor-state-provider.cjs +1 -6
- package/build/state/media-editor-state-provider.cjs.map +2 -2
- package/build/state/types.cjs.map +1 -1
- package/build/state/use-media-editor-state.cjs +57 -42
- package/build/state/use-media-editor-state.cjs.map +2 -2
- package/build/store/actions.cjs +2 -0
- package/build/store/actions.cjs.map +2 -2
- package/build/store/reducer.cjs +3 -1
- package/build/store/reducer.cjs.map +2 -2
- package/build/store/selectors.cjs +5 -0
- package/build/store/selectors.cjs.map +2 -2
- package/build-module/components/media-editor/index.mjs +151 -67
- package/build-module/components/media-editor/index.mjs.map +2 -2
- package/build-module/components/media-editor/use-crop-options.mjs +2 -3
- package/build-module/components/media-editor/use-crop-options.mjs.map +2 -2
- package/build-module/components/media-editor/use-save-media-editor.mjs +36 -20
- package/build-module/components/media-editor/use-save-media-editor.mjs.map +2 -2
- package/build-module/components/media-editor-canvas/index.mjs +10 -10
- package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
- package/build-module/components/media-editor-crop-panel/index.mjs +13 -9
- package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
- package/build-module/components/media-editor-fine-rotation/index.mjs +1 -1
- package/build-module/components/media-editor-fine-rotation/index.mjs.map +2 -2
- package/build-module/components/media-editor-image-controls/index.mjs +47 -36
- package/build-module/components/media-editor-image-controls/index.mjs.map +2 -2
- package/build-module/components/media-editor-modal/index.mjs +19 -9
- package/build-module/components/media-editor-modal/index.mjs.map +2 -2
- package/build-module/components/media-editor-provider/index.mjs +2 -1
- package/build-module/components/media-editor-provider/index.mjs.map +2 -2
- package/build-module/components/media-form/index.mjs +33 -30
- package/build-module/components/media-form/index.mjs.map +2 -2
- package/build-module/components/media-preview/index.mjs +2 -2
- package/build-module/components/media-preview/index.mjs.map +2 -2
- package/build-module/hooks/use-crop-gesture-handlers.mjs +1 -1
- package/build-module/hooks/use-crop-gesture-handlers.mjs.map +2 -2
- package/build-module/image-editor/core/interaction-controller.mjs +5 -0
- package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
- package/build-module/image-editor/react/components/cropper.mjs +4 -14
- package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
- package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +1 -1
- 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 +3 -1
- package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
- package/build-module/image-editor/react/hooks/use-interaction.mjs +1 -1
- package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
- package/build-module/state/composite-reducer.mjs +25 -10
- package/build-module/state/composite-reducer.mjs.map +2 -2
- package/build-module/state/index.mjs.map +1 -1
- package/build-module/state/media-editor-state-provider.mjs +1 -6
- package/build-module/state/media-editor-state-provider.mjs.map +2 -2
- package/build-module/state/types.mjs.map +1 -1
- package/build-module/state/use-media-editor-state.mjs +57 -42
- package/build-module/state/use-media-editor-state.mjs.map +2 -2
- package/build-module/store/actions.mjs +2 -0
- package/build-module/store/actions.mjs.map +2 -2
- package/build-module/store/reducer.mjs +3 -1
- package/build-module/store/reducer.mjs.map +2 -2
- package/build-module/store/selectors.mjs +4 -0
- package/build-module/store/selectors.mjs.map +2 -2
- package/build-style/style-rtl.css +5 -5
- package/build-style/style.css +5 -5
- package/build-types/components/media-editor/index.d.ts +4 -3
- package/build-types/components/media-editor/index.d.ts.map +1 -1
- package/build-types/components/media-editor/use-crop-options.d.ts +0 -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 +15 -3
- package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
- package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
- package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
- package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
- package/build-types/components/media-editor-modal/index.d.ts +7 -2
- package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
- package/build-types/components/media-editor-provider/index.d.ts +7 -1
- package/build-types/components/media-editor-provider/index.d.ts.map +1 -1
- package/build-types/components/media-form/index.d.ts +5 -2
- package/build-types/components/media-form/index.d.ts.map +1 -1
- package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -1
- package/build-types/image-editor/core/interaction-controller.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/stencils/rectangle-stencil.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
- package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
- package/build-types/state/composite-reducer.d.ts +5 -5
- package/build-types/state/composite-reducer.d.ts.map +1 -1
- package/build-types/state/index.d.ts +2 -2
- package/build-types/state/index.d.ts.map +1 -1
- package/build-types/state/media-editor-state-provider.d.ts +8 -16
- package/build-types/state/media-editor-state-provider.d.ts.map +1 -1
- package/build-types/state/types.d.ts +34 -5
- package/build-types/state/types.d.ts.map +1 -1
- package/build-types/state/use-media-editor-state.d.ts +53 -35
- package/build-types/state/use-media-editor-state.d.ts.map +1 -1
- package/build-types/store/actions.d.ts +9 -1
- package/build-types/store/actions.d.ts.map +1 -1
- package/build-types/store/reducer.d.ts +3 -0
- package/build-types/store/reducer.d.ts.map +1 -1
- package/build-types/store/selectors.d.ts +1 -0
- package/build-types/store/selectors.d.ts.map +1 -1
- package/package.json +41 -25
- package/src/components/media-editor/index.tsx +213 -79
- package/src/components/media-editor/use-crop-options.ts +1 -3
- package/src/components/media-editor/use-save-media-editor.ts +61 -20
- package/src/components/media-editor-canvas/index.tsx +9 -10
- package/src/components/media-editor-crop-panel/index.tsx +17 -9
- package/src/components/media-editor-fine-rotation/index.tsx +1 -1
- package/src/components/media-editor-image-controls/index.tsx +41 -41
- package/src/components/media-editor-image-controls/style.scss +1 -1
- package/src/components/media-editor-modal/index.tsx +26 -11
- package/src/components/media-editor-provider/index.tsx +8 -1
- package/src/components/media-form/index.tsx +48 -42
- package/src/components/media-preview/index.tsx +2 -2
- package/src/hooks/use-crop-gesture-handlers.ts +3 -1
- package/src/image-editor/core/interaction-controller.ts +8 -0
- package/src/image-editor/docs/architecture.md +10 -2
- package/src/image-editor/docs/recipes.md +8 -8
- package/src/image-editor/react/components/cropper.scss +5 -5
- package/src/image-editor/react/components/cropper.tsx +9 -18
- package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +3 -1
- package/src/image-editor/react/hooks/use-aria-announcer.ts +3 -1
- package/src/image-editor/react/hooks/use-interaction.ts +3 -2
- package/src/state/composite-reducer.ts +29 -17
- package/src/state/index.ts +3 -1
- package/src/state/media-editor-state-provider.tsx +9 -22
- package/src/state/types.ts +37 -5
- package/src/state/use-media-editor-state.ts +124 -78
- package/src/store/actions.ts +9 -0
- package/src/store/reducer.ts +6 -1
- package/src/store/selectors.ts +4 -0
- package/global.d.ts +0 -5
- package/src/components/media-editor/test/use-crop-options.jsdom.test.tsx +0 -104
- package/src/components/media-editor-crop-panel/test/index.jsdom.test.tsx +0 -74
- package/src/components/media-editor-image-controls/test/index.jsdom.test.tsx +0 -180
- package/src/components/media-editor-modal/test/build-modifiers.test.ts +0 -359
- package/src/components/media-editor-modal/test/index.jsdom.test.tsx +0 -165
- package/src/components/rotation-ruler/stories/index.story.tsx +0 -43
- package/src/components/rotation-ruler/test/index.jsdom.test.tsx +0 -140
- package/src/image-editor/core/export/test/canvas-renderer.jsdom.test.ts +0 -823
- package/src/image-editor/core/math/test/sanitize.ts +0 -242
- package/src/image-editor/core/test/camera.ts +0 -1218
- package/src/image-editor/core/test/interaction-controller.ts +0 -1254
- package/src/image-editor/core/test/preview-export-parity.ts +0 -249
- package/src/image-editor/core/test/render-camera-bridge.ts +0 -349
- package/src/image-editor/core/test/state.ts +0 -876
- package/src/image-editor/core/test/stencil-math.ts +0 -665
- package/src/image-editor/core/transforms/test/pipeline.ts +0 -267
- package/src/image-editor/react/components/stencils/test/rectangle-stencil.browser.test.tsx +0 -438
- package/src/image-editor/react/components/test/cropper.browser.test.tsx +0 -1460
- package/src/image-editor/react/hooks/test/use-aria-announcer.jsdom.test.ts +0 -491
- package/src/image-editor/react/hooks/test/use-cropper-reducer.jsdom.test.ts +0 -1049
- package/src/image-editor/react/hooks/test/use-interaction.jsdom.test.ts +0 -213
- package/src/image-editor/react/hooks/test/use-transform-style.jsdom.test.ts +0 -140
- package/src/image-editor/stories/rectangle-crop.story.tsx +0 -1073
- package/src/image-editor/stories/style.module.css +0 -65
- package/src/state/test/use-media-editor-state.jsdom.test.ts +0 -324
- package/src/store/test/reducer.ts +0 -64
- package/tsconfig.build.json +0 -26
- package/tsconfig.build.tsbuildinfo +0 -1
- package/tsconfig.json +0 -37
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { MediaEditorModalUpdate } from './actions';
|
|
2
2
|
type OnUpdateCallback = (updated: MediaEditorModalUpdate) => void;
|
|
3
|
+
type OnUndoCallback = () => void;
|
|
3
4
|
type OnCloseCallback = () => void;
|
|
4
5
|
export interface State {
|
|
5
6
|
isOpen: boolean;
|
|
6
7
|
id: number | null;
|
|
7
8
|
onUpdate: OnUpdateCallback | null;
|
|
9
|
+
onUndo: OnUndoCallback | null;
|
|
8
10
|
onClose: OnCloseCallback | null;
|
|
9
11
|
}
|
|
10
12
|
export declare const DEFAULT_STATE: State;
|
|
@@ -12,6 +14,7 @@ type Action = {
|
|
|
12
14
|
type: 'OPEN_MEDIA_EDITOR_MODAL';
|
|
13
15
|
id: number;
|
|
14
16
|
onUpdate: OnUpdateCallback | null;
|
|
17
|
+
onUndo: OnUndoCallback | null;
|
|
15
18
|
onClose: OnCloseCallback | null;
|
|
16
19
|
} | {
|
|
17
20
|
type: 'CLOSE_MEDIA_EDITOR_MODAL';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/store/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAExD,KAAK,gBAAgB,GAAG,CAAE,OAAO,EAAE,sBAAsB,KAAM,IAAI,CAAC;AACpE,KAAK,eAAe,GAAG,MAAM,IAAI,CAAC;AAElC,MAAM,WAAW,KAAK;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAClC,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;CAChC;AAED,eAAO,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"reducer.d.ts","sourceRoot":"","sources":["../../src/store/reducer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,WAAW,CAAC;AAExD,KAAK,gBAAgB,GAAG,CAAE,OAAO,EAAE,sBAAsB,KAAM,IAAI,CAAC;AACpE,KAAK,cAAc,GAAG,MAAM,IAAI,CAAC;AACjC,KAAK,eAAe,GAAG,MAAM,IAAI,CAAC;AAElC,MAAM,WAAW,KAAK;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;IAClB,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAClC,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;CAChC;AAED,eAAO,MAAM,aAAa,EAAE,KAM3B,CAAC;AAEF,KAAK,MAAM,GACR;IACA,IAAI,EAAE,yBAAyB,CAAC;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,gBAAgB,GAAG,IAAI,CAAC;IAClC,MAAM,EAAE,cAAc,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,eAAe,GAAG,IAAI,CAAC;CAC/B,GACD;IAAE,IAAI,EAAE,0BAA0B,CAAA;CAAE,CAAC;AAExC,MAAM,CAAC,OAAO,UAAU,OAAO,CAC9B,KAAK,EAAE,KAAK,YAAgB,EAC5B,MAAM,EAAE,MAAM,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAC/B,KAAK,CAmBP"}
|
|
@@ -2,5 +2,6 @@ import type { State } from './reducer';
|
|
|
2
2
|
export declare function isOpen(state: State): boolean;
|
|
3
3
|
export declare function getId(state: State): number | null;
|
|
4
4
|
export declare function getOnUpdate(state: State): ((updated: import("./actions").MediaEditorModalUpdate) => void) | null;
|
|
5
|
+
export declare function getOnUndo(state: State): (() => void) | null;
|
|
5
6
|
export declare function getOnClose(state: State): (() => void) | null;
|
|
6
7
|
//# sourceMappingURL=selectors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../src/store/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,wBAAgB,MAAM,CAAE,KAAK,EAAE,KAAK,GAAI,OAAO,CAE9C;AAED,wBAAgB,KAAK,CAAE,KAAK,EAAE,KAAK,GAAI,MAAM,GAAG,IAAI,CAEnD;AAED,wBAAgB,WAAW,CAAE,KAAK,EAAE,KAAK,0EAExC;AAED,wBAAgB,UAAU,CAAE,KAAK,EAAE,KAAK,uBAEvC"}
|
|
1
|
+
{"version":3,"file":"selectors.d.ts","sourceRoot":"","sources":["../../src/store/selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,WAAW,CAAC;AAEvC,wBAAgB,MAAM,CAAE,KAAK,EAAE,KAAK,GAAI,OAAO,CAE9C;AAED,wBAAgB,KAAK,CAAE,KAAK,EAAE,KAAK,GAAI,MAAM,GAAG,IAAI,CAEnD;AAED,wBAAgB,WAAW,CAAE,KAAK,EAAE,KAAK,0EAExC;AAED,wBAAgB,SAAS,CAAE,KAAK,EAAE,KAAK,uBAEtC;AAED,wBAAgB,UAAU,CAAE,KAAK,EAAE,KAAK,uBAEvC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/media-editor",
|
|
3
|
-
"version": "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": ">=
|
|
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,46 +52,52 @@
|
|
|
42
52
|
"build-module/store/index.mjs"
|
|
43
53
|
],
|
|
44
54
|
"dependencies": {
|
|
45
|
-
"@wordpress/a11y": "^
|
|
46
|
-
"@wordpress/admin-ui": "^
|
|
47
|
-
"@wordpress/api-fetch": "^
|
|
48
|
-
"@wordpress/base-styles": "^
|
|
49
|
-
"@wordpress/components": "^
|
|
50
|
-
"@wordpress/compose": "^
|
|
51
|
-
"@wordpress/core-data": "^
|
|
52
|
-
"@wordpress/data": "^
|
|
53
|
-
"@wordpress/dataviews": "^
|
|
54
|
-
"@wordpress/element": "^
|
|
55
|
-
"@wordpress/i18n": "^
|
|
56
|
-
"@wordpress/icons": "^
|
|
57
|
-
"@wordpress/keyboard-shortcuts": "^
|
|
58
|
-
"@wordpress/keycodes": "^
|
|
59
|
-
"@wordpress/notices": "^
|
|
60
|
-
"@wordpress/private-apis": "^
|
|
61
|
-
"@wordpress/ui": "^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": {
|
|
66
|
-
"@storybook/react-vite": "^10.
|
|
77
|
+
"@storybook/react-vite": "^10.6.1",
|
|
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.
|
|
71
|
-
"vitest": "^5.0.
|
|
81
|
+
"@testing-library/user-event": "^14.6.8",
|
|
82
|
+
"vitest": "^5.0.3",
|
|
72
83
|
"vitest-browser-react": "^2.3.0"
|
|
73
84
|
},
|
|
74
85
|
"peerDependencies": {
|
|
75
86
|
"@types/react": "^18 || ^19",
|
|
76
|
-
"react": "^18 || ^19"
|
|
87
|
+
"@types/react-dom": "^18 || ^19",
|
|
88
|
+
"react": "^18 || ^19",
|
|
89
|
+
"react-dom": "^18 || ^19"
|
|
77
90
|
},
|
|
78
91
|
"peerDependenciesMeta": {
|
|
79
92
|
"@types/react": {
|
|
80
93
|
"optional": true
|
|
94
|
+
},
|
|
95
|
+
"@types/react-dom": {
|
|
96
|
+
"optional": true
|
|
81
97
|
}
|
|
82
98
|
},
|
|
83
99
|
"publishConfig": {
|
|
84
100
|
"access": "public"
|
|
85
101
|
},
|
|
86
|
-
"gitHead": "
|
|
102
|
+
"gitHead": "8d30f92cbbde3ddf781c8799443c649befbbcb88"
|
|
87
103
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
import {
|
|
3
3
|
Button,
|
|
4
|
-
|
|
4
|
+
DropdownMenu,
|
|
5
|
+
MenuGroup,
|
|
6
|
+
MenuItem,
|
|
7
|
+
Spinner as WCSpinner,
|
|
5
8
|
__experimentalConfirmDialog as ConfirmDialog,
|
|
6
9
|
} from '@wordpress/components';
|
|
7
10
|
import { Stack, Tabs, VisuallyHidden } from '@wordpress/ui';
|
|
@@ -19,15 +22,27 @@ import {
|
|
|
19
22
|
useState,
|
|
20
23
|
} from '@wordpress/element';
|
|
21
24
|
import { __ } from '@wordpress/i18n';
|
|
22
|
-
import {
|
|
25
|
+
import {
|
|
26
|
+
backup,
|
|
27
|
+
close,
|
|
28
|
+
drawerRight,
|
|
29
|
+
keyboard,
|
|
30
|
+
moreVertical,
|
|
31
|
+
redo,
|
|
32
|
+
undo,
|
|
33
|
+
} from '@wordpress/icons';
|
|
23
34
|
import {
|
|
24
35
|
displayShortcut,
|
|
25
36
|
isAppleOS,
|
|
26
37
|
isKeyboardEvent,
|
|
27
38
|
} from '@wordpress/keycodes';
|
|
28
39
|
import { SnackbarNotices, store as noticesStore } from '@wordpress/notices';
|
|
29
|
-
import type { Field } from '@wordpress/dataviews';
|
|
30
|
-
import type {
|
|
40
|
+
import type { Field, Form } from '@wordpress/dataviews';
|
|
41
|
+
import type {
|
|
42
|
+
KeyboardEvent as ReactKeyboardEvent,
|
|
43
|
+
ReactElement,
|
|
44
|
+
ReactNode,
|
|
45
|
+
} from 'react';
|
|
31
46
|
import { MediaEditorProvider } from '../media-editor-provider';
|
|
32
47
|
import type { Media } from '../media-editor-provider';
|
|
33
48
|
import MediaPreview from '../media-preview';
|
|
@@ -71,7 +86,7 @@ const CROP_PANEL = 'crop';
|
|
|
71
86
|
interface MediaEditorTab {
|
|
72
87
|
id: string;
|
|
73
88
|
title: string;
|
|
74
|
-
render: () =>
|
|
89
|
+
render: () => ReactElement;
|
|
75
90
|
}
|
|
76
91
|
|
|
77
92
|
export interface MediaEditorFrameProps {
|
|
@@ -101,11 +116,12 @@ export interface MediaEditorFrameProps {
|
|
|
101
116
|
|
|
102
117
|
export interface MediaEditorProps {
|
|
103
118
|
fields?: Field< Media >[];
|
|
119
|
+
form?: Form;
|
|
104
120
|
id: number;
|
|
105
121
|
aspectRatioPresets?: AspectRatioPreset[];
|
|
106
122
|
onClose?: () => void;
|
|
107
123
|
onSaved?: ( result: MediaEditorSaveResult ) => void;
|
|
108
|
-
renderFrame: ( props: MediaEditorFrameProps ) =>
|
|
124
|
+
renderFrame: ( props: MediaEditorFrameProps ) => ReactElement;
|
|
109
125
|
noticesClassName?: string;
|
|
110
126
|
noticesPortalElement?: Element | null;
|
|
111
127
|
shouldCloseOnEsc?: boolean;
|
|
@@ -203,7 +219,19 @@ interface MediaEditorFrameContextValue {
|
|
|
203
219
|
onTogglePanel: () => void;
|
|
204
220
|
onCancel: () => void;
|
|
205
221
|
onSave: () => void;
|
|
206
|
-
|
|
222
|
+
/**
|
|
223
|
+
* When `true`, the media has a lineage root to restore to, so the
|
|
224
|
+
* "Restore original image" menu item is shown.
|
|
225
|
+
*/
|
|
226
|
+
canRestoreOriginal: boolean;
|
|
227
|
+
/**
|
|
228
|
+
* When `true`, another attachment has replaced the edited one in the
|
|
229
|
+
* cropper this session (today, only the original), so the menu item is
|
|
230
|
+
* disabled.
|
|
231
|
+
*/
|
|
232
|
+
isSourceReplaced: boolean;
|
|
233
|
+
/** Load the lineage root into the cropper as a dirty preview. */
|
|
234
|
+
onRestoreOriginal: () => void;
|
|
207
235
|
}
|
|
208
236
|
|
|
209
237
|
const MediaEditorFrameContext =
|
|
@@ -237,8 +265,17 @@ export interface HeaderActionsProps {
|
|
|
237
265
|
}
|
|
238
266
|
|
|
239
267
|
function HeaderActions( { showCloseButton = false }: HeaderActionsProps ) {
|
|
240
|
-
const {
|
|
241
|
-
|
|
268
|
+
const {
|
|
269
|
+
isImage,
|
|
270
|
+
isSaving,
|
|
271
|
+
onCancel,
|
|
272
|
+
isWide,
|
|
273
|
+
activePanel,
|
|
274
|
+
onTogglePanel,
|
|
275
|
+
canRestoreOriginal,
|
|
276
|
+
isSourceReplaced,
|
|
277
|
+
onRestoreOriginal,
|
|
278
|
+
} = useMediaEditorFrameContext();
|
|
242
279
|
const isPanelOpen = !! activePanel;
|
|
243
280
|
const [ isShortcutsModalOpen, setIsShortcutsModalOpen ] = useState( false );
|
|
244
281
|
return (
|
|
@@ -248,14 +285,6 @@ function HeaderActions( { showCloseButton = false }: HeaderActionsProps ) {
|
|
|
248
285
|
align="center"
|
|
249
286
|
gap="sm"
|
|
250
287
|
>
|
|
251
|
-
{ isImage && (
|
|
252
|
-
<Button
|
|
253
|
-
size="compact"
|
|
254
|
-
icon={ keyboard }
|
|
255
|
-
label={ __( 'Keyboard shortcuts' ) }
|
|
256
|
-
onClick={ () => setIsShortcutsModalOpen( true ) }
|
|
257
|
-
/>
|
|
258
|
-
) }
|
|
259
288
|
{ /* The sidebar holds more than one panel, so this opens and
|
|
260
289
|
closes the sidebar rather than naming a panel: reopening
|
|
261
290
|
returns to whichever tab was last showing, and the tab strip
|
|
@@ -271,6 +300,50 @@ function HeaderActions( { showCloseButton = false }: HeaderActionsProps ) {
|
|
|
271
300
|
aria-expanded={ isWide ? isPanelOpen : undefined }
|
|
272
301
|
onClick={ onTogglePanel }
|
|
273
302
|
/>
|
|
303
|
+
{ isImage && (
|
|
304
|
+
<DropdownMenu
|
|
305
|
+
icon={ moreVertical }
|
|
306
|
+
label={ __( 'More options' ) }
|
|
307
|
+
toggleProps={ { size: 'compact' } }
|
|
308
|
+
>
|
|
309
|
+
{ ( { onClose: closeMenu } ) => (
|
|
310
|
+
<>
|
|
311
|
+
{ canRestoreOriginal && (
|
|
312
|
+
<MenuGroup>
|
|
313
|
+
<MenuItem
|
|
314
|
+
icon={ backup }
|
|
315
|
+
iconPosition="left"
|
|
316
|
+
disabled={
|
|
317
|
+
isSourceReplaced || isSaving
|
|
318
|
+
}
|
|
319
|
+
info={ __(
|
|
320
|
+
'Discards unsaved changes and loads the original image.'
|
|
321
|
+
) }
|
|
322
|
+
onClick={ () => {
|
|
323
|
+
onRestoreOriginal();
|
|
324
|
+
closeMenu();
|
|
325
|
+
} }
|
|
326
|
+
>
|
|
327
|
+
{ __( 'Restore original image' ) }
|
|
328
|
+
</MenuItem>
|
|
329
|
+
</MenuGroup>
|
|
330
|
+
) }
|
|
331
|
+
<MenuGroup>
|
|
332
|
+
<MenuItem
|
|
333
|
+
icon={ keyboard }
|
|
334
|
+
iconPosition="left"
|
|
335
|
+
onClick={ () => {
|
|
336
|
+
setIsShortcutsModalOpen( true );
|
|
337
|
+
closeMenu();
|
|
338
|
+
} }
|
|
339
|
+
>
|
|
340
|
+
{ __( 'Keyboard shortcuts' ) }
|
|
341
|
+
</MenuItem>
|
|
342
|
+
</MenuGroup>
|
|
343
|
+
</>
|
|
344
|
+
) }
|
|
345
|
+
</DropdownMenu>
|
|
346
|
+
) }
|
|
274
347
|
{ showCloseButton && (
|
|
275
348
|
<Button
|
|
276
349
|
size="compact"
|
|
@@ -291,7 +364,7 @@ function HeaderActions( { showCloseButton = false }: HeaderActionsProps ) {
|
|
|
291
364
|
}
|
|
292
365
|
|
|
293
366
|
function HistoryActions() {
|
|
294
|
-
const { isImage, isUndoRedoDisabled,
|
|
367
|
+
const { isImage, isUndoRedoDisabled, isWide, activePanel } =
|
|
295
368
|
useMediaEditorFrameContext();
|
|
296
369
|
const {
|
|
297
370
|
reset,
|
|
@@ -300,11 +373,9 @@ function HistoryActions() {
|
|
|
300
373
|
hasRedo,
|
|
301
374
|
undo: undoCrop,
|
|
302
375
|
redo: redoCrop,
|
|
303
|
-
beginGesture,
|
|
304
|
-
endGesture,
|
|
305
376
|
} = useMediaEditor();
|
|
306
|
-
// Reset, undo and redo act on the
|
|
307
|
-
// 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
|
|
308
379
|
// breakpoint an open panel replaces the canvas, and leaving these behind
|
|
309
380
|
// would put an enabled, destructive Reset next to metadata fields it does
|
|
310
381
|
// not touch — clicking it would discard a crop the user cannot see.
|
|
@@ -330,10 +401,7 @@ function HistoryActions() {
|
|
|
330
401
|
if ( isUndoRedoDisabled ) {
|
|
331
402
|
return;
|
|
332
403
|
}
|
|
333
|
-
beginGesture();
|
|
334
404
|
reset();
|
|
335
|
-
onReset();
|
|
336
|
-
endGesture();
|
|
337
405
|
};
|
|
338
406
|
return (
|
|
339
407
|
<Stack
|
|
@@ -426,6 +494,7 @@ function SaveActions( { size = 'default' }: SaveActionsProps ) {
|
|
|
426
494
|
|
|
427
495
|
function MediaEditorContent( {
|
|
428
496
|
fields = [],
|
|
497
|
+
form,
|
|
429
498
|
id,
|
|
430
499
|
aspectRatioPresets,
|
|
431
500
|
onClose,
|
|
@@ -435,7 +504,7 @@ function MediaEditorContent( {
|
|
|
435
504
|
noticesPortalElement,
|
|
436
505
|
shouldCloseOnEsc = false,
|
|
437
506
|
}: MediaEditorProps ) {
|
|
438
|
-
const
|
|
507
|
+
const session = useMediaEditor();
|
|
439
508
|
// Width decides whether the settings panel docks beside the canvas or
|
|
440
509
|
// takes the whole body. It docks from `small` (600px): the modal is the
|
|
441
510
|
// viewport less a 16px margin either side, so a 320px panel and the
|
|
@@ -483,41 +552,16 @@ function MediaEditorContent( {
|
|
|
483
552
|
// its own controls, so it moves that cluster elsewhere. The same width
|
|
484
553
|
// undocks the panel, so this is `isWide` rather than a second query.
|
|
485
554
|
const layout: 'wide' | 'narrow' = isWide ? 'wide' : 'narrow';
|
|
486
|
-
const
|
|
487
|
-
( select ) =>
|
|
488
|
-
|
|
489
|
-
getEditedEntityRecord,
|
|
490
|
-
getEntityRecord,
|
|
491
|
-
hasEditsForEntityRecord,
|
|
492
|
-
} = select( coreStore );
|
|
493
|
-
// Trigger an _embed fetch so `_embedded.author` and
|
|
494
|
-
// `_embedded['wp:attached-to']` land on the record for the Details
|
|
495
|
-
// fields to read. `getEditedEntityRecord` doesn't formally accept a
|
|
496
|
-
// query, so we can't embed via that selector directly.
|
|
497
|
-
getEntityRecord(
|
|
555
|
+
const sourceMedia = useSelect(
|
|
556
|
+
( select ) =>
|
|
557
|
+
select( coreStore ).getEntityRecord(
|
|
498
558
|
'postType',
|
|
499
559
|
'attachment',
|
|
500
|
-
id
|
|
501
|
-
|
|
502
|
-
);
|
|
503
|
-
return {
|
|
504
|
-
media: getEditedEntityRecord(
|
|
505
|
-
'postType',
|
|
506
|
-
'attachment',
|
|
507
|
-
id
|
|
508
|
-
) as Media,
|
|
509
|
-
hasEdits: hasEditsForEntityRecord(
|
|
510
|
-
'postType',
|
|
511
|
-
'attachment',
|
|
512
|
-
id
|
|
513
|
-
),
|
|
514
|
-
};
|
|
515
|
-
},
|
|
560
|
+
id
|
|
561
|
+
) as Media,
|
|
516
562
|
[ id ]
|
|
517
563
|
);
|
|
518
564
|
|
|
519
|
-
const hasChanges = cropper.isCropperDirty || hasEdits;
|
|
520
|
-
|
|
521
565
|
const { clearEntityRecordEdits, editEntityRecord, invalidateResolution } =
|
|
522
566
|
useDispatch( coreStore );
|
|
523
567
|
const { removeAllNotices } = useDispatch( noticesStore );
|
|
@@ -526,8 +570,15 @@ function MediaEditorContent( {
|
|
|
526
570
|
const [ isPlacementActive, setIsPlacementActive ] = useState( false );
|
|
527
571
|
const [ isCanvasGestureActive, setIsCanvasGestureActive ] =
|
|
528
572
|
useState( false );
|
|
529
|
-
|
|
530
|
-
|
|
573
|
+
// Whether another attachment has replaced `id` in the cropper this
|
|
574
|
+
// session (today, the original via "Restore original image"). Stays a
|
|
575
|
+
// distinct flag (not derived from the cropper) so a bare replacement
|
|
576
|
+
// counts as a change even though swapping the source resets the
|
|
577
|
+
// cropper's own dirty baseline.
|
|
578
|
+
const [ isSourceReplaced, setIsSourceReplaced ] = useState( false );
|
|
579
|
+
const placementControlTimerRef = useRef<
|
|
580
|
+
ReturnType< typeof setTimeout > | undefined
|
|
581
|
+
>( undefined );
|
|
531
582
|
|
|
532
583
|
const signalPlacementControlInteraction = useCallback( () => {
|
|
533
584
|
setIsPlacementActive( true );
|
|
@@ -553,19 +604,103 @@ function MediaEditorContent( {
|
|
|
553
604
|
useEffect( () => {
|
|
554
605
|
setIsPlacementActive( false );
|
|
555
606
|
setIsCanvasGestureActive( false );
|
|
607
|
+
setIsSourceReplaced( false );
|
|
556
608
|
}, [ id ] );
|
|
557
609
|
|
|
558
|
-
//
|
|
559
|
-
//
|
|
560
|
-
//
|
|
610
|
+
// Restore-original: the edit root the edited attachment descends from,
|
|
611
|
+
// exposed by the server as the root-level `edit_root` id on the
|
|
612
|
+
// attachment (edit context, embeddable via the `wp:edit-root` link).
|
|
613
|
+
// Fetch the original's record for the URL and natural dimensions the
|
|
614
|
+
// cropper needs to seed itself.
|
|
615
|
+
const originalId: number | undefined = sourceMedia?.edit_root;
|
|
616
|
+
const originalRecord = useSelect(
|
|
617
|
+
( select ) =>
|
|
618
|
+
originalId
|
|
619
|
+
? ( select( coreStore ).getEntityRecord(
|
|
620
|
+
'postType',
|
|
621
|
+
'attachment',
|
|
622
|
+
originalId
|
|
623
|
+
) as Media | undefined )
|
|
624
|
+
: undefined,
|
|
625
|
+
[ originalId ]
|
|
626
|
+
);
|
|
627
|
+
const originalWidth = Number( originalRecord?.media_details?.width );
|
|
628
|
+
const originalHeight = Number( originalRecord?.media_details?.height );
|
|
629
|
+
const originalUrl = originalRecord?.source_url;
|
|
630
|
+
const originalSource =
|
|
631
|
+
originalId &&
|
|
632
|
+
originalRecord &&
|
|
633
|
+
typeof originalUrl === 'string' &&
|
|
634
|
+
originalUrl.length > 0 &&
|
|
635
|
+
Number.isFinite( originalWidth ) &&
|
|
636
|
+
originalWidth > 0 &&
|
|
637
|
+
Number.isFinite( originalHeight ) &&
|
|
638
|
+
originalHeight > 0
|
|
639
|
+
? {
|
|
640
|
+
id: originalId,
|
|
641
|
+
url: originalUrl,
|
|
642
|
+
media: originalRecord,
|
|
643
|
+
}
|
|
644
|
+
: undefined;
|
|
645
|
+
const canRestoreOriginal = !! originalSource;
|
|
646
|
+
const replacementSource =
|
|
647
|
+
isSourceReplaced && originalSource
|
|
648
|
+
? {
|
|
649
|
+
id: originalSource.id,
|
|
650
|
+
url: originalSource.url,
|
|
651
|
+
media: originalSource.media,
|
|
652
|
+
}
|
|
653
|
+
: undefined;
|
|
654
|
+
// Details and pending edits follow the attachment shown on the canvas.
|
|
655
|
+
// Keep `sourceMedia` separate for the snackbar's previous attachment.
|
|
656
|
+
const activeId = replacementSource?.id ?? id;
|
|
657
|
+
const { media, hasEdits } = useSelect(
|
|
658
|
+
( select ) => {
|
|
659
|
+
const {
|
|
660
|
+
getEditedEntityRecord,
|
|
661
|
+
getEntityRecord,
|
|
662
|
+
hasEditsForEntityRecord,
|
|
663
|
+
} = select( coreStore );
|
|
664
|
+
// Fetch embedded author and attached-post data for Details.
|
|
665
|
+
getEntityRecord(
|
|
666
|
+
'postType',
|
|
667
|
+
'attachment',
|
|
668
|
+
activeId,
|
|
669
|
+
ATTACHMENT_EMBED_QUERY
|
|
670
|
+
);
|
|
671
|
+
return {
|
|
672
|
+
media: getEditedEntityRecord(
|
|
673
|
+
'postType',
|
|
674
|
+
'attachment',
|
|
675
|
+
activeId
|
|
676
|
+
) as Media,
|
|
677
|
+
hasEdits: hasEditsForEntityRecord(
|
|
678
|
+
'postType',
|
|
679
|
+
'attachment',
|
|
680
|
+
activeId
|
|
681
|
+
),
|
|
682
|
+
};
|
|
683
|
+
},
|
|
684
|
+
[ activeId ]
|
|
685
|
+
);
|
|
686
|
+
// Refresh embedded data on opening or switching to the original.
|
|
561
687
|
useEffect( () => {
|
|
562
688
|
invalidateResolution( 'getEntityRecord', [
|
|
563
689
|
'postType',
|
|
564
690
|
'attachment',
|
|
565
|
-
|
|
691
|
+
activeId,
|
|
566
692
|
ATTACHMENT_EMBED_QUERY,
|
|
567
693
|
] );
|
|
568
|
-
}, [
|
|
694
|
+
}, [ activeId, invalidateResolution ] );
|
|
695
|
+
const handleRestoreOriginal = useCallback( () => {
|
|
696
|
+
// Restoring discards every pending edit, as the menu item says, so
|
|
697
|
+
// nothing staged against the attachment being replaced reaches a save.
|
|
698
|
+
clearEntityRecordEdits( 'postType', 'attachment', id );
|
|
699
|
+
setIsSourceReplaced( true );
|
|
700
|
+
}, [ clearEntityRecordEdits, id ] );
|
|
701
|
+
|
|
702
|
+
// A bare replacement has no cropper diff, so OR the flag in explicitly.
|
|
703
|
+
const hasChanges = session.hasOutputEdits || hasEdits || isSourceReplaced;
|
|
569
704
|
|
|
570
705
|
const mediaType = getMediaTypeFromMimeType( media?.mime_type ).type;
|
|
571
706
|
const isImage = !! media && mediaType === 'image';
|
|
@@ -593,20 +728,15 @@ function MediaEditorContent( {
|
|
|
593
728
|
setActivePanel( isWide ? lastPanelRef.current : null );
|
|
594
729
|
}
|
|
595
730
|
}, [ isWide, isImage ] );
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
const {
|
|
599
|
-
aspectRatioValue,
|
|
600
|
-
setAspectRatioValue,
|
|
601
|
-
aspectRatioOptions,
|
|
602
|
-
resetCropOptions,
|
|
603
|
-
} = useCropOptions( { aspectRatioPresets } );
|
|
731
|
+
const { aspectRatioValue, setAspectRatioValue, aspectRatioOptions } =
|
|
732
|
+
useCropOptions( { aspectRatioPresets } );
|
|
604
733
|
const { isSaving, save: saveMediaEditor } = useSaveMediaEditor( {
|
|
605
|
-
|
|
734
|
+
session,
|
|
606
735
|
id,
|
|
607
736
|
isImage,
|
|
608
|
-
media,
|
|
737
|
+
media: sourceMedia,
|
|
609
738
|
onSaved,
|
|
739
|
+
replacementSource,
|
|
610
740
|
} );
|
|
611
741
|
|
|
612
742
|
const handleChange = ( updates: Partial< Media > ) => {
|
|
@@ -618,12 +748,13 @@ function MediaEditorContent( {
|
|
|
618
748
|
if ( isSaving ) {
|
|
619
749
|
return;
|
|
620
750
|
}
|
|
621
|
-
editEntityRecord( 'postType', 'attachment',
|
|
751
|
+
editEntityRecord( 'postType', 'attachment', activeId, updates );
|
|
622
752
|
};
|
|
623
753
|
|
|
624
754
|
const discardAndClose = () => {
|
|
625
755
|
removeAllNotices( 'snackbar', MEDIA_EDITOR_NOTICES_CONTEXT );
|
|
626
|
-
clearEntityRecordEdits( 'postType', 'attachment',
|
|
756
|
+
clearEntityRecordEdits( 'postType', 'attachment', activeId );
|
|
757
|
+
setIsSourceReplaced( false );
|
|
627
758
|
onClose?.();
|
|
628
759
|
};
|
|
629
760
|
|
|
@@ -656,9 +787,9 @@ function MediaEditorContent( {
|
|
|
656
787
|
return;
|
|
657
788
|
}
|
|
658
789
|
if ( isRedoShortcut ) {
|
|
659
|
-
|
|
790
|
+
session.redo();
|
|
660
791
|
} else {
|
|
661
|
-
|
|
792
|
+
session.undo();
|
|
662
793
|
}
|
|
663
794
|
}
|
|
664
795
|
}
|
|
@@ -748,12 +879,13 @@ function MediaEditorContent( {
|
|
|
748
879
|
isDisabled: true,
|
|
749
880
|
} ) )
|
|
750
881
|
: fields,
|
|
882
|
+
form,
|
|
751
883
|
} }
|
|
752
884
|
>
|
|
753
885
|
<div className="media-editor">
|
|
754
886
|
{ ! media ? (
|
|
755
887
|
<div className="media-editor__loading">
|
|
756
|
-
<
|
|
888
|
+
<WCSpinner />
|
|
757
889
|
</div>
|
|
758
890
|
) : (
|
|
759
891
|
<div
|
|
@@ -849,7 +981,9 @@ function MediaEditorContent( {
|
|
|
849
981
|
onTogglePanel: togglePanel,
|
|
850
982
|
onCancel: handleRequestClose,
|
|
851
983
|
onSave: saveMediaEditor,
|
|
852
|
-
|
|
984
|
+
canRestoreOriginal,
|
|
985
|
+
isSourceReplaced,
|
|
986
|
+
onRestoreOriginal: handleRestoreOriginal,
|
|
853
987
|
};
|
|
854
988
|
|
|
855
989
|
return (
|
|
@@ -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
|
/**
|
|
@@ -50,7 +49,7 @@ export function useCropOptions( {
|
|
|
50
49
|
}: UseCropOptionsArgs = {} ): UseCropOptionsReturn {
|
|
51
50
|
const controller = useMediaEditor();
|
|
52
51
|
const { aspectRatioValue } = controller.cropOptions;
|
|
53
|
-
const cropperImage = controller.state.image;
|
|
52
|
+
const cropperImage = controller.cropper.state.image;
|
|
54
53
|
|
|
55
54
|
const aspectRatioOptions = useMemo(
|
|
56
55
|
() => getAspectRatioOptions( aspectRatioPresets ),
|
|
@@ -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
|
}
|