@wordpress/block-library 5.0.1 → 6.0.1
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 +6 -0
- package/README.md +1 -1
- package/build/audio/edit.js +2 -2
- package/build/audio/edit.js.map +1 -1
- package/build/audio/edit.native.js +2 -2
- package/build/audio/edit.native.js.map +1 -1
- package/build/button/edit.js +97 -87
- package/build/button/edit.js.map +1 -1
- package/build/button/edit.native.js +1 -1
- package/build/button/edit.native.js.map +1 -1
- package/build/button/index.js +4 -1
- package/build/button/index.js.map +1 -1
- package/build/buttons/edit.js +2 -1
- package/build/buttons/edit.js.map +1 -1
- package/build/buttons/index.js +2 -1
- package/build/buttons/index.js.map +1 -1
- package/build/buttons/transforms.js +2 -1
- package/build/buttons/transforms.js.map +1 -1
- package/build/column/index.js +4 -1
- package/build/column/index.js.map +1 -1
- package/build/column/save.js +9 -1
- package/build/column/save.js.map +1 -1
- package/build/columns/edit.native.js +5 -2
- package/build/columns/edit.native.js.map +1 -1
- package/build/columns/index.js +10 -1
- package/build/columns/index.js.map +1 -1
- package/build/cover/deprecated.js +0 -27
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit.js +57 -27
- package/build/cover/edit.js.map +1 -1
- package/build/cover/index.js +11 -1
- package/build/cover/index.js.map +1 -1
- package/build/cover/save.js +2 -1
- package/build/cover/save.js.map +1 -1
- package/build/cover/shared.js +1 -0
- package/build/cover/shared.js.map +1 -1
- package/build/cover/transforms.js +4 -0
- package/build/cover/transforms.js.map +1 -1
- package/build/embed/edit.js +1 -5
- package/build/embed/edit.js.map +1 -1
- package/build/embed/edit.native.js +85 -22
- package/build/embed/edit.native.js.map +1 -1
- package/build/embed/embed-bottom-sheet.native.js +17 -16
- package/build/embed/embed-bottom-sheet.native.js.map +1 -1
- package/build/embed/embed-controls.js +4 -1
- package/build/embed/embed-controls.js.map +1 -1
- package/build/embed/embed-no-preview.native.js +22 -9
- package/build/embed/embed-no-preview.native.js.map +1 -1
- package/build/embed/embed-placeholder.native.js +51 -7
- package/build/embed/embed-placeholder.native.js.map +1 -1
- package/build/embed/embed-preview.native.js +28 -10
- package/build/embed/embed-preview.native.js.map +1 -1
- package/build/embed/variations.js +0 -10
- package/build/embed/variations.js.map +1 -1
- package/build/embed/wp-embed-preview.js +44 -56
- package/build/embed/wp-embed-preview.js.map +1 -1
- package/build/embed/wp-embed-preview.native.js +95 -0
- package/build/embed/wp-embed-preview.native.js.map +1 -0
- package/build/file/deprecated.js +108 -0
- package/build/file/deprecated.js.map +1 -0
- package/build/file/edit.js +8 -1
- package/build/file/edit.js.map +1 -1
- package/build/file/index.js +9 -0
- package/build/file/index.js.map +1 -1
- package/build/file/inspector.js +1 -1
- package/build/file/inspector.js.map +1 -1
- package/build/file/save.js +4 -1
- package/build/file/save.js.map +1 -1
- package/build/file/transforms.js +3 -1
- package/build/file/transforms.js.map +1 -1
- package/build/gallery/constants.js +2 -2
- package/build/gallery/constants.js.map +1 -1
- package/build/gallery/deprecated.js +17 -8
- package/build/gallery/deprecated.js.map +1 -1
- package/build/gallery/edit-wrapper.js +63 -0
- package/build/gallery/edit-wrapper.js.map +1 -0
- package/build/gallery/edit.js +225 -231
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.js +67 -49
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/gallery.native.js +42 -79
- package/build/gallery/gallery.native.js.map +1 -1
- package/build/gallery/index.js +31 -7
- package/build/gallery/index.js.map +1 -1
- package/build/gallery/save.js +26 -43
- package/build/gallery/save.js.map +1 -1
- package/build/gallery/shared.js +9 -2
- package/build/gallery/shared.js.map +1 -1
- package/build/gallery/transforms.js +211 -12
- package/build/gallery/transforms.js.map +1 -1
- package/build/gallery/use-get-media.js +58 -0
- package/build/gallery/use-get-media.js.map +1 -0
- package/build/gallery/use-get-new-images.js +58 -0
- package/build/gallery/use-get-new-images.js.map +1 -0
- package/build/gallery/use-image-sizes.js +73 -0
- package/build/gallery/use-image-sizes.js.map +1 -0
- package/build/gallery/use-short-code-transform.js +63 -0
- package/build/gallery/use-short-code-transform.js.map +1 -0
- package/build/gallery/utils.js +51 -0
- package/build/gallery/utils.js.map +1 -0
- package/build/gallery/v1/constants.js +13 -0
- package/build/gallery/v1/constants.js.map +1 -0
- package/build/gallery/v1/edit.js +459 -0
- package/build/gallery/v1/edit.js.map +1 -0
- package/build/gallery/{gallery-button.native.js → v1/gallery-button.native.js} +0 -0
- package/build/gallery/v1/gallery-button.native.js.map +1 -0
- package/build/gallery/{gallery-image.js → v1/gallery-image.js} +0 -0
- package/build/gallery/v1/gallery-image.js.map +1 -0
- package/build/gallery/{gallery-image.native.js → v1/gallery-image.native.js} +0 -0
- package/build/gallery/v1/gallery-image.native.js.map +1 -0
- package/build/gallery/v1/gallery.js +122 -0
- package/build/gallery/v1/gallery.js.map +1 -0
- package/build/gallery/v1/gallery.native.js +159 -0
- package/build/gallery/v1/gallery.native.js.map +1 -0
- package/build/gallery/v1/save.js +75 -0
- package/build/gallery/v1/save.js.map +1 -0
- package/build/gallery/v1/shared.js +26 -0
- package/build/gallery/v1/shared.js.map +1 -0
- package/build/gallery/{tiles.native.js → v1/tiles.native.js} +2 -1
- package/build/gallery/v1/tiles.native.js.map +1 -0
- package/build/gallery/v1/update-gallery-modal.js +110 -0
- package/build/gallery/v1/update-gallery-modal.js.map +1 -0
- package/build/group/edit.js +21 -5
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +8 -2
- package/build/group/index.js.map +1 -1
- package/build/group/variations.js +31 -0
- package/build/group/variations.js.map +1 -0
- package/build/heading/heading-level-dropdown.js +11 -37
- package/build/heading/heading-level-dropdown.js.map +1 -1
- package/build/home-link/edit.js +2 -2
- package/build/home-link/edit.js.map +1 -1
- package/build/image/edit.js +8 -6
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +46 -17
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +11 -17
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +1 -0
- package/build/image/index.js.map +1 -1
- package/build/image/transforms.js +30 -7
- package/build/image/transforms.js.map +1 -1
- package/build/image/utils.js +23 -0
- package/build/image/utils.js.map +1 -1
- package/build/index.js +3 -1
- package/build/index.js.map +1 -1
- package/build/latest-comments/edit.js +7 -1
- package/build/latest-comments/edit.js.map +1 -1
- package/build/latest-posts/edit.native.js +12 -6
- package/build/latest-posts/edit.native.js.map +1 -1
- package/build/media-text/edit.js +1 -1
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/index.js +2 -0
- package/build/media-text/index.js.map +1 -1
- package/build/navigation/block-navigation-list.js +14 -3
- package/build/navigation/block-navigation-list.js.map +1 -1
- package/build/navigation/edit.js +44 -14
- package/build/navigation/edit.js.map +1 -1
- package/build/navigation/index.js +7 -1
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/menu-items-to-blocks.js +6 -5
- package/build/navigation/menu-items-to-blocks.js.map +1 -1
- package/build/navigation/placeholder-preview.js +3 -3
- package/build/navigation/placeholder-preview.js.map +1 -1
- package/build/navigation/placeholder.js +1 -1
- package/build/navigation/placeholder.js.map +1 -1
- package/build/navigation/use-block-navigator.js +2 -1
- package/build/navigation/use-block-navigator.js.map +1 -1
- package/build/navigation/variations.js +2 -3
- package/build/navigation/variations.js.map +1 -1
- package/build/navigation/view.js +53 -1
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +56 -72
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/index.js +6 -2
- package/build/navigation-link/index.js.map +1 -1
- package/build/navigation-link/transforms.js +83 -0
- package/build/navigation-link/transforms.js.map +1 -0
- package/build/navigation-submenu/edit.js +651 -0
- package/build/navigation-submenu/edit.js.map +1 -0
- package/build/navigation-submenu/icons.js +27 -0
- package/build/navigation-submenu/icons.js.map +1 -0
- package/build/navigation-submenu/index.js +89 -0
- package/build/navigation-submenu/index.js.map +1 -0
- package/build/navigation-submenu/save.js +18 -0
- package/build/navigation-submenu/save.js.map +1 -0
- package/build/navigation-submenu/transforms.js +82 -0
- package/build/navigation-submenu/transforms.js.map +1 -0
- package/build/navigation-submenu/view.js +51 -0
- package/build/navigation-submenu/view.js.map +1 -0
- package/build/page-list/convert-to-links-modal.js +19 -1
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/edit.js +16 -5
- package/build/page-list/edit.js.map +1 -1
- package/build/page-list/index.js +10 -1
- package/build/page-list/index.js.map +1 -1
- package/build/post-author/index.js +2 -1
- package/build/post-author/index.js.map +1 -1
- package/build/post-comment/edit.js +7 -4
- package/build/post-comment/edit.js.map +1 -1
- package/build/post-comment-author/edit.js +1 -1
- package/build/post-comment-author/edit.js.map +1 -1
- package/build/post-comment-content/edit.js +16 -12
- package/build/post-comment-content/edit.js.map +1 -1
- package/build/post-content/edit.js +1 -3
- package/build/post-content/edit.js.map +1 -1
- package/build/post-date/edit.js +35 -14
- package/build/post-date/edit.js.map +1 -1
- package/build/post-date/index.js +2 -1
- package/build/post-date/index.js.map +1 -1
- package/build/post-excerpt/edit.js +2 -1
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +24 -10
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-featured-image/index.js +5 -0
- package/build/post-featured-image/index.js.map +1 -1
- package/build/post-navigation-link/edit.js +19 -3
- package/build/post-navigation-link/edit.js.map +1 -1
- package/build/post-navigation-link/index.js +9 -1
- package/build/post-navigation-link/index.js.map +1 -1
- package/build/post-template/index.js +5 -2
- package/build/post-template/index.js.map +1 -1
- package/build/post-terms/edit.js +4 -2
- package/build/post-terms/edit.js.map +1 -1
- package/build/post-terms/index.js +2 -1
- package/build/post-terms/index.js.map +1 -1
- package/build/post-title/edit.js +3 -3
- package/build/post-title/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/index.js +3 -1
- package/build/query/edit/index.js.map +1 -1
- package/build/query/variations.js +4 -4
- package/build/query/variations.js.map +1 -1
- package/build/query-pagination/deprecated.js +24 -0
- package/build/query-pagination/deprecated.js.map +1 -0
- package/build/query-pagination/edit.js +54 -3
- package/build/query-pagination/edit.js.map +1 -1
- package/build/query-pagination/index.js +20 -1
- package/build/query-pagination/index.js.map +1 -1
- package/build/query-pagination/query-pagination-arrow-controls.js +38 -0
- package/build/query-pagination/query-pagination-arrow-controls.js.map +1 -0
- package/build/query-pagination/save.js +1 -1
- package/build/query-pagination/save.js.map +1 -1
- package/build/query-pagination-next/edit.js +19 -4
- package/build/query-pagination-next/edit.js.map +1 -1
- package/build/query-pagination-next/index.js +1 -1
- package/build/query-pagination-previous/edit.js +19 -4
- package/build/query-pagination-previous/edit.js.map +1 -1
- package/build/query-pagination-previous/index.js +1 -1
- package/build/site-logo/edit.js +75 -30
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-logo/index.js +7 -2
- package/build/site-logo/index.js.map +1 -1
- package/build/site-tagline/index.js +1 -0
- package/build/site-tagline/index.js.map +1 -1
- package/build/site-title/edit/index.js +25 -6
- package/build/site-title/edit/index.js.map +1 -1
- package/build/site-title/index.js +9 -2
- package/build/site-title/index.js.map +1 -1
- package/build/social-links/deprecated.js +106 -2
- package/build/social-links/deprecated.js.map +1 -1
- package/build/social-links/edit.js +15 -19
- package/build/social-links/edit.js.map +1 -1
- package/build/social-links/index.js +16 -1
- package/build/social-links/index.js.map +1 -1
- package/build/social-links/save.js +1 -3
- package/build/social-links/save.js.map +1 -1
- package/build/table/index.js +1 -1
- package/build/template-part/edit/advanced-controls.js +3 -1
- 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/video/edit-common-settings.js +1 -1
- package/build/video/edit-common-settings.js.map +1 -1
- package/build/video/edit.js +10 -5
- package/build/video/edit.js.map +1 -1
- package/build/video/tracks-editor.js +3 -1
- package/build/video/tracks-editor.js.map +1 -1
- package/build-module/audio/edit.js +3 -3
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/audio/edit.native.js +3 -3
- package/build-module/audio/edit.native.js.map +1 -1
- package/build-module/button/edit.js +101 -91
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/edit.native.js +2 -2
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/button/index.js +4 -1
- package/build-module/button/index.js.map +1 -1
- package/build-module/buttons/edit.js +2 -1
- package/build-module/buttons/edit.js.map +1 -1
- package/build-module/buttons/index.js +2 -1
- package/build-module/buttons/index.js.map +1 -1
- package/build-module/buttons/transforms.js +2 -1
- package/build-module/buttons/transforms.js.map +1 -1
- package/build-module/column/index.js +4 -1
- package/build-module/column/index.js.map +1 -1
- package/build-module/column/save.js +9 -1
- package/build-module/column/save.js.map +1 -1
- package/build-module/columns/edit.native.js +6 -3
- package/build-module/columns/edit.native.js.map +1 -1
- package/build-module/columns/index.js +10 -1
- package/build-module/columns/index.js.map +1 -1
- package/build-module/cover/deprecated.js +0 -27
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit.js +57 -28
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/cover/index.js +11 -1
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/save.js +2 -1
- package/build-module/cover/save.js.map +1 -1
- package/build-module/cover/shared.js +1 -0
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/cover/transforms.js +4 -0
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/embed/edit.js +1 -5
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/embed/edit.native.js +87 -25
- package/build-module/embed/edit.native.js.map +1 -1
- package/build-module/embed/embed-bottom-sheet.native.js +18 -16
- package/build-module/embed/embed-bottom-sheet.native.js.map +1 -1
- package/build-module/embed/embed-controls.js +4 -1
- package/build-module/embed/embed-controls.js.map +1 -1
- package/build-module/embed/embed-no-preview.native.js +22 -10
- package/build-module/embed/embed-no-preview.native.js.map +1 -1
- package/build-module/embed/embed-placeholder.native.js +51 -8
- package/build-module/embed/embed-placeholder.native.js.map +1 -1
- package/build-module/embed/embed-preview.native.js +26 -11
- package/build-module/embed/embed-preview.native.js.map +1 -1
- package/build-module/embed/variations.js +0 -10
- package/build-module/embed/variations.js.map +1 -1
- package/build-module/embed/wp-embed-preview.js +39 -56
- package/build-module/embed/wp-embed-preview.js.map +1 -1
- package/build-module/embed/wp-embed-preview.native.js +83 -0
- package/build-module/embed/wp-embed-preview.native.js.map +1 -0
- package/build-module/file/deprecated.js +98 -0
- package/build-module/file/deprecated.js.map +1 -0
- package/build-module/file/edit.js +8 -1
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/index.js +8 -0
- package/build-module/file/index.js.map +1 -1
- package/build-module/file/inspector.js +1 -1
- package/build-module/file/inspector.js.map +1 -1
- package/build-module/file/save.js +4 -1
- package/build-module/file/save.js.map +1 -1
- package/build-module/file/transforms.js +2 -1
- package/build-module/file/transforms.js.map +1 -1
- package/build-module/gallery/constants.js +2 -2
- package/build-module/gallery/constants.js.map +1 -1
- package/build-module/gallery/deprecated.js +15 -7
- package/build-module/gallery/deprecated.js.map +1 -1
- package/build-module/gallery/edit-wrapper.js +50 -0
- package/build-module/gallery/edit-wrapper.js.map +1 -0
- package/build-module/gallery/edit.js +222 -234
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.js +70 -51
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/gallery.native.js +43 -78
- package/build-module/gallery/gallery.native.js.map +1 -1
- package/build-module/gallery/index.js +30 -6
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/gallery/save.js +24 -43
- package/build-module/gallery/save.js.map +1 -1
- package/build-module/gallery/shared.js +8 -2
- package/build-module/gallery/shared.js.map +1 -1
- package/build-module/gallery/transforms.js +207 -12
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/gallery/use-get-media.js +48 -0
- package/build-module/gallery/use-get-media.js.map +1 -0
- package/build-module/gallery/use-get-new-images.js +50 -0
- package/build-module/gallery/use-get-new-images.js.map +1 -0
- package/build-module/gallery/use-image-sizes.js +64 -0
- package/build-module/gallery/use-image-sizes.js.map +1 -0
- package/build-module/gallery/use-short-code-transform.js +53 -0
- package/build-module/gallery/use-short-code-transform.js.map +1 -0
- package/build-module/gallery/utils.js +42 -0
- package/build-module/gallery/utils.js.map +1 -0
- package/build-module/gallery/v1/constants.js +4 -0
- package/build-module/gallery/v1/constants.js.map +1 -0
- package/build-module/gallery/v1/edit.js +430 -0
- package/build-module/gallery/v1/edit.js.map +1 -0
- package/build-module/gallery/{gallery-button.native.js → v1/gallery-button.native.js} +0 -0
- package/build-module/gallery/v1/gallery-button.native.js.map +1 -0
- package/build-module/gallery/{gallery-image.js → v1/gallery-image.js} +0 -0
- package/build-module/gallery/v1/gallery-image.js.map +1 -0
- package/build-module/gallery/{gallery-image.native.js → v1/gallery-image.native.js} +0 -0
- package/build-module/gallery/v1/gallery-image.native.js.map +1 -0
- package/build-module/gallery/v1/gallery.js +102 -0
- package/build-module/gallery/v1/gallery.js.map +1 -0
- package/build-module/gallery/v1/gallery.native.js +136 -0
- package/build-module/gallery/v1/gallery.native.js.map +1 -0
- package/build-module/gallery/v1/save.js +65 -0
- package/build-module/gallery/v1/save.js.map +1 -0
- package/build-module/gallery/v1/shared.js +16 -0
- package/build-module/gallery/v1/shared.js.map +1 -0
- package/build-module/gallery/{tiles.native.js → v1/tiles.native.js} +2 -1
- package/build-module/gallery/v1/tiles.native.js.map +1 -0
- package/build-module/gallery/v1/update-gallery-modal.js +93 -0
- package/build-module/gallery/v1/update-gallery-modal.js.map +1 -0
- package/build-module/group/edit.js +21 -6
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +7 -2
- package/build-module/group/index.js.map +1 -1
- package/build-module/group/variations.js +22 -0
- package/build-module/group/variations.js.map +1 -0
- package/build-module/heading/heading-level-dropdown.js +12 -37
- package/build-module/heading/heading-level-dropdown.js.map +1 -1
- package/build-module/home-link/edit.js +2 -2
- package/build-module/home-link/edit.js.map +1 -1
- package/build-module/image/edit.js +8 -6
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +48 -19
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +11 -15
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +1 -0
- package/build-module/image/index.js.map +1 -1
- package/build-module/image/transforms.js +26 -7
- package/build-module/image/transforms.js.map +1 -1
- package/build-module/image/utils.js +22 -1
- package/build-module/image/utils.js.map +1 -1
- package/build-module/index.js +2 -1
- package/build-module/index.js.map +1 -1
- package/build-module/latest-comments/edit.js +7 -1
- package/build-module/latest-comments/edit.js.map +1 -1
- package/build-module/latest-posts/edit.native.js +12 -6
- package/build-module/latest-posts/edit.native.js.map +1 -1
- package/build-module/media-text/edit.js +1 -1
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/index.js +2 -0
- package/build-module/media-text/index.js.map +1 -1
- package/build-module/navigation/block-navigation-list.js +15 -3
- package/build-module/navigation/block-navigation-list.js.map +1 -1
- package/build-module/navigation/edit.js +45 -15
- package/build-module/navigation/edit.js.map +1 -1
- package/build-module/navigation/index.js +7 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/menu-items-to-blocks.js +6 -5
- package/build-module/navigation/menu-items-to-blocks.js.map +1 -1
- package/build-module/navigation/placeholder-preview.js +3 -3
- package/build-module/navigation/placeholder-preview.js.map +1 -1
- package/build-module/navigation/placeholder.js +1 -1
- package/build-module/navigation/placeholder.js.map +1 -1
- package/build-module/navigation/use-block-navigator.js +2 -1
- package/build-module/navigation/use-block-navigator.js.map +1 -1
- package/build-module/navigation/variations.js +2 -3
- package/build-module/navigation/variations.js.map +1 -1
- package/build-module/navigation/view.js +53 -2
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +59 -74
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/index.js +5 -2
- package/build-module/navigation-link/index.js.map +1 -1
- package/build-module/navigation-link/transforms.js +74 -0
- package/build-module/navigation-link/transforms.js.map +1 -0
- package/build-module/navigation-submenu/edit.js +628 -0
- package/build-module/navigation-submenu/edit.js.map +1 -0
- package/build-module/navigation-submenu/icons.js +17 -0
- package/build-module/navigation-submenu/icons.js.map +1 -0
- package/build-module/navigation-submenu/index.js +74 -0
- package/build-module/navigation-submenu/index.js.map +1 -0
- package/build-module/navigation-submenu/save.js +10 -0
- package/build-module/navigation-submenu/save.js.map +1 -0
- package/build-module/navigation-submenu/transforms.js +73 -0
- package/build-module/navigation-submenu/transforms.js.map +1 -0
- package/build-module/navigation-submenu/view.js +49 -0
- package/build-module/navigation-submenu/view.js.map +1 -0
- package/build-module/page-list/convert-to-links-modal.js +19 -1
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/edit.js +16 -5
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/page-list/index.js +10 -1
- package/build-module/page-list/index.js.map +1 -1
- package/build-module/post-author/index.js +2 -1
- package/build-module/post-author/index.js.map +1 -1
- package/build-module/post-comment/edit.js +8 -6
- package/build-module/post-comment/edit.js.map +1 -1
- package/build-module/post-comment-author/edit.js +1 -1
- package/build-module/post-comment-author/edit.js.map +1 -1
- package/build-module/post-comment-content/edit.js +16 -13
- package/build-module/post-comment-content/edit.js.map +1 -1
- package/build-module/post-content/edit.js +1 -3
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-date/edit.js +36 -16
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-date/index.js +2 -1
- package/build-module/post-date/index.js.map +1 -1
- package/build-module/post-excerpt/edit.js +2 -1
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +22 -11
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-featured-image/index.js +5 -0
- package/build-module/post-featured-image/index.js.map +1 -1
- package/build-module/post-navigation-link/edit.js +19 -3
- package/build-module/post-navigation-link/edit.js.map +1 -1
- package/build-module/post-navigation-link/index.js +9 -1
- package/build-module/post-navigation-link/index.js.map +1 -1
- package/build-module/post-template/index.js +6 -3
- package/build-module/post-template/index.js.map +1 -1
- package/build-module/post-terms/edit.js +5 -3
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/post-terms/index.js +2 -1
- package/build-module/post-terms/index.js.map +1 -1
- package/build-module/post-title/edit.js +3 -3
- package/build-module/post-title/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/index.js +4 -2
- package/build-module/query/edit/index.js.map +1 -1
- package/build-module/query/variations.js +4 -4
- package/build-module/query/variations.js.map +1 -1
- package/build-module/query-pagination/deprecated.js +15 -0
- package/build-module/query-pagination/deprecated.js.map +1 -0
- package/build-module/query-pagination/edit.js +52 -5
- package/build-module/query-pagination/edit.js.map +1 -1
- package/build-module/query-pagination/index.js +19 -1
- package/build-module/query-pagination/index.js.map +1 -1
- package/build-module/query-pagination/query-pagination-arrow-controls.js +29 -0
- package/build-module/query-pagination/query-pagination-arrow-controls.js.map +1 -0
- package/build-module/query-pagination/save.js +2 -2
- package/build-module/query-pagination/save.js.map +1 -1
- package/build-module/query-pagination-next/edit.js +18 -4
- package/build-module/query-pagination-next/edit.js.map +1 -1
- package/build-module/query-pagination-next/index.js +1 -1
- package/build-module/query-pagination-previous/edit.js +18 -4
- package/build-module/query-pagination-previous/edit.js.map +1 -1
- package/build-module/query-pagination-previous/index.js +1 -1
- package/build-module/site-logo/edit.js +79 -34
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-logo/index.js +7 -2
- package/build-module/site-logo/index.js.map +1 -1
- package/build-module/site-tagline/index.js +1 -0
- package/build-module/site-tagline/index.js.map +1 -1
- package/build-module/site-title/edit/index.js +25 -7
- package/build-module/site-title/edit/index.js.map +1 -1
- package/build-module/site-title/index.js +9 -2
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-links/deprecated.js +106 -2
- package/build-module/social-links/deprecated.js.map +1 -1
- package/build-module/social-links/edit.js +16 -20
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/social-links/index.js +16 -1
- package/build-module/social-links/index.js.map +1 -1
- package/build-module/social-links/save.js +1 -3
- package/build-module/social-links/save.js.map +1 -1
- package/build-module/table/index.js +1 -1
- package/build-module/template-part/edit/advanced-controls.js +4 -2
- 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/video/edit-common-settings.js +2 -2
- package/build-module/video/edit-common-settings.js.map +1 -1
- package/build-module/video/edit.js +10 -5
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/tracks-editor.js +2 -1
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/button/style-rtl.css +1 -1
- package/build-style/button/style.css +1 -1
- package/build-style/columns/editor-rtl.css +2 -2
- package/build-style/columns/editor.css +2 -2
- package/build-style/columns/style-rtl.css +4 -4
- package/build-style/columns/style.css +4 -4
- package/build-style/common-rtl.css +4 -105
- package/build-style/common.css +4 -105
- package/build-style/editor-rtl.css +188 -205
- package/build-style/editor.css +188 -205
- package/build-style/embed/style-rtl.css +1 -0
- package/build-style/embed/style.css +1 -0
- package/build-style/gallery/editor-rtl.css +89 -21
- package/build-style/gallery/editor.css +89 -21
- package/build-style/gallery/style-rtl.css +202 -39
- package/build-style/gallery/style.css +202 -39
- package/build-style/group/theme-rtl.css +1 -3
- package/build-style/group/theme.css +1 -3
- package/build-style/heading/style-rtl.css +8 -0
- package/build-style/heading/style.css +8 -0
- package/build-style/html/editor-rtl.css +12 -11
- package/build-style/html/editor.css +12 -11
- package/build-style/list/style-rtl.css +4 -0
- package/build-style/list/style.css +4 -0
- package/build-style/navigation/editor-rtl.css +12 -7
- package/build-style/navigation/editor.css +12 -7
- package/build-style/navigation/style-rtl.css +140 -134
- package/build-style/navigation/style.css +140 -134
- package/build-style/navigation-link/editor-rtl.css +22 -13
- package/build-style/navigation-link/editor.css +22 -13
- package/build-style/{post-content → navigation-submenu}/editor-rtl.css +29 -8
- package/build-style/{post-content → navigation-submenu}/editor.css +29 -8
- package/build-style/{heading/editor.css → navigation-submenu/style-rtl.css} +13 -7
- package/build-style/{heading/editor-rtl.css → navigation-submenu/style.css} +13 -7
- package/build-style/page-list/editor-rtl.css +8 -0
- package/build-style/page-list/editor.css +8 -0
- package/build-style/page-list/style-rtl.css +2 -8
- package/build-style/page-list/style.css +2 -8
- package/build-style/paragraph/style-rtl.css +5 -1
- package/build-style/paragraph/style.css +5 -1
- package/build-style/post-featured-image/editor-rtl.css +4 -8
- package/build-style/post-featured-image/editor.css +4 -8
- package/build-style/post-featured-image/style-rtl.css +1 -0
- package/build-style/post-featured-image/style.css +1 -0
- package/build-style/post-template/style-rtl.css +2 -0
- package/build-style/post-template/style.css +2 -0
- package/build-style/pullquote/style-rtl.css +1 -0
- package/build-style/pullquote/style.css +1 -0
- package/build-style/query-pagination/editor-rtl.css +2 -5
- package/build-style/query-pagination/editor.css +2 -5
- package/build-style/query-pagination/style-rtl.css +17 -6
- package/build-style/query-pagination/style.css +17 -6
- package/build-style/quote/style-rtl.css +3 -0
- package/build-style/quote/style.css +3 -0
- package/build-style/reset-rtl.css +2 -1
- package/build-style/reset.css +2 -1
- package/build-style/social-links/style-rtl.css +0 -5
- package/build-style/social-links/style.css +0 -5
- package/build-style/style-rtl.css +415 -307
- package/build-style/style.css +415 -307
- package/build-style/theme-rtl.css +1 -11
- package/build-style/theme.css +1 -11
- package/package.json +30 -31
- package/src/audio/edit.js +6 -3
- package/src/audio/edit.native.js +9 -3
- package/src/button/block.json +4 -1
- package/src/button/edit.js +107 -115
- package/src/button/edit.native.js +5 -2
- package/src/button/style.scss +1 -1
- package/src/buttons/block.json +2 -1
- package/src/buttons/edit.js +1 -1
- package/src/column/block.json +4 -1
- package/src/column/save.js +11 -1
- package/src/columns/block.json +8 -1
- package/src/columns/edit.native.js +8 -3
- package/src/columns/editor.scss +2 -2
- package/src/columns/index.js +1 -0
- package/src/columns/style.scss +4 -4
- package/src/common.scss +3 -9
- package/src/cover/block.json +11 -1
- package/src/cover/deprecated.js +0 -27
- package/src/cover/edit.js +82 -32
- package/src/cover/save.js +2 -1
- package/src/cover/shared.js +1 -0
- package/src/cover/transforms.js +4 -2
- package/src/editor.scss +4 -20
- package/src/embed/edit.js +1 -11
- package/src/embed/edit.native.js +120 -32
- package/src/embed/embed-bottom-sheet.native.js +26 -20
- package/src/embed/embed-controls.js +10 -1
- package/src/embed/embed-no-preview.native.js +53 -14
- package/src/embed/embed-placeholder.native.js +58 -9
- package/src/embed/embed-preview.native.js +58 -41
- package/src/embed/style.scss +1 -0
- package/src/embed/styles.native.scss +18 -8
- package/src/embed/variations.js +0 -8
- package/src/embed/wp-embed-preview.js +41 -62
- package/src/embed/wp-embed-preview.native.js +80 -0
- package/src/file/block.json +6 -0
- package/src/file/deprecated.js +123 -0
- package/src/file/edit.js +6 -0
- package/src/file/index.js +2 -0
- package/src/file/inspector.js +12 -10
- package/src/file/save.js +3 -0
- package/src/file/test/__snapshots__/edit.native.js.snap +4 -0
- package/src/file/transforms.js +3 -1
- package/src/gallery/block.json +18 -0
- package/src/gallery/constants.js +2 -2
- package/src/gallery/deprecated.js +15 -7
- package/src/gallery/deprecated.scss +132 -0
- package/src/gallery/edit-wrapper.js +47 -0
- package/src/gallery/edit.js +317 -276
- package/src/gallery/editor.scss +106 -22
- package/src/gallery/gallery-styles.native.scss +4 -2
- package/src/gallery/gallery.js +82 -71
- package/src/gallery/gallery.native.js +49 -85
- package/src/gallery/index.js +12 -6
- package/src/gallery/save.js +20 -60
- package/src/gallery/shared.js +9 -2
- package/src/gallery/style.scss +113 -75
- package/src/gallery/transforms.js +212 -11
- package/src/gallery/use-get-media.js +59 -0
- package/src/gallery/use-get-new-images.js +68 -0
- package/src/gallery/use-image-sizes.js +66 -0
- package/src/gallery/use-short-code-transform.js +52 -0
- package/src/gallery/utils.js +46 -0
- package/src/gallery/v1/constants.js +3 -0
- package/src/gallery/v1/edit.js +509 -0
- package/src/gallery/{gallery-button.native.js → v1/gallery-button.native.js} +0 -0
- package/src/gallery/{gallery-image-style.native.scss → v1/gallery-image-style.native.scss} +0 -0
- package/src/gallery/{gallery-image.js → v1/gallery-image.js} +0 -0
- package/src/gallery/{gallery-image.native.js → v1/gallery-image.native.js} +0 -0
- package/src/gallery/v1/gallery-styles.native.scss +8 -0
- package/src/gallery/v1/gallery.js +119 -0
- package/src/gallery/v1/gallery.native.js +162 -0
- package/src/gallery/v1/save.js +81 -0
- package/src/gallery/v1/shared.js +19 -0
- package/src/gallery/{tiles-styles.native.scss → v1/tiles-styles.native.scss} +0 -0
- package/src/gallery/{tiles.native.js → v1/tiles.native.js} +2 -1
- package/src/gallery/v1/update-gallery-modal.js +97 -0
- package/src/group/block.json +4 -1
- package/src/group/edit.js +31 -7
- package/src/group/index.js +2 -0
- package/src/group/theme.scss +1 -3
- package/src/group/variations.js +18 -0
- package/src/heading/heading-level-dropdown.js +26 -58
- package/src/heading/style.scss +3 -0
- package/src/home-link/edit.js +2 -2
- package/src/home-link/index.php +2 -2
- package/src/html/editor.scss +16 -10
- package/src/image/block.json +1 -0
- package/src/image/edit.js +9 -7
- package/src/image/edit.native.js +75 -35
- package/src/image/image.js +10 -14
- package/src/image/styles.native.scss +5 -0
- package/src/image/transforms.js +32 -9
- package/src/image/utils.js +17 -1
- package/src/index.js +2 -0
- package/src/latest-comments/edit.js +4 -0
- package/src/latest-comments/index.php +2 -1
- package/src/latest-posts/edit.native.js +10 -8
- package/src/list/style.scss +8 -3
- package/src/media-text/edit.js +1 -1
- package/src/media-text/index.js +1 -0
- package/src/navigation/block-navigation-list.js +16 -7
- package/src/navigation/block.json +7 -1
- package/src/navigation/edit.js +60 -17
- package/src/navigation/editor.scss +38 -19
- package/src/navigation/index.php +12 -4
- package/src/navigation/menu-items-to-blocks.js +8 -7
- package/src/navigation/placeholder-preview.js +3 -3
- package/src/navigation/placeholder.js +1 -1
- package/src/navigation/style.scss +191 -145
- package/src/navigation/test/menu-items-to-blocks.js +6 -6
- package/src/navigation/use-block-navigator.js +1 -0
- package/src/navigation/variations.js +2 -3
- package/src/navigation/view.js +74 -4
- package/src/navigation-link/block.json +2 -1
- package/src/navigation-link/edit.js +63 -90
- package/src/navigation-link/editor.scss +30 -15
- package/src/navigation-link/index.js +2 -0
- package/src/navigation-link/index.php +8 -8
- package/src/navigation-link/transforms.js +93 -0
- package/src/navigation-submenu/block.json +65 -0
- package/src/navigation-submenu/edit.js +662 -0
- package/src/navigation-submenu/editor.scss +42 -0
- package/src/navigation-submenu/icons.js +16 -0
- package/src/navigation-submenu/index.js +29 -0
- package/src/navigation-submenu/index.php +299 -0
- package/src/navigation-submenu/save.js +8 -0
- package/src/navigation-submenu/style.scss +20 -0
- package/src/navigation-submenu/transforms.js +58 -0
- package/src/navigation-submenu/view.js +62 -0
- package/src/page-list/block.json +11 -1
- package/src/page-list/convert-to-links-modal.js +20 -0
- package/src/page-list/edit.js +18 -4
- package/src/page-list/editor.scss +14 -0
- package/src/page-list/index.php +48 -12
- package/src/page-list/style.scss +2 -14
- package/src/page-list/test/convert-to-links-modal.js +6 -6
- package/src/paragraph/style.scss +10 -1
- package/src/post-author/block.json +2 -1
- package/src/post-comment/edit.js +14 -7
- package/src/post-comment-author/edit.js +13 -10
- package/src/post-comment-content/edit.js +17 -9
- package/src/post-comment-content/index.php +6 -3
- package/src/post-content/edit.js +1 -3
- package/src/post-date/block.json +2 -1
- package/src/post-date/edit.js +36 -22
- package/src/post-excerpt/edit.js +1 -0
- package/src/post-featured-image/block.json +5 -0
- package/src/post-featured-image/dimension-controls.js +43 -35
- package/src/post-featured-image/editor.scss +4 -9
- package/src/post-featured-image/style.scss +1 -0
- package/src/post-navigation-link/block.json +9 -1
- package/src/post-navigation-link/edit.js +29 -2
- package/src/post-navigation-link/index.php +28 -3
- package/src/post-template/block.json +4 -1
- package/src/post-template/index.js +2 -2
- package/src/post-template/index.php +11 -0
- package/src/post-template/style.scss +2 -0
- package/src/post-terms/block.json +2 -1
- package/src/post-terms/edit.js +4 -5
- package/src/post-title/block.json +4 -1
- package/src/post-title/edit.js +4 -6
- package/src/post-title/index.php +1 -1
- package/src/pullquote/style.scss +1 -0
- package/src/query/edit/index.js +3 -3
- package/src/query/variations.js +4 -0
- package/src/query-pagination/block.json +16 -0
- package/src/query-pagination/deprecated.js +19 -0
- package/src/query-pagination/edit.js +58 -3
- package/src/query-pagination/editor.scss +3 -6
- package/src/query-pagination/index.js +2 -0
- package/src/query-pagination/index.php +24 -1
- package/src/query-pagination/query-pagination-arrow-controls.js +44 -0
- package/src/query-pagination/save.js +2 -6
- package/src/query-pagination/style.scss +22 -5
- package/src/query-pagination-next/block.json +1 -1
- package/src/query-pagination-next/edit.js +30 -8
- package/src/query-pagination-next/index.php +5 -1
- package/src/query-pagination-previous/block.json +1 -1
- package/src/query-pagination-previous/edit.js +30 -8
- package/src/query-pagination-previous/index.php +5 -1
- package/src/quote/style.scss +2 -0
- package/src/reset.scss +2 -1
- package/src/search/index.php +12 -15
- package/src/search/test/__snapshots__/edit.native.js.snap +7 -0
- package/src/site-logo/block.json +7 -2
- package/src/site-logo/edit.js +98 -30
- package/src/site-logo/index.php +31 -2
- package/src/site-tagline/block.json +1 -0
- package/src/site-title/block.json +9 -2
- package/src/site-title/edit/index.js +36 -9
- package/src/site-title/index.php +12 -2
- package/src/social-links/block.json +22 -1
- package/src/social-links/deprecated.js +99 -0
- package/src/social-links/edit.js +13 -24
- package/src/social-links/save.js +1 -7
- package/src/social-links/style.scss +0 -8
- package/src/style.scss +1 -5
- package/src/table/block.json +1 -1
- package/src/template-part/edit/advanced-controls.js +3 -3
- package/src/template-part/edit/index.js +0 -3
- package/src/template-part/index.php +1 -1
- package/src/theme.scss +0 -10
- package/src/video/edit-common-settings.js +2 -2
- package/src/video/edit.js +15 -5
- package/src/video/tracks-editor.js +2 -3
- package/build/embed/embed-controls.native.js +0 -32
- package/build/embed/embed-controls.native.js.map +0 -1
- package/build/embed/variations.native.js +0 -10
- package/build/embed/variations.native.js.map +0 -1
- package/build/gallery/gallery-button.native.js.map +0 -1
- package/build/gallery/gallery-image.js.map +0 -1
- package/build/gallery/gallery-image.native.js.map +0 -1
- package/build/gallery/tiles.native.js.map +0 -1
- package/build/image/image-editing/aspect-ratio-dropdown.js +0 -126
- package/build/image/image-editing/aspect-ratio-dropdown.js.map +0 -1
- package/build/image/image-editing/constants.js +0 -16
- package/build/image/image-editing/constants.js.map +0 -1
- package/build/image/image-editing/context.js +0 -59
- package/build/image/image-editing/context.js.map +0 -1
- package/build/image/image-editing/cropper.js +0 -83
- package/build/image/image-editing/cropper.js.map +0 -1
- package/build/image/image-editing/form-controls.js +0 -36
- package/build/image/image-editing/form-controls.js.map +0 -1
- package/build/image/image-editing/index.js +0 -60
- package/build/image/image-editing/index.js.map +0 -1
- package/build/image/image-editing/rotation-button.js +0 -37
- package/build/image/image-editing/rotation-button.js.map +0 -1
- package/build/image/image-editing/use-save-image.js +0 -84
- package/build/image/image-editing/use-save-image.js.map +0 -1
- package/build/image/image-editing/use-transform-image.js +0 -135
- package/build/image/image-editing/use-transform-image.js.map +0 -1
- package/build/image/image-editing/zoom-dropdown.js +0 -55
- package/build/image/image-editing/zoom-dropdown.js.map +0 -1
- package/build-module/embed/embed-controls.native.js +0 -21
- package/build-module/embed/embed-controls.native.js.map +0 -1
- package/build-module/embed/variations.native.js +0 -3
- package/build-module/embed/variations.native.js.map +0 -1
- package/build-module/gallery/gallery-button.native.js.map +0 -1
- package/build-module/gallery/gallery-image.js.map +0 -1
- package/build-module/gallery/gallery-image.native.js.map +0 -1
- package/build-module/gallery/tiles.native.js.map +0 -1
- package/build-module/image/image-editing/aspect-ratio-dropdown.js +0 -115
- package/build-module/image/image-editing/aspect-ratio-dropdown.js.map +0 -1
- package/build-module/image/image-editing/constants.js +0 -7
- package/build-module/image/image-editing/constants.js.map +0 -1
- package/build-module/image/image-editing/context.js +0 -44
- package/build-module/image/image-editing/context.js.map +0 -1
- package/build-module/image/image-editing/cropper.js +0 -69
- package/build-module/image/image-editing/cropper.js.map +0 -1
- package/build-module/image/image-editing/form-controls.js +0 -26
- package/build-module/image/image-editing/form-controls.js.map +0 -1
- package/build-module/image/image-editing/index.js +0 -37
- package/build-module/image/image-editing/index.js.map +0 -1
- package/build-module/image/image-editing/rotation-button.js +0 -26
- package/build-module/image/image-editing/rotation-button.js.map +0 -1
- package/build-module/image/image-editing/use-save-image.js +0 -70
- package/build-module/image/image-editing/use-save-image.js.map +0 -1
- package/build-module/image/image-editing/use-transform-image.js +0 -127
- package/build-module/image/image-editing/use-transform-image.js.map +0 -1
- package/build-module/image/image-editing/zoom-dropdown.js +0 -43
- package/build-module/image/image-editing/zoom-dropdown.js.map +0 -1
- package/src/embed/embed-controls.native.js +0 -23
- package/src/embed/variations.native.js +0 -3
- package/src/heading/editor.scss +0 -20
- package/src/image/image-editing/aspect-ratio-dropdown.js +0 -129
- package/src/image/image-editing/constants.js +0 -6
- package/src/image/image-editing/context.js +0 -56
- package/src/image/image-editing/cropper.js +0 -74
- package/src/image/image-editing/form-controls.js +0 -22
- package/src/image/image-editing/index.js +0 -52
- package/src/image/image-editing/rotation-button.js +0 -24
- package/src/image/image-editing/use-save-image.js +0 -97
- package/src/image/image-editing/use-transform-image.js +0 -162
- package/src/image/image-editing/zoom-dropdown.js +0 -40
- package/src/post-content/editor.scss +0 -11
package/src/gallery/shared.js
CHANGED
|
@@ -3,8 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { get, pick } from 'lodash';
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { __ } from '@wordpress/i18n';
|
|
10
|
+
|
|
11
|
+
export function defaultColumnsNumber( imageCount ) {
|
|
12
|
+
return imageCount ? Math.min( 3, imageCount ) : 3;
|
|
8
13
|
}
|
|
9
14
|
|
|
10
15
|
export const pickRelevantMediaFiles = ( image, sizeSlug = 'large' ) => {
|
|
@@ -19,5 +24,7 @@ export const pickRelevantMediaFiles = ( image, sizeSlug = 'large' ) => {
|
|
|
19
24
|
if ( fullUrl ) {
|
|
20
25
|
imageProps.fullUrl = fullUrl;
|
|
21
26
|
}
|
|
27
|
+
imageProps.alt =
|
|
28
|
+
imageProps.alt !== '' ? imageProps.alt : __( 'Image gallery image' );
|
|
22
29
|
return imageProps;
|
|
23
30
|
};
|
package/src/gallery/style.scss
CHANGED
|
@@ -1,129 +1,169 @@
|
|
|
1
|
-
.
|
|
2
|
-
.
|
|
1
|
+
// Import styles for rendering the static content of deprecated gallery versions.
|
|
2
|
+
@import "./deprecated.scss";
|
|
3
|
+
|
|
4
|
+
// Styles for current version of gallery block.
|
|
5
|
+
.wp-block-gallery.has-nested-images {
|
|
3
6
|
display: flex;
|
|
4
7
|
flex-wrap: wrap;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
margin: 0;
|
|
9
|
-
|
|
10
|
-
.blocks-gallery-image,
|
|
11
|
-
.blocks-gallery-item {
|
|
8
|
+
// Need bogus :not(#individual-image) to override long :not()
|
|
9
|
+
// specificity chain on default image block on front end.
|
|
10
|
+
figure.wp-block-image:not(#individual-image) {
|
|
12
11
|
// Add space between thumbnails, and unset right most thumbnails later.
|
|
13
|
-
margin: 0
|
|
14
|
-
display: flex;
|
|
15
|
-
flex-grow: 1;
|
|
16
|
-
flex-direction: column;
|
|
17
|
-
justify-content: center;
|
|
18
|
-
position: relative;
|
|
19
|
-
align-self: flex-start;
|
|
12
|
+
margin: 0 var(--gallery-block--gutter-size, #{$grid-unit-20}) var(--gallery-block--gutter-size, #{$grid-unit-20}) 0;
|
|
20
13
|
|
|
21
|
-
|
|
22
|
-
|
|
14
|
+
&:last-of-type:not(#individual-image) {
|
|
15
|
+
margin-right: 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
width: calc(50% - (var(--gallery-block--gutter-size, #{$grid-unit-20}) / 2));
|
|
23
19
|
|
|
24
20
|
&:nth-of-type(even) {
|
|
25
21
|
margin-right: 0;
|
|
26
22
|
}
|
|
23
|
+
}
|
|
27
24
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
figure.wp-block-image {
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-grow: 1;
|
|
28
|
+
justify-content: center;
|
|
29
|
+
position: relative;
|
|
30
|
+
margin-top: auto;
|
|
31
|
+
margin-bottom: auto;
|
|
32
|
+
flex-direction: column;
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
34
|
+
> div,
|
|
35
|
+
> a {
|
|
36
|
+
margin: 0;
|
|
37
|
+
flex-direction: column;
|
|
38
|
+
flex-grow: 1;
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
img {
|
|
41
42
|
display: block;
|
|
42
|
-
max-width: 100%;
|
|
43
43
|
height: auto;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
width: 100%;
|
|
47
|
-
|
|
48
|
-
// IE11 doesn't read rules inside this query. They are applied only to modern browsers.
|
|
49
|
-
@supports (position: sticky) {
|
|
50
|
-
width: auto;
|
|
51
|
-
}
|
|
44
|
+
max-width: 100%;
|
|
45
|
+
width: auto;
|
|
52
46
|
}
|
|
53
47
|
|
|
54
48
|
figcaption {
|
|
55
|
-
|
|
49
|
+
background: linear-gradient(0deg, rgba($color: $black, $alpha: 0.7) 0, rgba($color: $black, $alpha: 0.3) 70%, transparent);
|
|
56
50
|
bottom: 0;
|
|
57
|
-
width: 100%;
|
|
58
|
-
max-height: 100%;
|
|
59
|
-
overflow: auto;
|
|
60
|
-
padding: 3em 0.77em 0.7em;
|
|
61
51
|
color: $white;
|
|
52
|
+
font-size: $default-font-size;
|
|
53
|
+
left: 0;
|
|
54
|
+
margin-bottom: 0;
|
|
55
|
+
max-height: 60%;
|
|
56
|
+
overflow: auto;
|
|
57
|
+
padding: 0 8px 8px;
|
|
58
|
+
position: absolute;
|
|
62
59
|
text-align: center;
|
|
63
|
-
|
|
64
|
-
background: linear-gradient(0deg, rgba($color: $black, $alpha: 0.7) 0, rgba($color: $black, $alpha: 0.3) 70%, transparent);
|
|
60
|
+
width: 100%;
|
|
65
61
|
box-sizing: border-box;
|
|
66
|
-
margin: 0;
|
|
67
62
|
|
|
68
63
|
img {
|
|
69
64
|
display: inline;
|
|
70
65
|
}
|
|
71
66
|
}
|
|
67
|
+
|
|
68
|
+
&.is-style-rounded {
|
|
69
|
+
> div,
|
|
70
|
+
> a {
|
|
71
|
+
flex: 1 1 auto;
|
|
72
|
+
}
|
|
73
|
+
figcaption {
|
|
74
|
+
flex: initial;
|
|
75
|
+
background: none;
|
|
76
|
+
color: inherit;
|
|
77
|
+
margin: 0;
|
|
78
|
+
padding: 10px 10px 9px;
|
|
79
|
+
position: relative;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
72
82
|
}
|
|
73
83
|
|
|
74
84
|
figcaption {
|
|
75
85
|
flex-grow: 1;
|
|
86
|
+
flex-basis: 100%;
|
|
87
|
+
text-align: center;
|
|
76
88
|
}
|
|
77
89
|
|
|
78
|
-
//
|
|
79
|
-
|
|
80
|
-
|
|
90
|
+
// Non cropped images.
|
|
91
|
+
&:not(.is-cropped) {
|
|
92
|
+
|
|
93
|
+
figure.wp-block-image:not(#individual-image) {
|
|
94
|
+
margin-top: 0;
|
|
95
|
+
margin-bottom: auto;
|
|
96
|
+
img {
|
|
97
|
+
margin-bottom: var(--gallery-block--gutter-size, #{$grid-unit-20});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
figcaption {
|
|
101
|
+
bottom: var(--gallery-block--gutter-size, #{$grid-unit-20});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// Cropped Images.
|
|
107
|
+
&.is-cropped figure.wp-block-image:not(#individual-image) {
|
|
81
108
|
align-self: inherit;
|
|
109
|
+
> div:not(.components-drop-zone),
|
|
110
|
+
> a {
|
|
111
|
+
display: flex;
|
|
112
|
+
}
|
|
82
113
|
|
|
83
114
|
a,
|
|
84
115
|
img {
|
|
85
|
-
// IE11 doesn't support object-fit, so just make sure images aren't skewed.
|
|
86
|
-
// The following rules are for all browsers.
|
|
87
116
|
width: 100%;
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
height: 100%;
|
|
92
|
-
flex: 1;
|
|
93
|
-
object-fit: cover;
|
|
94
|
-
}
|
|
117
|
+
flex: 1 0 0%;
|
|
118
|
+
height: 100%;
|
|
119
|
+
object-fit: cover;
|
|
95
120
|
}
|
|
96
121
|
}
|
|
97
122
|
|
|
98
|
-
&.columns-1 .
|
|
99
|
-
&.columns-1 .blocks-gallery-item {
|
|
100
|
-
width: 100%;
|
|
123
|
+
&.columns-1 figure.wp-block-image:not(#individual-image) {
|
|
101
124
|
margin-right: 0;
|
|
125
|
+
width: 100%;
|
|
102
126
|
}
|
|
103
127
|
|
|
104
128
|
// Beyond mobile viewports, we allow up to 8 columns.
|
|
105
129
|
@include break-small {
|
|
106
130
|
@for $i from 3 through 8 {
|
|
107
|
-
&.columns-#{ $i } .
|
|
108
|
-
|
|
109
|
-
width: calc(#{
|
|
110
|
-
|
|
131
|
+
&.columns-#{ $i } figure.wp-block-image:not(#individual-image) {
|
|
132
|
+
margin-right: var(--gallery-block--gutter-size, #{$grid-unit-20});
|
|
133
|
+
width: calc(#{math.div(100%, $i)} - (var(--gallery-block--gutter-size, #{$grid-unit-20}) * #{math.div($i - 1, $i)}));
|
|
134
|
+
|
|
111
135
|
}
|
|
112
|
-
}
|
|
113
136
|
|
|
137
|
+
// Prevent collapsing margin while sibling is being dragged.
|
|
138
|
+
&.columns-#{$i} figure.wp-block-image:not(#individual-image).is-dragging ~ figure.wp-block-image:not(#individual-image) {
|
|
139
|
+
margin-right: var(--gallery-block--gutter-size, #{$grid-unit-20});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
114
142
|
// Unset the right margin on every rightmost gallery item to ensure center balance.
|
|
115
143
|
@for $column-count from 1 through 8 {
|
|
116
|
-
&.columns-#{
|
|
117
|
-
&.columns-#{ $column-count } .blocks-gallery-item:nth-of-type(#{ $column-count }n) {
|
|
144
|
+
&.columns-#{$column-count} figure.wp-block-image:not(#individual-image):nth-of-type(#{ $column-count }n) {
|
|
118
145
|
margin-right: 0;
|
|
119
146
|
}
|
|
120
147
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
148
|
+
// If number of columns not explicitly set default to 3 columns if 3 or more images.
|
|
149
|
+
&.columns-default {
|
|
150
|
+
figure.wp-block-image:not(#individual-image) {
|
|
151
|
+
margin-right: var(--gallery-block--gutter-size, #{$grid-unit-20});
|
|
152
|
+
width: calc(33.33% - (var(--gallery-block--gutter-size, 16px) * #{math.div(2, 3)}));
|
|
153
|
+
}
|
|
154
|
+
figure.wp-block-image:not(#individual-image):nth-of-type(3n+3) {
|
|
155
|
+
margin-right: 0;
|
|
156
|
+
}
|
|
157
|
+
// If only 2 child images use 2 columns.
|
|
158
|
+
figure.wp-block-image:not(#individual-image):first-child:nth-last-child(2),
|
|
159
|
+
figure.wp-block-image:not(#individual-image):first-child:nth-last-child(2) ~ figure.wp-block-image:not(#individual-image) {
|
|
160
|
+
width: calc(50% - (var(--gallery-block--gutter-size, 16px) * 0.5));
|
|
161
|
+
}
|
|
162
|
+
// For a single image set to 100%.
|
|
163
|
+
figure.wp-block-image:not(#individual-image):first-child:nth-last-child(1) {
|
|
164
|
+
width: 100%;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
127
167
|
}
|
|
128
168
|
|
|
129
169
|
// Apply max-width to floated items that have no intrinsic width.
|
|
@@ -135,8 +175,6 @@
|
|
|
135
175
|
|
|
136
176
|
// If the gallery is centered, center the content inside as well.
|
|
137
177
|
&.aligncenter {
|
|
138
|
-
|
|
139
|
-
justify-content: center;
|
|
140
|
-
}
|
|
178
|
+
justify-content: center;
|
|
141
179
|
}
|
|
142
180
|
}
|
|
@@ -8,12 +8,23 @@ import { filter, every, toString } from 'lodash';
|
|
|
8
8
|
*/
|
|
9
9
|
import { createBlock } from '@wordpress/blocks';
|
|
10
10
|
import { createBlobURL } from '@wordpress/blob';
|
|
11
|
+
import { select } from '@wordpress/data';
|
|
12
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
13
|
+
import { addFilter } from '@wordpress/hooks';
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* Internal dependencies
|
|
14
17
|
*/
|
|
18
|
+
import {
|
|
19
|
+
LINK_DESTINATION_ATTACHMENT,
|
|
20
|
+
LINK_DESTINATION_NONE,
|
|
21
|
+
LINK_DESTINATION_MEDIA,
|
|
22
|
+
} from './constants';
|
|
23
|
+
import {
|
|
24
|
+
LINK_DESTINATION_ATTACHMENT as DEPRECATED_LINK_DESTINATION_ATTACHMENT,
|
|
25
|
+
LINK_DESTINATION_MEDIA as DEPRECATED_LINK_DESTINATION_MEDIA,
|
|
26
|
+
} from './v1/constants';
|
|
15
27
|
import { pickRelevantMediaFiles } from './shared';
|
|
16
|
-
import { LINK_DESTINATION_ATTACHMENT } from './constants';
|
|
17
28
|
|
|
18
29
|
const parseShortcodeIds = ( ids ) => {
|
|
19
30
|
if ( ! ids ) {
|
|
@@ -23,6 +34,98 @@ const parseShortcodeIds = ( ids ) => {
|
|
|
23
34
|
return ids.split( ',' ).map( ( id ) => parseInt( id, 10 ) );
|
|
24
35
|
};
|
|
25
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Third party block plugins don't have an easy way to detect if the
|
|
39
|
+
* innerBlocks version of the Gallery is running when they run a
|
|
40
|
+
* 3rdPartyBlock -> GalleryBlock transform so this tranform filter
|
|
41
|
+
* will handle this. Once the innerBlocks version is the default
|
|
42
|
+
* in a core release, this could be deprecated and removed after
|
|
43
|
+
* plugin authors have been given time to update transforms.
|
|
44
|
+
*
|
|
45
|
+
* @typedef {Object} Attributes
|
|
46
|
+
* @typedef {Object} Block
|
|
47
|
+
* @property {Attributes} attributes The attributes of the block.
|
|
48
|
+
* @param {Block} block The transformed block.
|
|
49
|
+
* @return {Block} The transformed block.
|
|
50
|
+
*/
|
|
51
|
+
function updateThirdPartyTransformToGallery( block ) {
|
|
52
|
+
const settings = select( blockEditorStore ).getSettings();
|
|
53
|
+
if (
|
|
54
|
+
settings.__unstableGalleryWithImageBlocks &&
|
|
55
|
+
block.name === 'core/gallery' &&
|
|
56
|
+
block.attributes?.images.length > 0
|
|
57
|
+
) {
|
|
58
|
+
const innerBlocks = block.attributes.images.map(
|
|
59
|
+
( { url, id, alt } ) => {
|
|
60
|
+
return createBlock( 'core/image', {
|
|
61
|
+
url,
|
|
62
|
+
id: id ? parseInt( id, 10 ) : null,
|
|
63
|
+
alt,
|
|
64
|
+
sizeSlug: block.attributes.sizeSlug,
|
|
65
|
+
linkDestination: block.attributes.linkDestination,
|
|
66
|
+
} );
|
|
67
|
+
}
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
delete block.attributes.ids;
|
|
71
|
+
delete block.attributes.images;
|
|
72
|
+
block.innerBlocks = innerBlocks;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return block;
|
|
76
|
+
}
|
|
77
|
+
addFilter(
|
|
78
|
+
'blocks.switchToBlockType.transformedBlock',
|
|
79
|
+
'core/gallery/update-third-party-transform-to',
|
|
80
|
+
updateThirdPartyTransformToGallery
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Third party block plugins don't have an easy way to detect if the
|
|
85
|
+
* innerBlocks version of the Gallery is running when they run a
|
|
86
|
+
* GalleryBlock -> 3rdPartyBlock transform so this transform filter
|
|
87
|
+
* will handle this. Once the innerBlocks version is the default
|
|
88
|
+
* in a core release, this could be deprecated and removed after
|
|
89
|
+
* plugin authors have been given time to update transforms.
|
|
90
|
+
*
|
|
91
|
+
* @typedef {Object} Attributes
|
|
92
|
+
* @typedef {Object} Block
|
|
93
|
+
* @property {Attributes} attributes The attributes of the block.
|
|
94
|
+
* @param {Block} toBlock The block to transform to.
|
|
95
|
+
* @param {Block[]} fromBlocks The blocks to transform from.
|
|
96
|
+
* @return {Block} The transformed block.
|
|
97
|
+
*/
|
|
98
|
+
function updateThirdPartyTransformFromGallery( toBlock, fromBlocks ) {
|
|
99
|
+
const from = Array.isArray( fromBlocks ) ? fromBlocks : [ fromBlocks ];
|
|
100
|
+
const galleryBlock = from.find(
|
|
101
|
+
( transformedBlock ) =>
|
|
102
|
+
transformedBlock.name === 'core/gallery' &&
|
|
103
|
+
transformedBlock.innerBlocks.length > 0 &&
|
|
104
|
+
! transformedBlock.attributes.images?.length > 0 &&
|
|
105
|
+
! toBlock.name.includes( 'core/' )
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
if ( galleryBlock ) {
|
|
109
|
+
const images = galleryBlock.innerBlocks.map(
|
|
110
|
+
( { attributes: { url, id, alt } } ) => ( {
|
|
111
|
+
url,
|
|
112
|
+
id: id ? parseInt( id, 10 ) : null,
|
|
113
|
+
alt,
|
|
114
|
+
} )
|
|
115
|
+
);
|
|
116
|
+
const ids = images.map( ( { id } ) => id );
|
|
117
|
+
galleryBlock.attributes.images = images;
|
|
118
|
+
galleryBlock.attributes.ids = ids;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return toBlock;
|
|
122
|
+
}
|
|
123
|
+
addFilter(
|
|
124
|
+
'blocks.switchToBlockType.transformedBlock',
|
|
125
|
+
'core/gallery/update-third-party-transform-from',
|
|
126
|
+
updateThirdPartyTransformFromGallery
|
|
127
|
+
);
|
|
128
|
+
|
|
26
129
|
const transforms = {
|
|
27
130
|
from: [
|
|
28
131
|
{
|
|
@@ -42,6 +145,22 @@ const transforms = {
|
|
|
42
145
|
|
|
43
146
|
const validImages = filter( attributes, ( { url } ) => url );
|
|
44
147
|
|
|
148
|
+
const settings = select( blockEditorStore ).getSettings();
|
|
149
|
+
if ( settings.__unstableGalleryWithImageBlocks ) {
|
|
150
|
+
const innerBlocks = validImages.map( ( image ) => {
|
|
151
|
+
return createBlock( 'core/image', image );
|
|
152
|
+
} );
|
|
153
|
+
|
|
154
|
+
return createBlock(
|
|
155
|
+
'core/gallery',
|
|
156
|
+
{
|
|
157
|
+
align,
|
|
158
|
+
sizeSlug,
|
|
159
|
+
},
|
|
160
|
+
innerBlocks
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
45
164
|
return createBlock( 'core/gallery', {
|
|
46
165
|
images: validImages.map(
|
|
47
166
|
( { id, url, alt, caption } ) => ( {
|
|
@@ -60,19 +179,43 @@ const transforms = {
|
|
|
60
179
|
{
|
|
61
180
|
type: 'shortcode',
|
|
62
181
|
tag: 'gallery',
|
|
182
|
+
|
|
63
183
|
attributes: {
|
|
64
184
|
images: {
|
|
65
185
|
type: 'array',
|
|
66
186
|
shortcode: ( { named: { ids } } ) => {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
187
|
+
const settings = select(
|
|
188
|
+
blockEditorStore
|
|
189
|
+
).getSettings();
|
|
190
|
+
if ( ! settings.__unstableGalleryWithImageBlocks ) {
|
|
191
|
+
return parseShortcodeIds( ids ).map( ( id ) => ( {
|
|
192
|
+
id: toString( id ),
|
|
193
|
+
} ) );
|
|
194
|
+
}
|
|
70
195
|
},
|
|
71
196
|
},
|
|
72
197
|
ids: {
|
|
73
198
|
type: 'array',
|
|
74
199
|
shortcode: ( { named: { ids } } ) => {
|
|
75
|
-
|
|
200
|
+
const settings = select(
|
|
201
|
+
blockEditorStore
|
|
202
|
+
).getSettings();
|
|
203
|
+
if ( ! settings.__unstableGalleryWithImageBlocks ) {
|
|
204
|
+
return parseShortcodeIds( ids );
|
|
205
|
+
}
|
|
206
|
+
},
|
|
207
|
+
},
|
|
208
|
+
shortCodeTransforms: {
|
|
209
|
+
type: 'array',
|
|
210
|
+
shortcode: ( { named: { ids } } ) => {
|
|
211
|
+
const settings = select(
|
|
212
|
+
blockEditorStore
|
|
213
|
+
).getSettings();
|
|
214
|
+
if ( settings.__unstableGalleryWithImageBlocks ) {
|
|
215
|
+
return parseShortcodeIds( ids ).map( ( id ) => ( {
|
|
216
|
+
id: parseInt( id ),
|
|
217
|
+
} ) );
|
|
218
|
+
}
|
|
76
219
|
},
|
|
77
220
|
},
|
|
78
221
|
columns: {
|
|
@@ -83,10 +226,28 @@ const transforms = {
|
|
|
83
226
|
},
|
|
84
227
|
linkTo: {
|
|
85
228
|
type: 'string',
|
|
86
|
-
shortcode: ( {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
229
|
+
shortcode: ( { named: { link } } ) => {
|
|
230
|
+
const settings = select(
|
|
231
|
+
blockEditorStore
|
|
232
|
+
).getSettings();
|
|
233
|
+
if ( ! settings.__unstableGalleryWithImageBlocks ) {
|
|
234
|
+
switch ( link ) {
|
|
235
|
+
case 'post':
|
|
236
|
+
return DEPRECATED_LINK_DESTINATION_ATTACHMENT;
|
|
237
|
+
case 'file':
|
|
238
|
+
return DEPRECATED_LINK_DESTINATION_MEDIA;
|
|
239
|
+
default:
|
|
240
|
+
return DEPRECATED_LINK_DESTINATION_ATTACHMENT;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
switch ( link ) {
|
|
244
|
+
case 'post':
|
|
245
|
+
return LINK_DESTINATION_ATTACHMENT;
|
|
246
|
+
case 'file':
|
|
247
|
+
return LINK_DESTINATION_MEDIA;
|
|
248
|
+
default:
|
|
249
|
+
return LINK_DESTINATION_NONE;
|
|
250
|
+
}
|
|
90
251
|
},
|
|
91
252
|
},
|
|
92
253
|
},
|
|
@@ -95,8 +256,13 @@ const transforms = {
|
|
|
95
256
|
},
|
|
96
257
|
},
|
|
97
258
|
{
|
|
98
|
-
// When created by drag and dropping multiple files on an insertion point
|
|
259
|
+
// When created by drag and dropping multiple files on an insertion point. Because multiple
|
|
260
|
+
// files must not be transformed to a gallery when dropped within a gallery there is another transform
|
|
261
|
+
// within the image block to handle that case. Therefore this transform has to have priority 1
|
|
262
|
+
// set so that it overrrides the image block transformation when mulitple images are dropped outside
|
|
263
|
+
// of a gallery block.
|
|
99
264
|
type: 'files',
|
|
265
|
+
priority: 1,
|
|
100
266
|
isMatch( files ) {
|
|
101
267
|
return (
|
|
102
268
|
files.length !== 1 &&
|
|
@@ -107,6 +273,16 @@ const transforms = {
|
|
|
107
273
|
);
|
|
108
274
|
},
|
|
109
275
|
transform( files ) {
|
|
276
|
+
const settings = select( blockEditorStore ).getSettings();
|
|
277
|
+
if ( settings.__unstableGalleryWithImageBlocks ) {
|
|
278
|
+
const innerBlocks = files.map( ( file ) =>
|
|
279
|
+
createBlock( 'core/image', {
|
|
280
|
+
url: createBlobURL( file ),
|
|
281
|
+
} )
|
|
282
|
+
);
|
|
283
|
+
|
|
284
|
+
return createBlock( 'core/gallery', {}, innerBlocks );
|
|
285
|
+
}
|
|
110
286
|
const block = createBlock( 'core/gallery', {
|
|
111
287
|
images: files.map( ( file ) =>
|
|
112
288
|
pickRelevantMediaFiles( {
|
|
@@ -122,7 +298,32 @@ const transforms = {
|
|
|
122
298
|
{
|
|
123
299
|
type: 'block',
|
|
124
300
|
blocks: [ 'core/image' ],
|
|
125
|
-
transform: ( { images,
|
|
301
|
+
transform: ( { align, images, ids, sizeSlug }, innerBlocks ) => {
|
|
302
|
+
const settings = select( blockEditorStore ).getSettings();
|
|
303
|
+
if ( settings.__unstableGalleryWithImageBlocks ) {
|
|
304
|
+
if ( innerBlocks.length > 0 ) {
|
|
305
|
+
return innerBlocks.map(
|
|
306
|
+
( {
|
|
307
|
+
attributes: {
|
|
308
|
+
id,
|
|
309
|
+
url,
|
|
310
|
+
alt,
|
|
311
|
+
caption,
|
|
312
|
+
imageSizeSlug,
|
|
313
|
+
},
|
|
314
|
+
} ) =>
|
|
315
|
+
createBlock( 'core/image', {
|
|
316
|
+
id,
|
|
317
|
+
url,
|
|
318
|
+
alt,
|
|
319
|
+
caption,
|
|
320
|
+
sizeSlug: imageSizeSlug,
|
|
321
|
+
align,
|
|
322
|
+
} )
|
|
323
|
+
);
|
|
324
|
+
}
|
|
325
|
+
return createBlock( 'core/image', { align } );
|
|
326
|
+
}
|
|
126
327
|
if ( images.length > 0 ) {
|
|
127
328
|
return images.map( ( { url, alt, caption }, index ) =>
|
|
128
329
|
createBlock( 'core/image', {
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useState } from '@wordpress/element';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves the extended media info for each gallery image from the store. This is used to
|
|
10
|
+
* determine which image size options are available for the current gallery.
|
|
11
|
+
*
|
|
12
|
+
* @param {Array} innerBlockImages An array of the innerBlock images currently in the gallery.
|
|
13
|
+
*
|
|
14
|
+
* @return {Array} An array of media info options for each gallery image.
|
|
15
|
+
*/
|
|
16
|
+
export default function useGetMedia( innerBlockImages ) {
|
|
17
|
+
const [ currentImageMedia, setCurrentImageMedia ] = useState( [] );
|
|
18
|
+
|
|
19
|
+
const imageMedia = useSelect(
|
|
20
|
+
( select ) => {
|
|
21
|
+
if ( ! innerBlockImages?.length ) {
|
|
22
|
+
return currentImageMedia;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const imageIds = innerBlockImages
|
|
26
|
+
.map( ( imageBlock ) => imageBlock.attributes.id )
|
|
27
|
+
.filter( ( id ) => id !== undefined );
|
|
28
|
+
|
|
29
|
+
if ( imageIds.length === 0 ) {
|
|
30
|
+
return currentImageMedia;
|
|
31
|
+
}
|
|
32
|
+
const getMedia = select( coreStore ).getMedia;
|
|
33
|
+
const newImageMedia = imageIds.map( ( img ) => {
|
|
34
|
+
return getMedia( img );
|
|
35
|
+
} );
|
|
36
|
+
|
|
37
|
+
if ( newImageMedia.some( ( img ) => ! img ) ) {
|
|
38
|
+
return currentImageMedia;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
return newImageMedia;
|
|
42
|
+
},
|
|
43
|
+
[ innerBlockImages ]
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
if (
|
|
47
|
+
imageMedia?.length !== currentImageMedia.length ||
|
|
48
|
+
imageMedia.some(
|
|
49
|
+
( newImage ) =>
|
|
50
|
+
! currentImageMedia.find(
|
|
51
|
+
( currentImage ) => currentImage.id === newImage.id
|
|
52
|
+
)
|
|
53
|
+
)
|
|
54
|
+
) {
|
|
55
|
+
setCurrentImageMedia( imageMedia );
|
|
56
|
+
return imageMedia;
|
|
57
|
+
}
|
|
58
|
+
return currentImageMedia;
|
|
59
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useMemo, useState } from '@wordpress/element';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Keeps track of images already in the gallery to allow new innerBlocks to be identified. This
|
|
8
|
+
* is required so default gallery attributes can be applied without overwriting any custom
|
|
9
|
+
* attributes applied to existing images.
|
|
10
|
+
*
|
|
11
|
+
* @param {Array} images Basic image block data taken from current gallery innerBlock
|
|
12
|
+
* @param {Array} imageData The related image data for each of the current gallery images.
|
|
13
|
+
*
|
|
14
|
+
* @return {Array} An array of any new images that have been added to the gallery.
|
|
15
|
+
*/
|
|
16
|
+
export default function useGetNewImages( images, imageData ) {
|
|
17
|
+
const [ currentImages, setCurrentImages ] = useState( [] );
|
|
18
|
+
|
|
19
|
+
return useMemo( () => getNewImages(), [ images, imageData ] );
|
|
20
|
+
|
|
21
|
+
function getNewImages() {
|
|
22
|
+
let imagesUpdated = false;
|
|
23
|
+
|
|
24
|
+
// First lets check if any images have been deleted.
|
|
25
|
+
const newCurrentImages = currentImages.filter( ( currentImg ) =>
|
|
26
|
+
images.find( ( img ) => {
|
|
27
|
+
return currentImg.clientId === img.clientId;
|
|
28
|
+
} )
|
|
29
|
+
);
|
|
30
|
+
|
|
31
|
+
if ( newCurrentImages.length < currentImages.length ) {
|
|
32
|
+
imagesUpdated = true;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Now lets see if we have any images hydrated from saved content and if so
|
|
36
|
+
// add them to currentImages state.
|
|
37
|
+
images.forEach( ( image ) => {
|
|
38
|
+
if (
|
|
39
|
+
image.fromSavedContent &&
|
|
40
|
+
! newCurrentImages.find(
|
|
41
|
+
( currentImage ) => currentImage.id === image.id
|
|
42
|
+
)
|
|
43
|
+
) {
|
|
44
|
+
imagesUpdated = true;
|
|
45
|
+
newCurrentImages.push( image );
|
|
46
|
+
}
|
|
47
|
+
} );
|
|
48
|
+
|
|
49
|
+
// Now check for any new images that have been added to InnerBlocks and for which
|
|
50
|
+
// we have the imageData we need for setting default block attributes.
|
|
51
|
+
const newImages = images.filter(
|
|
52
|
+
( image ) =>
|
|
53
|
+
! newCurrentImages.find(
|
|
54
|
+
( currentImage ) =>
|
|
55
|
+
image.clientId &&
|
|
56
|
+
currentImage.clientId === image.clientId
|
|
57
|
+
) &&
|
|
58
|
+
imageData?.find( ( img ) => img.id === image.id ) &&
|
|
59
|
+
! image.fromSavedConent
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
if ( imagesUpdated || newImages?.length > 0 ) {
|
|
63
|
+
setCurrentImages( [ ...newCurrentImages, ...newImages ] );
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return newImages.length > 0 ? newImages : null;
|
|
67
|
+
}
|
|
68
|
+
}
|