@wordpress/block-library 7.14.7 → 7.14.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/build/embed/deprecated.js +43 -4
  2. package/build/embed/deprecated.js.map +1 -1
  3. package/build/embed/variations.js +1 -1
  4. package/build/embed/variations.js.map +1 -1
  5. package/build/file/deprecated.js +108 -4
  6. package/build/file/deprecated.js.map +1 -1
  7. package/build/gallery/deprecated.js +147 -22
  8. package/build/gallery/deprecated.js.map +1 -1
  9. package/build/list-item/hooks/use-outdent-list-item.js +5 -2
  10. package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
  11. package/build/page-list/edit.js +29 -10
  12. package/build/page-list/edit.js.map +1 -1
  13. package/build/table/deprecated.js +282 -27
  14. package/build/table/deprecated.js.map +1 -1
  15. package/build/video/deprecated.js +159 -0
  16. package/build/video/deprecated.js.map +1 -0
  17. package/build/video/index.js +3 -0
  18. package/build/video/index.js.map +1 -1
  19. package/build-module/embed/deprecated.js +44 -5
  20. package/build-module/embed/deprecated.js.map +1 -1
  21. package/build-module/embed/variations.js +1 -1
  22. package/build-module/embed/variations.js.map +1 -1
  23. package/build-module/file/deprecated.js +108 -4
  24. package/build-module/file/deprecated.js.map +1 -1
  25. package/build-module/gallery/deprecated.js +145 -23
  26. package/build-module/gallery/deprecated.js.map +1 -1
  27. package/build-module/list-item/hooks/use-outdent-list-item.js +5 -2
  28. package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
  29. package/build-module/page-list/edit.js +29 -10
  30. package/build-module/page-list/edit.js.map +1 -1
  31. package/build-module/table/deprecated.js +282 -27
  32. package/build-module/table/deprecated.js.map +1 -1
  33. package/build-module/video/deprecated.js +147 -0
  34. package/build-module/video/deprecated.js.map +1 -0
  35. package/build-module/video/index.js +2 -0
  36. package/build-module/video/index.js.map +1 -1
  37. package/build-style/button/style-rtl.css +1 -0
  38. package/build-style/button/style.css +1 -0
  39. package/build-style/style-rtl.css +1 -0
  40. package/build-style/style.css +1 -0
  41. package/package.json +6 -6
  42. package/src/avatar/index.php +1 -1
  43. package/src/button/style.scss +2 -0
  44. package/src/embed/deprecated.js +53 -26
  45. package/src/embed/variations.js +1 -1
  46. package/src/file/deprecated.js +130 -2
  47. package/src/gallery/deprecated.js +127 -2
  48. package/src/list-item/hooks/use-outdent-list-item.js +6 -2
  49. package/src/navigation/index.php +1 -1
  50. package/src/page-list/edit.js +36 -22
  51. package/src/post-featured-image/index.php +11 -18
  52. package/src/rss/index.php +3 -3
  53. package/src/search/index.php +5 -5
  54. package/src/table/deprecated.js +587 -348
  55. package/src/video/deprecated.js +57 -0
  56. package/src/video/index.js +2 -0
@@ -10,12 +10,10 @@ import {
10
10
  RichText,
11
11
  getColorClassName,
12
12
  useBlockProps,
13
+ __experimentalGetBorderClassesAndStyles as getBorderClassesAndStyles,
14
+ __experimentalGetColorClassesAndStyles as getColorClassesAndStyles,
13
15
  } from '@wordpress/block-editor';
14
16
 
15
- const supports = {
16
- align: true,
17
- };
18
-
19
17
  // As the previous arbitrary colors won't match theme color palettes, the hex
20
18
  // value will be mapped to the style.color.background attribute as if it was
21
19
  // a custom color selection.
@@ -26,380 +24,426 @@ const oldColors = {
26
24
  'subtle-pale-pink': '#fcf0ef',
27
25
  };
28
26
 
