@wordpress/block-library 8.7.0 → 8.8.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/column/index.js +2 -1
- package/build/column/index.js.map +1 -1
- package/build/columns/edit.js +24 -6
- package/build/columns/edit.js.map +1 -1
- package/build/columns/index.js +2 -1
- package/build/columns/index.js.map +1 -1
- package/build/columns/utils.js +4 -9
- package/build/columns/utils.js.map +1 -1
- package/build/cover/edit/index.js +46 -50
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +32 -6
- package/build/cover/edit/resizable-cover-popover.js.map +1 -0
- package/build/cover/index.js +12 -0
- package/build/cover/index.js.map +1 -1
- package/build/details/edit.js +67 -0
- package/build/details/edit.js.map +1 -0
- package/build/details/index.js +110 -0
- package/build/details/index.js.map +1 -0
- package/build/details/save.js +33 -0
- package/build/details/save.js.map +1 -0
- package/build/details-content/edit.js +34 -0
- package/build/details-content/edit.js.map +1 -0
- package/build/details-content/index.js +94 -0
- package/build/details-content/index.js.map +1 -0
- package/build/details-content/save.js +20 -0
- package/build/details-content/save.js.map +1 -0
- package/build/details-summary/edit.js +42 -0
- package/build/details-summary/edit.js.map +1 -0
- package/build/details-summary/index.js +97 -0
- package/build/details-summary/index.js.map +1 -0
- package/build/details-summary/save.js +24 -0
- package/build/details-summary/save.js.map +1 -0
- package/build/embed/deprecated.js +4 -1
- package/build/embed/deprecated.js.map +1 -1
- package/build/embed/embed-link-settings.native.js +1 -1
- package/build/embed/embed-link-settings.native.js.map +1 -1
- package/build/embed/embed-placeholder.js +1 -1
- package/build/embed/embed-placeholder.js.map +1 -1
- package/build/embed/index.js +4 -1
- package/build/embed/index.js.map +1 -1
- package/build/embed/transforms.js +4 -1
- package/build/embed/transforms.js.map +1 -1
- package/build/embed/util.js +4 -1
- package/build/embed/util.js.map +1 -1
- package/build/file/edit.native.js +0 -2
- package/build/file/edit.native.js.map +1 -1
- package/build/gallery/use-get-media.native.js +2 -1
- package/build/gallery/use-get-media.native.js.map +1 -1
- package/build/image/index.js +4 -2
- package/build/image/index.js.map +1 -1
- package/build/index.js +24 -6
- package/build/index.js.map +1 -1
- package/build/media-text/media-container.js +2 -6
- package/build/media-text/media-container.js.map +1 -1
- package/build/media-text/media-container.native.js +3 -3
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/navigation/deprecated.js +8 -11
- package/build/navigation/deprecated.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +1 -14
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/post-author/index.js +0 -1
- package/build/post-author/index.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +2 -1
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-featured-image/edit.js +8 -22
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-time-to-read/edit.js +1 -1
- package/build/post-time-to-read/edit.js.map +1 -1
- package/build/post-time-to-read/index.js +7 -0
- package/build/post-time-to-read/index.js.map +1 -1
- package/build/spacer/controls.js +25 -6
- package/build/spacer/controls.js.map +1 -1
- package/build/spacer/edit.js +14 -4
- package/build/spacer/edit.js.map +1 -1
- package/build/spacer/save.js +2 -2
- package/build/spacer/save.js.map +1 -1
- package/build/table/state.js +35 -35
- package/build/table/state.js.map +1 -1
- package/build/term-description/index.js +1 -2
- package/build/term-description/index.js.map +1 -1
- package/build/utils/clean-empty-object.js +5 -2
- package/build/utils/clean-empty-object.js.map +1 -1
- package/build-module/column/index.js +2 -1
- package/build-module/column/index.js.map +1 -1
- package/build-module/columns/edit.js +24 -6
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/columns/index.js +2 -1
- package/build-module/columns/index.js.map +1 -1
- package/build-module/columns/utils.js +4 -8
- package/build-module/columns/utils.js.map +1 -1
- package/build-module/cover/edit/index.js +48 -52
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +31 -6
- package/build-module/cover/edit/resizable-cover-popover.js.map +1 -0
- package/build-module/cover/index.js +12 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/details/edit.js +52 -0
- package/build-module/details/edit.js.map +1 -0
- package/build-module/details/index.js +91 -0
- package/build-module/details/index.js.map +1 -0
- package/build-module/details/save.js +20 -0
- package/build-module/details/save.js.map +1 -0
- package/build-module/details-content/edit.js +23 -0
- package/build-module/details-content/edit.js.map +1 -0
- package/build-module/details-content/index.js +76 -0
- package/build-module/details-content/index.js.map +1 -0
- package/build-module/details-content/save.js +11 -0
- package/build-module/details-content/save.js.map +1 -0
- package/build-module/details-summary/edit.js +30 -0
- package/build-module/details-summary/edit.js.map +1 -0
- package/build-module/details-summary/index.js +79 -0
- package/build-module/details-summary/index.js.map +1 -0
- package/build-module/details-summary/save.js +16 -0
- package/build-module/details-summary/save.js.map +1 -0
- package/build-module/embed/deprecated.js +4 -1
- package/build-module/embed/deprecated.js.map +1 -1
- package/build-module/embed/embed-link-settings.native.js +1 -1
- package/build-module/embed/embed-link-settings.native.js.map +1 -1
- package/build-module/embed/embed-placeholder.js +1 -1
- package/build-module/embed/embed-placeholder.js.map +1 -1
- package/build-module/embed/index.js +4 -1
- package/build-module/embed/index.js.map +1 -1
- package/build-module/embed/transforms.js +4 -1
- package/build-module/embed/transforms.js.map +1 -1
- package/build-module/embed/util.js +4 -1
- package/build-module/embed/util.js.map +1 -1
- package/build-module/file/edit.native.js +0 -2
- package/build-module/file/edit.native.js.map +1 -1
- package/build-module/gallery/use-get-media.native.js +2 -1
- package/build-module/gallery/use-get-media.native.js.map +1 -1
- package/build-module/image/index.js +4 -2
- package/build-module/image/index.js.map +1 -1
- package/build-module/index.js +21 -6
- package/build-module/index.js.map +1 -1
- package/build-module/media-text/media-container.js +1 -5
- package/build-module/media-text/media-container.js.map +1 -1
- package/build-module/media-text/media-container.native.js +1 -1
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/navigation/deprecated.js +8 -10
- package/build-module/navigation/deprecated.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +1 -14
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/post-author/index.js +0 -1
- package/build-module/post-author/index.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +2 -1
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-featured-image/edit.js +8 -22
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-time-to-read/edit.js +1 -1
- package/build-module/post-time-to-read/edit.js.map +1 -1
- package/build-module/post-time-to-read/index.js +7 -0
- package/build-module/post-time-to-read/index.js.map +1 -1
- package/build-module/spacer/controls.js +27 -9
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/spacer/edit.js +14 -5
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/spacer/save.js +3 -3
- package/build-module/spacer/save.js.map +1 -1
- package/build-module/table/state.js +35 -33
- package/build-module/table/state.js.map +1 -1
- package/build-module/term-description/index.js +1 -2
- package/build-module/term-description/index.js.map +1 -1
- package/build-module/utils/clean-empty-object.js +6 -3
- package/build-module/utils/clean-empty-object.js.map +1 -1
- package/build-style/columns/style-rtl.css +4 -1
- package/build-style/columns/style.css +4 -1
- package/build-style/common-rtl.css +1 -1
- package/build-style/common.css +1 -1
- package/build-style/cover/editor-rtl.css +11 -12
- package/build-style/cover/editor.css +11 -12
- package/build-style/cover/style-rtl.css +3 -2
- package/build-style/cover/style.css +3 -2
- package/build-style/details/style-rtl.css +91 -0
- package/build-style/details/style.css +91 -0
- package/build-style/details-summary/editor-rtl.css +91 -0
- package/build-style/details-summary/editor.css +91 -0
- package/build-style/details-summary/style-rtl.css +91 -0
- package/build-style/details-summary/style.css +91 -0
- package/build-style/editor-rtl.css +34 -48
- package/build-style/editor.css +34 -48
- package/build-style/file/style-rtl.css +4 -3
- package/build-style/file/style.css +4 -3
- package/build-style/post-excerpt/style-rtl.css +1 -1
- package/build-style/post-excerpt/style.css +1 -1
- package/build-style/pullquote/style-rtl.css +4 -1
- package/build-style/pullquote/style.css +4 -1
- package/build-style/shortcode/editor-rtl.css +15 -34
- package/build-style/shortcode/editor.css +15 -34
- package/build-style/spacer/editor-rtl.css +4 -2
- package/build-style/spacer/editor.css +4 -2
- package/build-style/style-rtl.css +25 -9
- package/build-style/style.css +25 -9
- package/package.json +31 -31
- package/src/column/block.json +2 -1
- package/src/columns/block.json +2 -1
- package/src/columns/edit.js +33 -9
- package/src/columns/style.scss +5 -1
- package/src/columns/utils.js +8 -9
- package/src/common.scss +1 -1
- package/src/cover/block.json +12 -0
- package/src/cover/edit/index.js +44 -37
- package/src/cover/edit/resizable-cover-popover.js +82 -0
- package/src/cover/editor.scss +20 -13
- package/src/cover/index.php +9 -10
- package/src/cover/style.scss +2 -1
- package/src/cover/test/edit.js +1 -1
- package/src/details/block.json +54 -0
- package/src/details/edit.js +59 -0
- package/src/details/index.js +35 -0
- package/src/details/save.js +15 -0
- package/src/details/style.scss +3 -0
- package/src/details-content/block.json +50 -0
- package/src/details-content/edit.js +29 -0
- package/src/details-content/index.js +23 -0
- package/src/details-content/save.js +12 -0
- package/src/details-summary/block.json +53 -0
- package/src/details-summary/edit.js +27 -0
- package/src/details-summary/editor.scss +3 -0
- package/src/details-summary/index.js +23 -0
- package/src/details-summary/save.js +13 -0
- package/src/details-summary/style.scss +3 -0
- package/src/editor.scss +1 -0
- package/src/embed/block.json +4 -1
- package/src/embed/embed-link-settings.native.js +1 -1
- package/src/embed/embed-placeholder.js +1 -1
- package/src/file/edit.native.js +0 -2
- package/src/file/style.scss +5 -2
- package/src/gallery/test/use-get-media.native.js +24 -0
- package/src/gallery/use-get-media.native.js +1 -1
- package/src/image/block.json +4 -2
- package/src/index.js +13 -3
- package/src/media-text/media-container.js +1 -5
- package/src/media-text/media-container.native.js +1 -1
- package/src/navigation/deprecated.js +15 -19
- package/src/navigation/edit/unsaved-inner-blocks.js +34 -46
- package/src/navigation/index.php +0 -4
- package/src/paragraph/test/edit.native.js +356 -1
- package/src/post-author/block.json +0 -1
- package/src/post-excerpt/index.php +3 -3
- package/src/post-excerpt/style.scss +2 -1
- package/src/post-featured-image/dimension-controls.js +5 -1
- package/src/post-featured-image/edit.js +8 -29
- package/src/post-time-to-read/block.json +7 -0
- package/src/post-time-to-read/edit.js +1 -1
- package/src/post-time-to-read/index.php +3 -3
- package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -2
- package/src/preformatted/test/edit.native.js +45 -2
- package/src/pullquote/style.scss +5 -1
- package/src/pullquote/test/edit.native.js +70 -0
- package/src/quote/test/edit.native.js +92 -0
- package/src/search/index.php +1 -1
- package/src/shortcode/editor.scss +26 -5
- package/src/spacer/controls.js +42 -17
- package/src/spacer/edit.js +23 -4
- package/src/spacer/editor.scss +2 -1
- package/src/spacer/save.js +3 -3
- package/src/style.scss +2 -0
- package/src/table/state.js +83 -66
- package/src/term-description/block.json +1 -2
- package/src/utils/clean-empty-object.js +4 -4
- package/src/verse/test/edit.native.js +33 -0
- package/build/cover/edit/resizable-cover.js.map +0 -1
- package/build/media-text/media-container-icon.js +0 -27
- package/build/media-text/media-container-icon.js.map +0 -1
- package/build-module/cover/edit/resizable-cover.js.map +0 -1
- package/build-module/media-text/media-container-icon.js +0 -17
- package/build-module/media-text/media-container-icon.js.map +0 -1
- package/src/cover/edit/resizable-cover.js +0 -61
- package/src/media-text/media-container-icon.js +0 -12
package/src/cover/style.scss
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
justify-content: center;
|
|
8
8
|
align-items: center;
|
|
9
9
|
padding: 1em;
|
|
10
|
+
overflow: hidden;
|
|
10
11
|
// This block has customizable padding, border-box makes that more predictable.
|
|
11
12
|
box-sizing: border-box;
|
|
12
13
|
// Keep the flex layout direction to the physical direction (LTR) in RTL languages.
|
|
@@ -203,7 +204,7 @@ video.wp-block-cover__video-background {
|
|
|
203
204
|
// Mobile Safari does not support fixed background attachment properly.
|
|
204
205
|
// See also https://stackoverflow.com/questions/24154666/background-size-cover-not-working-on-ios
|
|
205
206
|
// Chrome on Android does not appear to support the attachment at all: https://issuetracker.google.com/issues/36908439
|
|
206
|
-
@supports (-webkit-
|
|
207
|
+
@supports (-webkit-touch-callout: inherit) {
|
|
207
208
|
background-attachment: scroll;
|
|
208
209
|
}
|
|
209
210
|
|
package/src/cover/test/edit.js
CHANGED
|
@@ -208,7 +208,7 @@ describe( 'Cover block', () => {
|
|
|
208
208
|
|
|
209
209
|
await selectBlock( 'Block: Cover' );
|
|
210
210
|
await userEvent.type(
|
|
211
|
-
screen.getByLabelText( '
|
|
211
|
+
screen.getByLabelText( 'Alternative text' ),
|
|
212
212
|
'Me'
|
|
213
213
|
);
|
|
214
214
|
expect( screen.getByAltText( 'Me' ) ).toBeInTheDocument();
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 2,
|
|
4
|
+
"__experimental": true,
|
|
5
|
+
"name": "core/details",
|
|
6
|
+
"title": "Details",
|
|
7
|
+
"category": "text",
|
|
8
|
+
"description": "A block that displays a summary and shows or hides additional content.",
|
|
9
|
+
"keywords": [ "disclosure", "summary", "hide", "transcript" ],
|
|
10
|
+
"textdomain": "default",
|
|
11
|
+
"attributes": {
|
|
12
|
+
"showContent": {
|
|
13
|
+
"type": "boolean",
|
|
14
|
+
"default": false
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"supports": {
|
|
18
|
+
"align": true,
|
|
19
|
+
"color": {
|
|
20
|
+
"gradients": true,
|
|
21
|
+
"link": true,
|
|
22
|
+
"__experimentalDefaultControls": {
|
|
23
|
+
"background": true,
|
|
24
|
+
"text": true,
|
|
25
|
+
"link": true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"__experimentalBorder": {
|
|
29
|
+
"radius": true,
|
|
30
|
+
"color": true,
|
|
31
|
+
"width": true,
|
|
32
|
+
"style": true
|
|
33
|
+
},
|
|
34
|
+
"html": false,
|
|
35
|
+
"spacing": {
|
|
36
|
+
"margin": true,
|
|
37
|
+
"padding": true
|
|
38
|
+
},
|
|
39
|
+
"typography": {
|
|
40
|
+
"fontSize": true,
|
|
41
|
+
"lineHeight": true,
|
|
42
|
+
"__experimentalFontFamily": true,
|
|
43
|
+
"__experimentalFontWeight": true,
|
|
44
|
+
"__experimentalFontStyle": true,
|
|
45
|
+
"__experimentalTextTransform": true,
|
|
46
|
+
"__experimentalTextDecoration": true,
|
|
47
|
+
"__experimentalLetterSpacing": true,
|
|
48
|
+
"__experimentalDefaultControls": {
|
|
49
|
+
"fontSize": true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"style": "wp-block-details"
|
|
54
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
useBlockProps,
|
|
6
|
+
useInnerBlocksProps,
|
|
7
|
+
store as blockEditorStore,
|
|
8
|
+
InspectorControls,
|
|
9
|
+
} from '@wordpress/block-editor';
|
|
10
|
+
import { useSelect } from '@wordpress/data';
|
|
11
|
+
import { PanelBody, ToggleControl } from '@wordpress/components';
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
13
|
+
|
|
14
|
+
const TEMPLATE = [ [ 'core/details-summary' ], [ 'core/details-content' ] ];
|
|
15
|
+
|
|
16
|
+
function DetailsEdit( { attributes, setAttributes, clientId } ) {
|
|
17
|
+
const { showContent } = attributes;
|
|
18
|
+
const blockProps = useBlockProps();
|
|
19
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
20
|
+
allowedBlocks: TEMPLATE,
|
|
21
|
+
template: TEMPLATE,
|
|
22
|
+
templateLock: 'all',
|
|
23
|
+
} );
|
|
24
|
+
|
|
25
|
+
// Check if either the block or the inner blocks are selected.
|
|
26
|
+
const hasSelection = useSelect( ( select ) => {
|
|
27
|
+
const { isBlockSelected, hasSelectedInnerBlock } =
|
|
28
|
+
select( blockEditorStore );
|
|
29
|
+
/* Sets deep to true to also find blocks inside the details content block. */
|
|
30
|
+
return (
|
|
31
|
+
hasSelectedInnerBlock( clientId, true ) ||
|
|
32
|
+
isBlockSelected( clientId )
|
|
33
|
+
);
|
|
34
|
+
}, [] );
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<InspectorControls>
|
|
39
|
+
<PanelBody title={ __( 'Settings' ) }>
|
|
40
|
+
<ToggleControl
|
|
41
|
+
label={ __( 'Open by default' ) }
|
|
42
|
+
checked={ showContent }
|
|
43
|
+
onChange={ () =>
|
|
44
|
+
setAttributes( {
|
|
45
|
+
showContent: ! showContent,
|
|
46
|
+
} )
|
|
47
|
+
}
|
|
48
|
+
/>
|
|
49
|
+
</PanelBody>
|
|
50
|
+
</InspectorControls>
|
|
51
|
+
<details
|
|
52
|
+
{ ...innerBlocksProps }
|
|
53
|
+
open={ hasSelection || showContent }
|
|
54
|
+
></details>
|
|
55
|
+
</>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default DetailsEdit;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { details as icon } from '@wordpress/icons';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import initBlock from '../utils/init-block';
|
|
11
|
+
import metadata from './block.json';
|
|
12
|
+
import edit from './edit';
|
|
13
|
+
import save from './save';
|
|
14
|
+
|
|
15
|
+
const { name } = metadata;
|
|
16
|
+
export { metadata, name };
|
|
17
|
+
|
|
18
|
+
export const settings = {
|
|
19
|
+
icon,
|
|
20
|
+
example: {
|
|
21
|
+
innerBlocks: [
|
|
22
|
+
{
|
|
23
|
+
name: 'core/details-summary',
|
|
24
|
+
attributes: { summary: __( 'Details' ) },
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
name: 'core/details-content',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
},
|
|
31
|
+
save,
|
|
32
|
+
edit,
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
|
|
5
|
+
|
|
6
|
+
export default function save( { attributes } ) {
|
|
7
|
+
const { showContent } = attributes;
|
|
8
|
+
const blockProps = useBlockProps.save();
|
|
9
|
+
|
|
10
|
+
return (
|
|
11
|
+
<details { ...blockProps } open={ showContent }>
|
|
12
|
+
<InnerBlocks.Content />
|
|
13
|
+
</details>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 2,
|
|
4
|
+
"__experimental": true,
|
|
5
|
+
"name": "core/details-content",
|
|
6
|
+
"title": "Details Content",
|
|
7
|
+
"category": "text",
|
|
8
|
+
"parent": [ "core/details" ],
|
|
9
|
+
"description": "Add content that may be shown or hidden via a Details block.",
|
|
10
|
+
"textdomain": "default",
|
|
11
|
+
"supports": {
|
|
12
|
+
"align": false,
|
|
13
|
+
"color": {
|
|
14
|
+
"gradients": true,
|
|
15
|
+
"link": true,
|
|
16
|
+
"__experimentalDefaultControls": {
|
|
17
|
+
"background": true,
|
|
18
|
+
"text": true,
|
|
19
|
+
"link": true
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"__experimentalBorder": {
|
|
23
|
+
"radius": true,
|
|
24
|
+
"color": true,
|
|
25
|
+
"width": true,
|
|
26
|
+
"style": true
|
|
27
|
+
},
|
|
28
|
+
"html": false,
|
|
29
|
+
"lock": false,
|
|
30
|
+
"multiple": false,
|
|
31
|
+
"reusable": false,
|
|
32
|
+
"spacing": {
|
|
33
|
+
"margin": true,
|
|
34
|
+
"padding": true
|
|
35
|
+
},
|
|
36
|
+
"typography": {
|
|
37
|
+
"fontSize": true,
|
|
38
|
+
"lineHeight": true,
|
|
39
|
+
"__experimentalFontFamily": true,
|
|
40
|
+
"__experimentalFontWeight": true,
|
|
41
|
+
"__experimentalFontStyle": true,
|
|
42
|
+
"__experimentalTextTransform": true,
|
|
43
|
+
"__experimentalTextDecoration": true,
|
|
44
|
+
"__experimentalLetterSpacing": true,
|
|
45
|
+
"__experimentalDefaultControls": {
|
|
46
|
+
"fontSize": true
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
import { View } from '@wordpress/primitives';
|
|
7
|
+
|
|
8
|
+
const TEMPLATE = [
|
|
9
|
+
[
|
|
10
|
+
'core/paragraph',
|
|
11
|
+
{
|
|
12
|
+
placeholder: __(
|
|
13
|
+
'Add text or blocks that will display when the details block is opened.'
|
|
14
|
+
),
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
];
|
|
18
|
+
|
|
19
|
+
function DetailsContentEdit() {
|
|
20
|
+
const blockProps = useBlockProps();
|
|
21
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
22
|
+
template: TEMPLATE,
|
|
23
|
+
templateLock: false,
|
|
24
|
+
} );
|
|
25
|
+
|
|
26
|
+
return <View { ...innerBlocksProps }></View>;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default DetailsContentEdit;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { postContent as icon } from '@wordpress/icons';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import initBlock from '../utils/init-block';
|
|
10
|
+
import metadata from './block.json';
|
|
11
|
+
import edit from './edit';
|
|
12
|
+
import save from './save';
|
|
13
|
+
|
|
14
|
+
const { name } = metadata;
|
|
15
|
+
export { metadata, name };
|
|
16
|
+
|
|
17
|
+
export const settings = {
|
|
18
|
+
icon,
|
|
19
|
+
save,
|
|
20
|
+
edit,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useBlockProps, InnerBlocks } from '@wordpress/block-editor';
|
|
5
|
+
export default function save() {
|
|
6
|
+
const blockProps = useBlockProps.save();
|
|
7
|
+
return (
|
|
8
|
+
<div { ...blockProps }>
|
|
9
|
+
<InnerBlocks.Content />
|
|
10
|
+
</div>
|
|
11
|
+
);
|
|
12
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 2,
|
|
4
|
+
"__experimental": true,
|
|
5
|
+
"name": "core/details-summary",
|
|
6
|
+
"title": "Details Summary",
|
|
7
|
+
"category": "text",
|
|
8
|
+
"parent": [ "core/details" ],
|
|
9
|
+
"description": "Provide summary text used to toggle the display of content inside a Details block.",
|
|
10
|
+
"textdomain": "default",
|
|
11
|
+
"attributes": {
|
|
12
|
+
"summary": {
|
|
13
|
+
"type": "string"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"supports": {
|
|
17
|
+
"align": false,
|
|
18
|
+
"color": {
|
|
19
|
+
"gradients": true,
|
|
20
|
+
"__experimentalDefaultControls": {
|
|
21
|
+
"background": true,
|
|
22
|
+
"text": true
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"__experimentalBorder": {
|
|
26
|
+
"radius": true,
|
|
27
|
+
"color": true,
|
|
28
|
+
"width": true,
|
|
29
|
+
"style": true
|
|
30
|
+
},
|
|
31
|
+
"html": false,
|
|
32
|
+
"lock": false,
|
|
33
|
+
"multiple": false,
|
|
34
|
+
"reusable": false,
|
|
35
|
+
"spacing": {
|
|
36
|
+
"margin": true,
|
|
37
|
+
"padding": true
|
|
38
|
+
},
|
|
39
|
+
"typography": {
|
|
40
|
+
"fontSize": true,
|
|
41
|
+
"lineHeight": true,
|
|
42
|
+
"__experimentalFontFamily": true,
|
|
43
|
+
"__experimentalFontWeight": true,
|
|
44
|
+
"__experimentalFontStyle": true,
|
|
45
|
+
"__experimentalTextTransform": true,
|
|
46
|
+
"__experimentalTextDecoration": true,
|
|
47
|
+
"__experimentalLetterSpacing": true,
|
|
48
|
+
"__experimentalDefaultControls": {
|
|
49
|
+
"fontSize": true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { RichText, useBlockProps } from '@wordpress/block-editor';
|
|
5
|
+
import { __ } from '@wordpress/i18n';
|
|
6
|
+
|
|
7
|
+
function DetailsSummaryEdit( { attributes, setAttributes } ) {
|
|
8
|
+
const summary = attributes.summary ? attributes.summary : __( 'Details' );
|
|
9
|
+
return (
|
|
10
|
+
<summary
|
|
11
|
+
{ ...useBlockProps() }
|
|
12
|
+
onClick={ ( event ) => event.preventDefault() }
|
|
13
|
+
>
|
|
14
|
+
<RichText
|
|
15
|
+
aria-label={ __( 'Add summary' ) }
|
|
16
|
+
allowedFormats={ [] }
|
|
17
|
+
withoutInteractiveFormatting
|
|
18
|
+
value={ summary }
|
|
19
|
+
onChange={ ( newSummary ) =>
|
|
20
|
+
setAttributes( { summary: newSummary } )
|
|
21
|
+
}
|
|
22
|
+
/>
|
|
23
|
+
</summary>
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export default DetailsSummaryEdit;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { heading as icon } from '@wordpress/icons';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import initBlock from '../utils/init-block';
|
|
10
|
+
import metadata from './block.json';
|
|
11
|
+
import edit from './edit';
|
|
12
|
+
import save from './save';
|
|
13
|
+
|
|
14
|
+
const { name } = metadata;
|
|
15
|
+
export { metadata, name };
|
|
16
|
+
|
|
17
|
+
export const settings = {
|
|
18
|
+
icon,
|
|
19
|
+
save,
|
|
20
|
+
edit,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { RichText, useBlockProps } from '@wordpress/block-editor';
|
|
5
|
+
|
|
6
|
+
export default function save( { attributes } ) {
|
|
7
|
+
const summary = attributes.summary ? attributes.summary : 'Details';
|
|
8
|
+
return (
|
|
9
|
+
<summary { ...useBlockProps.save() }>
|
|
10
|
+
<RichText.Content value={ summary } />
|
|
11
|
+
</summary>
|
|
12
|
+
);
|
|
13
|
+
}
|
package/src/editor.scss
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
@import "./comments-pagination-numbers/editor.scss";
|
|
14
14
|
@import "./comments-title/editor.scss";
|
|
15
15
|
@import "./cover/editor.scss";
|
|
16
|
+
@import "./details-summary/editor.scss";
|
|
16
17
|
@import "./embed/editor.scss";
|
|
17
18
|
@import "./file/editor.scss";
|
|
18
19
|
@import "./freeform/editor.scss";
|
package/src/embed/block.json
CHANGED
|
@@ -40,7 +40,7 @@ const EmbedPlaceholder = ( {
|
|
|
40
40
|
<div className="components-placeholder__learn-more">
|
|
41
41
|
<ExternalLink
|
|
42
42
|
href={ __(
|
|
43
|
-
'https://wordpress.org/
|
|
43
|
+
'https://wordpress.org/documentation/article/embeds/'
|
|
44
44
|
) }
|
|
45
45
|
>
|
|
46
46
|
{ __( 'Learn more about embeds' ) }
|
package/src/file/edit.native.js
CHANGED
|
@@ -466,7 +466,6 @@ export class FileEdit extends Component {
|
|
|
466
466
|
__unstableMobileNoFocusOnMount
|
|
467
467
|
onChange={ this.onChangeFileName }
|
|
468
468
|
placeholder={ __( 'File name' ) }
|
|
469
|
-
rootTagsToEliminate={ [ 'p' ] }
|
|
470
469
|
tagName="p"
|
|
471
470
|
underlineColorAndroid="transparent"
|
|
472
471
|
value={ fileName }
|
|
@@ -502,7 +501,6 @@ export class FileEdit extends Component {
|
|
|
502
501
|
<RichText
|
|
503
502
|
withoutInteractiveFormatting
|
|
504
503
|
__unstableMobileNoFocusOnMount
|
|
505
|
-
rootTagsToEliminate={ [ 'p' ] }
|
|
506
504
|
tagName="p"
|
|
507
505
|
textAlign="center"
|
|
508
506
|
minWidth={ minWidth }
|
package/src/file/style.scss
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
.wp-block-file {
|
|
2
|
-
margin-bottom: 1.5em;
|
|
3
|
-
|
|
4
2
|
&:not(.wp-element-button) {
|
|
5
3
|
font-size: 0.8em;
|
|
6
4
|
}
|
|
@@ -19,6 +17,11 @@
|
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
19
|
|
|
20
|
+
// Lowest specificity to avoid overriding layout styles.
|
|
21
|
+
:where(.wp-block-file) {
|
|
22
|
+
margin-bottom: 1.5em;
|
|
23
|
+
}
|
|
24
|
+
|
|
22
25
|
.wp-block-file__embed {
|
|
23
26
|
margin-bottom: 1em;
|
|
24
27
|
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render } from 'test/helpers';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import useGetMedia from '../use-get-media';
|
|
10
|
+
|
|
11
|
+
describe( 'useGetMedia', () => {
|
|
12
|
+
// TODO: Explore why a Gallery block would ever be without inner blocks.
|
|
13
|
+
// This test and the associated default function parameter might be unnecessary.
|
|
14
|
+
it( 'should not error when receiving zero images', () => {
|
|
15
|
+
// Arrange
|
|
16
|
+
const TestSubject = () => {
|
|
17
|
+
useGetMedia( undefined );
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
// Assert
|
|
22
|
+
expect( () => render( <TestSubject /> ) ).not.toThrow();
|
|
23
|
+
} );
|
|
24
|
+
} );
|
|
@@ -14,7 +14,7 @@ const EMPTY_IMAGE_MEDIA = [];
|
|
|
14
14
|
*
|
|
15
15
|
* @return {Array} An array of media info options for each gallery image.
|
|
16
16
|
*/
|
|
17
|
-
export default function useGetMedia( innerBlockImages ) {
|
|
17
|
+
export default function useGetMedia( innerBlockImages = [] ) {
|
|
18
18
|
return useSelect(
|
|
19
19
|
( select ) => {
|
|
20
20
|
const imagesUploading = innerBlockImages.some(
|
package/src/image/block.json
CHANGED
|
@@ -85,10 +85,12 @@
|
|
|
85
85
|
"supports": {
|
|
86
86
|
"anchor": true,
|
|
87
87
|
"color": {
|
|
88
|
-
"__experimentalDuotone": true,
|
|
89
88
|
"text": false,
|
|
90
89
|
"background": false
|
|
91
90
|
},
|
|
91
|
+
"filter": {
|
|
92
|
+
"duotone": true
|
|
93
|
+
},
|
|
92
94
|
"__experimentalBorder": {
|
|
93
95
|
"color": true,
|
|
94
96
|
"radius": true,
|
|
@@ -104,7 +106,7 @@
|
|
|
104
106
|
"selectors": {
|
|
105
107
|
"border": ".wp-block-image img, .wp-block-image .wp-block-image__crop-area",
|
|
106
108
|
"filter": {
|
|
107
|
-
"duotone": "img, .components-placeholder"
|
|
109
|
+
"duotone": ".wp-block-image img, .wp-block-image .components-placeholder"
|
|
108
110
|
}
|
|
109
111
|
},
|
|
110
112
|
"styles": [
|
package/src/index.js
CHANGED
|
@@ -45,6 +45,9 @@ import * as commentsPaginationNext from './comments-pagination-next';
|
|
|
45
45
|
import * as commentsPaginationNumbers from './comments-pagination-numbers';
|
|
46
46
|
import * as commentsTitle from './comments-title';
|
|
47
47
|
import * as cover from './cover';
|
|
48
|
+
import * as details from './details';
|
|
49
|
+
import * as detailsContent from './details-content';
|
|
50
|
+
import * as detailsSummary from './details-summary';
|
|
48
51
|
import * as embed from './embed';
|
|
49
52
|
import * as file from './file';
|
|
50
53
|
import * as gallery from './gallery';
|
|
@@ -121,8 +124,8 @@ import isBlockMetadataExperimental from './utils/is-block-metadata-experimental'
|
|
|
121
124
|
/**
|
|
122
125
|
* Function to get all the block-library blocks in an array
|
|
123
126
|
*/
|
|
124
|
-
const getAllBlocks = () =>
|
|
125
|
-
[
|
|
127
|
+
const getAllBlocks = () => {
|
|
128
|
+
const blocks = [
|
|
126
129
|
// Common blocks are grouped at the top to prioritize their display
|
|
127
130
|
// in various contexts — like the inserter and auto-complete components.
|
|
128
131
|
paragraph,
|
|
@@ -224,7 +227,14 @@ const getAllBlocks = () =>
|
|
|
224
227
|
termDescription,
|
|
225
228
|
queryTitle,
|
|
226
229
|
postAuthorBiography,
|
|
227
|
-
]
|
|
230
|
+
];
|
|
231
|
+
if ( window?.__experimentalEnableDetailsBlocks ) {
|
|
232
|
+
blocks.push( details );
|
|
233
|
+
blocks.push( detailsContent );
|
|
234
|
+
blocks.push( detailsSummary );
|
|
235
|
+
}
|
|
236
|
+
return blocks.filter( Boolean );
|
|
237
|
+
};
|
|
228
238
|
|
|
229
239
|
/**
|
|
230
240
|
* Function to get all the core blocks in an array.
|
|
@@ -20,11 +20,7 @@ import { useDispatch } from '@wordpress/data';
|
|
|
20
20
|
import { forwardRef } from '@wordpress/element';
|
|
21
21
|
import { isBlobURL } from '@wordpress/blob';
|
|
22
22
|
import { store as noticesStore } from '@wordpress/notices';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Internal dependencies
|
|
26
|
-
*/
|
|
27
|
-
import icon from './media-container-icon';
|
|
23
|
+
import { media as icon } from '@wordpress/icons';
|
|
28
24
|
|
|
29
25
|
/**
|
|
30
26
|
* Constants
|
|
@@ -26,12 +26,12 @@ import { Component } from '@wordpress/element';
|
|
|
26
26
|
import { __ } from '@wordpress/i18n';
|
|
27
27
|
import { isURL, getProtocol } from '@wordpress/url';
|
|
28
28
|
import { compose, withPreferredColorScheme } from '@wordpress/compose';
|
|
29
|
+
import { media as icon } from '@wordpress/icons';
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
32
|
* Internal dependencies
|
|
32
33
|
*/
|
|
33
34
|
import styles from './style.scss';
|
|
34
|
-
import icon from './media-container-icon';
|
|
35
35
|
import SvgIconRetry from './icon-retry';
|
|
36
36
|
|
|
37
37
|
/**
|