@wordpress/media-editor 0.10.0 → 0.10.1

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 (140) hide show
  1. package/build/components/media-editor/index.cjs +185 -42
  2. package/build/components/media-editor/index.cjs.map +3 -3
  3. package/build/components/media-editor/use-crop-options.cjs +2 -26
  4. package/build/components/media-editor/use-crop-options.cjs.map +2 -2
  5. package/build/components/media-editor-canvas/index.cjs +2 -2
  6. package/build/components/media-editor-canvas/index.cjs.map +2 -2
  7. package/build/components/media-editor-crop-panel/index.cjs +24 -21
  8. package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
  9. package/build/components/media-editor-fine-rotation/index.cjs +81 -0
  10. package/build/components/media-editor-fine-rotation/index.cjs.map +7 -0
  11. package/build/components/media-editor-modal/index.cjs +25 -7
  12. package/build/components/media-editor-modal/index.cjs.map +2 -2
  13. package/build/components/media-editor-transform-controls/index.cjs +84 -0
  14. package/build/components/media-editor-transform-controls/index.cjs.map +7 -0
  15. package/build/hooks/use-crop-gesture-handlers.cjs +1 -1
  16. package/build/hooks/use-crop-gesture-handlers.cjs.map +2 -2
  17. package/build/image-editor/react/components/cropper.cjs +1 -1
  18. package/build/image-editor/react/components/cropper.cjs.map +2 -2
  19. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +1 -1
  20. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
  21. package/build/image-editor/react/hooks/use-aria-announcer.cjs +1 -3
  22. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
  23. package/build/image-editor/react/hooks/use-interaction.cjs +1 -1
  24. package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
  25. package/build/state/composite-reducer.cjs +2 -14
  26. package/build/state/composite-reducer.cjs.map +2 -2
  27. package/build/state/types.cjs +1 -2
  28. package/build/state/types.cjs.map +2 -2
  29. package/build/state/use-media-editor-state.cjs +0 -11
  30. package/build/state/use-media-editor-state.cjs.map +2 -2
  31. package/build/store/actions.cjs +4 -2
  32. package/build/store/actions.cjs.map +2 -2
  33. package/build/store/reducer.cjs +5 -3
  34. package/build/store/reducer.cjs.map +2 -2
  35. package/build/store/selectors.cjs +5 -0
  36. package/build/store/selectors.cjs.map +2 -2
  37. package/build-module/components/media-editor/index.mjs +191 -44
  38. package/build-module/components/media-editor/index.mjs.map +2 -2
  39. package/build-module/components/media-editor/use-crop-options.mjs +3 -27
  40. package/build-module/components/media-editor/use-crop-options.mjs.map +2 -2
  41. package/build-module/components/media-editor-canvas/index.mjs +2 -2
  42. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  43. package/build-module/components/media-editor-crop-panel/index.mjs +25 -26
  44. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  45. package/build-module/components/media-editor-fine-rotation/index.mjs +50 -0
  46. package/build-module/components/media-editor-fine-rotation/index.mjs.map +7 -0
  47. package/build-module/components/media-editor-modal/index.mjs +26 -8
  48. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  49. package/build-module/components/media-editor-transform-controls/index.mjs +68 -0
  50. package/build-module/components/media-editor-transform-controls/index.mjs.map +7 -0
  51. package/build-module/hooks/use-crop-gesture-handlers.mjs +1 -1
  52. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +2 -2
  53. package/build-module/image-editor/react/components/cropper.mjs +1 -1
  54. package/build-module/image-editor/react/components/cropper.mjs.map +2 -2
  55. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +1 -1
  56. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
  57. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +1 -3
  58. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
  59. package/build-module/image-editor/react/hooks/use-interaction.mjs +1 -1
  60. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
  61. package/build-module/state/composite-reducer.mjs +2 -14
  62. package/build-module/state/composite-reducer.mjs.map +2 -2
  63. package/build-module/state/types.mjs +1 -2
  64. package/build-module/state/types.mjs.map +2 -2
  65. package/build-module/state/use-media-editor-state.mjs +0 -11
  66. package/build-module/state/use-media-editor-state.mjs.map +2 -2
  67. package/build-module/store/actions.mjs +4 -2
  68. package/build-module/store/actions.mjs.map +2 -2
  69. package/build-module/store/reducer.mjs +5 -3
  70. package/build-module/store/reducer.mjs.map +2 -2
  71. package/build-module/store/selectors.mjs +4 -0
  72. package/build-module/store/selectors.mjs.map +2 -2
  73. package/build-style/style-rtl.css +51 -35
  74. package/build-style/style.css +51 -35
  75. package/build-types/components/media-editor/index.d.ts +14 -2
  76. package/build-types/components/media-editor/index.d.ts.map +1 -1
  77. package/build-types/components/media-editor/use-crop-options.d.ts +3 -5
  78. package/build-types/components/media-editor/use-crop-options.d.ts.map +1 -1
  79. package/build-types/components/media-editor-crop-panel/index.d.ts +3 -10
  80. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  81. package/build-types/components/media-editor-fine-rotation/index.d.ts +14 -0
  82. package/build-types/components/media-editor-fine-rotation/index.d.ts.map +1 -0
  83. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  84. package/build-types/components/media-editor-transform-controls/index.d.ts +8 -0
  85. package/build-types/components/media-editor-transform-controls/index.d.ts.map +1 -0
  86. package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -1
  87. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  88. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
  89. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
  90. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
  91. package/build-types/state/composite-reducer.d.ts.map +1 -1
  92. package/build-types/state/types.d.ts +3 -11
  93. package/build-types/state/types.d.ts.map +1 -1
  94. package/build-types/state/use-media-editor-state.d.ts +2 -5
  95. package/build-types/state/use-media-editor-state.d.ts.map +1 -1
  96. package/build-types/store/actions.d.ts +3 -1
  97. package/build-types/store/actions.d.ts.map +1 -1
  98. package/build-types/store/reducer.d.ts +3 -0
  99. package/build-types/store/reducer.d.ts.map +1 -1
  100. package/build-types/store/selectors.d.ts +1 -0
  101. package/build-types/store/selectors.d.ts.map +1 -1
  102. package/package.json +20 -19
  103. package/src/components/media-editor/index.tsx +226 -57
  104. package/src/components/media-editor/style.scss +0 -9
  105. package/src/components/media-editor/test/use-crop-options.tsx +1 -55
  106. package/src/components/media-editor/use-crop-options.ts +6 -42
  107. package/src/components/media-editor-canvas/index.tsx +2 -2
  108. package/src/components/media-editor-crop-panel/index.tsx +35 -33
  109. package/src/components/media-editor-crop-panel/test/index.tsx +39 -20
  110. package/src/components/media-editor-fine-rotation/index.tsx +74 -0
  111. package/src/components/media-editor-modal/index.tsx +20 -4
  112. package/src/components/media-editor-modal/style.scss +80 -0
  113. package/src/components/media-editor-modal/test/index.tsx +3 -0
  114. package/src/components/media-editor-transform-controls/index.tsx +70 -0
  115. package/src/components/media-editor-transform-controls/style.scss +8 -0
  116. package/src/hooks/use-crop-gesture-handlers.ts +1 -3
  117. package/src/image-editor/docs/recipes.md +2 -2
  118. package/src/image-editor/react/components/cropper.tsx +1 -3
  119. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +1 -3
  120. package/src/image-editor/react/hooks/use-aria-announcer.ts +1 -3
  121. package/src/image-editor/react/hooks/use-interaction.ts +2 -3
  122. package/src/state/composite-reducer.ts +2 -17
  123. package/src/state/test/use-media-editor-state.ts +3 -75
  124. package/src/state/types.ts +3 -9
  125. package/src/state/use-media-editor-state.ts +3 -19
  126. package/src/store/actions.ts +3 -0
  127. package/src/store/reducer.ts +6 -1
  128. package/src/store/selectors.ts +4 -0
  129. package/src/store/test/reducer.ts +9 -0
  130. package/src/style.scss +1 -1
  131. package/tsconfig.json +1 -0
  132. package/tsconfig.tsbuildinfo +1 -1
  133. package/build/components/media-editor-toolbar/index.cjs +0 -218
  134. package/build/components/media-editor-toolbar/index.cjs.map +0 -7
  135. package/build-module/components/media-editor-toolbar/index.mjs +0 -194
  136. package/build-module/components/media-editor-toolbar/index.mjs.map +0 -7
  137. package/build-types/components/media-editor-toolbar/index.d.ts +0 -24
  138. package/build-types/components/media-editor-toolbar/index.d.ts.map +0 -1
  139. package/src/components/media-editor-toolbar/index.tsx +0 -213
  140. package/src/components/media-editor-toolbar/style.scss +0 -49
