@yogiswara/honcho-editor-ui 1.0.13 → 1.0.14

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.
@@ -39,19 +39,13 @@ export type ImageItem = {
39
39
  file: File;
40
40
  };
41
41
  export declare function useHonchoEditor(controller: Controller, initImageId: string, firebaseUid: string): {
42
- handlePrev: (firebaseUid: string) => Promise<void>;
43
- handleNext: (firebaseUid: string) => Promise<void>;
44
42
  canvasRef: import("react").MutableRefObject<HTMLCanvasElement | null>;
45
43
  canvasContainerRef: import("react").MutableRefObject<HTMLDivElement | null>;
46
44
  fileInputRef: import("react").MutableRefObject<HTMLInputElement | null>;
47
45
  displayedToken: string | null;
48
- handleBack: (firebaseUid: string) => void;
49
- onGetImage: (firebaseUid: string, imageID: string) => Promise<Gallery>;
50
- getImageList: (firebaseUid: string) => Promise<Gallery[]>;
51
- syncConfig: (firebaseUid: string) => Promise<void>;
52
- getPresets: (firebaseUid: string) => Promise<Preset[]>;
53
- createPreset: (firebaseUid: string, name: string, settings: AdjustmentState) => Promise<Preset>;
54
- deletePreset: (firebaseUid: string, presetId: string) => Promise<void>;
46
+ handleBackCallback: () => void;
47
+ handlePrev: (firebaseUid: string) => Promise<void>;
48
+ handleNext: (firebaseUid: string) => Promise<void>;
55
49
  panelRef: import("react").MutableRefObject<HTMLDivElement | null>;
56
50
  contentRef: import("react").MutableRefObject<HTMLDivElement | null>;
57
51
  panelHeight: number;
@@ -157,6 +157,11 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
157
157
  handleOpenCopyDialog(); // Assumes handleOpenCopyDialog is defined in the hook
158
158
  }
159
159
  }, [ /* handleOpenCopyDialog dependency */]);
160
+ useEffect(() => {
161
+ if (editorRef.current?.getInitialized() === false) {
162
+ editorRef.current?.initialize();
163
+ }
164
+ }, [editorRef]);
160
165
  // Effect for measuring mobile panel content
161
166
  useEffect(() => {
162
167
  const timeoutId = setTimeout(() => {
@@ -227,6 +232,7 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
227
232
  try {
228
233
  await editorRef.current.loadImageFromFile(file);
229
234
  setIsImageLoaded(true);
235
+ updateCanvas();
230
236
  }
231
237
  catch (e) {
232
238
  console.error("Error loading image:", e);
@@ -293,8 +299,9 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
293
299
  }
294
300
  }, [imageList]);
295
301
  useEffect(() => {
296
- loadImageFromId(firebaseUid, currentImageId); // initImageId became state
297
- // so when next prev changes only setCurrentImageId
302
+ if (currentImageId && firebaseUid) {
303
+ loadImageFromId(firebaseUid, currentImageId);
304
+ }
298
305
  }, [currentImageId, firebaseUid, loadImageFromId]);
299
306
  const handleFileChange = (event) => {
300
307
  const files = event.target?.files;
@@ -369,91 +376,6 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
369
376
  setHistoryIndex(nextIndex);
370
377
  }
371
378
  }, [history, historyIndex, applyAdjustmentState]);
