@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/edit.js
CHANGED
|
@@ -1,279 +1,290 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
filter,
|
|
7
|
-
find,
|
|
8
|
-
forEach,
|
|
9
|
-
get,
|
|
10
|
-
isEmpty,
|
|
11
|
-
map,
|
|
12
|
-
reduce,
|
|
13
|
-
some,
|
|
14
|
-
toString,
|
|
15
|
-
} from 'lodash';
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
import { concat, find } from 'lodash';
|
|
16
6
|
|
|
17
7
|
/**
|
|
18
8
|
* WordPress dependencies
|
|
19
9
|
*/
|
|
20
10
|
import { compose } from '@wordpress/compose';
|
|
21
11
|
import {
|
|
12
|
+
BaseControl,
|
|
22
13
|
PanelBody,
|
|
23
14
|
SelectControl,
|
|
24
15
|
ToggleControl,
|
|
25
16
|
withNotices,
|
|
26
17
|
RangeControl,
|
|
18
|
+
Spinner,
|
|
27
19
|
} from '@wordpress/components';
|
|
28
20
|
import {
|
|
21
|
+
store as blockEditorStore,
|
|
29
22
|
MediaPlaceholder,
|
|
30
23
|
InspectorControls,
|
|
31
24
|
useBlockProps,
|
|
32
|
-
store as blockEditorStore,
|
|
33
25
|
} from '@wordpress/block-editor';
|
|
34
|
-
import { Platform, useEffect,
|
|
35
|
-
import { __ } from '@wordpress/i18n';
|
|
36
|
-
import {
|
|
37
|
-
import { useDispatch, useSelect } from '@wordpress/data';
|
|
26
|
+
import { Platform, useEffect, useMemo } from '@wordpress/element';
|
|
27
|
+
import { __, _x, sprintf } from '@wordpress/i18n';
|
|
28
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
38
29
|
import { withViewportMatch } from '@wordpress/viewport';
|
|
39
30
|
import { View } from '@wordpress/primitives';
|
|
40
|
-
import {
|
|
31
|
+
import { createBlock } from '@wordpress/blocks';
|
|
32
|
+
import { createBlobURL } from '@wordpress/blob';
|
|
33
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
41
34
|
|
|
42
35
|
/**
|
|
43
36
|
* Internal dependencies
|
|
44
37
|
*/
|
|
45
38
|
import { sharedIcon } from './shared-icon';
|
|
46
39
|
import { defaultColumnsNumber, pickRelevantMediaFiles } from './shared';
|
|
40
|
+
import { getHrefAndDestination } from './utils';
|
|
41
|
+
import {
|
|
42
|
+
getUpdatedLinkTargetSettings,
|
|
43
|
+
getImageSizeAttributes,
|
|
44
|
+
} from '../image/utils';
|
|
47
45
|
import Gallery from './gallery';
|
|
48
46
|
import {
|
|
49
47
|
LINK_DESTINATION_ATTACHMENT,
|
|
50
48
|
LINK_DESTINATION_MEDIA,
|
|
51
49
|
LINK_DESTINATION_NONE,
|
|
52
50
|
} from './constants';
|
|
51
|
+
import useImageSizes from './use-image-sizes';
|
|
52
|
+
import useShortCodeTransform from './use-short-code-transform';
|
|
53
|
+
import useGetNewImages from './use-get-new-images';
|
|
54
|
+
import useGetMedia from './use-get-media';
|
|
53
55
|
|
|
54
56
|
const MAX_COLUMNS = 8;
|
|
55
57
|
const linkOptions = [
|
|
56
58
|
{ value: LINK_DESTINATION_ATTACHMENT, label: __( 'Attachment Page' ) },
|
|
57
59
|
{ value: LINK_DESTINATION_MEDIA, label: __( 'Media File' ) },
|
|
58
|
-
{
|
|
60
|
+
{
|
|
61
|
+
value: LINK_DESTINATION_NONE,
|
|
62
|
+
label: _x( 'None', 'Media item link option' ),
|
|
63
|
+
},
|
|
59
64
|
];
|
|
60
65
|
const ALLOWED_MEDIA_TYPES = [ 'image' ];
|
|
61
66
|
|
|
62
|
-
const PLACEHOLDER_TEXT = Platform.
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
),
|
|
66
|
-
native: __( 'ADD MEDIA' ),
|
|
67
|
-
} );
|
|
67
|
+
const PLACEHOLDER_TEXT = Platform.isNative
|
|
68
|
+
? __( 'ADD MEDIA' )
|
|
69
|
+
: __( 'Drag images, upload new ones or select files from your library.' );
|
|
68
70
|
|
|
69
|
-
const MOBILE_CONTROL_PROPS_RANGE_CONTROL = Platform.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
} );
|
|
71
|
+
const MOBILE_CONTROL_PROPS_RANGE_CONTROL = Platform.isNative
|
|
72
|
+
? { type: 'stepper' }
|
|
73
|
+
: {};
|
|
73
74
|
|
|
74
75
|
function GalleryEdit( props ) {
|
|
75
76
|
const {
|
|
77
|
+
setAttributes,
|
|
76
78
|
attributes,
|
|
79
|
+
className,
|
|
77
80
|
clientId,
|
|
81
|
+
noticeOperations,
|
|
78
82
|
isSelected,
|
|
79
83
|
noticeUI,
|
|
80
|
-
|
|
81
|
-
onFocus,
|
|
84
|
+
insertBlocksAfter,
|
|
82
85
|
} = props;
|
|
86
|
+
|
|
83
87
|
const {
|
|
84
|
-
columns
|
|
88
|
+
columns,
|
|
85
89
|
imageCrop,
|
|
86
|
-
|
|
90
|
+
linkTarget,
|
|
87
91
|
linkTo,
|
|
92
|
+
shortCodeTransforms,
|
|
88
93
|
sizeSlug,
|
|
89
94
|
} = attributes;
|
|
90
|
-
const [ selectedImage, setSelectedImage ] = useState();
|
|
91
|
-
const [ attachmentCaptions, setAttachmentCaptions ] = useState();
|
|
92
|
-
const { __unstableMarkNextChangeAsNotPersistent } = useDispatch(
|
|
93
|
-
blockEditorStore
|
|
94
|
-
);
|
|
95
95
|
|
|
96
96
|
const {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
} =
|
|
102
|
-
const settings = select( blockEditorStore ).getSettings();
|
|
97
|
+
__unstableMarkNextChangeAsNotPersistent,
|
|
98
|
+
replaceInnerBlocks,
|
|
99
|
+
updateBlockAttributes,
|
|
100
|
+
} = useDispatch( blockEditorStore );
|
|
101
|
+
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
103
102
|
|
|
103
|
+
const { getBlock, getSettings, preferredStyle } = useSelect( ( select ) => {
|
|
104
|
+
const settings = select( blockEditorStore ).getSettings();
|
|
105
|
+
const preferredStyleVariations =
|
|
106
|
+
settings.__experimentalPreferredStyleVariations;
|
|
104
107
|
return {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
wasBlockJustInserted: select(
|
|
109
|
-
blockEditorStore
|
|
110
|
-
).wasBlockJustInserted( clientId, 'inserter_menu' ),
|
|
108
|
+
getBlock: select( blockEditorStore ).getBlock,
|
|
109
|
+
getSettings: select( blockEditorStore ).getSettings,
|
|
110
|
+
preferredStyle: preferredStyleVariations?.value?.[ 'core/image' ],
|
|
111
111
|
};
|
|
112
|
-
} );
|
|
112
|
+
}, [] );
|
|
113
113
|
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
return
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return currentResizedImages;
|
|
121
|
-
}
|
|
122
|
-
const image = getMedia( id );
|
|
123
|
-
const sizes = reduce(
|
|
124
|
-
imageSizes,
|
|
125
|
-
( currentSizes, size ) => {
|
|
126
|
-
const defaultUrl = get( image, [
|
|
127
|
-
'sizes',
|
|
128
|
-
size.slug,
|
|
129
|
-
'url',
|
|
130
|
-
] );
|
|
131
|
-
const mediaDetailsUrl = get( image, [
|
|
132
|
-
'media_details',
|
|
133
|
-
'sizes',
|
|
134
|
-
size.slug,
|
|
135
|
-
'source_url',
|
|
136
|
-
] );
|
|
137
|
-
return {
|
|
138
|
-
...currentSizes,
|
|
139
|
-
[ size.slug ]: defaultUrl || mediaDetailsUrl,
|
|
140
|
-
};
|
|
141
|
-
},
|
|
142
|
-
{}
|
|
143
|
-
);
|
|
144
|
-
return {
|
|
145
|
-
...currentResizedImages,
|
|
146
|
-
[ parseInt( id, 10 ) ]: sizes,
|
|
147
|
-
};
|
|
148
|
-
},
|
|
149
|
-
{}
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
return {};
|
|
153
|
-
}, [ isSelected, attributes.ids, imageSizes ] );
|
|
114
|
+
const innerBlockImages = useSelect(
|
|
115
|
+
( select ) => {
|
|
116
|
+
return select( blockEditorStore ).getBlock( clientId )?.innerBlocks;
|
|
117
|
+
},
|
|
118
|
+
[ clientId ]
|
|
119
|
+
);
|
|
154
120
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
121
|
+
const images = useMemo(
|
|
122
|
+
() =>
|
|
123
|
+
innerBlockImages?.map( ( block ) => ( {
|
|
124
|
+
clientId: block.clientId,
|
|
125
|
+
id: block.attributes.id,
|
|
126
|
+
url: block.attributes.url,
|
|
127
|
+
attributes: block.attributes,
|
|
128
|
+
fromSavedContent: Boolean( block.originalContent ),
|
|
129
|
+
} ) ),
|
|
130
|
+
[ innerBlockImages ]
|
|
131
|
+
);
|
|
158
132
|
|
|
159
|
-
|
|
160
|
-
if ( newAttrs.ids ) {
|
|
161
|
-
throw new Error(
|
|
162
|
-
'The "ids" attribute should not be changed directly. It is managed automatically when "images" attribute changes'
|
|
163
|
-
);
|
|
164
|
-
}
|
|
133
|
+
const imageData = useGetMedia( innerBlockImages );
|
|
165
134
|
|
|
166
|
-
|
|
167
|
-
newAttrs = {
|
|
168
|
-
...newAttrs,
|
|
169
|
-
// Unlike images[ n ].id which is a string, always ensure the
|
|
170
|
-
// ids array contains numbers as per its attribute type.
|
|
171
|
-
ids: map( newAttrs.images, ( { id } ) => parseInt( id, 10 ) ),
|
|
172
|
-
};
|
|
173
|
-
}
|
|
135
|
+
const newImages = useGetNewImages( images, imageData );
|
|
174
136
|
|
|
175
|
-
|
|
176
|
-
|
|
137
|
+
useEffect( () => {
|
|
138
|
+
newImages?.forEach( ( newImage ) => {
|
|
139
|
+
updateBlockAttributes( newImage.clientId, {
|
|
140
|
+
...buildImageAttributes( false, newImage.attributes ),
|
|
141
|
+
id: newImage.id,
|
|
142
|
+
align: undefined,
|
|
143
|
+
} );
|
|
144
|
+
} );
|
|
145
|
+
}, [ newImages ] );
|
|
177
146
|
|
|
178
|
-
|
|
179
|
-
return () => {
|
|
180
|
-
setSelectedImage( index );
|
|
181
|
-
};
|
|
182
|
-
}
|
|
147
|
+
const shortCodeImages = useShortCodeTransform( shortCodeTransforms );
|
|
183
148
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
|
|
149
|
+
useEffect( () => {
|
|
150
|
+
if ( ! shortCodeTransforms || ! shortCodeImages ) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
updateImages( shortCodeImages );
|
|
154
|
+
setAttributes( { shortCodeTransforms: undefined } );
|
|
155
|
+
}, [ shortCodeTransforms, shortCodeImages ] );
|
|
189
156
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
setAttributes( { images: newImages } );
|
|
196
|
-
}
|
|
157
|
+
const imageSizeOptions = useImageSizes(
|
|
158
|
+
imageData,
|
|
159
|
+
isSelected,
|
|
160
|
+
getSettings
|
|
161
|
+
);
|
|
197
162
|
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
163
|
+
/**
|
|
164
|
+
* Determines the image attributes that should be applied to an image block
|
|
165
|
+
* after the gallery updates.
|
|
166
|
+
*
|
|
167
|
+
* The gallery will receive the full collection of images when a new image
|
|
168
|
+
* is added. As a result we need to reapply the image's original settings if
|
|
169
|
+
* it already existed in the gallery. If the image is in fact new, we need
|
|
170
|
+
* to apply the gallery's current settings to the image.
|
|
171
|
+
*
|
|
172
|
+
* @param {Object} existingBlock Existing Image block that still exists after gallery update.
|
|
173
|
+
* @param {Object} image Media object for the actual image.
|
|
174
|
+
* @return {Object} Attributes to set on the new image block.
|
|
175
|
+
*/
|
|
176
|
+
function buildImageAttributes( existingBlock, image ) {
|
|
177
|
+
if ( existingBlock ) {
|
|
178
|
+
return existingBlock.attributes;
|
|
179
|
+
}
|
|
206
180
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
181
|
+
let newClassName;
|
|
182
|
+
if ( image.className && image.className !== '' ) {
|
|
183
|
+
newClassName = image.className;
|
|
184
|
+
} else {
|
|
185
|
+
newClassName = preferredStyle
|
|
186
|
+
? `is-style-${ preferredStyle }`
|
|
187
|
+
: undefined;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
return {
|
|
191
|
+
...pickRelevantMediaFiles( image, sizeSlug ),
|
|
192
|
+
...getHrefAndDestination( image, linkTo ),
|
|
193
|
+
...getUpdatedLinkTargetSettings( linkTarget, attributes ),
|
|
194
|
+
className: newClassName,
|
|
195
|
+
sizeSlug,
|
|
213
196
|
};
|
|
214
197
|
}
|
|
215
198
|
|
|
216
|
-
function
|
|
217
|
-
return (
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
columns: attributes.columns
|
|
223
|
-
? Math.min( newImages.length, attributes.columns )
|
|
224
|
-
: attributes.columns,
|
|
225
|
-
} );
|
|
226
|
-
};
|
|
199
|
+
function isValidFileType( file ) {
|
|
200
|
+
return (
|
|
201
|
+
ALLOWED_MEDIA_TYPES.some(
|
|
202
|
+
( mediaType ) => file.type?.indexOf( mediaType ) === 0
|
|
203
|
+
) || file.url?.indexOf( 'blob:' ) === 0
|
|
204
|
+
);
|
|
227
205
|
}
|
|
228
206
|
|
|
229
|
-
function
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
207
|
+
function updateImages( selectedImages ) {
|
|
208
|
+
const newFileUploads =
|
|
209
|
+
Object.prototype.toString.call( selectedImages ) ===
|
|
210
|
+
'[object FileList]';
|
|
211
|
+
|
|
212
|
+
const imageArray = newFileUploads
|
|
213
|
+
? Array.from( selectedImages ).map( ( file ) => {
|
|
214
|
+
if ( ! file.url ) {
|
|
215
|
+
return pickRelevantMediaFiles( {
|
|
216
|
+
url: createBlobURL( file ),
|
|
217
|
+
} );
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
return file;
|
|
221
|
+
} )
|
|
222
|
+
: selectedImages;
|
|
223
|
+
|
|
224
|
+
if ( ! imageArray.every( isValidFileType ) ) {
|
|
225
|
+
noticeOperations.removeAllNotices();
|
|
226
|
+
noticeOperations.createErrorNotice(
|
|
227
|
+
__(
|
|
228
|
+
'If uploading to a gallery all files need to be image formats'
|
|
229
|
+
),
|
|
230
|
+
{ id: 'gallery-upload-invalid-file' }
|
|
231
|
+
);
|
|
241
232
|
}
|
|
242
233
|
|
|
243
|
-
const
|
|
244
|
-
|
|
245
|
-
|
|
234
|
+
const processedImages = imageArray
|
|
235
|
+
.filter( ( file ) => file.url || isValidFileType( file ) )
|
|
236
|
+
.map( ( file ) => {
|
|
237
|
+
if ( ! file.url ) {
|
|
238
|
+
return pickRelevantMediaFiles( {
|
|
239
|
+
url: createBlobURL( file ),
|
|
240
|
+
} );
|
|
241
|
+
}
|
|
246
242
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return newImage.caption;
|
|
250
|
-
}
|
|
243
|
+
return file;
|
|
244
|
+
} );
|
|
251
245
|
|
|
252
|
-
|
|
253
|
-
|
|
246
|
+
// Because we are reusing existing innerImage blocks any reordering
|
|
247
|
+
// done in the media library will be lost so we need to reapply that ordering
|
|
248
|
+
// once the new image blocks are merged in with existing.
|
|
249
|
+
const newOrderMap = processedImages.reduce(
|
|
250
|
+
( result, image, index ) => (
|
|
251
|
+
( result[ image.id ] = index ), result
|
|
252
|
+
),
|
|
253
|
+
{}
|
|
254
|
+
);
|
|
254
255
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
256
|
+
const existingImageBlocks = ! newFileUploads
|
|
257
|
+
? innerBlockImages.filter( ( block ) =>
|
|
258
|
+
processedImages.find(
|
|
259
|
+
( img ) => img.id === block.attributes.id
|
|
260
|
+
)
|
|
261
|
+
)
|
|
262
|
+
: innerBlockImages;
|
|
263
|
+
|
|
264
|
+
const newImageList = processedImages.filter(
|
|
265
|
+
( img ) =>
|
|
266
|
+
! existingImageBlocks.find(
|
|
267
|
+
( existingImg ) => img.id === existingImg.attributes.id
|
|
268
|
+
)
|
|
263
269
|
);
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
} ) ),
|
|
273
|
-
columns: attributes.columns
|
|
274
|
-
? Math.min( newImages.length, attributes.columns )
|
|
275
|
-
: attributes.columns,
|
|
270
|
+
|
|
271
|
+
const newBlocks = newImageList.map( ( image ) => {
|
|
272
|
+
return createBlock( 'core/image', {
|
|
273
|
+
id: image.id,
|
|
274
|
+
url: image.url,
|
|
275
|
+
caption: image.caption,
|
|
276
|
+
alt: image.alt,
|
|
277
|
+
} );
|
|
276
278
|
} );
|
|
279
|
+
|
|
280
|
+
replaceInnerBlocks(
|
|
281
|
+
clientId,
|
|
282
|
+
concat( existingImageBlocks, newBlocks ).sort(
|
|
283
|
+
( a, b ) =>
|
|
284
|
+
newOrderMap[ a.attributes.id ] -
|
|
285
|
+
newOrderMap[ b.attributes.id ]
|
|
286
|
+
)
|
|
287
|
+
);
|
|
277
288
|
}
|
|
278
289
|
|
|
279
290
|
function onUploadError( message ) {
|
|
@@ -283,6 +294,34 @@ function GalleryEdit( props ) {
|
|
|
283
294
|
|
|
284
295
|
function setLinkTo( value ) {
|
|
285
296
|
setAttributes( { linkTo: value } );
|
|
297
|
+
const changedAttributes = {};
|
|
298
|
+
const blocks = [];
|
|
299
|
+
getBlock( clientId ).innerBlocks.forEach( ( block ) => {
|
|
300
|
+
blocks.push( block.clientId );
|
|
301
|
+
const image = block.attributes.id
|
|
302
|
+
? find( imageData, { id: block.attributes.id } )
|
|
303
|
+
: null;
|
|
304
|
+
changedAttributes[ block.clientId ] = getHrefAndDestination(
|
|
305
|
+
image,
|
|
306
|
+
value
|
|
307
|
+
);
|
|
308
|
+
} );
|
|
309
|
+
updateBlockAttributes( blocks, changedAttributes, true );
|
|
310
|
+
const linkToText = [ ...linkOptions ].find(
|
|
311
|
+
( linkType ) => linkType.value === value
|
|
312
|
+
);
|
|
313
|
+
|
|
314
|
+
createSuccessNotice(
|
|
315
|
+
sprintf(
|
|
316
|
+
/* translators: %s: image size settings */
|
|
317
|
+
__( 'All gallery image links updated to: %s' ),
|
|
318
|
+
linkToText.label
|
|
319
|
+
),
|
|
320
|
+
{
|
|
321
|
+
id: 'gallery-attributes-linkTo',
|
|
322
|
+
type: 'snackbar',
|
|
323
|
+
}
|
|
324
|
+
);
|
|
286
325
|
}
|
|
287
326
|
|
|
288
327
|
function setColumnsNumber( value ) {
|
|
@@ -299,77 +338,62 @@ function GalleryEdit( props ) {
|
|
|
299
338
|
: __( 'Thumbnails are not cropped.' );
|
|
300
339
|
}
|
|
301
340
|
|
|
302
|
-
function
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
341
|
+
function toggleOpenInNewTab( openInNewTab ) {
|
|
342
|
+
const newLinkTarget = openInNewTab ? '_blank' : undefined;
|
|
343
|
+
setAttributes( { linkTarget: newLinkTarget } );
|
|
344
|
+
const changedAttributes = {};
|
|
345
|
+
const blocks = [];
|
|
346
|
+
getBlock( clientId ).innerBlocks.forEach( ( block ) => {
|
|
347
|
+
blocks.push( block.clientId );
|
|
348
|
+
changedAttributes[ block.clientId ] = getUpdatedLinkTargetSettings(
|
|
349
|
+
newLinkTarget,
|
|
350
|
+
block.attributes
|
|
351
|
+
);
|
|
352
|
+
} );
|
|
353
|
+
updateBlockAttributes( blocks, changedAttributes, true );
|
|
354
|
+
const noticeText = openInNewTab
|
|
355
|
+
? __( 'All gallery images updated to open in new tab' )
|
|
356
|
+
: __( 'All gallery images updated to not open in new tab' );
|
|
357
|
+
createSuccessNotice( noticeText, {
|
|
358
|
+
id: 'gallery-attributes-openInNewTab',
|
|
359
|
+
type: 'snackbar',
|
|
316
360
|
} );
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
function getImagesSizeOptions() {
|
|
320
|
-
return map(
|
|
321
|
-
filter( imageSizes, ( { slug } ) =>
|
|
322
|
-
some( resizedImages, ( sizes ) => sizes[ slug ] )
|
|
323
|
-
),
|
|
324
|
-
( { name, slug } ) => ( { value: slug, label: name } )
|
|
325
|
-
);
|
|
326
361
|
}
|
|
327
362
|
|
|
328
363
|
function updateImagesSize( newSizeSlug ) {
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
364
|
+
setAttributes( { sizeSlug: newSizeSlug } );
|
|
365
|
+
const changedAttributes = {};
|
|
366
|
+
const blocks = [];
|
|
367
|
+
getBlock( clientId ).innerBlocks.forEach( ( block ) => {
|
|
368
|
+
blocks.push( block.clientId );
|
|
369
|
+
const image = block.attributes.id
|
|
370
|
+
? find( imageData, { id: block.attributes.id } )
|
|
371
|
+
: null;
|
|
372
|
+
changedAttributes[ block.clientId ] = getImageSizeAttributes(
|
|
373
|
+
image,
|
|
374
|
+
newSizeSlug
|
|
375
|
+
);
|
|
341
376
|
} );
|
|
377
|
+
updateBlockAttributes( blocks, changedAttributes, true );
|
|
378
|
+
const imageSize = imageSizeOptions.find(
|
|
379
|
+
( size ) => size.value === newSizeSlug
|
|
380
|
+
);
|
|
342
381
|
|
|
343
|
-
|
|
382
|
+
createSuccessNotice(
|
|
383
|
+
sprintf(
|
|
384
|
+
/* translators: %s: image size settings */
|
|
385
|
+
__( 'All gallery image sizes updated to: %s' ),
|
|
386
|
+
imageSize.label
|
|
387
|
+
),
|
|
388
|
+
{
|
|
389
|
+
id: 'gallery-attributes-sizeSlug',
|
|
390
|
+
type: 'snackbar',
|
|
391
|
+
}
|
|
392
|
+
);
|
|
344
393
|
}
|
|
345
394
|
|
|
346
395
|
useEffect( () => {
|
|
347
|
-
|
|
348
|
-
Platform.OS === 'web' &&
|
|
349
|
-
images &&
|
|
350
|
-
images.length > 0 &&
|
|
351
|
-
every( images, ( { url } ) => isBlobURL( url ) )
|
|
352
|
-
) {
|
|
353
|
-
const filesList = map( images, ( { url } ) => getBlobByURL( url ) );
|
|
354
|
-
forEach( images, ( { url } ) => revokeBlobURL( url ) );
|
|
355
|
-
mediaUpload( {
|
|
356
|
-
filesList,
|
|
357
|
-
onFileChange: onSelectImages,
|
|
358
|
-
allowedTypes: [ 'image' ],
|
|
359
|
-
} );
|
|
360
|
-
}
|
|
361
|
-
}, [] );
|
|
362
|
-
|
|
363
|
-
useEffect( () => {
|
|
364
|
-
// Deselect images when deselecting the block
|
|
365
|
-
if ( ! isSelected ) {
|
|
366
|
-
setSelectedImage();
|
|
367
|
-
}
|
|
368
|
-
}, [ isSelected ] );
|
|
369
|
-
|
|
370
|
-
useEffect( () => {
|
|
371
|
-
// linkTo attribute must be saved so blocks don't break when changing
|
|
372
|
-
// image_default_link_type in options.php
|
|
396
|
+
// linkTo attribute must be saved so blocks don't break when changing image_default_link_type in options.php
|
|
373
397
|
if ( ! linkTo ) {
|
|
374
398
|
__unstableMarkNextChangeAsNotPersistent();
|
|
375
399
|
setAttributes( {
|
|
@@ -382,39 +406,42 @@ function GalleryEdit( props ) {
|
|
|
382
406
|
|
|
383
407
|
const hasImages = !! images.length;
|
|
384
408
|
const hasImageIds = hasImages && images.some( ( image ) => !! image.id );
|
|
409
|
+
const imagesUploading = images.some(
|
|
410
|
+
( img ) => ! img.id && img.url?.indexOf( 'blob:' ) === 0
|
|
411
|
+
);
|
|
385
412
|
|
|
386
413
|
const mediaPlaceholder = (
|
|
387
414
|
<MediaPlaceholder
|
|
388
415
|
addToGallery={ hasImageIds }
|
|
416
|
+
handleUpload={ false }
|
|
389
417
|
isAppender={ hasImages }
|
|
390
|
-
disableMediaButtons={
|
|
418
|
+
disableMediaButtons={
|
|
419
|
+
( hasImages && ! isSelected ) || imagesUploading
|
|
420
|
+
}
|
|
391
421
|
icon={ ! hasImages && sharedIcon }
|
|
392
422
|
labels={ {
|
|
393
423
|
title: ! hasImages && __( 'Gallery' ),
|
|
394
424
|
instructions: ! hasImages && PLACEHOLDER_TEXT,
|
|
395
425
|
} }
|
|
396
|
-
onSelect={
|
|
426
|
+
onSelect={ updateImages }
|
|
397
427
|
accept="image/*"
|
|
398
428
|
allowedTypes={ ALLOWED_MEDIA_TYPES }
|
|
399
429
|
multiple
|
|
400
430
|
value={ hasImageIds ? images : {} }
|
|
401
431
|
onError={ onUploadError }
|
|
402
432
|
notices={ hasImages ? undefined : noticeUI }
|
|
403
|
-
onFocus={ onFocus }
|
|
404
|
-
autoOpenMediaUpload={
|
|
405
|
-
! hasImages && isSelected && wasBlockJustInserted
|
|
406
|
-
}
|
|
407
433
|
/>
|
|
408
434
|
);
|
|
409
435
|
|
|
410
|
-
const blockProps = useBlockProps(
|
|
436
|
+
const blockProps = useBlockProps( {
|
|
437
|
+
className: classnames( className, 'has-nested-images' ),
|
|
438
|
+
} );
|
|
411
439
|
|
|
412
440
|
if ( ! hasImages ) {
|
|
413
441
|
return <View { ...blockProps }>{ mediaPlaceholder }</View>;
|
|
414
442
|
}
|
|
415
443
|
|
|
416
|
-
const
|
|
417
|
-
const shouldShowSizeOptions = hasImages && ! isEmpty( imageSizeOptions );
|
|
444
|
+
const hasLinkTo = linkTo && linkTo !== 'none';
|
|
418
445
|
|
|
419
446
|
return (
|
|
420
447
|
<>
|
|
@@ -423,7 +450,11 @@ function GalleryEdit( props ) {
|
|
|
423
450
|
{ images.length > 1 && (
|
|
424
451
|
<RangeControl
|
|
425
452
|
label={ __( 'Columns' ) }
|
|
426
|
-
value={
|
|
453
|
+
value={
|
|
454
|
+
columns
|
|
455
|
+
? columns
|
|
456
|
+
: defaultColumnsNumber( images.length )
|
|
457
|
+
}
|
|
427
458
|
onChange={ setColumnsNumber }
|
|
428
459
|
min={ 1 }
|
|
429
460
|
max={ Math.min( MAX_COLUMNS, images.length ) }
|
|
@@ -444,7 +475,14 @@ function GalleryEdit( props ) {
|
|
|
444
475
|
options={ linkOptions }
|
|
445
476
|
hideCancelButton={ true }
|
|
446
477
|
/>
|
|
447
|
-
{
|
|
478
|
+
{ hasLinkTo && (
|
|
479
|
+
<ToggleControl
|
|
480
|
+
label={ __( 'Open in new tab' ) }
|
|
481
|
+
checked={ linkTarget === '_blank' }
|
|
482
|
+
onChange={ toggleOpenInNewTab }
|
|
483
|
+
/>
|
|
484
|
+
) }
|
|
485
|
+
{ imageSizeOptions?.length > 0 && (
|
|
448
486
|
<SelectControl
|
|
449
487
|
label={ __( 'Image size' ) }
|
|
450
488
|
value={ sizeSlug }
|
|
@@ -453,27 +491,30 @@ function GalleryEdit( props ) {
|
|
|
453
491
|
hideCancelButton={ true }
|
|
454
492
|
/>
|
|
455
493
|
) }
|
|
494
|
+
{ Platform.isWeb && ! imageSizeOptions && (
|
|
495
|
+
<BaseControl className={ 'gallery-image-sizes' }>
|
|
496
|
+
<BaseControl.VisualLabel>
|
|
497
|
+
{ __( 'Image size' ) }
|
|
498
|
+
</BaseControl.VisualLabel>
|
|
499
|
+
<View className={ 'gallery-image-sizes__loading' }>
|
|
500
|
+
<Spinner />
|
|
501
|
+
{ __( 'Loading options…' ) }
|
|
502
|
+
</View>
|
|
503
|
+
</BaseControl>
|
|
504
|
+
) }
|
|
456
505
|
</PanelBody>
|
|
457
506
|
</InspectorControls>
|
|
458
507
|
{ noticeUI }
|
|
459
508
|
<Gallery
|
|
460
509
|
{ ...props }
|
|
461
|
-
|
|
510
|
+
images={ images }
|
|
462
511
|
mediaPlaceholder={ mediaPlaceholder }
|
|
463
|
-
onMoveBackward={ onMoveBackward }
|
|
464
|
-
onMoveForward={ onMoveForward }
|
|
465
|
-
onRemoveImage={ onRemoveImage }
|
|
466
|
-
onSelectImage={ onSelectImage }
|
|
467
|
-
onDeselectImage={ onDeselectImage }
|
|
468
|
-
onSetImageAttributes={ setImageAttributes }
|
|
469
512
|
blockProps={ blockProps }
|
|
470
|
-
|
|
471
|
-
onFocusGalleryCaption={ onFocusGalleryCaption }
|
|
513
|
+
insertBlocksAfter={ insertBlocksAfter }
|
|
472
514
|
/>
|
|
473
515
|
</>
|
|
474
516
|
);
|
|
475
517
|
}
|
|
476
|
-
|
|
477
518
|
export default compose( [
|
|
478
519
|
withNotices,
|
|
479
520
|
withViewportMatch( { isNarrow: '< small' } ),
|