@yogiswara/honcho-editor-ui 1.0.14 → 1.0.15

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.
@@ -287,17 +287,27 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
287
287
  }
288
288
  }, [controller, loadImageFromUrl]);
289
289
  const handlePrev = useCallback(async (firebaseUid) => {
290
- const prevImageId = imageList[imageList.length - 2]?.id;
291
- if (prevImageId) {
292
- setCurrentImageId(prevImageId);
290
+ // Find the current image index
291
+ const currentIndex = imageList.findIndex(img => img.id === currentImageId);
292
+ // If not the first image, go to previous
293
+ if (currentIndex > 0) {
294
+ const prevImageId = imageList[currentIndex - 1]?.id;
295
+ if (prevImageId) {
296
+ setCurrentImageId(prevImageId);
297
+ }
293
298
  }
294
- }, [imageList]);
299
+ }, [imageList, currentImageId]);
295
300
  const handleNext = useCallback(async (firebaseUid) => {
296
- const nextImageId = imageList[1]?.id;
297
- if (nextImageId) {
298
- setCurrentImageId(nextImageId);
301
+ // Find the current image index
302
+ const currentIndex = imageList.findIndex(img => img.id === currentImageId);
303
+ // If not the last image, go to next
304
+ if (currentIndex < imageList.length - 1 && currentIndex !== -1) {
305
+ const nextImageId = imageList[currentIndex + 1]?.id;
306
+ if (nextImageId) {
307
+ setCurrentImageId(nextImageId);
308
+ }
299
309
  }
300
- }, [imageList]);
310
+ }, [imageList, currentImageId]);
301
311
  useEffect(() => {
302
312
  if (currentImageId && firebaseUid) {
303
313
  loadImageFromId(firebaseUid, currentImageId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "1.0.14",
3
+ "version": "1.0.15",
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",