@wordpress/media-editor 0.8.0 → 0.8.1-next.v.202605131006.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 (217) hide show
  1. package/build/components/media-editor/index.cjs +560 -0
  2. package/build/components/media-editor/index.cjs.map +7 -0
  3. package/build/components/media-editor-canvas/index.cjs +14 -2
  4. package/build/components/media-editor-canvas/index.cjs.map +2 -2
  5. package/build/components/media-editor-crop-panel/index.cjs +34 -27
  6. package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
  7. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs +162 -0
  8. package/build/components/media-editor-keyboard-shortcuts-modal/index.cjs.map +7 -0
  9. package/build/components/media-editor-modal/index.cjs +42 -430
  10. package/build/components/media-editor-modal/index.cjs.map +3 -3
  11. package/build/components/media-editor-toolbar/index.cjs +143 -75
  12. package/build/components/media-editor-toolbar/index.cjs.map +3 -3
  13. package/build/components/media-form/index.cjs +3 -0
  14. package/build/components/media-form/index.cjs.map +2 -2
  15. package/build/components/rotation-ruler/index.cjs +197 -0
  16. package/build/components/rotation-ruler/index.cjs.map +7 -0
  17. package/build/components/rotation-ruler/use-ruler-drag.cjs +154 -0
  18. package/build/components/rotation-ruler/use-ruler-drag.cjs.map +7 -0
  19. package/build/hooks/use-crop-gesture-handlers.cjs +43 -0
  20. package/build/hooks/use-crop-gesture-handlers.cjs.map +7 -0
  21. package/build/image-editor/core/constants.cjs +9 -0
  22. package/build/image-editor/core/constants.cjs.map +2 -2
  23. package/build/image-editor/core/containment.cjs +7 -13
  24. package/build/image-editor/core/containment.cjs.map +2 -2
  25. package/build/image-editor/core/interaction-controller.cjs +43 -7
  26. package/build/image-editor/core/interaction-controller.cjs.map +2 -2
  27. package/build/image-editor/core/state.cjs +5 -1
  28. package/build/image-editor/core/state.cjs.map +2 -2
  29. package/build/image-editor/core/transform-style.cjs.map +1 -1
  30. package/build/image-editor/core/types.cjs.map +1 -1
  31. package/build/image-editor/core/viewport-state.cjs +50 -0
  32. package/build/image-editor/core/viewport-state.cjs.map +7 -0
  33. package/build/image-editor/react/components/cropper.cjs +192 -72
  34. package/build/image-editor/react/components/cropper.cjs.map +3 -3
  35. package/build/image-editor/react/components/overlays/dimming-overlay.cjs +5 -2
  36. package/build/image-editor/react/components/overlays/dimming-overlay.cjs.map +2 -2
  37. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs +16 -4
  38. package/build/image-editor/react/components/stencils/rectangle-stencil.cjs.map +2 -2
  39. package/build/image-editor/react/components/viewport-provider.cjs +51 -0
  40. package/build/image-editor/react/components/viewport-provider.cjs.map +7 -0
  41. package/build/image-editor/react/hooks/use-aria-announcer.cjs +53 -6
  42. package/build/image-editor/react/hooks/use-aria-announcer.cjs.map +2 -2
  43. package/build/image-editor/react/hooks/use-cropper-state.cjs +127 -8
  44. package/build/image-editor/react/hooks/use-cropper-state.cjs.map +2 -2
  45. package/build/image-editor/react/hooks/use-interaction.cjs +26 -5
  46. package/build/image-editor/react/hooks/use-interaction.cjs.map +2 -2
  47. package/build/image-editor/react/hooks/use-viewport-state.cjs +51 -0
  48. package/build/image-editor/react/hooks/use-viewport-state.cjs.map +7 -0
  49. package/build/image-editor/react/visually-hidden-style.cjs +41 -0
  50. package/build/image-editor/react/visually-hidden-style.cjs.map +7 -0
  51. package/build/private-apis.cjs +2 -0
  52. package/build/private-apis.cjs.map +2 -2
  53. package/build-module/components/media-editor/index.mjs +545 -0
  54. package/build-module/components/media-editor/index.mjs.map +7 -0
  55. package/build-module/components/media-editor-canvas/index.mjs +14 -2
  56. package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
  57. package/build-module/components/media-editor-crop-panel/index.mjs +35 -28
  58. package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
  59. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs +144 -0
  60. package/build-module/components/media-editor-keyboard-shortcuts-modal/index.mjs.map +7 -0
  61. package/build-module/components/media-editor-modal/index.mjs +46 -455
  62. package/build-module/components/media-editor-modal/index.mjs.map +2 -2
  63. package/build-module/components/media-editor-toolbar/index.mjs +137 -77
  64. package/build-module/components/media-editor-toolbar/index.mjs.map +2 -2
  65. package/build-module/components/media-form/index.mjs +3 -0
  66. package/build-module/components/media-form/index.mjs.map +2 -2
  67. package/build-module/components/rotation-ruler/index.mjs +166 -0
  68. package/build-module/components/rotation-ruler/index.mjs.map +7 -0
  69. package/build-module/components/rotation-ruler/use-ruler-drag.mjs +126 -0
  70. package/build-module/components/rotation-ruler/use-ruler-drag.mjs.map +7 -0
  71. package/build-module/hooks/use-crop-gesture-handlers.mjs +17 -0
  72. package/build-module/hooks/use-crop-gesture-handlers.mjs.map +7 -0
  73. package/build-module/image-editor/core/constants.mjs +6 -0
  74. package/build-module/image-editor/core/constants.mjs.map +2 -2
  75. package/build-module/image-editor/core/containment.mjs +6 -12
  76. package/build-module/image-editor/core/containment.mjs.map +2 -2
  77. package/build-module/image-editor/core/interaction-controller.mjs +50 -8
  78. package/build-module/image-editor/core/interaction-controller.mjs.map +2 -2
  79. package/build-module/image-editor/core/state.mjs +5 -1
  80. package/build-module/image-editor/core/state.mjs.map +2 -2
  81. package/build-module/image-editor/core/transform-style.mjs.map +1 -1
  82. package/build-module/image-editor/core/viewport-state.mjs +24 -0
  83. package/build-module/image-editor/core/viewport-state.mjs.map +7 -0
  84. package/build-module/image-editor/react/components/cropper.mjs +195 -73
  85. package/build-module/image-editor/react/components/cropper.mjs.map +3 -3
  86. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs +5 -2
  87. package/build-module/image-editor/react/components/overlays/dimming-overlay.mjs.map +2 -2
  88. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs +26 -5
  89. package/build-module/image-editor/react/components/stencils/rectangle-stencil.mjs.map +2 -2
  90. package/build-module/image-editor/react/components/viewport-provider.mjs +27 -0
  91. package/build-module/image-editor/react/components/viewport-provider.mjs.map +7 -0
  92. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs +59 -7
  93. package/build-module/image-editor/react/hooks/use-aria-announcer.mjs.map +2 -2
  94. package/build-module/image-editor/react/hooks/use-cropper-state.mjs +134 -9
  95. package/build-module/image-editor/react/hooks/use-cropper-state.mjs.map +2 -2
  96. package/build-module/image-editor/react/hooks/use-interaction.mjs +26 -5
  97. package/build-module/image-editor/react/hooks/use-interaction.mjs.map +2 -2
  98. package/build-module/image-editor/react/hooks/use-viewport-state.mjs +29 -0
  99. package/build-module/image-editor/react/hooks/use-viewport-state.mjs.map +7 -0
  100. package/build-module/image-editor/react/visually-hidden-style.mjs +16 -0
  101. package/build-module/image-editor/react/visually-hidden-style.mjs.map +7 -0
  102. package/build-module/private-apis.mjs +2 -0
  103. package/build-module/private-apis.mjs.map +2 -2
  104. package/build-style/style-rtl.css +254 -29
  105. package/build-style/style.css +254 -29
  106. package/build-types/components/media-editor/index.d.ts +34 -0
  107. package/build-types/components/media-editor/index.d.ts.map +1 -0
  108. package/build-types/components/media-editor-canvas/index.d.ts +10 -1
  109. package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
  110. package/build-types/components/media-editor-crop-panel/index.d.ts +1 -1
  111. package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
  112. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts +6 -0
  113. package/build-types/components/media-editor-keyboard-shortcuts-modal/index.d.ts.map +1 -0
  114. package/build-types/components/media-editor-modal/index.d.ts +2 -2
  115. package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
  116. package/build-types/components/media-editor-provider/index.d.ts +1 -1
  117. package/build-types/components/media-editor-provider/index.d.ts.map +1 -1
  118. package/build-types/components/media-editor-toolbar/index.d.ts +4 -1
  119. package/build-types/components/media-editor-toolbar/index.d.ts.map +1 -1
  120. package/build-types/components/media-form/index.d.ts +1 -1
  121. package/build-types/components/media-form/index.d.ts.map +1 -1
  122. package/build-types/components/rotation-ruler/index.d.ts +46 -0
  123. package/build-types/components/rotation-ruler/index.d.ts.map +1 -0
  124. package/build-types/components/rotation-ruler/stories/index.story.d.ts +14 -0
  125. package/build-types/components/rotation-ruler/stories/index.story.d.ts.map +1 -0
  126. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts +61 -0
  127. package/build-types/components/rotation-ruler/use-ruler-drag.d.ts.map +1 -0
  128. package/build-types/hooks/use-crop-gesture-handlers.d.ts +42 -0
  129. package/build-types/hooks/use-crop-gesture-handlers.d.ts.map +1 -0
  130. package/build-types/image-editor/core/constants.d.ts +9 -0
  131. package/build-types/image-editor/core/constants.d.ts.map +1 -1
  132. package/build-types/image-editor/core/containment.d.ts +11 -7
  133. package/build-types/image-editor/core/containment.d.ts.map +1 -1
  134. package/build-types/image-editor/core/interaction-controller.d.ts +14 -2
  135. package/build-types/image-editor/core/interaction-controller.d.ts.map +1 -1
  136. package/build-types/image-editor/core/state.d.ts.map +1 -1
  137. package/build-types/image-editor/core/transform-style.d.ts +1 -1
  138. package/build-types/image-editor/core/types.d.ts +25 -0
  139. package/build-types/image-editor/core/types.d.ts.map +1 -1
  140. package/build-types/image-editor/core/viewport-state.d.ts +7 -0
  141. package/build-types/image-editor/core/viewport-state.d.ts.map +1 -0
  142. package/build-types/image-editor/react/components/cropper-provider.d.ts +1 -1
  143. package/build-types/image-editor/react/components/cropper-provider.d.ts.map +1 -1
  144. package/build-types/image-editor/react/components/cropper.d.ts +2 -1
  145. package/build-types/image-editor/react/components/cropper.d.ts.map +1 -1
  146. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts +3 -13
  147. package/build-types/image-editor/react/components/overlays/dimming-overlay.d.ts.map +1 -1
  148. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts +1 -1
  149. package/build-types/image-editor/react/components/overlays/grid-overlay.d.ts.map +1 -1
  150. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts +1 -1
  151. package/build-types/image-editor/react/components/stencils/rectangle-stencil.d.ts.map +1 -1
  152. package/build-types/image-editor/react/components/viewport-provider.d.ts +9 -0
  153. package/build-types/image-editor/react/components/viewport-provider.d.ts.map +1 -0
  154. package/build-types/image-editor/react/hooks/use-aria-announcer.d.ts.map +1 -1
  155. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts +29 -0
  156. package/build-types/image-editor/react/hooks/use-cropper-state.d.ts.map +1 -1
  157. package/build-types/image-editor/react/hooks/use-interaction.d.ts +5 -2
  158. package/build-types/image-editor/react/hooks/use-interaction.d.ts.map +1 -1
  159. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts +19 -0
  160. package/build-types/image-editor/react/hooks/use-viewport-state.d.ts.map +1 -0
  161. package/build-types/image-editor/react/visually-hidden-style.d.ts +6 -0
  162. package/build-types/image-editor/react/visually-hidden-style.d.ts.map +1 -0
  163. package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +1 -1
  164. package/build-types/private-apis.d.ts.map +1 -1
  165. package/build-types/store/actions.d.ts +3 -3
  166. package/build-types/store/actions.d.ts.map +1 -1
  167. package/package.json +16 -15
  168. package/src/components/media-editor/index.tsx +709 -0
  169. package/src/components/media-editor/style.scss +89 -0
  170. package/src/components/media-editor-canvas/index.tsx +24 -0
  171. package/src/components/media-editor-crop-panel/index.tsx +39 -27
  172. package/src/components/media-editor-crop-panel/test/index.tsx +109 -0
  173. package/src/components/media-editor-keyboard-shortcuts-modal/index.tsx +177 -0
  174. package/src/components/media-editor-keyboard-shortcuts-modal/style.scss +53 -0
  175. package/src/components/media-editor-modal/index.tsx +49 -589
  176. package/src/components/media-editor-modal/style.scss +13 -112
  177. package/src/components/media-editor-toolbar/index.tsx +122 -63
  178. package/src/components/media-editor-toolbar/style.scss +39 -11
  179. package/src/components/media-form/index.tsx +5 -0
  180. package/src/components/rotation-ruler/README.md +37 -0
  181. package/src/components/rotation-ruler/index.tsx +266 -0
  182. package/src/components/rotation-ruler/stories/index.story.tsx +54 -0
  183. package/src/components/rotation-ruler/style.scss +147 -0
  184. package/src/components/rotation-ruler/test/index.tsx +109 -0
  185. package/src/components/rotation-ruler/use-ruler-drag.ts +230 -0
  186. package/src/hooks/use-crop-gesture-handlers.ts +54 -0
  187. package/src/image-editor/core/constants.ts +12 -0
  188. package/src/image-editor/core/containment.ts +16 -28
  189. package/src/image-editor/core/interaction-controller.ts +66 -10
  190. package/src/image-editor/core/state.ts +15 -8
  191. package/src/image-editor/core/test/camera.ts +15 -26
  192. package/src/image-editor/core/test/interaction-controller.ts +158 -7
  193. package/src/image-editor/core/test/state.ts +21 -1
  194. package/src/image-editor/core/transform-style.ts +1 -1
  195. package/src/image-editor/core/types.ts +16 -0
  196. package/src/image-editor/core/viewport-state.ts +33 -0
  197. package/src/image-editor/docs/architecture.md +1 -1
  198. package/src/image-editor/docs/recipes.md +2 -2
  199. package/src/image-editor/react/components/cropper.scss +28 -0
  200. package/src/image-editor/react/components/cropper.tsx +268 -72
  201. package/src/image-editor/react/components/overlays/dimming-overlay.tsx +12 -12
  202. package/src/image-editor/react/components/stencils/rectangle-stencil.tsx +27 -8
  203. package/src/image-editor/react/components/stencils/test/rectangle-stencil.tsx +29 -3
  204. package/src/image-editor/react/components/test/cropper.tsx +294 -5
  205. package/src/image-editor/react/components/viewport-provider.tsx +39 -0
  206. package/src/image-editor/react/hooks/test/use-aria-announcer.ts +81 -0
  207. package/src/image-editor/react/hooks/test/use-cropper-state.ts +286 -0
  208. package/src/image-editor/react/hooks/test/use-interaction.ts +1 -0
  209. package/src/image-editor/react/hooks/use-aria-announcer.ts +68 -7
  210. package/src/image-editor/react/hooks/use-cropper-state.ts +230 -11
  211. package/src/image-editor/react/hooks/use-interaction.ts +36 -6
  212. package/src/image-editor/react/hooks/use-viewport-state.ts +48 -0
  213. package/src/image-editor/react/visually-hidden-style.ts +15 -0
  214. package/src/private-apis.ts +2 -0
  215. package/src/style.scss +3 -0
  216. package/tsconfig.json +1 -0
  217. package/tsconfig.tsbuildinfo +1 -1
