@yogiswara/honcho-editor-ui 2.1.3 → 2.1.5

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.
@@ -4,7 +4,7 @@ import { AdjustmentValues } from "../../../lib/editor/honcho-editor";
4
4
  interface PhotoData extends GallerySetup {
5
5
  adjustments?: Partial<AdjustmentValues>;
6
6
  frame?: string;
7
- originalData: Gallery;
7
+ originalData?: Gallery;
8
8
  }
9
9
  interface ImageGalleryProps {
10
10
  imageCollection: PhotoData[];
@@ -44,6 +44,13 @@ export interface EditorConfig {
44
44
  transformation_adjustment: TransformationAdjustment[];
45
45
  watermarks: Watermark[];
46
46
  }
47
+ export interface Content {
48
+ key: string;
49
+ path: string;
50
+ size: number;
51
+ width: number;
52
+ height: number;
53
+ }
47
54
  export interface GallerySetup {
48
55
  src: string;
49
56
  original: string;
@@ -4,6 +4,7 @@ import { Gallery, ResponseGalleryPaging } from '../../hooks/editor/type';
4
4
  export interface PhotoData {
5
5
  key: string;
6
6
  src: string;
7
+ original: string;
7
8
  width: number;
8
9
  height: number;
9
10
  alt: string;
@@ -3,15 +3,19 @@ import { useState, useCallback, useEffect, useMemo } from 'react';
3
3
  import { useAdjustmentHistory } from '../useAdjustmentHistory';
4
4
  import { useAdjustmentHistoryBatch } from '../useAdjustmentHistoryBatch';
5
5
  // Helper function to map the API response to the format our UI component needs
6
- const mapGalleryToPhotoData = (gallery) => ({
7
- key: gallery.id,
8
- src: gallery.raw_edited?.path || gallery.download?.path || '',
9
- width: gallery.raw_edited?.width || 1, // Default to 1 to prevent division by zero
10
- height: gallery.raw_edited?.height || 1,
11
- alt: gallery.id || 'gallery image',
12
- isSelected: false, // All images start as unselected
13
- originalData: gallery,
14
- });
6
+ const mapGalleryToPhotoData = (gallery) => {
7
+ const bestAvailableImage = gallery.thumbnail || gallery.download || { path: '', width: 1, height: 1, key: gallery.id, size: 0 };
8
+ return {
9
+ key: gallery.id,
10
+ src: bestAvailableImage.path,
11
+ original: gallery.download?.path || bestAvailableImage.path,
12
+ width: bestAvailableImage.width || 1,
13
+ height: bestAvailableImage.height || 1,
14
+ alt: gallery.id || 'gallery image',
15
+ isSelected: false,
16
+ originalData: gallery,
17
+ };
18
+ };
15
19
  const initialAdjustments = {
16
20
  tempScore: 0, tintScore: 0, vibranceScore: 0, exposureScore: 0, highlightsScore: 0, shadowsScore: 0,
17
21
  whitesScore: 0, blacksScore: 0, saturationScore: 0, contrastScore: 0, clarityScore: 0, sharpnessScore: 0,
@@ -52,17 +56,11 @@ export function useHonchoEditorBulk(controllerBulk, eventID, firebaseUid) {
52
56
  const lastSelectedId = selectedImageIds.length > 0 ? selectedImageIds[selectedImageIds.length - 1] : eventID;
53
57
  controllerBulk.handleBack(firebaseUid, lastSelectedId);
54
58
  }, [controllerBulk, firebaseUid, selectedImageIds, eventID]);
55
- const handleSelectedMode = useCallback(() => {
56
- setIsSelectedMode(true);
57
- }, []);
59
+ const handleSelectedMode = useCallback(() => setIsSelectedMode(true), []);
58
60
  const handleToggleSelect = useCallback((photoToToggle) => () => {
59
- setImageCollection(currentCollection => currentCollection.map(photo => photo.key === photoToToggle.key
60
- ? { ...photo, isSelected: !photo.isSelected }
61
- : photo));
62
- // Automatically enter selection mode on first selection
63
- if (!isSelectedMode) {
61
+ setImageCollection(current => current.map(p => p.key === photoToToggle.key ? { ...p, isSelected: !p.isSelected } : p));
62
+ if (!isSelectedMode)
64
63
  setIsSelectedMode(true);
65
- }
66
64
  }, [isSelectedMode]);
67
65
  const handlePreview = useCallback((photo) => () => {
68
66
  console.log("Previewing image:", photo.key);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "2.1.3",
3
+ "version": "2.1.5",
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",