@@ -32,26 +32,34 @@ var import_constants = require("../../image-editor/core/constants.cjs");
32
32
  var import_containment = require("../../image-editor/core/containment.cjs");
33
33
  var import_jsx_runtime = (
34
34
  // Tag the whole panel as a crop-control region so the modal's
35
- // Cmd+Z handler doesn't mistake the SelectControl / ToggleControl
36
- // inputs for metadata fields (which would suppress undo).
35
+ // Cmd+Z handler doesn't mistake the SelectControl input for a
36
+ // metadata field (which would suppress undo).
37
37
  require("react/jsx-runtime")
38
38
  );
39
+ var ZOOM_PERCENTAGE_SCALE = 100;
40
+ var MAX_ZOOM_PERCENTAGE = import_constants.MAX_ZOOM * ZOOM_PERCENTAGE_SCALE;
41
+ function getZoomPercentageForDisplay(zoom) {
42
+ return Math.round(zoom * ZOOM_PERCENTAGE_SCALE);
43
+ }
44
+ function getMinZoomPercentageForDisplay(zoom) {
45
+ return Math.ceil(zoom * ZOOM_PERCENTAGE_SCALE);
46
+ }
39
47
  function MediaEditorCropPanel({
40
48
  aspectRatioValue,
41
49
  onAspectRatioChange,
42
- freeformCrop,
43
- onFreeformChange,
44
50
  onPlacementControlInteraction,
45
51
  aspectRatioOptions
46
52
  }) {
47
53
  const { state, setZoom } = (0, import_state.useMediaEditor)();
48
54
  const zoomGestureHandlers = (0, import_use_crop_gesture_handlers.useCropGestureHandlers)();
49
55
  const minZoom = (0, import_containment.getMinZoom)(state);
56
+ const zoomPercentage = getZoomPercentageForDisplay(state.zoom);
57
+ const minZoomPercentage = getMinZoomPercentageForDisplay(minZoom);
50
58
  return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
51
59
  import_ui.Stack,
52
60
  {
53
61
  direction: "column",
54
- gap: "md",
62
+ gap: "xl",
55
63
  ...{ [import_use_crop_gesture_handlers.CROP_CONTROL_ATTR]: true },
56
64
  children: [
57
65
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ui.VisuallyHidden, { render: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {}), children: (0, import_i18n.__)("Crop options") }),
@@ -68,33 +76,28 @@ function MediaEditorCropPanel({
68
76
  }))
69
77
  }
70
78
  ),
71
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
72
- import_components.ToggleControl,
73
- {
74
- label: (0, import_i18n.__)("Show resize handles"),
75
- checked: freeformCrop,
76
- onChange: onFreeformChange
77
- }
78
- ),
79
79
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", { role: "presentation", ...zoomGestureHandlers, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
80
80
  import_components.RangeControl,
