@wordpress/block-library 8.8.0 → 8.9.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/cover/transforms.js +10 -7
- package/build/cover/transforms.js.map +1 -1
- package/build/group/edit.js +3 -1
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +3 -0
- package/build/group/index.js.map +1 -1
- package/build/image/edit.js +16 -13
- package/build/image/edit.js.map +1 -1
- package/build/image/index.js +1 -1
- package/build/index.native.js +9 -5
- package/build/index.native.js.map +1 -1
- package/build/media-text/edit.js +4 -2
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/index.js +3 -0
- package/build/media-text/index.js.map +1 -1
- package/build/navigation/edit/index.js +32 -64
- package/build/navigation/edit/index.js.map +1 -1
- package/build/post-date/edit.js +4 -2
- package/build/post-date/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +2 -2
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +8 -5
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/query/deprecated.js +8 -6
- package/build/query/deprecated.js.map +1 -1
- package/build/query/edit/inspector-controls/create-new-post-link.js +41 -0
- package/build/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
- package/build/query/edit/inspector-controls/index.js +14 -6
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/pattern-selection-modal.js +2 -1
- package/build/query/edit/pattern-selection-modal.js.map +1 -1
- package/build/query/index.js +5 -12
- package/build/query/index.js.map +1 -1
- package/build/site-logo/edit.js +114 -16
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-logo/index.js +1 -1
- package/build/social-link/icons/chain.js +1 -1
- package/build/social-link/icons/chain.js.map +1 -1
- package/build/social-link/icons/mail.js +1 -1
- package/build/social-link/icons/mail.js.map +1 -1
- package/build/spacer/edit.js +117 -11
- package/build/spacer/edit.js.map +1 -1
- package/build/template-part/edit/index.js +2 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/utils/hooks.js +2 -2
- package/build/template-part/edit/utils/hooks.js.map +1 -1
- package/build/utils/migrate-font-family.js +12 -5
- package/build/utils/migrate-font-family.js.map +1 -1
- package/build/video/edit.native.js +4 -3
- package/build/video/edit.native.js.map +1 -1
- package/build-module/cover/transforms.js +5 -1
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/group/edit.js +3 -1
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +3 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/image/edit.js +16 -13
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/index.js +1 -1
- package/build-module/index.native.js +9 -5
- package/build-module/index.native.js.map +1 -1
- package/build-module/media-text/edit.js +4 -2
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/index.js +3 -0
- package/build-module/media-text/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +31 -63
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/post-date/edit.js +4 -2
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +2 -2
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +8 -5
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/query/deprecated.js +5 -2
- package/build-module/query/deprecated.js.map +1 -1
- package/build-module/query/edit/inspector-controls/create-new-post-link.js +33 -0
- package/build-module/query/edit/inspector-controls/create-new-post-link.js.map +1 -0
- package/build-module/query/edit/inspector-controls/index.js +12 -7
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/pattern-selection-modal.js +2 -1
- package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
- package/build-module/query/index.js +5 -10
- package/build-module/query/index.js.map +1 -1
- package/build-module/site-logo/edit.js +115 -18
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-logo/index.js +1 -1
- package/build-module/social-link/icons/chain.js +1 -1
- package/build-module/social-link/icons/chain.js.map +1 -1
- package/build-module/social-link/icons/mail.js +1 -1
- package/build-module/social-link/icons/mail.js.map +1 -1
- package/build-module/spacer/edit.js +118 -12
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/template-part/edit/index.js +2 -1
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/utils/hooks.js +2 -2
- package/build-module/template-part/edit/utils/hooks.js.map +1 -1
- package/build-module/utils/migrate-font-family.js +9 -1
- package/build-module/utils/migrate-font-family.js.map +1 -1
- package/build-module/video/edit.native.js +4 -3
- package/build-module/video/edit.native.js.map +1 -1
- package/build-style/cover/editor-rtl.css +3 -3
- package/build-style/cover/editor.css +3 -3
- package/build-style/cover/style-rtl.css +1 -2
- package/build-style/cover/style.css +1 -2
- package/build-style/editor-rtl.css +71 -34
- package/build-style/editor.css +71 -34
- package/build-style/html/editor-rtl.css +2 -2
- package/build-style/html/editor.css +2 -2
- package/build-style/image/editor-rtl.css +1 -1
- package/build-style/image/editor.css +1 -1
- package/build-style/query/editor-rtl.css +8 -12
- package/build-style/query/editor.css +8 -12
- package/build-style/search/style-rtl.css +2 -0
- package/build-style/search/style.css +2 -0
- package/build-style/shortcode/editor-rtl.css +3 -4
- package/build-style/shortcode/editor.css +3 -4
- package/build-style/site-logo/editor-rtl.css +46 -0
- package/build-style/site-logo/editor.css +46 -0
- package/build-style/style-rtl.css +3 -2
- package/build-style/style.css +3 -2
- package/build-style/template-part/editor-rtl.css +8 -12
- package/build-style/template-part/editor.css +8 -12
- package/package.json +31 -31
- package/src/buttons/test/__snapshots__/edit.native.js.snap +18 -0
- package/src/buttons/test/edit.native.js +123 -2
- package/src/cover/editor.scss +1 -1
- package/src/cover/style.scss +0 -1
- package/src/cover/transforms.js +4 -1
- package/src/gallery/test/index.native.js +4 -4
- package/src/group/block.json +3 -0
- package/src/group/edit.js +8 -2
- package/src/heading/test/__snapshots__/index.native.js.snap +12 -0
- package/src/heading/test/index.native.js +71 -0
- package/src/html/editor.scss +2 -21
- package/src/image/block.json +1 -1
- package/src/image/edit.js +21 -17
- package/src/image/editor.scss +1 -1
- package/src/index.native.js +9 -5
- package/src/list/test/edit.native.js +7 -7
- package/src/media-text/block.json +3 -0
- package/src/media-text/edit.js +2 -1
- package/src/navigation/edit/index.js +32 -106
- package/src/navigation/index.php +15 -8
- package/src/paragraph/test/edit.native.js +288 -28
- package/src/post-date/edit.js +4 -0
- package/src/post-date/index.php +17 -8
- package/src/post-excerpt/edit.js +1 -1
- package/src/post-featured-image/edit.js +6 -5
- package/src/post-featured-image/index.php +1 -1
- package/src/preformatted/test/edit.native.js +6 -9
- package/src/pullquote/test/edit.native.js +7 -12
- package/src/query/deprecated.js +4 -1
- package/src/query/edit/inspector-controls/create-new-post-link.js +26 -0
- package/src/query/edit/inspector-controls/index.js +13 -6
- package/src/query/edit/pattern-selection-modal.js +1 -0
- package/src/query/editor.scss +8 -11
- package/src/query/index.js +1 -7
- package/src/quote/test/edit.native.js +6 -10
- package/src/search/style.scss +3 -0
- package/src/shortcode/editor.scss +1 -21
- package/src/site-logo/block.json +1 -1
- package/src/site-logo/edit.js +123 -9
- package/src/site-logo/editor.scss +57 -0
- package/src/social-link/icons/chain.js +1 -1
- package/src/social-link/icons/mail.js +1 -1
- package/src/social-link/index.php +2 -2
- package/src/spacer/edit.js +157 -18
- package/src/template-part/edit/index.js +1 -0
- package/src/template-part/edit/utils/hooks.js +2 -2
- package/src/template-part/editor.scss +9 -11
- package/src/utils/migrate-font-family.js +8 -1
- package/src/verse/test/edit.native.js +4 -9
- package/src/video/edit.native.js +2 -2
- package/tsconfig.json +1 -0
- package/build/query/hooks.js +0 -72
- package/build/query/hooks.js.map +0 -1
- package/build/utils/clean-empty-object.js +0 -37
- package/build/utils/clean-empty-object.js.map +0 -1
- package/build-module/query/hooks.js +0 -59
- package/build-module/query/hooks.js.map +0 -1
- package/build-module/utils/clean-empty-object.js +0 -28
- package/build-module/utils/clean-empty-object.js.map +0 -1
- package/src/query/hooks.js +0 -53
- package/src/utils/clean-empty-object.js +0 -28
|
@@ -12,7 +12,10 @@ import {
|
|
|
12
12
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
13
13
|
} from '@wordpress/components';
|
|
14
14
|
import { __ } from '@wordpress/i18n';
|
|
15
|
-
import {
|
|
15
|
+
import {
|
|
16
|
+
InspectorControls,
|
|
17
|
+
privateApis as blockEditorPrivateApis,
|
|
18
|
+
} from '@wordpress/block-editor';
|
|
16
19
|
import { debounce } from '@wordpress/compose';
|
|
17
20
|
import { useEffect, useState, useCallback } from '@wordpress/element';
|
|
18
21
|
|
|
@@ -24,6 +27,8 @@ import AuthorControl from './author-control';
|
|
|
24
27
|
import ParentControl from './parent-control';
|
|
25
28
|
import { TaxonomyControls } from './taxonomy-controls';
|
|
26
29
|
import StickyControl from './sticky-control';
|
|
30
|
+
import CreateNewPostLink from './create-new-post-link';
|
|
31
|
+
import { unlock } from '../../../private-apis';
|
|
27
32
|
import {
|
|
28
33
|
usePostTypes,
|
|
29
34
|
useIsPostTypeHierarchical,
|
|
@@ -32,11 +37,10 @@ import {
|
|
|
32
37
|
useTaxonomies,
|
|
33
38
|
} from '../../utils';
|
|
34
39
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
setDisplayLayout
|
|
39
|
-
} ) {
|
|
40
|
+
const { BlockInfo } = unlock( blockEditorPrivateApis );
|
|
41
|
+
|
|
42
|
+
export default function QueryInspectorControls( props ) {
|
|
43
|
+
const { attributes, setQuery, setDisplayLayout } = props;
|
|
40
44
|
const { query, displayLayout } = attributes;
|
|
41
45
|
const {
|
|
42
46
|
order,
|
|
@@ -127,6 +131,9 @@ export default function QueryInspectorControls( {
|
|
|
127
131
|
|
|
128
132
|
return (
|
|
129
133
|
<>
|
|
134
|
+
<BlockInfo>
|
|
135
|
+
<CreateNewPostLink { ...props } />
|
|
136
|
+
</BlockInfo>
|
|
130
137
|
{ showSettingsPanel && (
|
|
131
138
|
<InspectorControls>
|
|
132
139
|
<PanelBody title={ __( 'Settings' ) }>
|
|
@@ -62,6 +62,7 @@ export default function PatternSelectionModal( {
|
|
|
62
62
|
overlayClassName="block-library-query-pattern__selection-modal"
|
|
63
63
|
title={ __( 'Choose a pattern' ) }
|
|
64
64
|
onRequestClose={ () => setIsPatternSelectionModalOpen( false ) }
|
|
65
|
+
isFullScreen={ true }
|
|
65
66
|
>
|
|
66
67
|
<div className="block-library-query-pattern__selection-content">
|
|
67
68
|
<div className="block-library-query-pattern__selection-search">
|
package/src/query/editor.scss
CHANGED
|
@@ -20,20 +20,17 @@
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
.block-library-query-pattern__selection-modal {
|
|
23
|
-
// To keep modal dimensions consistent as subsections are navigated, width
|
|
24
|
-
// and height are used instead of max-(width/height).
|
|
25
|
-
.components-modal__frame {
|
|
26
|
-
@include break-small() {
|
|
27
|
-
width: calc(100% - #{$grid-unit-20 * 2});
|
|
28
|
-
height: calc(100% - #{$header-height * 2});
|
|
29
|
-
}
|
|
30
23
|
|
|
31
|
-
|
|
32
|
-
|
|
24
|
+
.block-editor-block-patterns-list {
|
|
25
|
+
column-count: 2;
|
|
26
|
+
column-gap: $grid-unit-30;
|
|
27
|
+
|
|
28
|
+
@include break-wide() {
|
|
29
|
+
column-count: 3;
|
|
33
30
|
}
|
|
34
31
|
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
.block-editor-block-patterns-list__list-item {
|
|
33
|
+
break-inside: avoid-column;
|
|
37
34
|
}
|
|
38
35
|
}
|
|
39
36
|
|
package/src/query/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { loop as icon } from '@wordpress/icons';
|
|
5
|
-
import { addFilter } from '@wordpress/hooks';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Internal dependencies
|
|
@@ -13,7 +12,6 @@ import edit from './edit';
|
|
|
13
12
|
import save from './save';
|
|
14
13
|
import variations from './variations';
|
|
15
14
|
import deprecated from './deprecated';
|
|
16
|
-
import queryInspectorControls from './hooks';
|
|
17
15
|
|
|
18
16
|
const { name } = metadata;
|
|
19
17
|
export { metadata, name };
|
|
@@ -26,8 +24,4 @@ export const settings = {
|
|
|
26
24
|
deprecated,
|
|
27
25
|
};
|
|
28
26
|
|
|
29
|
-
export const init = () => {
|
|
30
|
-
addFilter( 'editor.BlockEdit', 'core/query', queryInspectorControls );
|
|
31
|
-
|
|
32
|
-
return initBlock( { name, metadata, settings } );
|
|
33
|
-
};
|
|
27
|
+
export const init = () => initBlock( { name, metadata, settings } );
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
fireEvent,
|
|
11
11
|
within,
|
|
12
12
|
waitFor,
|
|
13
|
-
|
|
13
|
+
typeInRichText,
|
|
14
14
|
} from 'test/helpers';
|
|
15
15
|
|
|
16
16
|
/**
|
|
@@ -49,11 +49,7 @@ describe( 'Quote', () => {
|
|
|
49
49
|
// screen.debug();
|
|
50
50
|
let quoteTextInput =
|
|
51
51
|
within( quoteBlock ).getByPlaceholderText( 'Start writing…' );
|
|
52
|
-
|
|
53
|
-
changeAndSelectTextOfRichText( quoteTextInput, string, {
|
|
54
|
-
selectionStart: string.length,
|
|
55
|
-
selectionEnd: string.length,
|
|
56
|
-
} );
|
|
52
|
+
typeInRichText( quoteTextInput, 'A great statement.' );
|
|
57
53
|
fireEvent( quoteTextInput, 'onKeyDown', {
|
|
58
54
|
nativeEvent: {},
|
|
59
55
|
preventDefault() {},
|
|
@@ -63,12 +59,12 @@ describe( 'Quote', () => {
|
|
|
63
59
|
within( quoteBlock ).getAllByPlaceholderText(
|
|
64
60
|
'Start writing…'
|
|
65
61
|
)[ 1 ];
|
|
66
|
-
|
|
62
|
+
typeInRichText( quoteTextInput, 'Again.' );
|
|
67
63
|
const citationTextInput =
|
|
68
64
|
within( citationBlock ).getByPlaceholderText( 'Add citation' );
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
65
|
+
typeInRichText( citationTextInput, 'A person', {
|
|
66
|
+
finalSelectionStart: 2,
|
|
67
|
+
finalSelectionEnd: 2,
|
|
72
68
|
} );
|
|
73
69
|
fireEvent( citationTextInput, 'onKeyDown', {
|
|
74
70
|
nativeEvent: {},
|
package/src/search/style.scss
CHANGED
|
@@ -45,6 +45,9 @@ $button-spacing-y: math.div($grid-unit-15, 2); // 6px
|
|
|
45
45
|
// !important used to forcibly prevent undesired application of
|
|
46
46
|
// text-decoration styles on the input field.
|
|
47
47
|
text-decoration: unset !important;
|
|
48
|
+
|
|
49
|
+
// Hides a redundant extra search icon on Mobile Safari.
|
|
50
|
+
appearance: initial;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
53
|
.wp-block-search.wp-block-search__button-only {
|
|
@@ -7,28 +7,8 @@
|
|
|
7
7
|
// The editing view for the Shortcode block is equivalent to block UI.
|
|
8
8
|
// Therefore we increase specificity to avoid theme styles bleeding in.
|
|
9
9
|
.blocks-shortcode__textarea {
|
|
10
|
-
font-family: $editor-html-font !important;
|
|
11
|
-
color: $gray-900 !important;
|
|
12
|
-
background: $white !important;
|
|
13
|
-
padding: $grid-unit-15 !important;
|
|
14
|
-
border: $border-width solid $gray-900 !important;
|
|
15
|
-
box-shadow: none !important;
|
|
16
|
-
border-radius: $radius-block-ui !important;
|
|
17
10
|
box-sizing: border-box;
|
|
18
11
|
max-height: 250px;
|
|
19
12
|
resize: none;
|
|
20
|
-
|
|
21
|
-
/* Fonts smaller than 16px causes mobile safari to zoom. */
|
|
22
|
-
font-size: $mobile-text-min-font-size !important;
|
|
23
|
-
@include break-small {
|
|
24
|
-
font-size: $default-font-size !important;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
&:focus {
|
|
28
|
-
border-color: var(--wp-admin-theme-color) !important;
|
|
29
|
-
box-shadow: 0 0 0 ($border-width-focus - $border-width) var(--wp-admin-theme-color) !important;
|
|
30
|
-
|
|
31
|
-
// Windows High Contrast mode will show this outline, but not the box-shadow.
|
|
32
|
-
outline: 2px solid transparent !important;
|
|
33
|
-
}
|
|
13
|
+
@include editor-input-reset();
|
|
34
14
|
}
|
package/src/site-logo/block.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"name": "core/site-logo",
|
|
5
5
|
"title": "Site Logo",
|
|
6
6
|
"category": "theme",
|
|
7
|
-
"description": "Display
|
|
7
|
+
"description": "Display an image to represent this site. Update this block and the changes apply everywhere.",
|
|
8
8
|
"textdomain": "default",
|
|
9
9
|
"attributes": {
|
|
10
10
|
"width": {
|
package/src/site-logo/edit.js
CHANGED
|
@@ -24,12 +24,19 @@ import {
|
|
|
24
24
|
ToolbarButton,
|
|
25
25
|
Placeholder,
|
|
26
26
|
Button,
|
|
27
|
+
DropZone,
|
|
28
|
+
FlexItem,
|
|
29
|
+
__experimentalItemGroup as ItemGroup,
|
|
30
|
+
__experimentalHStack as HStack,
|
|
31
|
+
__experimentalTruncate as Truncate,
|
|
27
32
|
} from '@wordpress/components';
|
|
28
33
|
import { useViewportMatch } from '@wordpress/compose';
|
|
29
34
|
import {
|
|
30
35
|
BlockControls,
|
|
31
36
|
InspectorControls,
|
|
32
37
|
MediaPlaceholder,
|
|
38
|
+
MediaUpload,
|
|
39
|
+
MediaUploadCheck,
|
|
33
40
|
MediaReplaceFlow,
|
|
34
41
|
useBlockProps,
|
|
35
42
|
store as blockEditorStore,
|
|
@@ -349,6 +356,45 @@ const SiteLogo = ( {
|
|
|
349
356
|
);
|
|
350
357
|
};
|
|
351
358
|
|
|
359
|
+
// This is a light wrapper around MediaReplaceFlow because the block has two
|
|
360
|
+
// different MediaReplaceFlows, one for the inspector and one for the toolbar.
|
|
361
|
+
function SiteLogoReplaceFlow( { onRemoveLogo, ...mediaReplaceProps } ) {
|
|
362
|
+
return (
|
|
363
|
+
<MediaReplaceFlow
|
|
364
|
+
{ ...mediaReplaceProps }
|
|
365
|
+
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
366
|
+
accept={ ACCEPT_MEDIA_STRING }
|
|
367
|
+
>
|
|
368
|
+
<MenuItem onClick={ onRemoveLogo }>{ __( 'Reset' ) }</MenuItem>
|
|
369
|
+
</MediaReplaceFlow>
|
|
370
|
+
);
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
const InspectorLogoPreview = ( { mediaItemData = {}, itemGroupProps } ) => {
|
|
374
|
+
const {
|
|
375
|
+
alt_text: alt,
|
|
376
|
+
source_url: logoUrl,
|
|
377
|
+
slug: logoSlug,
|
|
378
|
+
media_details: logoMediaDetails,
|
|
379
|
+
} = mediaItemData;
|
|
380
|
+
const logoLabel = logoMediaDetails?.sizes?.full?.file || logoSlug;
|
|
381
|
+
return (
|
|
382
|
+
<ItemGroup { ...itemGroupProps } as="span">
|
|
383
|
+
<HStack justify="flex-start" as="span">
|
|
384
|
+
<img src={ logoUrl } alt={ alt } />
|
|
385
|
+
<FlexItem as="span">
|
|
386
|
+
<Truncate
|
|
387
|
+
numberOfLines={ 1 }
|
|
388
|
+
className="block-library-site-logo__inspector-media-replace-title"
|
|
389
|
+
>
|
|
390
|
+
{ logoLabel }
|
|
391
|
+
</Truncate>
|
|
392
|
+
</FlexItem>
|
|
393
|
+
</HStack>
|
|
394
|
+
</ItemGroup>
|
|
395
|
+
);
|
|
396
|
+
};
|
|
397
|
+
|
|
352
398
|
export default function LogoEdit( {
|
|
353
399
|
attributes,
|
|
354
400
|
className,
|
|
@@ -365,6 +411,7 @@ export default function LogoEdit( {
|
|
|
365
411
|
siteIconId,
|
|
366
412
|
mediaItemData,
|
|
367
413
|
isRequestingMediaItem,
|
|
414
|
+
mediaUpload,
|
|
368
415
|
} = useSelect( ( select ) => {
|
|
369
416
|
const { canUser, getEntityRecord, getEditedEntityRecord } =
|
|
370
417
|
select( coreStore );
|
|
@@ -396,6 +443,7 @@ export default function LogoEdit( {
|
|
|
396
443
|
mediaItemData: mediaItem,
|
|
397
444
|
isRequestingMediaItem: _isRequestingMediaItem,
|
|
398
445
|
siteIconId: _siteIconId,
|
|
446
|
+
mediaUpload: select( blockEditorStore ).getSettings().mediaUpload,
|
|
399
447
|
};
|
|
400
448
|
}, [] );
|
|
401
449
|
|
|
@@ -461,17 +509,29 @@ export default function LogoEdit( {
|
|
|
461
509
|
createErrorNotice( message, { type: 'snackbar' } );
|
|
462
510
|
};
|
|
463
511
|
|
|
512
|
+
const onFilesDrop = ( filesList ) => {
|
|
513
|
+
mediaUpload( {
|
|
514
|
+
allowedTypes: [ 'image' ],
|
|
515
|
+
filesList,
|
|
516
|
+
onFileChange( [ image ] ) {
|
|
517
|
+
if ( isBlobURL( image?.url ) ) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
onInitialSelectLogo( image );
|
|
521
|
+
},
|
|
522
|
+
onError: onUploadError,
|
|
523
|
+
} );
|
|
524
|
+
};
|
|
525
|
+
|
|
526
|
+
const mediaReplaceFlowProps = {
|
|
527
|
+
mediaURL: logoUrl,
|
|
528
|
+
onSelect: onSelectLogo,
|
|
529
|
+
onError: onUploadError,
|
|
530
|
+
onRemoveLogo,
|
|
531
|
+
};
|
|
464
532
|
const controls = canUserEdit && logoUrl && (
|
|
465
533
|
<BlockControls group="other">
|
|
466
|
-
<
|
|
467
|
-
mediaURL={ logoUrl }
|
|
468
|
-
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
469
|
-
accept={ ACCEPT_MEDIA_STRING }
|
|
470
|
-
onSelect={ onSelectLogo }
|
|
471
|
-
onError={ onUploadError }
|
|
472
|
-
>
|
|
473
|
-
<MenuItem onClick={ onRemoveLogo }>{ __( 'Reset' ) }</MenuItem>
|
|
474
|
-
</MediaReplaceFlow>
|
|
534
|
+
<SiteLogoReplaceFlow { ...mediaReplaceFlowProps } />
|
|
475
535
|
</BlockControls>
|
|
476
536
|
);
|
|
477
537
|
|
|
@@ -530,9 +590,63 @@ export default function LogoEdit( {
|
|
|
530
590
|
|
|
531
591
|
const label = __( 'Add a site logo' );
|
|
532
592
|
|
|
593
|
+
const mediaInspectorPanel = ( canUserEdit || logoUrl ) && (
|
|
594
|
+
<InspectorControls>
|
|
595
|
+
<PanelBody title={ __( 'Media' ) }>
|
|
596
|
+
<div className="block-library-site-logo__inspector-media-replace-container">
|
|
597
|
+
{ ! canUserEdit && !! logoUrl && (
|
|
598
|
+
<InspectorLogoPreview
|
|
599
|
+
mediaItemData={ mediaItemData }
|
|
600
|
+
itemGroupProps={ {
|
|
601
|
+
isBordered: true,
|
|
602
|
+
className:
|
|
603
|
+
'block-library-site-logo__inspector-readonly-logo-preview',
|
|
604
|
+
} }
|
|
605
|
+
/>
|
|
606
|
+
) }
|
|
607
|
+
{ canUserEdit && !! logoUrl && (
|
|
608
|
+
<SiteLogoReplaceFlow
|
|
609
|
+
{ ...mediaReplaceFlowProps }
|
|
610
|
+
name={
|
|
611
|
+
<InspectorLogoPreview
|
|
612
|
+
mediaItemData={ mediaItemData }
|
|
613
|
+
/>
|
|
614
|
+
}
|
|
615
|
+
popoverProps={ {} }
|
|
616
|
+
/>
|
|
617
|
+
) }
|
|
618
|
+
{ canUserEdit && ! logoUrl && (
|
|
619
|
+
<MediaUploadCheck>
|
|
620
|
+
<MediaUpload
|
|
621
|
+
onSelect={ onInitialSelectLogo }
|
|
622
|
+
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
623
|
+
render={ ( { open } ) => (
|
|
624
|
+
<div className="block-library-site-logo__inspector-upload-container">
|
|
625
|
+
<Button
|
|
626
|
+
onClick={ open }
|
|
627
|
+
variant="secondary"
|
|
628
|
+
>
|
|
629
|
+
{ isLoading ? (
|
|
630
|
+
<Spinner />
|
|
631
|
+
) : (
|
|
632
|
+
__( 'Add media' )
|
|
633
|
+
) }
|
|
634
|
+
</Button>
|
|
635
|
+
<DropZone onFilesDrop={ onFilesDrop } />
|
|
636
|
+
</div>
|
|
637
|
+
) }
|
|
638
|
+
/>
|
|
639
|
+
</MediaUploadCheck>
|
|
640
|
+
) }
|
|
641
|
+
</div>
|
|
642
|
+
</PanelBody>
|
|
643
|
+
</InspectorControls>
|
|
644
|
+
);
|
|
645
|
+
|
|
533
646
|
return (
|
|
534
647
|
<div { ...blockProps }>
|
|
535
648
|
{ controls }
|
|
649
|
+
{ mediaInspectorPanel }
|
|
536
650
|
{ !! logoUrl && logoImage }
|
|
537
651
|
{ ! logoUrl && ! canUserEdit && (
|
|
538
652
|
<Placeholder className="site-logo_placeholder">
|
|
@@ -93,3 +93,60 @@
|
|
|
93
93
|
}
|
|
94
94
|
}
|
|
95
95
|
}
|
|
96
|
+
|
|
97
|
+
.block-library-site-logo__inspector-upload-container {
|
|
98
|
+
position: relative;
|
|
99
|
+
// Since there is no option to skip rendering the drag'n'drop icon in drop
|
|
100
|
+
// zone, we hide it for now.
|
|
101
|
+
.components-drop-zone__content-icon {
|
|
102
|
+
display: none;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
.block-library-site-logo__inspector-upload-container,
|
|
107
|
+
.block-library-site-logo__inspector-media-replace-container {
|
|
108
|
+
button.components-button {
|
|
109
|
+
color: $gray-900;
|
|
110
|
+
box-shadow: inset 0 0 0 1px $gray-400;
|
|
111
|
+
width: 100%;
|
|
112
|
+
display: block;
|
|
113
|
+
height: $grid-unit-50;
|
|
114
|
+
|
|
115
|
+
&:hover {
|
|
116
|
+
color: var(--wp-admin-theme-color);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&:focus {
|
|
120
|
+
box-shadow: inset 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.block-library-site-logo__inspector-media-replace-title {
|
|
125
|
+
word-break: break-all;
|
|
126
|
+
// The Button component is white-space: nowrap, and that won't work with line-clamp.
|
|
127
|
+
white-space: normal;
|
|
128
|
+
|
|
129
|
+
// Without this, the ellipsis can sometimes be partially hidden by the Button padding.
|
|
130
|
+
text-align: start;
|
|
131
|
+
text-align-last: center;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.block-library-site-logo__inspector-media-replace-container {
|
|
136
|
+
.components-dropdown {
|
|
137
|
+
display: block;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
img {
|
|
141
|
+
width: $grid-unit-50 * 0.5;
|
|
142
|
+
aspect-ratio: 1;
|
|
143
|
+
box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.2);
|
|
144
|
+
border-radius: 50% !important;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
.block-library-site-logo__inspector-readonly-logo-preview {
|
|
148
|
+
padding: 6px 12px;
|
|
149
|
+
display: flex;
|
|
150
|
+
height: $grid-unit-50;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -5,6 +5,6 @@ import { Path, SVG } from '@wordpress/primitives';
|
|
|
5
5
|
|
|
6
6
|
export const ChainIcon = () => (
|
|
7
7
|
<SVG width="24" height="24" viewBox="0 0 24 24" version="1.1">
|
|
8
|
-
<Path d="
|
|
8
|
+
<Path d="M15.6 7.2H14v1.5h1.6c2 0 3.7 1.7 3.7 3.7s-1.7 3.7-3.7 3.7H14v1.5h1.6c2.8 0 5.2-2.3 5.2-5.2 0-2.9-2.3-5.2-5.2-5.2zM4.7 12.4c0-2 1.7-3.7 3.7-3.7H10V7.2H8.4c-2.9 0-5.2 2.3-5.2 5.2 0 2.9 2.3 5.2 5.2 5.2H10v-1.5H8.4c-2 0-3.7-1.7-3.7-3.7zm4.6.9h5.3v-1.5H9.3v1.5z" />
|
|
9
9
|
</SVG>
|
|
10
10
|
);
|
|
@@ -5,6 +5,6 @@ import { Path, SVG } from '@wordpress/primitives';
|
|
|
5
5
|
|
|
6
6
|
export const MailIcon = () => (
|
|
7
7
|
<SVG width="24" height="24" viewBox="0 0 24 24" version="1.1">
|
|
8
|
-
<Path d="
|
|
8
|
+
<Path d="M19 5H5c-1.1 0-2 .9-2 2v10c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm.5 12c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5V9.8l7.5 5.6 7.5-5.6V17zm0-9.1L12 13.6 4.5 7.9V7c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v.9z" />
|
|
9
9
|
</SVG>
|
|
10
10
|
);
|
|
@@ -144,7 +144,7 @@ function block_core_social_link_services( $service = '', $field = '' ) {
|
|
|
144
144
|
),
|
|
145
145
|
'chain' => array(
|
|
146
146
|
'name' => 'Link',
|
|
147
|
-
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="
|
|
147
|
+
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M15.6,7.2H14v1.5h1.6c2,0,3.7,1.7,3.7,3.7s-1.7,3.7-3.7,3.7H14v1.5h1.6c2.8,0,5.2-2.3,5.2-5.2,0-2.9-2.3-5.2-5.2-5.2zM4.7,12.4c0-2,1.7-3.7,3.7-3.7H10V7.2H8.4c-2.9,0-5.2,2.3-5.2,5.2,0,2.9,2.3,5.2,5.2,5.2H10v-1.5H8.4c-2,0-3.7-1.7-3.7-3.7zm4.6.9h5.3v-1.5H9.3v1.5z"></path></svg>',
|
|
148
148
|
),
|
|
149
149
|
'codepen' => array(
|
|
150
150
|
'name' => 'CodePen',
|
|
@@ -208,7 +208,7 @@ function block_core_social_link_services( $service = '', $field = '' ) {
|
|
|
208
208
|
),
|
|
209
209
|
'mail' => array(
|
|
210
210
|
'name' => 'Mail',
|
|
211
|
-
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="
|
|
211
|
+
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19,5H5c-1.1,0-2,.9-2,2v10c0,1.1.9,2,2,2h14c1.1,0,2-.9,2-2V7c0-1.1-.9-2-2-2zm.5,12c0,.3-.2.5-.5.5H5c-.3,0-.5-.2-.5-.5V9.8l7.5,5.6,7.5-5.6V17zm0-9.1L12,13.6,4.5,7.9V7c0-.3.2-.5.5-.5h14c.3,0,.5.2.5.5v.9z"></path></svg>',
|
|
212
212
|
),
|
|
213
213
|
'mastodon' => array(
|
|
214
214
|
'name' => 'Mastodon',
|