372
- // MARK: - Bulk Editor Functions For Desktop and Mobile
373
- // const adjustTempBulk = useCallback((uiAmount: number) => {
374
- // setTempScore(prevScore => {
375
- // const newScore = clamp(prevScore + uiAmount);
376
- // console.log("Adjusting temperature. New score:", newScore);
377
- // return newScore;
378
- // });
379
- // }, []);
380
- // const adjustTintBulk = useCallback((uiAmount: number) => {
381
- // setTintScore(prevScore => {
382
- // const newScore = clamp(prevScore + uiAmount);
383
- // console.log("Adjusting tint. New score:", newScore);
384
- // return newScore;
385
- // });
386
- // }, []);
387
- // const adjustVibranceBulk = useCallback((uiAmount: number) => {
388
- // setVibranceScore(prevScore => {
389
- // const newScore = clamp(prevScore + uiAmount);
390
- // console.log("Adjusting vibrance. New score:", newScore);
391
- // return newScore;
392
- // });
393
- // }, []);
394
- // const adjustSaturationBulk = useCallback((uiAmount: number) => {
395
- // setSaturationScore(prevScore => {
396
- // const newScore = clamp(prevScore + uiAmount);
397
- // console.log("Adjusting saturation. New score:", newScore);
398
- // return newScore;
399
- // });
400
- // }, []);
401
- // const adjustExposureBulk = useCallback((uiAmount: number) => {
402
- // setExposureScore(prevScore => {
403
- // const newScore = clamp(prevScore + uiAmount);
404
- // console.log("Adjusting exposure. New score:", newScore);
405
- // return newScore;
406
- // });
407
- // }, []);
408
- // const adjustContrastBulk = useCallback((uiAmount: number) => {
409
- // setContrastScore(prevScore => {
410
- // const newScore = clamp(prevScore + uiAmount);
411
- // console.log("Adjusting contrast. New score:", newScore);
412
- // return newScore;
413
- // });
414
- // }, []);
415
- // const adjustHighlightsBulk = useCallback((uiAmount: number) => {
416
- // setHighlightsScore(prevScore => {
417
- // const newScore = clamp(prevScore + uiAmount);
418
- // console.log("Adjusting highlights. New score:", newScore);
419
- // return newScore;
420
- // });
421
- // }, []);
422
- // const adjustShadowsBulk = useCallback((uiAmount: number) => {
423
- // setShadowsScore(prevScore => {
424
- // const newScore = clamp(prevScore + uiAmount);
425
- // console.log("Adjusting shadows. New score:", newScore);
426
- // return newScore;
427
- // });
428
- // }, []);
429
- // const adjustWhitesBulk = useCallback((uiAmount: number) => {
430
- // setWhitesScore(prevScore => {
431
- // const newScore = clamp(prevScore + uiAmount);
432
- // console.log("Adjusting whites. New score:", newScore);
433
- // return newScore;
434
- // });
435
- // }, []);
436
- // const adjustBlacksBulk = useCallback((uiAmount: number) => {
437
- // setBlacksScore(prevScore => {
438
- // const newScore = clamp(prevScore + uiAmount);
439
- // console.log("Adjusting blacks. New score:", newScore);
440
- // return newScore;
441
- // });
442
- // }, []);
443
- // const adjustClarityBulk = useCallback((uiAmount: number) => {
444
- // setClarityScore(prevScore => {
445
- // const newScore = clamp(prevScore + uiAmount);
446
- // console.log("Adjusting clarity. New score:", newScore);
447
- // return newScore;
448
- // });
449
- // }, []);
450
- // const adjustSharpnessBulk = useCallback((uiAmount: number) => {
451
- // setSharpnessScore(prevScore => {
452
- // const newScore = clamp(prevScore + uiAmount);
453
- // console.log("Adjusting sharpness. New score:", newScore);
454
- // return newScore;
455
- // });
456
- // }, []);
457
379
  const handleToggleImageSelection = useCallback((imageId) => {
458
380
  const newSelectedIds = new Set(selectedImageIds);
459
381
  const isCurrentlySelected = newSelectedIds.has(imageId);
@@ -593,6 +515,9 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
593
515
  });
594
516
  }
595
517
  }, []);
518
+ const handleBackCallback = useCallback(() => {
519
+ controller.handleBack(firebaseUid);
520
+ }, [controller]);
596
521
  // MARK: - UI Handlers (Moved from page.tsx)
597
522
  // Header and Dialog Handlers
598
523
  const handleHeaderMenuClick = (event) => setHeaderMenuAnchorEl(event.currentTarget);
@@ -973,20 +898,14 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
973
898
  };
974
899
  }, []);
975
900
  return {
976
- handlePrev,
977
- handleNext,
978
901
  // Refs
979
902
  canvasRef,
980
903
  canvasContainerRef,
981
904
  fileInputRef,
982
905
  displayedToken,
983
- handleBack: controller.handleBack,
984
- onGetImage: controller.onGetImage,
985
- getImageList: controller.getImageList,
986
- syncConfig: controller.syncConfig,
987
- getPresets: controller.getPresets,
988
- createPreset: controller.createPreset,
989
- deletePreset: controller.deletePreset,
906
+ handleBackCallback,
907
+ handlePrev,
908
+ handleNext,
990
909
  // Refs for mobile panel
991
910
  panelRef,
992
911
  contentRef,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "1.0.13",
3
+ "version": "1.0.14",
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",