29
- const deprecated = [
30
- // Deprecation migrating table block to use colors block support feature.
31
- {
32
- attributes: {
33
- hasFixedLayout: {
34
- type: 'boolean',
35
- default: false,
36
- },
37
- backgroundColor: {
38
- type: 'string',
39
- },
40
- caption: {
41
- type: 'string',
42
- source: 'html',
43
- selector: 'figcaption',
44
- default: '',
45
- },
46
- head: {
47
- type: 'array',
48
- default: [],
49
- source: 'query',
50
- selector: 'thead tr',
51
- query: {
52
- cells: {
53
- type: 'array',
54
- default: [],
55
- source: 'query',
56
- selector: 'td,th',
57
- query: {
58
- content: {
59
- type: 'string',
60
- source: 'html',
61
- },
62
- tag: {
63
- type: 'string',
64
- default: 'td',
65
- source: 'tag',
66
- },
67
- scope: {
68
- type: 'string',
69
- source: 'attribute',
70
- attribute: 'scope',
71
- },
72
- align: {
73
- type: 'string',
74
- source: 'attribute',
75
- attribute: 'data-align',
76
- },
27
+ // In #41140 support was added to global styles for caption elements which
28
+ // added a `wp-element-caption` classname to the embed figcaption element.
29
+ const v3 = {
30
+ attributes: {
31
+ hasFixedLayout: {
32
+ type: 'boolean',
33
+ default: false,
34
+ },
35
+ caption: {
36
+ type: 'string',
37
+ source: 'html',
38
+ selector: 'figcaption',
39
+ default: '',
40
+ },
41
+ head: {
42
+ type: 'array',
43
+ default: [],
44
+ source: 'query',
45
+ selector: 'thead tr',
46
+ query: {
47
+ cells: {
48
+ type: 'array',
49
+ default: [],
50
+ source: 'query',
51
+ selector: 'td,th',
52
+ query: {
53
+ content: {
54
+ type: 'string',
55
+ source: 'html',
56
+ },
57
+ tag: {
58
+ type: 'string',
59
+ default: 'td',
60
+ source: 'tag',
61
+ },
62
+ scope: {
63
+ type: 'string',
64
+ source: 'attribute',
65
+ attribute: 'scope',
66
+ },
67
+ align: {
68
+ type: 'string',
69
+ source: 'attribute',
70
+ attribute: 'data-align',
77
71
  },
78
72
  },
79
73
  },
80
74
  },
81
- body: {
82
- type: 'array',
83
- default: [],
84
- source: 'query',
85
- selector: 'tbody tr',
86
- query: {
87
- cells: {
88
- type: 'array',
89
- default: [],
90
- source: 'query',
91
- selector: 'td,th',
92
- query: {
93
- content: {
94
- type: 'string',
95
- source: 'html',
96
- },
97
- tag: {
98
- type: 'string',
99
- default: 'td',
100
- source: 'tag',
101
- },
102
- scope: {
103
- type: 'string',
104
- source: 'attribute',
105
- attribute: 'scope',
106
- },
107
- align: {
108
- type: 'string',
109
- source: 'attribute',
110
- attribute: 'data-align',
111
- },
75
+ },
76
+ body: {
77
+ type: 'array',
78
+ default: [],
79
+ source: 'query',
80
+ selector: 'tbody tr',
81
+ query: {
82
+ cells: {
83
+ type: 'array',
84
+ default: [],
85
+ source: 'query',
86
+ selector: 'td,th',
87
+ query: {
88
+ content: {
89
+ type: 'string',
90
+ source: 'html',
91
+ },
92
+ tag: {
93
+ type: 'string',
94
+ default: 'td',
95
+ source: 'tag',
96
+ },
97
+ scope: {
98
+ type: 'string',
99
+ source: 'attribute',
100
+ attribute: 'scope',
101
+ },
102
+ align: {
103
+ type: 'string',
104
+ source: 'attribute',
105
+ attribute: 'data-align',
112
106
  },
113
107
  },
114
108
  },
115
109
  },
116
- foot: {
117
- type: 'array',
118
- default: [],
119
- source: 'query',
120
- selector: 'tfoot tr',
121
- query: {
122
- cells: {
123
- type: 'array',
124
- default: [],
125
- source: 'query',
126
- selector: 'td,th',
127
- query: {
128
- content: {
129
- type: 'string',
130
- source: 'html',
131
- },
132
- tag: {
133
- type: 'string',
134
- default: 'td',
135
- source: 'tag',
136
- },
137
- scope: {
138
- type: 'string',
139
- source: 'attribute',
140
- attribute: 'scope',
141
- },
142
- align: {
143
- type: 'string',
144
- source: 'attribute',
145
- attribute: 'data-align',
146
- },
110
+ },
111
+ foot: {
112
+ type: 'array',
113
+ default: [],
114
+ source: 'query',
115
+ selector: 'tfoot tr',
116
+ query: {
117
+ cells: {
118
+ type: 'array',
119
+ default: [],
120
+ source: 'query',
121
+ selector: 'td,th',
122
+ query: {
123
+ content: {
124
+ type: 'string',
125
+ source: 'html',
126
+ },
127
+ tag: {
128
+ type: 'string',
129
+ default: 'td',
130
+ source: 'tag',
131
+ },
132
+ scope: {
133
+ type: 'string',
134
+ source: 'attribute',
135
+ attribute: 'scope',
136
+ },
137
+ align: {
138
+ type: 'string',
139
+ source: 'attribute',
140
+ attribute: 'data-align',
147
141
  },
148
142
  },
149
143
  },
150
144
  },
151
145
  },
152
- supports: {
153
- anchor: true,
154
- align: true,
155
- __experimentalSelector: '.wp-block-table > table',
146
+ },
147
+ supports: {
148
+ anchor: true,
149
+ align: true,
150
+ color: {
151
+ __experimentalSkipSerialization: true,
152
+ gradients: true,
153
+ __experimentalDefaultControls: {
154
+ background: true,
155
+ text: true,
156
+ },
156
157
  },
157
- save: ( { attributes } ) => {
158
- const {
159
- hasFixedLayout,
160
- head,
161
- body,
162
- foot,
163
- backgroundColor,
164
- caption,
165
- } = attributes;
166
- const isEmpty = ! head.length && ! body.length && ! foot.length;
167
-
168
- if ( isEmpty ) {
169
- return null;
170
- }
158
+ spacing: {
159
+ margin: true,
160
+ padding: true,
161
+ },
162
+ typography: {
163
+ fontSize: true,
164
+ lineHeight: true,
165
+ __experimentalFontFamily: true,
166
+ __experimentalFontStyle: true,
167
+ __experimentalFontWeight: true,
168
+ __experimentalLetterSpacing: true,
169
+ __experimentalTextTransform: true,
170
+ __experimentalTextDecoration: true,
171
+ __experimentalDefaultControls: {
172
+ fontSize: true,
173
+ },
174
+ },
175
+ __experimentalBorder: {
176
+ __experimentalSkipSerialization: true,
177
+ color: true,
178
+ style: true,
179
+ width: true,
180
+ __experimentalDefaultControls: {
181
+ color: true,
182
+ style: true,
183
+ width: true,
184
+ },
185
+ },
186
+ __experimentalSelector: '.wp-block-table > table',
187
+ },
188
+ save( { attributes } ) {
189
+ const { hasFixedLayout, head, body, foot, caption } = attributes;
190
+ const isEmpty = ! head.length && ! body.length && ! foot.length;
171
191
 
172
- const backgroundClass = getColorClassName(
173
- 'background-color',
174
- backgroundColor
175
- );
192
+ if ( isEmpty ) {
193
+ return null;
194
+ }
195
+
196
+ const colorProps = getColorClassesAndStyles( attributes );
197
+ const borderProps = getBorderClassesAndStyles( attributes );
176
198
 
177
- const classes = classnames( backgroundClass, {
199
+ const classes = classnames(
200
+ colorProps.className,
201
+ borderProps.className,
202
+ {
178
203
  'has-fixed-layout': hasFixedLayout,
179
- 'has-background': !! backgroundClass,
180
- } );
181
-
182
- const hasCaption = ! RichText.isEmpty( caption );
183
-
184
- const Section = ( { type, rows } ) => {
185
- if ( ! rows.length ) {
186
- return null;
187
- }
188
-
189
- const Tag = `t${ type }`;
190
-
191
- return (
192
- <Tag>
193
- { rows.map( ( { cells }, rowIndex ) => (
194
- <tr key={ rowIndex }>
195
- { cells.map(
196
- (
197
- { content, tag, scope, align },
198
- cellIndex
199
- ) => {
200
- const cellClasses = classnames( {
201
- [ `has-text-align-${ align }` ]:
202
- align,
203
- } );
204
-
205
- return (
206
- <RichText.Content
207
- className={
208
- cellClasses
209
- ? cellClasses
210
- : undefined
211
- }
212
- data-align={ align }
213
- tagName={ tag }
214
- value={ content }
215
- key={ cellIndex }
216
- scope={
217
- tag === 'th'
218
- ? scope
219
- : undefined
220
- }
221
- />
222
- );
223
- }
224
- ) }
225
- </tr>
226
- ) ) }
227
- </Tag>
228
- );
229
- };
204
+ }
205
+ );
206
+
207
+ const hasCaption = ! RichText.isEmpty( caption );
208
+
209
+ const Section = ( { type, rows } ) => {
210
+ if ( ! rows.length ) {
211
+ return null;
212
+ }
213
+
214
+ const Tag = `t${ type }`;
230
215
 
231
216
  return (
232
- <figure { ...useBlockProps.save() }>
233
- <table className={ classes === '' ? undefined : classes }>
234
- <Section type="head" rows={ head } />
235
- <Section type="body" rows={ body } />
236
- <Section type="foot" rows={ foot } />
237
- </table>
238
- { hasCaption && (
239
- <RichText.Content
240
- tagName="figcaption"
241
- value={ caption }
242
- />
243
- ) }
244
- </figure>
217
+ <Tag>
218
+ { rows.map( ( { cells }, rowIndex ) => (
219
+ <tr key={ rowIndex }>
220
+ { cells.map(
221
+ (
222
+ { content, tag, scope, align },
223
+ cellIndex
224
+ ) => {
225
+ const cellClasses = classnames( {
226
+ [ `has-text-align-${ align }` ]: align,
227
+ } );
228
+
229
+ return (
230
+ <RichText.Content
231
+ className={
232
+ cellClasses
233
+ ? cellClasses
234
+ : undefined
235
+ }
236
+ data-align={ align }
237
+ tagName={ tag }
238
+ value={ content }
239
+ key={ cellIndex }
240
+ scope={
241
+ tag === 'th' ? scope : undefined
242
+ }
243
+ />
244
+ );
245
+ }
246
+ ) }
247
+ </tr>
248
+ ) ) }
249
+ </Tag>
245
250
  );
251
+ };
252
+
253
+ return (
254
+ <figure { ...useBlockProps.save() }>
255
+ <table
256
+ className={ classes === '' ? undefined : classes }
257
+ style={ { ...colorProps.style, ...borderProps.style } }
258
+ >
259
+ <Section type="head" rows={ head } />
260
+ <Section type="body" rows={ body } />
261
+ <Section type="foot" rows={ foot } />
262
+ </table>
263
+ { hasCaption && (
264
+ <RichText.Content tagName="figcaption" value={ caption } />
265
+ ) }
266
+ </figure>
267
+ );
268
+ },
269
+ };
270
+
271
+ // Deprecation migrating table block to use colors block support feature.
272
+ const v2 = {
273
+ attributes: {
274
+ hasFixedLayout: {
275
+ type: 'boolean',
276
+ default: false,
246
277
  },
247
- isEligible: ( attributes ) => {
248
- return (
249
- attributes.backgroundColor &&
250
- attributes.backgroundColor in oldColors &&
251
- ! attributes.style
252
- );
278
+ backgroundColor: {
279
+ type: 'string',
253
280
  },
254
-
255
- // This version is the first to introduce the style attribute to the
256
- // table block. As a result, we'll explicitly override that.
257
- migrate: ( attributes ) => {
258
- return {
259
- ...attributes,
260
- backgroundColor: undefined,
261
- style: {
262
- color: {
263
- background: oldColors[ attributes.backgroundColor ],
264
- },
265
- },
266
- };
281
+ caption: {
282
+ type: 'string',
283
+ source: 'html',
284
+ selector: 'figcaption',
285
+ default: '',
267
286
  },
268
- },
269
- {
270
- attributes: {
271
- hasFixedLayout: {
272
- type: 'boolean',
273
- default: false,
274
- },
275
- backgroundColor: {
276
- type: 'string',
277
- },
278
- head: {
279
- type: 'array',
280
- default: [],
281
- source: 'query',
282
- selector: 'thead tr',
283
- query: {
284
- cells: {
285
- type: 'array',
286
- default: [],
287
- source: 'query',
288
- selector: 'td,th',
289
- query: {
290
- content: {
291
- type: 'string',
292
- source: 'html',
293
- },
294
- tag: {
295
- type: 'string',
296
- default: 'td',
297
- source: 'tag',
298
- },
299
- scope: {
300
- type: 'string',
301
- source: 'attribute',
302
- attribute: 'scope',
303
- },
287
+ head: {
288
+ type: 'array',
289
+ default: [],
290
+ source: 'query',
291
+ selector: 'thead tr',
292
+ query: {
293
+ cells: {
294
+ type: 'array',
295
+ default: [],
296
+ source: 'query',
297
+ selector: 'td,th',
298
+ query: {
299
+ content: {
300
+ type: 'string',
301
+ source: 'html',
302
+ },
303
+ tag: {
304
+ type: 'string',
305
+ default: 'td',
306
+ source: 'tag',
307
+ },
308
+ scope: {
309
+ type: 'string',
310
+ source: 'attribute',
311
+ attribute: 'scope',
312
+ },
313
+ align: {
314
+ type: 'string',
315
+ source: 'attribute',
316
+ attribute: 'data-align',
304
317
  },
305
318
  },
306
319
  },
307
320
  },
308
- body: {
309
- type: 'array',
310
- default: [],
311
- source: 'query',
312
- selector: 'tbody tr',
313
- query: {
314
- cells: {
315
- type: 'array',
316
- default: [],
317
- source: 'query',
318
- selector: 'td,th',
319
- query: {
320
- content: {
321
- type: 'string',
322
- source: 'html',
323
- },
324
- tag: {
325
- type: 'string',
326
- default: 'td',
327
- source: 'tag',
328
- },
329
- scope: {
330
- type: 'string',
331
- source: 'attribute',
332
- attribute: 'scope',
333
- },
321
+ },
322
+ body: {
323
+ type: 'array',
324
+ default: [],
325
+ source: 'query',
326
+ selector: 'tbody tr',
327
+ query: {
328
+ cells: {
329
+ type: 'array',
330
+ default: [],
331
+ source: 'query',
332
+ selector: 'td,th',
333
+ query: {
334
+ content: {
335
+ type: 'string',
336
+ source: 'html',
337
+ },
338
+ tag: {
339
+ type: 'string',
340
+ default: 'td',
341
+ source: 'tag',
342
+ },
343
+ scope: {
344
+ type: 'string',
345
+ source: 'attribute',
346
+ attribute: 'scope',
347
+ },
348
+ align: {
349
+ type: 'string',
350
+ source: 'attribute',
351
+ attribute: 'data-align',
334
352
  },
335
353
  },
336
354
  },
337
355
  },
338
- foot: {
339
- type: 'array',
340
- default: [],
341
- source: 'query',
342
- selector: 'tfoot tr',
343
- query: {
344
- cells: {
345
- type: 'array',
346
- default: [],
347
- source: 'query',
348
- selector: 'td,th',
349
- query: {
350
- content: {
351
- type: 'string',
352
- source: 'html',
353
- },
354
- tag: {
355
- type: 'string',
356
- default: 'td',
357
- source: 'tag',
358
- },
359
- scope: {
360
- type: 'string',
361
- source: 'attribute',
362
- attribute: 'scope',
363
- },
356
+ },
357
+ foot: {
358
+ type: 'array',
359
+ default: [],
360
+ source: 'query',
361
+ selector: 'tfoot tr',
362
+ query: {
363
+ cells: {
364
+ type: 'array',
365
+ default: [],
366
+ source: 'query',
367
+ selector: 'td,th',
368
+ query: {
369
+ content: {
370
+ type: 'string',
371
+ source: 'html',
372
+ },
373
+ tag: {
374
+ type: 'string',
375
+ default: 'td',
376
+ source: 'tag',
377
+ },
378
+ scope: {
379
+ type: 'string',
380
+ source: 'attribute',
381
+ attribute: 'scope',
382
+ },
383
+ align: {
384
+ type: 'string',
385
+ source: 'attribute',
386
+ attribute: 'data-align',
364
387
  },
365
388
  },
366
389
  },
367
390
  },
368
391
  },
369
- supports,
370
- save( { attributes } ) {
371
- const { hasFixedLayout, head, body, foot, backgroundColor } =
372
- attributes;
373
- const isEmpty = ! head.length && ! body.length && ! foot.length;
392
+ },
393
+ supports: {
394
+ anchor: true,
395
+ align: true,
396
+ __experimentalSelector: '.wp-block-table > table',
397
+ },
398
+ save: ( { attributes } ) => {
399
+ const { hasFixedLayout, head, body, foot, backgroundColor, caption } =
400
+ attributes;
401
+ const isEmpty = ! head.length && ! body.length && ! foot.length;
402
+
403
+ if ( isEmpty ) {
404
+ return null;
405
+ }
374
406
 
375
- if ( isEmpty ) {
407
+ const backgroundClass = getColorClassName(
408
+ 'background-color',
409
+ backgroundColor
410
+ );
411
+
412
+ const classes = classnames( backgroundClass, {
413
+ 'has-fixed-layout': hasFixedLayout,
414
+ 'has-background': !! backgroundClass,
415
+ } );
416
+
417
+ const hasCaption = ! RichText.isEmpty( caption );
418
+
419
+ const Section = ( { type, rows } ) => {
420
+ if ( ! rows.length ) {
376
421
  return null;
377
422
  }
378
423
 
379
- const backgroundClass = getColorClassName(
380
- 'background-color',
381
- backgroundColor
382
- );
424
+ const Tag = `t${ type }`;
383
425
 
384
- const classes = classnames( backgroundClass, {
385
- 'has-fixed-layout': hasFixedLayout,
386
- 'has-background': !! backgroundClass,
387
- } );
388
-
389
- const Section = ( { type, rows } ) => {
390
- if ( ! rows.length ) {
391
- return null;
392
- }
393
-
394
- const Tag = `t${ type }`;
395
-
396
- return (
397
- <Tag>
398
- { rows.map( ( { cells }, rowIndex ) => (
399
- <tr key={ rowIndex }>
400
- { cells.map(
401
- ( { content, tag, scope }, cellIndex ) => (
426
+ return (
427
+ <Tag>
428
+ { rows.map( ( { cells }, rowIndex ) => (
429
+ <tr key={ rowIndex }>
430
+ { cells.map(
431
+ (
432
+ { content, tag, scope, align },
433
+ cellIndex
434
+ ) => {
435
+ const cellClasses = classnames( {
436
+ [ `has-text-align-${ align }` ]: align,
437
+ } );
438
+
439
+ return (
402
440
  <RichText.Content
441
+ className={
442
+ cellClasses
443
+ ? cellClasses
444
+ : undefined
445
+ }
446
+ data-align={ align }
403
447
  tagName={ tag }
404
448
  value={ content }
405
449
  key={ cellIndex }
@@ -407,23 +451,218 @@ const deprecated = [
407
451
  tag === 'th' ? scope : undefined
408
452
  }
409
453
  />
410
- )
411
- ) }
412
- </tr>
413
- ) ) }
414
- </Tag>
415
- );
416
- };
454
+ );
455
+ }
456
+ ) }
457
+ </tr>
458
+ ) ) }
459
+ </Tag>
460
+ );
461
+ };
417
462
 
418
- return (
419
- <table className={ classes }>
463
+ return (
464
+ <figure { ...useBlockProps.save() }>
465
+ <table className={ classes === '' ? undefined : classes }>
420
466
  <Section type="head" rows={ head } />
421
467
  <Section type="body" rows={ body } />
422
468
  <Section type="foot" rows={ foot } />
423
469
  </table>
424
- );
470
+ { hasCaption && (
471
+ <RichText.Content tagName="figcaption" value={ caption } />
472
+ ) }
473
+ </figure>
474
+ );
475
+ },
476
+ isEligible: ( attributes ) => {
477
+ return (
478
+ attributes.backgroundColor &&
479
+ attributes.backgroundColor in oldColors &&
480
+ ! attributes.style
481
+ );
482
+ },
483
+
484
+ // This version is the first to introduce the style attribute to the
485
+ // table block. As a result, we'll explicitly override that.
486
+ migrate: ( attributes ) => {
487
+ return {
488
+ ...attributes,
489
+ backgroundColor: undefined,
490
+ style: {
491
+ color: {
492
+ background: oldColors[ attributes.backgroundColor ],
493
+ },
494
+ },
495
+ };
496
+ },
497
+ };
498
+
499
+ const v1 = {
500
+ attributes: {
501
+ hasFixedLayout: {
502
+ type: 'boolean',
503
+ default: false,
504
+ },
505
+ backgroundColor: {
506
+ type: 'string',
507
+ },
508
+ head: {
509
+ type: 'array',
510
+ default: [],
511
+ source: 'query',
512
+ selector: 'thead tr',
513
+ query: {
514
+ cells: {
515
+ type: 'array',
516
+ default: [],
517
+ source: 'query',
518
+ selector: 'td,th',
519
+ query: {
520
+ content: {
521
+ type: 'string',
522
+ source: 'html',
523
+ },
524
+ tag: {
525
+ type: 'string',
526
+ default: 'td',
527
+ source: 'tag',
528
+ },
529
+ scope: {
530
+ type: 'string',
531
+ source: 'attribute',
532
+ attribute: 'scope',
533
+ },
534
+ },
535
+ },
536
+ },
537
+ },
538
+ body: {
539
+ type: 'array',
540
+ default: [],
541
+ source: 'query',
542
+ selector: 'tbody tr',
543
+ query: {
544
+ cells: {
545
+ type: 'array',
546
+ default: [],
547
+ source: 'query',
548
+ selector: 'td,th',
549
+ query: {
550
+ content: {
551
+ type: 'string',
552
+ source: 'html',
553
+ },
554
+ tag: {
555
+ type: 'string',
556
+ default: 'td',
557
+ source: 'tag',
558
+ },
559
+ scope: {
560
+ type: 'string',
561
+ source: 'attribute',
562
+ attribute: 'scope',
563
+ },
564
+ },
565
+ },
566
+ },
567
+ },
568
+ foot: {
569
+ type: 'array',
570
+ default: [],
571
+ source: 'query',
572
+ selector: 'tfoot tr',
573
+ query: {
574
+ cells: {
575
+ type: 'array',
576
+ default: [],
577
+ source: 'query',
578
+ selector: 'td,th',
579
+ query: {
580
+ content: {
581
+ type: 'string',
582
+ source: 'html',
583
+ },
584
+ tag: {
585
+ type: 'string',
586
+ default: 'td',
587
+ source: 'tag',
588
+ },
589
+ scope: {
590
+ type: 'string',
591
+ source: 'attribute',
592
+ attribute: 'scope',
593
+ },
594
+ },
595
+ },
596
+ },
425
597
  },
426
598
  },
427
- ];
599
+ supports: {
600
+ align: true,
601
+ },
602
+ save( { attributes } ) {
603
+ const { hasFixedLayout, head, body, foot, backgroundColor } =
604
+ attributes;
605
+ const isEmpty = ! head.length && ! body.length && ! foot.length;
606
+
607
+ if ( isEmpty ) {
608
+ return null;
609
+ }
610
+
611
+ const backgroundClass = getColorClassName(
612
+ 'background-color',
613
+ backgroundColor
614
+ );
615
+
616
+ const classes = classnames( backgroundClass, {
617
+ 'has-fixed-layout': hasFixedLayout,
618
+ 'has-background': !! backgroundClass,
619
+ } );
620
+
621
+ const Section = ( { type, rows } ) => {
622
+ if ( ! rows.length ) {
623
+ return null;
624
+ }
625
+
626
+ const Tag = `t${ type }`;
428
627
 
429
- export default deprecated;
628
+ return (
629
+ <Tag>
630
+ { rows.map( ( { cells }, rowIndex ) => (
631
+ <tr key={ rowIndex }>
632
+ { cells.map(
633
+ ( { content, tag, scope }, cellIndex ) => (
634
+ <RichText.Content
635
+ tagName={ tag }
636
+ value={ content }
637
+ key={ cellIndex }
638
+ scope={
639
+ tag === 'th' ? scope : undefined
640
+ }
641
+ />
642
+ )
643
+ ) }
644
+ </tr>
645
+ ) ) }
646
+ </Tag>
647
+ );
648
+ };
649
+
650
+ return (
651
+ <table className={ classes }>
652
+ <Section type="head" rows={ head } />
653
+ <Section type="body" rows={ body } />
654
+ <Section type="foot" rows={ foot } />
655
+ </table>
656
+ );
657
+ },
658
+ };
659
+
660
+ /**
661
+ * New deprecations need to be placed first
662
+ * for them to have higher priority.
663
+ *
664
+ * Old deprecations may need to be updated as well.
665
+ *
666
+ * See block-deprecation.md
667
+ */
668
+ export default [ v3, v2, v1 ];