@yogiswara/honcho-editor-ui 1.4.0 → 1.4.2

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.
@@ -1,17 +1,17 @@
1
1
  import React from "react";
2
2
  interface Props {
3
- anchorEl: null | HTMLElement;
4
- valueSelect: string;
5
- isPasteEnabled: boolean;
6
- onBack: () => void;
7
- onUndo: () => void;
8
- onRedo: () => void;
9
- onRevert: () => void;
10
- onCopyEdit: () => void;
11
- onPasteEdit: () => void;
12
- onMenuClick: (event: React.MouseEvent<HTMLElement>) => void;
13
- onMenuClose: () => void;
14
- onSelectButton: () => void;
3
+ anchorEl?: null | HTMLElement;
4
+ valueSelect?: string;
5
+ isPasteEnabled?: boolean;
6
+ onBack?: () => void;
7
+ onUndo?: () => void;
8
+ onRedo?: () => void;
9
+ onRevert?: () => void;
10
+ onCopyEdit?: () => void;
11
+ onPasteEdit?: () => void;
12
+ onMenuClick?: (event: React.MouseEvent<HTMLElement>) => void;
13
+ onMenuClose?: () => void;
14
+ onSelectButton?: () => void;
15
15
  }
16
16
  export default function HHeaderEditor(props: Props): import("react/jsx-runtime").JSX.Element;
17
17
  export {};
