@yogiswara/honcho-editor-ui 1.4.23 → 1.4.25
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.
|
@@ -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;
|
|
@@ -91,17 +91,6 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
|
|
|
91
91
|
const initialHeight = useRef(0);
|
|
92
92
|
const panelRef = useRef(null);
|
|
93
93
|
const contentRef = useRef(null);
|
|
94
|
-
// Effect for measuring mobile panel content
|
|
95
|
-
// useEffect(() => {
|
|
96
|
-
// const timeoutId = setTimeout(() => {
|
|
97
|
-
// if (contentRef.current) {
|
|
98
|
-
// const height = contentRef.current.scrollHeight;
|
|
99
|
-
// setContentHeight(height);
|
|
100
|
-
// }
|
|
101
|
-
// }, 50);
|
|
102
|
-
// return () => clearTimeout(timeoutId);
|
|
103
|
-
// }, [activeSubPanel ]);
|
|
104
|
-
// isBulkEditing
|
|
105
94
|
// Effect for keyboard shortcuts
|
|
106
95
|
// MARK: - Core Editor Logic
|
|
107
96
|
// MARK: Batch Edit logic
|
|
@@ -227,27 +216,6 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
|
|
|
227
216
|
// });
|
|
228
217
|
// };
|
|
229
218
|
// const handleSelectBulkPreset = (event: SelectChangeEvent<string>) => setSelectedBulkPreset(event.target.value as string);
|
|
230
|
-
// MARK : Image original and canvas
|
|
231
|
-
// const handleShowOriginal = useCallback(() => {
|
|
232
|
-
// if (!editorRef.current || !isImageLoaded) return;
|
|
233
|
-
// console.log("Showing original image...");
|
|
234
|
-
// // 1. Set the flag to true to pause history recording
|
|
235
|
-
// setIsViewingOriginal(true);
|
|
236
|
-
// // 2. Apply the initial state to the view
|
|
237
|
-
// // applyAdjustmentState(initialAdjustments);
|
|
238
|
-
// }, [isImageLoaded]);
|
|
239
|
-
// const handleShowEdited = useCallback(() => {
|
|
240
|
-
// if (!editorRef.current || !isImageLoaded) return;
|
|
241
|
-
// console.log("Restoring edited image...");
|
|
242
|
-
// const latestState = history[historyIndex];
|
|
243
|
-
// if (latestState) {
|
|
244
|
-
// // 3. Re-apply the latest state from history
|
|
245
|
-
// // applyAdjustmentState(latestState);
|
|
246
|
-
// }
|
|
247
|
-
// // 4. Set the flag back to false AFTER the state has been restored.
|
|
248
|
-
// // A small timeout ensures this runs after the re-render.
|
|
249
|
-
// setTimeout(() => setIsViewingOriginal(false), 0);
|
|
250
|
-
// }, [isImageLoaded, history, historyIndex]);
|
|
251
219
|
// Mobile Panel Drag Handlers
|
|
252
220
|
const handleContentHeightChange = useCallback((height) => {
|
|
253
221
|
if (height > 0 && height !== contentHeight)
|
|
@@ -368,6 +336,21 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
|
|
|
368
336
|
const handlePresetAccordionChange = (panel) => (_, isExpanded) => {
|
|
369
337
|
setPresetExpandedPanels(prev => isExpanded ? [...new Set([...prev, panel])] : prev.filter(p => p !== panel));
|
|
370
338
|
};
|
|
339
|
+
const handleShowOriginal = useCallback(() => {
|
|
340
|
+
if (!editorRef.current || !isImageLoaded || !canvasRef.current)
|
|
341
|
+
return;
|
|
342
|
+
console.log("Showing original image...");
|
|
343
|
+
editorRef.current.setAdjustments(mapAdjustmentStateToAdjustmentEditor(initialAdjustments));
|
|
344
|
+
editorRef.current.processImage();
|
|
345
|
+
editorRef.current.renderToCanvas(canvasRef.current);
|
|
346
|
+
}, [isImageLoaded, editorRef, canvasRef]);
|
|
347
|
+
const handleShowEdited = useCallback(() => {
|
|
348
|
+
if (!editorRef.current || !isImageLoaded || !canvasRef.current)
|
|
349
|
+
return;
|
|
350
|
+
editorRef.current.setAdjustments(mapAdjustmentStateToAdjustmentEditor(currentAdjustmentsState));
|
|
351
|
+
editorRef.current.processImage();
|
|
352
|
+
editorRef.current.renderToCanvas(canvasRef.current);
|
|
353
|
+
}, [isImageLoaded, editorRef, canvasRef, currentAdjustmentsState]);
|
|
371
354
|
// MARK: - Preset Handlers
|
|
372
355
|
// Also it calls for the backend endpoint
|
|
373
356
|
const handleSelectMobilePreset = (presetId) => setSelectedMobilePreset(presetId);
|
|
@@ -602,6 +585,15 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
|
|
|
602
585
|
const handleCloseCopyDialog = () => setCopyDialogOpen(false);
|
|
603
586
|
const handleConfirmCopy = () => { handleCopyEdit(); handleCloseCopyDialog(); setShowCopyAlert(true); };
|
|
604
587
|
// MARK: useEffect HERE!
|
|
588
|
+
useEffect(() => {
|
|
589
|
+
const timeoutId = setTimeout(() => {
|
|
590
|
+
if (contentRef.current) {
|
|
591
|
+
const height = contentRef.current.scrollHeight;
|
|
592
|
+
setContentHeight(height);
|
|
593
|
+
}
|
|
594
|
+
}, 50);
|
|
595
|
+
return () => clearTimeout(timeoutId);
|
|
596
|
+
}, [activePanel, activeSubPanel]);
|
|
605
597
|
useEffect(() => {
|
|
606
598
|
if (showCopyAlert) {
|
|
607
599
|
const timer = setTimeout(() => setShowCopyAlert(false), 2000);
|
|
@@ -716,6 +708,8 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
|
|
|
716
708
|
canvasRef,
|
|
717
709
|
canvasContainerRef,
|
|
718
710
|
fileInputRef,
|
|
711
|
+
handleShowOriginal,
|
|
712
|
+
handleShowEdited,
|
|
719
713
|
// Status & State
|
|
720
714
|
editorStatus,
|
|
721
715
|
isEditorReady,
|