@wordpress/block-library 8.14.0 → 8.15.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 (260) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/build/avatar/edit.js +1 -0
  3. package/build/avatar/edit.js.map +1 -1
  4. package/build/block/index.js +2 -1
  5. package/build/block/index.js.map +1 -1
  6. package/build/buttons/edit.js +2 -2
  7. package/build/buttons/edit.js.map +1 -1
  8. package/build/column/edit.native.js +1 -4
  9. package/build/column/edit.native.js.map +1 -1
  10. package/build/columns/edit.js +1 -0
  11. package/build/columns/edit.js.map +1 -1
  12. package/build/comment-author-avatar/edit.js +1 -0
  13. package/build/comment-author-avatar/edit.js.map +1 -1
  14. package/build/cover/deprecated.js +4 -2
  15. package/build/cover/deprecated.js.map +1 -1
  16. package/build/embed/embed-placeholder.native.js +37 -13
  17. package/build/embed/embed-placeholder.native.js.map +1 -1
  18. package/build/file/index.js +1 -2
  19. package/build/file/index.js.map +1 -1
  20. package/build/file/inspector.js +1 -0
  21. package/build/file/inspector.js.map +1 -1
  22. package/build/file/view-interactivity.js +23 -0
  23. package/build/file/view-interactivity.js.map +1 -0
  24. package/build/file/view.js +1 -15
  25. package/build/file/view.js.map +1 -1
  26. package/build/footnotes/edit.js +20 -1
  27. package/build/footnotes/edit.js.map +1 -1
  28. package/build/footnotes/format.js +19 -16
  29. package/build/footnotes/format.js.map +1 -1
  30. package/build/footnotes/index.js +0 -1
  31. package/build/footnotes/index.js.map +1 -1
  32. package/build/gallery/edit.js +1 -1
  33. package/build/gallery/edit.js.map +1 -1
  34. package/build/latest-comments/edit.js +1 -0
  35. package/build/latest-comments/edit.js.map +1 -1
  36. package/build/latest-posts/edit.js +2 -0
  37. package/build/latest-posts/edit.js.map +1 -1
  38. package/build/list/edit.js +4 -4
  39. package/build/list/edit.js.map +1 -1
  40. package/build/media-text/media-container.native.js +2 -1
  41. package/build/media-text/media-container.native.js.map +1 -1
  42. package/build/missing/edit.native.js +7 -5
  43. package/build/missing/edit.native.js.map +1 -1
  44. package/build/navigation/constants.js +10 -4
  45. package/build/navigation/constants.js.map +1 -1
  46. package/build/navigation/edit/index.js +16 -2
  47. package/build/navigation/edit/index.js.map +1 -1
  48. package/build/navigation/edit/inner-blocks.js +2 -2
  49. package/build/navigation/edit/inner-blocks.js.map +1 -1
  50. package/build/navigation/edit/unsaved-inner-blocks.js +2 -2
  51. package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  52. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +10 -15
  53. package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  54. package/build/navigation/index.js +2 -3
  55. package/build/navigation/index.js.map +1 -1
  56. package/build/navigation/use-navigation-menu.js +33 -45
  57. package/build/navigation/use-navigation-menu.js.map +1 -1
  58. package/build/navigation/view-interactivity.js +185 -0
  59. package/build/navigation/view-interactivity.js.map +1 -0
  60. package/build/navigation/view-modal.js +64 -0
  61. package/build/navigation/view-modal.js.map +1 -0
  62. package/build/navigation/view.js +50 -174
  63. package/build/navigation/view.js.map +1 -1
  64. package/build/navigation-link/edit.js +12 -7
  65. package/build/navigation-link/edit.js.map +1 -1
  66. package/build/navigation-submenu/edit.js +2 -2
  67. package/build/navigation-submenu/edit.js.map +1 -1
  68. package/build/query-pagination/edit.js +1 -1
  69. package/build/query-pagination/edit.js.map +1 -1
  70. package/build/query-title/edit.js +43 -1
  71. package/build/query-title/edit.js.map +1 -1
  72. package/build/quote/transforms.js +8 -0
  73. package/build/quote/transforms.js.map +1 -1
  74. package/build/rss/edit.js +3 -0
  75. package/build/rss/edit.js.map +1 -1
  76. package/build/search/edit.js +4 -3
  77. package/build/search/edit.js.map +1 -1
  78. package/build/search/index.js +1 -0
  79. package/build/search/index.js.map +1 -1
  80. package/build/site-logo/edit.js +1 -0
  81. package/build/site-logo/edit.js.map +1 -1
  82. package/build/tag-cloud/edit.js +1 -0
  83. package/build/tag-cloud/edit.js.map +1 -1
  84. package/build/template-part/edit/index.js +1 -1
  85. package/build/template-part/edit/index.js.map +1 -1
  86. package/build/text-columns/edit.js +1 -0
  87. package/build/text-columns/edit.js.map +1 -1
  88. package/build-module/avatar/edit.js +1 -0
  89. package/build-module/avatar/edit.js.map +1 -1
  90. package/build-module/block/index.js +2 -1
  91. package/build-module/block/index.js.map +1 -1
  92. package/build-module/buttons/edit.js +2 -2
  93. package/build-module/buttons/edit.js.map +1 -1
  94. package/build-module/column/edit.native.js +1 -4
  95. package/build-module/column/edit.native.js.map +1 -1
  96. package/build-module/columns/edit.js +1 -0
  97. package/build-module/columns/edit.js.map +1 -1
  98. package/build-module/comment-author-avatar/edit.js +1 -0
  99. package/build-module/comment-author-avatar/edit.js.map +1 -1
  100. package/build-module/cover/deprecated.js +4 -2
  101. package/build-module/cover/deprecated.js.map +1 -1
  102. package/build-module/embed/embed-placeholder.native.js +37 -14
  103. package/build-module/embed/embed-placeholder.native.js.map +1 -1
  104. package/build-module/file/index.js +1 -2
  105. package/build-module/file/index.js.map +1 -1
  106. package/build-module/file/inspector.js +1 -0
  107. package/build-module/file/inspector.js.map +1 -1
  108. package/build-module/file/view-interactivity.js +19 -0
  109. package/build-module/file/view-interactivity.js.map +1 -0
  110. package/build-module/file/view.js +2 -15
  111. package/build-module/file/view.js.map +1 -1
  112. package/build-module/footnotes/edit.js +18 -2
  113. package/build-module/footnotes/edit.js.map +1 -1
  114. package/build-module/footnotes/format.js +19 -16
  115. package/build-module/footnotes/format.js.map +1 -1
  116. package/build-module/footnotes/index.js +0 -1
  117. package/build-module/footnotes/index.js.map +1 -1
  118. package/build-module/gallery/edit.js +1 -1
  119. package/build-module/gallery/edit.js.map +1 -1
  120. package/build-module/latest-comments/edit.js +1 -0
  121. package/build-module/latest-comments/edit.js.map +1 -1
  122. package/build-module/latest-posts/edit.js +2 -0
  123. package/build-module/latest-posts/edit.js.map +1 -1
  124. package/build-module/list/edit.js +4 -4
  125. package/build-module/list/edit.js.map +1 -1
  126. package/build-module/media-text/media-container.native.js +2 -1
  127. package/build-module/media-text/media-container.native.js.map +1 -1
  128. package/build-module/missing/edit.native.js +8 -6
  129. package/build-module/missing/edit.native.js.map +1 -1
  130. package/build-module/navigation/constants.js +8 -3
  131. package/build-module/navigation/constants.js.map +1 -1
  132. package/build-module/navigation/edit/index.js +17 -3
  133. package/build-module/navigation/edit/index.js.map +1 -1
  134. package/build-module/navigation/edit/inner-blocks.js +2 -2
  135. package/build-module/navigation/edit/inner-blocks.js.map +1 -1
  136. package/build-module/navigation/edit/unsaved-inner-blocks.js +2 -2
  137. package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
  138. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +10 -14
  139. package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
  140. package/build-module/navigation/index.js +2 -3
  141. package/build-module/navigation/index.js.map +1 -1
  142. package/build-module/navigation/use-navigation-menu.js +35 -47
  143. package/build-module/navigation/use-navigation-menu.js.map +1 -1
  144. package/build-module/navigation/view-interactivity.js +182 -0
  145. package/build-module/navigation/view-interactivity.js.map +1 -0
  146. package/build-module/navigation/view-modal.js +58 -0
  147. package/build-module/navigation/view-modal.js.map +1 -0
  148. package/build-module/navigation/view.js +50 -173
  149. package/build-module/navigation/view.js.map +1 -1
  150. package/build-module/navigation-link/edit.js +12 -7
  151. package/build-module/navigation-link/edit.js.map +1 -1
  152. package/build-module/navigation-submenu/edit.js +2 -2
  153. package/build-module/navigation-submenu/edit.js.map +1 -1
  154. package/build-module/query-pagination/edit.js +1 -1
  155. package/build-module/query-pagination/edit.js.map +1 -1
  156. package/build-module/query-title/edit.js +44 -3
  157. package/build-module/query-title/edit.js.map +1 -1
  158. package/build-module/quote/transforms.js +8 -0
  159. package/build-module/quote/transforms.js.map +1 -1
  160. package/build-module/rss/edit.js +3 -0
  161. package/build-module/rss/edit.js.map +1 -1
  162. package/build-module/search/edit.js +4 -3
  163. package/build-module/search/edit.js.map +1 -1
  164. package/build-module/search/index.js +1 -0
  165. package/build-module/search/index.js.map +1 -1
  166. package/build-module/site-logo/edit.js +1 -0
  167. package/build-module/site-logo/edit.js.map +1 -1
  168. package/build-module/tag-cloud/edit.js +1 -0
  169. package/build-module/tag-cloud/edit.js.map +1 -1
  170. package/build-module/template-part/edit/index.js +1 -1
  171. package/build-module/template-part/edit/index.js.map +1 -1
  172. package/build-module/text-columns/edit.js +1 -0
  173. package/build-module/text-columns/edit.js.map +1 -1
  174. package/build-style/details/style-rtl.css +4 -2
  175. package/build-style/details/style.css +4 -2
  176. package/build-style/footnotes/style-rtl.css +4 -3
  177. package/build-style/footnotes/style.css +4 -3
  178. package/build-style/navigation/style-rtl.css +14 -2
  179. package/build-style/navigation/style.css +14 -2
  180. package/build-style/query-pagination/style-rtl.css +4 -2
  181. package/build-style/query-pagination/style.css +4 -2
  182. package/build-style/style-rtl.css +26 -9
  183. package/build-style/style.css +26 -9
  184. package/package.json +33 -32
  185. package/src/audio/test/__snapshots__/edit.native.js.snap +58 -33
  186. package/src/avatar/edit.js +1 -0
  187. package/src/block/block.json +2 -1
  188. package/src/block/editor.native.scss +2 -2
  189. package/src/buttons/edit.js +2 -2
  190. package/src/column/edit.native.js +4 -10
  191. package/src/column/editor.native.scss +0 -4
  192. package/src/columns/edit.js +1 -0
  193. package/src/comment-author-avatar/edit.js +1 -0
  194. package/src/comment-template/index.php +5 -2
  195. package/src/cover/deprecated.js +2 -0
  196. package/src/embed/embed-placeholder.native.js +80 -47
  197. package/src/embed/styles.native.scss +54 -18
  198. package/src/embed/test/index.native.js +5 -5
  199. package/src/file/block.json +1 -2
  200. package/src/file/index.php +19 -1
  201. package/src/file/inspector.js +1 -0
  202. package/src/file/test/__snapshots__/edit.native.js.snap +58 -33
  203. package/src/file/view-interactivity.js +18 -0
  204. package/src/file/view.js +5 -14
  205. package/src/footnotes/block.json +0 -1
  206. package/src/footnotes/edit.js +21 -2
  207. package/src/footnotes/format.js +22 -20
  208. package/src/footnotes/style.scss +6 -3
  209. package/src/gallery/edit.js +1 -1
  210. package/src/gallery/test/index.native.js +17 -16
  211. package/src/home-link/index.php +15 -2
  212. package/src/image/index.php +47 -8
  213. package/src/image/test/edit.native.js +1 -1
  214. package/src/latest-comments/edit.js +1 -0
  215. package/src/latest-posts/edit.js +2 -0
  216. package/src/list/edit.js +6 -4
  217. package/src/list/test/edit.native.js +129 -33
  218. package/src/media-text/media-container.native.js +1 -0
  219. package/src/missing/edit.native.js +12 -10
  220. package/src/missing/style.native.scss +19 -12
  221. package/src/missing/test/__snapshots__/edit.native.js.snap +21 -13
  222. package/src/navigation/block.json +2 -3
  223. package/src/navigation/constants.js +12 -6
  224. package/src/navigation/edit/index.js +29 -1
  225. package/src/navigation/edit/inner-blocks.js +2 -2
  226. package/src/navigation/edit/unsaved-inner-blocks.js +2 -2
  227. package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +17 -21
  228. package/src/navigation/index.php +24 -6
  229. package/src/navigation/style.scss +27 -8
  230. package/src/navigation/use-navigation-menu.js +39 -63
  231. package/src/navigation/view-interactivity.js +196 -0
  232. package/src/navigation/view-modal.js +78 -0
  233. package/src/navigation/view.js +67 -189
  234. package/src/navigation-link/edit.js +61 -47
  235. package/src/navigation-submenu/edit.js +2 -2
  236. package/src/paragraph/test/__snapshots__/edit.native.js.snap +1 -0
  237. package/src/paragraph/test/edit.native.js +26 -0
  238. package/src/post-template/index.php +4 -2
  239. package/src/post-title/index.php +6 -3
  240. package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -0
  241. package/src/query-pagination/edit.js +17 -14
  242. package/src/query-title/edit.js +48 -6
  243. package/src/quote/test/__snapshots__/transforms.native.js.snap +10 -0
  244. package/src/quote/test/transforms.native.js +5 -1
  245. package/src/quote/transforms.js +13 -0
  246. package/src/rss/edit.js +3 -0
  247. package/src/search/block.json +1 -0
  248. package/src/search/edit.js +4 -3
  249. package/src/search/index.php +22 -4
  250. package/src/search/test/__snapshots__/edit.native.js.snap +7 -0
  251. package/src/site-logo/edit.js +1 -0
  252. package/src/tag-cloud/edit.js +1 -0
  253. package/src/template-part/edit/index.js +1 -1
  254. package/src/template-part/index.php +9 -15
  255. package/src/text-columns/edit.js +1 -0
  256. package/build/gallery/shared-icon.native.js +0 -38
  257. package/build/gallery/shared-icon.native.js.map +0 -1
  258. package/build-module/gallery/shared-icon.native.js +0 -24
  259. package/build-module/gallery/shared-icon.native.js.map +0 -1
  260. package/src/gallery/shared-icon.native.js +0 -23