@@ -50,8 +50,21 @@ export declare function useHonchoEditor(controller: Controller, initImageId: str
50
50
  isGalleryLoading: boolean;
51
51
  galleryError: string | null;
52
52
  galleryImageData: Gallery | null;
53
- currentAdjustmentsState: AdjustmentState;
54
53
  historyActions: import("../useAdjustmentHistory").HistoryActions;
54
+ handleBackCallback: () => void;
55
+ currentAdjustmentsState: AdjustmentState;
56
+ setTempScore: (value: number) => void;
57
+ setTintScore: (value: number) => void;
58
+ setVibranceScore: (value: number) => void;
59
+ setSaturationScore: (value: number) => void;
60
+ setExposureScore: (value: number) => void;
61
+ setHighlightsScore: (value: number) => void;
62
+ setShadowsScore: (value: number) => void;
63
+ setWhitesScore: (value: number) => void;
64
+ setBlacksScore: (value: number) => void;
65
+ setContrastScore: (value: number) => void;
66
+ setClarityScore: (value: number) => void;
67
+ setSharpnessScore: (value: number) => void;
55
68
  handleUndo: () => void;
56
69
  handleRedo: () => void;
57
70
  handleRevert: () => void;
@@ -8,7 +8,7 @@ const initialAdjustments = {
8
8
  tempScore: 0, tintScore: 0, vibranceScore: 0, exposureScore: 0, highlightsScore: 0, shadowsScore: 0,
9
9
  whitesScore: 0, blacksScore: 0, saturationScore: 0, contrastScore: 0, clarityScore: 0, sharpnessScore: 0,
10
10
  };
11
- const clamp = (value) => Math.max(-100, Math.min(100, value));
11
+ // const clamp = (value: number) => Math.max(-100, Math.min(100, value));
12
12
  export function useHonchoEditor(controller, initImageId, firebaseUid) {
13
13
  // const [currentImageId, setCurrentImageId] = useState<string>(initImageId);
14
14
  // const [currentImageData, setCurrentImageData] = useState<Gallery | null>(null);
@@ -156,49 +156,6 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
156
156
  // }, [activeSubPanel ]);
157
157
  // isBulkEditing
158
158
  // Effect for keyboard shortcuts
159
- useEffect(() => {
160
- window.addEventListener('keydown', handleKeyDown);
161
- return () => {
162
- window.removeEventListener('keydown', handleKeyDown);
163
- };
164
- }, [handleKeyDown]);
165
- // Effect for drag listeners
166
- useEffect(() => {
167
- if (isDragging) {
168
- window.addEventListener('mousemove', handleDragMove);
169
- window.addEventListener('mouseup', handleDragEnd);
170
- window.addEventListener('touchmove', handleDragMove);
171
- window.addEventListener('touchend', handleDragEnd);
172
- }
173
- return () => {
174
- window.removeEventListener('mousemove', handleDragMove);
175
- window.removeEventListener('mouseup', handleDragEnd);
176
- window.removeEventListener('touchmove', handleDragMove);
177
- window.removeEventListener('touchend', handleDragEnd);
178
- };
179
- }, [isDragging, handleDragMove, handleDragEnd]);
180
- useEffect(() => {
181
- // Cast navigator to our custom type to access the connection property safely
182
- const navigatorWithConnection = navigator;
183
- if (!navigatorWithConnection.connection) {
184
- return;
185
- }
186
- const navigatorConnection = navigatorWithConnection.connection;
187
- const updateConnectionStatus = () => {
188
- const slowConnectionTypes = ['slow-2g', '2g', '3g'];
189
- const isSlow = navigatorConnection.saveData ||
190
- slowConnectionTypes.includes(navigatorConnection.effectiveType);
191
- setIsConnectionSlow(isSlow);
192
- };
193
- // Check status immediately
194
- updateConnectionStatus();
195
- // Add event listener for changes
196
- navigatorConnection.addEventListener('change', updateConnectionStatus);
197
- // Cleanup on unmount
198
- return () => {
199
- navigatorConnection.removeEventListener('change', updateConnectionStatus);
200
- };
201
- }, []);
202
159
  // MARK: - Core Editor Logic
203
160
  const updateCanvasEditor = useCallback(() => {
204
161
  if ((editorRef.current?.getInitialized() === true) && canvasRef.current) {
@@ -628,6 +585,23 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
628
585
  const zoomLevelText = useMemo(() => {
629
586
  return `${Math.round(zoomLevel * 100)}%`;
630
587
  }, [zoomLevel]);
588
+ const updateAdjustments = useCallback((newValues) => {
589
+ const newState = { ...currentAdjustmentsState, ...newValues };
590
+ historyActions.pushState(newState);
591
+ }, [currentAdjustmentsState, historyActions]);
592
+ const setTempScore = (value) => updateAdjustments({ tempScore: value });
593
+ const setTintScore = (value) => updateAdjustments({ tintScore: value });
594
+ const setVibranceScore = (value) => updateAdjustments({ vibranceScore: value });
595
+ const setSaturationScore = (value) => updateAdjustments({ saturationScore: value });
596
+ const setExposureScore = (value) => updateAdjustments({ exposureScore: value });
597
+ const setHighlightsScore = (value) => updateAdjustments({ highlightsScore: value });
598
+ const setShadowsScore = (value) => updateAdjustments({ shadowsScore: value });
599
+ const setWhitesScore = (value) => updateAdjustments({ whitesScore: value });
600
+ const setBlacksScore = (value) => updateAdjustments({ blacksScore: value });
601
+ const setContrastScore = (value) => updateAdjustments({ contrastScore: value });
602
+ const setClarityScore = (value) => updateAdjustments({ clarityScore: value });
603
+ const setSharpnessScore = (value) => updateAdjustments({ sharpnessScore: value });
604
+ // MARK: useEffect HERE!
631
605
  useEffect(() => {
632
606
  if (showCopyAlert) {
633
607
  const timer = setTimeout(() => setShowCopyAlert(false), 2000);
@@ -686,7 +660,49 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
686
660
  editorRef.current.setAdjustments(mapAdjustmentStateToAdjustmentEditor(currentAdjustmentsState));
687
661
  updateCanvasEditor();
688
662
  }, [editorRef.current, currentAdjustmentsState]);
689
- //
663
+ useEffect(() => {
664
+ window.addEventListener('keydown', handleKeyDown);
665
+ return () => {
666
+ window.removeEventListener('keydown', handleKeyDown);
667
+ };
668
+ }, [handleKeyDown]);
669
+ // Effect for drag listeners
670
+ useEffect(() => {
671
+ if (isDragging) {
672
+ window.addEventListener('mousemove', handleDragMove);
673
+ window.addEventListener('mouseup', handleDragEnd);
674
+ window.addEventListener('touchmove', handleDragMove);
675
+ window.addEventListener('touchend', handleDragEnd);
676
+ }
677
+ return () => {
678
+ window.removeEventListener('mousemove', handleDragMove);
679
+ window.removeEventListener('mouseup', handleDragEnd);
680
+ window.removeEventListener('touchmove', handleDragMove);
681
+ window.removeEventListener('touchend', handleDragEnd);
682
+ };
683
+ }, [isDragging, handleDragMove, handleDragEnd]);
684
+ useEffect(() => {
685
+ // Cast navigator to our custom type to access the connection property safely
686
+ const navigatorWithConnection = navigator;
687
+ if (!navigatorWithConnection.connection) {
688
+ return;
689
+ }
690
+ const navigatorConnection = navigatorWithConnection.connection;
691
+ const updateConnectionStatus = () => {
692
+ const slowConnectionTypes = ['slow-2g', '2g', '3g'];
693
+ const isSlow = navigatorConnection.saveData ||
694
+ slowConnectionTypes.includes(navigatorConnection.effectiveType);
695
+ setIsConnectionSlow(isSlow);
696
+ };
697
+ // Check status immediately
698
+ updateConnectionStatus();
699
+ // Add event listener for changes
700
+ navigatorConnection.addEventListener('change', updateConnectionStatus);
701
+ // Cleanup on unmount
702
+ return () => {
703
+ navigatorConnection.removeEventListener('change', updateConnectionStatus);
704
+ };
705
+ }, []);
690
706
  return {
691
707
  // Refs
692
708
  canvasRef,
@@ -703,8 +719,21 @@ export function useHonchoEditor(controller, initImageId, firebaseUid) {
703
719
  isGalleryLoading,
704
720
  galleryError,
705
721
  galleryImageData,
706
- currentAdjustmentsState,
707
722
  historyActions,
723
+ handleBackCallback,
724
+ currentAdjustmentsState,
725
+ setTempScore,
726
+ setTintScore,
727
+ setVibranceScore,
728
+ setSaturationScore,
729
+ setExposureScore,
730
+ setHighlightsScore,
731
+ setShadowsScore,
732
+ setWhitesScore,
733
+ setBlacksScore,
734
+ setContrastScore,
735
+ setClarityScore,
736
+ setSharpnessScore,
708
737
  // History functions and state
709
738
  handleUndo: historyActions.undo,
710
739
  handleRedo: historyActions.redo,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yogiswara/honcho-editor-ui",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
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",