@wordpress/block-library 9.36.1-next.8b30e05b0.0 → 9.37.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 (302) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/audio/index.js +1 -1
  3. package/build/audio/index.js.map +2 -2
  4. package/build/avatar/edit.js +13 -38
  5. package/build/avatar/edit.js.map +2 -2
  6. package/build/breadcrumbs/block.json +3 -2
  7. package/build/breadcrumbs/edit.js +18 -18
  8. package/build/breadcrumbs/edit.js.map +2 -2
  9. package/build/button/block.json +2 -3
  10. package/build/button/deprecated.js +203 -0
  11. package/build/button/deprecated.js.map +3 -3
  12. package/build/button/edit.js +13 -24
  13. package/build/button/edit.js.map +3 -3
  14. package/build/button/index.js +1 -1
  15. package/build/button/index.js.map +2 -2
  16. package/build/button/save.js +0 -2
  17. package/build/button/save.js.map +2 -2
  18. package/build/code/index.js +1 -1
  19. package/build/code/index.js.map +2 -2
  20. package/build/comments-pagination-numbers/block.json +7 -0
  21. package/build/cover/index.js +2 -2
  22. package/build/cover/index.js.map +2 -2
  23. package/build/details/index.js +1 -1
  24. package/build/details/index.js.map +2 -2
  25. package/build/file/index.js +1 -1
  26. package/build/file/index.js.map +2 -2
  27. package/build/freeform/block.json +0 -1
  28. package/build/gallery/edit.js +1 -1
  29. package/build/gallery/edit.js.map +2 -2
  30. package/build/gallery/transforms.js +7 -3
  31. package/build/gallery/transforms.js.map +2 -2
  32. package/build/heading/index.js +1 -1
  33. package/build/heading/index.js.map +2 -2
  34. package/build/html/modal.js +18 -7
  35. package/build/html/modal.js.map +2 -2
  36. package/build/image/index.js +1 -1
  37. package/build/image/index.js.map +2 -2
  38. package/build/index.js +9 -3
  39. package/build/index.js.map +2 -2
  40. package/build/list-item/index.js +1 -1
  41. package/build/list-item/index.js.map +2 -2
  42. package/build/math/edit.js +14 -2
  43. package/build/math/edit.js.map +2 -2
  44. package/build/media-text/index.js +1 -1
  45. package/build/media-text/index.js.map +2 -2
  46. package/build/more/index.js +1 -1
  47. package/build/more/index.js.map +2 -2
  48. package/build/navigation/block.json +3 -0
  49. package/build/navigation/edit/index.js +57 -83
  50. package/build/navigation/edit/index.js.map +3 -3
  51. package/build/navigation/edit/overlay-menu-preview-button.js +96 -0
  52. package/build/navigation/edit/overlay-menu-preview-button.js.map +7 -0
  53. package/build/navigation/edit/overlay-menu-preview-controls.js +90 -0
  54. package/build/navigation/edit/overlay-menu-preview-controls.js.map +7 -0
  55. package/build/navigation/edit/overlay-panel.js +86 -0
  56. package/build/navigation/edit/overlay-panel.js.map +7 -0
  57. package/build/navigation/edit/overlay-template-part-selector.js +163 -0
  58. package/build/navigation/edit/overlay-template-part-selector.js.map +7 -0
  59. package/build/navigation/edit/overlay-visibility-control.js +54 -0
  60. package/build/navigation/edit/overlay-visibility-control.js.map +7 -0
  61. package/build/navigation/edit/responsive-wrapper.js +14 -2
  62. package/build/navigation/edit/responsive-wrapper.js.map +2 -2
  63. package/build/navigation-link/edit.js +7 -21
  64. package/build/navigation-link/edit.js.map +2 -2
  65. package/build/navigation-link/index.js +1 -1
  66. package/build/navigation-link/index.js.map +2 -2
  67. package/build/navigation-link/shared/index.js +5 -2
  68. package/build/navigation-link/shared/index.js.map +2 -2
  69. package/build/navigation-link/shared/use-handle-link-change.js +84 -0
  70. package/build/navigation-link/shared/use-handle-link-change.js.map +7 -0
  71. package/build/navigation-submenu/index.js +1 -1
  72. package/build/navigation-submenu/index.js.map +2 -2
  73. package/build/page-list-item/edit.js +4 -3
  74. package/build/page-list-item/edit.js.map +2 -2
  75. package/build/paragraph/index.js +1 -1
  76. package/build/paragraph/index.js.map +2 -2
  77. package/build/post-title/edit.js +6 -4
  78. package/build/post-title/edit.js.map +2 -2
  79. package/build/preformatted/index.js +1 -1
  80. package/build/preformatted/index.js.map +2 -2
  81. package/build/pullquote/index.js +1 -1
  82. package/build/pullquote/index.js.map +2 -2
  83. package/build/query/edit/inspector-controls/author-control.js +0 -1
  84. package/build/query/edit/inspector-controls/author-control.js.map +2 -2
  85. package/build/query/edit/inspector-controls/format-controls.js +0 -1
  86. package/build/query/edit/inspector-controls/format-controls.js.map +2 -2
  87. package/build/query/edit/inspector-controls/parent-control.js +1 -2
  88. package/build/query/edit/inspector-controls/parent-control.js.map +2 -2
  89. package/build/query/edit/inspector-controls/taxonomy-controls.js +0 -1
  90. package/build/query/edit/inspector-controls/taxonomy-controls.js.map +2 -2
  91. package/build/search/index.js +1 -1
  92. package/build/search/index.js.map +2 -2
  93. package/build/social-link/index.js +1 -1
  94. package/build/social-link/index.js.map +2 -2
  95. package/build/template-part/edit/index.js +3 -31
  96. package/build/template-part/edit/index.js.map +2 -2
  97. package/build/template-part/edit/utils/get-template-part-icon.js +9 -4
  98. package/build/template-part/edit/utils/get-template-part-icon.js.map +3 -3
  99. package/build/template-part/edit/utils/hooks.js +3 -2
  100. package/build/template-part/edit/utils/hooks.js.map +2 -2
  101. package/build/terms-query/edit/inspector-controls/include-control.js +0 -1
  102. package/build/terms-query/edit/inspector-controls/include-control.js.map +2 -2
  103. package/build/utils/deprecated-text-align-attributes.js +70 -0
  104. package/build/utils/deprecated-text-align-attributes.js.map +7 -0
  105. package/build/utils/migrate-text-align.js +42 -0
  106. package/build/utils/migrate-text-align.js.map +7 -0
  107. package/build/verse/index.js +1 -1
  108. package/build/verse/index.js.map +2 -2
  109. package/build/video/index.js +1 -1
  110. package/build/video/index.js.map +2 -2
  111. package/build-module/audio/index.js +1 -1
  112. package/build-module/audio/index.js.map +2 -2
  113. package/build-module/avatar/edit.js +13 -38
  114. package/build-module/avatar/edit.js.map +2 -2
  115. package/build-module/breadcrumbs/block.json +3 -2
  116. package/build-module/breadcrumbs/edit.js +18 -18
  117. package/build-module/breadcrumbs/edit.js.map +2 -2
  118. package/build-module/button/block.json +2 -3
  119. package/build-module/button/deprecated.js +205 -1
  120. package/build-module/button/deprecated.js.map +2 -2
  121. package/build-module/button/edit.js +13 -25
  122. package/build-module/button/edit.js.map +2 -2
  123. package/build-module/button/index.js +1 -1
  124. package/build-module/button/index.js.map +2 -2
  125. package/build-module/button/save.js +0 -2
  126. package/build-module/button/save.js.map +2 -2
  127. package/build-module/code/index.js +1 -1
  128. package/build-module/code/index.js.map +2 -2
  129. package/build-module/comments-pagination-numbers/block.json +7 -0
  130. package/build-module/cover/index.js +2 -2
  131. package/build-module/cover/index.js.map +2 -2
  132. package/build-module/details/index.js +1 -1
  133. package/build-module/details/index.js.map +2 -2
  134. package/build-module/file/index.js +1 -1
  135. package/build-module/file/index.js.map +2 -2
  136. package/build-module/freeform/block.json +0 -1
  137. package/build-module/gallery/edit.js +1 -1
  138. package/build-module/gallery/edit.js.map +2 -2
  139. package/build-module/gallery/transforms.js +7 -3
  140. package/build-module/gallery/transforms.js.map +2 -2
  141. package/build-module/heading/index.js +1 -1
  142. package/build-module/heading/index.js.map +2 -2
  143. package/build-module/html/modal.js +19 -7
  144. package/build-module/html/modal.js.map +2 -2
  145. package/build-module/image/index.js +1 -1
  146. package/build-module/image/index.js.map +2 -2
  147. package/build-module/index.js +9 -3
  148. package/build-module/index.js.map +2 -2
  149. package/build-module/list-item/index.js +1 -1
  150. package/build-module/list-item/index.js.map +2 -2
  151. package/build-module/math/edit.js +15 -3
  152. package/build-module/math/edit.js.map +2 -2
  153. package/build-module/media-text/index.js +1 -1
  154. package/build-module/media-text/index.js.map +2 -2
  155. package/build-module/more/index.js +1 -1
  156. package/build-module/more/index.js.map +2 -2
  157. package/build-module/navigation/block.json +3 -0
  158. package/build-module/navigation/edit/index.js +58 -88
  159. package/build-module/navigation/edit/index.js.map +2 -2
  160. package/build-module/navigation/edit/overlay-menu-preview-button.js +65 -0
  161. package/build-module/navigation/edit/overlay-menu-preview-button.js.map +7 -0
  162. package/build-module/navigation/edit/overlay-menu-preview-controls.js +64 -0
  163. package/build-module/navigation/edit/overlay-menu-preview-controls.js.map +7 -0
  164. package/build-module/navigation/edit/overlay-panel.js +58 -0
  165. package/build-module/navigation/edit/overlay-panel.js.map +7 -0
  166. package/build-module/navigation/edit/overlay-template-part-selector.js +142 -0
  167. package/build-module/navigation/edit/overlay-template-part-selector.js.map +7 -0
  168. package/build-module/navigation/edit/overlay-visibility-control.js +36 -0
  169. package/build-module/navigation/edit/overlay-visibility-control.js.map +7 -0
  170. package/build-module/navigation/edit/responsive-wrapper.js +14 -2
  171. package/build-module/navigation/edit/responsive-wrapper.js.map +2 -2
  172. package/build-module/navigation-link/edit.js +9 -23
  173. package/build-module/navigation-link/edit.js.map +2 -2
  174. package/build-module/navigation-link/index.js +1 -1
  175. package/build-module/navigation-link/index.js.map +2 -2
  176. package/build-module/navigation-link/shared/index.js +3 -1
  177. package/build-module/navigation-link/shared/index.js.map +2 -2
  178. package/build-module/navigation-link/shared/use-handle-link-change.js +59 -0
  179. package/build-module/navigation-link/shared/use-handle-link-change.js.map +7 -0
  180. package/build-module/navigation-submenu/index.js +1 -1
  181. package/build-module/navigation-submenu/index.js.map +2 -2
  182. package/build-module/page-list-item/edit.js +4 -3
  183. package/build-module/page-list-item/edit.js.map +2 -2
  184. package/build-module/paragraph/index.js +1 -1
  185. package/build-module/paragraph/index.js.map +2 -2
  186. package/build-module/post-title/edit.js +6 -4
  187. package/build-module/post-title/edit.js.map +2 -2
  188. package/build-module/preformatted/index.js +1 -1
  189. package/build-module/preformatted/index.js.map +2 -2
  190. package/build-module/pullquote/index.js +1 -1
  191. package/build-module/pullquote/index.js.map +2 -2
  192. package/build-module/query/edit/inspector-controls/author-control.js +0 -1
  193. package/build-module/query/edit/inspector-controls/author-control.js.map +2 -2
  194. package/build-module/query/edit/inspector-controls/format-controls.js +0 -1
  195. package/build-module/query/edit/inspector-controls/format-controls.js.map +2 -2
  196. package/build-module/query/edit/inspector-controls/parent-control.js +1 -2
  197. package/build-module/query/edit/inspector-controls/parent-control.js.map +2 -2
  198. package/build-module/query/edit/inspector-controls/taxonomy-controls.js +0 -1
  199. package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +2 -2
  200. package/build-module/search/index.js +1 -1
  201. package/build-module/search/index.js.map +2 -2
  202. package/build-module/social-link/index.js +1 -1
  203. package/build-module/social-link/index.js.map +2 -2
  204. package/build-module/template-part/edit/index.js +3 -31
  205. package/build-module/template-part/edit/index.js.map +2 -2
  206. package/build-module/template-part/edit/utils/get-template-part-icon.js +10 -4
  207. package/build-module/template-part/edit/utils/get-template-part-icon.js.map +2 -2
  208. package/build-module/template-part/edit/utils/hooks.js +3 -2
  209. package/build-module/template-part/edit/utils/hooks.js.map +2 -2
  210. package/build-module/terms-query/edit/inspector-controls/include-control.js +0 -1
  211. package/build-module/terms-query/edit/inspector-controls/include-control.js.map +2 -2
  212. package/build-module/utils/deprecated-text-align-attributes.js +39 -0
  213. package/build-module/utils/deprecated-text-align-attributes.js.map +7 -0
  214. package/build-module/utils/migrate-text-align.js +21 -0
  215. package/build-module/utils/migrate-text-align.js.map +7 -0
  216. package/build-module/verse/index.js +1 -1
  217. package/build-module/verse/index.js.map +2 -2
  218. package/build-module/video/index.js +1 -1
  219. package/build-module/video/index.js.map +2 -2
  220. package/build-style/accordion-heading/style-rtl.css +2 -18
  221. package/build-style/accordion-heading/style.css +2 -18
  222. package/build-style/classic-rtl.css +24 -0
  223. package/build-style/classic.css +24 -0
  224. package/build-style/common-rtl.css +4 -4
  225. package/build-style/common.css +4 -0
  226. package/build-style/editor-rtl.css +5 -0
  227. package/build-style/editor.css +5 -0
  228. package/build-style/navigation/editor-rtl.css +5 -0
  229. package/build-style/navigation/editor.css +5 -0
  230. package/build-style/style-rtl.css +8 -22
  231. package/build-style/style.css +8 -18
  232. package/build-style/verse/style-rtl.css +2 -0
  233. package/build-style/verse/style.css +2 -0
  234. package/package.json +40 -38
  235. package/src/accordion-heading/style.scss +2 -30
  236. package/src/audio/index.js +1 -1
  237. package/src/avatar/edit.js +68 -83
  238. package/src/breadcrumbs/block.json +3 -2
  239. package/src/breadcrumbs/edit.js +18 -18
  240. package/src/breadcrumbs/index.php +38 -17
  241. package/src/button/block.json +2 -3
  242. package/src/button/deprecated.js +214 -0
  243. package/src/button/edit.js +2 -11
  244. package/src/button/index.js +1 -1
  245. package/src/button/save.js +0 -2
  246. package/src/classic.scss +38 -0
  247. package/src/code/index.js +1 -1
  248. package/src/comments-pagination-numbers/block.json +7 -0
  249. package/src/common.scss +4 -0
  250. package/src/cover/index.js +2 -2
  251. package/src/details/index.js +1 -1
  252. package/src/file/index.js +1 -1
  253. package/src/freeform/block.json +0 -1
  254. package/src/gallery/edit.js +4 -1
  255. package/src/gallery/transforms.js +6 -2
  256. package/src/heading/index.js +1 -1
  257. package/src/html/modal.js +39 -20
  258. package/src/image/index.js +1 -1
  259. package/src/index.js +9 -3
  260. package/src/list-item/index.js +1 -1
  261. package/src/math/edit.js +15 -3
  262. package/src/media-text/index.js +1 -1
  263. package/src/more/index.js +1 -1
  264. package/src/navigation/block.json +3 -0
  265. package/src/navigation/edit/index.js +77 -82
  266. package/src/navigation/edit/overlay-menu-preview-button.js +82 -0
  267. package/src/navigation/edit/overlay-menu-preview-controls.js +65 -0
  268. package/src/navigation/edit/overlay-panel.js +78 -0
  269. package/src/navigation/edit/overlay-template-part-selector.js +198 -0
  270. package/src/navigation/edit/overlay-visibility-control.js +40 -0
  271. package/src/navigation/edit/responsive-wrapper.js +16 -1
  272. package/src/navigation/edit/test/overlay-template-part-selector.js +461 -0
  273. package/src/navigation/editor.scss +5 -0
  274. package/src/navigation-link/edit.js +9 -26
  275. package/src/navigation-link/index.js +1 -1
  276. package/src/navigation-link/shared/index.js +1 -0
  277. package/src/navigation-link/shared/test/use-handle-link-change.test.js +804 -0
  278. package/src/navigation-link/shared/use-handle-link-change.js +91 -0
  279. package/src/navigation-submenu/index.js +1 -1
  280. package/src/page-list/index.php +3 -4
  281. package/src/page-list-item/edit.js +4 -3
  282. package/src/paragraph/index.js +1 -1
  283. package/src/post-title/edit.js +8 -4
  284. package/src/post-title/index.php +1 -1
  285. package/src/preformatted/index.js +1 -1
  286. package/src/pullquote/index.js +1 -1
  287. package/src/query/edit/inspector-controls/author-control.js +0 -1
  288. package/src/query/edit/inspector-controls/format-controls.js +0 -1
  289. package/src/query/edit/inspector-controls/parent-control.js +0 -1
  290. package/src/query/edit/inspector-controls/taxonomy-controls.js +0 -1
  291. package/src/search/index.js +1 -1
  292. package/src/social-link/index.js +1 -1
  293. package/src/template-part/edit/index.js +5 -41
  294. package/src/template-part/edit/utils/get-template-part-icon.js +23 -4
  295. package/src/template-part/edit/utils/hooks.js +10 -2
  296. package/src/terms-query/edit/inspector-controls/include-control.js +0 -1
  297. package/src/utils/deprecated-text-align-attributes.js +45 -0
  298. package/src/utils/migrate-text-align.js +22 -0
  299. package/src/verse/index.js +1 -1
  300. package/src/verse/style.scss +4 -0
  301. package/src/video/index.js +1 -1
  302. package/tsconfig.tsbuildinfo +1 -1
