@wordpress/block-library 9.35.1-next.dc3f6d3c1.0 → 9.36.1-next.8b30e05b0.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 (262) 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 +12 -9
  9. package/build/audio/index.js.map +3 -3
  10. package/build/button/index.js +13 -10
  11. package/build/button/index.js.map +3 -3
  12. package/build/code/index.js +9 -6
  13. package/build/code/index.js.map +3 -3
  14. package/build/cover/edit/block-controls.js +37 -3
  15. package/build/cover/edit/block-controls.js.map +3 -3
  16. package/build/cover/edit/cover-placeholder.js +0 -1
  17. package/build/cover/edit/cover-placeholder.js.map +2 -2
  18. package/build/cover/edit/embed-video-url-input.js +83 -0
  19. package/build/cover/edit/embed-video-url-input.js.map +7 -0
  20. package/build/cover/edit/index.js +60 -0
  21. package/build/cover/edit/index.js.map +2 -2
  22. package/build/cover/embed-video-utils.js +151 -0
  23. package/build/cover/embed-video-utils.js.map +7 -0
  24. package/build/cover/index.js +10 -4
  25. package/build/cover/index.js.map +3 -3
  26. package/build/cover/save.js +12 -0
  27. package/build/cover/save.js.map +2 -2
  28. package/build/cover/shared.js +3 -0
  29. package/build/cover/shared.js.map +2 -2
  30. package/build/details/index.js +9 -6
  31. package/build/details/index.js.map +3 -3
  32. package/build/file/index.js +14 -14
  33. package/build/file/index.js.map +3 -3
  34. package/build/freeform/block.json +1 -1
  35. package/build/gallery/edit.js +0 -2
  36. package/build/gallery/edit.js.map +2 -2
  37. package/build/heading/index.js +9 -6
  38. package/build/heading/index.js.map +3 -3
  39. package/build/html/modal.js +127 -118
  40. package/build/html/modal.js.map +3 -3
  41. package/build/image/edit.js +0 -1
  42. package/build/image/edit.js.map +2 -2
  43. package/build/image/image.js +0 -1
  44. package/build/image/image.js.map +2 -2
  45. package/build/image/index.js +18 -18
  46. package/build/image/index.js.map +3 -3
  47. package/build/list-item/index.js +8 -6
  48. package/build/list-item/index.js.map +3 -3
  49. package/build/math/block.json +28 -1
  50. package/build/math/edit.js +4 -1
  51. package/build/math/edit.js.map +2 -2
  52. package/build/media-text/index.js +15 -8
  53. package/build/media-text/index.js.map +3 -3
  54. package/build/media-text/media-container.js +0 -2
  55. package/build/media-text/media-container.js.map +2 -2
  56. package/build/missing/block.json +1 -1
  57. package/build/missing/edit.js +2 -2
  58. package/build/missing/edit.js.map +1 -1
  59. package/build/more/index.js +9 -6
  60. package/build/more/index.js.map +3 -3
  61. package/build/navigation-link/edit.js +36 -11
  62. package/build/navigation-link/edit.js.map +2 -2
  63. package/build/navigation-link/index.js +11 -8
  64. package/build/navigation-link/index.js.map +3 -3
  65. package/build/navigation-submenu/index.js +11 -8
  66. package/build/navigation-submenu/index.js.map +3 -3
  67. package/build/paragraph/deprecated-attributes.js +68 -0
  68. package/build/paragraph/deprecated-attributes.js.map +7 -0
  69. package/build/paragraph/edit.js +2 -0
  70. package/build/paragraph/edit.js.map +3 -3
  71. package/build/paragraph/index.js +9 -6
  72. package/build/paragraph/index.js.map +3 -3
  73. package/build/pattern/block.json +1 -1
  74. package/build/preformatted/index.js +9 -6
  75. package/build/preformatted/index.js.map +3 -3
  76. package/build/pullquote/index.js +11 -11
  77. package/build/pullquote/index.js.map +3 -3
  78. package/build/search/index.js +14 -16
  79. package/build/search/index.js.map +3 -3
  80. package/build/social-link/index.js +11 -8
  81. package/build/social-link/index.js.map +3 -3
  82. package/build/template-part/edit/index.js +37 -7
  83. package/build/template-part/edit/index.js.map +2 -2
  84. package/build/template-part/edit/utils/hooks.js +2 -3
  85. package/build/template-part/edit/utils/hooks.js.map +2 -2
  86. package/build/term-count/index.js +1 -0
  87. package/build/term-count/index.js.map +2 -2
  88. package/build/term-name/index.js +1 -0
  89. package/build/term-name/index.js.map +2 -2
  90. package/build/verse/index.js +9 -6
  91. package/build/verse/index.js.map +3 -3
  92. package/build/video/index.js +12 -9
  93. package/build/video/index.js.map +3 -3
  94. package/build-module/accordion/view.js +46 -4
  95. package/build-module/accordion/view.js.map +2 -2
  96. package/build-module/accordion-heading/block.json +1 -1
  97. package/build-module/accordion-heading/deprecated.js +1 -1
  98. package/build-module/accordion-heading/deprecated.js.map +2 -2
  99. package/build-module/accordion-panel/block.json +1 -1
  100. package/build-module/audio/index.js +12 -9
  101. package/build-module/audio/index.js.map +2 -2
  102. package/build-module/button/index.js +13 -10
  103. package/build-module/button/index.js.map +2 -2
  104. package/build-module/code/index.js +9 -6
  105. package/build-module/code/index.js.map +2 -2
  106. package/build-module/cover/edit/block-controls.js +27 -3
  107. package/build-module/cover/edit/block-controls.js.map +2 -2
  108. package/build-module/cover/edit/cover-placeholder.js +0 -1
  109. package/build-module/cover/edit/cover-placeholder.js.map +2 -2
  110. package/build-module/cover/edit/embed-video-url-input.js +67 -0
  111. package/build-module/cover/edit/embed-video-url-input.js.map +7 -0
  112. package/build-module/cover/edit/index.js +61 -0
  113. package/build-module/cover/edit/index.js.map +2 -2
  114. package/build-module/cover/embed-video-utils.js +122 -0
  115. package/build-module/cover/embed-video-utils.js.map +7 -0
  116. package/build-module/cover/index.js +10 -4
  117. package/build-module/cover/index.js.map +2 -2
  118. package/build-module/cover/save.js +13 -0
  119. package/build-module/cover/save.js.map +2 -2
  120. package/build-module/cover/shared.js +2 -0
  121. package/build-module/cover/shared.js.map +2 -2
  122. package/build-module/details/index.js +9 -6
  123. package/build-module/details/index.js.map +2 -2
  124. package/build-module/file/index.js +14 -14
  125. package/build-module/file/index.js.map +2 -2
  126. package/build-module/freeform/block.json +1 -1
  127. package/build-module/gallery/edit.js +0 -2
  128. package/build-module/gallery/edit.js.map +2 -2
  129. package/build-module/heading/index.js +9 -6
  130. package/build-module/heading/index.js.map +2 -2
  131. package/build-module/html/modal.js +128 -119
  132. package/build-module/html/modal.js.map +2 -2
  133. package/build-module/image/edit.js +0 -1
  134. package/build-module/image/edit.js.map +2 -2
  135. package/build-module/image/image.js +0 -1
  136. package/build-module/image/image.js.map +2 -2
  137. package/build-module/image/index.js +18 -18
  138. package/build-module/image/index.js.map +2 -2
  139. package/build-module/list-item/index.js +8 -6
  140. package/build-module/list-item/index.js.map +2 -2
  141. package/build-module/math/block.json +28 -1
  142. package/build-module/math/edit.js +4 -1
  143. package/build-module/math/edit.js.map +2 -2
  144. package/build-module/media-text/index.js +15 -8
  145. package/build-module/media-text/index.js.map +2 -2
  146. package/build-module/media-text/media-container.js +0 -2
  147. package/build-module/media-text/media-container.js.map +2 -2
  148. package/build-module/missing/block.json +1 -1
  149. package/build-module/missing/edit.js +2 -2
  150. package/build-module/missing/edit.js.map +1 -1
  151. package/build-module/more/index.js +9 -6
  152. package/build-module/more/index.js.map +2 -2
  153. package/build-module/navigation-link/edit.js +37 -12
  154. package/build-module/navigation-link/edit.js.map +2 -2
  155. package/build-module/navigation-link/index.js +11 -8
  156. package/build-module/navigation-link/index.js.map +2 -2
  157. package/build-module/navigation-submenu/index.js +11 -8
  158. package/build-module/navigation-submenu/index.js.map +2 -2
  159. package/build-module/paragraph/deprecated-attributes.js +37 -0
  160. package/build-module/paragraph/deprecated-attributes.js.map +7 -0
  161. package/build-module/paragraph/edit.js +2 -0
  162. package/build-module/paragraph/edit.js.map +2 -2
  163. package/build-module/paragraph/index.js +9 -6
  164. package/build-module/paragraph/index.js.map +2 -2
  165. package/build-module/pattern/block.json +1 -1
  166. package/build-module/preformatted/index.js +9 -6
  167. package/build-module/preformatted/index.js.map +2 -2
  168. package/build-module/pullquote/index.js +11 -11
  169. package/build-module/pullquote/index.js.map +2 -2
  170. package/build-module/search/index.js +14 -16
  171. package/build-module/search/index.js.map +2 -2
  172. package/build-module/social-link/index.js +11 -8
  173. package/build-module/social-link/index.js.map +2 -2
  174. package/build-module/template-part/edit/index.js +37 -7
  175. package/build-module/template-part/edit/index.js.map +2 -2
  176. package/build-module/template-part/edit/utils/hooks.js +2 -3
  177. package/build-module/template-part/edit/utils/hooks.js.map +2 -2
  178. package/build-module/term-count/index.js +1 -0
  179. package/build-module/term-count/index.js.map +2 -2
  180. package/build-module/term-name/index.js +1 -0
  181. package/build-module/term-name/index.js.map +2 -2
  182. package/build-module/verse/index.js +9 -6
  183. package/build-module/verse/index.js.map +2 -2
  184. package/build-module/video/index.js +12 -9
  185. package/build-module/video/index.js.map +2 -2
  186. package/build-style/accordion/style-rtl.css +3 -0
  187. package/build-style/accordion/style.css +3 -0
  188. package/build-style/accordion-heading/style-rtl.css +1 -2
  189. package/build-style/accordion-heading/style.css +1 -2
  190. package/build-style/accordion-item/style-rtl.css +0 -7
  191. package/build-style/accordion-item/style.css +0 -7
  192. package/build-style/accordion-panel/style-rtl.css +1 -4
  193. package/build-style/accordion-panel/style.css +1 -4
  194. package/build-style/cover/style-rtl.css +47 -0
  195. package/build-style/cover/style.css +47 -0
  196. package/build-style/editor-rtl.css +11 -13
  197. package/build-style/editor.css +11 -13
  198. package/build-style/html/editor-rtl.css +11 -13
  199. package/build-style/html/editor.css +11 -13
  200. package/build-style/style-rtl.css +52 -12
  201. package/build-style/style.css +52 -12
  202. package/package.json +37 -37
  203. package/src/accordion/style.scss +4 -0
  204. package/src/accordion/view.js +60 -3
  205. package/src/accordion-heading/block.json +1 -1
  206. package/src/accordion-heading/deprecated.js +1 -1
  207. package/src/accordion-heading/style.scss +1 -9
  208. package/src/accordion-item/index.php +1 -0
  209. package/src/accordion-item/style.scss +2 -9
  210. package/src/accordion-panel/block.json +1 -1
  211. package/src/accordion-panel/style.scss +1 -5
  212. package/src/audio/index.js +13 -9
  213. package/src/breadcrumbs/index.php +71 -82
  214. package/src/button/index.js +14 -10
  215. package/src/code/index.js +10 -6
  216. package/src/cover/edit/block-controls.js +26 -2
  217. package/src/cover/edit/cover-placeholder.js +0 -1
  218. package/src/cover/edit/embed-video-url-input.js +74 -0
  219. package/src/cover/edit/index.js +81 -0
  220. package/src/cover/embed-video-utils.js +196 -0
  221. package/src/cover/index.js +11 -4
  222. package/src/cover/index.php +106 -0
  223. package/src/cover/save.js +14 -0
  224. package/src/cover/shared.js +1 -0
  225. package/src/cover/style.scss +47 -0
  226. package/src/details/index.js +10 -6
  227. package/src/file/index.js +15 -14
  228. package/src/freeform/block.json +1 -1
  229. package/src/gallery/edit.js +0 -2
  230. package/src/heading/index.js +10 -6
  231. package/src/html/editor.scss +10 -15
  232. package/src/html/modal.js +15 -10
  233. package/src/image/edit.js +0 -1
  234. package/src/image/image.js +0 -1
  235. package/src/image/index.js +19 -18
  236. package/src/image/index.php +1 -0
  237. package/src/list-item/index.js +9 -6
  238. package/src/math/block.json +28 -1
  239. package/src/math/edit.js +4 -1
  240. package/src/media-text/index.js +16 -8
  241. package/src/media-text/media-container.js +0 -2
  242. package/src/missing/block.json +1 -1
  243. package/src/missing/edit.js +2 -2
  244. package/src/more/index.js +10 -6
  245. package/src/navigation-link/edit.js +72 -26
  246. package/src/navigation-link/index.js +12 -8
  247. package/src/navigation-submenu/index.js +12 -8
  248. package/src/paragraph/deprecated-attributes.js +45 -0
  249. package/src/paragraph/edit.js +2 -0
  250. package/src/paragraph/index.js +10 -6
  251. package/src/pattern/block.json +1 -1
  252. package/src/preformatted/index.js +10 -6
  253. package/src/pullquote/index.js +12 -11
  254. package/src/search/index.js +14 -15
  255. package/src/social-link/index.js +12 -8
  256. package/src/style.scss +1 -0
  257. package/src/template-part/edit/index.js +44 -6
  258. package/src/template-part/edit/utils/hooks.js +2 -4
  259. package/src/term-count/index.js +1 -0
  260. package/src/term-name/index.js +1 -0
  261. package/src/verse/index.js +10 -6
  262. package/src/video/index.js +13 -9
