@yogiswara/honcho-editor-ui 1.4.24 → 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;
@@ -216,27 +216,6 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
216
216
  // });
217
217
  // };
218
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
219
  // Mobile Panel Drag Handlers
241
220
  const handleContentHeightChange = useCallback((height) => {
242
221
  if (height > 0 && height !== contentHeight)
@@ -357,6 +336,21 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
357
336
  const handlePresetAccordionChange = (panel) => (_, isExpanded) => {
358
337
  setPresetExpandedPanels(prev => isExpanded ? [...new Set([...prev, panel])] : prev.filter(p => p !== panel));
359
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]);
360
354
  // MARK: - Preset Handlers
361
355
  // Also it calls for the backend endpoint
362
356
  const handleSelectMobilePreset = (presetId) => setSelectedMobilePreset(presetId);
@@ -714,6 +708,8 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
714
708
  canvasRef,
715
709
  canvasContainerRef,
716
710
  fileInputRef,
711
+ handleShowOriginal,
712
+ handleShowEdited,
717
713
  // Status & State
718
714
  editorStatus,
719
715
  isEditorReady,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "1.4.24",
3
+ "version": "1.4.25",
4
4
  "description": "A complete UI component library for the Honcho photo editor.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",