@@ -16,6 +16,7 @@ import {
16
16
  __experimentalGetSpacingClassesAndStyles as getSpacingClassesAndStyles,
17
17
  __experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,
18
18
  __experimentalGetElementClassName,
19
+ getTypographyClassesAndStyles,
19
20
  } from '@wordpress/block-editor';
20
21
  import { compose } from '@wordpress/compose';
21
22
 
@@ -23,6 +24,7 @@ import { compose } from '@wordpress/compose';
23
24
  * Internal dependencies
24
25
  */
25
26
  import migrateFontFamily from '../utils/migrate-font-family';
27
+ import migrateTextAlign from '../utils/migrate-text-align';
26
28
 
27
29
  const migrateBorderRadius = ( attributes ) => {
28
30
  const { borderRadius, ...newAttributes } = attributes;
@@ -134,6 +136,217 @@ const blockAttributes = {
134
136
  },
135
137
  };
136
138
 
139
+ const v13 = {
140
+ attributes: {
141
+ tagName: {
142
+ type: 'string',
143
+ enum: [ 'a', 'button' ],
144
+ default: 'a',
145
+ },
146
+ type: {
147
+ type: 'string',
148
+ default: 'button',
149
+ },
150
+ textAlign: {
151
+ type: 'string',
152
+ },
153
+ url: {
154
+ type: 'string',
155
+ source: 'attribute',
156
+ selector: 'a',
157
+ attribute: 'href',
158
+ role: 'content',
159
+ },
160
+ title: {
161
+ type: 'string',
162
+ source: 'attribute',
163
+ selector: 'a,button',
164
+ attribute: 'title',
165
+ role: 'content',
166
+ },
167
+ text: {
168
+ type: 'rich-text',
169
+ source: 'rich-text',
170
+ selector: 'a,button',
171
+ role: 'content',
172
+ },
173
+ linkTarget: {
174
+ type: 'string',
175
+ source: 'attribute',
176
+ selector: 'a',
177
+ attribute: 'target',
178
+ role: 'content',
179
+ },
180
+ rel: {
181
+ type: 'string',
182
+ source: 'attribute',
183
+ selector: 'a',
184
+ attribute: 'rel',
185
+ role: 'content',
186
+ },
187
+ placeholder: {
188
+ type: 'string',
189
+ },
190
+ backgroundColor: {
191
+ type: 'string',
192
+ },
193
+ textColor: {
194
+ type: 'string',
195
+ },
196
+ gradient: {
197
+ type: 'string',
198
+ },
199
+ width: {
200
+ type: 'number',
201
+ },
202
+ },
203
+ supports: {
204
+ anchor: true,
205
+ align: true,
206
+ alignWide: false,
207
+ color: {
208
+ __experimentalSkipSerialization: true,
209
+ gradients: true,
210
+ __experimentalDefaultControls: {
211
+ background: true,
212
+ text: true,
213
+ },
214
+ },
215
+ typography: {
216
+ __experimentalSkipSerialization: [
217
+ 'fontSize',
218
+ 'lineHeight',
219
+ 'fontFamily',
220
+ 'fontWeight',
221
+ 'fontStyle',
222
+ 'textTransform',
223
+ 'textDecoration',
224
+ 'letterSpacing',
225
+ ],
226
+ fontSize: true,
227
+ lineHeight: true,
228
+ __experimentalFontFamily: true,
229
+ __experimentalFontWeight: true,
230
+ __experimentalFontStyle: true,
231
+ __experimentalTextTransform: true,
232
+ __experimentalTextDecoration: true,
233
+ __experimentalLetterSpacing: true,
234
+ __experimentalWritingMode: true,
235
+ __experimentalDefaultControls: {
236
+ fontSize: true,
237
+ },
238
+ },
239
+ reusable: false,
240
+ shadow: {
241
+ __experimentalSkipSerialization: true,
242
+ },
243
+ spacing: {
244
+ __experimentalSkipSerialization: true,
245
+ padding: [ 'horizontal', 'vertical' ],
246
+ __experimentalDefaultControls: {
247
+ padding: true,
248
+ },
249
+ },
250
+ __experimentalBorder: {
251
+ color: true,
252
+ radius: true,
253
+ style: true,
254
+ width: true,
255
+ __experimentalSkipSerialization: true,
256
+ __experimentalDefaultControls: {
257
+ color: true,
258
+ radius: true,
259
+ style: true,
260
+ width: true,
261
+ },
262
+ },
263
+ interactivity: {
264
+ clientNavigation: true,
265
+ },
266
+ },
267
+ selectors: {
268
+ root: '.wp-block-button .wp-block-button__link',
269
+ typography: {
270
+ writingMode: '.wp-block-button',
271
+ },
272
+ },
273
+ save( { attributes, className } ) {
274
+ const {
275
+ tagName,
276
+ type,
277
+ textAlign,
278
+ fontSize,
279
+ linkTarget,
280
+ rel,
281
+ style,
282
+ text,
283
+ title,
284
+ url,
285
+ width,
286
+ } = attributes;
287
+
288
+ const TagName = tagName || 'a';
289
+ const isButtonTag = 'button' === TagName;
290
+ const buttonType = type || 'button';
291
+ const borderProps = getBorderClassesAndStyles( attributes );
292
+ const colorProps = getColorClassesAndStyles( attributes );
293
+ const spacingProps = getSpacingClassesAndStyles( attributes );
294
+ const shadowProps = getShadowClassesAndStyles( attributes );
295
+ const typographyProps = getTypographyClassesAndStyles( attributes );
296
+ const buttonClasses = clsx(
297
+ 'wp-block-button__link',
298
+ colorProps.className,
299
+ borderProps.className,
300
+ typographyProps.className,
301
+ {
302
+ [ `has-text-align-${ textAlign }` ]: textAlign,
303
+ // For backwards compatibility add style that isn't provided via
304
+ // block support.
305
+ 'no-border-radius': style?.border?.radius === 0,
306
+ [ `has-custom-font-size` ]:
307
+ fontSize || style?.typography?.fontSize,
308
+ },
309
+ __experimentalGetElementClassName( 'button' )
310
+ );
311
+ const buttonStyle = {
312
+ ...borderProps.style,
313
+ ...colorProps.style,
314
+ ...spacingProps.style,
315
+ ...shadowProps.style,
316
+ ...typographyProps.style,
317
+ writingMode: undefined,
318
+ };
319
+
320
+ // The use of a `title` attribute here is soft-deprecated, but still applied
321
+ // if it had already been assigned, for the sake of backward-compatibility.
322
+ // A title will no longer be assigned for new or updated button block links.
323
+
324
+ const wrapperClasses = clsx( className, {
325
+ [ `has-custom-width wp-block-button__width-${ width }` ]: width,
326
+ } );
327
+
328
+ return (
329
+ <div { ...useBlockProps.save( { className: wrapperClasses } ) }>
330
+ <RichText.Content
331
+ tagName={ TagName }
332
+ type={ isButtonTag ? buttonType : null }
333
+ className={ buttonClasses }
334
+ href={ isButtonTag ? null : url }
335
+ title={ title }
336
+ style={ buttonStyle }
337
+ value={ text }
338
+ target={ isButtonTag ? null : linkTarget }
339
+ rel={ isButtonTag ? null : rel }
340
+ />
341
+ </div>
342
+ );
343
+ },
344
+ isEligible( attributes ) {
345
+ return !! attributes.textAlign;
346
+ },
347
+ migrate: migrateTextAlign,
348
+ };
349
+
137
350
  const v12 = {
138
351
  attributes: {
139
352
  tagName: {
@@ -587,6 +800,7 @@ const v10 = {
587
800
  };
588
801
 
589
802
  const deprecated = [
803
+ v13,
590
804
  v12,
591
805
  v11,
592
806
  v10,
@@ -11,6 +11,7 @@ import { getUpdatedLinkAttributes } from './get-updated-link-attributes';
11
11
  import removeAnchorTag from '../utils/remove-anchor-tag';
12
12
  import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
13
13
  import { unlock } from '../lock-unlock';
14
+ import useDeprecatedTextAlign from '../utils/deprecated-text-align-attributes';
14
15
 
15
16
  /**
16
17
  * WordPress dependencies
@@ -34,7 +35,6 @@ import {
34
35
  __experimentalToggleGroupControlOption as ToggleGroupControlOption,
35
36
  } from '@wordpress/components';
36
37
  import {
37
- AlignmentControl,
38
38
  BlockControls,
39
39
  InspectorControls,
40
40
  RichText,
@@ -186,7 +186,6 @@ function ButtonEdit( props ) {
186
186
  } = props;
187
187
  const {
188
188
  tagName,
189
- textAlign,
190
189
  linkTarget,
191
190
  placeholder,
192
191
  rel,
@@ -196,6 +195,7 @@ function ButtonEdit( props ) {
196
195
  width,
197
196
  metadata,
198
197
  } = attributes;
198
+ useDeprecatedTextAlign( props );
199
199
 
200
200
  const TagName = tagName || 'a';
201
201
 
@@ -361,7 +361,6 @@ function ButtonEdit( props ) {
361
361
  borderProps.className,
362
362
  typographyProps.className,
363
363
  {
364
- [ `has-text-align-${ textAlign }` ]: textAlign,
365
364
  // For backwards compatibility add style that isn't
366
365
  // provided via block support.
367
366
  'no-border-radius': style?.border?.radius === 0,
@@ -385,14 +384,6 @@ function ButtonEdit( props ) {
385
384
  </div>
386
385
  { hasBlockControls && (
387
386
  <BlockControls group="block">
388
- { hasNonContentControls && (
389
- <AlignmentControl
390
- value={ textAlign }
391
- onChange={ ( nextAlign ) => {
392
- setAttributes( { textAlign: nextAlign } );
393
- } }
394
- />
395
- ) }
396
387
  { isLinkTag && ! lockUrlControls && (
397
388
  <ToolbarButton
398
389
  name="link"
@@ -38,7 +38,7 @@ export const settings = {
38
38
  } ),
39
39
  };
40
40
 
41
- if ( window.__experimentalContentOnlyPatternInsertion ) {
41
+ if ( window.__experimentalContentOnlyInspectorFields ) {
42
42
  settings[ fieldsKey ] = [
43
43
  {
44
44
  id: 'text',
@@ -21,7 +21,6 @@ export default function save( { attributes, className } ) {
21
21
  const {
22
22
  tagName,
23
23
  type,
24
- textAlign,
25
24
  fontSize,
26
25
  linkTarget,
27
26
  rel,
@@ -46,7 +45,6 @@ export default function save( { attributes, className } ) {
46
45
  borderProps.className,
47
46
  typographyProps.className,
48
47
  {
49
- [ `has-text-align-${ textAlign }` ]: textAlign,
50
48
  // For backwards compatibility add style that isn't provided via
51
49
  // block support.
52
50
  'no-border-radius': style?.border?.radius === 0,
package/src/classic.scss CHANGED
@@ -20,3 +20,41 @@
20
20
  background: #32373c;
21
21
  color: $white;
22
22
  }
23
+
24
+ // These rules are needed to enforce the default styling of
25
+ // the Accordion Heading block in the classic theme.
26
+ .wp-block-accordion-heading {
27
+ // Heading elements may have default margins applied, so those
28
+ // styles need to be reset.
29
+ margin: 0;
30
+ }
31
+
32
+ .wp-block-accordion-heading__toggle {
33
+ // Button elements can have colors applied with high CSS specificity,
34
+ // and since this specificity is impossible to predict, we use
35
+ // `!important` to reset the color.
36
+ background-color: inherit !important;
37
+ color: inherit !important;
38
+
39
+ &:not(:focus-visible) {
40
+ outline: none;
41
+ }
42
+
43
+ &:hover,
44
+ &:focus {
45
+ // Sometimes styles are applied when the button element is
46
+ // hovered over or focused. This isn't expected for accordion
47
+ // toggle buttons, so reset those styles here.
48
+ text-decoration: none;
49
+ background-color: inherit !important;
50
+ box-shadow: none;
51
+ color: inherit;
52
+ border: none;
53
+ padding: var(--wp--preset--spacing--20, 1em) 0;
54
+ }
55
+
56
+ &:focus-visible {
57
+ outline-offset: 0;
58
+ outline: auto;
59
+ }
60
+ }
package/src/code/index.js CHANGED
@@ -43,7 +43,7 @@ export const settings = {
43
43
  save,
44
44
  };
45
45
 
46
- if ( window.__experimentalContentOnlyPatternInsertion ) {
46
+ if ( window.__experimentalContentOnlyInspectorFields ) {
47
47
  settings[ fieldsKey ] = [
48
48
  {
49
49
  id: 'content',
@@ -33,6 +33,13 @@
33
33
  },
34
34
  "interactivity": {
35
35
  "clientNavigation": true
36
+ },
37
+ "spacing": {
38
+ "margin": true,
39
+ "padding": true,
40
+ "__experimentalDefaultControls": {
41
+ "padding": true
42
+ }
36
43
  }
37
44
  }
38
45
  }
package/src/common.scss CHANGED
@@ -128,12 +128,14 @@ html :where([style*="border-top-color"]) {
128
128
  border-top-style: solid;
129
129
  }
130
130
  html :where([style*="border-right-color"]) {
131
+ /*rtl:ignore*/
131
132
  border-right-style: solid;
132
133
  }
133
134
  html :where([style*="border-bottom-color"]) {
134
135
  border-bottom-style: solid;
135
136
  }
136
137
  html :where([style*="border-left-color"]) {
138
+ /*rtl:ignore*/
137
139
  border-left-style: solid;
138
140
  }
139
141
 
@@ -144,12 +146,14 @@ html :where([style*="border-top-width"]) {
144
146
  border-top-style: solid;
145
147
  }
146
148
  html :where([style*="border-right-width"]) {
149
+ /*rtl:ignore*/
147
150
  border-right-style: solid;
148
151
  }
149
152
  html :where([style*="border-bottom-width"]) {
150
153
  border-bottom-style: solid;
151
154
  }
152
155
  html :where([style*="border-left-width"]) {
156
+ /*rtl:ignore*/
153
157
  border-left-style: solid;
154
158
  }
155
159
 
@@ -56,7 +56,7 @@ export const settings = {
56
56
  variations,
57
57
  };
58
58
 
59
- if ( window.__experimentalContentOnlyPatternInsertion ) {
59
+ if ( window.__experimentalContentOnlyInspectorFields ) {
60
60
  settings[ fieldsKey ] = [
61
61
  {
62
62
  id: 'background',
@@ -78,7 +78,7 @@ if ( window.__experimentalContentOnlyPatternInsertion ) {
78
78
  },
79
79
  ];
80
80
  settings[ formKey ] = {
81
- fields: [ 'content' ],
81
+ fields: [ 'background' ],
82
82
  };
83
83
  }
84
84
 
@@ -65,7 +65,7 @@ export const settings = {
65
65
  transforms,
66
66
  };
67
67
 
68
- if ( window.__experimentalContentOnlyPatternInsertion ) {
68
+ if ( window.__experimentalContentOnlyInspectorFields ) {
69
69
  settings[ fieldsKey ] = [
70
70
  {
71
71
  id: 'summary',
package/src/file/index.js CHANGED
@@ -36,7 +36,7 @@ export const settings = {
36
36
  save,
37
37
  };
38
38
 
39
- if ( window.__experimentalContentOnlyPatternInsertion ) {
39
+ if ( window.__experimentalContentOnlyInspectorFields ) {
40
40
  settings[ fieldsKey ] = [
41
41
  {
42
42
  id: 'file',
@@ -13,7 +13,6 @@
13
13
  }
14
14
  },
15
15
  "supports": {
16
- "html": false,
17
16
  "className": false,
18
17
  "customClassName": false,
19
18
  "lock": false,
@@ -290,7 +290,10 @@ export default function GalleryEdit( props ) {
290
290
  ...newLinkTarget,
291
291
  className: newClassName,
292
292
  sizeSlug,
293
- caption: imageAttributes.caption || image.caption?.raw,
293
+ caption:
294
+ imageAttributes.caption.length > 0
295
+ ? imageAttributes.caption
296
+ : image.caption?.raw,
294
297
  alt: imageAttributes.alt || image.alt_text,
295
298
  aspectRatio: aspectRatio === 'auto' ? undefined : aspectRatio,
296
299
  };
@@ -155,7 +155,7 @@ const transforms = {
155
155
  {
156
156
  type: 'shortcode',
157
157
  tag: 'gallery',
158
- transform( { named: { ids, columns = 3, link, orderby } } ) {
158
+ transform( { named: { ids, columns = 3, link, orderby, size } } ) {
159
159
  const imageIds = parseShortcodeIds( ids ).map( ( id ) =>
160
160
  parseInt( id, 10 )
161
161
  );
@@ -173,9 +173,13 @@ const transforms = {
173
173
  columns: parseInt( columns, 10 ),
174
174
  linkTo,
175
175
  randomOrder: orderby === 'rand',
176
+ ...( size && { sizeSlug: size } ),
176
177
  },
177
178
  imageIds.map( ( imageId ) =>
178
- createBlock( 'core/image', { id: imageId } )
179
+ createBlock( 'core/image', {
180
+ id: imageId,
181
+ ...( size && { sizeSlug: size } ),
182
+ } )
179
183
  )
180
184
  );
181
185
 
@@ -73,7 +73,7 @@ export const settings = {
73
73
  variations,
74
74
  };
75
75
 
76
- if ( window.__experimentalContentOnlyPatternInsertion ) {
76
+ if ( window.__experimentalContentOnlyInspectorFields ) {
77
77
  settings[ fieldsKey ] = [
78
78
  {
79
79
  id: 'content',
package/src/html/modal.js CHANGED
@@ -8,6 +8,7 @@ import {
8
8
  Modal,
9
9
  Button,
10
10
  Flex,
11
+ Notice,
11
12
  privateApis as componentsPrivateApis,
12
13
  __experimentalHStack as HStack,
13
14
  __experimentalGrid as Grid,
@@ -48,8 +49,9 @@ export default function HTMLEditModal( {
48
49
  };
49
50
  }, [] );
50
51
 
51
- // Show JS tab if user has permission OR if block contains JavaScript
52
- const shouldShowJsTab = canUserUseUnfilteredHTML || js.trim() !== '';
52
+ // Determine if we should show a warning about CSS/JS content being stripped
53
+ const hasRestrictedContent =
54
+ ! canUserUseUnfilteredHTML && ( css.trim() || js.trim() );
53
55
 
54
56
  if ( ! isOpen ) {
55
57
  return null;
@@ -68,11 +70,13 @@ export default function HTMLEditModal( {
68
70
  setIsDirty( true );
69
71
  };
70
72
  const handleUpdate = () => {
73
+ // For users without unfiltered_html capability, strip CSS and JS content
74
+ // to prevent kses from leaving broken content
71
75
  setAttributes( {
72
76
  content: serializeContent( {
73
77
  html: editedHtml,
74
- css: editedCss,
75
- js: editedJs,
78
+ css: canUserUseUnfilteredHTML ? editedCss : '',
79
+ js: canUserUseUnfilteredHTML ? editedJs : '',
76
80
  } ),
77
81
  } );
78
82
  setIsDirty( false );
@@ -130,8 +134,10 @@ export default function HTMLEditModal( {
130
134
  <div>
131
135
  <Tabs.TabList>
132
136
  <Tabs.Tab tabId="html">HTML</Tabs.Tab>
133
- <Tabs.Tab tabId="css">CSS</Tabs.Tab>
134
- { shouldShowJsTab && (
137
+ { canUserUseUnfilteredHTML && (
138
+ <Tabs.Tab tabId="css">CSS</Tabs.Tab>
139
+ ) }
140
+ { canUserUseUnfilteredHTML && (
135
141
  <Tabs.Tab tabId="js">
136
142
  { __( 'JavaScript' ) }
137
143
  </Tabs.Tab>
@@ -148,6 +154,17 @@ export default function HTMLEditModal( {
148
154
  />
149
155
  </div>
150
156
  </HStack>
157
+ { hasRestrictedContent && (
158
+ <Notice
159
+ status="warning"
160
+ isDismissible={ false }
161
+ className="block-library-html__modal-notice"
162
+ >
163
+ { __(
164
+ 'This block contains CSS or JavaScript that will be removed when you save because you do not have permission to use unfiltered HTML.'
165
+ ) }
166
+ </Notice>
167
+ ) }
151
168
  <HStack
152
169
  alignment="stretch"
153
170
  justify="flex-start"
@@ -168,20 +185,22 @@ export default function HTMLEditModal( {
168
185
  className="block-library-html__modal-editor"
169
186
  />
170
187
  </Tabs.TabPanel>
171
- <Tabs.TabPanel
172
- tabId="css"
173
- focusable={ false }
174
- className="block-library-html__modal-tab"
175
- >
176
- <PlainText
177
- value={ editedCss }
178
- onChange={ handleCssChange }
179
- placeholder={ __( 'Write CSS…' ) }
180
- aria-label={ __( 'CSS' ) }
181
- className="block-library-html__modal-editor"
182
- />
183
- </Tabs.TabPanel>
184
- { shouldShowJsTab && (
188
+ { canUserUseUnfilteredHTML && (
189
+ <Tabs.TabPanel
190
+ tabId="css"
191
+ focusable={ false }
192
+ className="block-library-html__modal-tab"
193
+ >
194
+ <PlainText
195
+ value={ editedCss }
196
+ onChange={ handleCssChange }
197
+ placeholder={ __( 'Write CSS' ) }
198
+ aria-label={ __( 'CSS' ) }
199
+ className="block-library-html__modal-editor"
200
+ />
201
+ </Tabs.TabPanel>
202
+ ) }
203
+ { canUserUseUnfilteredHTML && (
185
204
  <Tabs.TabPanel
186
205
  tabId="js"
187
206
  focusable={ false }
@@ -66,7 +66,7 @@ export const settings = {
66
66
  deprecated,
67
67
  };
68
68
 
69
- if ( window.__experimentalContentOnlyPatternInsertion ) {
69
+ if ( window.__experimentalContentOnlyInspectorFields ) {
70
70
  settings[ fieldsKey ] = [
71
71
  {
72
72
  id: 'image',
package/src/index.js CHANGED
@@ -334,11 +334,17 @@ export const registerCoreBlocks = (
334
334
  const bootstrappedBlockType = unlock(
335
335
  select( blocksStore )
336
336
  ).getBootstrappedBlockType( blockName );
337
- const bootstrappedApiVersion = bootstrappedBlockType.apiVersion;
338
337
 
339
338
  registerBlockType( blockName, {
340
- title: blockName,
341
- ...( bootstrappedApiVersion < 3 && { apiVersion: 3 } ),
339
+ // Use all metadata from PHP registration,
340
+ // but fall back title to block name if not provided,
341
+ // ensure minimum apiVersion 3 for block wrapper support,
342
+ // and override with a ServerSideRender-based edit function.
343
+ ...bootstrappedBlockType,
344
+ title: bootstrappedBlockType?.title || blockName,
345
+ ...( ( bootstrappedBlockType?.apiVersion ?? 0 ) < 3 && {
346
+ apiVersion: 3,
347
+ } ),
342
348
  edit: function Edit( { attributes } ) {
343
349
  const blockProps = useBlockProps();
344
350
  const { content, status, error } = useServerSideRender( {
@@ -36,7 +36,7 @@ export const settings = {
36
36
  [ unlock( privateApis ).requiresWrapperOnCopy ]: true,
37
37
  };
38
38
 
39
- if ( window.__experimentalContentOnlyPatternInsertion ) {
39
+ if ( window.__experimentalContentOnlyInspectorFields ) {
40
40
  settings[ fieldsKey ] = [
41
41
  {
42
42
  id: 'content',