@wordpress/block-library 9.35.0 → 9.35.1-next.dc3f6d3c1.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/build/audio/index.js +26 -0
- package/build/audio/index.js.map +2 -2
- package/build/breadcrumbs/edit.js +1 -1
- package/build/breadcrumbs/edit.js.map +2 -2
- package/build/button/index.js +22 -0
- package/build/button/index.js.map +2 -2
- package/build/code/index.js +12 -0
- package/build/code/index.js.map +2 -2
- package/build/cover/index.js +22 -0
- package/build/cover/index.js.map +2 -2
- package/build/details/index.js +12 -0
- package/build/details/index.js.map +2 -2
- package/build/file/index.js +33 -0
- package/build/file/index.js.map +2 -2
- package/build/heading/index.js +12 -0
- package/build/heading/index.js.map +2 -2
- package/build/html/modal.js +126 -144
- package/build/html/modal.js.map +2 -2
- package/build/image/index.js +46 -0
- package/build/image/index.js.map +2 -2
- package/build/list-item/index.js +13 -0
- package/build/list-item/index.js.map +2 -2
- package/build/media-text/index.js +28 -0
- package/build/media-text/index.js.map +2 -2
- package/build/more/index.js +13 -0
- package/build/more/index.js.map +2 -2
- package/build/navigation/block.json +2 -2
- package/build/navigation-link/block.json +2 -1
- package/build/navigation-link/edit.js +6 -0
- package/build/navigation-link/edit.js.map +2 -2
- package/build/navigation-link/index.js +22 -0
- package/build/navigation-link/index.js.map +2 -2
- package/build/navigation-link/shared/controls.js +15 -19
- package/build/navigation-link/shared/controls.js.map +2 -2
- package/build/navigation-link/shared/index.js +4 -0
- package/build/navigation-link/shared/index.js.map +2 -2
- package/build/navigation-link/shared/use-entity-binding.js +3 -2
- package/build/navigation-link/shared/use-entity-binding.js.map +2 -2
- package/build/navigation-submenu/block.json +2 -1
- package/build/navigation-submenu/index.js +22 -0
- package/build/navigation-submenu/index.js.map +2 -2
- package/build/paragraph/index.js +12 -0
- package/build/paragraph/index.js.map +2 -2
- package/build/post-comments-count/edit.js +1 -2
- package/build/post-comments-count/edit.js.map +2 -2
- package/build/post-comments-link/edit.js +10 -7
- package/build/post-comments-link/edit.js.map +2 -2
- package/build/preformatted/index.js +12 -0
- package/build/preformatted/index.js.map +2 -2
- package/build/pullquote/block.json +3 -2
- package/build/pullquote/index.js +20 -0
- package/build/pullquote/index.js.map +2 -2
- package/build/pullquote/transforms.js +0 -31
- package/build/pullquote/transforms.js.map +2 -2
- package/build/quote/transforms.js +0 -20
- package/build/quote/transforms.js.map +2 -2
- package/build/search/index.js +28 -0
- package/build/search/index.js.map +2 -2
- package/build/social-link/index.js +22 -0
- package/build/social-link/index.js.map +2 -2
- package/build/social-links/edit.js +1 -1
- package/build/social-links/edit.js.map +1 -1
- package/build/tabs/view.js +17 -4
- package/build/tabs/view.js.map +2 -2
- package/build/verse/index.js +12 -0
- package/build/verse/index.js.map +2 -2
- package/build/video/index.js +27 -0
- package/build/video/index.js.map +2 -2
- package/build-module/audio/index.js +26 -0
- package/build-module/audio/index.js.map +2 -2
- package/build-module/breadcrumbs/edit.js +1 -1
- package/build-module/breadcrumbs/edit.js.map +2 -2
- package/build-module/button/index.js +22 -0
- package/build-module/button/index.js.map +2 -2
- package/build-module/code/index.js +12 -0
- package/build-module/code/index.js.map +2 -2
- package/build-module/cover/index.js +22 -0
- package/build-module/cover/index.js.map +2 -2
- package/build-module/details/index.js +12 -0
- package/build-module/details/index.js.map +2 -2
- package/build-module/file/index.js +34 -1
- package/build-module/file/index.js.map +2 -2
- package/build-module/heading/index.js +12 -0
- package/build-module/heading/index.js.map +2 -2
- package/build-module/html/modal.js +127 -145
- package/build-module/html/modal.js.map +2 -2
- package/build-module/image/index.js +46 -0
- package/build-module/image/index.js.map +2 -2
- package/build-module/list-item/index.js +13 -0
- package/build-module/list-item/index.js.map +2 -2
- package/build-module/media-text/index.js +28 -0
- package/build-module/media-text/index.js.map +2 -2
- package/build-module/more/index.js +13 -0
- package/build-module/more/index.js.map +2 -2
- package/build-module/navigation/block.json +2 -2
- package/build-module/navigation-link/block.json +2 -1
- package/build-module/navigation-link/edit.js +20 -4
- package/build-module/navigation-link/edit.js.map +2 -2
- package/build-module/navigation-link/index.js +23 -1
- package/build-module/navigation-link/index.js.map +2 -2
- package/build-module/navigation-link/shared/controls.js +12 -18
- package/build-module/navigation-link/shared/controls.js.map +2 -2
- package/build-module/navigation-link/shared/index.js +3 -1
- package/build-module/navigation-link/shared/index.js.map +2 -2
- package/build-module/navigation-link/shared/use-entity-binding.js +3 -2
- package/build-module/navigation-link/shared/use-entity-binding.js.map +2 -2
- package/build-module/navigation-submenu/block.json +2 -1
- package/build-module/navigation-submenu/index.js +23 -1
- package/build-module/navigation-submenu/index.js.map +2 -2
- package/build-module/paragraph/index.js +12 -0
- package/build-module/paragraph/index.js.map +2 -2
- package/build-module/post-comments-count/edit.js +1 -3
- package/build-module/post-comments-count/edit.js.map +2 -2
- package/build-module/post-comments-link/edit.js +10 -8
- package/build-module/post-comments-link/edit.js.map +2 -2
- package/build-module/preformatted/index.js +12 -0
- package/build-module/preformatted/index.js.map +2 -2
- package/build-module/pullquote/block.json +3 -2
- package/build-module/pullquote/index.js +20 -0
- package/build-module/pullquote/index.js.map +2 -2
- package/build-module/pullquote/transforms.js +0 -31
- package/build-module/pullquote/transforms.js.map +2 -2
- package/build-module/quote/transforms.js +0 -20
- package/build-module/quote/transforms.js.map +2 -2
- package/build-module/search/index.js +28 -0
- package/build-module/search/index.js.map +2 -2
- package/build-module/social-link/index.js +22 -0
- package/build-module/social-link/index.js.map +2 -2
- package/build-module/social-links/edit.js +1 -1
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/tabs/view.js +17 -4
- package/build-module/tabs/view.js.map +2 -2
- package/build-module/verse/index.js +12 -0
- package/build-module/verse/index.js.map +2 -2
- package/build-module/video/index.js +27 -0
- package/build-module/video/index.js.map +2 -2
- package/package.json +37 -37
- package/src/audio/index.js +27 -0
- package/src/breadcrumbs/edit.js +4 -2
- package/src/breadcrumbs/index.php +112 -30
- package/src/button/index.js +23 -0
- package/src/code/index.js +13 -0
- package/src/cover/index.js +23 -0
- package/src/details/index.js +13 -0
- package/src/file/index.js +35 -1
- package/src/heading/index.js +13 -0
- package/src/heading/test/__snapshots__/transforms.native.js.snap +0 -6
- package/src/heading/test/transforms.native.js +1 -5
- package/src/html/modal.js +8 -28
- package/src/image/index.js +47 -0
- package/src/list-item/index.js +14 -0
- package/src/media-text/index.js +29 -0
- package/src/more/index.js +14 -0
- package/src/navigation/block.json +2 -2
- package/src/navigation-link/block.json +2 -1
- package/src/navigation-link/edit.js +27 -4
- package/src/navigation-link/index.js +24 -1
- package/src/navigation-link/shared/controls.js +13 -17
- package/src/navigation-link/shared/index.js +1 -1
- package/src/navigation-link/shared/use-entity-binding.js +5 -2
- package/src/navigation-submenu/block.json +2 -1
- package/src/navigation-submenu/index.js +24 -1
- package/src/paragraph/index.js +13 -0
- package/src/paragraph/test/__snapshots__/transforms.native.js.snap +0 -6
- package/src/paragraph/test/transforms.native.js +0 -1
- package/src/post-comments-count/edit.js +1 -9
- package/src/post-comments-link/edit.js +8 -18
- package/src/preformatted/index.js +13 -0
- package/src/pullquote/block.json +3 -2
- package/src/pullquote/index.js +21 -0
- package/src/pullquote/test/__snapshots__/transforms.native.js.snap +5 -5
- package/src/pullquote/test/transforms.native.js +1 -1
- package/src/pullquote/transforms.js +0 -31
- package/src/quote/test/__snapshots__/transforms.native.js.snap +0 -6
- package/src/quote/test/transforms.native.js +1 -5
- package/src/quote/transforms.js +0 -25
- package/src/search/index.js +29 -0
- package/src/social-link/index.js +23 -0
- package/src/social-links/edit.js +1 -1
- package/src/tabs/view.js +19 -4
- package/src/utils/transformation-categories.native.js +0 -1
- package/src/verse/index.js +13 -0
- package/src/video/index.js +28 -0
- package/src/pullquote/test/edit.native.js +0 -73
package/src/file/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { _x } from '@wordpress/i18n';
|
|
4
|
+
import { _x, __ } from '@wordpress/i18n';
|
|
5
5
|
import { file as icon } from '@wordpress/icons';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -32,4 +32,38 @@ export const settings = {
|
|
|
32
32
|
save,
|
|
33
33
|
};
|
|
34
34
|
|
|
35
|
+
if ( window.__experimentalContentOnlyPatternInsertion ) {
|
|
36
|
+
settings.fields = [
|
|
37
|
+
{
|
|
38
|
+
label: __( 'File' ),
|
|
39
|
+
type: 'Media',
|
|
40
|
+
shownByDefault: true,
|
|
41
|
+
mapping: {
|
|
42
|
+
id: 'id',
|
|
43
|
+
src: 'href',
|
|
44
|
+
},
|
|
45
|
+
args: {
|
|
46
|
+
allowedTypes: [],
|
|
47
|
+
multiple: false,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
label: __( 'Filename' ),
|
|
52
|
+
type: 'RichText',
|
|
53
|
+
shownByDefault: false,
|
|
54
|
+
mapping: {
|
|
55
|
+
value: 'fileName',
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
label: __( 'Button Text' ),
|
|
60
|
+
type: 'RichText',
|
|
61
|
+
shownByDefault: false,
|
|
62
|
+
mapping: {
|
|
63
|
+
value: 'downloadButtonText',
|
|
64
|
+
},
|
|
65
|
+
},
|
|
66
|
+
];
|
|
67
|
+
}
|
|
68
|
+
|
|
35
69
|
export const init = () => initBlock( { name, metadata, settings } );
|
package/src/heading/index.js
CHANGED
|
@@ -69,4 +69,17 @@ export const settings = {
|
|
|
69
69
|
variations,
|
|
70
70
|
};
|
|
71
71
|
|
|
72
|
+
if ( window.__experimentalContentOnlyPatternInsertion ) {
|
|
73
|
+
settings.fields = [
|
|
74
|
+
{
|
|
75
|
+
label: __( 'Content' ),
|
|
76
|
+
type: 'RichText',
|
|
77
|
+
shownByDefault: true,
|
|
78
|
+
mapping: {
|
|
79
|
+
value: 'content',
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
];
|
|
83
|
+
}
|
|
84
|
+
|
|
72
85
|
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -32,12 +32,6 @@ exports[`Heading block transforms to Paragraph block 1`] = `
|
|
|
32
32
|
<!-- /wp:paragraph -->"
|
|
33
33
|
`;
|
|
34
34
|
|
|
35
|
-
exports[`Heading block transforms to Pullquote block 1`] = `
|
|
36
|
-
"<!-- wp:pullquote -->
|
|
37
|
-
<figure class="wp-block-pullquote"><blockquote><p>Example text</p></blockquote></figure>
|
|
38
|
-
<!-- /wp:pullquote -->"
|
|
39
|
-
`;
|
|
40
|
-
|
|
41
35
|
exports[`Heading block transforms to Quote block 1`] = `
|
|
42
36
|
"<!-- wp:quote -->
|
|
43
37
|
<blockquote class="wp-block-quote"><!-- wp:heading -->
|
|
@@ -16,11 +16,7 @@ const initialHtml = `
|
|
|
16
16
|
<!-- /wp:heading -->`;
|
|
17
17
|
|
|
18
18
|
const transformsWithInnerBlocks = [ 'List', 'Quote', 'Columns', 'Group' ];
|
|
19
|
-
const blockTransforms = [
|
|
20
|
-
'Paragraph',
|
|
21
|
-
'Pullquote',
|
|
22
|
-
...transformsWithInnerBlocks,
|
|
23
|
-
];
|
|
19
|
+
const blockTransforms = [ 'Paragraph', ...transformsWithInnerBlocks ];
|
|
24
20
|
|
|
25
21
|
setupCoreBlocks();
|
|
26
22
|
|
package/src/html/modal.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { useState
|
|
5
|
+
import { useState } from '@wordpress/element';
|
|
6
6
|
import { useSelect } from '@wordpress/data';
|
|
7
7
|
import {
|
|
8
8
|
Modal,
|
|
@@ -40,32 +40,17 @@ export default function HTMLEditModal( {
|
|
|
40
40
|
const [ isFullscreen, setIsFullscreen ] = useState( false );
|
|
41
41
|
|
|
42
42
|
// Check if user has permission to save scripts and get editor styles
|
|
43
|
-
const { canUserUseUnfilteredHTML
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
[]
|
|
53
|
-
);
|
|
43
|
+
const { canUserUseUnfilteredHTML } = useSelect( ( select ) => {
|
|
44
|
+
const settings = select( blockEditorStore ).getSettings();
|
|
45
|
+
return {
|
|
46
|
+
canUserUseUnfilteredHTML:
|
|
47
|
+
settings.__experimentalCanUserUseUnfilteredHTML,
|
|
48
|
+
};
|
|
49
|
+
}, [] );
|
|
54
50
|
|
|
55
51
|
// Show JS tab if user has permission OR if block contains JavaScript
|
|
56
52
|
const shouldShowJsTab = canUserUseUnfilteredHTML || js.trim() !== '';
|
|
57
53
|
|
|
58
|
-
// Combine all editor styles to inject into modal
|
|
59
|
-
const styleContent = useMemo( () => {
|
|
60
|
-
if ( ! editorStyles ) {
|
|
61
|
-
return '';
|
|
62
|
-
}
|
|
63
|
-
return editorStyles
|
|
64
|
-
.filter( ( style ) => style.css )
|
|
65
|
-
.map( ( style ) => style.css )
|
|
66
|
-
.join( '\n' );
|
|
67
|
-
}, [ editorStyles ] );
|
|
68
|
-
|
|
69
54
|
if ( ! isOpen ) {
|
|
70
55
|
return null;
|
|
71
56
|
}
|
|
@@ -131,11 +116,6 @@ export default function HTMLEditModal( {
|
|
|
131
116
|
isFullScreen={ isFullscreen }
|
|
132
117
|
__experimentalHideHeader
|
|
133
118
|
>
|
|
134
|
-
{ styleContent && (
|
|
135
|
-
<style
|
|
136
|
-
dangerouslySetInnerHTML={ { __html: styleContent } }
|
|
137
|
-
/>
|
|
138
|
-
) }
|
|
139
119
|
<Tabs orientation="horizontal" defaultTabId="html">
|
|
140
120
|
<VStack spacing={ 4 } style={ { height: '100%' } }>
|
|
141
121
|
<HStack justify="space-between">
|
package/src/image/index.js
CHANGED
|
@@ -62,4 +62,51 @@ export const settings = {
|
|
|
62
62
|
deprecated,
|
|
63
63
|
};
|
|
64
64
|
|
|
65
|
+
if ( window.__experimentalContentOnlyPatternInsertion ) {
|
|
66
|
+
settings.fields = [
|
|
67
|
+
{
|
|
68
|
+
label: __( 'Image' ),
|
|
69
|
+
type: 'Media',
|
|
70
|
+
shownByDefault: true,
|
|
71
|
+
mapping: {
|
|
72
|
+
id: 'id',
|
|
73
|
+
src: 'url',
|
|
74
|
+
caption: 'caption',
|
|
75
|
+
alt: 'alt',
|
|
76
|
+
},
|
|
77
|
+
args: {
|
|
78
|
+
allowedTypes: [ 'image' ],
|
|
79
|
+
multiple: false,
|
|
80
|
+
},
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
label: __( 'Link' ),
|
|
84
|
+
type: 'Link',
|
|
85
|
+
shownByDefault: false,
|
|
86
|
+
mapping: {
|
|
87
|
+
href: 'href',
|
|
88
|
+
rel: 'rel',
|
|
89
|
+
target: 'linkTarget',
|
|
90
|
+
destination: 'linkDestination',
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
label: __( 'Caption' ),
|
|
95
|
+
type: 'RichText',
|
|
96
|
+
shownByDefault: false,
|
|
97
|
+
mapping: {
|
|
98
|
+
value: 'caption',
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
label: __( 'Alt text' ),
|
|
103
|
+
type: 'PlainText',
|
|
104
|
+
shownByDefault: false,
|
|
105
|
+
mapping: {
|
|
106
|
+
value: 'alt',
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
];
|
|
110
|
+
}
|
|
111
|
+
|
|
65
112
|
export const init = () => initBlock( { name, metadata, settings } );
|
package/src/list-item/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
+
import { __ } from '@wordpress/i18n';
|
|
4
5
|
import { listItem as icon } from '@wordpress/icons';
|
|
5
6
|
import { privateApis } from '@wordpress/block-editor';
|
|
6
7
|
|
|
@@ -32,4 +33,17 @@ export const settings = {
|
|
|
32
33
|
[ unlock( privateApis ).requiresWrapperOnCopy ]: true,
|
|
33
34
|
};
|
|
34
35
|
|
|
36
|
+
if ( window.__experimentalContentOnlyPatternInsertion ) {
|
|
37
|
+
settings.fields = [
|
|
38
|
+
{
|
|
39
|
+
label: __( 'Content' ),
|
|
40
|
+
type: 'RichText',
|
|
41
|
+
shownByDefault: true,
|
|
42
|
+
mapping: {
|
|
43
|
+
value: 'content',
|
|
44
|
+
},
|
|
45
|
+
},
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
|
|
35
49
|
export const init = () => initBlock( { name, metadata, settings } );
|
package/src/media-text/index.js
CHANGED
|
@@ -50,4 +50,33 @@ export const settings = {
|
|
|
50
50
|
deprecated,
|
|
51
51
|
};
|
|
52
52
|
|
|
53
|
+
if ( window.__experimentalContentOnlyPatternInsertion ) {
|
|
54
|
+
settings.fields = [
|
|
55
|
+
{
|
|
56
|
+
label: __( 'Media' ),
|
|
57
|
+
type: 'Media',
|
|
58
|
+
shownByDefault: true,
|
|
59
|
+
mapping: {
|
|
60
|
+
id: 'mediaId',
|
|
61
|
+
type: 'mediaType',
|
|
62
|
+
src: 'mediaUrl',
|
|
63
|
+
},
|
|
64
|
+
args: {
|
|
65
|
+
allowedTypes: [ 'image', 'video' ],
|
|
66
|
+
multiple: false,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
label: __( 'Link' ),
|
|
71
|
+
type: 'Link',
|
|
72
|
+
shownByDefault: false,
|
|
73
|
+
mapping: {
|
|
74
|
+
href: 'href',
|
|
75
|
+
rel: 'rel',
|
|
76
|
+
target: 'linkTarget',
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
|
|
53
82
|
export const init = () => initBlock( { name, metadata, settings } );
|
package/src/more/index.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { more as icon } from '@wordpress/icons';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Internal dependencies
|
|
@@ -35,4 +36,17 @@ export const settings = {
|
|
|
35
36
|
save,
|
|
36
37
|
};
|
|
37
38
|
|
|
39
|
+
if ( window.__experimentalContentOnlyPatternInsertion ) {
|
|
40
|
+
settings.fields = [
|
|
41
|
+
{
|
|
42
|
+
label: __( 'Content' ),
|
|
43
|
+
type: 'RichText',
|
|
44
|
+
shownByDefault: true,
|
|
45
|
+
mapping: {
|
|
46
|
+
value: 'customText',
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
|
|
38
52
|
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -105,6 +105,7 @@
|
|
|
105
105
|
"supports": {
|
|
106
106
|
"align": [ "wide", "full" ],
|
|
107
107
|
"ariaLabel": true,
|
|
108
|
+
"contentRole": true,
|
|
108
109
|
"html": false,
|
|
109
110
|
"inserter": true,
|
|
110
111
|
"typography": {
|
|
@@ -138,8 +139,7 @@
|
|
|
138
139
|
}
|
|
139
140
|
},
|
|
140
141
|
"interactivity": true,
|
|
141
|
-
"renaming": false
|
|
142
|
-
"contentRole": true
|
|
142
|
+
"renaming": false
|
|
143
143
|
},
|
|
144
144
|
"editorStyle": "wp-block-navigation-editor",
|
|
145
145
|
"style": "wp-block-navigation"
|
|
@@ -8,9 +8,13 @@ import clsx from 'clsx';
|
|
|
8
8
|
*/
|
|
9
9
|
import { createBlock } from '@wordpress/blocks';
|
|
10
10
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
ToolbarButton,
|
|
13
|
+
ToolbarGroup,
|
|
14
|
+
VisuallyHidden,
|
|
15
|
+
} from '@wordpress/components';
|
|
12
16
|
import { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';
|
|
13
|
-
import { __ } from '@wordpress/i18n';
|
|
17
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
14
18
|
import {
|
|
15
19
|
BlockControls,
|
|
16
20
|
InspectorControls,
|
|
@@ -26,13 +30,19 @@ import { useState, useEffect, useRef, useCallback } from '@wordpress/element';
|
|
|
26
30
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
27
31
|
import { link as linkIcon, addSubmenu } from '@wordpress/icons';
|
|
28
32
|
import { store as coreStore } from '@wordpress/core-data';
|
|
29
|
-
import { useMergeRefs, usePrevious } from '@wordpress/compose';
|
|
33
|
+
import { useMergeRefs, usePrevious, useInstanceId } from '@wordpress/compose';
|
|
30
34
|
|
|
31
35
|
/**
|
|
32
36
|
* Internal dependencies
|
|
33
37
|
*/
|
|
34
38
|
import { getColors } from '../navigation/edit/utils';
|
|
35
|
-
import {
|
|
39
|
+
import {
|
|
40
|
+
Controls,
|
|
41
|
+
LinkUI,
|
|
42
|
+
updateAttributes,
|
|
43
|
+
useEntityBinding,
|
|
44
|
+
MissingEntityHelpText,
|
|
45
|
+
} from './shared';
|
|
36
46
|
|
|
37
47
|
const DEFAULT_BLOCK = { name: 'core/navigation-link' };
|
|
38
48
|
const NESTING_BLOCK_NAMES = [
|
|
@@ -394,6 +404,12 @@ export default function NavigationLinkEdit( {
|
|
|
394
404
|
}
|
|
395
405
|
}
|
|
396
406
|
|
|
407
|
+
const instanceId = useInstanceId( NavigationLinkEdit );
|
|
408
|
+
const hasMissingEntity = hasUrlBinding && ! isBoundEntityAvailable;
|
|
409
|
+
const missingEntityDescriptionId = hasMissingEntity
|
|
410
|
+
? sprintf( 'navigation-link-edit-%d-desc', instanceId )
|
|
411
|
+
: undefined;
|
|
412
|
+
|
|
397
413
|
const blockProps = useBlockProps( {
|
|
398
414
|
ref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),
|
|
399
415
|
className: clsx( 'wp-block-navigation-item', {
|
|
@@ -407,6 +423,8 @@ export default function NavigationLinkEdit( {
|
|
|
407
423
|
[ getColorClassName( 'background-color', backgroundColor ) ]:
|
|
408
424
|
!! backgroundColor,
|
|
409
425
|
} ),
|
|
426
|
+
'aria-describedby': missingEntityDescriptionId,
|
|
427
|
+
'aria-invalid': hasMissingEntity,
|
|
410
428
|
style: {
|
|
411
429
|
color: ! textColor && customTextColor,
|
|
412
430
|
backgroundColor: ! backgroundColor && customBackgroundColor,
|
|
@@ -482,6 +500,11 @@ export default function NavigationLinkEdit( {
|
|
|
482
500
|
/>
|
|
483
501
|
</InspectorControls>
|
|
484
502
|
<div { ...blockProps }>
|
|
503
|
+
{ hasMissingEntity && (
|
|
504
|
+
<VisuallyHidden id={ missingEntityDescriptionId }>
|
|
505
|
+
<MissingEntityHelpText type={ type } kind={ kind } />
|
|
506
|
+
</VisuallyHidden>
|
|
507
|
+
) }
|
|
485
508
|
{ /* eslint-disable jsx-a11y/anchor-is-valid */ }
|
|
486
509
|
<a className={ classes }>
|
|
487
510
|
{ /* eslint-enable */ }
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { _x } from '@wordpress/i18n';
|
|
4
|
+
import { _x, __ } from '@wordpress/i18n';
|
|
5
5
|
import { customLink as linkIcon } from '@wordpress/icons';
|
|
6
6
|
import { InnerBlocks } from '@wordpress/block-editor';
|
|
7
7
|
import { addFilter } from '@wordpress/hooks';
|
|
@@ -89,6 +89,29 @@ export const settings = {
|
|
|
89
89
|
transforms,
|
|
90
90
|
};
|
|
91
91
|
|
|
92
|
+
if ( window.__experimentalContentOnlyPatternInsertion ) {
|
|
93
|
+
settings.fields = [
|
|
94
|
+
{
|
|
95
|
+
label: __( 'Label' ),
|
|
96
|
+
type: 'RichText',
|
|
97
|
+
shownByDefault: true,
|
|
98
|
+
mapping: {
|
|
99
|
+
value: 'label',
|
|
100
|
+
},
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
label: __( 'Link' ),
|
|
104
|
+
type: 'Link',
|
|
105
|
+
shownByDefault: false,
|
|
106
|
+
mapping: {
|
|
107
|
+
href: 'url',
|
|
108
|
+
rel: 'rel',
|
|
109
|
+
// TODO - opens in new tab? id?
|
|
110
|
+
},
|
|
111
|
+
},
|
|
112
|
+
];
|
|
113
|
+
}
|
|
114
|
+
|
|
92
115
|
export const init = () => {
|
|
93
116
|
addFilter(
|
|
94
117
|
'blocks.registerBlockType',
|
|
@@ -221,7 +221,7 @@ export function Controls( { attributes, setAttributes, clientId } ) {
|
|
|
221
221
|
} }
|
|
222
222
|
help={
|
|
223
223
|
hasUrlBinding && ! isBoundEntityAvailable ? (
|
|
224
|
-
<
|
|
224
|
+
<MissingEntityHelp
|
|
225
225
|
id={ helpTextId }
|
|
226
226
|
type={ attributes.type }
|
|
227
227
|
kind={ attributes.kind }
|
|
@@ -327,7 +327,7 @@ export function Controls( { attributes, setAttributes, clientId } ) {
|
|
|
327
327
|
* @param {string} props.kind - The entity kind
|
|
328
328
|
* @return {string} Help text for the bound URL
|
|
329
329
|
*/
|
|
330
|
-
function BindingHelpText( { type, kind } ) {
|
|
330
|
+
export function BindingHelpText( { type, kind } ) {
|
|
331
331
|
const entityType = getEntityTypeName( type, kind );
|
|
332
332
|
return sprintf(
|
|
333
333
|
/* translators: %s is the entity type (e.g., "page", "post", "category") */
|
|
@@ -340,27 +340,23 @@ function BindingHelpText( { type, kind } ) {
|
|
|
340
340
|
* Component to display error help text for missing entity bindings.
|
|
341
341
|
*
|
|
342
342
|
* @param {Object} props - Component props
|
|
343
|
-
* @param {string} props.id - ID for the help text element (for aria-describedby)
|
|
344
343
|
* @param {string} props.type - The entity type
|
|
345
344
|
* @param {string} props.kind - The entity kind
|
|
346
345
|
* @return {JSX.Element} Error help text component
|
|
347
346
|
*/
|
|
348
|
-
function MissingEntityHelpText( {
|
|
347
|
+
export function MissingEntityHelpText( { type, kind } ) {
|
|
349
348
|
const entityType = getEntityTypeName( type, kind );
|
|
349
|
+
return sprintf(
|
|
350
|
+
/* translators: %s is the entity type (e.g., "page", "post", "category") */
|
|
351
|
+
__( 'Synced %s is missing. Please update or remove this link.' ),
|
|
352
|
+
entityType
|
|
353
|
+
);
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
function MissingEntityHelp( { id, type, kind } ) {
|
|
350
357
|
return (
|
|
351
|
-
<span
|
|
352
|
-
|
|
353
|
-
className="navigation-link-control__error-text"
|
|
354
|
-
role="alert"
|
|
355
|
-
aria-live="polite"
|
|
356
|
-
>
|
|
357
|
-
{ sprintf(
|
|
358
|
-
/* translators: %s is the entity type (e.g., "page", "post", "category") */
|
|
359
|
-
__(
|
|
360
|
-
'Synced %s is missing. Please update or remove this link.'
|
|
361
|
-
),
|
|
362
|
-
entityType
|
|
363
|
-
) }
|
|
358
|
+
<span id={ id } className="navigation-link-control__error-text">
|
|
359
|
+
<MissingEntityHelpText type={ type } kind={ kind } />
|
|
364
360
|
</span>
|
|
365
361
|
);
|
|
366
362
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* to reduce code duplication and ensure consistent behavior.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
export { Controls } from './controls';
|
|
8
|
+
export { Controls, BindingHelpText, MissingEntityHelpText } from './controls';
|
|
9
9
|
export { updateAttributes } from './update-attributes';
|
|
10
10
|
export {
|
|
11
11
|
useEntityBinding,
|
|
@@ -98,10 +98,13 @@ export function useEntityBinding( { clientId, attributes } ) {
|
|
|
98
98
|
|
|
99
99
|
// Use the correct entity type based on kind.
|
|
100
100
|
const entityType = isTaxonomy ? 'taxonomy' : 'postType';
|
|
101
|
-
|
|
101
|
+
// Convert 'tag' back to 'post_tag' for the API call
|
|
102
|
+
// (it was converted from 'post_tag' to 'tag' for storage in updateAttributes)
|
|
103
|
+
const typeForAPI = type === 'tag' ? 'post_tag' : type;
|
|
104
|
+
const entityRecord = getEntityRecord( entityType, typeForAPI, id );
|
|
102
105
|
const hasResolved = hasFinishedResolution( 'getEntityRecord', [
|
|
103
106
|
entityType,
|
|
104
|
-
|
|
107
|
+
typeForAPI,
|
|
105
108
|
id,
|
|
106
109
|
] );
|
|
107
110
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { page, addSubmenu } from '@wordpress/icons';
|
|
5
|
-
import { _x } from '@wordpress/i18n';
|
|
5
|
+
import { _x, __ } from '@wordpress/i18n';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Internal dependencies
|
|
@@ -48,4 +48,27 @@ export const settings = {
|
|
|
48
48
|
transforms,
|
|
49
49
|
};
|
|
50
50
|
|
|
51
|
+
if ( window.__experimentalContentOnlyPatternInsertion ) {
|
|
52
|
+
settings.fields = [
|
|
53
|
+
{
|
|
54
|
+
label: __( 'Label' ),
|
|
55
|
+
type: 'RichText',
|
|
56
|
+
shownByDefault: true,
|
|
57
|
+
mapping: {
|
|
58
|
+
value: 'label',
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
label: __( 'Link' ),
|
|
63
|
+
type: 'Link',
|
|
64
|
+
shownByDefault: false,
|
|
65
|
+
mapping: {
|
|
66
|
+
href: 'url',
|
|
67
|
+
rel: 'rel',
|
|
68
|
+
// TODO - opens in new tab? id?
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
|
|
51
74
|
export const init = () => initBlock( { name, metadata, settings } );
|
package/src/paragraph/index.js
CHANGED
|
@@ -58,4 +58,17 @@ export const settings = {
|
|
|
58
58
|
variations,
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
+
if ( window.__experimentalContentOnlyPatternInsertion ) {
|
|
62
|
+
settings.fields = [
|
|
63
|
+
{
|
|
64
|
+
label: __( 'Content' ),
|
|
65
|
+
type: 'RichText',
|
|
66
|
+
shownByDefault: true,
|
|
67
|
+
mapping: {
|
|
68
|
+
value: 'content',
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
];
|
|
72
|
+
}
|
|
73
|
+
|
|
61
74
|
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -44,12 +44,6 @@ exports[`Paragraph block transforms to Preformatted block 1`] = `
|
|
|
44
44
|
<!-- /wp:preformatted -->"
|
|
45
45
|
`;
|
|
46
46
|
|
|
47
|
-
exports[`Paragraph block transforms to Pullquote block 1`] = `
|
|
48
|
-
"<!-- wp:pullquote -->
|
|
49
|
-
<figure class="wp-block-pullquote"><blockquote><p>Example text</p></blockquote></figure>
|
|
50
|
-
<!-- /wp:pullquote -->"
|
|
51
|
-
`;
|
|
52
|
-
|
|
53
47
|
exports[`Paragraph block transforms to Quote block 1`] = `
|
|
54
48
|
"<!-- wp:quote -->
|
|
55
49
|
<blockquote class="wp-block-quote"><!-- wp:paragraph -->
|
|
@@ -9,13 +9,11 @@ import clsx from 'clsx';
|
|
|
9
9
|
import {
|
|
10
10
|
AlignmentControl,
|
|
11
11
|
BlockControls,
|
|
12
|
-
Warning,
|
|
13
12
|
useBlockProps,
|
|
14
13
|
} from '@wordpress/block-editor';
|
|
15
14
|
import { useState, useEffect } from '@wordpress/element';
|
|
16
15
|
import apiFetch from '@wordpress/api-fetch';
|
|
17
16
|
import { addQueryArgs } from '@wordpress/url';
|
|
18
|
-
import { __ } from '@wordpress/i18n';
|
|
19
17
|
|
|
20
18
|
export default function PostCommentsCountEdit( {
|
|
21
19
|
attributes,
|
|
@@ -68,13 +66,7 @@ export default function PostCommentsCountEdit( {
|
|
|
68
66
|
/>
|
|
69
67
|
</BlockControls>
|
|
70
68
|
<div { ...blockProps } style={ blockStyles }>
|
|
71
|
-
{ hasPostAndComments ?
|
|
72
|
-
commentsCount
|
|
73
|
-
) : (
|
|
74
|
-
<Warning>
|
|
75
|
-
{ __( 'Post Comments Count block: post not found.' ) }
|
|
76
|
-
</Warning>
|
|
77
|
-
) }
|
|
69
|
+
{ hasPostAndComments ? commentsCount : '0' }
|
|
78
70
|
</div>
|
|
79
71
|
</>
|
|
80
72
|
);
|