@wordpress/block-library 9.6.1 → 9.7.1-next.5368f64a9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/archives/edit.js +1 -1
- package/build/archives/edit.js.map +1 -1
- package/build/audio/edit.js +2 -1
- package/build/audio/edit.js.map +1 -1
- package/build/block/edit.js +5 -8
- package/build/block/edit.js.map +1 -1
- package/build/button/edit.js +1 -1
- package/build/button/edit.js.map +1 -1
- package/build/buttons/index.js +1 -1
- package/build/categories/index.js +1 -0
- package/build/categories/index.js.map +1 -1
- package/build/comment-edit-link/index.js +13 -2
- package/build/comment-edit-link/index.js.map +1 -1
- package/build/comment-reply-link/index.js +13 -2
- package/build/comment-reply-link/index.js.map +1 -1
- package/build/comments/edit/comments-legacy.js +1 -0
- package/build/comments/edit/comments-legacy.js.map +1 -1
- package/build/cover/deprecated.js +1 -1
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit/block-controls.js +4 -2
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/cover/edit/index.js +6 -3
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +4 -12
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/details/index.js +3 -1
- package/build/details/index.js.map +1 -1
- package/build/details/transforms.js +24 -0
- package/build/details/transforms.js.map +1 -0
- package/build/embed/edit.js +5 -11
- package/build/embed/edit.js.map +1 -1
- package/build/embed/embed-placeholder.js +2 -0
- package/build/embed/embed-placeholder.js.map +1 -1
- package/build/embed/embed-preview.js +16 -4
- package/build/embed/embed-preview.js.map +1 -1
- package/build/file/edit.js +12 -1
- package/build/file/edit.js.map +1 -1
- package/build/file/transforms.js +18 -4
- package/build/file/transforms.js.map +1 -1
- package/build/freeform/edit.js +4 -4
- package/build/freeform/edit.js.map +1 -1
- package/build/freeform/modal.js +3 -0
- package/build/freeform/modal.js.map +1 -1
- package/build/home-link/edit.js +3 -9
- package/build/home-link/edit.js.map +1 -1
- package/build/image/edit.js +95 -45
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +39 -24
- package/build/image/image.js.map +1 -1
- package/build/image/transforms.js +0 -13
- package/build/image/transforms.js.map +1 -1
- package/build/image/use-max-width-observer.js +35 -0
- package/build/image/use-max-width-observer.js.map +1 -0
- package/build/image/utils.js +11 -0
- package/build/image/utils.js.map +1 -1
- package/build/latest-posts/edit.js +1 -1
- package/build/latest-posts/edit.js.map +1 -1
- package/build/media-text/deprecated.js +144 -3
- package/build/media-text/deprecated.js.map +1 -1
- package/build/media-text/edit.js +5 -5
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/image-fill.js +12 -0
- package/build/media-text/image-fill.js.map +1 -0
- package/build/media-text/media-container.js +21 -18
- package/build/media-text/media-container.js.map +1 -1
- package/build/media-text/media-container.native.js +0 -7
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/media-text/save.js +5 -6
- package/build/media-text/save.js.map +1 -1
- package/build/missing/edit.js +3 -2
- package/build/missing/edit.js.map +1 -1
- package/build/navigation/edit/deleted-navigation-warning.js +14 -7
- package/build/navigation/edit/deleted-navigation-warning.js.map +1 -1
- package/build/navigation/edit/index.js +1 -0
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +2 -1
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation/edit/navigation-menu-delete-control.js +1 -0
- package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +1 -0
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +2 -0
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +4 -4
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation-link/link-ui.js +2 -1
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +2 -0
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/edit.js +4 -1
- package/build/page-list/edit.js.map +1 -1
- package/build/post-comments-form/form.js +1 -0
- package/build/post-comments-form/form.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +6 -8
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-featured-image/edit.js +2 -4
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-title/index.js +4 -1
- package/build/post-title/index.js.map +1 -1
- package/build/query/edit/enhanced-pagination-modal.js +3 -2
- package/build/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js +3 -3
- package/build/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +2 -10
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-content.js +9 -3
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/edit/query-placeholder.js +2 -0
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/site-logo/edit.js +9 -13
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-title/index.js +4 -1
- package/build/site-title/index.js.map +1 -1
- package/build/social-link/edit.js +4 -1
- package/build/social-link/edit.js.map +1 -1
- package/build/social-links/edit.js +10 -9
- package/build/social-links/edit.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/index.js +1 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/inner-blocks.js +10 -1
- package/build/template-part/edit/inner-blocks.js.map +1 -1
- package/build/template-part/edit/placeholder.js +2 -0
- package/build/template-part/edit/placeholder.js.map +1 -1
- package/build/utils/hooks.js +10 -10
- package/build/utils/hooks.js.map +1 -1
- package/build/video/edit.js +16 -12
- package/build/video/edit.js.map +1 -1
- package/build/video/tracks-editor.js +3 -0
- package/build/video/tracks-editor.js.map +1 -1
- package/build-module/archives/edit.js +1 -1
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/audio/edit.js +2 -1
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/block/edit.js +6 -9
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/edit.js +1 -1
- package/build-module/button/edit.js.map +1 -1
- package/build-module/buttons/index.js +1 -1
- package/build-module/categories/index.js +1 -0
- package/build-module/categories/index.js.map +1 -1
- package/build-module/comment-edit-link/index.js +13 -2
- package/build-module/comment-edit-link/index.js.map +1 -1
- package/build-module/comment-reply-link/index.js +13 -2
- package/build-module/comment-reply-link/index.js.map +1 -1
- package/build-module/comments/edit/comments-legacy.js +1 -0
- package/build-module/comments/edit/comments-legacy.js.map +1 -1
- package/build-module/cover/deprecated.js +1 -1
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +4 -2
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/cover/edit/index.js +6 -3
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +5 -13
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/details/index.js +3 -1
- package/build-module/details/index.js.map +1 -1
- package/build-module/details/transforms.js +18 -0
- package/build-module/details/transforms.js.map +1 -0
- package/build-module/embed/edit.js +6 -12
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/embed/embed-placeholder.js +2 -0
- package/build-module/embed/embed-placeholder.js.map +1 -1
- package/build-module/embed/embed-preview.js +16 -4
- package/build-module/embed/embed-preview.js.map +1 -1
- package/build-module/file/edit.js +12 -1
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/transforms.js +18 -4
- package/build-module/file/transforms.js.map +1 -1
- package/build-module/freeform/edit.js +4 -4
- package/build-module/freeform/edit.js.map +1 -1
- package/build-module/freeform/modal.js +3 -0
- package/build-module/freeform/modal.js.map +1 -1
- package/build-module/home-link/edit.js +3 -9
- package/build-module/home-link/edit.js.map +1 -1
- package/build-module/image/edit.js +99 -48
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +40 -25
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/transforms.js +0 -13
- package/build-module/image/transforms.js.map +1 -1
- package/build-module/image/use-max-width-observer.js +29 -0
- package/build-module/image/use-max-width-observer.js.map +1 -0
- package/build-module/image/utils.js +11 -1
- package/build-module/image/utils.js.map +1 -1
- package/build-module/latest-posts/edit.js +1 -1
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/media-text/deprecated.js +144 -3
- package/build-module/media-text/deprecated.js.map +1 -1
- package/build-module/media-text/edit.js +5 -5
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/image-fill.js +6 -0
- package/build-module/media-text/image-fill.js.map +1 -0
- package/build-module/media-text/media-container.js +21 -17
- package/build-module/media-text/media-container.js.map +1 -1
- package/build-module/media-text/media-container.native.js +0 -1
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/media-text/save.js +5 -6
- package/build-module/media-text/save.js.map +1 -1
- package/build-module/missing/edit.js +3 -2
- package/build-module/missing/edit.js.map +1 -1
- package/build-module/navigation/edit/deleted-navigation-warning.js +15 -8
- package/build-module/navigation/edit/deleted-navigation-warning.js.map +1 -1
- package/build-module/navigation/edit/index.js +1 -0
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +2 -1
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-delete-control.js +1 -0
- package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +1 -0
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +2 -0
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +4 -4
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +4 -3
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +2 -0
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/edit.js +4 -1
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +1 -0
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +6 -8
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-featured-image/edit.js +3 -5
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-title/index.js +4 -1
- package/build-module/post-title/index.js.map +1 -1
- package/build-module/query/edit/enhanced-pagination-modal.js +3 -2
- package/build-module/query/edit/enhanced-pagination-modal.js.map +1 -1
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js +3 -3
- package/build-module/query/edit/inspector-controls/enhanced-pagination-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +2 -10
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-content.js +10 -4
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +2 -0
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/site-logo/edit.js +10 -14
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-title/index.js +4 -1
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-link/edit.js +4 -1
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-links/edit.js +11 -10
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/index.js +1 -1
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/inner-blocks.js +10 -1
- package/build-module/template-part/edit/inner-blocks.js.map +1 -1
- package/build-module/template-part/edit/placeholder.js +2 -0
- package/build-module/template-part/edit/placeholder.js.map +1 -1
- package/build-module/utils/hooks.js +10 -10
- package/build-module/utils/hooks.js.map +1 -1
- package/build-module/video/edit.js +16 -13
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/tracks-editor.js +3 -0
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/button/editor-rtl.css +0 -4
- package/build-style/button/editor.css +0 -4
- package/build-style/buttons/editor-rtl.css +2 -5
- package/build-style/buttons/editor.css +2 -5
- package/build-style/buttons/style-rtl.css +2 -2
- package/build-style/buttons/style.css +2 -2
- package/build-style/comment-edit-link/style-rtl.css +94 -0
- package/build-style/comment-edit-link/style.css +94 -0
- package/build-style/comment-reply-link/style-rtl.css +94 -0
- package/build-style/comment-reply-link/style.css +94 -0
- package/build-style/comments-pagination/editor-rtl.css +2 -2
- package/build-style/comments-pagination/editor.css +2 -2
- package/build-style/common-rtl.css +2 -2
- package/build-style/common.css +2 -2
- package/build-style/cover/editor-rtl.css +0 -6
- package/build-style/cover/editor.css +0 -6
- package/build-style/editor-rtl.css +35 -99
- package/build-style/editor.css +35 -101
- package/build-style/group/editor-rtl.css +0 -1
- package/build-style/group/editor.css +0 -1
- package/build-style/image/editor-rtl.css +6 -27
- package/build-style/image/editor.css +6 -27
- package/build-style/media-text/editor-rtl.css +3 -1
- package/build-style/media-text/editor.css +3 -1
- package/build-style/media-text/style-rtl.css +20 -0
- package/build-style/media-text/style.css +20 -0
- package/build-style/navigation/editor-rtl.css +1 -2
- package/build-style/navigation/editor.css +1 -2
- package/build-style/post-featured-image/style-rtl.css +1 -1
- package/build-style/post-featured-image/style.css +1 -1
- package/build-style/post-title/style-rtl.css +21 -0
- package/build-style/post-title/style.css +21 -0
- package/build-style/query-pagination/editor-rtl.css +2 -16
- package/build-style/query-pagination/editor.css +2 -18
- package/build-style/query-pagination/style-rtl.css +0 -11
- package/build-style/query-pagination/style.css +0 -13
- package/build-style/site-title/editor-rtl.css +0 -4
- package/build-style/site-title/editor.css +0 -4
- package/build-style/site-title/style-rtl.css +21 -0
- package/build-style/site-title/style.css +21 -0
- package/build-style/social-links/editor-rtl.css +17 -0
- package/build-style/social-links/editor.css +17 -0
- package/build-style/style-rtl.css +75 -16
- package/build-style/style.css +75 -18
- package/build-style/video/editor-rtl.css +0 -29
- package/build-style/video/editor.css +0 -29
- package/package.json +42 -35
- package/src/archives/edit.js +1 -1
- package/src/audio/edit.js +1 -0
- package/src/block/edit.js +9 -11
- package/src/button/edit.js +1 -1
- package/src/button/editor.scss +0 -5
- package/src/buttons/block.json +1 -1
- package/src/buttons/editor.scss +2 -8
- package/src/buttons/style.scss +2 -2
- package/src/categories/block.json +1 -0
- package/src/categories/index.php +13 -2
- package/src/comment-edit-link/block.json +13 -2
- package/src/comment-edit-link/style.scss +4 -0
- package/src/comment-reply-link/block.json +13 -2
- package/src/comment-reply-link/style.scss +4 -0
- package/src/comments/edit/comments-legacy.js +1 -0
- package/src/comments-pagination/editor.scss +1 -1
- package/src/cover/deprecated.js +3 -2
- package/src/cover/edit/block-controls.js +2 -0
- package/src/cover/edit/index.js +6 -1
- package/src/cover/edit/inspector-controls.js +3 -15
- package/src/cover/editor.scss +0 -5
- package/src/cover/test/edit.js +30 -26
- package/src/details/index.js +2 -0
- package/src/details/transforms.js +26 -0
- package/src/embed/edit.js +0 -7
- package/src/embed/embed-placeholder.js +10 -2
- package/src/embed/embed-preview.js +22 -2
- package/src/file/edit.js +11 -0
- package/src/file/index.php +1 -1
- package/src/file/transforms.js +26 -6
- package/src/freeform/edit.js +4 -4
- package/src/freeform/editor.scss +1 -1
- package/src/freeform/modal.js +7 -1
- package/src/gallery/editor.scss +1 -1
- package/src/group/editor.scss +0 -1
- package/src/home-link/edit.js +4 -7
- package/src/image/edit.js +130 -47
- package/src/image/editor.scss +7 -41
- package/src/image/image.js +100 -67
- package/src/image/index.php +1 -1
- package/src/image/transforms.js +0 -23
- package/src/image/use-max-width-observer.js +32 -0
- package/src/image/utils.js +13 -1
- package/src/latest-posts/edit.js +1 -1
- package/src/media-text/deprecated.js +159 -3
- package/src/media-text/edit.js +5 -5
- package/src/media-text/editor.scss +3 -1
- package/src/media-text/image-fill.js +11 -0
- package/src/media-text/index.php +53 -43
- package/src/media-text/media-container.js +25 -25
- package/src/media-text/media-container.native.js +0 -2
- package/src/media-text/save.js +9 -13
- package/src/media-text/style.scss +21 -0
- package/src/media-text/test/image-fill.js +19 -0
- package/src/missing/edit.js +8 -3
- package/src/navigation/edit/deleted-navigation-warning.js +23 -13
- package/src/navigation/edit/index.js +1 -0
- package/src/navigation/edit/menu-inspector-controls.js +3 -1
- package/src/navigation/edit/navigation-menu-delete-control.js +1 -0
- package/src/navigation/edit/placeholder/index.js +1 -0
- package/src/navigation/edit/responsive-wrapper.js +2 -0
- package/src/navigation/edit/unsaved-inner-blocks.js +4 -4
- package/src/navigation/editor.scss +11 -4
- package/src/navigation/index.php +1 -1
- package/src/navigation-link/link-ui.js +4 -3
- package/src/page-list/convert-to-links-modal.js +6 -1
- package/src/page-list/edit.js +6 -1
- package/src/page-list/index.php +3 -1
- package/src/post-comments-form/form.js +1 -0
- package/src/post-featured-image/dimension-controls.js +4 -4
- package/src/post-featured-image/edit.js +3 -6
- package/src/post-featured-image/style.scss +1 -1
- package/src/post-title/block.json +4 -1
- package/src/post-title/style.scss +24 -0
- package/src/query/edit/enhanced-pagination-modal.js +7 -3
- package/src/query/edit/inspector-controls/enhanced-pagination-control.js +3 -3
- package/src/query/edit/inspector-controls/index.js +2 -9
- package/src/query/edit/query-content.js +7 -0
- package/src/query/edit/query-placeholder.js +2 -0
- package/src/query/index.php +1 -1
- package/src/query-pagination/editor.scss +1 -21
- package/src/query-pagination/style.scss +0 -15
- package/src/search/index.php +1 -1
- package/src/site-logo/edit.js +11 -20
- package/src/site-title/block.json +4 -1
- package/src/site-title/editor.scss +0 -4
- package/src/site-title/style.scss +24 -0
- package/src/social-link/edit.js +2 -0
- package/src/social-links/edit.js +17 -10
- package/src/social-links/editor.scss +24 -5
- package/src/style.scss +2 -0
- package/src/tag-cloud/index.php +7 -2
- package/src/template-part/edit/advanced-controls.js +0 -1
- package/src/template-part/edit/index.js +12 -10
- package/src/template-part/edit/inner-blocks.js +20 -1
- package/src/template-part/edit/placeholder.js +6 -1
- package/src/utils/hooks.js +11 -11
- package/src/video/edit.js +24 -21
- package/src/video/editor.scss +0 -45
- package/src/video/tracks-editor.js +3 -0
- package/src/media-text/test/media-container.js +0 -24
|
@@ -6,15 +6,16 @@ import clsx from 'clsx';
|
|
|
6
6
|
/**
|
|
7
7
|
* WordPress dependencies
|
|
8
8
|
*/
|
|
9
|
-
import { isBlobURL } from '@wordpress/blob';
|
|
10
|
-
import { store as blocksStore } from '@wordpress/blocks';
|
|
9
|
+
import { isBlobURL, createBlobURL } from '@wordpress/blob';
|
|
10
|
+
import { store as blocksStore, createBlock } from '@wordpress/blocks';
|
|
11
11
|
import { Placeholder } from '@wordpress/components';
|
|
12
12
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
13
|
-
import { BlockIcon,
|
|
13
|
+
import { BlockIcon, useBlockProps, MediaPlaceholder, store as blockEditorStore, __experimentalUseBorderProps as useBorderProps, __experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles, useBlockEditingMode } from '@wordpress/block-editor';
|
|
14
14
|
import { useEffect, useRef, useState } from '@wordpress/element';
|
|
15
15
|
import { __, sprintf } from '@wordpress/i18n';
|
|
16
16
|
import { image as icon, plugins as pluginsIcon } from '@wordpress/icons';
|
|
17
17
|
import { store as noticesStore } from '@wordpress/notices';
|
|
18
|
+
import { useResizeObserver } from '@wordpress/compose';
|
|
18
19
|
|
|
19
20
|
/**
|
|
20
21
|
* Internal dependencies
|
|
@@ -22,6 +23,8 @@ import { store as noticesStore } from '@wordpress/notices';
|
|
|
22
23
|
import { unlock } from '../lock-unlock';
|
|
23
24
|
import { useUploadMediaFromBlobURL } from '../utils/hooks';
|
|
24
25
|
import Image from './image';
|
|
26
|
+
import { isValidFileType } from './utils';
|
|
27
|
+
import { useMaxWidthObserver } from './use-max-width-observer';
|
|
25
28
|
|
|
26
29
|
/**
|
|
27
30
|
* Module constants
|
|
@@ -29,6 +32,7 @@ import Image from './image';
|
|
|
29
32
|
import { LINK_DESTINATION_ATTACHMENT, LINK_DESTINATION_CUSTOM, LINK_DESTINATION_MEDIA, LINK_DESTINATION_NONE, ALLOWED_MEDIA_TYPES } from './constants';
|
|
30
33
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
31
34
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
35
|
+
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
32
36
|
export const pickRelevantMediaFiles = (image, size) => {
|
|
33
37
|
const imageProps = Object.fromEntries(Object.entries(image !== null && image !== void 0 ? image : {}).filter(([key]) => ['alt', 'id', 'link', 'caption'].includes(key)));
|
|
34
38
|
imageProps.url = image?.sizes?.[size]?.url || image?.media_details?.sizes?.[size]?.source_url || image.url;
|
|
@@ -84,6 +88,16 @@ export function ImageEdit({
|
|
|
84
88
|
metadata
|
|
85
89
|
} = attributes;
|
|
86
90
|
const [temporaryURL, setTemporaryURL] = useState(attributes.blob);
|
|
91
|
+
const containerRef = useRef();
|
|
92
|
+
// Only observe the max width from the parent container when the parent layout is not flex nor grid.
|
|
93
|
+
// This won't work for them because the container width changes with the image.
|
|
94
|
+
// TODO: Find a way to observe the container width for flex and grid layouts.
|
|
95
|
+
const isMaxWidthContainerWidth = !parentLayout || parentLayout.type !== 'flex' && parentLayout.type !== 'grid';
|
|
96
|
+
const [maxWidthObserver, maxContentWidth] = useMaxWidthObserver();
|
|
97
|
+
const [placeholderResizeListener, {
|
|
98
|
+
width: placeholderWidth
|
|
99
|
+
}] = useResizeObserver();
|
|
100
|
+
const isSmallContainer = placeholderWidth && placeholderWidth < 160;
|
|
87
101
|
const altRef = useRef();
|
|
88
102
|
useEffect(() => {
|
|
89
103
|
altRef.current = alt;
|
|
@@ -93,7 +107,8 @@ export function ImageEdit({
|
|
|
93
107
|
captionRef.current = caption;
|
|
94
108
|
}, [caption]);
|
|
95
109
|
const {
|
|
96
|
-
__unstableMarkNextChangeAsNotPersistent
|
|
110
|
+
__unstableMarkNextChangeAsNotPersistent,
|
|
111
|
+
replaceBlock
|
|
97
112
|
} = useDispatch(blockEditorStore);
|
|
98
113
|
useEffect(() => {
|
|
99
114
|
if (['wide', 'full'].includes(align)) {
|
|
@@ -107,7 +122,10 @@ export function ImageEdit({
|
|
|
107
122
|
}
|
|
108
123
|
}, [__unstableMarkNextChangeAsNotPersistent, align, setAttributes]);
|
|
109
124
|
const {
|
|
110
|
-
getSettings
|
|
125
|
+
getSettings,
|
|
126
|
+
getBlockRootClientId,
|
|
127
|
+
getBlockName,
|
|
128
|
+
canInsertBlockType
|
|
111
129
|
} = useSelect(blockEditorStore);
|
|
112
130
|
const blockEditingMode = useBlockEditingMode();
|
|
113
131
|
const {
|
|
@@ -124,7 +142,35 @@ export function ImageEdit({
|
|
|
124
142
|
blob: undefined
|
|
125
143
|
});
|
|
126
144
|
}
|
|
145
|
+
function onSelectImagesList(images) {
|
|
146
|
+
const win = containerRef.current?.ownerDocument.defaultView;
|
|
147
|
+
if (images.every(file => file instanceof win.File)) {
|
|
148
|
+
/** @type {File[]} */
|
|
149
|
+
const files = images;
|
|
150
|
+
const rootClientId = getBlockRootClientId(clientId);
|
|
151
|
+
if (files.some(file => !isValidFileType(file))) {
|
|
152
|
+
// Copied from the same notice in the gallery block.
|
|
153
|
+
createErrorNotice(__('If uploading to a gallery all files need to be image formats'), {
|
|
154
|
+
id: 'gallery-upload-invalid-file',
|
|
155
|
+
type: 'snackbar'
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
const imageBlocks = files.filter(file => isValidFileType(file)).map(file => createBlock('core/image', {
|
|
159
|
+
blob: createBlobURL(file)
|
|
160
|
+
}));
|
|
161
|
+
if (getBlockName(rootClientId) === 'core/gallery') {
|
|
162
|
+
replaceBlock(clientId, imageBlocks);
|
|
163
|
+
} else if (canInsertBlockType('core/gallery', rootClientId)) {
|
|
164
|
+
const galleryBlock = createBlock('core/gallery', {}, imageBlocks);
|
|
165
|
+
replaceBlock(clientId, galleryBlock);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
127
169
|
function onSelectImage(media) {
|
|
170
|
+
if (Array.isArray(media)) {
|
|
171
|
+
onSelectImagesList(media);
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
128
174
|
if (!media || !media.url) {
|
|
129
175
|
setAttributes({
|
|
130
176
|
url: undefined,
|
|
@@ -255,6 +301,7 @@ export function ImageEdit({
|
|
|
255
301
|
'has-custom-border': !!borderProps.className || borderProps.style && Object.keys(borderProps.style).length > 0
|
|
256
302
|
});
|
|
257
303
|
const blockProps = useBlockProps({
|
|
304
|
+
ref: containerRef,
|
|
258
305
|
className: classes
|
|
259
306
|
});
|
|
260
307
|
|
|
@@ -276,16 +323,16 @@ export function ImageEdit({
|
|
|
276
323
|
lockUrlControlsMessage: blockBindingsSource?.label ? sprintf( /* translators: %s: Label of the bindings source. */
|
|
277
324
|
__('Connected to %s'), blockBindingsSource.label) : __('Connected to dynamic data')
|
|
278
325
|
};
|
|
279
|
-
}, [isSingleSelected, metadata?.bindings?.url]);
|
|
326
|
+
}, [context, isSingleSelected, metadata?.bindings?.url]);
|
|
280
327
|
const placeholder = content => {
|
|
281
|
-
return /*#__PURE__*/
|
|
328
|
+
return /*#__PURE__*/_jsxs(Placeholder, {
|
|
282
329
|
className: clsx('block-editor-media-placeholder', {
|
|
283
330
|
[borderProps.className]: !!borderProps.className && !isSingleSelected
|
|
284
331
|
}),
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
label: __('Image'),
|
|
288
|
-
instructions: !lockUrlControls && __('Upload an image file, pick one from your
|
|
332
|
+
icon: !isSmallContainer && (lockUrlControls ? pluginsIcon : icon),
|
|
333
|
+
withIllustration: !isSingleSelected || isSmallContainer,
|
|
334
|
+
label: !isSmallContainer && __('Image'),
|
|
335
|
+
instructions: !lockUrlControls && !isSmallContainer && __('Upload or drag an image file here, or pick one from your library.'),
|
|
289
336
|
style: {
|
|
290
337
|
aspectRatio: !(width && height) && aspectRatio ? aspectRatio : undefined,
|
|
291
338
|
width: height && aspectRatio ? '100%' : width,
|
|
@@ -294,45 +341,49 @@ export function ImageEdit({
|
|
|
294
341
|
...borderProps.style,
|
|
295
342
|
...shadowProps.style
|
|
296
343
|
},
|
|
297
|
-
children: lockUrlControls
|
|
298
|
-
className: "block-bindings-media-placeholder-message",
|
|
299
|
-
children: lockUrlControlsMessage
|
|
300
|
-
}) : content
|
|
344
|
+
children: [lockUrlControls && !isSmallContainer && lockUrlControlsMessage, !lockUrlControls && !isSmallContainer && content, placeholderResizeListener]
|
|
301
345
|
});
|
|
302
346
|
};
|
|
303
|
-
return /*#__PURE__*/_jsxs(
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
347
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
348
|
+
children: [/*#__PURE__*/_jsxs("figure", {
|
|
349
|
+
...blockProps,
|
|
350
|
+
children: [/*#__PURE__*/_jsx(Image, {
|
|
351
|
+
temporaryURL: temporaryURL,
|
|
352
|
+
attributes: attributes,
|
|
353
|
+
setAttributes: setAttributes,
|
|
354
|
+
isSingleSelected: isSingleSelected,
|
|
355
|
+
insertBlocksAfter: insertBlocksAfter,
|
|
356
|
+
onReplace: onReplace,
|
|
357
|
+
onSelectImage: onSelectImage,
|
|
358
|
+
onSelectURL: onSelectURL,
|
|
359
|
+
onUploadError: onUploadError,
|
|
360
|
+
context: context,
|
|
361
|
+
clientId: clientId,
|
|
362
|
+
blockEditingMode: blockEditingMode,
|
|
363
|
+
parentLayoutType: parentLayout?.type,
|
|
364
|
+
maxContentWidth: maxContentWidth
|
|
365
|
+
}), /*#__PURE__*/_jsx(MediaPlaceholder, {
|
|
366
|
+
icon: /*#__PURE__*/_jsx(BlockIcon, {
|
|
367
|
+
icon: icon
|
|
368
|
+
}),
|
|
369
|
+
onSelect: onSelectImage,
|
|
370
|
+
onSelectURL: onSelectURL,
|
|
371
|
+
onError: onUploadError,
|
|
372
|
+
placeholder: placeholder,
|
|
373
|
+
accept: "image/*",
|
|
374
|
+
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
375
|
+
handleUpload: files => files.length === 1,
|
|
376
|
+
value: {
|
|
377
|
+
id,
|
|
378
|
+
src
|
|
379
|
+
},
|
|
380
|
+
mediaPreview: mediaPreview,
|
|
381
|
+
disableMediaButtons: temporaryURL || url
|
|
382
|
+
})]
|
|
383
|
+
}),
|
|
384
|
+
// The listener cannot be placed as the first element as it will break the in-between inserter.
|
|
385
|
+
// See https://github.com/WordPress/gutenberg/blob/71134165868298fc15e22896d0c28b41b3755ff7/packages/block-editor/src/components/block-list/use-in-between-inserter.js#L120
|
|
386
|
+
isSingleSelected && isMaxWidthContainerWidth && maxWidthObserver]
|
|
336
387
|
});
|
|
337
388
|
}
|
|
338
389
|
export default ImageEdit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","isBlobURL","store","blocksStore","Placeholder","useDispatch","useSelect","BlockIcon","MediaPlaceholder","useBlockProps","blockEditorStore","__experimentalUseBorderProps","useBorderProps","__experimentalGetShadowClassesAndStyles","getShadowClassesAndStyles","useBlockEditingMode","useEffect","useRef","useState","__","sprintf","image","icon","plugins","pluginsIcon","noticesStore","unlock","useUploadMediaFromBlobURL","Image","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_NONE","ALLOWED_MEDIA_TYPES","jsx","_jsx","jsxs","_jsxs","pickRelevantMediaFiles","size","imageProps","Object","fromEntries","entries","filter","key","includes","url","sizes","media_details","source_url","isExternalImage","id","hasSize","_image$sizes$size","_image$media_details$","ImageEdit","attributes","setAttributes","isSelected","isSingleSelected","className","insertBlocksAfter","onReplace","context","clientId","__unstableParentLayout","parentLayout","alt","caption","width","height","sizeSlug","aspectRatio","scale","align","metadata","temporaryURL","setTemporaryURL","blob","altRef","current","captionRef","__unstableMarkNextChangeAsNotPersistent","undefined","getSettings","blockEditingMode","createErrorNotice","onUploadError","message","type","src","onSelectImage","media","title","imageDefaultSize","newSize","mediaAttributes","omittedCaption","restMediaAttributes","additionalAttributes","linkDestination","window","wp","view","settings","defaultProps","link","href","onSelectURL","newURL","allowedTypes","onChange","onError","isExternal","mediaPreview","borderProps","shadowProps","classes","style","keys","length","blockProps","lockUrlControls","lockUrlControlsMessage","select","blockBindingsSource","getBlockBindingsSource","bindings","source","canUserEditValue","args","label","placeholder","content","withIllustration","instructions","objectFit","children","parentLayoutType","onSelect","accept","value","disableMediaButtons"],"sources":["@wordpress/block-library/src/image/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL } from '@wordpress/blob';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { Placeholder } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tBlockIcon,\n\tMediaPlaceholder,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { image as icon, plugins as pluginsIcon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport { useUploadMediaFromBlobURL } from '../utils/hooks';\nimport Image from './image';\n\n/**\n * Module constants\n */\nimport {\n\tLINK_DESTINATION_ATTACHMENT,\n\tLINK_DESTINATION_CUSTOM,\n\tLINK_DESTINATION_MEDIA,\n\tLINK_DESTINATION_NONE,\n\tALLOWED_MEDIA_TYPES,\n} from './constants';\n\nexport const pickRelevantMediaFiles = ( image, size ) => {\n\tconst imageProps = Object.fromEntries(\n\t\tObject.entries( image ?? {} ).filter( ( [ key ] ) =>\n\t\t\t[ 'alt', 'id', 'link', 'caption' ].includes( key )\n\t\t)\n\t);\n\n\timageProps.url =\n\t\timage?.sizes?.[ size ]?.url ||\n\t\timage?.media_details?.sizes?.[ size ]?.source_url ||\n\t\timage.url;\n\treturn imageProps;\n};\n\n/**\n * Is the url for the image hosted externally. An externally hosted image has no\n * id and is not a blob url.\n *\n * @param {number=} id The id of the image.\n * @param {string=} url The url of the image.\n *\n * @return {boolean} Is the url an externally hosted url?\n */\nexport const isExternalImage = ( id, url ) => url && ! id && ! isBlobURL( url );\n\n/**\n * Checks if WP generated the specified image size. Size generation is skipped\n * when the image is smaller than the said size.\n *\n * @param {Object} image\n * @param {string} size\n *\n * @return {boolean} Whether or not it has default image size.\n */\nfunction hasSize( image, size ) {\n\treturn (\n\t\t'url' in ( image?.sizes?.[ size ] ?? {} ) ||\n\t\t'source_url' in ( image?.media_details?.sizes?.[ size ] ?? {} )\n\t);\n}\n\nexport function ImageEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected: isSingleSelected,\n\tclassName,\n\tinsertBlocksAfter,\n\tonReplace,\n\tcontext,\n\tclientId,\n\t__unstableParentLayout: parentLayout,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\tcaption,\n\t\tid,\n\t\twidth,\n\t\theight,\n\t\tsizeSlug,\n\t\taspectRatio,\n\t\tscale,\n\t\talign,\n\t\tmetadata,\n\t} = attributes;\n\tconst [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );\n\n\tconst altRef = useRef();\n\tuseEffect( () => {\n\t\taltRef.current = alt;\n\t}, [ alt ] );\n\n\tconst captionRef = useRef();\n\tuseEffect( () => {\n\t\tcaptionRef.current = caption;\n\t}, [ caption ] );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( [ 'wide', 'full' ].includes( align ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\twidth: undefined,\n\t\t\t\theight: undefined,\n\t\t\t\taspectRatio: undefined,\n\t\t\t\tscale: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ __unstableMarkNextChangeAsNotPersistent, align, setAttributes ] );\n\n\tconst { getSettings } = useSelect( blockEditorStore );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\tsetAttributes( {\n\t\t\tsrc: undefined,\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t\tblob: undefined,\n\t\t} );\n\t}\n\n\tfunction onSelectImage( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\tsetAttributes( {\n\t\t\t\turl: undefined,\n\t\t\t\talt: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\ttitle: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t\tblob: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tsetTemporaryURL( media.url );\n\t\t\treturn;\n\t\t}\n\n\t\tconst { imageDefaultSize } = getSettings();\n\n\t\t// Try to use the previous selected image size if its available\n\t\t// otherwise try the default image size or fallback to \"full\"\n\t\tlet newSize = 'full';\n\t\tif ( sizeSlug && hasSize( media, sizeSlug ) ) {\n\t\t\tnewSize = sizeSlug;\n\t\t} else if ( hasSize( media, imageDefaultSize ) ) {\n\t\t\tnewSize = imageDefaultSize;\n\t\t}\n\n\t\tlet mediaAttributes = pickRelevantMediaFiles( media, newSize );\n\n\t\t// If a caption text was meanwhile written by the user,\n\t\t// make sure the text is not overwritten by empty captions.\n\t\tif ( captionRef.current && ! mediaAttributes.caption ) {\n\t\t\tconst { caption: omittedCaption, ...restMediaAttributes } =\n\t\t\t\tmediaAttributes;\n\t\t\tmediaAttributes = restMediaAttributes;\n\t\t}\n\n\t\tlet additionalAttributes;\n\t\t// Reset the dimension attributes if changing to a different image.\n\t\tif ( ! media.id || media.id !== id ) {\n\t\t\tadditionalAttributes = {\n\t\t\t\tsizeSlug: newSize,\n\t\t\t};\n\t\t} else {\n\t\t\t// Keep the same url when selecting the same file, so \"Resolution\"\n\t\t\t// option is not changed.\n\t\t\tadditionalAttributes = { url };\n\t\t}\n\n\t\t// Check if default link setting should be used.\n\t\tlet linkDestination = attributes.linkDestination;\n\t\tif ( ! linkDestination ) {\n\t\t\t// Use the WordPress option to determine the proper default.\n\t\t\t// The constants used in Gutenberg do not match WP options so a little more complicated than ideal.\n\t\t\t// TODO: fix this in a follow up PR, requires updating media-text and ui component.\n\t\t\tswitch (\n\t\t\t\twindow?.wp?.media?.view?.settings?.defaultProps?.link ||\n\t\t\t\tLINK_DESTINATION_NONE\n\t\t\t) {\n\t\t\t\tcase 'file':\n\t\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_MEDIA;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'post':\n\t\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_ATTACHMENT;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_CUSTOM:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_CUSTOM;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_NONE:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_NONE;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// Check if the image is linked to it's media.\n\t\tlet href;\n\t\tswitch ( linkDestination ) {\n\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\thref = media.url;\n\t\t\t\tbreak;\n\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\thref = media.link;\n\t\t\t\tbreak;\n\t\t}\n\t\tmediaAttributes.href = href;\n\n\t\tsetAttributes( {\n\t\t\tblob: undefined,\n\t\t\t...mediaAttributes,\n\t\t\t...additionalAttributes,\n\t\t\tlinkDestination,\n\t\t} );\n\t\tsetTemporaryURL();\n\t}\n\n\tfunction onSelectURL( newURL ) {\n\t\tif ( newURL !== url ) {\n\t\t\tsetAttributes( {\n\t\t\t\tblob: undefined,\n\t\t\t\turl: newURL,\n\t\t\t\tid: undefined,\n\t\t\t\tsizeSlug: getSettings().imageDefaultSize,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t}\n\t}\n\n\tuseUploadMediaFromBlobURL( {\n\t\turl: temporaryURL,\n\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\tonChange: onSelectImage,\n\t\tonError: onUploadError,\n\t} );\n\n\tconst isExternal = isExternalImage( id, url );\n\tconst src = isExternal ? url : undefined;\n\tconst mediaPreview = !! url && (\n\t\t<img\n\t\t\talt={ __( 'Edit image' ) }\n\t\t\ttitle={ __( 'Edit image' ) }\n\t\t\tclassName=\"edit-image-preview\"\n\t\t\tsrc={ url }\n\t\t/>\n\t);\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst shadowProps = getShadowClassesAndStyles( attributes );\n\n\tconst classes = clsx( className, {\n\t\t'is-transient': !! temporaryURL,\n\t\t'is-resized': !! width || !! height,\n\t\t[ `size-${ sizeSlug }` ]: sizeSlug,\n\t\t'has-custom-border':\n\t\t\t!! borderProps.className ||\n\t\t\t( borderProps.style &&\n\t\t\t\tObject.keys( borderProps.style ).length > 0 ),\n\t} );\n\n\tconst blockProps = useBlockProps( { className: classes } );\n\n\t// Much of this description is duplicated from MediaPlaceholder.\n\tconst { lockUrlControls = false, lockUrlControlsMessage } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isSingleSelected ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst blockBindingsSource = unlock(\n\t\t\t\tselect( blocksStore )\n\t\t\t).getBlockBindingsSource( metadata?.bindings?.url?.source );\n\n\t\t\treturn {\n\t\t\t\tlockUrlControls:\n\t\t\t\t\t!! metadata?.bindings?.url &&\n\t\t\t\t\t! blockBindingsSource?.canUserEditValue?.( {\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\targs: metadata?.bindings?.url?.args,\n\t\t\t\t\t} ),\n\t\t\t\tlockUrlControlsMessage: blockBindingsSource?.label\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Label of the bindings source. */\n\t\t\t\t\t\t\t__( 'Connected to %s' ),\n\t\t\t\t\t\t\tblockBindingsSource.label\n\t\t\t\t\t )\n\t\t\t\t\t: __( 'Connected to dynamic data' ),\n\t\t\t};\n\t\t},\n\t\t[ isSingleSelected, metadata?.bindings?.url ]\n\t);\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ clsx( 'block-editor-media-placeholder', {\n\t\t\t\t\t[ borderProps.className ]:\n\t\t\t\t\t\t!! borderProps.className && ! isSingleSelected,\n\t\t\t\t} ) }\n\t\t\t\twithIllustration\n\t\t\t\ticon={ lockUrlControls ? pluginsIcon : icon }\n\t\t\t\tlabel={ __( 'Image' ) }\n\t\t\t\tinstructions={\n\t\t\t\t\t! lockUrlControls &&\n\t\t\t\t\t__(\n\t\t\t\t\t\t'Upload an image file, pick one from your media library, or add one with a URL.'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tstyle={ {\n\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t! ( width && height ) && aspectRatio\n\t\t\t\t\t\t\t? aspectRatio\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\twidth: height && aspectRatio ? '100%' : width,\n\t\t\t\t\theight: width && aspectRatio ? '100%' : height,\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t\t...shadowProps.style,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ lockUrlControls ? (\n\t\t\t\t\t<span className=\"block-bindings-media-placeholder-message\">\n\t\t\t\t\t\t{ lockUrlControlsMessage }\n\t\t\t\t\t</span>\n\t\t\t\t) : (\n\t\t\t\t\tcontent\n\t\t\t\t) }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\treturn (\n\t\t<figure { ...blockProps }>\n\t\t\t<Image\n\t\t\t\ttemporaryURL={ temporaryURL }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tisSingleSelected={ isSingleSelected }\n\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonSelectImage={ onSelectImage }\n\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\tonUploadError={ onUploadError }\n\t\t\t\tcontext={ context }\n\t\t\t\tclientId={ clientId }\n\t\t\t\tblockEditingMode={ blockEditingMode }\n\t\t\t\tparentLayoutType={ parentLayout?.type }\n\t\t\t/>\n\t\t\t<MediaPlaceholder\n\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\tonError={ onUploadError }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t\taccept=\"image/*\"\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tvalue={ { id, src } }\n\t\t\t\tmediaPreview={ mediaPreview }\n\t\t\t\tdisableMediaButtons={ temporaryURL || url }\n\t\t\t/>\n\t\t</figure>\n\t);\n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AAc;MAC7B4B,mBAAmB,EAAGlE,YAAY,IAAI9B;IAAK,CAC3C,CAAC;EAAA,CACK,CAAC;AAEX;AAEA,eAAeS,SAAS","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["clsx","isBlobURL","createBlobURL","store","blocksStore","createBlock","Placeholder","useDispatch","useSelect","BlockIcon","useBlockProps","MediaPlaceholder","blockEditorStore","__experimentalUseBorderProps","useBorderProps","__experimentalGetShadowClassesAndStyles","getShadowClassesAndStyles","useBlockEditingMode","useEffect","useRef","useState","__","sprintf","image","icon","plugins","pluginsIcon","noticesStore","useResizeObserver","unlock","useUploadMediaFromBlobURL","Image","isValidFileType","useMaxWidthObserver","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_CUSTOM","LINK_DESTINATION_MEDIA","LINK_DESTINATION_NONE","ALLOWED_MEDIA_TYPES","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","pickRelevantMediaFiles","size","imageProps","Object","fromEntries","entries","filter","key","includes","url","sizes","media_details","source_url","isExternalImage","id","hasSize","_image$sizes$size","_image$media_details$","ImageEdit","attributes","setAttributes","isSelected","isSingleSelected","className","insertBlocksAfter","onReplace","context","clientId","__unstableParentLayout","parentLayout","alt","caption","width","height","sizeSlug","aspectRatio","scale","align","metadata","temporaryURL","setTemporaryURL","blob","containerRef","isMaxWidthContainerWidth","type","maxWidthObserver","maxContentWidth","placeholderResizeListener","placeholderWidth","isSmallContainer","altRef","current","captionRef","__unstableMarkNextChangeAsNotPersistent","replaceBlock","undefined","getSettings","getBlockRootClientId","getBlockName","canInsertBlockType","blockEditingMode","createErrorNotice","onUploadError","message","src","onSelectImagesList","images","win","ownerDocument","defaultView","every","file","File","files","rootClientId","some","imageBlocks","map","galleryBlock","onSelectImage","media","Array","isArray","title","imageDefaultSize","newSize","mediaAttributes","omittedCaption","restMediaAttributes","additionalAttributes","linkDestination","window","wp","view","settings","defaultProps","link","href","onSelectURL","newURL","allowedTypes","onChange","onError","isExternal","mediaPreview","borderProps","shadowProps","classes","style","keys","length","blockProps","ref","lockUrlControls","lockUrlControlsMessage","select","blockBindingsSource","getBlockBindingsSource","bindings","source","canUserEditValue","args","label","placeholder","content","withIllustration","instructions","objectFit","children","parentLayoutType","onSelect","accept","handleUpload","value","disableMediaButtons"],"sources":["@wordpress/block-library/src/image/edit.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { isBlobURL, createBlobURL } from '@wordpress/blob';\nimport { store as blocksStore, createBlock } from '@wordpress/blocks';\nimport { Placeholder } from '@wordpress/components';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tBlockIcon,\n\tuseBlockProps,\n\tMediaPlaceholder,\n\tstore as blockEditorStore,\n\t__experimentalUseBorderProps as useBorderProps,\n\t__experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,\n\tuseBlockEditingMode,\n} from '@wordpress/block-editor';\nimport { useEffect, useRef, useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { image as icon, plugins as pluginsIcon } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useResizeObserver } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport { unlock } from '../lock-unlock';\nimport { useUploadMediaFromBlobURL } from '../utils/hooks';\nimport Image from './image';\nimport { isValidFileType } from './utils';\nimport { useMaxWidthObserver } from './use-max-width-observer';\n\n/**\n * Module constants\n */\nimport {\n\tLINK_DESTINATION_ATTACHMENT,\n\tLINK_DESTINATION_CUSTOM,\n\tLINK_DESTINATION_MEDIA,\n\tLINK_DESTINATION_NONE,\n\tALLOWED_MEDIA_TYPES,\n} from './constants';\n\nexport const pickRelevantMediaFiles = ( image, size ) => {\n\tconst imageProps = Object.fromEntries(\n\t\tObject.entries( image ?? {} ).filter( ( [ key ] ) =>\n\t\t\t[ 'alt', 'id', 'link', 'caption' ].includes( key )\n\t\t)\n\t);\n\n\timageProps.url =\n\t\timage?.sizes?.[ size ]?.url ||\n\t\timage?.media_details?.sizes?.[ size ]?.source_url ||\n\t\timage.url;\n\treturn imageProps;\n};\n\n/**\n * Is the url for the image hosted externally. An externally hosted image has no\n * id and is not a blob url.\n *\n * @param {number=} id The id of the image.\n * @param {string=} url The url of the image.\n *\n * @return {boolean} Is the url an externally hosted url?\n */\nexport const isExternalImage = ( id, url ) => url && ! id && ! isBlobURL( url );\n\n/**\n * Checks if WP generated the specified image size. Size generation is skipped\n * when the image is smaller than the said size.\n *\n * @param {Object} image\n * @param {string} size\n *\n * @return {boolean} Whether or not it has default image size.\n */\nfunction hasSize( image, size ) {\n\treturn (\n\t\t'url' in ( image?.sizes?.[ size ] ?? {} ) ||\n\t\t'source_url' in ( image?.media_details?.sizes?.[ size ] ?? {} )\n\t);\n}\n\nexport function ImageEdit( {\n\tattributes,\n\tsetAttributes,\n\tisSelected: isSingleSelected,\n\tclassName,\n\tinsertBlocksAfter,\n\tonReplace,\n\tcontext,\n\tclientId,\n\t__unstableParentLayout: parentLayout,\n} ) {\n\tconst {\n\t\turl = '',\n\t\talt,\n\t\tcaption,\n\t\tid,\n\t\twidth,\n\t\theight,\n\t\tsizeSlug,\n\t\taspectRatio,\n\t\tscale,\n\t\talign,\n\t\tmetadata,\n\t} = attributes;\n\n\tconst [ temporaryURL, setTemporaryURL ] = useState( attributes.blob );\n\n\tconst containerRef = useRef();\n\t// Only observe the max width from the parent container when the parent layout is not flex nor grid.\n\t// This won't work for them because the container width changes with the image.\n\t// TODO: Find a way to observe the container width for flex and grid layouts.\n\tconst isMaxWidthContainerWidth =\n\t\t! parentLayout ||\n\t\t( parentLayout.type !== 'flex' && parentLayout.type !== 'grid' );\n\tconst [ maxWidthObserver, maxContentWidth ] = useMaxWidthObserver();\n\n\tconst [ placeholderResizeListener, { width: placeholderWidth } ] =\n\t\tuseResizeObserver();\n\n\tconst isSmallContainer = placeholderWidth && placeholderWidth < 160;\n\n\tconst altRef = useRef();\n\tuseEffect( () => {\n\t\taltRef.current = alt;\n\t}, [ alt ] );\n\n\tconst captionRef = useRef();\n\tuseEffect( () => {\n\t\tcaptionRef.current = caption;\n\t}, [ caption ] );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent, replaceBlock } =\n\t\tuseDispatch( blockEditorStore );\n\n\tuseEffect( () => {\n\t\tif ( [ 'wide', 'full' ].includes( align ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\twidth: undefined,\n\t\t\t\theight: undefined,\n\t\t\t\taspectRatio: undefined,\n\t\t\t\tscale: undefined,\n\t\t\t} );\n\t\t}\n\t}, [ __unstableMarkNextChangeAsNotPersistent, align, setAttributes ] );\n\n\tconst {\n\t\tgetSettings,\n\t\tgetBlockRootClientId,\n\t\tgetBlockName,\n\t\tcanInsertBlockType,\n\t} = useSelect( blockEditorStore );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tfunction onUploadError( message ) {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t\tsetAttributes( {\n\t\t\tsrc: undefined,\n\t\t\tid: undefined,\n\t\t\turl: undefined,\n\t\t\tblob: undefined,\n\t\t} );\n\t}\n\n\tfunction onSelectImagesList( images ) {\n\t\tconst win = containerRef.current?.ownerDocument.defaultView;\n\n\t\tif ( images.every( ( file ) => file instanceof win.File ) ) {\n\t\t\t/** @type {File[]} */\n\t\t\tconst files = images;\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\tif ( files.some( ( file ) => ! isValidFileType( file ) ) ) {\n\t\t\t\t// Copied from the same notice in the gallery block.\n\t\t\t\tcreateErrorNotice(\n\t\t\t\t\t__(\n\t\t\t\t\t\t'If uploading to a gallery all files need to be image formats'\n\t\t\t\t\t),\n\t\t\t\t\t{ id: 'gallery-upload-invalid-file', type: 'snackbar' }\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tconst imageBlocks = files\n\t\t\t\t.filter( ( file ) => isValidFileType( file ) )\n\t\t\t\t.map( ( file ) =>\n\t\t\t\t\tcreateBlock( 'core/image', {\n\t\t\t\t\t\tblob: createBlobURL( file ),\n\t\t\t\t\t} )\n\t\t\t\t);\n\n\t\t\tif ( getBlockName( rootClientId ) === 'core/gallery' ) {\n\t\t\t\treplaceBlock( clientId, imageBlocks );\n\t\t\t} else if ( canInsertBlockType( 'core/gallery', rootClientId ) ) {\n\t\t\t\tconst galleryBlock = createBlock(\n\t\t\t\t\t'core/gallery',\n\t\t\t\t\t{},\n\t\t\t\t\timageBlocks\n\t\t\t\t);\n\n\t\t\t\treplaceBlock( clientId, galleryBlock );\n\t\t\t}\n\t\t}\n\t}\n\n\tfunction onSelectImage( media ) {\n\t\tif ( Array.isArray( media ) ) {\n\t\t\tonSelectImagesList( media );\n\t\t\treturn;\n\t\t}\n\n\t\tif ( ! media || ! media.url ) {\n\t\t\tsetAttributes( {\n\t\t\t\turl: undefined,\n\t\t\t\talt: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\ttitle: undefined,\n\t\t\t\tcaption: undefined,\n\t\t\t\tblob: undefined,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\n\t\t\treturn;\n\t\t}\n\n\t\tif ( isBlobURL( media.url ) ) {\n\t\t\tsetTemporaryURL( media.url );\n\t\t\treturn;\n\t\t}\n\n\t\tconst { imageDefaultSize } = getSettings();\n\n\t\t// Try to use the previous selected image size if its available\n\t\t// otherwise try the default image size or fallback to \"full\"\n\t\tlet newSize = 'full';\n\t\tif ( sizeSlug && hasSize( media, sizeSlug ) ) {\n\t\t\tnewSize = sizeSlug;\n\t\t} else if ( hasSize( media, imageDefaultSize ) ) {\n\t\t\tnewSize = imageDefaultSize;\n\t\t}\n\n\t\tlet mediaAttributes = pickRelevantMediaFiles( media, newSize );\n\n\t\t// If a caption text was meanwhile written by the user,\n\t\t// make sure the text is not overwritten by empty captions.\n\t\tif ( captionRef.current && ! mediaAttributes.caption ) {\n\t\t\tconst { caption: omittedCaption, ...restMediaAttributes } =\n\t\t\t\tmediaAttributes;\n\t\t\tmediaAttributes = restMediaAttributes;\n\t\t}\n\n\t\tlet additionalAttributes;\n\t\t// Reset the dimension attributes if changing to a different image.\n\t\tif ( ! media.id || media.id !== id ) {\n\t\t\tadditionalAttributes = {\n\t\t\t\tsizeSlug: newSize,\n\t\t\t};\n\t\t} else {\n\t\t\t// Keep the same url when selecting the same file, so \"Resolution\"\n\t\t\t// option is not changed.\n\t\t\tadditionalAttributes = { url };\n\t\t}\n\n\t\t// Check if default link setting should be used.\n\t\tlet linkDestination = attributes.linkDestination;\n\t\tif ( ! linkDestination ) {\n\t\t\t// Use the WordPress option to determine the proper default.\n\t\t\t// The constants used in Gutenberg do not match WP options so a little more complicated than ideal.\n\t\t\t// TODO: fix this in a follow up PR, requires updating media-text and ui component.\n\t\t\tswitch (\n\t\t\t\twindow?.wp?.media?.view?.settings?.defaultProps?.link ||\n\t\t\t\tLINK_DESTINATION_NONE\n\t\t\t) {\n\t\t\t\tcase 'file':\n\t\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_MEDIA;\n\t\t\t\t\tbreak;\n\t\t\t\tcase 'post':\n\t\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_ATTACHMENT;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_CUSTOM:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_CUSTOM;\n\t\t\t\t\tbreak;\n\t\t\t\tcase LINK_DESTINATION_NONE:\n\t\t\t\t\tlinkDestination = LINK_DESTINATION_NONE;\n\t\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\n\t\t// Check if the image is linked to it's media.\n\t\tlet href;\n\t\tswitch ( linkDestination ) {\n\t\t\tcase LINK_DESTINATION_MEDIA:\n\t\t\t\thref = media.url;\n\t\t\t\tbreak;\n\t\t\tcase LINK_DESTINATION_ATTACHMENT:\n\t\t\t\thref = media.link;\n\t\t\t\tbreak;\n\t\t}\n\t\tmediaAttributes.href = href;\n\n\t\tsetAttributes( {\n\t\t\tblob: undefined,\n\t\t\t...mediaAttributes,\n\t\t\t...additionalAttributes,\n\t\t\tlinkDestination,\n\t\t} );\n\t\tsetTemporaryURL();\n\t}\n\n\tfunction onSelectURL( newURL ) {\n\t\tif ( newURL !== url ) {\n\t\t\tsetAttributes( {\n\t\t\t\tblob: undefined,\n\t\t\t\turl: newURL,\n\t\t\t\tid: undefined,\n\t\t\t\tsizeSlug: getSettings().imageDefaultSize,\n\t\t\t} );\n\t\t\tsetTemporaryURL();\n\t\t}\n\t}\n\n\tuseUploadMediaFromBlobURL( {\n\t\turl: temporaryURL,\n\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\tonChange: onSelectImage,\n\t\tonError: onUploadError,\n\t} );\n\n\tconst isExternal = isExternalImage( id, url );\n\tconst src = isExternal ? url : undefined;\n\tconst mediaPreview = !! url && (\n\t\t<img\n\t\t\talt={ __( 'Edit image' ) }\n\t\t\ttitle={ __( 'Edit image' ) }\n\t\t\tclassName=\"edit-image-preview\"\n\t\t\tsrc={ url }\n\t\t/>\n\t);\n\n\tconst borderProps = useBorderProps( attributes );\n\tconst shadowProps = getShadowClassesAndStyles( attributes );\n\n\tconst classes = clsx( className, {\n\t\t'is-transient': !! temporaryURL,\n\t\t'is-resized': !! width || !! height,\n\t\t[ `size-${ sizeSlug }` ]: sizeSlug,\n\t\t'has-custom-border':\n\t\t\t!! borderProps.className ||\n\t\t\t( borderProps.style &&\n\t\t\t\tObject.keys( borderProps.style ).length > 0 ),\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tref: containerRef,\n\t\tclassName: classes,\n\t} );\n\n\t// Much of this description is duplicated from MediaPlaceholder.\n\tconst { lockUrlControls = false, lockUrlControlsMessage } = useSelect(\n\t\t( select ) => {\n\t\t\tif ( ! isSingleSelected ) {\n\t\t\t\treturn {};\n\t\t\t}\n\n\t\t\tconst blockBindingsSource = unlock(\n\t\t\t\tselect( blocksStore )\n\t\t\t).getBlockBindingsSource( metadata?.bindings?.url?.source );\n\n\t\t\treturn {\n\t\t\t\tlockUrlControls:\n\t\t\t\t\t!! metadata?.bindings?.url &&\n\t\t\t\t\t! blockBindingsSource?.canUserEditValue?.( {\n\t\t\t\t\t\tselect,\n\t\t\t\t\t\tcontext,\n\t\t\t\t\t\targs: metadata?.bindings?.url?.args,\n\t\t\t\t\t} ),\n\t\t\t\tlockUrlControlsMessage: blockBindingsSource?.label\n\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t/* translators: %s: Label of the bindings source. */\n\t\t\t\t\t\t\t__( 'Connected to %s' ),\n\t\t\t\t\t\t\tblockBindingsSource.label\n\t\t\t\t\t )\n\t\t\t\t\t: __( 'Connected to dynamic data' ),\n\t\t\t};\n\t\t},\n\t\t[ context, isSingleSelected, metadata?.bindings?.url ]\n\t);\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ clsx( 'block-editor-media-placeholder', {\n\t\t\t\t\t[ borderProps.className ]:\n\t\t\t\t\t\t!! borderProps.className && ! isSingleSelected,\n\t\t\t\t} ) }\n\t\t\t\ticon={\n\t\t\t\t\t! isSmallContainer &&\n\t\t\t\t\t( lockUrlControls ? pluginsIcon : icon )\n\t\t\t\t}\n\t\t\t\twithIllustration={ ! isSingleSelected || isSmallContainer }\n\t\t\t\tlabel={ ! isSmallContainer && __( 'Image' ) }\n\t\t\t\tinstructions={\n\t\t\t\t\t! lockUrlControls &&\n\t\t\t\t\t! isSmallContainer &&\n\t\t\t\t\t__(\n\t\t\t\t\t\t'Upload or drag an image file here, or pick one from your library.'\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t\tstyle={ {\n\t\t\t\t\taspectRatio:\n\t\t\t\t\t\t! ( width && height ) && aspectRatio\n\t\t\t\t\t\t\t? aspectRatio\n\t\t\t\t\t\t\t: undefined,\n\t\t\t\t\twidth: height && aspectRatio ? '100%' : width,\n\t\t\t\t\theight: width && aspectRatio ? '100%' : height,\n\t\t\t\t\tobjectFit: scale,\n\t\t\t\t\t...borderProps.style,\n\t\t\t\t\t...shadowProps.style,\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ lockUrlControls &&\n\t\t\t\t\t! isSmallContainer &&\n\t\t\t\t\tlockUrlControlsMessage }\n\n\t\t\t\t{ ! lockUrlControls && ! isSmallContainer && content }\n\t\t\t\t{ placeholderResizeListener }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t<Image\n\t\t\t\t\ttemporaryURL={ temporaryURL }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tisSingleSelected={ isSingleSelected }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\tonSelectImage={ onSelectImage }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonUploadError={ onUploadError }\n\t\t\t\t\tcontext={ context }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tblockEditingMode={ blockEditingMode }\n\t\t\t\t\tparentLayoutType={ parentLayout?.type }\n\t\t\t\t\tmaxContentWidth={ maxContentWidth }\n\t\t\t\t/>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\tplaceholder={ placeholder }\n\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\thandleUpload={ ( files ) => files.length === 1 }\n\t\t\t\t\tvalue={ { id, src } }\n\t\t\t\t\tmediaPreview={ mediaPreview }\n\t\t\t\t\tdisableMediaButtons={ temporaryURL || url }\n\t\t\t\t/>\n\t\t\t</figure>\n\t\t\t{\n\t\t\t\t// The listener cannot be placed as the first element as it will break the in-between inserter.\n\t\t\t\t// See https://github.com/WordPress/gutenberg/blob/71134165868298fc15e22896d0c28b41b3755ff7/packages/block-editor/src/components/block-list/use-in-between-inserter.js#L120\n\t\t\t\tisSingleSelected && isMaxWidthContainerWidth && maxWidthObserver\n\t\t\t}\n\t\t</>\n\t);\n}\n\nexport default ImageEdit;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,SAAS,EAAEC,aAAa,QAAQ,iBAAiB;AAC1D,SAASC,KAAK,IAAIC,WAAW,EAAEC,WAAW,QAAQ,mBAAmB;AACrE,SAASC,WAAW,QAAQ,uBAAuB;AACnD,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SACCC,SAAS,EACTC,aAAa,EACbC,gBAAgB,EAChBR,KAAK,IAAIS,gBAAgB,EACzBC,4BAA4B,IAAIC,cAAc,EAC9CC,uCAAuC,IAAIC,yBAAyB,EACpEC,mBAAmB,QACb,yBAAyB;AAChC,SAASC,SAAS,EAAEC,MAAM,EAAEC,QAAQ,QAAQ,oBAAoB;AAChE,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,KAAK,IAAIC,IAAI,EAAEC,OAAO,IAAIC,WAAW,QAAQ,kBAAkB;AACxE,SAASvB,KAAK,IAAIwB,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,iBAAiB,QAAQ,oBAAoB;;AAEtD;AACA;AACA;AACA,SAASC,MAAM,QAAQ,gBAAgB;AACvC,SAASC,yBAAyB,QAAQ,gBAAgB;AAC1D,OAAOC,KAAK,MAAM,SAAS;AAC3B,SAASC,eAAe,QAAQ,SAAS;AACzC,SAASC,mBAAmB,QAAQ,0BAA0B;;AAE9D;AACA;AACA;AACA,SACCC,2BAA2B,EAC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rBwC,YAAY,EAAGA,YAAc;QAC7B8B,mBAAmB,EAAG/F,YAAY,IAAI9B;MAAK,CAC3C,CAAC;IAAA,CACK,CAAC;IAER;IACA;IACAa,gBAAgB,IAAIqB,wBAAwB,IAAIE,gBAAgB;EAAA,CAEhE,CAAC;AAEL;AAEA,eAAe3B,SAAS","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { isBlobURL } from '@wordpress/blob';
|
|
5
|
-
import {
|
|
5
|
+
import { ExternalLink, ResizableBox, Spinner, TextareaControl, TextControl, ToolbarButton, ToolbarGroup, Dropdown, __experimentalToolsPanel as ToolsPanel, __experimentalToolsPanelItem as ToolsPanelItem, __experimentalUseCustomUnits as useCustomUnits, Placeholder } from '@wordpress/components';
|
|
6
6
|
import { useViewportMatch } from '@wordpress/compose';
|
|
7
7
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
8
|
import { BlockControls, InspectorControls, __experimentalImageURLInputUI as ImageURLInputUI, MediaReplaceFlow, store as blockEditorStore, useSettings, __experimentalImageEditor as ImageEditor, __experimentalUseBorderProps as useBorderProps, __experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles, privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
@@ -83,7 +83,8 @@ export default function Image({
|
|
|
83
83
|
context,
|
|
84
84
|
clientId,
|
|
85
85
|
blockEditingMode,
|
|
86
|
-
parentLayoutType
|
|
86
|
+
parentLayoutType,
|
|
87
|
+
maxContentWidth
|
|
87
88
|
}) {
|
|
88
89
|
const {
|
|
89
90
|
url = '',
|
|
@@ -320,7 +321,7 @@ export default function Image({
|
|
|
320
321
|
}
|
|
321
322
|
}, [isSingleSelected]);
|
|
322
323
|
const canEditImage = id && naturalWidth && naturalHeight && imageEditing;
|
|
323
|
-
const allowCrop = isSingleSelected && canEditImage && !isEditingImage;
|
|
324
|
+
const allowCrop = isSingleSelected && canEditImage && !isEditingImage && !isContentOnlyMode;
|
|
324
325
|
function switchToCover() {
|
|
325
326
|
replaceBlocks(clientId, switchToBlockType(getBlock(clientId), 'core/cover'));
|
|
326
327
|
}
|
|
@@ -461,6 +462,20 @@ export default function Image({
|
|
|
461
462
|
const showUrlInput = isSingleSelected && !isEditingImage && !lockHrefControls && !lockUrlControls;
|
|
462
463
|
const showCoverControls = isSingleSelected && canInsertCover;
|
|
463
464
|
const showBlockControls = showUrlInput || allowCrop || showCoverControls;
|
|
465
|
+
const mediaReplaceFlow = isSingleSelected && !isEditingImage && !lockUrlControls && /*#__PURE__*/_jsx(BlockControls, {
|
|
466
|
+
group: "other",
|
|
467
|
+
children: /*#__PURE__*/_jsx(MediaReplaceFlow, {
|
|
468
|
+
mediaId: id,
|
|
469
|
+
mediaURL: url,
|
|
470
|
+
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
471
|
+
accept: "image/*",
|
|
472
|
+
onSelect: onSelectImage,
|
|
473
|
+
onSelectURL: onSelectURL,
|
|
474
|
+
onError: onUploadError,
|
|
475
|
+
name: !url ? __('Add image') : __('Replace'),
|
|
476
|
+
onReset: () => onSelectImage(undefined)
|
|
477
|
+
})
|
|
478
|
+
});
|
|
464
479
|
const controls = /*#__PURE__*/_jsxs(_Fragment, {
|
|
465
480
|
children: [showBlockControls && /*#__PURE__*/_jsxs(BlockControls, {
|
|
466
481
|
group: "block",
|
|
@@ -486,21 +501,6 @@ export default function Image({
|
|
|
486
501
|
label: __('Add text over image'),
|
|
487
502
|
onClick: switchToCover
|
|
488
503
|
})]
|
|
489
|
-
}), isSingleSelected && !isEditingImage && !lockUrlControls && /*#__PURE__*/_jsx(BlockControls, {
|
|
490
|
-
group: "other",
|
|
491
|
-
children: /*#__PURE__*/_jsx(MediaReplaceFlow, {
|
|
492
|
-
mediaId: id,
|
|
493
|
-
mediaURL: url,
|
|
494
|
-
allowedTypes: ALLOWED_MEDIA_TYPES,
|
|
495
|
-
accept: "image/*",
|
|
496
|
-
onSelect: onSelectImage,
|
|
497
|
-
onSelectURL: onSelectURL,
|
|
498
|
-
onError: onUploadError,
|
|
499
|
-
children: /*#__PURE__*/_jsx(MenuItem, {
|
|
500
|
-
onClick: () => onSelectImage(undefined),
|
|
501
|
-
children: __('Reset')
|
|
502
|
-
})
|
|
503
|
-
})
|
|
504
504
|
}), isSingleSelected && externalBlob && /*#__PURE__*/_jsx(BlockControls, {
|
|
505
505
|
children: /*#__PURE__*/_jsx(ToolbarGroup, {
|
|
506
506
|
children: /*#__PURE__*/_jsx(ToolbarButton, {
|
|
@@ -533,7 +533,7 @@ export default function Image({
|
|
|
533
533
|
onToggle();
|
|
534
534
|
}
|
|
535
535
|
},
|
|
536
|
-
children: _x('
|
|
536
|
+
children: _x('Alternative text', 'Alternative text for an image. Block toolbar label, a low character count is preferred.')
|
|
537
537
|
}),
|
|
538
538
|
renderContent: () => /*#__PURE__*/_jsx(TextareaControl, {
|
|
539
539
|
className: "wp-block-image__toolbar_content_textarea",
|
|
@@ -553,7 +553,7 @@ export default function Image({
|
|
|
553
553
|
}),
|
|
554
554
|
__nextHasNoMarginBottom: true
|
|
555
555
|
})
|
|
556
|
-
}), /*#__PURE__*/_jsx(Dropdown, {
|
|
556
|
+
}), title && /*#__PURE__*/_jsx(Dropdown, {
|
|
557
557
|
popoverProps: {
|
|
558
558
|
position: 'bottom right'
|
|
559
559
|
},
|
|
@@ -738,6 +738,7 @@ export default function Image({
|
|
|
738
738
|
// @todo It would be good to revisit this once a content-width variable
|
|
739
739
|
// becomes available.
|
|
740
740
|
const maxWidthBuffer = maxWidth * 2.5;
|
|
741
|
+
const maxResizeWidth = maxContentWidth || maxWidthBuffer;
|
|
741
742
|
let showRightHandle = false;
|
|
742
743
|
let showLeftHandle = false;
|
|
743
744
|
|
|
@@ -778,9 +779,9 @@ export default function Image({
|
|
|
778
779
|
},
|
|
779
780
|
showHandle: isSingleSelected,
|
|
780
781
|
minWidth: minWidth,
|
|
781
|
-
maxWidth:
|
|
782
|
+
maxWidth: maxResizeWidth,
|
|
782
783
|
minHeight: minHeight,
|
|
783
|
-
maxHeight:
|
|
784
|
+
maxHeight: maxResizeWidth / ratio,
|
|
784
785
|
lockAspectRatio: ratio,
|
|
785
786
|
enable: {
|
|
786
787
|
top: false,
|
|
@@ -791,6 +792,19 @@ export default function Image({
|
|
|
791
792
|
onResizeStart: onResizeStart,
|
|
792
793
|
onResizeStop: (event, direction, elt) => {
|
|
793
794
|
onResizeStop();
|
|
795
|
+
|
|
796
|
+
// Clear hardcoded width if the resized width is close to the max-content width.
|
|
797
|
+
if (maxContentWidth &&
|
|
798
|
+
// Only do this if the image is bigger than the container to prevent it from being squished.
|
|
799
|
+
// TODO: Remove this check if the image support setting 100% width.
|
|
800
|
+
naturalWidth >= maxContentWidth && Math.abs(elt.offsetWidth - maxContentWidth) < 10) {
|
|
801
|
+
setAttributes({
|
|
802
|
+
width: undefined,
|
|
803
|
+
height: undefined
|
|
804
|
+
});
|
|
805
|
+
return;
|
|
806
|
+
}
|
|
807
|
+
|
|
794
808
|
// Since the aspect ratio is locked when resizing, we can
|
|
795
809
|
// use the width of the resized element to calculate the
|
|
796
810
|
// height in CSS to prevent stretching when the max-width
|
|
@@ -809,11 +823,12 @@ export default function Image({
|
|
|
809
823
|
});
|
|
810
824
|
}
|
|
811
825
|
if (!url && !temporaryURL) {
|
|
812
|
-
|
|
813
|
-
|
|
826
|
+
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
827
|
+
children: [mediaReplaceFlow, metadata?.bindings ? controls : sizeControls]
|
|
828
|
+
});
|
|
814
829
|
}
|
|
815
830
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
816
|
-
children: [controls, img, /*#__PURE__*/_jsx(Caption, {
|
|
831
|
+
children: [mediaReplaceFlow, controls, img, /*#__PURE__*/_jsx(Caption, {
|
|
817
832
|
attributes: attributes,
|
|
818
833
|
setAttributes: setAttributes,
|
|
819
834
|
isSelected: isSingleSelected,
|