81
81
  {
82
82
  __next40pxDefaultSize: true,
83
- label: (0, import_i18n.__)("Zoom"),
84
- min: minZoom,
85
- max: import_constants.MAX_ZOOM,
86
- step: 0.1,
87
- value: state.zoom,
83
+ label: (0, import_i18n.__)("Zoom (%)"),
84
+ min: minZoomPercentage,
85
+ max: MAX_ZOOM_PERCENTAGE,
86
+ step: 1,
87
+ shiftStep: 10,
88
+ value: zoomPercentage,
88
89
  onChange: (value) => {
89
90
  onPlacementControlInteraction?.();
90
- setZoom(typeof value === "number" ? value : minZoom);
91
+ setZoom(
92
+ typeof value === "number" ? value / ZOOM_PERCENTAGE_SCALE : minZoom
93
+ );
91
94
  },
92
95
  renderTooltipContent: (value) => {
93
- const zoom = typeof value === "number" ? value : minZoom;
96
+ const percentage = typeof value === "number" ? value : minZoomPercentage;
94
97
  return (0, import_i18n.sprintf)(
95
98
  /* translators: %d: zoom level as a percentage. */
96
99
  (0, import_i18n.__)("%d%%"),
97
- Math.round(zoom * 100)
100
+ Math.round(percentage)
98
101
  );
99
102
  }
100
103
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/media-editor-crop-panel/index.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport {\n\tRangeControl,\n\tSelectControl,\n\tToggleControl,\n} from '@wordpress/components';\nimport { Stack, VisuallyHidden } from '@wordpress/ui';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useMediaEditor } from '../../state';\nimport {\n\tuseCropGestureHandlers,\n\tCROP_CONTROL_ATTR,\n} from '../../hooks/use-crop-gesture-handlers';\nimport { MAX_ZOOM } from '../../image-editor/core/constants';\nimport { getMinZoom } from '../../image-editor/core/containment';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\nexport interface MediaEditorCropPanelProps {\n\t/**\n\t * Selected aspect-ratio preset value as a string (so it round-trips\n\t * through `<SelectControl>`). `'0'` = free, `'-1'` = original, any\n\t * positive number = fixed ratio.\n\t */\n\taspectRatioValue: string;\n\t/** Setter for the aspect-ratio preset value. */\n\tonAspectRatioChange: ( value: string ) => void;\n\t/** Whether the cropper is in freeform (resize-handle) mode. */\n\tfreeformCrop: boolean;\n\t/** Setter for freeform mode. */\n\tonFreeformChange: ( value: boolean ) => void;\n\t/** Signal that a placement-oriented control is being adjusted. */\n\tonPlacementControlInteraction?: () => void;\n\t/** Aspect-ratio presets to display in the selector. */\n\taspectRatioOptions: AspectRatioPreset[];\n}\n\n/**\n * Sidebar panel for crop-shape controls \u2014 aspect-ratio presets and\n * freeform toggle. The tactile verbs (rotate, flip) live in the\n * bottom toolbar instead.\n * @param props\n * @param props.aspectRatioValue\n * @param props.onAspectRatioChange\n * @param props.freeformCrop\n * @param props.onFreeformChange\n * @param props.onPlacementControlInteraction\n * @param props.aspectRatioOptions\n */\nexport default function MediaEditorCropPanel( {\n\taspectRatioValue,\n\tonAspectRatioChange,\n\tfreeformCrop,\n\tonFreeformChange,\n\tonPlacementControlInteraction,\n\taspectRatioOptions,\n}: MediaEditorCropPanelProps ) {\n\tconst { state, setZoom } = useMediaEditor();\n\tconst zoomGestureHandlers = useCropGestureHandlers();\n\tconst minZoom = getMinZoom( state );\n\n\treturn (\n\t\t// Tag the whole panel as a crop-control region so the modal's\n\t\t// Cmd+Z handler doesn't mistake the SelectControl / ToggleControl\n\t\t// inputs for metadata fields (which would suppress undo).\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"md\"\n\t\t\t{ ...{ [ CROP_CONTROL_ATTR ]: true } }\n\t\t>\n\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t{ __( 'Crop options' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<SelectControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\tonChange={ onAspectRatioChange }\n\t\t\t\toptions={ aspectRatioOptions.map( ( preset ) => ( {\n\t\t\t\t\tlabel: preset.label,\n\t\t\t\t\tvalue: preset.value.toString(),\n\t\t\t\t} ) ) }\n\t\t\t/>\n\t\t\t<ToggleControl\n\t\t\t\tlabel={ __( 'Show resize handles' ) }\n\t\t\t\tchecked={ freeformCrop }\n\t\t\t\tonChange={ onFreeformChange }\n\t\t\t/>\n\t\t\t<div role=\"presentation\" { ...zoomGestureHandlers }>\n\t\t\t\t<RangeControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Zoom' ) }\n\t\t\t\t\tmin={ minZoom }\n\t\t\t\t\tmax={ MAX_ZOOM }\n\t\t\t\t\tstep={ 0.1 }\n\t\t\t\t\tvalue={ state.zoom }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tonPlacementControlInteraction?.();\n\t\t\t\t\t\tsetZoom( typeof value === 'number' ? value : minZoom );\n\t\t\t\t\t} }\n\t\t\t\t\trenderTooltipContent={ ( value ) => {\n\t\t\t\t\t\tconst zoom =\n\t\t\t\t\t\t\ttypeof value === 'number' ? value : minZoom;\n\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B,GAAG,qBAC7B;AAAA,UAAC;AAAA;AAAA,YACA,uBAAqB;AAAA,YACrB,WAAQ,gBAAI,MAAO;AAAA,YACnB,KAAM;AAAA,YACN,KAAM;AAAA,YACN,MAAO;AAAA,YACP,OAAQ,MAAM;AAAA,YACd,UAAW,CAAE,UAAW;AACvB,8CAAgC;AAChC,sBAAS,OAAO,UAAU,WAAW,QAAQ,OAAQ;AAAA,YACtD;AAAA,YACA,sBAAuB,CAAE,UAAW;AACnC,oBAAM,OACL,OAAO,UAAU,WAAW,QAAQ;AACrC,yBAAO;AAAA;AAAA,oBAEN,gBAAI,MAAO;AAAA,gBACX,KAAK,MAAO,OAAO,GAAI;AAAA,cACxB;AAAA,YACD;AAAA;AAAA,QACD,GACD;AAAA;AAAA;AAAA,EACD;AAEF;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { RangeControl, SelectControl } from '@wordpress/components';\nimport { Stack, VisuallyHidden } from '@wordpress/ui';\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useMediaEditor } from '../../state';\nimport {\n\tuseCropGestureHandlers,\n\tCROP_CONTROL_ATTR,\n} from '../../hooks/use-crop-gesture-handlers';\nimport { MAX_ZOOM } from '../../image-editor/core/constants';\nimport { getMinZoom } from '../../image-editor/core/containment';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\nconst ZOOM_PERCENTAGE_SCALE = 100;\nconst MAX_ZOOM_PERCENTAGE = MAX_ZOOM * ZOOM_PERCENTAGE_SCALE;\n\nfunction getZoomPercentageForDisplay( zoom: number ): number {\n\treturn Math.round( zoom * ZOOM_PERCENTAGE_SCALE );\n}\n\nfunction getMinZoomPercentageForDisplay( zoom: number ): number {\n\treturn Math.ceil( zoom * ZOOM_PERCENTAGE_SCALE );\n}\n\nexport interface MediaEditorCropPanelProps {\n\t/**\n\t * Selected aspect-ratio preset value as a string (so it round-trips\n\t * through `<SelectControl>`). `'0'` = free, `'-1'` = original, any\n\t * positive number = fixed ratio.\n\t */\n\taspectRatioValue: string;\n\t/** Setter for the aspect-ratio preset value. */\n\tonAspectRatioChange: ( value: string ) => void;\n\t/** Signal that a placement-oriented control is being adjusted. */\n\tonPlacementControlInteraction?: () => void;\n\t/** Aspect-ratio presets to display in the selector. */\n\taspectRatioOptions: AspectRatioPreset[];\n}\n\n/**\n * Sidebar panel for crop-shape controls. The tactile verbs (rotate, flip)\n * live in the bottom toolbar instead.\n * @param props\n * @param props.aspectRatioValue\n * @param props.onAspectRatioChange\n * @param props.onPlacementControlInteraction\n * @param props.aspectRatioOptions\n */\nexport default function MediaEditorCropPanel( {\n\taspectRatioValue,\n\tonAspectRatioChange,\n\tonPlacementControlInteraction,\n\taspectRatioOptions,\n}: MediaEditorCropPanelProps ) {\n\tconst { state, setZoom } = useMediaEditor();\n\tconst zoomGestureHandlers = useCropGestureHandlers();\n\tconst minZoom = getMinZoom( state );\n\tconst zoomPercentage = getZoomPercentageForDisplay( state.zoom );\n\tconst minZoomPercentage = getMinZoomPercentageForDisplay( minZoom );\n\n\treturn (\n\t\t// Tag the whole panel as a crop-control region so the modal's\n\t\t// Cmd+Z handler doesn't mistake the SelectControl input for a\n\t\t// metadata field (which would suppress undo).\n\t\t<Stack\n\t\t\tdirection=\"column\"\n\t\t\tgap=\"xl\"\n\t\t\t{ ...{ [ CROP_CONTROL_ATTR ]: true } }\n\t\t>\n\t\t\t<VisuallyHidden render={ <h2 /> }>\n\t\t\t\t{ __( 'Crop options' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<SelectControl\n\t\t\t\t__next40pxDefaultSize\n\t\t\t\tlabel={ __( 'Aspect ratio' ) }\n\t\t\t\tvalue={ aspectRatioValue }\n\t\t\t\tonChange={ onAspectRatioChange }\n\t\t\t\toptions={ aspectRatioOptions.map( ( preset ) => ( {\n\t\t\t\t\tlabel: preset.label,\n\t\t\t\t\tvalue: preset.value.toString(),\n\t\t\t\t} ) ) }\n\t\t\t/>\n\t\t\t<div role=\"presentation\" { ...zoomGestureHandlers }>\n\t\t\t\t<RangeControl\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tlabel={ __( 'Zoom (%)' ) }\n\t\t\t\t\tmin={ minZoomPercentage }\n\t\t\t\t\tmax={ MAX_ZOOM_PERCENTAGE }\n\t\t\t\t\tstep={ 1 }\n\t\t\t\t\tshiftStep={ 10 }\n\t\t\t\t\tvalue={ zoomPercentage }\n\t\t\t\t\tonChange={ ( value ) => {\n\t\t\t\t\t\tonPlacementControlInteraction?.();\n\t\t\t\t\t\tsetZoom(\n\t\t\t\t\t\t\ttypeof value === 'number'\n\t\t\t\t\t\t\t\t? value / ZOOM_PERCENTAGE_SCALE\n\t\t\t\t\t\t\t\t: minZoom\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t\trenderTooltipContent={ ( value ) => {\n\t\t\t\t\t\tconst percentage =\n\t\t\t\t\t\t\ttypeof value === 'number'\n\t\t\t\t\t\t\t\t? value\n\t\t\t\t\t\t\t\t: minZoomPercentage;\n\t\t\t\t\t\treturn sprintf(\n\t\t\t\t\t\t\t/* translators: %d: zoom level as a percentage. */\n\t\t\t\t\t\t\t__( '%d%%' ),\n\t\t\t\t\t\t\tMath.round( percentage )\n\t\t\t\t\t\t);\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</Stack>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAA4C;AAC5C,gBAAsC;AACtC,kBAA4B;AAK5B,mBAA+B;AAC/B,uCAGO;AACP,uBAAyB;AACzB,yBAA2B;AAsDzB;AAAA;AAAA;AAAA;AAAA;AAAA;AAnDF,IAAM,wBAAwB;AAC9B,IAAM,sBAAsB,4BAAW;AAEvC,SAAS,4BAA6B,MAAuB;AAC5D,SAAO,KAAK,MAAO,OAAO,qBAAsB;AACjD;AAEA,SAAS,+BAAgC,MAAuB;AAC/D,SAAO,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AA,YACD;AAAA;AAAA,QACD,GACD;AAAA;AAAA;AAAA,EACD;AAEF;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // packages/media-editor/src/components/media-editor-fine-rotation/index.tsx
31
+ var media_editor_fine_rotation_exports = {};
32
+ __export(media_editor_fine_rotation_exports, {
33
+ default: () => MediaEditorFineRotation
34
+ });
35
+ module.exports = __toCommonJS(media_editor_fine_rotation_exports);
36
+ var import_i18n = require("@wordpress/i18n");
37
+ var import_state = require("../../state/index.cjs");
38
+ var import_use_crop_gesture_handlers = require("../../hooks/use-crop-gesture-handlers.cjs");
39
+ var import_constants = require("../../image-editor/core/constants.cjs");
40
+ var import_rotation_ruler = __toESM(require("../rotation-ruler/index.cjs"));
41
+ var import_jsx_runtime = require("react/jsx-runtime");
42
+ function MediaEditorFineRotation({
43
+ onPlacementControlInteraction
44
+ }) {
45
+ const { state, setRotation } = (0, import_state.useMediaEditor)();
46
+ const rotationGestureHandlers = (0, import_use_crop_gesture_handlers.useCropGestureHandlers)({
47
+ commitOnKeyUp: false
48
+ });
49
+ const baseAngle = Math.round(state.rotation / 90) * 90;
50
+ const singleFlip = state.flip.horizontal !== state.flip.vertical;
51
+ const visualDir = singleFlip ? -1 : 1;
52
+ const fineOffset = (state.rotation - baseAngle) * visualDir;
53
+ const handleRotationSlider = (value) => {
54
+ const EPS = 0.01;
55
+ const clamped = Math.max(
56
+ -import_constants.MAX_ROTATION_OFFSET + EPS,
57
+ Math.min(import_constants.MAX_ROTATION_OFFSET - EPS, value)
58
+ );
59
+ onPlacementControlInteraction?.();
60
+ setRotation(baseAngle + clamped * visualDir);
61
+ };
62
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
63
+ "div",
64
+ {
65
+ role: "presentation",
66
+ className: "media-editor-fine-rotation",
67
+ ...rotationGestureHandlers,
68
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
+ import_rotation_ruler.default,
70
+ {
71
+ label: (0, import_i18n.__)("Fine rotation"),
72
+ min: -import_constants.MAX_ROTATION_OFFSET,
73
+ max: import_constants.MAX_ROTATION_OFFSET,
74
+ value: fineOffset,
75
+ onChange: handleRotationSlider
76
+ }
77
+ )
78
+ }
79
+ );
80
+ }
81
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/media-editor-fine-rotation/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { useMediaEditor } from '../../state';\nimport { useCropGestureHandlers } from '../../hooks/use-crop-gesture-handlers';\nimport { MAX_ROTATION_OFFSET } from '../../image-editor/core/constants';\nimport RotationRuler from '../rotation-ruler';\n\nexport interface MediaEditorFineRotationProps {\n\t/** Signal that a placement-oriented control is being adjusted. */\n\tonPlacementControlInteraction?: () => void;\n}\n\n/**\n * Fine-rotation slider for the media-editor footer. Lives separately from\n * the snap-rotate / flip buttons so the footer can place the two halves on\n * different rows at intermediate viewport widths.\n *\n * @param props\n * @param props.onPlacementControlInteraction\n */\nexport default function MediaEditorFineRotation( {\n\tonPlacementControlInteraction,\n}: MediaEditorFineRotationProps ) {\n\tconst { state, setRotation } = useMediaEditor();\n\t// `commitOnKeyUp: false` lets rapid arrow-key adjustments coalesce\n\t// into one undo entry via the gesture idle window. Pointer-up still\n\t// closes pointer drags immediately.\n\tconst rotationGestureHandlers = useCropGestureHandlers( {\n\t\tcommitOnKeyUp: false,\n\t} );\n\n\t// `setRotation` is an absolute-angle setter. When a single flip is active\n\t// the visual direction inverts, so slider input must flip sign to match\n\t// what the user sees. `snapRotate90` already handles this internally.\n\tconst baseAngle = Math.round( state.rotation / 90 ) * 90;\n\tconst singleFlip = state.flip.horizontal !== state.flip.vertical;\n\tconst visualDir = singleFlip ? -1 : 1;\n\tconst fineOffset = ( state.rotation - baseAngle ) * visualDir;\n\n\tconst handleRotationSlider = ( value: number ) => {\n\t\t// Clamp strictly inside [-MAX, MAX). Exactly \u00B1MAX lands state on a\n\t\t// 90\u00B0 midpoint and flips the derived baseAngle on the next render,\n\t\t// causing subsequent events to spiral.\n\t\tconst EPS = 0.01;\n\t\tconst clamped = Math.max(\n\t\t\t-MAX_ROTATION_OFFSET + EPS,\n\t\t\tMath.min( MAX_ROTATION_OFFSET - EPS, value )\n\t\t);\n\t\tonPlacementControlInteraction?.();\n\t\tsetRotation( baseAngle + clamped * visualDir );\n\t};\n\n\treturn (\n\t\t<div\n\t\t\trole=\"presentation\"\n\t\t\tclassName=\"media-editor-fine-rotation\"\n\t\t\t{ ...rotationGestureHandlers }\n\t\t>\n\t\t\t<RotationRuler\n\t\t\t\tlabel={ __( 'Fine rotation' ) }\n\t\t\t\tmin={ -MAX_ROTATION_OFFSET }\n\t\t\t\tmax={ MAX_ROTATION_OFFSET }\n\t\t\t\tvalue={ fineOffset }\n\t\t\t\tonChange={ handleRotationSlider }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,kBAAmB;AAKnB,mBAA+B;AAC/B,uCAAuC;AACvC,uBAAoC;AACpC,4BAA0B;AAqDvB;AAtCY,SAAR,wBAA0C;AAAA,EAChD;AACD,GAAkC;AACjC,QAAM,EAAE,OAAO,YAAY,QAAI,6BAAe;AAI9C,QAAM,8BAA0B,yDAAwB;AAAA,IACvD,eAAe;AAAA,EAChB,CAAE;AAKF,QAAM,YAAY,KAAK,MAAO,MAAM,WAAW,EAAG,IAAI;AACtD,QAAM,aAAa,MAAM,KAAK,eAAe,MAAM,KAAK;AACxD,QAAM,YAAY,aAAa,KAAK;AACpC,QAAM,cAAe,MAAM,WAAW,aAAc;AAEpD,QAAM,uBAAuB,CAAE,UAAmB;AAIjD,UAAM,MAAM;AACZ,UAAM,UAAU,KAAK;AAAA,MACpB,CAAC,uCAAsB;AAAA,MACvB,KAAK,IAAK,uCAAsB,KAAK,KAAM;AAAA,IAC5C;AACA,oCAAgC;AAChC,gBAAa,YAAY,UAAU,SAAU;AAAA,EAC9C;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,MAAK;AAAA,MACL,WAAU;AAAA,MACR,GAAG;AAAA,MAEL;AAAA,QAAC,sBAAAA;AAAA,QAAA;AAAA,UACA,WAAQ,gBAAI,eAAgB;AAAA,UAC5B,KAAM,CAAC;AAAA,UACP,KAAM;AAAA,UACN,OAAQ;AAAA,UACR,UAAW;AAAA;AAAA,MACZ;AAAA;AAAA,EACD;AAEF;",
6
+ "names": ["RotationRuler"]
7
+ }
@@ -46,12 +46,13 @@ function MediaEditorModal({
46
46
  fields = [],
47
47
  aspectRatioPresets
48
48
  }) {
49
- const { isModalOpen, id, onUpdate } = (0, import_data.useSelect)((select) => {
50
- const { isOpen, getId, getOnUpdate } = select(import_store.store);
49
+ const { isModalOpen, id, onUpdate, onClose } = (0, import_data.useSelect)((select) => {
50
+ const { isOpen, getId, getOnUpdate, getOnClose } = select(import_store.store);
51
51
  return {
52
52
  isModalOpen: isOpen(),
53
53
  id: getId(),
54
- onUpdate: getOnUpdate()
54
+ onUpdate: getOnUpdate(),
55
+ onClose: getOnClose()
55
56
  };
56
57
  }, []);
57
58
  const { closeMediaEditorModal } = (0, import_data.useDispatch)(import_store.store);
@@ -63,6 +64,10 @@ function MediaEditorModal({
63
64
  const stopKeyDownPropagation = (event) => {
64
65
  event.stopPropagation();
65
66
  };
67
+ const handleClose = () => {
68
+ closeMediaEditorModal();
69
+ onClose?.();
70
+ };
66
71
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
67
72
  import_media_editor.default,
68
73
  {
@@ -73,7 +78,7 @@ function MediaEditorModal({
73
78
  shouldCloseOnEsc: true,
74
79
  noticesClassName: "media-editor-modal__snackbar",
75
80
  noticesPortalElement: portalElement,
76
- onClose: closeMediaEditorModal,
81
+ onClose: handleClose,
77
82
  onSaved: ({ id: savedId, url, previous }) => {
78
83
  if (savedId && onUpdate) {
79
84
  const update = {
@@ -82,7 +87,7 @@ function MediaEditorModal({
82
87
  };
83
88
  onUpdate(update);
84
89
  }
85
- closeMediaEditorModal();
90
+ handleClose();
86
91
  if (previous && savedId !== previous.id && onUpdate) {
87
92
  createSuccessNotice((0, import_i18n.__)("Image edited."), {
88
93
  type: "snackbar",
@@ -103,6 +108,8 @@ function MediaEditorModal({
103
108
  renderFrame: ({
104
109
  children,
105
110
  headerActions,
111
+ footerActions,
112
+ footerLayout,
106
113
  onRequestClose,
107
114
  onKeyDown,
108
115
  shouldCloseOnClickOutside
@@ -111,7 +118,7 @@ function MediaEditorModal({
111
118
  {
112
119
  className: "media-editor-modal__shortcut-scope",
113
120
  onKeyDown: stopKeyDownPropagation,
114
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
121
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
115
122
  import_components.Modal,
116
123
  {
117
124
  className: "media-editor-modal",
@@ -122,7 +129,18 @@ function MediaEditorModal({
122
129
  onKeyDown,
123
130
  onRequestClose,
124
131
  headerActions,
125
- children
132
+ children: [
133
+ children,
134
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
135
+ "div",
136
+ {
137
+ className: `media-editor-modal__footer is-${footerLayout}`,
138
+ role: "region",
139
+ "aria-label": (0, import_i18n.__)("Editor actions"),
140
+ children: footerActions
141
+ }
142
+ )
143
+ ]
126
144
  }
127
145
  )
128
146
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/media-editor-modal/index.tsx"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Field } from '@wordpress/dataviews';\nimport type { KeyboardEvent as ReactKeyboardEvent } from 'react';\n\n/**\n * Internal dependencies\n */\nimport MediaEditor from '../media-editor';\nimport type { Media } from '../media-editor-provider';\nimport { store as mediaEditorStore } from '../../store';\nimport type { MediaEditorModalUpdate } from '../../store/actions';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\ninterface MediaEditorModalProps {\n\t/**\n\t * Attachment fields to render in the Details tab.\n\t *\n\t * Passed from the editor layer (which owns the `usePostFields` hook),\n\t * since `@wordpress/media-editor` cannot depend on `@wordpress/editor`.\n\t */\n\tfields?: Field< Media >[];\n\t/**\n\t * Fixed aspect-ratio presets for image cropping. Free and Original are\n\t * always provided by the media editor.\n\t */\n\taspectRatioPresets?: AspectRatioPreset[];\n}\n\nexport function MediaEditorModal( {\n\tfields = [],\n\taspectRatioPresets,\n}: MediaEditorModalProps ) {\n\tconst { isModalOpen, id, onUpdate } = useSelect( ( select ) => {\n\t\tconst { isOpen, getId, getOnUpdate } = select( mediaEditorStore );\n\t\treturn {\n\t\t\tisModalOpen: isOpen(),\n\t\t\tid: getId(),\n\t\t\tonUpdate: getOnUpdate(),\n\t\t};\n\t}, [] );\n\n\tconst { closeMediaEditorModal } = useDispatch( mediaEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tif ( ! isModalOpen || ! id ) {\n\t\treturn null;\n\t}\n\n\tconst portalElement =\n\t\ttypeof document === 'undefined' ? null : document.body;\n\n\t// React synthetic events bubble through the React tree, not the DOM tree,\n\t// so a host `ShortcutProvider` higher up still receives keydown events\n\t// from inside this portaled modal. Stop propagation at the modal boundary\n\t// so host shortcuts (undo/redo, save, etc.) don't fire from within.\n\tconst stopKeyDownPropagation = (\n\t\tevent: ReactKeyboardEvent< HTMLDivElement >\n\t) => {\n\t\tevent.stopPropagation();\n\t};\n\n\treturn (\n\t\t<MediaEditor\n\t\t\tid={ id }\n\t\t\tfields={ fields }\n\t\t\taspectRatioPresets={ aspectRatioPresets }\n\t\t\tshowCloseButton\n\t\t\tshouldCloseOnEsc\n\t\t\tnoticesClassName=\"media-editor-modal__snackbar\"\n\t\t\tnoticesPortalElement={ portalElement }\n\t\t\tonClose={ closeMediaEditorModal }\n\t\t\tonSaved={ ( { id: savedId, url, previous } ) => {\n\t\t\t\tif ( savedId && onUpdate ) {\n\t\t\t\t\tconst update: MediaEditorModalUpdate = {\n\t\t\t\t\t\tid: savedId,\n\t\t\t\t\t\turl,\n\t\t\t\t\t};\n\t\t\t\t\tonUpdate( update );\n\t\t\t\t}\n\t\t\t\tcloseMediaEditorModal();\n\t\t\t\tif ( previous && savedId !== previous.id && onUpdate ) {\n\t\t\t\t\t// Intentionally unscoped: the modal is closing, so the\n\t\t\t\t\t// snackbar surfaces in the host editor (not the media\n\t\t\t\t\t// editor's `MEDIA_EDITOR_NOTICES_CONTEXT` region).\n\t\t\t\t\tcreateSuccessNotice( __( 'Image edited.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\tonUpdate( {\n\t\t\t\t\t\t\t\t\t\tid: previous.id,\n\t\t\t\t\t\t\t\t\t\turl: previous.url,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} }\n\t\t\trenderFrame={ ( {\n\t\t\t\tchildren,\n\t\t\t\theaderActions,\n\t\t\t\tonRequestClose,\n\t\t\t\tonKeyDown,\n\t\t\t\tshouldCloseOnClickOutside,\n\t\t\t} ) => (\n\t\t\t\t<ShortcutProvider\n\t\t\t\t\tclassName=\"media-editor-modal__shortcut-scope\"\n\t\t\t\t\tonKeyDown={ stopKeyDownPropagation }\n\t\t\t\t>\n\t\t\t\t\t<Modal\n\t\t\t\t\t\tclassName=\"media-editor-modal\"\n\t\t\t\t\t\ttitle={ __( 'Edit media' ) }\n\t\t\t\t\t\tsize=\"fill\"\n\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\tshouldCloseOnClickOutside={ shouldCloseOnClickOutside }\n\t\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t\t\tonRequestClose={ onRequestClose }\n\t\t\t\t\t\theaderActions={ headerActions }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t</Modal>\n\t\t\t\t</ShortcutProvider>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default MediaEditorModal;\n"],
5
- "mappings": ";;;;;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MAAM;AAAA,YACN,SAAS;AAAA,cACR;AAAA,gBACC,WAAO,gBAAI,MAAO;AAAA,gBAClB,SAAS,MAAM;AACd,2BAAU;AAAA,oBACT,IAAI,SAAS;AAAA,oBACb,KAAK,SAAS;AAAA,kBACf,CAAE;AAAA,gBACH;AAAA,cACD;AAAA,YACD;AAAA,UACD,CAAE;AAAA,QACH;AAAA,MACD;AAAA,MACA,aAAc,CAAE;AAAA,QACf;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACD,MACC;AAAA,QAAC;AAAA;AAAA,UACA,WAAU;AAAA,UACV,WAAY;AAAA,UAEZ;AAAA,YAAC;AAAA;AAAA,cACA,WAAU;AAAA,cACV,WAAQ,gBAAI,YAAa;AAAA,cACzB,MAAK;AAAA,cACL,eAAgB;AAAA,cAChB;AAAA,cACA;AAAA,cACA;AAAA,cACA;AAAA,cAEE;AAAA;AAAA,UACH;AAAA;AAAA,MACD;AAAA;AAAA,EAEF;AAEF;AAEA,IAAO,6BAAQ;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Modal } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport { ShortcutProvider } from '@wordpress/keyboard-shortcuts';\nimport { store as noticesStore } from '@wordpress/notices';\nimport type { Field } from '@wordpress/dataviews';\nimport type { KeyboardEvent as ReactKeyboardEvent } from 'react';\n\n/**\n * Internal dependencies\n */\nimport MediaEditor from '../media-editor';\nimport type { Media } from '../media-editor-provider';\nimport { store as mediaEditorStore } from '../../store';\nimport type { MediaEditorModalUpdate } from '../../store/actions';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\n\ninterface MediaEditorModalProps {\n\t/**\n\t * Attachment fields to render in the Details tab.\n\t *\n\t * Passed from the editor layer (which owns the `usePostFields` hook),\n\t * since `@wordpress/media-editor` cannot depend on `@wordpress/editor`.\n\t */\n\tfields?: Field< Media >[];\n\t/**\n\t * Fixed aspect-ratio presets for image cropping. Free and Original are\n\t * always provided by the media editor.\n\t */\n\taspectRatioPresets?: AspectRatioPreset[];\n}\n\nexport function MediaEditorModal( {\n\tfields = [],\n\taspectRatioPresets,\n}: MediaEditorModalProps ) {\n\tconst { isModalOpen, id, onUpdate, onClose } = useSelect( ( select ) => {\n\t\tconst { isOpen, getId, getOnUpdate, getOnClose } =\n\t\t\tselect( mediaEditorStore );\n\t\treturn {\n\t\t\tisModalOpen: isOpen(),\n\t\t\tid: getId(),\n\t\t\tonUpdate: getOnUpdate(),\n\t\t\tonClose: getOnClose(),\n\t\t};\n\t}, [] );\n\n\tconst { closeMediaEditorModal } = useDispatch( mediaEditorStore );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\n\tif ( ! isModalOpen || ! id ) {\n\t\treturn null;\n\t}\n\n\tconst portalElement =\n\t\ttypeof document === 'undefined' ? null : document.body;\n\n\t// React synthetic events bubble through the React tree, not the DOM tree,\n\t// so a host `ShortcutProvider` higher up still receives keydown events\n\t// from inside this portaled modal. Stop propagation at the modal boundary\n\t// so host shortcuts (undo/redo, save, etc.) don't fire from within.\n\tconst stopKeyDownPropagation = (\n\t\tevent: ReactKeyboardEvent< HTMLDivElement >\n\t) => {\n\t\tevent.stopPropagation();\n\t};\n\n\tconst handleClose = () => {\n\t\tcloseMediaEditorModal();\n\t\tonClose?.();\n\t};\n\n\treturn (\n\t\t<MediaEditor\n\t\t\tid={ id }\n\t\t\tfields={ fields }\n\t\t\taspectRatioPresets={ aspectRatioPresets }\n\t\t\tshowCloseButton\n\t\t\tshouldCloseOnEsc\n\t\t\tnoticesClassName=\"media-editor-modal__snackbar\"\n\t\t\tnoticesPortalElement={ portalElement }\n\t\t\tonClose={ handleClose }\n\t\t\tonSaved={ ( { id: savedId, url, previous } ) => {\n\t\t\t\tif ( savedId && onUpdate ) {\n\t\t\t\t\tconst update: MediaEditorModalUpdate = {\n\t\t\t\t\t\tid: savedId,\n\t\t\t\t\t\turl,\n\t\t\t\t\t};\n\t\t\t\t\tonUpdate( update );\n\t\t\t\t}\n\t\t\t\thandleClose();\n\t\t\t\tif ( previous && savedId !== previous.id && onUpdate ) {\n\t\t\t\t\t// Intentionally unscoped: the modal is closing, so the\n\t\t\t\t\t// snackbar surfaces in the host editor (not the media\n\t\t\t\t\t// editor's `MEDIA_EDITOR_NOTICES_CONTEXT` region).\n\t\t\t\t\tcreateSuccessNotice( __( 'Image edited.' ), {\n\t\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t\t\tactions: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tlabel: __( 'Undo' ),\n\t\t\t\t\t\t\t\tonClick: () => {\n\t\t\t\t\t\t\t\t\tonUpdate( {\n\t\t\t\t\t\t\t\t\t\tid: previous.id,\n\t\t\t\t\t\t\t\t\t\turl: previous.url,\n\t\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t],\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t} }\n\t\t\trenderFrame={ ( {\n\t\t\t\tchildren,\n\t\t\t\theaderActions,\n\t\t\t\tfooterActions,\n\t\t\t\tfooterLayout,\n\t\t\t\tonRequestClose,\n\t\t\t\tonKeyDown,\n\t\t\t\tshouldCloseOnClickOutside,\n\t\t\t} ) => (\n\t\t\t\t<ShortcutProvider\n\t\t\t\t\tclassName=\"media-editor-modal__shortcut-scope\"\n\t\t\t\t\tonKeyDown={ stopKeyDownPropagation }\n\t\t\t\t>\n\t\t\t\t\t<Modal\n\t\t\t\t\t\tclassName=\"media-editor-modal\"\n\t\t\t\t\t\ttitle={ __( 'Edit media' ) }\n\t\t\t\t\t\tsize=\"fill\"\n\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\tshouldCloseOnClickOutside={ shouldCloseOnClickOutside }\n\t\t\t\t\t\tonKeyDown={ onKeyDown }\n\t\t\t\t\t\tonRequestClose={ onRequestClose }\n\t\t\t\t\t\theaderActions={ headerActions }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ children }\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tclassName={ `media-editor-modal__footer is-${ footerLayout }` }\n\t\t\t\t\t\t\trole=\"region\"\n\t\t\t\t\t\t\taria-label={ __( 'Editor actions' ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ footerActions }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</Modal>\n\t\t\t\t</ShortcutProvider>\n\t\t\t) }\n\t\t/>\n\t);\n}\n\nexport default MediaEditorModal;\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAsB;AACtB,kBAAuC;AACvC,kBAAmB;AACnB,gCAAiC;AACjC,qBAAsC;AAOtC,0BAAwB;AAExB,mBAA0C;AA+GrC;AA5FE,SAAS,iBAAkB;AAAA,EACjC,SAAS,CAAC;AAAA,EACV;AACD,GAA2B;AAC1B,QAAM,EAAE,aAAa,IAAI,UAAU,QAAQ,QAAI,uBAAW,CAAE,WAAY;AACvE,UAAM,EAAE,QAAQ,OAAO,aAAa,WAAW,IAC9C,OAAQ,aAAAA,KAAiB;AAC1B,WAAO;AAAA,MACN,aAAa,OAAO;AAAA,MACpB,IAAI,MAAM;AAAA,MACV,UAAU,YAAY;AAAA,MACtB,SAAS,WAAW;AAAA,IACrB;AAAA,EACD,GAAG,CAAC,CAAE;AAEN,QAAM,EAAE,sBAAsB,QAAI,yBAAa,aAAAA,KAAiB;AAChE,QAAM,EAAE,oBAAoB,QAAI,yBAAa,eAAAC,KAAa;AAE1D,MAAK,CAAE,eAAe,CAAE,IAAK;AAC5B,WAAO;AAAA,EACR;AAEA,QAAM,gBACL,OAAO,aAAa,cAAc,OAAO,SAAS;AAMnD,QAAM,yBAAyB,CAC9B,UACI;AACJ,UAAM,gBAAgB;AAAA,EACvB;AAEA,QAAM,cAAc,MAAM;AACzB,0BAAsB;AACtB,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;AAAA,MACD;AAAA;AAAA,EAEF;AAEF;AAEA,IAAO,6BAAQ;",
6
6
  "names": ["mediaEditorStore", "noticesStore", "MediaEditor"]
7
7
  }
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // packages/media-editor/src/components/media-editor-transform-controls/index.tsx
21
+ var media_editor_transform_controls_exports = {};
22
+ __export(media_editor_transform_controls_exports, {
23
+ default: () => MediaEditorTransformControls
24
+ });
25
+ module.exports = __toCommonJS(media_editor_transform_controls_exports);
26
+ var import_components = require("@wordpress/components");
27
+ var import_i18n = require("@wordpress/i18n");
28
+ var import_icons = require("@wordpress/icons");
29
+ var import_state = require("../../state/index.cjs");
30
+ var import_jsx_runtime = require("react/jsx-runtime");
31
+ function MediaEditorTransformControls() {
32
+ const { state, setFlip, snapRotate90 } = (0, import_state.useMediaEditor)();
33
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "media-editor-transform-controls", children: [
34
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
35
+ import_components.Button,
36
+ {
37
+ size: "compact",
38
+ icon: import_icons.rotateLeft,
39
+ label: (0, import_i18n.__)("Rotate 90\xB0 counter-clockwise"),
40
+ showTooltip: true,
41
+ onClick: () => snapRotate90(-1)
42
+ }
43
+ ),
44
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
45
+ import_components.Button,
46
+ {
47
+ size: "compact",
48
+ icon: import_icons.rotateRight,
49
+ label: (0, import_i18n.__)("Rotate 90\xB0 clockwise"),
50
+ showTooltip: true,
51
+ onClick: () => snapRotate90(1)
52
+ }
53
+ ),
54
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
55
+ import_components.Button,
56
+ {
57
+ size: "compact",
58
+ icon: import_icons.flipHorizontal,
59
+ label: (0, import_i18n.__)("Flip horizontal"),
60
+ showTooltip: true,
61
+ isPressed: state.flip.horizontal,
62
+ onClick: () => setFlip({
63
+ horizontal: !state.flip.horizontal,
64
+ vertical: state.flip.vertical
65
+ })
66
+ }
67
+ ),
68
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
69
+ import_components.Button,
70
+ {
71
+ size: "compact",
72
+ icon: import_icons.flipVertical,
73
+ label: (0, import_i18n.__)("Flip vertical"),
74
+ showTooltip: true,
75
+ isPressed: state.flip.vertical,
76
+ onClick: () => setFlip({
77
+ horizontal: state.flip.horizontal,
78
+ vertical: !state.flip.vertical
79
+ })
80
+ }
81
+ )
82
+ ] });
83
+ }
84
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/media-editor-transform-controls/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { Button } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport {\n\trotateLeft,\n\trotateRight,\n\tflipHorizontal,\n\tflipVertical,\n} from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport { useMediaEditor } from '../../state';\n\n/**\n * Snap-rotate and flip controls for the media-editor footer. Rotation and\n * reflection are both geometric transforms, hence \"transform controls\".\n * Lives separately from the fine-rotation slider so the footer can place\n * the two halves on different rows at intermediate viewport widths.\n */\nexport default function MediaEditorTransformControls() {\n\tconst { state, setFlip, snapRotate90 } = useMediaEditor();\n\treturn (\n\t\t<div className=\"media-editor-transform-controls\">\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateLeft }\n\t\t\t\tlabel={ __( 'Rotate 90\u00B0 counter-clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tonClick={ () => snapRotate90( -1 ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ rotateRight }\n\t\t\t\tlabel={ __( 'Rotate 90\u00B0 clockwise' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tonClick={ () => snapRotate90( 1 ) }\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipHorizontal }\n\t\t\t\tlabel={ __( 'Flip horizontal' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.horizontal }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: ! state.flip.horizontal,\n\t\t\t\t\t\tvertical: state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\ticon={ flipVertical }\n\t\t\t\tlabel={ __( 'Flip vertical' ) }\n\t\t\t\tshowTooltip\n\t\t\t\tisPressed={ state.flip.vertical }\n\t\t\t\tonClick={ () =>\n\t\t\t\t\tsetFlip( {\n\t\t\t\t\t\thorizontal: state.flip.horizontal,\n\t\t\t\t\t\tvertical: ! state.flip.vertical,\n\t\t\t\t\t} )\n\t\t\t\t}\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,wBAAuB;AACvB,kBAAmB;AACnB,mBAKO;AAKP,mBAA+B;AAW7B;AAHa,SAAR,+BAAgD;AACtD,QAAM,EAAE,OAAO,SAAS,aAAa,QAAI,6BAAe;AACxD,SACC,6CAAC,SAAI,WAAU,mCACd;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,WAAQ,gBAAI,iCAA+B;AAAA,QAC3C,aAAW;AAAA,QACX,SAAU,MAAM,aAAc,EAAG;AAAA;AAAA,IAClC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,WAAQ,gBAAI,yBAAuB;AAAA,QACnC,aAAW;AAAA,QACX,SAAU,MAAM,aAAc,CAAE;AAAA;AAAA,IACjC;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,WAAQ,gBAAI,iBAAkB;AAAA,QAC9B,aAAW;AAAA,QACX,WAAY,MAAM,KAAK;AAAA,QACvB,SAAU,MACT,QAAS;AAAA,UACR,YAAY,CAAE,MAAM,KAAK;AAAA,UACzB,UAAU,MAAM,KAAK;AAAA,QACtB,CAAE;AAAA;AAAA,IAEJ;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACA,MAAK;AAAA,QACL,MAAO;AAAA,QACP,WAAQ,gBAAI,eAAgB;AAAA,QAC5B,aAAW;AAAA,QACX,WAAY,MAAM,KAAK;AAAA,QACvB,SAAU,MACT,QAAS;AAAA,UACR,YAAY,MAAM,KAAK;AAAA,UACvB,UAAU,CAAE,MAAM,KAAK;AAAA,QACxB,CAAE;AAAA;AAAA,IAEJ;AAAA,KACD;AAEF;",
6
+ "names": []
7
+ }
@@ -31,7 +31,7 @@ var KEYBOARD_GESTURE_IDLE_MS = 300;
31
31
  function useCropGestureHandlers(options = {}) {
32
32
  const { commitOnKeyUp = true } = options;
33
33
  const { beginGesture, endGesture } = (0, import_state.useMediaEditor)();
34
- const keyboardTimerRef = (0, import_element.useRef)(void 0);
34
+ const keyboardTimerRef = (0, import_element.useRef)();
35
35
  const clearKeyboardTimer = (0, import_element.useCallback)(() => {
36
36
  clearTimeout(keyboardTimerRef.current);
37
37
  }, []);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/hooks/use-crop-gesture-handlers.ts"],
4
- "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useMediaEditor } from '../state';\n\n/**\n * Data attribute applied to crop control wrappers. The modal's keyboard\n * shortcut handler uses this to distinguish crop controls (where custom\n * undo/redo should fire) from metadata text fields (where the browser's\n * native undo should be preserved).\n */\nexport const CROP_CONTROL_ATTR = 'data-crop-control';\n\n/** Idle window used to group repeated keyboard input into one gesture. */\nconst KEYBOARD_GESTURE_IDLE_MS = 300;\n\nexport interface UseCropGestureHandlersOptions {\n\t/**\n\t * When `true` (default), key-up closes the gesture so each\n\t * discrete keypress becomes its own undo step. Set to `false` for\n\t * continuous-input controls (e.g. the rotation ruler) where rapid\n\t * keypresses should coalesce into a single history entry across\n\t * the whole gesture.\n\t */\n\tcommitOnKeyUp?: boolean;\n}\n\n/**\n * Event handler props to spread onto a wrapper element around a crop\n * control. Marks the wrapper as a crop control (via `data-crop-control`)\n * so the modal's Cmd+Z handler can identify it, and wires gesture\n * boundaries on the composite store so a slider drag becomes a single\n * undo entry rather than one per tick.\n *\n * Usage:\n * const gestureHandlers = useCropGestureHandlers();\n * <div role=\"presentation\" { ...gestureHandlers }>\n * <RangeControl ... />\n * </div>\n *\n * @param options Optional behavior flags.\n */\nexport function useCropGestureHandlers(\n\toptions: UseCropGestureHandlersOptions = {}\n) {\n\tconst { commitOnKeyUp = true } = options;\n\tconst { beginGesture, endGesture } = useMediaEditor();\n\tconst keyboardTimerRef = useRef<\n\t\tReturnType< typeof setTimeout > | undefined\n\t>( undefined );\n\n\tconst clearKeyboardTimer = useCallback( () => {\n\t\tclearTimeout( keyboardTimerRef.current );\n\t}, [] );\n\n\tconst scheduleKeyboardEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tkeyboardTimerRef.current = setTimeout( () => {\n\t\t\tendGesture();\n\t\t}, KEYBOARD_GESTURE_IDLE_MS );\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tuseEffect( () => clearKeyboardTimer, [ clearKeyboardTimer ] );\n\n\tconst handlePointerDownCapture = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tbeginGesture();\n\t}, [ beginGesture, clearKeyboardTimer ] );\n\n\tconst handlePointerEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tendGesture();\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tconst handleKeyDownCapture = useCallback( () => {\n\t\tbeginGesture();\n\t\tif ( ! commitOnKeyUp ) {\n\t\t\tscheduleKeyboardEnd();\n\t\t}\n\t}, [ beginGesture, commitOnKeyUp, scheduleKeyboardEnd ] );\n\n\tconst handleKeyUp = useCallback( () => {\n\t\tif ( commitOnKeyUp ) {\n\t\t\tendGesture();\n\t\t\treturn;\n\t\t}\n\t\tscheduleKeyboardEnd();\n\t}, [ commitOnKeyUp, endGesture, scheduleKeyboardEnd ] );\n\n\treturn {\n\t\t[ CROP_CONTROL_ATTR ]: true,\n\t\tonPointerDownCapture: handlePointerDownCapture,\n\t\tonPointerUp: handlePointerEnd,\n\t\tonPointerCancel: handlePointerEnd,\n\t\tonKeyDownCapture: handleKeyDownCapture,\n\t\tonKeyUp: handleKeyUp,\n\t};\n}\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA+C;AAK/C,mBAA+B;AAQxB,IAAM,oBAAoB;AAGjC,IAAM,2BAA2B;AA4B1B,SAAS,uBACf,UAAyC,CAAC,GACzC;AACD,QAAM,EAAE,gBAAgB,KAAK,IAAI;AACjC,QAAM,EAAE,cAAc,WAAW,QAAI,6BAAe;AACpD,QAAM,uBAAmB,uBAEtB,MAAU;AAEb,QAAM,yBAAqB,4BAAa,MAAM;AAC7C,iBAAc,iBAAiB,OAAQ;AAAA,EACxC,GAAG,CAAC,CAAE;AAEN,QAAM,0BAAsB,4BAAa,MAAM;AAC9C,uBAAmB;AACnB,qBAAiB,UAAU,WAAY,MAAM;AAC5C,iBAAW;AAAA,IACZ,GAAG,wBAAyB;AAAA,EAC7B,GAAG,CAAE,oBAAoB,UAAW,CAAE;AAEtC,gCAAW,MAAM,oBAAoB,CAAE,kBAAmB,CAAE;AAE5D,QAAM,+BAA2B,4BAAa,MAAM;AACnD,uBAAmB;AACnB,iBAAa;AAAA,EACd,GAAG,CAAE,cAAc,kBAAmB,CAAE;AAExC,QAAM,uBAAmB,4BAAa,MAAM;AAC3C,uBAAmB;AACnB,eAAW;AAAA,EACZ,GAAG,CAAE,oBAAoB,UAAW,CAAE;AAEtC,QAAM,2BAAuB,4BAAa,MAAM;AAC/C,iBAAa;AACb,QAAK,CAAE,eAAgB;AACtB,0BAAoB;AAAA,IACrB;AAAA,EACD,GAAG,CAAE,cAAc,eAAe,mBAAoB,CAAE;AAExD,QAAM,kBAAc,4BAAa,MAAM;AACtC,QAAK,eAAgB;AACpB,iBAAW;AACX;AAAA,IACD;AACA,wBAAoB;AAAA,EACrB,GAAG,CAAE,eAAe,YAAY,mBAAoB,CAAE;AAEtD,SAAO;AAAA,IACN,CAAE,iBAAkB,GAAG;AAAA,IACvB,sBAAsB;AAAA,IACtB,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,SAAS;AAAA,EACV;AACD;",
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport { useCallback, useEffect, useRef } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport { useMediaEditor } from '../state';\n\n/**\n * Data attribute applied to crop control wrappers. The modal's keyboard\n * shortcut handler uses this to distinguish crop controls (where custom\n * undo/redo should fire) from metadata text fields (where the browser's\n * native undo should be preserved).\n */\nexport const CROP_CONTROL_ATTR = 'data-crop-control';\n\n/** Idle window used to group repeated keyboard input into one gesture. */\nconst KEYBOARD_GESTURE_IDLE_MS = 300;\n\nexport interface UseCropGestureHandlersOptions {\n\t/**\n\t * When `true` (default), key-up closes the gesture so each\n\t * discrete keypress becomes its own undo step. Set to `false` for\n\t * continuous-input controls (e.g. the rotation ruler) where rapid\n\t * keypresses should coalesce into a single history entry across\n\t * the whole gesture.\n\t */\n\tcommitOnKeyUp?: boolean;\n}\n\n/**\n * Event handler props to spread onto a wrapper element around a crop\n * control. Marks the wrapper as a crop control (via `data-crop-control`)\n * so the modal's Cmd+Z handler can identify it, and wires gesture\n * boundaries on the composite store so a slider drag becomes a single\n * undo entry rather than one per tick.\n *\n * Usage:\n * const gestureHandlers = useCropGestureHandlers();\n * <div role=\"presentation\" { ...gestureHandlers }>\n * <RangeControl ... />\n * </div>\n *\n * @param options Optional behavior flags.\n */\nexport function useCropGestureHandlers(\n\toptions: UseCropGestureHandlersOptions = {}\n) {\n\tconst { commitOnKeyUp = true } = options;\n\tconst { beginGesture, endGesture } = useMediaEditor();\n\tconst keyboardTimerRef = useRef< ReturnType< typeof setTimeout > >();\n\n\tconst clearKeyboardTimer = useCallback( () => {\n\t\tclearTimeout( keyboardTimerRef.current );\n\t}, [] );\n\n\tconst scheduleKeyboardEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tkeyboardTimerRef.current = setTimeout( () => {\n\t\t\tendGesture();\n\t\t}, KEYBOARD_GESTURE_IDLE_MS );\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tuseEffect( () => clearKeyboardTimer, [ clearKeyboardTimer ] );\n\n\tconst handlePointerDownCapture = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tbeginGesture();\n\t}, [ beginGesture, clearKeyboardTimer ] );\n\n\tconst handlePointerEnd = useCallback( () => {\n\t\tclearKeyboardTimer();\n\t\tendGesture();\n\t}, [ clearKeyboardTimer, endGesture ] );\n\n\tconst handleKeyDownCapture = useCallback( () => {\n\t\tbeginGesture();\n\t\tif ( ! commitOnKeyUp ) {\n\t\t\tscheduleKeyboardEnd();\n\t\t}\n\t}, [ beginGesture, commitOnKeyUp, scheduleKeyboardEnd ] );\n\n\tconst handleKeyUp = useCallback( () => {\n\t\tif ( commitOnKeyUp ) {\n\t\t\tendGesture();\n\t\t\treturn;\n\t\t}\n\t\tscheduleKeyboardEnd();\n\t}, [ commitOnKeyUp, endGesture, scheduleKeyboardEnd ] );\n\n\treturn {\n\t\t[ CROP_CONTROL_ATTR ]: true,\n\t\tonPointerDownCapture: handlePointerDownCapture,\n\t\tonPointerUp: handlePointerEnd,\n\t\tonPointerCancel: handlePointerEnd,\n\t\tonKeyDownCapture: handleKeyDownCapture,\n\t\tonKeyUp: handleKeyUp,\n\t};\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qBAA+C;AAK/C,mBAA+B;AAQxB,IAAM,oBAAoB;AAGjC,IAAM,2BAA2B;AA4B1B,SAAS,uBACf,UAAyC,CAAC,GACzC;AACD,QAAM,EAAE,gBAAgB,KAAK,IAAI;AACjC,QAAM,EAAE,cAAc,WAAW,QAAI,6BAAe;AACpD,QAAM,uBAAmB,uBAA0C;AAEnE,QAAM,yBAAqB,4BAAa,MAAM;AAC7C,iBAAc,iBAAiB,OAAQ;AAAA,EACxC,GAAG,CAAC,CAAE;AAEN,QAAM,0BAAsB,4BAAa,MAAM;AAC9C,uBAAmB;AACnB,qBAAiB,UAAU,WAAY,MAAM;AAC5C,iBAAW;AAAA,IACZ,GAAG,wBAAyB;AAAA,EAC7B,GAAG,CAAE,oBAAoB,UAAW,CAAE;AAEtC,gCAAW,MAAM,oBAAoB,CAAE,kBAAmB,CAAE;AAE5D,QAAM,+BAA2B,4BAAa,MAAM;AACnD,uBAAmB;AACnB,iBAAa;AAAA,EACd,GAAG,CAAE,cAAc,kBAAmB,CAAE;AAExC,QAAM,uBAAmB,4BAAa,MAAM;AAC3C,uBAAmB;AACnB,eAAW;AAAA,EACZ,GAAG,CAAE,oBAAoB,UAAW,CAAE;AAEtC,QAAM,2BAAuB,4BAAa,MAAM;AAC/C,iBAAa;AACb,QAAK,CAAE,eAAgB;AACtB,0BAAoB;AAAA,IACrB;AAAA,EACD,GAAG,CAAE,cAAc,eAAe,mBAAoB,CAAE;AAExD,QAAM,kBAAc,4BAAa,MAAM;AACtC,QAAK,eAAgB;AACpB,iBAAW;AACX;AAAA,IACD;AACA,wBAAoB;AAAA,EACrB,GAAG,CAAE,eAAe,YAAY,mBAAoB,CAAE;AAEtD,SAAO;AAAA,IACN,CAAE,iBAAkB,GAAG;AAAA,IACvB,sBAAsB;AAAA,IACtB,aAAa;AAAA,IACb,iBAAiB;AAAA,IACjB,kBAAkB;AAAA,IAClB,SAAS;AAAA,EACV;AACD;",
6
6
  "names": []
7
7
  }
@@ -324,7 +324,7 @@ function CropperInner({
324
324
  [setCropRect, setViewportPan, canvasSize, visualSize]
325
325
  );
326
326
  const [settling, setSettling] = (0, import_element.useState)(false);
327
- const settleTimerRef = (0, import_element.useRef)(void 0);
327
+ const settleTimerRef = (0, import_element.useRef)();
328
328
  (0, import_element.useEffect)(() => {
329
329
  return () => {
330
330
  clearTimeout(settleTimerRef.current);