@wordpress/block-library 9.35.1-next.dc3f6d3c1.0 → 9.36.1-next.6deb34194.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 (315) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/accordion/view.js +46 -4
  3. package/build/accordion/view.js.map +2 -2
  4. package/build/accordion-heading/block.json +1 -1
  5. package/build/accordion-heading/deprecated.js +1 -1
  6. package/build/accordion-heading/deprecated.js.map +2 -2
  7. package/build/accordion-panel/block.json +1 -1
  8. package/build/audio/index.js +13 -10
  9. package/build/audio/index.js.map +3 -3
  10. package/build/avatar/edit.js +13 -38
  11. package/build/avatar/edit.js.map +2 -2
  12. package/build/breadcrumbs/block.json +3 -2
  13. package/build/breadcrumbs/edit.js +18 -18
  14. package/build/breadcrumbs/edit.js.map +2 -2
  15. package/build/button/index.js +14 -11
  16. package/build/button/index.js.map +3 -3
  17. package/build/code/index.js +10 -7
  18. package/build/code/index.js.map +3 -3
  19. package/build/comments-pagination-numbers/block.json +7 -0
  20. package/build/cover/edit/block-controls.js +37 -3
  21. package/build/cover/edit/block-controls.js.map +3 -3
  22. package/build/cover/edit/cover-placeholder.js +0 -1
  23. package/build/cover/edit/cover-placeholder.js.map +2 -2
  24. package/build/cover/edit/embed-video-url-input.js +83 -0
  25. package/build/cover/edit/embed-video-url-input.js.map +7 -0
  26. package/build/cover/edit/index.js +60 -0
  27. package/build/cover/edit/index.js.map +2 -2
  28. package/build/cover/embed-video-utils.js +151 -0
  29. package/build/cover/embed-video-utils.js.map +7 -0
  30. package/build/cover/index.js +11 -5
  31. package/build/cover/index.js.map +3 -3
  32. package/build/cover/save.js +12 -0
  33. package/build/cover/save.js.map +2 -2
  34. package/build/cover/shared.js +3 -0
  35. package/build/cover/shared.js.map +2 -2
  36. package/build/details/index.js +10 -7
  37. package/build/details/index.js.map +3 -3
  38. package/build/file/index.js +15 -15
  39. package/build/file/index.js.map +3 -3
  40. package/build/freeform/block.json +1 -1
  41. package/build/gallery/edit.js +1 -3
  42. package/build/gallery/edit.js.map +2 -2
  43. package/build/gallery/transforms.js +7 -3
  44. package/build/gallery/transforms.js.map +2 -2
  45. package/build/heading/index.js +10 -7
  46. package/build/heading/index.js.map +3 -3
  47. package/build/html/modal.js +141 -121
  48. package/build/html/modal.js.map +3 -3
  49. package/build/image/edit.js +0 -1
  50. package/build/image/edit.js.map +2 -2
  51. package/build/image/image.js +0 -1
  52. package/build/image/image.js.map +2 -2
  53. package/build/image/index.js +19 -19
  54. package/build/image/index.js.map +3 -3
  55. package/build/index.js +9 -3
  56. package/build/index.js.map +2 -2
  57. package/build/list-item/index.js +9 -7
  58. package/build/list-item/index.js.map +3 -3
  59. package/build/math/block.json +28 -1
  60. package/build/math/edit.js +17 -2
  61. package/build/math/edit.js.map +2 -2
  62. package/build/media-text/index.js +16 -9
  63. package/build/media-text/index.js.map +3 -3
  64. package/build/media-text/media-container.js +0 -2
  65. package/build/media-text/media-container.js.map +2 -2
  66. package/build/missing/block.json +1 -1
  67. package/build/missing/edit.js +2 -2
  68. package/build/missing/edit.js.map +1 -1
  69. package/build/more/index.js +10 -7
  70. package/build/more/index.js.map +3 -3
  71. package/build/navigation-link/edit.js +36 -11
  72. package/build/navigation-link/edit.js.map +2 -2
  73. package/build/navigation-link/index.js +12 -9
  74. package/build/navigation-link/index.js.map +3 -3
  75. package/build/navigation-submenu/index.js +12 -9
  76. package/build/navigation-submenu/index.js.map +3 -3
  77. package/build/page-list-item/edit.js +4 -3
  78. package/build/page-list-item/edit.js.map +2 -2
  79. package/build/paragraph/deprecated-attributes.js +68 -0
  80. package/build/paragraph/deprecated-attributes.js.map +7 -0
  81. package/build/paragraph/edit.js +2 -0
  82. package/build/paragraph/edit.js.map +3 -3
  83. package/build/paragraph/index.js +10 -7
  84. package/build/paragraph/index.js.map +3 -3
  85. package/build/pattern/block.json +1 -1
  86. package/build/post-title/edit.js +6 -4
  87. package/build/post-title/edit.js.map +2 -2
  88. package/build/preformatted/index.js +10 -7
  89. package/build/preformatted/index.js.map +3 -3
  90. package/build/pullquote/index.js +12 -12
  91. package/build/pullquote/index.js.map +3 -3
  92. package/build/search/index.js +15 -17
  93. package/build/search/index.js.map +3 -3
  94. package/build/social-link/index.js +12 -9
  95. package/build/social-link/index.js.map +3 -3
  96. package/build/template-part/edit/index.js +37 -7
  97. package/build/template-part/edit/index.js.map +2 -2
  98. package/build/template-part/edit/utils/get-template-part-icon.js +9 -4
  99. package/build/template-part/edit/utils/get-template-part-icon.js.map +3 -3
  100. package/build/template-part/edit/utils/hooks.js +2 -3
  101. package/build/template-part/edit/utils/hooks.js.map +2 -2
  102. package/build/term-count/index.js +1 -0
  103. package/build/term-count/index.js.map +2 -2
  104. package/build/term-name/index.js +1 -0
  105. package/build/term-name/index.js.map +2 -2
  106. package/build/verse/index.js +10 -7
  107. package/build/verse/index.js.map +3 -3
  108. package/build/video/index.js +13 -10
  109. package/build/video/index.js.map +3 -3
  110. package/build-module/accordion/view.js +46 -4
  111. package/build-module/accordion/view.js.map +2 -2
  112. package/build-module/accordion-heading/block.json +1 -1
  113. package/build-module/accordion-heading/deprecated.js +1 -1
  114. package/build-module/accordion-heading/deprecated.js.map +2 -2
  115. package/build-module/accordion-panel/block.json +1 -1
  116. package/build-module/audio/index.js +13 -10
  117. package/build-module/audio/index.js.map +2 -2
  118. package/build-module/avatar/edit.js +13 -38
  119. package/build-module/avatar/edit.js.map +2 -2
  120. package/build-module/breadcrumbs/block.json +3 -2
  121. package/build-module/breadcrumbs/edit.js +18 -18
  122. package/build-module/breadcrumbs/edit.js.map +2 -2
  123. package/build-module/button/index.js +14 -11
  124. package/build-module/button/index.js.map +2 -2
  125. package/build-module/code/index.js +10 -7
  126. package/build-module/code/index.js.map +2 -2
  127. package/build-module/comments-pagination-numbers/block.json +7 -0
  128. package/build-module/cover/edit/block-controls.js +27 -3
  129. package/build-module/cover/edit/block-controls.js.map +2 -2
  130. package/build-module/cover/edit/cover-placeholder.js +0 -1
  131. package/build-module/cover/edit/cover-placeholder.js.map +2 -2
  132. package/build-module/cover/edit/embed-video-url-input.js +67 -0
  133. package/build-module/cover/edit/embed-video-url-input.js.map +7 -0
  134. package/build-module/cover/edit/index.js +61 -0
  135. package/build-module/cover/edit/index.js.map +2 -2
  136. package/build-module/cover/embed-video-utils.js +122 -0
  137. package/build-module/cover/embed-video-utils.js.map +7 -0
  138. package/build-module/cover/index.js +11 -5
  139. package/build-module/cover/index.js.map +2 -2
  140. package/build-module/cover/save.js +13 -0
  141. package/build-module/cover/save.js.map +2 -2
  142. package/build-module/cover/shared.js +2 -0
  143. package/build-module/cover/shared.js.map +2 -2
  144. package/build-module/details/index.js +10 -7
  145. package/build-module/details/index.js.map +2 -2
  146. package/build-module/file/index.js +15 -15
  147. package/build-module/file/index.js.map +2 -2
  148. package/build-module/freeform/block.json +1 -1
  149. package/build-module/gallery/edit.js +1 -3
  150. package/build-module/gallery/edit.js.map +2 -2
  151. package/build-module/gallery/transforms.js +7 -3
  152. package/build-module/gallery/transforms.js.map +2 -2
  153. package/build-module/heading/index.js +10 -7
  154. package/build-module/heading/index.js.map +2 -2
  155. package/build-module/html/modal.js +143 -122
  156. package/build-module/html/modal.js.map +2 -2
  157. package/build-module/image/edit.js +0 -1
  158. package/build-module/image/edit.js.map +2 -2
  159. package/build-module/image/image.js +0 -1
  160. package/build-module/image/image.js.map +2 -2
  161. package/build-module/image/index.js +19 -19
  162. package/build-module/image/index.js.map +2 -2
  163. package/build-module/index.js +9 -3
  164. package/build-module/index.js.map +2 -2
  165. package/build-module/list-item/index.js +9 -7
  166. package/build-module/list-item/index.js.map +2 -2
  167. package/build-module/math/block.json +28 -1
  168. package/build-module/math/edit.js +18 -3
  169. package/build-module/math/edit.js.map +2 -2
  170. package/build-module/media-text/index.js +16 -9
  171. package/build-module/media-text/index.js.map +2 -2
  172. package/build-module/media-text/media-container.js +0 -2
  173. package/build-module/media-text/media-container.js.map +2 -2
  174. package/build-module/missing/block.json +1 -1
  175. package/build-module/missing/edit.js +2 -2
  176. package/build-module/missing/edit.js.map +1 -1
  177. package/build-module/more/index.js +10 -7
  178. package/build-module/more/index.js.map +2 -2
  179. package/build-module/navigation-link/edit.js +37 -12
  180. package/build-module/navigation-link/edit.js.map +2 -2
  181. package/build-module/navigation-link/index.js +12 -9
  182. package/build-module/navigation-link/index.js.map +2 -2
  183. package/build-module/navigation-submenu/index.js +12 -9
  184. package/build-module/navigation-submenu/index.js.map +2 -2
  185. package/build-module/page-list-item/edit.js +4 -3
  186. package/build-module/page-list-item/edit.js.map +2 -2
  187. package/build-module/paragraph/deprecated-attributes.js +37 -0
  188. package/build-module/paragraph/deprecated-attributes.js.map +7 -0
  189. package/build-module/paragraph/edit.js +2 -0
  190. package/build-module/paragraph/edit.js.map +2 -2
  191. package/build-module/paragraph/index.js +10 -7
  192. package/build-module/paragraph/index.js.map +2 -2
  193. package/build-module/pattern/block.json +1 -1
  194. package/build-module/post-title/edit.js +6 -4
  195. package/build-module/post-title/edit.js.map +2 -2
  196. package/build-module/preformatted/index.js +10 -7
  197. package/build-module/preformatted/index.js.map +2 -2
  198. package/build-module/pullquote/index.js +12 -12
  199. package/build-module/pullquote/index.js.map +2 -2
  200. package/build-module/search/index.js +15 -17
  201. package/build-module/search/index.js.map +2 -2
  202. package/build-module/social-link/index.js +12 -9
  203. package/build-module/social-link/index.js.map +2 -2
  204. package/build-module/template-part/edit/index.js +37 -7
  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 +2 -3
  209. package/build-module/template-part/edit/utils/hooks.js.map +2 -2
  210. package/build-module/term-count/index.js +1 -0
  211. package/build-module/term-count/index.js.map +2 -2
  212. package/build-module/term-name/index.js +1 -0
  213. package/build-module/term-name/index.js.map +2 -2
  214. package/build-module/verse/index.js +10 -7
  215. package/build-module/verse/index.js.map +2 -2
  216. package/build-module/video/index.js +13 -10
  217. package/build-module/video/index.js.map +2 -2
  218. package/build-style/accordion/style-rtl.css +3 -0
  219. package/build-style/accordion/style.css +3 -0
  220. package/build-style/accordion-heading/style-rtl.css +2 -19
  221. package/build-style/accordion-heading/style.css +2 -19
  222. package/build-style/accordion-item/style-rtl.css +0 -7
  223. package/build-style/accordion-item/style.css +0 -7
  224. package/build-style/accordion-panel/style-rtl.css +1 -4
  225. package/build-style/accordion-panel/style.css +1 -4
  226. package/build-style/classic-rtl.css +24 -0
  227. package/build-style/classic.css +24 -0
  228. package/build-style/common-rtl.css +4 -4
  229. package/build-style/common.css +4 -0
  230. package/build-style/cover/style-rtl.css +47 -0
  231. package/build-style/cover/style.css +47 -0
  232. package/build-style/editor-rtl.css +11 -13
  233. package/build-style/editor.css +11 -13
  234. package/build-style/html/editor-rtl.css +11 -13
  235. package/build-style/html/editor.css +11 -13
  236. package/build-style/style-rtl.css +59 -33
  237. package/build-style/style.css +59 -29
  238. package/build-style/verse/style-rtl.css +2 -0
  239. package/build-style/verse/style.css +2 -0
  240. package/package.json +40 -38
  241. package/src/accordion/style.scss +4 -0
  242. package/src/accordion/view.js +60 -3
  243. package/src/accordion-heading/block.json +1 -1
  244. package/src/accordion-heading/deprecated.js +1 -1
  245. package/src/accordion-heading/style.scss +2 -38
  246. package/src/accordion-item/index.php +1 -0
  247. package/src/accordion-item/style.scss +2 -9
  248. package/src/accordion-panel/block.json +1 -1
  249. package/src/accordion-panel/style.scss +1 -5
  250. package/src/audio/index.js +14 -10
  251. package/src/avatar/edit.js +68 -83
  252. package/src/breadcrumbs/block.json +3 -2
  253. package/src/breadcrumbs/edit.js +18 -18
  254. package/src/breadcrumbs/index.php +103 -93
  255. package/src/button/index.js +15 -11
  256. package/src/classic.scss +38 -0
  257. package/src/code/index.js +11 -7
  258. package/src/comments-pagination-numbers/block.json +7 -0
  259. package/src/common.scss +4 -0
  260. package/src/cover/edit/block-controls.js +26 -2
  261. package/src/cover/edit/cover-placeholder.js +0 -1
  262. package/src/cover/edit/embed-video-url-input.js +74 -0
  263. package/src/cover/edit/index.js +81 -0
  264. package/src/cover/embed-video-utils.js +196 -0
  265. package/src/cover/index.js +12 -5
  266. package/src/cover/index.php +106 -0
  267. package/src/cover/save.js +14 -0
  268. package/src/cover/shared.js +1 -0
  269. package/src/cover/style.scss +47 -0
  270. package/src/details/index.js +11 -7
  271. package/src/file/index.js +16 -15
  272. package/src/freeform/block.json +1 -1
  273. package/src/gallery/edit.js +4 -3
  274. package/src/gallery/transforms.js +6 -2
  275. package/src/heading/index.js +11 -7
  276. package/src/html/editor.scss +10 -15
  277. package/src/html/modal.js +54 -30
  278. package/src/image/edit.js +0 -1
  279. package/src/image/image.js +0 -1
  280. package/src/image/index.js +20 -19
  281. package/src/image/index.php +1 -0
  282. package/src/index.js +9 -3
  283. package/src/list-item/index.js +10 -7
  284. package/src/math/block.json +28 -1
  285. package/src/math/edit.js +18 -3
  286. package/src/media-text/index.js +17 -9
  287. package/src/media-text/media-container.js +0 -2
  288. package/src/missing/block.json +1 -1
  289. package/src/missing/edit.js +2 -2
  290. package/src/more/index.js +11 -7
  291. package/src/navigation-link/edit.js +72 -26
  292. package/src/navigation-link/index.js +13 -9
  293. package/src/navigation-submenu/index.js +13 -9
  294. package/src/page-list/index.php +3 -4
  295. package/src/page-list-item/edit.js +4 -3
  296. package/src/paragraph/deprecated-attributes.js +45 -0
  297. package/src/paragraph/edit.js +2 -0
  298. package/src/paragraph/index.js +11 -7
  299. package/src/pattern/block.json +1 -1
  300. package/src/post-title/edit.js +8 -4
  301. package/src/post-title/index.php +1 -1
  302. package/src/preformatted/index.js +11 -7
  303. package/src/pullquote/index.js +13 -12
  304. package/src/search/index.js +15 -16
  305. package/src/social-link/index.js +13 -9
  306. package/src/style.scss +1 -0
  307. package/src/template-part/edit/index.js +44 -6
  308. package/src/template-part/edit/utils/get-template-part-icon.js +23 -4
  309. package/src/template-part/edit/utils/hooks.js +2 -4
  310. package/src/term-count/index.js +1 -0
  311. package/src/term-name/index.js +1 -0
  312. package/src/verse/index.js +11 -7
  313. package/src/verse/style.scss +4 -0
  314. package/src/video/index.js +14 -10
  315. package/tsconfig.tsbuildinfo +1 -1
