1- import React from 'react' ;
1+ import React , { useEffect } from 'react' ;
22import { Button } from '@/components/ui/button' ;
33import { Textarea } from '@/components/ui/textarea' ;
44import { ScrollArea } from '@/components/ui/scroll-area' ;
@@ -15,12 +15,15 @@ export const ContentTab: React.FC<ContentTabProps> = ({
1515 customStyles,
1616 computedStyles,
1717 isContentEdited,
18+ isStyleEdited,
1819 applyingChanges,
1920 editableContent,
2021 originalContent,
2122 setEditableContent,
2223 setIsContentEdited,
24+ setIsStyleEdited,
2325 applyContentChanges,
26+ applyStyleChanges,
2427 handleStyleChange
2528} ) => {
2629 // Check if content has changed from original
@@ -45,15 +48,20 @@ export const ContentTab: React.FC<ContentTabProps> = ({
4548 console . error ( 'No component selected for content save' ) ;
4649 return ;
4750 }
48-
49- console . log ( 'Saving content for component:' , {
50- id : selectedComponent . id ,
51- selector : selectedComponent . selector ,
52- tagName : selectedComponent . tagName ,
53- content : editableContent . substring ( 0 , 50 ) + ( editableContent . length > 50 ? '...' : '' )
54- } ) ;
5551
56- applyContentChanges ( editableContent ) ;
52+ // Save content changes if needed
53+ if ( hasContentChanged ) {
54+ applyContentChanges ( editableContent ) ;
55+ }
56+
57+ // Always save typography style changes when we have custom styles
58+ if ( Object . keys ( customStyles ) . length > 0 ) {
59+ console . log ( "Applying style changes as we have custom styles" ) ;
60+ applyStyleChanges ( ) ;
61+ } else if ( isStyleEdited ) {
62+ console . log ( "Applying style changes based on isStyleEdited flag" ) ;
63+ applyStyleChanges ( ) ;
64+ }
5765 } ;
5866
5967 // Handle content changes with real-time preview updates
@@ -68,6 +76,17 @@ export const ContentTab: React.FC<ContentTabProps> = ({
6876 }
6977 } ;
7078
79+ // Wrapper for handleStyleChange that also sets isStyleEdited flag
80+ const handleTypographyStyleChange = ( property : string , value : string ) => {
81+ console . log ( "Typography style change:" , property , value ) ;
82+
83+ // Call the original style change handler
84+ handleStyleChange ( property , value ) ;
85+
86+ // Force isStyleEdited to true
87+ setIsStyleEdited ( true ) ;
88+ } ;
89+
7190 if ( ! selectedComponent ) {
7291 return (
7392 < div className = "p-3 sm:p-5 m-0 flex flex-col items-center justify-center h-full text-center" >
@@ -103,11 +122,14 @@ export const ContentTab: React.FC<ContentTabProps> = ({
103122 variant = "default"
104123 size = "sm"
105124 className = "text-xs h-8"
106- onClick = { handleContentSave }
107- disabled = { ! hasContentChanged || applyingChanges }
125+ onClick = { ( ) => {
126+ console . log ( "Save button clicked, isStyleEdited:" , isStyleEdited , "hasContentChanged:" , hasContentChanged ) ;
127+ handleContentSave ( ) ;
128+ } }
129+ disabled = { ( ! hasContentChanged && ! isStyleEdited && Object . keys ( customStyles ) . length === 0 ) || applyingChanges }
108130 >
109131 < Save className = "w-3.5 h-3.5 mr-1.5" />
110- Save Content
132+ Save Changes
111133 </ Button >
112134 </ div >
113135 </ div >
@@ -134,7 +156,9 @@ export const ContentTab: React.FC<ContentTabProps> = ({
134156 < TypographyControls
135157 customStyles = { customStyles }
136158 computedStyles = { computedStyles }
137- onChange = { handleStyleChange }
159+ onChange = { ( property , value ) => {
160+ handleTypographyStyleChange ( property , value ) ;
161+ } }
138162 />
139163 </ div >
140164 </ ScrollArea >
0 commit comments