@wordpress/block-library 9.7.0 → 9.7.1-next.1f6eadc42.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/archives/edit.js +1 -1
- package/build/archives/edit.js.map +1 -1
- package/build/block/edit.js +2 -3
- package/build/block/edit.js.map +1 -1
- package/build/buttons/index.js +1 -1
- package/build/comments/edit/comments-legacy.js +2 -4
- package/build/comments/edit/comments-legacy.js.map +1 -1
- package/build/cover/deprecated.js +1 -1
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit/index.js +4 -2
- package/build/cover/edit/index.js.map +1 -1
- package/build/embed/edit.js +5 -11
- package/build/embed/edit.js.map +1 -1
- package/build/embed/embed-placeholder.js +4 -8
- package/build/embed/embed-placeholder.js.map +1 -1
- package/build/embed/embed-preview.js +16 -4
- package/build/embed/embed-preview.js.map +1 -1
- package/build/file/transforms.js +18 -4
- package/build/file/transforms.js.map +1 -1
- package/build/form-input/deprecated.js +113 -1
- package/build/form-input/deprecated.js.map +1 -1
- package/build/form-input/edit.js +16 -12
- package/build/form-input/edit.js.map +1 -1
- package/build/form-input/save.js +9 -1
- package/build/form-input/save.js.map +1 -1
- package/build/freeform/modal.js +6 -12
- package/build/freeform/modal.js.map +1 -1
- package/build/image/edit.js +55 -15
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +23 -20
- package/build/image/image.js.map +1 -1
- package/build/image/transforms.js +0 -13
- package/build/image/transforms.js.map +1 -1
- package/build/image/use-max-width-observer.js +35 -0
- package/build/image/use-max-width-observer.js.map +1 -0
- package/build/image/utils.js +11 -0
- package/build/image/utils.js.map +1 -1
- package/build/latest-posts/edit.js +1 -1
- package/build/latest-posts/edit.js.map +1 -1
- package/build/missing/edit.js +2 -4
- package/build/missing/edit.js.map +1 -1
- package/build/navigation/edit/deleted-navigation-warning.js +14 -10
- package/build/navigation/edit/deleted-navigation-warning.js.map +1 -1
- package/build/navigation/edit/index.js +2 -4
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +2 -1
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation/edit/navigation-menu-delete-control.js +2 -4
- package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +2 -4
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +4 -8
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation-link/link-ui.js +2 -4
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +4 -8
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/edit.js +2 -4
- package/build/page-list/edit.js.map +1 -1
- package/build/post-comments-form/form.js +2 -4
- package/build/post-comments-form/form.js.map +1 -1
- package/build/post-featured-image/edit.js +2 -4
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-title/index.js +4 -1
- package/build/post-title/index.js.map +1 -1
- package/build/query/edit/enhanced-pagination-modal.js +4 -6
- package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js +3 -3
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +2 -10
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +9 -3
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/edit/query-placeholder.js +4 -8
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/site-logo/edit.js +4 -8
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-title/index.js +4 -1
- package/build/site-title/index.js.map +1 -1
- package/build/social-link/edit.js +1 -1
- package/build/social-link/edit.js.map +1 -1
- package/build/template-part/edit/inner-blocks.js +10 -1
- package/build/template-part/edit/inner-blocks.js.map +1 -1
- package/build/template-part/edit/placeholder.js +4 -8
- package/build/template-part/edit/placeholder.js.map +1 -1
- package/build/video/edit.js +4 -8
- package/build/video/edit.js.map +1 -1
- package/build/video/tracks-editor.js +6 -12
- package/build/video/tracks-editor.js.map +1 -1
- package/build-module/archives/edit.js +1 -1
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/block/edit.js +2 -3
- package/build-module/block/edit.js.map +1 -1
- package/build-module/buttons/index.js +1 -1
- package/build-module/comments/edit/comments-legacy.js +2 -4
- package/build-module/comments/edit/comments-legacy.js.map +1 -1
- package/build-module/cover/deprecated.js +1 -1
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit/index.js +4 -2
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/embed/edit.js +6 -12
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/embed/embed-placeholder.js +4 -8
- package/build-module/embed/embed-placeholder.js.map +1 -1
- package/build-module/embed/embed-preview.js +16 -4
- package/build-module/embed/embed-preview.js.map +1 -1
- package/build-module/file/transforms.js +18 -4
- package/build-module/file/transforms.js.map +1 -1
- package/build-module/form-input/deprecated.js +114 -2
- package/build-module/form-input/deprecated.js.map +1 -1
- package/build-module/form-input/edit.js +16 -12
- package/build-module/form-input/edit.js.map +1 -1
- package/build-module/form-input/save.js +9 -1
- package/build-module/form-input/save.js.map +1 -1
- package/build-module/freeform/modal.js +6 -12
- package/build-module/freeform/modal.js.map +1 -1
- package/build-module/image/edit.js +58 -18
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +23 -20
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/transforms.js +0 -13
- package/build-module/image/transforms.js.map +1 -1
- package/build-module/image/use-max-width-observer.js +29 -0
- package/build-module/image/use-max-width-observer.js.map +1 -0
- package/build-module/image/utils.js +11 -1
- package/build-module/image/utils.js.map +1 -1
- package/build-module/latest-posts/edit.js +1 -1
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/missing/edit.js +2 -4
- package/build-module/missing/edit.js.map +1 -1
- package/build-module/navigation/edit/deleted-navigation-warning.js +15 -11
- package/build-module/navigation/edit/deleted-navigation-warning.js.map +1 -1
- package/build-module/navigation/edit/index.js +2 -4
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +2 -1
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-delete-control.js +2 -4
- package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +2 -4
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +4 -8
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +2 -4
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +4 -8
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/edit.js +2 -4
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +2 -4
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/post-featured-image/edit.js +2 -4
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-title/index.js +4 -1
- package/build-module/post-title/index.js.map +1 -1
- package/build-module/query/edit/enhanced-pagination-modal.js +4 -6
- package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +3 -3
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +2 -10
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +10 -4
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +4 -8
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/site-logo/edit.js +4 -8
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-title/index.js +4 -1
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-link/edit.js +1 -1
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/template-part/edit/inner-blocks.js +10 -1
- package/build-module/template-part/edit/inner-blocks.js.map +1 -1
- package/build-module/template-part/edit/placeholder.js +4 -8
- package/build-module/template-part/edit/placeholder.js.map +1 -1
- package/build-module/video/edit.js +4 -8
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/tracks-editor.js +6 -12
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/buttons/editor-rtl.css +2 -2
- package/build-style/buttons/editor.css +2 -2
- package/build-style/buttons/style-rtl.css +2 -2
- package/build-style/buttons/style.css +2 -2
- package/build-style/common-rtl.css +2 -2
- package/build-style/common.css +2 -2
- package/build-style/editor-rtl.css +11 -31
- package/build-style/editor.css +11 -31
- package/build-style/form-input/style-rtl.css +7 -8
- package/build-style/form-input/style.css +7 -8
- package/build-style/image/editor-rtl.css +6 -26
- package/build-style/image/editor.css +6 -26
- package/build-style/navigation/editor-rtl.css +1 -1
- package/build-style/navigation/editor.css +1 -1
- package/build-style/post-title/style-rtl.css +21 -0
- package/build-style/post-title/style.css +21 -0
- package/build-style/site-title/style-rtl.css +21 -0
- package/build-style/site-title/style.css +21 -0
- package/build-style/style-rtl.css +53 -12
- package/build-style/style.css +53 -12
- package/package.json +42 -35
- package/src/archives/edit.js +1 -1
- package/src/block/edit.js +3 -7
- package/src/buttons/block.json +1 -1
- package/src/buttons/editor.scss +2 -2
- package/src/buttons/style.scss +2 -2
- package/src/comments/edit/comments-legacy.js +1 -2
- package/src/cover/deprecated.js +3 -2
- package/src/cover/edit/index.js +5 -1
- package/src/embed/edit.js +0 -7
- package/src/embed/embed-placeholder.js +2 -4
- package/src/embed/embed-preview.js +22 -2
- package/src/file/index.php +1 -1
- package/src/file/transforms.js +26 -6
- package/src/form-input/deprecated.js +114 -1
- package/src/form-input/edit.js +17 -11
- package/src/form-input/save.js +13 -3
- package/src/form-input/style.scss +9 -8
- package/src/freeform/modal.js +3 -6
- package/src/image/edit.js +91 -20
- package/src/image/editor.scss +7 -38
- package/src/image/image.js +31 -20
- package/src/image/index.php +1 -1
- package/src/image/transforms.js +0 -23
- package/src/image/use-max-width-observer.js +32 -0
- package/src/image/utils.js +13 -1
- package/src/latest-posts/edit.js +1 -1
- package/src/missing/edit.js +1 -2
- package/src/navigation/edit/deleted-navigation-warning.js +23 -20
- package/src/navigation/edit/index.js +1 -2
- package/src/navigation/edit/menu-inspector-controls.js +3 -1
- package/src/navigation/edit/navigation-menu-delete-control.js +1 -2
- package/src/navigation/edit/placeholder/index.js +1 -2
- package/src/navigation/edit/responsive-wrapper.js +2 -4
- package/src/navigation/editor.scss +5 -1
- package/src/navigation/index.php +1 -1
- package/src/navigation-link/link-ui.js +1 -2
- package/src/page-list/convert-to-links-modal.js +2 -4
- package/src/page-list/edit.js +1 -2
- package/src/post-comments-form/form.js +1 -2
- package/src/post-featured-image/edit.js +1 -2
- package/src/post-title/block.json +4 -1
- package/src/post-title/style.scss +24 -0
- package/src/query/edit/enhanced-pagination-modal.js +3 -4
- package/src/query/edit/inspector-controls/enhanced-pagination-control.js +3 -3
- package/src/query/edit/inspector-controls/index.js +2 -9
- package/src/query/edit/query-content.js +7 -0
- package/src/query/edit/query-placeholder.js +2 -4
- package/src/query/index.php +1 -1
- package/src/search/index.php +1 -1
- package/src/site-logo/edit.js +2 -4
- package/src/site-title/block.json +4 -1
- package/src/site-title/style.scss +24 -0
- package/src/social-link/edit.js +1 -1
- package/src/template-part/edit/inner-blocks.js +20 -1
- package/src/template-part/edit/placeholder.js +2 -4
- package/src/video/edit.js +2 -4
- package/src/video/tracks-editor.js +3 -6
package/src/image/edit.js
CHANGED
|
@@ -6,14 +6,14 @@ import clsx from 'clsx';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { isBlobURL } from '@wordpress/blob';
|
|
10
|
-
import { store as blocksStore } from '@wordpress/blocks';
|
|
9
|
+
import { isBlobURL, createBlobURL } from '@wordpress/blob';
|
|
10
|
+
import { store as blocksStore, createBlock } from '@wordpress/blocks';
|
|
11
11
|
import { Placeholder } from '@wordpress/components';
|
|
12
12
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
13
|
import {
|
|
14
14
|
BlockIcon,
|
|
15
|
-
MediaPlaceholder,
|
|
16
15
|
useBlockProps,
|
|
16
|
+
MediaPlaceholder,
|
|
17
17
|
store as blockEditorStore,
|
|
18
18
|
__experimentalUseBorderProps as useBorderProps,
|
|
19
19
|
__experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,
|
|
@@ -31,6 +31,8 @@ import { useResizeObserver } from '@wordpress/compose';
|
|
|
31
31
|
import { unlock } from '../lock-unlock';
|
|
32
32
|
import { useUploadMediaFromBlobURL } from '../utils/hooks';
|
|
33
33
|
import Image from './image';
|
|
34
|
+
import { isValidFileType } from './utils';
|
|
35
|
+
import { useMaxWidthObserver } from './use-max-width-observer';
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* Module constants
|
|
@@ -108,11 +110,23 @@ export function ImageEdit( {
|
|
|
108
110
|
align,
|
|
109
111
|
metadata,
|
|
110
112
|
} = attributes;
|
|
113
|
+
|
|
111
114
|
const [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );
|
|
112
115
|
|
|
113
|
-
const
|
|
116
|
+
const containerRef = useRef();
|
|
117
|
+
// Only observe the max width from the parent container when the parent layout is not flex nor grid.
|
|
118
|
+
// This won't work for them because the container width changes with the image.
|
|
119
|
+
// TODO: Find a way to observe the container width for flex and grid layouts.
|
|
120
|
+
const isMaxWidthContainerWidth =
|
|
121
|
+
! parentLayout ||
|
|
122
|
+
( parentLayout.type !== 'flex' && parentLayout.type !== 'grid' );
|
|
123
|
+
const [ maxWidthObserver, maxContentWidth ] = useMaxWidthObserver();
|
|
124
|
+
|
|
125
|
+
const [ placeholderResizeListener, { width: placeholderWidth } ] =
|
|
114
126
|
useResizeObserver();
|
|
115
127
|
|
|
128
|
+
const isSmallContainer = placeholderWidth && placeholderWidth < 160;
|
|
129
|
+
|
|
116
130
|
const altRef = useRef();
|
|
117
131
|
useEffect( () => {
|
|
118
132
|
altRef.current = alt;
|
|
@@ -123,7 +137,7 @@ export function ImageEdit( {
|
|
|
123
137
|
captionRef.current = caption;
|
|
124
138
|
}, [ caption ] );
|
|
125
139
|
|
|
126
|
-
const { __unstableMarkNextChangeAsNotPersistent } =
|
|
140
|
+
const { __unstableMarkNextChangeAsNotPersistent, replaceBlock } =
|
|
127
141
|
useDispatch( blockEditorStore );
|
|
128
142
|
|
|
129
143
|
useEffect( () => {
|
|
@@ -138,7 +152,12 @@ export function ImageEdit( {
|
|
|
138
152
|
}
|
|
139
153
|
}, [ __unstableMarkNextChangeAsNotPersistent, align, setAttributes ] );
|
|
140
154
|
|
|
141
|
-
const {
|
|
155
|
+
const {
|
|
156
|
+
getSettings,
|
|
157
|
+
getBlockRootClientId,
|
|
158
|
+
getBlockName,
|
|
159
|
+
canInsertBlockType,
|
|
160
|
+
} = useSelect( blockEditorStore );
|
|
142
161
|
const blockEditingMode = useBlockEditingMode();
|
|
143
162
|
|
|
144
163
|
const { createErrorNotice } = useDispatch( noticesStore );
|
|
@@ -152,7 +171,52 @@ export function ImageEdit( {
|
|
|
152
171
|
} );
|
|
153
172
|
}
|
|
154
173
|
|
|
174
|
+
function onSelectImagesList( images ) {
|
|
175
|
+
const win = containerRef.current?.ownerDocument.defaultView;
|
|
176
|
+
|
|
177
|
+
if ( images.every( ( file ) => file instanceof win.File ) ) {
|
|
178
|
+
/** @type {File[]} */
|
|
179
|
+
const files = images;
|
|
180
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
181
|
+
|
|
182
|
+
if ( files.some( ( file ) => ! isValidFileType( file ) ) ) {
|
|
183
|
+
// Copied from the same notice in the gallery block.
|
|
184
|
+
createErrorNotice(
|
|
185
|
+
__(
|
|
186
|
+
'If uploading to a gallery all files need to be image formats'
|
|
187
|
+
),
|
|
188
|
+
{ id: 'gallery-upload-invalid-file', type: 'snackbar' }
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const imageBlocks = files
|
|
193
|
+
.filter( ( file ) => isValidFileType( file ) )
|
|
194
|
+
.map( ( file ) =>
|
|
195
|
+
createBlock( 'core/image', {
|
|
196
|
+
blob: createBlobURL( file ),
|
|
197
|
+
} )
|
|
198
|
+
);
|
|
199
|
+
|
|
200
|
+
if ( getBlockName( rootClientId ) === 'core/gallery' ) {
|
|
201
|
+
replaceBlock( clientId, imageBlocks );
|
|
202
|
+
} else if ( canInsertBlockType( 'core/gallery', rootClientId ) ) {
|
|
203
|
+
const galleryBlock = createBlock(
|
|
204
|
+
'core/gallery',
|
|
205
|
+
{},
|
|
206
|
+
imageBlocks
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
replaceBlock( clientId, galleryBlock );
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
155
214
|
function onSelectImage( media ) {
|
|
215
|
+
if ( Array.isArray( media ) ) {
|
|
216
|
+
onSelectImagesList( media );
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
|
|
156
220
|
if ( ! media || ! media.url ) {
|
|
157
221
|
setAttributes( {
|
|
158
222
|
url: undefined,
|
|
@@ -296,7 +360,10 @@ export function ImageEdit( {
|
|
|
296
360
|
Object.keys( borderProps.style ).length > 0 ),
|
|
297
361
|
} );
|
|
298
362
|
|
|
299
|
-
const blockProps = useBlockProps( {
|
|
363
|
+
const blockProps = useBlockProps( {
|
|
364
|
+
ref: containerRef,
|
|
365
|
+
className: classes,
|
|
366
|
+
} );
|
|
300
367
|
|
|
301
368
|
// Much of this description is duplicated from MediaPlaceholder.
|
|
302
369
|
const { lockUrlControls = false, lockUrlControlsMessage } = useSelect(
|
|
@@ -335,13 +402,17 @@ export function ImageEdit( {
|
|
|
335
402
|
[ borderProps.className ]:
|
|
336
403
|
!! borderProps.className && ! isSingleSelected,
|
|
337
404
|
} ) }
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
405
|
+
icon={
|
|
406
|
+
! isSmallContainer &&
|
|
407
|
+
( lockUrlControls ? pluginsIcon : icon )
|
|
408
|
+
}
|
|
409
|
+
withIllustration={ ! isSingleSelected || isSmallContainer }
|
|
410
|
+
label={ ! isSmallContainer && __( 'Image' ) }
|
|
341
411
|
instructions={
|
|
342
412
|
! lockUrlControls &&
|
|
413
|
+
! isSmallContainer &&
|
|
343
414
|
__(
|
|
344
|
-
'Upload an image file, pick one from your
|
|
415
|
+
'Upload or drag an image file here, or pick one from your library.'
|
|
345
416
|
)
|
|
346
417
|
}
|
|
347
418
|
style={ {
|
|
@@ -356,13 +427,12 @@ export function ImageEdit( {
|
|
|
356
427
|
...shadowProps.style,
|
|
357
428
|
} }
|
|
358
429
|
>
|
|
359
|
-
{ lockUrlControls
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
) }
|
|
430
|
+
{ lockUrlControls &&
|
|
431
|
+
! isSmallContainer &&
|
|
432
|
+
lockUrlControlsMessage }
|
|
433
|
+
|
|
434
|
+
{ ! lockUrlControls && ! isSmallContainer && content }
|
|
435
|
+
{ placeholderResizeListener }
|
|
366
436
|
</Placeholder>
|
|
367
437
|
);
|
|
368
438
|
};
|
|
@@ -384,7 +454,7 @@ export function ImageEdit( {
|
|
|
384
454
|
clientId={ clientId }
|
|
385
455
|
blockEditingMode={ blockEditingMode }
|
|
386
456
|
parentLayoutType={ parentLayout?.type }
|
|
387
|
-
|
|
457
|
+
maxContentWidth={ maxContentWidth }
|
|
388
458
|
/>
|
|
389
459
|
<MediaPlaceholder
|
|
390
460
|
icon={ <BlockIcon icon={ icon } /> }
|
|
@@ -394,6 +464,7 @@ export function ImageEdit( {
|
|
|
394
464
|
placeholder={ placeholder }
|
|
395
465
|
accept="image/*"
|
|
396
466
|
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
467
|
+
handleUpload={ ( files ) => files.length === 1 }
|
|
397
468
|
value={ { id, src } }
|
|
398
469
|
mediaPreview={ mediaPreview }
|
|
399
470
|
disableMediaButtons={ temporaryURL || url }
|
|
@@ -402,7 +473,7 @@ export function ImageEdit( {
|
|
|
402
473
|
{
|
|
403
474
|
// The listener cannot be placed as the first element as it will break the in-between inserter.
|
|
404
475
|
// See https://github.com/WordPress/gutenberg/blob/71134165868298fc15e22896d0c28b41b3755ff7/packages/block-editor/src/components/block-list/use-in-between-inserter.js#L120
|
|
405
|
-
|
|
476
|
+
isSingleSelected && isMaxWidthContainerWidth && maxWidthObserver
|
|
406
477
|
}
|
|
407
478
|
</>
|
|
408
479
|
);
|
package/src/image/editor.scss
CHANGED
|
@@ -1,44 +1,8 @@
|
|
|
1
1
|
// Provide special styling for the placeholder.
|
|
2
2
|
// @todo this particular minimal style of placeholder could be componentized further.
|
|
3
3
|
.wp-block-image.wp-block-image {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
&.is-selected .block-editor-media-placeholder {
|
|
7
|
-
// Block UI appearance.
|
|
8
|
-
color: $gray-900;
|
|
9
|
-
background-color: $white;
|
|
10
|
-
box-shadow: inset 0 0 0 $border-width $gray-900;
|
|
11
|
-
border: none;
|
|
12
|
-
|
|
13
|
-
// Disable any duotone filter applied in the selected state.
|
|
14
|
-
filter: none !important;
|
|
15
|
-
|
|
16
|
-
> svg {
|
|
17
|
-
opacity: 0;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
.components-placeholder__illustration {
|
|
21
|
-
display: none;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
&::before {
|
|
25
|
-
opacity: 0;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
.block-bindings-media-placeholder-message {
|
|
29
|
-
opacity: 0;
|
|
30
|
-
}
|
|
31
|
-
&.is-selected .block-bindings-media-placeholder-message {
|
|
32
|
-
opacity: 1;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Remove the transition while we still have a legacy placeholder style.
|
|
36
|
-
// Otherwise the content jumps between the 1px placeholder border, and any inherited custom
|
|
37
|
-
// parent border that may get applied when you deselect.
|
|
38
|
-
.components-placeholder__label,
|
|
39
|
-
.components-placeholder__instructions,
|
|
40
|
-
.components-button {
|
|
41
|
-
transition: none;
|
|
4
|
+
.block-editor-media-placeholder.is-small {
|
|
5
|
+
min-height: 60px;
|
|
42
6
|
}
|
|
43
7
|
}
|
|
44
8
|
|
|
@@ -149,6 +113,11 @@ figure.wp-block-image:not(.wp-block) {
|
|
|
149
113
|
text-align: center;
|
|
150
114
|
}
|
|
151
115
|
|
|
116
|
+
// Relatively position the alignment container to support the content resizer.
|
|
117
|
+
.wp-block[data-align]:has(> .wp-block-image) {
|
|
118
|
+
position: relative;
|
|
119
|
+
}
|
|
120
|
+
|
|
152
121
|
.wp-block-image__crop-area {
|
|
153
122
|
position: relative;
|
|
154
123
|
max-width: 100%;
|
package/src/image/image.js
CHANGED
|
@@ -108,7 +108,7 @@ export default function Image( {
|
|
|
108
108
|
clientId,
|
|
109
109
|
blockEditingMode,
|
|
110
110
|
parentLayoutType,
|
|
111
|
-
|
|
111
|
+
maxContentWidth,
|
|
112
112
|
} ) {
|
|
113
113
|
const {
|
|
114
114
|
url = '',
|
|
@@ -556,6 +556,24 @@ export default function Image( {
|
|
|
556
556
|
|
|
557
557
|
const showBlockControls = showUrlInput || allowCrop || showCoverControls;
|
|
558
558
|
|
|
559
|
+
const mediaReplaceFlow = isSingleSelected &&
|
|
560
|
+
! isEditingImage &&
|
|
561
|
+
! lockUrlControls && (
|
|
562
|
+
<BlockControls group="other">
|
|
563
|
+
<MediaReplaceFlow
|
|
564
|
+
mediaId={ id }
|
|
565
|
+
mediaURL={ url }
|
|
566
|
+
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
567
|
+
accept="image/*"
|
|
568
|
+
onSelect={ onSelectImage }
|
|
569
|
+
onSelectURL={ onSelectURL }
|
|
570
|
+
onError={ onUploadError }
|
|
571
|
+
name={ ! url ? __( 'Add image' ) : __( 'Replace' ) }
|
|
572
|
+
onReset={ () => onSelectImage( undefined ) }
|
|
573
|
+
/>
|
|
574
|
+
</BlockControls>
|
|
575
|
+
);
|
|
576
|
+
|
|
559
577
|
const controls = (
|
|
560
578
|
<>
|
|
561
579
|
{ showBlockControls && (
|
|
@@ -592,20 +610,6 @@ export default function Image( {
|
|
|
592
610
|
) }
|
|
593
611
|
</BlockControls>
|
|
594
612
|
) }
|
|
595
|
-
{ isSingleSelected && ! isEditingImage && ! lockUrlControls && (
|
|
596
|
-
<BlockControls group="other">
|
|
597
|
-
<MediaReplaceFlow
|
|
598
|
-
mediaId={ id }
|
|
599
|
-
mediaURL={ url }
|
|
600
|
-
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
601
|
-
accept="image/*"
|
|
602
|
-
onSelect={ onSelectImage }
|
|
603
|
-
onSelectURL={ onSelectURL }
|
|
604
|
-
onError={ onUploadError }
|
|
605
|
-
onReset={ () => onSelectImage( undefined ) }
|
|
606
|
-
/>
|
|
607
|
-
</BlockControls>
|
|
608
|
-
) }
|
|
609
613
|
{ isSingleSelected && externalBlob && (
|
|
610
614
|
<BlockControls>
|
|
611
615
|
<ToolbarGroup>
|
|
@@ -934,7 +938,7 @@ export default function Image( {
|
|
|
934
938
|
// @todo It would be good to revisit this once a content-width variable
|
|
935
939
|
// becomes available.
|
|
936
940
|
const maxWidthBuffer = maxWidth * 2.5;
|
|
937
|
-
const
|
|
941
|
+
const maxResizeWidth = maxContentWidth || maxWidthBuffer;
|
|
938
942
|
|
|
939
943
|
let showRightHandle = false;
|
|
940
944
|
let showLeftHandle = false;
|
|
@@ -980,9 +984,9 @@ export default function Image( {
|
|
|
980
984
|
} }
|
|
981
985
|
showHandle={ isSingleSelected }
|
|
982
986
|
minWidth={ minWidth }
|
|
983
|
-
maxWidth={
|
|
987
|
+
maxWidth={ maxResizeWidth }
|
|
984
988
|
minHeight={ minHeight }
|
|
985
|
-
maxHeight={
|
|
989
|
+
maxHeight={ maxResizeWidth / ratio }
|
|
986
990
|
lockAspectRatio={ ratio }
|
|
987
991
|
enable={ {
|
|
988
992
|
top: false,
|
|
@@ -996,6 +1000,7 @@ export default function Image( {
|
|
|
996
1000
|
|
|
997
1001
|
// Clear hardcoded width if the resized width is close to the max-content width.
|
|
998
1002
|
if (
|
|
1003
|
+
maxContentWidth &&
|
|
999
1004
|
// Only do this if the image is bigger than the container to prevent it from being squished.
|
|
1000
1005
|
// TODO: Remove this check if the image support setting 100% width.
|
|
1001
1006
|
naturalWidth >= maxContentWidth &&
|
|
@@ -1029,12 +1034,18 @@ export default function Image( {
|
|
|
1029
1034
|
}
|
|
1030
1035
|
|
|
1031
1036
|
if ( ! url && ! temporaryURL ) {
|
|
1032
|
-
|
|
1033
|
-
|
|
1037
|
+
return (
|
|
1038
|
+
<>
|
|
1039
|
+
{ mediaReplaceFlow }
|
|
1040
|
+
{ /* Add all controls if the image attributes are connected. */ }
|
|
1041
|
+
{ metadata?.bindings ? controls : sizeControls }
|
|
1042
|
+
</>
|
|
1043
|
+
);
|
|
1034
1044
|
}
|
|
1035
1045
|
|
|
1036
1046
|
return (
|
|
1037
1047
|
<>
|
|
1048
|
+
{ mediaReplaceFlow }
|
|
1038
1049
|
{ controls }
|
|
1039
1050
|
{ img }
|
|
1040
1051
|
|
package/src/image/index.php
CHANGED
|
@@ -72,7 +72,7 @@ function render_block_core_image( $attributes, $content, $block ) {
|
|
|
72
72
|
) {
|
|
73
73
|
$suffix = wp_scripts_get_suffix();
|
|
74
74
|
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
|
|
75
|
-
$module_url = gutenberg_url( '/build/
|
|
75
|
+
$module_url = gutenberg_url( '/build-module/block-library/image/view.min.js' );
|
|
76
76
|
}
|
|
77
77
|
|
|
78
78
|
wp_register_script_module(
|
package/src/image/transforms.js
CHANGED
|
@@ -3,9 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { createBlobURL, isBlobURL } from '@wordpress/blob';
|
|
5
5
|
import { createBlock, getBlockAttributes } from '@wordpress/blocks';
|
|
6
|
-
import { dispatch } from '@wordpress/data';
|
|
7
|
-
import { store as noticesStore } from '@wordpress/notices';
|
|
8
|
-
import { __ } from '@wordpress/i18n';
|
|
9
6
|
|
|
10
7
|
export function stripFirstImage( attributes, { shortcode } ) {
|
|
11
8
|
const { body } = document.implementation.createHTMLDocument( '' );
|
|
@@ -138,26 +135,6 @@ const transforms = {
|
|
|
138
135
|
// creating a new gallery.
|
|
139
136
|
type: 'files',
|
|
140
137
|
isMatch( files ) {
|
|
141
|
-
// The following check is intended to catch non-image files when dropped together with images.
|
|
142
|
-
if (
|
|
143
|
-
files.some(
|
|
144
|
-
( file ) => file.type.indexOf( 'image/' ) === 0
|
|
145
|
-
) &&
|
|
146
|
-
files.some(
|
|
147
|
-
( file ) => file.type.indexOf( 'image/' ) !== 0
|
|
148
|
-
)
|
|
149
|
-
) {
|
|
150
|
-
const { createErrorNotice } = dispatch( noticesStore );
|
|
151
|
-
createErrorNotice(
|
|
152
|
-
__(
|
|
153
|
-
'If uploading to a gallery all files need to be image formats'
|
|
154
|
-
),
|
|
155
|
-
{
|
|
156
|
-
id: 'gallery-transform-invalid-file',
|
|
157
|
-
type: 'snackbar',
|
|
158
|
-
}
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
138
|
return files.every(
|
|
162
139
|
( file ) => file.type.indexOf( 'image/' ) === 0
|
|
163
140
|
);
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRef } from '@wordpress/element';
|
|
5
|
+
import { useResizeObserver } from '@wordpress/compose';
|
|
6
|
+
|
|
7
|
+
function useMaxWidthObserver() {
|
|
8
|
+
const [ contentResizeListener, { width } ] = useResizeObserver();
|
|
9
|
+
const observerRef = useRef();
|
|
10
|
+
|
|
11
|
+
const maxWidthObserver = (
|
|
12
|
+
<div
|
|
13
|
+
// Some themes set max-width on blocks.
|
|
14
|
+
className="wp-block"
|
|
15
|
+
aria-hidden="true"
|
|
16
|
+
style={ {
|
|
17
|
+
position: 'absolute',
|
|
18
|
+
inset: 0,
|
|
19
|
+
width: '100%',
|
|
20
|
+
height: 0,
|
|
21
|
+
margin: 0,
|
|
22
|
+
} }
|
|
23
|
+
ref={ observerRef }
|
|
24
|
+
>
|
|
25
|
+
{ contentResizeListener }
|
|
26
|
+
</div>
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
return [ maxWidthObserver, width ];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export { useMaxWidthObserver };
|
package/src/image/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Internal dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { NEW_TAB_REL } from './constants';
|
|
4
|
+
import { NEW_TAB_REL, ALLOWED_MEDIA_TYPES } from './constants';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Evaluates a CSS aspect-ratio property value as a number.
|
|
@@ -81,3 +81,15 @@ export function getImageSizeAttributes( image, size ) {
|
|
|
81
81
|
|
|
82
82
|
return {};
|
|
83
83
|
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Checks if the file has a valid file type.
|
|
87
|
+
*
|
|
88
|
+
* @param {File} file - The file to check.
|
|
89
|
+
* @return {boolean} - Returns true if the file has a valid file type, otherwise false.
|
|
90
|
+
*/
|
|
91
|
+
export function isValidFileType( file ) {
|
|
92
|
+
return ALLOWED_MEDIA_TYPES.some(
|
|
93
|
+
( mediaType ) => file.type.indexOf( mediaType ) === 0
|
|
94
|
+
);
|
|
95
|
+
}
|
package/src/latest-posts/edit.js
CHANGED
|
@@ -243,7 +243,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
|
|
|
243
243
|
{ displayPostContent && (
|
|
244
244
|
<RadioControl
|
|
245
245
|
className="wp-block-latest-posts__post-content-radio"
|
|
246
|
-
label={ __( 'Show
|
|
246
|
+
label={ __( 'Show' ) }
|
|
247
247
|
selected={ displayPostContentRadio }
|
|
248
248
|
options={ [
|
|
249
249
|
{ label: __( 'Excerpt' ), value: 'excerpt' },
|
package/src/missing/edit.js
CHANGED
|
@@ -50,8 +50,7 @@ export default function MissingEdit( { attributes, clientId } ) {
|
|
|
50
50
|
|
|
51
51
|
const convertToHtmlButton = (
|
|
52
52
|
<Button
|
|
53
|
-
|
|
54
|
-
__next40pxDefaultSize={ false }
|
|
53
|
+
__next40pxDefaultSize
|
|
55
54
|
key="convert"
|
|
56
55
|
onClick={ convertToHTML }
|
|
57
56
|
variant="primary"
|
|
@@ -2,29 +2,32 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { Warning } from '@wordpress/block-editor';
|
|
5
|
-
import { Button } from '@wordpress/components';
|
|
5
|
+
import { Button, Notice } from '@wordpress/components';
|
|
6
6
|
import { __ } from '@wordpress/i18n';
|
|
7
7
|
import { createInterpolateElement } from '@wordpress/element';
|
|
8
8
|
|
|
9
|
-
function DeletedNavigationWarning( { onCreateNew } ) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
9
|
+
function DeletedNavigationWarning( { onCreateNew, isNotice = false } ) {
|
|
10
|
+
const message = createInterpolateElement(
|
|
11
|
+
__(
|
|
12
|
+
'Navigation Menu has been deleted or is unavailable. <button>Create a new Menu?</button>'
|
|
13
|
+
),
|
|
14
|
+
{
|
|
15
|
+
button: (
|
|
16
|
+
<Button
|
|
17
|
+
__next40pxDefaultSize
|
|
18
|
+
onClick={ onCreateNew }
|
|
19
|
+
variant="link"
|
|
20
|
+
/>
|
|
21
|
+
),
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
return isNotice ? (
|
|
26
|
+
<Notice status="warning" isDismissible={ false }>
|
|
27
|
+
{ message }
|
|
28
|
+
</Notice>
|
|
29
|
+
) : (
|
|
30
|
+
<Warning>{ message }</Warning>
|
|
28
31
|
);
|
|
29
32
|
}
|
|
30
33
|
|
|
@@ -591,8 +591,7 @@ function Navigation( {
|
|
|
591
591
|
{ isResponsive && (
|
|
592
592
|
<>
|
|
593
593
|
<Button
|
|
594
|
-
|
|
595
|
-
__next40pxDefaultSize={ false }
|
|
594
|
+
__next40pxDefaultSize
|
|
596
595
|
className={ overlayMenuPreviewClasses }
|
|
597
596
|
onClick={ () => {
|
|
598
597
|
setOverlayMenuPreview(
|
|
@@ -94,7 +94,9 @@ const MainContent = ( {
|
|
|
94
94
|
const { navigationMenu } = useNavigationMenu( currentMenuId );
|
|
95
95
|
|
|
96
96
|
if ( currentMenuId && isNavigationMenuMissing ) {
|
|
97
|
-
return
|
|
97
|
+
return (
|
|
98
|
+
<DeletedNavigationWarning onCreateNew={ onCreateNew } isNotice />
|
|
99
|
+
);
|
|
98
100
|
}
|
|
99
101
|
|
|
100
102
|
if ( isLoading ) {
|
|
@@ -19,8 +19,7 @@ export default function NavigationMenuDeleteControl( { onDelete } ) {
|
|
|
19
19
|
return (
|
|
20
20
|
<>
|
|
21
21
|
<Button
|
|
22
|
-
|
|
23
|
-
__next40pxDefaultSize={ false }
|
|
22
|
+
__next40pxDefaultSize
|
|
24
23
|
className="wp-block-navigation-delete-menu-button"
|
|
25
24
|
variant="secondary"
|
|
26
25
|
isDestructive
|
|
@@ -76,8 +76,7 @@ export default function NavigationPlaceholder( {
|
|
|
76
76
|
|
|
77
77
|
{ canUserCreateNavigationMenus && (
|
|
78
78
|
<Button
|
|
79
|
-
|
|
80
|
-
__next40pxDefaultSize={ false }
|
|
79
|
+
__next40pxDefaultSize
|
|
81
80
|
variant="tertiary"
|
|
82
81
|
onClick={ onCreateEmpty }
|
|
83
82
|
>
|
|
@@ -79,8 +79,7 @@ export default function ResponsiveWrapper( {
|
|
|
79
79
|
<>
|
|
80
80
|
{ ! isOpen && (
|
|
81
81
|
<Button
|
|
82
|
-
|
|
83
|
-
__next40pxDefaultSize={ false }
|
|
82
|
+
__next40pxDefaultSize
|
|
84
83
|
aria-haspopup="true"
|
|
85
84
|
aria-label={ hasIcon && __( 'Open menu' ) }
|
|
86
85
|
className={ openButtonClasses }
|
|
@@ -102,8 +101,7 @@ export default function ResponsiveWrapper( {
|
|
|
102
101
|
>
|
|
103
102
|
<div { ...dialogProps }>
|
|
104
103
|
<Button
|
|
105
|
-
|
|
106
|
-
__next40pxDefaultSize={ false }
|
|
104
|
+
__next40pxDefaultSize
|
|
107
105
|
className="wp-block-navigation__responsive-container-close"
|
|
108
106
|
aria-label={ hasIcon && __( 'Close menu' ) }
|
|
109
107
|
onClick={ () => onToggle( false ) }
|
|
@@ -563,7 +563,11 @@ body.editor-styles-wrapper .wp-block-navigation__responsive-container.is-menu-op
|
|
|
563
563
|
width: 100%;
|
|
564
564
|
background-color: $gray-100;
|
|
565
565
|
padding: 0 $grid-unit-30;
|
|
566
|
-
|
|
566
|
+
|
|
567
|
+
// Adding !important to override default 40px size.
|
|
568
|
+
// Ref - https://github.com/WordPress/gutenberg/pull/65075#discussion_r1746282734
|
|
569
|
+
height: $grid-unit-40 * 2 !important;
|
|
570
|
+
|
|
567
571
|
margin-bottom: $grid-unit-15;
|
|
568
572
|
|
|
569
573
|
&.open {
|
package/src/navigation/index.php
CHANGED
|
@@ -624,7 +624,7 @@ class WP_Navigation_Block_Renderer {
|
|
|
624
624
|
if ( static::is_interactive( $attributes, $inner_blocks ) ) {
|
|
625
625
|
$suffix = wp_scripts_get_suffix();
|
|
626
626
|
if ( defined( 'IS_GUTENBERG_PLUGIN' ) && IS_GUTENBERG_PLUGIN ) {
|
|
627
|
-
$module_url = gutenberg_url( '/build/
|
|
627
|
+
$module_url = gutenberg_url( '/build-module/block-library/navigation/view.min.js' );
|
|
628
628
|
}
|
|
629
629
|
|
|
630
630
|
wp_register_script_module(
|
|
@@ -310,8 +310,7 @@ const LinkUITools = ( { setAddingBlock, focusAddBlockButton } ) => {
|
|
|
310
310
|
return (
|
|
311
311
|
<VStack className="link-ui-tools">
|
|
312
312
|
<Button
|
|
313
|
-
|
|
314
|
-
__next40pxDefaultSize={ false }
|
|
313
|
+
__next40pxDefaultSize
|
|
315
314
|
ref={ addBlockButtonRef }
|
|
316
315
|
icon={ plus }
|
|
317
316
|
onClick={ ( e ) => {
|
|
@@ -32,16 +32,14 @@ export function ConvertToLinksModal( { onClick, onClose, disabled } ) {
|
|
|
32
32
|
</p>
|
|
33
33
|
<div className="wp-block-page-list-modal-buttons">
|
|
34
34
|
<Button
|
|
35
|
-
|
|
36
|
-
__next40pxDefaultSize={ false }
|
|
35
|
+
__next40pxDefaultSize
|
|
37
36
|
variant="tertiary"
|
|
38
37
|
onClick={ onClose }
|
|
39
38
|
>
|
|
40
39
|
{ __( 'Cancel' ) }
|
|
41
40
|
</Button>
|
|
42
41
|
<Button
|
|
43
|
-
|
|
44
|
-
__next40pxDefaultSize={ false }
|
|
42
|
+
__next40pxDefaultSize
|
|
45
43
|
variant="primary"
|
|
46
44
|
accessibleWhenDisabled
|
|
47
45
|
disabled={ disabled }
|
package/src/page-list/edit.js
CHANGED
|
@@ -342,8 +342,7 @@ export default function PageListEdit( {
|
|
|
342
342
|
<PanelBody title={ __( 'Edit this menu' ) }>
|
|
343
343
|
<p>{ convertDescription }</p>
|
|
344
344
|
<Button
|
|
345
|
-
|
|
346
|
-
__next40pxDefaultSize={ false }
|
|
345
|
+
__next40pxDefaultSize
|
|
347
346
|
variant="primary"
|
|
348
347
|
accessibleWhenDisabled
|
|
349
348
|
disabled={ ! hasResolvedPages }
|