@wordpress/block-library 6.0.3 → 6.0.4

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 (66) hide show
  1. package/build/buttons/deprecated.js +11 -7
  2. package/build/buttons/deprecated.js.map +1 -1
  3. package/build/buttons/edit.js +1 -4
  4. package/build/buttons/edit.js.map +1 -1
  5. package/build/column/index.js +1 -1
  6. package/build/cover/index.js +1 -1
  7. package/build/gallery/edit.js +1 -1
  8. package/build/gallery/edit.js.map +1 -1
  9. package/build/gallery/use-mobile-warning.js +2 -2
  10. package/build/gallery/use-mobile-warning.js.map +1 -1
  11. package/build/group/index.js +1 -1
  12. package/build/navigation/edit/placeholder/index.js +2 -2
  13. package/build/navigation/edit/placeholder/index.js.map +1 -1
  14. package/build/navigation/edit/responsive-wrapper.js +1 -2
  15. package/build/navigation/edit/responsive-wrapper.js.map +1 -1
  16. package/build/navigation/index.js +2 -1
  17. package/build/navigation/index.js.map +1 -1
  18. package/build/navigation/view.js +29 -26
  19. package/build/navigation/view.js.map +1 -1
  20. package/build-module/buttons/deprecated.js +11 -7
  21. package/build-module/buttons/deprecated.js.map +1 -1
  22. package/build-module/buttons/edit.js +2 -5
  23. package/build-module/buttons/edit.js.map +1 -1
  24. package/build-module/column/index.js +1 -1
  25. package/build-module/cover/index.js +1 -1
  26. package/build-module/gallery/edit.js +1 -1
  27. package/build-module/gallery/edit.js.map +1 -1
  28. package/build-module/gallery/use-mobile-warning.js +2 -2
  29. package/build-module/gallery/use-mobile-warning.js.map +1 -1
  30. package/build-module/group/index.js +1 -1
  31. package/build-module/navigation/edit/placeholder/index.js +2 -2
  32. package/build-module/navigation/edit/placeholder/index.js.map +1 -1
  33. package/build-module/navigation/edit/responsive-wrapper.js +1 -2
  34. package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
  35. package/build-module/navigation/index.js +2 -1
  36. package/build-module/navigation/index.js.map +1 -1
  37. package/build-module/navigation/view.js +28 -26
  38. package/build-module/navigation/view.js.map +1 -1
  39. package/build-style/navigation/style-rtl.css +14 -16
  40. package/build-style/navigation/style.css +14 -16
  41. package/build-style/navigation-submenu/style-rtl.css +1 -0
  42. package/build-style/navigation-submenu/style.css +1 -0
  43. package/build-style/page-list/style-rtl.css +5 -2
  44. package/build-style/page-list/style.css +5 -2
  45. package/build-style/style-rtl.css +20 -22
  46. package/build-style/style.css +20 -22
  47. package/package.json +4 -4
  48. package/src/buttons/deprecated.js +11 -8
  49. package/src/buttons/edit.js +0 -5
  50. package/src/column/block.json +1 -1
  51. package/src/cover/block.json +1 -1
  52. package/src/gallery/edit.js +3 -1
  53. package/src/gallery/use-mobile-warning.js +2 -2
  54. package/src/group/block.json +1 -1
  55. package/src/navigation/block.json +2 -1
  56. package/src/navigation/edit/placeholder/index.js +2 -2
  57. package/src/navigation/edit/responsive-wrapper.js +1 -5
  58. package/src/navigation/index.php +1 -112
  59. package/src/navigation/style.scss +17 -16
  60. package/src/navigation/view.js +33 -32
  61. package/src/navigation-submenu/style.scss +4 -0
  62. package/src/page-list/style.scss +5 -2
  63. package/src/style.scss +0 -1
  64. package/build-style/post-content/style-rtl.css +0 -79
  65. package/build-style/post-content/style.css +0 -79
  66. package/src/post-content/style.scss +0 -4
@@ -85,117 +85,6 @@ function block_core_navigation_build_css_font_sizes( $attributes ) {
85
85
  return $font_sizes;
86
86
  }
87
87
 