@@ -0,0 +1,545 @@
1
+ // packages/media-editor/src/components/media-editor/index.tsx
2
+ import apiFetch from "@wordpress/api-fetch";
3
+ import {
4
+ Button,
5
+ Flex,
6
+ Spinner,
7
+ __experimentalConfirmDialog as ConfirmDialog,
8
+ privateApis as componentsPrivateApis
9
+ } from "@wordpress/components";
10
+ import { Stack } from "@wordpress/ui";
11
+ import { useDispatch, useRegistry, useSelect } from "@wordpress/data";
12
+ import { store as coreStore } from "@wordpress/core-data";
13
+ import {
14
+ createPortal,
15
+ useCallback,
16
+ useContext,
17
+ useEffect,
18
+ useMemo,
19
+ useRef,
20
+ useState
21
+ } from "@wordpress/element";
22
+ import { __, sprintf } from "@wordpress/i18n";
23
+ import { close, drawerRight, keyboard } from "@wordpress/icons";
24
+ import { isAppleOS, isKeyboardEvent } from "@wordpress/keycodes";
25
+ import { SnackbarNotices, store as noticesStore } from "@wordpress/notices";
26
+ import {
27
+ ComplementaryArea,
28
+ InterfaceSkeleton,
29
+ PinnedItems
30
+ } from "@wordpress/interface";
31
+ import { MediaEditorProvider } from "../media-editor-provider/index.mjs";
32
+ import MediaPreview from "../media-preview/index.mjs";
33
+ import MediaEditorCanvas from "../media-editor-canvas/index.mjs";
34
+ import MediaEditorToolbar from "../media-editor-toolbar/index.mjs";
35
+ import MediaEditorCropPanel, {
36
+ resolveAspectRatio
37
+ } from "../media-editor-crop-panel/index.mjs";
38
+ import MediaForm from "../media-form/index.mjs";
39
+ import { unlock } from "../../lock-unlock.mjs";
40
+ import { getMediaTypeFromMimeType } from "../../utils/index.mjs";
41
+ import { CropperProvider, useCropper } from "../../image-editor/index.mjs";
42
+ import { CROP_CONTROL_ATTR } from "../../hooks/use-crop-gesture-handlers.mjs";
43
+ import { buildModifiers } from "../media-editor-modal/build-modifiers.mjs";
44
+ import MediaEditorKeyboardShortcutsModal from "../media-editor-keyboard-shortcuts-modal/index.mjs";
45
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
46
+ var METADATA_EDIT_KEYS = [
47
+ "title",
48
+ "caption",
49
+ "description",
50
+ "alt_text",
51
+ "post"
52
+ ];
53
+ var ATTACHMENT_EMBED_QUERY = { _embed: "author,wp:attached-to" };
54
+ var NOTICES_CONTEXT = "media-editor";
55
+ var PLACEMENT_CONTROL_IDLE_MS = 300;
56
+ var { Tabs } = unlock(componentsPrivateApis);
57
+ function MediaEditorSidebar({ tabs }) {
58
+ const tabsContextValue = useContext(Tabs.Context);
59
+ return /* @__PURE__ */ jsx(
60
+ ComplementaryArea,
61
+ {
62
+ scope: "media-editor",
63
+ identifier: "media-editor/details",
64
+ title: __("Details"),
65
+ icon: drawerRight,
66
+ isActiveByDefault: true,
67
+ className: "media-editor__sidebar",
68
+ panelClassName: "media-editor__sidebar-panel",
69
+ headerClassName: "media-editor__sidebar-header",
70
+ header: /* @__PURE__ */ jsx(Tabs.Context.Provider, { value: tabsContextValue, children: /* @__PURE__ */ jsx(Tabs.TabList, { children: tabs.map((tab) => /* @__PURE__ */ jsx(Tabs.Tab, { tabId: tab.id, children: tab.title }, tab.id)) }) }),
71
+ children: /* @__PURE__ */ jsx(Tabs.Context.Provider, { value: tabsContextValue, children: tabs.map((tab) => /* @__PURE__ */ jsx(
72
+ Tabs.TabPanel,
73
+ {
74
+ tabId: tab.id,
75
+ focusable: false,
76
+ children: tab.panel
77
+ },
78
+ tab.id
79
+ )) })
80
+ }
81
+ );
82
+ }
83
+ function HeaderActions({
84
+ isSaving,
85
+ hasMedia,
86
+ hasChanges,
87
+ isImage,
88
+ showCloseButton = false,
89
+ onCancel,
90
+ onSave
91
+ }) {
92
+ const saveDisabled = isSaving || !hasMedia || !hasChanges;
93
+ const [isShortcutsModalOpen, setIsShortcutsModalOpen] = useState(false);
94
+ return /* @__PURE__ */ jsxs(
95
+ Flex,
96
+ {
97
+ className: "media-editor__header-actions",
98
+ justify: "flex-end",
99
+ expanded: false,
100
+ gap: 2,
101
+ children: [
102
+ isImage && /* @__PURE__ */ jsx(
103
+ Button,
104
+ {
105
+ size: "compact",
106
+ icon: keyboard,
107
+ label: __("Keyboard shortcuts"),
108
+ onClick: () => setIsShortcutsModalOpen(true)
109
+ }
110
+ ),
111
+ /* @__PURE__ */ jsx(PinnedItems.Slot, { scope: "media-editor" }),
112
+ /* @__PURE__ */ jsx(
113
+ Button,
114
+ {
115
+ size: "compact",
116
+ variant: "tertiary",
117
+ onClick: onCancel,
118
+ disabled: isSaving,
119
+ accessibleWhenDisabled: true,
120
+ children: __("Cancel")
121
+ }
122
+ ),
123
+ /* @__PURE__ */ jsx(
124
+ Button,
125
+ {
126
+ size: "compact",
127
+ variant: "primary",
128
+ onClick: onSave,
129
+ isBusy: isSaving,
130
+ disabled: saveDisabled,
131
+ accessibleWhenDisabled: true,
132
+ children: __("Save")
133
+ }
134
+ ),
135
+ showCloseButton && /* @__PURE__ */ jsx(
136
+ Button,
137
+ {
138
+ size: "compact",
139
+ icon: close,
140
+ label: __("Close"),
141
+ onClick: onCancel,
142
+ disabled: isSaving,
143
+ accessibleWhenDisabled: true
144
+ }
145
+ ),
146
+ isShortcutsModalOpen && /* @__PURE__ */ jsx(
147
+ MediaEditorKeyboardShortcutsModal,
148
+ {
149
+ onClose: () => setIsShortcutsModalOpen(false)
150
+ }
151
+ )
152
+ ]
153
+ }
154
+ );
155
+ }
156
+ function MediaEditorContent({
157
+ fields = [],
158
+ id,
159
+ aspectRatioPresets,
160
+ onClose,
161
+ onSaved,
162
+ renderFrame,
163
+ noticesClassName = "media-editor__snackbar",
164
+ noticesPortalElement,
165
+ showCloseButton = false,
166
+ shouldCloseOnEsc = false
167
+ }) {
168
+ const cropper = useCropper();
169
+ const { media, hasEdits } = useSelect(
170
+ (select) => {
171
+ const {
172
+ getEditedEntityRecord,
173
+ getEntityRecord,
174
+ hasEditsForEntityRecord
175
+ } = select(coreStore);
176
+ getEntityRecord(
177
+ "postType",
178
+ "attachment",
179
+ id,
180
+ ATTACHMENT_EMBED_QUERY
181
+ );
182
+ return {
183
+ media: getEditedEntityRecord(
184
+ "postType",
185
+ "attachment",
186
+ id
187
+ ),
188
+ hasEdits: hasEditsForEntityRecord(
189
+ "postType",
190
+ "attachment",
191
+ id
192
+ )
193
+ };
194
+ },
195
+ [id]
196
+ );
197
+ const hasChanges = cropper.isDirty || hasEdits;
198
+ const registry = useRegistry();
199
+ const {
200
+ clearEntityRecordEdits,
201
+ editEntityRecord,
202
+ invalidateResolution,
203
+ receiveEntityRecords,
204
+ saveEditedEntityRecord
205
+ } = useDispatch(coreStore);
206
+ const { createErrorNotice, removeAllNotices } = useDispatch(noticesStore);
207
+ const [isSaving, setIsSaving] = useState(false);
208
+ const [isDiscardDialogOpen, setIsDiscardDialogOpen] = useState(false);
209
+ const [isPlacementActive, setIsPlacementActive] = useState(false);
210
+ const [isCanvasGestureActive, setIsCanvasGestureActive] = useState(false);
211
+ const placementControlTimerRef = useRef();
212
+ const [aspectRatioValue, setAspectRatioValue] = useState("0");
213
+ const [freeformCrop, setFreeformCrop] = useState(true);
214
+ const signalPlacementControlInteraction = useCallback(() => {
215
+ setIsPlacementActive(true);
216
+ clearTimeout(placementControlTimerRef.current);
217
+ placementControlTimerRef.current = setTimeout(() => {
218
+ setIsPlacementActive(false);
219
+ }, PLACEMENT_CONTROL_IDLE_MS);
220
+ }, []);
221
+ const handleCanvasGestureStart = useCallback(() => {
222
+ setIsCanvasGestureActive(true);
223
+ }, []);
224
+ const handleCanvasGestureEnd = useCallback(() => {
225
+ setIsCanvasGestureActive(false);
226
+ }, []);
227
+ const isCropInteractionActive = isPlacementActive || isCanvasGestureActive;
228
+ useEffect(() => {
229
+ return () => {
230
+ clearTimeout(placementControlTimerRef.current);
231
+ };
232
+ }, []);
233
+ useEffect(() => {
234
+ setAspectRatioValue("0");
235
+ setFreeformCrop(true);
236
+ setIsPlacementActive(false);
237
+ setIsCanvasGestureActive(false);
238
+ }, [id]);
239
+ useEffect(() => {
240
+ invalidateResolution("getEntityRecord", [
241
+ "postType",
242
+ "attachment",
243
+ id,
244
+ ATTACHMENT_EMBED_QUERY
245
+ ]);
246
+ }, [id, invalidateResolution]);
247
+ const mediaType = getMediaTypeFromMimeType(media?.mime_type).type;
248
+ const isImage = !!media && mediaType === "image";
249
+ const imageAspectRatio = useMemo(() => {
250
+ if (!isImage) {
251
+ return null;
252
+ }
253
+ const naturalWidth = Number(media?.media_details?.width);
254
+ const naturalHeight = Number(media?.media_details?.height);
255
+ if (Number.isFinite(naturalWidth) && Number.isFinite(naturalHeight) && naturalHeight > 0) {
256
+ return naturalWidth / naturalHeight;
257
+ }
258
+ return null;
259
+ }, [isImage, media]);
260
+ const tabs = useMemo(() => {
261
+ const detailsTab = {
262
+ id: "details",
263
+ title: __("Details"),
264
+ panel: /* @__PURE__ */ jsx(
265
+ Stack,
266
+ {
267
+ className: "media-editor__panel",
268
+ direction: "column",
269
+ gap: "lg",
270
+ children: /* @__PURE__ */ jsx(MediaForm, {})
271
+ }
272
+ )
273
+ };
274
+ if (!isImage) {
275
+ return [detailsTab];
276
+ }
277
+ return [
278
+ {
279
+ id: "crop",
280
+ title: __("Crop"),
281
+ panel: /* @__PURE__ */ jsx(
282
+ Stack,
283
+ {
284
+ className: "media-editor__panel",
285
+ direction: "column",
286
+ gap: "lg",
287
+ children: /* @__PURE__ */ jsx(
288
+ MediaEditorCropPanel,
289
+ {
290
+ aspectRatioValue,
291
+ onAspectRatioChange: setAspectRatioValue,
292
+ freeformCrop,
293
+ onFreeformChange: setFreeformCrop,
294
+ onPlacementControlInteraction: signalPlacementControlInteraction,
295
+ aspectRatioPresets
296
+ }
297
+ )
298
+ }
299
+ )
300
+ },
301
+ detailsTab
302
+ ];
303
+ }, [
304
+ isImage,
305
+ aspectRatioValue,
306
+ freeformCrop,
307
+ aspectRatioPresets,
308
+ signalPlacementControlInteraction
309
+ ]);
310
+ const handleChange = (updates) => {
311
+ editEntityRecord("postType", "attachment", id, updates);
312
+ };
313
+ const discardAndClose = () => {
314
+ removeAllNotices("snackbar", NOTICES_CONTEXT);
315
+ clearEntityRecordEdits("postType", "attachment", id);
316
+ onClose?.();
317
+ };
318
+ const handleRequestClose = () => {
319
+ if (isSaving) {
320
+ return;
321
+ }
322
+ if (hasChanges) {
323
+ setIsDiscardDialogOpen(true);
324
+ return;
325
+ }
326
+ discardAndClose();
327
+ };
328
+ const handleSave = async () => {
329
+ removeAllNotices("snackbar", NOTICES_CONTEXT);
330
+ setIsSaving(true);
331
+ try {
332
+ let saved;
333
+ const modifiers = cropper.isDirty && cropper.state.image ? buildModifiers(cropper.state, {
334
+ width: cropper.state.image.naturalWidth,
335
+ height: cropper.state.image.naturalHeight
336
+ }) : [];
337
+ if (modifiers.length > 0) {
338
+ const pendingEdits = registry.select(coreStore).getEntityRecordNonTransientEdits(
339
+ "postType",
340
+ "attachment",
341
+ id
342
+ );
343
+ const metadataEdits = {};
344
+ for (const key of METADATA_EDIT_KEYS) {
345
+ if (pendingEdits && key in pendingEdits) {
346
+ metadataEdits[key] = pendingEdits[key];
347
+ }
348
+ }
349
+ if (!("post" in metadataEdits) && media?.post !== void 0) {
350
+ metadataEdits.post = media.post;
351
+ }
352
+ saved = await apiFetch({
353
+ path: `/wp/v2/media/${id}/edit`,
354
+ method: "POST",
355
+ data: {
356
+ src: media?.source_url,
357
+ modifiers,
358
+ ...metadataEdits
359
+ }
360
+ });
361
+ if (saved) {
362
+ receiveEntityRecords(
363
+ "postType",
364
+ "attachment",
365
+ saved,
366
+ void 0,
367
+ true
368
+ );
369
+ }
370
+ } else {
371
+ saved = await saveEditedEntityRecord(
372
+ "postType",
373
+ "attachment",
374
+ id
375
+ );
376
+ }
377
+ const next = saved ?? media;
378
+ if (next && next.id !== id) {
379
+ clearEntityRecordEdits("postType", "attachment", id);
380
+ }
381
+ if (next && next.id) {
382
+ if (next.id === id) {
383
+ cropper.reset();
384
+ }
385
+ onSaved?.({
386
+ id: next.id,
387
+ url: next.source_url,
388
+ media: next
389
+ });
390
+ }
391
+ } catch (error) {
392
+ const message = error instanceof Error ? error.message : error?.message ?? __("An unknown error occurred.");
393
+ createErrorNotice(
394
+ isImage ? sprintf(
395
+ /* translators: %s: Error message. */
396
+ __("Could not save image. %s"),
397
+ message
398
+ ) : sprintf(
399
+ /* translators: %s: Error message. */
400
+ __("Could not save media. %s"),
401
+ message
402
+ ),
403
+ { type: "snackbar", context: NOTICES_CONTEXT }
404
+ );
405
+ } finally {
406
+ setIsSaving(false);
407
+ }
408
+ };
409
+ const handleKeyDown = (event) => {
410
+ const isUndoShortcut = isKeyboardEvent.primary(event, "z");
411
+ const isRedoShortcut = isKeyboardEvent.primaryShift(event, "z") || !isAppleOS() && isKeyboardEvent.primary(event, "y");
412
+ if ((isUndoShortcut || isRedoShortcut) && isImage) {
413
+ const target = event.target;
414
+ const isMetadataField = (target.tagName === "INPUT" || target.tagName === "TEXTAREA" || target.isContentEditable) && !target.closest(`[${CROP_CONTROL_ATTR}]`);
415
+ if (!isMetadataField) {
416
+ event.preventDefault();
417
+ if (isCropInteractionActive) {
418
+ return;
419
+ }
420
+ if (isRedoShortcut) {
421
+ cropper.redo();
422
+ } else {
423
+ cropper.undo();
424
+ }
425
+ }
426
+ }
427
+ if (shouldCloseOnEsc) {
428
+ if (event.code !== "Escape" && event.key !== "Escape") {
429
+ return;
430
+ }
431
+ if (isSaving) {
432
+ event.preventDefault();
433
+ return;
434
+ }
435
+ if (hasChanges) {
436
+ event.preventDefault();
437
+ setIsDiscardDialogOpen(true);
438
+ }
439
+ }
440
+ };
441
+ const snackbar = /* @__PURE__ */ jsx(
442
+ SnackbarNotices,
443
+ {
444
+ className: noticesClassName,
445
+ context: NOTICES_CONTEXT
446
+ }
447
+ );
448
+ const children = /* @__PURE__ */ jsxs(
449
+ MediaEditorProvider,
450
+ {
451
+ value: media ?? void 0,
452
+ onChange: handleChange,
453
+ settings: { fields },
454
+ children: [
455
+ /* @__PURE__ */ jsx("div", { className: "media-editor", children: !media ? /* @__PURE__ */ jsx("div", { className: "media-editor__loading", children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
456
+ /* @__PURE__ */ jsx(Tabs, { children: /* @__PURE__ */ jsx(MediaEditorSidebar, { tabs }) }),
457
+ /* @__PURE__ */ jsx(
458
+ InterfaceSkeleton,
459
+ {
460
+ className: "media-editor__skeleton",
461
+ labels: {
462
+ body: isImage ? __("Image editor") : __("Media preview"),
463
+ sidebar: __("Media details"),
464
+ footer: __("Image editing tools")
465
+ },
466
+ content: /* @__PURE__ */ jsx("div", { className: "media-editor__canvas", children: isImage ? /* @__PURE__ */ jsx(
467
+ MediaEditorCanvas,
468
+ {
469
+ aspectRatio: resolveAspectRatio(
470
+ aspectRatioValue,
471
+ imageAspectRatio
472
+ ),
473
+ freeformCrop,
474
+ focusOnMount: true,
475
+ isPlacementActive,
476
+ onGestureStart: handleCanvasGestureStart,
477
+ onGestureEnd: handleCanvasGestureEnd
478
+ }
479
+ ) : /* @__PURE__ */ jsx(MediaPreview, {}) }),
480
+ footer: isImage ? /* @__PURE__ */ jsx(
481
+ MediaEditorToolbar,
482
+ {
483
+ onReset: () => {
484
+ setAspectRatioValue("0");
485
+ setFreeformCrop(true);
486
+ },
487
+ onPlacementControlInteraction: signalPlacementControlInteraction,
488
+ isUndoRedoDisabled: isCropInteractionActive
489
+ }
490
+ ) : void 0,
491
+ sidebar: /* @__PURE__ */ jsx(ComplementaryArea.Slot, { scope: "media-editor" })
492
+ }
493
+ )
494
+ ] }) }),
495
+ /* @__PURE__ */ jsx(
496
+ ConfirmDialog,
497
+ {
498
+ isOpen: isDiscardDialogOpen,
499
+ confirmButtonText: __("Discard"),
500
+ cancelButtonText: __("Keep editing"),
501
+ onCancel: () => setIsDiscardDialogOpen(false),
502
+ onConfirm: () => {
503
+ setIsDiscardDialogOpen(false);
504
+ discardAndClose();
505
+ },
506
+ children: __(
507
+ "Are you sure you want to discard your unsaved changes?"
508
+ )
509
+ }
510
+ ),
511
+ noticesPortalElement ? createPortal(snackbar, noticesPortalElement) : snackbar
512
+ ]
513
+ }
514
+ );
515
+ return renderFrame({
516
+ children,
517
+ headerActions: /* @__PURE__ */ jsx(
518
+ HeaderActions,
519
+ {
520
+ isSaving,
521
+ hasMedia: !!media,
522
+ hasChanges,
523
+ isImage,
524
+ showCloseButton,
525
+ onCancel: handleRequestClose,
526
+ onSave: handleSave
527
+ }
528
+ ),
529
+ onRequestClose: handleRequestClose,
530
+ onKeyDown: handleKeyDown,
531
+ shouldCloseOnClickOutside: !hasChanges && !isSaving,
532
+ isSaving,
533
+ hasChanges,
534
+ hasMedia: !!media
535
+ });
536
+ }
537
+ function MediaEditor(props) {
538
+ return /* @__PURE__ */ jsx(CropperProvider, { children: /* @__PURE__ */ jsx(MediaEditorContent, { ...props }) }, props.id);
539
+ }
540
+ var media_editor_default = MediaEditor;
541
+ export {
542
+ MediaEditor,
543
+ media_editor_default as default
544
+ };
545
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/components/media-editor/index.tsx"],
4
+ "sourcesContent": ["/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\nimport {\n\tButton,\n\tFlex,\n\tSpinner,\n\t__experimentalConfirmDialog as ConfirmDialog,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { Stack } from '@wordpress/ui';\nimport { useDispatch, useRegistry, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tcreatePortal,\n\tuseCallback,\n\tuseContext,\n\tuseEffect,\n\tuseMemo,\n\tuseRef,\n\tuseState,\n} from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { close, drawerRight, keyboard } from '@wordpress/icons';\nimport { isAppleOS, isKeyboardEvent } from '@wordpress/keycodes';\nimport { SnackbarNotices, store as noticesStore } from '@wordpress/notices';\nimport type { Field } from '@wordpress/dataviews';\nimport {\n\tComplementaryArea,\n\tInterfaceSkeleton,\n\tPinnedItems,\n\t// No type declarations available for @wordpress/interface.\n\t// @ts-expect-error\n} from '@wordpress/interface';\nimport type { KeyboardEvent as ReactKeyboardEvent, ReactNode } from 'react';\n\n/**\n * Internal dependencies\n */\nimport { MediaEditorProvider } from '../media-editor-provider';\nimport type { Media } from '../media-editor-provider';\nimport MediaPreview from '../media-preview';\nimport MediaEditorCanvas from '../media-editor-canvas';\nimport MediaEditorToolbar from '../media-editor-toolbar';\nimport MediaEditorCropPanel, {\n\tresolveAspectRatio,\n} from '../media-editor-crop-panel';\nimport MediaForm from '../media-form';\nimport { unlock } from '../../lock-unlock';\nimport { getMediaTypeFromMimeType } from '../../utils';\nimport { CropperProvider, useCropper } from '../../image-editor';\nimport type { AspectRatioPreset } from '../../image-editor/core/constants';\nimport { CROP_CONTROL_ATTR } from '../../hooks/use-crop-gesture-handlers';\nimport { buildModifiers } from '../media-editor-modal/build-modifiers';\nimport MediaEditorKeyboardShortcutsModal from '../media-editor-keyboard-shortcuts-modal';\n\n// Details-tab edits are bundled into transformed `/edit` requests. Core's\n// endpoint only accepts this whitelist.\nconst METADATA_EDIT_KEYS = [\n\t'title',\n\t'caption',\n\t'description',\n\t'alt_text',\n\t'post',\n] as const;\n\n// Embed query for the attachment's author and parent post. Shared between\n// the `getEntityRecord` read and the matching `invalidateResolution` so the\n// two stay in lockstep.\nconst ATTACHMENT_EMBED_QUERY = { _embed: 'author,wp:attached-to' } as const;\n\n// Scope save-failure snackbars so they don't leak into the host editor/page.\nconst NOTICES_CONTEXT = 'media-editor';\nconst PLACEMENT_CONTROL_IDLE_MS = 300;\n\nconst { Tabs } = unlock( componentsPrivateApis );\n\ninterface EditorTab {\n\tid: string;\n\ttitle: string;\n\tpanel: JSX.Element;\n}\n\nexport interface MediaEditorSaveResult {\n\tid: number;\n\turl?: string;\n\tmedia: Media;\n}\n\nexport interface MediaEditorFrameProps {\n\tchildren: ReactNode;\n\theaderActions: ReactNode;\n\tonRequestClose: () => void;\n\tonKeyDown: ( event: ReactKeyboardEvent< HTMLElement > ) => void;\n\tshouldCloseOnClickOutside: boolean;\n\tisSaving: boolean;\n\thasChanges: boolean;\n\thasMedia: boolean;\n}\n\nexport interface MediaEditorProps {\n\tfields?: Field< Media >[];\n\tid: number;\n\taspectRatioPresets?: AspectRatioPreset[];\n\tonClose?: () => void;\n\tonSaved?: ( result: MediaEditorSaveResult ) => void;\n\trenderFrame: ( props: MediaEditorFrameProps ) => JSX.Element;\n\tnoticesClassName?: string;\n\tnoticesPortalElement?: Element | null;\n\tshowCloseButton?: boolean;\n\tshouldCloseOnEsc?: boolean;\n}\n\nfunction MediaEditorSidebar( { tabs }: { tabs: EditorTab[] } ) {\n\tconst tabsContextValue = useContext( Tabs.Context );\n\treturn (\n\t\t<ComplementaryArea\n\t\t\tscope=\"media-editor\"\n\t\t\tidentifier=\"media-editor/details\"\n\t\t\ttitle={ __( 'Details' ) }\n\t\t\ticon={ drawerRight }\n\t\t\tisActiveByDefault\n\t\t\tclassName=\"media-editor__sidebar\"\n\t\t\tpanelClassName=\"media-editor__sidebar-panel\"\n\t\t\theaderClassName=\"media-editor__sidebar-header\"\n\t\t\theader={\n\t\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t\t<Tabs.TabList>\n\t\t\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t\t\t<Tabs.Tab key={ tab.id } tabId={ tab.id }>\n\t\t\t\t\t\t\t\t{ tab.title }\n\t\t\t\t\t\t\t</Tabs.Tab>\n\t\t\t\t\t\t) ) }\n\t\t\t\t\t</Tabs.TabList>\n\t\t\t\t</Tabs.Context.Provider>\n\t\t\t}\n\t\t>\n\t\t\t<Tabs.Context.Provider value={ tabsContextValue }>\n\t\t\t\t{ tabs.map( ( tab ) => (\n\t\t\t\t\t<Tabs.TabPanel\n\t\t\t\t\t\tkey={ tab.id }\n\t\t\t\t\t\ttabId={ tab.id }\n\t\t\t\t\t\tfocusable={ false }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ tab.panel }\n\t\t\t\t\t</Tabs.TabPanel>\n\t\t\t\t) ) }\n\t\t\t</Tabs.Context.Provider>\n\t\t</ComplementaryArea>\n\t);\n}\n\ninterface HeaderActionsProps {\n\tisSaving: boolean;\n\thasMedia: boolean;\n\thasChanges: boolean;\n\tisImage: boolean;\n\tshowCloseButton?: boolean;\n\tonCancel: () => void;\n\tonSave: () => void;\n}\n\nfunction HeaderActions( {\n\tisSaving,\n\thasMedia,\n\thasChanges,\n\tisImage,\n\tshowCloseButton = false,\n\tonCancel,\n\tonSave,\n}: HeaderActionsProps ) {\n\tconst saveDisabled = isSaving || ! hasMedia || ! hasChanges;\n\tconst [ isShortcutsModalOpen, setIsShortcutsModalOpen ] = useState( false );\n\treturn (\n\t\t<Flex\n\t\t\tclassName=\"media-editor__header-actions\"\n\t\t\tjustify=\"flex-end\"\n\t\t\texpanded={ false }\n\t\t\tgap={ 2 }\n\t\t>\n\t\t\t{ isImage && (\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\ticon={ keyboard }\n\t\t\t\t\tlabel={ __( 'Keyboard shortcuts' ) }\n\t\t\t\t\tonClick={ () => setIsShortcutsModalOpen( true ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<PinnedItems.Slot scope=\"media-editor\" />\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t\tonClick={ onCancel }\n\t\t\t\tdisabled={ isSaving }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t>\n\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t</Button>\n\t\t\t<Button\n\t\t\t\tsize=\"compact\"\n\t\t\t\tvariant=\"primary\"\n\t\t\t\tonClick={ onSave }\n\t\t\t\tisBusy={ isSaving }\n\t\t\t\tdisabled={ saveDisabled }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t>\n\t\t\t\t{ __( 'Save' ) }\n\t\t\t</Button>\n\t\t\t{ showCloseButton && (\n\t\t\t\t<Button\n\t\t\t\t\tsize=\"compact\"\n\t\t\t\t\ticon={ close }\n\t\t\t\t\tlabel={ __( 'Close' ) }\n\t\t\t\t\tonClick={ onCancel }\n\t\t\t\t\tdisabled={ isSaving }\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ isShortcutsModalOpen && (\n\t\t\t\t<MediaEditorKeyboardShortcutsModal\n\t\t\t\t\tonClose={ () => setIsShortcutsModalOpen( false ) }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Flex>\n\t);\n}\n\ntype PendingMetadataEdits = Record< string, unknown > | undefined;\n\nfunction MediaEditorContent( {\n\tfields = [],\n\tid,\n\taspectRatioPresets,\n\tonClose,\n\tonSaved,\n\trenderFrame,\n\tnoticesClassName = 'media-editor__snackbar',\n\tnoticesPortalElement,\n\tshowCloseButton = false,\n\tshouldCloseOnEsc = false,\n}: MediaEditorProps ) {\n\tconst cropper = useCropper();\n\n\tconst { media, hasEdits } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t\tgetEntityRecord,\n\t\t\t\thasEditsForEntityRecord,\n\t\t\t} = select( coreStore );\n\t\t\t// Trigger an _embed fetch so `_embedded.author` and\n\t\t\t// `_embedded['wp:attached-to']` land on the record for the Details\n\t\t\t// fields to read. `getEditedEntityRecord` doesn't formally accept a\n\t\t\t// query, so we can't embed via that selector directly.\n\t\t\tgetEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\tid,\n\t\t\t\tATTACHMENT_EMBED_QUERY\n\t\t\t);\n\t\t\treturn {\n\t\t\t\tmedia: getEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tid\n\t\t\t\t) as Media,\n\t\t\t\thasEdits: hasEditsForEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tid\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ id ]\n\t);\n\n\tconst hasChanges = cropper.isDirty || hasEdits;\n\n\tconst registry = useRegistry();\n\tconst {\n\t\tclearEntityRecordEdits,\n\t\teditEntityRecord,\n\t\tinvalidateResolution,\n\t\treceiveEntityRecords,\n\t\tsaveEditedEntityRecord,\n\t} = useDispatch( coreStore );\n\tconst { createErrorNotice, removeAllNotices } = useDispatch( noticesStore );\n\n\tconst [ isSaving, setIsSaving ] = useState( false );\n\tconst [ isDiscardDialogOpen, setIsDiscardDialogOpen ] = useState( false );\n\tconst [ isPlacementActive, setIsPlacementActive ] = useState( false );\n\tconst [ isCanvasGestureActive, setIsCanvasGestureActive ] =\n\t\tuseState( false );\n\tconst placementControlTimerRef =\n\t\tuseRef< ReturnType< typeof setTimeout > >();\n\n\tconst [ aspectRatioValue, setAspectRatioValue ] = useState( '0' );\n\tconst [ freeformCrop, setFreeformCrop ] = useState( true );\n\n\tconst signalPlacementControlInteraction = useCallback( () => {\n\t\tsetIsPlacementActive( true );\n\t\tclearTimeout( placementControlTimerRef.current );\n\t\tplacementControlTimerRef.current = setTimeout( () => {\n\t\t\tsetIsPlacementActive( false );\n\t\t}, PLACEMENT_CONTROL_IDLE_MS );\n\t}, [] );\n\tconst handleCanvasGestureStart = useCallback( () => {\n\t\tsetIsCanvasGestureActive( true );\n\t}, [] );\n\tconst handleCanvasGestureEnd = useCallback( () => {\n\t\tsetIsCanvasGestureActive( false );\n\t}, [] );\n\tconst isCropInteractionActive = isPlacementActive || isCanvasGestureActive;\n\n\tuseEffect( () => {\n\t\treturn () => {\n\t\t\tclearTimeout( placementControlTimerRef.current );\n\t\t};\n\t}, [] );\n\n\tuseEffect( () => {\n\t\tsetAspectRatioValue( '0' );\n\t\tsetFreeformCrop( true );\n\t\tsetIsPlacementActive( false );\n\t\tsetIsCanvasGestureActive( false );\n\t}, [ id ] );\n\n\t// Bust the cached `_embed` resolution each time the editor mounts (or the\n\t// id changes) so embedded data such as the attached post's title or the\n\t// author's name reflects any edits made elsewhere since the last open.\n\tuseEffect( () => {\n\t\tinvalidateResolution( 'getEntityRecord', [\n\t\t\t'postType',\n\t\t\t'attachment',\n\t\t\tid,\n\t\t\tATTACHMENT_EMBED_QUERY,\n\t\t] );\n\t}, [ id, invalidateResolution ] );\n\n\tconst mediaType = getMediaTypeFromMimeType( media?.mime_type ).type;\n\tconst isImage = !! media && mediaType === 'image';\n\n\tconst imageAspectRatio = useMemo( () => {\n\t\tif ( ! isImage ) {\n\t\t\treturn null;\n\t\t}\n\t\tconst naturalWidth = Number( media?.media_details?.width );\n\t\tconst naturalHeight = Number( media?.media_details?.height );\n\t\tif (\n\t\t\tNumber.isFinite( naturalWidth ) &&\n\t\t\tNumber.isFinite( naturalHeight ) &&\n\t\t\tnaturalHeight > 0\n\t\t) {\n\t\t\treturn naturalWidth / naturalHeight;\n\t\t}\n\t\treturn null;\n\t}, [ isImage, media ] );\n\n\tconst tabs = useMemo< EditorTab[] >( () => {\n\t\tconst detailsTab: EditorTab = {\n\t\t\tid: 'details',\n\t\t\ttitle: __( 'Details' ),\n\t\t\tpanel: (\n\t\t\t\t<Stack\n\t\t\t\t\tclassName=\"media-editor__panel\"\n\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\tgap=\"lg\"\n\t\t\t\t>\n\t\t\t\t\t<MediaForm />\n\t\t\t\t</Stack>\n\t\t\t),\n\t\t};\n\t\tif ( ! isImage ) {\n\t\t\treturn [ detailsTab ];\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\tid: 'crop',\n\t\t\t\ttitle: __( 'Crop' ),\n\t\t\t\tpanel: (\n\t\t\t\t\t<Stack\n\t\t\t\t\t\tclassName=\"media-editor__panel\"\n\t\t\t\t\t\tdirection=\"column\"\n\t\t\t\t\t\tgap=\"lg\"\n\t\t\t\t\t>\n\t\t\t\t\t\t<MediaEditorCropPanel\n\t\t\t\t\t\t\taspectRatioValue={ aspectRatioValue }\n\t\t\t\t\t\t\tonAspectRatioChange={ setAspectRatioValue }\n\t\t\t\t\t\t\tfreeformCrop={ freeformCrop }\n\t\t\t\t\t\t\tonFreeformChange={ setFreeformCrop }\n\t\t\t\t\t\t\tonPlacementControlInteraction={\n\t\t\t\t\t\t\t\tsignalPlacementControlInteraction\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\taspectRatioPresets={ aspectRatioPresets }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</Stack>\n\t\t\t\t),\n\t\t\t},\n\t\t\tdetailsTab,\n\t\t];\n\t}, [\n\t\tisImage,\n\t\taspectRatioValue,\n\t\tfreeformCrop,\n\t\taspectRatioPresets,\n\t\tsignalPlacementControlInteraction,\n\t] );\n\n\tconst handleChange = ( updates: Partial< Media > ) => {\n\t\teditEntityRecord( 'postType', 'attachment', id, updates );\n\t};\n\n\tconst discardAndClose = () => {\n\t\tremoveAllNotices( 'snackbar', NOTICES_CONTEXT );\n\t\tclearEntityRecordEdits( 'postType', 'attachment', id );\n\t\tonClose?.();\n\t};\n\n\tconst handleRequestClose = () => {\n\t\tif ( isSaving ) {\n\t\t\treturn;\n\t\t}\n\t\tif ( hasChanges ) {\n\t\t\tsetIsDiscardDialogOpen( true );\n\t\t\treturn;\n\t\t}\n\t\tdiscardAndClose();\n\t};\n\n\tconst handleSave = async () => {\n\t\tremoveAllNotices( 'snackbar', NOTICES_CONTEXT );\n\t\tsetIsSaving( true );\n\t\ttry {\n\t\t\tlet saved: Media | null | undefined;\n\n\t\t\tconst modifiers =\n\t\t\t\tcropper.isDirty && cropper.state.image\n\t\t\t\t\t? buildModifiers( cropper.state, {\n\t\t\t\t\t\t\twidth: cropper.state.image.naturalWidth,\n\t\t\t\t\t\t\theight: cropper.state.image.naturalHeight,\n\t\t\t\t\t } )\n\t\t\t\t\t: [];\n\n\t\t\tif ( modifiers.length > 0 ) {\n\t\t\t\tconst pendingEdits = registry\n\t\t\t\t\t.select( coreStore )\n\t\t\t\t\t.getEntityRecordNonTransientEdits(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\tid\n\t\t\t\t\t) as PendingMetadataEdits;\n\t\t\t\tconst metadataEdits: Record< string, unknown > = {};\n\t\t\t\tfor ( const key of METADATA_EDIT_KEYS ) {\n\t\t\t\t\tif ( pendingEdits && key in pendingEdits ) {\n\t\t\t\t\t\tmetadataEdits[ key ] = pendingEdits[ key ];\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t// The `/edit` endpoint creates a new attachment for the crop\n\t\t\t\t// and doesn't inherit `post_parent` from the source (unlike\n\t\t\t\t// title/caption/etc.), so carry the existing value across when\n\t\t\t\t// the user hasn't explicitly edited it. Use a defined-check so\n\t\t\t\t// an explicit `0` (unattached) is also preserved.\n\t\t\t\tif (\n\t\t\t\t\t! ( 'post' in metadataEdits ) &&\n\t\t\t\t\tmedia?.post !== undefined\n\t\t\t\t) {\n\t\t\t\t\tmetadataEdits.post = media.post;\n\t\t\t\t}\n\n\t\t\t\tsaved = ( await apiFetch( {\n\t\t\t\t\tpath: `/wp/v2/media/${ id }/edit`,\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tdata: {\n\t\t\t\t\t\tsrc: media?.source_url,\n\t\t\t\t\t\tmodifiers,\n\t\t\t\t\t\t...metadataEdits,\n\t\t\t\t\t},\n\t\t\t\t} ) ) as Media;\n\n\t\t\t\tif ( saved ) {\n\t\t\t\t\treceiveEntityRecords(\n\t\t\t\t\t\t'postType',\n\t\t\t\t\t\t'attachment',\n\t\t\t\t\t\tsaved,\n\t\t\t\t\t\tundefined,\n\t\t\t\t\t\ttrue\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tsaved = ( await saveEditedEntityRecord(\n\t\t\t\t\t'postType',\n\t\t\t\t\t'attachment',\n\t\t\t\t\tid\n\t\t\t\t) ) as Media | undefined;\n\t\t\t}\n\n\t\t\tconst next = ( saved ?? media ) as Media | null;\n\n\t\t\tif ( next && next.id !== id ) {\n\t\t\t\tclearEntityRecordEdits( 'postType', 'attachment', id );\n\t\t\t}\n\n\t\t\tif ( next && next.id ) {\n\t\t\t\tif ( next.id === id ) {\n\t\t\t\t\tcropper.reset();\n\t\t\t\t}\n\t\t\t\tonSaved?.( {\n\t\t\t\t\tid: next.id,\n\t\t\t\t\turl: next.source_url,\n\t\t\t\t\tmedia: next,\n\t\t\t\t} );\n\t\t\t}\n\t\t} catch ( error ) {\n\t\t\tconst message =\n\t\t\t\terror instanceof Error\n\t\t\t\t\t? error.message\n\t\t\t\t\t: ( error as { message?: string } )?.message ??\n\t\t\t\t\t __( 'An unknown error occurred.' );\n\t\t\tcreateErrorNotice(\n\t\t\t\tisImage\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Error message. */\n\t\t\t\t\t\t\t__( 'Could not save image. %s' ),\n\t\t\t\t\t\t\tmessage\n\t\t\t\t\t )\n\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Error message. */\n\t\t\t\t\t\t\t__( 'Could not save media. %s' ),\n\t\t\t\t\t\t\tmessage\n\t\t\t\t\t ),\n\t\t\t\t{ type: 'snackbar', context: NOTICES_CONTEXT }\n\t\t\t);\n\t\t} finally {\n\t\t\tsetIsSaving( false );\n\t\t}\n\t};\n\n\tconst handleKeyDown = ( event: ReactKeyboardEvent< HTMLElement > ) => {\n\t\tconst isUndoShortcut = isKeyboardEvent.primary( event, 'z' );\n\t\tconst isRedoShortcut =\n\t\t\tisKeyboardEvent.primaryShift( event, 'z' ) ||\n\t\t\t( ! isAppleOS() && isKeyboardEvent.primary( event, 'y' ) );\n\t\tif ( ( isUndoShortcut || isRedoShortcut ) && isImage ) {\n\t\t\tconst target = event.target as HTMLElement;\n\t\t\tconst isMetadataField =\n\t\t\t\t( target.tagName === 'INPUT' ||\n\t\t\t\t\ttarget.tagName === 'TEXTAREA' ||\n\t\t\t\t\ttarget.isContentEditable ) &&\n\t\t\t\t! target.closest( `[${ CROP_CONTROL_ATTR }]` );\n\t\t\tif ( ! isMetadataField ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( isCropInteractionActive ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif ( isRedoShortcut ) {\n\t\t\t\t\tcropper.redo();\n\t\t\t\t} else {\n\t\t\t\t\tcropper.undo();\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tif ( shouldCloseOnEsc ) {\n\t\t\tif ( event.code !== 'Escape' && event.key !== 'Escape' ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( isSaving ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif ( hasChanges ) {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tsetIsDiscardDialogOpen( true );\n\t\t\t}\n\t\t}\n\t};\n\n\tconst snackbar = (\n\t\t<SnackbarNotices\n\t\t\tclassName={ noticesClassName }\n\t\t\tcontext={ NOTICES_CONTEXT }\n\t\t/>\n\t);\n\n\tconst children = (\n\t\t<MediaEditorProvider\n\t\t\tvalue={ media ?? undefined }\n\t\t\tonChange={ handleChange }\n\t\t\tsettings={ { fields } }\n\t\t>\n\t\t\t<div className=\"media-editor\">\n\t\t\t\t{ ! media ? (\n\t\t\t\t\t<div className=\"media-editor__loading\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</div>\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<Tabs>\n\t\t\t\t\t\t\t<MediaEditorSidebar tabs={ tabs } />\n\t\t\t\t\t\t</Tabs>\n\t\t\t\t\t\t<InterfaceSkeleton\n\t\t\t\t\t\t\tclassName=\"media-editor__skeleton\"\n\t\t\t\t\t\t\tlabels={ {\n\t\t\t\t\t\t\t\tbody: isImage\n\t\t\t\t\t\t\t\t\t? __( 'Image editor' )\n\t\t\t\t\t\t\t\t\t: __( 'Media preview' ),\n\t\t\t\t\t\t\t\tsidebar: __( 'Media details' ),\n\t\t\t\t\t\t\t\tfooter: __( 'Image editing tools' ),\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tcontent={\n\t\t\t\t\t\t\t\t<div className=\"media-editor__canvas\">\n\t\t\t\t\t\t\t\t\t{ isImage ? (\n\t\t\t\t\t\t\t\t\t\t<MediaEditorCanvas\n\t\t\t\t\t\t\t\t\t\t\taspectRatio={ resolveAspectRatio(\n\t\t\t\t\t\t\t\t\t\t\t\taspectRatioValue,\n\t\t\t\t\t\t\t\t\t\t\t\timageAspectRatio\n\t\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t\t\tfreeformCrop={ freeformCrop }\n\t\t\t\t\t\t\t\t\t\t\tfocusOnMount\n\t\t\t\t\t\t\t\t\t\t\tisPlacementActive={\n\t\t\t\t\t\t\t\t\t\t\t\tisPlacementActive\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonGestureStart={\n\t\t\t\t\t\t\t\t\t\t\t\thandleCanvasGestureStart\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\tonGestureEnd={\n\t\t\t\t\t\t\t\t\t\t\t\thandleCanvasGestureEnd\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t\t\t<MediaPreview />\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tfooter={\n\t\t\t\t\t\t\t\tisImage ? (\n\t\t\t\t\t\t\t\t\t<MediaEditorToolbar\n\t\t\t\t\t\t\t\t\t\tonReset={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetAspectRatioValue( '0' );\n\t\t\t\t\t\t\t\t\t\t\tsetFreeformCrop( true );\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tonPlacementControlInteraction={\n\t\t\t\t\t\t\t\t\t\t\tsignalPlacementControlInteraction\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tisUndoRedoDisabled={\n\t\t\t\t\t\t\t\t\t\t\tisCropInteractionActive\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t) : undefined\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tsidebar={\n\t\t\t\t\t\t\t\t<ComplementaryArea.Slot scope=\"media-editor\" />\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</div>\n\t\t\t<ConfirmDialog\n\t\t\t\tisOpen={ isDiscardDialogOpen }\n\t\t\t\tconfirmButtonText={ __( 'Discard' ) }\n\t\t\t\tcancelButtonText={ __( 'Keep editing' ) }\n\t\t\t\tonCancel={ () => setIsDiscardDialogOpen( false ) }\n\t\t\t\tonConfirm={ () => {\n\t\t\t\t\tsetIsDiscardDialogOpen( false );\n\t\t\t\t\tdiscardAndClose();\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __(\n\t\t\t\t\t'Are you sure you want to discard your unsaved changes?'\n\t\t\t\t) }\n\t\t\t</ConfirmDialog>\n\t\t\t{ noticesPortalElement\n\t\t\t\t? createPortal( snackbar, noticesPortalElement )\n\t\t\t\t: snackbar }\n\t\t</MediaEditorProvider>\n\t);\n\n\treturn renderFrame( {\n\t\tchildren,\n\t\theaderActions: (\n\t\t\t<HeaderActions\n\t\t\t\tisSaving={ isSaving }\n\t\t\t\thasMedia={ !! media }\n\t\t\t\thasChanges={ hasChanges }\n\t\t\t\tisImage={ isImage }\n\t\t\t\tshowCloseButton={ showCloseButton }\n\t\t\t\tonCancel={ handleRequestClose }\n\t\t\t\tonSave={ handleSave }\n\t\t\t/>\n\t\t),\n\t\tonRequestClose: handleRequestClose,\n\t\tonKeyDown: handleKeyDown,\n\t\tshouldCloseOnClickOutside: ! hasChanges && ! isSaving,\n\t\tisSaving,\n\t\thasChanges,\n\t\thasMedia: !! media,\n\t} );\n}\n\nexport function MediaEditor( props: MediaEditorProps ) {\n\treturn (\n\t\t<CropperProvider key={ props.id }>\n\t\t\t<MediaEditorContent { ...props } />\n\t\t</CropperProvider>\n\t);\n}\n\nexport default MediaEditor;\n"],
5
+ "mappings": ";AAGA,OAAO,cAAc;AACrB;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA,+BAA+B;AAAA,EAC/B,eAAe;AAAA,OACT;AACP,SAAS,aAAa;AACtB,SAAS,aAAa,aAAa,iBAAiB;AACpD,SAAS,SAAS,iBAAiB;AACnC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,IAAI,eAAe;AAC5B,SAAS,OAAO,aAAa,gBAAgB;AAC7C,SAAS,WAAW,uBAAuB;AAC3C,SAAS,iBAAiB,SAAS,oBAAoB;AAEvD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OAGM;AAMP,SAAS,2BAA2B;AAEpC,OAAO,kBAAkB;AACzB,OAAO,uBAAuB;AAC9B,OAAO,wBAAwB;AAC/B,OAAO;AAAA,EACN;AAAA,OACM;AACP,OAAO,eAAe;AACtB,SAAS,cAAc;AACvB,SAAS,gCAAgC;AACzC,SAAS,iBAAiB,kBAAkB;AAE5C,SAAS,yBAAyB;AAClC,SAAS,sBAAsB;AAC/B,OAAO,uCAAuC;AA2EvC,SAmdF,UAndE,KA6CL,YA7CK;AAvEP,IAAM,qBAAqB;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACD;AAKA,IAAM,yBAAyB,EAAE,QAAQ,wBAAwB;AAGjE,IAAM,kBAAkB;AACxB,IAAM,4BAA4B;AAElC,IAAM,EAAE,KAAK,IAAI,OAAQ,qBAAsB;AAsC/C,SAAS,mBAAoB,EAAE,KAAK,GAA2B;AAC9D,QAAM,mBAAmB,WAAY,KAAK,OAAQ;AAClD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAM;AAAA,MACN,YAAW;AAAA,MACX,OA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QAAS;AAAA,YACT,mBAAoB,GAAI,SAAU;AAAA,YAClC,kBAAmB,GAAI,cAAe;AAAA,YACtC,UAAW,MAAM,uBAAwB,KAAM;AAAA,YAC/C,WAAY,MAAM;AACjB,qCAAwB,KAAM;AAC9B,8BAAgB;AAAA,YACjB;AAAA,YAEE;AAAA,cACD;AAAA,YACD;AAAA;AAAA,QACD;AAAA,QACE,uBACC,aAAc,UAAU,oBAAqB,IAC7C;AAAA;AAAA;AAAA,EACJ;AAGD,SAAO,YAAa;AAAA,IACnB;AAAA,IACA,eACC;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA,UAAW,CAAC,CAAE;AAAA,QACd;AAAA,QACA;AAAA,QACA;AAAA,QACA,UAAW;AAAA,QACX,QAAS;AAAA;AAAA,IACV;AAAA,IAED,gBAAgB;AAAA,IAChB,WAAW;AAAA,IACX,2BAA2B,CAAE,cAAc,CAAE;AAAA,IAC7C;AAAA,IACA;AAAA,IACA,UAAU,CAAC,CAAE;AAAA,EACd,CAAE;AACH;AAEO,SAAS,YAAa,OAA0B;AACtD,SACC,oBAAC,mBACA,8BAAC,sBAAqB,GAAG,OAAQ,KADX,MAAM,EAE7B;AAEF;AAEA,IAAO,uBAAQ;",
6
+ "names": []
7
+ }
@@ -6,7 +6,10 @@ import { jsx } from "react/jsx-runtime";
6
6
  function MediaEditorCanvas({
7
7
  aspectRatio,
8
8
  freeformCrop,
9
- isPlacementActive = false
9
+ focusOnMount,
10
+ isPlacementActive = false,
11
+ onGestureStart,
12
+ onGestureEnd
10
13
  }) {
11
14
  const { media } = useMediaEditorContext();
12
15
  const controller = useCropper();
@@ -22,8 +25,17 @@ function MediaEditorCanvas({
22
25
  controller,
23
26
  aspectRatio,
24
27
  freeformCrop,
28
+ focusOnMount,
25
29
  showGrid: "interactive",
26
- isPlacementActive
30
+ isPlacementActive,
31
+ onGestureStart: () => {
32
+ onGestureStart?.();
33
+ controller.commitHistory();
34
+ },
35
+ onGestureEnd: () => {
36
+ controller.commitHistory();
37
+ onGestureEnd?.();
38
+ }
27
39
  }
28
40
  ) });