@@ -57,7 +57,7 @@
57
57
  }
58
58
  },
59
59
  "shadow": true,
60
- "blockVisibility": false,
60
+ "visibility": false,
61
61
  "lock": false
62
62
  },
63
63
  "selectors": {
@@ -74,7 +74,7 @@ const v1 = {
74
74
  },
75
75
  },
76
76
  shadow: true,
77
- blockVisibility: false,
77
+ visibility: false,
78
78
  },
79
79
  save( { attributes } ) {
80
80
  const { level, title, iconPosition, showIcon } = attributes;
@@ -1,12 +1,4 @@
1
- // In many classic themes, selectors like `.entry-content h1` are used,
2
- // potentially applying relatively high specificity (such as `0-1-1`) to
3
- // heading elements. To properly override those styles, use a selector
4
- // with a specificity of `0-2-0`.
5
- .wp-block-accordion-heading.wp-block-accordion-heading {
6
- // Some themes may have an explicit width. Since it's unpredictable
7
- // what CSS specificity should be used to override them, ensure 100%
8
- // width using min-width instead.
9
- min-width: 100%;
1
+ .wp-block-accordion-heading {
10
2
  // Some classic themes apply default margins to heading elements,
11
3
  // so those styles need to be reset.
12
4
  margin: 0;
@@ -36,6 +36,7 @@ function block_core_accordion_item_render( $attributes, $content ) {
36
36
  $p->set_attribute( 'data-wp-context', '{ "id": "' . $unique_id . '", "openByDefault": ' . $open_by_default . ' }' );
37
37
  $p->set_attribute( 'data-wp-class--is-open', 'state.isOpen' );
38
38
  $p->set_attribute( 'data-wp-init', 'callbacks.initAccordionItems' );
39
+ $p->set_attribute( 'data-wp-on-window--hashchange', 'callbacks.hashChange' );
39
40
 
40
41
  if ( $p->next_tag( array( 'class_name' => 'wp-block-accordion-heading__toggle' ) ) ) {
41
42
  $p->set_attribute( 'data-wp-on--click', 'actions.toggle' );
@@ -1,13 +1,6 @@
1
1
  .wp-block-accordion-item {
2
- display: grid;
3
- grid-template-rows: max-content 0fr;
4
-
5
- &.is-open {
6
- grid-template-rows: max-content 1fr;
7
-
8
- > .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon {
9
- transform: rotate(45deg);
10
- }
2
+ &.is-open > .wp-block-accordion-heading .wp-block-accordion-heading__toggle-icon {
3
+ transform: rotate(45deg);
11
4
  }
12
5
 
13
6
  /* Add transitions only for users who do not prefer reduced motion */
@@ -50,7 +50,7 @@
50
50
  "layout": {
51
51
  "allowEditing": false
52
52
  },
53
- "blockVisibility": false,
53
+ "visibility": false,
54
54
  "contentRole": true,
55
55
  "allowedBlocks": true,
56
56
  "lock": false
@@ -1,8 +1,4 @@
1
- // Some classic themes may use selectors like `.wp-block .wp-block`
2
- // and apply some kind of width to the blocks. To properly override
3
- // those styles, use a selector with a specificity of `0-2-0`.
4
- .wp-block-accordion-panel.wp-block-accordion-panel {
5
- min-width: 100%;
1
+ .wp-block-accordion-panel {
6
2
 
7
3
  // Prevent blockGap from Accordion Content block from adding extra margin between accordions.
8
4
  &[inert],
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import { __ } from '@wordpress/i18n';
5
5
  import { audio 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
 
@@ -33,14 +37,14 @@ export const settings = {
33
37
  };
34
38
 
35
39
  if ( window.__experimentalContentOnlyPatternInsertion ) {
36
- settings.fields = [
40
+ settings[ fieldsKey ] = [
37
41
  {
42
+ id: 'audio',
38
43
  label: __( 'Audio' ),
39
- type: 'Media',
40
- shownByDefault: true,
44
+ type: 'media',
41
45
  mapping: {
42
46
  id: 'id',
43
- src: 'src',
47
+ url: 'src',
44
48
  },
45
49
  args: {
46
50
  allowedTypes: [ 'audio' ],
@@ -48,14 +52,14 @@ if ( window.__experimentalContentOnlyPatternInsertion ) {
48
52
  },
49
53
  },
50
54
  {
55
+ id: 'caption',
51
56
  label: __( 'Caption' ),
52
- type: 'RichText',
53
- shownByDefault: false,
54
- mapping: {
55
- value: 'caption',
56
- },
57
+ type: 'richtext',
57
58
  },
58
59
  ];
60
+ settings[ formKey ] = {
61
+ fields: [ 'audio' ],
62
+ };
59
63
  }
60
64
 
61
65
  export const init = () => initBlock( { name, metadata, settings } );
@@ -26,9 +26,9 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
26
26
 
27
27
  if ( $attributes['showHomeLink'] ) {
28
28
  if ( ! $is_home_or_front_page ) {
29
- $breadcrumb_items[] = block_core_breadcrumbs_create_link(
30
- home_url( '/' ),
31
- __( 'Home' )
29
+ $breadcrumb_items[] = array(
30
+ 'label' => __( 'Home' ),
31
+ 'url' => home_url( '/' ),
32
32
  );
33
33
  } else {
34
34
  $breadcrumb_items[] = block_core_breadcrumbs_create_item( __( 'Home' ), block_core_breadcrumbs_is_paged() );
@@ -53,8 +53,8 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
53
53
  }
54
54
  } elseif ( is_404() ) {
55
55
  // Handle 404 pages.
56
- $breadcrumb_items[] = block_core_breadcrumbs_create_current_item(
57
- __( 'Page not found' )
56
+ $breadcrumb_items[] = array(
57
+ 'label' => __( 'Page not found' ),
58
58
  );
59
59
  } elseif ( is_archive() ) {
60
60
  // Handle archive pages (taxonomy, post type, date, author archives).
@@ -100,7 +100,23 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
100
100
  $show_terms = $attributes['prefersTaxonomy'];
101
101
  }
102
102
 
103
- // Build breadcrumb trail.
103
+ // Add post type archive link if applicable.
104
+ $post_type_object = get_post_type_object( $post_type );
105
+ $archive_link = get_post_type_archive_link( $post_type );
106
+ if ( $archive_link && untrailingslashit( home_url() ) !== untrailingslashit( $archive_link ) ) {
107
+ $label = $post_type_object->labels->archives;
108
+ if ( 'post' === $post_type ) {
109
+ $page_for_posts = get_option( 'page_for_posts' );
110
+ if ( $page_for_posts ) {
111
+ $label = block_core_breadcrumbs_get_post_title( $page_for_posts );
112
+ }
113
+ }
114
+ $breadcrumb_items[] = array(
115
+ 'label' => $label,
116
+ 'url' => $archive_link,
117
+ );
118
+ }
119
+ // Build breadcrumb trail based on hierarchical structure or taxonomy terms.
104
120
  if ( ! $show_terms ) {
105
121
  $breadcrumb_items = array_merge( $breadcrumb_items, block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id ) );
106
122
  } else {
@@ -112,17 +128,17 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
112
128
  $title = block_core_breadcrumbs_get_post_title( $post );
113
129
 
114
130
  if ( $is_paged ) {
115
- $breadcrumb_items[] = block_core_breadcrumbs_create_link(
116
- get_permalink( $post ),
117
- $title,
118
- true
131
+ $breadcrumb_items[] = array(
132
+ 'label' => $title,
133
+ 'url' => get_permalink( $post ),
134
+ 'allow_html' => true,
119
135
  );
120
136
 
121
137
  $breadcrumb_items[] = block_core_breadcrumbs_create_page_number_item( 'page' );
122
138
  } else {
123
- $breadcrumb_items[] = block_core_breadcrumbs_create_current_item(
124
- $title,
125
- true
139
+ $breadcrumb_items[] = array(
140
+ 'label' => $title,
141
+ 'allow_html' => true,
126
142
  );
127
143
  }
128
144
  }
@@ -150,7 +166,11 @@ function render_block_core_breadcrumbs( $attributes, $content, $block ) {
150
166
  '',
151
167
  array_map(
152
168
  static function ( $item ) {
153
- return '<li>' . $item . '</li>';
169
+ $label = ! empty( $item['allow_html'] ) ? wp_kses_post( $item['label'] ) : esc_html( $item['label'] );
170
+ if ( ! empty( $item['url'] ) ) {
171
+ return '<li><a href="' . esc_url( $item['url'] ) . '">' . $label . '</a></li>';
172
+ }
173
+ return '<li><span aria-current="page">' . $label . '</span></li>';
154
174
  },
155
175
  $breadcrumb_items
156
176
  )
@@ -177,52 +197,20 @@ function block_core_breadcrumbs_is_paged() {
177
197
  *
178
198
  * @since 7.0.0
179
199
  * @param string $query_var Optional. Query variable to get current page number. Default 'paged'.
180
- * @return string The "Page X" breadcrumb HTML.
200
+ * @return array The "Page X" breadcrumb item data.
181
201
  */
182
202
  function block_core_breadcrumbs_create_page_number_item( $query_var = 'paged' ) {
183
203
  $paged = (int) get_query_var( $query_var );
184
204
 
185
- return block_core_breadcrumbs_create_current_item(
186
- /* translators: %s: page number */
187
- sprintf( __( 'Page %s' ), number_format_i18n( $paged ) )
188
- );
189
- }
190
-
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 )
205
+ return array(
206
+ 'label' => sprintf(
207
+ /* translators: %s: page number */
208
+ __( 'Page %s' ),
209
+ number_format_i18n( $paged )
210
+ ),
207
211
  );
208
212
  }
209
213
 
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
214
 
227
215
  /**
228
216
  * Creates a breadcrumb item that's either a link or current page item.
@@ -232,17 +220,17 @@ function block_core_breadcrumbs_create_current_item( $text, $allow_html = false
232
220
  *
233
221
  * @since 7.0.0
234
222
  *
235
- * @param string $text The text content (will be escaped).
223
+ * @param string $text The text content.
236
224
  * @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
225
  *
239
- * @return string The breadcrumb HTML.
226
+ * @return array The breadcrumb item data.
240
227
  */
241
- function block_core_breadcrumbs_create_item( $text, $is_paged = false, $allow_html = false ) {
228
+ function block_core_breadcrumbs_create_item( $text, $is_paged = false ) {
229
+ $item = array( 'label' => $text );
242
230
  if ( $is_paged ) {
243
- return block_core_breadcrumbs_create_link( get_pagenum_link( 1 ), $text, $allow_html );
231
+ $item['url'] = get_pagenum_link( 1 );
244
232
  }
245
- return block_core_breadcrumbs_create_current_item( $text, $allow_html );
233
+ return $item;
246
234
  }
247
235
 
248
236
  /**
@@ -267,9 +255,9 @@ function block_core_breadcrumbs_get_post_title( $post_id_or_object ) {
267
255
  *
268
256
  * @since 7.0.0
269
257
  *
270
- * @param int $post_id The post ID.
258
+ * @param int $post_id The post ID.
271
259
  *
272
- * @return array Array of breadcrumb HTML items.
260
+ * @return array Array of breadcrumb item data.
273
261
  */
274
262
  function block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id ) {
275
263
  $breadcrumb_items = array();
@@ -277,10 +265,10 @@ function block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id
277
265
  $ancestors = array_reverse( $ancestors );
278
266
 
279
267
  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
268
+ $breadcrumb_items[] = array(
269
+ 'label' => block_core_breadcrumbs_get_post_title( $ancestor_id ),
270
+ 'url' => get_permalink( $ancestor_id ),
271
+ 'allow_html' => true,
284
272
  );
285
273
  }
286
274
  return $breadcrumb_items;
@@ -296,7 +284,7 @@ function block_core_breadcrumbs_get_hierarchical_post_type_breadcrumbs( $post_id
296
284
  * @param int $term_id The term ID.
297
285
  * @param string $taxonomy The taxonomy name.
298
286
  *
299
- * @return array Array of breadcrumb HTML items for ancestors.
287
+ * @return array Array of breadcrumb item data for ancestors.
300
288
  */
301
289
  function block_core_breadcrumbs_get_term_ancestors_items( $term_id, $taxonomy ) {
302
290
  $breadcrumb_items = array();
@@ -308,9 +296,9 @@ function block_core_breadcrumbs_get_term_ancestors_items( $term_id, $taxonomy )
308
296
  foreach ( $term_ancestors as $ancestor_id ) {
309
297
  $ancestor_term = get_term( $ancestor_id, $taxonomy );
310
298
  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
299
+ $breadcrumb_items[] = array(
300
+ 'label' => $ancestor_term->name,
301
+ 'url' => get_term_link( $ancestor_term ),
314
302
  );
315
303
  }
316
304
  }
@@ -327,7 +315,7 @@ function block_core_breadcrumbs_get_term_ancestors_items( $term_id, $taxonomy )
327
315
  *
328
316
  * @since 7.0.0
329
317
  *
330
- * @return array Array of breadcrumb HTML items.
318
+ * @return array Array of breadcrumb item data.
331
319
  */
332
320
  function block_core_breadcrumbs_get_archive_breadcrumbs() {
333
321
  $breadcrumb_items = array();
@@ -354,16 +342,16 @@ function block_core_breadcrumbs_get_archive_breadcrumbs() {
354
342
  if ( $year ) {
355
343
  if ( $month ) {
356
344
  // Year is linked if we have month.
357
- $breadcrumb_items[] = block_core_breadcrumbs_create_link(
358
- get_year_link( $year ),
359
- $year
345
+ $breadcrumb_items[] = array(
346
+ 'label' => $year,
347
+ 'url' => get_year_link( $year ),
360
348
  );
361
349
 
362
350
  if ( $day ) {
363
351
  // 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 ) )
352
+ $breadcrumb_items[] = array(
353
+ 'label' => date_i18n( 'F', mktime( 0, 0, 0, $month, 1, $year ) ),
354
+ 'url' => get_month_link( $year, $month ),
367
355
  );
368
356
  // Add day (current if not paginated, link if paginated).
369
357
  $breadcrumb_items[] = block_core_breadcrumbs_create_item(
@@ -429,7 +417,7 @@ function block_core_breadcrumbs_get_archive_breadcrumbs() {
429
417
  if ( $post_type_object ) {
430
418
  // Add post type (current if not paginated, link if paginated).
431
419
  $breadcrumb_items[] = block_core_breadcrumbs_create_item(
432
- $post_type_object->labels->name,
420
+ $post_type_object->labels->archives,
433
421
  $is_paged
434
422
  );
435
423
  }
@@ -462,10 +450,11 @@ function block_core_breadcrumbs_get_archive_breadcrumbs() {
462
450
  * @param int $post_id The post ID.
463
451
  * @param string $post_type The post type name.
464
452
  *
465
- * @return array Array of breadcrumb HTML items.
453
+ * @return array Array of breadcrumb item data.
466
454
  */
467
455
  function block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) {
468
456
  $breadcrumb_items = array();
457
+
469
458
  // Get public taxonomies for this post type.
470
459
  $taxonomies = wp_filter_object_list(
471
460
  get_object_taxonomies( $post_type, 'objects' ),
@@ -476,7 +465,7 @@ function block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) {
476
465
  );
477
466
 
478
467
  if ( empty( $taxonomies ) ) {
479
- return array();
468
+ return $breadcrumb_items;
480
469
  }
481
470
 
482
471
  /**
@@ -550,9 +539,9 @@ function block_core_breadcrumbs_get_terms_breadcrumbs( $post_id, $post_type ) {
550
539
  $breadcrumb_items,
551
540
  block_core_breadcrumbs_get_term_ancestors_items( $term->term_id, $taxonomy_name )
552
541
  );
553
- $breadcrumb_items[] = block_core_breadcrumbs_create_link(
554
- get_term_link( $term ),
555
- $term->name
542
+ $breadcrumb_items[] = array(
543
+ 'label' => $term->name,
544
+ 'url' => get_term_link( $term ),
556
545
  );
557
546
  }
558
547
  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
 
@@ -35,26 +39,26 @@ export const settings = {
35
39
  };
36
40
 
37
41
  if ( window.__experimentalContentOnlyPatternInsertion ) {
38
- settings.fields = [
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/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
 
@@ -40,16 +44,16 @@ export const settings = {
40
44
  };
41
45
 
42
46
  if ( window.__experimentalContentOnlyPatternInsertion ) {
43
- settings.fields = [
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 } );
@@ -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 }
@@ -0,0 +1,74 @@
1
+ /**
2
+ * WordPress dependencies
3
+ */
4
+ import { useState } from '@wordpress/element';
5
+ import {
6
+ __experimentalConfirmDialog as ConfirmDialog,
7
+ __experimentalVStack as VStack,
8
+ TextControl,
9
+ Notice,
10
+ } from '@wordpress/components';
11
+ import { __ } from '@wordpress/i18n';
12
+
13
+ /**
14
+ * Internal dependencies
15
+ */
16
+ import { isValidVideoEmbedUrl } from '../embed-video-utils';
17
+
18
+ export default function EmbedVideoUrlInput( { onSubmit, onClose } ) {
19
+ const [ url, setUrl ] = useState( '' );
20
+ const [ error, setError ] = useState( '' );
21
+
22
+ const handleConfirm = () => {
23
+ if ( ! url ) {
24
+ setError( __( 'Please enter a URL.' ) );
25
+ return;
26
+ }
27
+
28
+ if ( ! isValidVideoEmbedUrl( url ) ) {
29
+ setError(
30
+ __(
31
+ 'This URL is not supported. Please enter a valid video link from a supported provider.'
32
+ )
33
+ );
34
+ return;
35
+ }
36
+
37
+ onSubmit( url );
38
+ onClose();
39
+ };
40
+
41
+ return (
42
+ <ConfirmDialog
43
+ isOpen
44
+ onConfirm={ handleConfirm }
45
+ onCancel={ onClose }
46
+ confirmButtonText={ __( 'Add video' ) }
47
+ size="medium"
48
+ >
49
+ <VStack spacing={ 4 }>
50
+ { error && (
51
+ <Notice status="error" isDismissible={ false }>
52
+ { error }
53
+ </Notice>
54
+ ) }
55
+ <TextControl
56
+ __next40pxDefaultSize
57
+ label={ __( 'Video URL' ) }
58
+ value={ url }
59
+ onChange={ ( value ) => {
60
+ setUrl( value );
61
+ setError( '' );
62
+ } }
63
+ placeholder={ __(
64
+ 'Enter YouTube, Vimeo, or other video URL'
65
+ ) }
66
+ __nextHasNoMarginBottom
67
+ help={ __(
68
+ 'Add a background video to the cover block that will autoplay in a loop.'
69
+ ) }
70
+ />
71
+ </VStack>
72
+ </ConfirmDialog>
73
+ );
74
+ }