@wordpress/block-library 7.1.1 → 7.2.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.
Files changed (304) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/build/avatar/edit.js +205 -0
  3. package/build/avatar/edit.js.map +1 -0
  4. package/build/avatar/hooks.js +111 -0
  5. package/build/avatar/hooks.js.map +1 -0
  6. package/build/avatar/index.js +83 -0
  7. package/build/avatar/index.js.map +1 -0
  8. package/build/avatar/user-control.js +63 -0
  9. package/build/avatar/user-control.js.map +1 -0
  10. package/build/column/index.js +2 -1
  11. package/build/column/index.js.map +1 -1
  12. package/build/comment-author-avatar/index.js +1 -0
  13. package/build/comment-author-avatar/index.js.map +1 -1
  14. package/build/comment-date/edit.js +10 -25
  15. package/build/comment-date/edit.js.map +1 -1
  16. package/build/comment-template/edit.js +79 -52
  17. package/build/comment-template/edit.js.map +1 -1
  18. package/build/cover/edit.js +23 -33
  19. package/build/cover/edit.js.map +1 -1
  20. package/build/embed/variations.js +2 -2
  21. package/build/embed/variations.js.map +1 -1
  22. package/build/gallery/edit.js +18 -5
  23. package/build/gallery/edit.js.map +1 -1
  24. package/build/gallery/gallery.js +1 -1
  25. package/build/gallery/gallery.js.map +1 -1
  26. package/build/gallery/gap-styles.js +29 -0
  27. package/build/gallery/gap-styles.js.map +1 -0
  28. package/build/gallery/index.js +17 -1
  29. package/build/gallery/index.js.map +1 -1
  30. package/build/group/index.js +3 -1
  31. package/build/group/index.js.map +1 -1
  32. package/build/group/variations.js +1 -2
  33. package/build/group/variations.js.map +1 -1
  34. package/build/image/image.js +3 -1
  35. package/build/image/image.js.map +1 -1
  36. package/build/index.js +8 -2
  37. package/build/index.js.map +1 -1
  38. package/build/list/index.js +5 -7
  39. package/build/list/index.js.map +1 -1
  40. package/build/list/v2/edit.js +85 -0
  41. package/build/list/v2/edit.js.map +1 -0
  42. package/build/list/v2/index.js +33 -0
  43. package/build/list/v2/index.js.map +1 -0
  44. package/build/list/v2/save.js +34 -0
  45. package/build/list/v2/save.js.map +1 -0
  46. package/build/list/v2/transforms.js +121 -0
  47. package/build/list/v2/transforms.js.map +1 -0
  48. package/build/list-item/edit.js +47 -0
  49. package/build/list-item/edit.js.map +1 -0
  50. package/build/list-item/index.js +67 -0
  51. package/build/list-item/index.js.map +1 -0
  52. package/build/list-item/save.js +23 -0
  53. package/build/list-item/save.js.map +1 -0
  54. package/build/media-text/edit.js +3 -1
  55. package/build/media-text/edit.js.map +1 -1
  56. package/build/navigation/use-navigation-entities.js +26 -54
  57. package/build/navigation/use-navigation-entities.js.map +1 -1
  58. package/build/navigation-link/edit.js +88 -34
  59. package/build/navigation-link/edit.js.map +1 -1
  60. package/build/post-date/edit.js +31 -37
  61. package/build/post-date/edit.js.map +1 -1
  62. package/build/post-featured-image/edit.js +2 -1
  63. package/build/post-featured-image/edit.js.map +1 -1
  64. package/build/pullquote/edit.js +5 -3
  65. package/build/pullquote/edit.js.map +1 -1
  66. package/build/query/variations.js +4 -4
  67. package/build/query/variations.js.map +1 -1
  68. package/build/query-no-results/edit.js +28 -0
  69. package/build/query-no-results/edit.js.map +1 -0
  70. package/build/query-no-results/index.js +54 -0
  71. package/build/query-no-results/index.js.map +1 -0
  72. package/build/query-no-results/save.js +18 -0
  73. package/build/query-no-results/save.js.map +1 -0
  74. package/build/search/edit.js +2 -3
  75. package/build/search/edit.js.map +1 -1
  76. package/build/separator/deprecated.js +83 -0
  77. package/build/separator/deprecated.js.map +1 -0
  78. package/build/separator/edit.js +31 -23
  79. package/build/separator/edit.js.map +1 -1
  80. package/build/separator/index.js +17 -7
  81. package/build/separator/index.js.map +1 -1
  82. package/build/separator/save.js +18 -13
  83. package/build/separator/save.js.map +1 -1
  84. package/build/separator/use-deprecated-opacity.js +39 -0
  85. package/build/separator/use-deprecated-opacity.js.map +1 -0
  86. package/build/social-links/edit.js +14 -3
  87. package/build/social-links/edit.js.map +1 -1
  88. package/build/social-links/index.js +1 -1
  89. package/build/spacer/controls.js +6 -16
  90. package/build/spacer/controls.js.map +1 -1
  91. package/build/spacer/controls.native.js +3 -1
  92. package/build/spacer/controls.native.js.map +1 -1
  93. package/build/spacer/edit.js +4 -5
  94. package/build/spacer/edit.js.map +1 -1
  95. package/build/table/deprecated.js +1 -1
  96. package/build/table/deprecated.js.map +1 -1
  97. package/build/tag-cloud/edit.js +58 -2
  98. package/build/tag-cloud/edit.js.map +1 -1
  99. package/build/tag-cloud/index.js +8 -0
  100. package/build/tag-cloud/index.js.map +1 -1
  101. package/build-module/avatar/edit.js +190 -0
  102. package/build-module/avatar/edit.js.map +1 -0
  103. package/build-module/avatar/hooks.js +99 -0
  104. package/build-module/avatar/hooks.js.map +1 -0
  105. package/build-module/avatar/index.js +70 -0
  106. package/build-module/avatar/index.js.map +1 -0
  107. package/build-module/avatar/user-control.js +52 -0
  108. package/build-module/avatar/user-control.js.map +1 -0
  109. package/build-module/column/index.js +2 -1
  110. package/build-module/column/index.js.map +1 -1
  111. package/build-module/comment-author-avatar/index.js +1 -0
  112. package/build-module/comment-author-avatar/index.js.map +1 -1
  113. package/build-module/comment-date/edit.js +13 -30
  114. package/build-module/comment-date/edit.js.map +1 -1
  115. package/build-module/comment-template/edit.js +79 -52
  116. package/build-module/comment-template/edit.js.map +1 -1
  117. package/build-module/cover/edit.js +23 -34
  118. package/build-module/cover/edit.js.map +1 -1
  119. package/build-module/embed/variations.js +2 -2
  120. package/build-module/embed/variations.js.map +1 -1
  121. package/build-module/gallery/edit.js +17 -5
  122. package/build-module/gallery/edit.js.map +1 -1
  123. package/build-module/gallery/gallery.js +1 -1
  124. package/build-module/gallery/gallery.js.map +1 -1
  125. package/build-module/gallery/gap-styles.js +22 -0
  126. package/build-module/gallery/gap-styles.js.map +1 -0
  127. package/build-module/gallery/index.js +17 -1
  128. package/build-module/gallery/index.js.map +1 -1
  129. package/build-module/group/index.js +3 -1
  130. package/build-module/group/index.js.map +1 -1
  131. package/build-module/group/variations.js +1 -2
  132. package/build-module/group/variations.js.map +1 -1
  133. package/build-module/image/image.js +3 -1
  134. package/build-module/image/image.js.map +1 -1
  135. package/build-module/index.js +5 -2
  136. package/build-module/index.js.map +1 -1
  137. package/build-module/list/index.js +5 -1
  138. package/build-module/list/index.js.map +1 -1
  139. package/build-module/list/v2/edit.js +69 -0
  140. package/build-module/list/v2/edit.js.map +1 -0
  141. package/build-module/list/v2/index.js +19 -0
  142. package/build-module/list/v2/index.js.map +1 -0
  143. package/build-module/list/v2/save.js +23 -0
  144. package/build-module/list/v2/save.js.map +1 -0
  145. package/build-module/list/v2/transforms.js +111 -0
  146. package/build-module/list/v2/transforms.js.map +1 -0
  147. package/build-module/list-item/edit.js +37 -0
  148. package/build-module/list-item/edit.js.map +1 -0
  149. package/build-module/list-item/index.js +53 -0
  150. package/build-module/list-item/index.js.map +1 -0
  151. package/build-module/list-item/save.js +15 -0
  152. package/build-module/list-item/save.js.map +1 -0
  153. package/build-module/media-text/edit.js +3 -1
  154. package/build-module/media-text/edit.js.map +1 -1
  155. package/build-module/navigation/use-navigation-entities.js +27 -54
  156. package/build-module/navigation/use-navigation-entities.js.map +1 -1
  157. package/build-module/navigation-link/edit.js +88 -33
  158. package/build-module/navigation-link/edit.js.map +1 -1
  159. package/build-module/post-date/edit.js +32 -43
  160. package/build-module/post-date/edit.js.map +1 -1
  161. package/build-module/post-featured-image/edit.js +2 -1
  162. package/build-module/post-featured-image/edit.js.map +1 -1
  163. package/build-module/pullquote/edit.js +6 -3
  164. package/build-module/pullquote/edit.js.map +1 -1
  165. package/build-module/query/variations.js +4 -4
  166. package/build-module/query/variations.js.map +1 -1
  167. package/build-module/query-no-results/edit.js +18 -0
  168. package/build-module/query-no-results/edit.js.map +1 -0
  169. package/build-module/query-no-results/index.js +40 -0
  170. package/build-module/query-no-results/index.js.map +1 -0
  171. package/build-module/query-no-results/save.js +10 -0
  172. package/build-module/query-no-results/save.js.map +1 -0
  173. package/build-module/search/edit.js +2 -3
  174. package/build-module/search/edit.js.map +1 -1
  175. package/build-module/separator/deprecated.js +70 -0
  176. package/build-module/separator/deprecated.js.map +1 -0
  177. package/build-module/separator/edit.js +31 -22
  178. package/build-module/separator/edit.js.map +1 -1
  179. package/build-module/separator/index.js +16 -7
  180. package/build-module/separator/index.js.map +1 -1
  181. package/build-module/separator/save.js +19 -14
  182. package/build-module/separator/save.js.map +1 -1
  183. package/build-module/separator/use-deprecated-opacity.js +30 -0
  184. package/build-module/separator/use-deprecated-opacity.js.map +1 -0
  185. package/build-module/social-links/edit.js +15 -4
  186. package/build-module/social-links/edit.js.map +1 -1
  187. package/build-module/social-links/index.js +1 -1
  188. package/build-module/spacer/controls.js +8 -19
  189. package/build-module/spacer/controls.js.map +1 -1
  190. package/build-module/spacer/controls.native.js +2 -1
  191. package/build-module/spacer/controls.native.js.map +1 -1
  192. package/build-module/spacer/edit.js +3 -3
  193. package/build-module/spacer/edit.js.map +1 -1
  194. package/build-module/table/deprecated.js +1 -1
  195. package/build-module/table/deprecated.js.map +1 -1
  196. package/build-module/tag-cloud/edit.js +60 -4
  197. package/build-module/tag-cloud/edit.js.map +1 -1
  198. package/build-module/tag-cloud/index.js +8 -0
  199. package/build-module/tag-cloud/index.js.map +1 -1
  200. package/build-style/avatar/editor-rtl.css +79 -0
  201. package/build-style/avatar/editor.css +79 -0
  202. package/build-style/editor-rtl.css +23 -2
  203. package/build-style/editor.css +23 -2
  204. package/build-style/gallery/editor-rtl.css +0 -1
  205. package/build-style/gallery/editor.css +0 -1
  206. package/build-style/gallery/style-rtl.css +102 -169
  207. package/build-style/gallery/style.css +102 -169
  208. package/build-style/image/style-rtl.css +2 -0
  209. package/build-style/image/style.css +2 -0
  210. package/build-style/navigation-link/editor-rtl.css +13 -0
  211. package/build-style/navigation-link/editor.css +13 -0
  212. package/build-style/pullquote/style-rtl.css +0 -4
  213. package/build-style/pullquote/style.css +0 -4
  214. package/build-style/separator/editor-rtl.css +3 -0
  215. package/build-style/separator/editor.css +3 -0
  216. package/build-style/separator/theme-rtl.css +7 -1
  217. package/build-style/separator/theme.css +7 -1
  218. package/build-style/site-logo/editor-rtl.css +3 -1
  219. package/build-style/site-logo/editor.css +3 -1
  220. package/build-style/style-rtl.css +104 -173
  221. package/build-style/style.css +104 -173
  222. package/build-style/theme-rtl.css +7 -1
  223. package/build-style/theme.css +7 -1
  224. package/package.json +28 -28
  225. package/src/avatar/block.json +53 -0
  226. package/src/avatar/edit.js +222 -0
  227. package/src/avatar/editor.scss +3 -0
  228. package/src/avatar/hooks.js +96 -0
  229. package/src/avatar/index.js +18 -0
  230. package/src/avatar/index.php +146 -0
  231. package/src/avatar/user-control.js +56 -0
  232. package/src/column/block.json +2 -1
  233. package/src/comment-author-avatar/block.json +1 -0
  234. package/src/comment-date/edit.js +20 -30
  235. package/src/comment-template/edit.js +65 -44
  236. package/src/cover/edit.js +26 -31
  237. package/src/editor.scss +1 -0
  238. package/src/embed/variations.js +2 -2
  239. package/src/gallery/block.json +17 -1
  240. package/src/gallery/deprecated.scss +2 -2
  241. package/src/gallery/edit.js +15 -8
  242. package/src/gallery/editor.scss +0 -1
  243. package/src/gallery/gallery.js +8 -7
  244. package/src/gallery/gap-styles.js +21 -0
  245. package/src/gallery/index.php +42 -1
  246. package/src/gallery/style.scss +11 -44
  247. package/src/group/block.json +3 -1
  248. package/src/group/variations.js +1 -1
  249. package/src/image/image.js +4 -1
  250. package/src/image/style.scss +3 -0
  251. package/src/index.js +6 -1
  252. package/src/list/index.js +6 -1
  253. package/src/list/v2/edit.js +77 -0
  254. package/src/list/v2/index.js +20 -0
  255. package/src/list/v2/save.js +18 -0
  256. package/src/list/v2/transforms.js +116 -0
  257. package/src/list-item/block.json +26 -0
  258. package/src/list-item/edit.js +47 -0
  259. package/src/list-item/index.js +27 -0
  260. package/src/list-item/save.js +13 -0
  261. package/src/media-text/edit.js +1 -1
  262. package/src/navigation/index.php +22 -2
  263. package/src/navigation/use-navigation-entities.js +37 -73
  264. package/src/navigation-link/edit.js +145 -61
  265. package/src/navigation-link/editor.scss +11 -0
  266. package/src/post-date/edit.js +63 -52
  267. package/src/post-date/index.php +1 -1
  268. package/src/post-date/test/edit.js +17 -0
  269. package/src/post-featured-image/edit.js +9 -1
  270. package/src/post-featured-image/index.php +2 -1
  271. package/src/pullquote/edit.js +4 -3
  272. package/src/pullquote/style.scss +0 -5
  273. package/src/query/variations.js +4 -0
  274. package/src/query-no-results/block.json +20 -0
  275. package/src/query-no-results/edit.js +28 -0
  276. package/src/query-no-results/index.js +20 -0
  277. package/src/query-no-results/index.php +59 -0
  278. package/src/query-no-results/save.js +8 -0
  279. package/src/search/edit.js +1 -2
  280. package/src/separator/block.json +13 -6
  281. package/src/separator/deprecated.js +57 -0
  282. package/src/separator/deprecated.scss +6 -0
  283. package/src/separator/edit.js +36 -14
  284. package/src/separator/editor.scss +6 -0
  285. package/src/separator/index.js +2 -0
  286. package/src/separator/save.js +22 -14
  287. package/src/separator/test/edit.js +113 -0
  288. package/src/separator/theme.scss +7 -1
  289. package/src/separator/use-deprecated-opacity.js +41 -0
  290. package/src/site-logo/editor.scss +3 -1
  291. package/src/social-links/block.json +1 -1
  292. package/src/social-links/edit.js +15 -5
  293. package/src/spacer/controls.js +12 -18
  294. package/src/spacer/controls.native.js +2 -1
  295. package/src/spacer/edit.js +3 -6
  296. package/src/table/deprecated.js +5 -1
  297. package/src/tag-cloud/block.json +8 -0
  298. package/src/tag-cloud/edit.js +82 -2
  299. package/src/tag-cloud/index.php +6 -0
  300. package/build/separator/separator-settings.js +0 -36
  301. package/build/separator/separator-settings.js.map +0 -1
  302. package/build-module/separator/separator-settings.js +0 -27
  303. package/build-module/separator/separator-settings.js.map +0 -1
  304. package/src/separator/separator-settings.js +0 -24
