@wordpress/media-editor 0.19.0 → 0.20.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 (142) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/build/components/media-editor/index.cjs +132 -50
  3. package/build/components/media-editor/index.cjs.map +2 -2
  4. package/build/components/media-editor/use-crop-options.cjs +1 -1
  5. package/build/components/media-editor/use-crop-options.cjs.map +2 -2
  6. package/build/components/media-editor/use-save-media-editor.cjs +36 -20
  7. package/build/components/media-editor/use-save-media-editor.cjs.map +2 -2
  8. package/build/components/media-editor-canvas/index.cjs +8 -8
  9. package/build/components/media-editor-canvas/index.cjs.map +2 -2
  10. package/build/components/media-editor-fine-rotation/index.cjs +1 -1
  11. package/build/components/media-editor-fine-rotation/index.cjs.map +2 -2
  12. package/build/components/media-editor-image-controls/index.cjs +46 -29
  13. package/build/components/media-editor-image-controls/index.cjs.map +2 -2
  14. package/build/components/media-editor-modal/index.cjs +17 -9
  15. package/build/components/media-editor-modal/index.cjs.map +2 -2
  16. package/build/hooks/use-crop-gesture-handlers.cjs +1 -1
  17. package/build/hooks/use-crop-gesture-handlers.cjs.map +2 -2
  18. package/build/image-editor/core/interaction-controller.cjs +5 -0
  19. package/build/image-editor/core/interaction-controller.cjs.map +2 -2
  20. package/build/image-editor/react/components/cropper.cjs +3 -3
  21. package/build/image-editor/react/components/cropper.cjs.map +2 -2
  22. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +1 -1
  23. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
  24. package/build/image-editor/react/hooks/use-aria-announcer.cjs +3 -1
  25. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
  26. package/build/image-editor/react/hooks/use-interaction.cjs +1 -1
  27. package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
  28. package/build/state/composite-reducer.cjs +3 -3
  29. package/build/state/composite-reducer.cjs.map +2 -2
  30. package/build/state/index.cjs.map +1 -1
  31. package/build/state/media-editor-state-provider.cjs +1 -6
  32. package/build/state/media-editor-state-provider.cjs.map +2 -2
  33. package/build/state/use-media-editor-state.cjs +38 -36
  34. package/build/state/use-media-editor-state.cjs.map +2 -2
  35. package/build/store/actions.cjs +2 -0
  36. package/build/store/actions.cjs.map +2 -2
  37. package/build/store/reducer.cjs +3 -1
  38. package/build/store/reducer.cjs.map +2 -2
  39. package/build/store/selectors.cjs +5 -0
  40. package/build/store/selectors.cjs.map +2 -2
  41. package/build-module/components/media-editor/index.mjs +145 -52
  42. package/build-module/components/media-editor/index.mjs.map +2 -2
  43. package/build-module/components/media-editor/use-crop-options.mjs +1 -1
  44. package/build-module/components/media-editor/use-crop-options.mjs.map +2 -2
  45. package/build-module/components/media-editor/use-save-media-editor.mjs +36 -20
  46. package/build-module/components/media-editor/use-save-media-editor.mjs.map +2 -2
  47. package/build-module/components/media-editor-canvas/index.mjs +8 -8
  48. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  49. package/build-module/components/media-editor-fine-rotation/index.mjs +1 -1
  50. package/build-module/components/media-editor-fine-rotation/index.mjs.map +2 -2
  51. package/build-module/components/media-editor-image-controls/index.mjs +47 -36
  52. package/build-module/components/media-editor-image-controls/index.mjs.map +2 -2
  53. package/build-module/components/media-editor-modal/index.mjs +17 -9
  54. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  55. package/build-module/hooks/use-crop-gesture-handlers.mjs +1 -1
  56. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +2 -2
  57. package/build-module/image-editor/core/interaction-controller.mjs +5 -0
  58. package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
  59. package/build-module/image-editor/react/components/cropper.mjs +3 -3
  60. package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
  61. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +1 -1
  62. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
  63. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +3 -1
  64. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
  65. package/build-module/image-editor/react/hooks/use-interaction.mjs +1 -1
  66. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
  67. package/build-module/state/composite-reducer.mjs +3 -3
  68. package/build-module/state/composite-reducer.mjs.map +2 -2
  69. package/build-module/state/index.mjs.map +1 -1
  70. package/build-module/state/media-editor-state-provider.mjs +1 -6
  71. package/build-module/state/media-editor-state-provider.mjs.map +2 -2
  72. package/build-module/state/use-media-editor-state.mjs +38 -36
  73. package/build-module/state/use-media-editor-state.mjs.map +2 -2
  74. package/build-module/store/actions.mjs +2 -0
  75. package/build-module/store/actions.mjs.map +2 -2
  76. package/build-module/store/reducer.mjs +3 -1
  77. package/build-module/store/reducer.mjs.map +2 -2
  78. package/build-module/store/selectors.mjs +4 -0
  79. package/build-module/store/selectors.mjs.map +2 -2
  80. package/build-style/style-rtl.css +5 -5
  81. package/build-style/style.css +5 -5
  82. package/build-types/components/media-editor/index.d.ts +2 -2
  83. package/build-types/components/media-editor/index.d.ts.map +1 -1
  84. package/build-types/components/media-editor/use-save-media-editor.d.ts +15 -3
  85. package/build-types/components/media-editor/use-save-media-editor.d.ts.map +1 -1
  86. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  87. package/build-types/components/media-editor-image-controls/index.d.ts.map +1 -1
  88. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  89. package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -1
  90. package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -1
  91. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  92. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
  93. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
  94. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
  95. package/build-types/state/composite-reducer.d.ts +5 -5
  96. package/build-types/state/composite-reducer.d.ts.map +1 -1
  97. package/build-types/state/index.d.ts +1 -1
  98. package/build-types/state/index.d.ts.map +1 -1
  99. package/build-types/state/media-editor-state-provider.d.ts +8 -16
  100. package/build-types/state/media-editor-state-provider.d.ts.map +1 -1
  101. package/build-types/state/use-media-editor-state.d.ts +37 -30
  102. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  103. package/build-types/store/actions.d.ts +9 -1
  104. package/build-types/store/actions.d.ts.map +1 -1
  105. package/build-types/store/reducer.d.ts +3 -0
  106. package/build-types/store/reducer.d.ts.map +1 -1
  107. package/build-types/store/selectors.d.ts +1 -0
  108. package/build-types/store/selectors.d.ts.map +1 -1
  109. package/package.json +27 -22
  110. package/src/components/media-editor/index.tsx +203 -59
  111. package/src/components/media-editor/test/restore-original.browser.test.tsx +227 -0
  112. package/src/components/media-editor/test/use-crop-options.jsdom.test.tsx +12 -10
  113. package/src/components/media-editor/use-crop-options.ts +1 -1
  114. package/src/components/media-editor/use-save-media-editor.ts +61 -20
  115. package/src/components/media-editor-canvas/index.tsx +7 -8
  116. package/src/components/media-editor-crop-panel/test/index.jsdom.test.tsx +2 -4
  117. package/src/components/media-editor-fine-rotation/index.tsx +1 -1
  118. package/src/components/media-editor-image-controls/index.tsx +41 -41
  119. package/src/components/media-editor-image-controls/test/index.jsdom.test.tsx +19 -13
  120. package/src/components/media-editor-modal/index.tsx +18 -10
  121. package/src/components/media-editor-modal/test/index.jsdom.test.tsx +18 -1
  122. package/src/hooks/use-crop-gesture-handlers.ts +3 -1
  123. package/src/image-editor/core/interaction-controller.ts +8 -0
  124. package/src/image-editor/core/test/interaction-controller.ts +45 -0
  125. package/src/image-editor/docs/architecture.md +6 -2
  126. package/src/image-editor/docs/recipes.md +8 -8
  127. package/src/image-editor/react/components/cropper.scss +5 -5
  128. package/src/image-editor/react/components/cropper.tsx +8 -3
  129. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +3 -1
  130. package/src/image-editor/react/components/test/cropper.browser.test.tsx +7 -5
  131. package/src/image-editor/react/hooks/use-aria-announcer.ts +3 -1
  132. package/src/image-editor/react/hooks/use-interaction.ts +3 -2
  133. package/src/state/composite-reducer.ts +6 -7
  134. package/src/state/index.ts +1 -1
  135. package/src/state/media-editor-state-provider.tsx +9 -22
  136. package/src/state/test/use-media-editor-state.browser.test.tsx +79 -0
  137. package/src/state/test/use-media-editor-state.jsdom.test.ts +126 -64
  138. package/src/state/use-media-editor-state.ts +79 -68
  139. package/src/store/actions.ts +9 -0
  140. package/src/store/reducer.ts +6 -1
  141. package/src/store/selectors.ts +4 -0
  142. package/tsconfig.build.tsbuildinfo +1 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/state/composite-reducer.ts"],
