@wordpress/block-library 7.17.0 → 7.19.0
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.
- package/CHANGELOG.md +4 -0
- package/build/audio/edit.js +44 -4
- package/build/audio/edit.js.map +1 -1
- package/build/button/deprecated.js +16 -2
- package/build/button/deprecated.js.map +1 -1
- package/build/button/edit.js +14 -8
- package/build/button/edit.js.map +1 -1
- package/build/button/index.js +4 -1
- package/build/button/index.js.map +1 -1
- package/build/button/save.js +2 -0
- package/build/button/save.js.map +1 -1
- package/build/buttons/edit.native.js +1 -1
- package/build/buttons/edit.native.js.map +1 -1
- package/build/columns/transforms.js +5 -0
- package/build/columns/transforms.js.map +1 -1
- package/build/comment-template/index.js +6 -2
- package/build/comment-template/index.js.map +1 -1
- package/build/cover/edit/index.js +3 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +3 -7
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/embed/deprecated.js +43 -4
- package/build/embed/deprecated.js.map +1 -1
- package/build/file/deprecated.js +108 -4
- package/build/file/deprecated.js.map +1 -1
- package/build/file/transforms.js +3 -9
- package/build/file/transforms.js.map +1 -1
- package/build/gallery/deprecated.js +148 -23
- package/build/gallery/deprecated.js.map +1 -1
- package/build/gallery/gallery.js +3 -2
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/use-image-sizes.js +2 -1
- package/build/gallery/use-image-sizes.js.map +1 -1
- package/build/gallery/v1/edit.js +6 -3
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/group/edit.js +105 -48
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +3 -0
- package/build/group/index.js.map +1 -1
- package/build/group/placeholder.js +168 -0
- package/build/group/placeholder.js.map +1 -0
- package/build/group/variations.js +3 -3
- package/build/group/variations.js.map +1 -1
- package/build/image/edit.native.js +1 -1
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +6 -9
- package/build/image/image.js.map +1 -1
- package/build/latest-comments/edit.js +2 -1
- package/build/latest-comments/edit.js.map +1 -1
- package/build/latest-comments/index.js +5 -1
- package/build/latest-comments/index.js.map +1 -1
- package/build/latest-posts/deprecated.js +13 -0
- package/build/latest-posts/deprecated.js.map +1 -1
- package/build/latest-posts/edit.js +1 -1
- package/build/latest-posts/edit.js.map +1 -1
- package/build/latest-posts/index.js +13 -0
- package/build/latest-posts/index.js.map +1 -1
- package/build/list/utils.js +4 -8
- package/build/list/utils.js.map +1 -1
- package/build/list-item/edit.js +2 -1
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/use-outdent-list-item.js +5 -7
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/navigation/edit/index.js +94 -103
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/manage-menus-button.js +36 -0
- package/build/navigation/edit/manage-menus-button.js.map +1 -0
- package/build/navigation/edit/navigation-menu-selector.js +12 -5
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +2 -6
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +5 -17
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation-link/edit.js +14 -3
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +4 -4
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/edit.js +29 -10
- package/build/page-list/edit.js.map +1 -1
- package/build/post-author/edit.js +35 -20
- package/build/post-author/edit.js.map +1 -1
- package/build/post-comments-count/index.js +4 -0
- package/build/post-comments-count/index.js.map +1 -1
- package/build/post-comments-form/index.js +4 -0
- package/build/post-comments-form/index.js.map +1 -1
- package/build/post-comments-link/index.js +4 -0
- package/build/post-comments-link/index.js.map +1 -1
- package/build/post-content/edit.js +14 -6
- package/build/post-content/edit.js.map +1 -1
- package/build/post-content/index.js +3 -0
- package/build/post-content/index.js.map +1 -1
- package/build/pullquote/deprecated.js +6 -6
- package/build/pullquote/deprecated.js.map +1 -1
- package/build/search/edit.js +1 -3
- package/build/search/edit.js.map +1 -1
- package/build/site-logo/edit.js +2 -2
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-tagline/edit.js +21 -9
- package/build/site-tagline/edit.js.map +1 -1
- package/build/site-title/edit/index.js +20 -8
- package/build/site-title/edit/index.js.map +1 -1
- package/build/social-link/edit.js +11 -2
- package/build/social-link/edit.js.map +1 -1
- package/build/social-link/index.js +3 -0
- package/build/social-link/index.js.map +1 -1
- package/build/spacer/controls.js +3 -7
- package/build/spacer/controls.js.map +1 -1
- package/build/table/deprecated.js +282 -27
- package/build/table/deprecated.js.map +1 -1
- package/build/table/state.js +1 -1
- package/build/table/state.js.map +1 -1
- package/build/template-part/variations.js +5 -0
- package/build/template-part/variations.js.map +1 -1
- package/build/utils/clean-empty-object.js +5 -4
- package/build/utils/clean-empty-object.js.map +1 -1
- package/build/video/deprecated.js +159 -0
- package/build/video/deprecated.js.map +1 -0
- package/build/video/edit.js +41 -5
- package/build/video/edit.js.map +1 -1
- package/build/video/index.js +3 -0
- package/build/video/index.js.map +1 -1
- package/build/video/tracks-editor.js +3 -28
- package/build/video/tracks-editor.js.map +1 -1
- package/build-module/audio/edit.js +46 -7
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/button/deprecated.js +16 -2
- package/build-module/button/deprecated.js.map +1 -1
- package/build-module/button/edit.js +16 -10
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/index.js +4 -1
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/save.js +2 -0
- package/build-module/button/save.js.map +1 -1
- package/build-module/buttons/edit.native.js +1 -1
- package/build-module/buttons/edit.native.js.map +1 -1
- package/build-module/columns/transforms.js +5 -0
- package/build-module/columns/transforms.js.map +1 -1
- package/build-module/comment-template/index.js +6 -2
- package/build-module/comment-template/index.js.map +1 -1
- package/build-module/cover/edit/index.js +3 -1
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +4 -8
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/embed/deprecated.js +44 -5
- package/build-module/embed/deprecated.js.map +1 -1
- package/build-module/file/deprecated.js +108 -4
- package/build-module/file/deprecated.js.map +1 -1
- package/build-module/file/transforms.js +3 -8
- package/build-module/file/transforms.js.map +1 -1
- package/build-module/gallery/deprecated.js +147 -25
- package/build-module/gallery/deprecated.js.map +1 -1
- package/build-module/gallery/gallery.js +3 -2
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/use-image-sizes.js +3 -2
- package/build-module/gallery/use-image-sizes.js.map +1 -1
- package/build-module/gallery/v1/edit.js +7 -4
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/group/edit.js +101 -48
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +3 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/group/placeholder.js +154 -0
- package/build-module/group/placeholder.js.map +1 -0
- package/build-module/group/variations.js +3 -3
- package/build-module/group/variations.js.map +1 -1
- package/build-module/image/edit.native.js +1 -1
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +8 -11
- package/build-module/image/image.js.map +1 -1
- package/build-module/latest-comments/edit.js +2 -1
- package/build-module/latest-comments/edit.js.map +1 -1
- package/build-module/latest-comments/index.js +5 -1
- package/build-module/latest-comments/index.js.map +1 -1
- package/build-module/latest-posts/deprecated.js +13 -0
- package/build-module/latest-posts/deprecated.js.map +1 -1
- package/build-module/latest-posts/edit.js +2 -2
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/latest-posts/index.js +13 -0
- package/build-module/latest-posts/index.js.map +1 -1
- package/build-module/list/utils.js +5 -9
- package/build-module/list/utils.js.map +1 -1
- package/build-module/list-item/edit.js +2 -1
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js +5 -6
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/navigation/edit/index.js +96 -105
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/manage-menus-button.js +26 -0
- package/build-module/navigation/edit/manage-menus-button.js.map +1 -0
- package/build-module/navigation/edit/navigation-menu-selector.js +13 -6
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +2 -6
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +7 -18
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation-link/edit.js +14 -4
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +4 -4
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/edit.js +29 -10
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/post-author/edit.js +35 -21
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-comments-count/index.js +4 -0
- package/build-module/post-comments-count/index.js.map +1 -1
- package/build-module/post-comments-form/index.js +4 -0
- package/build-module/post-comments-form/index.js.map +1 -1
- package/build-module/post-comments-link/index.js +4 -0
- package/build-module/post-comments-link/index.js.map +1 -1
- package/build-module/post-content/edit.js +14 -6
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-content/index.js +3 -0
- package/build-module/post-content/index.js.map +1 -1
- package/build-module/pullquote/deprecated.js +7 -7
- package/build-module/pullquote/deprecated.js.map +1 -1
- package/build-module/search/edit.js +1 -3
- package/build-module/search/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +3 -3
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-tagline/edit.js +23 -11
- package/build-module/site-tagline/edit.js.map +1 -1
- package/build-module/site-title/edit/index.js +22 -10
- package/build-module/site-title/edit/index.js.map +1 -1
- package/build-module/social-link/edit.js +11 -2
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-link/index.js +3 -0
- package/build-module/social-link/index.js.map +1 -1
- package/build-module/spacer/controls.js +4 -8
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/table/deprecated.js +282 -27
- package/build-module/table/deprecated.js.map +1 -1
- package/build-module/table/state.js +1 -1
- package/build-module/table/state.js.map +1 -1
- package/build-module/template-part/variations.js +5 -0
- package/build-module/template-part/variations.js.map +1 -1
- package/build-module/utils/clean-empty-object.js +5 -5
- package/build-module/utils/clean-empty-object.js.map +1 -1
- package/build-module/video/deprecated.js +147 -0
- package/build-module/video/deprecated.js.map +1 -0
- package/build-module/video/edit.js +45 -9
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/index.js +2 -0
- package/build-module/video/index.js.map +1 -1
- package/build-module/video/tracks-editor.js +4 -29
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/button/style-rtl.css +1 -0
- package/build-style/button/style.css +1 -0
- package/build-style/comment-template/style-rtl.css +1 -0
- package/build-style/comment-template/style.css +1 -0
- package/build-style/editor-rtl.css +80 -5
- package/build-style/editor.css +80 -5
- package/build-style/group/editor-rtl.css +44 -0
- package/build-style/group/editor.css +44 -0
- package/build-style/latest-comments/style-rtl.css +1 -0
- package/build-style/latest-comments/style.css +1 -0
- package/build-style/latest-posts/style-rtl.css +3 -0
- package/build-style/latest-posts/style.css +3 -0
- package/build-style/navigation/editor-rtl.css +27 -4
- package/build-style/navigation/editor.css +27 -4
- package/build-style/navigation/style-rtl.css +13 -1
- package/build-style/navigation/style.css +13 -1
- package/build-style/navigation-link/editor-rtl.css +8 -1
- package/build-style/navigation-link/editor.css +8 -1
- package/build-style/post-comments-form/style-rtl.css +3 -0
- package/build-style/post-comments-form/style.css +3 -0
- package/build-style/query/editor-rtl.css +1 -1
- package/build-style/query/editor.css +1 -1
- package/build-style/query-pagination/style-rtl.css +1 -1
- package/build-style/query-pagination/style.css +1 -1
- package/build-style/style-rtl.css +28 -2
- package/build-style/style.css +28 -2
- package/build-style/table/editor-rtl.css +1 -0
- package/build-style/table/editor.css +1 -0
- package/build-style/table/style-rtl.css +5 -0
- package/build-style/table/style.css +5 -0
- package/build-style/table/theme-rtl.css +1 -3
- package/build-style/table/theme.css +1 -3
- package/build-style/theme-rtl.css +1 -3
- package/build-style/theme.css +1 -3
- package/package.json +29 -28
- package/src/audio/edit.js +79 -24
- package/src/avatar/index.php +1 -1
- package/src/block/test/edit.native.js +8 -8
- package/src/button/block.json +4 -1
- package/src/button/deprecated.js +18 -2
- package/src/button/edit.js +12 -10
- package/src/button/save.js +12 -2
- package/src/button/style.scss +2 -0
- package/src/buttons/edit.native.js +1 -1
- package/src/buttons/test/edit.native.js +19 -19
- package/src/columns/test/edit.native.js +32 -32
- package/src/columns/transforms.js +8 -0
- package/src/comment-template/block.json +6 -2
- package/src/comment-template/style.scss +2 -0
- package/src/cover/edit/index.js +3 -1
- package/src/cover/edit/inspector-controls.js +11 -13
- package/src/cover/test/edit.native.js +26 -26
- package/src/embed/deprecated.js +53 -26
- package/src/embed/test/index.native.js +43 -43
- package/src/file/deprecated.js +130 -2
- package/src/file/transforms.js +3 -8
- package/src/gallery/deprecated.js +129 -4
- package/src/gallery/gallery.js +2 -0
- package/src/gallery/index.php +19 -10
- package/src/gallery/test/index.native.js +11 -11
- package/src/gallery/use-image-sizes.js +3 -2
- package/src/gallery/v1/edit.js +21 -25
- package/src/group/block.json +3 -0
- package/src/group/edit.js +105 -46
- package/src/group/editor.scss +48 -0
- package/src/group/placeholder.js +187 -0
- package/src/group/test/edit.native.js +3 -3
- package/src/group/test/placeholder.js +78 -0
- package/src/group/variations.js +3 -3
- package/src/image/edit.native.js +1 -1
- package/src/image/image.js +22 -10
- package/src/image/test/edit.native.js +17 -17
- package/src/latest-comments/block.json +5 -1
- package/src/latest-comments/edit.js +1 -0
- package/src/latest-comments/style.scss +3 -0
- package/src/latest-posts/block.json +13 -0
- package/src/latest-posts/edit.js +2 -2
- package/src/latest-posts/style.scss +3 -0
- package/src/list/test/edit.native.js +36 -36
- package/src/list/utils.js +3 -11
- package/src/list-item/edit.js +1 -0
- package/src/list-item/hooks/use-outdent-list-item.js +3 -6
- package/src/missing/test/edit-integration.native.js +5 -5
- package/src/navigation/edit/index.js +186 -161
- package/src/navigation/edit/manage-menus-button.js +21 -0
- package/src/navigation/edit/navigation-menu-selector.js +20 -5
- package/src/navigation/edit/responsive-wrapper.js +2 -10
- package/src/navigation/edit/unsaved-inner-blocks.js +5 -22
- package/src/navigation/editor.scss +29 -4
- package/src/navigation/style.scss +19 -1
- package/src/navigation-link/edit.js +13 -4
- package/src/navigation-link/editor.scss +8 -0
- package/src/navigation-submenu/edit.js +7 -5
- package/src/page-list/edit.js +36 -22
- package/src/post-author/edit.js +44 -20
- package/src/post-comments-count/block.json +4 -0
- package/src/post-comments-form/block.json +4 -0
- package/src/post-comments-form/style.scss +3 -0
- package/src/post-comments-link/block.json +4 -0
- package/src/post-content/block.json +3 -0
- package/src/post-content/edit.js +8 -4
- package/src/pullquote/deprecated.js +7 -7
- package/src/query/editor.scss +1 -1
- package/src/query-pagination/style.scss +1 -1
- package/src/read-more/index.php +9 -2
- package/src/search/edit.js +1 -1
- package/src/shortcode/test/edit.native.js +5 -5
- package/src/site-logo/edit.js +3 -3
- package/src/site-tagline/edit.js +25 -18
- package/src/site-title/edit/index.js +26 -12
- package/src/social-link/block.json +3 -0
- package/src/social-link/edit.js +8 -1
- package/src/social-link/index.php +11 -7
- package/src/social-link/test/index.native.js +10 -10
- package/src/social-links/test/edit.native.js +4 -4
- package/src/spacer/controls.js +10 -12
- package/src/spacer/test/index.native.js +17 -17
- package/src/table/deprecated.js +587 -348
- package/src/table/editor.scss +1 -0
- package/src/table/state.js +1 -1
- package/src/table/style.scss +7 -0
- package/src/table/theme.scss +1 -3
- package/src/template-part/index.php +5 -0
- package/src/template-part/variations.js +4 -0
- package/src/utils/clean-empty-object.js +5 -6
- package/src/video/deprecated.js +57 -0
- package/src/video/edit.js +71 -23
- package/src/video/index.js +2 -0
- package/src/video/tracks-editor.js +12 -28
package/src/table/deprecated.js
CHANGED
|
@@ -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
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
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
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
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
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
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
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
192
|
+
if ( isEmpty ) {
|
|
193
|
+
return null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const colorProps = getColorClassesAndStyles( attributes );
|
|
197
|
+
const borderProps = getBorderClassesAndStyles( attributes );
|
|
176
198
|
|
|
177
|
-
|
|
199
|
+
const classes = classnames(
|
|
200
|
+
colorProps.className,
|
|
201
|
+
borderProps.className,
|
|
202
|
+
{
|
|
178
203
|
'has-fixed-layout': hasFixedLayout,
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
<
|
|
233
|
-
|
|
234
|
-
<
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
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
|
-
|
|
248
|
-
|
|
249
|
-
attributes.backgroundColor &&
|
|
250
|
-
attributes.backgroundColor in oldColors &&
|
|
251
|
-
! attributes.style
|
|
252
|
-
);
|
|
278
|
+
backgroundColor: {
|
|
279
|
+
type: 'string',
|
|
253
280
|
},
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
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
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
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
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
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
|
-
|
|
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
|
|
380
|
-
'background-color',
|
|
381
|
-
backgroundColor
|
|
382
|
-
);
|
|
424
|
+
const Tag = `t${ type }`;
|
|
383
425
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
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
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
) }
|
|
457
|
+
</tr>
|
|
458
|
+
) ) }
|
|
459
|
+
</Tag>
|
|
460
|
+
);
|
|
461
|
+
};
|
|
417
462
|
|
|
418
|
-
|
|
419
|
-
|
|
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
|
-
|
|
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 ];
|