1.115.0
2 months ago
1.115.1
2 months ago
1.115.2
2 months ago
1.22.1
2 months ago
1.27.7
2 months ago
1.34.1
2 months ago
1.73.0
2 months ago
1.76.0
2 months ago
1.9.2
2 months ago
1.94.0
2 months ago
index.js
2 months ago
index.js
241 lines
| 1 | /* eslint camelcase: 0 */ |
| 2 | import save1_115_2 from './1.115.2/save'; |
| 3 | import save1_115_1 from './1.115.1/save'; |
| 4 | import save1_115_0 from './1.115.0/save'; |
| 5 | import save1_9_2 from './1.9.2/save'; |
| 6 | import save1_22_1 from './1.22.1/save'; |
| 7 | import save1_27_7 from './1.27.7/save'; |
| 8 | import save1_34_1 from './1.34.1/save'; |
| 9 | import save1_73_0 from './1.73.0/save'; |
| 10 | import save1_76_0 from './1.76.0/save'; |
| 11 | import save1_94_0 from './1.94.0/save'; |
| 12 | const migrateLegacyPadding = (attributes) => { |
| 13 | const { padding_left_and_right, style } = attributes; |
| 14 | const spacingPadding = style?.spacing?.padding; |
| 15 | if ( |
| 16 | padding_left_and_right === undefined || |
| 17 | spacingPadding?.left !== undefined || |
| 18 | spacingPadding?.right !== undefined |
| 19 | ) { |
| 20 | return attributes; |
| 21 | } |
| 22 | |
| 23 | // Legacy mapping: '0'/'...-none' = no padding + content width, |
| 24 | // '1' keeps existing behavior, '2' forces no padding but keeps full width. |
| 25 | const isNoPadding = |
| 26 | padding_left_and_right === '0' || |
| 27 | padding_left_and_right === 'vk_slider_item-paddingLR-none'; |
| 28 | |
| 29 | let paddingValue; |
| 30 | if (isNoPadding) { |
| 31 | paddingValue = '0'; |
| 32 | } else if (padding_left_and_right === '1') { |
| 33 | paddingValue = undefined; |
| 34 | } else if (padding_left_and_right === '2') { |
| 35 | paddingValue = '0'; |
| 36 | } |
| 37 | |
| 38 | const nextAttributes = { |
| 39 | ...attributes, |
| 40 | contentWidth: isNoPadding, |
| 41 | }; |
| 42 | |
| 43 | if (paddingValue === undefined) { |
| 44 | return nextAttributes; |
| 45 | } |
| 46 | |
| 47 | return { |
| 48 | ...nextAttributes, |
| 49 | style: { |
| 50 | ...style, |
| 51 | spacing: { |
| 52 | ...style?.spacing, |
| 53 | padding: { |
| 54 | ...style?.spacing?.padding, |
| 55 | left: paddingValue, |
| 56 | right: paddingValue, |
| 57 | }, |
| 58 | }, |
| 59 | }, |
| 60 | }; |
| 61 | }; |
| 62 | |
| 63 | const blockAttributes = { |
| 64 | style: { |
| 65 | type: 'object', |
| 66 | }, |
| 67 | verticalAlignment: { |
| 68 | type: 'string', |
| 69 | default: 'center', |
| 70 | }, |
| 71 | bgColor: { |
| 72 | type: 'string', |
| 73 | default: '#ffffff', |
| 74 | }, |
| 75 | bgImage: { |
| 76 | type: 'string', |
| 77 | default: null, |
| 78 | }, |
| 79 | bgImageTablet: { |
| 80 | type: 'string', |
| 81 | default: null, |
| 82 | }, |
| 83 | bgImageMobile: { |
| 84 | type: 'string', |
| 85 | default: null, |
| 86 | }, |
| 87 | opacity: { |
| 88 | type: 'number', |
| 89 | default: 0.5, |
| 90 | }, |
| 91 | bgSize: { |
| 92 | type: 'string', |
| 93 | default: 'repeat', |
| 94 | }, |
| 95 | padding_left_and_right: { |
| 96 | type: 'string', |
| 97 | default: '0', |
| 98 | }, |
| 99 | padding_top_and_bottom: { |
| 100 | type: 'string', |
| 101 | default: '1', |
| 102 | }, |
| 103 | clientId: { |
| 104 | type: 'string', |
| 105 | default: null, |
| 106 | }, |
| 107 | }; |
| 108 | |
| 109 | const blockAttributes2 = { |
| 110 | ...blockAttributes, |
| 111 | col_xs: { |
| 112 | type: 'number', |
| 113 | default: 1, |
| 114 | }, |
| 115 | col_sm: { |
| 116 | type: 'number', |
| 117 | default: 1, |
| 118 | }, |
| 119 | col_md: { |
| 120 | type: 'number', |
| 121 | default: 1, |
| 122 | }, |
| 123 | col_lg: { |
| 124 | type: 'number', |
| 125 | default: 1, |
| 126 | }, |
| 127 | col_xl: { |
| 128 | type: 'number', |
| 129 | default: 1, |
| 130 | }, |
| 131 | } |
| 132 | const blockAttributes3 = { |
| 133 | ...blockAttributes, |
| 134 | clientId: { |
| 135 | type: 'string', |
| 136 | }, |
| 137 | } |
| 138 | |
| 139 | const blockAttributes4 = { |
| 140 | ...blockAttributes3, |
| 141 | bgColor: { |
| 142 | type: 'string', |
| 143 | }, |
| 144 | } |
| 145 | |
| 146 | |
| 147 | // 1.34.1 で blockId を追加 |
| 148 | const blockAttributes5 = { |
| 149 | ...blockAttributes4, |
| 150 | blockId: { |
| 151 | type: 'string', |
| 152 | }, |
| 153 | } |
| 154 | |
| 155 | // 1.73.0 で linkUrl, linkTarget を追加 |
| 156 | const blockAttributes6 = { |
| 157 | ...blockAttributes5, |
| 158 | linkUrl: { |
| 159 | type: 'string' |
| 160 | }, |
| 161 | linkTarget: { |
| 162 | type: 'string', |
| 163 | default: '' |
| 164 | }, |
| 165 | } |
| 166 | |
| 167 | // 1.73.0 で linkUrl, linkTarget を追加 |
| 168 | const blockAttributes7 = { |
| 169 | ...blockAttributes6, |
| 170 | relAttribute: { |
| 171 | type: 'string', |
| 172 | default: '' |
| 173 | }, |
| 174 | linkDescription: { |
| 175 | type: 'string', |
| 176 | default: '' |
| 177 | }, |
| 178 | } |
| 179 | |
| 180 | // 1.115.1 から width を追加 |
| 181 | const blockAttributes8 = { |
| 182 | ...blockAttributes7, |
| 183 | contentWidth: { |
| 184 | type: 'boolean', |
| 185 | default: false, |
| 186 | }, |
| 187 | } |
| 188 | |
| 189 | export default [ |
| 190 | { |
| 191 | attributes: blockAttributes8, |
| 192 | save: save1_115_2, |
| 193 | migrate: migrateLegacyPadding, |
| 194 | }, |
| 195 | { |
| 196 | attributes: blockAttributes7, |
| 197 | save: save1_115_1, |
| 198 | migrate: migrateLegacyPadding, |
| 199 | }, |
| 200 | { |
| 201 | attributes: blockAttributes7, |
| 202 | save: save1_115_0, |
| 203 | migrate: migrateLegacyPadding, |
| 204 | }, |
| 205 | { |
| 206 | attributes: blockAttributes7, |
| 207 | save: save1_94_0, |
| 208 | migrate: migrateLegacyPadding, |
| 209 | }, |
| 210 | { |
| 211 | attributes: blockAttributes6, |
| 212 | save: save1_76_0, |
| 213 | migrate: migrateLegacyPadding, |
| 214 | }, |
| 215 | { |
| 216 | attributes: blockAttributes5, |
| 217 | save: save1_73_0, |
| 218 | migrate: migrateLegacyPadding, |
| 219 | }, |
| 220 | { |
| 221 | attributes: blockAttributes4, |
| 222 | save: save1_34_1, |
| 223 | migrate: migrateLegacyPadding, |
| 224 | }, |
| 225 | { |
| 226 | attributes: blockAttributes4, |
| 227 | save: save1_27_7, |
| 228 | migrate: migrateLegacyPadding, |
| 229 | }, |
| 230 | { |
| 231 | attributes: blockAttributes3, |
| 232 | save: save1_22_1, |
| 233 | migrate: migrateLegacyPadding, |
| 234 | }, |
| 235 | { |
| 236 | attributes: blockAttributes, |
| 237 | save: save1_9_2, |
| 238 | migrate: migrateLegacyPadding, |
| 239 | }, |
| 240 | ]; |
| 241 |