@wordpress/block-library 8.14.0 → 8.15.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/avatar/edit.js +1 -0
- package/build/avatar/edit.js.map +1 -1
- package/build/block/index.js +2 -1
- package/build/block/index.js.map +1 -1
- package/build/buttons/edit.js +2 -2
- package/build/buttons/edit.js.map +1 -1
- package/build/column/edit.native.js +1 -4
- package/build/column/edit.native.js.map +1 -1
- package/build/columns/edit.js +1 -0
- package/build/columns/edit.js.map +1 -1
- package/build/comment-author-avatar/edit.js +1 -0
- package/build/comment-author-avatar/edit.js.map +1 -1
- package/build/cover/deprecated.js +4 -2
- package/build/cover/deprecated.js.map +1 -1
- package/build/embed/embed-placeholder.native.js +37 -13
- package/build/embed/embed-placeholder.native.js.map +1 -1
- package/build/file/index.js +1 -2
- package/build/file/index.js.map +1 -1
- package/build/file/inspector.js +1 -0
- package/build/file/inspector.js.map +1 -1
- package/build/file/view-interactivity.js +23 -0
- package/build/file/view-interactivity.js.map +1 -0
- package/build/file/view.js +1 -15
- package/build/file/view.js.map +1 -1
- package/build/footnotes/edit.js +20 -1
- package/build/footnotes/edit.js.map +1 -1
- package/build/footnotes/format.js +19 -16
- package/build/footnotes/format.js.map +1 -1
- package/build/footnotes/index.js +0 -1
- package/build/footnotes/index.js.map +1 -1
- package/build/gallery/edit.js +1 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/latest-comments/edit.js +1 -0
- package/build/latest-comments/edit.js.map +1 -1
- package/build/latest-posts/edit.js +2 -0
- package/build/latest-posts/edit.js.map +1 -1
- package/build/list/edit.js +4 -4
- package/build/list/edit.js.map +1 -1
- package/build/media-text/media-container.native.js +2 -1
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/missing/edit.native.js +7 -5
- package/build/missing/edit.native.js.map +1 -1
- package/build/navigation/constants.js +10 -4
- package/build/navigation/constants.js.map +1 -1
- package/build/navigation/edit/index.js +16 -2
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +2 -2
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +2 -2
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +10 -15
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build/navigation/index.js +2 -3
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +33 -45
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation/view-interactivity.js +185 -0
- package/build/navigation/view-interactivity.js.map +1 -0
- package/build/navigation/view-modal.js +64 -0
- package/build/navigation/view-modal.js.map +1 -0
- package/build/navigation/view.js +50 -174
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +12 -7
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +2 -2
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/query-pagination/edit.js +1 -1
- package/build/query-pagination/edit.js.map +1 -1
- package/build/query-title/edit.js +43 -1
- package/build/query-title/edit.js.map +1 -1
- package/build/quote/transforms.js +8 -0
- package/build/quote/transforms.js.map +1 -1
- package/build/rss/edit.js +3 -0
- package/build/rss/edit.js.map +1 -1
- package/build/search/edit.js +4 -3
- package/build/search/edit.js.map +1 -1
- package/build/search/index.js +1 -0
- package/build/search/index.js.map +1 -1
- package/build/site-logo/edit.js +1 -0
- package/build/site-logo/edit.js.map +1 -1
- package/build/tag-cloud/edit.js +1 -0
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/template-part/edit/index.js +1 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build/text-columns/edit.js +1 -0
- package/build/text-columns/edit.js.map +1 -1
- package/build-module/avatar/edit.js +1 -0
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/block/index.js +2 -1
- package/build-module/block/index.js.map +1 -1
- package/build-module/buttons/edit.js +2 -2
- package/build-module/buttons/edit.js.map +1 -1
- package/build-module/column/edit.native.js +1 -4
- package/build-module/column/edit.native.js.map +1 -1
- package/build-module/columns/edit.js +1 -0
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/comment-author-avatar/edit.js +1 -0
- package/build-module/comment-author-avatar/edit.js.map +1 -1
- package/build-module/cover/deprecated.js +4 -2
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/embed/embed-placeholder.native.js +37 -14
- package/build-module/embed/embed-placeholder.native.js.map +1 -1
- package/build-module/file/index.js +1 -2
- package/build-module/file/index.js.map +1 -1
- package/build-module/file/inspector.js +1 -0
- package/build-module/file/inspector.js.map +1 -1
- package/build-module/file/view-interactivity.js +19 -0
- package/build-module/file/view-interactivity.js.map +1 -0
- package/build-module/file/view.js +2 -15
- package/build-module/file/view.js.map +1 -1
- package/build-module/footnotes/edit.js +18 -2
- package/build-module/footnotes/edit.js.map +1 -1
- package/build-module/footnotes/format.js +19 -16
- package/build-module/footnotes/format.js.map +1 -1
- package/build-module/footnotes/index.js +0 -1
- package/build-module/footnotes/index.js.map +1 -1
- package/build-module/gallery/edit.js +1 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/latest-comments/edit.js +1 -0
- package/build-module/latest-comments/edit.js.map +1 -1
- package/build-module/latest-posts/edit.js +2 -0
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/list/edit.js +4 -4
- package/build-module/list/edit.js.map +1 -1
- package/build-module/media-text/media-container.native.js +2 -1
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/missing/edit.native.js +8 -6
- package/build-module/missing/edit.native.js.map +1 -1
- package/build-module/navigation/constants.js +8 -3
- package/build-module/navigation/constants.js.map +1 -1
- package/build-module/navigation/edit/index.js +17 -3
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +2 -2
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +2 -2
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +10 -14
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build-module/navigation/index.js +2 -3
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +35 -47
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation/view-interactivity.js +182 -0
- package/build-module/navigation/view-interactivity.js.map +1 -0
- package/build-module/navigation/view-modal.js +58 -0
- package/build-module/navigation/view-modal.js.map +1 -0
- package/build-module/navigation/view.js +50 -173
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +12 -7
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +2 -2
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/query-pagination/edit.js +1 -1
- package/build-module/query-pagination/edit.js.map +1 -1
- package/build-module/query-title/edit.js +44 -3
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/quote/transforms.js +8 -0
- package/build-module/quote/transforms.js.map +1 -1
- package/build-module/rss/edit.js +3 -0
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/search/edit.js +4 -3
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/index.js +1 -0
- package/build-module/search/index.js.map +1 -1
- package/build-module/site-logo/edit.js +1 -0
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/tag-cloud/edit.js +1 -0
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/template-part/edit/index.js +1 -1
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/text-columns/edit.js +1 -0
- package/build-module/text-columns/edit.js.map +1 -1
- package/build-style/details/style-rtl.css +4 -2
- package/build-style/details/style.css +4 -2
- package/build-style/footnotes/style-rtl.css +4 -3
- package/build-style/footnotes/style.css +4 -3
- package/build-style/navigation/style-rtl.css +14 -2
- package/build-style/navigation/style.css +14 -2
- package/build-style/query-pagination/style-rtl.css +4 -2
- package/build-style/query-pagination/style.css +4 -2
- package/build-style/style-rtl.css +26 -9
- package/build-style/style.css +26 -9
- package/package.json +33 -32
- package/src/audio/test/__snapshots__/edit.native.js.snap +58 -33
- package/src/avatar/edit.js +1 -0
- package/src/block/block.json +2 -1
- package/src/block/editor.native.scss +2 -2
- package/src/buttons/edit.js +2 -2
- package/src/column/edit.native.js +4 -10
- package/src/column/editor.native.scss +0 -4
- package/src/columns/edit.js +1 -0
- package/src/comment-author-avatar/edit.js +1 -0
- package/src/comment-template/index.php +5 -2
- package/src/cover/deprecated.js +2 -0
- package/src/embed/embed-placeholder.native.js +80 -47
- package/src/embed/styles.native.scss +54 -18
- package/src/embed/test/index.native.js +5 -5
- package/src/file/block.json +1 -2
- package/src/file/index.php +19 -1
- package/src/file/inspector.js +1 -0
- package/src/file/test/__snapshots__/edit.native.js.snap +58 -33
- package/src/file/view-interactivity.js +18 -0
- package/src/file/view.js +5 -14
- package/src/footnotes/block.json +0 -1
- package/src/footnotes/edit.js +21 -2
- package/src/footnotes/format.js +22 -20
- package/src/footnotes/style.scss +6 -3
- package/src/gallery/edit.js +1 -1
- package/src/gallery/test/index.native.js +17 -16
- package/src/home-link/index.php +15 -2
- package/src/image/index.php +47 -8
- package/src/image/test/edit.native.js +1 -1
- package/src/latest-comments/edit.js +1 -0
- package/src/latest-posts/edit.js +2 -0
- package/src/list/edit.js +6 -4
- package/src/list/test/edit.native.js +129 -33
- package/src/media-text/media-container.native.js +1 -0
- package/src/missing/edit.native.js +12 -10
- package/src/missing/style.native.scss +19 -12
- package/src/missing/test/__snapshots__/edit.native.js.snap +21 -13
- package/src/navigation/block.json +2 -3
- package/src/navigation/constants.js +12 -6
- package/src/navigation/edit/index.js +29 -1
- package/src/navigation/edit/inner-blocks.js +2 -2
- package/src/navigation/edit/unsaved-inner-blocks.js +2 -2
- package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +17 -21
- package/src/navigation/index.php +24 -6
- package/src/navigation/style.scss +27 -8
- package/src/navigation/use-navigation-menu.js +39 -63
- package/src/navigation/view-interactivity.js +196 -0
- package/src/navigation/view-modal.js +78 -0
- package/src/navigation/view.js +67 -189
- package/src/navigation-link/edit.js +61 -47
- package/src/navigation-submenu/edit.js +2 -2
- package/src/paragraph/test/__snapshots__/edit.native.js.snap +1 -0
- package/src/paragraph/test/edit.native.js +26 -0
- package/src/post-template/index.php +4 -2
- package/src/post-title/index.php +6 -3
- package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -0
- package/src/query-pagination/edit.js +17 -14
- package/src/query-title/edit.js +48 -6
- package/src/quote/test/__snapshots__/transforms.native.js.snap +10 -0
- package/src/quote/test/transforms.native.js +5 -1
- package/src/quote/transforms.js +13 -0
- package/src/rss/edit.js +3 -0
- package/src/search/block.json +1 -0
- package/src/search/edit.js +4 -3
- package/src/search/index.php +22 -4
- package/src/search/test/__snapshots__/edit.native.js.snap +7 -0
- package/src/site-logo/edit.js +1 -0
- package/src/tag-cloud/edit.js +1 -0
- package/src/template-part/edit/index.js +1 -1
- package/src/template-part/index.php +9 -15
- package/src/text-columns/edit.js +1 -0
- package/build/gallery/shared-icon.native.js +0 -38
- package/build/gallery/shared-icon.native.js.map +0 -1
- package/build-module/gallery/shared-icon.native.js +0 -24
- package/build-module/gallery/shared-icon.native.js.map +0 -1
- package/src/gallery/shared-icon.native.js +0 -23
|
@@ -330,7 +330,7 @@ describe( 'Embed block', () => {
|
|
|
330
330
|
const editor = await initializeWithEmbedBlock( EMPTY_EMBED_HTML );
|
|
331
331
|
|
|
332
332
|
// Edit URL.
|
|
333
|
-
fireEvent.press( await editor.findByText( '
|
|
333
|
+
fireEvent.press( await editor.findByText( 'Add link' ) );
|
|
334
334
|
|
|
335
335
|
// Wait for edit URL modal to be visible.
|
|
336
336
|
const embedEditURLModal = editor.getByTestId(
|
|
@@ -351,7 +351,7 @@ describe( 'Embed block', () => {
|
|
|
351
351
|
const editor = await initializeWithEmbedBlock( EMPTY_EMBED_HTML );
|
|
352
352
|
|
|
353
353
|
// Edit URL.
|
|
354
|
-
fireEvent.press( editor.getByText( '
|
|
354
|
+
fireEvent.press( editor.getByText( 'Add link' ) );
|
|
355
355
|
|
|
356
356
|
// Wait for edit URL modal to be visible.
|
|
357
357
|
const embedEditURLModal = editor.getByTestId(
|
|
@@ -392,7 +392,7 @@ describe( 'Embed block', () => {
|
|
|
392
392
|
const editor = await initializeWithEmbedBlock( EMPTY_EMBED_HTML );
|
|
393
393
|
|
|
394
394
|
// Edit URL.
|
|
395
|
-
fireEvent.press( editor.getByText( '
|
|
395
|
+
fireEvent.press( editor.getByText( 'Add link' ) );
|
|
396
396
|
|
|
397
397
|
// Wait for edit URL modal to be visible.
|
|
398
398
|
const embedEditURLModal = editor.getByTestId(
|
|
@@ -592,7 +592,7 @@ describe( 'Embed block', () => {
|
|
|
592
592
|
fireEvent.press( editor.block );
|
|
593
593
|
|
|
594
594
|
// Edit URL.
|
|
595
|
-
fireEvent.press( editor.getByText( '
|
|
595
|
+
fireEvent.press( editor.getByText( 'Add link' ) );
|
|
596
596
|
|
|
597
597
|
// Wait for edit URL modal to be visible.
|
|
598
598
|
await waitForModalVisible( embedEditURLModal );
|
|
@@ -602,7 +602,7 @@ describe( 'Embed block', () => {
|
|
|
602
602
|
fireEvent( embedEditURLModal, MODAL_DISMISS_EVENT );
|
|
603
603
|
|
|
604
604
|
// Edit URL.
|
|
605
|
-
fireEvent.press( editor.getByText( '
|
|
605
|
+
fireEvent.press( editor.getByText( 'Add link' ) );
|
|
606
606
|
|
|
607
607
|
// Wait for edit URL modal to be visible.
|
|
608
608
|
await waitForModalVisible( embedEditURLModal );
|
package/src/file/block.json
CHANGED
package/src/file/index.php
CHANGED
|
@@ -5,6 +5,24 @@
|
|
|
5
5
|
* @package WordPress
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
if ( gutenberg_should_block_use_interactivity_api( 'core/file' ) ) {
|
|
9
|
+
/**
|
|
10
|
+
* Replaces view script for the File block with version using Interactivity API.
|
|
11
|
+
*
|
|
12
|
+
* @param array $metadata Block metadata as read in via block.json.
|
|
13
|
+
*
|
|
14
|
+
* @return array Filtered block type metadata.
|
|
15
|
+
*/
|
|
16
|
+
function gutenberg_block_core_file_update_interactive_view_script( $metadata ) {
|
|
17
|
+
if ( 'core/file' === $metadata['name'] ) {
|
|
18
|
+
$metadata['viewScript'] = array( 'file:./view-interactivity.min.js' );
|
|
19
|
+
$metadata['supports']['interactivity'] = true;
|
|
20
|
+
}
|
|
21
|
+
return $metadata;
|
|
22
|
+
}
|
|
23
|
+
add_filter( 'block_type_metadata', 'gutenberg_block_core_file_update_interactive_view_script', 10, 1 );
|
|
24
|
+
}
|
|
25
|
+
|
|
8
26
|
/**
|
|
9
27
|
* When the `core/file` block is rendering, check if we need to enqueue the `'wp-block-file-view` script.
|
|
10
28
|
*
|
|
@@ -54,7 +72,7 @@ function render_block_core_file( $attributes, $content, $block ) {
|
|
|
54
72
|
);
|
|
55
73
|
|
|
56
74
|
// If it uses the Interactivity API, add the directives.
|
|
57
|
-
if (
|
|
75
|
+
if ( gutenberg_should_block_use_interactivity_api( 'core/file' ) && $should_load_view_script ) {
|
|
58
76
|
$processor = new WP_HTML_Tag_Processor( $content );
|
|
59
77
|
$processor->next_tag();
|
|
60
78
|
$processor->set_attribute( 'data-wp-interactive', '' );
|
package/src/file/inspector.js
CHANGED
|
@@ -94,6 +94,7 @@ exports[`File block renders file error state without crashing 1`] = `
|
|
|
94
94
|
onStartShouldSetResponder={[Function]}
|
|
95
95
|
placeholder="File name"
|
|
96
96
|
placeholderTextColor="gray"
|
|
97
|
+
selectionColor="black"
|
|
97
98
|
style={
|
|
98
99
|
{
|
|
99
100
|
"backgroundColor": undefined,
|
|
@@ -322,6 +323,7 @@ exports[`File block renders file without crashing 1`] = `
|
|
|
322
323
|
onStartShouldSetResponder={[Function]}
|
|
323
324
|
placeholder="File name"
|
|
324
325
|
placeholderTextColor="gray"
|
|
326
|
+
selectionColor="black"
|
|
325
327
|
style={
|
|
326
328
|
{
|
|
327
329
|
"backgroundColor": undefined,
|
|
@@ -439,22 +441,13 @@ exports[`File block renders placeholder without crashing 1`] = `
|
|
|
439
441
|
}
|
|
440
442
|
>
|
|
441
443
|
<View
|
|
442
|
-
accessibilityHint="Double tap to select"
|
|
443
|
-
accessibilityLabel="File block. Empty"
|
|
444
|
-
accessibilityRole="button"
|
|
445
|
-
accessible={true}
|
|
446
|
-
focusable={true}
|
|
447
|
-
onClick={[Function]}
|
|
448
|
-
onResponderGrant={[Function]}
|
|
449
|
-
onResponderMove={[Function]}
|
|
450
|
-
onResponderRelease={[Function]}
|
|
451
|
-
onResponderTerminate={[Function]}
|
|
452
|
-
onResponderTerminationRequest={[Function]}
|
|
453
|
-
onStartShouldSetResponder={[Function]}
|
|
454
444
|
style={
|
|
455
445
|
[
|
|
456
446
|
[
|
|
457
|
-
|
|
447
|
+
[
|
|
448
|
+
undefined,
|
|
449
|
+
false,
|
|
450
|
+
],
|
|
458
451
|
undefined,
|
|
459
452
|
undefined,
|
|
460
453
|
],
|
|
@@ -462,33 +455,65 @@ exports[`File block renders placeholder without crashing 1`] = `
|
|
|
462
455
|
]
|
|
463
456
|
}
|
|
464
457
|
>
|
|
458
|
+
<View>
|
|
459
|
+
<View
|
|
460
|
+
style={
|
|
461
|
+
{
|
|
462
|
+
"fill": "black",
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
>
|
|
466
|
+
<View
|
|
467
|
+
style={{}}
|
|
468
|
+
>
|
|
469
|
+
<Svg
|
|
470
|
+
fill="black"
|
|
471
|
+
height={24}
|
|
472
|
+
style={{}}
|
|
473
|
+
viewBox="0 0 24 24"
|
|
474
|
+
width={24}
|
|
475
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
476
|
+
>
|
|
477
|
+
Path
|
|
478
|
+
</Svg>
|
|
479
|
+
</View>
|
|
480
|
+
</View>
|
|
481
|
+
<Text>
|
|
482
|
+
File
|
|
483
|
+
</Text>
|
|
484
|
+
</View>
|
|
465
485
|
<View
|
|
486
|
+
accessibilityHint="Double tap to select"
|
|
487
|
+
accessibilityLabel="File block. Empty"
|
|
488
|
+
accessibilityRole="button"
|
|
489
|
+
accessible={true}
|
|
490
|
+
collapsable={false}
|
|
491
|
+
focusable={true}
|
|
492
|
+
hitSlop={
|
|
493
|
+
{
|
|
494
|
+
"bottom": 22,
|
|
495
|
+
"left": 22,
|
|
496
|
+
"right": 22,
|
|
497
|
+
"top": 22,
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
onClick={[Function]}
|
|
501
|
+
onResponderGrant={[Function]}
|
|
502
|
+
onResponderMove={[Function]}
|
|
503
|
+
onResponderRelease={[Function]}
|
|
504
|
+
onResponderTerminate={[Function]}
|
|
505
|
+
onResponderTerminationRequest={[Function]}
|
|
506
|
+
onStartShouldSetResponder={[Function]}
|
|
466
507
|
style={
|
|
467
508
|
{
|
|
468
|
-
"
|
|
509
|
+
"opacity": 1,
|
|
469
510
|
}
|
|
470
511
|
}
|
|
471
512
|
>
|
|
472
|
-
<
|
|
473
|
-
|
|
474
|
-
>
|
|
475
|
-
<Svg
|
|
476
|
-
height={24}
|
|
477
|
-
style={{}}
|
|
478
|
-
viewBox="0 0 24 24"
|
|
479
|
-
width={24}
|
|
480
|
-
xmlns="http://www.w3.org/2000/svg"
|
|
481
|
-
>
|
|
482
|
-
Path
|
|
483
|
-
</Svg>
|
|
484
|
-
</View>
|
|
513
|
+
<Text>
|
|
514
|
+
Choose a file
|
|
515
|
+
</Text>
|
|
485
516
|
</View>
|
|
486
|
-
<Text>
|
|
487
|
-
File
|
|
488
|
-
</Text>
|
|
489
|
-
<Text>
|
|
490
|
-
CHOOSE A FILE
|
|
491
|
-
</Text>
|
|
492
517
|
</View>
|
|
493
518
|
</View>
|
|
494
519
|
`;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { store } from '@wordpress/interactivity';
|
|
5
|
+
/**
|
|
6
|
+
* Internal dependencies
|
|
7
|
+
*/
|
|
8
|
+
import { browserSupportsPdfs as hasPdfPreview } from './utils';
|
|
9
|
+
|
|
10
|
+
store( {
|
|
11
|
+
selectors: {
|
|
12
|
+
core: {
|
|
13
|
+
file: {
|
|
14
|
+
hasPdfPreview,
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
},
|
|
18
|
+
} );
|
package/src/file/view.js
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { store } from '@wordpress/interactivity';
|
|
5
1
|
/**
|
|
6
2
|
* Internal dependencies
|
|
7
3
|
*/
|
|
8
|
-
import {
|
|
4
|
+
import { hidePdfEmbedsOnUnsupportedBrowsers } from './utils';
|
|
9
5
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
hasPdfPreview,
|
|
15
|
-
},
|
|
16
|
-
},
|
|
17
|
-
},
|
|
18
|
-
} );
|
|
6
|
+
document.addEventListener(
|
|
7
|
+
'DOMContentLoaded',
|
|
8
|
+
hidePdfEmbedsOnUnsupportedBrowsers
|
|
9
|
+
);
|
package/src/footnotes/block.json
CHANGED
package/src/footnotes/edit.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { RichText, useBlockProps } from '@wordpress/block-editor';
|
|
4
|
+
import { BlockIcon, RichText, useBlockProps } from '@wordpress/block-editor';
|
|
5
5
|
import { useEntityProp } from '@wordpress/core-data';
|
|
6
|
+
import { __ } from '@wordpress/i18n';
|
|
7
|
+
import { Placeholder } from '@wordpress/components';
|
|
8
|
+
import { formatListNumbered as icon } from '@wordpress/icons';
|
|
6
9
|
|
|
7
10
|
export default function FootnotesEdit( { context: { postType, postId } } ) {
|
|
8
11
|
const [ meta, updateMeta ] = useEntityProp(
|
|
@@ -12,8 +15,24 @@ export default function FootnotesEdit( { context: { postType, postId } } ) {
|
|
|
12
15
|
postId
|
|
13
16
|
);
|
|
14
17
|
const footnotes = meta?.footnotes ? JSON.parse( meta.footnotes ) : [];
|
|
18
|
+
const blockProps = useBlockProps();
|
|
19
|
+
|
|
20
|
+
if ( ! footnotes.length ) {
|
|
21
|
+
return (
|
|
22
|
+
<div { ...blockProps }>
|
|
23
|
+
<Placeholder
|
|
24
|
+
icon={ <BlockIcon icon={ icon } /> }
|
|
25
|
+
label={ __( 'Footnotes' ) }
|
|
26
|
+
instructions={ __(
|
|
27
|
+
'Footnotes found in blocks within this document will be displayed here.'
|
|
28
|
+
) }
|
|
29
|
+
/>
|
|
30
|
+
</div>
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
|
|
15
34
|
return (
|
|
16
|
-
<ol { ...
|
|
35
|
+
<ol { ...blockProps }>
|
|
17
36
|
{ footnotes.map( ( { id, content } ) => (
|
|
18
37
|
<li key={ id }>
|
|
19
38
|
<RichText
|
package/src/footnotes/format.js
CHANGED
|
@@ -24,11 +24,9 @@ import { name } from './block.json';
|
|
|
24
24
|
export const formatName = 'core/footnote';
|
|
25
25
|
export const format = {
|
|
26
26
|
title: __( 'Footnote' ),
|
|
27
|
-
tagName: '
|
|
27
|
+
tagName: 'sup',
|
|
28
28
|
className: 'fn',
|
|
29
29
|
attributes: {
|
|
30
|
-
id: 'id',
|
|
31
|
-
href: 'href',
|
|
32
30
|
'data-fn': 'data-fn',
|
|
33
31
|
},
|
|
34
32
|
contentEditable: false,
|
|
@@ -42,26 +40,30 @@ export const format = {
|
|
|
42
40
|
} = useSelect( blockEditorStore );
|
|
43
41
|
const { selectionChange, insertBlock } =
|
|
44
42
|
useDispatch( blockEditorStore );
|
|
43
|
+
|
|
45
44
|
function onClick() {
|
|
46
45
|
registry.batch( () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
value
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
let id;
|
|
47
|
+
if ( isObjectActive ) {
|
|
48
|
+
const object = value.replacements[ value.start ];
|
|
49
|
+
id = object?.attributes?.[ 'data-fn' ];
|
|
50
|
+
} else {
|
|
51
|
+
id = createId();
|
|
52
|
+
const newValue = insertObject(
|
|
53
|
+
value,
|
|
54
|
+
{
|
|
55
|
+
type: formatName,
|
|
56
|
+
attributes: {
|
|
57
|
+
'data-fn': id,
|
|
58
|
+
},
|
|
59
|
+
innerHTML: `<a href="#${ id }" id="${ id }-link">*</a>`,
|
|
56
60
|
},
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
onChange( newValue );
|
|
61
|
+
value.end,
|
|
62
|
+
value.end
|
|
63
|
+
);
|
|
64
|
+
newValue.start = newValue.end - 1;
|
|
65
|
+
onChange( newValue );
|
|
66
|
+
}
|
|
65
67
|
|
|
66
68
|
// BFS search to find the first footnote block.
|
|
67
69
|
let fnBlock = null;
|
package/src/footnotes/style.scss
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
+
// These styles are for backwards compatibility with the old footnotes anchors.
|
|
2
|
+
// Can be removed in the future.
|
|
1
3
|
.editor-styles-wrapper,
|
|
2
4
|
.entry-content {
|
|
3
5
|
counter-reset: footnotes;
|
|
4
6
|
}
|
|
5
7
|
|
|
6
|
-
[data-fn].fn {
|
|
8
|
+
a[data-fn].fn {
|
|
7
9
|
vertical-align: super;
|
|
8
10
|
font-size: smaller;
|
|
9
11
|
counter-increment: footnotes;
|
|
10
|
-
display: inline-
|
|
12
|
+
display: inline-flex;
|
|
13
|
+
text-decoration: none;
|
|
11
14
|
text-indent: -9999999px;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
[data-fn].fn::after {
|
|
17
|
+
a[data-fn].fn::after {
|
|
15
18
|
content: "[" counter(footnotes) "]";
|
|
16
19
|
text-indent: 0;
|
|
17
20
|
float: left;
|
package/src/gallery/edit.js
CHANGED
|
@@ -134,7 +134,7 @@ describe( 'Gallery block', () => {
|
|
|
134
134
|
// Tap on Gallery block
|
|
135
135
|
const block = await getBlock( screen, 'Gallery' );
|
|
136
136
|
fireEvent.press( block );
|
|
137
|
-
fireEvent.press( within( block ).getByText( '
|
|
137
|
+
fireEvent.press( within( block ).getByText( 'Add media' ) );
|
|
138
138
|
|
|
139
139
|
// Observe that media options picker is displayed
|
|
140
140
|
/* eslint-disable jest/no-conditional-expect */
|
|
@@ -161,7 +161,7 @@ describe( 'Gallery block', () => {
|
|
|
161
161
|
|
|
162
162
|
// This case is disabled until the issue (https://github.com/WordPress/gutenberg/issues/38444)
|
|
163
163
|
// is addressed.
|
|
164
|
-
it.skip( 'block remains selected after
|
|
164
|
+
it.skip( 'block remains selected after dismissing the media options picker', async () => {
|
|
165
165
|
// Initialize with an empty gallery
|
|
166
166
|
const { getByLabelText, getByText, getByTestId } =
|
|
167
167
|
await initializeEditor( {
|
|
@@ -169,13 +169,13 @@ describe( 'Gallery block', () => {
|
|
|
169
169
|
} );
|
|
170
170
|
|
|
171
171
|
// Tap on Gallery block
|
|
172
|
-
fireEvent.press( getByText( '
|
|
172
|
+
fireEvent.press( getByText( 'Add media' ) );
|
|
173
173
|
|
|
174
174
|
// Observe that media options picker is displayed
|
|
175
175
|
expect( getByText( 'Choose images' ) ).toBeVisible();
|
|
176
176
|
expect( getByText( 'WordPress Media Library' ) ).toBeVisible();
|
|
177
177
|
|
|
178
|
-
//
|
|
178
|
+
// Dismiss the picker
|
|
179
179
|
if ( Platform.isIOS ) {
|
|
180
180
|
fireEvent.press( getByText( 'Cancel' ) );
|
|
181
181
|
} else {
|
|
@@ -283,7 +283,7 @@ describe( 'Gallery block', () => {
|
|
|
283
283
|
const { selectOption } = setupPicker( screen, MEDIA_OPTIONS );
|
|
284
284
|
|
|
285
285
|
// Upload images from device
|
|
286
|
-
fireEvent.press( getByText( '
|
|
286
|
+
fireEvent.press( getByText( 'Add media' ) );
|
|
287
287
|
selectOption( 'Choose from device' );
|
|
288
288
|
expectMediaPickerCall( 'DEVICE_MEDIA_LIBRARY', [ 'image' ], true );
|
|
289
289
|
|
|
@@ -321,7 +321,7 @@ describe( 'Gallery block', () => {
|
|
|
321
321
|
const { galleryBlock, getByText } = await initializeWithGalleryBlock();
|
|
322
322
|
|
|
323
323
|
// Upload images from device
|
|
324
|
-
fireEvent.press( getByText( '
|
|
324
|
+
fireEvent.press( getByText( 'Add media' ) );
|
|
325
325
|
fireEvent.press( getByText( 'Choose from device' ) );
|
|
326
326
|
expectMediaPickerCall( 'DEVICE_MEDIA_LIBRARY', [ 'image' ], true );
|
|
327
327
|
|
|
@@ -375,7 +375,7 @@ describe( 'Gallery block', () => {
|
|
|
375
375
|
const { galleryBlock, getByText } = await initializeWithGalleryBlock();
|
|
376
376
|
|
|
377
377
|
// Take a photo
|
|
378
|
-
fireEvent.press( getByText( '
|
|
378
|
+
fireEvent.press( getByText( 'Add media' ) );
|
|
379
379
|
fireEvent.press( getByText( 'Take a Photo' ) );
|
|
380
380
|
expectMediaPickerCall( 'DEVICE_CAMERA', [ 'image' ], true );
|
|
381
381
|
|
|
@@ -429,7 +429,7 @@ describe( 'Gallery block', () => {
|
|
|
429
429
|
);
|
|
430
430
|
|
|
431
431
|
// Upload images from free photo library
|
|
432
|
-
fireEvent.press( getByText( '
|
|
432
|
+
fireEvent.press( getByText( 'Add media' ) );
|
|
433
433
|
fireEvent.press( getByText( 'Free Photo Library' ) );
|
|
434
434
|
expectMediaPickerCall( 'stock-photo-library', [ 'image' ], true );
|
|
435
435
|
|
|
@@ -469,7 +469,7 @@ describe( 'Gallery block', () => {
|
|
|
469
469
|
const { galleryBlock, getByText } = await initializeWithGalleryBlock();
|
|
470
470
|
|
|
471
471
|
// Upload images from device
|
|
472
|
-
fireEvent.press( getByText( '
|
|
472
|
+
fireEvent.press( getByText( 'Add media' ) );
|
|
473
473
|
fireEvent.press( getByText( 'Choose from device' ) );
|
|
474
474
|
expectMediaPickerCall( 'DEVICE_MEDIA_LIBRARY', [ 'image' ], true );
|
|
475
475
|
|
|
@@ -511,10 +511,11 @@ describe( 'Gallery block', () => {
|
|
|
511
511
|
// Reference: https://github.com/wordpress-mobile/test-cases/blob/trunk/test-cases/gutenberg/gallery.md#tc010
|
|
512
512
|
it( 'rearranges gallery items', async () => {
|
|
513
513
|
// Initialize with a gallery that contains three items
|
|
514
|
-
const { galleryBlock } =
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
514
|
+
const { getByLabelText, galleryBlock } =
|
|
515
|
+
await initializeWithGalleryBlock( {
|
|
516
|
+
numberOfItems: 3,
|
|
517
|
+
media,
|
|
518
|
+
} );
|
|
518
519
|
|
|
519
520
|
// Rearrange items (final disposition will be: Image 3 - Image 1 - Image 2)
|
|
520
521
|
const galleryItem1 = getGalleryItem( galleryBlock, 1 );
|
|
@@ -523,7 +524,7 @@ describe( 'Gallery block', () => {
|
|
|
523
524
|
fireEvent.press( galleryItem3 );
|
|
524
525
|
await act( () =>
|
|
525
526
|
fireEvent.press(
|
|
526
|
-
|
|
527
|
+
getByLabelText(
|
|
527
528
|
/Move block left from position 3 to position 2/
|
|
528
529
|
)
|
|
529
530
|
)
|
|
@@ -532,7 +533,7 @@ describe( 'Gallery block', () => {
|
|
|
532
533
|
fireEvent.press( galleryItem1 );
|
|
533
534
|
await act( () =>
|
|
534
535
|
fireEvent.press(
|
|
535
|
-
|
|
536
|
+
getByLabelText(
|
|
536
537
|
/Move block right from position 1 to position 2/
|
|
537
538
|
)
|
|
538
539
|
)
|
|
@@ -568,7 +569,7 @@ describe( 'Gallery block', () => {
|
|
|
568
569
|
);
|
|
569
570
|
|
|
570
571
|
// Upload images from other apps
|
|
571
|
-
fireEvent.press( getByText( '
|
|
572
|
+
fireEvent.press( getByText( 'Add media' ) );
|
|
572
573
|
fireEvent.press( getByText( 'Other Apps' ) );
|
|
573
574
|
expectMediaPickerCall( 'other-files', [ 'image' ], true );
|
|
574
575
|
|
package/src/home-link/index.php
CHANGED
|
@@ -98,8 +98,15 @@ function block_core_home_link_build_li_wrapper_attributes( $context ) {
|
|
|
98
98
|
$colors['css_classes'],
|
|
99
99
|
$font_sizes['css_classes']
|
|
100
100
|
);
|
|
101
|
-
$classes[] = 'wp-block-navigation-item';
|
|
102
101
|
$style_attribute = ( $colors['inline_styles'] . $font_sizes['inline_styles'] );
|
|
102
|
+
$classes[] = 'wp-block-navigation-item';
|
|
103
|
+
|
|
104
|
+
if ( is_front_page() ) {
|
|
105
|
+
$classes[] = 'current-menu-item';
|
|
106
|
+
} elseif ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) {
|
|
107
|
+
// Edge case where the Reading settings has a posts page set but not a static homepage.
|
|
108
|
+
$classes[] = 'current-menu-item';
|
|
109
|
+
}
|
|
103
110
|
|
|
104
111
|
$wrapper_attributes = get_block_wrapper_attributes(
|
|
105
112
|
array(
|
|
@@ -124,8 +131,14 @@ function render_block_core_home_link( $attributes, $content, $block ) {
|
|
|
124
131
|
if ( empty( $attributes['label'] ) ) {
|
|
125
132
|
return '';
|
|
126
133
|
}
|
|
134
|
+
$aria_current = '';
|
|
127
135
|
|
|
128
|
-
|
|
136
|
+
if ( is_front_page() ) {
|
|
137
|
+
$aria_current = ' aria-current="page"';
|
|
138
|
+
} elseif ( is_home() && ( (int) get_option( 'page_for_posts' ) !== get_queried_object_id() ) ) {
|
|
139
|
+
// Edge case where the Reading settings has a posts page set but not a static homepage.
|
|
140
|
+
$aria_current = ' aria-current="page"';
|
|
141
|
+
}
|
|
129
142
|
|
|
130
143
|
return sprintf(
|
|
131
144
|
'<li %1$s><a class="wp-block-home-link__content wp-block-navigation-item__content" href="%2$s" rel="home"%3$s>%4$s</a></li>',
|
package/src/image/index.php
CHANGED
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
* Renders the `core/image` block on the server,
|
|
10
10
|
* adding a data-id attribute to the element if core/gallery has added on pre-render.
|
|
11
11
|
*
|
|
12
|
-
* @param array
|
|
13
|
-
* @param string
|
|
12
|
+
* @param array $attributes The block attributes.
|
|
13
|
+
* @param string $content The block content.
|
|
14
|
+
* @param WP_Block $block The block object.
|
|
14
15
|
* @return string Returns the block content with the data-id attribute added.
|
|
15
16
|
*/
|
|
16
|
-
function render_block_core_image( $attributes, $content ) {
|
|
17
|
+
function render_block_core_image( $attributes, $content, $block ) {
|
|
17
18
|
|
|
18
19
|
$processor = new WP_HTML_Tag_Processor( $content );
|
|
19
20
|
$processor->next_tag( 'img' );
|
|
@@ -30,14 +31,52 @@ function render_block_core_image( $attributes, $content ) {
|
|
|
30
31
|
$processor->set_attribute( 'data-id', $attributes['data-id'] );
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
$should_load_view_script = false;
|
|
35
|
+
$experiments = get_option( 'gutenberg-experiments' );
|
|
36
|
+
$link_destination = isset( $attributes['linkDestination'] ) ? $attributes['linkDestination'] : 'none';
|
|
37
|
+
// Get the lightbox setting from the block attributes.
|
|
38
|
+
if ( isset( $attributes['behaviors']['lightbox'] ) ) {
|
|
39
|
+
$lightbox_settings = $attributes['behaviors']['lightbox'];
|
|
40
|
+
// If the lightbox setting is not set in the block attributes, get it from the theme.json file.
|
|
41
|
+
} else {
|
|
42
|
+
$theme_data = WP_Theme_JSON_Resolver_Gutenberg::get_merged_data()->get_data();
|
|
43
|
+
if ( isset( $theme_data['behaviors']['blocks'][ $block->name ]['lightbox'] ) ) {
|
|
44
|
+
$lightbox_settings = $theme_data['behaviors']['blocks'][ $block->name ]['lightbox'];
|
|
45
|
+
} else {
|
|
46
|
+
$lightbox_settings = null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// If the lightbox is enabled, the image is not linked, and the Interactivity API is enabled, load the view script.
|
|
51
|
+
if ( isset( $lightbox_settings['enabled'] ) &&
|
|
52
|
+
true === $lightbox_settings['enabled'] &&
|
|
53
|
+
'none' === $link_destination &&
|
|
54
|
+
! empty( $experiments['gutenberg-interactivity-api-core-blocks'] )
|
|
55
|
+
) {
|
|
56
|
+
$should_load_view_script = true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
$view_js_file = 'wp-block-image-view';
|
|
60
|
+
if ( ! wp_script_is( $view_js_file ) ) {
|
|
61
|
+
$script_handles = $block->block_type->view_script_handles;
|
|
62
|
+
|
|
63
|
+
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
|
|
64
|
+
if ( ! $should_load_view_script && in_array( $view_js_file, $script_handles, true ) ) {
|
|
65
|
+
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
|
|
66
|
+
}
|
|
67
|
+
// If the script is needed, but it was previously removed, add it again.
|
|
68
|
+
if ( $should_load_view_script && ! in_array( $view_js_file, $script_handles, true ) ) {
|
|
69
|
+
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
33
73
|
return $processor->get_updated_html();
|
|
34
74
|
}
|
|
35
75
|
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Registers the `core/image` block on server.
|
|
78
|
+
*/
|
|
39
79
|
function register_block_core_image() {
|
|
40
|
-
|
|
41
80
|
register_block_type_from_metadata(
|
|
42
81
|
__DIR__ . '/image',
|
|
43
82
|
array(
|
|
@@ -45,4 +84,4 @@ function register_block_core_image() {
|
|
|
45
84
|
)
|
|
46
85
|
);
|
|
47
86
|
}
|
|
48
|
-
add_action( 'init', 'register_block_core_image' );
|
|
87
|
+
add_action( 'init', 'register_block_core_image' );
|
|
@@ -442,7 +442,7 @@ describe( 'Image Block', () => {
|
|
|
442
442
|
<!-- /wp:image -->`;
|
|
443
443
|
const screen = await initializeEditor( { initialHtml } );
|
|
444
444
|
|
|
445
|
-
fireEvent.press( screen.getByText( '
|
|
445
|
+
fireEvent.press( screen.getByText( 'Add image' ) );
|
|
446
446
|
fireEvent.press( screen.getByText( 'WordPress Media Library' ) );
|
|
447
447
|
|
|
448
448
|
const expectedHtml = `<!-- wp:image {"id":${ IMAGE.id },"sizeSlug":"large","linkDestination":"none"} -->
|