@@ -1,25 +1,18 @@
1
1
  // Import styles for rendering the static content of deprecated gallery versions.
2
2
  @import "./deprecated.scss";
3
3
 
4
+ // The following is a temporary override until flex layout supports
5
+ // an align items setting of normal.
6
+ figure.wp-block-gallery.has-nested-images {
7
+ align-items: normal;
8
+ }
4
9
  // Styles for current version of gallery block.
5
10
  .wp-block-gallery.has-nested-images {
6
- display: flex;
7
- flex-wrap: wrap;
8
11
  // Need bogus :not(#individual-image) to override long :not()
9
12
  // specificity chain on default image block on front end.
10
13
  figure.wp-block-image:not(#individual-image) {
11
- // Add space between thumbnails, and unset right most thumbnails later.
12
- margin: 0 var(--gallery-block--gutter-size, #{$grid-unit-20}) var(--gallery-block--gutter-size, #{$grid-unit-20}) 0;
13
-
14
- &:last-of-type:not(#individual-image) {
15
- margin-right: 0;
16
- }
17
-
18
- width: calc(50% - (var(--gallery-block--gutter-size, #{$grid-unit-20}) / 2));
19
-
20
- &:nth-of-type(even) {
21
- margin-right: 0;
22
- }
14
+ width: calc(50% - (var(--wp--style--unstable-gallery-gap, #{$grid-unit-20}) / 2));
15
+ margin: 0;
23
16
  }
24
17
 
25
18
  figure.wp-block-image {
@@ -27,8 +20,6 @@
27
20
  flex-grow: 1;
28
21
  justify-content: center;
29
22
  position: relative;
30
- margin-top: auto;
31
- margin-bottom: auto;
32
23
  flex-direction: column;
33
24
  max-width: 100%;
34
25
 
@@ -96,17 +87,9 @@
96
87
 
97
88
  // Non cropped images.
98
89
  &:not(.is-cropped) {
99
-
100
90
  figure.wp-block-image:not(#individual-image) {
101
91
  margin-top: 0;
102
92
  margin-bottom: auto;
103
- img {
104
- margin-bottom: var(--gallery-block--gutter-size, #{$grid-unit-20});
105
- }
106
-
107
- figcaption {
108
- bottom: var(--gallery-block--gutter-size, #{$grid-unit-20});
109
- }
110
93
  }
111
94
  }
112
95
 
@@ -128,7 +111,6 @@
128
111
  }
129
112
 
130
113
  &.columns-1 figure.wp-block-image:not(#individual-image) {
131
- margin-right: 0;
132
114
  width: 100%;
133
115
  }
134
116
 
@@ -136,35 +118,20 @@
136
118
  @include break-small {
137
119
  @for $i from 3 through 8 {
138
120
  &.columns-#{ $i } figure.wp-block-image:not(#individual-image) {
139
- margin-right: var(--gallery-block--gutter-size, #{$grid-unit-20});
140
- width: calc(#{math.div(100%, $i)} - (var(--gallery-block--gutter-size, #{$grid-unit-20}) * #{math.div($i - 1, $i)}));
141
-
142
- }
121
+ width: calc(#{math.div(100%, $i)} - (var(--wp--style--unstable-gallery-gap, #{$grid-unit-20}) * #{math.div($i - 1, $i)}));
143
122
 
144
- // Prevent collapsing margin while sibling is being dragged.
145
- &.columns-#{$i} figure.wp-block-image:not(#individual-image).is-dragging ~ figure.wp-block-image:not(#individual-image) {
146
- margin-right: var(--gallery-block--gutter-size, #{$grid-unit-20});
147
- }
148
- }
149
- // Unset the right margin on every rightmost gallery item to ensure center balance.
150
- @for $column-count from 1 through 8 {
151
- &.columns-#{$column-count} figure.wp-block-image:not(#individual-image):nth-of-type(#{ $column-count }n) {
152
- margin-right: 0;
153
123
  }
154
124
  }
155
125
  // If number of columns not explicitly set default to 3 columns if 3 or more images.
156
126
  &.columns-default {
157
127
  figure.wp-block-image:not(#individual-image) {
158
- margin-right: var(--gallery-block--gutter-size, #{$grid-unit-20});
159
- width: calc(33.33% - (var(--gallery-block--gutter-size, 16px) * #{math.div(2, 3)}));
160
- }
161
- figure.wp-block-image:not(#individual-image):nth-of-type(3n+3) {
162
- margin-right: 0;
128
+
129
+ width: calc(33.33% - (var(--wp--style--unstable-gallery-gap, 16px) * #{math.div(2, 3)}));
163
130
  }
164
131
  // If only 2 child images use 2 columns.
165
132
  figure.wp-block-image:not(#individual-image):first-child:nth-last-child(2),
166
133
  figure.wp-block-image:not(#individual-image):first-child:nth-last-child(2) ~ figure.wp-block-image:not(#individual-image) {
167
- width: calc(50% - (var(--gallery-block--gutter-size, 16px) * 0.5));
134
+ width: calc(50% - (var(--wp--style--unstable-gallery-gap, 16px) * 0.5));
168
135
  }
169
136
  // For a single image set to 100%.
170
137
  figure.wp-block-image:not(#individual-image):first-child:nth-last-child(1) {
@@ -61,7 +61,9 @@
61
61
  "fontSize": true
62
62
  }
63
63
  },
64
- "__experimentalLayout": true
64
+ "__experimentalLayout": {
65
+ "allowOrientation": false
66
+ }
65
67
  },
66
68
  "editorStyle": "wp-block-group-editor",
67
69
  "style": "wp-block-group"
@@ -18,7 +18,7 @@ const variations = [
18
18
  name: 'group-row',
19
19
  title: __( 'Row' ),
20
20
  description: __( 'Blocks shown in a row.' ),
21
- attributes: { layout: { type: 'flex', allowOrientation: false } },
21
+ attributes: { layout: { type: 'flex' } },
22
22
  scope: [ 'inserter', 'transform' ],
23
23
  isActive: ( blockAttributes ) =>
24
24
  blockAttributes.layout?.type === 'flex',
@@ -95,7 +95,10 @@ export default function Image( {
95
95
  );
96
96
  const multiSelectedClientIds = getMultiSelectedBlockClientIds();
97
97
  return {
98
- image: id && isSelected ? getMedia( id ) : null,
98
+ image:
99
+ id && isSelected
100
+ ? getMedia( id, { context: 'view' } )
101
+ : null,
99
102
  multiImageSelection:
100
103
  multiSelectedClientIds.length &&
101
104
  multiSelectedClientIds.every(
@@ -2,6 +2,8 @@
2
2
  margin: 0 0 1em 0;
3
3
 
4
4
  img {
5
+ height: auto;
6
+ max-width: 100%;
5
7
  vertical-align: bottom;
6
8
  }
7
9
 
@@ -56,6 +58,7 @@
56
58
  margin-bottom: 0.5em;
57
59
  }
58
60
 
61
+ // This is needed for classic themes where the align class is not on the container.
59
62
  .aligncenter {
60
63
  margin-left: auto;
61
64
  margin-right: auto;
package/src/index.js CHANGED
@@ -13,6 +13,7 @@ import {
13
13
  * Internal dependencies
14
14
  */
15
15
  import * as archives from './archives';
16
+ import * as avatar from './avatar';
16
17
  import * as audio from './audio';
17
18
  import * as button from './button';
18
19
  import * as buttons from './buttons';
@@ -46,6 +47,7 @@ import * as image from './image';
46
47
  import * as latestComments from './latest-comments';
47
48
  import * as latestPosts from './latest-posts';
48
49
  import * as list from './list';
50
+ import * as listItem from './list-item';
49
51
  import * as logInOut from './loginout';
50
52
  import * as mediaText from './media-text';
51
53
  import * as missing from './missing';
@@ -77,6 +79,7 @@ import * as postTitle from './post-title';
77
79
  import * as preformatted from './preformatted';
78
80
  import * as pullquote from './pullquote';
79
81
  import * as query from './query';
82
+ import * as queryNoResults from './query-no-results';
80
83
  import * as queryPagination from './query-pagination';
81
84
  import * as queryPaginationNext from './query-pagination-next';
82
85
  import * as queryPaginationNumbers from './query-pagination-numbers';
@@ -135,6 +138,7 @@ export const __experimentalGetCoreBlocks = () => [
135
138
  heading,
136
139
  gallery,
137
140
  list,
141
+ listItem,
138
142
  quote,
139
143
 
140
144
  // Register all remaining core blocks.
@@ -248,9 +252,10 @@ export const __experimentalRegisterExperimentalCoreBlocks = process.env
248
252
  ? ( { enableFSEBlocks } = {} ) => {
249
253
  [
250
254
  // Experimental blocks.
255
+ avatar,
251
256
  homeLink,
252
257
  postAuthorName,
253
-
258
+ queryNoResults,
254
259
  // Full Site Editing blocks.
255
260
  ...( enableFSEBlocks
256
261
  ? [
package/src/list/index.js CHANGED
@@ -11,12 +11,13 @@ import edit from './edit';
11
11
  import metadata from './block.json';
12
12
  import save from './save';
13
13
  import transforms from './transforms';
14
+ import settingsV2 from './v2';
14
15
 
15
16
  const { name } = metadata;
16
17
 
17
18
  export { metadata, name };
18
19
 
19
- export const settings = {
20
+ const settingsV1 = {
20
21
  icon,
21
22
  example: {
22
23
  attributes: {
@@ -41,3 +42,7 @@ export const settings = {
41
42
  save,
42
43
  deprecated,
43
44
  };
45
+
46
+ export const settings = window?.__experimentalEnableListBlockV2
47
+ ? settingsV2
48
+ : settingsV1;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ BlockControls,
6
+ useBlockProps,
7
+ useInnerBlocksProps,
8
+ } from '@wordpress/block-editor';
9
+ import { ToolbarButton } from '@wordpress/components';
10
+ import { isRTL, __ } from '@wordpress/i18n';
11
+ import {
12
+ formatListBullets,
13
+ formatListBulletsRTL,
14
+ formatListNumbered,
15
+ formatListNumberedRTL,
16
+ } from '@wordpress/icons';
17
+
18
+ /**
19
+ * Internal dependencies
20
+ */
21
+ import OrderedListSettings from '../ordered-list-settings';
22
+
23
+ const TEMPLATE = [ [ 'core/list-item' ] ];
24
+
25
+ function Edit( { attributes, setAttributes } ) {
26
+ const blockProps = useBlockProps();
27
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
28
+ allowedBlocks: [ 'core/list-item' ],
29
+ template: TEMPLATE,
30
+ } );
31
+ const { ordered, reversed, start } = attributes;
32
+ const TagName = ordered ? 'ol' : 'ul';
33
+
34
+ const controls = (
35
+ <BlockControls group="block">
36
+ <ToolbarButton
37
+ icon={ isRTL() ? formatListBulletsRTL : formatListBullets }
38
+ title={ __( 'Unordered' ) }
39
+ describedBy={ __( 'Convert to unordered list' ) }
40
+ isActive={ ordered === false }
41
+ onClick={ () => {
42
+ setAttributes( { ordered: false } );
43
+ } }
44
+ />
45
+ <ToolbarButton
46
+ icon={ isRTL() ? formatListNumberedRTL : formatListNumbered }
47
+ title={ __( 'Ordered' ) }
48
+ describedBy={ __( 'Convert to ordered list' ) }
49
+ isActive={ ordered === true }
50
+ onClick={ () => {
51
+ setAttributes( { ordered: true } );
52
+ } }
53
+ />
54
+ </BlockControls>
55
+ );
56
+
57
+ return (
58
+ <>
59
+ <TagName
60
+ reversed={ reversed }
61
+ start={ start }
62
+ { ...innerBlocksProps }
63
+ />
64
+ { controls }
65
+ { ordered && (
66
+ <OrderedListSettings
67
+ setAttributes={ setAttributes }
68
+ ordered={ ordered }
69
+ reversed={ reversed }
70
+ start={ start }
71
+ />
72
+ ) }
73
+ </>
74
+ );
75
+ }
76
+
77
+ export default Edit;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { list as icon } from '@wordpress/icons';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import edit from './edit';
10
+ import save from './save';
11
+ import transforms from './transforms';
12
+
13
+ const settings = {
14
+ icon,
15
+ edit,
16
+ save,
17
+ transforms,
18
+ };
19
+
20
+ export default settings;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { InnerBlocks, useBlockProps } from '@wordpress/block-editor';
5
+
6
+ export default function save( { attributes } ) {
7
+ const { ordered, reversed, start } = attributes;
8
+ const TagName = ordered ? 'ol' : 'ul';
9
+ return (
10
+ <TagName
11
+ reversed={ reversed }
12
+ start={ start }
13
+ { ...useBlockProps.save() }
14
+ >
15
+ <InnerBlocks.Content />
16
+ </TagName>
17
+ );
18
+ }
@@ -0,0 +1,116 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { createBlock, switchToBlockType } from '@wordpress/blocks';
5
+ import {
6
+ __UNSTABLE_LINE_SEPARATOR,
7
+ create,
8
+ split,
9
+ toHTMLString,
10
+ } from '@wordpress/rich-text';
11
+
12
+ const transforms = {
13
+ from: [
14
+ {
15
+ type: 'block',
16
+ isMultiBlock: true,
17
+ blocks: [ 'core/paragraph', 'core/heading' ],
18
+ transform: ( blockAttributes ) => {
19
+ let childBlocks = [];
20
+ if ( blockAttributes.length > 1 ) {
21
+ childBlocks = blockAttributes.map( ( { content } ) => {
22
+ return createBlock( 'core/list-item', { content } );
23
+ } );
24
+ } else if ( blockAttributes.length === 1 ) {
25
+ const value = create( {
26
+ html: blockAttributes[ 0 ].content,
27
+ } );
28
+ childBlocks = split( value, '\n' ).map( ( result ) => {
29
+ return createBlock( 'core/list-item', {
30
+ content: toHTMLString( { value: result } ),
31
+ } );
32
+ } );
33
+ }
34
+ return createBlock(
35
+ 'core/list',
36
+ {
37
+ anchor: blockAttributes.anchor,
38
+ },
39
+ childBlocks
40
+ );
41
+ },
42
+ },
43
+ {
44
+ type: 'block',
45
+ blocks: [ 'core/quote', 'core/pullquote' ],
46
+ transform: ( { value, anchor } ) => {
47
+ return createBlock(
48
+ 'core/list',
49
+ {
50
+ anchor,
51
+ },
52
+ split(
53
+ create( { html: value, multilineTag: 'p' } ),
54
+ __UNSTABLE_LINE_SEPARATOR
55
+ ).map( ( result ) => {
56
+ return createBlock( 'core/list-item', {
57
+ content: toHTMLString( { value: result } ),
58
+ } );
59
+ } )
60
+ );
61
+ },
62
+ },
63
+ ...[ '*', '-' ].map( ( prefix ) => ( {
64
+ type: 'prefix',
65
+ prefix,
66
+ transform( content ) {
67
+ return createBlock( 'core/list', {}, [
68
+ createBlock( 'core/list-item', { content } ),
69
+ ] );
70
+ },
71
+ } ) ),
72
+ ...[ '1.', '1)' ].map( ( prefix ) => ( {
73
+ type: 'prefix',
74
+ prefix,
75
+ transform( content ) {
76
+ return createBlock(
77
+ 'core/list',
78
+ {
79
+ ordered: true,
80
+ },
81
+ [ createBlock( 'core/list-item', { content } ) ]
82
+ );
83
+ },
84
+ } ) ),
85
+ ],
86
+ to: [
87
+ ...[ 'core/paragraph', 'core/heading' ].map( ( block ) => ( {
88
+ type: 'block',
89
+ blocks: [ block ],
90
+ transform: ( _attributes, childBlocks ) => {
91
+ return childBlocks
92
+ .filter( ( { name } ) => name === 'core/list-item' )
93
+ .map( ( { attributes } ) =>
94
+ createBlock( block, {
95
+ content: attributes.content,
96
+ } )
97
+ );
98
+ },
99
+ } ) ),
100
+ ...[ 'core/quote', 'core/pullquote' ].map( ( block ) => ( {
101
+ type: 'block',
102
+ blocks: [ block ],
103
+ transform: ( attributes, innerBlocks ) => {
104
+ return switchToBlockType(
105
+ switchToBlockType(
106
+ createBlock( 'core/list', attributes, innerBlocks ),
107
+ 'core/paragraph'
108
+ ),
109
+ block
110
+ );
111
+ },
112
+ } ) ),
113
+ ],
114
+ };
115
+
116
+ export default transforms;
@@ -0,0 +1,26 @@
1
+ {
2
+ "$schema": "https://schemas.wp.org/trunk/block.json",
3
+ "apiVersion": 2,
4
+ "name": "core/list-item",
5
+ "title": "List item",
6
+ "category": "text",
7
+ "parent": [ "core/list" ],
8
+ "description": "Create a list item.",
9
+ "textdomain": "default",
10
+ "attributes": {
11
+ "placeholder": {
12
+ "type": "string"
13
+ },
14
+ "content": {
15
+ "type": "string",
16
+ "source": "html",
17
+ "selector": "li",
18
+ "default": "",
19
+ "__experimentalRole": "content"
20
+ }
21
+ },
22
+ "supports": {
23
+ "className": false,
24
+ "__experimentalSelector": "li"
25
+ }
26
+ }
@@ -0,0 +1,47 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import {
5
+ RichText,
6
+ useBlockProps,
7
+ useInnerBlocksProps,
8
+ } from '@wordpress/block-editor';
9
+ import { __ } from '@wordpress/i18n';
10
+ import { createBlock } from '@wordpress/blocks';
11
+
12
+ export default function ListItemEdit( {
13
+ name,
14
+ attributes,
15
+ setAttributes,
16
+ mergeBlocks,
17
+ onReplace,
18
+ } ) {
19
+ const blockProps = useBlockProps();
20
+ const innerBlocksProps = useInnerBlocksProps( blockProps, {
21
+ allowedBlocks: [ 'core/list' ],
22
+ } );
23
+
24
+ return (
25
+ <li { ...innerBlocksProps }>
26
+ <RichText
27
+ identifier="content"
28
+ tagName="div"
29
+ onChange={ ( nextContent ) =>
30
+ setAttributes( { content: nextContent } )
31
+ }
32
+ value={ attributes.content }
33
+ aria-label={ __( 'List text' ) }
34
+ placeholder={ attributes.placeholder || __( 'List' ) }
35
+ onSplit={ ( value ) =>
36
+ createBlock( name, {
37
+ ...attributes,
38
+ content: value,
39
+ } )
40
+ }
41
+ onMerge={ mergeBlocks }
42
+ onReplace={ onReplace }
43
+ />
44
+ { innerBlocksProps.children }
45
+ </li>
46
+ );
47
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { list as icon } from '@wordpress/icons';
5
+
6
+ /**
7
+ * Internal dependencies
8
+ */
9
+ import metadata from './block.json';
10
+ import edit from './edit';
11
+ import save from './save';
12
+
13
+ const { name } = metadata;
14
+
15
+ export { metadata, name };
16
+
17
+ export const settings = {
18
+ icon,
19
+ edit,
20
+ save,
21
+ merge( attributes, attributesToMerge ) {
22
+ return {
23
+ ...attributes,
24
+ content: attributes.content + attributesToMerge.content,
25
+ };
26
+ },
27
+ };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { InnerBlocks, RichText, useBlockProps } from '@wordpress/block-editor';
5
+
6
+ export default function save( { attributes } ) {
7
+ return (
8
+ <li { ...useBlockProps.save() }>
9
+ <RichText.Content value={ attributes.content } />
10
+ <InnerBlocks.Content />
11
+ </li>
12
+ );
13
+ }
@@ -161,7 +161,7 @@ function MediaTextEdit( { attributes, isSelected, setAttributes } ) {
161
161
  const image = useSelect(
162
162
  ( select ) =>
163
163
  mediaId && isSelected
164
- ? select( coreStore ).getMedia( mediaId )
164
+ ? select( coreStore ).getMedia( mediaId, { context: 'view' } )
165
165
  : null,
166
166
  [ isSelected, mediaId ]
167
167
  );
@@ -361,10 +361,14 @@ function block_core_navigation_get_fallback_blocks() {
361
361
  */
362
362
  function render_block_core_navigation( $attributes, $content, $block ) {
363
363
 
364
+ static $seen_menu_names = array();
365
+
364
366
  // Flag used to indicate whether the rendered output is considered to be
365
367
  // a fallback (i.e. the block has no menu associated with it).
366
368
  $is_fallback = false;
367
369
 
370
+ $nav_menu_name = '';
371
+
368
372
  /**
369
373
  * Deprecated:
370
374
  * The rgbTextColor and rgbBackgroundColor attributes
@@ -428,6 +432,14 @@ function render_block_core_navigation( $attributes, $content, $block ) {
428
432
  return '';
429
433
  }
430
434
 
435
+ $nav_menu_name = $navigation_post->post_title;
436
+
437
+ if ( isset( $seen_menu_names[ $nav_menu_name ] ) ) {
438
+ ++$seen_menu_names[ $nav_menu_name ];
439
+ } else {
440
+ $seen_menu_names[ $nav_menu_name ] = 1;
441
+ }
442
+
431
443
  $parsed_blocks = parse_blocks( $navigation_post->post_content );
432
444
 
433
445
  // 'parse_blocks' includes a null block with '\n\n' as the content when
@@ -508,10 +520,18 @@ function render_block_core_navigation( $attributes, $content, $block ) {
508
520
 
509
521
  $block_styles = isset( $attributes['styles'] ) ? $attributes['styles'] : '';
510
522
 
523
+ // If the menu name has been used previously then append an ID
524
+ // to the name to ensure uniqueness across a given post.
525
+ if ( isset( $seen_menu_names[ $nav_menu_name ] ) && $seen_menu_names[ $nav_menu_name ] > 1 ) {
526
+ $count = $seen_menu_names[ $nav_menu_name ];
527
+ $nav_menu_name = $nav_menu_name . ' ' . ( $count );
528
+ }
529
+
511
530
  $wrapper_attributes = get_block_wrapper_attributes(
512
531
  array(
513
- 'class' => implode( ' ', $classes ),
514
- 'style' => $block_styles . $colors['inline_styles'] . $font_sizes['inline_styles'],
532
+ 'class' => implode( ' ', $classes ),
533
+ 'style' => $block_styles . $colors['inline_styles'] . $font_sizes['inline_styles'],
534
+ 'aria-label' => $nav_menu_name,
515
535
  )
516
536
  );
517
537