@@ -330,7 +330,7 @@ describe( 'Embed block', () => {
330
330
  const editor = await initializeWithEmbedBlock( EMPTY_EMBED_HTML );
331
331
 
332
332
  // Edit URL.
333
- fireEvent.press( await editor.findByText( 'ADD LINK' ) );
333
+ fireEvent.press( await editor.findByText( 'Add link' ) );
334
334
 
335
335
  // Wait for edit URL modal to be visible.
336
336
  const embedEditURLModal = editor.getByTestId(
@@ -351,7 +351,7 @@ describe( 'Embed block', () => {
351
351
  const editor = await initializeWithEmbedBlock( EMPTY_EMBED_HTML );
352
352
 
353
353
  // Edit URL.
354
- fireEvent.press( editor.getByText( 'ADD LINK' ) );
354
+ fireEvent.press( editor.getByText( 'Add link' ) );
355
355
 
356
356
  // Wait for edit URL modal to be visible.
357
357
  const embedEditURLModal = editor.getByTestId(
@@ -392,7 +392,7 @@ describe( 'Embed block', () => {
392
392
  const editor = await initializeWithEmbedBlock( EMPTY_EMBED_HTML );
393
393
 
394
394
  // Edit URL.
395
- fireEvent.press( editor.getByText( 'ADD LINK' ) );
395
+ fireEvent.press( editor.getByText( 'Add link' ) );
396
396
 
397
397
  // Wait for edit URL modal to be visible.
398
398
  const embedEditURLModal = editor.getByTestId(
@@ -592,7 +592,7 @@ describe( 'Embed block', () => {
592
592
  fireEvent.press( editor.block );
593
593
 
594
594
  // Edit URL.
595
- fireEvent.press( editor.getByText( 'ADD LINK' ) );
595
+ fireEvent.press( editor.getByText( 'Add link' ) );
596
596
 
597
597
  // Wait for edit URL modal to be visible.
598
598
  await waitForModalVisible( embedEditURLModal );
@@ -602,7 +602,7 @@ describe( 'Embed block', () => {
602
602
  fireEvent( embedEditURLModal, MODAL_DISMISS_EVENT );
603
603
 
604
604
  // Edit URL.
605
- fireEvent.press( editor.getByText( 'ADD LINK' ) );
605
+ fireEvent.press( editor.getByText( 'Add link' ) );
606
606
 
607
607
  // Wait for edit URL modal to be visible.
608
608
  await waitForModalVisible( embedEditURLModal );
@@ -65,8 +65,7 @@
65
65
  "background": true,
66
66
  "link": true
67
67
  }
68
- },
69
- "interactivity": true
68
+ }
70
69
  },
71
70
  "viewScript": "file:./view.min.js",
72
71
  "editorStyle": "wp-block-file-editor",
@@ -5,6 +5,24 @@
5
5
  * @package WordPress
6
6
  */
7
7
 
8
+ if ( gutenberg_should_block_use_interactivity_api( 'core/file' ) ) {
9
+ /**
10
+ * Replaces view script for the File block with version using Interactivity API.
11
+ *
12
+ * @param array $metadata Block metadata as read in via block.json.
13
+ *
14
+ * @return array Filtered block type metadata.
15
+ */
16
+ function gutenberg_block_core_file_update_interactive_view_script( $metadata ) {
17
+ if ( 'core/file' === $metadata['name'] ) {
18
+ $metadata['viewScript'] = array( 'file:./view-interactivity.min.js' );
19
+ $metadata['supports']['interactivity'] = true;
20
+ }
21
+ return $metadata;
22
+ }
23
+ add_filter( 'block_type_metadata', 'gutenberg_block_core_file_update_interactive_view_script', 10, 1 );
24
+ }
25
+
8
26
  /**
9
27
  * When the `core/file` block is rendering, check if we need to enqueue the `'wp-block-file-view` script.
10
28
  *
@@ -54,7 +72,7 @@ function render_block_core_file( $attributes, $content, $block ) {
54
72
  );
55
73
 
56
74
  // If it uses the Interactivity API, add the directives.
57
- if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN && $should_load_view_script ) {
75
+ if ( gutenberg_should_block_use_interactivity_api( 'core/file' ) && $should_load_view_script ) {
58
76
  $processor = new WP_HTML_Tag_Processor( $content );
59
77
  $processor->next_tag();
60
78
  $processor->set_attribute( 'data-wp-interactive', '' );
@@ -58,6 +58,7 @@ export default function FileBlockInspector( {
58
58
  { displayPreview && (
59
59
  <RangeControl
60
60
  __nextHasNoMarginBottom
61
+ __next40pxDefaultSize
61
62
  label={ __( 'Height in pixels' ) }
62
63
  min={ MIN_PREVIEW_HEIGHT }
63
64
  max={ Math.max(
@@ -94,6 +94,7 @@ exports[`File block renders file error state without crashing 1`] = `
94
94
  onStartShouldSetResponder={[Function]}
95
95
  placeholder="File name"
96
96
  placeholderTextColor="gray"
97
+ selectionColor="black"
97
98
  style={
98
99
  {
99
100
  "backgroundColor": undefined,
@@ -322,6 +323,7 @@ exports[`File block renders file without crashing 1`] = `
322
323
  onStartShouldSetResponder={[Function]}
323
324
  placeholder="File name"
324
325
  placeholderTextColor="gray"
326
+ selectionColor="black"
325
327
  style={
326
328
  {
327
329
  "backgroundColor": undefined,
@@ -439,22 +441,13 @@ exports[`File block renders placeholder without crashing 1`] = `
439
441
  }
440
442
  >
441
443
  <View
442
- accessibilityHint="Double tap to select"
443
- accessibilityLabel="File block. Empty"
444
- accessibilityRole="button"
445
- accessible={true}
446
- focusable={true}
447
- onClick={[Function]}
448
- onResponderGrant={[Function]}
449
- onResponderMove={[Function]}
450
- onResponderRelease={[Function]}
451
- onResponderTerminate={[Function]}
452
- onResponderTerminationRequest={[Function]}
453
- onStartShouldSetResponder={[Function]}
454
444
  style={
455
445
  [
456
446
  [
457
- undefined,
447
+ [
448
+ undefined,
449
+ false,
450
+ ],
458
451
  undefined,
459
452
  undefined,
460
453
  ],
@@ -462,33 +455,65 @@ exports[`File block renders placeholder without crashing 1`] = `
462
455
  ]
463
456
  }
464
457
  >
458
+ <View>
459
+ <View
460
+ style={
461
+ {
462
+ "fill": "black",
463
+ }
464
+ }
465
+ >
466
+ <View
467
+ style={{}}
468
+ >
469
+ <Svg
470
+ fill="black"
471
+ height={24}
472
+ style={{}}
473
+ viewBox="0 0 24 24"
474
+ width={24}
475
+ xmlns="http://www.w3.org/2000/svg"
476
+ >
477
+ Path
478
+ </Svg>
479
+ </View>
480
+ </View>
481
+ <Text>
482
+ File
483
+ </Text>
484
+ </View>
465
485
  <View
486
+ accessibilityHint="Double tap to select"
487
+ accessibilityLabel="File block. Empty"
488
+ accessibilityRole="button"
489
+ accessible={true}
490
+ collapsable={false}
491
+ focusable={true}
492
+ hitSlop={
493
+ {
494
+ "bottom": 22,
495
+ "left": 22,
496
+ "right": 22,
497
+ "top": 22,
498
+ }
499
+ }
500
+ onClick={[Function]}
501
+ onResponderGrant={[Function]}
502
+ onResponderMove={[Function]}
503
+ onResponderRelease={[Function]}
504
+ onResponderTerminate={[Function]}
505
+ onResponderTerminationRequest={[Function]}
506
+ onStartShouldSetResponder={[Function]}
466
507
  style={
467
508
  {
468
- "fill": "gray",
509
+ "opacity": 1,
469
510
  }
470
511
  }
471
512
  >
472
- <View
473
- style={{}}
474
- >
475
- <Svg
476
- height={24}
477
- style={{}}
478
- viewBox="0 0 24 24"
479
- width={24}
480
- xmlns="http://www.w3.org/2000/svg"
481
- >
482
- Path
483
- </Svg>
484
- </View>
513
+ <Text>
514
+ Choose a file
515
+ </Text>
485
516
  </View>
486
- <Text>
487
- File
488
- </Text>
489
- <Text>
490
- CHOOSE A FILE
491
- </Text>
492
517
  </View>
493
518
  </View>
494
519
  `;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { store } from '@wordpress/interactivity';
5
+ /**
6
+ * Internal dependencies
7
+ */
8
+ import { browserSupportsPdfs as hasPdfPreview } from './utils';
9
+
10
+ store( {
11
+ selectors: {
12
+ core: {
13
+ file: {
14
+ hasPdfPreview,
15
+ },
16
+ },
17
+ },
18
+ } );
package/src/file/view.js CHANGED
@@ -1,18 +1,9 @@
1
- /**
2
- * WordPress dependencies
3
- */
4
- import { store } from '@wordpress/interactivity';
5
1
  /**
6
2
  * Internal dependencies
7
3
  */
8
- import { browserSupportsPdfs as hasPdfPreview } from './utils';
4
+ import { hidePdfEmbedsOnUnsupportedBrowsers } from './utils';
9
5
 
10
- store( {
11
- selectors: {
12
- core: {
13
- file: {
14
- hasPdfPreview,
15
- },
16
- },
17
- },
18
- } );
6
+ document.addEventListener(
7
+ 'DOMContentLoaded',
8
+ hidePdfEmbedsOnUnsupportedBrowsers
9
+ );
@@ -11,7 +11,6 @@
11
11
  "supports": {
12
12
  "html": false,
13
13
  "multiple": false,
14
- "inserter": false,
15
14
  "reusable": false
16
15
  },
17
16
  "style": "wp-block-footnotes"
@@ -1,8 +1,11 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { RichText, useBlockProps } from '@wordpress/block-editor';
4
+ import { BlockIcon, RichText, useBlockProps } from '@wordpress/block-editor';
5
5
  import { useEntityProp } from '@wordpress/core-data';
6
+ import { __ } from '@wordpress/i18n';
7
+ import { Placeholder } from '@wordpress/components';
8
+ import { formatListNumbered as icon } from '@wordpress/icons';
6
9
 
7
10
  export default function FootnotesEdit( { context: { postType, postId } } ) {
8
11
  const [ meta, updateMeta ] = useEntityProp(
@@ -12,8 +15,24 @@ export default function FootnotesEdit( { context: { postType, postId } } ) {
12
15
  postId
13
16
  );
14
17
  const footnotes = meta?.footnotes ? JSON.parse( meta.footnotes ) : [];
18
+ const blockProps = useBlockProps();
19
+
20
+ if ( ! footnotes.length ) {
21
+ return (
22
+ <div { ...blockProps }>
23
+ <Placeholder
24
+ icon={ <BlockIcon icon={ icon } /> }
25
+ label={ __( 'Footnotes' ) }
26
+ instructions={ __(
27
+ 'Footnotes found in blocks within this document will be displayed here.'
28
+ ) }
29
+ />
30
+ </div>
31
+ );
32
+ }
33
+
15
34
  return (
16
- <ol { ...useBlockProps() }>
35
+ <ol { ...blockProps }>
17
36
  { footnotes.map( ( { id, content } ) => (
18
37
  <li key={ id }>
19
38
  <RichText
@@ -24,11 +24,9 @@ import { name } from './block.json';
24
24
  export const formatName = 'core/footnote';
25
25
  export const format = {
26
26
  title: __( 'Footnote' ),
27
- tagName: 'a',
27
+ tagName: 'sup',
28
28
  className: 'fn',
29
29
  attributes: {
30
- id: 'id',
31
- href: 'href',
32
30
  'data-fn': 'data-fn',
33
31
  },
34
32
  contentEditable: false,
@@ -42,26 +40,30 @@ export const format = {
42
40
  } = useSelect( blockEditorStore );
43
41
  const { selectionChange, insertBlock } =
44
42
  useDispatch( blockEditorStore );
43
+
45
44
  function onClick() {
46
45
  registry.batch( () => {
47
- const id = createId();
48
- const newValue = insertObject(
49
- value,
50
- {
51
- type: formatName,
52
- attributes: {
53
- href: '#' + id,
54
- id: `${ id }-link`,
55
- 'data-fn': id,
46
+ let id;
47
+ if ( isObjectActive ) {
48
+ const object = value.replacements[ value.start ];
49
+ id = object?.attributes?.[ 'data-fn' ];
50
+ } else {
51
+ id = createId();
52
+ const newValue = insertObject(
53
+ value,
54
+ {
55
+ type: formatName,
56
+ attributes: {
57
+ 'data-fn': id,
58
+ },
59
+ innerHTML: `<a href="#${ id }" id="${ id }-link">*</a>`,
56
60
  },
57
- innerHTML: '*',
58
- },
59
- value.end,
60
- value.end
61
- );
62
- newValue.start = newValue.end - 1;
63
-
64
- onChange( newValue );
61
+ value.end,
62
+ value.end
63
+ );
64
+ newValue.start = newValue.end - 1;
65
+ onChange( newValue );
66
+ }
65
67
 
66
68
  // BFS search to find the first footnote block.
67
69
  let fnBlock = null;
@@ -1,17 +1,20 @@
1
+ // These styles are for backwards compatibility with the old footnotes anchors.
2
+ // Can be removed in the future.
1
3
  .editor-styles-wrapper,
2
4
  .entry-content {
3
5
  counter-reset: footnotes;
4
6
  }
5
7
 
6
- [data-fn].fn {
8
+ a[data-fn].fn {
7
9
  vertical-align: super;
8
10
  font-size: smaller;
9
11
  counter-increment: footnotes;
10
- display: inline-block;
12
+ display: inline-flex;
13
+ text-decoration: none;
11
14
  text-indent: -9999999px;
12
15
  }
13
16
 
14
- [data-fn].fn::after {
17
+ a[data-fn].fn::after {
15
18
  content: "[" counter(footnotes) "]";
16
19
  text-indent: 0;
17
20
  float: left;
@@ -562,7 +562,7 @@ function GalleryEdit( props ) {
562
562
  max={ Math.min( MAX_COLUMNS, images.length ) }
563
563
  { ...MOBILE_CONTROL_PROPS_RANGE_CONTROL }
564
564
  required
565
- size="__unstable-large"
565
+ __next40pxDefaultSize
566
566
  />
567
567
  ) }
568
568
  <ToggleControl
@@ -134,7 +134,7 @@ describe( 'Gallery block', () => {
134
134
  // Tap on Gallery block
135
135
  const block = await getBlock( screen, 'Gallery' );
136
136
  fireEvent.press( block );
137
- fireEvent.press( within( block ).getByText( 'ADD MEDIA' ) );
137
+ fireEvent.press( within( block ).getByText( 'Add media' ) );
138
138
 
139
139
  // Observe that media options picker is displayed
140
140
  /* eslint-disable jest/no-conditional-expect */
@@ -161,7 +161,7 @@ describe( 'Gallery block', () => {
161
161
 
162
162
  // This case is disabled until the issue (https://github.com/WordPress/gutenberg/issues/38444)
163
163
  // is addressed.
164
- it.skip( 'block remains selected after dimissing the media options picker', async () => {
164
+ it.skip( 'block remains selected after dismissing the media options picker', async () => {
165
165
  // Initialize with an empty gallery
166
166
  const { getByLabelText, getByText, getByTestId } =
167
167
  await initializeEditor( {
@@ -169,13 +169,13 @@ describe( 'Gallery block', () => {
169
169
  } );
170
170
 
171
171
  // Tap on Gallery block
172
- fireEvent.press( getByText( 'ADD MEDIA' ) );
172
+ fireEvent.press( getByText( 'Add media' ) );
173
173
 
174
174
  // Observe that media options picker is displayed
175
175
  expect( getByText( 'Choose images' ) ).toBeVisible();
176
176
  expect( getByText( 'WordPress Media Library' ) ).toBeVisible();
177
177
 
178
- // Dimiss the picker
178
+ // Dismiss the picker
179
179
  if ( Platform.isIOS ) {
180
180
  fireEvent.press( getByText( 'Cancel' ) );
181
181
  } else {
@@ -283,7 +283,7 @@ describe( 'Gallery block', () => {
283
283
  const { selectOption } = setupPicker( screen, MEDIA_OPTIONS );
284
284
 
285
285
  // Upload images from device
286
- fireEvent.press( getByText( 'ADD MEDIA' ) );
286
+ fireEvent.press( getByText( 'Add media' ) );
287
287
  selectOption( 'Choose from device' );
288
288
  expectMediaPickerCall( 'DEVICE_MEDIA_LIBRARY', [ 'image' ], true );
289
289
 
@@ -321,7 +321,7 @@ describe( 'Gallery block', () => {
321
321
  const { galleryBlock, getByText } = await initializeWithGalleryBlock();
322
322
 
323
323
  // Upload images from device
324
- fireEvent.press( getByText( 'ADD MEDIA' ) );
324
+ fireEvent.press( getByText( 'Add media' ) );
325
325
  fireEvent.press( getByText( 'Choose from device' ) );
326
326
  expectMediaPickerCall( 'DEVICE_MEDIA_LIBRARY', [ 'image' ], true );
327
327
 
@@ -375,7 +375,7 @@ describe( 'Gallery block', () => {
375
375
  const { galleryBlock, getByText } = await initializeWithGalleryBlock();
376
376
 
377
377
  // Take a photo
378
- fireEvent.press( getByText( 'ADD MEDIA' ) );
378
+ fireEvent.press( getByText( 'Add media' ) );
379
379
  fireEvent.press( getByText( 'Take a Photo' ) );
380
380
  expectMediaPickerCall( 'DEVICE_CAMERA', [ 'image' ], true );
381
381
 
@@ -429,7 +429,7 @@ describe( 'Gallery block', () => {
429
429
  );
430
430
 
431
431
  // Upload images from free photo library
432
- fireEvent.press( getByText( 'ADD MEDIA' ) );
432
+ fireEvent.press( getByText( 'Add media' ) );
433
433
  fireEvent.press( getByText( 'Free Photo Library' ) );
434
434
  expectMediaPickerCall( 'stock-photo-library', [ 'image' ], true );
435
435
 
@@ -469,7 +469,7 @@ describe( 'Gallery block', () => {
469
469
  const { galleryBlock, getByText } = await initializeWithGalleryBlock();
470
470
 
471
471
  // Upload images from device
472
- fireEvent.press( getByText( 'ADD MEDIA' ) );
472
+ fireEvent.press( getByText( 'Add media' ) );
473
473
  fireEvent.press( getByText( 'Choose from device' ) );
474
474
  expectMediaPickerCall( 'DEVICE_MEDIA_LIBRARY', [ 'image' ], true );
475
475
 
@@ -511,10 +511,11 @@ describe( 'Gallery block', () => {
511
511
  // Reference: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/gallery.md#tc010
512
512
  it( 'rearranges gallery items', async () => {
513
513
  // Initialize with a gallery that contains three items
514
- const { galleryBlock } = await initializeWithGalleryBlock( {
515
- numberOfItems: 3,
516
- media,
517
- } );
514
+ const { getByLabelText, galleryBlock } =
515
+ await initializeWithGalleryBlock( {
516
+ numberOfItems: 3,
517
+ media,
518
+ } );
518
519
 
519
520
  // Rearrange items (final disposition will be: Image 3 - Image 1 - Image 2)
520
521
  const galleryItem1 = getGalleryItem( galleryBlock, 1 );
@@ -523,7 +524,7 @@ describe( 'Gallery block', () => {
523
524
  fireEvent.press( galleryItem3 );
524
525
  await act( () =>
525
526
  fireEvent.press(
526
- within( galleryItem3 ).getByLabelText(
527
+ getByLabelText(
527
528
  /Move block left from position 3 to position 2/
528
529
  )
529
530
  )
@@ -532,7 +533,7 @@ describe( 'Gallery block', () => {
532
533
  fireEvent.press( galleryItem1 );
533
534
  await act( () =>
534
535
  fireEvent.press(
535
- within( galleryItem1 ).getByLabelText(
536
+ getByLabelText(
536
537
  /Move block right from position 1 to position 2/
537
538
  )
538
539
  )
@@ -568,7 +569,7 @@ describe( 'Gallery block', () => {
568
569
  );
569
570
 
570
571
  // Upload images from other apps
571
- fireEvent.press( getByText( 'ADD MEDIA' ) );
572
+ fireEvent.press( getByText( 'Add media' ) );
572
573
  fireEvent.press( getByText( 'Other Apps' ) );
573
574
  expectMediaPickerCall( 'other-files', [ 'image' ], true );
574
575
 
@@ -98,8 +98,15 @@ function block_core_home_link_build_li_wrapper_attributes( $context ) {
98
98
  $colors['css_classes'],
99
99
  $font_sizes['css_classes']
100
100
  );
101
- $classes[] = 'wp-block-navigation-item';
102
101
  $style_attribute = ( $colors['inline_styles'] . $font_sizes['inline_styles'] );
102
+ $classes[] = 'wp-block-navigation-item';
103
+
104
+ if ( is_front_page() ) {
105
+ $classes[] = 'current-menu-item';
106
+ } elseif ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) {
107
+ // Edge case where the Reading settings has a posts page set but not a static homepage.
108
+ $classes[] = 'current-menu-item';
109
+ }
103
110
 
104
111
  $wrapper_attributes = get_block_wrapper_attributes(
105
112
  array(
@@ -124,8 +131,14 @@ function render_block_core_home_link( $attributes, $content, $block ) {
124
131
  if ( empty( $attributes['label'] ) ) {
125
132
  return '';
126
133
  }
134
+ $aria_current = '';
127
135
 
128
- $aria_current = is_home() || ( is_front_page() && 'page' === get_option( 'show_on_front' ) ) ? ' aria-current="page"' : '';
136
+ if ( is_front_page() ) {
137
+ $aria_current = ' aria-current="page"';
138
+ } elseif ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) {
139
+ // Edge case where the Reading settings has a posts page set but not a static homepage.
140
+ $aria_current = ' aria-current="page"';
141
+ }
129
142
 
130
143
  return sprintf(
131
144
  '<li %1$s><a class="wp-block-home-link__content wp-block-navigation-item__content" href="%2$s" rel="home"%3$s>%4$s</a></li>',
@@ -9,11 +9,12 @@
9
9
  * Renders the `core/image` block on the server,
10
10
  * adding a data-id attribute to the element if core/gallery has added on pre-render.
11
11
  *
12
- * @param array $attributes The block attributes.
13
- * @param string $content The block content.
12
+ * @param array $attributes The block attributes.
13
+ * @param string $content The block content.
14
+ * @param WP_Block $block The block object.
14
15
  * @return string Returns the block content with the data-id attribute added.
15
16
  */
16
- function render_block_core_image( $attributes, $content ) {
17
+ function render_block_core_image( $attributes, $content, $block ) {
17
18
 
18
19
  $processor = new WP_HTML_Tag_Processor( $content );
19
20
  $processor->next_tag( 'img' );
@@ -30,14 +31,52 @@ function render_block_core_image( $attributes, $content ) {
30
31
  $processor->set_attribute( 'data-id', $attributes['data-id'] );
31
32
  }
32
33
 
34
+ $should_load_view_script = false;
35
+ $experiments = get_option( 'gutenberg-experiments' );
36
+ $link_destination = isset( $attributes['linkDestination'] ) ? $attributes['linkDestination'] : 'none';
37
+ // Get the lightbox setting from the block attributes.
38
+ if ( isset( $attributes['behaviors']['lightbox'] ) ) {
39
+ $lightbox_settings = $attributes['behaviors']['lightbox'];
40
+ // If the lightbox setting is not set in the block attributes, get it from the theme.json file.
41
+ } else {
42
+ $theme_data = WP_Theme_JSON_Resolver_Gutenberg::get_merged_data()->get_data();
43
+ if ( isset( $theme_data['behaviors']['blocks'][ $block->name ]['lightbox'] ) ) {
44
+ $lightbox_settings = $theme_data['behaviors']['blocks'][ $block->name ]['lightbox'];
45
+ } else {
46
+ $lightbox_settings = null;
47
+ }
48
+ }
49
+
50
+ // If the lightbox is enabled, the image is not linked, and the Interactivity API is enabled, load the view script.
51
+ if ( isset( $lightbox_settings['enabled'] ) &&
52
+ true === $lightbox_settings['enabled'] &&
53
+ 'none' === $link_destination &&
54
+ ! empty( $experiments['gutenberg-interactivity-api-core-blocks'] )
55
+ ) {
56
+ $should_load_view_script = true;
57
+ }
58
+
59
+ $view_js_file = 'wp-block-image-view';
60
+ if ( ! wp_script_is( $view_js_file ) ) {
61
+ $script_handles = $block->block_type->view_script_handles;
62
+
63
+ // If the script is not needed, and it is still in the `view_script_handles`, remove it.
64
+ if ( ! $should_load_view_script && in_array( $view_js_file, $script_handles, true ) ) {
65
+ $block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
66
+ }
67
+ // If the script is needed, but it was previously removed, add it again.
68
+ if ( $should_load_view_script && ! in_array( $view_js_file, $script_handles, true ) ) {
69
+ $block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
70
+ }
71
+ }
72
+
33
73
  return $processor->get_updated_html();
34
74
  }
35
75
 
36
- /**
37
- * Registers the `core/image` block on server.
38
- */
76
+ /**
77
+ * Registers the `core/image` block on server.
78
+ */
39
79
  function register_block_core_image() {
40
-
41
80
  register_block_type_from_metadata(
42
81
  __DIR__ . '/image',
43
82
  array(
@@ -45,4 +84,4 @@ function register_block_core_image() {
45
84
  )
46
85
  );
47
86
  }
48
- add_action( 'init', 'register_block_core_image' );
87
+ add_action( 'init', 'register_block_core_image' );
@@ -442,7 +442,7 @@ describe( 'Image Block', () => {
442
442
  <!-- /wp:image -->`;
443
443
  const screen = await initializeEditor( { initialHtml } );
444
444
 
445
- fireEvent.press( screen.getByText( 'ADD IMAGE' ) );
445
+ fireEvent.press( screen.getByText( 'Add image' ) );
446
446
  fireEvent.press( screen.getByText( 'WordPress Media Library' ) );
447
447
 
448
448
  const expectedHtml = `<!-- wp:image {"id":${ IMAGE.id },"sizeSlug":"large","linkDestination":"none"} -->
@@ -68,6 +68,7 @@ export default function LatestComments( { attributes, setAttributes } ) {
68
68
  />
69
69
  <RangeControl
70
70
  __nextHasNoMarginBottom
71
+ __next40pxDefaultSize
71
72
  label={ __( 'Number of comments' ) }
72
73
  value={ commentsToShow }
73
74
  onChange={ ( value ) =>