4
- "sourcesContent": ["import {\n\tcropperReducer,\n\tareCropperStatesEqual,\n\tcomputeInscribedRect,\n\ttype CropperState,\n} from '../image-editor';\nimport {\n\tDEFAULT_CROP_OPTIONS,\n\ttype CropOptionsSlice,\n\ttype MediaEditorAction,\n\ttype MediaEditorState,\n} from './types';\n\n/**\n * Pure composite reducer for the media editor.\n *\n * Delegates `CROPPER`-tagged actions to the framework-agnostic\n * `cropperReducer` and owns first-class transitions for the sidebar\n * `cropOptions` slice. `RESTORE_SNAPSHOT` replaces the whole composite\n * in one transaction (used by undo/redo).\n *\n * Note: this reducer carries NO history of its own. Snapshots and\n * stacks live in the `useMediaEditorState` hook that wraps it.\n *\n * @param state Current composite state.\n * @param action Action to apply.\n * @return Next composite state.\n */\nexport function mediaEditorReducer(\n\tstate: MediaEditorState,\n\taction: MediaEditorAction\n): MediaEditorState {\n\tswitch ( action.type ) {\n\t\tcase 'CROPPER': {\n\t\t\tconst nextCropper = cropperReducer( state.cropper, action.action );\n\t\t\tif ( nextCropper === state.cropper ) {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t\treturn { ...state, cropper: nextCropper };\n\t\t}\n\t\tcase 'SET_ASPECT_RATIO_VALUE': {\n\t\t\tconst { presetKey, resolved, visualSize } = action.payload;\n\t\t\t// Atomically: update the preset key AND reshape the\n\t\t\t// cropRect (when the ratio is non-Free and we have a\n\t\t\t// visualSize). One transaction = one undo entry.\n\t\t\tconst shouldReshape =\n\t\t\t\tresolved !== undefined &&\n\t\t\t\tresolved > 0 &&\n\t\t\t\tvisualSize.width > 0 &&\n\t\t\t\tvisualSize.height > 0;\n\t\t\tconst nextCropOptions: CropOptionsSlice = {\n\t\t\t\t...state.cropOptions,\n\t\t\t\taspectRatioValue: presetKey,\n\t\t\t};\n\t\t\tif ( ! shouldReshape ) {\n\t\t\t\tif ( state.cropOptions.aspectRatioValue === presetKey ) {\n\t\t\t\t\treturn state;\n\t\t\t\t}\n\t\t\t\treturn { ...state, cropOptions: nextCropOptions };\n\t\t\t}\n\t\t\tconst newCropRect = computeInscribedRect( resolved, visualSize );\n\t\t\tconst nextCropper = cropperReducer( state.cropper, {\n\t\t\t\ttype: 'SET_CROP_RECT',\n\t\t\t\tpayload: newCropRect,\n\t\t\t} );\n\t\t\treturn {\n\t\t\t\tcropper: nextCropper,\n\t\t\t\tcropOptions: nextCropOptions,\n\t\t\t};\n\t\t}\n\t\tcase 'RESET_CROP_OPTIONS': {\n\t\t\tif (\n\t\t\t\tstate.cropOptions.aspectRatioValue ===\n\t\t\t\tDEFAULT_CROP_OPTIONS.aspectRatioValue\n\t\t\t) {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tcropOptions: { ...DEFAULT_CROP_OPTIONS },\n\t\t\t};\n\t\t}\n\t\tcase 'RESTORE_SNAPSHOT':\n\t\t\treturn action.payload;\n\t\tcase 'VIEWPORT_ADJUST_CROP_RECT': {\n\t\t\tconst nextCropper = cropperReducer( state.cropper, {\n\t\t\t\ttype: 'SET_CROP_RECT',\n\t\t\t\tpayload: action.payload,\n\t\t\t} );\n\t\t\tif ( nextCropper === state.cropper ) {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t\treturn { ...state, cropper: nextCropper };\n\t\t}\n\t}\n}\n\n/**\n * Value-equality check for two composite states. Used by the history\n * machinery to dedup snapshots when an action turned out to be a no-op.\n *\n * @param a First composite state.\n * @param b Second composite state.\n * @return Whether `a` and `b` are value-equal across all slices.\n */\nexport function areMediaEditorStatesEqual(\n\ta: MediaEditorState,\n\tb: MediaEditorState\n): boolean {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\treturn (\n\t\tareCropperStatesEqual( a.cropper, b.cropper ) &&\n\t\ta.cropOptions.aspectRatioValue === b.cropOptions.aspectRatioValue\n\t);\n}\n\n/**\n * Build the initial composite state from optional partial overrides.\n *\n * @param initialCropper Initial cropper-slice fields to merge.\n * @param initialOptions Initial cropOptions-slice fields to merge.\n * @return Composite initial state.\n */\nexport function buildInitialMediaEditorState(\n\tinitialCropper: CropperState,\n\tinitialOptions?: Partial< CropOptionsSlice >\n): MediaEditorState {\n\treturn {\n\t\tcropper: initialCropper,\n\t\tcropOptions: { ...DEFAULT_CROP_OPTIONS, ...initialOptions },\n\t};\n}\n"],
5
- "mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AACP;AAAA,EACC;AAAA,OAIM;AAiBA,SAAS,mBACf,OACA,QACmB;AACnB,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,WAAW;AACf,YAAM,cAAc,eAAgB,MAAM,SAAS,OAAO,MAAO;AACjE,UAAK,gBAAgB,MAAM,SAAU;AACpC,eAAO;AAAA,MACR;AACA,aAAO,EAAE,GAAG,OAAO,SAAS,YAAY;AAAA,IACzC;AAAA,IACA,KAAK,0BAA0B;AAC9B,YAAM,EAAE,WAAW,UAAU,WAAW,IAAI,OAAO;AAInD,YAAM,gBACL,aAAa,UACb,WAAW,KACX,WAAW,QAAQ,KACnB,WAAW,SAAS;AACrB,YAAM,kBAAoC;AAAA,QACzC,GAAG,MAAM;AAAA,QACT,kBAAkB;AAAA,MACnB;AACA,UAAK,CAAE,eAAgB;AACtB,YAAK,MAAM,YAAY,qBAAqB,WAAY;AACvD,iBAAO;AAAA,QACR;AACA,eAAO,EAAE,GAAG,OAAO,aAAa,gBAAgB;AAAA,MACjD;AACA,YAAM,cAAc,qBAAsB,UAAU,UAAW;AAC/D,YAAM,cAAc,eAAgB,MAAM,SAAS;AAAA,QAClD,MAAM;AAAA,QACN,SAAS;AAAA,MACV,CAAE;AACF,aAAO;AAAA,QACN,SAAS;AAAA,QACT,aAAa;AAAA,MACd;AAAA,IACD;AAAA,IACA,KAAK,sBAAsB;AAC1B,UACC,MAAM,YAAY,qBAClB,qBAAqB,kBACpB;AACD,eAAO;AAAA,MACR;AACA,aAAO;AAAA,QACN,GAAG;AAAA,QACH,aAAa,EAAE,GAAG,qBAAqB;AAAA,MACxC;AAAA,IACD;AAAA,IACA,KAAK;AACJ,aAAO,OAAO;AAAA,IACf,KAAK,6BAA6B;AACjC,YAAM,cAAc,eAAgB,MAAM,SAAS;AAAA,QAClD,MAAM;AAAA,QACN,SAAS,OAAO;AAAA,MACjB,CAAE;AACF,UAAK,gBAAgB,MAAM,SAAU;AACpC,eAAO;AAAA,MACR;AACA,aAAO,EAAE,GAAG,OAAO,SAAS,YAAY;AAAA,IACzC;AAAA,EACD;AACD;AAUO,SAAS,0BACf,GACA,GACU;AACV,MAAK,MAAM,GAAI;AACd,WAAO;AAAA,EACR;AACA,SACC,sBAAuB,EAAE,SAAS,EAAE,OAAQ,KAC5C,EAAE,YAAY,qBAAqB,EAAE,YAAY;AAEnD;AASO,SAAS,6BACf,gBACA,gBACmB;AACnB,SAAO;AAAA,IACN,SAAS;AAAA,IACT,aAAa,EAAE,GAAG,sBAAsB,GAAG,eAAe;AAAA,EAC3D;AACD;",
4
+ "sourcesContent": ["import {\n\tcropperReducer,\n\tareCropperStatesEqual,\n\tcomputeInscribedRect,\n\ttype CropperState,\n} from '../image-editor';\nimport {\n\tDEFAULT_CROP_OPTIONS,\n\ttype CropOptionsSlice,\n\ttype MediaEditorAction,\n\ttype MediaEditorState,\n} from './types';\n\n/**\n * Pure composite reducer for the media editor.\n *\n * Delegates `CROPPER`-tagged actions to the framework-agnostic\n * `cropperReducer` and owns first-class transitions for the sidebar\n * `cropOptions` slice. `RESTORE_SNAPSHOT` replaces the whole composite\n * in one transaction (used by undo/redo).\n *\n * Note: this reducer carries NO history of its own. Snapshots and\n * stacks live in the `useMediaEditorState` hook that wraps it.\n *\n * @param state Current composite state.\n * @param action Action to apply.\n * @return Next composite state.\n */\nexport function mediaEditorReducer(\n\tstate: MediaEditorState,\n\taction: MediaEditorAction\n): MediaEditorState {\n\tswitch ( action.type ) {\n\t\tcase 'CROPPER': {\n\t\t\tconst nextCropper = cropperReducer( state.cropper, action.action );\n\t\t\tif ( nextCropper === state.cropper ) {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t\treturn { ...state, cropper: nextCropper };\n\t\t}\n\t\tcase 'SET_ASPECT_RATIO_VALUE': {\n\t\t\tconst { presetKey, resolved, visualSize } = action.payload;\n\t\t\t// Atomically: update the preset key AND reshape the\n\t\t\t// cropRect (when the ratio is non-Free and we have a\n\t\t\t// visualSize). One transaction = one undo entry.\n\t\t\tconst shouldReshape =\n\t\t\t\tresolved !== undefined &&\n\t\t\t\tresolved > 0 &&\n\t\t\t\tvisualSize.width > 0 &&\n\t\t\t\tvisualSize.height > 0;\n\t\t\tconst nextCropOptions: CropOptionsSlice = {\n\t\t\t\t...state.cropOptions,\n\t\t\t\taspectRatioValue: presetKey,\n\t\t\t};\n\t\t\tif ( ! shouldReshape ) {\n\t\t\t\tif ( state.cropOptions.aspectRatioValue === presetKey ) {\n\t\t\t\t\treturn state;\n\t\t\t\t}\n\t\t\t\treturn { ...state, cropOptions: nextCropOptions };\n\t\t\t}\n\t\t\tconst newCropRect = computeInscribedRect( resolved, visualSize );\n\t\t\tconst nextCropper = cropperReducer( state.cropper, {\n\t\t\t\ttype: 'SET_CROP_RECT',\n\t\t\t\tpayload: newCropRect,\n\t\t\t} );\n\t\t\treturn {\n\t\t\t\tcropper: nextCropper,\n\t\t\t\tcropOptions: nextCropOptions,\n\t\t\t};\n\t\t}\n\t\tcase 'RESET_CROP_OPTIONS': {\n\t\t\tif (\n\t\t\t\tstate.cropOptions.aspectRatioValue ===\n\t\t\t\tDEFAULT_CROP_OPTIONS.aspectRatioValue\n\t\t\t) {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t...state,\n\t\t\t\tcropOptions: { ...DEFAULT_CROP_OPTIONS },\n\t\t\t};\n\t\t}\n\t\tcase 'RESTORE_SNAPSHOT':\n\t\t\treturn action.payload;\n\t\tcase 'VIEWPORT_ADJUST_CROP_RECT': {\n\t\t\tconst nextCropper = cropperReducer( state.cropper, {\n\t\t\t\ttype: 'SET_CROP_RECT',\n\t\t\t\tpayload: action.payload,\n\t\t\t} );\n\t\t\tif ( nextCropper === state.cropper ) {\n\t\t\t\treturn state;\n\t\t\t}\n\t\t\treturn { ...state, cropper: nextCropper };\n\t\t}\n\t}\n}\n\n/**\n * Value-equality check for two composite states. Used by the history\n * machinery to dedup snapshots when an action turned out to be a no-op.\n *\n * @param a First composite state.\n * @param b Second composite state.\n * @return Whether `a` and `b` are value-equal across all slices.\n */\nexport function areMediaEditorStatesEqual(\n\ta: MediaEditorState,\n\tb: MediaEditorState\n): boolean {\n\tif ( a === b ) {\n\t\treturn true;\n\t}\n\treturn (\n\t\tareCropperStatesEqual( a.cropper, b.cropper ) &&\n\t\ta.cropOptions.aspectRatioValue === b.cropOptions.aspectRatioValue\n\t);\n}\n\n/**\n * Build the composite state a session starts from: the given cropper\n * slice and default crop options.\n *\n * @param cropper The cropper slice.\n * @return Composite initial state.\n */\nexport function buildInitialMediaEditorState(\n\tcropper: CropperState\n): MediaEditorState {\n\treturn {\n\t\tcropper,\n\t\tcropOptions: { ...DEFAULT_CROP_OPTIONS },\n\t};\n}\n"],
5
+ "mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAEM;AACP;AAAA,EACC;AAAA,OAI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,IACzC;AAAA,EACD;AACD;AAUO,SAAS,0BACf,GACA,GACU;AACV,MAAK,MAAM,GAAI;AACd,WAAO;AAAA,EACR;AACA,SACC,sBAAuB,EAAE,SAAS,EAAE,OAAQ,KAC5C,EAAE,YAAY,qBAAqB,EAAE,YAAY;AAEnD;AASO,SAAS,6BACf,SACmB;AACnB,SAAO;AAAA,IACN;AAAA,IACA,aAAa,EAAE,GAAG,qBAAqB;AAAA,EACxC;AACD;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/state/index.ts"],
4
- "sourcesContent": ["export {\n\tuseMediaEditorState,\n\tresolveAspectRatio,\n} from './use-media-editor-state';\nexport type { MediaEditorController } from './use-media-editor-state';\nexport {\n\tMediaEditorStateProvider,\n\tuseMediaEditor,\n} from './media-editor-state-provider';\nexport {\n\tmediaEditorReducer,\n\tareMediaEditorStatesEqual,\n\tbuildInitialMediaEditorState,\n} from './composite-reducer';\nexport { DEFAULT_CROP_OPTIONS } from './types';\nexport type {\n\tCropOptionsSlice,\n\tMediaEditorState,\n\tMediaEditorAction,\n} from './types';\n"],
4
+ "sourcesContent": ["export {\n\tuseMediaEditorState,\n\tresolveAspectRatio,\n} from './use-media-editor-state';\nexport type { MediaEditorSession } from './use-media-editor-state';\nexport {\n\tMediaEditorStateProvider,\n\tuseMediaEditor,\n} from './media-editor-state-provider';\nexport {\n\tmediaEditorReducer,\n\tareMediaEditorStatesEqual,\n\tbuildInitialMediaEditorState,\n} from './composite-reducer';\nexport { DEFAULT_CROP_OPTIONS } from './types';\nexport type {\n\tCropOptionsSlice,\n\tMediaEditorState,\n\tMediaEditorAction,\n} from './types';\n"],
5
5
  "mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,OACM;AAEP;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,4BAA4B;",
6
6
  "names": []
7
7
  }
@@ -8,14 +8,9 @@ var MediaEditorStateContext = createContext(
8
8
  null
9
9
  );
10
10
  function MediaEditorStateProvider({
11
- initialCropperState,
12
- initialCropOptions,
13
11
  children
14
12
  }) {
15
- const controller = useMediaEditorState({
16
- cropper: initialCropperState,
17
- cropOptions: initialCropOptions
18
- });
13
+ const controller = useMediaEditorState();
19
14
  return /* @__PURE__ */ jsx(MediaEditorStateContext.Provider, { value: controller, children });
20
15
  }