package/src/file/index.js CHANGED
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { _x, __ } from '@wordpress/i18n';
5
5
  import { file as icon } from '@wordpress/icons';
6
+ import { privateApis as blocksPrivateApis } from '@wordpress/blocks';
6
7
 
7
8
  /**
8
9
  * Internal dependencies
@@ -13,6 +14,9 @@ import edit from './edit';
13
14
  import metadata from './block.json';
14
15
  import save from './save';
15
16
  import transforms from './transforms';
17
+ import { unlock } from '../lock-unlock';
18
+
19
+ const { fieldsKey, formKey } = unlock( blocksPrivateApis );
16
20
 
17
21
  const { name } = metadata;
18
22
 
@@ -32,15 +36,15 @@ export const settings = {
32
36
  save,
33
37
  };
34
38
 
35
- if ( window.__experimentalContentOnlyPatternInsertion ) {
36
- settings.fields = [
39
+ if ( window.__experimentalContentOnlyInspectorFields ) {
40
+ settings[ fieldsKey ] = [
37
41
  {
42
+ id: 'file',
38
43
  label: __( 'File' ),
39
- type: 'Media',
40
- shownByDefault: true,
44
+ type: 'media',
41
45
  mapping: {
42
46
  id: 'id',
43
- src: 'href',
47
+ url: 'href',
44
48
  },
45
49
  args: {
46
50
  allowedTypes: [],
@@ -48,22 +52,19 @@ if ( window.__experimentalContentOnlyPatternInsertion ) {
48
52
  },
49
53
  },
50
54
  {
55
+ id: 'fileName',
51
56
  label: __( 'Filename' ),
52
- type: 'RichText',
53
- shownByDefault: false,
54
- mapping: {
55
- value: 'fileName',
56
- },
57
+ type: 'richtext',
57
58
  },
58
59
  {
60
+ id: 'downloadButtonText',
59
61
  label: __( 'Button Text' ),
60
- type: 'RichText',
61
- shownByDefault: false,
62
- mapping: {
63
- value: 'downloadButtonText',
64
- },
62
+ type: 'richtext',
65
63
  },
66
64
  ];
65
+ settings[ formKey ] = {
66
+ fields: [ 'file' ],
67
+ };
67
68
  }
68
69
 
69
70
  export const init = () => initBlock( { name, metadata, settings } );
@@ -19,7 +19,7 @@
19
19
  "lock": false,
20
20
  "reusable": false,
21
21
  "renaming": false,
22
- "blockVisibility": false
22
+ "visibility": false
23
23
  },
24
24
  "editorStyle": "wp-block-freeform-editor"
25
25
  }
@@ -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
  };
@@ -596,7 +599,6 @@ export default function GalleryEdit( props ) {
596
599
  instructions: PLACEHOLDER_TEXT,
597
600
  } }
598
601
  onSelect={ updateImages }
599
- accept="image/*"
600
602
  allowedTypes={ ALLOWED_MEDIA_TYPES }
601
603
  multiple
602
604
  onError={ onUploadError }
@@ -910,7 +912,6 @@ export default function GalleryEdit( props ) {
910
912
  <BlockControls group="other">
911
913
  <MediaReplaceFlow
912
914
  allowedTypes={ ALLOWED_MEDIA_TYPES }
913
- accept="image/*"
914
915
  handleUpload={ false }
915
916
  onSelect={ updateImages }
916
917
  name={ __( 'Add' ) }
@@ -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
 
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { heading as icon } from '@wordpress/icons';
5
5
  import { __, sprintf } from '@wordpress/i18n';
6
+ import { privateApis as blocksPrivateApis } from '@wordpress/blocks';
6
7
 
7
8
  /**
8
9
  * Internal dependencies
@@ -14,6 +15,9 @@ import metadata from './block.json';
14
15
  import save from './save';
15
16
  import transforms from './transforms';
16
17
  import variations from './variations';
18
+ import { unlock } from '../lock-unlock';
19
+
20
+ const { fieldsKey, formKey } = unlock( blocksPrivateApis );
17
21
 
18
22
  const { name } = metadata;
19
23
 
@@ -69,17 +73,17 @@ export const settings = {
69
73
  variations,
70
74
  };
71
75
 
72
- if ( window.__experimentalContentOnlyPatternInsertion ) {
73
- settings.fields = [
76
+ if ( window.__experimentalContentOnlyInspectorFields ) {
77
+ settings[ fieldsKey ] = [
74
78
  {
79
+ id: 'content',
75
80
  label: __( 'Content' ),
76
- type: 'RichText',
77
- shownByDefault: true,
78
- mapping: {
79
- value: 'content',
80
- },
81
+ type: 'richtext',
81
82
  },
82
83
  ];
84
+ settings[ formKey ] = {
85
+ fields: [ 'content' ],
86
+ };
83
87
  }
84
88
 
85
89
  export const init = () => initBlock( { name, metadata, settings } );
@@ -14,22 +14,20 @@
14
14
 
15
15
  // Modal styles
16
16
  .block-library-html__modal {
17
- // Make modal content scrollable
18
- .components-modal__content {
19
- display: flex;
20
- flex-direction: column;
21
- padding: 0;
22
- min-height: 70vh;
23
- }
17
+ height: 100%;
24
18
 
25
19
  .components-modal__children-container {
26
20
  height: 100%;
27
- padding: $grid-unit-20;
28
21
  }
29
22
  }
30
23
 
31
24
  .block-library-html__modal-tabs {
32
- height: 100%;
25
+ overflow-y: auto;
26
+ }
27
+
28
+ .block-library-html__modal-content {
29
+ flex: 1;
30
+ min-height: 0;
33
31
  }
34
32
 
35
33
  .block-library-html__modal-tab {
@@ -73,10 +71,7 @@
73
71
  display: flex;
74
72
  align-items: center;
75
73
  justify-content: center;
76
- padding: $grid-unit-60;
77
- }
78
-
79
- .block-library-html__modal-actions {
80
- margin-top: $grid-unit-20;
81
- padding: 0 $grid-unit-40 $grid-unit-40;
74
+ padding: $grid-unit-20;
75
+ flex: 1;
76
+ min-height: 0;
82
77
  }
package/src/html/modal.js CHANGED
@@ -8,9 +8,10 @@ import {
8
8
  Modal,
9
9
  Button,
10
10
  Flex,
11
+ Notice,
11
12
  privateApis as componentsPrivateApis,
12
13
  __experimentalHStack as HStack,
13
- __experimentalVStack as VStack,
14
+ __experimentalGrid as Grid,
14
15
  } from '@wordpress/components';
15
16
  import { PlainText, store as blockEditorStore } from '@wordpress/block-editor';
16
17
  import { fullscreen, square } from '@wordpress/icons';
@@ -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 );
@@ -117,13 +121,23 @@ export default function HTMLEditModal( {
117
121
  __experimentalHideHeader
118
122
  >
119
123
  <Tabs orientation="horizontal" defaultTabId="html">
120
- <VStack spacing={ 4 } style={ { height: '100%' } }>
121
- <HStack justify="space-between">
124
+ <Grid
125
+ columns={ 1 }
126
+ templateRows="auto 1fr auto"
127
+ gap={ 4 }
128
+ style={ { height: '100%' } }
129
+ >
130
+ <HStack
131
+ justify="space-between"
132
+ className="block-library-html__modal-header"
133
+ >
122
134
  <div>
123
135
  <Tabs.TabList>
124
136
  <Tabs.Tab tabId="html">HTML</Tabs.Tab>
125
- <Tabs.Tab tabId="css">CSS</Tabs.Tab>
126
- { shouldShowJsTab && (
137
+ { canUserUseUnfilteredHTML && (
138
+ <Tabs.Tab tabId="css">CSS</Tabs.Tab>
139
+ ) }
140
+ { canUserUseUnfilteredHTML && (
127
141
  <Tabs.Tab tabId="js">
128
142
  { __( 'JavaScript' ) }
129
143
  </Tabs.Tab>
@@ -140,14 +154,24 @@ export default function HTMLEditModal( {
140
154
  />
141
155
  </div>
142
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
+ ) }
143
168
  <HStack
144
169
  alignment="stretch"
145
170
  justify="flex-start"
146
171
  spacing={ 4 }
147
172
  className="block-library-html__modal-tabs"
148
- style={ { flexGrow: 1 } }
149
173
  >
150
- <div style={ { flexGrow: 1 } }>
174
+ <div className="block-library-html__modal-content">
151
175
  <Tabs.TabPanel
152
176
  tabId="html"
153
177
  focusable={ false }
@@ -161,20 +185,22 @@ export default function HTMLEditModal( {
161
185
  className="block-library-html__modal-editor"
162
186
  />
163
187
  </Tabs.TabPanel>
164
- <Tabs.TabPanel
165
- tabId="css"
166
- focusable={ false }
167
- className="block-library-html__modal-tab"
168
- >
169
- <PlainText
170
- value={ editedCss }
171
- onChange={ handleCssChange }
172
- placeholder={ __( 'Write CSS…' ) }
173
- aria-label={ __( 'CSS' ) }
174
- className="block-library-html__modal-editor"
175
- />
176
- </Tabs.TabPanel>
177
- { 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 && (
178
204
  <Tabs.TabPanel
179
205
  tabId="js"
180
206
  focusable={ false }
@@ -192,10 +218,7 @@ export default function HTMLEditModal( {
192
218
  </Tabs.TabPanel>
193
219
  ) }
194
220
  </div>
195
- <div
196
- className="block-library-html__preview"
197
- style={ { width: '50%' } }
198
- >
221
+ <div className="block-library-html__preview">
199
222
  <Preview
200
223
  content={ serializeContent( {
201
224
  html: editedHtml,
@@ -209,6 +232,7 @@ export default function HTMLEditModal( {
209
232
  alignment="center"
210
233
  justify="flex-end"
211
234
  spacing={ 4 }
235
+ className="block-library-html__modal-footer"
212
236
  >
213
237
  <Button
214
238
  __next40pxDefaultSize
@@ -225,7 +249,7 @@ export default function HTMLEditModal( {
225
249
  { __( 'Update' ) }
226
250
  </Button>
227
251
  </HStack>
228
- </VStack>
252
+ </Grid>
229
253
  </Tabs>
230
254
  </Modal>
231
255
 
package/src/image/edit.js CHANGED
@@ -464,7 +464,6 @@ export function ImageEdit( {
464
464
  onSelectURL={ onSelectURL }
465
465
  onError={ onUploadError }
466
466
  placeholder={ placeholder }
467
- accept="image/*"
468
467
  allowedTypes={ ALLOWED_MEDIA_TYPES }
469
468
  handleUpload={ ( files ) => files.length === 1 }
470
469
  value={ { id, src } }
@@ -718,7 +718,6 @@ export default function Image( {
718
718
  mediaId={ id }
719
719
  mediaURL={ url }
720
720
  allowedTypes={ ALLOWED_MEDIA_TYPES }
721
- accept="image/*"
722
721
  onSelect={ onSelectImage }
723
722
  onSelectURL={ onSelectURL }
724
723
  onError={ onUploadError }
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { image as icon } from '@wordpress/icons';
6
+ import { privateApis as blocksPrivateApis } from '@wordpress/blocks';
6
7
 
7
8
  /**
8
9
  * Internal dependencies
@@ -13,6 +14,9 @@ import edit from './edit';
13
14
  import metadata from './block.json';
14
15
  import save from './save';
15
16
  import transforms from './transforms';
17
+ import { unlock } from '../lock-unlock';
18
+
19
+ const { fieldsKey, formKey } = unlock( blocksPrivateApis );
16
20
 
17
21
  const { name } = metadata;
18
22
 
@@ -62,15 +66,15 @@ export const settings = {
62
66
  deprecated,
63
67
  };
64
68
 
65
- if ( window.__experimentalContentOnlyPatternInsertion ) {
66
- settings.fields = [
69
+ if ( window.__experimentalContentOnlyInspectorFields ) {
70
+ settings[ fieldsKey ] = [
67
71
  {
72
+ id: 'image',
68
73
  label: __( 'Image' ),
69
- type: 'Media',
70
- shownByDefault: true,
74
+ type: 'media',
71
75
  mapping: {
72
76
  id: 'id',
73
- src: 'url',
77
+ url: 'url',
74
78
  caption: 'caption',
75
79
  alt: 'alt',
76
80
  },
@@ -80,33 +84,30 @@ if ( window.__experimentalContentOnlyPatternInsertion ) {
80
84
  },
81
85
  },
82
86
  {
87
+ id: 'link',
83
88
  label: __( 'Link' ),
84
- type: 'Link',
85
- shownByDefault: false,
89
+ type: 'link',
86
90
  mapping: {
87
- href: 'href',
91
+ url: 'href',
88
92
  rel: 'rel',
89
- target: 'linkTarget',
93
+ linkTarget: 'linkTarget',
90
94
  destination: 'linkDestination',
91
95
  },
92
96
  },
93
97
  {
98
+ id: 'caption',
94
99
  label: __( 'Caption' ),
95
- type: 'RichText',
96
- shownByDefault: false,
97
- mapping: {
98
- value: 'caption',
99
- },
100
+ type: 'richtext',
100
101
  },
101
102
  {
103
+ id: 'alt',
102
104
  label: __( 'Alt text' ),
103
- type: 'PlainText',
104
- shownByDefault: false,
105
- mapping: {
106
- value: 'alt',
107
- },
105
+ type: 'text',
108
106
  },
109
107
  ];
108
+ settings[ formKey ] = {
109
+ fields: [ 'image' ],
110
+ };
110
111
  }
111
112
 
112
113
  export const init = () => initBlock( { name, metadata, settings } );
@@ -196,6 +196,7 @@ function block_core_image_render_lightbox( $block_content, $block ) {
196
196
  $img_styles = $processor->get_attribute( 'style' );
197
197
  $img_width = 'none';
198
198
  $img_height = 'none';
199
+ $img_srcset = false;
199
200
  $aria_label = __( 'Enlarge' );
200
201
  $dialog_aria_label = __( 'Enlarged image' );
201
202
 
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( {
@@ -4,6 +4,7 @@
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { listItem as icon } from '@wordpress/icons';
6
6
  import { privateApis } from '@wordpress/block-editor';
7
+ import { privateApis as blocksPrivateApis } from '@wordpress/blocks';
7
8
 
8
9
  /**
9
10
  * Internal dependencies
@@ -15,6 +16,8 @@ import save from './save';
15
16
  import transforms from './transforms';
16
17
  import { unlock } from '../lock-unlock';
17
18
 
19
+ const { fieldsKey, formKey } = unlock( blocksPrivateApis );
20
+
18
21
  const { name } = metadata;
19
22
 
20
23
  export { metadata, name };
@@ -33,17 +36,17 @@ export const settings = {
33
36
  [ unlock( privateApis ).requiresWrapperOnCopy ]: true,
34
37
  };
35
38
 
36
- if ( window.__experimentalContentOnlyPatternInsertion ) {
37
- settings.fields = [
39
+ if ( window.__experimentalContentOnlyInspectorFields ) {
40
+ settings[ fieldsKey ] = [
38
41
  {
42
+ id: 'content',
39
43
  label: __( 'Content' ),
40
- type: 'RichText',
41
- shownByDefault: true,
42
- mapping: {
43
- value: 'content',
44
- },
44
+ type: 'richtext',
45
45
  },
46
46
  ];
47
+ settings[ formKey ] = {
48
+ fields: [ 'content' ],
49
+ };
47
50
  }
48
51
 
49
52
  export const init = () => initBlock( { name, metadata, settings } );
@@ -8,7 +8,34 @@
8
8
  "keywords": [ "equation", "formula", "latex", "mathematics" ],
9
9
  "textdomain": "default",
10
10
  "supports": {
11
- "html": false
11
+ "html": false,
12
+ "__experimentalBorder": {
13
+ "color": true,
14
+ "radius": true,
15
+ "style": true,
16
+ "width": true
17
+ },
18
+ "color": {
19
+ "gradients": true,
20
+ "__experimentalDefaultControls": {
21
+ "background": true,
22
+ "text": true
23
+ }
24
+ },
25
+ "spacing": {
26
+ "margin": true,
27
+ "padding": true,
28
+ "__experimentalDefaultControls": {
29
+ "margin": false,
30
+ "padding": false
31
+ }
32
+ },
33
+ "typography": {
34
+ "fontSize": true,
35
+ "__experimentalDefaultControls": {
36
+ "fontSize": true
37
+ }
38
+ }
12
39
  },
13
40
  "attributes": {
14
41
  "latex": {
package/src/math/edit.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { __ } from '@wordpress/i18n';
4
+ import { __, sprintf } from '@wordpress/i18n';
5
5
  import {
6
6
  useBlockProps,
7
7
  store as blockEditorStore,
@@ -14,6 +14,7 @@ import {
14
14
  } from '@wordpress/components';
15
15
  import { useState, useEffect, useRef } from '@wordpress/element';
16
16
  import { useDispatch } from '@wordpress/data';
17
+ import { speak } from '@wordpress/a11y';
17
18
 
18
19
  /**
19
20
  * Internal dependencies
@@ -72,7 +73,8 @@ export default function MathEdit( { attributes, setAttributes, isSelected } ) {
72
73
  placement="bottom-start"
73
74
  offset={ 8 }
74
75
  anchor={ blockRef }
75
- focusOnMount="firstContentElement"
76
+ focusOnMount={ false }
77
+ __unstableSlotName="__unstable-block-tools-after"
76
78
  >
77
79
  <div style={ { padding: '4px', minWidth: '300px' } }>
78
80
  <VStack spacing={ 1 }>
@@ -96,6 +98,15 @@ export default function MathEdit( { attributes, setAttributes, isSelected } ) {
96
98
  setError( null );
97
99
  } catch ( err ) {
98
100
  setError( err.message );
101
+ speak(
102
+ sprintf(
103
+ /* translators: %s: error message returned when parsing LaTeX. */
104
+ __(
105
+ 'Error parsing mathematical expression: %s'
106
+ ),
107
+ err.message
108
+ )
109
+ );
99
110
  }
100
111
  setAttributes( {
101
112
  mathML: newMathML,
@@ -110,7 +121,11 @@ export default function MathEdit( { attributes, setAttributes, isSelected } ) {
110
121
  intent="error"
111
122
  className="wp-block-math__error"
112
123
  >
113
- { error }
124
+ { sprintf(
125
+ /* translators: %s: error message returned when parsing LaTeX. */
126
+ __( 'Error: %s' ),
127
+ error
128
+ ) }
114
129
  </Badge>
115
130
  <style children=".wp-block-math__error .components-badge__content{white-space:normal}" />
116
131
  </>