@@ -97,8 +97,8 @@ const ColorSchemePicker = props => {
9797 const customColorSchemes = applyFilters ( 'stackable.global-settings.global-color-schemes.custom-color-schemes' , [ ] )
9898
9999 // Add a custom color scheme
100- const handleAddItem = ( ) => {
101- doAction ( 'stackable.global-settings.global-color-schemes.custom-color-schemes.add-color-scheme' , saveTimeout )
100+ const handleAddItem = ( scheme = null ) => {
101+ doAction ( 'stackable.global-settings.global-color-schemes.custom-color-schemes.add-color-scheme' , scheme , setItemInEdit , saveTimeout )
102102 }
103103
104104 // For sorting custom color schemes
@@ -192,13 +192,22 @@ const ColorSchemePicker = props => {
192192 }
193193 }
194194
195+ const onDuplicate = item => {
196+ // eslint-disable-next-line no-alert
197+ const confirmDuplicate = window . confirm ( __ ( 'Do you want to duplicate this color scheme?' , i18n ) )
198+
199+ if ( confirmDuplicate ) {
200+ handleAddItem ( item )
201+ }
202+ }
203+
195204 // If the property does not have a value for hover/parent-hover states, return the desktop value
196205 const getInheritedValue = property => {
197- if ( property [ currentState ] ) {
206+ if ( property ?. [ currentState ] ) {
198207 return property [ currentState ]
199208 }
200209
201- return property . desktop
210+ return property ? .desktop
202211 }
203212
204213 const ItemPreview = ( { item, withWrapper = false } ) => {
@@ -221,6 +230,8 @@ const ColorSchemePicker = props => {
221230 backgroundColor : backgroundColorStyle ,
222231 headingColor : getInheritedValue ( item . colorScheme . headingColor ) || defaults . headingColor . desktop ,
223232 textColor : getInheritedValue ( item . colorScheme . textColor ) || defaults . textColor . desktop ,
233+ linkColor : getInheritedValue ( item . colorScheme . linkColor ) || defaults . linkColor . desktop ,
234+ accentColor : getInheritedValue ( item . colorScheme . accentColor ) || defaults . accentColor . desktop ,
224235 buttonBackgroundColor : getInheritedValue ( item . colorScheme . buttonBackgroundColor ) || defaults . buttonBackgroundColor . desktop ,
225236 buttonOutlineColor : getInheritedValue ( item . colorScheme . buttonOutlineColor ) || defaults . buttonOutlineColor . desktop ,
226237 }
@@ -251,12 +262,14 @@ const ColorSchemePicker = props => {
251262 showResetCallback = { item => showResetButton ( item ) }
252263 /> : < >
253264 < InspectorSubHeader
254- title = { __ ( 'Editing Color Scheme' , i18n ) }
265+ title = { __ ( 'Edit Color Scheme' , i18n ) }
255266 onBack = { ( ) => setItemInEdit ( null ) }
256267 showTrash = { subHeaderControls . showTrash }
257268 showReset = { subHeaderControls . showReset }
269+ showDuplicate = { isPro }
258270 onTrash = { ( ) => onDeleteItem ( itemInEdit ) }
259271 onReset = { ( ) => onReset ( itemInEdit ) }
272+ onDuplicate = { ( ) => onDuplicate ( itemInEdit ) }
260273 />
261274 < div className = "stk-global-color-scheme__edit-panel-preview" >
262275 < p > { __ ( 'Editing this scheme will also change all blocks that currently use this color scheme.' , i18n ) } </ p >
0 commit comments