@yogiswara/honcho-editor-ui 1.4.7 → 1.4.9

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.
@@ -218,6 +218,36 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
218
218
  // const handleBulkSharpnessDecrease = createRelativeAdjuster('sharpnessScore', setSharpnessScore, -5);
219
219
  // const handleBulkSharpnessIncrease = createRelativeAdjuster('sharpnessScore', setSharpnessScore, 5);
220
220
  // const handleBulkSharpnessIncreaseMax = createRelativeAdjuster('sharpnessScore', setSharpnessScore, 20);
221
+ // // Bulk Editing Handlers
222
+ // const toggleBulkEditing = () => {
223
+ // setIsBulkEditing(prev => {
224
+ // const isNowBulk = !prev;
225
+ // setSelectedImages(isNowBulk ? 'Selected' : 'Select');
226
+ // return isNowBulk;
227
+ // });
228
+ // };
229
+ // 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]);
221
251
  // Mobile Panel Drag Handlers
222
252
  const handleContentHeightChange = useCallback((height) => {
223
253
  if (height > 0 && height !== contentHeight)
@@ -281,7 +311,7 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
281
311
  const imagePath = data?.raw_edited?.path
282
312
  ? data.raw_edited.path
283
313
  : data?.download?.path;
284
- console.log("[DEBUG] Extracted imagePath to load:", imagePath);
314
+ console.log("[DEBUG FOR EXTRACT] Extracted imagePath to load:", imagePath);
285
315
  return imagePath;
286
316
  }, []);
287
317
  const loadImageEditorFromUrl = useCallback(async (url) => {
@@ -289,13 +319,13 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
289
319
  if (!editorRef.current)
290
320
  return;
291
321
  setEditorStatus("Downloading image...");
292
- console.log(`[DEBUG] Attempting to fetch image from URL: ${url}`);
293
322
  const response = await fetch(url);
294
323
  if (!response.ok)
295
324
  throw new Error(`Failed to fetch image from URL: ${url}`);
296
325
  const blob = await response.blob();
297
326
  const filename = url.substring(url.lastIndexOf('/') + 1) || 'image.jpg';
298
327
  const file = new File([blob], filename, { type: blob.type });
328
+ console.log("[DEBUG FOR LOAD] File to load:", file);
299
329
  await editorRef.current.loadImageFromFile(file);
300
330
  setIsImageLoaded(true);
301
331
  }
@@ -423,36 +453,6 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
423
453
  setPresetToRename(null);
424
454
  setNewPresetName("");
425
455
  };
426
- // // Bulk Editing Handlers
427
- // const toggleBulkEditing = () => {
428
- // setIsBulkEditing(prev => {
429
- // const isNowBulk = !prev;
430
- // setSelectedImages(isNowBulk ? 'Selected' : 'Select');
431
- // return isNowBulk;
432
- // });
433
- // };
434
- // const handleSelectBulkPreset = (event: SelectChangeEvent<string>) => setSelectedBulkPreset(event.target.value as string);
435
- // MARK : Image original and canvas
436
- // const handleShowOriginal = useCallback(() => {
437
- // if (!editorRef.current || !isImageLoaded) return;
438
- // console.log("Showing original image...");
439
- // // 1. Set the flag to true to pause history recording
440
- // setIsViewingOriginal(true);
441
- // // 2. Apply the initial state to the view
442
- // // applyAdjustmentState(initialAdjustments);
443
- // }, [isImageLoaded]);
444
- // const handleShowEdited = useCallback(() => {
445
- // if (!editorRef.current || !isImageLoaded) return;
446
- // console.log("Restoring edited image...");
447
- // const latestState = history[historyIndex];
448
- // if (latestState) {
449
- // // 3. Re-apply the latest state from history
450
- // // applyAdjustmentState(latestState);
451
- // }
452
- // // 4. Set the flag back to false AFTER the state has been restored.
453
- // // A small timeout ensures this runs after the re-render.
454
- // setTimeout(() => setIsViewingOriginal(false), 0);
455
- // }, [isImageLoaded, history, historyIndex]);
456
456
  // MARK: DEBUG (NEW LOGIC)
457
457
  // MARK: - Zoom Handlers
