@@ -153,16 +153,18 @@ export const deleteSelectedInstance = () => {
153
153
} ) ;
154
154
} ;
155
155
156
- export const convertPositionToPadding = ( ) => {
156
+ export const convertPositionToProperty = (
157
+ targetProperty : "padding" | "margin"
158
+ ) => {
157
159
const batch = createBatchUpdate ( ) ;
158
160
159
161
// Get the position properties we want to convert
160
162
const positionProps = [ "top" , "right" , "bottom" , "left" ] as const ;
161
- const paddingProps = [
162
- "padding -top" ,
163
- "padding -right" ,
164
- "padding -bottom" ,
165
- "padding -left" ,
163
+ const targetProps = [
164
+ ` ${ targetProperty } -top` ,
165
+ ` ${ targetProperty } -right` ,
166
+ ` ${ targetProperty } -bottom` ,
167
+ ` ${ targetProperty } -left` ,
166
168
] as const ;
167
169
168
170
// Get the current styles for the selected instance
@@ -206,12 +208,12 @@ export const convertPositionToPadding = () => {
206
208
return ;
207
209
}
208
210
209
- // Convert position to padding
211
+ // Convert position to target property
210
212
positionProps . forEach ( ( prop , index ) => {
211
213
const value = positionValues . get ( prop ) ;
212
214
if ( value ) {
213
- // Set the corresponding padding
214
- batch . setProperty ( paddingProps [ index ] ) ( value ) ;
215
+ // Set the corresponding target property
216
+ batch . setProperty ( targetProps [ index ] ) ( value ) ;
215
217
// Delete the position property
216
218
batch . deleteProperty ( prop ) ;
217
219
}
@@ -556,7 +558,11 @@ export const { emitCommand, subscribeCommands } = createCommandsEmitter({
556
558
557
559
{
558
560
name : "convertPositionToPadding" ,
559
- handler : convertPositionToPadding ,
561
+ handler : ( ) => convertPositionToProperty ( "padding" ) ,
562
+ } ,
563
+ {
564
+ name : "convertPositionToMargin" ,
565
+ handler : ( ) => convertPositionToProperty ( "margin" ) ,
560
566
} ,
561
567
562
568
{
0 commit comments