21
16
  function useMediaEditor() {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/state/media-editor-state-provider.tsx"],
4
- "sourcesContent": ["import { createContext, useContext } from '@wordpress/element';\nimport type { CropperState } from '../image-editor';\nimport {\n\tuseMediaEditorState,\n\ttype MediaEditorController,\n} from './use-media-editor-state';\nimport type { CropOptionsSlice } from './types';\n\nconst MediaEditorStateContext = createContext< MediaEditorController | null >(\n\tnull\n);\n\ninterface MediaEditorStateProviderProps {\n\t/** Optional cropper-slice initial state. */\n\tinitialCropperState?: Partial< CropperState >;\n\t/** Optional cropOptions-slice initial state. */\n\tinitialCropOptions?: Partial< CropOptionsSlice >;\n\t/** Child components. */\n\tchildren: React.ReactNode;\n}\n\n/**\n * Provider that vends the composite media-editor controller via\n * context. Wrap the media editor in this so every consumer\n * (canvas, toolbar, sidebar) reads from the same store.\n *\n * @param props\n * @param props.initialCropperState\n * @param props.initialCropOptions\n * @param props.children\n */\nexport function MediaEditorStateProvider( {\n\tinitialCropperState,\n\tinitialCropOptions,\n\tchildren,\n}: MediaEditorStateProviderProps ) {\n\tconst controller = useMediaEditorState( {\n\t\tcropper: initialCropperState,\n\t\tcropOptions: initialCropOptions,\n\t} );\n\n\treturn (\n\t\t<MediaEditorStateContext.Provider value={ controller }>\n\t\t\t{ children }\n\t\t</MediaEditorStateContext.Provider>\n\t);\n}\n\n/**\n * Consume the composite media-editor controller. Throws if used\n * outside a `<MediaEditorStateProvider>`.\n *\n * @return The composite controller.\n */\nexport function useMediaEditor(): MediaEditorController {\n\tconst context = useContext( MediaEditorStateContext );\n\tif ( ! context ) {\n\t\tthrow new Error(\n\t\t\t'useMediaEditor must be used within a MediaEditorStateProvider.'\n\t\t);\n\t}\n\treturn context;\n}\n"],
5
- "mappings": ";AAAA,SAAS,eAAe,kBAAkB;AAE1C;AAAA,EACC;AAAA,OAEM;AAqCL;AAlCF,IAAM,0BAA0B;AAAA,EAC/B;AACD;AAqBO,SAAS,yBAA0B;AAAA,EACzC;AAAA,EACA;AAAA,EACA;AACD,GAAmC;AAClC,QAAM,aAAa,oBAAqB;AAAA,IACvC,SAAS;AAAA,IACT,aAAa;AAAA,EACd,CAAE;AAEF,SACC,oBAAC,wBAAwB,UAAxB,EAAiC,OAAQ,YACvC,UACH;AAEF;AAQO,SAAS,iBAAwC;AACvD,QAAM,UAAU,WAAY,uBAAwB;AACpD,MAAK,CAAE,SAAU;AAChB,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;",
4
+ "sourcesContent": ["import { createContext, useContext } from '@wordpress/element';\nimport {\n\tuseMediaEditorState,\n\ttype MediaEditorSession,\n} from './use-media-editor-state';\n\nconst MediaEditorStateContext = createContext< MediaEditorSession | null >(\n\tnull\n);\n\ninterface MediaEditorStateProviderProps {\n\t/** Child components. */\n\tchildren: React.ReactNode;\n}\n\n/**\n * Provider that vends the media editor session via context. Wrap\n * the media editor in this so every consumer (canvas, toolbar,\n * sidebar) reads from the same store.\n *\n * @param props\n * @param props.children\n */\nexport function MediaEditorStateProvider( {\n\tchildren,\n}: MediaEditorStateProviderProps ) {\n\tconst controller = useMediaEditorState();\n\n\treturn (\n\t\t<MediaEditorStateContext.Provider value={ controller }>\n\t\t\t{ children }\n\t\t</MediaEditorStateContext.Provider>\n\t);\n}\n\n/**\n * Consume the media editor session. Throws if used\n * outside a `<MediaEditorStateProvider>`.\n *\n * @return The media editor session.\n */\nexport function useMediaEditor(): MediaEditorSession {\n\tconst context = useContext( MediaEditorStateContext );\n\tif ( ! context ) {\n\t\tthrow new Error(\n\t\t\t'useMediaEditor must be used within a MediaEditorStateProvider.'\n\t\t);\n\t}\n\treturn context;\n}\n"],
5
+ "mappings": ";AAAA,SAAS,eAAe,kBAAkB;AAC1C;AAAA,EACC;AAAA,OAEM;AAyBL;AAvBF,IAAM,0BAA0B;AAAA,EAC/B;AACD;AAeO,SAAS,yBAA0B;AAAA,EACzC;AACD,GAAmC;AAClC,QAAM,aAAa,oBAAoB;AAEvC,SACC,oBAAC,wBAAwB,UAAxB,EAAiC,OAAQ,YACvC,UACH;AAEF;AAQO,SAAS,iBAAqC;AACpD,QAAM,UAAU,WAAY,uBAAwB;AACpD,MAAK,CAAE,SAAU;AAChB,UAAM,IAAI;AAAA,MACT;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -38,17 +38,11 @@ function resolveAspectRatio(presetKey, cropperImage) {
38
38
  function areCropperImagesEqual(a, b) {
39
39
  return a?.src === b?.src && a?.naturalWidth === b?.naturalWidth && a?.naturalHeight === b?.naturalHeight;
40
40
  }
41
- function useMediaEditorState(initialState) {
41
+ function useMediaEditorState() {
42
42
  const [state, dispatch] = useReducer(
43
43
  mediaEditorReducer,
44
44
  null,
45
- () => buildInitialMediaEditorState(
46
- enforceContainment({
47
- ...DEFAULT_STATE,
48
- ...initialState?.cropper
49
- }),
50
- initialState?.cropOptions
51
- )
45
+ () => buildInitialMediaEditorState({ ...DEFAULT_STATE })
52
46
  );
53
47
  const [initialBaseline, setInitialBaseline] = useState(() => state);
54
48
  const stateRef = useRef(state);
@@ -117,17 +111,15 @@ function useMediaEditorState(initialState) {
117
111
  ),
118
112
  [dispatchCropperAction]
119
113
  );
120
- const setImage = useCallback((image) => {
114
+ const setSourceImage = useCallback((image) => {
121
115
  if (areCropperImagesEqual(stateRef.current.cropper.image, image)) {
122
116
  return;
123
117
  }
124
- const action = {
125
- type: "CROPPER",
126
- action: { type: "SET_IMAGE", payload: image }
127
- };
128
- const next = mediaEditorReducer(stateRef.current, action);
118
+ const next = buildInitialMediaEditorState(
119
+ enforceContainment({ ...DEFAULT_STATE, image })
120
+ );
129
121
  stateRef.current = next;
130
- dispatch(action);
122
+ dispatch({ type: "RESTORE_SNAPSHOT", payload: next });
131
123
  setInitialBaseline(next);
132
124
  isGestureOpenRef.current = false;
133
125
  gestureSnapshotRef.current = null;
@@ -212,7 +204,7 @@ function useMediaEditorState(initialState) {
212
204
  (mimeType, quality) => {
213
205
  if (!state.cropper.image) {
214
206
  return Promise.reject(
215
- new Error("No image loaded — call setImage first.")
207
+ new Error("No image loaded — call setSourceImage first.")
216
208
  );
217
209
  }
218
210
  return exportCroppedImage(
@@ -224,52 +216,62 @@ function useMediaEditorState(initialState) {
224
216
  },
225
217
  [state.cropper]
226
218
  );
227
- const controller = useMemo(
219
+ const cropper = useMemo(
228
220
  () => ({
229
- // CropperController surface (state is the cropper slice so a
230
- // <Cropper> takes this controller as-is).
231
221
  ...cropperSetters,
232
222
  state: state.cropper,
233
- setImage,
223
+ setImage: setSourceImage,
234
224
  reset,
235
- isDirty,
225
+ isDirty: isCropperDirty,
226
+ getCroppedImage,
227
+ setVisualSize,
228
+ adjustCropRectForViewport
229
+ }),
230
+ [
231
+ cropperSetters,
232
+ state.cropper,
233
+ setSourceImage,
234
+ reset,
235
+ isCropperDirty,
236
236
  getCroppedImage,
237
- // Composite extensions
237
+ setVisualSize,
238
+ adjustCropRectForViewport
239
+ ]
240
+ );
241
+ const session = useMemo(
242
+ () => ({
243
+ cropper,
238
244
  cropOptions: state.cropOptions,
239
245
  setAspectRatioValue,
240
246
  resetCropOptions,
241
- isCropperDirty,
247
+ setSourceImage,
248
+ isDirty,
249
+ // Only geometry changes the saved image so far.
250
+ hasOutputEdits: isCropperDirty,
242
251
  hasUndo,
243
252
  hasRedo,
244
253
  undo,
245
254
  redo,
246
255
  beginGesture,
247
- endGesture,
248
- setVisualSize,
249
- adjustCropRectForViewport
256
+ endGesture
250
257
  }),
251
258
  [
252
- cropperSetters,
253
- state.cropper,
254
- setImage,
255
- reset,
256
- isDirty,
257
- getCroppedImage,
259
+ cropper,
258
260
  state.cropOptions,
259
261
  setAspectRatioValue,
260
262
  resetCropOptions,
263
+ setSourceImage,
264
+ isDirty,
261
265
  isCropperDirty,
262
266
  hasUndo,
263
267
  hasRedo,
264
268
  undo,
265
269
  redo,
266
270
  beginGesture,
267
- endGesture,
268
- setVisualSize,
269
- adjustCropRectForViewport
271
+ endGesture
270
272
  ]
271
273
  );
272
- return controller;
274
+ return session;
273
275
  }
274
276
  export {
275
277
  resolveAspectRatio,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/state/use-media-editor-state.ts"],
4
- "sourcesContent": ["import {\n\tuseCallback,\n\tuseMemo,\n\tuseReducer,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport {\n\tDEFAULT_STATE,\n\tORIGINAL_ASPECT_RATIO,\n\tareCropperStatesEqual,\n\tbuildCropperSetters,\n\tenforceContainment,\n\texportCroppedImage,\n\ttype CropperAction,\n\ttype CropperController,\n\ttype CropperState,\n\ttype NormalizedRect,\n\ttype Size,\n} from '../image-editor';\nimport {\n\tmediaEditorReducer,\n\tareMediaEditorStatesEqual,\n\tbuildInitialMediaEditorState,\n} from './composite-reducer';\nimport type {\n\tCropOptionsSlice,\n\tMediaEditorAction,\n\tMediaEditorState,\n} from './types';\n\n/**\n * Resolve an aspect-ratio preset value (the string the dropdown\n * round-trips) into a numeric width/height ratio for the cropper.\n *\n * - `'0'` → `undefined` (Free; no lock)\n * - `'-1'` (Original) → image's natural width / height, or `undefined`\n * if no image is loaded.\n * - Any positive decimal → the parsed number.\n *\n * Centralizing here means the dropdown, the action dispatcher, and\n * the test harness all resolve the same way.\n *\n * @param presetKey Preset value from the dropdown.\n * @param cropperImage The cropper's loaded image, or `null`.\n * @return The resolved ratio, or `undefined` for Free / unresolvable.\n */\nexport function resolveAspectRatio(\n\tpresetKey: string,\n\tcropperImage: CropperState[ 'image' ] | null\n): number | undefined {\n\tconst num = parseFloat( presetKey );\n\tif ( num === 0 || Number.isNaN( num ) ) {\n\t\treturn undefined;\n\t}\n\tif ( num === ORIGINAL_ASPECT_RATIO ) {\n\t\tif (\n\t\t\tcropperImage &&\n\t\t\tcropperImage.naturalWidth > 0 &&\n\t\t\tcropperImage.naturalHeight > 0\n\t\t) {\n\t\t\treturn cropperImage.naturalWidth / cropperImage.naturalHeight;\n\t\t}\n\t\treturn undefined;\n\t}\n\tif ( num > 0 ) {\n\t\treturn num;\n\t}\n\treturn undefined;\n}\n\nfunction areCropperImagesEqual(\n\ta: CropperState[ 'image' ],\n\tb: CropperState[ 'image' ]\n): boolean {\n\treturn (\n\t\ta?.src === b?.src &&\n\t\ta?.naturalWidth === b?.naturalWidth &&\n\t\ta?.naturalHeight === b?.naturalHeight\n\t);\n}\n\n/**\n * The composite controller exposed by `useMediaEditorState`.\n *\n * Satisfies `CropperController` (so a `<Cropper>` can take this\n * controller directly via the `controller` prop) and adds slice\n * setters, undo/redo, gesture boundaries, and viewport reporting.\n */\nexport interface MediaEditorController extends CropperController {\n\t/** The cropOptions slice. */\n\tcropOptions: CropOptionsSlice;\n\t/** Set the aspect-ratio preset. Atomic with the cropRect reshape. */\n\tsetAspectRatioValue: ( presetKey: string ) => void;\n\t/** Reset cropOptions to defaults. */\n\tresetCropOptions: () => void;\n\t/**\n\t * Whether the cropper geometry differs from the initial baseline.\n\t */\n\tisCropperDirty: boolean;\n\t/** Whether there's an undoable change in history. */\n\thasUndo: boolean;\n\t/** Whether there's a redoable change in history. */\n\thasRedo: boolean;\n\t/** Undo the last committed action across all slices. */\n\tundo: () => void;\n\t/** Redo the last undone action across all slices. */\n\tredo: () => void;\n\t/**\n\t * Open a gesture boundary. During a gesture all state-changing\n\t * actions coalesce into one undo entry — the snapshot taken at\n\t * `beginGesture`. Pair with `endGesture` on pointer-up / key-up.\n\t */\n\tbeginGesture: () => void;\n\t/** Close a gesture boundary and commit the pre-gesture snapshot. */\n\tendGesture: () => void;\n\t/**\n\t * Report the current rendered image size to the controller. The\n\t * Cropper component calls this whenever its visualSize changes;\n\t * the controller needs it to compute aspect-ratio reshapes.\n\t */\n\tsetVisualSize: ( size: Size ) => void;\n\t/**\n\t * Reshape the cropRect in response to a viewport change. Behaves\n\t * like `setCropRect` but does NOT record an undo entry — window\n\t * resizes aren't editor actions.\n\t */\n\tadjustCropRectForViewport: ( rect: NormalizedRect ) => void;\n}\n\ninterface InitialMediaEditorState {\n\tcropper?: Partial< CropperState >;\n\tcropOptions?: Partial< CropOptionsSlice >;\n}\n\n/**\n * Composite store for the media editor.\n *\n * Owns the only undo/redo history for the editor. Cropper geometry\n * actions and sidebar cropOptions actions flow through the same\n * reducer and the same history stack.\n *\n * History semantics:\n * - Each action's pre-state is pushed to the undo stack before the\n * action commits, unless a gesture is open or the action is a\n * no-op (post-state value-equal to pre-state).\n * - During a gesture (`beginGesture` → `endGesture`) all mutations\n * coalesce: only the pre-gesture snapshot is pushed, at gesture\n * end. Any pending gesture is flushed on undo/redo.\n * - Viewport-driven cropRect reshapes (window resize) use a\n * dedicated non-recording dispatch path so they never produce\n * undo entries.\n *\n * `isDirty` tracks the full editor session, including undoable UI\n * state. Use `isCropperDirty` when deciding whether the image output\n * needs saving.\n *\n * @param initialState Optional seed for the cropper and cropOptions slices.\n * @return The composite controller.\n */\nexport function useMediaEditorState(\n\tinitialState?: InitialMediaEditorState\n): MediaEditorController {\n\tconst [ state, dispatch ] = useReducer( mediaEditorReducer, null, () =>\n\t\tbuildInitialMediaEditorState(\n\t\t\tenforceContainment( {\n\t\t\t\t...DEFAULT_STATE,\n\t\t\t\t...initialState?.cropper,\n\t\t\t} ),\n\t\t\tinitialState?.cropOptions\n\t\t)\n\t);\n\n\t// The \"clean\" snapshot the current state is compared against for\n\t// `isDirty`. Stored in state (not a ref) so the comparison reads\n\t// a value, not a ref's `current`. `setImage` refreshes this when\n\t// a new image establishes a fresh baseline.\n\tconst [ initialBaseline, setInitialBaseline ] =\n\t\tuseState< MediaEditorState >( () => state );\n\n\t// Latest-state ref used by setters that need to read fresh state\n\t// (focal-point zoom, dispatch wrapper). Every mutation path\n\t// (`dispatchWithHistory`, `setImage`, `undo`, `redo`) writes this\n\t// synchronously, so multiple actions in one event see the latest\n\t// reducer output before React commits.\n\tconst stateRef = useRef( state );\n\tconst visualSizeRef = useRef< Size >( { width: 0, height: 0 } );\n\n\t// History stacks: full composite snapshots. Refs avoid re-renders\n\t// on every push; a boolean state pair drives the enabled/disabled\n\t// indicators for undo/redo buttons.\n\tconst historyRef = useRef< MediaEditorState[] >( [] );\n\tconst redoStackRef = useRef< MediaEditorState[] >( [] );\n\tconst [ hasUndo, setHasUndo ] = useState( false );\n\tconst [ hasRedo, setHasRedo ] = useState( false );\n\n\t// Gesture state. While open, the first non-no-op action captures\n\t// the pre-gesture snapshot; subsequent actions don't push.\n\t// `endGesture` pushes the captured snapshot (or nothing, if the\n\t// gesture produced no changes).\n\tconst isGestureOpenRef = useRef( false );\n\tconst gestureSnapshotRef = useRef< MediaEditorState | null >( null );\n\n\tconst pushSnapshot = useCallback( ( snapshot: MediaEditorState ) => {\n\t\tconst last = historyRef.current[ historyRef.current.length - 1 ];\n\t\tif ( last && areMediaEditorStatesEqual( last, snapshot ) ) {\n\t\t\treturn;\n\t\t}\n\t\thistoryRef.current = [ ...historyRef.current, snapshot ];\n\t\tredoStackRef.current = [];\n\t\tsetHasUndo( true );\n\t\tsetHasRedo( false );\n\t}, [] );\n\n\t// Core dispatch wrapper. Synchronously computes the post-state via\n\t// the pure reducer so we can skip history pushes for no-op actions\n\t// and keep `stateRef` in lockstep with React's pending state.\n\tconst dispatchWithHistory = useCallback(\n\t\t( action: MediaEditorAction, recordHistory = true ) => {\n\t\t\tconst preState = stateRef.current;\n\t\t\tconst postState = mediaEditorReducer( preState, action );\n\t\t\tif ( recordHistory ) {\n\t\t\t\tif ( ! areMediaEditorStatesEqual( preState, postState ) ) {\n\t\t\t\t\tif ( isGestureOpenRef.current ) {\n\t\t\t\t\t\tif ( gestureSnapshotRef.current === null ) {\n\t\t\t\t\t\t\tgestureSnapshotRef.current = preState;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpushSnapshot( preState );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tstateRef.current = postState;\n\t\t\tdispatch( action );\n\t\t},\n\t\t[ pushSnapshot ]\n\t);\n\n\tconst beginGesture = useCallback( () => {\n\t\tif ( isGestureOpenRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tisGestureOpenRef.current = true;\n\t\tgestureSnapshotRef.current = null;\n\t}, [] );\n\n\t// Close a gesture (or flush a pending one before undo/redo).\n\t// Pushes the pre-gesture snapshot only if it differs from current\n\t// state. Safe to call when no gesture is open.\n\tconst endGesture = useCallback( () => {\n\t\tconst snapshot = gestureSnapshotRef.current;\n\t\tif (\n\t\t\tsnapshot &&\n\t\t\t! areMediaEditorStatesEqual( snapshot, stateRef.current )\n\t\t) {\n\t\t\tpushSnapshot( snapshot );\n\t\t}\n\t\tgestureSnapshotRef.current = null;\n\t\tisGestureOpenRef.current = false;\n\t}, [ pushSnapshot ] );\n\n\t// =====================================================================\n\t// Cropper-slice setters (built from the shared factory so the pure\n\t// hook and this composite stay in lockstep — add a setter in\n\t// `buildCropperSetters` once and both hooks get it).\n\t// =====================================================================\n\n\tconst dispatchCropperAction = useCallback(\n\t\t( action: CropperAction ) => {\n\t\t\tdispatchWithHistory( { type: 'CROPPER', action } );\n\t\t},\n\t\t[ dispatchWithHistory ]\n\t);\n\n\tconst cropperSetters = useMemo(\n\t\t() =>\n\t\t\tbuildCropperSetters(\n\t\t\t\tdispatchCropperAction,\n\t\t\t\t() => stateRef.current.cropper\n\t\t\t),\n\t\t[ dispatchCropperAction ]\n\t);\n\n\tconst setImage = useCallback( ( image: CropperState[ 'image' ] ) => {\n\t\tif ( areCropperImagesEqual( stateRef.current.cropper.image, image ) ) {\n\t\t\treturn;\n\t\t}\n\t\t// New image = fresh canvas: clear history, refresh the\n\t\t// initial snapshot so isDirty starts at false.\n\t\tconst action = {\n\t\t\ttype: 'CROPPER' as const,\n\t\t\taction: { type: 'SET_IMAGE' as const, payload: image },\n\t\t};\n\t\tconst next = mediaEditorReducer( stateRef.current, action );\n\t\tstateRef.current = next;\n\t\tdispatch( action );\n\t\tsetInitialBaseline( next );\n\t\tisGestureOpenRef.current = false;\n\t\tgestureSnapshotRef.current = null;\n\t\thistoryRef.current = [];\n\t\tredoStackRef.current = [];\n\t\tsetHasUndo( false );\n\t\tsetHasRedo( false );\n\t}, [] );\n\n\tconst reset = useCallback(\n\t\t( resetState?: Partial< CropperState > ) => {\n\t\t\tdispatchWithHistory( {\n\t\t\t\ttype: 'CROPPER',\n\t\t\t\taction: { type: 'RESET', payload: resetState },\n\t\t\t} );\n\t\t},\n\t\t[ dispatchWithHistory ]\n\t);\n\n\t// =====================================================================\n\t// CropOptions-slice setters\n\t// =====================================================================\n\n\tconst setAspectRatioValue = useCallback(\n\t\t( presetKey: string ) => {\n\t\t\tconst resolved = resolveAspectRatio(\n\t\t\t\tpresetKey,\n\t\t\t\tstateRef.current.cropper.image\n\t\t\t);\n\t\t\tdispatchWithHistory( {\n\t\t\t\ttype: 'SET_ASPECT_RATIO_VALUE',\n\t\t\t\tpayload: {\n\t\t\t\t\tpresetKey,\n\t\t\t\t\tresolved,\n\t\t\t\t\tvisualSize: visualSizeRef.current,\n\t\t\t\t},\n\t\t\t} );\n\t\t},\n\t\t[ dispatchWithHistory ]\n\t);\n\n\tconst resetCropOptions = useCallback( () => {\n\t\tdispatchWithHistory( { type: 'RESET_CROP_OPTIONS' } );\n\t}, [ dispatchWithHistory ] );\n\n\t// =====================================================================\n\t// History\n\t// =====================================================================\n\n\tconst undo = useCallback( () => {\n\t\tendGesture();\n\t\tconst prev = historyRef.current[ historyRef.current.length - 1 ];\n\t\tif ( ! prev ) {\n\t\t\treturn;\n\t\t}\n\t\tredoStackRef.current = [ stateRef.current, ...redoStackRef.current ];\n\t\thistoryRef.current = historyRef.current.slice( 0, -1 );\n\t\tsetHasUndo( historyRef.current.length > 0 );\n\t\tsetHasRedo( true );\n\t\tstateRef.current = prev;\n\t\tdispatch( { type: 'RESTORE_SNAPSHOT', payload: prev } );\n\t}, [ endGesture ] );\n\n\tconst redo = useCallback( () => {\n\t\tendGesture();\n\t\tconst next = redoStackRef.current[ 0 ];\n\t\tif ( ! next ) {\n\t\t\treturn;\n\t\t}\n\t\thistoryRef.current = [ ...historyRef.current, stateRef.current ];\n\t\tredoStackRef.current = redoStackRef.current.slice( 1 );\n\t\tsetHasUndo( true );\n\t\tsetHasRedo( redoStackRef.current.length > 0 );\n\t\tstateRef.current = next;\n\t\tdispatch( { type: 'RESTORE_SNAPSHOT', payload: next } );\n\t}, [ endGesture ] );\n\n\t// =====================================================================\n\t// Viewport\n\t// =====================================================================\n\n\tconst setVisualSize = useCallback( ( size: Size ) => {\n\t\tvisualSizeRef.current = size;\n\t}, [] );\n\n\tconst adjustCropRectForViewport = useCallback(\n\t\t( rect: NormalizedRect ) => {\n\t\t\tdispatchWithHistory(\n\t\t\t\t{ type: 'VIEWPORT_ADJUST_CROP_RECT', payload: rect },\n\t\t\t\tfalse\n\t\t\t);\n\t\t},\n\t\t[ dispatchWithHistory ]\n\t);\n\n\t// =====================================================================\n\t// Derived\n\t// =====================================================================\n\n\tconst isDirty = ! areMediaEditorStatesEqual( state, initialBaseline );\n\tconst isCropperDirty = ! areCropperStatesEqual(\n\t\tstate.cropper,\n\t\tinitialBaseline.cropper\n\t);\n\n\tconst getCroppedImage = useCallback(\n\t\t( mimeType?: string, quality?: number ): Promise< Blob > => {\n\t\t\tif ( ! state.cropper.image ) {\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew Error( 'No image loaded — call setImage first.' )\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn exportCroppedImage(\n\t\t\t\tstate.cropper.image.src,\n\t\t\t\tstate.cropper,\n\t\t\t\tmimeType,\n\t\t\t\tquality\n\t\t\t);\n\t\t},\n\t\t[ state.cropper ]\n\t);\n\n\tconst controller = useMemo< MediaEditorController >(\n\t\t() => ( {\n\t\t\t// CropperController surface (state is the cropper slice so a\n\t\t\t// <Cropper> takes this controller as-is).\n\t\t\t...cropperSetters,\n\t\t\tstate: state.cropper,\n\t\t\tsetImage,\n\t\t\treset,\n\t\t\tisDirty,\n\t\t\tgetCroppedImage,\n\t\t\t// Composite extensions\n\t\t\tcropOptions: state.cropOptions,\n\t\t\tsetAspectRatioValue,\n\t\t\tresetCropOptions,\n\t\t\tisCropperDirty,\n\t\t\thasUndo,\n\t\t\thasRedo,\n\t\t\tundo,\n\t\t\tredo,\n\t\t\tbeginGesture,\n\t\t\tendGesture,\n\t\t\tsetVisualSize,\n\t\t\tadjustCropRectForViewport,\n\t\t} ),\n\t\t[\n\t\t\tcropperSetters,\n\t\t\tstate.cropper,\n\t\t\tsetImage,\n\t\t\treset,\n\t\t\tisDirty,\n\t\t\tgetCroppedImage,\n\t\t\tstate.cropOptions,\n\t\t\tsetAspectRatioValue,\n\t\t\tresetCropOptions,\n\t\t\tisCropperDirty,\n\t\t\thasUndo,\n\t\t\thasRedo,\n\t\t\tundo,\n\t\t\tredo,\n\t\t\tbeginGesture,\n\t\t\tendGesture,\n\t\t\tsetVisualSize,\n\t\t\tadjustCropRectForViewport,\n\t\t]\n\t);\n\treturn controller;\n}\n"],
5
- "mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAMM;AACP;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAuBA,SAAS,mBACf,WACA,cACqB;AACrB,QAAM,MAAM,WAAY,SAAU;AAClC,MAAK,QAAQ,KAAK,OAAO,MAAO,GAAI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AA;AAAA;AAAA,MAGP,GAAG;AAAA,MACH,OAAO,MAAM;AAAA,MACb;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAEA,aAAa,MAAM;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;",
4
+ "sourcesContent": ["import {\n\tuseCallback,\n\tuseMemo,\n\tuseReducer,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport {\n\tDEFAULT_STATE,\n\tORIGINAL_ASPECT_RATIO,\n\tareCropperStatesEqual,\n\tbuildCropperSetters,\n\tenforceContainment,\n\texportCroppedImage,\n\ttype CropperAction,\n\ttype CropperController,\n\ttype CropperState,\n\ttype NormalizedRect,\n\ttype Size,\n} from '../image-editor';\nimport {\n\tmediaEditorReducer,\n\tareMediaEditorStatesEqual,\n\tbuildInitialMediaEditorState,\n} from './composite-reducer';\nimport type {\n\tCropOptionsSlice,\n\tMediaEditorAction,\n\tMediaEditorState,\n} from './types';\n\n/**\n * Resolve an aspect-ratio preset value (the string the dropdown\n * round-trips) into a numeric width/height ratio for the cropper.\n *\n * - `'0'` → `undefined` (Free; no lock)\n * - `'-1'` (Original) → image's natural width / height, or `undefined`\n * if no image is loaded.\n * - Any positive decimal → the parsed number.\n *\n * Centralizing here means the dropdown, the action dispatcher, and\n * the test harness all resolve the same way.\n *\n * @param presetKey Preset value from the dropdown.\n * @param cropperImage The cropper's loaded image, or `null`.\n * @return The resolved ratio, or `undefined` for Free / unresolvable.\n */\nexport function resolveAspectRatio(\n\tpresetKey: string,\n\tcropperImage: CropperState[ 'image' ] | null\n): number | undefined {\n\tconst num = parseFloat( presetKey );\n\tif ( num === 0 || Number.isNaN( num ) ) {\n\t\treturn undefined;\n\t}\n\tif ( num === ORIGINAL_ASPECT_RATIO ) {\n\t\tif (\n\t\t\tcropperImage &&\n\t\t\tcropperImage.naturalWidth > 0 &&\n\t\t\tcropperImage.naturalHeight > 0\n\t\t) {\n\t\t\treturn cropperImage.naturalWidth / cropperImage.naturalHeight;\n\t\t}\n\t\treturn undefined;\n\t}\n\tif ( num > 0 ) {\n\t\treturn num;\n\t}\n\treturn undefined;\n}\n\nfunction areCropperImagesEqual(\n\ta: CropperState[ 'image' ],\n\tb: CropperState[ 'image' ]\n): boolean {\n\treturn (\n\t\ta?.src === b?.src &&\n\t\ta?.naturalWidth === b?.naturalWidth &&\n\t\ta?.naturalHeight === b?.naturalHeight\n\t);\n}\n\n/**\n * The media editor session exposed by `useMediaEditorState`.\n *\n * The session owns what is being edited and how: the source image,\n * every editing slice, the shared undo/redo history, gesture\n * boundaries, and whether the edits change the saved image. The\n * cropper is one participant in the session — `cropper` is a\n * geometry-only controller that a `<Cropper>` takes via its\n * `controller` prop — rather than the session itself.\n */\nexport interface MediaEditorSession {\n\t/**\n\t * Geometry controller for the cropper slice. Its setters record\n\t * history in the session; its `isDirty` covers geometry only.\n\t * Its `setImage` is `setSourceImage`, so the `<Cropper>` reporting\n\t * a newly loaded image starts a fresh session.\n\t */\n\tcropper: CropperController;\n\t/** The cropOptions slice. */\n\tcropOptions: CropOptionsSlice;\n\t/** Set the aspect-ratio preset. Atomic with the cropRect reshape. */\n\tsetAspectRatioValue: ( presetKey: string ) => void;\n\t/** Reset cropOptions to defaults. */\n\tresetCropOptions: () => void;\n\t/**\n\t * Replace the image being edited. A different image starts a\n\t * fresh session: default geometry and crop options, a clean\n\t * baseline, and no history. Reporting the same image again is a\n\t * no-op.\n\t */\n\tsetSourceImage: ( image: CropperState[ 'image' ] ) => void;\n\t/**\n\t * Whether anything in the session differs from its baseline,\n\t * including editor-only state such as the aspect-ratio preset.\n\t */\n\tisDirty: boolean;\n\t/**\n\t * Whether the edits change the saved image, so saving has to\n\t * produce new image output rather than only metadata.\n\t */\n\thasOutputEdits: boolean;\n\t/** Whether there's an undoable change in history. */\n\thasUndo: boolean;\n\t/** Whether there's a redoable change in history. */\n\thasRedo: boolean;\n\t/** Undo the last committed action across all slices. */\n\tundo: () => void;\n\t/** Redo the last undone action across all slices. */\n\tredo: () => void;\n\t/**\n\t * Open a gesture boundary. During a gesture all state-changing\n\t * actions coalesce into one undo entry — the snapshot taken at\n\t * `beginGesture`. Pair with `endGesture` on pointer-up / key-up.\n\t */\n\tbeginGesture: () => void;\n\t/** Close a gesture boundary and commit the pre-gesture snapshot. */\n\tendGesture: () => void;\n}\n\n/**\n * The media editor session.\n *\n * Owns the only undo/redo history for the editor. Cropper geometry\n * actions and sidebar cropOptions actions flow through the same\n * reducer and the same history stack.\n *\n * History semantics:\n * - Each action's pre-state is pushed to the undo stack before the\n * action commits, unless a gesture is open or the action is a\n * no-op (post-state value-equal to pre-state).\n * - During a gesture (`beginGesture` → `endGesture`) all mutations\n * coalesce: only the pre-gesture snapshot is pushed, at gesture\n * end. Any pending gesture is flushed on undo/redo.\n * - Viewport-driven cropRect reshapes (window resize) use a\n * dedicated non-recording dispatch path so they never produce\n * undo entries.\n *\n * `isDirty` tracks the full editor session, including undoable UI\n * state. Use `hasOutputEdits` when deciding whether the image output\n * needs saving.\n *\n * The session starts empty. Call `setSourceImage` to load an image.\n *\n * @return The media editor session.\n */\nexport function useMediaEditorState(): MediaEditorSession {\n\tconst [ state, dispatch ] = useReducer( mediaEditorReducer, null, () =>\n\t\tbuildInitialMediaEditorState( { ...DEFAULT_STATE } )\n\t);\n\n\t// The \"clean\" snapshot the current state is compared against for\n\t// `isDirty`. Stored in state (not a ref) so the comparison reads\n\t// a value, not a ref's `current`. `setSourceImage` refreshes this when\n\t// a new image establishes a fresh baseline.\n\tconst [ initialBaseline, setInitialBaseline ] =\n\t\tuseState< MediaEditorState >( () => state );\n\n\t// Latest-state ref used by setters that need to read fresh state\n\t// (focal-point zoom, dispatch wrapper). Every mutation path\n\t// (`dispatchWithHistory`, `setSourceImage`, `undo`, `redo`) writes this\n\t// synchronously, so multiple actions in one event see the latest\n\t// reducer output before React commits.\n\tconst stateRef = useRef( state );\n\tconst visualSizeRef = useRef< Size >( { width: 0, height: 0 } );\n\n\t// History stacks: full composite snapshots. Refs avoid re-renders\n\t// on every push; a boolean state pair drives the enabled/disabled\n\t// indicators for undo/redo buttons.\n\tconst historyRef = useRef< MediaEditorState[] >( [] );\n\tconst redoStackRef = useRef< MediaEditorState[] >( [] );\n\tconst [ hasUndo, setHasUndo ] = useState( false );\n\tconst [ hasRedo, setHasRedo ] = useState( false );\n\n\t// Gesture state. While open, the first non-no-op action captures\n\t// the pre-gesture snapshot; subsequent actions don't push.\n\t// `endGesture` pushes the captured snapshot (or nothing, if the\n\t// gesture produced no changes).\n\tconst isGestureOpenRef = useRef( false );\n\tconst gestureSnapshotRef = useRef< MediaEditorState | null >( null );\n\n\tconst pushSnapshot = useCallback( ( snapshot: MediaEditorState ) => {\n\t\tconst last = historyRef.current[ historyRef.current.length - 1 ];\n\t\tif ( last && areMediaEditorStatesEqual( last, snapshot ) ) {\n\t\t\treturn;\n\t\t}\n\t\thistoryRef.current = [ ...historyRef.current, snapshot ];\n\t\tredoStackRef.current = [];\n\t\tsetHasUndo( true );\n\t\tsetHasRedo( false );\n\t}, [] );\n\n\t// Core dispatch wrapper. Synchronously computes the post-state via\n\t// the pure reducer so we can skip history pushes for no-op actions\n\t// and keep `stateRef` in lockstep with React's pending state.\n\tconst dispatchWithHistory = useCallback(\n\t\t( action: MediaEditorAction, recordHistory = true ) => {\n\t\t\tconst preState = stateRef.current;\n\t\t\tconst postState = mediaEditorReducer( preState, action );\n\t\t\tif ( recordHistory ) {\n\t\t\t\tif ( ! areMediaEditorStatesEqual( preState, postState ) ) {\n\t\t\t\t\tif ( isGestureOpenRef.current ) {\n\t\t\t\t\t\tif ( gestureSnapshotRef.current === null ) {\n\t\t\t\t\t\t\tgestureSnapshotRef.current = preState;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tpushSnapshot( preState );\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\tstateRef.current = postState;\n\t\t\tdispatch( action );\n\t\t},\n\t\t[ pushSnapshot ]\n\t);\n\n\tconst beginGesture = useCallback( () => {\n\t\tif ( isGestureOpenRef.current ) {\n\t\t\treturn;\n\t\t}\n\t\tisGestureOpenRef.current = true;\n\t\tgestureSnapshotRef.current = null;\n\t}, [] );\n\n\t// Close a gesture (or flush a pending one before undo/redo).\n\t// Pushes the pre-gesture snapshot only if it differs from current\n\t// state. Safe to call when no gesture is open.\n\tconst endGesture = useCallback( () => {\n\t\tconst snapshot = gestureSnapshotRef.current;\n\t\tif (\n\t\t\tsnapshot &&\n\t\t\t! areMediaEditorStatesEqual( snapshot, stateRef.current )\n\t\t) {\n\t\t\tpushSnapshot( snapshot );\n\t\t}\n\t\tgestureSnapshotRef.current = null;\n\t\tisGestureOpenRef.current = false;\n\t}, [ pushSnapshot ] );\n\n\t// =====================================================================\n\t// Cropper-slice setters (built from the shared factory so the pure\n\t// hook and this composite stay in lockstep — add a setter in\n\t// `buildCropperSetters` once and both hooks get it).\n\t// =====================================================================\n\n\tconst dispatchCropperAction = useCallback(\n\t\t( action: CropperAction ) => {\n\t\t\tdispatchWithHistory( { type: 'CROPPER', action } );\n\t\t},\n\t\t[ dispatchWithHistory ]\n\t);\n\n\tconst cropperSetters = useMemo(\n\t\t() =>\n\t\t\tbuildCropperSetters(\n\t\t\t\tdispatchCropperAction,\n\t\t\t\t() => stateRef.current.cropper\n\t\t\t),\n\t\t[ dispatchCropperAction ]\n\t);\n\n\tconst setSourceImage = useCallback( ( image: CropperState[ 'image' ] ) => {\n\t\tif ( areCropperImagesEqual( stateRef.current.cropper.image, image ) ) {\n\t\t\treturn;\n\t\t}\n\t\t// New image = fresh session: default geometry and crop options, a\n\t\t// clean baseline, and no history. Built from defaults rather than\n\t\t// dispatching SET_IMAGE, which keeps the current pan / zoom /\n\t\t// rotation / flip / cropRect — edits made against one image must\n\t\t// not survive onto another.\n\t\tconst next = buildInitialMediaEditorState(\n\t\t\tenforceContainment( { ...DEFAULT_STATE, image } )\n\t\t);\n\t\tstateRef.current = next;\n\t\tdispatch( { type: 'RESTORE_SNAPSHOT', payload: next } );\n\t\tsetInitialBaseline( next );\n\t\tisGestureOpenRef.current = false;\n\t\tgestureSnapshotRef.current = null;\n\t\thistoryRef.current = [];\n\t\tredoStackRef.current = [];\n\t\tsetHasUndo( false );\n\t\tsetHasRedo( false );\n\t}, [] );\n\n\tconst reset = useCallback(\n\t\t( resetState?: Partial< CropperState > ) => {\n\t\t\tdispatchWithHistory( {\n\t\t\t\ttype: 'CROPPER',\n\t\t\t\taction: { type: 'RESET', payload: resetState },\n\t\t\t} );\n\t\t},\n\t\t[ dispatchWithHistory ]\n\t);\n\n\t// =====================================================================\n\t// CropOptions-slice setters\n\t// =====================================================================\n\n\tconst setAspectRatioValue = useCallback(\n\t\t( presetKey: string ) => {\n\t\t\tconst resolved = resolveAspectRatio(\n\t\t\t\tpresetKey,\n\t\t\t\tstateRef.current.cropper.image\n\t\t\t);\n\t\t\tdispatchWithHistory( {\n\t\t\t\ttype: 'SET_ASPECT_RATIO_VALUE',\n\t\t\t\tpayload: {\n\t\t\t\t\tpresetKey,\n\t\t\t\t\tresolved,\n\t\t\t\t\tvisualSize: visualSizeRef.current,\n\t\t\t\t},\n\t\t\t} );\n\t\t},\n\t\t[ dispatchWithHistory ]\n\t);\n\n\tconst resetCropOptions = useCallback( () => {\n\t\tdispatchWithHistory( { type: 'RESET_CROP_OPTIONS' } );\n\t}, [ dispatchWithHistory ] );\n\n\t// =====================================================================\n\t// History\n\t// =====================================================================\n\n\tconst undo = useCallback( () => {\n\t\tendGesture();\n\t\tconst prev = historyRef.current[ historyRef.current.length - 1 ];\n\t\tif ( ! prev ) {\n\t\t\treturn;\n\t\t}\n\t\tredoStackRef.current = [ stateRef.current, ...redoStackRef.current ];\n\t\thistoryRef.current = historyRef.current.slice( 0, -1 );\n\t\tsetHasUndo( historyRef.current.length > 0 );\n\t\tsetHasRedo( true );\n\t\tstateRef.current = prev;\n\t\tdispatch( { type: 'RESTORE_SNAPSHOT', payload: prev } );\n\t}, [ endGesture ] );\n\n\tconst redo = useCallback( () => {\n\t\tendGesture();\n\t\tconst next = redoStackRef.current[ 0 ];\n\t\tif ( ! next ) {\n\t\t\treturn;\n\t\t}\n\t\thistoryRef.current = [ ...historyRef.current, stateRef.current ];\n\t\tredoStackRef.current = redoStackRef.current.slice( 1 );\n\t\tsetHasUndo( true );\n\t\tsetHasRedo( redoStackRef.current.length > 0 );\n\t\tstateRef.current = next;\n\t\tdispatch( { type: 'RESTORE_SNAPSHOT', payload: next } );\n\t}, [ endGesture ] );\n\n\t// =====================================================================\n\t// Viewport\n\t// =====================================================================\n\n\tconst setVisualSize = useCallback( ( size: Size ) => {\n\t\tvisualSizeRef.current = size;\n\t}, [] );\n\n\tconst adjustCropRectForViewport = useCallback(\n\t\t( rect: NormalizedRect ) => {\n\t\t\tdispatchWithHistory(\n\t\t\t\t{ type: 'VIEWPORT_ADJUST_CROP_RECT', payload: rect },\n\t\t\t\tfalse\n\t\t\t);\n\t\t},\n\t\t[ dispatchWithHistory ]\n\t);\n\n\t// =====================================================================\n\t// Derived\n\t// =====================================================================\n\n\tconst isDirty = ! areMediaEditorStatesEqual( state, initialBaseline );\n\tconst isCropperDirty = ! areCropperStatesEqual(\n\t\tstate.cropper,\n\t\tinitialBaseline.cropper\n\t);\n\n\tconst getCroppedImage = useCallback(\n\t\t( mimeType?: string, quality?: number ): Promise< Blob > => {\n\t\t\tif ( ! state.cropper.image ) {\n\t\t\t\treturn Promise.reject(\n\t\t\t\t\tnew Error( 'No image loaded — call setSourceImage first.' )\n\t\t\t\t);\n\t\t\t}\n\t\t\treturn exportCroppedImage(\n\t\t\t\tstate.cropper.image.src,\n\t\t\t\tstate.cropper,\n\t\t\t\tmimeType,\n\t\t\t\tquality\n\t\t\t);\n\t\t},\n\t\t[ state.cropper ]\n\t);\n\n\tconst cropper = useMemo< CropperController >(\n\t\t() => ( {\n\t\t\t...cropperSetters,\n\t\t\tstate: state.cropper,\n\t\t\tsetImage: setSourceImage,\n\t\t\treset,\n\t\t\tisDirty: isCropperDirty,\n\t\t\tgetCroppedImage,\n\t\t\tsetVisualSize,\n\t\t\tadjustCropRectForViewport,\n\t\t} ),\n\t\t[\n\t\t\tcropperSetters,\n\t\t\tstate.cropper,\n\t\t\tsetSourceImage,\n\t\t\treset,\n\t\t\tisCropperDirty,\n\t\t\tgetCroppedImage,\n\t\t\tsetVisualSize,\n\t\t\tadjustCropRectForViewport,\n\t\t]\n\t);\n\n\tconst session = useMemo< MediaEditorSession >(\n\t\t() => ( {\n\t\t\tcropper,\n\t\t\tcropOptions: state.cropOptions,\n\t\t\tsetAspectRatioValue,\n\t\t\tresetCropOptions,\n\t\t\tsetSourceImage,\n\t\t\tisDirty,\n\t\t\t// Only geometry changes the saved image so far.\n\t\t\thasOutputEdits: isCropperDirty,\n\t\t\thasUndo,\n\t\t\thasRedo,\n\t\t\tundo,\n\t\t\tredo,\n\t\t\tbeginGesture,\n\t\t\tendGesture,\n\t\t} ),\n\t\t[\n\t\t\tcropper,\n\t\t\tstate.cropOptions,\n\t\t\tsetAspectRatioValue,\n\t\t\tresetCropOptions,\n\t\t\tsetSourceImage,\n\t\t\tisDirty,\n\t\t\tisCropperDirty,\n\t\t\thasUndo,\n\t\t\thasRedo,\n\t\t\tundo,\n\t\t\tredo,\n\t\t\tbeginGesture,\n\t\t\tendGesture,\n\t\t]\n\t);\n\treturn session;\n}\n"],
5
+ "mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AA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AAA,QACN,MAAM,QAAQ,MAAM;AAAA,QACpB,MAAM;AAAA,QACN;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA,CAAE,MAAM,OAAQ;AAAA,EACjB;AAEA,QAAM,UAAU;AAAA,IACf,OAAQ;AAAA,MACP,GAAG;AAAA,MACH,OAAO,MAAM;AAAA,MACb,UAAU;AAAA,MACV;AAAA,MACA,SAAS;AAAA,MACT;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AAEA,QAAM,UAAU;AAAA,IACf,OAAQ;AAAA,MACP;AAAA,MACA,aAAa,MAAM;AAAA,MACnB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,MAEA,gBAAgB;AAAA,MAChB;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,IACA;AAAA,MACC;AAAA,MACA,MAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,IACD;AAAA,EACD;AACA,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -2,12 +2,14 @@
2
2
  function openMediaEditorModal({
3
3
  id,
4
4
  onUpdate,
5
+ onUndo,
5
6
  onClose
6
7
  }) {
7
8
  return {
8
9
  type: "OPEN_MEDIA_EDITOR_MODAL",
9
10
  id,
10
11
  onUpdate: onUpdate ?? null,
12
+ onUndo: onUndo ?? null,
11
13
  onClose: onClose ?? null
12
14
  };
13
15
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/actions.ts"],
4
- "sourcesContent": ["/**\n * Shape passed to `onUpdate` after a successful save. Deliberately normalized\n * and minimal: `url` instead of REST's `source_url`, so consumers can drop\n * it straight into block attributes (matches the legacy `ImageEditor`'s\n * `onSaveImage` shape at\n * `packages/block-editor/src/components/image-editor/use-save-image.js`).\n * Keeping this decoupled from the REST field names also leaves room to reuse\n * the modal outside a WordPress REST context (e.g. native/Electron hosts).\n */\nexport interface MediaEditorModalUpdate {\n\tid: number;\n\turl?: string;\n}\n\ninterface OpenMediaEditorModalArgs {\n\tid: number;\n\tonUpdate?: ( updated: MediaEditorModalUpdate ) => void;\n\tonClose?: () => void;\n}\n\nexport function openMediaEditorModal( {\n\tid,\n\tonUpdate,\n\tonClose,\n}: OpenMediaEditorModalArgs ) {\n\treturn {\n\t\ttype: 'OPEN_MEDIA_EDITOR_MODAL' as const,\n\t\tid,\n\t\tonUpdate: onUpdate ?? null,\n\t\tonClose: onClose ?? null,\n\t};\n}\n\nexport function closeMediaEditorModal() {\n\treturn { type: 'CLOSE_MEDIA_EDITOR_MODAL' as const };\n}\n"],
5
- "mappings": ";AAoBO,SAAS,qBAAsB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AACD,GAA8B;AAC7B,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,UAAU,YAAY;AAAA,IACtB,SAAS,WAAW;AAAA,EACrB;AACD;AAEO,SAAS,wBAAwB;AACvC,SAAO,EAAE,MAAM,2BAAoC;AACpD;",
4
+ "sourcesContent": ["/**\n * Shape passed to `onUpdate` after a successful save. Deliberately normalized\n * and minimal: `url` instead of REST's `source_url`, so consumers can drop\n * it straight into block attributes (matches the legacy `ImageEditor`'s\n * `onSaveImage` shape at\n * `packages/block-editor/src/components/image-editor/use-save-image.js`).\n * Keeping this decoupled from the REST field names also leaves room to reuse\n * the modal outside a WordPress REST context (e.g. native/Electron hosts).\n */\nexport interface MediaEditorModalUpdate {\n\tid: number;\n\turl?: string;\n}\n\ninterface OpenMediaEditorModalArgs {\n\tid: number;\n\tonUpdate?: ( updated: MediaEditorModalUpdate ) => void;\n\t/**\n\t * Restore the caller's state after a saved attachment change. May run\n\t * before an asynchronous `onUpdate` finishes; the caller should cancel\n\t * that update. Without this callback, Undo calls `onUpdate` with the\n\t * previous attachment's id and URL.\n\t */\n\tonUndo?: () => void;\n\tonClose?: () => void;\n}\n\nexport function openMediaEditorModal( {\n\tid,\n\tonUpdate,\n\tonUndo,\n\tonClose,\n}: OpenMediaEditorModalArgs ) {\n\treturn {\n\t\ttype: 'OPEN_MEDIA_EDITOR_MODAL' as const,\n\t\tid,\n\t\tonUpdate: onUpdate ?? null,\n\t\tonUndo: onUndo ?? null,\n\t\tonClose: onClose ?? null,\n\t};\n}\n\nexport function closeMediaEditorModal() {\n\treturn { type: 'CLOSE_MEDIA_EDITOR_MODAL' as const };\n}\n"],
5
+ "mappings": ";AA2BO,SAAS,qBAAsB;AAAA,EACrC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD,GAA8B;AAC7B,SAAO;AAAA,IACN,MAAM;AAAA,IACN;AAAA,IACA,UAAU,YAAY;AAAA,IACtB,QAAQ,UAAU;AAAA,IAClB,SAAS,WAAW;AAAA,EACrB;AACD;AAEO,SAAS,wBAAwB;AACvC,SAAO,EAAE,MAAM,2BAAoC;AACpD;",
6
6
  "names": []
7
7
  }
@@ -3,16 +3,18 @@ var DEFAULT_STATE = {
3
3
  isOpen: false,
4
4
  id: null,
5
5
  onUpdate: null,
6
+ onUndo: null,
6
7
  onClose: null
7
8
  };
8
9
  function reducer(state = DEFAULT_STATE, action) {
9
10
  switch (action.type) {
10
11
  case "OPEN_MEDIA_EDITOR_MODAL": {
11
- const { id, onUpdate, onClose } = action;
12
+ const { id, onUpdate, onUndo, onClose } = action;
12
13
  return {
13
14
  isOpen: true,
14
15
  id,
15
16
  onUpdate,
17
+ onUndo,
16
18
  onClose
17
19
  };
18
20
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/reducer.ts"],
4
- "sourcesContent": ["import type { MediaEditorModalUpdate } from './actions';\n\ntype OnUpdateCallback = ( updated: MediaEditorModalUpdate ) => void;\ntype OnCloseCallback = () => void;\n\nexport interface State {\n\tisOpen: boolean;\n\tid: number | null;\n\tonUpdate: OnUpdateCallback | null;\n\tonClose: OnCloseCallback | null;\n}\n\nexport const DEFAULT_STATE: State = {\n\tisOpen: false,\n\tid: null,\n\tonUpdate: null,\n\tonClose: null,\n};\n\ntype Action =\n\t| {\n\t\t\ttype: 'OPEN_MEDIA_EDITOR_MODAL';\n\t\t\tid: number;\n\t\t\tonUpdate: OnUpdateCallback | null;\n\t\t\tonClose: OnCloseCallback | null;\n\t }\n\t| { type: 'CLOSE_MEDIA_EDITOR_MODAL' };\n\nexport default function reducer(\n\tstate: State = DEFAULT_STATE,\n\taction: Action | { type: string }\n): State {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_MEDIA_EDITOR_MODAL': {\n\t\t\tconst { id, onUpdate, onClose } = action as Extract<\n\t\t\t\tAction,\n\t\t\t\t{ type: 'OPEN_MEDIA_EDITOR_MODAL' }\n\t\t\t>;\n\t\t\treturn {\n\t\t\t\tisOpen: true,\n\t\t\t\tid,\n\t\t\t\tonUpdate,\n\t\t\t\tonClose,\n\t\t\t};\n\t\t}\n\t\tcase 'CLOSE_MEDIA_EDITOR_MODAL':\n\t\t\treturn DEFAULT_STATE;\n\t}\n\treturn state;\n}\n"],
5
- "mappings": ";AAYO,IAAM,gBAAuB;AAAA,EACnC,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,SAAS;AACV;AAWe,SAAR,QACN,QAAe,eACf,QACQ;AACR,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,2BAA2B;AAC/B,YAAM,EAAE,IAAI,UAAU,QAAQ,IAAI;AAIlC,aAAO;AAAA,QACN,QAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA,KAAK;AACJ,aAAO;AAAA,EACT;AACA,SAAO;AACR;",
4
+ "sourcesContent": ["import type { MediaEditorModalUpdate } from './actions';\n\ntype OnUpdateCallback = ( updated: MediaEditorModalUpdate ) => void;\ntype OnUndoCallback = () => void;\ntype OnCloseCallback = () => void;\n\nexport interface State {\n\tisOpen: boolean;\n\tid: number | null;\n\tonUpdate: OnUpdateCallback | null;\n\tonUndo: OnUndoCallback | null;\n\tonClose: OnCloseCallback | null;\n}\n\nexport const DEFAULT_STATE: State = {\n\tisOpen: false,\n\tid: null,\n\tonUpdate: null,\n\tonUndo: null,\n\tonClose: null,\n};\n\ntype Action =\n\t| {\n\t\t\ttype: 'OPEN_MEDIA_EDITOR_MODAL';\n\t\t\tid: number;\n\t\t\tonUpdate: OnUpdateCallback | null;\n\t\t\tonUndo: OnUndoCallback | null;\n\t\t\tonClose: OnCloseCallback | null;\n\t }\n\t| { type: 'CLOSE_MEDIA_EDITOR_MODAL' };\n\nexport default function reducer(\n\tstate: State = DEFAULT_STATE,\n\taction: Action | { type: string }\n): State {\n\tswitch ( action.type ) {\n\t\tcase 'OPEN_MEDIA_EDITOR_MODAL': {\n\t\t\tconst { id, onUpdate, onUndo, onClose } = action as Extract<\n\t\t\t\tAction,\n\t\t\t\t{ type: 'OPEN_MEDIA_EDITOR_MODAL' }\n\t\t\t>;\n\t\t\treturn {\n\t\t\t\tisOpen: true,\n\t\t\t\tid,\n\t\t\t\tonUpdate,\n\t\t\t\tonUndo,\n\t\t\t\tonClose,\n\t\t\t};\n\t\t}\n\t\tcase 'CLOSE_MEDIA_EDITOR_MODAL':\n\t\t\treturn DEFAULT_STATE;\n\t}\n\treturn state;\n}\n"],
5
+ "mappings": ";AAcO,IAAM,gBAAuB;AAAA,EACnC,QAAQ;AAAA,EACR,IAAI;AAAA,EACJ,UAAU;AAAA,EACV,QAAQ;AAAA,EACR,SAAS;AACV;AAYe,SAAR,QACN,QAAe,eACf,QACQ;AACR,UAAS,OAAO,MAAO;AAAA,IACtB,KAAK,2BAA2B;AAC/B,YAAM,EAAE,IAAI,UAAU,QAAQ,QAAQ,IAAI;AAI1C,aAAO;AAAA,QACN,QAAQ;AAAA,QACR;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD;AAAA,IACD;AAAA,IACA,KAAK;AACJ,aAAO;AAAA,EACT;AACA,SAAO;AACR;",
6
6
  "names": []
7
7
  }
@@ -8,12 +8,16 @@ function getId(state) {
8
8
  function getOnUpdate(state) {
9
9
  return state.onUpdate;
10
10
  }
11
+ function getOnUndo(state) {
12
+ return state.onUndo;
13
+ }
11
14
  function getOnClose(state) {
12
15
  return state.onClose;
13
16
  }
14
17
  export {
15
18
  getId,
16
19
  getOnClose,
20
+ getOnUndo,
17
21
  getOnUpdate,
18
22
  isOpen
19
23
  };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/store/selectors.ts"],
4
- "sourcesContent": ["import type { State } from './reducer';\n\nexport function isOpen( state: State ): boolean {\n\treturn state.isOpen;\n}\n\nexport function getId( state: State ): number | null {\n\treturn state.id;\n}\n\nexport function getOnUpdate( state: State ) {\n\treturn state.onUpdate;\n}\n\nexport function getOnClose( state: State ) {\n\treturn state.onClose;\n}\n"],
5
- "mappings": ";AAEO,SAAS,OAAQ,OAAwB;AAC/C,SAAO,MAAM;AACd;AAEO,SAAS,MAAO,OAA8B;AACpD,SAAO,MAAM;AACd;AAEO,SAAS,YAAa,OAAe;AAC3C,SAAO,MAAM;AACd;AAEO,SAAS,WAAY,OAAe;AAC1C,SAAO,MAAM;AACd;",
4
+ "sourcesContent": ["import type { State } from './reducer';\n\nexport function isOpen( state: State ): boolean {\n\treturn state.isOpen;\n}\n\nexport function getId( state: State ): number | null {\n\treturn state.id;\n}\n\nexport function getOnUpdate( state: State ) {\n\treturn state.onUpdate;\n}\n\nexport function getOnUndo( state: State ) {\n\treturn state.onUndo;\n}\n\nexport function getOnClose( state: State ) {\n\treturn state.onClose;\n}\n"],
5
+ "mappings": ";AAEO,SAAS,OAAQ,OAAwB;AAC/C,SAAO,MAAM;AACd;AAEO,SAAS,MAAO,OAA8B;AACpD,SAAO,MAAM;AACd;AAEO,SAAS,YAAa,OAAe;AAC3C,SAAO,MAAM;AACd;AAEO,SAAS,UAAW,OAAe;AACzC,SAAO,MAAM;AACd;AAEO,SAAS,WAAY,OAAe;AAC1C,SAAO,MAAM;AACd;",
6
6
  "names": []
7
7
  }
@@ -228,8 +228,8 @@
228
228
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
229
229
  }
230
230
  .wp-media-editor-image-editor__canvas--focus-visible:focus .wp-media-editor-image-editor__stencil-rect {
231
- border-color: var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #007cba));
232
- box-shadow: 0 0 0 1px var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #007cba));
231
+ border-color: var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #3858e9));
232
+ box-shadow: 0 0 0 1px var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #3858e9));
233
233
  }
234
234
  .wp-media-editor-image-editor__handle {
235
235
  appearance: none;
@@ -241,7 +241,7 @@
241
241
  width: 12px;
242
242
  height: 12px;
243
243
  background: #fff;
244
- border: 1px solid var(--wp-admin-theme-color, #007cba);
244
+ border: 1px solid var(--wp-admin-theme-color, #3858e9);
245
245
  border-radius: 50%;
246
246
  box-sizing: border-box;
247
247
  pointer-events: auto;
@@ -251,9 +251,9 @@
251
251
  outline: none;
252
252
  }
253
253
  .wp-media-editor-image-editor__canvas--focus-visible .wp-media-editor-image-editor__handle:focus {
254
- background: var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #007cba));
254
+ background: var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #3858e9));
255
255
  border-color: transparent;
256
- box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #007cba));
256
+ box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #3858e9));
257
257
  }
258
258
  .wp-media-editor-image-editor__handle::before {
259
259
  content: "";
@@ -230,8 +230,8 @@
230
230
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
231
231
  }
232
232
  .wp-media-editor-image-editor__canvas--focus-visible:focus .wp-media-editor-image-editor__stencil-rect {
233
- border-color: var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #007cba));
234
- box-shadow: 0 0 0 1px var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #007cba));
233
+ border-color: var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #3858e9));
234
+ box-shadow: 0 0 0 1px var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #3858e9));
235
235
  }
236
236
  .wp-media-editor-image-editor__handle {
237
237
  appearance: none;
@@ -243,7 +243,7 @@
243
243
  width: 12px;
244
244
  height: 12px;
245
245
  background: #fff;
246
- border: 1px solid var(--wp-admin-theme-color, #007cba);
246
+ border: 1px solid var(--wp-admin-theme-color, #3858e9);
247
247
  border-radius: 50%;
248
248
  box-sizing: border-box;
249
249
  pointer-events: auto;
@@ -253,9 +253,9 @@
253
253
  outline: none;
254
254
  }
255
255
  .wp-media-editor-image-editor__canvas--focus-visible .wp-media-editor-image-editor__handle:focus {
256
- background: var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #007cba));
256
+ background: var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #3858e9));
257
257
  border-color: transparent;
258
- box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #007cba));
258
+ box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--wp-image-editor-focus-color, var(--wp-admin-theme-color, #3858e9));
259
259
  }
260
260
  .wp-media-editor-image-editor__handle::before {
261
261
  content: "";
@@ -1,5 +1,5 @@
1
1
  import type { Field } from '@wordpress/dataviews';
2
- import type { KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react';
2
+ import type { KeyboardEvent as ReactKeyboardEvent, ReactElement, ReactNode } from 'react';
3
3
  import type { Media } from '../media-editor-provider';
4
4
  import type { AspectRatioPreset } from '../../image-editor/core/constants';
5
5
  import { type MediaEditorSaveResult } from './use-save-media-editor';
@@ -34,7 +34,7 @@ export interface MediaEditorProps {
34
34
  aspectRatioPresets?: AspectRatioPreset[];
35
35
  onClose?: () => void;
36
36
  onSaved?: (result: MediaEditorSaveResult) => void;
37
- renderFrame: (props: MediaEditorFrameProps) => JSX.Element;
37
+ renderFrame: (props: MediaEditorFrameProps) => ReactElement;
38
38
  noticesClassName?: string;
39
39
  noticesPortalElement?: Element | null;
40
40
  shouldCloseOnEsc?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor/index.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,IAAI,kBAAkB,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAE5E,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,CAAC;IAC3B,SAAS,EAAE,CAAE,KAAK,EAAE,kBAAkB,CAAE,WAAW,CAAE,KAAM,IAAI,CAAC;IAChE,yBAAyB,EAAE,OAAO,CAAC;IACnC,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,QAAQ,EAAE,OA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,MAAM,WAAW,gBAAgB;IAChC;;;;;OAKG;IACH,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAC7B;AAED,iBAAS,WAAW,CAAE,EAAE,IAAgB,EAAE,EAAE,gBAAgB,+BAkC3D;AAsgBD,wBAAgB,WAAW,CAAE,KAAK,EAAE,gBAAgB,+BAMnD;yBANe,WAAW;;;;;eAeZ,WAAW"}
@@ -1,5 +1,5 @@
1
1
  import type { Media } from '../media-editor-provider';
2
- import type { MediaEditorController } from '../../state';
2
+ import type { MediaEditorSession } from '../../state';
3
3
  export declare const MEDIA_EDITOR_NOTICES_CONTEXT = "media-editor";
4
4
  export interface MediaEditorSaveResult {
5
5
  id: number;
@@ -11,16 +11,28 @@ export interface MediaEditorSaveResult {
11
11
  };
12
12
  }
13
13
  interface UseSaveMediaEditorArgs {
14
- cropper: MediaEditorController;
14
+ session: MediaEditorSession;
15
15
  id: number;
16
16
  isImage: boolean;
17
17
  media?: Media | null;
18
18
  onSaved?: (result: MediaEditorSaveResult) => void;
19
+ /**
20
+ * When another attachment has replaced the edited one (today, the original
21
+ * via "Restore original image"), the save targets the replacement:
22
+ * - with no fresh crop, the block is repointed at the replacement and any
23
+ * changed details are saved there (no `/edit`);
24
+ * - with a fresh crop, `/edit` runs against the replacement's id and url.
25
+ */
26
+ replacementSource?: {
27
+ id: number;
28
+ url?: string;
29
+ media: Media;
30
+ };
19
31
  }
20
32
  interface UseSaveMediaEditorReturn {
21
33
  isSaving: boolean;
22
34
  save: () => Promise<void>;
23
35
  }
24
- export declare function useSaveMediaEditor({ cropper, id, isImage, media, onSaved, }: UseSaveMediaEditorArgs): UseSaveMediaEditorReturn;
36
+ export declare function useSaveMediaEditor({ session, id, isImage, media, onSaved, replacementSource, }: UseSaveMediaEditorArgs): UseSaveMediaEditorReturn;
25
37
  export {};
26
38
  //# sourceMappingURL=use-save-media-editor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use-save-media-editor.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor/use-save-media-editor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAiBzD,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAI3D,MAAM,WAAW,qBAAqB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE;QACV,EAAE,EAAE,MAAM,CAAC;QACX,GAAG,CAAC,EAAE,MAAM,CAAC;KACb,CAAC;CACF;AAED,UAAU,sBAAsB;IAC/B,OAAO,EAAE,qBAAqB,CAAC;IAC/B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,CAAE,MAAM,EAAE,qBAAqB,KAAM,IAAI,CAAC;CACpD;AAED,UAAU,wBAAwB;IACjC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,OAAO,CAAE,IAAI,CAAE,CAAC;CAC5B;AAgCD,wBAAgB,kBAAkB,CAAE,EACnC,OAAO,EACP,EAAE,EACF,OAAO,EACP,KAAK,EACL,OAAO,GACP,EAAE,sBAAsB,GAAI,wBAAwB,CAuHpD"}
1
+ {"version":3,"file":"use-save-media-editor.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor/use-save-media-editor.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAiBtD,eAAO,MAAM,4BAA4B,iBAAiB,CAAC;AAI3D,MAAM,WAAW,qBAAqB;IACrC,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,KAAK,CAAC;IACb,QAAQ,CAAC,EAAE;QACV,EAAE,EAAE,MAAM,CAAC;QACX,GAAG,CAAC,EAAE,MAAM,CAAC;KACb,CAAC;CACF;AAED,UAAU,sBAAsB;IAC/B,OAAO,EAAE,kBAAkB,CAAC;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,OAAO,CAAC,EAAE,CAAE,MAAM,EAAE,qBAAqB,KAAM,IAAI,CAAC;IACpD;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE;QACnB,EAAE,EAAE,MAAM,CAAC;QACX,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,KAAK,CAAC;KACb,CAAC;CACF;AAED,UAAU,wBAAwB;IACjC,QAAQ,EAAE,OAAO,CAAC;IAClB,IAAI,EAAE,MAAM,OAAO,CAAE,IAAI,CAAE,CAAC;CAC5B;AAiCD,wBAAgB,kBAAkB,CAAE,EACnC,OAAO,EACP,EAAE,EACF,OAAO,EACP,KAAK,EACL,OAAO,EACP,iBAAiB,GACjB,EAAE,sBAAsB,GAAI,wBAAwB,CAkJpD"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-canvas/index.tsx"],"names":[],"mappings":"AASA,MAAM,WAAW,sBAAsB;IACtC,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kDAAkD;IAClD,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAE,EAC1C,iBAAyB,EACzB,cAAc,EACd,YAAY,EACZ,QAAgB,GAChB,EAAE,sBAAsB,sCAmIxB"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-canvas/index.tsx"],"names":[],"mappings":"AASA,MAAM,WAAW,sBAAsB;IACtC,kEAAkE;IAClE,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,kDAAkD;IAClD,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,gDAAgD;IAChD,YAAY,CAAC,EAAE,MAAM,IAAI,CAAC;IAC1B;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAAE,EAC1C,iBAAyB,EACzB,cAAc,EACd,YAAY,EACZ,QAAgB,GAChB,EAAE,sBAAsB,sCAkIxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-image-controls/index.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAEN,KAAK,iBAAiB,EACtB,MAAM,mCAAmC,CAAC;AAI3C;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,MAAM,WAAW,6BAA6B;IAC7C;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,qDAAqD;IACrD,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACzC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAE,EACjD,UAAkB,EAClB,sBAA8B,EAC9B,kBAAkB,EAClB,UAAgC,EAChC,QAAgB,GAChB,EAAE,6BAA6B,+BA+L/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/components/media-editor-image-controls/index.tsx"],"names":[],"mappings":"AAcA,OAAO,EAEN,KAAK,iBAAiB,EACtB,MAAM,mCAAmC,CAAC;AAI3C;;;;;;GAMG;AACH,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAEvC,MAAM,WAAW,6BAA6B;IAC7C;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;OAIG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,qDAAqD;IACrD,kBAAkB,CAAC,EAAE,iBAAiB,EAAE,CAAC;IACzC;;;;OAIG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,OAAO,UAAU,wBAAwB,CAAE,EACjD,UAAkB,EAClB,sBAA8B,EAC9B,kBAAkB,EAClB,UAAgC,EAChC,QAAgB,GAChB,EAAE,6BAA6B,+BAmM/B"}
@@ -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,sCAwGvB;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,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 +1 @@
1
- {"version":3,"file":"use-crop-gesture-handlers.d.ts","sourceRoot":"","sources":["../../src/hooks/use-crop-gesture-handlers.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAKrD,MAAM,WAAW,6BAA6B;IAC7C;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACrC,OAAO,GAAE,6BAAkC;;;;;;;EAoD3C"}
1
+ {"version":3,"file":"use-crop-gesture-handlers.d.ts","sourceRoot":"","sources":["../../src/hooks/use-crop-gesture-handlers.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,eAAO,MAAM,iBAAiB,sBAAsB,CAAC;AAKrD,MAAM,WAAW,6BAA6B;IAC7C;;;;;;OAMG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,sBAAsB,CACrC,OAAO,GAAE,6BAAkC;;;;;;;EAsD3C"}
@@ -1 +1 @@
1
- {"version":3,"file":"interaction-controller.d.ts","sourceRoot":"","sources":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EAAE,EAAE,WAAW,GAAI,IAAI,CAiG1D;IAED;;;;;;;;;OASG;IACH,WAAW,CAAE,CAAC,EAAE,UAAU,GAAI,IAAI,CA0DjC;IAED;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CACf,CAAC,EAAE,UAAU,EACb,aAAa,EAAE,OAAO,EACtB,GAAG,GAAE,QAAmB,GACtB,IAAI,CA6FN;IAOD,OAAO,CAAC,eAAe,CA2JrB;IAQF,OAAO,CAAC,YAAY;IAkFpB;;;;;;OAMG;IACH,aAAa,CAAE,CAAC,EAAE,aAAa,GAAI,IAAI,CAwHtC;IAED;;;;;OAKG;IACH,OAAO,IAAI,IAAI,CAmBd;CACD"}
1
+ {"version":3,"file":"interaction-controller.d.ts","sourceRoot":"","sources":["../../../src/image-editor/core/interaction-controller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AA6CnE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IACjC,uDAAuD;IACvD,UAAU,EAAE,OAAO,CAAC;IACpB,0DAA0D;IAC1D,SAAS,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACzC,0DAA0D;IAC1D,MAAM,EAAE,CAAE,GAAG,EAAE,eAAe,KAAM,IAAI,CAAC;IACzC;;;;OAIG;IACH,OAAO,EAAE,CAAE,IAAI,EAAE,MAAM,KAAM,IAAI,CAAC;IAClC,sDAAsD;IACtD,cAAc,EAAE,CAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,eAAe,KAAM,IAAI,CAAC;IAC/D,iCAAiC;IACjC,YAAY,EAAE,CAAE,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,KAAM,IAAI,CAAC;IAC5C,qCAAqC;IACrC,UAAU,CAAC,EAAE,CAAE,SAAS,EAAE,YAAY,GAAG,UAAU,KAAM,IAAI,CAAC;CAC9D;AAED;;;;;;GAMG;AACH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,CAAC,kBAAkB,CAAS;IAEnC,wCAAwC;IACxC,OAAO,CAAC,KAAK,CAAK;IAElB,YAAa,OAAO,EAAE,4BAA4B,EAEjD;IAED,qEAAqE;IACrE,OAAO,KAAK,OAAO,GAElB;IAED,qEAAqE;IACrE,OAAO,KAAK,OAAO,GAElB;IAED,uEAAuE;IACvE,OAAO,KAAK,SAAS,GAEpB;IAED,0EAA0E;IAC1E,OAAO,KAAK,YAAY,GAEvB;IAED;;;;;OAKG;IACH,OAAO,CAAC,eAAe;IAMvB,2EAA2E;IAC3E,OAAO,KAAK,aAAa,GAExB;IAED;;;;OAIG;IACH,OAAO,CAAC,SAAS;IA0BjB;;;;;;;;;OASG;IACH,iBAAiB,CAAE,CAAC,EAAE,YAAY,EAAE,EAAE,EAAE,WAAW,GAAI,IAAI,CAyG1D;IAED;;;;;;;;;OASG;IACH,WAAW,CAAE,CAAC,EAAE,UAAU,GAAI,IAAI,CA0DjC;IAED;;;;;;;;;;;;;OAaG;IACH,gBAAgB,CACf,CAAC,EAAE,UAAU,EACb,aAAa,EAAE,OAAO,EACtB,GAAG,GAAE,QAAmB,GACtB,IAAI,CA6FN;IAOD,OAAO,CAAC,eAAe,CA2JrB;IAQF,OAAO,CAAC,YAAY;IAkFpB;;;;;;OAMG;IACH,aAAa,CAAE,CAAC,EAAE,aAAa,GAAI,IAAI,CAwHtC;IAED;;;;;OAKG;IACH,OAAO,IAAI,IAAI,CAmBd;CACD"}
@@ -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,4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