458
458
  const handleZoomAction = useCallback((action) => {
@@ -634,23 +634,32 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
634
634
  // will trigger when currentImageId change
635
635
  if (!galleryImageData)
636
636
  return;
637
+ console.log("++ USEEFFECT FOR NEXT AND PREV");
637
638
  const init = async () => {
639
+ console.log("1. INIT EDITOR");
638
640
  if (editorRef.current?.getInitialized() === false) {
639
641
  await editorRef.current?.initialize();
640
642
  }
641
643
  const adjustmentData = galleryImageData.editor_config?.color_adjustment;
644
+ console.log("2. ADJUSTMENTDATA: ", adjustmentData);
642
645
  // set event
643
646
  setEventId(galleryImageData.event_id);
647
+ console.log("3. EVENTID: ", eventId);
644
648
  // TODO get slideshow image list
645
649
  // set to imageList
646
650
  const pathGallery = extractPathFromGallery(galleryImageData);
647
651
  // load image to editor
652
+ console.log("4. PATHGALLERY: ", pathGallery);
648
653
  await loadImageEditorFromUrl(pathGallery);
649
- console.log("Image loaded to editor");
654
+ console.log("5. LOAD IMAGE TO EDITOR");
655
+ updateCanvasEditor();
656
+ console.log("6. UPDATE CANVAS EDITOR");
650
657
  // adjustment setup
651
658
  if (adjustmentData) {
659
+ console.log("7. ADJUSTMENTDATA FOUND");
652
660
  const adjustmentState = mapColorAdjustmentToAdjustmentState(adjustmentData);
653
661
  // set adjustment to editor to make adjustmentState change
662
+ console.log("8. SYNC HISTORY");
654
663
  historyActions.syncHistory([adjustmentState]);
655
664
  }
656
665
  else {
@@ -658,7 +667,7 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
658
667
  }
659
668
  };
660
669
  init();
661
- }, [galleryImageData, editorRef.current]);
670
+ }, [galleryImageData, editorRef.current, updateCanvasEditor]);
662
671
  useEffect(() => {
663
672
  // Render photo if adjustmentState change;
664
673
  if (!editorRef.current || !isImageLoaded)
@@ -690,14 +699,12 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
690
699
  useEffect(() => {
691
700
  // Cast navigator to our custom type to access the connection property safely
692
701
  const navigatorWithConnection = navigator;
693
- if (!navigatorWithConnection.connection) {
702
+ if (!navigatorWithConnection.connection)
694
703
  return;
695
- }
696
704
  const navigatorConnection = navigatorWithConnection.connection;
697
705
  const updateConnectionStatus = () => {
698
706
  const slowConnectionTypes = ['slow-2g', '2g', '3g'];
699
- const isSlow = navigatorConnection.saveData ||
700
- slowConnectionTypes.includes(navigatorConnection.effectiveType);
707
+ const isSlow = navigatorConnection.saveData || slowConnectionTypes.includes(navigatorConnection.effectiveType);
701
708
  setIsConnectionSlow(isSlow);
702
709
  };
703
710
  // Check status immediately
@@ -183,6 +183,7 @@ export function useGallerySwipe(firebaseUid, initImageId, controller) {
183
183
  }
184
184
  // Scenario 1: At the last image of current list
185
185
  if (currentIndex === currentImageList.length - 1) {
186
+ console.log("[SCENARIO 1] if last image: " + currentImageList.length);
186
187
  // Try to load next page for more images
187
188
  const newImages = await loadNextPage();
188
189
  if (newImages.length > 0) {
@@ -206,6 +207,7 @@ export function useGallerySwipe(firebaseUid, initImageId, controller) {
206
207
  else {
207
208
  // Scenario 2: Navigate to next image in current list
208
209
  const nextImage = currentImageList[currentIndex + 1];
210
+ console.log("[SCENARIO 2] Navigating to next image:", nextImage);
209
211
  setCurrentImageId(nextImage.id);
210
212
  // Fetch complete data for the next image
211
213
  const nextImageData = await controller.onGetImage(firebaseUid, nextImage.id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "1.4.7",
3
+ "version": "1.4.9",
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",