@wordpress/media-editor 0.16.0 → 0.17.2-next.v.202608281122.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +25 -1
- package/build/components/media-editor/index.cjs +188 -183
- package/build/components/media-editor/index.cjs.map +3 -3
- package/build/components/media-editor-canvas/index.cjs +0 -2
- package/build/components/media-editor-canvas/index.cjs.map +2 -2
- package/build/components/media-editor-crop-panel/index.cjs +2 -3
- package/build/components/media-editor-crop-panel/index.cjs.map +2 -2
- package/build/components/media-editor-modal/index.cjs +16 -14
- package/build/components/media-editor-modal/index.cjs.map +3 -3
- package/build-module/components/media-editor/index.mjs +192 -190
- package/build-module/components/media-editor/index.mjs.map +2 -2
- package/build-module/components/media-editor-canvas/index.mjs +0 -2
- package/build-module/components/media-editor-canvas/index.mjs.map +2 -2
- package/build-module/components/media-editor-crop-panel/index.mjs +2 -3
- package/build-module/components/media-editor-crop-panel/index.mjs.map +2 -2
- package/build-module/components/media-editor-modal/index.mjs +16 -14
- package/build-module/components/media-editor-modal/index.mjs.map +2 -2
- package/build-style/style-rtl.css +62 -95
- package/build-style/style.css +62 -95
- package/build-types/components/media-editor/index.d.ts +39 -11
- package/build-types/components/media-editor/index.d.ts.map +1 -1
- package/build-types/components/media-editor-canvas/index.d.ts +1 -4
- package/build-types/components/media-editor-canvas/index.d.ts.map +1 -1
- package/build-types/components/media-editor-crop-panel/index.d.ts +4 -11
- package/build-types/components/media-editor-crop-panel/index.d.ts.map +1 -1
- package/build-types/components/media-editor-modal/index.d.ts.map +1 -1
- package/global.d.ts +5 -0
- package/package.json +23 -22
- package/src/components/media-editor/index.tsx +381 -271
- package/src/components/media-editor/style.scss +136 -131
- package/src/components/media-editor-canvas/index.tsx +5 -9
- package/src/components/media-editor-crop-panel/index.tsx +4 -12
- package/src/components/media-editor-crop-panel/test/index.tsx +2 -10
- package/src/components/media-editor-modal/index.tsx +23 -12
- package/src/components/media-editor-modal/style.scss +14 -51
- package/src/image-editor/stories/rectangle-crop.story.tsx +15 -0
- package/tsconfig.build.json +26 -0
- package/tsconfig.build.tsbuildinfo +1 -0
- package/tsconfig.json +23 -16
- package/build-types/components/rotation-ruler/stories/index.story.d.ts +0 -8
- package/build-types/components/rotation-ruler/stories/index.story.d.ts.map +0 -1
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts +0 -10
- package/build-types/image-editor/stories/rectangle-crop.story.d.ts.map +0 -1
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
// packages/media-editor/src/components/media-editor/index.tsx
|
|
2
|
+
import clsx from "clsx";
|
|
2
3
|
import {
|
|
3
4
|
Button,
|
|
4
5
|
Spinner,
|
|
5
6
|
__experimentalConfirmDialog as ConfirmDialog
|
|
6
7
|
} from "@wordpress/components";
|
|
7
|
-
import { Stack, Tabs } from "@wordpress/ui";
|
|
8
|
+
import { Stack, Tabs, VisuallyHidden } from "@wordpress/ui";
|
|
8
9
|
import { useViewportMatch } from "@wordpress/compose";
|
|
9
10
|
import { useDispatch, useSelect } from "@wordpress/data";
|
|
10
11
|
import { store as coreStore } from "@wordpress/core-data";
|
|
12
|
+
import { NavigableRegion } from "@wordpress/admin-ui";
|
|
11
13
|
import {
|
|
14
|
+
createContext,
|
|
12
15
|
createPortal,
|
|
13
16
|
useCallback,
|
|
17
|
+
useContext,
|
|
14
18
|
useEffect,
|
|
15
|
-
useMemo,
|
|
16
19
|
useRef,
|
|
17
20
|
useState
|
|
18
21
|
} from "@wordpress/element";
|
|
@@ -24,17 +27,12 @@ import {
|
|
|
24
27
|
isKeyboardEvent
|
|
25
28
|
} from "@wordpress/keycodes";
|
|
26
29
|
import { SnackbarNotices, store as noticesStore } from "@wordpress/notices";
|
|
27
|
-
import {
|
|
28
|
-
ComplementaryArea,
|
|
29
|
-
InterfaceSkeleton,
|
|
30
|
-
PinnedItems
|
|
31
|
-
} from "@wordpress/interface";
|
|
32
30
|
import { MediaEditorProvider } from "../media-editor-provider/index.mjs";
|
|
33
31
|
import MediaPreview from "../media-preview/index.mjs";
|
|
34
32
|
import MediaEditorCanvas from "../media-editor-canvas/index.mjs";
|
|
35
33
|
import MediaEditorFineRotation from "../media-editor-fine-rotation/index.mjs";
|
|
36
|
-
import MediaEditorImageControls from "../media-editor-image-controls/index.mjs";
|
|
37
34
|
import MediaEditorCropPanel from "../media-editor-crop-panel/index.mjs";
|
|
35
|
+
import MediaEditorImageControls from "../media-editor-image-controls/index.mjs";
|
|
38
36
|
import MediaForm from "../media-form/index.mjs";
|
|
39
37
|
import { getMediaTypeFromMimeType } from "../../utils/index.mjs";
|
|
40
38
|
import { MediaEditorStateProvider, useMediaEditor } from "../../state/index.mjs";
|
|
@@ -45,44 +43,61 @@ import {
|
|
|
45
43
|
useSaveMediaEditor
|
|
46
44
|
} from "./use-save-media-editor.mjs";
|
|
47
45
|
import { useCropOptions } from "./use-crop-options.mjs";
|
|
48
|
-
import {
|
|
46
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
49
47
|
var ATTACHMENT_EMBED_QUERY = { _embed: "author,wp:attached-to" };
|
|
50
48
|
var PLACEMENT_CONTROL_IDLE_MS = 300;
|
|
49
|
+
var DETAILS_PANEL = "details";
|
|
50
|
+
var CROP_PANEL = "crop";
|
|
51
51
|
function MediaEditorSidebar({
|
|
52
52
|
tabs,
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
activeTab,
|
|
54
|
+
onSelectTab
|
|
55
55
|
}) {
|
|
56
|
-
return /* @__PURE__ */
|
|
57
|
-
|
|
56
|
+
return /* @__PURE__ */ jsxs(
|
|
57
|
+
NavigableRegion,
|
|
58
58
|
{
|
|
59
|
-
scope: "media-editor",
|
|
60
|
-
identifier: "media-editor/details",
|
|
61
|
-
title: __("Details"),
|
|
62
|
-
icon: drawerRight,
|
|
63
|
-
isActiveByDefault: true,
|
|
64
59
|
className: "media-editor__sidebar",
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
60
|
+
ariaLabel: __("Media settings"),
|
|
61
|
+
children: [
|
|
62
|
+
/* @__PURE__ */ jsx(VisuallyHidden, { render: /* @__PURE__ */ jsx("h2", {}), children: __("Media settings") }),
|
|
63
|
+
/* @__PURE__ */ jsxs(
|
|
64
|
+
Tabs.Root,
|
|
65
|
+
{
|
|
66
|
+
className: "media-editor__tabs",
|
|
67
|
+
value: activeTab,
|
|
68
|
+
onValueChange: onSelectTab,
|
|
69
|
+
children: [
|
|
70
|
+
/* @__PURE__ */ jsx("div", { className: "media-editor__tablist", children: /* @__PURE__ */ jsx(Tabs.List, { variant: "minimal", children: tabs.map((tab) => /* @__PURE__ */ jsx(Tabs.Tab, { value: tab.id, children: tab.title }, tab.id)) }) }),
|
|
71
|
+
tabs.map((tab) => /* @__PURE__ */ jsx(
|
|
72
|
+
Tabs.Panel,
|
|
73
|
+
{
|
|
74
|
+
value: tab.id,
|
|
75
|
+
tabIndex: -1,
|
|
76
|
+
className: "media-editor__panel",
|
|
77
|
+
children: /* @__PURE__ */ jsx(Stack, { direction: "column", gap: "lg", children: tab.render() })
|
|
78
|
+
},
|
|
79
|
+
tab.id
|
|
80
|
+
))
|
|
81
|
+
]
|
|
82
|
+
}
|
|
83
|
+
)
|
|
84
|
+
]
|
|
77
85
|
}
|
|
78
86
|
);
|
|
79
87
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
88
|
+
var MediaEditorFrameContext = createContext(null);
|
|
89
|
+
function useMediaEditorFrameContext() {
|
|
90
|
+
const context = useContext(MediaEditorFrameContext);
|
|
91
|
+
if (!context) {
|
|
92
|
+
throw new Error(
|
|
93
|
+
"useMediaEditorFrameContext must be used within MediaEditor"
|
|
94
|
+
);
|
|
95
|
+
}
|
|
96
|
+
return context;
|
|
97
|
+
}
|
|
98
|
+
function HeaderActions({ showCloseButton = false }) {
|
|
99
|
+
const { isImage, isSaving, onCancel, isWide, activePanel, onTogglePanel } = useMediaEditorFrameContext();
|
|
100
|
+
const isPanelOpen = !!activePanel;
|
|
86
101
|
const [isShortcutsModalOpen, setIsShortcutsModalOpen] = useState(false);
|
|
87
102
|
return /* @__PURE__ */ jsxs(
|
|
88
103
|
Stack,
|
|
@@ -101,7 +116,17 @@ function HeaderActions({
|
|
|
101
116
|
onClick: () => setIsShortcutsModalOpen(true)
|
|
102
117
|
}
|
|
103
118
|
),
|
|
104
|
-
/* @__PURE__ */ jsx(
|
|
119
|
+
/* @__PURE__ */ jsx(
|
|
120
|
+
Button,
|
|
121
|
+
{
|
|
122
|
+
size: "compact",
|
|
123
|
+
icon: drawerRight,
|
|
124
|
+
label: __("Media settings"),
|
|
125
|
+
isPressed: isPanelOpen,
|
|
126
|
+
"aria-expanded": isWide ? isPanelOpen : void 0,
|
|
127
|
+
onClick: onTogglePanel
|
|
128
|
+
}
|
|
129
|
+
),
|
|
105
130
|
showCloseButton && /* @__PURE__ */ jsx(
|
|
106
131
|
Button,
|
|
107
132
|
{
|
|
@@ -123,10 +148,8 @@ function HeaderActions({
|
|
|
123
148
|
}
|
|
124
149
|
);
|
|
125
150
|
}
|
|
126
|
-
function HistoryActions({
|
|
127
|
-
isUndoRedoDisabled =
|
|
128
|
-
onReset
|
|
129
|
-
}) {
|
|
151
|
+
function HistoryActions() {
|
|
152
|
+
const { isImage, isUndoRedoDisabled, onReset, isWide, activePanel } = useMediaEditorFrameContext();
|
|
130
153
|
const {
|
|
131
154
|
reset,
|
|
132
155
|
isDirty,
|
|
@@ -137,6 +160,9 @@ function HistoryActions({
|
|
|
137
160
|
beginGesture,
|
|
138
161
|
endGesture
|
|
139
162
|
} = useMediaEditor();
|
|
163
|
+
if (!isImage || !isWide && !!activePanel) {
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
140
166
|
const handleUndo = () => {
|
|
141
167
|
if (isUndoRedoDisabled) {
|
|
142
168
|
return;
|
|
@@ -203,18 +229,13 @@ function HistoryActions({
|
|
|
203
229
|
}
|
|
204
230
|
);
|
|
205
231
|
}
|
|
206
|
-
function
|
|
207
|
-
isSaving,
|
|
208
|
-
hasMedia,
|
|
209
|
-
hasChanges,
|
|
210
|
-
onCancel,
|
|
211
|
-
onSave
|
|
212
|
-
}) {
|
|
232
|
+
function SaveActions({ size = "default" }) {
|
|
233
|
+
const { isSaving, hasMedia, hasChanges, onCancel, onSave } = useMediaEditorFrameContext();
|
|
213
234
|
const saveDisabled = isSaving || !hasMedia || !hasChanges;
|
|
214
235
|
return /* @__PURE__ */ jsxs(
|
|
215
236
|
Stack,
|
|
216
237
|
{
|
|
217
|
-
className: "media-
|
|
238
|
+
className: "media-editor__save-actions",
|
|
218
239
|
justify: "flex-end",
|
|
219
240
|
align: "center",
|
|
220
241
|
gap: "sm",
|
|
@@ -223,6 +244,7 @@ function FooterActions({
|
|
|
223
244
|
Button,
|
|
224
245
|
{
|
|
225
246
|
__next40pxDefaultSize: true,
|
|
247
|
+
size,
|
|
226
248
|
variant: "tertiary",
|
|
227
249
|
onClick: onCancel,
|
|
228
250
|
disabled: isSaving,
|
|
@@ -234,6 +256,7 @@ function FooterActions({
|
|
|
234
256
|
Button,
|
|
235
257
|
{
|
|
236
258
|
__next40pxDefaultSize: true,
|
|
259
|
+
size,
|
|
237
260
|
variant: "primary",
|
|
238
261
|
onClick: onSave,
|
|
239
262
|
isBusy: isSaving,
|
|
@@ -255,12 +278,26 @@ function MediaEditorContent({
|
|
|
255
278
|
renderFrame,
|
|
256
279
|
noticesClassName = "media-editor__snackbar",
|
|
257
280
|
noticesPortalElement,
|
|
258
|
-
showCloseButton = false,
|
|
259
281
|
shouldCloseOnEsc = false
|
|
260
282
|
}) {
|
|
261
283
|
const cropper = useMediaEditor();
|
|
262
|
-
const
|
|
263
|
-
const
|
|
284
|
+
const isWide = useViewportMatch("small");
|
|
285
|
+
const [activePanel, setActivePanel] = useState(
|
|
286
|
+
isWide ? DETAILS_PANEL : null
|
|
287
|
+
);
|
|
288
|
+
const hasChosenPanelRef = useRef(false);
|
|
289
|
+
const lastPanelRef = useRef(DETAILS_PANEL);
|
|
290
|
+
const hasChosenTabRef = useRef(false);
|
|
291
|
+
const selectPanel = useCallback((panel) => {
|
|
292
|
+
hasChosenTabRef.current = true;
|
|
293
|
+
lastPanelRef.current = panel;
|
|
294
|
+
setActivePanel(panel);
|
|
295
|
+
}, []);
|
|
296
|
+
const togglePanel = useCallback(() => {
|
|
297
|
+
hasChosenPanelRef.current = true;
|
|
298
|
+
setActivePanel((open) => open ? null : lastPanelRef.current);
|
|
299
|
+
}, []);
|
|
300
|
+
const layout = isWide ? "wide" : "narrow";
|
|
264
301
|
const { media, hasEdits } = useSelect(
|
|
265
302
|
(select) => {
|
|
266
303
|
const {
|
|
@@ -329,14 +366,24 @@ function MediaEditorContent({
|
|
|
329
366
|
}, [id, invalidateResolution]);
|
|
330
367
|
const mediaType = getMediaTypeFromMimeType(media?.mime_type).type;
|
|
331
368
|
const isImage = !!media && mediaType === "image";
|
|
369
|
+
useEffect(() => {
|
|
370
|
+
if (hasChosenPanelRef.current && hasChosenTabRef.current) {
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
const defaultPanel = isWide && isImage ? CROP_PANEL : DETAILS_PANEL;
|
|
374
|
+
if (!hasChosenTabRef.current) {
|
|
375
|
+
lastPanelRef.current = defaultPanel;
|
|
376
|
+
}
|
|
377
|
+
if (!hasChosenPanelRef.current) {
|
|
378
|
+
setActivePanel(isWide ? lastPanelRef.current : null);
|
|
379
|
+
}
|
|
380
|
+
}, [isWide, isImage]);
|
|
332
381
|
const {
|
|
333
382
|
aspectRatioValue,
|
|
334
383
|
setAspectRatioValue,
|
|
335
384
|
aspectRatioOptions,
|
|
336
385
|
resetCropOptions
|
|
337
|
-
} = useCropOptions({
|
|
338
|
-
aspectRatioPresets
|
|
339
|
-
});
|
|
386
|
+
} = useCropOptions({ aspectRatioPresets });
|
|
340
387
|
const { isSaving, save: saveMediaEditor } = useSaveMediaEditor({
|
|
341
388
|
cropper,
|
|
342
389
|
id,
|
|
@@ -344,56 +391,6 @@ function MediaEditorContent({
|
|
|
344
391
|
media,
|
|
345
392
|
onSaved
|
|
346
393
|
});
|
|
347
|
-
const tabs = useMemo(() => {
|
|
348
|
-
const detailsTab = {
|
|
349
|
-
id: "details",
|
|
350
|
-
title: __("Details"),
|
|
351
|
-
panel: /* @__PURE__ */ jsx(
|
|
352
|
-
Stack,
|
|
353
|
-
{
|
|
354
|
-
className: "media-editor__panel",
|
|
355
|
-
direction: "column",
|
|
356
|
-
gap: "lg",
|
|
357
|
-
children: /* @__PURE__ */ jsx(MediaForm, {})
|
|
358
|
-
}
|
|
359
|
-
)
|
|
360
|
-
};
|
|
361
|
-
if (!isImage) {
|
|
362
|
-
return [detailsTab];
|
|
363
|
-
}
|
|
364
|
-
return [
|
|
365
|
-
{
|
|
366
|
-
id: "crop",
|
|
367
|
-
title: __("Crop"),
|
|
368
|
-
panel: /* @__PURE__ */ jsx(
|
|
369
|
-
Stack,
|
|
370
|
-
{
|
|
371
|
-
className: "media-editor__panel",
|
|
372
|
-
direction: "column",
|
|
373
|
-
gap: "lg",
|
|
374
|
-
children: /* @__PURE__ */ jsx(
|
|
375
|
-
MediaEditorCropPanel,
|
|
376
|
-
{
|
|
377
|
-
aspectRatioValue,
|
|
378
|
-
onAspectRatioChange: setAspectRatioValue,
|
|
379
|
-
aspectRatioOptions,
|
|
380
|
-
showTransformControls: isPanelLayout
|
|
381
|
-
}
|
|
382
|
-
)
|
|
383
|
-
}
|
|
384
|
-
)
|
|
385
|
-
},
|
|
386
|
-
detailsTab
|
|
387
|
-
];
|
|
388
|
-
}, [
|
|
389
|
-
isImage,
|
|
390
|
-
aspectRatioValue,
|
|
391
|
-
setAspectRatioValue,
|
|
392
|
-
aspectRatioOptions,
|
|
393
|
-
isPanelLayout
|
|
394
|
-
]);
|
|
395
|
-
const [selectedTabId, setSelectedTabId] = useState();
|
|
396
|
-
const activeTabId = selectedTabId ?? tabs[0]?.id;
|
|
397
394
|
const handleChange = (updates) => {
|
|
398
395
|
editEntityRecord("postType", "attachment", id, updates);
|
|
399
396
|
};
|
|
@@ -451,6 +448,34 @@ function MediaEditorContent({
|
|
|
451
448
|
context: MEDIA_EDITOR_NOTICES_CONTEXT
|
|
452
449
|
}
|
|
453
450
|
);
|
|
451
|
+
const imageControls = isImage && !isWide ? /* @__PURE__ */ jsx(
|
|
452
|
+
MediaEditorImageControls,
|
|
453
|
+
{
|
|
454
|
+
showAspectRatioControl: true,
|
|
455
|
+
aspectRatioPresets
|
|
456
|
+
}
|
|
457
|
+
) : null;
|
|
458
|
+
const tabs = [
|
|
459
|
+
...isImage ? [
|
|
460
|
+
{
|
|
461
|
+
id: CROP_PANEL,
|
|
462
|
+
title: __("Crop"),
|
|
463
|
+
render: () => /* @__PURE__ */ jsx(
|
|
464
|
+
MediaEditorCropPanel,
|
|
465
|
+
{
|
|
466
|
+
aspectRatioValue,
|
|
467
|
+
onAspectRatioChange: setAspectRatioValue,
|
|
468
|
+
aspectRatioOptions
|
|
469
|
+
}
|
|
470
|
+
)
|
|
471
|
+
}
|
|
472
|
+
] : [],
|
|
473
|
+
{
|
|
474
|
+
id: DETAILS_PANEL,
|
|
475
|
+
title: __("Details"),
|
|
476
|
+
render: () => /* @__PURE__ */ jsx(MediaForm, {})
|
|
477
|
+
}
|
|
478
|
+
];
|
|
454
479
|
const ruler = isImage ? /* @__PURE__ */ jsx(
|
|
455
480
|
MediaEditorFineRotation,
|
|
456
481
|
{
|
|
@@ -464,39 +489,47 @@ function MediaEditorContent({
|
|
|
464
489
|
onChange: handleChange,
|
|
465
490
|
settings: { fields },
|
|
466
491
|
children: [
|
|
467
|
-
/* @__PURE__ */ jsx("div", { className: "media-editor", children: !media ? /* @__PURE__ */ jsx("div", { className: "media-editor__loading", children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsxs(
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
{
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
492
|
+
/* @__PURE__ */ jsx("div", { className: "media-editor", children: !media ? /* @__PURE__ */ jsx("div", { className: "media-editor__loading", children: /* @__PURE__ */ jsx(Spinner, {}) }) : /* @__PURE__ */ jsxs(
|
|
493
|
+
"div",
|
|
494
|
+
{
|
|
495
|
+
className: clsx("media-editor__body", {
|
|
496
|
+
"has-panel-open": !!activePanel
|
|
497
|
+
}),
|
|
498
|
+
children: [
|
|
499
|
+
/* @__PURE__ */ jsxs(
|
|
500
|
+
NavigableRegion,
|
|
501
|
+
{
|
|
502
|
+
className: "media-editor__content",
|
|
503
|
+
ariaLabel: isImage ? __("Image editor") : __("Media preview"),
|
|
504
|
+
children: [
|
|
505
|
+
/* @__PURE__ */ jsx("div", { className: "media-editor__canvas-area", children: isImage ? /* @__PURE__ */ jsx(
|
|
506
|
+
MediaEditorCanvas,
|
|
507
|
+
{
|
|
508
|
+
isPlacementActive,
|
|
509
|
+
onGestureStart: handleCanvasGestureStart,
|
|
510
|
+
onGestureEnd: handleCanvasGestureEnd
|
|
511
|
+
}
|
|
512
|
+
) : /* @__PURE__ */ jsx(MediaPreview, {}) }),
|
|
513
|
+
isImage && /* @__PURE__ */ jsxs("div", { className: "media-editor__canvas-toolbar", children: [
|
|
514
|
+
ruler,
|
|
515
|
+
imageControls
|
|
516
|
+
] })
|
|
517
|
+
]
|
|
518
|
+
}
|
|
519
|
+
),
|
|
520
|
+
!!activePanel && /* @__PURE__ */ jsx(
|
|
521
|
+
MediaEditorSidebar,
|
|
522
|
+
{
|
|
523
|
+
tabs,
|
|
524
|
+
activeTab: tabs.some(
|
|
525
|
+
(tab) => tab.id === activePanel
|
|
526
|
+
) ? activePanel : DETAILS_PANEL,
|
|
527
|
+
onSelectTab: selectPanel
|
|
528
|
+
}
|
|
529
|
+
)
|
|
530
|
+
]
|
|
531
|
+
}
|
|
532
|
+
) }),
|
|
500
533
|
/* @__PURE__ */ jsx(
|
|
501
534
|
ConfirmDialog,
|
|
502
535
|
{
|
|
@@ -517,69 +550,38 @@ function MediaEditorContent({
|
|
|
517
550
|
]
|
|
518
551
|
}
|
|
519
552
|
);
|
|
520
|
-
const
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
FooterActions,
|
|
536
|
-
{
|
|
537
|
-
isSaving,
|
|
538
|
-
hasMedia: !!media,
|
|
539
|
-
hasChanges,
|
|
540
|
-
onCancel: handleRequestClose,
|
|
541
|
-
onSave: saveMediaEditor
|
|
542
|
-
}
|
|
543
|
-
);
|
|
544
|
-
let footerActions;
|
|
545
|
-
if (footerLayout === "wide") {
|
|
546
|
-
footerActions = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
547
|
-
history,
|
|
548
|
-
actions
|
|
549
|
-
] });
|
|
550
|
-
} else {
|
|
551
|
-
footerActions = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
552
|
-
imageControls,
|
|
553
|
-
/* @__PURE__ */ jsxs("div", { className: "media-editor-modal__footer-row", children: [
|
|
554
|
-
history,
|
|
555
|
-
actions
|
|
556
|
-
] })
|
|
557
|
-
] });
|
|
558
|
-
}
|
|
559
|
-
return renderFrame({
|
|
553
|
+
const contextValue = {
|
|
554
|
+
isImage,
|
|
555
|
+
isSaving,
|
|
556
|
+
hasMedia: !!media,
|
|
557
|
+
hasChanges,
|
|
558
|
+
isUndoRedoDisabled: isCropInteractionActive,
|
|
559
|
+
aspectRatioPresets,
|
|
560
|
+
isWide,
|
|
561
|
+
activePanel,
|
|
562
|
+
onTogglePanel: togglePanel,
|
|
563
|
+
onCancel: handleRequestClose,
|
|
564
|
+
onSave: saveMediaEditor,
|
|
565
|
+
onReset: resetCropOptions
|
|
566
|
+
};
|
|
567
|
+
return /* @__PURE__ */ jsx(MediaEditorFrameContext.Provider, { value: contextValue, children: renderFrame({
|
|
560
568
|
children,
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
{
|
|
564
|
-
isSaving,
|
|
565
|
-
isImage,
|
|
566
|
-
showCloseButton,
|
|
567
|
-
onCancel: handleRequestClose
|
|
568
|
-
}
|
|
569
|
-
),
|
|
570
|
-
footerActions,
|
|
571
|
-
footerLayout,
|
|
569
|
+
isImage,
|
|
570
|
+
layout,
|
|
572
571
|
onRequestClose: handleRequestClose,
|
|
573
572
|
onKeyDown: handleKeyDown,
|
|
574
573
|
shouldCloseOnClickOutside: !hasChanges && !isSaving,
|
|
575
574
|
isSaving,
|
|
576
575
|
hasChanges,
|
|
577
576
|
hasMedia: !!media
|
|
578
|
-
});
|
|
577
|
+
}) });
|
|
579
578
|
}
|
|
580
579
|
function MediaEditor(props) {
|
|
581
580
|
return /* @__PURE__ */ jsx(MediaEditorStateProvider, { children: /* @__PURE__ */ jsx(MediaEditorContent, { ...props }) }, props.id);
|
|
582
581
|
}
|
|
582
|
+
MediaEditor.HeaderActions = HeaderActions;
|
|
583
|
+
MediaEditor.HistoryActions = HistoryActions;
|
|
584
|
+
MediaEditor.SaveActions = SaveActions;
|
|
583
585
|
var media_editor_default = MediaEditor;
|
|
584
586
|
export {
|
|
585
587
|
MediaEditor,
|