@wordpress/block-library 9.26.0 → 9.27.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/button/edit.js +1 -1
- package/build/button/edit.js.map +1 -1
- package/build/cover/edit/block-controls.js +4 -2
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/cover/edit/index.js +6 -3
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +11 -4
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/edit/poster-image.js +81 -0
- package/build/cover/edit/poster-image.js.map +1 -0
- package/build/cover/index.js +6 -0
- package/build/cover/index.js.map +1 -1
- package/build/cover/save.js +3 -1
- package/build/cover/save.js.map +1 -1
- package/build/details/index.js +1 -1
- package/build/details/index.js.map +1 -1
- package/build/gallery/constants.js +2 -1
- package/build/gallery/constants.js.map +1 -1
- package/build/gallery/edit.js +93 -15
- package/build/gallery/edit.js.map +1 -1
- package/build/image/edit.js +6 -0
- package/build/image/edit.js.map +1 -1
- package/build/list/index.js +0 -1
- package/build/list/index.js.map +1 -1
- package/build/media-text/edit.js +2 -2
- package/build/media-text/edit.js.map +1 -1
- package/build/more/edit.native.js +17 -32
- package/build/more/edit.native.js.map +1 -1
- package/build/navigation-link/edit.js +49 -16
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/update-attributes.js +112 -14
- package/build/navigation-link/update-attributes.js.map +1 -1
- package/build/navigation-submenu/edit.js +19 -2
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/post-author/edit.js +78 -35
- package/build/post-author/edit.js.map +1 -1
- package/build/post-comments-form/form.js +1 -1
- package/build/post-comments-form/form.js.map +1 -1
- package/build/post-content/edit.js +78 -16
- package/build/post-content/edit.js.map +1 -1
- package/build/post-content/index.js +6 -0
- package/build/post-content/index.js.map +1 -1
- package/build/post-featured-image/edit.js +2 -1
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/search/edit.js +1 -1
- package/build/search/edit.js.map +1 -1
- package/build/separator/edit.js +5 -30
- package/build/separator/edit.js.map +1 -1
- package/build/site-logo/edit.js +16 -5
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-tagline/index.js +1 -1
- package/build/video/edit.js +2 -5
- package/build/video/edit.js.map +1 -1
- package/build/video/poster-image.js +25 -25
- package/build/video/poster-image.js.map +1 -1
- package/build/video/tracks-editor.js +95 -104
- package/build/video/tracks-editor.js.map +1 -1
- package/build/video/tracks.js +6 -2
- package/build/video/tracks.js.map +1 -1
- package/build-module/button/edit.js +1 -1
- package/build-module/button/edit.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +4 -2
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/cover/edit/index.js +6 -3
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +10 -4
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/edit/poster-image.js +74 -0
- package/build-module/cover/edit/poster-image.js.map +1 -0
- package/build-module/cover/index.js +6 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/save.js +3 -1
- package/build-module/cover/save.js.map +1 -1
- package/build-module/details/index.js +1 -1
- package/build-module/details/index.js.map +1 -1
- package/build-module/gallery/constants.js +1 -0
- package/build-module/gallery/constants.js.map +1 -1
- package/build-module/gallery/edit.js +95 -17
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/image/edit.js +6 -0
- package/build-module/image/edit.js.map +1 -1
- package/build-module/list/index.js +0 -1
- package/build-module/list/index.js.map +1 -1
- package/build-module/media-text/edit.js +2 -2
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/more/edit.native.js +16 -30
- package/build-module/more/edit.native.js.map +1 -1
- package/build-module/navigation-link/edit.js +50 -17
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/update-attributes.js +113 -15
- package/build-module/navigation-link/update-attributes.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +20 -3
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/post-author/edit.js +78 -35
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +1 -1
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/post-content/edit.js +80 -18
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-content/index.js +6 -0
- package/build-module/post-content/index.js.map +1 -1
- package/build-module/post-featured-image/edit.js +2 -1
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/search/edit.js +1 -1
- package/build-module/search/edit.js.map +1 -1
- package/build-module/separator/edit.js +6 -31
- package/build-module/separator/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +17 -6
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-tagline/index.js +1 -1
- package/build-module/video/edit.js +2 -5
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/poster-image.js +26 -26
- package/build-module/video/poster-image.js.map +1 -1
- package/build-module/video/tracks-editor.js +96 -105
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-module/video/tracks.js +6 -2
- package/build-module/video/tracks.js.map +1 -1
- package/build-style/archives/editor-rtl.css +0 -4
- package/build-style/archives/editor.css +0 -4
- package/build-style/editor-rtl.css +0 -21
- package/build-style/editor.css +0 -21
- package/build-style/file/style-rtl.css +1 -1
- package/build-style/file/style.css +1 -1
- package/build-style/gallery/editor-rtl.css +0 -13
- package/build-style/gallery/editor.css +0 -13
- package/build-style/navigation/style-rtl.css +2 -0
- package/build-style/navigation/style.css +2 -0
- package/build-style/style-rtl.css +3 -1
- package/build-style/style.css +3 -1
- package/build-style/video/editor-rtl.css +0 -4
- package/build-style/video/editor.css +0 -4
- package/package.json +35 -35
- package/src/archives/editor.scss +0 -4
- package/src/button/edit.js +1 -1
- package/src/comments-pagination/index.php +7 -2
- package/src/cover/block.json +6 -0
- package/src/cover/edit/block-controls.js +22 -17
- package/src/cover/edit/index.js +4 -1
- package/src/cover/edit/inspector-controls.js +12 -3
- package/src/cover/edit/poster-image.js +91 -0
- package/src/cover/save.js +2 -0
- package/src/details/index.js +1 -1
- package/src/file/style.scss +1 -1
- package/src/gallery/constants.js +1 -0
- package/src/gallery/edit.js +182 -68
- package/src/gallery/editor.scss +0 -17
- package/src/image/edit.js +12 -0
- package/src/list/block.json +0 -1
- package/src/media-text/edit.js +1 -1
- package/src/more/edit.native.js +19 -33
- package/src/navigation/style.scss +2 -0
- package/src/navigation-link/edit.js +46 -17
- package/src/navigation-link/test/edit.js +738 -6
- package/src/navigation-link/update-attributes.js +125 -12
- package/src/navigation-submenu/edit.js +21 -1
- package/src/post-author/edit.js +91 -40
- package/src/post-comments-form/form.js +1 -1
- package/src/post-content/block.json +6 -0
- package/src/post-content/edit.js +71 -19
- package/src/post-content/index.php +11 -4
- package/src/post-featured-image/edit.js +1 -0
- package/src/post-featured-image/index.php +3 -2
- package/src/rss/index.php +2 -1
- package/src/search/edit.js +1 -1
- package/src/separator/edit.js +8 -43
- package/src/site-logo/edit.js +22 -10
- package/src/site-tagline/block.json +1 -1
- package/src/video/edit.js +1 -4
- package/src/video/editor.scss +0 -6
- package/src/video/poster-image.js +29 -24
- package/src/video/tracks-editor.js +93 -103
- package/src/video/tracks.js +2 -1
package/src/gallery/edit.js
CHANGED
|
@@ -7,15 +7,15 @@ import clsx from 'clsx';
|
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
9
|
import {
|
|
10
|
-
BaseControl,
|
|
11
|
-
PanelBody,
|
|
12
10
|
SelectControl,
|
|
13
11
|
ToggleControl,
|
|
14
12
|
RangeControl,
|
|
15
|
-
Spinner,
|
|
16
13
|
MenuGroup,
|
|
17
14
|
MenuItem,
|
|
15
|
+
__experimentalToolsPanel as ToolsPanel,
|
|
16
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
18
17
|
ToolbarDropdownMenu,
|
|
18
|
+
PanelBody,
|
|
19
19
|
} from '@wordpress/components';
|
|
20
20
|
import {
|
|
21
21
|
store as blockEditorStore,
|
|
@@ -48,6 +48,7 @@ import {
|
|
|
48
48
|
import { sharedIcon } from './shared-icon';
|
|
49
49
|
import { defaultColumnsNumber, pickRelevantMediaFiles } from './shared';
|
|
50
50
|
import { getHrefAndDestination } from './utils';
|
|
51
|
+
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
|
|
51
52
|
import {
|
|
52
53
|
getUpdatedLinkTargetSettings,
|
|
53
54
|
getImageSizeAttributes,
|
|
@@ -58,6 +59,7 @@ import {
|
|
|
58
59
|
LINK_DESTINATION_MEDIA,
|
|
59
60
|
LINK_DESTINATION_NONE,
|
|
60
61
|
LINK_DESTINATION_LIGHTBOX,
|
|
62
|
+
DEFAULT_MEDIA_SIZE_SLUG,
|
|
61
63
|
} from './constants';
|
|
62
64
|
import useImageSizes from './use-image-sizes';
|
|
63
65
|
import useGetNewImages from './use-get-new-images';
|
|
@@ -465,7 +467,7 @@ export default function GalleryEdit( props ) {
|
|
|
465
467
|
sprintf(
|
|
466
468
|
/* translators: %s: image size settings */
|
|
467
469
|
__( 'All gallery image sizes updated to: %s' ),
|
|
468
|
-
imageSize
|
|
470
|
+
imageSize?.label ?? newSizeSlug
|
|
469
471
|
),
|
|
470
472
|
{
|
|
471
473
|
id: 'gallery-attributes-sizeSlug',
|
|
@@ -546,6 +548,8 @@ export default function GalleryEdit( props ) {
|
|
|
546
548
|
...nativeInnerBlockProps,
|
|
547
549
|
} );
|
|
548
550
|
|
|
551
|
+
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
552
|
+
|
|
549
553
|
if ( ! hasImages ) {
|
|
550
554
|
return (
|
|
551
555
|
<View { ...innerBlocksProps }>
|
|
@@ -560,39 +564,163 @@ export default function GalleryEdit( props ) {
|
|
|
560
564
|
return (
|
|
561
565
|
<>
|
|
562
566
|
<InspectorControls>
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
567
|
+
{ Platform.isWeb && (
|
|
568
|
+
<ToolsPanel
|
|
569
|
+
label={ __( 'Settings' ) }
|
|
570
|
+
resetAll={ () => {
|
|
571
|
+
setAttributes( {
|
|
572
|
+
columns: undefined,
|
|
573
|
+
imageCrop: true,
|
|
574
|
+
randomOrder: false,
|
|
575
|
+
} );
|
|
576
|
+
|
|
577
|
+
if ( sizeSlug !== DEFAULT_MEDIA_SIZE_SLUG ) {
|
|
578
|
+
updateImagesSize( DEFAULT_MEDIA_SIZE_SLUG );
|
|
572
579
|
}
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
580
|
+
|
|
581
|
+
if ( linkTarget ) {
|
|
582
|
+
toggleOpenInNewTab( false );
|
|
583
|
+
}
|
|
584
|
+
} }
|
|
585
|
+
dropdownMenuProps={ dropdownMenuProps }
|
|
586
|
+
>
|
|
587
|
+
{ images.length > 1 && (
|
|
588
|
+
<ToolsPanelItem
|
|
589
|
+
isShownByDefault
|
|
590
|
+
label={ __( 'Columns' ) }
|
|
591
|
+
hasValue={ () =>
|
|
592
|
+
!! columns && columns !== images.length
|
|
593
|
+
}
|
|
594
|
+
onDeselect={ () =>
|
|
595
|
+
setColumnsNumber( undefined )
|
|
596
|
+
}
|
|
597
|
+
>
|
|
598
|
+
<RangeControl
|
|
599
|
+
__nextHasNoMarginBottom
|
|
600
|
+
label={ __( 'Columns' ) }
|
|
601
|
+
value={
|
|
602
|
+
columns
|
|
603
|
+
? columns
|
|
604
|
+
: defaultColumnsNumber(
|
|
605
|
+
images.length
|
|
606
|
+
)
|
|
607
|
+
}
|
|
608
|
+
onChange={ setColumnsNumber }
|
|
609
|
+
min={ 1 }
|
|
610
|
+
max={ Math.min(
|
|
611
|
+
MAX_COLUMNS,
|
|
612
|
+
images.length
|
|
613
|
+
) }
|
|
614
|
+
required
|
|
615
|
+
__next40pxDefaultSize
|
|
616
|
+
/>
|
|
617
|
+
</ToolsPanelItem>
|
|
618
|
+
) }
|
|
619
|
+
{ imageSizeOptions?.length > 0 && (
|
|
620
|
+
<ToolsPanelItem
|
|
621
|
+
isShownByDefault
|
|
622
|
+
label={ __( 'Resolution' ) }
|
|
623
|
+
hasValue={ () =>
|
|
624
|
+
sizeSlug !== DEFAULT_MEDIA_SIZE_SLUG
|
|
625
|
+
}
|
|
626
|
+
onDeselect={ () =>
|
|
627
|
+
updateImagesSize( DEFAULT_MEDIA_SIZE_SLUG )
|
|
628
|
+
}
|
|
629
|
+
>
|
|
630
|
+
<SelectControl
|
|
631
|
+
__nextHasNoMarginBottom
|
|
632
|
+
label={ __( 'Resolution' ) }
|
|
633
|
+
help={ __(
|
|
634
|
+
'Select the size of the source images.'
|
|
635
|
+
) }
|
|
636
|
+
value={ sizeSlug }
|
|
637
|
+
options={ imageSizeOptions }
|
|
638
|
+
onChange={ updateImagesSize }
|
|
639
|
+
hideCancelButton
|
|
640
|
+
size="__unstable-large"
|
|
641
|
+
/>
|
|
642
|
+
</ToolsPanelItem>
|
|
643
|
+
) }
|
|
644
|
+
<ToolsPanelItem
|
|
645
|
+
isShownByDefault
|
|
646
|
+
label={ __( 'Crop images to fit' ) }
|
|
647
|
+
hasValue={ () => ! imageCrop }
|
|
648
|
+
onDeselect={ () =>
|
|
649
|
+
setAttributes( { imageCrop: true } )
|
|
650
|
+
}
|
|
651
|
+
>
|
|
652
|
+
<ToggleControl
|
|
653
|
+
__nextHasNoMarginBottom
|
|
654
|
+
label={ __( 'Crop images to fit' ) }
|
|
655
|
+
checked={ !! imageCrop }
|
|
656
|
+
onChange={ toggleImageCrop }
|
|
657
|
+
/>
|
|
658
|
+
</ToolsPanelItem>
|
|
659
|
+
<ToolsPanelItem
|
|
660
|
+
isShownByDefault
|
|
661
|
+
label={ __( 'Randomize order' ) }
|
|
662
|
+
hasValue={ () => !! randomOrder }
|
|
663
|
+
onDeselect={ () =>
|
|
664
|
+
setAttributes( { randomOrder: false } )
|
|
665
|
+
}
|
|
666
|
+
>
|
|
667
|
+
<ToggleControl
|
|
668
|
+
__nextHasNoMarginBottom
|
|
669
|
+
label={ __( 'Randomize order' ) }
|
|
670
|
+
checked={ !! randomOrder }
|
|
671
|
+
onChange={ toggleRandomOrder }
|
|
672
|
+
/>
|
|
673
|
+
</ToolsPanelItem>
|
|
674
|
+
{ hasLinkTo && (
|
|
675
|
+
<ToolsPanelItem
|
|
676
|
+
isShownByDefault
|
|
677
|
+
label={ __( 'Open images in new tab' ) }
|
|
678
|
+
hasValue={ () => !! linkTarget }
|
|
679
|
+
onDeselect={ () => toggleOpenInNewTab( false ) }
|
|
680
|
+
>
|
|
681
|
+
<ToggleControl
|
|
682
|
+
__nextHasNoMarginBottom
|
|
683
|
+
label={ __( 'Open images in new tab' ) }
|
|
684
|
+
checked={ linkTarget === '_blank' }
|
|
685
|
+
onChange={ toggleOpenInNewTab }
|
|
686
|
+
/>
|
|
687
|
+
</ToolsPanelItem>
|
|
688
|
+
) }
|
|
689
|
+
</ToolsPanel>
|
|
690
|
+
) }
|
|
691
|
+
{ Platform.isNative && (
|
|
692
|
+
<PanelBody title={ __( 'Settings' ) }>
|
|
693
|
+
{ images.length > 1 && (
|
|
694
|
+
<RangeControl
|
|
695
|
+
__nextHasNoMarginBottom
|
|
696
|
+
label={ __( 'Columns' ) }
|
|
697
|
+
value={
|
|
698
|
+
columns
|
|
699
|
+
? columns
|
|
700
|
+
: defaultColumnsNumber( images.length )
|
|
701
|
+
}
|
|
702
|
+
onChange={ setColumnsNumber }
|
|
703
|
+
min={ 1 }
|
|
704
|
+
max={ Math.min( MAX_COLUMNS, images.length ) }
|
|
705
|
+
{ ...MOBILE_CONTROL_PROPS_RANGE_CONTROL }
|
|
706
|
+
required
|
|
707
|
+
__next40pxDefaultSize
|
|
708
|
+
/>
|
|
709
|
+
) }
|
|
710
|
+
{ imageSizeOptions?.length > 0 && (
|
|
711
|
+
<SelectControl
|
|
712
|
+
__nextHasNoMarginBottom
|
|
713
|
+
label={ __( 'Resolution' ) }
|
|
714
|
+
help={ __(
|
|
715
|
+
'Select the size of the source images.'
|
|
716
|
+
) }
|
|
717
|
+
value={ sizeSlug }
|
|
718
|
+
options={ imageSizeOptions }
|
|
719
|
+
onChange={ updateImagesSize }
|
|
720
|
+
hideCancelButton
|
|
721
|
+
size="__unstable-large"
|
|
722
|
+
/>
|
|
723
|
+
) }
|
|
596
724
|
<SelectControl
|
|
597
725
|
__nextHasNoMarginBottom
|
|
598
726
|
label={ __( 'Link' ) }
|
|
@@ -602,42 +730,28 @@ export default function GalleryEdit( props ) {
|
|
|
602
730
|
hideCancelButton
|
|
603
731
|
size="__unstable-large"
|
|
604
732
|
/>
|
|
605
|
-
) : null }
|
|
606
|
-
<ToggleControl
|
|
607
|
-
__nextHasNoMarginBottom
|
|
608
|
-
label={ __( 'Crop images to fit' ) }
|
|
609
|
-
checked={ !! imageCrop }
|
|
610
|
-
onChange={ toggleImageCrop }
|
|
611
|
-
/>
|
|
612
|
-
<ToggleControl
|
|
613
|
-
__nextHasNoMarginBottom
|
|
614
|
-
label={ __( 'Randomize order' ) }
|
|
615
|
-
checked={ !! randomOrder }
|
|
616
|
-
onChange={ toggleRandomOrder }
|
|
617
|
-
/>
|
|
618
|
-
{ hasLinkTo && (
|
|
619
733
|
<ToggleControl
|
|
620
734
|
__nextHasNoMarginBottom
|
|
621
|
-
label={ __( '
|
|
622
|
-
checked={
|
|
623
|
-
onChange={
|
|
735
|
+
label={ __( 'Crop images to fit' ) }
|
|
736
|
+
checked={ !! imageCrop }
|
|
737
|
+
onChange={ toggleImageCrop }
|
|
624
738
|
/>
|
|
625
|
-
|
|
626
|
-
{ Platform.isWeb && ! imageSizeOptions && hasImageIds && (
|
|
627
|
-
<BaseControl
|
|
628
|
-
className="gallery-image-sizes"
|
|
739
|
+
<ToggleControl
|
|
629
740
|
__nextHasNoMarginBottom
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
741
|
+
label={ __( 'Randomize order' ) }
|
|
742
|
+
checked={ !! randomOrder }
|
|
743
|
+
onChange={ toggleRandomOrder }
|
|
744
|
+
/>
|
|
745
|
+
{ hasLinkTo && (
|
|
746
|
+
<ToggleControl
|
|
747
|
+
__nextHasNoMarginBottom
|
|
748
|
+
label={ __( 'Open images in new tab' ) }
|
|
749
|
+
checked={ linkTarget === '_blank' }
|
|
750
|
+
onChange={ toggleOpenInNewTab }
|
|
751
|
+
/>
|
|
752
|
+
) }
|
|
753
|
+
</PanelBody>
|
|
754
|
+
) }
|
|
641
755
|
</InspectorControls>
|
|
642
756
|
{ Platform.isWeb ? (
|
|
643
757
|
<BlockControls group="block">
|
package/src/gallery/editor.scss
CHANGED
|
@@ -68,23 +68,6 @@
|
|
|
68
68
|
}
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
-
.gallery-image-sizes {
|
|
72
|
-
.components-base-control__label {
|
|
73
|
-
margin-bottom: 4px;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
.gallery-image-sizes__loading {
|
|
77
|
-
display: flex;
|
|
78
|
-
align-items: center;
|
|
79
|
-
color: $gray-700;
|
|
80
|
-
font-size: $helptext-font-size;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
.components-spinner {
|
|
84
|
-
margin: 0 8px 0 4px;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
71
|
/**
|
|
89
72
|
* Deprecated css past this point. This can be removed once all galleries are migrated
|
|
90
73
|
* to V2.
|
package/src/image/edit.js
CHANGED
|
@@ -249,6 +249,18 @@ export function ImageEdit( {
|
|
|
249
249
|
|
|
250
250
|
let mediaAttributes = pickRelevantMediaFiles( media, newSize );
|
|
251
251
|
|
|
252
|
+
// Normalize newline characters in caption to <br />
|
|
253
|
+
// to preserve line breaks in both editor and frontend.
|
|
254
|
+
if (
|
|
255
|
+
typeof mediaAttributes.caption === 'string' &&
|
|
256
|
+
mediaAttributes.caption.includes( '\n' )
|
|
257
|
+
) {
|
|
258
|
+
mediaAttributes.caption = mediaAttributes.caption.replace(
|
|
259
|
+
/\n/g,
|
|
260
|
+
'<br>'
|
|
261
|
+
);
|
|
262
|
+
}
|
|
263
|
+
|
|
252
264
|
// If a caption text was meanwhile written by the user,
|
|
253
265
|
// make sure the text is not overwritten by empty captions.
|
|
254
266
|
if ( captionRef.current && ! mediaAttributes.caption ) {
|
package/src/list/block.json
CHANGED
package/src/media-text/edit.js
CHANGED
package/src/more/edit.native.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { Component } from '@wordpress/element';
|
|
6
5
|
import { withPreferredColorScheme } from '@wordpress/compose';
|
|
7
6
|
import { HorizontalRule } from '@wordpress/components';
|
|
8
7
|
|
|
@@ -11,40 +10,27 @@ import { HorizontalRule } from '@wordpress/components';
|
|
|
11
10
|
*/
|
|
12
11
|
import styles from './editor.scss';
|
|
13
12
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
super( ...arguments );
|
|
13
|
+
function MoreEdit( { attributes, getStylesFromColorScheme } ) {
|
|
14
|
+
const { customText } = attributes;
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
16
|
+
const textStyle = getStylesFromColorScheme(
|
|
17
|
+
styles.moreText,
|
|
18
|
+
styles.moreTextDark
|
|
19
|
+
);
|
|
20
|
+
const lineStyle = getStylesFromColorScheme(
|
|
21
|
+
styles.moreLine,
|
|
22
|
+
styles.moreLineDark
|
|
23
|
+
);
|
|
22
24
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
);
|
|
33
|
-
const lineStyle = getStylesFromColorScheme(
|
|
34
|
-
styles.moreLine,
|
|
35
|
-
styles.moreLineDark
|
|
36
|
-
);
|
|
37
|
-
|
|
38
|
-
return (
|
|
39
|
-
<HorizontalRule
|
|
40
|
-
text={ content }
|
|
41
|
-
marginLeft={ 0 }
|
|
42
|
-
marginRight={ 0 }
|
|
43
|
-
textStyle={ textStyle }
|
|
44
|
-
lineStyle={ lineStyle }
|
|
45
|
-
/>
|
|
46
|
-
);
|
|
47
|
-
}
|
|
25
|
+
return (
|
|
26
|
+
<HorizontalRule
|
|
27
|
+
text={ customText || __( 'Read more' ) }
|
|
28
|
+
marginLeft={ 0 }
|
|
29
|
+
marginRight={ 0 }
|
|
30
|
+
textStyle={ textStyle }
|
|
31
|
+
lineStyle={ lineStyle }
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
48
34
|
}
|
|
49
35
|
|
|
50
36
|
export default withPreferredColorScheme( MoreEdit );
|
|
@@ -46,6 +46,7 @@ $navigation-icon-size: 24px;
|
|
|
46
46
|
// but still allow them to be overridden by user-set colors.
|
|
47
47
|
.wp-block-navigation-item__content {
|
|
48
48
|
display: block;
|
|
49
|
+
z-index: 1;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
52
|
// This rule needs extra specificity so that it inherits the correct color from its parent.
|
|
@@ -181,6 +182,7 @@ $navigation-icon-size: 24px;
|
|
|
181
182
|
> .wp-block-navigation-item__content {
|
|
182
183
|
display: flex;
|
|
183
184
|
flex-grow: 1;
|
|
185
|
+
padding: 0.5em 1em;
|
|
184
186
|
|
|
185
187
|
// Right-align the chevron in submenus.
|
|
186
188
|
.wp-block-navigation__submenu-icon {
|
|
@@ -11,6 +11,7 @@ import { useSelect, useDispatch } from '@wordpress/data';
|
|
|
11
11
|
import {
|
|
12
12
|
__experimentalToolsPanel as ToolsPanel,
|
|
13
13
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
14
|
+
CheckboxControl,
|
|
14
15
|
TextControl,
|
|
15
16
|
TextareaControl,
|
|
16
17
|
ToolbarButton,
|
|
@@ -174,8 +175,9 @@ function getMissingText( type ) {
|
|
|
174
175
|
* packages/block-library/src/navigation-submenu/edit.js
|
|
175
176
|
* Consider reusing this components for both blocks.
|
|
176
177
|
*/
|
|
177
|
-
function Controls( { attributes, setAttributes,
|
|
178
|
-
const { label, url, description, rel } = attributes;
|
|
178
|
+
function Controls( { attributes, setAttributes, setIsEditingControl } ) {
|
|
179
|
+
const { label, url, description, rel, opensInNewTab } = attributes;
|
|
180
|
+
const lastURLRef = useRef( url );
|
|
179
181
|
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
180
182
|
return (
|
|
181
183
|
<ToolsPanel
|
|
@@ -186,6 +188,7 @@ function Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) {
|
|
|
186
188
|
url: '',
|
|
187
189
|
description: '',
|
|
188
190
|
rel: '',
|
|
191
|
+
opensInNewTab: false,
|
|
189
192
|
} );
|
|
190
193
|
} }
|
|
191
194
|
dropdownMenuProps={ dropdownMenuProps }
|
|
@@ -205,8 +208,8 @@ function Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) {
|
|
|
205
208
|
setAttributes( { label: labelValue } );
|
|
206
209
|
} }
|
|
207
210
|
autoComplete="off"
|
|
208
|
-
onFocus={ () =>
|
|
209
|
-
onBlur={ () =>
|
|
211
|
+
onFocus={ () => setIsEditingControl( true ) }
|
|
212
|
+
onBlur={ () => setIsEditingControl( false ) }
|
|
210
213
|
/>
|
|
211
214
|
</ToolsPanelItem>
|
|
212
215
|
|
|
@@ -222,14 +225,41 @@ function Controls( { attributes, setAttributes, setIsLabelFieldFocused } ) {
|
|
|
222
225
|
label={ __( 'Link' ) }
|
|
223
226
|
value={ url ? safeDecodeURI( url ) : '' }
|
|
224
227
|
onChange={ ( urlValue ) => {
|
|
228
|
+
setAttributes( {
|
|
229
|
+
url: encodeURI( safeDecodeURI( urlValue ) ),
|
|
230
|
+
} );
|
|
231
|
+
} }
|
|
232
|
+
autoComplete="off"
|
|
233
|
+
type="url"
|
|
234
|
+
onFocus={ () => {
|
|
235
|
+
lastURLRef.current = url;
|
|
236
|
+
setIsEditingControl( true );
|
|
237
|
+
} }
|
|
238
|
+
onBlur={ () => {
|
|
239
|
+
// Defer the updateAttributes call to ensure entity connection isn't severed by accident.
|
|
225
240
|
updateAttributes(
|
|
226
|
-
{ url:
|
|
241
|
+
{ url: ! url ? lastURLRef.current : url },
|
|
227
242
|
setAttributes,
|
|
228
|
-
attributes
|
|
243
|
+
{ ...attributes, url: lastURLRef.current }
|
|
229
244
|
);
|
|
245
|
+
setIsEditingControl( false );
|
|
230
246
|
} }
|
|
231
|
-
|
|
232
|
-
|
|
247
|
+
/>
|
|
248
|
+
</ToolsPanelItem>
|
|
249
|
+
|
|
250
|
+
<ToolsPanelItem
|
|
251
|
+
hasValue={ () => !! opensInNewTab }
|
|
252
|
+
label={ __( 'Open in new tab' ) }
|
|
253
|
+
onDeselect={ () => setAttributes( { opensInNewTab: false } ) }
|
|
254
|
+
isShownByDefault
|
|
255
|
+
>
|
|
256
|
+
<CheckboxControl
|
|
257
|
+
__nextHasNoMarginBottom
|
|
258
|
+
label={ __( 'Open in new tab' ) }
|
|
259
|
+
checked={ opensInNewTab }
|
|
260
|
+
onChange={ ( value ) =>
|
|
261
|
+
setAttributes( { opensInNewTab: value } )
|
|
262
|
+
}
|
|
233
263
|
/>
|
|
234
264
|
</ToolsPanelItem>
|
|
235
265
|
|
|
@@ -309,9 +339,10 @@ export default function NavigationLinkEdit( {
|
|
|
309
339
|
const linkUIref = useRef();
|
|
310
340
|
const prevUrl = usePrevious( url );
|
|
311
341
|
|
|
312
|
-
// Change the label using inspector causes
|
|
313
|
-
// This is a workaround to keep the focus on the
|
|
314
|
-
|
|
342
|
+
// Change the `label` and `url` using inspector causes RichText to change focus.
|
|
343
|
+
// This is a workaround to keep the focus on the field when it's focused we don't render the RichText.
|
|
344
|
+
// See: https://github.com/WordPress/gutenberg/pull/61374.
|
|
345
|
+
const [ isEditingControl, setIsEditingControl ] = useState( false );
|
|
315
346
|
|
|
316
347
|
const {
|
|
317
348
|
isAtMaxNesting,
|
|
@@ -546,14 +577,14 @@ export default function NavigationLinkEdit( {
|
|
|
546
577
|
<Controls
|
|
547
578
|
attributes={ attributes }
|
|
548
579
|
setAttributes={ setAttributes }
|
|
549
|
-
|
|
580
|
+
setIsEditingControl={ setIsEditingControl }
|
|
550
581
|
/>
|
|
551
582
|
</InspectorControls>
|
|
552
583
|
<div { ...blockProps }>
|
|
553
584
|
{ /* eslint-disable jsx-a11y/anchor-is-valid */ }
|
|
554
585
|
<a className={ classes }>
|
|
555
586
|
{ /* eslint-enable */ }
|
|
556
|
-
{ ! url ? (
|
|
587
|
+
{ ! url && ! isEditingControl ? (
|
|
557
588
|
<div className="wp-block-navigation-link__placeholder-text">
|
|
558
589
|
<span>{ missingText }</span>
|
|
559
590
|
</div>
|
|
@@ -561,7 +592,7 @@ export default function NavigationLinkEdit( {
|
|
|
561
592
|
<>
|
|
562
593
|
{ ! isInvalid &&
|
|
563
594
|
! isDraft &&
|
|
564
|
-
!
|
|
595
|
+
! isEditingControl && (
|
|
565
596
|
<>
|
|
566
597
|
<RichText
|
|
567
598
|
ref={ ref }
|
|
@@ -595,9 +626,7 @@ export default function NavigationLinkEdit( {
|
|
|
595
626
|
) }
|
|
596
627
|
</>
|
|
597
628
|
) }
|
|
598
|
-
{ ( isInvalid ||
|
|
599
|
-
isDraft ||
|
|
600
|
-
isLabelFieldFocused ) && (
|
|
629
|
+
{ ( isInvalid || isDraft || isEditingControl ) && (
|
|
601
630
|
<div
|
|
602
631
|
className={ clsx(
|
|
603
632
|
'wp-block-navigation-link__placeholder-text',
|