@wordpress/block-library 8.4.0 → 8.6.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 +4 -0
- package/build/archives/edit.js +3 -0
- package/build/archives/edit.js.map +1 -1
- package/build/audio/edit.js +2 -0
- package/build/audio/edit.js.map +1 -1
- package/build/avatar/edit.js +5 -9
- package/build/avatar/edit.js.map +1 -1
- package/build/buttons/edit.native.js +1 -1
- package/build/buttons/edit.native.js.map +1 -1
- package/build/categories/edit.js +5 -0
- package/build/categories/edit.js.map +1 -1
- package/build/columns/edit.js +11 -8
- package/build/columns/edit.js.map +1 -1
- package/build/columns/edit.native.js +1 -1
- package/build/columns/edit.native.js.map +1 -1
- package/build/columns/utils.js +2 -2
- package/build/columns/utils.js.map +1 -1
- package/build/comment-author-name/edit.js +2 -0
- package/build/comment-author-name/edit.js.map +1 -1
- package/build/comment-date/edit.js +1 -0
- package/build/comment-date/edit.js.map +1 -1
- package/build/comment-edit-link/edit.js +1 -0
- package/build/comment-edit-link/edit.js.map +1 -1
- package/build/comments/edit/placeholder.js +8 -5
- package/build/comments/edit/placeholder.js.map +1 -1
- package/build/comments-title/edit.js +2 -0
- package/build/comments-title/edit.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +2 -0
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/index.js +13 -4
- package/build/cover/index.js.map +1 -1
- package/build/cover/variations.js +29 -0
- package/build/cover/variations.js.map +1 -0
- package/build/embed/edit.js +13 -14
- package/build/embed/edit.js.map +1 -1
- package/build/embed/edit.native.js +18 -14
- package/build/embed/edit.native.js.map +1 -1
- package/build/embed/embed-controls.js +1 -0
- package/build/embed/embed-controls.js.map +1 -1
- package/build/embed/util.js +39 -12
- package/build/embed/util.js.map +1 -1
- package/build/file/inspector.js +3 -0
- package/build/file/inspector.js.map +1 -1
- package/build/freeform/modal.js +1 -1
- package/build/freeform/modal.js.map +1 -1
- package/build/gallery/edit.js +3 -0
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/shared.js +4 -8
- package/build/gallery/shared.js.map +1 -1
- package/build/gallery/use-image-sizes.js +4 -8
- package/build/gallery/use-image-sizes.js.map +1 -1
- package/build/gallery/v1/edit.js +8 -3
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/gallery/v1/gallery-image.js +1 -3
- package/build/gallery/v1/gallery-image.js.map +1 -1
- package/build/gallery/v1/shared.js +4 -7
- package/build/gallery/v1/shared.js.map +1 -1
- package/build/image/edit.js +6 -4
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +6 -2
- package/build/image/image.js.map +1 -1
- package/build/image/utils.js +3 -1
- 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 +3 -0
- package/build/latest-comments/edit.js.map +1 -1
- package/build/latest-posts/edit.js +14 -10
- package/build/latest-posts/edit.js.map +1 -1
- package/build/latest-posts/edit.native.js +3 -3
- package/build/latest-posts/edit.native.js.map +1 -1
- package/build/list/ordered-list-settings.js +1 -0
- package/build/list/ordered-list-settings.js.map +1 -1
- package/build/list-item/edit.js +2 -2
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/use-outdent-list-item.js +2 -1
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/loginout/edit.js +2 -0
- package/build/loginout/edit.js.map +1 -1
- package/build/media-text/constants.js +17 -1
- package/build/media-text/constants.js.map +1 -1
- package/build/media-text/edit.js +9 -19
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/edit.native.js +6 -5
- package/build/media-text/edit.native.js.map +1 -1
- package/build/media-text/transforms.js +32 -44
- package/build/media-text/transforms.js.map +1 -1
- package/build/more/edit.js +1 -0
- package/build/more/edit.js.map +1 -1
- package/build/navigation/edit/index.js +64 -68
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +4 -1
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +2 -5
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +26 -22
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/overlay-menu-preview.js +1 -0
- package/build/navigation/edit/overlay-menu-preview.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +1 -1
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +14 -1
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +3 -5
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build/navigation/edit/use-generate-default-navigation-title.js +1 -1
- package/build/navigation/edit/use-generate-default-navigation-title.js.map +1 -1
- package/build/navigation/edit/use-navigation-notice.js +4 -7
- package/build/navigation/edit/use-navigation-notice.js.map +1 -1
- package/build/navigation-link/edit.js +0 -11
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +1 -13
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +47 -0
- package/build/page-list/convert-to-links-modal.js.map +1 -0
- package/build/page-list/edit.js +62 -62
- package/build/page-list/edit.js.map +1 -1
- package/build/page-list-item/edit.js +3 -2
- package/build/page-list-item/edit.js.map +1 -1
- package/build/paragraph/edit.js +1 -0
- package/build/paragraph/edit.js.map +1 -1
- package/build/post-author/edit.js +4 -0
- package/build/post-author/edit.js.map +1 -1
- package/build/post-author-name/edit.js +2 -0
- package/build/post-author-name/edit.js.map +1 -1
- package/build/post-content/edit.js +6 -1
- package/build/post-content/edit.js.map +1 -1
- package/build/post-date/edit.js +2 -0
- package/build/post-date/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +1 -0
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +0 -6
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-featured-image/edit.js +3 -1
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-navigation-link/edit.js +2 -0
- package/build/post-navigation-link/edit.js.map +1 -1
- package/build/post-terms/use-post-terms.js +1 -1
- package/build/post-terms/use-post-terms.js.map +1 -1
- package/build/post-time-to-read/edit.js +104 -0
- package/build/post-time-to-read/edit.js.map +1 -0
- package/build/post-time-to-read/icon.js +25 -0
- package/build/post-time-to-read/icon.js.map +1 -0
- package/build/post-time-to-read/index.js +57 -0
- package/build/post-time-to-read/index.js.map +1 -0
- package/build/post-title/edit.js +2 -0
- package/build/post-title/edit.js.map +1 -1
- package/build/pullquote/deprecated.js +3 -3
- package/build/pullquote/deprecated.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +1 -0
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/query-placeholder.js +3 -2
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/utils.js +26 -9
- package/build/query/utils.js.map +1 -1
- package/build/query-title/edit.js +2 -0
- package/build/query-title/edit.js.map +1 -1
- package/build/read-more/edit.js +1 -0
- package/build/read-more/edit.js.map +1 -1
- package/build/rss/edit.js +3 -0
- package/build/rss/edit.js.map +1 -1
- package/build/site-logo/edit.js +3 -0
- package/build/site-logo/edit.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 +2 -0
- package/build/site-title/edit/index.js.map +1 -1
- package/build/social-links/edit.js +4 -1
- package/build/social-links/edit.js.map +1 -1
- package/build/spacer/controls.native.js +10 -8
- package/build/spacer/controls.native.js.map +1 -1
- package/build/spacer/edit.native.js +43 -5
- package/build/spacer/edit.native.js.map +1 -1
- package/build/spacer/save.native.js +30 -0
- package/build/spacer/save.native.js.map +1 -0
- package/build/table/edit.js +3 -0
- package/build/table/edit.js.map +1 -1
- package/build/table/state.js +12 -4
- package/build/table/state.js.map +1 -1
- package/build/table-of-contents/edit.js +1 -0
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/tag-cloud/edit.js +1 -0
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/template-part/edit/import-controls.js +33 -30
- package/build/template-part/edit/import-controls.js.map +1 -1
- package/build/template-part/edit/utils/transformers.js +69 -19
- package/build/template-part/edit/utils/transformers.js.map +1 -1
- package/build/text-columns/edit.js +3 -7
- package/build/text-columns/edit.js.map +1 -1
- package/build/text-columns/save.js +11 -13
- package/build/text-columns/save.js.map +1 -1
- package/build/video/edit-common-settings.js +5 -0
- package/build/video/edit-common-settings.js.map +1 -1
- package/build-module/archives/edit.js +3 -0
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/audio/edit.js +2 -0
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/avatar/edit.js +5 -8
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/buttons/edit.native.js +1 -1
- package/build-module/buttons/edit.native.js.map +1 -1
- package/build-module/categories/edit.js +5 -0
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/columns/edit.js +11 -7
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/columns/edit.native.js +1 -1
- package/build-module/columns/edit.native.js.map +1 -1
- package/build-module/columns/utils.js +3 -3
- package/build-module/columns/utils.js.map +1 -1
- package/build-module/comment-author-name/edit.js +2 -0
- package/build-module/comment-author-name/edit.js.map +1 -1
- package/build-module/comment-date/edit.js +1 -0
- package/build-module/comment-date/edit.js.map +1 -1
- package/build-module/comment-edit-link/edit.js +1 -0
- package/build-module/comment-edit-link/edit.js.map +1 -1
- package/build-module/comments/edit/placeholder.js +9 -5
- package/build-module/comments/edit/placeholder.js.map +1 -1
- package/build-module/comments-title/edit.js +2 -0
- package/build-module/comments-title/edit.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +2 -0
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/index.js +12 -4
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/variations.js +19 -0
- package/build-module/cover/variations.js.map +1 -0
- package/build-module/embed/edit.js +14 -15
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/embed/edit.native.js +19 -15
- package/build-module/embed/edit.native.js.map +1 -1
- package/build-module/embed/embed-controls.js +1 -0
- package/build-module/embed/embed-controls.js.map +1 -1
- package/build-module/embed/util.js +34 -10
- package/build-module/embed/util.js.map +1 -1
- package/build-module/file/inspector.js +3 -0
- package/build-module/file/inspector.js.map +1 -1
- package/build-module/freeform/modal.js +1 -1
- package/build-module/freeform/modal.js.map +1 -1
- package/build-module/gallery/edit.js +3 -0
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/shared.js +4 -7
- package/build-module/gallery/shared.js.map +1 -1
- package/build-module/gallery/use-image-sizes.js +4 -7
- package/build-module/gallery/use-image-sizes.js.map +1 -1
- package/build-module/gallery/v1/edit.js +9 -4
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/gallery/v1/gallery-image.js +1 -2
- package/build-module/gallery/v1/gallery-image.js.map +1 -1
- package/build-module/gallery/v1/shared.js +4 -6
- package/build-module/gallery/v1/shared.js.map +1 -1
- package/build-module/image/edit.js +7 -5
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +7 -3
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/utils.js +4 -2
- 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 +3 -0
- package/build-module/latest-comments/edit.js.map +1 -1
- package/build-module/latest-posts/edit.js +14 -9
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/latest-posts/edit.native.js +3 -3
- package/build-module/latest-posts/edit.native.js.map +1 -1
- package/build-module/list/ordered-list-settings.js +1 -0
- package/build-module/list/ordered-list-settings.js.map +1 -1
- package/build-module/list-item/edit.js +2 -2
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js +2 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/loginout/edit.js +2 -0
- package/build-module/loginout/edit.js.map +1 -1
- package/build-module/media-text/constants.js +10 -0
- package/build-module/media-text/constants.js.map +1 -1
- package/build-module/media-text/edit.js +4 -14
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/edit.native.js +4 -3
- package/build-module/media-text/edit.native.js.map +1 -1
- package/build-module/media-text/transforms.js +32 -44
- package/build-module/media-text/transforms.js.map +1 -1
- package/build-module/more/edit.js +1 -0
- package/build-module/more/edit.js.map +1 -1
- package/build-module/navigation/edit/index.js +65 -69
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +4 -1
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +2 -5
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +25 -22
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/overlay-menu-preview.js +1 -0
- package/build-module/navigation/edit/overlay-menu-preview.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +1 -1
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +14 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +3 -5
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build-module/navigation/edit/use-generate-default-navigation-title.js +1 -1
- package/build-module/navigation/edit/use-generate-default-navigation-title.js.map +1 -1
- package/build-module/navigation/edit/use-navigation-notice.js +5 -8
- package/build-module/navigation/edit/use-navigation-notice.js.map +1 -1
- package/build-module/navigation-link/edit.js +0 -11
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +1 -13
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +35 -0
- package/build-module/page-list/convert-to-links-modal.js.map +1 -0
- package/build-module/page-list/edit.js +64 -65
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/page-list-item/edit.js +3 -2
- package/build-module/page-list-item/edit.js.map +1 -1
- package/build-module/paragraph/edit.js +1 -0
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/post-author/edit.js +4 -0
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-author-name/edit.js +2 -0
- package/build-module/post-author-name/edit.js.map +1 -1
- package/build-module/post-content/edit.js +6 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-date/edit.js +2 -0
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +1 -0
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +0 -6
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-featured-image/edit.js +3 -1
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-navigation-link/edit.js +2 -0
- package/build-module/post-navigation-link/edit.js.map +1 -1
- package/build-module/post-terms/use-post-terms.js +1 -1
- package/build-module/post-terms/use-post-terms.js.map +1 -1
- package/build-module/post-time-to-read/edit.js +90 -0
- package/build-module/post-time-to-read/edit.js.map +1 -0
- package/build-module/post-time-to-read/icon.js +15 -0
- package/build-module/post-time-to-read/icon.js.map +1 -0
- package/build-module/post-time-to-read/index.js +40 -0
- package/build-module/post-time-to-read/index.js.map +1 -0
- package/build-module/post-title/edit.js +2 -0
- package/build-module/post-title/edit.js.map +1 -1
- package/build-module/pullquote/deprecated.js +3 -2
- package/build-module/pullquote/deprecated.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +1 -0
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +4 -3
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/utils.js +21 -6
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query-title/edit.js +2 -0
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/read-more/edit.js +1 -0
- package/build-module/read-more/edit.js.map +1 -1
- package/build-module/rss/edit.js +3 -0
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +3 -0
- package/build-module/site-logo/edit.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 +2 -0
- package/build-module/site-title/edit/index.js.map +1 -1
- package/build-module/social-links/edit.js +4 -1
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/spacer/controls.native.js +9 -8
- package/build-module/spacer/controls.native.js.map +1 -1
- package/build-module/spacer/edit.native.js +39 -7
- package/build-module/spacer/edit.native.js.map +1 -1
- package/build-module/spacer/save.native.js +22 -0
- package/build-module/spacer/save.native.js.map +1 -0
- package/build-module/table/edit.js +3 -0
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table/state.js +13 -5
- package/build-module/table/state.js.map +1 -1
- package/build-module/table-of-contents/edit.js +1 -0
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/tag-cloud/edit.js +1 -0
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/template-part/edit/import-controls.js +32 -29
- package/build-module/template-part/edit/import-controls.js.map +1 -1
- package/build-module/template-part/edit/utils/transformers.js +69 -20
- package/build-module/template-part/edit/utils/transformers.js.map +1 -1
- package/build-module/text-columns/edit.js +3 -6
- package/build-module/text-columns/edit.js.map +1 -1
- package/build-module/text-columns/save.js +11 -12
- package/build-module/text-columns/save.js.map +1 -1
- package/build-module/video/edit-common-settings.js +5 -0
- package/build-module/video/edit-common-settings.js.map +1 -1
- package/build-style/cover/style-rtl.css +11 -5
- package/build-style/cover/style.css +11 -5
- package/build-style/editor-rtl.css +9 -4
- package/build-style/editor.css +9 -4
- package/build-style/navigation/editor-rtl.css +1 -1
- package/build-style/navigation/editor.css +1 -1
- package/build-style/page-list/editor-rtl.css +4 -0
- package/build-style/page-list/editor.css +4 -0
- package/build-style/post-excerpt/editor-rtl.css +1 -1
- package/build-style/post-excerpt/editor.css +1 -1
- package/build-style/post-featured-image/style-rtl.css +1 -0
- package/build-style/post-featured-image/style.css +1 -0
- package/build-style/query/editor-rtl.css +1 -0
- package/build-style/query/editor.css +1 -0
- package/build-style/site-logo/editor-rtl.css +2 -2
- package/build-style/site-logo/editor.css +2 -2
- package/build-style/style-rtl.css +12 -5
- package/build-style/style.css +12 -5
- package/package.json +31 -30
- package/src/archives/edit.js +3 -0
- package/src/audio/edit.js +2 -0
- package/src/audio/test/__snapshots__/edit.native.js.snap +82 -42
- package/src/audio/test/__snapshots__/transforms.native.js.snap +25 -0
- package/src/audio/test/transforms.native.js +42 -0
- package/src/avatar/edit.js +2 -4
- package/src/block/test/__snapshots__/transforms.native.js.snap +15 -0
- package/src/block/test/transforms.native.js +40 -0
- package/src/buttons/edit.native.js +1 -1
- package/src/buttons/test/__snapshots__/edit.native.js.snap +11 -11
- package/src/buttons/test/__snapshots__/transforms.native.js.snap +31 -0
- package/src/buttons/test/transforms.native.js +48 -0
- package/src/categories/edit.js +5 -0
- package/src/code/test/__snapshots__/edit.native.js.snap +2 -2
- package/src/columns/edit.js +29 -17
- package/src/columns/edit.native.js +1 -1
- package/src/columns/test/__snapshots__/edit.native.js.snap +66 -66
- package/src/columns/test/__snapshots__/transforms.native.js.snap +61 -0
- package/src/columns/test/transforms.native.js +91 -0
- package/src/columns/test/utils.js +54 -0
- package/src/columns/utils.js +8 -8
- package/src/comment-author-name/edit.js +2 -0
- package/src/comment-date/edit.js +1 -0
- package/src/comment-edit-link/edit.js +1 -0
- package/src/comment-template/index.php +1 -2
- package/src/comments/edit/placeholder.js +16 -4
- package/src/comments-title/edit.js +2 -0
- package/src/cover/block.json +9 -3
- package/src/cover/edit/inspector-controls.js +2 -0
- package/src/cover/index.js +2 -0
- package/src/cover/index.php +4 -6
- package/src/cover/style.scss +16 -7
- package/src/cover/test/__snapshots__/edit.native.js.snap +36 -36
- package/src/cover/test/__snapshots__/transforms.native.js.snap +73 -0
- package/src/cover/test/transforms.native.js +112 -0
- package/src/cover/variations.js +20 -0
- package/src/embed/edit.js +16 -12
- package/src/embed/edit.native.js +28 -18
- package/src/embed/embed-controls.js +1 -0
- package/src/embed/test/__snapshots__/index.native.js.snap +52 -52
- package/src/embed/test/__snapshots__/transforms.native.js.snap +23 -0
- package/src/embed/test/index.js +12 -0
- package/src/embed/test/transforms.native.js +44 -0
- package/src/embed/util.js +29 -8
- package/src/file/inspector.js +3 -0
- package/src/file/test/__snapshots__/edit.native.js.snap +67 -51
- package/src/file/test/__snapshots__/transforms.native.js.snap +19 -0
- package/src/file/test/transforms.native.js +42 -0
- package/src/freeform/modal.js +1 -1
- package/src/freeform/test/__snapshots__/transforms.native.js.snap +19 -0
- package/src/freeform/test/transforms.native.js +39 -0
- package/src/gallery/edit.js +5 -0
- package/src/gallery/shared.js +6 -11
- package/src/gallery/test/__snapshots__/index.native.js.snap +71 -71
- package/src/gallery/test/__snapshots__/transforms.native.js.snap +53 -0
- package/src/gallery/test/transforms.native.js +52 -0
- package/src/gallery/use-image-sizes.js +3 -16
- package/src/gallery/v1/edit.js +8 -16
- package/src/gallery/v1/gallery-image.js +1 -2
- package/src/gallery/v1/shared.js +5 -10
- package/src/group/test/__snapshots__/edit.native.js.snap +5 -5
- package/src/group/test/__snapshots__/transforms.native.js.snap +35 -0
- package/src/group/test/transforms.native.js +75 -0
- package/src/heading/test/__snapshots__/index.native.js.snap +1 -1
- package/src/heading/test/__snapshots__/transforms.native.js.snap +47 -0
- package/src/heading/test/transforms.native.js +46 -0
- package/src/image/edit.js +4 -4
- package/src/image/image.js +4 -9
- package/src/image/index.php +4 -4
- package/src/image/test/__snapshots__/transforms.native.js.snap +49 -0
- package/src/image/test/transforms.native.js +48 -0
- package/src/image/utils.js +2 -2
- package/src/index.js +2 -0
- package/src/latest-comments/edit.js +3 -0
- package/src/latest-posts/edit.js +15 -16
- package/src/latest-posts/edit.native.js +3 -3
- package/src/latest-posts/test/__snapshots__/transforms.native.js.snap +15 -0
- package/src/latest-posts/test/transforms.native.js +61 -0
- package/src/list/ordered-list-settings.js +1 -0
- package/src/list/test/__snapshots__/edit.native.js.snap +4 -4
- package/src/list/test/__snapshots__/transforms.native.js.snap +85 -0
- package/src/list/test/transforms.native.js +56 -0
- package/src/list-item/edit.js +10 -3
- package/src/list-item/hooks/use-outdent-list-item.js +2 -1
- package/src/loginout/edit.js +2 -0
- package/src/media-text/constants.js +16 -0
- package/src/media-text/edit.js +10 -18
- package/src/media-text/edit.native.js +3 -9
- package/src/media-text/test/__snapshots__/transforms.native.js.snap +73 -0
- package/src/media-text/test/transforms.native.js +112 -0
- package/src/media-text/transforms.js +24 -51
- package/src/missing/test/__snapshots__/edit.native.js.snap +21 -3
- package/src/more/edit.js +1 -0
- package/src/more/test/__snapshots__/transforms.native.js.snap +19 -0
- package/src/more/test/transforms.native.js +42 -0
- package/src/navigation/edit/index.js +121 -76
- package/src/navigation/edit/inner-blocks.js +3 -0
- package/src/navigation/edit/menu-inspector-controls.js +2 -7
- package/src/navigation/edit/navigation-menu-selector.js +41 -25
- package/src/navigation/edit/overlay-menu-preview.js +1 -0
- package/src/navigation/edit/placeholder/index.js +1 -1
- package/src/navigation/edit/unsaved-inner-blocks.js +46 -32
- package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +124 -122
- package/src/navigation/edit/use-create-navigation-menu.js +1 -1
- package/src/navigation/edit/use-generate-default-navigation-title.js +1 -1
- package/src/navigation/edit/use-navigation-notice.js +16 -13
- package/src/navigation/editor.scss +23 -20
- package/src/navigation/index.php +5 -3
- package/src/navigation-link/edit.js +0 -9
- package/src/navigation-link/index.php +5 -8
- package/src/navigation-link/test/__snapshots__/hooks.js.snap +12 -12
- package/src/navigation-submenu/edit.js +0 -10
- package/src/navigation-submenu/index.php +23 -6
- package/src/nextpage/test/__snapshots__/transforms.native.js.snap +19 -0
- package/src/nextpage/test/transforms.native.js +42 -0
- package/src/page-list/convert-to-links-modal.js +38 -0
- package/src/page-list/edit.js +82 -69
- package/src/page-list/editor.scss +6 -0
- package/src/page-list-item/edit.js +2 -3
- package/src/paragraph/edit.js +1 -0
- package/src/paragraph/test/__snapshots__/transforms.native.js.snap +59 -0
- package/src/paragraph/test/transforms.native.js +50 -0
- package/src/post-author/edit.js +4 -0
- package/src/post-author-name/edit.js +2 -0
- package/src/post-content/edit.js +5 -1
- package/src/post-date/edit.js +2 -0
- package/src/post-excerpt/edit.js +1 -0
- package/src/post-excerpt/editor.scss +1 -1
- package/src/post-excerpt/index.php +1 -2
- package/src/post-featured-image/dimension-controls.js +0 -8
- package/src/post-featured-image/edit.js +3 -1
- package/src/post-featured-image/style.scss +1 -0
- package/src/post-navigation-link/edit.js +2 -0
- package/src/post-terms/index.php +1 -0
- package/src/post-terms/use-post-terms.js +1 -1
- package/src/post-time-to-read/block.json +20 -0
- package/src/post-time-to-read/edit.js +101 -0
- package/src/post-time-to-read/icon.js +15 -0
- package/src/post-time-to-read/index.js +17 -0
- package/src/post-time-to-read/index.php +62 -0
- package/src/post-title/edit.js +2 -0
- package/src/preformatted/test/__snapshots__/edit.native.js.snap +10 -10
- package/src/preformatted/test/__snapshots__/transforms.native.js.snap +31 -0
- package/src/preformatted/test/transforms.native.js +42 -0
- package/src/pullquote/deprecated.js +2 -6
- package/src/pullquote/test/__snapshots__/transforms.native.js.snap +47 -0
- package/src/pullquote/test/transforms.native.js +46 -0
- package/src/query/edit/inspector-controls/index.js +1 -0
- package/src/query/edit/query-placeholder.js +10 -5
- package/src/query/editor.scss +1 -0
- package/src/query/test/utils.js +33 -1
- package/src/query/utils.js +19 -6
- package/src/query-title/edit.js +2 -0
- package/src/quote/test/__snapshots__/transforms.native.js.snap +39 -0
- package/src/quote/test/transforms.native.js +67 -0
- package/src/read-more/edit.js +1 -0
- package/src/rss/edit.js +3 -0
- package/src/search/test/__snapshots__/edit.native.js.snap +71 -61
- package/src/search/test/__snapshots__/transforms.native.js.snap +15 -0
- package/src/search/test/transforms.native.js +40 -0
- package/src/separator/test/__snapshots__/edit.native.js.snap +1 -1
- package/src/separator/test/__snapshots__/transforms.native.js.snap +19 -0
- package/src/separator/test/transforms.native.js +42 -0
- package/src/shortcode/test/__snapshots__/transforms.native.js.snap +19 -0
- package/src/shortcode/test/transforms.native.js +42 -0
- package/src/site-logo/edit.js +3 -0
- package/src/site-logo/editor.scss +3 -3
- package/src/site-logo/index.php +7 -2
- package/src/site-tagline/block.json +1 -0
- package/src/site-title/edit/index.js +2 -0
- package/src/social-link/index.php +6 -6
- package/src/social-links/edit.js +3 -0
- package/src/social-links/test/__snapshots__/edit.native.js.snap +16 -16
- package/src/social-links/test/__snapshots__/transforms.native.js.snap +31 -0
- package/src/social-links/test/transforms.native.js +53 -0
- package/src/spacer/controls.native.js +13 -5
- package/src/spacer/edit.native.js +45 -6
- package/src/spacer/save.native.js +18 -0
- package/src/spacer/test/__snapshots__/index.native.js.snap +21 -9
- package/src/spacer/test/__snapshots__/transforms.native.js.snap +19 -0
- package/src/spacer/test/index.native.js +81 -0
- package/src/spacer/test/transforms.native.js +42 -0
- package/src/table/edit.js +3 -0
- package/src/table/state.js +8 -17
- package/src/table-of-contents/edit.js +1 -0
- package/src/tag-cloud/edit.js +1 -0
- package/src/template-part/edit/import-controls.js +26 -34
- package/src/template-part/edit/utils/transformers.js +96 -19
- package/src/template-part/index.php +7 -6
- package/src/text-columns/edit.js +1 -6
- package/src/text-columns/save.js +1 -6
- package/src/verse/test/__snapshots__/edit.native.js.snap +2 -2
- package/src/verse/test/__snapshots__/transforms.native.js.snap +25 -0
- package/src/verse/test/transforms.native.js +42 -0
- package/src/video/edit-common-settings.js +5 -0
- package/src/video/test/__snapshots__/transforms.native.js.snap +41 -0
- package/src/video/test/transforms.native.js +48 -0
- package/tsconfig.json +2 -1
- package/tsconfig.tsbuildinfo +1 -1
package/build/cover/index.js
CHANGED
|
@@ -21,6 +21,8 @@ var _save = _interopRequireDefault(require("./save"));
|
|
|
21
21
|
|
|
22
22
|
var _transforms = _interopRequireDefault(require("./transforms"));
|
|
23
23
|
|
|
24
|
+
var _variations = _interopRequireDefault(require("./variations"));
|
|
25
|
+
|
|
24
26
|
/**
|
|
25
27
|
* WordPress dependencies
|
|
26
28
|
*/
|
|
@@ -118,14 +120,17 @@ const metadata = {
|
|
|
118
120
|
spacing: {
|
|
119
121
|
padding: true,
|
|
120
122
|
margin: ["top", "bottom"],
|
|
123
|
+
blockGap: true,
|
|
121
124
|
__experimentalDefaultControls: {
|
|
122
|
-
padding: true
|
|
125
|
+
padding: true,
|
|
126
|
+
blockGap: true
|
|
123
127
|
}
|
|
124
128
|
},
|
|
125
129
|
color: {
|
|
126
130
|
__experimentalDuotone: "> .wp-block-cover__image-background, > .wp-block-cover__video-background",
|
|
127
|
-
text:
|
|
128
|
-
background: false
|
|
131
|
+
text: true,
|
|
132
|
+
background: false,
|
|
133
|
+
__experimentalSkipSerialization: ["gradients"]
|
|
129
134
|
},
|
|
130
135
|
typography: {
|
|
131
136
|
fontSize: true,
|
|
@@ -139,6 +144,9 @@ const metadata = {
|
|
|
139
144
|
__experimentalDefaultControls: {
|
|
140
145
|
fontSize: true
|
|
141
146
|
}
|
|
147
|
+
},
|
|
148
|
+
__experimentalLayout: {
|
|
149
|
+
allowJustification: false
|
|
142
150
|
}
|
|
143
151
|
},
|
|
144
152
|
editorStyle: "wp-block-cover-editor",
|
|
@@ -176,7 +184,8 @@ const settings = {
|
|
|
176
184
|
transforms: _transforms.default,
|
|
177
185
|
save: _save.default,
|
|
178
186
|
edit: _edit.default,
|
|
179
|
-
deprecated: _deprecated.default
|
|
187
|
+
deprecated: _deprecated.default,
|
|
188
|
+
variations: _variations.default
|
|
180
189
|
};
|
|
181
190
|
exports.settings = settings;
|
|
182
191
|
|
package/build/cover/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/cover/index.js"],"names":["name","metadata","settings","icon","example","attributes","customOverlayColor","dimRatio","url","innerBlocks","content","align","style","typography","fontSize","color","text","transforms","save","edit","deprecated","init"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/cover/index.js"],"names":["name","metadata","settings","icon","example","attributes","customOverlayColor","dimRatio","url","innerBlocks","content","align","style","typography","fontSize","color","text","transforms","save","edit","deprecated","variations","init"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AAfA;AACA;AACA;;AAIA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,YADuB;AAEvBC,EAAAA,OAAO,EAAE;AACRC,IAAAA,UAAU,EAAE;AACXC,MAAAA,kBAAkB,EAAE,SADT;AAEXC,MAAAA,QAAQ,EAAE,EAFC;AAGXC,MAAAA,GAAG,EAAE;AAHM,KADJ;AAMRC,IAAAA,WAAW,EAAE,CACZ;AACCT,MAAAA,IAAI,EAAE,gBADP;AAECK,MAAAA,UAAU,EAAE;AACXK,QAAAA,OAAO,EAAE,cAAI,8BAAJ,CADE;AAEXC,QAAAA,KAAK,EAAE,QAFI;AAGXC,QAAAA,KAAK,EAAE;AACNC,UAAAA,UAAU,EAAE;AACXC,YAAAA,QAAQ,EAAE;AADC,WADN;AAINC,UAAAA,KAAK,EAAE;AACNC,YAAAA,IAAI,EAAE;AADA;AAJD;AAHI;AAFb,KADY;AANL,GAFc;AA0BvBC,EAAAA,UAAU,EAAVA,mBA1BuB;AA2BvBC,EAAAA,IAAI,EAAJA,aA3BuB;AA4BvBC,EAAAA,IAAI,EAAJA,aA5BuB;AA6BvBC,EAAAA,UAAU,EAAVA,mBA7BuB;AA8BvBC,EAAAA,UAAU,EAAVA;AA9BuB,CAAjB;;;AAiCA,MAAMC,IAAI,GAAG,MAAM,wBAAW;AAAEtB,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAX,CAAnB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { cover as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tcustomOverlayColor: '#065174',\n\t\t\tdimRatio: 40,\n\t\t\turl: 'https://s.w.org/images/core/5.3/Windbuchencom.jpg',\n\t\t},\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcontent: __( '<strong>Snow Patrol</strong>' ),\n\t\t\t\t\talign: 'center',\n\t\t\t\t\tstyle: {\n\t\t\t\t\t\ttypography: {\n\t\t\t\t\t\t\tfontSize: 48,\n\t\t\t\t\t\t},\n\t\t\t\t\t\tcolor: {\n\t\t\t\t\t\t\ttext: 'white',\n\t\t\t\t\t\t},\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\ttransforms,\n\tsave,\n\tedit,\n\tdeprecated,\n\tvariations,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = void 0;
|
|
7
|
+
|
|
8
|
+
var _i18n = require("@wordpress/i18n");
|
|
9
|
+
|
|
10
|
+
var _icons = require("@wordpress/icons");
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* WordPress dependencies
|
|
14
|
+
*/
|
|
15
|
+
const variations = [{
|
|
16
|
+
name: 'cover',
|
|
17
|
+
title: (0, _i18n.__)('Cover'),
|
|
18
|
+
description: (0, _i18n.__)('Add an image or video with a text overlay — great for headers.'),
|
|
19
|
+
attributes: {
|
|
20
|
+
layout: {
|
|
21
|
+
type: 'constrained'
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
isDefault: true,
|
|
25
|
+
icon: _icons.cover
|
|
26
|
+
}];
|
|
27
|
+
var _default = variations;
|
|
28
|
+
exports.default = _default;
|
|
29
|
+
//# sourceMappingURL=variations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/cover/variations.js"],"names":["variations","name","title","description","attributes","layout","type","isDefault","icon","cover"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,MAAMA,UAAU,GAAG,CAClB;AACCC,EAAAA,IAAI,EAAE,OADP;AAECC,EAAAA,KAAK,EAAE,cAAI,OAAJ,CAFR;AAGCC,EAAAA,WAAW,EAAE,cACZ,gEADY,CAHd;AAMCC,EAAAA,UAAU,EAAE;AAAEC,IAAAA,MAAM,EAAE;AAAEC,MAAAA,IAAI,EAAE;AAAR;AAAV,GANb;AAOCC,EAAAA,SAAS,EAAE,IAPZ;AAQCC,EAAAA,IAAI,EAAEC;AARP,CADkB,CAAnB;eAaeT,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { cover } from '@wordpress/icons';\n\nconst variations = [\n\t{\n\t\tname: 'cover',\n\t\ttitle: __( 'Cover' ),\n\t\tdescription: __(\n\t\t\t'Add an image or video with a text overlay — great for headers.'\n\t\t),\n\t\tattributes: { layout: { type: 'constrained' } },\n\t\tisDefault: true,\n\t\ticon: cover,\n\t},\n];\n\nexport default variations;\n"]}
|
package/build/embed/edit.js
CHANGED
|
@@ -113,14 +113,10 @@ const EmbedEdit = props => {
|
|
|
113
113
|
/**
|
|
114
114
|
* Returns the attributes derived from the preview, merged with the current attributes.
|
|
115
115
|
*
|
|
116
|
-
* @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.
|
|
117
116
|
* @return {Object} Merged attributes.
|
|
118
117
|
*/
|
|
119
118
|
|
|
120
|
-
const getMergedAttributes =
|
|
121
|
-
let ignorePreviousClassName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
122
|
-
return (0, _util.getMergedAttributesWithPreview)(attributes, preview, title, responsive, ignorePreviousClassName);
|
|
123
|
-
};
|
|
119
|
+
const getMergedAttributes = () => (0, _util.getMergedAttributesWithPreview)(attributes, preview, title, responsive);
|
|
124
120
|
|
|
125
121
|
const toggleResponsive = () => {
|
|
126
122
|
const {
|
|
@@ -150,18 +146,17 @@ const EmbedEdit = props => {
|
|
|
150
146
|
setAttributes({
|
|
151
147
|
url: newURL
|
|
152
148
|
});
|
|
153
|
-
}, [preview === null || preview === void 0 ? void 0 : preview.html, attributesUrl]); // Handle incoming preview.
|
|
149
|
+
}, [preview === null || preview === void 0 ? void 0 : preview.html, attributesUrl, cannotEmbed, fetching]); // Handle incoming preview.
|
|
154
150
|
|
|
155
151
|
(0, _element.useEffect)(() => {
|
|
156
152
|
if (preview && !isEditingURL) {
|
|
157
|
-
// When obtaining an incoming preview,
|
|
158
|
-
//
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
setAttributes(getMergedAttributes(true));
|
|
153
|
+
// When obtaining an incoming preview,
|
|
154
|
+
// we set the attributes derived from the preview data.
|
|
155
|
+
const mergedAttributes = getMergedAttributes();
|
|
156
|
+
setAttributes(mergedAttributes);
|
|
162
157
|
|
|
163
158
|
if (onReplace) {
|
|
164
|
-
const upgradedBlock = (0, _util.createUpgradedEmbedBlock)(props,
|
|
159
|
+
const upgradedBlock = (0, _util.createUpgradedEmbedBlock)(props, mergedAttributes);
|
|
165
160
|
|
|
166
161
|
if (upgradedBlock) {
|
|
167
162
|
onReplace(upgradedBlock);
|
|
@@ -188,11 +183,15 @@ const EmbedEdit = props => {
|
|
|
188
183
|
onSubmit: event => {
|
|
189
184
|
if (event) {
|
|
190
185
|
event.preventDefault();
|
|
191
|
-
}
|
|
186
|
+
} // If the embed URL was changed, we need to reset the aspect ratio class.
|
|
187
|
+
// To do this we have to remove the existing ratio class so it can be recalculated.
|
|
188
|
+
|
|
192
189
|
|
|
190
|
+
const blockClass = (0, _util.removeAspectRatioClasses)(attributes.className);
|
|
193
191
|
setIsEditingURL(false);
|
|
194
192
|
setAttributes({
|
|
195
|
-
url
|
|
193
|
+
url,
|
|
194
|
+
className: blockClass
|
|
196
195
|
});
|
|
197
196
|
},
|
|
198
197
|
value: url,
|
package/build/embed/edit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/embed/edit.js"],"names":["EmbedEdit","props","attributes","providerNameSlug","previewable","responsive","url","attributesUrl","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","defaultEmbedInfo","title","icon","embedContentIcon","setURL","isEditingURL","setIsEditingURL","invalidateResolution","coreStore","preview","fetching","themeSupportsResponsive","cannotEmbed","select","getEmbedPreview","isPreviewEmbedFallback","isRequestingEmbedPreview","getThemeSupports","embedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","data","status","validPreview","getMergedAttributes","ignorePreviousClassName","toggleResponsive","allowResponsive","className","newAllowResponsive","newURL","replace","upgradedBlock","blockProps","label","showEmbedP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,CAAlB;AAEA,SACC,qDACC,4BAAC,sBAAD;AACC,IAAA,cAAc,EAAGvB,OAAO,IAAI,CAAEG,WAD/B;AAEC,IAAA,uBAAuB,EAAGD,uBAF3B;AAGC,IAAA,uBAAuB,EAAGnB,UAH3B;AAIC,IAAA,eAAe,EAAGuC,eAJnB;AAKC,IAAA,gBAAgB,EAAGD,gBALpB;AAMC,IAAA,oBAAoB,EAAG,MAAMxB,eAAe,CAAE,IAAF;AAN7C,IADD,EASC,4BAAC,gBAAD,EAAW+B,UAAX,EACC,4BAAC,qBAAD;AACC,IAAA,OAAO,EAAG5B,OADX;AAEC,IAAA,WAAW,EAAGlB,WAFf;AAGC,IAAA,SAAS,EAAGyC,SAHb;AAIC,IAAA,GAAG,EAAGvC,GAJP;AAKC,IAAA,IAAI,EAAG6B,IALR;AAMC,IAAA,OAAO,EAAGsB,OANX;AAOC,IAAA,eAAe,EAAKD,KAAF,IACjB9C,aAAa,CAAE;AAAE+C,MAAAA,OAAO,EAAED;AAAX,KAAF,CARf;AAUC,IAAA,UAAU,EAAGhD,UAVd;AAWC,IAAA,IAAI,EAAGO,IAXR;AAYC,IAAA,KAAK,EAAGoC,KAZT;AAaC,IAAA,iBAAiB,EAAGxC;AAbrB,IADD,CATD,CADD;AA6BA,CA3ND;;eA6NeX,S","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tfallback,\n\tgetEmbedInfoByProvider,\n\tgetMergedAttributesWithPreview,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: {\n\t\t\tproviderNameSlug,\n\t\t\tpreviewable,\n\t\t\tresponsive,\n\t\t\turl: attributesUrl,\n\t\t},\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst { icon, title } =\n\t\tgetEmbedInfoByProvider( providerNameSlug ) || defaultEmbedInfo;\n\n\tconst [ url, setURL ] = useState( attributesUrl );\n\tconst [ isEditingURL, setIsEditingURL ] = useState( false );\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst { preview, fetching, themeSupportsResponsive, cannotEmbed } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEmbedPreview,\n\t\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\t\tisRequestingEmbedPreview,\n\t\t\t\t\tgetThemeSupports,\n\t\t\t\t} = select( coreStore );\n\t\t\t\tif ( ! attributesUrl ) {\n\t\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t\t}\n\n\t\t\t\tconst embedPreview = getEmbedPreview( attributesUrl );\n\t\t\t\tconst previewIsFallback =\n\t\t\t\t\tisPreviewEmbedFallback( attributesUrl );\n\n\t\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\t\tconst badEmbedProvider =\n\t\t\t\t\tembedPreview?.html === false &&\n\t\t\t\t\tembedPreview?.type === undefined;\n\t\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t\t// a valid JSON response with no HTML and `data.status` set to 404, rather\n\t\t\t\t// than generating a fallback response as other embeds do.\n\t\t\t\tconst wordpressCantEmbed = embedPreview?.data?.status === 404;\n\t\t\t\tconst validPreview =\n\t\t\t\t\t!! embedPreview &&\n\t\t\t\t\t! badEmbedProvider &&\n\t\t\t\t\t! wordpressCantEmbed;\n\t\t\t\treturn {\n\t\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\t\tfetching: isRequestingEmbedPreview( attributesUrl ),\n\t\t\t\t\tthemeSupportsResponsive:\n\t\t\t\t\t\tgetThemeSupports()[ 'responsive-embeds' ],\n\t\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ attributesUrl ]\n\t\t);\n\n\t/**\n\t * Returns the attributes derived from the preview, merged with the current attributes.\n\t *\n\t * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.\n\t * @return {Object} Merged attributes.\n\t */\n\tconst getMergedAttributes = ( ignorePreviousClassName = false ) =>\n\t\tgetMergedAttributesWithPreview(\n\t\t\tattributes,\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tresponsive,\n\t\t\tignorePreviousClassName\n\t\t);\n\n\tconst toggleResponsive = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\tconst { html } = preview;\n\t\tconst newAllowResponsive = ! allowResponsive;\n\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! preview?.html || ! cannotEmbed || fetching ) {\n\t\t\treturn;\n\t\t}\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = attributesUrl.replace( /\\/$/, '' );\n\t\tsetURL( newURL );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [ preview?.html, attributesUrl ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// When obtaining an incoming preview, we set the attributes derived from\n\t\t\t// the preview data. In this case when getting the merged attributes,\n\t\t\t// we ignore the previous classname because it might not match the expected\n\t\t\t// classes by the new preview.\n\t\t\tsetAttributes( getMergedAttributes( true ) );\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tgetMergedAttributes()\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// translators: %s: type of embed e.g: \"YouTube\", \"Twitter\", etc. \"Embed\" is used when no specific type exists\n\tconst label = sprintf( __( '%s URL' ), title );\n\n\t// No preview, or we can't embed the current URL, or we've clicked the edit button.\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed || isEditingURL;\n\n\tif ( showEmbedPlaceholder ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\t\tif ( event ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\tsetIsEditingURL( false );\n\t\t\t\t\t\tsetAttributes( { url } );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ url }\n\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\tonChange={ ( event ) => setURL( event.target.value ) }\n\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [ url ] );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\tcaption,\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = classnames( classFromPreview, props.className );\n\n\treturn (\n\t\t<>\n\t\t\t<EmbedControls\n\t\t\t\tshowEditButton={ preview && ! cannotEmbed }\n\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\tswitchBackToURLInput={ () => setIsEditingURL( true ) }\n\t\t\t/>\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedPreview\n\t\t\t\t\tpreview={ preview }\n\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\tclassName={ className }\n\t\t\t\t\turl={ url }\n\t\t\t\t\ttype={ type }\n\t\t\t\t\tcaption={ caption }\n\t\t\t\t\tonCaptionChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t}\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</>\n\t);\n};\n\nexport default EmbedEdit;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/embed/edit.js"],"names":["EmbedEdit","props","attributes","providerNameSlug","previewable","responsive","url","attributesUrl","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","defaultEmbedInfo","title","icon","embedContentIcon","setURL","isEditingURL","setIsEditingURL","invalidateResolution","coreStore","preview","fetching","themeSupportsResponsive","cannotEmbed","select","getEmbedPreview","isPreviewEmbedFallback","isRequestingEmbedPreview","getThemeSupports","embedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","data","status","validPreview","getMergedAttributes","toggleResponsive","allowResponsive","className","newAllowResponsive","newURL","replace","mergedAttributes","upgradedBlock","blockProps","label","showEmbedPlaceholder","event","preventDefault","blockClass","target","value","caption","classFromPreview"],"mappings":";;;;;;;;;AA0BA;;AAvBA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AAEA;;AACA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAeA;AACA;AACA;;AAGA;AACA;AACA;AAQA,MAAMA,SAAS,GAAKC,KAAF,IAAa;AAC9B,QAAM;AACLC,IAAAA,UAAU,EAAE;AACXC,MAAAA,gBADW;AAEXC,MAAAA,WAFW;AAGXC,MAAAA,UAHW;AAIXC,MAAAA,GAAG,EAAEC;AAJM,KADP;AAOLL,IAAAA,UAPK;AAQLM,IAAAA,UARK;AASLC,IAAAA,SATK;AAULC,IAAAA,aAVK;AAWLC,IAAAA,iBAXK;AAYLC,IAAAA;AAZK,MAaFX,KAbJ;AAeA,QAAMY,gBAAgB,GAAG;AACxBC,IAAAA,KAAK,EAAE,cAAI,OAAJ,EAAa,aAAb,CADiB;AAExBC,IAAAA,IAAI,EAAEC;AAFkB,GAAzB;AAIA,QAAM;AAAED,IAAAA,IAAF;AAAQD,IAAAA;AAAR,MACL,kCAAwBX,gBAAxB,KAA8CU,gBAD/C;AAGA,QAAM,CAAEP,GAAF,EAAOW,MAAP,IAAkB,uBAAUV,aAAV,CAAxB;AACA,QAAM,CAAEW,YAAF,EAAgBC,eAAhB,IAAoC,uBAAU,KAAV,CAA1C;AACA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AAbrB,IADD,CATD,CADD;AA6BA,CA9ND;;eAgOeX,S","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tremoveAspectRatioClasses,\n\tfallback,\n\tgetEmbedInfoByProvider,\n\tgetMergedAttributesWithPreview,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { __, _x, sprintf } from '@wordpress/i18n';\nimport { useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: {\n\t\t\tproviderNameSlug,\n\t\t\tpreviewable,\n\t\t\tresponsive,\n\t\t\turl: attributesUrl,\n\t\t},\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst { icon, title } =\n\t\tgetEmbedInfoByProvider( providerNameSlug ) || defaultEmbedInfo;\n\n\tconst [ url, setURL ] = useState( attributesUrl );\n\tconst [ isEditingURL, setIsEditingURL ] = useState( false );\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst { preview, fetching, themeSupportsResponsive, cannotEmbed } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEmbedPreview,\n\t\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\t\tisRequestingEmbedPreview,\n\t\t\t\t\tgetThemeSupports,\n\t\t\t\t} = select( coreStore );\n\t\t\t\tif ( ! attributesUrl ) {\n\t\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t\t}\n\n\t\t\t\tconst embedPreview = getEmbedPreview( attributesUrl );\n\t\t\t\tconst previewIsFallback =\n\t\t\t\t\tisPreviewEmbedFallback( attributesUrl );\n\n\t\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\t\tconst badEmbedProvider =\n\t\t\t\t\tembedPreview?.html === false &&\n\t\t\t\t\tembedPreview?.type === undefined;\n\t\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t\t// a valid JSON response with no HTML and `data.status` set to 404, rather\n\t\t\t\t// than generating a fallback response as other embeds do.\n\t\t\t\tconst wordpressCantEmbed = embedPreview?.data?.status === 404;\n\t\t\t\tconst validPreview =\n\t\t\t\t\t!! embedPreview &&\n\t\t\t\t\t! badEmbedProvider &&\n\t\t\t\t\t! wordpressCantEmbed;\n\t\t\t\treturn {\n\t\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\t\tfetching: isRequestingEmbedPreview( attributesUrl ),\n\t\t\t\t\tthemeSupportsResponsive:\n\t\t\t\t\t\tgetThemeSupports()[ 'responsive-embeds' ],\n\t\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ attributesUrl ]\n\t\t);\n\n\t/**\n\t * Returns the attributes derived from the preview, merged with the current attributes.\n\t *\n\t * @return {Object} Merged attributes.\n\t */\n\tconst getMergedAttributes = () =>\n\t\tgetMergedAttributesWithPreview(\n\t\t\tattributes,\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tresponsive\n\t\t);\n\n\tconst toggleResponsive = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\tconst { html } = preview;\n\t\tconst newAllowResponsive = ! allowResponsive;\n\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! preview?.html || ! cannotEmbed || fetching ) {\n\t\t\treturn;\n\t\t}\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = attributesUrl.replace( /\\/$/, '' );\n\t\tsetURL( newURL );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [ preview?.html, attributesUrl, cannotEmbed, fetching ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// When obtaining an incoming preview,\n\t\t\t// we set the attributes derived from the preview data.\n\t\t\tconst mergedAttributes = getMergedAttributes();\n\t\t\tsetAttributes( mergedAttributes );\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tmergedAttributes\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// translators: %s: type of embed e.g: \"YouTube\", \"Twitter\", etc. \"Embed\" is used when no specific type exists\n\tconst label = sprintf( __( '%s URL' ), title );\n\n\t// No preview, or we can't embed the current URL, or we've clicked the edit button.\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed || isEditingURL;\n\n\tif ( showEmbedPlaceholder ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\tonSubmit={ ( event ) => {\n\t\t\t\t\t\tif ( event ) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\t// If the embed URL was changed, we need to reset the aspect ratio class.\n\t\t\t\t\t\t// To do this we have to remove the existing ratio class so it can be recalculated.\n\t\t\t\t\t\tconst blockClass = removeAspectRatioClasses(\n\t\t\t\t\t\t\tattributes.className\n\t\t\t\t\t\t);\n\n\t\t\t\t\t\tsetIsEditingURL( false );\n\t\t\t\t\t\tsetAttributes( { url, className: blockClass } );\n\t\t\t\t\t} }\n\t\t\t\t\tvalue={ url }\n\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\tonChange={ ( event ) => setURL( event.target.value ) }\n\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [ url ] );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\tcaption,\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = classnames( classFromPreview, props.className );\n\n\treturn (\n\t\t<>\n\t\t\t<EmbedControls\n\t\t\t\tshowEditButton={ preview && ! cannotEmbed }\n\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\tswitchBackToURLInput={ () => setIsEditingURL( true ) }\n\t\t\t/>\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedPreview\n\t\t\t\t\tpreview={ preview }\n\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\tclassName={ className }\n\t\t\t\t\turl={ url }\n\t\t\t\t\ttype={ type }\n\t\t\t\t\tcaption={ caption }\n\t\t\t\t\tonCaptionChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t}\n\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\ticon={ icon }\n\t\t\t\t\tlabel={ label }\n\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t</>\n\t);\n};\n\nexport default EmbedEdit;\n"]}
|
|
@@ -130,14 +130,10 @@ const EmbedEdit = props => {
|
|
|
130
130
|
/**
|
|
131
131
|
* Returns the attributes derived from the preview, merged with the current attributes.
|
|
132
132
|
*
|
|
133
|
-
* @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.
|
|
134
133
|
* @return {Object} Merged attributes.
|
|
135
134
|
*/
|
|
136
135
|
|
|
137
|
-
const getMergedAttributes =
|
|
138
|
-
let ignorePreviousClassName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
|
|
139
|
-
return (0, _util.getMergedAttributesWithPreview)(attributes, preview, title, responsive, ignorePreviousClassName);
|
|
140
|
-
};
|
|
136
|
+
const getMergedAttributes = () => (0, _util.getMergedAttributesWithPreview)(attributes, preview, title, responsive);
|
|
141
137
|
|
|
142
138
|
const toggleResponsive = () => {
|
|
143
139
|
const {
|
|
@@ -166,18 +162,17 @@ const EmbedEdit = props => {
|
|
|
166
162
|
setAttributes({
|
|
167
163
|
url: newURL
|
|
168
164
|
});
|
|
169
|
-
}, [preview === null || preview === void 0 ? void 0 : preview.html, url]); // Handle incoming preview.
|
|
165
|
+
}, [preview === null || preview === void 0 ? void 0 : preview.html, url, cannotEmbed, fetching]); // Handle incoming preview.
|
|
170
166
|
|
|
171
167
|
(0, _element.useEffect)(() => {
|
|
172
168
|
if (preview && !isEditingURL) {
|
|
173
|
-
// When obtaining an incoming preview,
|
|
174
|
-
//
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
setAttributes(getMergedAttributes(true));
|
|
169
|
+
// When obtaining an incoming preview,
|
|
170
|
+
// we set the attributes derived from the preview data.
|
|
171
|
+
const mergedAttributes = getMergedAttributes();
|
|
172
|
+
setAttributes(mergedAttributes);
|
|
178
173
|
|
|
179
174
|
if (onReplace) {
|
|
180
|
-
const upgradedBlock = (0, _util.createUpgradedEmbedBlock)(props,
|
|
175
|
+
const upgradedBlock = (0, _util.createUpgradedEmbedBlock)(props, mergedAttributes);
|
|
181
176
|
|
|
182
177
|
if (upgradedBlock) {
|
|
183
178
|
onReplace(upgradedBlock);
|
|
@@ -187,14 +182,23 @@ const EmbedEdit = props => {
|
|
|
187
182
|
}, [preview, isEditingURL]);
|
|
188
183
|
(0, _element.useEffect)(() => setShowEmbedBottomSheet(isEditingURL), [isEditingURL]);
|
|
189
184
|
const onEditURL = (0, _element.useCallback)(value => {
|
|
190
|
-
//
|
|
185
|
+
// If the embed URL was changed, we need to reset the aspect ratio class.
|
|
186
|
+
// To do this we have to remove the existing ratio class so it can be recalculated.
|
|
187
|
+
if (attributes.url !== value) {
|
|
188
|
+
const blockClass = (0, _util.removeAspectRatioClasses)(attributes.className);
|
|
189
|
+
setAttributes({
|
|
190
|
+
className: blockClass
|
|
191
|
+
});
|
|
192
|
+
} // The order of the following calls is important, we need to update the URL attribute before changing `isEditingURL`,
|
|
191
193
|
// otherwise the side-effect that potentially replaces the block when updating the local state won't use the new URL
|
|
192
194
|
// for creating the new block.
|
|
195
|
+
|
|
196
|
+
|
|
193
197
|
setAttributes({
|
|
194
198
|
url: value
|
|
195
199
|
});
|
|
196
200
|
setIsEditingURL(false);
|
|
197
|
-
}, []);
|
|
201
|
+
}, [attributes, setAttributes]);
|
|
198
202
|
const blockProps = (0, _blockEditor.useBlockProps)();
|
|
199
203
|
|
|
200
204
|
if (fetching) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/embed/edit.native.js"],"names":["PREVIEWABLE_PROVIDERS","NOT_PREVIEWABLE_WP_EMBED_PROVIDERS","WP_EMBED_TYPE","EmbedEdit","props","attributes","align","providerNameSlug","previewable","responsive","url","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","clientId","defaultEmbedInfo","title","icon","embedContentIcon","embedInfoByProvider","wasBlockJustInserted","select","blockEditorStore","isEditingURL","setIsEditingURL","showEmbedBottomSheet","setShowEmbedBottomSheet","invalidateResolution","coreStore","preview","fetching","themeSupportsResponsive","cannotEmbed","getEmbedPreview","hasFinishedResolution","isPreviewEmbedFallback","getThemeSupports","embedPreview","hasResolvedEmbedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","code","validPreview","getMergedAttributes","ignorePreviousClassName","toggleResponsive","allowResponsive","className","newAllowResponsive","newURL","replace","upgradedBlock","onEditURL","value","blockProps","showEmbedPlaceholder","classFromPreview","isProviderPreviewable","includes","linkLabel","event"],"mappings":";;;;;;;;;AA0BA;;AAvBA;;AAOA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AAEA;;AACA;;AAIA;;AACA;;AAjCA;AACA;AACA;;AAeA;AACA;AACA;;AAGA;AACA;AACA;AAWA;AACA;AACA,MAAMA,qBAAqB,GAAG,CAAE,SAAF,EAAa,SAAb,EAAwB,WAAxB,EAAqC,OAArC,CAA9B,C,CACA;AACA;;AACA,MAAMC,kCAAkC,GAAG,CAAE,WAAF,CAA3C;AAEA,MAAMC,aAAa,GAAG,UAAtB;;AAEA,MAAMC,SAAS,GAAKC,KAAF,IAAa;AAC9B,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,KAAF;AAASC,MAAAA,gBAAT;AAA2BC,MAAAA,WAA3B;AAAwCC,M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uB,CAAE,KAAF,CANxC;AAOC,IAAA,QAAQ,EAAG8B,SAPZ;AAQC,IAAA,eAAe;AARhB,IAxDD,CADD;AAqEA,CAnQD;;eAqQevD,S","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tfallback,\n\tgetEmbedInfoByProvider,\n\tgetMergedAttributesWithPreview,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\nimport EmbedLinkSettings from './embed-link-settings';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { useCallback, useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\n\n// The inline preview feature will be released progressible, for this reason\n// the embed will only be considered previewable for the following providers list.\nconst PREVIEWABLE_PROVIDERS = [ 'youtube', 'twitter', 'instagram', 'vimeo' ];\n// Some providers are rendering the inline preview as a WordPress embed and\n// are not supported yet, so we need to disallow them with a fixed providers list.\nconst NOT_PREVIEWABLE_WP_EMBED_PROVIDERS = [ 'pinterest' ];\n\nconst WP_EMBED_TYPE = 'wp-embed';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: { align, providerNameSlug, previewable, responsive, url },\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t\tclientId,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst embedInfoByProvider = getEmbedInfoByProvider( providerNameSlug );\n\tconst { icon, title } = embedInfoByProvider || defaultEmbedInfo;\n\n\tconst { wasBlockJustInserted } = useSelect(\n\t\t( select ) => ( {\n\t\t\twasBlockJustInserted: select(\n\t\t\t\tblockEditorStore\n\t\t\t).wasBlockJustInserted( clientId, 'inserter_menu' ),\n\t\t} ),\n\t\t[ clientId ]\n\t);\n\tconst [ isEditingURL, setIsEditingURL ] = useState(\n\t\tisSelected && wasBlockJustInserted && ! url\n\t);\n\tconst [ showEmbedBottomSheet, setShowEmbedBottomSheet ] =\n\t\tuseState( isEditingURL );\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst { preview, fetching, themeSupportsResponsive, cannotEmbed } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEmbedPreview,\n\t\t\t\t\thasFinishedResolution,\n\t\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\t\tgetThemeSupports,\n\t\t\t\t} = select( coreStore );\n\t\t\t\tif ( ! url ) {\n\t\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t\t}\n\n\t\t\t\tconst embedPreview = getEmbedPreview( url );\n\t\t\t\tconst hasResolvedEmbedPreview = hasFinishedResolution(\n\t\t\t\t\t'getEmbedPreview',\n\t\t\t\t\t[ url ]\n\t\t\t\t);\n\t\t\t\tconst previewIsFallback = isPreviewEmbedFallback( url );\n\n\t\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\t\tconst badEmbedProvider =\n\t\t\t\t\tembedPreview?.html === false &&\n\t\t\t\t\tembedPreview?.type === undefined;\n\t\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t\t// a valid JSON response with no HTML and `code` set to 404, rather\n\t\t\t\t// than generating a fallback response as other embeds do.\n\t\t\t\tconst wordpressCantEmbed = embedPreview?.code === '404';\n\t\t\t\tconst validPreview =\n\t\t\t\t\t!! embedPreview &&\n\t\t\t\t\t! badEmbedProvider &&\n\t\t\t\t\t! wordpressCantEmbed;\n\n\t\t\t\treturn {\n\t\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\t\tfetching: ! hasResolvedEmbedPreview,\n\t\t\t\t\tthemeSupportsResponsive:\n\t\t\t\t\t\tgetThemeSupports()[ 'responsive-embeds' ],\n\t\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ url ]\n\t\t);\n\n\t/**\n\t * Returns the attributes derived from the preview, merged with the current attributes.\n\t *\n\t * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.\n\t * @return {Object} Merged attributes.\n\t */\n\tconst getMergedAttributes = ( ignorePreviousClassName = false ) =>\n\t\tgetMergedAttributesWithPreview(\n\t\t\tattributes,\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tresponsive,\n\t\t\tignorePreviousClassName\n\t\t);\n\n\tconst toggleResponsive = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\tconst { html } = preview;\n\t\tconst newAllowResponsive = ! allowResponsive;\n\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! preview?.html || ! cannotEmbed || fetching ) {\n\t\t\treturn;\n\t\t}\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = url.replace( /\\/$/, '' );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [ preview?.html, url ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// When obtaining an incoming preview, we set the attributes derived from\n\t\t\t// the preview data. In this case when getting the merged attributes,\n\t\t\t// we ignore the previous classname because it might not match the expected\n\t\t\t// classes by the new preview.\n\t\t\tsetAttributes( getMergedAttributes( true ) );\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tgetMergedAttributes()\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tuseEffect(\n\t\t() => setShowEmbedBottomSheet( isEditingURL ),\n\t\t[ isEditingURL ]\n\t);\n\n\tconst onEditURL = useCallback( ( value ) => {\n\t\t// The order of the following calls is important, we need to update the URL attribute before changing `isEditingURL`,\n\t\t// otherwise the side-effect that potentially replaces the block when updating the local state won't use the new URL\n\t\t// for creating the new block.\n\t\tsetAttributes( { url: value } );\n\t\tsetIsEditingURL( false );\n\t}, [] );\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed;\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = classnames( classFromPreview, props.className );\n\n\tconst isProviderPreviewable =\n\t\tPREVIEWABLE_PROVIDERS.includes( providerNameSlug ) ||\n\t\t// For WordPress embeds, we enable the inline preview for all its providers\n\t\t// except the ones that are not supported yet.\n\t\t( WP_EMBED_TYPE === type &&\n\t\t\t! NOT_PREVIEWABLE_WP_EMBED_PROVIDERS.includes( providerNameSlug ) );\n\n\tconst linkLabel = WP_EMBED_TYPE === type ? 'WordPress' : title;\n\n\treturn (\n\t\t<>\n\t\t\t{ showEmbedPlaceholder ? (\n\t\t\t\t<>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonPress={ ( event ) => {\n\t\t\t\t\t\t\t\tonFocus( event );\n\t\t\t\t\t\t\t\tsetIsEditingURL( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [\n\t\t\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\topenEmbedLinkSettings={ () =>\n\t\t\t\t\t\t\t\tsetShowEmbedBottomSheet( true )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<EmbedControls\n\t\t\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\tlinkLabel={ linkLabel }\n\t\t\t\t\t\tonEditURL={ onEditURL }\n\t\t\t\t\t/>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPreview\n\t\t\t\t\t\t\talign={ align }\n\t\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tpreview={ preview }\n\t\t\t\t\t\t\tisProviderPreviewable={ isProviderPreviewable }\n\t\t\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\tisDefaultEmbedInfo={ ! embedInfoByProvider }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<EmbedLinkSettings\n\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\tautoFocus\n\t\t\t\tvalue={ url }\n\t\t\t\tlabel={ linkLabel }\n\t\t\t\tisVisible={ showEmbedBottomSheet }\n\t\t\t\tonClose={ () => setShowEmbedBottomSheet( false ) }\n\t\t\t\tonSubmit={ onEditURL }\n\t\t\t\twithBottomSheet\n\t\t\t/>\n\t\t</>\n\t);\n};\n\nexport default EmbedEdit;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/embed/edit.native.js"],"names":["PREVIEWABLE_PROVIDERS","NOT_PREVIEWABLE_WP_EMBED_PROVIDERS","WP_EMBED_TYPE","EmbedEdit","props","attributes","align","providerNameSlug","previewable","responsive","url","isSelected","onReplace","setAttributes","insertBlocksAfter","onFocus","clientId","defaultEmbedInfo","title","icon","embedContentIcon","embedInfoByProvider","wasBlockJustInserted","select","blockEditorStore","isEditingURL","setIsEditingURL","showEmbedBottomSheet","setShowEmbedBottomSheet","invalidateResolution","coreStore","preview","fetching","themeSupportsResponsive","cannotEmbed","getEmbedPreview","hasFinishedResolution","isPreviewEmbedFallback","getThemeSupports","embedPreview","hasResolvedEmbedPreview","previewIsFallback","badEmbedProvider","html","type","undefined","wordpressCantEmbed","code","validPreview","getMergedAttributes","toggleResponsive","allowResponsive","className","newAllowResponsive","newURL","replace","mergedAttributes","upgradedBlock","onEditURL","value","blockClass","blockProps","showEmbedPlaceholder","classFromPreview","isProviderPreviewable","includes","linkLabel","event"],"mappings":";;;;;;;;;AA2BA;;AAxBA;;AAQA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAKA;;AAEA;;AACA;;AAIA;;AACA;;AAlCA;AACA;AACA;;AAgBA;AACA;AACA;;AAGA;AACA;AACA;AAWA;AACA;AACA,MAAMA,qBAAqB,GAAG,CAAE,SAAF,EAAa,SAAb,EAAwB,WAAxB,EAAqC,OAArC,CAA9B,C,CACA;AACA;;AACA,MAAMC,kCAAkC,GAAG,CAAE,WAAF,CAA3C;AAEA,MAAMC,aAAa,GAAG,UAAtB;;AAEA,MAAMC,SAAS,GAAKC,KAAF,IAAa;AAC9B,QAAM;AACLC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,KAAF;AAASC,MAAAA,gBAAT;AAA2BC,MAAAA,WAA3B;AAAwCC,MAAAA,UAAxC;AAAoDC,MAAAA;AAApD,KADP;AAELL,IAAAA,UAFK;AAGLM,IAAAA,UAHK;AAILC,IAAAA,SAJK;AAKLC,IAAAA,aALK;AAMLC,IAAAA,iBANK;AAOLC,IAAAA,OAPK;AAQLC,IAAAA;AARK,MASFZ,KATJ;AAWA,QAAMa,gBAAgB,GAAG;AACxBC,IAAAA,KAAK,EAAE,cAAI,OAAJ,EAAa,aAAb,CADiB;AAExBC,IAAAA,IAAI,EAAEC;AAFkB,GAAzB;AAIA,QAAMC,mBAAmB,GAAG,kCAAwBd,gBAAxB,CAA5B;AACA,QAAM;AAAEY,IAAAA,IAAF;AAAQD,IAAAA;AAAR,MAAkBG,mBAAmB,IAAIJ,gBAA/C;AAEA,QAAM;AAAEK,IAAAA;AAAF,MAA2B,qBAC9BC,MAAF,KAAgB;AACfD,IAAAA,oBAAoB,EAAEC,MAAM,CAC3BC,kBAD2B,CAAN,CAEpB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AAG0C,eAHnB;AAIC,IAAA,gBAAgB,EAAGD,gBAJpB;AAKC,IAAA,GAAG,EAAGxC,GALP;AAMC,IAAA,SAAS,EAAGwD,SANb;AAOC,IAAA,SAAS,EAAGR;AAPb,IADD,EAUC,4BAAC,gBAAD,EAAWG,UAAX,EACC,4BAAC,qBAAD;AACC,IAAA,KAAK,EAAGvD,KADT;AAEC,IAAA,SAAS,EAAG8C,SAFb;AAGC,IAAA,QAAQ,EAAGpC,QAHZ;AAIC,IAAA,IAAI,EAAGG,IAJR;AAKC,IAAA,iBAAiB,EAAGL,iBALrB;AAMC,IAAA,UAAU,EAAGH,UANd;AAOC,IAAA,KAAK,EAAGO,KAPT;AAQC,IAAA,OAAO,EAAGH,OARX;AASC,IAAA,OAAO,EAAGgB,OATX;AAUC,IAAA,qBAAqB,EAAGiC,qBAVzB;AAWC,IAAA,WAAW,EAAGxD,WAXf;AAYC,IAAA,IAAI,EAAGoC,IAZR;AAaC,IAAA,GAAG,EAAGlC,GAbP;AAcC,IAAA,kBAAkB,EAAG,CAAEW;AAdxB,IADD,CAVD,CA1BF,EAwDC,4BAAC,0BAAD,CACC;AADD;AAEC,IAAA,SAAS,MAFV;AAGC,IAAA,KAAK,EAAGX,GAHT;AAIC,IAAA,KAAK,EAAGwD,SAJT;AAKC,IAAA,SAAS,EAAGvC,oBALb;AAMC,IAAA,OAAO,EAAG,MAAMC,uBAAuB,CAAE,KAAF,CANxC;AAOC,IAAA,QAAQ,EAAG8B,SAPZ;AAQC,IAAA,eAAe;AARhB,IAxDD,CADD;AAqEA,CA5QD;;eA8QevD,S","sourcesContent":["/**\n * Internal dependencies\n */\nimport {\n\tcreateUpgradedEmbedBlock,\n\tgetClassNames,\n\tremoveAspectRatioClasses,\n\tfallback,\n\tgetEmbedInfoByProvider,\n\tgetMergedAttributesWithPreview,\n} from './util';\nimport EmbedControls from './embed-controls';\nimport { embedContentIcon } from './icons';\nimport EmbedLoading from './embed-loading';\nimport EmbedPlaceholder from './embed-placeholder';\nimport EmbedPreview from './embed-preview';\nimport EmbedLinkSettings from './embed-link-settings';\n\n/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { _x } from '@wordpress/i18n';\nimport { useCallback, useState, useEffect } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { View } from '@wordpress/primitives';\n\n// The inline preview feature will be released progressible, for this reason\n// the embed will only be considered previewable for the following providers list.\nconst PREVIEWABLE_PROVIDERS = [ 'youtube', 'twitter', 'instagram', 'vimeo' ];\n// Some providers are rendering the inline preview as a WordPress embed and\n// are not supported yet, so we need to disallow them with a fixed providers list.\nconst NOT_PREVIEWABLE_WP_EMBED_PROVIDERS = [ 'pinterest' ];\n\nconst WP_EMBED_TYPE = 'wp-embed';\n\nconst EmbedEdit = ( props ) => {\n\tconst {\n\t\tattributes: { align, providerNameSlug, previewable, responsive, url },\n\t\tattributes,\n\t\tisSelected,\n\t\tonReplace,\n\t\tsetAttributes,\n\t\tinsertBlocksAfter,\n\t\tonFocus,\n\t\tclientId,\n\t} = props;\n\n\tconst defaultEmbedInfo = {\n\t\ttitle: _x( 'Embed', 'block title' ),\n\t\ticon: embedContentIcon,\n\t};\n\tconst embedInfoByProvider = getEmbedInfoByProvider( providerNameSlug );\n\tconst { icon, title } = embedInfoByProvider || defaultEmbedInfo;\n\n\tconst { wasBlockJustInserted } = useSelect(\n\t\t( select ) => ( {\n\t\t\twasBlockJustInserted: select(\n\t\t\t\tblockEditorStore\n\t\t\t).wasBlockJustInserted( clientId, 'inserter_menu' ),\n\t\t} ),\n\t\t[ clientId ]\n\t);\n\tconst [ isEditingURL, setIsEditingURL ] = useState(\n\t\tisSelected && wasBlockJustInserted && ! url\n\t);\n\tconst [ showEmbedBottomSheet, setShowEmbedBottomSheet ] =\n\t\tuseState( isEditingURL );\n\tconst { invalidateResolution } = useDispatch( coreStore );\n\n\tconst { preview, fetching, themeSupportsResponsive, cannotEmbed } =\n\t\tuseSelect(\n\t\t\t( select ) => {\n\t\t\t\tconst {\n\t\t\t\t\tgetEmbedPreview,\n\t\t\t\t\thasFinishedResolution,\n\t\t\t\t\tisPreviewEmbedFallback,\n\t\t\t\t\tgetThemeSupports,\n\t\t\t\t} = select( coreStore );\n\t\t\t\tif ( ! url ) {\n\t\t\t\t\treturn { fetching: false, cannotEmbed: false };\n\t\t\t\t}\n\n\t\t\t\tconst embedPreview = getEmbedPreview( url );\n\t\t\t\tconst hasResolvedEmbedPreview = hasFinishedResolution(\n\t\t\t\t\t'getEmbedPreview',\n\t\t\t\t\t[ url ]\n\t\t\t\t);\n\t\t\t\tconst previewIsFallback = isPreviewEmbedFallback( url );\n\n\t\t\t\t// The external oEmbed provider does not exist. We got no type info and no html.\n\t\t\t\tconst badEmbedProvider =\n\t\t\t\t\tembedPreview?.html === false &&\n\t\t\t\t\tembedPreview?.type === undefined;\n\t\t\t\t// Some WordPress URLs that can't be embedded will cause the API to return\n\t\t\t\t// a valid JSON response with no HTML and `code` set to 404, rather\n\t\t\t\t// than generating a fallback response as other embeds do.\n\t\t\t\tconst wordpressCantEmbed = embedPreview?.code === '404';\n\t\t\t\tconst validPreview =\n\t\t\t\t\t!! embedPreview &&\n\t\t\t\t\t! badEmbedProvider &&\n\t\t\t\t\t! wordpressCantEmbed;\n\n\t\t\t\treturn {\n\t\t\t\t\tpreview: validPreview ? embedPreview : undefined,\n\t\t\t\t\tfetching: ! hasResolvedEmbedPreview,\n\t\t\t\t\tthemeSupportsResponsive:\n\t\t\t\t\t\tgetThemeSupports()[ 'responsive-embeds' ],\n\t\t\t\t\tcannotEmbed: ! validPreview || previewIsFallback,\n\t\t\t\t};\n\t\t\t},\n\t\t\t[ url ]\n\t\t);\n\n\t/**\n\t * Returns the attributes derived from the preview, merged with the current attributes.\n\t *\n\t * @return {Object} Merged attributes.\n\t */\n\tconst getMergedAttributes = () =>\n\t\tgetMergedAttributesWithPreview(\n\t\t\tattributes,\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tresponsive\n\t\t);\n\n\tconst toggleResponsive = () => {\n\t\tconst { allowResponsive, className } = attributes;\n\t\tconst { html } = preview;\n\t\tconst newAllowResponsive = ! allowResponsive;\n\n\t\tsetAttributes( {\n\t\t\tallowResponsive: newAllowResponsive,\n\t\t\tclassName: getClassNames(\n\t\t\t\thtml,\n\t\t\t\tclassName,\n\t\t\t\tresponsive && newAllowResponsive\n\t\t\t),\n\t\t} );\n\t};\n\n\tuseEffect( () => {\n\t\tif ( ! preview?.html || ! cannotEmbed || fetching ) {\n\t\t\treturn;\n\t\t}\n\t\t// At this stage, we're not fetching the preview and know it can't be embedded,\n\t\t// so try removing any trailing slash, and resubmit.\n\t\tconst newURL = url.replace( /\\/$/, '' );\n\t\tsetIsEditingURL( false );\n\t\tsetAttributes( { url: newURL } );\n\t}, [ preview?.html, url, cannotEmbed, fetching ] );\n\n\t// Handle incoming preview.\n\tuseEffect( () => {\n\t\tif ( preview && ! isEditingURL ) {\n\t\t\t// When obtaining an incoming preview,\n\t\t\t// we set the attributes derived from the preview data.\n\t\t\tconst mergedAttributes = getMergedAttributes();\n\t\t\tsetAttributes( mergedAttributes );\n\n\t\t\tif ( onReplace ) {\n\t\t\t\tconst upgradedBlock = createUpgradedEmbedBlock(\n\t\t\t\t\tprops,\n\t\t\t\t\tmergedAttributes\n\t\t\t\t);\n\n\t\t\t\tif ( upgradedBlock ) {\n\t\t\t\t\tonReplace( upgradedBlock );\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}, [ preview, isEditingURL ] );\n\n\tuseEffect(\n\t\t() => setShowEmbedBottomSheet( isEditingURL ),\n\t\t[ isEditingURL ]\n\t);\n\n\tconst onEditURL = useCallback(\n\t\t( value ) => {\n\t\t\t// If the embed URL was changed, we need to reset the aspect ratio class.\n\t\t\t// To do this we have to remove the existing ratio class so it can be recalculated.\n\t\t\tif ( attributes.url !== value ) {\n\t\t\t\tconst blockClass = removeAspectRatioClasses(\n\t\t\t\t\tattributes.className\n\t\t\t\t);\n\t\t\t\tsetAttributes( { className: blockClass } );\n\t\t\t}\n\n\t\t\t// The order of the following calls is important, we need to update the URL attribute before changing `isEditingURL`,\n\t\t\t// otherwise the side-effect that potentially replaces the block when updating the local state won't use the new URL\n\t\t\t// for creating the new block.\n\t\t\tsetAttributes( { url: value } );\n\t\t\tsetIsEditingURL( false );\n\t\t},\n\t\t[ attributes, setAttributes ]\n\t);\n\n\tconst blockProps = useBlockProps();\n\n\tif ( fetching ) {\n\t\treturn (\n\t\t\t<View { ...blockProps }>\n\t\t\t\t<EmbedLoading />\n\t\t\t</View>\n\t\t);\n\t}\n\n\tconst showEmbedPlaceholder = ! preview || cannotEmbed;\n\n\t// Even though we set attributes that get derived from the preview,\n\t// we don't access them directly because for the initial render,\n\t// the `setAttributes` call will not have taken effect. If we're\n\t// rendering responsive content, setting the responsive classes\n\t// after the preview has been rendered can result in unwanted\n\t// clipping or scrollbars. The `getAttributesFromPreview` function\n\t// that `getMergedAttributes` uses is memoized so that we're not\n\t// calculating them on every render.\n\tconst {\n\t\ttype,\n\t\tallowResponsive,\n\t\tclassName: classFromPreview,\n\t} = getMergedAttributes();\n\tconst className = classnames( classFromPreview, props.className );\n\n\tconst isProviderPreviewable =\n\t\tPREVIEWABLE_PROVIDERS.includes( providerNameSlug ) ||\n\t\t// For WordPress embeds, we enable the inline preview for all its providers\n\t\t// except the ones that are not supported yet.\n\t\t( WP_EMBED_TYPE === type &&\n\t\t\t! NOT_PREVIEWABLE_WP_EMBED_PROVIDERS.includes( providerNameSlug ) );\n\n\tconst linkLabel = WP_EMBED_TYPE === type ? 'WordPress' : title;\n\n\treturn (\n\t\t<>\n\t\t\t{ showEmbedPlaceholder ? (\n\t\t\t\t<>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPlaceholder\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonPress={ ( event ) => {\n\t\t\t\t\t\t\t\tonFocus( event );\n\t\t\t\t\t\t\t\tsetIsEditingURL( true );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tcannotEmbed={ cannotEmbed }\n\t\t\t\t\t\t\tfallback={ () => fallback( url, onReplace ) }\n\t\t\t\t\t\t\ttryAgain={ () => {\n\t\t\t\t\t\t\t\tinvalidateResolution( 'getEmbedPreview', [\n\t\t\t\t\t\t\t\t\turl,\n\t\t\t\t\t\t\t\t] );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\topenEmbedLinkSettings={ () =>\n\t\t\t\t\t\t\t\tsetShowEmbedBottomSheet( true )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) : (\n\t\t\t\t<>\n\t\t\t\t\t<EmbedControls\n\t\t\t\t\t\tthemeSupportsResponsive={ themeSupportsResponsive }\n\t\t\t\t\t\tblockSupportsResponsive={ responsive }\n\t\t\t\t\t\tallowResponsive={ allowResponsive }\n\t\t\t\t\t\ttoggleResponsive={ toggleResponsive }\n\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\tlinkLabel={ linkLabel }\n\t\t\t\t\t\tonEditURL={ onEditURL }\n\t\t\t\t\t/>\n\t\t\t\t\t<View { ...blockProps }>\n\t\t\t\t\t\t<EmbedPreview\n\t\t\t\t\t\t\talign={ align }\n\t\t\t\t\t\t\tclassName={ className }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\ticon={ icon }\n\t\t\t\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t\t\t\t\tisSelected={ isSelected }\n\t\t\t\t\t\t\tlabel={ title }\n\t\t\t\t\t\t\tonFocus={ onFocus }\n\t\t\t\t\t\t\tpreview={ preview }\n\t\t\t\t\t\t\tisProviderPreviewable={ isProviderPreviewable }\n\t\t\t\t\t\t\tpreviewable={ previewable }\n\t\t\t\t\t\t\ttype={ type }\n\t\t\t\t\t\t\turl={ url }\n\t\t\t\t\t\t\tisDefaultEmbedInfo={ ! embedInfoByProvider }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</View>\n\t\t\t\t</>\n\t\t\t) }\n\t\t\t<EmbedLinkSettings\n\t\t\t\t// eslint-disable-next-line jsx-a11y/no-autofocus\n\t\t\t\tautoFocus\n\t\t\t\tvalue={ url }\n\t\t\t\tlabel={ linkLabel }\n\t\t\t\tisVisible={ showEmbedBottomSheet }\n\t\t\t\tonClose={ () => setShowEmbedBottomSheet( false ) }\n\t\t\t\tonSubmit={ onEditURL }\n\t\t\t\twithBottomSheet\n\t\t\t/>\n\t\t</>\n\t);\n};\n\nexport default EmbedEdit;\n"]}
|
|
@@ -40,6 +40,7 @@ const EmbedControls = _ref => {
|
|
|
40
40
|
title: (0, _i18n.__)('Media settings'),
|
|
41
41
|
className: "blocks-responsive"
|
|
42
42
|
}, (0, _element.createElement)(_components.ToggleControl, {
|
|
43
|
+
__nextHasNoMarginBottom: true,
|
|
43
44
|
label: (0, _i18n.__)('Resize for smaller devices'),
|
|
44
45
|
checked: allowResponsive,
|
|
45
46
|
help: getResponsiveHelp,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/embed/embed-controls.js"],"names":["getResponsiveHelp","checked","EmbedControls","blockSupportsResponsive","showEditButton","themeSupportsResponsive","allowResponsive","toggleResponsive","switchBackToURLInput","edit"],"mappings":";;;;;;;;;AAGA;;AACA;;AAMA;;AACA;;AAXA;AACA;AACA;AAWA,SAASA,iBAAT,CAA4BC,OAA5B,EAAsC;AACrC,SAAOA,OAAO,GACX,cACA,wEADA,CADW,GAIX,cACA,2EADA,CAJH;AAOA;;AAED,MAAMC,aAAa,GAAG;AAAA,MAAE;AACvBC,IAAAA,uBADuB;AAEvBC,IAAAA,cAFuB;AAGvBC,IAAAA,uBAHuB;AAIvBC,IAAAA,eAJuB;AAKvBC,IAAAA,gBALuB;AAMvBC,IAAAA;AANuB,GAAF;AAAA,SAQrB,qDACC,4BAAC,0BAAD,QACC,4BAAC,wBAAD,QACGJ,cAAc,IACf,4BAAC,yBAAD;AACC,IAAA,SAAS,EAAC,6BADX;AAEC,IAAA,KAAK,EAAG,cAAI,UAAJ,CAFT;AAGC,IAAA,IAAI,EAAGK,WAHR;AAIC,IAAA,OAAO,EAAGD;AAJX,IAFF,CADD,CADD,EAaGH,uBAAuB,IAAIF,uBAA3B,IACD,4BAAC,8BAAD,QACC,4BAAC,qBAAD;AACC,IAAA,KAAK,EAAG,cAAI,gBAAJ,CADT;AAEC,IAAA,SAAS,EAAC;AAFX,KAIC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,4BAAJ,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/embed/embed-controls.js"],"names":["getResponsiveHelp","checked","EmbedControls","blockSupportsResponsive","showEditButton","themeSupportsResponsive","allowResponsive","toggleResponsive","switchBackToURLInput","edit"],"mappings":";;;;;;;;;AAGA;;AACA;;AAMA;;AACA;;AAXA;AACA;AACA;AAWA,SAASA,iBAAT,CAA4BC,OAA5B,EAAsC;AACrC,SAAOA,OAAO,GACX,cACA,wEADA,CADW,GAIX,cACA,2EADA,CAJH;AAOA;;AAED,MAAMC,aAAa,GAAG;AAAA,MAAE;AACvBC,IAAAA,uBADuB;AAEvBC,IAAAA,cAFuB;AAGvBC,IAAAA,uBAHuB;AAIvBC,IAAAA,eAJuB;AAKvBC,IAAAA,gBALuB;AAMvBC,IAAAA;AANuB,GAAF;AAAA,SAQrB,qDACC,4BAAC,0BAAD,QACC,4BAAC,wBAAD,QACGJ,cAAc,IACf,4BAAC,yBAAD;AACC,IAAA,SAAS,EAAC,6BADX;AAEC,IAAA,KAAK,EAAG,cAAI,UAAJ,CAFT;AAGC,IAAA,IAAI,EAAGK,WAHR;AAIC,IAAA,OAAO,EAAGD;AAJX,IAFF,CADD,CADD,EAaGH,uBAAuB,IAAIF,uBAA3B,IACD,4BAAC,8BAAD,QACC,4BAAC,qBAAD;AACC,IAAA,KAAK,EAAG,cAAI,gBAAJ,CADT;AAEC,IAAA,SAAS,EAAC;AAFX,KAIC,4BAAC,yBAAD;AACC,IAAA,uBAAuB,MADxB;AAEC,IAAA,KAAK,EAAG,cAAI,4BAAJ,CAFT;AAGC,IAAA,OAAO,EAAGG,eAHX;AAIC,IAAA,IAAI,EAAGN,iBAJR;AAKC,IAAA,QAAQ,EAAGO;AALZ,IAJD,CADD,CAdF,CARqB;AAAA,CAAtB;;eAwCeL,a","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport {\n\tToolbarButton,\n\tPanelBody,\n\tToggleControl,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { BlockControls, InspectorControls } from '@wordpress/block-editor';\nimport { edit } from '@wordpress/icons';\n\nfunction getResponsiveHelp( checked ) {\n\treturn checked\n\t\t? __(\n\t\t\t\t'This embed will preserve its aspect ratio when the browser is resized.'\n\t\t )\n\t\t: __(\n\t\t\t\t'This embed may not preserve its aspect ratio when the browser is resized.'\n\t\t );\n}\n\nconst EmbedControls = ( {\n\tblockSupportsResponsive,\n\tshowEditButton,\n\tthemeSupportsResponsive,\n\tallowResponsive,\n\ttoggleResponsive,\n\tswitchBackToURLInput,\n} ) => (\n\t<>\n\t\t<BlockControls>\n\t\t\t<ToolbarGroup>\n\t\t\t\t{ showEditButton && (\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tclassName=\"components-toolbar__control\"\n\t\t\t\t\t\tlabel={ __( 'Edit URL' ) }\n\t\t\t\t\t\ticon={ edit }\n\t\t\t\t\t\tonClick={ switchBackToURLInput }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</ToolbarGroup>\n\t\t</BlockControls>\n\t\t{ themeSupportsResponsive && blockSupportsResponsive && (\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody\n\t\t\t\t\ttitle={ __( 'Media settings' ) }\n\t\t\t\t\tclassName=\"blocks-responsive\"\n\t\t\t\t>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\tlabel={ __( 'Resize for smaller devices' ) }\n\t\t\t\t\t\tchecked={ allowResponsive }\n\t\t\t\t\t\thelp={ getResponsiveHelp }\n\t\t\t\t\t\tonChange={ toggleResponsive }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t) }\n\t</>\n);\n\nexport default EmbedControls;\n"]}
|
package/build/embed/util.js
CHANGED
|
@@ -9,7 +9,7 @@ exports.createUpgradedEmbedBlock = void 0;
|
|
|
9
9
|
exports.fallback = fallback;
|
|
10
10
|
exports.getAttributesFromPreview = exports.findMoreSuitableBlock = void 0;
|
|
11
11
|
exports.getClassNames = getClassNames;
|
|
12
|
-
exports.removeAspectRatioClasses = exports.matchesPatterns = exports.isFromWordPress = exports.getPhotoHtml = exports.getMergedAttributesWithPreview = exports.getEmbedInfoByProvider = void 0;
|
|
12
|
+
exports.removeAspectRatioClasses = exports.matchesPatterns = exports.isFromWordPress = exports.hasAspectRatioClass = exports.getPhotoHtml = exports.getMergedAttributesWithPreview = exports.getEmbedInfoByProvider = void 0;
|
|
13
13
|
|
|
14
14
|
var _element = require("@wordpress/element");
|
|
15
15
|
|
|
@@ -237,6 +237,28 @@ const createUpgradedEmbedBlock = function (props) {
|
|
|
237
237
|
...attributesFromPreview
|
|
238
238
|
});
|
|
239
239
|
};
|
|
240
|
+
/**
|
|
241
|
+
* Determine if the block already has an aspect ratio class applied.
|
|
242
|
+
*
|
|
243
|
+
* @param {string} existingClassNames Existing block classes.
|
|
244
|
+
* @return {boolean} True or false if the classnames contain an aspect ratio class.
|
|
245
|
+
*/
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
exports.createUpgradedEmbedBlock = createUpgradedEmbedBlock;
|
|
249
|
+
|
|
250
|
+
const hasAspectRatioClass = existingClassNames => {
|
|
251
|
+
if (!existingClassNames) {
|
|
252
|
+
return false;
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
return _constants.ASPECT_RATIOS.some(_ref4 => {
|
|
256
|
+
let {
|
|
257
|
+
className
|
|
258
|
+
} = _ref4;
|
|
259
|
+
return existingClassNames.includes(className);
|
|
260
|
+
});
|
|
261
|
+
};
|
|
240
262
|
/**
|
|
241
263
|
* Removes all previously set aspect ratio related classes and return the rest
|
|
242
264
|
* existing class names.
|
|
@@ -246,7 +268,7 @@ const createUpgradedEmbedBlock = function (props) {
|
|
|
246
268
|
*/
|
|
247
269
|
|
|
248
270
|
|
|
249
|
-
exports.
|
|
271
|
+
exports.hasAspectRatioClass = hasAspectRatioClass;
|
|
250
272
|
|
|
251
273
|
const removeAspectRatioClasses = existingClassNames => {
|
|
252
274
|
if (!existingClassNames) {
|
|
@@ -256,10 +278,10 @@ const removeAspectRatioClasses = existingClassNames => {
|
|
|
256
278
|
return existingClassNames;
|
|
257
279
|
}
|
|
258
280
|
|
|
259
|
-
const aspectRatioClassNames = _constants.ASPECT_RATIOS.reduce((accumulator,
|
|
281
|
+
const aspectRatioClassNames = _constants.ASPECT_RATIOS.reduce((accumulator, _ref5) => {
|
|
260
282
|
let {
|
|
261
283
|
className
|
|
262
|
-
} =
|
|
284
|
+
} = _ref5;
|
|
263
285
|
accumulator[className] = false;
|
|
264
286
|
return accumulator;
|
|
265
287
|
}, {
|
|
@@ -371,6 +393,13 @@ const getAttributesFromPreview = (0, _memize.default)(function (preview, title,
|
|
|
371
393
|
if (html || 'photo' === type) {
|
|
372
394
|
attributes.type = type;
|
|
373
395
|
attributes.providerNameSlug = providerNameSlug;
|
|
396
|
+
} // Aspect ratio classes are removed when the embed URL is updated.
|
|
397
|
+
// If the embed already has an aspect ratio class, that means the URL has not changed.
|
|
398
|
+
// Which also means no need to regenerate it with getClassNames.
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
if (hasAspectRatioClass(currentClassNames)) {
|
|
402
|
+
return attributes;
|
|
374
403
|
}
|
|
375
404
|
|
|
376
405
|
attributes.className = getClassNames(html, currentClassNames, isResponsive && allowResponsive);
|
|
@@ -379,24 +408,22 @@ const getAttributesFromPreview = (0, _memize.default)(function (preview, title,
|
|
|
379
408
|
/**
|
|
380
409
|
* Returns the attributes derived from the preview, merged with the current attributes.
|
|
381
410
|
*
|
|
382
|
-
* @param {Object} currentAttributes
|
|
383
|
-
* @param {Object} preview
|
|
384
|
-
* @param {string} title
|
|
385
|
-
* @param {boolean} isResponsive
|
|
386
|
-
* @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.
|
|
411
|
+
* @param {Object} currentAttributes The current attributes of the block.
|
|
412
|
+
* @param {Object} preview The preview data.
|
|
413
|
+
* @param {string} title The block's title, e.g. Twitter.
|
|
414
|
+
* @param {boolean} isResponsive Boolean indicating if the block supports responsive content.
|
|
387
415
|
* @return {Object} Merged attributes.
|
|
388
416
|
*/
|
|
389
417
|
|
|
390
418
|
exports.getAttributesFromPreview = getAttributesFromPreview;
|
|
391
419
|
|
|
392
|
-
const getMergedAttributesWithPreview =
|
|
393
|
-
let ignorePreviousClassName = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : false;
|
|
420
|
+
const getMergedAttributesWithPreview = (currentAttributes, preview, title, isResponsive) => {
|
|
394
421
|
const {
|
|
395
422
|
allowResponsive,
|
|
396
423
|
className
|
|
397
424
|
} = currentAttributes;
|
|
398
425
|
return { ...currentAttributes,
|
|
399
|
-
...getAttributesFromPreview(preview, title,
|
|
426
|
+
...getAttributesFromPreview(preview, title, className, isResponsive, allowResponsive)
|
|
400
427
|
};
|
|
401
428
|
};
|
|
402
429
|
|
package/build/embed/util.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/embed/util.js"],"names":["name","DEFAULT_EMBED_BLOCK","metadata","getEmbedInfoByProvider","provider","find","matchesPatterns","url","patterns","some","pattern","match","findMoreSuitableBlock","isFromWordPress","html","includes","getPhotoHtml","photo","imageUrl","thumbnail_url","photoPreview","title","createUpgradedEmbedBlock","props","attributesFromPreview","preview","attributes","providerNameSlug","type","restAttributes","matchedBlock","isCurrentBlockWP","WP_EMBED_TYPE","shouldCreateNewBlock","wpVariation","removeAspectRatioClasses","existingClassNames","aspectRatioClassNames","ASPECT_RATIOS","reduce","accumulator","className","getClassNames","allowResponsive","previewDocument","document","implementation","createHTMLDocument","body","innerHTML","iframe","querySelector","height","width","aspectRatio","toFixed","ratioIndex","length","potentialRatio","ratio","ratioDiff","fallback","onReplace","link","content","getAttributesFromPreview","currentClassNames","isResponsive","provider_name","providerName","toLowerCase","getMergedAttributesWithPreview","currentAttributes","ignorePreviousClassName","undefined"],"mappings":";;;;;;;;;;;;;AAeA;;AAZA;;AAKA;;AACA;;AACA;;AAMA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAQA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAM;AAAEA,EAAAA,IAAI,EAAEC;AAAR,IAAgCC,QAAtC;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,sBAAsB,GAAKC,QAAF;AAAA;;AAAA,gCACrC,gCAAoBH,mBAApB,CADqC,wDACrC,oBAA2CI,IAA3C,CACC;AAAA,QAAE;AAAEL,MAAAA;AAAF,KAAF;AAAA,WAAgBA,IAAI,KAAKI,QAAzB;AAAA,GADD,CADqC;AAAA,CAA/B;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAME,eAAe,GAAG,UAAEC,GAAF;AAAA,MAAOC,QAAP,uEAAkB,EAAlB;AAAA,SAC9BA,QAAQ,CAACC,IAAT,CAAiBC,OAAF,IAAeH,GAAG,CAACI,KAAJ,CAAWD,OAAX,CAA9B,CAD8B;AAAA,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jB,UAAP;AACA,CAtCsC,CAAjC;AAyCP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;AACO,MAAM6C,8BAA8B,GAAG,UAC7CC,iBAD6C,EAE7C/C,OAF6C,EAG7CJ,KAH6C,EAI7C8C,YAJ6C,EAMzC;AAAA,MADJM,uBACI,uEADsB,KACtB;AACJ,QAAM;AAAE9B,IAAAA,eAAF;AAAmBF,IAAAA;AAAnB,MAAiC+B,iBAAvC;AACA,SAAO,EACN,GAAGA,iBADG;AAEN,OAAGP,wBAAwB,CAC1BxC,OAD0B,EAE1BJ,KAF0B,EAG1BoD,uBAAuB,GAAGC,SAAH,GAAejC,SAHZ,EAI1B0B,YAJ0B,EAK1BxB,eAL0B;AAFrB,GAAP;AAUA,CAlBM","sourcesContent":["/**\n * Internal dependencies\n */\nimport { ASPECT_RATIOS, WP_EMBED_TYPE } from './constants';\n\n/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\nimport classnames from 'classnames/dedupe';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { renderToString } from '@wordpress/element';\nimport {\n\tcreateBlock,\n\tgetBlockType,\n\tgetBlockVariations,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\n\nconst { name: DEFAULT_EMBED_BLOCK } = metadata;\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * Returns the embed block's information by matching the provided service provider\n *\n * @param {string} provider The embed block's provider\n * @return {WPBlockVariation} The embed block's information\n */\nexport const getEmbedInfoByProvider = ( provider ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === provider\n\t);\n\n/**\n * Returns true if any of the regular expressions match the URL.\n *\n * @param {string} url The URL to test.\n * @param {Array} patterns The list of regular expressions to test agains.\n * @return {boolean} True if any of the regular expressions match the URL.\n */\nexport const matchesPatterns = ( url, patterns = [] ) =>\n\tpatterns.some( ( pattern ) => url.match( pattern ) );\n\n/**\n * Finds the block variation that should be used for the URL,\n * based on the provided URL and the variation's patterns.\n *\n * @param {string} url The URL to test.\n * @return {WPBlockVariation} The block variation that should be used for this URL\n */\nexport const findMoreSuitableBlock = ( url ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find( ( { patterns } ) =>\n\t\tmatchesPatterns( url, patterns )\n\t);\n\nexport const isFromWordPress = ( html ) =>\n\thtml && html.includes( 'class=\"wp-embedded-content\"' );\n\nexport const getPhotoHtml = ( photo ) => {\n\t// If full image url not found use thumbnail.\n\tconst imageUrl = photo.url || photo.thumbnail_url;\n\n\t// 100% width for the preview so it fits nicely into the document, some \"thumbnails\" are\n\t// actually the full size photo.\n\tconst photoPreview = (\n\t\t<p>\n\t\t\t<img src={ imageUrl } alt={ photo.title } width=\"100%\" />\n\t\t</p>\n\t);\n\treturn renderToString( photoPreview );\n};\n\n/**\n * Creates a more suitable embed block based on the passed in props\n * and attributes generated from an embed block's preview.\n *\n * We require `attributesFromPreview` to be generated from the latest attributes\n * and preview, and because of the way the react lifecycle operates, we can't\n * guarantee that the attributes contained in the block's props are the latest\n * versions, so we require that these are generated separately.\n * See `getAttributesFromPreview` in the generated embed edit component.\n *\n * @param {Object} props The block's props.\n * @param {Object} [attributesFromPreview] Attributes generated from the block's most up to date preview.\n * @return {Object|undefined} A more suitable embed block if one exists.\n */\nexport const createUpgradedEmbedBlock = (\n\tprops,\n\tattributesFromPreview = {}\n) => {\n\tconst { preview, attributes = {} } = props;\n\tconst { url, providerNameSlug, type, ...restAttributes } = attributes;\n\n\tif ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) return;\n\n\tconst matchedBlock = findMoreSuitableBlock( url );\n\n\t// WordPress blocks can work on multiple sites, and so don't have patterns,\n\t// so if we're in a WordPress block, assume the user has chosen it for a WordPress URL.\n\tconst isCurrentBlockWP =\n\t\tproviderNameSlug === 'wordpress' || type === WP_EMBED_TYPE;\n\t// If current block is not WordPress and a more suitable block found\n\t// that is different from the current one, create the new matched block.\n\tconst shouldCreateNewBlock =\n\t\t! isCurrentBlockWP &&\n\t\tmatchedBlock &&\n\t\t( matchedBlock.attributes.providerNameSlug !== providerNameSlug ||\n\t\t\t! providerNameSlug );\n\tif ( shouldCreateNewBlock ) {\n\t\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\t\turl,\n\t\t\t...restAttributes,\n\t\t\t...matchedBlock.attributes,\n\t\t} );\n\t}\n\n\tconst wpVariation = getBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === 'wordpress'\n\t);\n\n\t// We can't match the URL for WordPress embeds, we have to check the HTML instead.\n\tif (\n\t\t! wpVariation ||\n\t\t! preview ||\n\t\t! isFromWordPress( preview.html ) ||\n\t\tisCurrentBlockWP\n\t) {\n\t\treturn;\n\t}\n\n\t// This is not the WordPress embed block so transform it into one.\n\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\turl,\n\t\t...wpVariation.attributes,\n\t\t// By now we have the preview, but when the new block first renders, it\n\t\t// won't have had all the attributes set, and so won't get the correct\n\t\t// type and it won't render correctly. So, we pass through the current attributes\n\t\t// here so that the initial render works when we switch to the WordPress\n\t\t// block. This only affects the WordPress block because it can't be\n\t\t// rendered in the usual Sandbox (it has a sandbox of its own) and it\n\t\t// relies on the preview to set the correct render type.\n\t\t...attributesFromPreview,\n\t} );\n};\n\n/**\n * Removes all previously set aspect ratio related classes and return the rest\n * existing class names.\n *\n * @param {string} existingClassNames Any existing class names.\n * @return {string} The class names without any aspect ratio related class.\n */\nexport const removeAspectRatioClasses = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\t// Avoids extraneous work and also, by returning the same value as\n\t\t// received, ensures the post is not dirtied by a change of the block\n\t\t// attribute from `undefined` to an emtpy string.\n\t\treturn existingClassNames;\n\t}\n\tconst aspectRatioClassNames = ASPECT_RATIOS.reduce(\n\t\t( accumulator, { className } ) => {\n\t\t\taccumulator[ className ] = false;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ 'wp-has-aspect-ratio': false }\n\t);\n\treturn classnames( existingClassNames, aspectRatioClassNames );\n};\n\n/**\n * Returns class names with any relevant responsive aspect ratio names.\n *\n * @param {string} html The preview HTML that possibly contains an iframe with width and height set.\n * @param {string} existingClassNames Any existing class names.\n * @param {boolean} allowResponsive If the responsive class names should be added, or removed.\n * @return {string} Deduped class names.\n */\nexport function getClassNames(\n\thtml,\n\texistingClassNames,\n\tallowResponsive = true\n) {\n\tif ( ! allowResponsive ) {\n\t\treturn removeAspectRatioClasses( existingClassNames );\n\t}\n\n\tconst previewDocument = document.implementation.createHTMLDocument( '' );\n\tpreviewDocument.body.innerHTML = html;\n\tconst iframe = previewDocument.body.querySelector( 'iframe' );\n\n\t// If we have a fixed aspect iframe, and it's a responsive embed block.\n\tif ( iframe && iframe.height && iframe.width ) {\n\t\tconst aspectRatio = ( iframe.width / iframe.height ).toFixed( 2 );\n\t\t// Given the actual aspect ratio, find the widest ratio to support it.\n\t\tfor (\n\t\t\tlet ratioIndex = 0;\n\t\t\tratioIndex < ASPECT_RATIOS.length;\n\t\t\tratioIndex++\n\t\t) {\n\t\t\tconst potentialRatio = ASPECT_RATIOS[ ratioIndex ];\n\t\t\tif ( aspectRatio >= potentialRatio.ratio ) {\n\t\t\t\t// Evaluate the difference between actual aspect ratio and closest match.\n\t\t\t\t// If the difference is too big, do not scale the embed according to aspect ratio.\n\t\t\t\tconst ratioDiff = aspectRatio - potentialRatio.ratio;\n\t\t\t\tif ( ratioDiff > 0.1 ) {\n\t\t\t\t\t// No close aspect ratio match found.\n\t\t\t\t\treturn removeAspectRatioClasses( existingClassNames );\n\t\t\t\t}\n\t\t\t\t// Close aspect ratio match found.\n\t\t\t\treturn classnames(\n\t\t\t\t\tremoveAspectRatioClasses( existingClassNames ),\n\t\t\t\t\tpotentialRatio.className,\n\t\t\t\t\t'wp-has-aspect-ratio'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn existingClassNames;\n}\n\n/**\n * Fallback behaviour for unembeddable URLs.\n * Creates a paragraph block containing a link to the URL, and calls `onReplace`.\n *\n * @param {string} url The URL that could not be embedded.\n * @param {Function} onReplace Function to call with the created fallback block.\n */\nexport function fallback( url, onReplace ) {\n\tconst link = <a href={ url }>{ url }</a>;\n\tonReplace(\n\t\tcreateBlock( 'core/paragraph', { content: renderToString( link ) } )\n\t);\n}\n\n/***\n * Gets block attributes based on the preview and responsive state.\n *\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {Object} currentClassNames The block's current class names.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @param {boolean} allowResponsive Apply responsive classes to fixed size content.\n * @return {Object} Attributes and values.\n */\nexport const getAttributesFromPreview = memoize(\n\t(\n\t\tpreview,\n\t\ttitle,\n\t\tcurrentClassNames,\n\t\tisResponsive,\n\t\tallowResponsive = true\n\t) => {\n\t\tif ( ! preview ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst attributes = {};\n\t\t// Some plugins only return HTML with no type info, so default this to 'rich'.\n\t\tlet { type = 'rich' } = preview;\n\t\t// If we got a provider name from the API, use it for the slug, otherwise we use the title,\n\t\t// because not all embed code gives us a provider name.\n\t\tconst { html, provider_name: providerName } = preview;\n\t\tconst providerNameSlug = kebabCase(\n\t\t\t( providerName || title ).toLowerCase()\n\t\t);\n\n\t\tif ( isFromWordPress( html ) ) {\n\t\t\ttype = WP_EMBED_TYPE;\n\t\t}\n\n\t\tif ( html || 'photo' === type ) {\n\t\t\tattributes.type = type;\n\t\t\tattributes.providerNameSlug = providerNameSlug;\n\t\t}\n\n\t\tattributes.className = getClassNames(\n\t\t\thtml,\n\t\t\tcurrentClassNames,\n\t\t\tisResponsive && allowResponsive\n\t\t);\n\n\t\treturn attributes;\n\t}\n);\n\n/**\n * Returns the attributes derived from the preview, merged with the current attributes.\n *\n * @param {Object} currentAttributes The current attributes of the block.\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @param {boolean} ignorePreviousClassName Determines if the previous className attribute should be ignored when merging.\n * @return {Object} Merged attributes.\n */\nexport const getMergedAttributesWithPreview = (\n\tcurrentAttributes,\n\tpreview,\n\ttitle,\n\tisResponsive,\n\tignorePreviousClassName = false\n) => {\n\tconst { allowResponsive, className } = currentAttributes;\n\treturn {\n\t\t...currentAttributes,\n\t\t...getAttributesFromPreview(\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tignorePreviousClassName ? undefined : className,\n\t\t\tisResponsive,\n\t\t\tallowResponsive\n\t\t),\n\t};\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/embed/util.js"],"names":["name","DEFAULT_EMBED_BLOCK","metadata","getEmbedInfoByProvider","provider","find","matchesPatterns","url","patterns","some","pattern","match","findMoreSuitableBlock","isFromWordPress","html","includes","getPhotoHtml","photo","imageUrl","thumbnail_url","photoPreview","title","createUpgradedEmbedBlock","props","attributesFromPreview","preview","attributes","providerNameSlug","type","restAttributes","matchedBlock","isCurrentBlockWP","WP_EMBED_TYPE","shouldCreateNewBlock","wpVariation","hasAspectRatioClass","existingClassNames","ASPECT_RATIOS","className","removeAspectRatioClasses","aspectRatioClassNames","reduce","accumulator","getClassNames","allowResponsive","previewDocument","document","implementation","createHTMLDocument","body","innerHTML","iframe","querySelector","height","width","aspectRatio","toFixed","ratioIndex","length","potentialRatio","ratio","ratioDiff","fallback","onReplace","link","content","getAttributesFromPreview","currentClassNames","isResponsive","provider_name","providerName","toLowerCase","getMergedAttributesWithPreview","currentAttributes"],"mappings":";;;;;;;;;;;;;AAeA;;AAZA;;AAKA;;AACA;;AACA;;AAMA;;AAhBA;AACA;AACA;;AAGA;AACA;AACA;;AAKA;AACA;AACA;;AAQA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAM;AAAEA,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AC1BzC,OAD0B,EAE1BJ,KAF0B,EAG1BiB,SAH0B,EAI1B8B,YAJ0B,EAK1BxB,eAL0B;AAFrB,GAAP;AAUA,CAlBM","sourcesContent":["/**\n * Internal dependencies\n */\nimport { ASPECT_RATIOS, WP_EMBED_TYPE } from './constants';\n\n/**\n * External dependencies\n */\nimport { kebabCase } from 'lodash';\nimport classnames from 'classnames/dedupe';\nimport memoize from 'memize';\n\n/**\n * WordPress dependencies\n */\nimport { renderToString } from '@wordpress/element';\nimport {\n\tcreateBlock,\n\tgetBlockType,\n\tgetBlockVariations,\n} from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\n\nconst { name: DEFAULT_EMBED_BLOCK } = metadata;\n\n/** @typedef {import('@wordpress/blocks').WPBlockVariation} WPBlockVariation */\n\n/**\n * Returns the embed block's information by matching the provided service provider\n *\n * @param {string} provider The embed block's provider\n * @return {WPBlockVariation} The embed block's information\n */\nexport const getEmbedInfoByProvider = ( provider ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === provider\n\t);\n\n/**\n * Returns true if any of the regular expressions match the URL.\n *\n * @param {string} url The URL to test.\n * @param {Array} patterns The list of regular expressions to test agains.\n * @return {boolean} True if any of the regular expressions match the URL.\n */\nexport const matchesPatterns = ( url, patterns = [] ) =>\n\tpatterns.some( ( pattern ) => url.match( pattern ) );\n\n/**\n * Finds the block variation that should be used for the URL,\n * based on the provided URL and the variation's patterns.\n *\n * @param {string} url The URL to test.\n * @return {WPBlockVariation} The block variation that should be used for this URL\n */\nexport const findMoreSuitableBlock = ( url ) =>\n\tgetBlockVariations( DEFAULT_EMBED_BLOCK )?.find( ( { patterns } ) =>\n\t\tmatchesPatterns( url, patterns )\n\t);\n\nexport const isFromWordPress = ( html ) =>\n\thtml && html.includes( 'class=\"wp-embedded-content\"' );\n\nexport const getPhotoHtml = ( photo ) => {\n\t// If full image url not found use thumbnail.\n\tconst imageUrl = photo.url || photo.thumbnail_url;\n\n\t// 100% width for the preview so it fits nicely into the document, some \"thumbnails\" are\n\t// actually the full size photo.\n\tconst photoPreview = (\n\t\t<p>\n\t\t\t<img src={ imageUrl } alt={ photo.title } width=\"100%\" />\n\t\t</p>\n\t);\n\treturn renderToString( photoPreview );\n};\n\n/**\n * Creates a more suitable embed block based on the passed in props\n * and attributes generated from an embed block's preview.\n *\n * We require `attributesFromPreview` to be generated from the latest attributes\n * and preview, and because of the way the react lifecycle operates, we can't\n * guarantee that the attributes contained in the block's props are the latest\n * versions, so we require that these are generated separately.\n * See `getAttributesFromPreview` in the generated embed edit component.\n *\n * @param {Object} props The block's props.\n * @param {Object} [attributesFromPreview] Attributes generated from the block's most up to date preview.\n * @return {Object|undefined} A more suitable embed block if one exists.\n */\nexport const createUpgradedEmbedBlock = (\n\tprops,\n\tattributesFromPreview = {}\n) => {\n\tconst { preview, attributes = {} } = props;\n\tconst { url, providerNameSlug, type, ...restAttributes } = attributes;\n\n\tif ( ! url || ! getBlockType( DEFAULT_EMBED_BLOCK ) ) return;\n\n\tconst matchedBlock = findMoreSuitableBlock( url );\n\n\t// WordPress blocks can work on multiple sites, and so don't have patterns,\n\t// so if we're in a WordPress block, assume the user has chosen it for a WordPress URL.\n\tconst isCurrentBlockWP =\n\t\tproviderNameSlug === 'wordpress' || type === WP_EMBED_TYPE;\n\t// If current block is not WordPress and a more suitable block found\n\t// that is different from the current one, create the new matched block.\n\tconst shouldCreateNewBlock =\n\t\t! isCurrentBlockWP &&\n\t\tmatchedBlock &&\n\t\t( matchedBlock.attributes.providerNameSlug !== providerNameSlug ||\n\t\t\t! providerNameSlug );\n\tif ( shouldCreateNewBlock ) {\n\t\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\t\turl,\n\t\t\t...restAttributes,\n\t\t\t...matchedBlock.attributes,\n\t\t} );\n\t}\n\n\tconst wpVariation = getBlockVariations( DEFAULT_EMBED_BLOCK )?.find(\n\t\t( { name } ) => name === 'wordpress'\n\t);\n\n\t// We can't match the URL for WordPress embeds, we have to check the HTML instead.\n\tif (\n\t\t! wpVariation ||\n\t\t! preview ||\n\t\t! isFromWordPress( preview.html ) ||\n\t\tisCurrentBlockWP\n\t) {\n\t\treturn;\n\t}\n\n\t// This is not the WordPress embed block so transform it into one.\n\treturn createBlock( DEFAULT_EMBED_BLOCK, {\n\t\turl,\n\t\t...wpVariation.attributes,\n\t\t// By now we have the preview, but when the new block first renders, it\n\t\t// won't have had all the attributes set, and so won't get the correct\n\t\t// type and it won't render correctly. So, we pass through the current attributes\n\t\t// here so that the initial render works when we switch to the WordPress\n\t\t// block. This only affects the WordPress block because it can't be\n\t\t// rendered in the usual Sandbox (it has a sandbox of its own) and it\n\t\t// relies on the preview to set the correct render type.\n\t\t...attributesFromPreview,\n\t} );\n};\n\n/**\n * Determine if the block already has an aspect ratio class applied.\n *\n * @param {string} existingClassNames Existing block classes.\n * @return {boolean} True or false if the classnames contain an aspect ratio class.\n */\nexport const hasAspectRatioClass = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\treturn false;\n\t}\n\treturn ASPECT_RATIOS.some( ( { className } ) =>\n\t\texistingClassNames.includes( className )\n\t);\n};\n\n/**\n * Removes all previously set aspect ratio related classes and return the rest\n * existing class names.\n *\n * @param {string} existingClassNames Any existing class names.\n * @return {string} The class names without any aspect ratio related class.\n */\nexport const removeAspectRatioClasses = ( existingClassNames ) => {\n\tif ( ! existingClassNames ) {\n\t\t// Avoids extraneous work and also, by returning the same value as\n\t\t// received, ensures the post is not dirtied by a change of the block\n\t\t// attribute from `undefined` to an emtpy string.\n\t\treturn existingClassNames;\n\t}\n\tconst aspectRatioClassNames = ASPECT_RATIOS.reduce(\n\t\t( accumulator, { className } ) => {\n\t\t\taccumulator[ className ] = false;\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ 'wp-has-aspect-ratio': false }\n\t);\n\treturn classnames( existingClassNames, aspectRatioClassNames );\n};\n\n/**\n * Returns class names with any relevant responsive aspect ratio names.\n *\n * @param {string} html The preview HTML that possibly contains an iframe with width and height set.\n * @param {string} existingClassNames Any existing class names.\n * @param {boolean} allowResponsive If the responsive class names should be added, or removed.\n * @return {string} Deduped class names.\n */\nexport function getClassNames(\n\thtml,\n\texistingClassNames,\n\tallowResponsive = true\n) {\n\tif ( ! allowResponsive ) {\n\t\treturn removeAspectRatioClasses( existingClassNames );\n\t}\n\n\tconst previewDocument = document.implementation.createHTMLDocument( '' );\n\tpreviewDocument.body.innerHTML = html;\n\tconst iframe = previewDocument.body.querySelector( 'iframe' );\n\n\t// If we have a fixed aspect iframe, and it's a responsive embed block.\n\tif ( iframe && iframe.height && iframe.width ) {\n\t\tconst aspectRatio = ( iframe.width / iframe.height ).toFixed( 2 );\n\t\t// Given the actual aspect ratio, find the widest ratio to support it.\n\t\tfor (\n\t\t\tlet ratioIndex = 0;\n\t\t\tratioIndex < ASPECT_RATIOS.length;\n\t\t\tratioIndex++\n\t\t) {\n\t\t\tconst potentialRatio = ASPECT_RATIOS[ ratioIndex ];\n\t\t\tif ( aspectRatio >= potentialRatio.ratio ) {\n\t\t\t\t// Evaluate the difference between actual aspect ratio and closest match.\n\t\t\t\t// If the difference is too big, do not scale the embed according to aspect ratio.\n\t\t\t\tconst ratioDiff = aspectRatio - potentialRatio.ratio;\n\t\t\t\tif ( ratioDiff > 0.1 ) {\n\t\t\t\t\t// No close aspect ratio match found.\n\t\t\t\t\treturn removeAspectRatioClasses( existingClassNames );\n\t\t\t\t}\n\t\t\t\t// Close aspect ratio match found.\n\t\t\t\treturn classnames(\n\t\t\t\t\tremoveAspectRatioClasses( existingClassNames ),\n\t\t\t\t\tpotentialRatio.className,\n\t\t\t\t\t'wp-has-aspect-ratio'\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\treturn existingClassNames;\n}\n\n/**\n * Fallback behaviour for unembeddable URLs.\n * Creates a paragraph block containing a link to the URL, and calls `onReplace`.\n *\n * @param {string} url The URL that could not be embedded.\n * @param {Function} onReplace Function to call with the created fallback block.\n */\nexport function fallback( url, onReplace ) {\n\tconst link = <a href={ url }>{ url }</a>;\n\tonReplace(\n\t\tcreateBlock( 'core/paragraph', { content: renderToString( link ) } )\n\t);\n}\n\n/***\n * Gets block attributes based on the preview and responsive state.\n *\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {Object} currentClassNames The block's current class names.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @param {boolean} allowResponsive Apply responsive classes to fixed size content.\n * @return {Object} Attributes and values.\n */\nexport const getAttributesFromPreview = memoize(\n\t(\n\t\tpreview,\n\t\ttitle,\n\t\tcurrentClassNames,\n\t\tisResponsive,\n\t\tallowResponsive = true\n\t) => {\n\t\tif ( ! preview ) {\n\t\t\treturn {};\n\t\t}\n\n\t\tconst attributes = {};\n\t\t// Some plugins only return HTML with no type info, so default this to 'rich'.\n\t\tlet { type = 'rich' } = preview;\n\t\t// If we got a provider name from the API, use it for the slug, otherwise we use the title,\n\t\t// because not all embed code gives us a provider name.\n\t\tconst { html, provider_name: providerName } = preview;\n\t\tconst providerNameSlug = kebabCase(\n\t\t\t( providerName || title ).toLowerCase()\n\t\t);\n\n\t\tif ( isFromWordPress( html ) ) {\n\t\t\ttype = WP_EMBED_TYPE;\n\t\t}\n\n\t\tif ( html || 'photo' === type ) {\n\t\t\tattributes.type = type;\n\t\t\tattributes.providerNameSlug = providerNameSlug;\n\t\t}\n\n\t\t// Aspect ratio classes are removed when the embed URL is updated.\n\t\t// If the embed already has an aspect ratio class, that means the URL has not changed.\n\t\t// Which also means no need to regenerate it with getClassNames.\n\t\tif ( hasAspectRatioClass( currentClassNames ) ) {\n\t\t\treturn attributes;\n\t\t}\n\n\t\tattributes.className = getClassNames(\n\t\t\thtml,\n\t\t\tcurrentClassNames,\n\t\t\tisResponsive && allowResponsive\n\t\t);\n\n\t\treturn attributes;\n\t}\n);\n\n/**\n * Returns the attributes derived from the preview, merged with the current attributes.\n *\n * @param {Object} currentAttributes The current attributes of the block.\n * @param {Object} preview The preview data.\n * @param {string} title The block's title, e.g. Twitter.\n * @param {boolean} isResponsive Boolean indicating if the block supports responsive content.\n * @return {Object} Merged attributes.\n */\nexport const getMergedAttributesWithPreview = (\n\tcurrentAttributes,\n\tpreview,\n\ttitle,\n\tisResponsive\n) => {\n\tconst { allowResponsive, className } = currentAttributes;\n\n\treturn {\n\t\t...currentAttributes,\n\t\t...getAttributesFromPreview(\n\t\t\tpreview,\n\t\t\ttitle,\n\t\t\tclassName,\n\t\t\tisResponsive,\n\t\t\tallowResponsive\n\t\t),\n\t};\n};\n"]}
|