29
41
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/components/media-editor-canvas/index.tsx"],
4
- "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { useMediaEditorContext } from '../media-editor-provider';\nimport { getMediaTypeFromMimeType } from '../../utils';\nimport { Cropper, useCropper } from '../../image-editor';\n\nexport interface MediaEditorCanvasProps {\n\t/** Fixed aspect ratio (width / height). `undefined` means free. */\n\taspectRatio?: number;\n\t/** Enable freeform crop mode (resize handles). */\n\tfreeformCrop?: boolean;\n\t/** Whether external placement activity should reveal the grid. */\n\tisPlacementActive?: boolean;\n}\n\n/**\n * Editing surface for image media in the media editor modal. Pulls its\n * cropper controller from the surrounding `<CropperProvider>` so the\n * bottom bar and Crop sidebar tab share the same state.\n *\n * Returns `null` for missing or non-image media so the modal's outer\n * guards can render a spinner or fall through to `<MediaPreview>`.\n * @param props\n * @param props.aspectRatio\n * @param props.freeformCrop\n * @param props.isPlacementActive\n */\nexport default function MediaEditorCanvas( {\n\taspectRatio,\n\tfreeformCrop,\n\tisPlacementActive = false,\n}: MediaEditorCanvasProps ) {\n\tconst { media } = useMediaEditorContext();\n\tconst controller = useCropper();\n\n\tconst mediaUrl = media?.source_url;\n\tconst mediaType = getMediaTypeFromMimeType( media?.mime_type );\n\n\tif ( ! mediaUrl || mediaType.type !== 'image' ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"media-editor-canvas\">\n\t\t\t<Cropper\n\t\t\t\tsrc={ mediaUrl }\n\t\t\t\tcontroller={ controller }\n\t\t\t\taspectRatio={ aspectRatio }\n\t\t\t\tfreeformCrop={ freeformCrop }\n\t\t\t\tshowGrid=\"interactive\"\n\t\t\t\tisPlacementActive={ isPlacementActive }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],
5
- "mappings": ";AAGA,SAAS,6BAA6B;AACtC,SAAS,gCAAgC;AACzC,SAAS,SAAS,kBAAkB;AAwCjC;AAjBY,SAAR,kBAAoC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA,oBAAoB;AACrB,GAA4B;AAC3B,QAAM,EAAE,MAAM,IAAI,sBAAsB;AACxC,QAAM,aAAa,WAAW;AAE9B,QAAM,WAAW,OAAO;AACxB,QAAM,YAAY,yBAA0B,OAAO,SAAU;AAE7D,MAAK,CAAE,YAAY,UAAU,SAAS,SAAU;AAC/C,WAAO;AAAA,EACR;AAEA,SACC,oBAAC,SAAI,WAAU,uBACd;AAAA,IAAC;AAAA;AAAA,MACA,KAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAS;AAAA,MACT;AAAA;AAAA,EACD,GACD;AAEF;",
4
+ "sourcesContent": ["/**\n * Internal dependencies\n */\nimport { useMediaEditorContext } from '../media-editor-provider';\nimport { getMediaTypeFromMimeType } from '../../utils';\nimport { Cropper, useCropper } from '../../image-editor';\n\nexport interface MediaEditorCanvasProps {\n\t/** Fixed aspect ratio (width / height). `undefined` means free. */\n\taspectRatio?: number;\n\t/** Enable freeform crop mode (resize handles). */\n\tfreeformCrop?: boolean;\n\t/** Focus the crop area when the canvas mounts. */\n\tfocusOnMount?: boolean;\n\t/** Whether external placement activity should reveal the grid. */\n\tisPlacementActive?: boolean;\n\t/** Fires when a canvas cropper gesture begins. */\n\tonGestureStart?: () => void;\n\t/** Fires when a canvas cropper gesture ends. */\n\tonGestureEnd?: () => void;\n}\n\n/**\n * Editing surface for image media in the media editor modal. Pulls its\n * cropper controller from the surrounding `<CropperProvider>` so the\n * bottom bar and Crop sidebar tab share the same state.\n *\n * Returns `null` for missing or non-image media so the modal's outer\n * guards can render a spinner or fall through to `<MediaPreview>`.\n * @param props\n * @param props.aspectRatio\n * @param props.freeformCrop\n * @param props.focusOnMount\n * @param props.isPlacementActive\n * @param props.onGestureStart\n * @param props.onGestureEnd\n */\nexport default function MediaEditorCanvas( {\n\taspectRatio,\n\tfreeformCrop,\n\tfocusOnMount,\n\tisPlacementActive = false,\n\tonGestureStart,\n\tonGestureEnd,\n}: MediaEditorCanvasProps ) {\n\tconst { media } = useMediaEditorContext();\n\tconst controller = useCropper();\n\n\tconst mediaUrl = media?.source_url;\n\tconst mediaType = getMediaTypeFromMimeType( media?.mime_type );\n\n\tif ( ! mediaUrl || mediaType.type !== 'image' ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"media-editor-canvas\">\n\t\t\t<Cropper\n\t\t\t\tsrc={ mediaUrl }\n\t\t\t\tcontroller={ controller }\n\t\t\t\taspectRatio={ aspectRatio }\n\t\t\t\tfreeformCrop={ freeformCrop }\n\t\t\t\tfocusOnMount={ focusOnMount }\n\t\t\t\tshowGrid=\"interactive\"\n\t\t\t\tisPlacementActive={ isPlacementActive }\n\t\t\t\t// Flush on gesture start so any pending sidebar interaction\n\t\t\t\t// (e.g. zoom slider debounce) is committed as its own undo\n\t\t\t\t// step before the canvas gesture begins.\n\t\t\t\tonGestureStart={ () => {\n\t\t\t\t\tonGestureStart?.();\n\t\t\t\t\tcontroller.commitHistory();\n\t\t\t\t} }\n\t\t\t\tonGestureEnd={ () => {\n\t\t\t\t\tcontroller.commitHistory();\n\t\t\t\t\tonGestureEnd?.();\n\t\t\t\t} }\n\t\t\t/>\n\t\t</div>\n\t);\n}\n"],
5
+ "mappings": ";AAGA,SAAS,6BAA6B;AACtC,SAAS,gCAAgC;AACzC,SAAS,SAAS,kBAAkB;AAoDjC;AApBY,SAAR,kBAAoC;AAAA,EAC1C;AAAA,EACA;AAAA,EACA;AAAA,EACA,oBAAoB;AAAA,EACpB;AAAA,EACA;AACD,GAA4B;AAC3B,QAAM,EAAE,MAAM,IAAI,sBAAsB;AACxC,QAAM,aAAa,WAAW;AAE9B,QAAM,WAAW,OAAO;AACxB,QAAM,YAAY,yBAA0B,OAAO,SAAU;AAE7D,MAAK,CAAE,YAAY,UAAU,SAAS,SAAU;AAC/C,WAAO;AAAA,EACR;AAEA,SACC,oBAAC,SAAI,WAAU,uBACd;AAAA,IAAC;AAAA;AAAA,MACA,KAAM;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,UAAS;AAAA,MACT;AAAA,MAIA,gBAAiB,MAAM;AACtB,yBAAiB;AACjB,mBAAW,cAAc;AAAA,MAC1B;AAAA,MACA,cAAe,MAAM;AACpB,mBAAW,cAAc;AACzB,uBAAe;AAAA,MAChB;AAAA;AAAA,EACD,GACD;AAEF;",
6
6
  "names": []
7
7
  }