@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
@@ -17,30 +17,45 @@
17
17
  * @return string Returns the post breadcrumb for hierarchical post types.
18
18
  */
19
19
  function render_block_core_breadcrumbs( $attributes, $content, $block ) {
20
- $is_home_or_front_page = is_home() || is_front_page();
21
- if ( ! $attributes['showOnHomePage'] && $is_home_or_front_page ) {
20
+ $is_front_page = is_front_page();
21
+
22
+ if ( ! $attributes['showOnHomePage'] && $is_front_page ) {
22
23
  return '';
23
24
  }
24
25
 
26
+ $is_home = is_home();
27
+ $page_for_posts = get_option( 'page_for_posts' );
25
28
  $breadcrumb_items = array();
26
29
 
27
- if ( $attributes['showHomeLink'] ) {
28
- if ( ! $is_home_or_front_page ) {
29
- $breadcrumb_items[] = block_core_breadcrumbs_create_link(
30
- home_url( '/' ),
31
- __( 'Home' )
30
+ if ( $attributes['showHomeItem'] ) {
31
+ // We make `home` a link if not on front page, or if front page
32
+ // is set to a custom page and is paged.
33
+ if ( ! $is_front_page || ( 'page' === get_option( 'show_on_front' ) && (int) get_query_var( 'page' ) > 1 ) ) {
34
+ $breadcrumb_items[] = array(
35
+ 'label' => __( 'Home' ),
36
+ 'url' => home_url( '/' ),
32
37
  );
33
38
  } else {
34
39
  $breadcrumb_items[] = block_core_breadcrumbs_create_item( __( 'Home' ), block_core_breadcrumbs_is_paged() );
35
40
  }
36
41
  }
37
42
 
38
- // Handle home and front page.
39
- if ( $is_home_or_front_page ) {
40
- // This check is explicitly nested in order not to execute the `else` branch.
43
+ // Handle home.
44
+ if ( $is_home ) {
45
+ // These checks are explicitly nested in order not to execute the `else` branch.
46
+ if ( $page_for_posts ) {
47
+ $breadcrumb_items[] = block_core_breadcrumbs_create_item( block_core_breadcrumbs_get_post_title( $page_for_posts ), block_core_breadcrumbs_is_paged() );
48
+ }
41
49
  if ( block_core_breadcrumbs_is_paged() ) {
42
50
  $breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item();
43
51
  }
52
+ } elseif ( $is_front_page ) {
53
+ // Handle front page.
54
+ // This check is explicitly nested in order not to execute the `else` branch.
55
+ // If front page is set to custom page and is paged, add the page number.
56
+ if ( (int) get_query_var( 'page' ) > 1 ) {
57
+ $breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item( 'page' );
58
+ }
44
59
  } elseif ( is_search() ) {
45
60
  // Handle search results.
46
61
  $is_paged = block_core_breadcrumbs_is_paged();
@@ -53,8 +68,8 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
53
68
  }
54
69
  } elseif ( is_404() ) {
55
70
  // Handle 404 pages.
56
- $breadcrumb_items[] = block_core_breadcrumbs_create_current_item(
57
- __( 'Page not found' )
71
+ $breadcrumb_items[] = array(
72
+ 'label' => __( 'Page not found' ),
58
73
  );
59
74
  } elseif ( is_archive() ) {
60
75
  // Handle archive pages (taxonomy, post type, date, author archives).
@@ -100,7 +115,20 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
100
115
  $show_terms = $attributes['prefersTaxonomy'];
101
116
  }
102
117
 
103
- // Build breadcrumb trail.
118
+ // Add post type archive link if applicable.
119
+ $post_type_object = get_post_type_object( $post_type );
120
+ $archive_link = get_post_type_archive_link( $post_type );
121
+ if ( $archive_link && untrailingslashit( home_url() ) !== untrailingslashit( $archive_link ) ) {
122
+ $label = $post_type_object->labels->archives;
123
+ if ( 'post' === $post_type && $page_for_posts ) {
124
+ $label = block_core_breadcrumbs_get_post_title( $page_for_posts );
125
+ }
126
+ $breadcrumb_items[] = array(
127
+ 'label' => $label,
128
+ 'url' => $archive_link,
129
+ );
130
+ }
131
+ // Build breadcrumb trail based on hierarchical structure or taxonomy terms.
104
132
  if ( ! $show_terms ) {
105
133
  $breadcrumb_items = array_merge( $breadcrumb_items, block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id ) );
106
134
  } else {
@@ -108,27 +136,26 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
108
136
  }
109
137
 
110
138
  // Add post title: linked when viewing a paginated page, plain text otherwise.
111
- $is_paged = (int) get_query_var( 'page' ) > 1;
139
+ $is_paged = (int) get_query_var( 'page' ) > 1 || (int) get_query_var( 'cpage' ) > 1;
112
140
  $title = block_core_breadcrumbs_get_post_title( $post );
113
141
 
114
142
  if ( $is_paged ) {
115
- $breadcrumb_items[] = block_core_breadcrumbs_create_link(
116
- get_permalink( $post ),
117
- $title,
118
- true
143
+ $breadcrumb_items[] = array(
144
+ 'label' => $title,
145
+ 'url' => get_permalink( $post ),
146
+ 'allow_html' => true,
119
147
  );
120
-
121
- $breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item( 'page' );
148
+ $breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item( (int) get_query_var( 'cpage' ) > 1 ? 'cpage' : 'page' );
122
149
  } else {
123
- $breadcrumb_items[] = block_core_breadcrumbs_create_current_item(
124
- $title,
125
- true
150
+ $breadcrumb_items[] = array(
151
+ 'label' => $title,
152
+ 'allow_html' => true,
126
153
  );
127
154
  }
128
155
  }
129
156
 
130
- // Remove last item if disabled.
131
- if ( ! $attributes['showLastItem'] && ! empty( $breadcrumb_items ) ) {
157
+ // Remove current item if disabled.
158
+ if ( ! $attributes['showCurrentItem'] && ! empty( $breadcrumb_items ) ) {
132
159
  array_pop( $breadcrumb_items );
133
160
  }
134
161
 
@@ -150,7 +177,11 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
150
177
  '',
151
178
  array_map(
152
179
  static function ( $item ) {
153
- return '<li>' . $item . '</li>';
180
+ $label = ! empty( $item['allow_html'] ) ? wp_kses_post( $item['label'] ) : esc_html( $item['label'] );
181
+ if ( ! empty( $item['url'] ) ) {
182
+ return '<li><a href="' . esc_url( $item['url'] ) . '">' . $label . '</a></li>';
183
+ }
184
+ return '<li><span aria-current="page">' . $label . '</span></li>';
154
185
  },
155
186
  $breadcrumb_items
156
187
  )
@@ -177,52 +208,30 @@ function block_core_breadcrumbs_is_paged() {
177
208
  *
178
209
  * @since 7.0.0
179
210
  * @param string $query_var Optional. Query variable to get current page number. Default 'paged'.
180
- * @return string The "Page X" breadcrumb HTML.
211
+ * @return array The "Page X" breadcrumb item data.
181
212
  */
182
213
  function block_core_breadcrumbs_create_page_number_item( $query_var = 'paged' ) {
183
214
  $paged = (int) get_query_var( $query_var );
184
215
 
185
- return block_core_breadcrumbs_create_current_item(
186
- /* translators: %s: page number */
187
- sprintf( __( 'Page %s' ), number_format_i18n( $paged ) )
188
- );
189
- }
216
+ if ( 'cpage' === $query_var ) {
217
+ return array(
218
+ 'label' => sprintf(
219
+ /* translators: %s: comment page number */
220
+ __( 'Comments Page %s' ),
221
+ number_format_i18n( $paged )
222
+ ),
223
+ );
224
+ }
190
225
 
191
- /**
192
- * Creates a breadcrumb link item.
193
- *
194
- * @since 7.0.0
195
- *
196
- * @param string $url The URL for the link (will be escaped).
197
- * @param string $text The link text (will be escaped).
198
- * @param bool $allow_html Whether to allow HTML in the text. If true, uses wp_kses_post(), otherwise uses esc_html(). Default false.
199
- *
200
- * @return string The breadcrumb link HTML.
201
- */
202
- function block_core_breadcrumbs_create_link( $url, $text, $allow_html = false ) {
203
- return sprintf(
204
- '<a href="%s">%s</a>',
205
- esc_url( $url ),
206
- $allow_html ? wp_kses_post( $text ) : esc_html( $text )
226
+ return array(
227
+ 'label' => sprintf(
228
+ /* translators: %s: page number */
229
+ __( 'Page %s' ),
230
+ number_format_i18n( $paged )
231
+ ),
207
232
  );
208
233
  }
209
234
 
210
- /**
211
- * Creates a breadcrumb current page item.
212
- *
213
- * @since 7.0.0
214
- *
215
- * @param string $text The text content (will be escaped).
216
- * @param bool $allow_html Whether to allow HTML in the text. If true, uses wp_kses_post(), otherwise uses esc_html(). Default false.
217
- *
218
- * @return string The breadcrumb current page HTML.
219
- */
220
- function block_core_breadcrumbs_create_current_item( $text, $allow_html = false ) {
221
- return sprintf(
222
- '<span aria-current="page">%s</span>',
223
- $allow_html ? wp_kses_post( $text ) : esc_html( $text )
224
- );
225
- }
226
235
 
227
236
  /**
228
237
  * Creates a breadcrumb item that's either a link or current page item.
@@ -232,17 +241,17 @@ function block_core_breadcrumbs_create_current_item( $text, $allow_html = false
232
241
  *
233
242
  * @since 7.0.0
234
243
  *
235
- * @param string $text The text content (will be escaped).
244
+ * @param string $text The text content.
236
245
  * @param bool $is_paged Whether we're on a paginated view.
237
- * @param bool $allow_html Whether to allow HTML in the text. If true, uses wp_kses_post(), otherwise uses esc_html(). Default false.
238
246
  *
239
- * @return string The breadcrumb HTML.
247
+ * @return array The breadcrumb item data.
240
248
  */
241
- function block_core_breadcrumbs_create_item( $text, $is_paged = false, $allow_html = false ) {
249
+ function block_core_breadcrumbs_create_item( $text, $is_paged = false ) {
250
+ $item = array( 'label' => $text );
242
251
  if ( $is_paged ) {
243
- return block_core_breadcrumbs_create_link( get_pagenum_link( 1 ), $text, $allow_html );
252
+ $item['url'] = get_pagenum_link( 1 );
244
253
  }
245
- return block_core_breadcrumbs_create_current_item( $text, $allow_html );
254
+ return $item;
246
255
  }
247
256
 
248
257
  /**
@@ -267,9 +276,9 @@ function block_core_breadcrumbs_get_post_title( $post_id_or_object ) {
267
276
  *
268
277
  * @since 7.0.0
269
278
  *
270
- * @param int $post_id The post ID.
279
+ * @param int $post_id The post ID.
271
280
  *
272
- * @return array Array of breadcrumb HTML items.
281
+ * @return array Array of breadcrumb item data.
273
282
  */
274
283
  function block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id ) {
275
284
  $breadcrumb_items = array();
@@ -277,10 +286,10 @@ function block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id
277
286
  $ancestors = array_reverse( $ancestors );
278
287
 
279
288
  foreach ( $ancestors as $ancestor_id ) {
280
- $breadcrumb_items[] = block_core_breadcrumbs_create_link(
281
- get_permalink( $ancestor_id ),
282
- block_core_breadcrumbs_get_post_title( $ancestor_id ),
283
- true
289
+ $breadcrumb_items[] = array(
290
+ 'label' => block_core_breadcrumbs_get_post_title( $ancestor_id ),
291
+ 'url' => get_permalink( $ancestor_id ),
292
+ 'allow_html' => true,
284
293
  );
285
294
  }
286
295
  return $breadcrumb_items;
@@ -296,7 +305,7 @@ function block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id
296
305
  * @param int $term_id The term ID.
297
306
  * @param string $taxonomy The taxonomy name.
298
307
  *
299
- * @return array Array of breadcrumb HTML items for ancestors.
308
+ * @return array Array of breadcrumb item data for ancestors.
300
309
  */
301
310
  function block_core_breadcrumbs_get_term_ancestors_items( $term_id, $taxonomy ) {
302
311
  $breadcrumb_items = array();
@@ -308,9 +317,9 @@ function block_core_breadcrumbs_get_term_ancestors_items( $term_id, $taxonomy )
308
317
  foreach ( $term_ancestors as $ancestor_id ) {
309
318
  $ancestor_term = get_term( $ancestor_id, $taxonomy );
310
319
  if ( $ancestor_term && ! is_wp_error( $ancestor_term ) ) {
311
- $breadcrumb_items[] = block_core_breadcrumbs_create_link(
312
- get_term_link( $ancestor_term ),
313
- $ancestor_term->name
320
+ $breadcrumb_items[] = array(
321
+ 'label' => $ancestor_term->name,
322
+ 'url' => get_term_link( $ancestor_term ),
314
323
  );
315
324
  }
316
325
  }
@@ -327,7 +336,7 @@ function block_core_breadcrumbs_get_term_ancestors_items( $term_id, $taxonomy )
327
336
  *
328
337
  * @since 7.0.0
329
338
  *
330
- * @return array Array of breadcrumb HTML items.
339
+ * @return array Array of breadcrumb item data.
331
340
  */
332
341
  function block_core_breadcrumbs_get_archive_breadcrumbs() {
333
342
  $breadcrumb_items = array();
@@ -354,16 +363,16 @@ function block_core_breadcrumbs_get_archive_breadcrumbs() {
354
363
  if ( $year ) {
355
364
  if ( $month ) {
356
365
  // Year is linked if we have month.
357
- $breadcrumb_items[] = block_core_breadcrumbs_create_link(
358
- get_year_link( $year ),
359
- $year
366
+ $breadcrumb_items[] = array(
367
+ 'label' => $year,
368
+ 'url' => get_year_link( $year ),
360
369
  );
361
370
 
362
371
  if ( $day ) {
363
372
  // Month is linked if we have day.
364
- $breadcrumb_items[] = block_core_breadcrumbs_create_link(
365
- get_month_link( $year, $month ),
366
- date_i18n( 'F', mktime( 0, 0, 0, $month, 1, $year ) )
373
+ $breadcrumb_items[] = array(
374
+ 'label' => date_i18n( 'F', mktime( 0, 0, 0, $month, 1, $year ) ),
375
+ 'url' => get_month_link( $year, $month ),
367
376
  );
368
377
  // Add day (current if not paginated, link if paginated).
369
378
  $breadcrumb_items[] = block_core_breadcrumbs_create_item(
@@ -429,7 +438,7 @@ function block_core_breadcrumbs_get_archive_breadcrumbs() {
429
438
  if ( $post_type_object ) {
430
439
  // Add post type (current if not paginated, link if paginated).
431
440
  $breadcrumb_items[] = block_core_breadcrumbs_create_item(
432
- $post_type_object->labels->name,
441
+ $post_type_object->labels->archives,
433
442
  $is_paged
434
443
  );
435
444
  }
@@ -462,10 +471,11 @@ function block_core_breadcrumbs_get_archive_breadcrumbs() {
462
471
  * @param int $post_id The post ID.
463
472
  * @param string $post_type The post type name.
464
473
  *
465
- * @return array Array of breadcrumb HTML items.
474
+ * @return array Array of breadcrumb item data.
466
475
  */
467
476
  function block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) {
468
477
  $breadcrumb_items = array();
478
+
469
479
  // Get public taxonomies for this post type.
470
480
  $taxonomies = wp_filter_object_list(
471
481
  get_object_taxonomies( $post_type, 'objects' ),
@@ -476,7 +486,7 @@ function block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) {
476
486
  );
477
487
 
478
488
  if ( empty( $taxonomies ) ) {
479
- return array();
489
+ return $breadcrumb_items;
480
490
  }
481
491
 
482
492
  /**
@@ -550,9 +560,9 @@ function block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) {
550
560
  $breadcrumb_items,
551
561
  block_core_breadcrumbs_get_term_ancestors_items( $term->term_id, $taxonomy_name )
552
562
  );
553
- $breadcrumb_items[] = block_core_breadcrumbs_create_link(
554
- get_term_link( $term ),
555
- $term->name
563
+ $breadcrumb_items[] = array(
564
+ 'label' => $term->name,
565
+ 'url' => get_term_link( $term ),
556
566
  );
557
567
  }
558
568
  return $breadcrumb_items;
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { button as icon } from '@wordpress/icons';
6
+ import { privateApis as blocksPrivateApis } from '@wordpress/blocks';
6
7
 
7
8
  /**
8
9
  * Internal dependencies
@@ -12,6 +13,9 @@ import deprecated from './deprecated';
12
13
  import edit from './edit';
13
14
  import metadata from './block.json';
14
15
  import save from './save';
16
+ import { unlock } from '../lock-unlock';
17
+
18
+ const { fieldsKey, formKey } = unlock( blocksPrivateApis );
15
19
 
16
20
  const { name } = metadata;
17
21
 
@@ -34,27 +38,27 @@ export const settings = {
34
38
  } ),
35
39
  };
36
40
 
37
- if ( window.__experimentalContentOnlyPatternInsertion ) {
38
- settings.fields = [
41
+ if ( window.__experimentalContentOnlyInspectorFields ) {
42
+ settings[ fieldsKey ] = [
39
43
  {
44
+ id: 'text',
40
45
  label: __( 'Content' ),
41
- type: 'RichText',
42
- shownByDefault: true,
43
- mapping: {
44
- value: 'text',
45
- },
46
+ type: 'richtext',
46
47
  },
47
48
  {
49
+ id: 'link',
48
50
  label: __( 'Link' ),
49
- type: 'Link',
50
- shownByDefault: false,
51
+ type: 'link',
51
52
  mapping: {
52
- href: 'url',
53
+ url: 'url',
53
54
  rel: 'rel',
54
- target: 'linkTarget',
55
+ linkTarget: 'linkTarget',
55
56
  },
56
57
  },
57
58
  ];
59
+ settings[ formKey ] = {
60
+ fields: [ 'text' ],
61
+ };
58
62
  }
59
63
 
60
64
  export const init = () => initBlock( { name, metadata, settings } );
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
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { code as icon } from '@wordpress/icons';
6
+ import { privateApis as blocksPrivateApis } from '@wordpress/blocks';
6
7
 
7
8
  /**
8
9
  * Internal dependencies
@@ -12,6 +13,9 @@ import edit from './edit';
12
13
  import metadata from './block.json';
13
14
  import save from './save';
14
15
  import transforms from './transforms';
16
+ import { unlock } from '../lock-unlock';
17
+
18
+ const { fieldsKey, formKey } = unlock( blocksPrivateApis );
15
19
 
16
20
  const { name } = metadata;
17
21
 
@@ -39,17 +43,17 @@ export const settings = {
39
43
  save,
40
44
  };
41
45
 
42
- if ( window.__experimentalContentOnlyPatternInsertion ) {
43
- settings.fields = [
46
+ if ( window.__experimentalContentOnlyInspectorFields ) {
47
+ settings[ fieldsKey ] = [
44
48
  {
49
+ id: 'content',
45
50
  label: __( 'Code' ),
46
- type: 'RichText',
47
- shownByDefault: true,
48
- mapping: {
49
- value: 'content',
50
- },
51
+ type: 'richtext',
51
52
  },
52
53
  ];
54
+ settings[ formKey ] = {
55
+ fields: [ 'content' ],
56
+ };
53
57
  }
54
58
 
55
59
  export const init = () => initBlock( { name, metadata, settings } );
@@ -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
 
@@ -11,12 +11,15 @@ import {
11
11
  privateApis as blockEditorPrivateApis,
12
12
  } from '@wordpress/block-editor';
13
13
  import { __ } from '@wordpress/i18n';
14
+ import { MenuItem } from '@wordpress/components';
15
+ import { link } from '@wordpress/icons';
14
16
 
15
17
  /**
16
18
  * Internal dependencies
17
19
  */
18
20
  import { ALLOWED_MEDIA_TYPES } from '../shared';
19
21
  import { unlock } from '../../lock-unlock';
22
+ import EmbedVideoUrlInput from './embed-video-url-input';
20
23
 
21
24
  const { cleanEmptyObject } = unlock( blockEditorPrivateApis );
22
25
 
@@ -27,6 +30,7 @@ export default function CoverBlockControls( {
27
30
  currentSettings,
28
31
  toggleUseFeaturedImage,
29
32
  onClearMedia,
33
+ onSelectEmbedUrl,
30
34
  blockEditingMode,
31
35
  } ) {
32
36
  const { contentPosition, id, useFeaturedImage, minHeight, minHeightUnit } =
@@ -36,6 +40,7 @@ export default function CoverBlockControls( {
36
40
  const [ prevMinHeightValue, setPrevMinHeightValue ] = useState( minHeight );
37
41
  const [ prevMinHeightUnit, setPrevMinHeightUnit ] =
38
42
  useState( minHeightUnit );
43
+ const [ isEmbedUrlInputOpen, setIsEmbedUrlInputOpen ] = useState( false );
39
44
  const isMinFullHeight =
40
45
  minHeightUnit === 'vh' &&
41
46
  minHeight === 100 &&
@@ -102,14 +107,33 @@ export default function CoverBlockControls( {
102
107
  mediaId={ id }
103
108
  mediaURL={ url }
104
109
  allowedTypes={ ALLOWED_MEDIA_TYPES }
105
- accept="image/*,video/*"
106
110
  onSelect={ onSelectMedia }
107
111
  onToggleFeaturedImage={ toggleUseFeaturedImage }
108
112
  useFeaturedImage={ useFeaturedImage }
109
113
  name={ ! url ? __( 'Add media' ) : __( 'Replace' ) }
110
114
  onReset={ onClearMedia }
111
- />
115
+ >
116
+ { ( { onClose } ) => (
117
+ <MenuItem
118
+ icon={ link }
119
+ onClick={ () => {
120
+ setIsEmbedUrlInputOpen( true );
121
+ onClose();
122
+ } }
123
+ >
124
+ { __( 'Embed video from URL' ) }
125
+ </MenuItem>
126
+ ) }
127
+ </MediaReplaceFlow>
112
128
  </BlockControls>
129
+ { isEmbedUrlInputOpen && (
130
+ <EmbedVideoUrlInput
131
+ onSubmit={ ( embedUrl ) => {
132
+ onSelectEmbedUrl( embedUrl );
133
+ } }
134
+ onClose={ () => setIsEmbedUrlInputOpen( false ) }
135
+ />
136
+ ) }
113
137
  </>
114
138
  );
115
139
  }
@@ -25,7 +25,6 @@ export default function CoverPlaceholder( {
25
25
  title: __( 'Cover' ),
26
26
  } }
27
27
  onSelect={ onSelectMedia }
28
- accept="image/*,video/*"
29
28
  allowedTypes={ ALLOWED_MEDIA_TYPES }
30
29
  disableMediaButtons={ disableMediaButtons }
31
30
  onToggleFeaturedImage={ toggleUseFeaturedImage }