Skip to content

Commit

Permalink
Add migration
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdkei committed Sep 12, 2024
1 parent bb60307 commit 53d017d
Showing 1 changed file with 36 additions and 21 deletions.
57 changes: 36 additions & 21 deletions src/blocks/_pro/gridcolcard-item/deprecated/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,85 +5,100 @@ import save1_84_0 from './1.84.0/save';
const blockAttributes = {
editLock: {
type: 'boolean',
default: false
default: false,
},
textColor: {
type: 'string'
type: 'string',
},
backgroundColor: {
type: 'string'
type: 'string',
},
containerSpace: {
type: 'object',
default: {
'top': null,
'left': null,
'right': null,
'bottom': null
}
top: null,
left: null,
right: null,
bottom: null,
},
},
headerImageAspectRatio: {
type: 'string',
default: '1.618/1'
default: '1.618/1',
},
headerImageFit: {
type: 'boolean',
default: true
default: true,
},
headerDisplay: {
type: 'string',
default: 'delete'
default: 'delete',
},
footerDisplay: {
type: 'string',
default: 'delete'
default: 'delete',
},
borderRadius: {
type: 'string',
default: null
default: null,
},
border: {
type: 'boolean',
default: false
default: false,
},
borderColor: {
type: 'string',
default: '#e5e5e5'
default: '#e5e5e5',
},
url: {
type: 'string'
type: 'string',
},
urlOpenType: {
type: 'Boolean',
default: false
}
default: false,
},
};

// 1.38.0 からの変更で追加したもの
const blockAttributes2 = {
...blockAttributes,
borderWidth: {
type: 'number',
default: 1
default: 1,
},
};

const blockAttributes3 = {
...blockAttributes2,
headerDisplay: {
type: 'string',
default: 'display'
default: 'display', // 新しいデフォルト
},
footerDisplay: {
type: 'string',
default: 'display'
default: 'display', // 新しいデフォルト
},
};

const deprecated = [
{
attributes: blockAttributes3,
save: save1_84_0,
migrate: (attributes) => {
let newAttributes = { ...attributes };

// headerDisplayがundefinedの場合、deleteに変換
if (typeof attributes.headerDisplay === 'undefined') {
newAttributes.headerDisplay = 'delete';
}

// footerDisplayがundefinedの場合、deleteに変換
if (typeof attributes.footerDisplay === 'undefined') {
newAttributes.footerDisplay = 'delete';
}

return newAttributes;
},
},
{
attributes: blockAttributes2,
Expand Down

0 comments on commit 53d017d

Please sign in to comment.