@yogiswara/honcho-editor-ui 1.4.24 → 2.0.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/dist/components/editor/HSliderLightMobile.js +7 -1
- package/dist/hooks/editor/useHonchoEditor.d.ts +2 -0
- package/dist/hooks/editor/useHonchoEditor.js +17 -124
- package/dist/hooks/editor/useHonchoEditorBulk.d.ts +74 -0
- package/dist/hooks/editor/useHonchoEditorBulk.js +235 -0
- package/package.json +1 -1
|
@@ -68,12 +68,13 @@ export default function HSliderLightMobile(props) {
|
|
|
68
68
|
},
|
|
69
69
|
'& .MuiSlider-thumb': {
|
|
70
70
|
background: colors.surface,
|
|
71
|
+
boxShadow: 'none',
|
|
71
72
|
opacity: 1,
|
|
72
73
|
},
|
|
73
74
|
'& .MuiSlider-thumb:hover': {
|
|
74
75
|
boxShadow: 'none',
|
|
75
76
|
}
|
|
76
|
-
}, size: "small", value: props.exposureScore, step: 0.1, min: -
|
|
77
|
+
}, size: "small", value: props.exposureScore, step: 0.1, min: -100, max: 100, onChange: (_event, newValue) => props.onExposureChange(newValue) }), _jsxs(Stack, { direction: "row", justifyContent: "space-between", alignItems: "center", sx: { pt: '10px', pb: '0px' }, children: [_jsx(Typography, { sx: { ...typography.bodyMedium, color: colors.surface }, children: "Contrast" }), _jsx(TextField, { hiddenLabel: true, id: "filled-hidden-label-small", value: formatValue(props.contrastScore), variant: "filled", onChange: (e) => handleInputChange(e, -100, 100, props.onContrastChange), sx: {
|
|
77
78
|
width: "40px",
|
|
78
79
|
alignItems: "center",
|
|
79
80
|
textAlign: "right",
|
|
@@ -121,6 +122,7 @@ export default function HSliderLightMobile(props) {
|
|
|
121
122
|
},
|
|
122
123
|
'& .MuiSlider-thumb': {
|
|
123
124
|
background: colors.surface,
|
|
125
|
+
boxShadow: 'none',
|
|
124
126
|
opacity: 1,
|
|
125
127
|
},
|
|
126
128
|
'& .MuiSlider-thumb:hover': {
|
|
@@ -174,6 +176,7 @@ export default function HSliderLightMobile(props) {
|
|
|
174
176
|
},
|
|
175
177
|
'& .MuiSlider-thumb': {
|
|
176
178
|
background: colors.surface,
|
|
179
|
+
boxShadow: 'none',
|
|
177
180
|
opacity: 1,
|
|
178
181
|
},
|
|
179
182
|
'& .MuiSlider-thumb:hover': {
|
|
@@ -227,6 +230,7 @@ export default function HSliderLightMobile(props) {
|
|
|
227
230
|
},
|
|
228
231
|
'& .MuiSlider-thumb': {
|
|
229
232
|
background: colors.surface,
|
|
233
|
+
boxShadow: 'none',
|
|
230
234
|
opacity: 1,
|
|
231
235
|
},
|
|
232
236
|
'& .MuiSlider-thumb:hover': {
|
|
@@ -280,6 +284,7 @@ export default function HSliderLightMobile(props) {
|
|
|
280
284
|
},
|
|
281
285
|
'& .MuiSlider-thumb': {
|
|
282
286
|
background: colors.surface,
|
|
287
|
+
boxShadow: 'none',
|
|
283
288
|
opacity: 1,
|
|
284
289
|
},
|
|
285
290
|
'& .MuiSlider-thumb:hover': {
|
|
@@ -333,6 +338,7 @@ export default function HSliderLightMobile(props) {
|
|
|
333
338
|
},
|
|
334
339
|
'& .MuiSlider-thumb': {
|
|
335
340
|
background: colors.surface,
|
|
341
|
+
boxShadow: 'none',
|
|
336
342
|
opacity: 1,
|
|
337
343
|
},
|
|
338
344
|
'& .MuiSlider-thumb:hover': {
|
|
@@ -40,6 +40,8 @@ export declare function useHonchoEditor(controller: Controller, initImageId: str
|
|
|
40
40
|
canvasRef: import("react").MutableRefObject<HTMLCanvasElement | null>;
|
|
41
41
|
canvasContainerRef: import("react").MutableRefObject<HTMLDivElement | null>;
|
|
42
42
|
fileInputRef: import("react").MutableRefObject<HTMLInputElement | null>;
|
|
43
|
+
handleShowOriginal: () => void;
|
|
44
|
+
handleShowEdited: () => void;
|
|
43
45
|
editorStatus: string;
|
|
44
46
|
isEditorReady: boolean;
|
|
45
47
|
isImageLoaded: boolean;
|
|
@@ -10,9 +10,6 @@ const initialAdjustments = {
|
|
|
10
10
|
};
|
|
11
11
|
// const clamp = (value: number) => Math.max(-100, Math.min(100, value));
|
|
12
12
|
export function useHonchoEditor(controller, initImageId, firebaseUid) {
|
|
13
|
-
// const [currentImageId, setCurrentImageId] = useState<string>(initImageId);
|
|
14
|
-
// const [currentImageData, setCurrentImageData] = useState<Gallery | null>(null);
|
|
15
|
-
// const [currentAdjustmentsState, setCurrentAdjustmentsState] = useState<AdjustmentState>(initialAdjustments);
|
|
16
13
|
const { onSwipeNext, onSwipePrev, isNextAvailable, isPrevAvailable, isLoading: isGalleryLoading, error: galleryError, currentImageData: galleryImageData } = useGallerySwipe(firebaseUid, initImageId, controller);
|
|
17
14
|
// The useAdjustmentHistory hook now manages all undo/redo and adjustment state logic.
|
|
18
15
|
const { currentState: currentAdjustmentsState, actions: historyActions, historyInfo, config: historyConfig, } = useAdjustmentHistory(initialAdjustments);
|
|
@@ -117,126 +114,6 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
|
|
|
117
114
|
// }
|
|
118
115
|
// setSelectedImageIds(newSelectedIds);
|
|
119
116
|
// }, [selectedImageIds, tempScore, tintScore, vibranceScore, saturationScore, exposureScore, highlightsScore, shadowsScore, whitesScore, blacksScore, contrastScore, clarityScore, sharpnessScore]);
|
|
120
|
-
// const createAbsoluteSetter = (key: keyof AdjustmentState, setter: React.Dispatch<React.SetStateAction<number>>) => (value: number) => {
|
|
121
|
-
// setter(value); // Update UI slider
|
|
122
|
-
// if(isBulkEditing) {
|
|
123
|
-
// setAdjustmentsMap(prevMap => {
|
|
124
|
-
// const newMap = new Map(prevMap);
|
|
125
|
-
// selectedImageIds.forEach(id => {
|
|
126
|
-
// const currentState = newMap.get(id) || initialAdjustments;
|
|
127
|
-
// newMap.set(id, { ...currentState, [key]: value });
|
|
128
|
-
// });
|
|
129
|
-
// return newMap;
|
|
130
|
-
// });
|
|
131
|
-
// }
|
|
132
|
-
// };
|
|
133
|
-
// const createRelativeAdjuster = (key: keyof AdjustmentState, uiSetter: React.Dispatch<React.SetStateAction<number>>, amount: number) => () => {
|
|
134
|
-
// uiSetter(prev => clamp(prev + amount));
|
|
135
|
-
// if (isBulkEditing) {
|
|
136
|
-
// setAdjustmentsMap(prevMap => {
|
|
137
|
-
// const newMap = new Map(prevMap);
|
|
138
|
-
// selectedImageIds.forEach(id => {
|
|
139
|
-
// const currentState = newMap.get(id) || initialAdjustments;
|
|
140
|
-
// const currentValue = currentState[key];
|
|
141
|
-
// const newValue = clamp(currentValue + amount);
|
|
142
|
-
// newMap.set(id, { ...currentState, [key]: newValue });
|
|
143
|
-
// });
|
|
144
|
-
// console.log("this is UI Setter: ", uiSetter);
|
|
145
|
-
// return newMap;
|
|
146
|
-
// });
|
|
147
|
-
// }
|
|
148
|
-
// };
|
|
149
|
-
// const setTempScoreAbs = createAbsoluteSetter('tempScore', setTempScore);
|
|
150
|
-
// const setTintScoreAbs = createAbsoluteSetter('tintScore', setTintScore);
|
|
151
|
-
// const setVibranceScoreAbs = createAbsoluteSetter('vibranceScore', setVibranceScore);
|
|
152
|
-
// const setSaturationScoreAbs = createAbsoluteSetter('saturationScore', setSaturationScore);
|
|
153
|
-
// const setExposureScoreAbs = createAbsoluteSetter('exposureScore', setExposureScore);
|
|
154
|
-
// const setHighlightsScoreAbs = createAbsoluteSetter('highlightsScore', setHighlightsScore);
|
|
155
|
-
// const setShadowsScoreAbs = createAbsoluteSetter('shadowsScore', setShadowsScore);
|
|
156
|
-
// const setWhitesScoreAbs = createAbsoluteSetter('whitesScore', setWhitesScore);
|
|
157
|
-
// const setBlacksScoreAbs = createAbsoluteSetter('blacksScore', setBlacksScore);
|
|
158
|
-
// const setContrastScoreAbs = createAbsoluteSetter('contrastScore', setContrastScore);
|
|
159
|
-
// const setClarityScoreAbs = createAbsoluteSetter('clarityScore', setClarityScore);
|
|
160
|
-
// const setSharpnessScoreAbs = createAbsoluteSetter('sharpnessScore', setSharpnessScore);
|
|
161
|
-
// // MARK: - Bulk Editor Handlers
|
|
162
|
-
// const handleBulkTempDecreaseMax = createRelativeAdjuster('tempScore', setTempScore, -20);
|
|
163
|
-
// const handleBulkTempDecrease = createRelativeAdjuster('tempScore', setTempScore, -5);
|
|
164
|
-
// const handleBulkTempIncrease = createRelativeAdjuster('tempScore', setTempScore, 5);
|
|
165
|
-
// const handleBulkTempIncreaseMax = createRelativeAdjuster('tempScore', setTempScore, 20);
|
|
166
|
-
// const handleBulkTintDecreaseMax = createRelativeAdjuster('tintScore', setTintScore, -20);
|
|
167
|
-
// const handleBulkTintDecrease = createRelativeAdjuster('tintScore', setTintScore, -5);
|
|
168
|
-
// const handleBulkTintIncrease = createRelativeAdjuster('tintScore', setTintScore, 5);
|
|
169
|
-
// const handleBulkTintIncreaseMax = createRelativeAdjuster('tintScore', setTintScore, 20);
|
|
170
|
-
// const handleBulkVibranceDecreaseMax = createRelativeAdjuster('vibranceScore', setVibranceScore, -20);
|
|
171
|
-
// const handleBulkVibranceDecrease = createRelativeAdjuster('vibranceScore', setVibranceScore, -5);
|
|
172
|
-
// const handleBulkVibranceIncrease = createRelativeAdjuster('vibranceScore', setVibranceScore, 5);
|
|
173
|
-
// const handleBulkVibranceIncreaseMax = createRelativeAdjuster('vibranceScore', setVibranceScore, 20);
|
|
174
|
-
// const handleBulkSaturationDecreaseMax = createRelativeAdjuster('saturationScore', setSaturationScore, -20);
|
|
175
|
-
// const handleBulkSaturationDecrease = createRelativeAdjuster('saturationScore', setSaturationScore, -5);
|
|
176
|
-
// const handleBulkSaturationIncrease = createRelativeAdjuster('saturationScore', setSaturationScore, 5);
|
|
177
|
-
// const handleBulkSaturationIncreaseMax = createRelativeAdjuster('saturationScore', setSaturationScore, 20);
|
|
178
|
-
// const handleBulkExposureDecreaseMax = createRelativeAdjuster('exposureScore', setExposureScore, -20);
|
|
179
|
-
// const handleBulkExposureDecrease = createRelativeAdjuster('exposureScore', setExposureScore, -5);
|
|
180
|
-
// const handleBulkExposureIncrease = createRelativeAdjuster('exposureScore', setExposureScore, 5);
|
|
181
|
-
// const handleBulkExposureIncreaseMax = createRelativeAdjuster('exposureScore', setExposureScore, 20);
|
|
182
|
-
// const handleBulkContrastDecreaseMax = createRelativeAdjuster('contrastScore', setContrastScore, -20);
|
|
183
|
-
// const handleBulkContrastDecrease = createRelativeAdjuster('contrastScore', setContrastScore, -5);
|
|
184
|
-
// const handleBulkContrastIncrease = createRelativeAdjuster('contrastScore', setContrastScore, 5);
|
|
185
|
-
// const handleBulkContrastIncreaseMax = createRelativeAdjuster('contrastScore', setContrastScore, 20);
|
|
186
|
-
// const handleBulkHighlightsDecreaseMax = createRelativeAdjuster('highlightsScore', setHighlightsScore, -20);
|
|
187
|
-
// const handleBulkHighlightsDecrease = createRelativeAdjuster('highlightsScore', setHighlightsScore, -5);
|
|
188
|
-
// const handleBulkHighlightsIncrease = createRelativeAdjuster('highlightsScore', setHighlightsScore, 5);
|
|
189
|
-
// const handleBulkHighlightsIncreaseMax = createRelativeAdjuster('highlightsScore', setHighlightsScore, 20);
|
|
190
|
-
// const handleBulkShadowsDecreaseMax = createRelativeAdjuster('shadowsScore', setShadowsScore, -20);
|
|
191
|
-
// const handleBulkShadowsDecrease = createRelativeAdjuster('shadowsScore', setShadowsScore, -5);
|
|
192
|
-
// const handleBulkShadowsIncrease = createRelativeAdjuster('shadowsScore', setShadowsScore, 5);
|
|
193
|
-
// const handleBulkShadowsIncreaseMax = createRelativeAdjuster('shadowsScore', setShadowsScore, 20);
|
|
194
|
-
// const handleBulkWhitesDecreaseMax = createRelativeAdjuster('whitesScore', setWhitesScore, -20);
|
|
195
|
-
// const handleBulkWhitesDecrease = createRelativeAdjuster('whitesScore', setWhitesScore, -5);
|
|
196
|
-
// const handleBulkWhitesIncrease = createRelativeAdjuster('whitesScore', setWhitesScore, 5);
|
|
197
|
-
// const handleBulkWhitesIncreaseMax = createRelativeAdjuster('whitesScore', setWhitesScore, 20);
|
|
198
|
-
// const handleBulkBlacksDecreaseMax = createRelativeAdjuster('blacksScore', setBlacksScore, -20);
|
|
199
|
-
// const handleBulkBlacksDecrease = createRelativeAdjuster('blacksScore', setBlacksScore, -5);
|
|
200
|
-
// const handleBulkBlacksIncrease = createRelativeAdjuster('blacksScore', setBlacksScore, 5);
|
|
201
|
-
// const handleBulkBlacksIncreaseMax = createRelativeAdjuster('blacksScore', setBlacksScore, 20);
|
|
202
|
-
// const handleBulkClarityDecreaseMax = createRelativeAdjuster('clarityScore', setClarityScore, -20);
|
|
203
|
-
// const handleBulkClarityDecrease = createRelativeAdjuster('clarityScore', setClarityScore, -5);
|
|
204
|
-
// const handleBulkClarityIncrease = createRelativeAdjuster('clarityScore', setClarityScore, 5);
|
|
205
|
-
// const handleBulkClarityIncreaseMax = createRelativeAdjuster('clarityScore', setClarityScore, 20);
|
|
206
|
-
// const handleBulkSharpnessDecreaseMax = createRelativeAdjuster('sharpnessScore', setSharpnessScore, -20);
|
|
207
|
-
// const handleBulkSharpnessDecrease = createRelativeAdjuster('sharpnessScore', setSharpnessScore, -5);
|
|
208
|
-
// const handleBulkSharpnessIncrease = createRelativeAdjuster('sharpnessScore', setSharpnessScore, 5);
|
|
209
|
-
// const handleBulkSharpnessIncreaseMax = createRelativeAdjuster('sharpnessScore', setSharpnessScore, 20);
|
|
210
|
-
// // Bulk Editing Handlers
|
|
211
|
-
// const toggleBulkEditing = () => {
|
|
212
|
-
// setIsBulkEditing(prev => {
|
|
213
|
-
// const isNowBulk = !prev;
|
|
214
|
-
// setSelectedImages(isNowBulk ? 'Selected' : 'Select');
|
|
215
|
-
// return isNowBulk;
|
|
216
|
-
// });
|
|
217
|
-
// };
|
|
218
|
-
// const handleSelectBulkPreset = (event: SelectChangeEvent<string>) => setSelectedBulkPreset(event.target.value as string);
|
|
219
|
-
// MARK : Image original and canvas
|
|
220
|
-
// const handleShowOriginal = useCallback(() => {
|
|
221
|
-
// if (!editorRef.current || !isImageLoaded) return;
|
|
222
|
-
// console.log("Showing original image...");
|
|
223
|
-
// // 1. Set the flag to true to pause history recording
|
|
224
|
-
// setIsViewingOriginal(true);
|
|
225
|
-
// // 2. Apply the initial state to the view
|
|
226
|
-
// // applyAdjustmentState(initialAdjustments);
|
|
227
|
-
// }, [isImageLoaded]);
|
|
228
|
-
// const handleShowEdited = useCallback(() => {
|
|
229
|
-
// if (!editorRef.current || !isImageLoaded) return;
|
|
230
|
-
// console.log("Restoring edited image...");
|
|
231
|
-
// const latestState = history[historyIndex];
|
|
232
|
-
// if (latestState) {
|
|
233
|
-
// // 3. Re-apply the latest state from history
|
|
234
|
-
// // applyAdjustmentState(latestState);
|
|
235
|
-
// }
|
|
236
|
-
// // 4. Set the flag back to false AFTER the state has been restored.
|
|
237
|
-
// // A small timeout ensures this runs after the re-render.
|
|
238
|
-
// setTimeout(() => setIsViewingOriginal(false), 0);
|
|
239
|
-
// }, [isImageLoaded, history, historyIndex]);
|
|
240
117
|
// Mobile Panel Drag Handlers
|
|
241
118
|
const handleContentHeightChange = useCallback((height) => {
|
|
242
119
|
if (height > 0 && height !== contentHeight)
|
|
@@ -329,7 +206,6 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
|
|
|
329
206
|
editorRef.current = editor;
|
|
330
207
|
setIsEditorReady(true);
|
|
331
208
|
setEditorStatus("Ready! Select an image to start.");
|
|
332
|
-
console.log("[Editor] Initialization successful."); // Log entry
|
|
333
209
|
}
|
|
334
210
|
catch (error) {
|
|
335
211
|
console.error("[Editor] CRITICAL: Editor initialization failed:", error); // Critical error log
|
|
@@ -357,6 +233,21 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
|
|
|
357
233
|
const handlePresetAccordionChange = (panel) => (_, isExpanded) => {
|
|
358
234
|
setPresetExpandedPanels(prev => isExpanded ? [...new Set([...prev, panel])] : prev.filter(p => p !== panel));
|
|
359
235
|
};
|
|
236
|
+
const handleShowOriginal = useCallback(() => {
|
|
237
|
+
if (!editorRef.current || !isImageLoaded || !canvasRef.current)
|
|
238
|
+
return;
|
|
239
|
+
console.log("Showing original image...");
|
|
240
|
+
editorRef.current.setAdjustments(mapAdjustmentStateToAdjustmentEditor(initialAdjustments));
|
|
241
|
+
editorRef.current.processImage();
|
|
242
|
+
editorRef.current.renderToCanvas(canvasRef.current);
|
|
243
|
+
}, [isImageLoaded, editorRef, canvasRef]);
|
|
244
|
+
const handleShowEdited = useCallback(() => {
|
|
245
|
+
if (!editorRef.current || !isImageLoaded || !canvasRef.current)
|
|
246
|
+
return;
|
|
247
|
+
editorRef.current.setAdjustments(mapAdjustmentStateToAdjustmentEditor(currentAdjustmentsState));
|
|
248
|
+
editorRef.current.processImage();
|
|
249
|
+
editorRef.current.renderToCanvas(canvasRef.current);
|
|
250
|
+
}, [isImageLoaded, editorRef, canvasRef, currentAdjustmentsState]);
|
|
360
251
|
// MARK: - Preset Handlers
|
|
361
252
|
// Also it calls for the backend endpoint
|
|
362
253
|
const handleSelectMobilePreset = (presetId) => setSelectedMobilePreset(presetId);
|
|
@@ -714,6 +605,8 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
|
|
|
714
605
|
canvasRef,
|
|
715
606
|
canvasContainerRef,
|
|
716
607
|
fileInputRef,
|
|
608
|
+
handleShowOriginal,
|
|
609
|
+
handleShowEdited,
|
|
717
610
|
// Status & State
|
|
718
611
|
editorStatus,
|
|
719
612
|
isEditorReady,
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { SelectChangeEvent } from "@mui/material";
|
|
2
|
+
import { AdjustmentState, ImageItem } from './useHonchoEditor';
|
|
3
|
+
export declare function useHonchoEditorBulk(): {
|
|
4
|
+
isBulkEditing: boolean;
|
|
5
|
+
selectedImages: string;
|
|
6
|
+
imageList: ImageItem[];
|
|
7
|
+
selectedImageIds: Set<string>;
|
|
8
|
+
adjustmentsMap: Map<string, AdjustmentState>;
|
|
9
|
+
selectedBulkPreset: string;
|
|
10
|
+
handleFileChangeBulk: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
11
|
+
handleToggleImageSelection: (imageId: string) => void;
|
|
12
|
+
toggleBulkEditing: () => void;
|
|
13
|
+
handleSelectBulkPreset: (event: SelectChangeEvent<string>) => void;
|
|
14
|
+
setTempScore: (value: number) => void;
|
|
15
|
+
setTintScore: (value: number) => void;
|
|
16
|
+
setVibranceScore: (value: number) => void;
|
|
17
|
+
setSaturationScore: (value: number) => void;
|
|
18
|
+
setExposureScore: (value: number) => void;
|
|
19
|
+
setHighlightsScore: (value: number) => void;
|
|
20
|
+
setShadowsScore: (value: number) => void;
|
|
21
|
+
setWhitesScore: (value: number) => void;
|
|
22
|
+
setBlacksScore: (value: number) => void;
|
|
23
|
+
setContrastScore: (value: number) => void;
|
|
24
|
+
setClarityScore: (value: number) => void;
|
|
25
|
+
setSharpnessScore: (value: number) => void;
|
|
26
|
+
handleBulkTempDecreaseMax: () => void;
|
|
27
|
+
handleBulkTempDecrease: () => void;
|
|
28
|
+
handleBulkTempIncrease: () => void;
|
|
29
|
+
handleBulkTempIncreaseMax: () => void;
|
|
30
|
+
handleBulkTintDecreaseMax: () => void;
|
|
31
|
+
handleBulkTintDecrease: () => void;
|
|
32
|
+
handleBulkTintIncrease: () => void;
|
|
33
|
+
handleBulkTintIncreaseMax: () => void;
|
|
34
|
+
handleBulkVibranceDecreaseMax: () => void;
|
|
35
|
+
handleBulkVibranceDecrease: () => void;
|
|
36
|
+
handleBulkVibranceIncrease: () => void;
|
|
37
|
+
handleBulkVibranceIncreaseMax: () => void;
|
|
38
|
+
handleBulkSaturationDecreaseMax: () => void;
|
|
39
|
+
handleBulkSaturationDecrease: () => void;
|
|
40
|
+
handleBulkSaturationIncrease: () => void;
|
|
41
|
+
handleBulkSaturationIncreaseMax: () => void;
|
|
42
|
+
handleBulkExposureDecreaseMax: () => void;
|
|
43
|
+
handleBulkExposureDecrease: () => void;
|
|
44
|
+
handleBulkExposureIncrease: () => void;
|
|
45
|
+
handleBulkExposureIncreaseMax: () => void;
|
|
46
|
+
handleBulkContrastDecreaseMax: () => void;
|
|
47
|
+
handleBulkContrastDecrease: () => void;
|
|
48
|
+
handleBulkContrastIncrease: () => void;
|
|
49
|
+
handleBulkContrastIncreaseMax: () => void;
|
|
50
|
+
handleBulkHighlightsDecreaseMax: () => void;
|
|
51
|
+
handleBulkHighlightsDecrease: () => void;
|
|
52
|
+
handleBulkHighlightsIncrease: () => void;
|
|
53
|
+
handleBulkHighlightsIncreaseMax: () => void;
|
|
54
|
+
handleBulkShadowsDecreaseMax: () => void;
|
|
55
|
+
handleBulkShadowsDecrease: () => void;
|
|
56
|
+
handleBulkShadowsIncrease: () => void;
|
|
57
|
+
handleBulkShadowsIncreaseMax: () => void;
|
|
58
|
+
handleBulkWhitesDecreaseMax: () => void;
|
|
59
|
+
handleBulkWhitesDecrease: () => void;
|
|
60
|
+
handleBulkWhitesIncrease: () => void;
|
|
61
|
+
handleBulkWhitesIncreaseMax: () => void;
|
|
62
|
+
handleBulkBlacksDecreaseMax: () => void;
|
|
63
|
+
handleBulkBlacksDecrease: () => void;
|
|
64
|
+
handleBulkBlacksIncrease: () => void;
|
|
65
|
+
handleBulkBlacksIncreaseMax: () => void;
|
|
66
|
+
handleBulkClarityDecreaseMax: () => void;
|
|
67
|
+
handleBulkClarityDecrease: () => void;
|
|
68
|
+
handleBulkClarityIncrease: () => void;
|
|
69
|
+
handleBulkClarityIncreaseMax: () => void;
|
|
70
|
+
handleBulkSharpnessDecreaseMax: () => void;
|
|
71
|
+
handleBulkSharpnessDecrease: () => void;
|
|
72
|
+
handleBulkSharpnessIncrease: () => void;
|
|
73
|
+
handleBulkSharpnessIncreaseMax: () => void;
|
|
74
|
+
};
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
3
|
+
import { useAdjustmentHistory } from '../useAdjustmentHistory';
|
|
4
|
+
const initialAdjustments = {
|
|
5
|
+
tempScore: 0, tintScore: 0, vibranceScore: 0, exposureScore: 0, highlightsScore: 0, shadowsScore: 0,
|
|
6
|
+
whitesScore: 0, blacksScore: 0, saturationScore: 0, contrastScore: 0, clarityScore: 0, sharpnessScore: 0,
|
|
7
|
+
};
|
|
8
|
+
const clamp = (value) => Math.max(-100, Math.min(100, value));
|
|
9
|
+
export function useHonchoEditorBulk() {
|
|
10
|
+
const { currentState, actions: historyActions, historyInfo } = useAdjustmentHistory(initialAdjustments);
|
|
11
|
+
// State for Bulk Editing
|
|
12
|
+
const [isBulkEditing, setIsBulkEditing] = useState(false);
|
|
13
|
+
const [selectedImages, setSelectedImages] = useState('Select');
|
|
14
|
+
const [imageList, setImageList] = useState([]);
|
|
15
|
+
const [selectedImageIds, setSelectedImageIds] = useState(new Set());
|
|
16
|
+
const [adjustmentsMap, setAdjustmentsMap] = useState(new Map());
|
|
17
|
+
const [selectedBulkPreset, setSelectedBulkPreset] = useState('preset1');
|
|
18
|
+
const handleFileChangeBulk = (event) => {
|
|
19
|
+
const files = event.target?.files;
|
|
20
|
+
if (!files || files.length <= 1) {
|
|
21
|
+
// If it's not a bulk operation, we clear the state.
|
|
22
|
+
setIsBulkEditing(false);
|
|
23
|
+
setImageList([]);
|
|
24
|
+
setSelectedImageIds(new Set());
|
|
25
|
+
setAdjustmentsMap(new Map());
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
;
|
|
29
|
+
setIsBulkEditing(true);
|
|
30
|
+
const newImageList = Array.from(files).map((file, index) => ({
|
|
31
|
+
id: `${file.name}-${Date.now()}-${index}`,
|
|
32
|
+
name: file.name,
|
|
33
|
+
file: file,
|
|
34
|
+
url: URL.createObjectURL(file),
|
|
35
|
+
}));
|
|
36
|
+
const newAdjustmentsMap = new Map();
|
|
37
|
+
newImageList.forEach(image => {
|
|
38
|
+
newAdjustmentsMap.set(image.id, { ...initialAdjustments });
|
|
39
|
+
});
|
|
40
|
+
setAdjustmentsMap(newAdjustmentsMap);
|
|
41
|
+
setImageList(newImageList);
|
|
42
|
+
setSelectedImageIds(new Set(newImageList.map(img => img.id)));
|
|
43
|
+
};
|
|
44
|
+
const handleToggleImageSelection = useCallback((imageId) => {
|
|
45
|
+
const newSelectedIds = new Set(selectedImageIds);
|
|
46
|
+
if (newSelectedIds.has(imageId)) {
|
|
47
|
+
if (newSelectedIds.size > 1) { // Prevent deselecting the last image
|
|
48
|
+
newSelectedIds.delete(imageId);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
newSelectedIds.add(imageId);
|
|
53
|
+
}
|
|
54
|
+
setSelectedImageIds(newSelectedIds);
|
|
55
|
+
}, [selectedImageIds]);
|
|
56
|
+
const toggleBulkEditing = () => {
|
|
57
|
+
setIsBulkEditing(prev => {
|
|
58
|
+
const isNowBulk = !prev;
|
|
59
|
+
setSelectedImages(isNowBulk ? 'Selected' : 'Select');
|
|
60
|
+
return isNowBulk;
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
const handleSelectBulkPreset = (event) => setSelectedBulkPreset(event.target.value);
|
|
64
|
+
// This factory creates functions that adjust a value for all selected images
|
|
65
|
+
const createAbsoluteSetter = (key, setter) => (value) => {
|
|
66
|
+
setter(value); // Update UI slider
|
|
67
|
+
if (isBulkEditing) {
|
|
68
|
+
setAdjustmentsMap(prevMap => {
|
|
69
|
+
const newMap = new Map(prevMap);
|
|
70
|
+
selectedImageIds.forEach(id => {
|
|
71
|
+
const currentState = newMap.get(id) || initialAdjustments;
|
|
72
|
+
newMap.set(id, { ...currentState, [key]: value });
|
|
73
|
+
});
|
|
74
|
+
return newMap;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const updateAdjustments = useCallback((newValues) => {
|
|
79
|
+
const newState = { ...currentState, ...newValues };
|
|
80
|
+
historyActions.pushState(newState);
|
|
81
|
+
}, [currentState, historyActions]);
|
|
82
|
+
const createRelativeAdjuster = (key, amount) => () => {
|
|
83
|
+
const currentValue = currentState[key];
|
|
84
|
+
const newValue = clamp(currentValue + amount);
|
|
85
|
+
updateAdjustments({ [key]: newValue });
|
|
86
|
+
};
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (!isBulkEditing)
|
|
89
|
+
return;
|
|
90
|
+
setAdjustmentsMap(prevMap => {
|
|
91
|
+
const newMap = new Map(prevMap);
|
|
92
|
+
selectedImageIds.forEach(id => {
|
|
93
|
+
// Apply the new global state to each selected image
|
|
94
|
+
newMap.set(id, currentState);
|
|
95
|
+
});
|
|
96
|
+
return newMap;
|
|
97
|
+
});
|
|
98
|
+
}, [currentState, selectedImageIds, isBulkEditing]);
|
|
99
|
+
const setTempScore = (value) => updateAdjustments({ tempScore: value });
|
|
100
|
+
const setTintScore = (value) => updateAdjustments({ tintScore: value });
|
|
101
|
+
const setVibranceScore = (value) => updateAdjustments({ vibranceScore: value });
|
|
102
|
+
const setSaturationScore = (value) => updateAdjustments({ saturationScore: value });
|
|
103
|
+
const setExposureScore = (value) => updateAdjustments({ exposureScore: value });
|
|
104
|
+
const setHighlightsScore = (value) => updateAdjustments({ highlightsScore: value });
|
|
105
|
+
const setShadowsScore = (value) => updateAdjustments({ shadowsScore: value });
|
|
106
|
+
const setWhitesScore = (value) => updateAdjustments({ whitesScore: value });
|
|
107
|
+
const setBlacksScore = (value) => updateAdjustments({ blacksScore: value });
|
|
108
|
+
const setContrastScore = (value) => updateAdjustments({ contrastScore: value });
|
|
109
|
+
const setClarityScore = (value) => updateAdjustments({ clarityScore: value });
|
|
110
|
+
const setSharpnessScore = (value) => updateAdjustments({ sharpnessScore: value });
|
|
111
|
+
const handleBulkTempDecreaseMax = createRelativeAdjuster('tempScore', -20);
|
|
112
|
+
const handleBulkTempDecrease = createRelativeAdjuster('tempScore', -5);
|
|
113
|
+
const handleBulkTempIncrease = createRelativeAdjuster('tempScore', 5);
|
|
114
|
+
const handleBulkTempIncreaseMax = createRelativeAdjuster('tempScore', 20);
|
|
115
|
+
const handleBulkTintDecreaseMax = createRelativeAdjuster('tintScore', -20);
|
|
116
|
+
const handleBulkTintDecrease = createRelativeAdjuster('tintScore', -5);
|
|
117
|
+
const handleBulkTintIncrease = createRelativeAdjuster('tintScore', 5);
|
|
118
|
+
const handleBulkTintIncreaseMax = createRelativeAdjuster('tintScore', 20);
|
|
119
|
+
const handleBulkVibranceDecreaseMax = createRelativeAdjuster('vibranceScore', -20);
|
|
120
|
+
const handleBulkVibranceDecrease = createRelativeAdjuster('vibranceScore', -5);
|
|
121
|
+
const handleBulkVibranceIncrease = createRelativeAdjuster('vibranceScore', 5);
|
|
122
|
+
const handleBulkVibranceIncreaseMax = createRelativeAdjuster('vibranceScore', 20);
|
|
123
|
+
const handleBulkSaturationDecreaseMax = createRelativeAdjuster('saturationScore', -20);
|
|
124
|
+
const handleBulkSaturationDecrease = createRelativeAdjuster('saturationScore', -5);
|
|
125
|
+
const handleBulkSaturationIncrease = createRelativeAdjuster('saturationScore', 5);
|
|
126
|
+
const handleBulkSaturationIncreaseMax = createRelativeAdjuster('saturationScore', 20);
|
|
127
|
+
const handleBulkExposureDecreaseMax = createRelativeAdjuster('exposureScore', -20);
|
|
128
|
+
const handleBulkExposureDecrease = createRelativeAdjuster('exposureScore', -5);
|
|
129
|
+
const handleBulkExposureIncrease = createRelativeAdjuster('exposureScore', 5);
|
|
130
|
+
const handleBulkExposureIncreaseMax = createRelativeAdjuster('exposureScore', 20);
|
|
131
|
+
const handleBulkContrastDecreaseMax = createRelativeAdjuster('contrastScore', -20);
|
|
132
|
+
const handleBulkContrastDecrease = createRelativeAdjuster('contrastScore', -5);
|
|
133
|
+
const handleBulkContrastIncrease = createRelativeAdjuster('contrastScore', 5);
|
|
134
|
+
const handleBulkContrastIncreaseMax = createRelativeAdjuster('contrastScore', 20);
|
|
135
|
+
const handleBulkHighlightsDecreaseMax = createRelativeAdjuster('highlightsScore', -20);
|
|
136
|
+
const handleBulkHighlightsDecrease = createRelativeAdjuster('highlightsScore', -5);
|
|
137
|
+
const handleBulkHighlightsIncrease = createRelativeAdjuster('highlightsScore', 5);
|
|
138
|
+
const handleBulkHighlightsIncreaseMax = createRelativeAdjuster('highlightsScore', 20);
|
|
139
|
+
const handleBulkShadowsDecreaseMax = createRelativeAdjuster('shadowsScore', -20);
|
|
140
|
+
const handleBulkShadowsDecrease = createRelativeAdjuster('shadowsScore', -5);
|
|
141
|
+
const handleBulkShadowsIncrease = createRelativeAdjuster('shadowsScore', 5);
|
|
142
|
+
const handleBulkShadowsIncreaseMax = createRelativeAdjuster('shadowsScore', 20);
|
|
143
|
+
const handleBulkWhitesDecreaseMax = createRelativeAdjuster('whitesScore', -20);
|
|
144
|
+
const handleBulkWhitesDecrease = createRelativeAdjuster('whitesScore', -5);
|
|
145
|
+
const handleBulkWhitesIncrease = createRelativeAdjuster('whitesScore', 5);
|
|
146
|
+
const handleBulkWhitesIncreaseMax = createRelativeAdjuster('whitesScore', 20);
|
|
147
|
+
const handleBulkBlacksDecreaseMax = createRelativeAdjuster('blacksScore', -20);
|
|
148
|
+
const handleBulkBlacksDecrease = createRelativeAdjuster('blacksScore', -5);
|
|
149
|
+
const handleBulkBlacksIncrease = createRelativeAdjuster('blacksScore', 5);
|
|
150
|
+
const handleBulkBlacksIncreaseMax = createRelativeAdjuster('blacksScore', 20);
|
|
151
|
+
const handleBulkClarityDecreaseMax = createRelativeAdjuster('clarityScore', -20);
|
|
152
|
+
const handleBulkClarityDecrease = createRelativeAdjuster('clarityScore', -5);
|
|
153
|
+
const handleBulkClarityIncrease = createRelativeAdjuster('clarityScore', 5);
|
|
154
|
+
const handleBulkClarityIncreaseMax = createRelativeAdjuster('clarityScore', 20);
|
|
155
|
+
const handleBulkSharpnessDecreaseMax = createRelativeAdjuster('sharpnessScore', -20);
|
|
156
|
+
const handleBulkSharpnessDecrease = createRelativeAdjuster('sharpnessScore', -5);
|
|
157
|
+
const handleBulkSharpnessIncrease = createRelativeAdjuster('sharpnessScore', 5);
|
|
158
|
+
const handleBulkSharpnessIncreaseMax = createRelativeAdjuster('sharpnessScore', 20);
|
|
159
|
+
return {
|
|
160
|
+
isBulkEditing,
|
|
161
|
+
selectedImages,
|
|
162
|
+
imageList,
|
|
163
|
+
selectedImageIds,
|
|
164
|
+
adjustmentsMap,
|
|
165
|
+
selectedBulkPreset,
|
|
166
|
+
handleFileChangeBulk,
|
|
167
|
+
handleToggleImageSelection,
|
|
168
|
+
toggleBulkEditing,
|
|
169
|
+
handleSelectBulkPreset,
|
|
170
|
+
// Bulk Adjustment Handlers
|
|
171
|
+
setTempScore,
|
|
172
|
+
setTintScore,
|
|
173
|
+
setVibranceScore,
|
|
174
|
+
setSaturationScore,
|
|
175
|
+
setExposureScore,
|
|
176
|
+
setHighlightsScore,
|
|
177
|
+
setShadowsScore,
|
|
178
|
+
setWhitesScore,
|
|
179
|
+
setBlacksScore,
|
|
180
|
+
setContrastScore,
|
|
181
|
+
setClarityScore,
|
|
182
|
+
setSharpnessScore,
|
|
183
|
+
// Adjustment
|
|
184
|
+
handleBulkTempDecreaseMax,
|
|
185
|
+
handleBulkTempDecrease,
|
|
186
|
+
handleBulkTempIncrease,
|
|
187
|
+
handleBulkTempIncreaseMax,
|
|
188
|
+
handleBulkTintDecreaseMax,
|
|
189
|
+
handleBulkTintDecrease,
|
|
190
|
+
handleBulkTintIncrease,
|
|
191
|
+
handleBulkTintIncreaseMax,
|
|
192
|
+
handleBulkVibranceDecreaseMax,
|
|
193
|
+
handleBulkVibranceDecrease,
|
|
194
|
+
handleBulkVibranceIncrease,
|
|
195
|
+
handleBulkVibranceIncreaseMax,
|
|
196
|
+
handleBulkSaturationDecreaseMax,
|
|
197
|
+
handleBulkSaturationDecrease,
|
|
198
|
+
handleBulkSaturationIncrease,
|
|
199
|
+
handleBulkSaturationIncreaseMax,
|
|
200
|
+
// Adjustment Light
|
|
201
|
+
handleBulkExposureDecreaseMax,
|
|
202
|
+
handleBulkExposureDecrease,
|
|
203
|
+
handleBulkExposureIncrease,
|
|
204
|
+
handleBulkExposureIncreaseMax,
|
|
205
|
+
handleBulkContrastDecreaseMax,
|
|
206
|
+
handleBulkContrastDecrease,
|
|
207
|
+
handleBulkContrastIncrease,
|
|
208
|
+
handleBulkContrastIncreaseMax,
|
|
209
|
+
handleBulkHighlightsDecreaseMax,
|
|
210
|
+
handleBulkHighlightsDecrease,
|
|
211
|
+
handleBulkHighlightsIncrease,
|
|
212
|
+
handleBulkHighlightsIncreaseMax,
|
|
213
|
+
handleBulkShadowsDecreaseMax,
|
|
214
|
+
handleBulkShadowsDecrease,
|
|
215
|
+
handleBulkShadowsIncrease,
|
|
216
|
+
handleBulkShadowsIncreaseMax,
|
|
217
|
+
handleBulkWhitesDecreaseMax,
|
|
218
|
+
handleBulkWhitesDecrease,
|
|
219
|
+
handleBulkWhitesIncrease,
|
|
220
|
+
handleBulkWhitesIncreaseMax,
|
|
221
|
+
handleBulkBlacksDecreaseMax,
|
|
222
|
+
handleBulkBlacksDecrease,
|
|
223
|
+
handleBulkBlacksIncrease,
|
|
224
|
+
handleBulkBlacksIncreaseMax,
|
|
225
|
+
// Adjustment Details
|
|
226
|
+
handleBulkClarityDecreaseMax,
|
|
227
|
+
handleBulkClarityDecrease,
|
|
228
|
+
handleBulkClarityIncrease,
|
|
229
|
+
handleBulkClarityIncreaseMax,
|
|
230
|
+
handleBulkSharpnessDecreaseMax,
|
|
231
|
+
handleBulkSharpnessDecrease,
|
|
232
|
+
handleBulkSharpnessIncrease,
|
|
233
|
+
handleBulkSharpnessIncreaseMax,
|
|
234
|
+
};
|
|
235
|
+
}
|