@wordpress/block-library 7.12.0 → 7.13.1-next.957ca95e4c.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/columns/transforms.js +10 -1
- package/build/columns/transforms.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/edit/block-controls.js +9 -2
- package/build/cover/edit/block-controls.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/gap-styles.js +5 -4
- package/build/gallery/gap-styles.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/home-link/index.js +14 -1
- package/build/home-link/index.js.map +1 -1
- package/build/image/edit.js +16 -2
- 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/image/use-client-width.js +3 -1
- package/build/image/use-client-width.js.map +1 -1
- package/build/index.js +1 -1
- package/build/index.js.map +1 -1
- package/build/index.native.js +9 -18
- package/build/index.native.js.map +1 -1
- package/build/latest-posts/deprecated.js +14 -1
- package/build/latest-posts/deprecated.js.map +1 -1
- package/build/latest-posts/index.js +14 -1
- package/build/latest-posts/index.js.map +1 -1
- package/build/list/deprecated.js +84 -1
- package/build/list/deprecated.js.map +1 -1
- package/build/list/edit.js +153 -134
- package/build/list/edit.js.map +1 -1
- package/build/list/index.js +33 -34
- package/build/list/index.js.map +1 -1
- package/build/list/save.js +1 -5
- package/build/list/save.js.map +1 -1
- package/build/list/{v2/tag-name.js → tag-name.js} +0 -0
- package/build/list/tag-name.js.map +1 -0
- package/build/list/{v2/tag-name.native.js → tag-name.native.js} +0 -0
- package/build/list/tag-name.native.js.map +1 -0
- package/build/list/transforms.js +61 -95
- package/build/list/transforms.js.map +1 -1
- package/build/list/{v2/migrate.js → utils.js} +3 -2
- package/build/list/utils.js.map +1 -0
- package/build/list-item/edit.js +3 -1
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/edit.native.js +21 -3
- package/build/list-item/edit.native.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 +44 -0
- package/build/list-item/hooks/use-copy.js.map +1 -0
- package/build/list-item/hooks/use-merge.js +0 -1
- package/build/list-item/hooks/use-merge.js.map +1 -1
- package/build/list-item/hooks/use-outdent-list-item.js +0 -1
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/list-item/hooks/use-space.js +10 -1
- package/build/list-item/hooks/use-space.js.map +1 -1
- package/build/list-item/index.js +0 -1
- package/build/list-item/index.js.map +1 -1
- 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/list-item/utils.js +4 -1
- package/build/list-item/utils.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 +17 -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 +125 -41
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +6 -4
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +6 -16
- 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/index.js +1 -0
- package/build/navigation/index.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 +7 -0
- package/build/paragraph/index.js.map +1 -1
- package/build/paragraph/transforms.js +7 -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-excerpt/index.js +4 -2
- package/build/post-excerpt/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/edit.js +0 -1
- package/build/post-terms/edit.js.map +1 -1
- package/build/post-terms/index.js +5 -3
- package/build/post-terms/index.js.map +1 -1
- package/build/post-terms/use-post-terms.js +4 -24
- package/build/post-terms/use-post-terms.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-no-results/index.js +13 -0
- package/build/query-no-results/index.js.map +1 -1
- package/build/query-pagination-numbers/index.js +4 -2
- package/build/query-pagination-numbers/index.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 +8 -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/index.js +4 -2
- package/build/quote/index.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 +43 -9
- package/build/social-links/edit.js.map +1 -1
- package/build/social-links/index.js +9 -0
- package/build/social-links/index.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 +24 -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 +10 -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 +2 -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/columns/transforms.js +10 -1
- package/build-module/columns/transforms.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/edit/block-controls.js +10 -3
- package/build-module/cover/edit/block-controls.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/gap-styles.js +6 -5
- package/build-module/gallery/gap-styles.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/home-link/index.js +14 -1
- package/build-module/home-link/index.js.map +1 -1
- package/build-module/image/edit.js +18 -4
- 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/image/use-client-width.js +3 -1
- package/build-module/image/use-client-width.js.map +1 -1
- package/build-module/index.js +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +9 -17
- package/build-module/index.native.js.map +1 -1
- package/build-module/latest-posts/deprecated.js +14 -1
- package/build-module/latest-posts/deprecated.js.map +1 -1
- package/build-module/latest-posts/index.js +14 -1
- package/build-module/latest-posts/index.js.map +1 -1
- package/build-module/list/deprecated.js +83 -1
- package/build-module/list/deprecated.js.map +1 -1
- package/build-module/list/edit.js +151 -134
- package/build-module/list/edit.js.map +1 -1
- package/build-module/list/index.js +33 -29
- package/build-module/list/index.js.map +1 -1
- package/build-module/list/save.js +2 -6
- package/build-module/list/save.js.map +1 -1
- package/build-module/list/{v2/tag-name.js → tag-name.js} +0 -0
- package/build-module/list/tag-name.js.map +1 -0
- package/build-module/list/{v2/tag-name.native.js → tag-name.native.js} +0 -0
- package/build-module/list/tag-name.native.js.map +1 -0
- package/build-module/list/transforms.js +62 -97
- package/build-module/list/transforms.js.map +1 -1
- package/build-module/list/{v2/migrate.js → utils.js} +3 -2
- package/build-module/list/utils.js.map +1 -0
- package/build-module/list-item/edit.js +4 -2
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/edit.native.js +19 -3
- package/build-module/list-item/edit.native.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 +34 -0
- package/build-module/list-item/hooks/use-copy.js.map +1 -0
- package/build-module/list-item/hooks/use-merge.js +0 -1
- package/build-module/list-item/hooks/use-merge.js.map +1 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js +0 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/list-item/hooks/use-space.js +10 -1
- package/build-module/list-item/hooks/use-space.js.map +1 -1
- package/build-module/list-item/index.js +0 -1
- package/build-module/list-item/index.js.map +1 -1
- 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/list-item/utils.js +4 -1
- package/build-module/list-item/utils.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 +17 -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 +125 -43
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +6 -4
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +7 -16
- 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/index.js +1 -0
- package/build-module/navigation/index.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 +7 -0
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/paragraph/transforms.js +7 -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-excerpt/index.js +4 -2
- package/build-module/post-excerpt/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/edit.js +0 -1
- package/build-module/post-terms/edit.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-terms/use-post-terms.js +5 -25
- package/build-module/post-terms/use-post-terms.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-no-results/index.js +13 -0
- package/build-module/query-no-results/index.js.map +1 -1
- package/build-module/query-pagination-numbers/index.js +4 -2
- package/build-module/query-pagination-numbers/index.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 +8 -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/index.js +4 -2
- package/build-module/quote/index.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 +45 -12
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/social-links/index.js +9 -0
- package/build-module/social-links/index.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 +24 -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 +10 -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 +2 -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 +7 -10
- package/build-style/button/style.css +7 -10
- package/build-style/code/editor-rtl.css +79 -0
- package/build-style/code/editor.css +79 -0
- package/build-style/cover/editor-rtl.css +0 -3
- package/build-style/cover/editor.css +0 -3
- package/build-style/editor-rtl.css +94 -146
- package/build-style/editor.css +94 -146
- package/build-style/group/editor-rtl.css +9 -10
- package/build-style/group/editor.css +9 -10
- package/build-style/image/editor-rtl.css +21 -2
- package/build-style/image/editor.css +21 -2
- package/build-style/media-text/style-rtl.css +1 -0
- package/build-style/media-text/style.css +1 -0
- package/build-style/navigation/editor-rtl.css +11 -23
- package/build-style/navigation/editor.css +11 -23
- package/build-style/navigation/style-rtl.css +10 -3
- package/build-style/navigation/style.css +10 -3
- 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 +37 -23
- package/build-style/style.css +37 -23
- 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 +7 -14
- 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/code/editor.scss +3 -0
- 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/columns/transforms.js +17 -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/edit/block-controls.js +15 -3
- package/src/cover/editor.scss +0 -4
- package/src/cover/shared.js +2 -1
- package/src/editor.scss +1 -0
- 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/gap-styles.js +10 -6
- package/src/gallery/index.php +23 -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 +4 -6
- 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/block.json +14 -1
- package/src/home-link/edit.js +19 -20
- package/src/image/block.json +13 -7
- package/src/image/edit.js +22 -4
- package/src/image/editor.scss +39 -3
- package/src/image/index.php +1 -1
- package/src/image/use-client-width.js +1 -1
- package/src/index.js +1 -4
- package/src/index.native.js +17 -23
- package/src/latest-posts/block.json +14 -1
- package/src/list/block.json +4 -0
- package/src/list/deprecated.js +71 -1
- package/src/list/edit.js +146 -133
- package/src/list/index.js +25 -24
- package/src/list/save.js +3 -4
- package/src/list/{v2/tag-name.js → tag-name.js} +0 -0
- package/src/list/{v2/tag-name.native.js → tag-name.native.js} +0 -0
- package/src/list/test/__snapshots__/edit.native.js.snap +14 -2
- package/src/list/test/edit.native.js +0 -154
- package/src/list/transforms.js +57 -111
- package/src/list/{v2/migrate.js → utils.js} +2 -2
- package/src/list-item/block.json +0 -1
- package/src/list-item/edit.js +2 -1
- package/src/list-item/edit.native.js +32 -2
- package/src/list-item/hooks/index.js +1 -0
- package/src/list-item/hooks/use-copy.js +38 -0
- package/src/list-item/hooks/use-space.js +10 -2
- package/src/list-item/list-style-type.native.js +8 -1
- package/src/list-item/style.native.scss +12 -0
- package/src/media-text/block.json +17 -0
- package/src/media-text/deprecated.js +3 -2
- package/src/media-text/style.scss +2 -0
- package/src/navigation/block.json +1 -0
- package/src/navigation/deprecated.js +4 -2
- package/src/navigation/edit/index.js +173 -85
- package/src/navigation/edit/responsive-wrapper.js +8 -3
- package/src/navigation/edit/unsaved-inner-blocks.js +17 -25
- package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +31 -37
- package/src/navigation/editor.scss +5 -25
- package/src/navigation/index.php +24 -24
- package/src/navigation/menu-items-to-blocks.js +3 -6
- package/src/navigation/style.scss +14 -4
- package/src/navigation/test/use-navigation-menu.js +18 -1
- 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 +7 -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-excerpt/block.json +4 -2
- 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-terms/edit.js +0 -1
- package/src/post-terms/use-post-terms.js +10 -15
- 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/block.json +13 -0
- package/src/query-no-results/edit.js +1 -1
- package/src/query-pagination-numbers/block.json +4 -2
- package/src/query-title/block.json +8 -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/block.json +4 -2
- 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/block.json +9 -0
- package/src/social-links/edit.js +47 -19
- 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 +24 -1
- package/src/tag-cloud/block.json +5 -1
- package/src/template-part/index.js +3 -2
- package/src/term-description/block.json +10 -0
- package/src/text-columns/edit.js +2 -2
- package/src/text-columns/save.js +2 -2
- package/src/verse/block.json +2 -0
- package/src/video/block.json +4 -0
- package/src/video/style.scss +2 -0
- package/build/list/v2/deprecated.js +0 -117
- package/build/list/v2/deprecated.js.map +0 -1
- package/build/list/v2/edit.js +0 -200
- package/build/list/v2/edit.js.map +0 -1
- package/build/list/v2/index.js +0 -36
- package/build/list/v2/index.js.map +0 -1
- package/build/list/v2/migrate.js.map +0 -1
- package/build/list/v2/save.js +0 -34
- package/build/list/v2/save.js.map +0 -1
- package/build/list/v2/tag-name.js.map +0 -1
- package/build/list/v2/tag-name.native.js.map +0 -1
- package/build/list/v2/transforms.js +0 -137
- package/build/list/v2/transforms.js.map +0 -1
- package/build-module/list/v2/deprecated.js +0 -104
- package/build-module/list/v2/deprecated.js.map +0 -1
- package/build-module/list/v2/edit.js +0 -179
- package/build-module/list/v2/edit.js.map +0 -1
- package/build-module/list/v2/index.js +0 -21
- package/build-module/list/v2/index.js.map +0 -1
- package/build-module/list/v2/migrate.js.map +0 -1
- package/build-module/list/v2/save.js +0 -23
- package/build-module/list/v2/save.js.map +0 -1
- package/build-module/list/v2/tag-name.js.map +0 -1
- package/build-module/list/v2/tag-name.native.js.map +0 -1
- package/build-module/list/v2/transforms.js +0 -127
- package/build-module/list/v2/transforms.js.map +0 -1
- package/src/list/test/migrate.js +0 -158
- package/src/list/v2/deprecated.js +0 -89
- package/src/list/v2/edit.js +0 -192
- package/src/list/v2/index.js +0 -22
- package/src/list/v2/save.js +0 -18
- package/src/list/v2/transforms.js +0 -120
|
@@ -27,8 +27,7 @@ const transforms = {
|
|
|
27
27
|
return (0, _richText.create)({
|
|
28
28
|
html: content
|
|
29
29
|
});
|
|
30
|
-
}), '\
|
|
31
|
-
multilineTag: 'p'
|
|
30
|
+
}), '\n')
|
|
32
31
|
}),
|
|
33
32
|
anchor: attributes.anchor
|
|
34
33
|
});
|
|
@@ -42,7 +41,7 @@ const transforms = {
|
|
|
42
41
|
anchor
|
|
43
42
|
} = _ref2;
|
|
44
43
|
return (0, _blocks.createBlock)('core/pullquote', {
|
|
45
|
-
value:
|
|
44
|
+
value: content,
|
|
46
45
|
anchor
|
|
47
46
|
});
|
|
48
47
|
}
|
|
@@ -57,18 +56,13 @@ const transforms = {
|
|
|
57
56
|
} = _ref3;
|
|
58
57
|
const paragraphs = [];
|
|
59
58
|
|
|
60
|
-
if (value
|
|
61
|
-
paragraphs.push(
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}), '\u2028').map(piece => (0, _blocks.createBlock)('core/paragraph', {
|
|
65
|
-
content: (0, _richText.toHTMLString)({
|
|
66
|
-
value: piece
|
|
67
|
-
})
|
|
68
|
-
})));
|
|
59
|
+
if (value) {
|
|
60
|
+
paragraphs.push((0, _blocks.createBlock)('core/paragraph', {
|
|
61
|
+
content: value
|
|
62
|
+
}));
|
|
69
63
|
}
|
|
70
64
|
|
|
71
|
-
if (citation
|
|
65
|
+
if (citation) {
|
|
72
66
|
paragraphs.push((0, _blocks.createBlock)('core/paragraph', {
|
|
73
67
|
content: citation
|
|
74
68
|
}));
|
|
@@ -88,42 +82,29 @@ const transforms = {
|
|
|
88
82
|
transform: _ref4 => {
|
|
89
83
|
let {
|
|
90
84
|
value,
|
|
91
|
-
citation
|
|
92
|
-
...attrs
|
|
85
|
+
citation
|
|
93
86
|
} = _ref4;
|
|
94
87
|
|
|
95
88
|
// If there is no pullquote content, use the citation as the
|
|
96
89
|
// content of the resulting heading. A nonexistent citation
|
|
97
90
|
// will result in an empty heading.
|
|
98
|
-
if (value
|
|
91
|
+
if (!value) {
|
|
99
92
|
return (0, _blocks.createBlock)('core/heading', {
|
|
100
93
|
content: citation
|
|
101
94
|
});
|
|
102
95
|
}
|
|
103
96
|
|
|
104
|
-
const pieces = (0, _richText.split)((0, _richText.create)({
|
|
105
|
-
html: value,
|
|
106
|
-
multilineTag: 'p'
|
|
107
|
-
}), '\u2028');
|
|
108
97
|
const headingBlock = (0, _blocks.createBlock)('core/heading', {
|
|
109
|
-
content:
|
|
110
|
-
value: pieces[0]
|
|
111
|
-
})
|
|
98
|
+
content: value
|
|
112
99
|
});
|
|
113
100
|
|
|
114
|
-
if (!citation
|
|
101
|
+
if (!citation) {
|
|
115
102
|
return headingBlock;
|
|
116
103
|
}
|
|
117
104
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
value: (0, _richText.toHTMLString)({
|
|
122
|
-
value: quotePieces.length ? (0, _richText.join)(pieces.slice(1), '\u2028') : (0, _richText.create)(),
|
|
123
|
-
multilineTag: 'p'
|
|
124
|
-
})
|
|
125
|
-
});
|
|
126
|
-
return [headingBlock, pullquoteBlock];
|
|
105
|
+
return [headingBlock, (0, _blocks.createBlock)('core/heading', {
|
|
106
|
+
content: citation
|
|
107
|
+
})];
|
|
127
108
|
}
|
|
128
109
|
}]
|
|
129
110
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/pullquote/transforms.js"],"names":["transforms","from","type","isMultiBlock","blocks","transform","attributes","value","map","content","html","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/pullquote/transforms.js"],"names":["transforms","from","type","isMultiBlock","blocks","transform","attributes","value","map","content","html","anchor","to","citation","paragraphs","push","length","headingBlock"],"mappings":";;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,MAAMA,UAAU,GAAG;AAClBC,EAAAA,IAAI,EAAE,CACL;AACCC,IAAAA,IAAI,EAAE,OADP;AAECC,IAAAA,YAAY,EAAE,IAFf;AAGCC,IAAAA,MAAM,EAAE,CAAE,gBAAF,CAHT;AAICC,IAAAA,SAAS,EAAIC,UAAF,IAAkB;AAC5B,aAAO,yBAAa,gBAAb,EAA+B;AACrCC,QAAAA,KAAK,EAAE,4BAAc;AACpBA,UAAAA,KAAK,EAAE,oBACND,UAAU,CAACE,GAAX,CAAgB;AAAA,gBAAE;AAAEC,cAAAA;AAAF,aAAF;AAAA,mBACf,sBAAQ;AAAEC,cAAAA,IAAI,EAAED;AAAR,aAAR,CADe;AAAA,WAAhB,CADM,EAIN,IAJM;AADa,SAAd,CAD8B;AASrCE,QAAAA,MAAM,EAAEL,UAAU,CAACK;AATkB,OAA/B,CAAP;AAWA;AAhBF,GADK,EAmBL;AACCT,IAAAA,IAAI,EAAE,OADP;AAECE,IAAAA,MAAM,EAAE,CAAE,cAAF,CAFT;AAGCC,IAAAA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a,cAAb,EAA6B;AACjDR,QAAAA,OAAO,EAAEF;AADwC,OAA7B,CAArB;;AAGA,UAAK,CAAEM,QAAP,EAAkB;AACjB,eAAOI,YAAP;AACA;;AACD,aAAO,CACNA,YADM,EAEN,yBAAa,cAAb,EAA6B;AAC5BR,QAAAA,OAAO,EAAEI;AADmB,OAA7B,CAFM,CAAP;AAMA;AAxBF,GA5BG;AA/Bc,CAAnB;eAwFeb,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { create, join, toHTMLString } from '@wordpress/rich-text';\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( attributes ) => {\n\t\t\t\treturn createBlock( 'core/pullquote', {\n\t\t\t\t\tvalue: toHTMLString( {\n\t\t\t\t\t\tvalue: join(\n\t\t\t\t\t\t\tattributes.map( ( { content } ) =>\n\t\t\t\t\t\t\t\tcreate( { html: content } )\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t'\\n'\n\t\t\t\t\t\t),\n\t\t\t\t\t} ),\n\t\t\t\t\tanchor: attributes.anchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/heading' ],\n\t\t\ttransform: ( { content, anchor } ) => {\n\t\t\t\treturn createBlock( 'core/pullquote', {\n\t\t\t\t\tvalue: content,\n\t\t\t\t\tanchor,\n\t\t\t\t} );\n\t\t\t},\n\t\t},\n\t],\n\tto: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/paragraph' ],\n\t\t\ttransform: ( { value, citation } ) => {\n\t\t\t\tconst paragraphs = [];\n\t\t\t\tif ( value ) {\n\t\t\t\t\tparagraphs.push(\n\t\t\t\t\t\tcreateBlock( 'core/paragraph', {\n\t\t\t\t\t\t\tcontent: value,\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif ( citation ) {\n\t\t\t\t\tparagraphs.push(\n\t\t\t\t\t\tcreateBlock( 'core/paragraph', {\n\t\t\t\t\t\t\tcontent: citation,\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tif ( paragraphs.length === 0 ) {\n\t\t\t\t\treturn createBlock( 'core/paragraph', {\n\t\t\t\t\t\tcontent: '',\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn paragraphs;\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/heading' ],\n\t\t\ttransform: ( { value, citation } ) => {\n\t\t\t\t// If there is no pullquote content, use the citation as the\n\t\t\t\t// content of the resulting heading. A nonexistent citation\n\t\t\t\t// will result in an empty heading.\n\t\t\t\tif ( ! value ) {\n\t\t\t\t\treturn createBlock( 'core/heading', {\n\t\t\t\t\t\tcontent: citation,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\tconst headingBlock = createBlock( 'core/heading', {\n\t\t\t\t\tcontent: value,\n\t\t\t\t} );\n\t\t\t\tif ( ! citation ) {\n\t\t\t\t\treturn headingBlock;\n\t\t\t\t}\n\t\t\t\treturn [\n\t\t\t\t\theadingBlock,\n\t\t\t\t\tcreateBlock( 'core/heading', {\n\t\t\t\t\t\tcontent: citation,\n\t\t\t\t\t} ),\n\t\t\t\t];\n\t\t\t},\n\t\t},\n\t],\n};\n\nexport default transforms;\n"]}
|
|
@@ -7,14 +7,8 @@ exports.default = void 0;
|
|
|
7
7
|
|
|
8
8
|
var _element = require("@wordpress/element");
|
|
9
9
|
|
|
10
|
-
var _lodash = require("lodash");
|
|
11
|
-
|
|
12
10
|
var _blockEditor = require("@wordpress/block-editor");
|
|
13
11
|
|
|
14
|
-
/**
|
|
15
|
-
* External dependencies
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
12
|
/**
|
|
19
13
|
* WordPress dependencies
|
|
20
14
|
*/
|
|
@@ -24,8 +18,11 @@ const migrateToTaxQuery = attributes => {
|
|
|
24
18
|
const {
|
|
25
19
|
query
|
|
26
20
|
} = attributes;
|
|
27
|
-
const
|
|
28
|
-
|
|
21
|
+
const {
|
|
22
|
+
categoryIds,
|
|
23
|
+
tagIds,
|
|
24
|
+
...newQuery
|
|
25
|
+
} = query;
|
|
29
26
|
|
|
30
27
|
if ((_query$categoryIds = query.categoryIds) !== null && _query$categoryIds !== void 0 && _query$categoryIds.length || (_query$tagIds = query.tagIds) !== null && _query$tagIds !== void 0 && _query$tagIds.length) {
|
|
31
28
|
var _query$categoryIds2, _query$tagIds2;
|
|
@@ -147,7 +144,11 @@ const deprecated = [// Version with `categoryIds and tagIds`.
|
|
|
147
144
|
|
|
148
145
|
migrate(attributes) {
|
|
149
146
|
const withTaxQuery = migrateToTaxQuery(attributes);
|
|
150
|
-
|
|
147
|
+
const {
|
|
148
|
+
layout,
|
|
149
|
+
...restWithTaxQuery
|
|
150
|
+
} = withTaxQuery;
|
|
151
|
+
return { ...restWithTaxQuery,
|
|
151
152
|
displayLayout: withTaxQuery.layout
|
|
152
153
|
};
|
|
153
154
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/query/deprecated.js"],"names":["migrateToTaxQuery","attributes","query","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/query/deprecated.js"],"names":["migrateToTaxQuery","attributes","query","categoryIds","tagIds","newQuery","length","taxQuery","category","undefined","post_tag","deprecated","queryId","type","default","perPage","pages","offset","postType","order","orderBy","author","search","exclude","sticky","inherit","tagName","displayLayout","supports","align","html","color","gradients","link","__experimentalLayout","isEligible","migrate","save","Tag","blockProps","useBlockProps","innerBlocksProps","useInnerBlocksProps","layout","withTaxQuery","restWithTaxQuery"],"mappings":";;;;;;;;;AAGA;;AAHA;AACA;AACA;AAOA,MAAMA,iBAAiB,GAAKC,UAAF,IAAkB;AAAA;;AAC3C,QAA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;AACRC,QAAAA,OAAO,EAAE,IADD;AAERC,QAAAA,KAAK,EAAE,CAFC;AAGRC,QAAAA,MAAM,EAAE,CAHA;AAIRC,QAAAA,QAAQ,EAAE,MAJF;AAKRf,QAAAA,WAAW,EAAE,EALL;AAMRC,QAAAA,MAAM,EAAE,EANA;AAORe,QAAAA,KAAK,EAAE,MAPC;AAQRC,QAAAA,OAAO,EAAE,MARD;AASRC,QAAAA,MAAM,EAAE,EATA;AAURC,QAAAA,MAAM,EAAE,EAVA;AAWRC,QAAAA,OAAO,EAAE,EAXD;AAYRC,QAAAA,MAAM,EAAE,EAZA;AAaRC,QAAAA,OAAO,EAAE;AAbD;AAFH,KAJI;AAsBXkB,IAAAA,MAAM,EAAE;AACP9B,MAAAA,IAAI,EAAE,QADC;AAEPC,MAAAA,OAAO,EAAE;AACRD,QAAAA,IAAI,EAAE;AADE;AAFF;AAtBG,GADb;AA8BCe,EAAAA,QAAQ,EAAE;AACTE,IAAAA,IAAI,EAAE;AADG,GA9BX;;AAiCCM,EAAAA,OAAO,CAAEnC,UAAF,EAAe;AACrB,UAAM2C,YAAY,GAAG5C,iBAAiB,CAAEC,UAAF,CAAtC;AACA,UAAM;AAAE0C,MAAAA,MAAF;AAAU,SAAGE;AAAb,QAAkCD,YAAxC;AACA,WAAO,EACN,GAAGC,gBADG;AAENlB,MAAAA,aAAa,EAAEiB,YAAY,CAACD;AAFtB,KAAP;AAIA,GAxCF;;AAyCCN,EAAAA,IAAI,GAAG;AACN,WAAO,4BAAC,wBAAD,CAAa,OAAb,OAAP;AACA;;AA3CF,CAvDkB,CAAnB;eAsGe1B,U","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tInnerBlocks,\n\tuseInnerBlocksProps,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\n\nconst migrateToTaxQuery = ( attributes ) => {\n\tconst { query } = attributes;\n\tconst { categoryIds, tagIds, ...newQuery } = query;\n\n\tif ( query.categoryIds?.length || query.tagIds?.length ) {\n\t\tnewQuery.taxQuery = {\n\t\t\tcategory: !! query.categoryIds?.length\n\t\t\t\t? query.categoryIds\n\t\t\t\t: undefined,\n\t\t\tpost_tag: !! query.tagIds?.length ? query.tagIds : undefined,\n\t\t};\n\t}\n\treturn {\n\t\t...attributes,\n\t\tquery: newQuery,\n\t};\n};\n\nconst deprecated = [\n\t// Version with `categoryIds and tagIds`.\n\t{\n\t\tattributes: {\n\t\t\tqueryId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\tquery: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdefault: {\n\t\t\t\t\tperPage: null,\n\t\t\t\t\tpages: 0,\n\t\t\t\t\toffset: 0,\n\t\t\t\t\tpostType: 'post',\n\t\t\t\t\tcategoryIds: [],\n\t\t\t\t\ttagIds: [],\n\t\t\t\t\torder: 'desc',\n\t\t\t\t\torderBy: 'date',\n\t\t\t\t\tauthor: '',\n\t\t\t\t\tsearch: '',\n\t\t\t\t\texclude: [],\n\t\t\t\t\tsticky: '',\n\t\t\t\t\tinherit: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\ttagName: {\n\t\t\t\ttype: 'string',\n\t\t\t\tdefault: 'div',\n\t\t\t},\n\t\t\tdisplayLayout: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdefault: {\n\t\t\t\t\ttype: 'list',\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tsupports: {\n\t\t\talign: [ 'wide', 'full' ],\n\t\t\thtml: false,\n\t\t\tcolor: {\n\t\t\t\tgradients: true,\n\t\t\t\tlink: true,\n\t\t\t},\n\t\t\t__experimentalLayout: true,\n\t\t},\n\t\tisEligible: ( { query: { categoryIds, tagIds } = {} } ) =>\n\t\t\tcategoryIds || tagIds,\n\t\tmigrate: migrateToTaxQuery,\n\t\tsave( { attributes: { tagName: Tag = 'div' } } ) {\n\t\t\tconst blockProps = useBlockProps.save();\n\t\t\tconst innerBlocksProps = useInnerBlocksProps.save( blockProps );\n\t\t\treturn <Tag { ...innerBlocksProps } />;\n\t\t},\n\t},\n\t// Version with NO wrapper `div` element.\n\t{\n\t\tattributes: {\n\t\t\tqueryId: {\n\t\t\t\ttype: 'number',\n\t\t\t},\n\t\t\tquery: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdefault: {\n\t\t\t\t\tperPage: null,\n\t\t\t\t\tpages: 0,\n\t\t\t\t\toffset: 0,\n\t\t\t\t\tpostType: 'post',\n\t\t\t\t\tcategoryIds: [],\n\t\t\t\t\ttagIds: [],\n\t\t\t\t\torder: 'desc',\n\t\t\t\t\torderBy: 'date',\n\t\t\t\t\tauthor: '',\n\t\t\t\t\tsearch: '',\n\t\t\t\t\texclude: [],\n\t\t\t\t\tsticky: '',\n\t\t\t\t\tinherit: true,\n\t\t\t\t},\n\t\t\t},\n\t\t\tlayout: {\n\t\t\t\ttype: 'object',\n\t\t\t\tdefault: {\n\t\t\t\t\ttype: 'list',\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tsupports: {\n\t\t\thtml: false,\n\t\t},\n\t\tmigrate( attributes ) {\n\t\t\tconst withTaxQuery = migrateToTaxQuery( attributes );\n\t\t\tconst { layout, ...restWithTaxQuery } = withTaxQuery;\n\t\t\treturn {\n\t\t\t\t...restWithTaxQuery,\n\t\t\t\tdisplayLayout: withTaxQuery.layout,\n\t\t\t};\n\t\t},\n\t\tsave() {\n\t\t\treturn <InnerBlocks.Content />;\n\t\t},\n\t},\n];\n\nexport default deprecated;\n"]}
|
|
@@ -211,6 +211,7 @@ function QueryPatternSetup(_ref2) {
|
|
|
211
211
|
return (0, _element.createElement)(_queryPlaceholder.default, {
|
|
212
212
|
clientId: clientId,
|
|
213
213
|
name: name,
|
|
214
|
+
attributes: attributes,
|
|
214
215
|
setAttributes: setAttributes,
|
|
215
216
|
icon: icon,
|
|
216
217
|
label: label
|
|
@@ -235,7 +236,8 @@ function QueryPatternSetup(_ref2) {
|
|
|
235
236
|
const QueryEdit = props => {
|
|
236
237
|
const {
|
|
237
238
|
clientId,
|
|
238
|
-
name
|
|
239
|
+
name,
|
|
240
|
+
attributes
|
|
239
241
|
} = props;
|
|
240
242
|
const [isPatternSelectionModalOpen, setIsPatternSelectionModalOpen] = (0, _element.useState)(false);
|
|
241
243
|
const {
|
|
@@ -246,15 +248,22 @@ const QueryEdit = props => {
|
|
|
246
248
|
const Component = hasInnerBlocks ? QueryContent : QueryPatternSetup;
|
|
247
249
|
|
|
248
250
|
const onBlockPatternSelect = blocks => {
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
-
|
|
251
|
+
const {
|
|
252
|
+
newBlocks,
|
|
253
|
+
queryClientIds
|
|
254
|
+
} = (0, _utils.getTransformedBlocksFromPattern)(blocks, attributes);
|
|
255
|
+
replaceBlock(clientId, newBlocks);
|
|
252
256
|
|
|
253
|
-
if (
|
|
254
|
-
selectBlock(
|
|
257
|
+
if (queryClientIds[0]) {
|
|
258
|
+
selectBlock(queryClientIds[0]);
|
|
255
259
|
}
|
|
256
|
-
};
|
|
260
|
+
}; // When we preview Query Loop blocks we should prefer the current
|
|
261
|
+
// block's postType, which is passed through block context.
|
|
262
|
+
|
|
257
263
|
|
|
264
|
+
const blockPreviewContext = (0, _element.useMemo)(() => ({
|
|
265
|
+
previewPostType: attributes.query.postType
|
|
266
|
+
}), [attributes.query.postType]);
|
|
258
267
|
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(Component, (0, _extends2.default)({}, props, {
|
|
259
268
|
openPatternSelectionModal: () => setIsPatternSelectionModalOpen(true)
|
|
260
269
|
})), isPatternSelectionModalOpen && (0, _element.createElement)(_components.Modal, {
|
|
@@ -262,11 +271,13 @@ const QueryEdit = props => {
|
|
|
262
271
|
title: (0, _i18n.__)('Choose a pattern'),
|
|
263
272
|
closeLabel: (0, _i18n.__)('Cancel'),
|
|
264
273
|
onRequestClose: () => setIsPatternSelectionModalOpen(false)
|
|
274
|
+
}, (0, _element.createElement)(_blockEditor.BlockContextProvider, {
|
|
275
|
+
value: blockPreviewContext
|
|
265
276
|
}, (0, _element.createElement)(_blockEditor.__experimentalBlockPatternSetup, {
|
|
266
277
|
blockName: name,
|
|
267
278
|
clientId: clientId,
|
|
268
279
|
onBlockPatternSelect: onBlockPatternSelect
|
|
269
|
-
})));
|
|
280
|
+
}))));
|
|
270
281
|
};
|
|
271
282
|
|
|
272
283
|
var _default = QueryEdit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/query/edit/index.js"],"names":["TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","layout","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","instanceId","themeSupportsLayout","select","getSettings","supportsLayout","defaultLayout","usedLayout","inherit","blockProps","innerBlocksProps","template","__experimentalLayout","undefined","postsPerPage","DEFAULTS_POSTS_PER_PAGE","newQuery","perPage","Object","keys","length","updateQuery","Number","isFinite","updateDisplayLayout","newDisplayLayout","label","value","QueryPatternSetup","isStartingBlank","setIsStartingBlank","blockType","allVariations","hasPatterns","getBlockVariations","getBlockType","blocksStore","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","rootClientId","matchingVariation","icon","src","title","QueryEdit","props","isPatternSelectionModalOpen","setIsPatternSelectionModalOpen","replaceBlock","selectBlock","hasInnerBlocks","getBlocks","Component","onBlockPatternSelect","blocks","clonedBlocks","map","block","firstQueryClientId"],"mappings":";;;;;;;;;;AAMA;;;;AAHA;;AACA;;AACA;;AAEA;;AAUA;;AAMA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAuBA;AACA;AACA;AAOA,MAAMA,QAAQ,GAAG,CAAE,CAAE,oBAAF,CAAF,CAAjB;;AACO,SAASC,YAAT,OAMH;AAAA,MAN0B;AAC7BC,IAAAA,UAD6B;AAE7BC,IAAAA,aAF6B;AAG7BC,IAAAA,yBAH6B;AAI7BC,IAAAA,IAJ6B;AAK7BC,IAAAA;AAL6B,GAM1B;AACH,QAAM;AAC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AAI,kBAAJ,CAFT;AAGC,IAAA,UAAU,EAAG,cAAI,QAAJ,CAHd;AAIC,IAAA,cAAc,EAAG,MAChBC,8BAA8B,CAAE,KAAF;AALhC,KAQC,4BAAC,4CAAD;AACC,IAAA,SAAS,EAAGxD,IADb;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,oBAAoB,EAAG6D;AAHxB,IARD,CARF,CADD;AA0BA,CA9CD;;eAgDeT,S","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blocksStore, cloneBlock } from '@wordpress/blocks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState, useEffect } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\tuseSetting,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n\t__experimentalGetMatchingVariation as getMatchingVariation,\n\t__experimentalBlockPatternSetup as BlockPatternSetup,\n} from '@wordpress/block-editor';\nimport {\n\tButton,\n\tSelectControl,\n\tPlaceholder,\n\tModal,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport QueryToolbar from './query-toolbar';\nimport QueryInspectorControls from './inspector-controls';\nimport QueryPlaceholder from './query-placeholder';\nimport { DEFAULTS_POSTS_PER_PAGE } from '../constants';\nimport { getFirstQueryClientIdFromBlocks } from '../utils';\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\topenPatternSelectionModal,\n\tname,\n\tclientId,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tdisplayLayout,\n\t\ttagName: TagName = 'div',\n\t\tlayout = {},\n\t} = attributes;\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn { themeSupportsLayout: getSettings()?.supportsLayout };\n\t}, [] );\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = !! layout && layout.inherit ? defaultLayout : layout;\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t\t__experimentalLayout: themeSupportsLayout ? usedLayout : undefined,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tpostsPerPage:\n\t\t\t\t+getSettings().postsPerPage || DEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\tif ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [ query.perPage ] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [ queryId, instanceId ] );\n\tconst updateQuery = ( newQuery ) =>\n\t\tsetAttributes( { query: { ...query, ...newQuery } } );\n\tconst updateDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tdisplayLayout: { ...displayLayout, ...newDisplayLayout },\n\t\t} );\n\treturn (\n\t\t<>\n\t\t\t<QueryInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t/>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t\t\topenPatternSelectionModal={ openPatternSelectionModal }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n\nfunction QueryPatternSetup( {\n\tattributes,\n\tclientId,\n\tname,\n\topenPatternSelectionModal,\n\tsetAttributes,\n} ) {\n\tconst [ isStartingBlank, setIsStartingBlank ] = useState( false );\n\tconst blockProps = useBlockProps();\n\n\tconst { blockType, allVariations, hasPatterns } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tallVariations: getBlockVariations( name ),\n\t\t\t\thasPatterns: !! __experimentalGetPatternsByBlockTypes(\n\t\t\t\t\tname,\n\t\t\t\t\trootClientId\n\t\t\t\t).length,\n\t\t\t};\n\t\t},\n\t\t[ name, clientId ]\n\t);\n\n\tconst matchingVariation = getMatchingVariation( attributes, allVariations );\n\tconst icon = matchingVariation?.icon || blockType?.icon?.src;\n\tconst label = matchingVariation?.title || blockType?.title;\n\tif ( isStartingBlank ) {\n\t\treturn (\n\t\t\t<QueryPlaceholder\n\t\t\t\tclientId={ clientId }\n\t\t\t\tname={ name }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Choose a pattern for the query loop or start blank.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ !! hasPatterns && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ openPatternSelectionModal }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetIsStartingBlank( true );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t</Button>\n\t\t\t</Placeholder>\n\t\t</div>\n\t);\n}\n\nconst QueryEdit = ( props ) => {\n\tconst { clientId, name } = props;\n\tconst [ isPatternSelectionModalOpen, setIsPatternSelectionModalOpen ] =\n\t\tuseState( false );\n\tconst { replaceBlock, selectBlock } = useDispatch( blockEditorStore );\n\tconst hasInnerBlocks = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( blockEditorStore ).getBlocks( clientId ).length,\n\t\t[ clientId ]\n\t);\n\tconst Component = hasInnerBlocks ? QueryContent : QueryPatternSetup;\n\tconst onBlockPatternSelect = ( blocks ) => {\n\t\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\t\tconst firstQueryClientId =\n\t\t\tgetFirstQueryClientIdFromBlocks( clonedBlocks );\n\t\treplaceBlock( clientId, clonedBlocks );\n\t\tif ( firstQueryClientId ) {\n\t\t\tselectBlock( firstQueryClientId );\n\t\t}\n\t};\n\treturn (\n\t\t<>\n\t\t\t<Component\n\t\t\t\t{ ...props }\n\t\t\t\topenPatternSelectionModal={ () =>\n\t\t\t\t\tsetIsPatternSelectionModalOpen( true )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isPatternSelectionModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\tclassName=\"block-editor-query-pattern__selection-modal\"\n\t\t\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\t\t\tonRequestClose={ () =>\n\t\t\t\t\t\tsetIsPatternSelectionModalOpen( false )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<BlockPatternSetup\n\t\t\t\t\t\tblockName={ name }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tonBlockPatternSelect={ onBlockPatternSelect }\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport default QueryEdit;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/query/edit/index.js"],"names":["TEMPLATE","QueryContent","attributes","setAttributes","openPatternSelectionModal","name","clientId","queryId","query","displayLayout","tagName","TagName","layout","__unstableMarkNextChangeAsNotPersistent","blockEditorStore","instanceId","themeSupportsLayout","select","getSettings","supportsLayout","defaultLayout","usedLayout","inherit","blockProps","innerBlocksProps","template","__experimentalLayout","undefined","postsPerPage","DEFAULTS_POSTS_PER_PAGE","newQuery","perPage","Object","keys","length","updateQuery","Number","isFinite","updateDisplayLayout","newDisplayLayout","label","value","QueryPatternSetup","isStartingBlank","setIsStartingBlank","blockType","allVariations","hasPatterns","getBlockVariations","getBlockType","blocksStore","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","rootClientId","matchingVariation","icon","src","title","QueryEdit","props","isPatternSelectionModalOpen","setIsPatternSelectionModalOpen","replaceBlock","selectBlock","hasInnerBlocks","getBlocks","Component","onBlockPatternSelect","blocks","newBlocks","queryClientIds","blockPreviewContext","previewPostType","postType"],"mappings":";;;;;;;;;;AAMA;;;;AAHA;;AACA;;AACA;;AAEA;;AAWA;;AAMA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAjCA;AACA;AACA;;AAwBA;AACA;AACA;AAOA,MAAMA,QAAQ,GAAG,CAAE,CAAE,oBAAF,CAAF,CAAjB;;AACO,SAASC,YAAT,OAMH;AAAA,MAN0B;AAC7BC,IAAAA,UAD6B;AAE7BC,IAAAA,aAF6B;AAG7BC,IAAAA,yBAH6B;AAI7BC,IAAAA,IAJ6B;AAK7BC,IAAAA;AAL6B,GAM1B;AACH,QAAM;AACLC,IAAAA,OADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,aAHK;AAILC,IAAAA,OAAO,EAAEC,OAAO,GAAG,KAJd;AAKLC,IAAAA,MAAM,GAAG;AALJ,MAMFV,UANJ;AAOA,QAAM;AAAEW,IAAAA;AAAF,MACL,uBAAaC,kBAAb,CADD;AAEA,QAAMC,UAAU,GAAG,4BAAed,YAAf,CAAnB;AACA,QAAM;AAAEe,IAAAA;AAAF,MAA0B,qBAAaC,MAAF,IAAc;AAAA;;AACxD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEH,kBAAF,CAA9B;AACA,WAAO;AAAEE,MAAAA,mBAAmB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EAAGU;AAA9B,KACC,4BAAC,4CAAD;AACC,IAAA,SAAS,EAAGlE,IADb;AAEC,IAAA,QAAQ,EAAGC,QAFZ;AAGC,IAAA,oBAAoB,EAAG6D;AAHxB,IADD,CARD,CARF,CADD;AA4BA,CAzDD;;eA2DeT,S","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport {\n\tBlockControls,\n\tBlockContextProvider,\n\tInspectorControls,\n\tuseBlockProps,\n\tuseSetting,\n\tstore as blockEditorStore,\n\tuseInnerBlocksProps,\n\t__experimentalGetMatchingVariation as getMatchingVariation,\n\t__experimentalBlockPatternSetup as BlockPatternSetup,\n} from '@wordpress/block-editor';\nimport {\n\tButton,\n\tSelectControl,\n\tPlaceholder,\n\tModal,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport QueryToolbar from './query-toolbar';\nimport QueryInspectorControls from './inspector-controls';\nimport QueryPlaceholder from './query-placeholder';\nimport { DEFAULTS_POSTS_PER_PAGE } from '../constants';\nimport { getTransformedBlocksFromPattern } from '../utils';\n\nconst TEMPLATE = [ [ 'core/post-template' ] ];\nexport function QueryContent( {\n\tattributes,\n\tsetAttributes,\n\topenPatternSelectionModal,\n\tname,\n\tclientId,\n} ) {\n\tconst {\n\t\tqueryId,\n\t\tquery,\n\t\tdisplayLayout,\n\t\ttagName: TagName = 'div',\n\t\tlayout = {},\n\t} = attributes;\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\tconst instanceId = useInstanceId( QueryContent );\n\tconst { themeSupportsLayout } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn { themeSupportsLayout: getSettings()?.supportsLayout };\n\t}, [] );\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = !! layout && layout.inherit ? defaultLayout : layout;\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t\t__experimentalLayout: themeSupportsLayout ? usedLayout : undefined,\n\t} );\n\tconst { postsPerPage } = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn {\n\t\t\tpostsPerPage:\n\t\t\t\t+getSettings().postsPerPage || DEFAULTS_POSTS_PER_PAGE,\n\t\t};\n\t}, [] );\n\t// There are some effects running where some initialization logic is\n\t// happening and setting some values to some attributes (ex. queryId).\n\t// These updates can cause an `undo trap` where undoing will result in\n\t// resetting again, so we need to mark these changes as not persistent\n\t// with `__unstableMarkNextChangeAsNotPersistent`.\n\n\t// Changes in query property (which is an object) need to be in the same callback,\n\t// because updates are batched after the render and changes in different query properties\n\t// would cause to override previous wanted changes.\n\tuseEffect( () => {\n\t\tconst newQuery = {};\n\t\tif ( ! query.perPage && postsPerPage ) {\n\t\t\tnewQuery.perPage = postsPerPage;\n\t\t}\n\t\tif ( !! Object.keys( newQuery ).length ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tupdateQuery( newQuery );\n\t\t}\n\t}, [ query.perPage ] );\n\t// We need this for multi-query block pagination.\n\t// Query parameters for each block are scoped to their ID.\n\tuseEffect( () => {\n\t\tif ( ! Number.isFinite( queryId ) ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( { queryId: instanceId } );\n\t\t}\n\t}, [ queryId, instanceId ] );\n\tconst updateQuery = ( newQuery ) =>\n\t\tsetAttributes( { query: { ...query, ...newQuery } } );\n\tconst updateDisplayLayout = ( newDisplayLayout ) =>\n\t\tsetAttributes( {\n\t\t\tdisplayLayout: { ...displayLayout, ...newDisplayLayout },\n\t\t} );\n\treturn (\n\t\t<>\n\t\t\t<QueryInspectorControls\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t/>\n\t\t\t<BlockControls>\n\t\t\t\t<QueryToolbar\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetQuery={ updateQuery }\n\t\t\t\t\tsetDisplayLayout={ updateDisplayLayout }\n\t\t\t\t\topenPatternSelectionModal={ openPatternSelectionModal }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t\t<SelectControl\n\t\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\t\toptions={ [\n\t\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t] }\n\t\t\t\t\tvalue={ TagName }\n\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<TagName { ...innerBlocksProps } />\n\t\t</>\n\t);\n}\n\nfunction QueryPatternSetup( {\n\tattributes,\n\tclientId,\n\tname,\n\topenPatternSelectionModal,\n\tsetAttributes,\n} ) {\n\tconst [ isStartingBlank, setIsStartingBlank ] = useState( false );\n\tconst blockProps = useBlockProps();\n\n\tconst { blockType, allVariations, hasPatterns } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlockVariations, getBlockType } = select( blocksStore );\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tallVariations: getBlockVariations( name ),\n\t\t\t\thasPatterns: !! __experimentalGetPatternsByBlockTypes(\n\t\t\t\t\tname,\n\t\t\t\t\trootClientId\n\t\t\t\t).length,\n\t\t\t};\n\t\t},\n\t\t[ name, clientId ]\n\t);\n\n\tconst matchingVariation = getMatchingVariation( attributes, allVariations );\n\tconst icon = matchingVariation?.icon || blockType?.icon?.src;\n\tconst label = matchingVariation?.title || blockType?.title;\n\tif ( isStartingBlank ) {\n\t\treturn (\n\t\t\t<QueryPlaceholder\n\t\t\t\tclientId={ clientId }\n\t\t\t\tname={ name }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t/>\n\t\t);\n\t}\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Placeholder\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tinstructions={ __(\n\t\t\t\t\t'Choose a pattern for the query loop or start blank.'\n\t\t\t\t) }\n\t\t\t>\n\t\t\t\t{ !! hasPatterns && (\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ openPatternSelectionModal }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetIsStartingBlank( true );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t</Button>\n\t\t\t</Placeholder>\n\t\t</div>\n\t);\n}\n\nconst QueryEdit = ( props ) => {\n\tconst { clientId, name, attributes } = props;\n\tconst [ isPatternSelectionModalOpen, setIsPatternSelectionModalOpen ] =\n\t\tuseState( false );\n\tconst { replaceBlock, selectBlock } = useDispatch( blockEditorStore );\n\tconst hasInnerBlocks = useSelect(\n\t\t( select ) =>\n\t\t\t!! select( blockEditorStore ).getBlocks( clientId ).length,\n\t\t[ clientId ]\n\t);\n\tconst Component = hasInnerBlocks ? QueryContent : QueryPatternSetup;\n\tconst onBlockPatternSelect = ( blocks ) => {\n\t\tconst { newBlocks, queryClientIds } = getTransformedBlocksFromPattern(\n\t\t\tblocks,\n\t\t\tattributes\n\t\t);\n\t\treplaceBlock( clientId, newBlocks );\n\t\tif ( queryClientIds[ 0 ] ) {\n\t\t\tselectBlock( queryClientIds[ 0 ] );\n\t\t}\n\t};\n\t// When we preview Query Loop blocks we should prefer the current\n\t// block's postType, which is passed through block context.\n\tconst blockPreviewContext = useMemo(\n\t\t() => ( {\n\t\t\tpreviewPostType: attributes.query.postType,\n\t\t} ),\n\t\t[ attributes.query.postType ]\n\t);\n\treturn (\n\t\t<>\n\t\t\t<Component\n\t\t\t\t{ ...props }\n\t\t\t\topenPatternSelectionModal={ () =>\n\t\t\t\t\tsetIsPatternSelectionModalOpen( true )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isPatternSelectionModalOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\tclassName=\"block-editor-query-pattern__selection-modal\"\n\t\t\t\t\ttitle={ __( 'Choose a pattern' ) }\n\t\t\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\t\t\tonRequestClose={ () =>\n\t\t\t\t\t\tsetIsPatternSelectionModalOpen( false )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<BlockContextProvider value={ blockPreviewContext }>\n\t\t\t\t\t\t<BlockPatternSetup\n\t\t\t\t\t\t\tblockName={ name }\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tonBlockPatternSelect={ onBlockPatternSelect }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</BlockContextProvider>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport default QueryEdit;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"names":["getTermIdByTermValue","termsMappedByName","termValue","termId","id","termValueLower","toLocaleLowerCase","term","useTaxonomiesInfo","postType","taxonomies","taxonomiesInfo","select","getEntityRecords","coreStore","termsQuery","per_page","MAX_FETCHED_TERMS","_taxonomiesInfo","map","slug","name","_terms","terms","TaxonomyControls","onChange","query","onTermsChange","taxonomySlug","newTermValues","taxonomyInfo","find","termIds","Array","from","reduce","accumulator","mapByName","add","Set","newTaxQuery","taxQuery","getExistingTaxQueryValue","mapById","push","value","length","names"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIA;AACA,MAAMA,oBAAoB,GAAG,CAAEC,iBAAF,EAAqBC,SAArB,KAAoC;AAAA;;AAChE;AACA,QAAMC,MAAM,GAAG,CAAAD,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEE,EAAX,+BAAiBH,iBAAiB,CAAEC,SAAF,CAAlC,0DAAiB,sBAAgCE,EAAjD,CAAf;AACA,MAAKD,MAAL,EAAc,OAAOA,MAAP;AACd;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACC,QAAME,cAAc,GAAGH,SAAS,CAACI,iBAAV,EAAvB;;AACA,OAAM,MAAMC,IAAZ,IAAoBN,iBAApB,EAAwC;AACvC,QAAKM,IAAI,CAACD,iBAAL,OAA6BD,cAAlC,EAAmD;AAClD,aAAOJ,iBAAiB,CAAEM,IAAF,CAAjB,CAA0BH,EAAjC;AACA;AACD;AACD,CAnBD;;AAqBO,MAAMI,iBAAiB,GAAKC,QAAF,IAAgB;AAChD,QAAMC,UAAU,GAAG,0BAAeD,QAAf,CAAnB;AACA,QAAME,cAAc,GAAG,qBACpBC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAuBD,MAAM,CAAEE,eAAF,CAAnC;AACA,UAAMC,UAAU,GAAG;AAAEC,MAAAA,QAAQ,EAAEC;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/taxonomy-controls.js"],"names":["getTermIdByTermValue","termsMappedByName","termValue","termId","id","termValueLower","toLocaleLowerCase","term","useTaxonomiesInfo","postType","taxonomies","taxonomiesInfo","select","getEntityRecords","coreStore","termsQuery","context","per_page","MAX_FETCHED_TERMS","_taxonomiesInfo","map","slug","name","_terms","terms","TaxonomyControls","onChange","query","onTermsChange","taxonomySlug","newTermValues","taxonomyInfo","find","termIds","Array","from","reduce","accumulator","mapByName","add","Set","newTaxQuery","taxQuery","getExistingTaxQueryValue","mapById","push","value","length","names"],"mappings":";;;;;;;;;;AAGA;;AACA;;AACA;;AAKA;;AACA;;AAXA;AACA;AACA;;AAKA;AACA;AACA;AAIA;AACA,MAAMA,oBAAoB,GAAG,CAAEC,iBAAF,EAAqBC,SAArB,KAAoC;AAAA;;AAChE;AACA,QAAMC,MAAM,GAAG,CAAAD,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEE,EAAX,+BAAiBH,iBAAiB,CAAEC,SAAF,CAAlC,0DAAiB,sBAAgCE,EAAjD,CAAf;AACA,MAAKD,MAAL,EAAc,OAAOA,MAAP;AACd;AACD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACC,QAAME,cAAc,GAAGH,SAAS,CAACI,iBAAV,EAAvB;;AACA,OAAM,MAAMC,IAAZ,IAAoBN,iBAApB,EAAwC;AACvC,QAAKM,IAAI,CAACD,iBAAL,OAA6BD,cAAlC,EAAmD;AAClD,aAAOJ,iBAAiB,CAAEM,IAAF,CAAjB,CAA0BH,EAAjC;AACA;AACD;AACD,CAnBD;;AAqBO,MAAMI,iBAAiB,GAAKC,QAAF,IAAgB;AAChD,QAAMC,UAAU,GAAG,0BAAeD,QAAf,CAAnB;AACA,QAAME,cAAc,GAAG,qBACpBC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAA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KAAF,+BAAEA,KAAK,CAAEwB,KAAT,yCAAE,aAAcD,MAAhB,CAAL,EAA8B;AAC7B,aAAO,IAAP;AACA;;AACD,WACC;AACC,MAAA,GAAG,EAAG1B,IADP;AAEC,MAAA,SAAS,EAAC;AAFX,OAIC,4BAAC,0BAAD;AACC,MAAA,KAAK,EAAGC,IADT;AAEC,MAAA,KAAK,EAAGqB,wBAAwB,CAAEtB,IAAF,CAFjC;AAGC,MAAA,WAAW,EAAGG,KAAK,CAACwB,KAHrB;AAIC,MAAA,QAAQ,EAAGpB,aAAa,CAAEP,IAAF;AAJzB,MAJD,CADD;AAaA,GAjBD,CAFF,CADD;AAuBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { FormTokenField } from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { getEntitiesInfo, useTaxonomies } from '../../utils';\nimport { MAX_FETCHED_TERMS } from '../../constants';\n\n// Helper function to get the term id based on user input in terms `FormTokenField`.\nconst getTermIdByTermValue = ( termsMappedByName, termValue ) => {\n\t// First we check for exact match by `term.id` or case sensitive `term.name` match.\n\tconst termId = termValue?.id || termsMappedByName[ termValue ]?.id;\n\tif ( termId ) return termId;\n\t/**\n\t * Here we make an extra check for entered terms in a non case sensitive way,\n\t * to match user expectations, due to `FormTokenField` behaviour that shows\n\t * suggestions which are case insensitive.\n\t *\n\t * Although WP tries to discourage users to add terms with the same name (case insensitive),\n\t * it's still possible if you manually change the name, as long as the terms have different slugs.\n\t * In this edge case we always apply the first match from the terms list.\n\t */\n\tconst termValueLower = termValue.toLocaleLowerCase();\n\tfor ( const term in termsMappedByName ) {\n\t\tif ( term.toLocaleLowerCase() === termValueLower ) {\n\t\t\treturn termsMappedByName[ term ].id;\n\t\t}\n\t}\n};\n\nexport const useTaxonomiesInfo = ( postType ) => {\n\tconst taxonomies = useTaxonomies( postType );\n\tconst taxonomiesInfo = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst termsQuery = { context: 'view', per_page: MAX_FETCHED_TERMS };\n\t\t\tconst _taxonomiesInfo = taxonomies?.map( ( { slug, name } ) => {\n\t\t\t\tconst _terms = getEntityRecords( 'taxonomy', slug, termsQuery );\n\t\t\t\treturn {\n\t\t\t\t\tslug,\n\t\t\t\t\tname,\n\t\t\t\t\tterms: getEntitiesInfo( _terms ),\n\t\t\t\t};\n\t\t\t} );\n\t\t\treturn _taxonomiesInfo;\n\t\t},\n\t\t[ taxonomies ]\n\t);\n\treturn taxonomiesInfo;\n};\n\nexport function TaxonomyControls( { onChange, query } ) {\n\tconst taxonomiesInfo = useTaxonomiesInfo( query.postType );\n\tconst onTermsChange = ( taxonomySlug ) => ( newTermValues ) => {\n\t\tconst taxonomyInfo = taxonomiesInfo.find(\n\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t);\n\t\tif ( ! taxonomyInfo ) return;\n\t\tconst termIds = Array.from(\n\t\t\tnewTermValues.reduce( ( accumulator, termValue ) => {\n\t\t\t\tconst termId = getTermIdByTermValue(\n\t\t\t\t\ttaxonomyInfo.terms.mapByName,\n\t\t\t\t\ttermValue\n\t\t\t\t);\n\t\t\t\tif ( termId ) accumulator.add( termId );\n\t\t\t\treturn accumulator;\n\t\t\t}, new Set() )\n\t\t);\n\t\tconst newTaxQuery = {\n\t\t\t...query.taxQuery,\n\t\t\t[ taxonomySlug ]: termIds,\n\t\t};\n\t\tonChange( { taxQuery: newTaxQuery } );\n\t};\n\t// Returns only the existing term ids in proper format to be\n\t// used in `FormTokenField`. This prevents the component from\n\t// crashing in the editor, when non existing term ids were provided.\n\tconst getExistingTaxQueryValue = ( taxonomySlug ) => {\n\t\tconst taxonomyInfo = taxonomiesInfo.find(\n\t\t\t( { slug } ) => slug === taxonomySlug\n\t\t);\n\t\tif ( ! taxonomyInfo ) return [];\n\t\treturn ( query.taxQuery?.[ taxonomySlug ] || [] ).reduce(\n\t\t\t( accumulator, termId ) => {\n\t\t\t\tconst term = taxonomyInfo.terms.mapById[ termId ];\n\t\t\t\tif ( term ) {\n\t\t\t\t\taccumulator.push( {\n\t\t\t\t\t\tid: termId,\n\t\t\t\t\t\tvalue: term.name,\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t[]\n\t\t);\n\t};\n\treturn (\n\t\t<>\n\t\t\t{ !! taxonomiesInfo?.length &&\n\t\t\t\ttaxonomiesInfo.map( ( { slug, name, terms } ) => {\n\t\t\t\t\tif ( ! terms?.names?.length ) {\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<div\n\t\t\t\t\t\t\tkey={ slug }\n\t\t\t\t\t\t\tclassName=\"block-library-query-inspector__taxonomy-control\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FormTokenField\n\t\t\t\t\t\t\t\tlabel={ name }\n\t\t\t\t\t\t\t\tvalue={ getExistingTaxQueryValue( slug ) }\n\t\t\t\t\t\t\t\tsuggestions={ terms.names }\n\t\t\t\t\t\t\t\tonChange={ onTermsChange( slug ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</div>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -20,6 +20,7 @@ function QueryPlaceholder(_ref) {
|
|
|
20
20
|
let {
|
|
21
21
|
clientId,
|
|
22
22
|
name,
|
|
23
|
+
attributes,
|
|
23
24
|
setAttributes,
|
|
24
25
|
icon,
|
|
25
26
|
label
|
|
@@ -51,7 +52,11 @@ function QueryPlaceholder(_ref) {
|
|
|
51
52
|
let nextVariation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultVariation;
|
|
52
53
|
|
|
53
54
|
if (nextVariation.attributes) {
|
|
54
|
-
setAttributes(nextVariation.attributes
|
|
55
|
+
setAttributes({ ...nextVariation.attributes,
|
|
56
|
+
query: { ...nextVariation.attributes.query,
|
|
57
|
+
postType: attributes.query.postType || nextVariation.attributes.query.postType
|
|
58
|
+
}
|
|
59
|
+
});
|
|
55
60
|
}
|
|
56
61
|
|
|
57
62
|
if (nextVariation.innerBlocks) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/query/edit/query-placeholder.js"],"names":["QueryPlaceholder","clientId","name","setAttributes","icon","label","defaultVariation","scopeVariations","select","getBlockVariations","getBlockType","getDefaultBlockVariation","blocksStore","blockType","replaceInnerBlocks","blockEditorStore","blockProps","nextVariation","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/query/edit/query-placeholder.js"],"names":["QueryPlaceholder","clientId","name","attributes","setAttributes","icon","label","defaultVariation","scopeVariations","select","getBlockVariations","getBlockType","getDefaultBlockVariation","blocksStore","blockType","replaceInnerBlocks","blockEditorStore","blockProps","nextVariation","query","postType","innerBlocks"],"mappings":";;;;;;;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;AAYA,SAASA,gBAAT,OAOI;AAAA,MAPuB;AAC1BC,IAAAA,QAD0B;AAE1BC,IAAAA,IAF0B;AAG1BC,IAAAA,UAH0B;AAI1BC,IAAAA,aAJ0B;AAK1BC,IAAAA,IAL0B;AAM1BC,IAAAA;AAN0B,GAOvB;AACH,QAAM;AAAEC,IAAAA,gBAAF;AAAoBC,IAAAA;AAApB,MAAwC,qBAC3CC,MAAF,IAAc;AACb,UAAM;AACLC,MAAAA,kBADK;AAELC,MAAAA,YAFK;AAGLC,MAAAA;AAHK,QAIFH,MAAM,CAAEI,aAAF,CAJV;AAMA,WAAO;AACNC,MAAAA,SAAS,EAAEH,YAAY,CAAET,IAAF,CADjB;AAENK,MAAAA,gBAAgB,EAAEK,wBAAwB,CAAEV,IAAF,EAAQ,OAAR,CAFpC;AAGNM,MAAAA,eAAe,EAAEE,kBAAkB,CAAER,IAAF,EAAQ,OAAR;AAH7B,KAAP;AAKA,GAb4C,EAc7C,CAAEA,IAAF,CAd6C,CAA9C;AAgBA,QAAM;AAAEa,IAAAA;AAAF,MAAyB,uBAAaC,kBAAb,CAA/B;AACA,QAAMC,UAAU,GAAG,iCAAnB;AACA,SACC,mCAAUA,UAAV,EACC,4BAAC,+CAAD;AACC,IAAA,IAAI,EAAGZ,IADR;AAEC,IAAA,KAAK,EAAGC,KAFT;AAGC,IAAA,UAAU,EAAGE,eAHd;AAIC,IAAA,QAAQ,EAAG,YAAwC;AAAA,UAAtCU,aAAsC,uEAAtBX,gBAAsB;;AAClD,UAAKW,aAAa,CAACf,UAAnB,EAAgC;AAC/BC,QAAAA,aAAa,CAAE,EACd,GAAGc,aAAa,CAACf,UADH;AAEdgB,UAAAA,KAAK,EAAE,EACN,GAAGD,aAAa,CAACf,UAAd,CAAyBgB,KADtB;AAENC,YAAAA,QAAQ,EACPjB,UAAU,CAACgB,KAAX,CAAiBC,QAAjB,IACAF,aAAa,CAACf,UAAd,CAAyBgB,KAAzB,CAA+BC;AAJ1B;AAFO,SAAF,CAAb;AASA;;AACD,UAAKF,aAAa,CAACG,WAAnB,EAAiC;AAChCN,QAAAA,kBAAkB,CACjBd,QADiB,EAEjB,iDACCiB,aAAa,CAACG,WADf,CAFiB,EAKjB,KALiB,CAAlB;AAOA;AACD;AAzBF,IADD,CADD;AA+BA;;eAEcrB,gB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tuseBlockProps,\n\t__experimentalBlockVariationPicker,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tcreateBlocksFromInnerBlocksTemplate,\n\tstore as blocksStore,\n} from '@wordpress/blocks';\n\nfunction QueryPlaceholder( {\n\tclientId,\n\tname,\n\tattributes,\n\tsetAttributes,\n\ticon,\n\tlabel,\n} ) {\n\tconst { defaultVariation, scopeVariations } = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetBlockVariations,\n\t\t\t\tgetBlockType,\n\t\t\t\tgetDefaultBlockVariation,\n\t\t\t} = select( blocksStore );\n\n\t\t\treturn {\n\t\t\t\tblockType: getBlockType( name ),\n\t\t\t\tdefaultVariation: getDefaultBlockVariation( name, 'block' ),\n\t\t\t\tscopeVariations: getBlockVariations( name, 'block' ),\n\t\t\t};\n\t\t},\n\t\t[ name ]\n\t);\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\tconst blockProps = useBlockProps();\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<__experimentalBlockVariationPicker\n\t\t\t\ticon={ icon }\n\t\t\t\tlabel={ label }\n\t\t\t\tvariations={ scopeVariations }\n\t\t\t\tonSelect={ ( nextVariation = defaultVariation ) => {\n\t\t\t\t\tif ( nextVariation.attributes ) {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t...nextVariation.attributes,\n\t\t\t\t\t\t\tquery: {\n\t\t\t\t\t\t\t\t...nextVariation.attributes.query,\n\t\t\t\t\t\t\t\tpostType:\n\t\t\t\t\t\t\t\t\tattributes.query.postType ||\n\t\t\t\t\t\t\t\t\tnextVariation.attributes.query.postType,\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\tif ( nextVariation.innerBlocks ) {\n\t\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\tcreateBlocksFromInnerBlocksTemplate(\n\t\t\t\t\t\t\t\tnextVariation.innerBlocks\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tfalse\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</div>\n\t);\n}\n\nexport default QueryPlaceholder;\n"]}
|
package/build/query/utils.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useTaxonomies = exports.usePostTypes = exports.mapToIHasNameAndId = exports.
|
|
6
|
+
exports.useTaxonomies = exports.usePostTypes = exports.mapToIHasNameAndId = exports.getTransformedBlocksFromPattern = exports.getEntitiesInfo = void 0;
|
|
7
7
|
|
|
8
8
|
var _lodash = require("lodash");
|
|
9
9
|
|
|
@@ -15,6 +15,8 @@ var _coreData = require("@wordpress/core-data");
|
|
|
15
15
|
|
|
16
16
|
var _htmlEntities = require("@wordpress/html-entities");
|
|
17
17
|
|
|
18
|
+
var _blocks = require("@wordpress/blocks");
|
|
19
|
+
|
|
18
20
|
/**
|
|
19
21
|
* External dependencies
|
|
20
22
|
*/
|
|
@@ -164,18 +166,33 @@ const useTaxonomies = postType => {
|
|
|
164
166
|
return taxonomies;
|
|
165
167
|
};
|
|
166
168
|
/**
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
+
* Clones a pattern's blocks and then recurses over that list of blocks,
|
|
170
|
+
* transforming them to retain some `query` attribute properties.
|
|
171
|
+
* For now we retain the `postType` and `inherit` properties as they are
|
|
172
|
+
* fundamental for the expected functionality of the block and don't affect
|
|
173
|
+
* its design and presentation.
|
|
174
|
+
*
|
|
175
|
+
* Returns the cloned/transformed blocks and array of existing Query Loop
|
|
176
|
+
* client ids for further manipulation, in order to avoid multiple recursions.
|
|
169
177
|
*
|
|
170
|
-
* @param {WPBlock[]}
|
|
171
|
-
* @
|
|
178
|
+
* @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).
|
|
179
|
+
* @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.
|
|
180
|
+
* @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.
|
|
172
181
|
*/
|
|
173
182
|
|
|
174
183
|
|
|
175
184
|
exports.useTaxonomies = useTaxonomies;
|
|
176
185
|
|
|
177
|
-
const
|
|
178
|
-
const
|
|
186
|
+
const getTransformedBlocksFromPattern = (blocks, queryBlockAttributes) => {
|
|
187
|
+
const {
|
|
188
|
+
query: {
|
|
189
|
+
postType,
|
|
190
|
+
inherit
|
|
191
|
+
}
|
|
192
|
+
} = queryBlockAttributes;
|
|
193
|
+
const clonedBlocks = blocks.map(block => (0, _blocks.cloneBlock)(block));
|
|
194
|
+
const queryClientIds = [];
|
|
195
|
+
const blocksQueue = [...clonedBlocks];
|
|
179
196
|
|
|
180
197
|
while (blocksQueue.length > 0) {
|
|
181
198
|
var _block$innerBlocks;
|
|
@@ -183,14 +200,23 @@ const getFirstQueryClientIdFromBlocks = blocks => {
|
|
|
183
200
|
const block = blocksQueue.shift();
|
|
184
201
|
|
|
185
202
|
if (block.name === 'core/query') {
|
|
186
|
-
|
|
203
|
+
block.attributes.query = { ...block.attributes.query,
|
|
204
|
+
postType,
|
|
205
|
+
inherit
|
|
206
|
+
};
|
|
207
|
+
queryClientIds.push(block.clientId);
|
|
187
208
|
}
|
|
188
209
|
|
|
189
210
|
(_block$innerBlocks = block.innerBlocks) === null || _block$innerBlocks === void 0 ? void 0 : _block$innerBlocks.forEach(innerBlock => {
|
|
190
211
|
blocksQueue.push(innerBlock);
|
|
191
212
|
});
|
|
192
213
|
}
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
newBlocks: clonedBlocks,
|
|
217
|
+
queryClientIds
|
|
218
|
+
};
|
|
193
219
|
};
|
|
194
220
|
|
|
195
|
-
exports.
|
|
221
|
+
exports.getTransformedBlocksFromPattern = getTransformedBlocksFromPattern;
|
|
196
222
|
//# sourceMappingURL=utils.js.map
|
package/build/query/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/query/utils.js"],"names":["getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","mapToIHasNameAndId","path","map","usePostTypes","postTypes","select","getPostTypes","coreStore","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","value","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","getFirstQueryClientIdFromBlocks","blocks","blocksQueue","block","shift","clientId","innerBlocks","forEach","innerBlock"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAXA;AACA;AACA;;AAGA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,eAAe,GAAKC,QAAF,IAAgB;AAC9C,QAAMC,OAAO,GAAGD,QAAH,aAAGA,QAAH,uBAAGA,QAAQ,CAAEE,MAAV,CACf,CAAEC,WAAF,EAAeC,MAAf,KAA2B;AAC1B,UAAM;AAAEC,MAAAA,OAAF;AAAWC,MAAAA,SAAX;AAAsBC,MAAAA;AAAtB,QAAgCJ,WAAtC;AACAE,IAAAA,OAAO,CAAED,MAAM,CAACI,EAAT,CAAP,GAAuBJ,MAAvB;AACAE,IAAAA,SAAS,CAAEF,MAAM,CAACK,IAAT,CAAT,GAA2BL,MAA3B;AACAG,IAAAA,KAAK,CAACG,IAAN,CAAYN,MAAM,CAACK,IAAnB;AACA,WAAON,WAAP;AACA,GAPc,EAQf;AAAEE,IAAAA,OAAO,EAAE,EAAX;AAAeC,IAAAA,SAAS,EAAE,EAA1B;AAA8BC,IAAAA,KAAK,EAAE;AAArC,GARe,CAAhB;AAUA,SAAO;AACNP,IAAAA,QADM;AAEN,OAAGC;AAFG,GAAP;AAIA,CAfM;AAiBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMU,kBAAkB,GAAG,CAAEX,QAAF,EAAYY,IAAZ,KAAsB;AACvD,SAAO,CAAEZ,QAAQ,IAAI,EAAd,EAAmBa,GAAnB,CAA0BT,MAAF,KAAgB,EAC9C,GAAGA,MAD2C;AAE9CK,IAAAA,IAAI,EAAE,kCAAgB,iBAAKL,MAAL,EAAaQ,IAAb,CAAhB;AAFwC,GAAhB,CA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M9B,CAAET,SAAF,CAN8B,CAA/B;AAQA,SAAO;AAAEW,IAAAA,sBAAF;AAA0BI,IAAAA;AAA1B,GAAP;AACA,CA1BM;AA4BP;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMK,aAAa,GAAKC,QAAF,IAAgB;AAC5C,QAAMP,UAAU,GAAG,qBAChBb,MAAF,IAAc;AACb,UAAM;AAAEqB,MAAAA;AAAF,QAAoBrB,MAAM,CAAEE,eAAF,CAAhC;AACA,UAAMoB,kBAAkB,GAAGD,aAAa,CAAE;AACzCT,MAAAA,IAAI,EAAEQ,QADmC;AAEzCf,MAAAA,QAAQ,EAAE,CAAC,CAF8B;AAGzCkB,MAAAA,OAAO,EAAE;AAHgC,KAAF,CAAxC;AAKA,WAAOD,kBAAP;AACA,GATiB,EAUlB,CAAEF,QAAF,CAVkB,CAAnB;AAYA,SAAOP,UAAP;AACA,CAdM;AAgBP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMW,+BAA+B,GAAKC,MAAF,IAAc;AAC5D,QAAMC,WAAW,GAAG,CAAE,GAAGD,MAAL,CAApB;;AACA,SAAQC,WAAW,CAACf,MAAZ,GAAqB,CAA7B,EAAiC;AAAA;;AAChC,UAAMgB,KAAK,GAAGD,WAAW,CAACE,KAAZ,EAAd;;AACA,QAAKD,KAAK,CAAClC,IAAN,KAAe,YAApB,EAAmC;AAClC,aAAOkC,KAAK,CAACE,QAAb;AACA;;AACD,0BAAAF,KAAK,CAACG,WAAN,0EAAmBC,OAAnB,CAA8BC,UAAF,IAAkB;AAC7CN,MAAAA,WAAW,CAAChC,IAAZ,CAAkBsC,UAAlB;AACA,KAFD;AAGA;AACD,CAXM","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( get( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = 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\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Recurses over a list of blocks and returns the first found\n * Query Loop block's clientId.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through.\n * @return {string=} The first found Query Loop's clientId.\n */\nexport const getFirstQueryClientIdFromBlocks = ( blocks ) => {\n\tconst blocksQueue = [ ...blocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\treturn block.clientId;\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n};\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/query/utils.js"],"names":["getEntitiesInfo","entities","mapping","reduce","accumulator","entity","mapById","mapByName","names","id","name","push","mapToIHasNameAndId","path","map","usePostTypes","postTypes","select","getPostTypes","coreStore","excludedPostTypes","filteredPostTypes","per_page","filter","viewable","slug","includes","postTypesTaxonomiesMap","length","type","taxonomies","postTypesSelectOptions","labels","label","singular_name","value","useTaxonomies","postType","getTaxonomies","filteredTaxonomies","context","getTransformedBlocksFromPattern","blocks","queryBlockAttributes","query","inherit","clonedBlocks","block","queryClientIds","blocksQueue","shift","attributes","clientId","innerBlocks","forEach","innerBlock","newBlocks"],"mappings":";;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAZA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,eAAe,GAAKC,QAAF,IAAgB;AAC9C,QAAMC,OAAO,GAAGD,QAAH,aAAGA,QAAH,uBAAGA,QAAQ,CAAEE,MAAV,CACf,CAAEC,WAAF,EAAeC,MAAf,KAA2B;AAC1B,UAAM;AAAEC,MAAAA,OAAF;AAAWC,MAAAA,SAAX;AAAsBC,MAAAA;AAAtB,QAAgCJ,WAAtC;AACAE,IAAAA,OAAO,CAAED,MAAM,CAACI,EAAT,CAAP,GAAuBJ,MAAvB;AACAE,IAAAA,SAAS,CAAEF,MAAM,CAACK,IAAT,CAAT,GAA2BL,MAA3B;AACAG,IAAAA,KAAK,CAACG,IAAN,CAAYN,MAAM,CAACK,IAAnB;AACA,WAAON,WAAP;AACA,GAPc,EAQf;AAAEE,IAAAA,OAAO,EAAE,EAAX;AAAeC,IAAAA,SA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AGA,QAAMG,YAAY,GAAGJ,MAAM,CAAC5B,GAAP,CAAciC,KAAF,IAAa,wBAAYA,KAAZ,CAAzB,CAArB;AACA,QAAMC,cAAc,GAAG,EAAvB;AACA,QAAMC,WAAW,GAAG,CAAE,GAAGH,YAAL,CAApB;;AACA,SAAQG,WAAW,CAACrB,MAAZ,GAAqB,CAA7B,EAAiC;AAAA;;AAChC,UAAMmB,KAAK,GAAGE,WAAW,CAACC,KAAZ,EAAd;;AACA,QAAKH,KAAK,CAACrC,IAAN,KAAe,YAApB,EAAmC;AAClCqC,MAAAA,KAAK,CAACI,UAAN,CAAiBP,KAAjB,GAAyB,EACxB,GAAGG,KAAK,CAACI,UAAN,CAAiBP,KADI;AAExBP,QAAAA,QAFwB;AAGxBQ,QAAAA;AAHwB,OAAzB;AAKAG,MAAAA,cAAc,CAACrC,IAAf,CAAqBoC,KAAK,CAACK,QAA3B;AACA;;AACD,0BAAAL,KAAK,CAACM,WAAN,0EAAmBC,OAAnB,CAA8BC,UAAF,IAAkB;AAC7CN,MAAAA,WAAW,CAACtC,IAAZ,CAAkB4C,UAAlB;AACA,KAFD;AAGA;;AACD,SAAO;AAAEC,IAAAA,SAAS,EAAEV,YAAb;AAA2BE,IAAAA;AAA3B,GAAP;AACA,CAzBM","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMemo } from '@wordpress/element';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { cloneBlock } from '@wordpress/blocks';\n\n/**\n * @typedef IHasNameAndId\n * @property {string|number} id The entity's id.\n * @property {string} name The entity's name.\n */\n\n/**\n * The object used in Query block that contains info and helper mappings\n * from an array of IHasNameAndId objects.\n *\n * @typedef {Object} QueryEntitiesInfo\n * @property {IHasNameAndId[]} entities The array of entities.\n * @property {Object<string, IHasNameAndId>} mapById Object mapping with the id as key and the entity as value.\n * @property {Object<string, IHasNameAndId>} mapByName Object mapping with the name as key and the entity as value.\n * @property {string[]} names Array with the entities' names.\n */\n\n/**\n * Returns a helper object with mapping from Objects that implement\n * the `IHasNameAndId` interface. The returned object is used for\n * integration with `FormTokenField` component.\n *\n * @param {IHasNameAndId[]} entities The entities to extract of helper object.\n * @return {QueryEntitiesInfo} The object with the entities information.\n */\nexport const getEntitiesInfo = ( entities ) => {\n\tconst mapping = entities?.reduce(\n\t\t( accumulator, entity ) => {\n\t\t\tconst { mapById, mapByName, names } = accumulator;\n\t\t\tmapById[ entity.id ] = entity;\n\t\t\tmapByName[ entity.name ] = entity;\n\t\t\tnames.push( entity.name );\n\t\t\treturn accumulator;\n\t\t},\n\t\t{ mapById: {}, mapByName: {}, names: [] }\n\t);\n\treturn {\n\t\tentities,\n\t\t...mapping,\n\t};\n};\n\n/**\n * Helper util to map records to add a `name` prop from a\n * provided path, in order to handle all entities in the same\n * fashion(implementing`IHasNameAndId` interface).\n *\n * @param {Object[]} entities The array of entities.\n * @param {string} path The path to map a `name` property from the entity.\n * @return {IHasNameAndId[]} An array of enitities that now implement the `IHasNameAndId` interface.\n */\nexport const mapToIHasNameAndId = ( entities, path ) => {\n\treturn ( entities || [] ).map( ( entity ) => ( {\n\t\t...entity,\n\t\tname: decodeEntities( get( entity, path ) ),\n\t} ) );\n};\n\n/**\n * Returns a helper object that contains:\n * 1. An `options` object from the available post types, to be passed to a `SelectControl`.\n * 2. A helper map with available taxonomies per post type.\n *\n * @return {Object} The helper object related to post types.\n */\nexport const usePostTypes = () => {\n\tconst postTypes = useSelect( ( select ) => {\n\t\tconst { getPostTypes } = select( coreStore );\n\t\tconst excludedPostTypes = [ 'attachment' ];\n\t\tconst filteredPostTypes = getPostTypes( { per_page: -1 } )?.filter(\n\t\t\t( { viewable, slug } ) =>\n\t\t\t\tviewable && ! excludedPostTypes.includes( slug )\n\t\t);\n\t\treturn filteredPostTypes;\n\t}, [] );\n\tconst postTypesTaxonomiesMap = useMemo( () => {\n\t\tif ( ! postTypes?.length ) return;\n\t\treturn postTypes.reduce( ( accumulator, type ) => {\n\t\t\taccumulator[ type.slug ] = type.taxonomies;\n\t\t\treturn accumulator;\n\t\t}, {} );\n\t}, [ postTypes ] );\n\tconst postTypesSelectOptions = useMemo(\n\t\t() =>\n\t\t\t( postTypes || [] ).map( ( { labels, slug } ) => ( {\n\t\t\t\tlabel: labels.singular_name,\n\t\t\t\tvalue: slug,\n\t\t\t} ) ),\n\t\t[ postTypes ]\n\t);\n\treturn { postTypesTaxonomiesMap, postTypesSelectOptions };\n};\n\n/**\n * Hook that returns the taxonomies associated with a specific post type.\n *\n * @param {string} postType The post type from which to retrieve the associated taxonomies.\n * @return {Object[]} An array of the associated taxonomies.\n */\nexport const useTaxonomies = ( postType ) => {\n\tconst taxonomies = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getTaxonomies } = select( coreStore );\n\t\t\tconst filteredTaxonomies = 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\treturn filteredTaxonomies;\n\t\t},\n\t\t[ postType ]\n\t);\n\treturn taxonomies;\n};\n\n/**\n * Clones a pattern's blocks and then recurses over that list of blocks,\n * transforming them to retain some `query` attribute properties.\n * For now we retain the `postType` and `inherit` properties as they are\n * fundamental for the expected functionality of the block and don't affect\n * its design and presentation.\n *\n * Returns the cloned/transformed blocks and array of existing Query Loop\n * client ids for further manipulation, in order to avoid multiple recursions.\n *\n * @param {WPBlock[]} blocks The list of blocks to look through and transform(mutate).\n * @param {Record<string,*>} queryBlockAttributes The existing Query Loop's attributes.\n * @return {{ newBlocks: WPBlock[], queryClientIds: string[] }} An object with the cloned/transformed blocks and all the Query Loop clients from these blocks.\n */\nexport const getTransformedBlocksFromPattern = (\n\tblocks,\n\tqueryBlockAttributes\n) => {\n\tconst {\n\t\tquery: { postType, inherit },\n\t} = queryBlockAttributes;\n\tconst clonedBlocks = blocks.map( ( block ) => cloneBlock( block ) );\n\tconst queryClientIds = [];\n\tconst blocksQueue = [ ...clonedBlocks ];\n\twhile ( blocksQueue.length > 0 ) {\n\t\tconst block = blocksQueue.shift();\n\t\tif ( block.name === 'core/query' ) {\n\t\t\tblock.attributes.query = {\n\t\t\t\t...block.attributes.query,\n\t\t\t\tpostType,\n\t\t\t\tinherit,\n\t\t\t};\n\t\t\tqueryClientIds.push( block.clientId );\n\t\t}\n\t\tblock.innerBlocks?.forEach( ( innerBlock ) => {\n\t\t\tblocksQueue.push( innerBlock );\n\t\t} );\n\t}\n\treturn { newBlocks: clonedBlocks, queryClientIds };\n};\n"]}
|
|
@@ -15,7 +15,7 @@ var _i18n = require("@wordpress/i18n");
|
|
|
15
15
|
* WordPress dependencies
|
|
16
16
|
*/
|
|
17
17
|
const TEMPLATE = [['core/paragraph', {
|
|
18
|
-
placeholder: (0, _i18n.__)('Add text or blocks that will display when
|
|
18
|
+
placeholder: (0, _i18n.__)('Add text or blocks that will display when a query returns no results.')
|
|
19
19
|
}]];
|
|
20
20
|
|
|
21
21
|
function QueryNoResultsEdit() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/query-no-results/edit.js"],"names":["TEMPLATE","placeholder","QueryNoResultsEdit","blockProps","innerBlocksProps","template"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,MAAMA,QAAQ,GAAG,CAChB,CACC,gBADD,EAEC;AACCC,EAAAA,WAAW,EAAE,cACZ,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/query-no-results/edit.js"],"names":["TEMPLATE","placeholder","QueryNoResultsEdit","blockProps","innerBlocksProps","template"],"mappings":";;;;;;;;;AAGA;;AACA;;AAJA;AACA;AACA;AAIA,MAAMA,QAAQ,GAAG,CAChB,CACC,gBADD,EAEC;AACCC,EAAAA,WAAW,EAAE,cACZ,uEADY;AADd,CAFD,CADgB,CAAjB;;AAWe,SAASC,kBAAT,GAA8B;AAC5C,QAAMC,UAAU,GAAG,iCAAnB;AACA,QAAMC,gBAAgB,GAAG,sCAAqBD,UAArB,EAAiC;AACzDE,IAAAA,QAAQ,EAAEL;AAD+C,GAAjC,CAAzB;AAIA,SAAO,mCAAUI,gBAAV,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\n\nconst TEMPLATE = [\n\t[\n\t\t'core/paragraph',\n\t\t{\n\t\t\tplaceholder: __(\n\t\t\t\t'Add text or blocks that will display when a query returns no results.'\n\t\t\t),\n\t\t},\n\t],\n];\n\nexport default function QueryNoResultsEdit() {\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t} );\n\n\treturn <div { ...innerBlocksProps } />;\n}\n"]}
|
|
@@ -37,6 +37,19 @@ const metadata = {
|
|
|
37
37
|
color: {
|
|
38
38
|
gradients: true,
|
|
39
39
|
link: true
|
|
40
|
+
},
|
|
41
|
+
typography: {
|
|
42
|
+
fontSize: true,
|
|
43
|
+
lineHeight: true,
|
|
44
|
+
__experimentalFontFamily: true,
|
|
45
|
+
__experimentalFontWeight: true,
|
|
46
|
+
__experimentalFontStyle: true,
|
|
47
|
+
__experimentalTextTransform: true,
|
|
48
|
+
__experimentalTextDecoration: true,
|
|
49
|
+
__experimentalLetterSpacing: true,
|
|
50
|
+
__experimentalDefaultControls: {
|
|
51
|
+
fontSize: true
|
|
52
|
+
}
|
|
40
53
|
}
|
|
41
54
|
}
|
|
42
55
|
};
|