@wordpress/block-library 9.42.0 → 9.43.1-next.v.202604091042.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.
- package/CHANGELOG.md +2 -0
- package/build/code/edit.cjs +2 -1
- package/build/code/edit.cjs.map +2 -2
- package/build/cover/edit/color-utils.cjs +1 -1
- package/build/cover/edit/color-utils.cjs.map +2 -2
- package/build/cover/edit/index.cjs +31 -25
- package/build/cover/edit/index.cjs.map +2 -2
- package/build/cover/embed-video-utils.cjs +9 -7
- package/build/cover/embed-video-utils.cjs.map +2 -2
- package/build/file/utils/index.cjs +1 -1
- package/build/file/utils/index.cjs.map +2 -2
- package/build/form/view.cjs +1 -1
- package/build/form/view.cjs.map +2 -2
- package/build/form-input/edit.cjs +36 -29
- package/build/form-input/edit.cjs.map +2 -2
- package/build/form-input/variations.cjs +10 -0
- package/build/form-input/variations.cjs.map +2 -2
- package/build/group/block.json +3 -1
- package/build/icon/edit.cjs +1 -3
- package/build/icon/edit.cjs.map +2 -2
- package/build/image/image.cjs +17 -7
- package/build/image/image.cjs.map +2 -2
- package/build/latest-comments/deprecated.cjs +33 -0
- package/build/latest-comments/deprecated.cjs.map +2 -2
- package/build/list-item/block.json +1 -0
- package/build/navigation/edit/index.cjs +123 -119
- package/build/navigation/edit/index.cjs.map +3 -3
- package/build/navigation/edit/navigation-menu-selector.cjs +2 -1
- package/build/navigation/edit/navigation-menu-selector.cjs.map +2 -2
- package/build/navigation-link/link-ui/page-creator.cjs +1 -1
- package/build/navigation-link/link-ui/page-creator.cjs.map +2 -2
- package/build/navigation-link/shared/update-attributes.cjs +1 -1
- package/build/navigation-link/shared/update-attributes.cjs.map +2 -2
- package/build/navigation-link/shared/use-link-preview.cjs +1 -1
- package/build/navigation-link/shared/use-link-preview.cjs.map +2 -2
- package/build/pattern/edit.cjs +1 -1
- package/build/pattern/edit.cjs.map +2 -2
- package/build/search/block.json +0 -4
- package/build/search/edit.cjs +6 -33
- package/build/search/edit.cjs.map +2 -2
- package/build/site-logo/edit.cjs +19 -13
- package/build/site-logo/edit.cjs.map +3 -3
- package/build/site-tagline/deprecated.cjs +2 -1
- package/build/site-tagline/deprecated.cjs.map +2 -2
- package/build/tab/save.cjs +2 -4
- package/build/tab/save.cjs.map +2 -2
- package/build/tabs/save.cjs +2 -4
- package/build/tabs/save.cjs.map +2 -2
- package/build/utils/media-control.cjs +1 -1
- package/build/utils/media-control.cjs.map +2 -2
- package/build-module/code/edit.mjs +2 -1
- package/build-module/code/edit.mjs.map +2 -2
- package/build-module/cover/edit/color-utils.mjs +1 -1
- package/build-module/cover/edit/color-utils.mjs.map +2 -2
- package/build-module/cover/edit/index.mjs +39 -28
- package/build-module/cover/edit/index.mjs.map +2 -2
- package/build-module/cover/embed-video-utils.mjs +8 -6
- package/build-module/cover/embed-video-utils.mjs.map +2 -2
- package/build-module/file/utils/index.mjs +1 -1
- package/build-module/file/utils/index.mjs.map +2 -2
- package/build-module/form/view.mjs +1 -1
- package/build-module/form/view.mjs.map +2 -2
- package/build-module/form-input/edit.mjs +36 -29
- package/build-module/form-input/edit.mjs.map +2 -2
- package/build-module/form-input/variations.mjs +10 -0
- package/build-module/form-input/variations.mjs.map +2 -2
- package/build-module/group/block.json +3 -1
- package/build-module/icon/edit.mjs +1 -3
- package/build-module/icon/edit.mjs.map +2 -2
- package/build-module/image/image.mjs +17 -7
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/latest-comments/deprecated.mjs +33 -0
- package/build-module/latest-comments/deprecated.mjs.map +2 -2
- package/build-module/list-item/block.json +1 -0
- package/build-module/navigation/edit/index.mjs +123 -119
- package/build-module/navigation/edit/index.mjs.map +2 -2
- package/build-module/navigation/edit/navigation-menu-selector.mjs +2 -1
- package/build-module/navigation/edit/navigation-menu-selector.mjs.map +2 -2
- package/build-module/navigation-link/link-ui/page-creator.mjs +1 -1
- package/build-module/navigation-link/link-ui/page-creator.mjs.map +2 -2
- package/build-module/navigation-link/shared/update-attributes.mjs +1 -1
- package/build-module/navigation-link/shared/update-attributes.mjs.map +2 -2
- package/build-module/navigation-link/shared/use-link-preview.mjs +1 -1
- package/build-module/navigation-link/shared/use-link-preview.mjs.map +2 -2
- package/build-module/pattern/edit.mjs +1 -1
- package/build-module/pattern/edit.mjs.map +2 -2
- package/build-module/search/block.json +0 -4
- package/build-module/search/edit.mjs +6 -33
- package/build-module/search/edit.mjs.map +2 -2
- package/build-module/site-logo/edit.mjs +21 -14
- package/build-module/site-logo/edit.mjs.map +2 -2
- package/build-module/site-tagline/deprecated.mjs +2 -1
- package/build-module/site-tagline/deprecated.mjs.map +2 -2
- package/build-module/tab/save.mjs +2 -4
- package/build-module/tab/save.mjs.map +2 -2
- package/build-module/tabs/save.mjs +2 -4
- package/build-module/tabs/save.mjs.map +2 -2
- package/build-module/utils/media-control.mjs +1 -1
- package/build-module/utils/media-control.mjs.map +2 -2
- package/build-style/code/style-rtl.css +1 -1
- package/build-style/code/style.css +1 -1
- package/build-style/editor-rtl.css +15 -5
- package/build-style/editor.css +15 -5
- package/build-style/form-input/editor-rtl.css +6 -5
- package/build-style/form-input/editor.css +6 -5
- package/build-style/icon/editor-rtl.css +5 -0
- package/build-style/icon/editor.css +5 -0
- package/build-style/image/editor-rtl.css +4 -0
- package/build-style/image/editor.css +4 -0
- package/build-style/navigation/style-rtl.css +4 -1
- package/build-style/navigation/style.css +4 -1
- package/build-style/style-rtl.css +5 -2
- package/build-style/style.css +5 -2
- package/package.json +38 -38
- package/src/code/edit.js +1 -0
- package/src/code/style.scss +1 -1
- package/src/cover/edit/color-utils.js +1 -1
- package/src/cover/edit/index.js +63 -34
- package/src/cover/embed-video-utils.js +10 -8
- package/src/embed/test/index.native.js +3 -2
- package/src/file/utils/index.js +1 -1
- package/src/form/view.js +1 -1
- package/src/form-input/edit.js +19 -15
- package/src/form-input/editor.scss +6 -6
- package/src/form-input/variations.js +10 -0
- package/src/group/block.json +3 -1
- package/src/home-link/index.php +14 -33
- package/src/icon/edit.js +1 -3
- package/src/icon/editor.scss +5 -0
- package/src/image/editor.scss +5 -0
- package/src/image/image.js +24 -7
- package/src/image/index.php +4 -4
- package/src/latest-comments/deprecated.js +33 -0
- package/src/list-item/block.json +1 -0
- package/src/loginout/index.php +13 -0
- package/src/navigation/edit/index.js +134 -130
- package/src/navigation/edit/navigation-menu-selector.js +2 -1
- package/src/navigation/style.scss +5 -3
- package/src/navigation-link/index.php +10 -38
- package/src/navigation-link/link-ui/page-creator.js +1 -1
- package/src/navigation-link/shared/build-css-font-sizes.php +43 -0
- package/src/navigation-link/shared/update-attributes.js +1 -1
- package/src/navigation-link/shared/use-link-preview.js +1 -1
- package/src/navigation-submenu/index.php +10 -38
- package/src/page-list/index.php +14 -41
- package/src/pattern/edit.js +1 -1
- package/src/search/block.json +0 -4
- package/src/search/edit.js +2 -35
- package/src/site-logo/edit.js +24 -13
- package/src/site-tagline/deprecated.js +1 -0
- package/src/tab/save.js +2 -6
- package/src/tabs/save.js +2 -6
- package/src/utils/media-control.js +3 -1
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
require_once __DIR__ . '/navigation-link/shared/item-should-render.php';
|
|
9
9
|
require_once __DIR__ . '/navigation-link/shared/render-submenu-icon.php';
|
|
10
|
+
require_once __DIR__ . '/navigation-link/shared/build-css-font-sizes.php';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Build an array with CSS classes and inline styles defining the colors
|
|
@@ -80,43 +81,6 @@ function block_core_navigation_link_build_css_colors( $context, $attributes, $is
|
|
|
80
81
|
return $colors;
|
|
81
82
|
}
|
|
82
83
|
|
|
83
|
-
/**
|
|
84
|
-
* Build an array with CSS classes and inline styles defining the font sizes
|
|
85
|
-
* which will be applied to the navigation markup in the front-end.
|
|
86
|
-
*
|
|
87
|
-
* @since 5.9.0
|
|
88
|
-
*
|
|
89
|
-
* @param array $context Navigation block context.
|
|
90
|
-
* @return array Font size CSS classes and inline styles.
|
|
91
|
-
*/
|
|
92
|
-
function block_core_navigation_link_build_css_font_sizes( $context ) {
|
|
93
|
-
// CSS classes.
|
|
94
|
-
$font_sizes = array(
|
|
95
|
-
'css_classes' => array(),
|
|
96
|
-
'inline_styles' => '',
|
|
97
|
-
);
|
|
98
|
-
|
|
99
|
-
$has_named_font_size = array_key_exists( 'fontSize', $context );
|
|
100
|
-
$has_custom_font_size = isset( $context['style']['typography']['fontSize'] );
|
|
101
|
-
|
|
102
|
-
if ( $has_named_font_size ) {
|
|
103
|
-
// Add the font size class.
|
|
104
|
-
$font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
|
|
105
|
-
} elseif ( $has_custom_font_size ) {
|
|
106
|
-
// Add the custom font size inline style.
|
|
107
|
-
$font_sizes['inline_styles'] = sprintf(
|
|
108
|
-
'font-size: %s;',
|
|
109
|
-
wp_get_typography_font_size_value(
|
|
110
|
-
array(
|
|
111
|
-
'size' => $context['style']['typography']['fontSize'],
|
|
112
|
-
)
|
|
113
|
-
)
|
|
114
|
-
);
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
return $font_sizes;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
84
|
/**
|
|
121
85
|
* Decodes a url if it's encoded, returning the same url if not.
|
|
122
86
|
*
|
|
@@ -174,7 +138,15 @@ function render_block_core_navigation_link( $attributes, $content, $block ) {
|
|
|
174
138
|
return '';
|
|
175
139
|
}
|
|
176
140
|
|
|
177
|
-
|
|
141
|
+
// The build system prefixes this function with "gutenberg_" to avoid
|
|
142
|
+
// collisions with the core version. Until this function is backported to
|
|
143
|
+
// core, we need to guard its use and only call the prefixed name in
|
|
144
|
+
// the plugin.
|
|
145
|
+
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
|
|
146
|
+
$font_sizes = gutenberg_block_core_shared_navigation_build_css_font_sizes( $block->context );
|
|
147
|
+
} else {
|
|
148
|
+
$font_sizes = block_core_shared_navigation_build_css_font_sizes( $block->context );
|
|
149
|
+
}
|
|
178
150
|
$classes = array_merge(
|
|
179
151
|
$font_sizes['css_classes']
|
|
180
152
|
);
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Shared helper function for building CSS font sizes in navigation blocks.
|
|
4
|
+
*
|
|
5
|
+
* @package WordPress
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Build an array with CSS classes and inline styles defining the font sizes
|
|
10
|
+
* which will be applied to the navigation markup in the front-end.
|
|
11
|
+
*
|
|
12
|
+
* @since 7.1.0
|
|
13
|
+
*
|
|
14
|
+
* @param array $context Navigation block context.
|
|
15
|
+
* @return array Font size CSS classes and inline styles.
|
|
16
|
+
*/
|
|
17
|
+
function block_core_shared_navigation_build_css_font_sizes( $context ) {
|
|
18
|
+
// CSS classes.
|
|
19
|
+
$font_sizes = array(
|
|
20
|
+
'css_classes' => array(),
|
|
21
|
+
'inline_styles' => '',
|
|
22
|
+
);
|
|
23
|
+
|
|
24
|
+
$has_named_font_size = array_key_exists( 'fontSize', $context );
|
|
25
|
+
$has_custom_font_size = isset( $context['style']['typography']['fontSize'] );
|
|
26
|
+
|
|
27
|
+
if ( $has_named_font_size ) {
|
|
28
|
+
// Add the font size class.
|
|
29
|
+
$font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
|
|
30
|
+
} elseif ( $has_custom_font_size ) {
|
|
31
|
+
// Add the custom font size inline style.
|
|
32
|
+
$font_sizes['inline_styles'] = sprintf(
|
|
33
|
+
'font-size: %s;',
|
|
34
|
+
wp_get_typography_font_size_value(
|
|
35
|
+
array(
|
|
36
|
+
'size' => $context['style']['typography']['fontSize'],
|
|
37
|
+
)
|
|
38
|
+
)
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return $font_sizes;
|
|
43
|
+
}
|
|
@@ -34,7 +34,7 @@ const shouldSeverEntityLink = ( originalUrl, newUrl ) => {
|
|
|
34
34
|
? window.location.origin
|
|
35
35
|
: 'https://wordpress.org' );
|
|
36
36
|
return new URL( url, base );
|
|
37
|
-
} catch
|
|
37
|
+
} catch {
|
|
38
38
|
// If URL construction still fails, it's likely an invalid URL
|
|
39
39
|
// and we should sever the entity link
|
|
40
40
|
return null;
|
|
@@ -101,7 +101,7 @@ export function computeDisplayUrl( { linkUrl, homeUrl } = {} ) {
|
|
|
101
101
|
// Different host - this is an external link
|
|
102
102
|
isExternal = true;
|
|
103
103
|
}
|
|
104
|
-
} catch
|
|
104
|
+
} catch {
|
|
105
105
|
// URL parsing failed - treat as external (e.g. no homeUrl, or URL without protocol)
|
|
106
106
|
isExternal = true;
|
|
107
107
|
}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
require_once __DIR__ . '/navigation-link/shared/item-should-render.php';
|
|
9
9
|
require_once __DIR__ . '/navigation-link/shared/render-submenu-icon.php';
|
|
10
|
+
require_once __DIR__ . '/navigation-link/shared/build-css-font-sizes.php';
|
|
10
11
|
|
|
11
12
|
/**
|
|
12
13
|
* Returns the submenu visibility value with backward compatibility
|
|
@@ -49,43 +50,6 @@ function block_core_navigation_submenu_get_submenu_visibility( $context ) {
|
|
|
49
50
|
return $submenu_visibility ?? 'hover';
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
/**
|
|
53
|
-
* Build an array with CSS classes and inline styles defining the font sizes
|
|
54
|
-
* which will be applied to the navigation markup in the front-end.
|
|
55
|
-
*
|
|
56
|
-
* @since 5.9.0
|
|
57
|
-
*
|
|
58
|
-
* @param array $context Navigation block context.
|
|
59
|
-
* @return array Font size CSS classes and inline styles.
|
|
60
|
-
*/
|
|
61
|
-
function block_core_navigation_submenu_build_css_font_sizes( $context ) {
|
|
62
|
-
// CSS classes.
|
|
63
|
-
$font_sizes = array(
|
|
64
|
-
'css_classes' => array(),
|
|
65
|
-
'inline_styles' => '',
|
|
66
|
-
);
|
|
67
|
-
|
|
68
|
-
$has_named_font_size = array_key_exists( 'fontSize', $context );
|
|
69
|
-
$has_custom_font_size = isset( $context['style']['typography']['fontSize'] );
|
|
70
|
-
|
|
71
|
-
if ( $has_named_font_size ) {
|
|
72
|
-
// Add the font size class.
|
|
73
|
-
$font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
|
|
74
|
-
} elseif ( $has_custom_font_size ) {
|
|
75
|
-
// Add the custom font size inline style.
|
|
76
|
-
$font_sizes['inline_styles'] = sprintf(
|
|
77
|
-
'font-size: %s;',
|
|
78
|
-
wp_get_typography_font_size_value(
|
|
79
|
-
array(
|
|
80
|
-
'size' => $context['style']['typography']['fontSize'],
|
|
81
|
-
)
|
|
82
|
-
)
|
|
83
|
-
);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return $font_sizes;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
53
|
/**
|
|
90
54
|
* Renders the `core/navigation-submenu` block.
|
|
91
55
|
*
|
|
@@ -110,7 +74,15 @@ function render_block_core_navigation_submenu( $attributes, $content, $block ) {
|
|
|
110
74
|
return '';
|
|
111
75
|
}
|
|
112
76
|
|
|
113
|
-
|
|
77
|
+
// The build system prefixes this function with "gutenberg_" to avoid
|
|
78
|
+
// collisions with the core version. Until this function is backported to
|
|
79
|
+
// core, we need to guard its use and only call the prefixed name in
|
|
80
|
+
// the plugin.
|
|
81
|
+
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
|
|
82
|
+
$font_sizes = gutenberg_block_core_shared_navigation_build_css_font_sizes( $block->context );
|
|
83
|
+
} else {
|
|
84
|
+
$font_sizes = block_core_shared_navigation_build_css_font_sizes( $block->context );
|
|
85
|
+
}
|
|
114
86
|
$style_attribute = $font_sizes['inline_styles'];
|
|
115
87
|
|
|
116
88
|
// Render inner blocks first to check if any menu items will actually display.
|
package/src/page-list/index.php
CHANGED
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* @package WordPress
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
require_once __DIR__ . '/navigation-link/shared/build-css-font-sizes.php';
|
|
9
|
+
|
|
8
10
|
/**
|
|
9
11
|
* Returns the submenu visibility value with backward compatibility
|
|
10
12
|
* for the deprecated openSubmenusOnClick attribute.
|
|
@@ -123,44 +125,6 @@ function block_core_page_list_build_css_colors( $attributes, $context ) {
|
|
|
123
125
|
|
|
124
126
|
return $colors;
|
|
125
127
|
}
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Build an array with CSS classes and inline styles defining the font sizes
|
|
129
|
-
* which will be applied to the pages markup in the front-end when it is a descendant of navigation.
|
|
130
|
-
*
|
|
131
|
-
* @since 5.8.0
|
|
132
|
-
*
|
|
133
|
-
* @param array $context Navigation block context.
|
|
134
|
-
* @return array Font size CSS classes and inline styles.
|
|
135
|
-
*/
|
|
136
|
-
function block_core_page_list_build_css_font_sizes( $context ) {
|
|
137
|
-
// CSS classes.
|
|
138
|
-
$font_sizes = array(
|
|
139
|
-
'css_classes' => array(),
|
|
140
|
-
'inline_styles' => '',
|
|
141
|
-
);
|
|
142
|
-
|
|
143
|
-
$has_named_font_size = array_key_exists( 'fontSize', $context );
|
|
144
|
-
$has_custom_font_size = isset( $context['style']['typography']['fontSize'] );
|
|
145
|
-
|
|
146
|
-
if ( $has_named_font_size ) {
|
|
147
|
-
// Add the font size class.
|
|
148
|
-
$font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
|
|
149
|
-
} elseif ( $has_custom_font_size ) {
|
|
150
|
-
// Add the custom font size inline style.
|
|
151
|
-
$font_sizes['inline_styles'] = sprintf(
|
|
152
|
-
'font-size: %s;',
|
|
153
|
-
wp_get_typography_font_size_value(
|
|
154
|
-
array(
|
|
155
|
-
'size' => $context['style']['typography']['fontSize'],
|
|
156
|
-
)
|
|
157
|
-
)
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return $font_sizes;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
128
|
/**
|
|
165
129
|
* Outputs Page list markup from an array of pages with nested children.
|
|
166
130
|
*
|
|
@@ -342,12 +306,21 @@ function render_block_core_page_list( $attributes, $content, $block ) {
|
|
|
342
306
|
}
|
|
343
307
|
}
|
|
344
308
|
|
|
345
|
-
$colors
|
|
346
|
-
|
|
347
|
-
|
|
309
|
+
$colors = block_core_page_list_build_css_colors( $attributes, $block->context );
|
|
310
|
+
// The build system prefixes this function with "gutenberg_" to avoid
|
|
311
|
+
// collisions with the core version. Until this function is backported to
|
|
312
|
+
// core, we need to guard its use and only call the prefixed name in
|
|
313
|
+
// the plugin.
|
|
314
|
+
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
|
|
315
|
+
$font_sizes = gutenberg_block_core_shared_navigation_build_css_font_sizes( $block->context );
|
|
316
|
+
} else {
|
|
317
|
+
$font_sizes = block_core_shared_navigation_build_css_font_sizes( $block->context );
|
|
318
|
+
}
|
|
319
|
+
$classes = array_merge(
|
|
348
320
|
$colors['css_classes'],
|
|
349
321
|
$font_sizes['css_classes']
|
|
350
322
|
);
|
|
323
|
+
|
|
351
324
|
$style_attribute = ( $colors['inline_styles'] . $font_sizes['inline_styles'] );
|
|
352
325
|
$css_classes = trim( implode( ' ', $classes ) );
|
|
353
326
|
|
package/src/pattern/edit.js
CHANGED
package/src/search/block.json
CHANGED
package/src/search/edit.js
CHANGED
|
@@ -70,7 +70,6 @@ export default function SearchEdit( {
|
|
|
70
70
|
buttonText,
|
|
71
71
|
buttonPosition,
|
|
72
72
|
buttonUseIcon,
|
|
73
|
-
isSearchFieldHidden,
|
|
74
73
|
style,
|
|
75
74
|
} = attributes;
|
|
76
75
|
|
|
@@ -139,6 +138,7 @@ export default function SearchEdit( {
|
|
|
139
138
|
const isButtonPositionOutside = 'button-outside' === buttonPosition;
|
|
140
139
|
const hasNoButton = 'no-button' === buttonPosition;
|
|
141
140
|
const hasOnlyButton = 'button-only' === buttonPosition;
|
|
141
|
+
const isSearchFieldHidden = hasOnlyButton && ! isSelected;
|
|
142
142
|
const searchFieldRef = useRef();
|
|
143
143
|
const buttonRef = useRef();
|
|
144
144
|
|
|
@@ -147,25 +147,6 @@ export default function SearchEdit( {
|
|
|
147
147
|
defaultValues: { '%': PC_WIDTH_DEFAULT, px: PX_WIDTH_DEFAULT },
|
|
148
148
|
} );
|
|
149
149
|
|
|
150
|
-
useEffect( () => {
|
|
151
|
-
if ( hasOnlyButton && ! isSelected ) {
|
|
152
|
-
setAttributes( {
|
|
153
|
-
isSearchFieldHidden: true,
|
|
154
|
-
} );
|
|
155
|
-
}
|
|
156
|
-
}, [ hasOnlyButton, isSelected, setAttributes ] );
|
|
157
|
-
|
|
158
|
-
// Show the search field when width changes.
|
|
159
|
-
useEffect( () => {
|
|
160
|
-
if ( ! hasOnlyButton || ! isSelected ) {
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
setAttributes( {
|
|
165
|
-
isSearchFieldHidden: false,
|
|
166
|
-
} );
|
|
167
|
-
}, [ hasOnlyButton, isSelected, setAttributes, width ] );
|
|
168
|
-
|
|
169
150
|
const getBlockClassNames = () => {
|
|
170
151
|
return clsx(
|
|
171
152
|
className,
|
|
@@ -183,7 +164,7 @@ export default function SearchEdit( {
|
|
|
183
164
|
buttonUseIcon && ! hasNoButton
|
|
184
165
|
? 'wp-block-search__icon-button'
|
|
185
166
|
: undefined,
|
|
186
|
-
|
|
167
|
+
isSearchFieldHidden
|
|
187
168
|
? 'wp-block-search__searchfield-hidden'
|
|
188
169
|
: undefined
|
|
189
170
|
);
|
|
@@ -292,14 +273,6 @@ export default function SearchEdit( {
|
|
|
292
273
|
}
|
|
293
274
|
: borderProps.style ),
|
|
294
275
|
};
|
|
295
|
-
const handleButtonClick = () => {
|
|
296
|
-
if ( hasOnlyButton ) {
|
|
297
|
-
setAttributes( {
|
|
298
|
-
isSearchFieldHidden: ! isSearchFieldHidden,
|
|
299
|
-
} );
|
|
300
|
-
}
|
|
301
|
-
};
|
|
302
|
-
|
|
303
276
|
return (
|
|
304
277
|
<>
|
|
305
278
|
{ buttonUseIcon && (
|
|
@@ -312,7 +285,6 @@ export default function SearchEdit( {
|
|
|
312
285
|
? stripHTML( buttonText )
|
|
313
286
|
: __( 'Search' )
|
|
314
287
|
}
|
|
315
|
-
onClick={ handleButtonClick }
|
|
316
288
|
ref={ buttonRef }
|
|
317
289
|
>
|
|
318
290
|
<Icon icon={ search } />
|
|
@@ -331,7 +303,6 @@ export default function SearchEdit( {
|
|
|
331
303
|
onChange={ ( html ) =>
|
|
332
304
|
setAttributes( { buttonText: html } )
|
|
333
305
|
}
|
|
334
|
-
onClick={ handleButtonClick }
|
|
335
306
|
/>
|
|
336
307
|
) }
|
|
337
308
|
</>
|
|
@@ -351,7 +322,6 @@ export default function SearchEdit( {
|
|
|
351
322
|
showLabel: true,
|
|
352
323
|
buttonUseIcon: false,
|
|
353
324
|
buttonPosition: 'button-outside',
|
|
354
|
-
isSearchFieldHidden: false,
|
|
355
325
|
} );
|
|
356
326
|
} }
|
|
357
327
|
dropdownMenuProps={ dropdownMenuProps }
|
|
@@ -382,7 +352,6 @@ export default function SearchEdit( {
|
|
|
382
352
|
onDeselect={ () => {
|
|
383
353
|
setAttributes( {
|
|
384
354
|
buttonPosition: 'button-outside',
|
|
385
|
-
isSearchFieldHidden: false,
|
|
386
355
|
} );
|
|
387
356
|
} }
|
|
388
357
|
isShownByDefault
|
|
@@ -394,8 +363,6 @@ export default function SearchEdit( {
|
|
|
394
363
|
onChange={ ( value ) => {
|
|
395
364
|
setAttributes( {
|
|
396
365
|
buttonPosition: value,
|
|
397
|
-
isSearchFieldHidden:
|
|
398
|
-
value === 'button-only',
|
|
399
366
|
} );
|
|
400
367
|
} }
|
|
401
368
|
options={ buttonPositionControls }
|
package/src/site-logo/edit.js
CHANGED
|
@@ -35,6 +35,7 @@ import {
|
|
|
35
35
|
store as blockEditorStore,
|
|
36
36
|
__experimentalImageEditor as ImageEditor,
|
|
37
37
|
useBlockEditingMode,
|
|
38
|
+
privateApis as blockEditorPrivateApis,
|
|
38
39
|
} from '@wordpress/block-editor';
|
|
39
40
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
40
41
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -46,9 +47,11 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
46
47
|
*/
|
|
47
48
|
import { MIN_SIZE } from '../image/constants';
|
|
48
49
|
import { MediaControl, MediaControlPreview } from '../utils/media-control';
|
|
50
|
+
import { unlock } from '../lock-unlock';
|
|
49
51
|
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
|
|
50
52
|
|
|
51
53
|
const ALLOWED_MEDIA_TYPES = [ 'image' ];
|
|
54
|
+
const { mediaEditKey } = unlock( blockEditorPrivateApis );
|
|
52
55
|
|
|
53
56
|
const SiteLogo = ( {
|
|
54
57
|
alt,
|
|
@@ -75,18 +78,22 @@ const SiteLogo = ( {
|
|
|
75
78
|
const blockEditingMode = useBlockEditingMode();
|
|
76
79
|
const isContentOnlyMode = blockEditingMode === 'contentOnly';
|
|
77
80
|
|
|
78
|
-
const { imageEditing, maxWidth, title } = useSelect(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
81
|
+
const { imageEditing, maxWidth, title, editMediaEntity } = useSelect(
|
|
82
|
+
( select ) => {
|
|
83
|
+
const settings = select( blockEditorStore ).getSettings();
|
|
84
|
+
const siteEntities = select( coreStore ).getEntityRecord(
|
|
85
|
+
'root',
|
|
86
|
+
'__unstableBase'
|
|
87
|
+
);
|
|
88
|
+
return {
|
|
89
|
+
title: siteEntities?.name,
|
|
90
|
+
imageEditing: settings.imageEditing,
|
|
91
|
+
maxWidth: settings.maxWidth,
|
|
92
|
+
editMediaEntity: settings?.[ mediaEditKey ],
|
|
93
|
+
};
|
|
94
|
+
},
|
|
95
|
+
[]
|
|
96
|
+
);
|
|
90
97
|
|
|
91
98
|
useEffect( () => {
|
|
92
99
|
// Turn the `Use as site icon` toggle off if it is on but the logo and icon have
|
|
@@ -200,7 +207,11 @@ const SiteLogo = ( {
|
|
|
200
207
|
/* eslint-enable no-lonely-if */
|
|
201
208
|
|
|
202
209
|
const canEditImage =
|
|
203
|
-
logoId &&
|
|
210
|
+
logoId &&
|
|
211
|
+
naturalWidth &&
|
|
212
|
+
naturalHeight &&
|
|
213
|
+
imageEditing &&
|
|
214
|
+
!! editMediaEntity;
|
|
204
215
|
|
|
205
216
|
// Hide crop and dimensions editing in write mode
|
|
206
217
|
const shouldShowCropAndDimensions = ! isContentOnlyMode;
|
package/src/tab/save.js
CHANGED
|
@@ -3,15 +3,11 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
|
|
5
5
|
|
|
6
|
-
export default function save(
|
|
7
|
-
const { anchor } = attributes;
|
|
8
|
-
|
|
9
|
-
const tabPanelId = anchor;
|
|
10
|
-
|
|
6
|
+
export default function save() {
|
|
11
7
|
const blockProps = useBlockProps.save( {
|
|
12
8
|
role: 'tabpanel',
|
|
13
9
|
} );
|
|
14
10
|
const innerBlocksProps = useInnerBlocksProps.save( blockProps );
|
|
15
11
|
|
|
16
|
-
return <section { ...innerBlocksProps }
|
|
12
|
+
return <section { ...innerBlocksProps } />;
|
|
17
13
|
}
|
package/src/tabs/save.js
CHANGED
|
@@ -3,13 +3,9 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
|
|
5
5
|
|
|
6
|
-
export default function save(
|
|
7
|
-
const { anchor } = attributes;
|
|
8
|
-
|
|
9
|
-
const tabsId = anchor;
|
|
10
|
-
|
|
6
|
+
export default function save() {
|
|
11
7
|
const blockProps = useBlockProps.save();
|
|
12
8
|
const innerBlocksProps = useInnerBlocksProps.save( blockProps );
|
|
13
9
|
|
|
14
|
-
return <div { ...innerBlocksProps }
|
|
10
|
+
return <div { ...innerBlocksProps } />;
|
|
15
11
|
}
|
|
@@ -140,7 +140,9 @@ export function MediaControl( {
|
|
|
140
140
|
filename={ filename }
|
|
141
141
|
className="block-library-utils__media-control__inspector-media-replace-title"
|
|
142
142
|
label={
|
|
143
|
-
mediaUrl
|
|
143
|
+
mediaUrl
|
|
144
|
+
? getFilename( filename ) || emptyLabel
|
|
145
|
+
: emptyLabel
|
|
144
146
|
}
|
|
145
147
|
/>
|
|
146
148
|
}
|