@wordpress/block-library 8.22.0 → 8.24.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 +4 -0
- package/build/block/edit.js +11 -13
- package/build/block/edit.js.map +1 -1
- package/build/block/edit.native.js +3 -4
- package/build/block/edit.native.js.map +1 -1
- package/build/button/edit.js +61 -9
- package/build/button/edit.js.map +1 -1
- package/build/code/transforms.js +20 -7
- package/build/code/transforms.js.map +1 -1
- package/build/column/edit.js +1 -1
- package/build/column/edit.js.map +1 -1
- package/build/column/edit.native.js +1 -1
- package/build/column/edit.native.js.map +1 -1
- package/build/comments/edit/comments-inspector-controls.js +1 -0
- package/build/comments/edit/comments-inspector-controls.js.map +1 -1
- package/build/cover/edit/index.js +2 -1
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +1 -0
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/details/edit.js +1 -2
- package/build/details/edit.js.map +1 -1
- package/build/file/edit.js +8 -9
- package/build/file/edit.js.map +1 -1
- package/build/file/view.js +4 -6
- package/build/file/view.js.map +1 -1
- package/build/form/index.js +1 -1
- package/build/form/index.js.map +1 -1
- package/build/form-submit-button/edit.js +2 -1
- package/build/form-submit-button/edit.js.map +1 -1
- package/build/gallery/gap-styles.js +12 -7
- package/build/gallery/gap-styles.js.map +1 -1
- package/build/group/edit.js +4 -7
- package/build/group/edit.js.map +1 -1
- package/build/html/transforms.js +7 -2
- package/build/html/transforms.js.map +1 -1
- package/build/image/deprecated.js +8 -0
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.js +17 -18
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +22 -15
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +35 -27
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +2 -3
- package/build/image/index.js.map +1 -1
- package/build/image/view.js +234 -266
- package/build/image/view.js.map +1 -1
- package/build/missing/index.js +1 -1
- package/build/navigation/edit/overlay-menu-preview.js +1 -1
- package/build/navigation/edit/overlay-menu-preview.js.map +1 -1
- package/build/navigation/use-template-part-area-label.js +2 -1
- package/build/navigation/use-template-part-area-label.js.map +1 -1
- package/build/navigation/view.js +153 -176
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +1 -1
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/index.js +2 -1
- package/build/navigation-link/index.js.map +1 -1
- package/build/pattern/edit.js +2 -4
- package/build/pattern/edit.js.map +1 -1
- package/build/post-author/edit.js +0 -1
- package/build/post-author/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +21 -6
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-template/edit.js +2 -8
- package/build/post-template/edit.js.map +1 -1
- package/build/post-template/index.js +1 -1
- package/build/post-terms/edit.js +0 -2
- package/build/post-terms/edit.js.map +1 -1
- package/build/preformatted/transforms.js +1 -4
- package/build/preformatted/transforms.js.map +1 -1
- package/build/query/edit/query-content.js +1 -0
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/view.js +52 -60
- package/build/query/view.js.map +1 -1
- package/build/quote/index.js +6 -0
- package/build/quote/index.js.map +1 -1
- package/build/search/view.js +66 -74
- package/build/search/view.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js +1 -0
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/index.js +3 -7
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/index.js +6 -2
- package/build/template-part/index.js.map +1 -1
- package/build/template-part/variations.js +5 -1
- package/build/template-part/variations.js.map +1 -1
- package/build/utils/remove-anchor-tag.js +17 -0
- package/build/utils/remove-anchor-tag.js.map +1 -0
- package/build-module/block/edit.js +11 -13
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/edit.native.js +3 -4
- package/build-module/block/edit.native.js.map +1 -1
- package/build-module/button/edit.js +65 -13
- package/build-module/button/edit.js.map +1 -1
- package/build-module/code/transforms.js +20 -7
- package/build-module/code/transforms.js.map +1 -1
- package/build-module/column/edit.js +1 -1
- package/build-module/column/edit.js.map +1 -1
- package/build-module/column/edit.native.js +1 -1
- package/build-module/column/edit.native.js.map +1 -1
- package/build-module/comments/edit/comments-inspector-controls.js +1 -0
- package/build-module/comments/edit/comments-inspector-controls.js.map +1 -1
- package/build-module/cover/edit/index.js +2 -1
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +1 -0
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/details/edit.js +1 -2
- package/build-module/details/edit.js.map +1 -1
- package/build-module/file/edit.js +8 -9
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/view.js +5 -7
- package/build-module/file/view.js.map +1 -1
- package/build-module/form/index.js +1 -1
- package/build-module/form/index.js.map +1 -1
- package/build-module/form-submit-button/edit.js +2 -1
- package/build-module/form-submit-button/edit.js.map +1 -1
- package/build-module/gallery/gap-styles.js +13 -8
- package/build-module/gallery/gap-styles.js.map +1 -1
- package/build-module/group/edit.js +4 -7
- package/build-module/group/edit.js.map +1 -1
- package/build-module/html/transforms.js +7 -2
- package/build-module/html/transforms.js.map +1 -1
- package/build-module/image/deprecated.js +8 -0
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.js +18 -19
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +23 -16
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +36 -28
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +2 -3
- package/build-module/image/index.js.map +1 -1
- package/build-module/image/view.js +235 -267
- package/build-module/image/view.js.map +1 -1
- package/build-module/missing/index.js +1 -1
- package/build-module/navigation/edit/overlay-menu-preview.js +1 -1
- package/build-module/navigation/edit/overlay-menu-preview.js.map +1 -1
- package/build-module/navigation/use-template-part-area-label.js +2 -1
- package/build-module/navigation/use-template-part-area-label.js.map +1 -1
- package/build-module/navigation/view.js +154 -177
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +2 -2
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/index.js +2 -1
- package/build-module/navigation-link/index.js.map +1 -1
- package/build-module/pattern/edit.js +2 -4
- package/build-module/pattern/edit.js.map +1 -1
- package/build-module/post-author/edit.js +0 -1
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +21 -6
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-template/edit.js +2 -8
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-template/index.js +1 -1
- package/build-module/post-terms/edit.js +0 -2
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/preformatted/transforms.js +1 -4
- package/build-module/preformatted/transforms.js.map +1 -1
- package/build-module/query/edit/query-content.js +1 -0
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/view.js +53 -61
- package/build-module/query/view.js.map +1 -1
- package/build-module/quote/index.js +6 -0
- package/build-module/quote/index.js.map +1 -1
- package/build-module/search/view.js +67 -75
- package/build-module/search/view.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js +1 -0
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +5 -9
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/index.js +6 -2
- package/build-module/template-part/index.js.map +1 -1
- package/build-module/template-part/variations.js +5 -1
- package/build-module/template-part/variations.js.map +1 -1
- package/build-module/utils/remove-anchor-tag.js +11 -0
- package/build-module/utils/remove-anchor-tag.js.map +1 -0
- package/build-style/cover/style-rtl.css +14 -14
- package/build-style/cover/style.css +14 -14
- package/build-style/editor-rtl.css +15 -6
- package/build-style/editor.css +15 -6
- package/build-style/gallery/style-rtl.css +28 -0
- package/build-style/gallery/style.css +28 -0
- package/build-style/image/style-rtl.css +19 -13
- package/build-style/image/style.css +19 -13
- package/build-style/post-featured-image/editor-rtl.css +9 -0
- package/build-style/post-featured-image/editor.css +9 -0
- package/build-style/quote/style-rtl.css +3 -0
- package/build-style/quote/style.css +3 -0
- package/build-style/read-more/style-rtl.css +2 -2
- package/build-style/read-more/style.css +2 -2
- package/build-style/style-rtl.css +66 -29
- package/build-style/style.css +66 -29
- package/package.json +32 -32
- package/src/block/edit.js +20 -20
- package/src/block/edit.native.js +5 -13
- package/src/button/edit.js +76 -10
- package/src/buttons/test/__snapshots__/edit.native.js.snap +0 -6
- package/src/buttons/test/edit.native.js +0 -27
- package/src/code/transforms.js +14 -8
- package/src/column/edit.js +1 -1
- package/src/column/edit.native.js +1 -1
- package/src/comments/edit/comments-inspector-controls.js +1 -0
- package/src/cover/edit/index.js +1 -0
- package/src/cover/edit/inspector-controls.js +1 -0
- package/src/cover/style.scss +1 -1
- package/src/cover/test/edit.js +1 -1
- package/src/details/edit.js +0 -1
- package/src/editor.scss +6 -6
- package/src/file/edit.js +11 -10
- package/src/file/index.php +30 -11
- package/src/file/view.js +5 -7
- package/src/form/index.js +1 -1
- package/src/form-submit-button/edit.js +1 -0
- package/src/gallery/gap-styles.js +10 -9
- package/src/gallery/style.scss +1 -0
- package/src/group/edit.js +4 -11
- package/src/heading/test/__snapshots__/index.native.js.snap +6 -0
- package/src/heading/test/index.native.js +40 -0
- package/src/html/transforms.js +5 -2
- package/src/image/block.json +2 -3
- package/src/image/deprecated.js +8 -0
- package/src/image/edit.js +16 -21
- package/src/image/edit.native.js +17 -18
- package/src/image/image.js +48 -51
- package/src/image/index.php +57 -49
- package/src/image/style.scss +18 -13
- package/src/image/view.js +281 -324
- package/src/missing/block.json +1 -1
- package/src/navigation/edit/overlay-menu-preview.js +1 -1
- package/src/navigation/index.php +46 -402
- package/src/navigation/use-template-part-area-label.js +4 -2
- package/src/navigation/view.js +159 -192
- package/src/navigation-link/block.json +2 -1
- package/src/navigation-link/edit.js +2 -2
- package/src/navigation-link/index.php +57 -0
- package/src/paragraph/test/__snapshots__/transforms.native.js.snap +6 -0
- package/src/paragraph/test/edit.native.js +37 -1
- package/src/paragraph/test/transforms.native.js +1 -0
- package/src/pattern/edit.js +7 -4
- package/src/pattern/index.php +6 -1
- package/src/post-author/edit.js +0 -1
- package/src/post-featured-image/edit.js +38 -5
- package/src/post-featured-image/editor.scss +19 -0
- package/src/post-template/block.json +0 -1
- package/src/post-template/edit.js +1 -5
- package/src/post-terms/edit.js +0 -2
- package/src/preformatted/transforms.js +1 -4
- package/src/query/edit/query-content.js +1 -0
- package/src/query/index.php +42 -24
- package/src/query/view.js +58 -65
- package/src/query-pagination-next/index.php +3 -3
- package/src/query-pagination-numbers/index.php +1 -1
- package/src/query-pagination-previous/index.php +3 -3
- package/src/quote/block.json +6 -0
- package/src/quote/style.scss +4 -0
- package/src/read-more/style.scss +1 -1
- package/src/search/index.php +40 -40
- package/src/search/view.js +58 -63
- package/src/template-part/edit/advanced-controls.js +1 -0
- package/src/template-part/edit/index.js +7 -14
- package/src/template-part/index.js +4 -3
- package/src/template-part/index.php +4 -4
- package/src/template-part/variations.js +4 -2
- package/src/utils/remove-anchor-tag.js +10 -0
- package/tsconfig.json +1 -0
|
@@ -96,6 +96,25 @@
|
|
|
96
96
|
height: 100%;
|
|
97
97
|
width: 100%;
|
|
98
98
|
}
|
|
99
|
+
|
|
100
|
+
// When the Post Featured Image block is linked,
|
|
101
|
+
// it's wrapped with a disabled <a /> tag.
|
|
102
|
+
// Restore cursor style so it doesn't appear 'clickable'.
|
|
103
|
+
> a {
|
|
104
|
+
cursor: default;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// When the Post Featured Image block is linked,
|
|
108
|
+
// and wrapped with a disabled <a /> tag
|
|
109
|
+
// ensure that the placeholder items are visible when selected.
|
|
110
|
+
&.is-selected .components-placeholder.has-illustration {
|
|
111
|
+
.components-button,
|
|
112
|
+
.components-placeholder__instructions,
|
|
113
|
+
.components-placeholder__label {
|
|
114
|
+
opacity: 1;
|
|
115
|
+
pointer-events: auto;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
99
118
|
}
|
|
100
119
|
|
|
101
120
|
div[data-type="core/post-featured-image"] {
|
|
@@ -96,7 +96,6 @@ export default function PostTemplateEdit( {
|
|
|
96
96
|
// REST API or be handled by custom REST filters like `rest_{$this->post_type}_query`.
|
|
97
97
|
...restQueryArgs
|
|
98
98
|
} = {},
|
|
99
|
-
queryContext = [ { page: 1 } ],
|
|
100
99
|
templateSlug,
|
|
101
100
|
previewPostType,
|
|
102
101
|
},
|
|
@@ -104,8 +103,6 @@ export default function PostTemplateEdit( {
|
|
|
104
103
|
__unstableLayoutClassNames,
|
|
105
104
|
} ) {
|
|
106
105
|
const { type: layoutType, columnCount = 3 } = layout || {};
|
|
107
|
-
|
|
108
|
-
const [ { page } ] = queryContext;
|
|
109
106
|
const [ activeBlockContextId, setActiveBlockContextId ] = useState();
|
|
110
107
|
const { posts, blocks } = useSelect(
|
|
111
108
|
( select ) => {
|
|
@@ -126,7 +123,7 @@ export default function PostTemplateEdit( {
|
|
|
126
123
|
slug: templateSlug.replace( 'category-', '' ),
|
|
127
124
|
} );
|
|
128
125
|
const query = {
|
|
129
|
-
offset:
|
|
126
|
+
offset: offset || 0,
|
|
130
127
|
order,
|
|
131
128
|
orderby: orderBy,
|
|
132
129
|
};
|
|
@@ -194,7 +191,6 @@ export default function PostTemplateEdit( {
|
|
|
194
191
|
},
|
|
195
192
|
[
|
|
196
193
|
perPage,
|
|
197
|
-
page,
|
|
198
194
|
offset,
|
|
199
195
|
order,
|
|
200
196
|
orderBy,
|
package/src/post-terms/edit.js
CHANGED
|
@@ -97,7 +97,6 @@ export default function PostTermsEdit( {
|
|
|
97
97
|
<RichText
|
|
98
98
|
allowedFormats={ ALLOWED_FORMATS }
|
|
99
99
|
className="wp-block-post-terms__prefix"
|
|
100
|
-
multiline={ false }
|
|
101
100
|
aria-label={ __( 'Prefix' ) }
|
|
102
101
|
placeholder={ __( 'Prefix' ) + ' ' }
|
|
103
102
|
value={ prefix }
|
|
@@ -141,7 +140,6 @@ export default function PostTermsEdit( {
|
|
|
141
140
|
<RichText
|
|
142
141
|
allowedFormats={ ALLOWED_FORMATS }
|
|
143
142
|
className="wp-block-post-terms__suffix"
|
|
144
|
-
multiline={ false }
|
|
145
143
|
aria-label={ __( 'Suffix' ) }
|
|
146
144
|
placeholder={ ' ' + __( 'Suffix' ) }
|
|
147
145
|
value={ suffix }
|
|
@@ -34,10 +34,7 @@ const transforms = {
|
|
|
34
34
|
type: 'block',
|
|
35
35
|
blocks: [ 'core/paragraph' ],
|
|
36
36
|
transform: ( attributes ) =>
|
|
37
|
-
createBlock( 'core/paragraph',
|
|
38
|
-
...attributes,
|
|
39
|
-
content: attributes.content.replace( /\n/g, '<br>' ),
|
|
40
|
-
} ),
|
|
37
|
+
createBlock( 'core/paragraph', attributes ),
|
|
41
38
|
},
|
|
42
39
|
{
|
|
43
40
|
type: 'block',
|
|
@@ -131,6 +131,7 @@ export default function QueryContent( {
|
|
|
131
131
|
<InspectorControls group="advanced">
|
|
132
132
|
<SelectControl
|
|
133
133
|
__nextHasNoMarginBottom
|
|
134
|
+
__next40pxDefaultSize
|
|
134
135
|
label={ __( 'HTML element' ) }
|
|
135
136
|
options={ [
|
|
136
137
|
{ label: __( 'Default (<div>)' ), value: 'div' },
|
package/src/query/index.php
CHANGED
|
@@ -21,19 +21,15 @@ function render_block_core_query( $attributes, $content, $block ) {
|
|
|
21
21
|
$p = new WP_HTML_Tag_Processor( $content );
|
|
22
22
|
if ( $p->next_tag() ) {
|
|
23
23
|
// Add the necessary directives.
|
|
24
|
-
$p->set_attribute( 'data-wp-interactive',
|
|
24
|
+
$p->set_attribute( 'data-wp-interactive', '{"namespace":"core/query"}' );
|
|
25
25
|
$p->set_attribute( 'data-wp-navigation-id', 'query-' . $attributes['queryId'] );
|
|
26
26
|
// Use context to send translated strings.
|
|
27
27
|
$p->set_attribute(
|
|
28
28
|
'data-wp-context',
|
|
29
29
|
wp_json_encode(
|
|
30
30
|
array(
|
|
31
|
-
'
|
|
32
|
-
|
|
33
|
-
'loadingText' => __( 'Loading page, please wait.' ),
|
|
34
|
-
'loadedText' => __( 'Page Loaded.' ),
|
|
35
|
-
),
|
|
36
|
-
),
|
|
31
|
+
'loadingText' => __( 'Loading page, please wait.' ),
|
|
32
|
+
'loadedText' => __( 'Page Loaded.' ),
|
|
37
33
|
),
|
|
38
34
|
JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP
|
|
39
35
|
)
|
|
@@ -44,38 +40,51 @@ function render_block_core_query( $attributes, $content, $block ) {
|
|
|
44
40
|
$block->block_type->supports['interactivity'] = true;
|
|
45
41
|
|
|
46
42
|
// Add a div to announce messages using `aria-live`.
|
|
47
|
-
$
|
|
43
|
+
$html_tag = 'div';
|
|
44
|
+
if ( ! empty( $attributes['tagName'] ) ) {
|
|
45
|
+
$html_tag = esc_attr( $attributes['tagName'] );
|
|
46
|
+
}
|
|
47
|
+
$last_tag_position = strripos( $content, '</' . $html_tag . '>' );
|
|
48
48
|
$content = substr_replace(
|
|
49
49
|
$content,
|
|
50
50
|
'<div
|
|
51
51
|
class="screen-reader-text"
|
|
52
52
|
aria-live="polite"
|
|
53
|
-
data-wp-text="context.
|
|
53
|
+
data-wp-text="context.message"
|
|
54
54
|
></div>
|
|
55
55
|
<div
|
|
56
56
|
class="wp-block-query__enhanced-pagination-animation"
|
|
57
|
-
data-wp-class--start-animation="
|
|
58
|
-
data-wp-class--finish-animation="
|
|
57
|
+
data-wp-class--start-animation="state.startAnimation"
|
|
58
|
+
data-wp-class--finish-animation="state.finishAnimation"
|
|
59
59
|
></div>',
|
|
60
|
-
$
|
|
60
|
+
$last_tag_position,
|
|
61
61
|
0
|
|
62
62
|
);
|
|
63
63
|
}
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
$
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_asset ) );
|
|
66
|
+
$is_gutenberg_plugin = defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN;
|
|
67
|
+
$should_load_view_script = $attributes['enhancedPagination'] && isset( $attributes['queryId'] );
|
|
68
|
+
$view_asset = 'wp-block-query-view';
|
|
69
|
+
$script_handles = $block->block_type->view_script_handles;
|
|
70
|
+
|
|
71
|
+
if ( $is_gutenberg_plugin ) {
|
|
72
|
+
if ( $should_load_view_script ) {
|
|
73
|
+
gutenberg_enqueue_module( '@wordpress/block-library/query' );
|
|
75
74
|
}
|
|
76
|
-
//
|
|
77
|
-
|
|
78
|
-
|
|
75
|
+
// Remove the view script because we are using the module.
|
|
76
|
+
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_asset ) );
|
|
77
|
+
} else {
|
|
78
|
+
if ( ! wp_script_is( $view_asset ) ) {
|
|
79
|
+
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
|
|
80
|
+
if ( ! $should_load_view_script && in_array( $view_asset, $script_handles, true )
|
|
81
|
+
) {
|
|
82
|
+
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_asset ) );
|
|
83
|
+
}
|
|
84
|
+
// If the script is needed, but it was previously removed, add it again.
|
|
85
|
+
if ( $should_load_view_script && ! in_array( $view_asset, $script_handles, true ) ) {
|
|
86
|
+
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_asset ) );
|
|
87
|
+
}
|
|
79
88
|
}
|
|
80
89
|
}
|
|
81
90
|
|
|
@@ -127,6 +136,15 @@ function register_block_core_query() {
|
|
|
127
136
|
'render_callback' => 'render_block_core_query',
|
|
128
137
|
)
|
|
129
138
|
);
|
|
139
|
+
|
|
140
|
+
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
|
|
141
|
+
gutenberg_register_module(
|
|
142
|
+
'@wordpress/block-library/query',
|
|
143
|
+
'/wp-content/plugins/gutenberg/build/interactivity/query.min.js',
|
|
144
|
+
array( '@wordpress/interactivity' ),
|
|
145
|
+
defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' )
|
|
146
|
+
);
|
|
147
|
+
}
|
|
130
148
|
}
|
|
131
149
|
add_action( 'init', 'register_block_core_query' );
|
|
132
150
|
|
package/src/query/view.js
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
store,
|
|
6
|
+
getContext,
|
|
7
|
+
getElement,
|
|
8
|
+
navigate,
|
|
9
|
+
prefetch,
|
|
10
|
+
} from '@wordpress/interactivity';
|
|
5
11
|
|
|
6
12
|
const isValidLink = ( ref ) =>
|
|
7
13
|
ref &&
|
|
@@ -18,83 +24,70 @@ const isValidEvent = ( event ) =>
|
|
|
18
24
|
! event.shiftKey &&
|
|
19
25
|
! event.defaultPrevented;
|
|
20
26
|
|
|
21
|
-
store( {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
context.core.query.animation === 'finish',
|
|
29
|
-
},
|
|
27
|
+
store( 'core/query', {
|
|
28
|
+
state: {
|
|
29
|
+
get startAnimation() {
|
|
30
|
+
return getContext().animation === 'start';
|
|
31
|
+
},
|
|
32
|
+
get finishAnimation() {
|
|
33
|
+
return getContext().animation === 'finish';
|
|
30
34
|
},
|
|
31
35
|
},
|
|
32
36
|
actions: {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
37
|
+
*navigate( event ) {
|
|
38
|
+
const ctx = getContext();
|
|
39
|
+
const { ref } = getElement();
|
|
40
|
+
const isDisabled = ref.closest( '[data-wp-navigation-id]' )?.dataset
|
|
41
|
+
.wpNavigationDisabled;
|
|
38
42
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
isValidEvent( event ) &&
|
|
42
|
-
! isDisabled
|
|
43
|
-
) {
|
|
44
|
-
event.preventDefault();
|
|
43
|
+
if ( isValidLink( ref ) && isValidEvent( event ) && ! isDisabled ) {
|
|
44
|
+
event.preventDefault();
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
const id = ref.closest( '[data-wp-navigation-id]' ).dataset
|
|
47
|
+
.wpNavigationId;
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}, 400 );
|
|
49
|
+
// Don't announce the navigation immediately, wait 400 ms.
|
|
50
|
+
const timeout = setTimeout( () => {
|
|
51
|
+
ctx.message = ctx.loadingText;
|
|
52
|
+
ctx.animation = 'start';
|
|
53
|
+
}, 400 );
|
|
55
54
|
|
|
56
|
-
|
|
55
|
+
yield navigate( ref.href );
|
|
57
56
|
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
// Dismiss loading message if it hasn't been added yet.
|
|
58
|
+
clearTimeout( timeout );
|
|
60
59
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
context.core.query.loadedText
|
|
68
|
-
? '\u00A0'
|
|
69
|
-
: '' );
|
|
60
|
+
// Announce that the page has been loaded. If the message is the
|
|
61
|
+
// same, we use a no-break space similar to the @wordpress/a11y
|
|
62
|
+
// package: https://github.com/WordPress/gutenberg/blob/c395242b8e6ee20f8b06c199e4fc2920d7018af1/packages/a11y/src/filter-message.js#L20-L26
|
|
63
|
+
ctx.message =
|
|
64
|
+
ctx.loadedText +
|
|
65
|
+
( ctx.message === ctx.loadedText ? '\u00A0' : '' );
|
|
70
66
|
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
ctx.animation = 'finish';
|
|
68
|
+
ctx.url = ref.href;
|
|
73
69
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
},
|
|
70
|
+
// Focus the first anchor of the Query block.
|
|
71
|
+
const firstAnchor = `[data-wp-navigation-id=${ id }] .wp-block-post-template a[href]`;
|
|
72
|
+
document.querySelector( firstAnchor )?.focus();
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
*prefetch() {
|
|
76
|
+
const { ref } = getElement();
|
|
77
|
+
const isDisabled = ref.closest( '[data-wp-navigation-id]' )?.dataset
|
|
78
|
+
.wpNavigationDisabled;
|
|
79
|
+
if ( isValidLink( ref ) && ! isDisabled ) {
|
|
80
|
+
yield prefetch( ref.href );
|
|
81
|
+
}
|
|
87
82
|
},
|
|
88
83
|
},
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
},
|
|
97
|
-
},
|
|
84
|
+
callbacks: {
|
|
85
|
+
*prefetch() {
|
|
86
|
+
const { url } = getContext();
|
|
87
|
+
const { ref } = getElement();
|
|
88
|
+
if ( url && isValidLink( ref ) ) {
|
|
89
|
+
yield prefetch( ref.href );
|
|
90
|
+
}
|
|
98
91
|
},
|
|
99
92
|
},
|
|
100
93
|
} );
|
|
@@ -72,9 +72,9 @@ function render_block_core_query_pagination_next( $attributes, $content, $block
|
|
|
72
72
|
)
|
|
73
73
|
) ) {
|
|
74
74
|
$p->set_attribute( 'data-wp-key', 'query-pagination-next' );
|
|
75
|
-
$p->set_attribute( 'data-wp-on--click', '
|
|
76
|
-
$p->set_attribute( 'data-wp-on--mouseenter', '
|
|
77
|
-
$p->set_attribute( 'data-wp-
|
|
75
|
+
$p->set_attribute( 'data-wp-on--click', 'core/query::actions.navigate' );
|
|
76
|
+
$p->set_attribute( 'data-wp-on--mouseenter', 'core/query::actions.prefetch' );
|
|
77
|
+
$p->set_attribute( 'data-wp-watch', 'core/query::callbacks.prefetch' );
|
|
78
78
|
$content = $p->get_updated_html();
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -98,7 +98,7 @@ function render_block_core_query_pagination_numbers( $attributes, $content, $blo
|
|
|
98
98
|
'class_name' => 'page-numbers',
|
|
99
99
|
)
|
|
100
100
|
) ) {
|
|
101
|
-
$p->set_attribute( 'data-wp-on--click', '
|
|
101
|
+
$p->set_attribute( 'data-wp-on--click', 'core/query::actions.navigate' );
|
|
102
102
|
}
|
|
103
103
|
$content = $p->get_updated_html();
|
|
104
104
|
}
|
|
@@ -60,9 +60,9 @@ function render_block_core_query_pagination_previous( $attributes, $content, $bl
|
|
|
60
60
|
)
|
|
61
61
|
) ) {
|
|
62
62
|
$p->set_attribute( 'data-wp-key', 'query-pagination-previous' );
|
|
63
|
-
$p->set_attribute( 'data-wp-on--click', '
|
|
64
|
-
$p->set_attribute( 'data-wp-on--mouseenter', '
|
|
65
|
-
$p->set_attribute( 'data-wp-
|
|
63
|
+
$p->set_attribute( 'data-wp-on--click', 'core/query::actions.navigate' );
|
|
64
|
+
$p->set_attribute( 'data-wp-on--mouseenter', 'core/query::actions.prefetch' );
|
|
65
|
+
$p->set_attribute( 'data-wp-watch', 'core/query::callbacks.prefetch' );
|
|
66
66
|
$content = $p->get_updated_html();
|
|
67
67
|
}
|
|
68
68
|
}
|
package/src/quote/block.json
CHANGED
package/src/quote/style.scss
CHANGED
package/src/read-more/style.scss
CHANGED
package/src/search/index.php
CHANGED
|
@@ -80,25 +80,35 @@ function render_block_core_search( $attributes, $content, $block ) {
|
|
|
80
80
|
|
|
81
81
|
$is_expandable_searchfield = 'button-only' === $button_position && 'expand-searchfield' === $button_behavior;
|
|
82
82
|
if ( $is_expandable_searchfield ) {
|
|
83
|
-
$input->set_attribute( 'data-wp-bind--aria-hidden', '!context.
|
|
84
|
-
$input->set_attribute( 'data-wp-bind--tabindex', '
|
|
83
|
+
$input->set_attribute( 'data-wp-bind--aria-hidden', '!context.isSearchInputVisible' );
|
|
84
|
+
$input->set_attribute( 'data-wp-bind--tabindex', 'state.tabindex' );
|
|
85
85
|
// Adding these attributes manually is needed until the Interactivity API SSR logic is added to core.
|
|
86
86
|
$input->set_attribute( 'aria-hidden', 'true' );
|
|
87
87
|
$input->set_attribute( 'tabindex', '-1' );
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
|
|
91
|
-
$
|
|
92
|
-
|
|
93
|
-
$script_handles = $block->block_type->view_script_handles;
|
|
90
|
+
$is_gutenberg_plugin = defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN;
|
|
91
|
+
$script_handles = $block->block_type->view_script_handles;
|
|
92
|
+
$view_js_file = 'wp-block-search-view';
|
|
94
93
|
|
|
95
|
-
|
|
96
|
-
if (
|
|
97
|
-
|
|
94
|
+
if ( $is_gutenberg_plugin ) {
|
|
95
|
+
if ( $is_expandable_searchfield ) {
|
|
96
|
+
gutenberg_enqueue_module( '@wordpress/block-library/search-block' );
|
|
98
97
|
}
|
|
99
|
-
//
|
|
100
|
-
|
|
101
|
-
|
|
98
|
+
// Remove the view script because we are using the module.
|
|
99
|
+
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
|
|
100
|
+
} else {
|
|
101
|
+
// If the script already exists, there is no point in removing it from viewScript.
|
|
102
|
+
if ( ! wp_script_is( $view_js_file ) ) {
|
|
103
|
+
|
|
104
|
+
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
|
|
105
|
+
if ( ! $is_expandable_searchfield && in_array( $view_js_file, $script_handles, true ) ) {
|
|
106
|
+
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
|
|
107
|
+
}
|
|
108
|
+
// If the script is needed, but it was previously removed, add it again.
|
|
109
|
+
if ( $is_expandable_searchfield && ! in_array( $view_js_file, $script_handles, true ) ) {
|
|
110
|
+
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
|
|
111
|
+
}
|
|
102
112
|
}
|
|
103
113
|
}
|
|
104
114
|
}
|
|
@@ -145,11 +155,11 @@ function render_block_core_search( $attributes, $content, $block ) {
|
|
|
145
155
|
if ( $button->next_tag() ) {
|
|
146
156
|
$button->add_class( implode( ' ', $button_classes ) );
|
|
147
157
|
if ( 'expand-searchfield' === $attributes['buttonBehavior'] && 'button-only' === $attributes['buttonPosition'] ) {
|
|
148
|
-
$button->set_attribute( 'data-wp-bind--aria-label', '
|
|
149
|
-
$button->set_attribute( 'data-wp-bind--aria-controls', '
|
|
150
|
-
$button->set_attribute( 'data-wp-bind--aria-expanded', 'context.
|
|
151
|
-
$button->set_attribute( 'data-wp-bind--type', '
|
|
152
|
-
$button->set_attribute( 'data-wp-on--click', 'actions.
|
|
158
|
+
$button->set_attribute( 'data-wp-bind--aria-label', 'state.ariaLabel' );
|
|
159
|
+
$button->set_attribute( 'data-wp-bind--aria-controls', 'state.ariaControls' );
|
|
160
|
+
$button->set_attribute( 'data-wp-bind--aria-expanded', 'context.isSearchInputVisible' );
|
|
161
|
+
$button->set_attribute( 'data-wp-bind--type', 'state.type' );
|
|
162
|
+
$button->set_attribute( 'data-wp-on--click', 'actions.openSearchInput' );
|
|
153
163
|
// Adding these attributes manually is needed until the Interactivity API SSR logic is added to core.
|
|
154
164
|
$button->set_attribute( 'aria-label', __( 'Expand search field' ) );
|
|
155
165
|
$button->set_attribute( 'aria-controls', 'wp-block-search__input-' . $input_id );
|
|
@@ -176,11 +186,11 @@ function render_block_core_search( $attributes, $content, $block ) {
|
|
|
176
186
|
$aria_label_expanded = __( 'Submit Search' );
|
|
177
187
|
$aria_label_collapsed = __( 'Expand search field' );
|
|
178
188
|
$form_directives = '
|
|
179
|
-
data-wp-interactive
|
|
180
|
-
data-wp-context=\'{ "
|
|
181
|
-
data-wp-class--wp-block-search__searchfield-hidden="!context.
|
|
182
|
-
data-wp-on--keydown="actions.
|
|
183
|
-
data-wp-on--focusout="actions.
|
|
189
|
+
data-wp-interactive=\'{ "namespace": "core/search" }\'
|
|
190
|
+
data-wp-context=\'{ "isSearchInputVisible": ' . $open_by_default . ', "inputId": "' . $input_id . '", "ariaLabelExpanded": "' . $aria_label_expanded . '", "ariaLabelCollapsed": "' . $aria_label_collapsed . '" }\'
|
|
191
|
+
data-wp-class--wp-block-search__searchfield-hidden="!context.isSearchInputVisible"
|
|
192
|
+
data-wp-on--keydown="actions.handleSearchKeydown"
|
|
193
|
+
data-wp-on--focusout="actions.handleSearchFocusout"
|
|
184
194
|
';
|
|
185
195
|
}
|
|
186
196
|
|
|
@@ -203,27 +213,17 @@ function register_block_core_search() {
|
|
|
203
213
|
'render_callback' => 'render_block_core_search',
|
|
204
214
|
)
|
|
205
215
|
);
|
|
206
|
-
}
|
|
207
|
-
add_action( 'init', 'register_block_core_search' );
|
|
208
216
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
function block_core_search_ensure_interactivity_dependency() {
|
|
217
|
-
global $wp_scripts;
|
|
218
|
-
if (
|
|
219
|
-
isset( $wp_scripts->registered['wp-block-search-view'] ) &&
|
|
220
|
-
! in_array( 'wp-interactivity', $wp_scripts->registered['wp-block-search-view']->deps, true )
|
|
221
|
-
) {
|
|
222
|
-
$wp_scripts->registered['wp-block-search-view']->deps[] = 'wp-interactivity';
|
|
217
|
+
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
|
|
218
|
+
gutenberg_register_module(
|
|
219
|
+
'@wordpress/block-library/search-block',
|
|
220
|
+
gutenberg_url( '/build/interactivity/search.min.js' ),
|
|
221
|
+
array( '@wordpress/interactivity' ),
|
|
222
|
+
defined( 'GUTENBERG_VERSION' ) ? GUTENBERG_VERSION : get_bloginfo( 'version' )
|
|
223
|
+
);
|
|
223
224
|
}
|
|
224
225
|
}
|
|
225
|
-
|
|
226
|
-
add_action( 'wp_print_scripts', 'block_core_search_ensure_interactivity_dependency' );
|
|
226
|
+
add_action( 'init', 'register_block_core_search' );
|
|
227
227
|
|
|
228
228
|
/**
|
|
229
229
|
* Builds the correct top level classnames for the 'core/search' block.
|