88
- /**
89
- * Returns the menu items for a WordPress menu location.
90
- *
91
- * @param string $location The menu location.
92
- * @return array Menu items for the location.
93
- */
94
- function gutenberg_get_menu_items_at_location( $location ) {
95
- if ( empty( $location ) ) {
96
- return;
97
- }
98
-
99
- // Build menu data. The following approximates the code in
100
- // `wp_nav_menu()` and `gutenberg_output_block_nav_menu`.
101
-
102
- // Find the location in the list of locations, returning early if the
103
- // location can't be found.
104
- $locations = get_nav_menu_locations();
105
- if ( ! isset( $locations[ $location ] ) ) {
106
- return;
107
- }
108
-
109
- // Get the menu from the location, returning early if there is no
110
- // menu or there was an error.
111
- $menu = wp_get_nav_menu_object( $locations[ $location ] );
112
- if ( ! $menu || is_wp_error( $menu ) ) {
113
- return;
114
- }
115
-
116
- $menu_items = wp_get_nav_menu_items( $menu->term_id, array( 'update_post_term_cache' => false ) );
117
- _wp_menu_item_classes_by_context( $menu_items );
118
-
119
- return $menu_items;
120
- }
121
-
122
- /**
123
- * Sorts a standard array of menu items into a nested structure keyed by the
124
- * id of the parent menu.
125
- *
126
- * @param array $menu_items Menu items to sort.
127
- * @return array An array keyed by the id of the parent menu where each element
128
- * is an array of menu items that belong to that parent.
129
- */
130
- function gutenberg_sort_menu_items_by_parent_id( $menu_items ) {
131
- $sorted_menu_items = array();
132
- foreach ( (array) $menu_items as $menu_item ) {
133
- $sorted_menu_items[ $menu_item->menu_order ] = $menu_item;
134
- }
135
- unset( $menu_items, $menu_item );
136
-
137
- $menu_items_by_parent_id = array();
138
- foreach ( $sorted_menu_items as $menu_item ) {
139
- $menu_items_by_parent_id[ $menu_item->menu_item_parent ][] = $menu_item;
140
- }
141
-
142
- return $menu_items_by_parent_id;
143
- }
144
-
145
- /**
146
- * Turns menu item data into a nested array of parsed blocks
147
- *
148
- * @param array $menu_items An array of menu items that represent
149
- * an individual level of a menu.
150
- * @param array $menu_items_by_parent_id An array keyed by the id of the
151
- * parent menu where each element is an
152
- * array of menu items that belong to
153
- * that parent.
154
- * @return array An array of parsed block data.
155
- */
156
- function gutenberg_parse_blocks_from_menu_items( $menu_items, $menu_items_by_parent_id ) {
157
- if ( empty( $menu_items ) ) {
158
- return array();
159
- }
160
-
161
- $blocks = array();
162
-
163
- foreach ( $menu_items as $menu_item ) {
164
- $class_name = ! empty( $menu_item->classes ) ? implode( ' ', (array) $menu_item->classes ) : null;
165
- $id = ( null !== $menu_item->object_id && 'custom' !== $menu_item->object ) ? $menu_item->object_id : null;
166
- $opens_in_new_tab = null !== $menu_item->target && '_blank' === $menu_item->target;
167
- $rel = ( null !== $menu_item->xfn && '' !== $menu_item->xfn ) ? $menu_item->xfn : null;
168
- $kind = null !== $menu_item->type ? str_replace( '_', '-', $menu_item->type ) : 'custom';
169
-
170
- $block = array(
171
- 'blockName' => 'core/navigation-link',
172
- 'attrs' => array(
173
- 'className' => $class_name,
174
- 'description' => $menu_item->description,
175
- 'id' => $id,
176
- 'kind' => $kind,
177
- 'label' => $menu_item->title,
178
- 'opensInNewTab' => $opens_in_new_tab,
179
- 'rel' => $rel,
180
- 'title' => $menu_item->attr_title,
181
- 'type' => $menu_item->object,
182
- 'url' => $menu_item->url,
183
- ),
184
- );
185
-
186
- $block['innerBlocks'] = gutenberg_parse_blocks_from_menu_items(
187
- isset( $menu_items_by_parent_id[ $menu_item->ID ] )
188
- ? $menu_items_by_parent_id[ $menu_item->ID ]
189
- : array(),
190
- $menu_items_by_parent_id
191
- );
192
-
193
- $blocks[] = $block;
194
- }
195
-
196
- return $blocks;
197
- }
198
-
199
88
  /**
200
89
  * Returns the top-level submenu SVG chevron icon.
201
90
  *
@@ -354,7 +243,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
354
243
 
355
244
  $responsive_container_markup = sprintf(
356
245
  '<button aria-expanded="false" aria-haspopup="true" aria-label="%3$s" class="%6$s" data-micromodal-trigger="modal-%1$s"><svg width="24" height="24" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" role="img" aria-hidden="true" focusable="false"><rect x="4" y="7.5" width="16" height="1.5" /><rect x="4" y="15" width="16" height="1.5" /></svg></button>
357
- <div class="%5$s" id="modal-%1$s" aria-hidden="true">
246
+ <div class="%5$s" id="modal-%1$s">
358
247
  <div class="wp-block-navigation__responsive-close" tabindex="-1" data-micromodal-close>
359
248
  <div class="wp-block-navigation__responsive-dialog" role="dialog" aria-modal="true" aria-labelledby="modal-%1$s-title" >
360
249
  <button aria-label="%4$s" data-micromodal-close class="wp-block-navigation__responsive-container-close"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="24" height="24" role="img" aria-hidden="true" focusable="false"><path d="M13 11.8l6.1-6.3-1-1-6.1 6.2-6.1-6.2-1 1 6.1 6.3-6.5 6.7 1 1 6.5-6.6 6.5 6.6 1-1z"></path></svg></button>
@@ -304,6 +304,11 @@
304
304
 
305
305
  // Navigation block inner container.
306
306
  .wp-block-navigation__container {
307
+ display: flex;
308
+ flex-wrap: var(--layout-wrap, wrap);
309
+ flex-direction: var(--layout-direction, initial);
310
+ justify-content: var(--layout-justify, initial);
311
+ align-items: var(--layout-align, initial);
307
312
 
308
313
  // Reset the default list styles
309
314
  list-style: none;
@@ -329,7 +334,11 @@
329
334
  bottom: 0;
330
335
 
331
336
  .wp-block-navigation__responsive-container-content {
332
- display: contents;
337
+ display: flex;
338
+ flex-wrap: var(--layout-wrap, wrap);
339
+ flex-direction: var(--layout-direction, initial);
340
+ justify-content: var(--layout-justify, initial);
341
+ align-items: var(--layout-align, initial);
333
342
  }
334
343
 
335
344
  // Overlay menu.
@@ -350,8 +359,6 @@
350
359
  // Add extra top padding so items don't conflict with close button.
351
360
  padding: 72px 24px 24px 24px;
352
361
  background-color: inherit;
353
- // Fallback to inheritance in case the --justification-setting variable fails.
354
- align-items: inherit;
355
362
 
356
363
  .wp-block-navigation__responsive-container-content {
357
364
  // Override the container flex layout settings
@@ -360,7 +367,11 @@
360
367
  display: flex;
361
368
  flex-direction: column;
362
369
  // Inherit alignment settings from container.
363
- align-items: var(--justification-setting, inherit);
370
+ align-items: var(--layout-justification-setting, inherit);
371
+
372
+ // Always align the contents of the menu to the top.
373
+ justify-content: flex-start;
374
+
364
375
  // Allow menu to scroll.
365
376
  overflow: auto;
366
377
  padding: 0;
@@ -412,7 +423,7 @@
412
423
  display: flex;
413
424
  flex-direction: column;
414
425
  // Inherit alignment settings from container.
415
- align-items: var(--justification-setting, inherit);
426
+ align-items: var(--layout-justification-setting, initial);
416
427
  }
417
428
  }
418
429
 
@@ -435,7 +446,7 @@
435
446
  @include break-small() {
436
447
  &:not(.hidden-by-default) {
437
448
  &:not(.is-menu-open) {
438
- display: contents;
449
+ display: block;
439
450
  width: 100%;
440
451
  position: relative;
441
452
  z-index: 2;
@@ -518,13 +529,3 @@ html.has-modal-open {
518
529
  overflow: hidden;
519
530
  }
520
531
 
521
- .wp-block-navigation__responsive-close,
522
- .wp-block-navigation__responsive-dialog,
523
- .wp-block-navigation__container {
524
- display: contents;
525
-
526
- .is-menu-open & {
527
- // Fallback to inheritance in case the --justification-setting variable fails.
528
- align-items: inherit;
529
- }
530
- }
@@ -56,42 +56,43 @@ function toggleSubmenuOnClick( event ) {
56
56
  }
57
57
  }
58
58
 
59
- const submenuButtons = document.querySelectorAll(
60
- '.wp-block-navigation-submenu__toggle'
61
- );
62
-
63
- submenuButtons.forEach( function ( button ) {
64
- button.addEventListener( 'click', toggleSubmenuOnClick );
65
- } );
66
-
67
- // Close on click outside.
68
- document.addEventListener( 'click', function ( event ) {
69
- const navigationBlocks = document.querySelectorAll(
70
- '.wp-block-navigation'
71
- );
72
- navigationBlocks.forEach( function ( block ) {
73
- if ( ! block.contains( event.target ) ) {
74
- closeSubmenus( block );
75
- }
76
- } );
77
- } );
78
- // Close on focus outside.
79
- document.addEventListener( 'keyup', function ( event ) {
80
- const submenuBlocks = document.querySelectorAll(
81
- '.wp-block-navigation-item.has-child'
82
- );
83
- submenuBlocks.forEach( function ( block ) {
84
- if ( ! block.contains( event.target ) ) {
85
- closeSubmenus( block );
86
- }
87
- } );
88
- } );
89
-
90
59
  // Necessary for some themes such as TT1 Blocks, where
91
60
  // scripts could be loaded before the body.
92
- window.onload = () =>
61
+ window.onload = () => {
93
62
  MicroModal.init( {
94
63
  onShow: navigationToggleModal,
95
64
  onClose: navigationToggleModal,
96
65
  openClass: 'is-menu-open',
97
66
  } );
67
+
68
+ const submenuButtons = document.querySelectorAll(
69
+ '.wp-block-navigation-submenu__toggle'
70
+ );
71
+
72
+ submenuButtons.forEach( function ( button ) {
73
+ button.addEventListener( 'click', toggleSubmenuOnClick );
74
+ } );
75
+
76
+ // Close on click outside.
77
+ document.addEventListener( 'click', function ( event ) {
78
+ const navigationBlocks = document.querySelectorAll(
79
+ '.wp-block-navigation'
80
+ );
81
+ navigationBlocks.forEach( function ( block ) {
82
+ if ( ! block.contains( event.target ) ) {
83
+ closeSubmenus( block );
84
+ }
85
+ } );
86
+ } );
87
+ // Close on focus outside.
88
+ document.addEventListener( 'keyup', function ( event ) {
89
+ const submenuBlocks = document.querySelectorAll(
90
+ '.wp-block-navigation-item.has-child'
91
+ );
92
+ submenuBlocks.forEach( function ( block ) {
93
+ if ( ! block.contains( event.target ) ) {
94
+ closeSubmenus( block );
95
+ }
96
+ } );
97
+ } );
98
+ };
@@ -13,6 +13,10 @@ button.wp-block-navigation-item__content {
13
13
  color: currentColor;
14
14
  font-size: inherit;
15
15
  font-family: inherit;
16
+
17
+ // Buttons default to center alignment. This becomes visible
18
+ // when a menu item label is long enough to wrap.
19
+ text-align: left;
16
20
  }
17
21
 
18
22
  .wp-block-navigation-submenu__toggle {
@@ -1,8 +1,11 @@
1
1
  // The Page List block should inherit navigation styles when nested within it
2
2
  .wp-block-navigation {
3
3
  .wp-block-page-list {
4
- display: contents;
5
- flex-wrap: wrap;
4
+ display: flex;
5
+ flex-direction: var(--layout-direction, initial);
6
+ justify-content: var(--layout-justify, initial);
7
+ align-items: var(--layout-align, initial);
8
+ flex-wrap: var(--layout-wrap, wrap);
6
9
  background-color: inherit;
7
10
  }
8
11
 
package/src/style.scss CHANGED
@@ -31,7 +31,6 @@
31
31
  @import "./post-title/style.scss";
32
32
  @import "./preformatted/style.scss";
33
33
  @import "./pullquote/style.scss";
34
- @import "./post-content/style.scss";
35
34
  @import "./post-template/style.scss";
36
35
  @import "./query-pagination/style.scss";
37
36
  @import "./quote/style.scss";
@@ -1,79 +0,0 @@
1
- /**
2
- * Colors
3
- */
4
- /**
5
- * Breakpoints & Media Queries
6
- */
7
- /**
8
- * SCSS Variables.
9
- *
10
- * Please use variables from this sheet to ensure consistency across the UI.
11
- * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
12
- * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
13
- */
14
- /**
15
- * Colors
16
- */
17
- /**
18
- * Fonts & basic variables.
19
- */
20
- /**
21
- * Grid System.
22
- * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
23
- */
24
- /**
25
- * Dimensions.
26
- */
27
- /**
28
- * Shadows.
29
- */
30
- /**
31
- * Editor widths.
32
- */
33
- /**
34
- * Block & Editor UI.
35
- */
36
- /**
37
- * Block paddings.
38
- */
39
- /**
40
- * React Native specific.
41
- * These variables do not appear to be used anywhere else.
42
- */
43
- /**
44
- * Converts a hex value into the rgb equivalent.
45
- *
46
- * @param {string} hex - the hexadecimal value to convert
47
- * @return {string} comma separated rgb values
48
- */
49
- /**
50
- * Breakpoint mixins
51
- */
52
- /**
53
- * Long content fade mixin
54
- *
55
- * Creates a fading overlay to signify that the content is longer
56
- * than the space allows.
57
- */
58
- /**
59
- * Focus styles.
60
- */
61
- /**
62
- * Applies editor left position to the selector passed as argument
63
- */
64
- /**
65
- * Styles that are reused verbatim in a few places
66
- */
67
- /**
68
- * Allows users to opt-out of animations via OS-level preferences.
69
- */
70
- /**
71
- * Reset default styles for JavaScript UI based pages.
72
- * This is a WP-admin agnostic reset
73
- */
74
- /**
75
- * Reset the WP Admin page styles for Gutenberg-like pages.
76
- */
77
- .wp-block-post-content + * {
78
- clear: both;
79
- }
@@ -1,79 +0,0 @@
1
- /**
2
- * Colors
3
- */
4
- /**
5
- * Breakpoints & Media Queries
6
- */
7
- /**
8
- * SCSS Variables.
9
- *
10
- * Please use variables from this sheet to ensure consistency across the UI.
11
- * Don't add to this sheet unless you're pretty sure the value will be reused in many places.
12
- * For example, don't add rules to this sheet that affect block visuals. It's purely for UI.
13
- */
14
- /**
15
- * Colors
16
- */
17
- /**
18
- * Fonts & basic variables.
19
- */
20
- /**
21
- * Grid System.
22
- * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
23
- */
24
- /**
25
- * Dimensions.
26
- */
27
- /**
28
- * Shadows.
29
- */
30
- /**
31
- * Editor widths.
32
- */
33
- /**
34
- * Block & Editor UI.
35
- */
36
- /**
37
- * Block paddings.
38
- */
39
- /**
40
- * React Native specific.
41
- * These variables do not appear to be used anywhere else.
42
- */
43
- /**
44
- * Converts a hex value into the rgb equivalent.
45
- *
46
- * @param {string} hex - the hexadecimal value to convert
47
- * @return {string} comma separated rgb values
48
- */
49
- /**
50
- * Breakpoint mixins
51
- */
52
- /**
53
- * Long content fade mixin
54
- *
55
- * Creates a fading overlay to signify that the content is longer
56
- * than the space allows.
57
- */
58
- /**
59
- * Focus styles.
60
- */
61
- /**
62
- * Applies editor left position to the selector passed as argument
63
- */
64
- /**
65
- * Styles that are reused verbatim in a few places
66
- */
67
- /**
68
- * Allows users to opt-out of animations via OS-level preferences.
69
- */
70
- /**
71
- * Reset default styles for JavaScript UI based pages.
72
- * This is a WP-admin agnostic reset
73
- */
74
- /**
75
- * Reset the WP Admin page styles for Gutenberg-like pages.
76
- */
77
- .wp-block-post-content + * {
78
- clear: both;
79
- }
@@ -1,4 +0,0 @@
1
- // Required to ensure that subsequent blocks clear floats inside entry content.
2
- .wp-block-post-content + * {
3
- clear: both;
4
- }