@wordpress/block-library 7.12.0 → 7.12.2-next.d6164808d3.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 +7 -1
- package/build/archives/index.js +5 -1
- package/build/archives/index.js.map +1 -1
- package/build/audio/index.js +4 -0
- package/build/audio/index.js.map +1 -1
- package/build/button/deprecated.js +14 -5
- package/build/button/deprecated.js.map +1 -1
- package/build/button/index.js +1 -1
- package/build/categories/edit.js +3 -1
- package/build/categories/edit.js.map +1 -1
- package/build/categories/index.js +14 -1
- package/build/categories/index.js.map +1 -1
- package/build/code/index.js +4 -2
- package/build/code/index.js.map +1 -1
- package/build/column/index.js +13 -0
- package/build/column/index.js.map +1 -1
- package/build/columns/deprecated.js +16 -5
- package/build/columns/deprecated.js.map +1 -1
- package/build/columns/edit.js +6 -2
- package/build/columns/edit.js.map +1 -1
- package/build/columns/edit.native.js +6 -2
- package/build/columns/edit.native.js.map +1 -1
- package/build/columns/index.js +13 -0
- package/build/columns/index.js.map +1 -1
- package/build/comment-author-name/index.js +5 -1
- package/build/comment-author-name/index.js.map +1 -1
- package/build/comment-content/index.js +5 -1
- package/build/comment-content/index.js.map +1 -1
- package/build/comment-date/index.js +1 -0
- package/build/comment-date/index.js.map +1 -1
- package/build/comment-edit-link/index.js +5 -1
- package/build/comment-edit-link/index.js.map +1 -1
- package/build/comment-reply-link/index.js +5 -1
- package/build/comment-reply-link/index.js.map +1 -1
- package/build/comment-template/index.js +14 -1
- package/build/comment-template/index.js.map +1 -1
- package/build/comments/index.js +13 -0
- package/build/comments/index.js.map +1 -1
- package/build/comments-pagination/index.js +13 -0
- package/build/comments-pagination/index.js.map +1 -1
- package/build/comments-pagination-next/index.js +4 -2
- package/build/comments-pagination-next/index.js.map +1 -1
- package/build/comments-pagination-numbers/edit.js +5 -1
- package/build/comments-pagination-numbers/edit.js.map +1 -1
- package/build/comments-pagination-numbers/index.js +14 -1
- package/build/comments-pagination-numbers/index.js.map +1 -1
- package/build/comments-pagination-previous/index.js +4 -2
- package/build/comments-pagination-previous/index.js.map +1 -1
- package/build/comments-title/deprecated.js +4 -2
- package/build/comments-title/deprecated.js.map +1 -1
- package/build/comments-title/index.js +4 -2
- package/build/comments-title/index.js.map +1 -1
- package/build/cover/deprecated.js +20 -5
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/index.js +13 -0
- package/build/cover/index.js.map +1 -1
- package/build/cover/shared.js +1 -1
- package/build/cover/shared.js.map +1 -1
- package/build/embed/icons.js +1 -1
- package/build/embed/icons.js.map +1 -1
- package/build/gallery/deprecated.js +6 -1
- package/build/gallery/deprecated.js.map +1 -1
- package/build/gallery/edit.js +15 -2
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/index.js +5 -0
- package/build/gallery/index.js.map +1 -1
- package/build/gallery/transforms.js +20 -7
- package/build/gallery/transforms.js.map +1 -1
- package/build/gallery/utils.js +7 -6
- package/build/gallery/utils.js.map +1 -1
- package/build/group/deprecated.js +108 -12
- package/build/group/deprecated.js.map +1 -1
- package/build/group/edit.js +23 -1
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +10 -2
- package/build/group/index.js.map +1 -1
- package/build/group/variations.js +8 -8
- package/build/group/variations.js.map +1 -1
- package/build/heading/deprecated.js +5 -3
- package/build/heading/deprecated.js.map +1 -1
- package/build/heading/index.js +3 -1
- package/build/heading/index.js.map +1 -1
- package/build/heading/transforms.js +3 -1
- package/build/heading/transforms.js.map +1 -1
- package/build/home-link/edit.js +8 -4
- package/build/home-link/edit.js.map +1 -1
- package/build/image/edit.js +13 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/index.js +13 -7
- package/build/image/index.js.map +1 -1
- package/build/index.native.js +6 -3
- package/build/index.native.js.map +1 -1
- package/build/list-item/edit.js +3 -1
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/index.js +8 -0
- package/build/list-item/hooks/index.js.map +1 -1
- package/build/list-item/hooks/use-copy.js +42 -0
- package/build/list-item/hooks/use-copy.js.map +1 -0
- package/build/list-item/list-style-type.native.js +4 -1
- package/build/list-item/list-style-type.native.js.map +1 -1
- package/build/media-text/deprecated.js +5 -1
- package/build/media-text/deprecated.js.map +1 -1
- package/build/media-text/index.js +13 -0
- package/build/media-text/index.js.map +1 -1
- package/build/navigation/deprecated.js +6 -1
- package/build/navigation/deprecated.js.map +1 -1
- package/build/navigation/edit/index.js +119 -38
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +2 -1
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +4 -7
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build/navigation/menu-items-to-blocks.js +1 -7
- package/build/navigation/menu-items-to-blocks.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +8 -7
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation-link/edit.js +6 -8
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +4 -6
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/edit.js +7 -3
- package/build/page-list/edit.js.map +1 -1
- package/build/paragraph/deprecated.js +18 -10
- package/build/paragraph/deprecated.js.map +1 -1
- package/build/paragraph/edit.js +1 -0
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/index.js +5 -0
- package/build/paragraph/index.js.map +1 -1
- package/build/paragraph/transforms.js +5 -0
- package/build/paragraph/transforms.js.map +1 -1
- package/build/post-author/index.js +4 -2
- package/build/post-author/index.js.map +1 -1
- package/build/post-author-biography/index.js +1 -0
- package/build/post-author-biography/index.js.map +1 -1
- package/build/post-author-name/index.js +5 -1
- package/build/post-author-name/index.js.map +1 -1
- package/build/post-comments-count/edit.js +11 -1
- package/build/post-comments-count/edit.js.map +1 -1
- package/build/post-comments-count/index.js +4 -1
- package/build/post-comments-count/index.js.map +1 -1
- package/build/post-comments-link/index.js +4 -2
- package/build/post-comments-link/index.js.map +1 -1
- package/build/post-date/edit.js +9 -2
- package/build/post-date/edit.js.map +1 -1
- package/build/post-date/index.js +9 -0
- package/build/post-date/index.js.map +1 -1
- package/build/post-featured-image/edit.js +27 -12
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-featured-image/index.js +12 -0
- package/build/post-featured-image/index.js.map +1 -1
- package/build/post-navigation-link/index.js +3 -2
- package/build/post-navigation-link/index.js.map +1 -1
- package/build/post-template/edit.js +8 -4
- package/build/post-template/edit.js.map +1 -1
- package/build/post-template/index.js +14 -1
- package/build/post-template/index.js.map +1 -1
- package/build/post-terms/index.js +5 -3
- package/build/post-terms/index.js.map +1 -1
- package/build/post-title/index.js +2 -1
- package/build/post-title/index.js.map +1 -1
- package/build/preformatted/index.js +4 -2
- package/build/preformatted/index.js.map +1 -1
- package/build/pullquote/deprecated.js +135 -25
- package/build/pullquote/deprecated.js.map +1 -1
- package/build/pullquote/edit.js +1 -1
- package/build/pullquote/edit.js.map +1 -1
- package/build/pullquote/edit.native.js +0 -1
- package/build/pullquote/edit.native.js.map +1 -1
- package/build/pullquote/index.js +13 -6
- package/build/pullquote/index.js.map +1 -1
- package/build/pullquote/save.js +2 -2
- package/build/pullquote/save.js.map +1 -1
- package/build/pullquote/transforms.js +14 -33
- package/build/pullquote/transforms.js.map +1 -1
- package/build/query/deprecated.js +10 -9
- package/build/query/deprecated.js.map +1 -1
- package/build/query/edit/index.js +19 -8
- package/build/query/edit/index.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +1 -0
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query/edit/query-placeholder.js +6 -1
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/utils.js +35 -9
- package/build/query/utils.js.map +1 -1
- package/build/query-no-results/edit.js +1 -1
- package/build/query-no-results/edit.js.map +1 -1
- package/build/query-title/edit.js +10 -1
- package/build/query-title/edit.js.map +1 -1
- package/build/query-title/index.js +7 -2
- package/build/query-title/index.js.map +1 -1
- package/build/quote/deprecated.js +13 -6
- package/build/quote/deprecated.js.map +1 -1
- package/build/quote/transforms.js +22 -37
- package/build/quote/transforms.js.map +1 -1
- package/build/separator/deprecated.js +3 -4
- package/build/separator/deprecated.js.map +1 -1
- package/build/separator/index.js +1 -0
- package/build/separator/index.js.map +1 -1
- package/build/social-link/icons/reddit.js +1 -1
- package/build/social-link/icons/reddit.js.map +1 -1
- package/build/social-links/edit.js +2 -1
- package/build/social-links/edit.js.map +1 -1
- package/build/spacer/index.js +7 -1
- package/build/spacer/index.js.map +1 -1
- package/build/table/index.js +4 -0
- package/build/table/index.js.map +1 -1
- package/build/table/state.js +9 -3
- package/build/table/state.js.map +1 -1
- package/build/table-of-contents/index.js +11 -1
- package/build/table-of-contents/index.js.map +1 -1
- package/build/tag-cloud/index.js +5 -1
- package/build/tag-cloud/index.js.map +1 -1
- package/build/template-part/index.js +2 -2
- package/build/template-part/index.js.map +1 -1
- package/build/term-description/index.js +4 -0
- package/build/term-description/index.js.map +1 -1
- package/build/text-columns/edit.js +3 -1
- package/build/text-columns/edit.js.map +1 -1
- package/build/text-columns/save.js +3 -1
- package/build/text-columns/save.js.map +1 -1
- package/build/verse/index.js +1 -0
- package/build/verse/index.js.map +1 -1
- package/build/video/index.js +4 -0
- package/build/video/index.js.map +1 -1
- package/build-module/archives/index.js +5 -1
- package/build-module/archives/index.js.map +1 -1
- package/build-module/audio/index.js +4 -0
- package/build-module/audio/index.js.map +1 -1
- package/build-module/button/deprecated.js +14 -4
- package/build-module/button/deprecated.js.map +1 -1
- package/build-module/button/index.js +1 -1
- package/build-module/categories/edit.js +4 -2
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/categories/index.js +14 -1
- package/build-module/categories/index.js.map +1 -1
- package/build-module/code/index.js +4 -2
- package/build-module/code/index.js.map +1 -1
- package/build-module/column/index.js +13 -0
- package/build-module/column/index.js.map +1 -1
- package/build-module/columns/deprecated.js +16 -4
- package/build-module/columns/deprecated.js.map +1 -1
- package/build-module/columns/edit.js +7 -3
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/columns/edit.native.js +7 -3
- package/build-module/columns/edit.native.js.map +1 -1
- package/build-module/columns/index.js +13 -0
- package/build-module/columns/index.js.map +1 -1
- package/build-module/comment-author-name/index.js +5 -1
- package/build-module/comment-author-name/index.js.map +1 -1
- package/build-module/comment-content/index.js +5 -1
- package/build-module/comment-content/index.js.map +1 -1
- package/build-module/comment-date/index.js +1 -0
- package/build-module/comment-date/index.js.map +1 -1
- package/build-module/comment-edit-link/index.js +5 -1
- package/build-module/comment-edit-link/index.js.map +1 -1
- package/build-module/comment-reply-link/index.js +5 -1
- package/build-module/comment-reply-link/index.js.map +1 -1
- package/build-module/comment-template/index.js +14 -1
- package/build-module/comment-template/index.js.map +1 -1
- package/build-module/comments/index.js +13 -0
- package/build-module/comments/index.js.map +1 -1
- package/build-module/comments-pagination/index.js +13 -0
- package/build-module/comments-pagination/index.js.map +1 -1
- package/build-module/comments-pagination-next/index.js +4 -2
- package/build-module/comments-pagination-next/index.js.map +1 -1
- package/build-module/comments-pagination-numbers/edit.js +5 -1
- package/build-module/comments-pagination-numbers/edit.js.map +1 -1
- package/build-module/comments-pagination-numbers/index.js +14 -1
- package/build-module/comments-pagination-numbers/index.js.map +1 -1
- package/build-module/comments-pagination-previous/index.js +4 -2
- package/build-module/comments-pagination-previous/index.js.map +1 -1
- package/build-module/comments-title/deprecated.js +4 -2
- package/build-module/comments-title/deprecated.js.map +1 -1
- package/build-module/comments-title/index.js +4 -2
- package/build-module/comments-title/index.js.map +1 -1
- package/build-module/cover/deprecated.js +20 -4
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/index.js +13 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/shared.js +1 -1
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/embed/icons.js +1 -1
- package/build-module/embed/icons.js.map +1 -1
- package/build-module/gallery/deprecated.js +7 -2
- package/build-module/gallery/deprecated.js.map +1 -1
- package/build-module/gallery/edit.js +15 -2
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/index.js +5 -0
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/gallery/transforms.js +20 -7
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/gallery/utils.js +7 -6
- package/build-module/gallery/utils.js.map +1 -1
- package/build-module/group/deprecated.js +109 -12
- package/build-module/group/deprecated.js.map +1 -1
- package/build-module/group/edit.js +25 -2
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +10 -2
- package/build-module/group/index.js.map +1 -1
- package/build-module/group/variations.js +8 -8
- package/build-module/group/variations.js.map +1 -1
- package/build-module/heading/deprecated.js +5 -2
- package/build-module/heading/deprecated.js.map +1 -1
- package/build-module/heading/index.js +3 -1
- package/build-module/heading/index.js.map +1 -1
- package/build-module/heading/transforms.js +3 -1
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/home-link/edit.js +10 -6
- package/build-module/home-link/edit.js.map +1 -1
- package/build-module/image/edit.js +14 -2
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/index.js +13 -7
- package/build-module/image/index.js.map +1 -1
- package/build-module/index.native.js +6 -2
- package/build-module/index.native.js.map +1 -1
- package/build-module/list-item/edit.js +4 -2
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/index.js +1 -0
- package/build-module/list-item/hooks/index.js.map +1 -1
- package/build-module/list-item/hooks/use-copy.js +32 -0
- package/build-module/list-item/hooks/use-copy.js.map +1 -0
- package/build-module/list-item/list-style-type.native.js +3 -1
- package/build-module/list-item/list-style-type.native.js.map +1 -1
- package/build-module/media-text/deprecated.js +6 -2
- package/build-module/media-text/deprecated.js.map +1 -1
- package/build-module/media-text/index.js +13 -0
- package/build-module/media-text/index.js.map +1 -1
- package/build-module/navigation/deprecated.js +7 -2
- package/build-module/navigation/deprecated.js.map +1 -1
- package/build-module/navigation/edit/index.js +120 -40
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +2 -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 +4 -7
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build-module/navigation/menu-items-to-blocks.js +1 -6
- package/build-module/navigation/menu-items-to-blocks.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +8 -7
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation-link/edit.js +7 -9
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +5 -7
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/edit.js +7 -2
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/paragraph/deprecated.js +18 -9
- package/build-module/paragraph/deprecated.js.map +1 -1
- package/build-module/paragraph/edit.js +1 -0
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/index.js +5 -0
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/paragraph/transforms.js +5 -0
- package/build-module/paragraph/transforms.js.map +1 -1
- package/build-module/post-author/index.js +4 -2
- package/build-module/post-author/index.js.map +1 -1
- package/build-module/post-author-biography/index.js +1 -0
- package/build-module/post-author-biography/index.js.map +1 -1
- package/build-module/post-author-name/index.js +5 -1
- package/build-module/post-author-name/index.js.map +1 -1
- package/build-module/post-comments-count/edit.js +10 -1
- package/build-module/post-comments-count/edit.js.map +1 -1
- package/build-module/post-comments-count/index.js +4 -1
- package/build-module/post-comments-count/index.js.map +1 -1
- package/build-module/post-comments-link/index.js +4 -2
- package/build-module/post-comments-link/index.js.map +1 -1
- package/build-module/post-date/edit.js +9 -2
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-date/index.js +9 -0
- package/build-module/post-date/index.js.map +1 -1
- package/build-module/post-featured-image/edit.js +28 -13
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-featured-image/index.js +12 -0
- package/build-module/post-featured-image/index.js.map +1 -1
- package/build-module/post-navigation-link/index.js +3 -2
- package/build-module/post-navigation-link/index.js.map +1 -1
- package/build-module/post-template/edit.js +8 -4
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-template/index.js +14 -1
- package/build-module/post-template/index.js.map +1 -1
- package/build-module/post-terms/index.js +5 -3
- package/build-module/post-terms/index.js.map +1 -1
- package/build-module/post-title/index.js +2 -1
- package/build-module/post-title/index.js.map +1 -1
- package/build-module/preformatted/index.js +4 -2
- package/build-module/preformatted/index.js.map +1 -1
- package/build-module/pullquote/deprecated.js +134 -25
- package/build-module/pullquote/deprecated.js.map +1 -1
- package/build-module/pullquote/edit.js +1 -1
- package/build-module/pullquote/edit.js.map +1 -1
- package/build-module/pullquote/edit.native.js +0 -1
- package/build-module/pullquote/edit.native.js.map +1 -1
- package/build-module/pullquote/index.js +13 -6
- package/build-module/pullquote/index.js.map +1 -1
- package/build-module/pullquote/save.js +2 -2
- package/build-module/pullquote/save.js.map +1 -1
- package/build-module/pullquote/transforms.js +15 -34
- package/build-module/pullquote/transforms.js.map +1 -1
- package/build-module/query/deprecated.js +10 -8
- package/build-module/query/deprecated.js.map +1 -1
- package/build-module/query/edit/index.js +23 -12
- package/build-module/query/edit/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +1 -0
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +6 -1
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/utils.js +32 -7
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query-no-results/edit.js +1 -1
- package/build-module/query-no-results/edit.js.map +1 -1
- package/build-module/query-title/edit.js +10 -1
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/query-title/index.js +7 -2
- package/build-module/query-title/index.js.map +1 -1
- package/build-module/quote/deprecated.js +13 -5
- package/build-module/quote/deprecated.js.map +1 -1
- package/build-module/quote/transforms.js +23 -38
- package/build-module/quote/transforms.js.map +1 -1
- package/build-module/separator/deprecated.js +3 -3
- package/build-module/separator/deprecated.js.map +1 -1
- package/build-module/separator/index.js +1 -0
- package/build-module/separator/index.js.map +1 -1
- package/build-module/social-link/icons/reddit.js +1 -1
- package/build-module/social-link/icons/reddit.js.map +1 -1
- package/build-module/social-links/edit.js +2 -1
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/spacer/index.js +7 -1
- package/build-module/spacer/index.js.map +1 -1
- package/build-module/table/index.js +4 -0
- package/build-module/table/index.js.map +1 -1
- package/build-module/table/state.js +10 -4
- package/build-module/table/state.js.map +1 -1
- package/build-module/table-of-contents/index.js +11 -1
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-module/tag-cloud/index.js +5 -1
- package/build-module/tag-cloud/index.js.map +1 -1
- package/build-module/template-part/index.js +2 -2
- package/build-module/template-part/index.js.map +1 -1
- package/build-module/term-description/index.js +4 -0
- package/build-module/term-description/index.js.map +1 -1
- package/build-module/text-columns/edit.js +4 -2
- package/build-module/text-columns/edit.js.map +1 -1
- package/build-module/text-columns/save.js +4 -2
- package/build-module/text-columns/save.js.map +1 -1
- package/build-module/verse/index.js +1 -0
- package/build-module/verse/index.js.map +1 -1
- package/build-module/video/index.js +4 -0
- package/build-module/video/index.js.map +1 -1
- package/build-style/audio/style-rtl.css +3 -0
- package/build-style/audio/style.css +3 -0
- package/build-style/button/style-rtl.css +6 -6
- package/build-style/button/style.css +6 -6
- package/build-style/editor-rtl.css +105 -122
- package/build-style/editor.css +105 -122
- package/build-style/group/editor-rtl.css +27 -8
- package/build-style/group/editor.css +27 -8
- package/build-style/image/editor-rtl.css +21 -2
- package/build-style/image/editor.css +21 -2
- package/build-style/navigation/editor-rtl.css +8 -4
- package/build-style/navigation/editor.css +8 -4
- package/build-style/navigation/style-rtl.css +2 -2
- package/build-style/navigation/style.css +2 -2
- package/build-style/paragraph/editor-rtl.css +1 -1
- package/build-style/paragraph/editor.css +1 -1
- package/build-style/post-date/style-rtl.css +79 -0
- package/build-style/post-date/style.css +79 -0
- package/build-style/post-featured-image/editor-rtl.css +45 -43
- package/build-style/post-featured-image/editor.css +45 -43
- package/build-style/post-featured-image/style-rtl.css +1 -0
- package/build-style/post-featured-image/style.css +1 -0
- package/build-style/post-title/style-rtl.css +1 -0
- package/build-style/post-title/style.css +1 -0
- package/build-style/pullquote/editor-rtl.css +0 -12
- package/build-style/pullquote/editor.css +0 -12
- package/build-style/pullquote/style-rtl.css +1 -8
- package/build-style/pullquote/style.css +1 -8
- package/build-style/query-title/style-rtl.css +79 -0
- package/build-style/query-title/style.css +79 -0
- package/build-style/site-logo/editor-rtl.css +3 -52
- package/build-style/site-logo/editor.css +3 -52
- package/build-style/social-links/style-rtl.css +2 -2
- package/build-style/social-links/style.css +2 -2
- package/build-style/style-rtl.css +27 -18
- package/build-style/style.css +27 -18
- package/build-style/video/style-rtl.css +3 -0
- package/build-style/video/style.css +3 -0
- package/package.json +30 -29
- package/src/archives/block.json +5 -1
- package/src/audio/block.json +4 -0
- package/src/audio/style.scss +2 -0
- package/src/button/block.json +1 -1
- package/src/button/deprecated.js +21 -22
- package/src/button/style.scss +6 -6
- package/src/calendar/index.php +2 -2
- package/src/categories/block.json +14 -1
- package/src/categories/edit.js +2 -2
- package/src/code/block.json +4 -2
- package/src/column/block.json +13 -0
- package/src/columns/block.json +13 -0
- package/src/columns/deprecated.js +10 -4
- package/src/columns/edit.js +7 -3
- package/src/columns/edit.native.js +7 -3
- package/src/comment-author-name/block.json +5 -1
- package/src/comment-content/block.json +5 -1
- package/src/comment-date/block.json +1 -0
- package/src/comment-edit-link/block.json +5 -1
- package/src/comment-reply-link/block.json +5 -1
- package/src/comment-template/block.json +14 -1
- package/src/comments/block.json +13 -0
- package/src/comments/index.php +6 -5
- package/src/comments-pagination/block.json +13 -0
- package/src/comments-pagination-next/block.json +4 -2
- package/src/comments-pagination-numbers/block.json +14 -1
- package/src/comments-pagination-numbers/edit.js +12 -3
- package/src/comments-pagination-previous/block.json +4 -2
- package/src/comments-title/block.json +4 -2
- package/src/cover/block.json +13 -0
- package/src/cover/deprecated.js +11 -4
- package/src/cover/shared.js +2 -1
- package/src/embed/icons.js +1 -1
- package/src/gallery/block.json +5 -0
- package/src/gallery/deprecated.js +4 -2
- package/src/gallery/edit.js +22 -2
- package/src/gallery/transforms.js +18 -5
- package/src/gallery/utils.js +11 -7
- package/src/group/block.json +10 -2
- package/src/group/deprecated.js +89 -2
- package/src/group/edit.js +15 -2
- package/src/group/editor.scss +28 -3
- package/src/group/variations.js +4 -3
- package/src/heading/block.json +3 -1
- package/src/heading/deprecated.js +4 -2
- package/src/home-link/edit.js +19 -20
- package/src/image/block.json +13 -7
- package/src/image/edit.js +19 -1
- package/src/image/editor.scss +39 -3
- package/src/image/index.php +1 -1
- package/src/index.native.js +15 -10
- package/src/list-item/edit.js +2 -1
- package/src/list-item/hooks/index.js +1 -0
- package/src/list-item/hooks/use-copy.js +36 -0
- package/src/list-item/list-style-type.native.js +8 -1
- package/src/list-item/style.native.scss +4 -0
- package/src/media-text/block.json +13 -0
- package/src/media-text/deprecated.js +3 -2
- package/src/navigation/deprecated.js +4 -2
- package/src/navigation/edit/index.js +159 -81
- package/src/navigation/edit/unsaved-inner-blocks.js +3 -1
- package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +31 -37
- package/src/navigation/editor.scss +3 -2
- package/src/navigation/index.php +11 -16
- package/src/navigation/menu-items-to-blocks.js +3 -6
- package/src/navigation/style.scss +3 -2
- package/src/navigation/use-navigation-menu.js +11 -8
- package/src/navigation-link/edit.js +9 -13
- package/src/navigation-submenu/edit.js +9 -13
- package/src/page-list/edit.js +6 -2
- package/src/paragraph/block.json +5 -0
- package/src/paragraph/deprecated.js +33 -35
- package/src/paragraph/edit.js +1 -0
- package/src/paragraph/editor.scss +5 -3
- package/src/post-author/block.json +4 -2
- package/src/post-author-biography/block.json +1 -0
- package/src/post-author-name/block.json +5 -1
- package/src/post-comments-count/block.json +4 -1
- package/src/post-comments-count/edit.js +10 -2
- package/src/post-comments-link/block.json +4 -2
- package/src/post-date/block.json +9 -0
- package/src/post-date/edit.js +12 -2
- package/src/post-date/index.php +10 -2
- package/src/post-date/style.scss +4 -0
- package/src/post-featured-image/block.json +12 -0
- package/src/post-featured-image/edit.js +43 -13
- package/src/post-featured-image/editor.scss +44 -53
- package/src/post-featured-image/index.php +61 -4
- package/src/post-featured-image/style.scss +1 -0
- package/src/post-navigation-link/block.json +3 -2
- package/src/post-template/block.json +15 -1
- package/src/post-template/edit.js +6 -1
- package/src/post-template/index.php +7 -4
- package/src/post-terms/block.json +5 -3
- package/src/post-title/block.json +2 -1
- package/src/post-title/style.scss +2 -0
- package/src/preformatted/block.json +4 -2
- package/src/pullquote/block.json +11 -4
- package/src/pullquote/deprecated.js +490 -412
- package/src/pullquote/edit.js +1 -1
- package/src/pullquote/edit.native.js +0 -1
- package/src/pullquote/editor.scss +0 -16
- package/src/pullquote/index.js +1 -3
- package/src/pullquote/save.js +1 -1
- package/src/pullquote/style.scss +0 -11
- package/src/pullquote/transforms.js +17 -33
- package/src/query/deprecated.js +4 -9
- package/src/query/edit/index.js +28 -15
- package/src/query/edit/inspector-controls/taxonomy-controls.js +1 -1
- package/src/query/edit/query-placeholder.js +17 -2
- package/src/query/utils.js +29 -7
- package/src/query-no-results/edit.js +1 -1
- package/src/query-title/block.json +7 -2
- package/src/query-title/edit.js +19 -2
- package/src/query-title/index.php +11 -1
- package/src/query-title/style.scss +4 -0
- package/src/quote/deprecated.js +6 -5
- package/src/quote/transforms.js +4 -18
- package/src/search/index.php +1 -1
- package/src/separator/block.json +1 -0
- package/src/separator/deprecated.js +2 -3
- package/src/site-logo/editor.scss +8 -66
- package/src/social-link/icons/reddit.js +1 -1
- package/src/social-link/index.php +1 -1
- package/src/social-link/socials-with-bg.scss +1 -1
- package/src/social-link/socials-without-bg.scss +1 -1
- package/src/social-links/edit.js +1 -0
- package/src/spacer/block.json +7 -1
- package/src/style.scss +2 -0
- package/src/table/block.json +4 -0
- package/src/table/state.js +21 -19
- package/src/table-of-contents/block.json +11 -1
- package/src/tag-cloud/block.json +5 -1
- package/src/template-part/index.js +3 -2
- package/src/term-description/block.json +4 -0
- package/src/text-columns/edit.js +2 -2
- package/src/text-columns/save.js +2 -2
- package/src/verse/block.json +1 -0
- package/src/video/block.json +4 -0
- package/src/video/style.scss +2 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-author-biography/index.js"],"names":["name","metadata","settings","icon","edit"],"mappings":";;;;;;;;;AAIA;;AAKA;;AATA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-author-biography/index.js"],"names":["name","metadata","settings","icon","edit"],"mappings":";;;;;;;;;AAIA;;AAKA;;AATA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,iBADuB;AAEvBC,EAAAA,IAAI,EAAJA;AAFuB,CAAjB","sourcesContent":["/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\n/**\n * WordPress dependencies\n */\nimport { postAuthor as icon } from '@wordpress/icons';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n"]}
|
|
@@ -61,7 +61,11 @@ const metadata = {
|
|
|
61
61
|
__experimentalFontWeight: true,
|
|
62
62
|
__experimentalFontStyle: true,
|
|
63
63
|
__experimentalTextTransform: true,
|
|
64
|
-
|
|
64
|
+
__experimentalTextDecoration: true,
|
|
65
|
+
__experimentalLetterSpacing: true,
|
|
66
|
+
__experimentalDefaultControls: {
|
|
67
|
+
fontSize: true
|
|
68
|
+
}
|
|
65
69
|
}
|
|
66
70
|
}
|
|
67
71
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-author-name/index.js"],"names":["name","metadata","settings","icon","transforms","edit"],"mappings":";;;;;;;;;AAIA;;AACA;;AAKA;;AAVA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-author-name/index.js"],"names":["name","metadata","settings","icon","transforms","edit"],"mappings":";;;;;;;;;AAIA;;AACA;;AAKA;;AAVA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAUA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,iBADuB;AAEvBC,EAAAA,UAAU,EAAVA,mBAFuB;AAGvBC,EAAAA,IAAI,EAAJA;AAHuB,CAAjB","sourcesContent":["/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport transforms from './transforms';\n\n/**\n * WordPress dependencies\n */\nimport { postAuthor as icon } from '@wordpress/icons';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\ttransforms,\n\tedit,\n};\n"]}
|
|
@@ -9,6 +9,8 @@ exports.default = PostCommentsCountEdit;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
+
|
|
12
14
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
15
|
|
|
14
16
|
var _blockEditor = require("@wordpress/block-editor");
|
|
@@ -27,6 +29,8 @@ var _i18n = require("@wordpress/i18n");
|
|
|
27
29
|
* WordPress dependencies
|
|
28
30
|
*/
|
|
29
31
|
function PostCommentsCountEdit(_ref) {
|
|
32
|
+
var _blockProps$style;
|
|
33
|
+
|
|
30
34
|
let {
|
|
31
35
|
attributes,
|
|
32
36
|
context,
|
|
@@ -62,6 +66,10 @@ function PostCommentsCountEdit(_ref) {
|
|
|
62
66
|
}
|
|
63
67
|
});
|
|
64
68
|
}, [postId]);
|
|
69
|
+
const hasPostAndComments = postId && commentsCount !== undefined;
|
|
70
|
+
const blockStyles = { ...blockProps.style,
|
|
71
|
+
textDecoration: hasPostAndComments ? (_blockProps$style = blockProps.style) === null || _blockProps$style === void 0 ? void 0 : _blockProps$style.textDecoration : undefined
|
|
72
|
+
};
|
|
65
73
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.BlockControls, {
|
|
66
74
|
group: "block"
|
|
67
75
|
}, (0, _element.createElement)(_blockEditor.AlignmentControl, {
|
|
@@ -71,6 +79,8 @@ function PostCommentsCountEdit(_ref) {
|
|
|
71
79
|
textAlign: nextAlign
|
|
72
80
|
});
|
|
73
81
|
}
|
|
74
|
-
})), (0, _element.createElement)("div",
|
|
82
|
+
})), (0, _element.createElement)("div", (0, _extends2.default)({}, blockProps, {
|
|
83
|
+
style: blockStyles
|
|
84
|
+
}), hasPostAndComments ? commentsCount : (0, _element.createElement)(_blockEditor.Warning, null, (0, _i18n.__)('Post Comments Count block: post not found.'))));
|
|
75
85
|
}
|
|
76
86
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-comments-count/edit.js"],"names":["PostCommentsCountEdit","attributes","context","setAttributes","textAlign","postId","commentsCount","setCommentsCount","blockProps","className","currentPostId","path","post","parse","then","res","headers","get","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-comments-count/edit.js"],"names":["PostCommentsCountEdit","attributes","context","setAttributes","textAlign","postId","commentsCount","setCommentsCount","blockProps","className","currentPostId","path","post","parse","then","res","headers","get","hasPostAndComments","undefined","blockStyles","style","textDecoration","nextAlign"],"mappings":";;;;;;;;;AAcA;;;;AAXA;;AAKA;;AAOA;;AACA;;AACA;;AAjBA;AACA;AACA;;AAG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AEC,IAAA,QAAQ,EAAKmB,SAAF,IAAiB;AAC3BpB,MAAAA,aAAa,CAAE;AAAEC,QAAAA,SAAS,EAAEmB;AAAb,OAAF,CAAb;AACA;AAJF,IADD,CADD,EASC,8DAAUf,UAAV;AAAuB,IAAA,KAAK,EAAGY;AAA/B,MACGF,kBAAkB,GACnBZ,aADmB,GAGnB,4BAAC,oBAAD,QACG,cAAI,4CAAJ,CADH,CAJF,CATD,CADD;AAqBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tWarning,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { useState, useEffect } from '@wordpress/element';\nimport apiFetch from '@wordpress/api-fetch';\nimport { addQueryArgs } from '@wordpress/url';\nimport { __ } from '@wordpress/i18n';\n\nexport default function PostCommentsCountEdit( {\n\tattributes,\n\tcontext,\n\tsetAttributes,\n} ) {\n\tconst { textAlign } = attributes;\n\tconst { postId } = context;\n\tconst [ commentsCount, setCommentsCount ] = useState();\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\tuseEffect( () => {\n\t\tif ( ! postId ) {\n\t\t\treturn;\n\t\t}\n\t\tconst currentPostId = postId;\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\tpost: postId,\n\t\t\t} ),\n\t\t\tparse: false,\n\t\t} ).then( ( res ) => {\n\t\t\t// Stale requests will have the `currentPostId` of an older closure.\n\t\t\tif ( currentPostId === postId ) {\n\t\t\t\tsetCommentsCount( res.headers.get( 'X-WP-Total' ) );\n\t\t\t}\n\t\t} );\n\t}, [ postId ] );\n\n\tconst hasPostAndComments = postId && commentsCount !== undefined;\n\tconst blockStyles = {\n\t\t...blockProps.style,\n\t\ttextDecoration: hasPostAndComments\n\t\t\t? blockProps.style?.textDecoration\n\t\t\t: undefined,\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<div { ...blockProps } style={ blockStyles }>\n\t\t\t\t{ hasPostAndComments ? (\n\t\t\t\t\tcommentsCount\n\t\t\t\t) : (\n\t\t\t\t\t<Warning>\n\t\t\t\t\t\t{ __( 'Post Comments Count block: post not found.' ) }\n\t\t\t\t\t</Warning>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -45,8 +45,11 @@ const metadata = {
|
|
|
45
45
|
typography: {
|
|
46
46
|
fontSize: true,
|
|
47
47
|
lineHeight: true,
|
|
48
|
-
|
|
48
|
+
__experimentalFontFamily: true,
|
|
49
49
|
__experimentalFontWeight: true,
|
|
50
|
+
__experimentalFontStyle: true,
|
|
51
|
+
__experimentalTextTransform: true,
|
|
52
|
+
__experimentalTextDecoration: true,
|
|
50
53
|
__experimentalLetterSpacing: true,
|
|
51
54
|
__experimentalDefaultControls: {
|
|
52
55
|
fontSize: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-comments-count/index.js"],"names":["name","metadata","settings","icon","edit"],"mappings":";;;;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;;AAGA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-comments-count/index.js"],"names":["name","metadata","settings","icon","edit"],"mappings":";;;;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,wBADuB;AAEvBC,EAAAA,IAAI,EAAJA;AAFuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postCommentsCount as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n"]}
|
|
@@ -46,10 +46,12 @@ const metadata = {
|
|
|
46
46
|
typography: {
|
|
47
47
|
fontSize: true,
|
|
48
48
|
lineHeight: true,
|
|
49
|
-
|
|
49
|
+
__experimentalFontFamily: true,
|
|
50
50
|
__experimentalFontWeight: true,
|
|
51
|
-
|
|
51
|
+
__experimentalFontStyle: true,
|
|
52
52
|
__experimentalTextTransform: true,
|
|
53
|
+
__experimentalTextDecoration: true,
|
|
54
|
+
__experimentalLetterSpacing: true,
|
|
53
55
|
__experimentalDefaultControls: {
|
|
54
56
|
fontSize: true
|
|
55
57
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-comments-link/index.js"],"names":["name","metadata","settings","edit","icon"],"mappings":";;;;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;;AAGA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-comments-link/index.js"],"names":["name","metadata","settings","edit","icon"],"mappings":";;;;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,aADuB;AAEvBC,EAAAA,IAAI,EAAJA;AAFuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postCommentsCount as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\tedit,\n\ticon,\n};\n"]}
|
package/build/post-date/edit.js
CHANGED
|
@@ -40,7 +40,8 @@ function PostDateEdit(_ref) {
|
|
|
40
40
|
attributes: {
|
|
41
41
|
textAlign,
|
|
42
42
|
format,
|
|
43
|
-
isLink
|
|
43
|
+
isLink,
|
|
44
|
+
displayType
|
|
44
45
|
},
|
|
45
46
|
context: {
|
|
46
47
|
postId,
|
|
@@ -59,7 +60,7 @@ function PostDateEdit(_ref) {
|
|
|
59
60
|
const dateSettings = (0, _date.__experimentalGetSettings)();
|
|
60
61
|
const [siteFormat = dateSettings.formats.date] = (0, _coreData.useEntityProp)('root', 'site', 'date_format');
|
|
61
62
|
const [siteTimeFormat = dateSettings.formats.time] = (0, _coreData.useEntityProp)('root', 'site', 'time_format');
|
|
62
|
-
const [date, setDate] = (0, _coreData.useEntityProp)('postType', postTypeSlug,
|
|
63
|
+
const [date, setDate] = (0, _coreData.useEntityProp)('postType', postTypeSlug, displayType, postId);
|
|
63
64
|
const postType = (0, _data.useSelect)(select => postTypeSlug ? select(_coreData.store).getPostType(postTypeSlug) : null, [postTypeSlug]);
|
|
64
65
|
let postDate = date ? (0, _element.createElement)("time", {
|
|
65
66
|
dateTime: (0, _date.dateI18n)('c', date),
|
|
@@ -133,6 +134,12 @@ function PostDateEdit(_ref) {
|
|
|
133
134
|
isLink: !isLink
|
|
134
135
|
}),
|
|
135
136
|
checked: isLink
|
|
137
|
+
}), (0, _element.createElement)(_components.ToggleControl, {
|
|
138
|
+
label: (0, _i18n.__)('Display last modified date'),
|
|
139
|
+
onChange: value => setAttributes({
|
|
140
|
+
displayType: value ? 'modified' : 'date'
|
|
141
|
+
}),
|
|
142
|
+
checked: displayType === 'modified'
|
|
136
143
|
}))), (0, _element.createElement)("div", blockProps, postDate));
|
|
137
144
|
}
|
|
138
145
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-date/edit.js"],"names":["PostDateEdit","attributes","textAlign","format","isLink","context","postId","postType","postTypeSlug","queryId","setAttributes","blockProps","className","timeRef","isDescendentOfQueryLoop","Number","isFinite","dateSettings","siteFormat","formats","date","siteTimeFormat","time","setDate","select","coreStore","getPostType","postDate","event","preventDefault","nextAlign","anchorRef","current","onClose","is12HourFormat","isOpen","onToggle","openOnArrowDown","keyCode","DOWN","edit","nextFormat","labels","singular_name","toLowerCase","test"],"mappings":";;;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAIA;;AAQA;;AAOA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;AA2Be,SAASA,YAAT,OAIX;AAAA,MAJkC;AACrCC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,SAAF;AAAaC,MAAAA,MAAb;AAAqBC,MAAAA;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-date/edit.js"],"names":["PostDateEdit","attributes","textAlign","format","isLink","displayType","context","postId","postType","postTypeSlug","queryId","setAttributes","blockProps","className","timeRef","isDescendentOfQueryLoop","Number","isFinite","dateSettings","siteFormat","formats","date","siteTimeFormat","time","setDate","select","coreStore","getPostType","postDate","event","preventDefault","nextAlign","anchorRef","current","onClose","is12HourFormat","isOpen","onToggle","openOnArrowDown","keyCode","DOWN","edit","nextFormat","labels","singular_name","toLowerCase","value","test"],"mappings":";;;;;;;;;;AASA;;AANA;;AAKA;;AAEA;;AAIA;;AAQA;;AAOA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;AA2Be,SAASA,YAAT,OAIX;AAAA,MAJkC;AACrCC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,SAAF;AAAaC,MAAAA,MAAb;AAAqBC,MAAAA,MAArB;AAA6BC,MAAAA;AAA7B,KADyB;AAErCC,IAAAA,OAAO,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA,QAAQ,EAAEC,YAApB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,UAAJ;AAAnB,KACC,4BAAC,2CAAD;AACC,IAAA,MAAM,EAAGnC,MADV;AAEC,IAAA,aAAa,EAAGgB,UAFjB;AAGC,IAAA,QAAQ,EAAKuB,UAAF,IACV/B,aAAa,CAAE;AAAER,MAAAA,MAAM,EAAEuC;AAAV,KAAF;AAJf,IADD,EAQC,4BAAC,yBAAD;AACC,IAAA,KAAK,EACJlC,QAAQ,SAAR,IAAAA,QAAQ,WAAR,IAAAA,QAAQ,CAAEmC,MAAV,CAAiBC,aAAjB,GACG,oBACA;AACA,kBAAI,YAAJ,CAFA,EAGApC,QAAQ,CAACmC,MAAT,CAAgBC,aAAhB,CAA8BC,WAA9B,EAHA,CADH,GAMG,cAAI,cAAJ,CARL;AAUC,IAAA,QAAQ,EAAG,MAAMlC,aAAa,CAAE;AAAEP,MAAAA,MAAM,EAAE,CAAEA;AAAZ,KAAF,CAV/B;AAWC,IAAA,OAAO,EAAGA;AAXX,IARD,EAqBC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,4BAAJ,CADT;AAEC,IAAA,QAAQ,EAAK0C,KAAF,IACVnC,aAAa,CAAE;AACdN,MAAAA,WAAW,EAAEyC,KAAK,GAAG,UAAH,GAAgB;AADpB,KAAF,CAHf;AAOC,IAAA,OAAO,EAAGzC,WAAW,KAAK;AAP3B,IArBD,CADD,CA5CD,EA8EC,mCAAUO,UAAV,EAAyBgB,QAAzB,CA9ED,CADD;AAkFA;;AAEM,SAASO,cAAT,CAAyBhC,MAAzB,EAAkC;AACxC;AACA;AACA;AACA;AACA;AACA,SAAO,oBAAoB4C,IAApB,CAA0B5C,MAA1B,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useRef } from '@wordpress/element';\nimport {\n\tdateI18n,\n\t__experimentalGetSettings as getDateSettings,\n} from '@wordpress/date';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\t__experimentalDateFormatPicker as DateFormatPicker,\n\t__experimentalPublishDateTimePicker as PublishDateTimePicker,\n} from '@wordpress/block-editor';\nimport {\n\tDropdown,\n\tToolbarGroup,\n\tToolbarButton,\n\tToggleControl,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { edit } from '@wordpress/icons';\nimport { DOWN } from '@wordpress/keycodes';\nimport { useSelect } from '@wordpress/data';\n\nexport default function PostDateEdit( {\n\tattributes: { textAlign, format, isLink, displayType },\n\tcontext: { postId, postType: postTypeSlug, queryId },\n\tsetAttributes,\n} ) {\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\tconst timeRef = useRef();\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst dateSettings = getDateSettings();\n\tconst [ siteFormat = dateSettings.formats.date ] = useEntityProp(\n\t\t'root',\n\t\t'site',\n\t\t'date_format'\n\t);\n\tconst [ siteTimeFormat = dateSettings.formats.time ] = useEntityProp(\n\t\t'root',\n\t\t'site',\n\t\t'time_format'\n\t);\n\tconst [ date, setDate ] = useEntityProp(\n\t\t'postType',\n\t\tpostTypeSlug,\n\t\tdisplayType,\n\t\tpostId\n\t);\n\n\tconst postType = useSelect(\n\t\t( select ) =>\n\t\t\tpostTypeSlug\n\t\t\t\t? select( coreStore ).getPostType( postTypeSlug )\n\t\t\t\t: null,\n\t\t[ postTypeSlug ]\n\t);\n\n\tlet postDate = date ? (\n\t\t<time dateTime={ dateI18n( 'c', date ) } ref={ timeRef }>\n\t\t\t{ dateI18n( format || siteFormat, date ) }\n\t\t</time>\n\t) : (\n\t\t__( 'Post Date' )\n\t);\n\n\tif ( isLink && date ) {\n\t\tpostDate = (\n\t\t\t<a\n\t\t\t\thref=\"#post-date-pseudo-link\"\n\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t>\n\t\t\t\t{ postDate }\n\t\t\t</a>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t{ date && ! isDescendentOfQueryLoop && (\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tpopoverProps={ { anchorRef: timeRef.current } }\n\t\t\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t\t\t<PublishDateTimePicker\n\t\t\t\t\t\t\t\t\tcurrentDate={ date }\n\t\t\t\t\t\t\t\t\tonChange={ setDate }\n\t\t\t\t\t\t\t\t\tis12Hour={ is12HourFormat(\n\t\t\t\t\t\t\t\t\t\tsiteTimeFormat\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => {\n\t\t\t\t\t\t\t\tconst openOnArrowDown = ( event ) => {\n\t\t\t\t\t\t\t\t\tif ( ! isOpen && event.keyCode === DOWN ) {\n\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\t\t\t\ticon={ edit }\n\t\t\t\t\t\t\t\t\t\ttitle={ __( 'Change Date' ) }\n\t\t\t\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<DateFormatPicker\n\t\t\t\t\t\tformat={ format }\n\t\t\t\t\t\tdefaultFormat={ siteFormat }\n\t\t\t\t\t\tonChange={ ( nextFormat ) =>\n\t\t\t\t\t\t\tsetAttributes( { format: nextFormat } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tpostType?.labels.singular_name\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"post\".\n\t\t\t\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\t\t\t\tpostType.labels.singular_name.toLowerCase()\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __( 'Link to post' )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonChange={ () => setAttributes( { isLink: ! isLink } ) }\n\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Display last modified date' ) }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdisplayType: value ? 'modified' : 'date',\n\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tchecked={ displayType === 'modified' }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\n\t\t\t<div { ...blockProps }>{ postDate }</div>\n\t\t</>\n\t);\n}\n\nexport function is12HourFormat( format ) {\n\t// To know if the time format is a 12 hour time, look for any of the 12 hour\n\t// format characters: 'a', 'A', 'g', and 'h'. The character must be\n\t// unescaped, i.e. not preceded by a '\\'. Coincidentally, 'aAgh' is how I\n\t// feel when working with regular expressions.\n\t// https://www.php.net/manual/en/datetime.format.php\n\treturn /(?:^|[^\\\\])[aAgh]/.test( format );\n}\n"]}
|
package/build/post-date/index.js
CHANGED
|
@@ -38,6 +38,10 @@ const metadata = {
|
|
|
38
38
|
isLink: {
|
|
39
39
|
type: "boolean",
|
|
40
40
|
"default": false
|
|
41
|
+
},
|
|
42
|
+
displayType: {
|
|
43
|
+
type: "string",
|
|
44
|
+
"default": "date"
|
|
41
45
|
}
|
|
42
46
|
},
|
|
43
47
|
usesContext: ["postId", "postType", "queryId"],
|
|
@@ -52,6 +56,10 @@ const metadata = {
|
|
|
52
56
|
link: true
|
|
53
57
|
}
|
|
54
58
|
},
|
|
59
|
+
spacing: {
|
|
60
|
+
margin: true,
|
|
61
|
+
padding: true
|
|
62
|
+
},
|
|
55
63
|
typography: {
|
|
56
64
|
fontSize: true,
|
|
57
65
|
lineHeight: true,
|
|
@@ -59,6 +67,7 @@ const metadata = {
|
|
|
59
67
|
__experimentalFontWeight: true,
|
|
60
68
|
__experimentalFontStyle: true,
|
|
61
69
|
__experimentalTextTransform: true,
|
|
70
|
+
__experimentalTextDecoration: true,
|
|
62
71
|
__experimentalLetterSpacing: true,
|
|
63
72
|
__experimentalDefaultControls: {
|
|
64
73
|
fontSize: true
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-date/index.js"],"names":["name","metadata","settings","icon","edit","deprecated"],"mappings":";;;;;;;;;AAGA;;AAMA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-date/index.js"],"names":["name","metadata","settings","icon","edit","deprecated"],"mappings":";;;;;;;;;AAGA;;AAMA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,eADuB;AAEvBC,EAAAA,IAAI,EAAJA,aAFuB;AAGvBC,EAAAA,UAAU,EAAVA;AAHuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postDate as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport deprecated from './deprecated';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tdeprecated,\n};\n"]}
|
|
@@ -9,6 +9,8 @@ exports.default = PostFeaturedImageEdit;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
+
var _classnames = _interopRequireDefault(require("classnames"));
|
|
13
|
+
|
|
12
14
|
var _coreData = require("@wordpress/core-data");
|
|
13
15
|
|
|
14
16
|
var _data = require("@wordpress/data");
|
|
@@ -25,6 +27,10 @@ var _notices = require("@wordpress/notices");
|
|
|
25
27
|
|
|
26
28
|
var _dimensionControls = _interopRequireDefault(require("./dimension-controls"));
|
|
27
29
|
|
|
30
|
+
/**
|
|
31
|
+
* External dependencies
|
|
32
|
+
*/
|
|
33
|
+
|
|
28
34
|
/**
|
|
29
35
|
* WordPress dependencies
|
|
30
36
|
*/
|
|
@@ -34,13 +40,6 @@ var _dimensionControls = _interopRequireDefault(require("./dimension-controls"))
|
|
|
34
40
|
*/
|
|
35
41
|
const ALLOWED_MEDIA_TYPES = ['image'];
|
|
36
42
|
|
|
37
|
-
const placeholder = content => {
|
|
38
|
-
return (0, _element.createElement)(_components.Placeholder, {
|
|
39
|
-
className: "block-editor-media-placeholder",
|
|
40
|
-
withIllustration: true
|
|
41
|
-
}, content);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
43
|
function getMediaSourceUrlBySizeSlug(media, slug) {
|
|
45
44
|
var _media$media_details, _media$media_details$, _media$media_details$2;
|
|
46
45
|
|
|
@@ -109,6 +108,15 @@ function PostFeaturedImageDisplay(_ref) {
|
|
|
109
108
|
height
|
|
110
109
|
}
|
|
111
110
|
});
|
|
111
|
+
const borderProps = (0, _blockEditor.__experimentalUseBorderProps)(attributes);
|
|
112
|
+
|
|
113
|
+
const placeholder = content => {
|
|
114
|
+
return (0, _element.createElement)(_components.Placeholder, {
|
|
115
|
+
className: (0, _classnames.default)('block-editor-media-placeholder', borderProps.className),
|
|
116
|
+
withIllustration: true,
|
|
117
|
+
style: borderProps.style
|
|
118
|
+
}, content);
|
|
119
|
+
};
|
|
112
120
|
|
|
113
121
|
const onSelectImage = value => {
|
|
114
122
|
if (value !== null && value !== void 0 && value.id) {
|
|
@@ -160,6 +168,10 @@ function PostFeaturedImageDisplay(_ref) {
|
|
|
160
168
|
}
|
|
161
169
|
|
|
162
170
|
const label = (0, _i18n.__)('Add a featured image');
|
|
171
|
+
const imageStyles = { ...borderProps.style,
|
|
172
|
+
height,
|
|
173
|
+
objectFit: height && scale
|
|
174
|
+
};
|
|
163
175
|
|
|
164
176
|
if (!featuredImage) {
|
|
165
177
|
image = (0, _element.createElement)(_blockEditor.MediaPlaceholder, {
|
|
@@ -187,13 +199,11 @@ function PostFeaturedImageDisplay(_ref) {
|
|
|
187
199
|
} else {
|
|
188
200
|
// We have a Featured image so show a Placeholder if is loading.
|
|
189
201
|
image = !media ? placeholder() : (0, _element.createElement)("img", {
|
|
202
|
+
className: borderProps.className,
|
|
190
203
|
src: mediaUrl,
|
|
191
204
|
alt: media.alt_text ? (0, _i18n.sprintf)( // translators: %s: The image's alt text.
|
|
192
205
|
(0, _i18n.__)('Featured image: %s'), media.alt_text) : (0, _i18n.__)('Featured image'),
|
|
193
|
-
style:
|
|
194
|
-
height,
|
|
195
|
-
objectFit: height && scale
|
|
196
|
-
}
|
|
206
|
+
style: imageStyles
|
|
197
207
|
});
|
|
198
208
|
}
|
|
199
209
|
|
|
@@ -215,9 +225,14 @@ function PostFeaturedImageEdit(props) {
|
|
|
215
225
|
var _props$context;
|
|
216
226
|
|
|
217
227
|
const blockProps = (0, _blockEditor.useBlockProps)();
|
|
228
|
+
const borderProps = (0, _blockEditor.__experimentalUseBorderProps)(props.attributes);
|
|
218
229
|
|
|
219
230
|
if (!((_props$context = props.context) !== null && _props$context !== void 0 && _props$context.postId)) {
|
|
220
|
-
return (0, _element.createElement)("div", blockProps,
|
|
231
|
+
return (0, _element.createElement)("div", blockProps, (0, _element.createElement)(_components.Placeholder, {
|
|
232
|
+
className: (0, _classnames.default)('block-editor-media-placeholder', borderProps.className),
|
|
233
|
+
withIllustration: true,
|
|
234
|
+
style: borderProps.style
|
|
235
|
+
}));
|
|
221
236
|
}
|
|
222
237
|
|
|
223
238
|
return (0, _element.createElement)(PostFeaturedImageDisplay, props);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-featured-image/edit.js"],"names":["ALLOWED_MEDIA_TYPES","placeholder","content","getMediaSourceUrlBySizeSlug","media","slug","media_details","sizes","source_url","PostFeaturedImageDisplay","clientId","attributes","setAttributes","context","postId","postType","postTypeSlug","queryId","isDescendentOfQueryLoop","Number","isFinite","isLink","height","width","scale","sizeSlug","rel","linkTarget","featuredImage","setFeaturedImage","select","getMedia","getPostType","coreStore","mediaUrl","imageSizes","blockEditorStore","getSettings","imageSizeOptions","filter","map","name","value","label","blockProps","style","onSelectImage","id","createErrorNotice","noticesStore","onUploadError","message","type","controls","labels","singular_name","toLowerCase","newRel","image","open","upload","alt_text","objectFit","PostFeaturedImageEdit","props"],"mappings":";;;;;;;;;;;AAGA;;AACA;;AACA;;AAQA;;AAQA;;AACA;;AACA;;AAKA;;AA5BA;AACA;AACA;;AAuBA;AACA;AACA;AAGA,MAAMA,mBAAmB,GAAG,CAAE,OAAF,CAA5B;;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c,uBAAd,IACD,4BAAC,0BAAD;AAAe,IAAA,KAAK,EAAC;AAArB,KACC,4BAAC,6BAAD;AACC,IAAA,OAAO,EAAGU,aADX;AAEC,IAAA,QAAQ,EAAGM,QAFZ;AAGC,IAAA,YAAY,EAAGlC,mBAHhB;AAIC,IAAA,MAAM,EAAC,SAJR;AAKC,IAAA,QAAQ,EAAG8C,aALZ;AAMC,IAAA,OAAO,EAAGI;AANX,KAQC,4BAAC,oBAAD;AAAU,IAAA,OAAO,EAAG,MAAMrB,gBAAgB,CAAE,CAAF;AAA1C,KACG,cAAI,OAAJ,CADH,CARD,CADD,CAHF,EAkBC,sCAAae,UAAb,EAA4Bc,KAA5B,CAlBD,CADD;AAsBA;;AAEc,SAASK,qBAAT,CAAgCC,KAAhC,EAAwC;AAAA;;AACtD,QAAMpB,UAAU,GAAG,iCAAnB;;AACA,MAAK,oBAAEoB,KAAK,CAACnD,OAAR,2CAAE,eAAeC,MAAjB,CAAL,EAA+B;AAC9B,WAAO,mCAAU8B,UAAV,EAAyB3C,WAAW,EAApC,CAAP;AACA;;AACD,SAAO,4BAAC,wBAAD,EAA+B+D,KAA/B,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tMenuItem,\n\tToggleControl,\n\tPanelBody,\n\tPlaceholder,\n\tButton,\n\tTextControl,\n} from '@wordpress/components';\nimport {\n\tInspectorControls,\n\tBlockControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { upload } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport DimensionControls from './dimension-controls';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nconst placeholder = ( content ) => {\n\treturn (\n\t\t<Placeholder\n\t\t\tclassName=\"block-editor-media-placeholder\"\n\t\t\twithIllustration={ true }\n\t\t>\n\t\t\t{ content }\n\t\t</Placeholder>\n\t);\n};\n\nfunction getMediaSourceUrlBySizeSlug( media, slug ) {\n\treturn (\n\t\tmedia?.media_details?.sizes?.[ slug ]?.source_url || media?.source_url\n\t);\n}\n\nfunction PostFeaturedImageDisplay( {\n\tclientId,\n\tattributes,\n\tsetAttributes,\n\tcontext: { postId, postType: postTypeSlug, queryId },\n} ) {\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst { isLink, height, width, scale, sizeSlug, rel, linkTarget } =\n\t\tattributes;\n\tconst [ featuredImage, setFeaturedImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostTypeSlug,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\n\tconst { media, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getMedia, getPostType } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tmedia:\n\t\t\t\t\tfeaturedImage &&\n\t\t\t\t\tgetMedia( featuredImage, {\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t} ),\n\t\t\t\tpostType: postTypeSlug && getPostType( postTypeSlug ),\n\t\t\t};\n\t\t},\n\t\t[ featuredImage, postTypeSlug ]\n\t);\n\tconst mediaUrl = getMediaSourceUrlBySizeSlug( media, sizeSlug );\n\n\tconst imageSizes = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().imageSizes,\n\t\t[]\n\t);\n\tconst imageSizeOptions = imageSizes\n\t\t.filter( ( { slug } ) => {\n\t\t\treturn media?.media_details?.sizes?.[ slug ]?.source_url;\n\t\t} )\n\t\t.map( ( { name, slug } ) => ( {\n\t\t\tvalue: slug,\n\t\t\tlabel: name,\n\t\t} ) );\n\n\tconst blockProps = useBlockProps( {\n\t\tstyle: { width, height },\n\t} );\n\n\tconst onSelectImage = ( value ) => {\n\t\tif ( value?.id ) {\n\t\t\tsetFeaturedImage( value.id );\n\t\t}\n\t};\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst controls = (\n\t\t<>\n\t\t\t<DimensionControls\n\t\t\t\tclientId={ clientId }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\timageSizeOptions={ imageSizeOptions }\n\t\t\t/>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tpostType?.labels.singular_name\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"post\".\n\t\t\t\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\t\t\t\tpostType.labels.singular_name.toLowerCase()\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __( 'Link to post' )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonChange={ () => setAttributes( { isLink: ! isLink } ) }\n\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t/>\n\t\t\t\t\t{ isLink && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlinkTarget: value ? '_blank' : '_self',\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\t\t\tvalue={ rel }\n\t\t\t\t\t\t\t\tonChange={ ( newRel ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { rel: newRel } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\tlet image;\n\tif ( ! featuredImage && isDescendentOfQueryLoop ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ controls }\n\t\t\t\t<div { ...blockProps }>{ placeholder() }</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tconst label = __( 'Add a featured image' );\n\n\tif ( ! featuredImage ) {\n\t\timage = (\n\t\t\t<MediaPlaceholder\n\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\taccept=\"image/*\"\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tonError={ onUploadError }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t\tmediaLibraryButton={ ( { open } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\ttooltipPosition=\"top center\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t} }\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} else {\n\t\t// We have a Featured image so show a Placeholder if is loading.\n\t\timage = ! media ? (\n\t\t\tplaceholder()\n\t\t) : (\n\t\t\t<img\n\t\t\t\tsrc={ mediaUrl }\n\t\t\t\talt={\n\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The image's alt text.\n\t\t\t\t\t\t\t\t__( 'Featured image: %s' ),\n\t\t\t\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Featured image' )\n\t\t\t\t}\n\t\t\t\tstyle={ { height, objectFit: height && scale } }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ controls }\n\t\t\t{ !! media && ! isDescendentOfQueryLoop && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\tmediaId={ featuredImage }\n\t\t\t\t\t\tmediaURL={ mediaUrl }\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t>\n\t\t\t\t\t\t<MenuItem onClick={ () => setFeaturedImage( 0 ) }>\n\t\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MediaReplaceFlow>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<figure { ...blockProps }>{ image }</figure>\n\t\t</>\n\t);\n}\n\nexport default function PostFeaturedImageEdit( props ) {\n\tconst blockProps = useBlockProps();\n\tif ( ! props.context?.postId ) {\n\t\treturn <div { ...blockProps }>{ placeholder() }</div>;\n\t}\n\treturn <PostFeaturedImageDisplay { ...props } />;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-featured-image/edit.js"],"names":["ALLOWED_MEDIA_TYPES","getMediaSourceUrlBySizeSlug","media","slug","media_details","sizes","source_url","PostFeaturedImageDisplay","clientId","attributes","setAttributes","context","postId","postType","postTypeSlug","queryId","isDescendentOfQueryLoop","Number","isFinite","isLink","height","width","scale","sizeSlug","rel","linkTarget","featuredImage","setFeaturedImage","select","getMedia","getPostType","coreStore","mediaUrl","imageSizes","blockEditorStore","getSettings","imageSizeOptions","filter","map","name","value","label","blockProps","style","borderProps","placeholder","content","className","onSelectImage","id","createErrorNotice","noticesStore","onUploadError","message","type","controls","labels","singular_name","toLowerCase","newRel","image","imageStyles","objectFit","open","upload","alt_text","PostFeaturedImageEdit","props"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AAQA;;AASA;;AACA;;AACA;;AAKA;;AAlCA;AACA;AACA;;AAGA;AACA;AACA;;AAwBA;AACA;AACA;AAGA,MAAMA,mBAAmB,GAAG,CAAE,OAAF,CAA5B;;AAEA,SAASC,2BAAT,CAAsCC,KAAtC,EAA6CC,IAA7C,EAAoD;AAAA;;AACnD,SACC,CAAAD,KAAK,SAAL,IAAAA,KAAK,WAAL,oCAAAA,KAAK,CAAEE,aAAP,uGAAsBC,KAAtB,0GAA+BF,IAA/B,mFAAuCG,UAAvC,MAAqDJ,KAArD,aAAqDA,KAArD,uBAAqDA,KAAK,CAAEI,UAA5D,CADD;AAGA;;AAED,SAASC,wBAAT,OAKI;AAAA,MAL+B;AAClCC,IAAAA,QADkC;AAElCC,IAAAA,UAFkC;AAGlCC,IAAAA,aAHkC;AAIlCC,IAAAA,OAAO,EAAE;AAAEC,MAAAA,MAAF;AAAUC,MAAAA,QAAQ,EAAEC,YAApB;AAAkCC,MAAAA;AAAlC;AAJyB,GAK/B;AACH,QAAMC,uBAAuB,GAAGC,MAAM,CAACC,QAAP,CAAiBH,OAAjB,CAAhC;AACA,QAAM;AAAEI,IAAAA,MAAF;AAAUC,IAAAA,MAAV;AAAkBC,IAAAA,KAAlB;AAAyBC,IAAAA,KAAzB;AAAgCC,IAAAA,QAAhC;AAA0CC,IAAAA,GAA1C;AAA+CC,IAAAA;AAA/C,MACLhB,UADD;AAEA,QAAM,CAAEiB,aAAF,EAAiBC,gBAAjB,IAAsC,6BAC3C,UAD2C,EAE3Cb,YAF2C,EAG3C,gBAH2C,EAI3CF,MAJ2C,CAA5C;AAOA,QAAM;AAAEV,IAAAA,KAAF;AAASW,IAAAA;AAAT,MAAsB,qBACzBe,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,QAA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AAS,EAAG,yBACX,gCADW,EAEXE,WAAW,CAACG,SAFD,CADb;AAKC,MAAA,gBAAgB,EAAG,IALpB;AAMC,MAAA,KAAK,EAAGH,WAAW,CAACD;AANrB,MADD,CADD;AAYA;;AACD,SAAO,4BAAC,wBAAD,EAA+BwB,KAA/B,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tMenuItem,\n\tToggleControl,\n\tPanelBody,\n\tPlaceholder,\n\tButton,\n\tTextControl,\n} from '@wordpress/components';\nimport {\n\tInspectorControls,\n\tBlockControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBorderProps as useBorderProps,\n} from '@wordpress/block-editor';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { upload } from '@wordpress/icons';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport DimensionControls from './dimension-controls';\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nfunction getMediaSourceUrlBySizeSlug( media, slug ) {\n\treturn (\n\t\tmedia?.media_details?.sizes?.[ slug ]?.source_url || media?.source_url\n\t);\n}\n\nfunction PostFeaturedImageDisplay( {\n\tclientId,\n\tattributes,\n\tsetAttributes,\n\tcontext: { postId, postType: postTypeSlug, queryId },\n} ) {\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst { isLink, height, width, scale, sizeSlug, rel, linkTarget } =\n\t\tattributes;\n\tconst [ featuredImage, setFeaturedImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostTypeSlug,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\n\tconst { media, postType } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getMedia, getPostType } = select( coreStore );\n\t\t\treturn {\n\t\t\t\tmedia:\n\t\t\t\t\tfeaturedImage &&\n\t\t\t\t\tgetMedia( featuredImage, {\n\t\t\t\t\t\tcontext: 'view',\n\t\t\t\t\t} ),\n\t\t\t\tpostType: postTypeSlug && getPostType( postTypeSlug ),\n\t\t\t};\n\t\t},\n\t\t[ featuredImage, postTypeSlug ]\n\t);\n\tconst mediaUrl = getMediaSourceUrlBySizeSlug( media, sizeSlug );\n\n\tconst imageSizes = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().imageSizes,\n\t\t[]\n\t);\n\tconst imageSizeOptions = imageSizes\n\t\t.filter( ( { slug } ) => {\n\t\t\treturn media?.media_details?.sizes?.[ slug ]?.source_url;\n\t\t} )\n\t\t.map( ( { name, slug } ) => ( {\n\t\t\tvalue: slug,\n\t\t\tlabel: name,\n\t\t} ) );\n\n\tconst blockProps = useBlockProps( {\n\t\tstyle: { width, height },\n\t} );\n\tconst borderProps = useBorderProps( attributes );\n\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder\n\t\t\t\tclassName={ classnames(\n\t\t\t\t\t'block-editor-media-placeholder',\n\t\t\t\t\tborderProps.className\n\t\t\t\t) }\n\t\t\t\twithIllustration={ true }\n\t\t\t\tstyle={ borderProps.style }\n\t\t\t>\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst onSelectImage = ( value ) => {\n\t\tif ( value?.id ) {\n\t\t\tsetFeaturedImage( value.id );\n\t\t}\n\t};\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message, { type: 'snackbar' } );\n\t};\n\n\tconst controls = (\n\t\t<>\n\t\t\t<DimensionControls\n\t\t\t\tclientId={ clientId }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\timageSizeOptions={ imageSizeOptions }\n\t\t\t/>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tpostType?.labels.singular_name\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"post\".\n\t\t\t\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\t\t\t\tpostType.labels.singular_name.toLowerCase()\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __( 'Link to post' )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonChange={ () => setAttributes( { isLink: ! isLink } ) }\n\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t/>\n\t\t\t\t\t{ isLink && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Open in new tab' ) }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\t\t\tlinkTarget: value ? '_blank' : '_self',\n\t\t\t\t\t\t\t\t\t} )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tchecked={ linkTarget === '_blank' }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\t\t\tvalue={ rel }\n\t\t\t\t\t\t\t\tonChange={ ( newRel ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { rel: newRel } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\tlet image;\n\tif ( ! featuredImage && isDescendentOfQueryLoop ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ controls }\n\t\t\t\t<div { ...blockProps }>{ placeholder() }</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tconst label = __( 'Add a featured image' );\n\tconst imageStyles = {\n\t\t...borderProps.style,\n\t\theight,\n\t\tobjectFit: height && scale,\n\t};\n\n\tif ( ! featuredImage ) {\n\t\timage = (\n\t\t\t<MediaPlaceholder\n\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\taccept=\"image/*\"\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tonError={ onUploadError }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t\tmediaLibraryButton={ ( { open } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\ttooltipPosition=\"top center\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t} }\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} else {\n\t\t// We have a Featured image so show a Placeholder if is loading.\n\t\timage = ! media ? (\n\t\t\tplaceholder()\n\t\t) : (\n\t\t\t<img\n\t\t\t\tclassName={ borderProps.className }\n\t\t\t\tsrc={ mediaUrl }\n\t\t\t\talt={\n\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The image's alt text.\n\t\t\t\t\t\t\t\t__( 'Featured image: %s' ),\n\t\t\t\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Featured image' )\n\t\t\t\t}\n\t\t\t\tstyle={ imageStyles }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ controls }\n\t\t\t{ !! media && ! isDescendentOfQueryLoop && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\tmediaId={ featuredImage }\n\t\t\t\t\t\tmediaURL={ mediaUrl }\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t>\n\t\t\t\t\t\t<MenuItem onClick={ () => setFeaturedImage( 0 ) }>\n\t\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MediaReplaceFlow>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<figure { ...blockProps }>{ image }</figure>\n\t\t</>\n\t);\n}\n\nexport default function PostFeaturedImageEdit( props ) {\n\tconst blockProps = useBlockProps();\n\tconst borderProps = useBorderProps( props.attributes );\n\n\tif ( ! props.context?.postId ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Placeholder\n\t\t\t\t\tclassName={ classnames(\n\t\t\t\t\t\t'block-editor-media-placeholder',\n\t\t\t\t\t\tborderProps.className\n\t\t\t\t\t) }\n\t\t\t\t\twithIllustration={ true }\n\t\t\t\t\tstyle={ borderProps.style }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\treturn <PostFeaturedImageDisplay { ...props } />;\n}\n"]}
|
|
@@ -62,6 +62,18 @@ const metadata = {
|
|
|
62
62
|
text: false,
|
|
63
63
|
background: false
|
|
64
64
|
},
|
|
65
|
+
__experimentalBorder: {
|
|
66
|
+
color: true,
|
|
67
|
+
radius: true,
|
|
68
|
+
width: true,
|
|
69
|
+
__experimentalSelector: "img, .block-editor-media-placeholder",
|
|
70
|
+
__experimentalSkipSerialization: true,
|
|
71
|
+
__experimentalDefaultControls: {
|
|
72
|
+
color: true,
|
|
73
|
+
radius: true,
|
|
74
|
+
width: true
|
|
75
|
+
}
|
|
76
|
+
},
|
|
65
77
|
html: false,
|
|
66
78
|
spacing: {
|
|
67
79
|
margin: true,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-featured-image/index.js"],"names":["name","metadata","settings","icon","edit"],"mappings":";;;;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;;AAGA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-featured-image/index.js"],"names":["name","metadata","settings","icon","edit"],"mappings":";;;;;;;;;AAGA;;AAMA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,wBADuB;AAEvBC,EAAAA,IAAI,EAAJA;AAFuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { postFeaturedImage as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n};\n"]}
|
|
@@ -52,10 +52,11 @@ const metadata = {
|
|
|
52
52
|
fontSize: true,
|
|
53
53
|
lineHeight: true,
|
|
54
54
|
__experimentalFontFamily: true,
|
|
55
|
-
__experimentalFontStyle: true,
|
|
56
55
|
__experimentalFontWeight: true,
|
|
57
|
-
|
|
56
|
+
__experimentalFontStyle: true,
|
|
58
57
|
__experimentalTextTransform: true,
|
|
58
|
+
__experimentalTextDecoration: true,
|
|
59
|
+
__experimentalLetterSpacing: true,
|
|
59
60
|
__experimentalDefaultControls: {
|
|
60
61
|
fontSize: true
|
|
61
62
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-navigation-link/index.js"],"names":["name","metadata","settings","edit","variations"],"mappings":";;;;;;;;;AAIA;;AACA;;AALA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-navigation-link/index.js"],"names":["name","metadata","settings","edit","variations"],"mappings":";;;;;;;;;AAIA;;AACA;;AALA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,aADuB;AAEvBC,EAAAA,UAAU,EAAVA;AAFuB,CAAjB","sourcesContent":["/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport variations from './variations';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\tedit,\n\tvariations,\n};\n"]}
|
|
@@ -99,7 +99,8 @@ function PostTemplateEdit(_ref2) {
|
|
|
99
99
|
displayLayout: {
|
|
100
100
|
type: layoutType = 'flex',
|
|
101
101
|
columns = 1
|
|
102
|
-
} = {}
|
|
102
|
+
} = {},
|
|
103
|
+
previewPostType
|
|
103
104
|
}
|
|
104
105
|
} = _ref2;
|
|
105
106
|
const [{
|
|
@@ -186,13 +187,16 @@ function PostTemplateEdit(_ref2) {
|
|
|
186
187
|
query.postType = templateSlug.replace('archive-', '');
|
|
187
188
|
postType = query.postType;
|
|
188
189
|
}
|
|
189
|
-
}
|
|
190
|
+
} // When we preview Query Loop blocks we should prefer the current
|
|
191
|
+
// block's postType, which is passed through block context.
|
|
192
|
+
|
|
190
193
|
|
|
194
|
+
const usedPostType = previewPostType || postType;
|
|
191
195
|
return {
|
|
192
|
-
posts: getEntityRecords('postType',
|
|
196
|
+
posts: getEntityRecords('postType', usedPostType, query),
|
|
193
197
|
blocks: getBlocks(clientId)
|
|
194
198
|
};
|
|
195
|
-
}, [perPage, page, offset, order, orderBy, clientId, author, search, postType, exclude, sticky, inherit, templateSlug, taxQuery, parents]);
|
|
199
|
+
}, [perPage, page, offset, order, orderBy, clientId, author, search, postType, exclude, sticky, inherit, templateSlug, taxQuery, parents, previewPostType]);
|
|
196
200
|
const blockContexts = (0, _element.useMemo)(() => posts === null || posts === void 0 ? void 0 : posts.map(post => ({
|
|
197
201
|
postType: post.type,
|
|
198
202
|
postId: post.id
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-template/edit.js"],"names":["TEMPLATE","PostTemplateInnerBlocks","innerBlocksProps","className","template","PostTemplateBlockPreview","blocks","blockContextId","isHidden","setActiveBlockContextId","blockPreviewProps","props","handleOnClick","style","display","undefined","MemoizedPostTemplateBlockPreview","PostTemplateEdit","clientId","context","query","perPage","offset","postType","order","orderBy","author","search","exclude","sticky","inherit","taxQuery","parents","queryContext","page","templateSlug","displayLayout","type","layoutType","columns","activeBlockContextId","posts","select","getEntityRecords","getTaxonomies","coreStore","getBlocks","blockEditorStore","taxonomies","per_page","orderby","builtTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","taxonomy","find","slug","rest_base","keys","length","assign","parent","startsWith","replace","blockContexts","map","post","postId","id","hasLayoutFlex","blockProps","blockContext"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAMA;;AACA;;AACA;;AAOA;;AACA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;AAcA,MAAMA,QAAQ,GAAG,CAChB,CAAE,iBAAF,CADgB,EAEhB,CAAE,gBAAF,CAFgB,EAGhB,CAAE,mBAAF,CAHgB,CAAjB;;AAMA,SAASC,uBAAT,GAAmC;AAClC,QAAMC,gBAAgB,GAAG,sCACxB;AAAEC,IAAAA,SAAS,EAAE;AAAb,GADwB,EAExB;AAAEC,IAAAA,QAAQ,EAAEJ;AAAZ,GAFwB,CAAzB;AAIA,SAAO,kCAASE,gBAAT,CAAP;AACA;;AAED,SAASG,wBAAT,OAKI;AAAA,MAL+B;AAClCC,IAAAA,MADkC;AAElCC,IAAAA,cAFkC;AAGlCC,IAAAA,QAHkC;AAIlCC,IAAAA;AAJkC,G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D,4BAAC,uBAAD,OAHC,GAIE,IARL,EASC,4BAAC,gCAAD;AACC,MAAA,MAAM,EAAGjE,MADV;AAEC,MAAA,cAAc,EAAGqE,YAAY,CAACJ,MAF/B;AAGC,MAAA,uBAAuB,EAAG9D,uBAH3B;AAIC,MAAA,QAAQ,EACPkE,YAAY,CAACJ,MAAb,MACE/B,oBAAoB,yBACrB4B,aAAa,CAAE,CAAF,CADQ,qDACrB,iBAAoBG,MADC,CADtB;AALF,MATD,CADkB;AAAA,GAAnB,CAFF,CADD;AA2BA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { memo, useMemo, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\t__experimentalUseBlockPreview as useBlockPreview,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\nconst TEMPLATE = [\n\t[ 'core/post-title' ],\n\t[ 'core/post-date' ],\n\t[ 'core/post-excerpt' ],\n];\n\nfunction PostTemplateInnerBlocks() {\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ className: 'wp-block-post' },\n\t\t{ template: TEMPLATE }\n\t);\n\treturn <li { ...innerBlocksProps } />;\n}\n\nfunction PostTemplateBlockPreview( {\n\tblocks,\n\tblockContextId,\n\tisHidden,\n\tsetActiveBlockContextId,\n} ) {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t\tprops: {\n\t\t\tclassName: 'wp-block-post',\n\t\t},\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveBlockContextId( blockContextId );\n\t};\n\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<li\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\trole=\"button\"\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\nconst MemoizedPostTemplateBlockPreview = memo( PostTemplateBlockPreview );\n\nexport default function PostTemplateEdit( {\n\tclientId,\n\tcontext: {\n\t\tquery: {\n\t\t\tperPage,\n\t\t\toffset,\n\t\t\tpostType,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t} = {},\n\t\tqueryContext = [ { page: 1 } ],\n\t\ttemplateSlug,\n\t\tdisplayLayout: { type: layoutType = 'flex', columns = 1 } = {},\n\t},\n} ) {\n\tconst [ { page } ] = queryContext;\n\tconst [ activeBlockContextId, setActiveBlockContextId ] = useState();\n\n\tconst { posts, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, getTaxonomies } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\tconst taxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\tconst query = {\n\t\t\t\toffset: perPage ? perPage * ( page - 1 ) + offset : 0,\n\t\t\t\torder,\n\t\t\t\torderby: orderBy,\n\t\t\t};\n\t\t\tif ( taxQuery ) {\n\t\t\t\t// We have to build the tax query for the REST API and use as\n\t\t\t\t// keys the taxonomies `rest_base` with the `term ids` as values.\n\t\t\t\tconst builtTaxQuery = Object.entries( taxQuery ).reduce(\n\t\t\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\t\t\tconst taxonomy = taxonomies?.find(\n\t\t\t\t\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( taxonomy?.rest_base ) {\n\t\t\t\t\t\t\taccumulator[ taxonomy?.rest_base ] = terms;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn accumulator;\n\t\t\t\t\t},\n\t\t\t\t\t{}\n\t\t\t\t);\n\t\t\t\tif ( !! Object.keys( builtTaxQuery ).length ) {\n\t\t\t\t\tObject.assign( query, builtTaxQuery );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( perPage ) {\n\t\t\t\tquery.per_page = perPage;\n\t\t\t}\n\t\t\tif ( author ) {\n\t\t\t\tquery.author = author;\n\t\t\t}\n\t\t\tif ( search ) {\n\t\t\t\tquery.search = search;\n\t\t\t}\n\t\t\tif ( exclude?.length ) {\n\t\t\t\tquery.exclude = exclude;\n\t\t\t}\n\t\t\tif ( parents?.length ) {\n\t\t\t\tquery.parent = parents;\n\t\t\t}\n\t\t\t// If sticky is not set, it will return all posts in the results.\n\t\t\t// If sticky is set to `only`, it will limit the results to sticky posts only.\n\t\t\t// If it is anything else, it will exclude sticky posts from results. For the record the value stored is `exclude`.\n\t\t\tif ( sticky ) {\n\t\t\t\tquery.sticky = sticky === 'only';\n\t\t\t}\n\t\t\t// If `inherit` is truthy, adjust conditionally the query to create a better preview.\n\t\t\tif ( inherit ) {\n\t\t\t\t// Change the post-type if needed.\n\t\t\t\tif ( templateSlug?.startsWith( 'archive-' ) ) {\n\t\t\t\t\tquery.postType = templateSlug.replace( 'archive-', '' );\n\t\t\t\t\tpostType = query.postType;\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tposts: getEntityRecords( 'postType', postType, query ),\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tperPage,\n\t\t\tpage,\n\t\t\toffset,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tclientId,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\tpostType,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttemplateSlug,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t]\n\t);\n\tconst blockContexts = useMemo(\n\t\t() =>\n\t\t\tposts?.map( ( post ) => ( {\n\t\t\t\tpostType: post.type,\n\t\t\t\tpostId: post.id,\n\t\t\t} ) ),\n\t\t[ posts ]\n\t);\n\tconst hasLayoutFlex = layoutType === 'flex' && columns > 1;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t'is-flex-container': hasLayoutFlex,\n\t\t\t[ `columns-${ columns }` ]: hasLayoutFlex,\n\t\t} ),\n\t} );\n\n\tif ( ! posts ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! posts.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No results found.' ) }</p>;\n\t}\n\n\t// To avoid flicker when switching active block contexts, a preview is rendered\n\t// for each block context, but the preview for the active block context is hidden.\n\t// This ensures that when it is displayed again, the cached rendering of the\n\t// block preview is used, instead of having to re-render the preview from scratch.\n\treturn (\n\t\t<ul { ...blockProps }>\n\t\t\t{ blockContexts &&\n\t\t\t\tblockContexts.map( ( blockContext ) => (\n\t\t\t\t\t<BlockContextProvider\n\t\t\t\t\t\tkey={ blockContext.postId }\n\t\t\t\t\t\tvalue={ blockContext }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ blockContext.postId ===\n\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId ) ? (\n\t\t\t\t\t\t\t<PostTemplateInnerBlocks />\n\t\t\t\t\t\t) : null }\n\t\t\t\t\t\t<MemoizedPostTemplateBlockPreview\n\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\tblockContextId={ blockContext.postId }\n\t\t\t\t\t\t\tsetActiveBlockContextId={ setActiveBlockContextId }\n\t\t\t\t\t\t\tisHidden={\n\t\t\t\t\t\t\t\tblockContext.postId ===\n\t\t\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-template/edit.js"],"names":["TEMPLATE","PostTemplateInnerBlocks","innerBlocksProps","className","template","PostTemplateBlockPreview","blocks","blockContextId","isHidden","setActiveBlockContextId","blockPreviewProps","props","handleOnClick","style","display","undefined","MemoizedPostTemplateBlockPreview","PostTemplateEdit","clientId","context","query","perPage","offset","postType","order","orderBy","author","search","exclude","sticky","inherit","taxQuery","parents","queryContext","page","templateSlug","displayLayout","type","layoutType","columns","previewPostType","activeBlockContextId","posts","select","getEntityRecords","getTaxonomies","coreStore","getBlocks","blockEditorStore","taxonomies","per_page","orderby","builtTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","taxonomy","find","slug","rest_base","keys","length","assign","parent","startsWith","replace","usedPostType","blockContexts","map","post","postId","id","hasLayoutFlex","blockProps","blockContext"],"mappings":";;;;;;;;;AAQA;;;;AALA;;AAMA;;AACA;;AACA;;AAOA;;AACA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;AAcA,MAAMA,QAAQ,GAAG,CAChB,CAAE,iBAAF,CADgB,EAEhB,CAAE,gBAAF,CAFgB,EAGhB,CAAE,mBAAF,CAHgB,CAAjB;;AAMA,SAASC,uBAAT,GAAmC;AAClC,QAAMC,gBAAgB,GAAG,sCACxB;AAAEC,IAAAA,SAAS,EAAE;AAAb,GADwB,EAExB;AAAEC,IAAAA,QAAQ,EAAEJ;AAAZ,GAFwB,CAAzB;AAIA,SAAO,kCAASE,gBAAT,CAAP;AACA;;AAED,SAASG,wBAAT,OAKI;AAAA,MAL+B;AAClCC,IAAAA,MADkC;AAElCC,IAAAA,cAFkC;AAGlCC,IAAAA,QAHkC;AAIlCC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A,KAAK,EAAGI;AAFT,OAIGA,YAAY,CAACJ,MAAb,MACAhC,oBAAoB,wBACrB6B,aAAa,CAAE,CAAF,CADQ,oDACrB,gBAAoBG,MADC,CADpB,IAGD,4BAAC,uBAAD,OAHC,GAIE,IARL,EASC,4BAAC,gCAAD;AACC,MAAA,MAAM,EAAGnE,MADV;AAEC,MAAA,cAAc,EAAGuE,YAAY,CAACJ,MAF/B;AAGC,MAAA,uBAAuB,EAAGhE,uBAH3B;AAIC,MAAA,QAAQ,EACPoE,YAAY,CAACJ,MAAb,MACEhC,oBAAoB,yBACrB6B,aAAa,CAAE,CAAF,CADQ,qDACrB,iBAAoBG,MADC,CADtB;AALF,MATD,CADkB;AAAA,GAAnB,CAFF,CADD;AA2BA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { memo, useMemo, useState } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\t__experimentalUseBlockPreview as useBlockPreview,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\nconst TEMPLATE = [\n\t[ 'core/post-title' ],\n\t[ 'core/post-date' ],\n\t[ 'core/post-excerpt' ],\n];\n\nfunction PostTemplateInnerBlocks() {\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{ className: 'wp-block-post' },\n\t\t{ template: TEMPLATE }\n\t);\n\treturn <li { ...innerBlocksProps } />;\n}\n\nfunction PostTemplateBlockPreview( {\n\tblocks,\n\tblockContextId,\n\tisHidden,\n\tsetActiveBlockContextId,\n} ) {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t\tprops: {\n\t\t\tclassName: 'wp-block-post',\n\t\t},\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveBlockContextId( blockContextId );\n\t};\n\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<li\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\trole=\"button\"\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t\tstyle={ style }\n\t\t/>\n\t);\n}\n\nconst MemoizedPostTemplateBlockPreview = memo( PostTemplateBlockPreview );\n\nexport default function PostTemplateEdit( {\n\tclientId,\n\tcontext: {\n\t\tquery: {\n\t\t\tperPage,\n\t\t\toffset,\n\t\t\tpostType,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t} = {},\n\t\tqueryContext = [ { page: 1 } ],\n\t\ttemplateSlug,\n\t\tdisplayLayout: { type: layoutType = 'flex', columns = 1 } = {},\n\t\tpreviewPostType,\n\t},\n} ) {\n\tconst [ { page } ] = queryContext;\n\tconst [ activeBlockContextId, setActiveBlockContextId ] = useState();\n\n\tconst { posts, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords, getTaxonomies } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\t\t\tconst taxonomies = getTaxonomies( {\n\t\t\t\ttype: postType,\n\t\t\t\tper_page: -1,\n\t\t\t\tcontext: 'view',\n\t\t\t} );\n\t\t\tconst query = {\n\t\t\t\toffset: perPage ? perPage * ( page - 1 ) + offset : 0,\n\t\t\t\torder,\n\t\t\t\torderby: orderBy,\n\t\t\t};\n\t\t\tif ( taxQuery ) {\n\t\t\t\t// We have to build the tax query for the REST API and use as\n\t\t\t\t// keys the taxonomies `rest_base` with the `term ids` as values.\n\t\t\t\tconst builtTaxQuery = Object.entries( taxQuery ).reduce(\n\t\t\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\t\t\tconst taxonomy = taxonomies?.find(\n\t\t\t\t\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( taxonomy?.rest_base ) {\n\t\t\t\t\t\t\taccumulator[ taxonomy?.rest_base ] = terms;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn accumulator;\n\t\t\t\t\t},\n\t\t\t\t\t{}\n\t\t\t\t);\n\t\t\t\tif ( !! Object.keys( builtTaxQuery ).length ) {\n\t\t\t\t\tObject.assign( query, builtTaxQuery );\n\t\t\t\t}\n\t\t\t}\n\t\t\tif ( perPage ) {\n\t\t\t\tquery.per_page = perPage;\n\t\t\t}\n\t\t\tif ( author ) {\n\t\t\t\tquery.author = author;\n\t\t\t}\n\t\t\tif ( search ) {\n\t\t\t\tquery.search = search;\n\t\t\t}\n\t\t\tif ( exclude?.length ) {\n\t\t\t\tquery.exclude = exclude;\n\t\t\t}\n\t\t\tif ( parents?.length ) {\n\t\t\t\tquery.parent = parents;\n\t\t\t}\n\t\t\t// If sticky is not set, it will return all posts in the results.\n\t\t\t// If sticky is set to `only`, it will limit the results to sticky posts only.\n\t\t\t// If it is anything else, it will exclude sticky posts from results. For the record the value stored is `exclude`.\n\t\t\tif ( sticky ) {\n\t\t\t\tquery.sticky = sticky === 'only';\n\t\t\t}\n\t\t\t// If `inherit` is truthy, adjust conditionally the query to create a better preview.\n\t\t\tif ( inherit ) {\n\t\t\t\t// Change the post-type if needed.\n\t\t\t\tif ( templateSlug?.startsWith( 'archive-' ) ) {\n\t\t\t\t\tquery.postType = templateSlug.replace( 'archive-', '' );\n\t\t\t\t\tpostType = query.postType;\n\t\t\t\t}\n\t\t\t}\n\t\t\t// When we preview Query Loop blocks we should prefer the current\n\t\t\t// block's postType, which is passed through block context.\n\t\t\tconst usedPostType = previewPostType || postType;\n\t\t\treturn {\n\t\t\t\tposts: getEntityRecords( 'postType', usedPostType, query ),\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[\n\t\t\tperPage,\n\t\t\tpage,\n\t\t\toffset,\n\t\t\torder,\n\t\t\torderBy,\n\t\t\tclientId,\n\t\t\tauthor,\n\t\t\tsearch,\n\t\t\tpostType,\n\t\t\texclude,\n\t\t\tsticky,\n\t\t\tinherit,\n\t\t\ttemplateSlug,\n\t\t\ttaxQuery,\n\t\t\tparents,\n\t\t\tpreviewPostType,\n\t\t]\n\t);\n\tconst blockContexts = useMemo(\n\t\t() =>\n\t\t\tposts?.map( ( post ) => ( {\n\t\t\t\tpostType: post.type,\n\t\t\t\tpostId: post.id,\n\t\t\t} ) ),\n\t\t[ posts ]\n\t);\n\tconst hasLayoutFlex = layoutType === 'flex' && columns > 1;\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t'is-flex-container': hasLayoutFlex,\n\t\t\t[ `columns-${ columns }` ]: hasLayoutFlex,\n\t\t} ),\n\t} );\n\n\tif ( ! posts ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! posts.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No results found.' ) }</p>;\n\t}\n\n\t// To avoid flicker when switching active block contexts, a preview is rendered\n\t// for each block context, but the preview for the active block context is hidden.\n\t// This ensures that when it is displayed again, the cached rendering of the\n\t// block preview is used, instead of having to re-render the preview from scratch.\n\treturn (\n\t\t<ul { ...blockProps }>\n\t\t\t{ blockContexts &&\n\t\t\t\tblockContexts.map( ( blockContext ) => (\n\t\t\t\t\t<BlockContextProvider\n\t\t\t\t\t\tkey={ blockContext.postId }\n\t\t\t\t\t\tvalue={ blockContext }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ blockContext.postId ===\n\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId ) ? (\n\t\t\t\t\t\t\t<PostTemplateInnerBlocks />\n\t\t\t\t\t\t) : null }\n\t\t\t\t\t\t<MemoizedPostTemplateBlockPreview\n\t\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\t\tblockContextId={ blockContext.postId }\n\t\t\t\t\t\t\tsetActiveBlockContextId={ setActiveBlockContextId }\n\t\t\t\t\t\t\tisHidden={\n\t\t\t\t\t\t\t\tblockContext.postId ===\n\t\t\t\t\t\t\t\t( activeBlockContextId ||\n\t\t\t\t\t\t\t\t\tblockContexts[ 0 ]?.postId )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n"]}
|
|
@@ -29,13 +29,26 @@ const metadata = {
|
|
|
29
29
|
parent: ["core/query"],
|
|
30
30
|
description: "Contains the block elements used to render a post, like the title, date, featured image, content or excerpt, and more.",
|
|
31
31
|
textdomain: "default",
|
|
32
|
-
usesContext: ["queryId", "query", "queryContext", "displayLayout", "templateSlug"],
|
|
32
|
+
usesContext: ["queryId", "query", "queryContext", "displayLayout", "templateSlug", "previewPostType"],
|
|
33
33
|
supports: {
|
|
34
34
|
reusable: false,
|
|
35
35
|
html: false,
|
|
36
36
|
align: true,
|
|
37
37
|
__experimentalLayout: {
|
|
38
38
|
allowEditing: false
|
|
39
|
+
},
|
|
40
|
+
typography: {
|
|
41
|
+
fontSize: true,
|
|
42
|
+
lineHeight: true,
|
|
43
|
+
__experimentalFontFamily: true,
|
|
44
|
+
__experimentalFontWeight: true,
|
|
45
|
+
__experimentalFontStyle: true,
|
|
46
|
+
__experimentalTextTransform: true,
|
|
47
|
+
__experimentalTextDecoration: true,
|
|
48
|
+
__experimentalLetterSpacing: true,
|
|
49
|
+
__experimentalDefaultControls: {
|
|
50
|
+
fontSize: true
|
|
51
|
+
}
|
|
39
52
|
}
|
|
40
53
|
},
|
|
41
54
|
style: "wp-block-post-template",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-template/index.js"],"names":["name","metadata","settings","icon","layout","edit","save"],"mappings":";;;;;;;;;AAGA;;AAMA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-template/index.js"],"names":["name","metadata","settings","icon","layout","edit","save"],"mappings":";;;;;;;;;AAGA;;AAMA;;AACA;;AAVA;AACA;AACA;;AAGA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAEC,aADiB;AAEvBC,EAAAA,IAAI,EAAJA,aAFuB;AAGvBC,EAAAA,IAAI,EAAJA;AAHuB,CAAjB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { layout } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon: layout,\n\tedit,\n\tsave,\n};\n"]}
|