@wordpress/block-library 9.11.0 → 9.12.1-next.082ed6819.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/block-keyboard-shortcuts/index.js +7 -7
- package/build/block-keyboard-shortcuts/index.js.map +1 -1
- package/build/button/index.js +1 -1
- package/build/button/index.js.map +1 -1
- package/build/cover/deprecated.js +140 -4
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit/block-controls.js +1 -1
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/cover/edit/cover-placeholder.js +1 -2
- package/build/cover/edit/cover-placeholder.js.map +1 -1
- package/build/cover/edit/index.js +23 -23
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/index.js +10 -10
- package/build/cover/index.js.map +1 -1
- package/build/cover/save.js +13 -13
- package/build/cover/save.js.map +1 -1
- package/build/cover/shared.js +6 -7
- package/build/cover/shared.js.map +1 -1
- package/build/details/index.js +20 -0
- package/build/details/index.js.map +1 -1
- package/build/file/edit.js +8 -4
- package/build/file/edit.js.map +1 -1
- package/build/freeform/modal.js +1 -1
- package/build/freeform/modal.js.map +1 -1
- package/build/gallery/edit.js +1 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/heading/index.js +1 -7
- package/build/heading/index.js.map +1 -1
- package/build/home-link/edit.js +20 -36
- package/build/home-link/edit.js.map +1 -1
- package/build/image/edit.js +1 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +144 -78
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +1 -1
- package/build/latest-posts/edit.js +0 -1
- package/build/latest-posts/edit.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/navigation/edit/index.js +2 -23
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/use-template-part-area-label.js +6 -8
- package/build/navigation/use-template-part-area-label.js.map +1 -1
- package/build/page-list/index.js +14 -0
- package/build/page-list/index.js.map +1 -1
- package/build/paragraph/edit.js +26 -25
- package/build/paragraph/edit.js.map +1 -1
- package/build/post-content/index.js +13 -0
- package/build/post-content/index.js.map +1 -1
- package/build/post-template/edit.js +11 -0
- package/build/post-template/edit.js.map +1 -1
- package/build/post-template/index.js +1 -1
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js +1 -3
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +3 -13
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/pattern-selection-modal.js +0 -3
- package/build/query/edit/pattern-selection-modal.js.map +1 -1
- package/build/query/edit/query-content.js +10 -12
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/index.js +1 -1
- package/build/query/utils.js +38 -9
- package/build/query/utils.js.map +1 -1
- package/build/social-link/edit.js +22 -9
- package/build/social-link/edit.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js +2 -7
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/index.js +1 -4
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/selection-modal.js +0 -3
- package/build/template-part/edit/selection-modal.js.map +1 -1
- package/build/template-part/edit/utils/get-template-part-icon.js +23 -0
- package/build/template-part/edit/utils/get-template-part-icon.js.map +1 -0
- package/build/template-part/edit/utils/hooks.js +1 -6
- package/build/template-part/edit/utils/hooks.js.map +1 -1
- package/build/template-part/variations.js +6 -12
- package/build/template-part/variations.js.map +1 -1
- package/build/video/edit.js +1 -1
- package/build/video/edit.js.map +1 -1
- package/build/video/tracks-editor.js +135 -123
- package/build/video/tracks-editor.js.map +1 -1
- package/build-module/block-keyboard-shortcuts/index.js +7 -7
- package/build-module/block-keyboard-shortcuts/index.js.map +1 -1
- package/build-module/button/index.js +1 -1
- package/build-module/button/index.js.map +1 -1
- package/build-module/cover/deprecated.js +140 -4
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +1 -1
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/cover/edit/cover-placeholder.js +1 -2
- package/build-module/cover/edit/cover-placeholder.js.map +1 -1
- package/build-module/cover/edit/index.js +23 -23
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/index.js +10 -10
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/save.js +13 -13
- package/build-module/cover/save.js.map +1 -1
- package/build-module/cover/shared.js +6 -7
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/details/index.js +21 -1
- package/build-module/details/index.js.map +1 -1
- package/build-module/file/edit.js +8 -4
- package/build-module/file/edit.js.map +1 -1
- package/build-module/freeform/modal.js +1 -1
- package/build-module/freeform/modal.js.map +1 -1
- package/build-module/gallery/edit.js +1 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/heading/index.js +1 -7
- package/build-module/heading/index.js.map +1 -1
- package/build-module/home-link/edit.js +23 -39
- package/build-module/home-link/edit.js.map +1 -1
- package/build-module/image/edit.js +1 -1
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +149 -83
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +1 -1
- package/build-module/latest-posts/edit.js +0 -1
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/navigation/edit/index.js +2 -23
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/use-template-part-area-label.js +6 -8
- package/build-module/navigation/use-template-part-area-label.js.map +1 -1
- package/build-module/page-list/index.js +14 -0
- package/build-module/page-list/index.js.map +1 -1
- package/build-module/paragraph/edit.js +26 -25
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/post-content/index.js +13 -0
- package/build-module/post-content/index.js.map +1 -1
- package/build-module/post-template/edit.js +11 -0
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-template/index.js +1 -1
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +1 -3
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +3 -13
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/pattern-selection-modal.js +0 -3
- package/build-module/query/edit/pattern-selection-modal.js.map +1 -1
- package/build-module/query/edit/query-content.js +10 -12
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/index.js +1 -1
- package/build-module/query/utils.js +35 -8
- package/build-module/query/utils.js.map +1 -1
- package/build-module/social-link/edit.js +24 -11
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js +3 -8
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +1 -4
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/selection-modal.js +0 -3
- package/build-module/template-part/edit/selection-modal.js.map +1 -1
- package/build-module/template-part/edit/utils/get-template-part-icon.js +15 -0
- package/build-module/template-part/edit/utils/get-template-part-icon.js.map +1 -0
- package/build-module/template-part/edit/utils/hooks.js +1 -6
- package/build-module/template-part/edit/utils/hooks.js.map +1 -1
- package/build-module/template-part/variations.js +5 -11
- package/build-module/template-part/variations.js.map +1 -1
- package/build-module/video/edit.js +1 -1
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/tracks-editor.js +136 -124
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/cover/editor-rtl.css +3 -5
- package/build-style/cover/editor.css +3 -5
- package/build-style/cover/style-rtl.css +19 -15
- package/build-style/cover/style.css +19 -15
- package/build-style/editor-rtl.css +19 -30
- package/build-style/editor.css +19 -30
- package/build-style/group/editor-rtl.css +0 -10
- package/build-style/group/editor.css +0 -10
- package/build-style/image/editor-rtl.css +4 -0
- package/build-style/image/editor.css +4 -0
- package/build-style/image/style-rtl.css +0 -2
- package/build-style/image/style.css +0 -2
- package/build-style/latest-posts/editor-rtl.css +0 -7
- package/build-style/latest-posts/editor.css +0 -7
- package/build-style/media-text/style-rtl.css +1 -1
- package/build-style/media-text/style.css +1 -1
- package/build-style/navigation/style-rtl.css +1 -1
- package/build-style/navigation/style.css +1 -1
- package/build-style/page-list/style-rtl.css +4 -0
- package/build-style/page-list/style.css +4 -0
- package/build-style/query/editor-rtl.css +0 -4
- package/build-style/query/editor.css +0 -4
- package/build-style/search/style-rtl.css +3 -3
- package/build-style/search/style.css +3 -3
- package/build-style/social-link/editor-rtl.css +4 -4
- package/build-style/social-link/editor.css +4 -4
- package/build-style/style-rtl.css +28 -22
- package/build-style/style.css +28 -22
- package/build-style/video/editor-rtl.css +8 -0
- package/build-style/video/editor.css +8 -0
- package/build-types/lock-unlock.d.ts +2 -0
- package/build-types/lock-unlock.d.ts.map +1 -0
- package/package.json +39 -39
- package/src/block-keyboard-shortcuts/index.js +25 -11
- package/src/button/index.js +1 -1
- package/src/comments/block.json +3 -9
- package/src/cover/deprecated.js +182 -4
- package/src/cover/edit/block-controls.js +1 -1
- package/src/cover/edit/cover-placeholder.js +0 -3
- package/src/cover/edit/index.js +42 -27
- package/src/cover/editor.scss +4 -5
- package/src/cover/index.js +8 -8
- package/src/cover/save.js +27 -20
- package/src/cover/shared.js +10 -10
- package/src/cover/style.scss +40 -16
- package/src/cover/test/__snapshots__/edit.native.js.snap +9 -9
- package/src/cover/test/__snapshots__/transforms.native.js.snap +4 -4
- package/src/cover/test/edit.js +2 -2
- package/src/cover/test/edit.native.js +4 -4
- package/src/cover/test/transforms.native.js +4 -4
- package/src/details/block.json +1 -0
- package/src/details/index.js +23 -1
- package/src/file/edit.js +9 -3
- package/src/freeform/modal.js +1 -1
- package/src/gallery/edit.js +1 -1
- package/src/group/editor.scss +0 -12
- package/src/heading/block.json +1 -7
- package/src/home-link/edit.js +27 -45
- package/src/home-link/index.php +0 -3
- package/src/image/block.json +1 -1
- package/src/image/edit.js +1 -1
- package/src/image/editor.scss +4 -0
- package/src/image/image.js +200 -109
- package/src/image/style.scss +0 -1
- package/src/image/test/__snapshots__/transforms.native.js.snap +1 -1
- package/src/latest-posts/edit.js +0 -1
- package/src/latest-posts/editor.scss +0 -11
- package/src/media-text/style.scss +1 -1
- package/src/media-text/test/__snapshots__/transforms.native.js.snap +2 -2
- package/src/navigation/edit/index.js +3 -30
- package/src/navigation/index.php +5 -151
- package/src/navigation/style.scss +1 -1
- package/src/navigation/use-template-part-area-label.js +10 -10
- package/src/page-list/block.json +14 -0
- package/src/page-list/style.scss +4 -0
- package/src/paragraph/edit.js +20 -17
- package/src/pattern/index.php +0 -7
- package/src/post-content/block.json +14 -1
- package/src/post-template/block.json +2 -1
- package/src/post-template/edit.js +19 -0
- package/src/query/block.json +1 -1
- package/src/query/edit/inspector-controls/enhanced-pagination-control.js +3 -5
- package/src/query/edit/inspector-controls/index.js +2 -12
- package/src/query/edit/pattern-selection-modal.js +0 -3
- package/src/query/edit/query-content.js +9 -17
- package/src/query/editor.scss +0 -4
- package/src/query/index.php +1 -1
- package/src/query/test/utils.js +59 -1
- package/src/query/utils.js +43 -15
- package/src/rss/index.php +11 -8
- package/src/search/index.php +2 -2
- package/src/search/style.scss +3 -5
- package/src/social-link/edit.js +47 -19
- package/src/social-link/editor.scss +6 -7
- package/src/template-part/edit/advanced-controls.js +13 -13
- package/src/template-part/edit/index.js +1 -4
- package/src/template-part/edit/selection-modal.js +0 -3
- package/src/template-part/edit/utils/get-template-part-icon.js +20 -0
- package/src/template-part/edit/utils/hooks.js +2 -7
- package/src/template-part/variations.js +4 -16
- package/src/video/edit.js +1 -1
- package/src/video/editor.scss +9 -0
- package/src/video/test/__snapshots__/transforms.native.js.snap +1 -1
- package/src/video/tracks-editor.js +157 -141
- package/tsconfig.tsbuildinfo +1 -1
- package/build/query/edit/inspector-controls/create-new-post-link.js +0 -40
- package/build/query/edit/inspector-controls/create-new-post-link.js.map +0 -1
- package/build-module/query/edit/inspector-controls/create-new-post-link.js +0 -33
- package/build-module/query/edit/inspector-controls/create-new-post-link.js.map +0 -1
- package/src/query/edit/inspector-controls/create-new-post-link.js +0 -32
- /package/src/{lock-unlock.js → lock-unlock.ts} +0 -0
package/src/file/edit.js
CHANGED
|
@@ -128,15 +128,21 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
|
|
|
128
128
|
}
|
|
129
129
|
|
|
130
130
|
const isPdf = newMedia.url.endsWith( '.pdf' );
|
|
131
|
+
const pdfAttributes = {
|
|
132
|
+
displayPreview: isPdf
|
|
133
|
+
? attributes.displayPreview ?? true
|
|
134
|
+
: undefined,
|
|
135
|
+
previewHeight: isPdf ? attributes.previewHeight ?? 600 : undefined,
|
|
136
|
+
};
|
|
137
|
+
|
|
131
138
|
setAttributes( {
|
|
132
139
|
href: newMedia.url,
|
|
133
140
|
fileName: newMedia.title,
|
|
134
141
|
textLinkHref: newMedia.url,
|
|
135
142
|
id: newMedia.id,
|
|
136
|
-
displayPreview: isPdf ? true : undefined,
|
|
137
|
-
previewHeight: isPdf ? 600 : undefined,
|
|
138
143
|
fileId: `wp-block-file--media-${ clientId }`,
|
|
139
144
|
blob: undefined,
|
|
145
|
+
...pdfAttributes,
|
|
140
146
|
} );
|
|
141
147
|
setTemporaryURL();
|
|
142
148
|
}
|
|
@@ -201,7 +207,7 @@ function FileEdit( { attributes, isSelected, setAttributes, clientId } ) {
|
|
|
201
207
|
labels={ {
|
|
202
208
|
title: __( 'File' ),
|
|
203
209
|
instructions: __(
|
|
204
|
-
'
|
|
210
|
+
'Drag and drop a file, upload, or choose from your library.'
|
|
205
211
|
),
|
|
206
212
|
} }
|
|
207
213
|
onSelect={ onSelectFile }
|
package/src/freeform/modal.js
CHANGED
package/src/gallery/edit.js
CHANGED
|
@@ -96,7 +96,7 @@ const ALLOWED_MEDIA_TYPES = [ 'image' ];
|
|
|
96
96
|
|
|
97
97
|
const PLACEHOLDER_TEXT = Platform.isNative
|
|
98
98
|
? __( 'Add media' )
|
|
99
|
-
: __( 'Drag images, upload
|
|
99
|
+
: __( 'Drag and drop images, upload, or choose from your library.' );
|
|
100
100
|
|
|
101
101
|
const MOBILE_CONTROL_PROPS_RANGE_CONTROL = Platform.isNative
|
|
102
102
|
? { type: 'stepper' }
|
package/src/group/editor.scss
CHANGED
|
@@ -10,18 +10,6 @@
|
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
12
|
|
|
13
|
-
// Reset user select, but the next rule should take precedence for nested
|
|
14
|
-
// groups.
|
|
15
|
-
:where([data-has-multi-selection]:not([contenteditable="true"]) .wp-block-group > *) {
|
|
16
|
-
user-select: initial;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// When we are not multi-selecting, prevent children from capturing the
|
|
20
|
-
// selection, which happens when the group is flex and children inlined.
|
|
21
|
-
:where([data-has-multi-selection]:not([contenteditable="true"]) .wp-block-group) {
|
|
22
|
-
user-select: none;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
13
|
// Place block list appender in the same place content will appear.
|
|
26
14
|
[data-type="core/group"].is-selected {
|
|
27
15
|
.block-list-appender {
|
package/src/heading/block.json
CHANGED
package/src/home-link/edit.js
CHANGED
|
@@ -6,15 +6,10 @@ import clsx from 'clsx';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import {
|
|
10
|
-
RichText,
|
|
11
|
-
useBlockProps,
|
|
12
|
-
store as blockEditorStore,
|
|
13
|
-
} from '@wordpress/block-editor';
|
|
9
|
+
import { RichText, useBlockProps } from '@wordpress/block-editor';
|
|
14
10
|
import { __ } from '@wordpress/i18n';
|
|
15
|
-
import { useSelect
|
|
11
|
+
import { useSelect } from '@wordpress/data';
|
|
16
12
|
import { store as coreStore } from '@wordpress/core-data';
|
|
17
|
-
import { useEffect } from '@wordpress/element';
|
|
18
13
|
|
|
19
14
|
const preventDefault = ( event ) => event.preventDefault();
|
|
20
15
|
|
|
@@ -24,8 +19,6 @@ export default function HomeEdit( { attributes, setAttributes, context } ) {
|
|
|
24
19
|
return select( coreStore ).getEntityRecord( 'root', '__unstableBase' )
|
|
25
20
|
?.home;
|
|
26
21
|
}, [] );
|
|
27
|
-
const { __unstableMarkNextChangeAsNotPersistent } =
|
|
28
|
-
useDispatch( blockEditorStore );
|
|
29
22
|
|
|
30
23
|
const { textColor, backgroundColor, style } = context;
|
|
31
24
|
const blockProps = useBlockProps( {
|
|
@@ -41,42 +34,31 @@ export default function HomeEdit( { attributes, setAttributes, context } ) {
|
|
|
41
34
|
},
|
|
42
35
|
} );
|
|
43
36
|
|
|
44
|
-
const { label } = attributes;
|
|
45
|
-
|
|
46
|
-
useEffect( () => {
|
|
47
|
-
if ( label === undefined ) {
|
|
48
|
-
__unstableMarkNextChangeAsNotPersistent();
|
|
49
|
-
setAttributes( { label: __( 'Home' ) } );
|
|
50
|
-
}
|
|
51
|
-
}, [ label ] );
|
|
52
|
-
|
|
53
37
|
return (
|
|
54
|
-
|
|
55
|
-
<
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
</div>
|
|
80
|
-
</>
|
|
38
|
+
<div { ...blockProps }>
|
|
39
|
+
<a
|
|
40
|
+
className="wp-block-home-link__content wp-block-navigation-item__content"
|
|
41
|
+
href={ homeUrl }
|
|
42
|
+
onClick={ preventDefault }
|
|
43
|
+
>
|
|
44
|
+
<RichText
|
|
45
|
+
identifier="label"
|
|
46
|
+
className="wp-block-home-link__label"
|
|
47
|
+
value={ attributes.label ?? __( 'Home' ) }
|
|
48
|
+
onChange={ ( labelValue ) => {
|
|
49
|
+
setAttributes( { label: labelValue } );
|
|
50
|
+
} }
|
|
51
|
+
aria-label={ __( 'Home link text' ) }
|
|
52
|
+
placeholder={ __( 'Add home link' ) }
|
|
53
|
+
withoutInteractiveFormatting
|
|
54
|
+
allowedFormats={ [
|
|
55
|
+
'core/bold',
|
|
56
|
+
'core/italic',
|
|
57
|
+
'core/image',
|
|
58
|
+
'core/strikethrough',
|
|
59
|
+
] }
|
|
60
|
+
/>
|
|
61
|
+
</a>
|
|
62
|
+
</div>
|
|
81
63
|
);
|
|
82
64
|
}
|
package/src/home-link/index.php
CHANGED
|
@@ -137,9 +137,6 @@ function block_core_home_link_build_li_wrapper_attributes( $context ) {
|
|
|
137
137
|
*/
|
|
138
138
|
function render_block_core_home_link( $attributes, $content, $block ) {
|
|
139
139
|
if ( empty( $attributes['label'] ) ) {
|
|
140
|
-
// Using a fallback for the label attribute allows rendering the block even if no attributes have been set,
|
|
141
|
-
// e.g. when using the block as a hooked block.
|
|
142
|
-
// Note that the fallback value needs to be kept in sync with the one set in `edit.js` (upon first loading the block in the editor).
|
|
143
140
|
$attributes['label'] = __( 'Home' );
|
|
144
141
|
}
|
|
145
142
|
$aria_current = '';
|
package/src/image/block.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"name": "core/image",
|
|
5
5
|
"title": "Image",
|
|
6
6
|
"category": "media",
|
|
7
|
-
"usesContext": [ "allowResize", "imageCrop", "fixedHeight" ],
|
|
7
|
+
"usesContext": [ "allowResize", "imageCrop", "fixedHeight", "postId", "postType", "queryId" ],
|
|
8
8
|
"description": "Insert an image to make a visual statement.",
|
|
9
9
|
"keywords": [ "img", "photo", "picture" ],
|
|
10
10
|
"textdomain": "default",
|
package/src/image/edit.js
CHANGED
|
@@ -411,7 +411,7 @@ export function ImageEdit( {
|
|
|
411
411
|
! lockUrlControls &&
|
|
412
412
|
! isSmallContainer &&
|
|
413
413
|
__(
|
|
414
|
-
'
|
|
414
|
+
'Drag and drop an image, upload, or choose from your library.'
|
|
415
415
|
)
|
|
416
416
|
}
|
|
417
417
|
style={ {
|
package/src/image/editor.scss
CHANGED
|
@@ -159,6 +159,10 @@ figure.wp-block-image:not(.wp-block) {
|
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
.wp-block-image__toolbar_content_textarea__container {
|
|
163
|
+
padding: $grid-unit;
|
|
164
|
+
}
|
|
165
|
+
|
|
162
166
|
.wp-block-image__toolbar_content_textarea {
|
|
163
167
|
// Corresponds to the size of the textarea in the block inspector.
|
|
164
168
|
width: 250px;
|
package/src/image/image.js
CHANGED
|
@@ -10,11 +10,14 @@ import {
|
|
|
10
10
|
TextControl,
|
|
11
11
|
ToolbarButton,
|
|
12
12
|
ToolbarGroup,
|
|
13
|
-
Dropdown,
|
|
14
13
|
__experimentalToolsPanel as ToolsPanel,
|
|
15
14
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
16
15
|
__experimentalUseCustomUnits as useCustomUnits,
|
|
17
16
|
Placeholder,
|
|
17
|
+
MenuItem,
|
|
18
|
+
ToolbarItem,
|
|
19
|
+
DropdownMenu,
|
|
20
|
+
Popover,
|
|
18
21
|
} from '@wordpress/components';
|
|
19
22
|
import { useViewportMatch } from '@wordpress/compose';
|
|
20
23
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
@@ -29,15 +32,15 @@ import {
|
|
|
29
32
|
__experimentalUseBorderProps as useBorderProps,
|
|
30
33
|
__experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,
|
|
31
34
|
privateApis as blockEditorPrivateApis,
|
|
35
|
+
BlockSettingsMenuControls,
|
|
32
36
|
} from '@wordpress/block-editor';
|
|
33
37
|
import { useEffect, useMemo, useState, useRef } from '@wordpress/element';
|
|
34
38
|
import { __, _x, sprintf, isRTL } from '@wordpress/i18n';
|
|
35
|
-
import { DOWN } from '@wordpress/keycodes';
|
|
36
39
|
import { getFilename } from '@wordpress/url';
|
|
37
40
|
import { getBlockBindingsSource, switchToBlockType } from '@wordpress/blocks';
|
|
38
|
-
import { crop, overlayText, upload } from '@wordpress/icons';
|
|
41
|
+
import { crop, overlayText, upload, chevronDown } from '@wordpress/icons';
|
|
39
42
|
import { store as noticesStore } from '@wordpress/notices';
|
|
40
|
-
import { store as coreStore } from '@wordpress/core-data';
|
|
43
|
+
import { store as coreStore, useEntityProp } from '@wordpress/core-data';
|
|
41
44
|
|
|
42
45
|
/**
|
|
43
46
|
* Internal dependencies
|
|
@@ -69,6 +72,10 @@ const scaleOptions = [
|
|
|
69
72
|
},
|
|
70
73
|
];
|
|
71
74
|
|
|
75
|
+
const WRITEMODE_POPOVER_PROPS = {
|
|
76
|
+
placement: 'bottom-start',
|
|
77
|
+
};
|
|
78
|
+
|
|
72
79
|
// If the image has a href, wrap in an <a /> tag to trigger any inherited link element styles.
|
|
73
80
|
const ImageWrapper = ( { href, children } ) => {
|
|
74
81
|
if ( ! href ) {
|
|
@@ -94,6 +101,150 @@ const ImageWrapper = ( { href, children } ) => {
|
|
|
94
101
|
);
|
|
95
102
|
};
|
|
96
103
|
|
|
104
|
+
function ContentOnlyControls( {
|
|
105
|
+
attributes,
|
|
106
|
+
setAttributes,
|
|
107
|
+
lockAltControls,
|
|
108
|
+
lockAltControlsMessage,
|
|
109
|
+
lockTitleControls,
|
|
110
|
+
lockTitleControlsMessage,
|
|
111
|
+
} ) {
|
|
112
|
+
// Use internal state instead of a ref to make sure that the component
|
|
113
|
+
// re-renders when the popover's anchor updates.
|
|
114
|
+
const [ popoverAnchor, setPopoverAnchor ] = useState( null );
|
|
115
|
+
const [ isAltDialogOpen, setIsAltDialogOpen ] = useState( false );
|
|
116
|
+
const [ isTitleDialogOpen, setIsTitleDialogOpen ] = useState( false );
|
|
117
|
+
return (
|
|
118
|
+
<>
|
|
119
|
+
<ToolbarItem ref={ setPopoverAnchor }>
|
|
120
|
+
{ ( toggleProps ) => (
|
|
121
|
+
<DropdownMenu
|
|
122
|
+
icon={ chevronDown }
|
|
123
|
+
/* translators: button label text should, if possible, be under 16 characters. */
|
|
124
|
+
label={ __( 'More' ) }
|
|
125
|
+
toggleProps={ {
|
|
126
|
+
...toggleProps,
|
|
127
|
+
description: __( 'Displays more controls.' ),
|
|
128
|
+
} }
|
|
129
|
+
popoverProps={ WRITEMODE_POPOVER_PROPS }
|
|
130
|
+
>
|
|
131
|
+
{ ( { onClose } ) => (
|
|
132
|
+
<>
|
|
133
|
+
<MenuItem
|
|
134
|
+
onClick={ () => {
|
|
135
|
+
setIsAltDialogOpen( true );
|
|
136
|
+
onClose();
|
|
137
|
+
} }
|
|
138
|
+
aria-haspopup="dialog"
|
|
139
|
+
>
|
|
140
|
+
{ _x(
|
|
141
|
+
'Alternative text',
|
|
142
|
+
'Alternative text for an image. Block toolbar label, a low character count is preferred.'
|
|
143
|
+
) }
|
|
144
|
+
</MenuItem>
|
|
145
|
+
<MenuItem
|
|
146
|
+
onClick={ () => {
|
|
147
|
+
setIsTitleDialogOpen( true );
|
|
148
|
+
onClose();
|
|
149
|
+
} }
|
|
150
|
+
aria-haspopup="dialog"
|
|
151
|
+
>
|
|
152
|
+
{ __( 'Title text' ) }
|
|
153
|
+
</MenuItem>
|
|
154
|
+
</>
|
|
155
|
+
) }
|
|
156
|
+
</DropdownMenu>
|
|
157
|
+
) }
|
|
158
|
+
</ToolbarItem>
|
|
159
|
+
{ isAltDialogOpen && (
|
|
160
|
+
<Popover
|
|
161
|
+
placement="bottom-start"
|
|
162
|
+
anchor={ popoverAnchor }
|
|
163
|
+
onClose={ () => setIsAltDialogOpen( false ) }
|
|
164
|
+
offset={ 13 }
|
|
165
|
+
variant="toolbar"
|
|
166
|
+
>
|
|
167
|
+
<div className="wp-block-image__toolbar_content_textarea__container">
|
|
168
|
+
<TextareaControl
|
|
169
|
+
className="wp-block-image__toolbar_content_textarea"
|
|
170
|
+
label={ __( 'Alternative text' ) }
|
|
171
|
+
value={ attributes.alt || '' }
|
|
172
|
+
onChange={ ( value ) =>
|
|
173
|
+
setAttributes( { alt: value } )
|
|
174
|
+
}
|
|
175
|
+
disabled={ lockAltControls }
|
|
176
|
+
help={
|
|
177
|
+
lockAltControls ? (
|
|
178
|
+
<>{ lockAltControlsMessage }</>
|
|
179
|
+
) : (
|
|
180
|
+
<>
|
|
181
|
+
<ExternalLink
|
|
182
|
+
href={
|
|
183
|
+
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
184
|
+
__(
|
|
185
|
+
'https://www.w3.org/WAI/tutorials/images/decision-tree/'
|
|
186
|
+
)
|
|
187
|
+
}
|
|
188
|
+
>
|
|
189
|
+
{ __(
|
|
190
|
+
'Describe the purpose of the image.'
|
|
191
|
+
) }
|
|
192
|
+
</ExternalLink>
|
|
193
|
+
<br />
|
|
194
|
+
{ __( 'Leave empty if decorative.' ) }
|
|
195
|
+
</>
|
|
196
|
+
)
|
|
197
|
+
}
|
|
198
|
+
__nextHasNoMarginBottom
|
|
199
|
+
/>
|
|
200
|
+
</div>
|
|
201
|
+
</Popover>
|
|
202
|
+
) }
|
|
203
|
+
{ isTitleDialogOpen && (
|
|
204
|
+
<Popover
|
|
205
|
+
placement="bottom-start"
|
|
206
|
+
anchor={ popoverAnchor }
|
|
207
|
+
onClose={ () => setIsTitleDialogOpen( false ) }
|
|
208
|
+
offset={ 13 }
|
|
209
|
+
variant="toolbar"
|
|
210
|
+
>
|
|
211
|
+
<div className="wp-block-image__toolbar_content_textarea__container">
|
|
212
|
+
<TextControl
|
|
213
|
+
__next40pxDefaultSize
|
|
214
|
+
className="wp-block-image__toolbar_content_textarea"
|
|
215
|
+
__nextHasNoMarginBottom
|
|
216
|
+
label={ __( 'Title attribute' ) }
|
|
217
|
+
value={ attributes.title || '' }
|
|
218
|
+
onChange={ ( value ) =>
|
|
219
|
+
setAttributes( {
|
|
220
|
+
title: value,
|
|
221
|
+
} )
|
|
222
|
+
}
|
|
223
|
+
disabled={ lockTitleControls }
|
|
224
|
+
help={
|
|
225
|
+
lockTitleControls ? (
|
|
226
|
+
<>{ lockTitleControlsMessage }</>
|
|
227
|
+
) : (
|
|
228
|
+
<>
|
|
229
|
+
{ __(
|
|
230
|
+
'Describe the role of this image on the page.'
|
|
231
|
+
) }
|
|
232
|
+
<ExternalLink href="https://www.w3.org/TR/html52/dom.html#the-title-attribute">
|
|
233
|
+
{ __(
|
|
234
|
+
'(Note: many devices and browsers do not display this text.)'
|
|
235
|
+
) }
|
|
236
|
+
</ExternalLink>
|
|
237
|
+
</>
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
/>
|
|
241
|
+
</div>
|
|
242
|
+
</Popover>
|
|
243
|
+
) }
|
|
244
|
+
</>
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
|
|
97
248
|
export default function Image( {
|
|
98
249
|
temporaryURL,
|
|
99
250
|
attributes,
|
|
@@ -625,112 +776,15 @@ export default function Image( {
|
|
|
625
776
|
// Add some extra controls for content attributes when content only mode is active.
|
|
626
777
|
// With content only mode active, the inspector is hidden, so users need another way
|
|
627
778
|
// to edit these attributes.
|
|
628
|
-
<BlockControls group="
|
|
629
|
-
<
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
onKeyDown={ ( event ) => {
|
|
637
|
-
if ( ! isOpen && event.keyCode === DOWN ) {
|
|
638
|
-
event.preventDefault();
|
|
639
|
-
onToggle();
|
|
640
|
-
}
|
|
641
|
-
} }
|
|
642
|
-
>
|
|
643
|
-
{ _x(
|
|
644
|
-
'Alternative text',
|
|
645
|
-
'Alternative text for an image. Block toolbar label, a low character count is preferred.'
|
|
646
|
-
) }
|
|
647
|
-
</ToolbarButton>
|
|
648
|
-
) }
|
|
649
|
-
renderContent={ () => (
|
|
650
|
-
<TextareaControl
|
|
651
|
-
className="wp-block-image__toolbar_content_textarea"
|
|
652
|
-
label={ __( 'Alternative text' ) }
|
|
653
|
-
value={ alt || '' }
|
|
654
|
-
onChange={ updateAlt }
|
|
655
|
-
disabled={ lockAltControls }
|
|
656
|
-
help={
|
|
657
|
-
lockAltControls ? (
|
|
658
|
-
<>{ lockAltControlsMessage }</>
|
|
659
|
-
) : (
|
|
660
|
-
<>
|
|
661
|
-
<ExternalLink
|
|
662
|
-
href={
|
|
663
|
-
// translators: Localized tutorial, if one exists. W3C Web Accessibility Initiative link has list of existing translations.
|
|
664
|
-
__(
|
|
665
|
-
'https://www.w3.org/WAI/tutorials/images/decision-tree/'
|
|
666
|
-
)
|
|
667
|
-
}
|
|
668
|
-
>
|
|
669
|
-
{ __(
|
|
670
|
-
'Describe the purpose of the image.'
|
|
671
|
-
) }
|
|
672
|
-
</ExternalLink>
|
|
673
|
-
<br />
|
|
674
|
-
{ __(
|
|
675
|
-
'Leave empty if decorative.'
|
|
676
|
-
) }
|
|
677
|
-
</>
|
|
678
|
-
)
|
|
679
|
-
}
|
|
680
|
-
__nextHasNoMarginBottom
|
|
681
|
-
/>
|
|
682
|
-
) }
|
|
779
|
+
<BlockControls group="block">
|
|
780
|
+
<ContentOnlyControls
|
|
781
|
+
attributes={ attributes }
|
|
782
|
+
setAttributes={ setAttributes }
|
|
783
|
+
lockAltControls={ lockAltControls }
|
|
784
|
+
lockAltControlsMessage={ lockAltControlsMessage }
|
|
785
|
+
lockTitleControls={ lockTitleControls }
|
|
786
|
+
lockTitleControlsMessage={ lockTitleControlsMessage }
|
|
683
787
|
/>
|
|
684
|
-
{ title && (
|
|
685
|
-
<Dropdown
|
|
686
|
-
popoverProps={ { position: 'bottom right' } }
|
|
687
|
-
renderToggle={ ( { isOpen, onToggle } ) => (
|
|
688
|
-
<ToolbarButton
|
|
689
|
-
onClick={ onToggle }
|
|
690
|
-
aria-haspopup="true"
|
|
691
|
-
aria-expanded={ isOpen }
|
|
692
|
-
onKeyDown={ ( event ) => {
|
|
693
|
-
if (
|
|
694
|
-
! isOpen &&
|
|
695
|
-
event.keyCode === DOWN
|
|
696
|
-
) {
|
|
697
|
-
event.preventDefault();
|
|
698
|
-
onToggle();
|
|
699
|
-
}
|
|
700
|
-
} }
|
|
701
|
-
>
|
|
702
|
-
{ __( 'Title' ) }
|
|
703
|
-
</ToolbarButton>
|
|
704
|
-
) }
|
|
705
|
-
renderContent={ () => (
|
|
706
|
-
<TextControl
|
|
707
|
-
__next40pxDefaultSize
|
|
708
|
-
className="wp-block-image__toolbar_content_textarea"
|
|
709
|
-
__nextHasNoMarginBottom
|
|
710
|
-
label={ __( 'Title attribute' ) }
|
|
711
|
-
value={ title || '' }
|
|
712
|
-
onChange={ onSetTitle }
|
|
713
|
-
disabled={ lockTitleControls }
|
|
714
|
-
help={
|
|
715
|
-
lockTitleControls ? (
|
|
716
|
-
<>{ lockTitleControlsMessage }</>
|
|
717
|
-
) : (
|
|
718
|
-
<>
|
|
719
|
-
{ __(
|
|
720
|
-
'Describe the role of this image on the page.'
|
|
721
|
-
) }
|
|
722
|
-
<ExternalLink href="https://www.w3.org/TR/html52/dom.html#the-title-attribute">
|
|
723
|
-
{ __(
|
|
724
|
-
'(Note: many devices and browsers do not display this text.)'
|
|
725
|
-
) }
|
|
726
|
-
</ExternalLink>
|
|
727
|
-
</>
|
|
728
|
-
)
|
|
729
|
-
}
|
|
730
|
-
/>
|
|
731
|
-
) }
|
|
732
|
-
/>
|
|
733
|
-
) }
|
|
734
788
|
</BlockControls>
|
|
735
789
|
) }
|
|
736
790
|
<InspectorControls>
|
|
@@ -842,6 +896,16 @@ export default function Image( {
|
|
|
842
896
|
const shadowProps = getShadowClassesAndStyles( attributes );
|
|
843
897
|
const isRounded = attributes.className?.includes( 'is-style-rounded' );
|
|
844
898
|
|
|
899
|
+
const { postType, postId, queryId } = context;
|
|
900
|
+
const isDescendentOfQueryLoop = Number.isFinite( queryId );
|
|
901
|
+
|
|
902
|
+
const [ , setFeaturedImage ] = useEntityProp(
|
|
903
|
+
'postType',
|
|
904
|
+
postType,
|
|
905
|
+
'featured_media',
|
|
906
|
+
postId
|
|
907
|
+
);
|
|
908
|
+
|
|
845
909
|
let img =
|
|
846
910
|
temporaryURL && hasImageErrored ? (
|
|
847
911
|
// Show a placeholder during upload when the blob URL can't be loaded. This can
|
|
@@ -1043,10 +1107,37 @@ export default function Image( {
|
|
|
1043
1107
|
);
|
|
1044
1108
|
}
|
|
1045
1109
|
|
|
1110
|
+
/**
|
|
1111
|
+
* Set the post's featured image with the current image.
|
|
1112
|
+
*/
|
|
1113
|
+
const setPostFeatureImage = () => {
|
|
1114
|
+
setFeaturedImage( id );
|
|
1115
|
+
createSuccessNotice( __( 'Post featured image updated.' ), {
|
|
1116
|
+
type: 'snackbar',
|
|
1117
|
+
} );
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
const featuredImageControl = (
|
|
1121
|
+
<BlockSettingsMenuControls>
|
|
1122
|
+
{ ( { selectedClientIds } ) =>
|
|
1123
|
+
selectedClientIds.length === 1 &&
|
|
1124
|
+
! isDescendentOfQueryLoop &&
|
|
1125
|
+
postId &&
|
|
1126
|
+
id &&
|
|
1127
|
+
clientId === selectedClientIds[ 0 ] && (
|
|
1128
|
+
<MenuItem onClick={ setPostFeatureImage }>
|
|
1129
|
+
{ __( 'Set featured image' ) }
|
|
1130
|
+
</MenuItem>
|
|
1131
|
+
)
|
|
1132
|
+
}
|
|
1133
|
+
</BlockSettingsMenuControls>
|
|
1134
|
+
);
|
|
1135
|
+
|
|
1046
1136
|
return (
|
|
1047
1137
|
<>
|
|
1048
1138
|
{ mediaReplaceFlow }
|
|
1049
1139
|
{ controls }
|
|
1140
|
+
{ featuredImageControl }
|
|
1050
1141
|
{ img }
|
|
1051
1142
|
|
|
1052
1143
|
<Caption
|
package/src/image/style.scss
CHANGED
|
@@ -12,7 +12,7 @@ exports[`Image block transformations to Columns block 1`] = `
|
|
|
12
12
|
|
|
13
13
|
exports[`Image block transformations to Cover block 1`] = `
|
|
14
14
|
"<!-- wp:cover {"url":"https://cldup.com/cXyG__fTLN.jpg","id":1,"dimRatio":50,"style":{"color":{}}} -->
|
|
15
|
-
<div class="wp-block-cover"><
|
|
15
|
+
<div class="wp-block-cover"><img class="wp-block-cover__image-background wp-image-1" alt="" src="https://cldup.com/cXyG__fTLN.jpg" data-object-fit="cover"/><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"align":"center","fontSize":"large"} -->
|
|
16
16
|
<p class="has-text-align-center has-large-font-size">Mountain</p>
|
|
17
17
|
<!-- /wp:paragraph --></div></div>
|
|
18
18
|
<!-- /wp:cover -->"
|
package/src/latest-posts/edit.js
CHANGED
|
@@ -238,7 +238,6 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
|
|
|
238
238
|
/>
|
|
239
239
|
{ displayPostContent && (
|
|
240
240
|
<RadioControl
|
|
241
|
-
className="wp-block-latest-posts__post-content-radio"
|
|
242
241
|
label={ __( 'Show' ) }
|
|
243
242
|
selected={ displayPostContentRadio }
|
|
244
243
|
options={ [
|
|
@@ -18,14 +18,3 @@
|
|
|
18
18
|
padding-left: 0;
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
// Apply the same styles that would be applied to
|
|
23
|
-
// ".block-editor-block-inspector .components-base-control"
|
|
24
|
-
// (see packages/block-editor/src/components/block-inspector/style.scss)
|
|
25
|
-
.wp-block-latest-posts__post-content-radio {
|
|
26
|
-
margin-bottom: #{ $grid-unit-30 };
|
|
27
|
-
|
|
28
|
-
&:last-child {
|
|
29
|
-
margin-bottom: $grid-unit-10;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
@@ -14,7 +14,7 @@ exports[`Media & Text block transformations with Image to Columns block 1`] = `
|
|
|
14
14
|
|
|
15
15
|
exports[`Media & Text block transformations with Image to Cover block 1`] = `
|
|
16
16
|
"<!-- wp:cover {"url":"https://cldup.com/cXyG__fTLN.jpg","id":4674,"dimRatio":50,"align":"wide"} -->
|
|
17
|
-
<div class="wp-block-cover alignwide"><
|
|
17
|
+
<div class="wp-block-cover alignwide"><img class="wp-block-cover__image-background wp-image-4674" alt="" src="https://cldup.com/cXyG__fTLN.jpg" data-object-fit="cover"/><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"className":"has-large-font-size"} -->
|
|
18
18
|
<p class="has-large-font-size">Mountain</p>
|
|
19
19
|
<!-- /wp:paragraph --></div></div>
|
|
20
20
|
<!-- /wp:cover -->"
|
|
@@ -50,7 +50,7 @@ exports[`Media & Text block transformations with Video to Columns block 1`] = `
|
|
|
50
50
|
|
|
51
51
|
exports[`Media & Text block transformations with Video to Cover block 1`] = `
|
|
52
52
|
"<!-- wp:cover {"url":"https://i.cloudup.com/YtZFJbuQCE.mov","id":4675,"dimRatio":50,"backgroundType":"video","align":"wide"} -->
|
|
53
|
-
<div class="wp-block-cover alignwide"><
|
|
53
|
+
<div class="wp-block-cover alignwide"><video class="wp-block-cover__video-background intrinsic-ignore" autoplay muted loop playsinline src="https://i.cloudup.com/YtZFJbuQCE.mov" data-object-fit="cover"></video><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><div class="wp-block-cover__inner-container"><!-- wp:paragraph {"className":"has-large-font-size"} -->
|
|
54
54
|
<p class="has-large-font-size">Cloudup</p>
|
|
55
55
|
<!-- /wp:paragraph --></div></div>
|
|
56
56
|
<!-- /wp:cover -->"
|