@wordpress/block-library 7.11.0 → 7.13.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 +9 -1
- package/build/archives/edit.js +7 -0
- package/build/archives/edit.js.map +1 -1
- package/build/archives/index.js +9 -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/block/edit.js +4 -2
- package/build/block/edit.js.map +1 -1
- package/build/block/edit.native.js +4 -2
- package/build/block/edit.native.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/calendar/edit.js +12 -5
- package/build/calendar/edit.js.map +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 +8 -3
- package/build/columns/edit.native.js.map +1 -1
- package/build/columns/index.js +13 -0
- package/build/columns/index.js.map +1 -1
- package/build/comment-author-name/index.js +5 -1
- package/build/comment-author-name/index.js.map +1 -1
- package/build/comment-content/index.js +5 -1
- package/build/comment-content/index.js.map +1 -1
- package/build/comment-date/index.js +1 -0
- package/build/comment-date/index.js.map +1 -1
- package/build/comment-edit-link/index.js +5 -1
- package/build/comment-edit-link/index.js.map +1 -1
- package/build/comment-reply-link/index.js +5 -1
- package/build/comment-reply-link/index.js.map +1 -1
- package/build/comment-template/index.js +14 -1
- package/build/comment-template/index.js.map +1 -1
- package/build/comments/index.js +13 -0
- package/build/comments/index.js.map +1 -1
- package/build/comments-pagination/index.js +13 -0
- package/build/comments-pagination/index.js.map +1 -1
- package/build/comments-pagination-next/index.js +4 -2
- package/build/comments-pagination-next/index.js.map +1 -1
- package/build/comments-pagination-numbers/edit.js +5 -1
- package/build/comments-pagination-numbers/edit.js.map +1 -1
- package/build/comments-pagination-numbers/index.js +14 -1
- package/build/comments-pagination-numbers/index.js.map +1 -1
- package/build/comments-pagination-previous/index.js +4 -2
- package/build/comments-pagination-previous/index.js.map +1 -1
- package/build/comments-title/deprecated.js +4 -2
- package/build/comments-title/deprecated.js.map +1 -1
- package/build/comments-title/index.js +4 -2
- package/build/comments-title/index.js.map +1 -1
- package/build/cover/deprecated.js +20 -5
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit/resizable-cover.js +6 -0
- package/build/cover/edit/resizable-cover.js.map +1 -1
- package/build/cover/index.js +13 -0
- package/build/cover/index.js.map +1 -1
- package/build/cover/shared.js +1 -1
- package/build/cover/shared.js.map +1 -1
- package/build/embed/icons.js +1 -1
- package/build/embed/icons.js.map +1 -1
- package/build/gallery/deprecated.js +6 -1
- package/build/gallery/deprecated.js.map +1 -1
- package/build/gallery/edit.js +15 -2
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/index.js +5 -0
- package/build/gallery/index.js.map +1 -1
- package/build/gallery/transforms.js +20 -7
- package/build/gallery/transforms.js.map +1 -1
- package/build/gallery/utils.js +7 -6
- package/build/gallery/utils.js.map +1 -1
- package/build/group/deprecated.js +108 -12
- package/build/group/deprecated.js.map +1 -1
- package/build/group/edit.js +23 -1
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +10 -2
- package/build/group/index.js.map +1 -1
- package/build/group/transforms.js +5 -0
- package/build/group/transforms.js.map +1 -1
- package/build/group/variations.js +8 -8
- package/build/group/variations.js.map +1 -1
- package/build/heading/deprecated.js +5 -3
- package/build/heading/deprecated.js.map +1 -1
- package/build/heading/index.js +3 -1
- package/build/heading/index.js.map +1 -1
- package/build/heading/transforms.js +3 -1
- package/build/heading/transforms.js.map +1 -1
- package/build/home-link/edit.js +8 -4
- package/build/home-link/edit.js.map +1 -1
- package/build/image/edit.js +13 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/index.js +13 -7
- package/build/image/index.js.map +1 -1
- package/build/index.native.js +23 -7
- package/build/index.native.js.map +1 -1
- package/build/list/index.js +10 -0
- package/build/list/index.js.map +1 -1
- package/build/list/v2/edit.js +16 -5
- package/build/list/v2/edit.js.map +1 -1
- package/build/list/v2/tag-name.js +31 -0
- package/build/list/v2/tag-name.js.map +1 -0
- package/build/list/v2/tag-name.native.js +32 -0
- package/build/list/v2/tag-name.native.js.map +1 -0
- package/build/list/v2/transforms.js +1 -11
- package/build/list/v2/transforms.js.map +1 -1
- package/build/list-item/edit.js +4 -1
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/edit.native.js +158 -0
- package/build/list-item/edit.native.js.map +1 -0
- package/build/list-item/hooks/index.js +8 -0
- package/build/list-item/hooks/index.js.map +1 -1
- package/build/list-item/hooks/use-copy.js +42 -0
- package/build/list-item/hooks/use-copy.js.map +1 -0
- package/build/list-item/icons.native.js +53 -0
- package/build/list-item/icons.native.js.map +1 -0
- package/build/list-item/list-style-type.native.js +139 -0
- package/build/list-item/list-style-type.native.js.map +1 -0
- package/build/list-item/utils.js +4 -0
- package/build/list-item/utils.js.map +1 -1
- package/build/media-text/deprecated.js +193 -67
- package/build/media-text/deprecated.js.map +1 -1
- package/build/media-text/edit.js +2 -1
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/index.js +17 -0
- package/build/media-text/index.js.map +1 -1
- package/build/media-text/media-container.js +1 -1
- package/build/media-text/media-container.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 +180 -154
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +11 -14
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +4 -2
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/responsive-wrapper.js +13 -3
- package/build/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +2 -1
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +4 -7
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js +5 -1
- package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build/navigation/edit/use-inner-blocks.js +43 -0
- package/build/navigation/edit/use-inner-blocks.js.map +1 -0
- package/build/navigation/edit/utils.js +28 -0
- package/build/navigation/edit/utils.js.map +1 -0
- 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 +15 -10
- 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/edit.js +5 -2
- package/build/post-author/edit.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/edit.js +7 -1
- package/build/post-author-biography/edit.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-content/edit.js +4 -2
- package/build/post-content/edit.js.map +1 -1
- package/build/post-date/edit.js +9 -2
- package/build/post-date/edit.js.map +1 -1
- package/build/post-date/index.js +9 -0
- package/build/post-date/index.js.map +1 -1
- package/build/post-featured-image/edit.js +43 -14
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-featured-image/index.js +21 -0
- package/build/post-featured-image/index.js.map +1 -1
- package/build/post-navigation-link/index.js +3 -2
- package/build/post-navigation-link/index.js.map +1 -1
- package/build/post-template/edit.js +8 -4
- package/build/post-template/edit.js.map +1 -1
- package/build/post-template/index.js +14 -1
- package/build/post-template/index.js.map +1 -1
- package/build/post-terms/index.js +5 -3
- package/build/post-terms/index.js.map +1 -1
- package/build/post-title/index.js +2 -1
- package/build/post-title/index.js.map +1 -1
- package/build/preformatted/index.js +4 -2
- package/build/preformatted/index.js.map +1 -1
- package/build/pullquote/deprecated.js +135 -25
- package/build/pullquote/deprecated.js.map +1 -1
- package/build/pullquote/edit.js +1 -1
- package/build/pullquote/edit.js.map +1 -1
- package/build/pullquote/edit.native.js +0 -1
- package/build/pullquote/edit.native.js.map +1 -1
- package/build/pullquote/index.js +13 -6
- package/build/pullquote/index.js.map +1 -1
- package/build/pullquote/save.js +2 -2
- package/build/pullquote/save.js.map +1 -1
- package/build/pullquote/transforms.js +14 -33
- package/build/pullquote/transforms.js.map +1 -1
- package/build/query/deprecated.js +10 -9
- package/build/query/deprecated.js.map +1 -1
- package/build/query/edit/index.js +19 -8
- package/build/query/edit/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +42 -9
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +22 -14
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query/edit/query-placeholder.js +6 -1
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/utils.js +35 -9
- package/build/query/utils.js.map +1 -1
- package/build/query-no-results/edit.js +1 -1
- package/build/query-no-results/edit.js.map +1 -1
- package/build/query-title/edit.js +30 -8
- package/build/query-title/edit.js.map +1 -1
- package/build/query-title/index.js +11 -2
- package/build/query-title/index.js.map +1 -1
- package/build/query-title/variations.js +10 -0
- package/build/query-title/variations.js.map +1 -1
- package/build/quote/deprecated.js +13 -6
- package/build/quote/deprecated.js.map +1 -1
- package/build/quote/transforms.js +24 -39
- 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/edit.js +1 -1
- package/build/separator/edit.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 +44 -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/edit/index.js +4 -2
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/index.js +2 -2
- package/build/template-part/index.js.map +1 -1
- package/build/term-description/index.js +4 -0
- package/build/term-description/index.js.map +1 -1
- package/build/text-columns/edit.js +3 -1
- package/build/text-columns/edit.js.map +1 -1
- package/build/text-columns/save.js +3 -1
- package/build/text-columns/save.js.map +1 -1
- package/build/verse/index.js +1 -0
- package/build/verse/index.js.map +1 -1
- package/build/video/index.js +4 -0
- package/build/video/index.js.map +1 -1
- package/build-module/archives/edit.js +7 -0
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/archives/index.js +9 -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/block/edit.js +5 -3
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/edit.native.js +5 -3
- package/build-module/block/edit.native.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/calendar/edit.js +12 -4
- package/build-module/calendar/edit.js.map +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 +9 -4
- package/build-module/columns/edit.native.js.map +1 -1
- package/build-module/columns/index.js +13 -0
- package/build-module/columns/index.js.map +1 -1
- package/build-module/comment-author-name/index.js +5 -1
- package/build-module/comment-author-name/index.js.map +1 -1
- package/build-module/comment-content/index.js +5 -1
- package/build-module/comment-content/index.js.map +1 -1
- package/build-module/comment-date/index.js +1 -0
- package/build-module/comment-date/index.js.map +1 -1
- package/build-module/comment-edit-link/index.js +5 -1
- package/build-module/comment-edit-link/index.js.map +1 -1
- package/build-module/comment-reply-link/index.js +5 -1
- package/build-module/comment-reply-link/index.js.map +1 -1
- package/build-module/comment-template/index.js +14 -1
- package/build-module/comment-template/index.js.map +1 -1
- package/build-module/comments/index.js +13 -0
- package/build-module/comments/index.js.map +1 -1
- package/build-module/comments-pagination/index.js +13 -0
- package/build-module/comments-pagination/index.js.map +1 -1
- package/build-module/comments-pagination-next/index.js +4 -2
- package/build-module/comments-pagination-next/index.js.map +1 -1
- package/build-module/comments-pagination-numbers/edit.js +5 -1
- package/build-module/comments-pagination-numbers/edit.js.map +1 -1
- package/build-module/comments-pagination-numbers/index.js +14 -1
- package/build-module/comments-pagination-numbers/index.js.map +1 -1
- package/build-module/comments-pagination-previous/index.js +4 -2
- package/build-module/comments-pagination-previous/index.js.map +1 -1
- package/build-module/comments-title/deprecated.js +4 -2
- package/build-module/comments-title/deprecated.js.map +1 -1
- package/build-module/comments-title/index.js +4 -2
- package/build-module/comments-title/index.js.map +1 -1
- package/build-module/cover/deprecated.js +20 -4
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit/resizable-cover.js +6 -0
- package/build-module/cover/edit/resizable-cover.js.map +1 -1
- package/build-module/cover/index.js +13 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/shared.js +1 -1
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/embed/icons.js +1 -1
- package/build-module/embed/icons.js.map +1 -1
- package/build-module/gallery/deprecated.js +7 -2
- package/build-module/gallery/deprecated.js.map +1 -1
- package/build-module/gallery/edit.js +15 -2
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/index.js +5 -0
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/gallery/transforms.js +20 -7
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/gallery/utils.js +7 -6
- package/build-module/gallery/utils.js.map +1 -1
- package/build-module/group/deprecated.js +109 -12
- package/build-module/group/deprecated.js.map +1 -1
- package/build-module/group/edit.js +25 -2
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +10 -2
- package/build-module/group/index.js.map +1 -1
- package/build-module/group/transforms.js +5 -0
- package/build-module/group/transforms.js.map +1 -1
- package/build-module/group/variations.js +8 -8
- package/build-module/group/variations.js.map +1 -1
- package/build-module/heading/deprecated.js +5 -2
- package/build-module/heading/deprecated.js.map +1 -1
- package/build-module/heading/index.js +3 -1
- package/build-module/heading/index.js.map +1 -1
- package/build-module/heading/transforms.js +3 -1
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/home-link/edit.js +10 -6
- package/build-module/home-link/edit.js.map +1 -1
- package/build-module/image/edit.js +14 -2
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/index.js +13 -7
- package/build-module/image/index.js.map +1 -1
- package/build-module/index.native.js +22 -6
- package/build-module/index.native.js.map +1 -1
- package/build-module/list/index.js +5 -1
- package/build-module/list/index.js.map +1 -1
- package/build-module/list/v2/edit.js +15 -5
- package/build-module/list/v2/edit.js.map +1 -1
- package/build-module/list/v2/tag-name.js +21 -0
- package/build-module/list/v2/tag-name.js.map +1 -0
- package/build-module/list/v2/tag-name.native.js +21 -0
- package/build-module/list/v2/tag-name.native.js.map +1 -0
- package/build-module/list/v2/transforms.js +1 -10
- package/build-module/list/v2/transforms.js.map +1 -1
- package/build-module/list-item/edit.js +5 -5
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/edit.native.js +141 -0
- package/build-module/list-item/edit.native.js.map +1 -0
- package/build-module/list-item/hooks/index.js +1 -0
- package/build-module/list-item/hooks/index.js.map +1 -1
- package/build-module/list-item/hooks/use-copy.js +32 -0
- package/build-module/list-item/hooks/use-copy.js.map +1 -0
- package/build-module/list-item/icons.native.js +37 -0
- package/build-module/list-item/icons.native.js.map +1 -0
- package/build-module/list-item/list-style-type.native.js +126 -0
- package/build-module/list-item/list-style-type.native.js.map +1 -0
- package/build-module/list-item/utils.js +4 -0
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/media-text/deprecated.js +195 -67
- package/build-module/media-text/deprecated.js.map +1 -1
- package/build-module/media-text/edit.js +2 -1
- package/build-module/media-text/edit.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/media-text/media-container.js +1 -1
- package/build-module/media-text/media-container.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 +178 -154
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +12 -15
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +4 -2
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/responsive-wrapper.js +12 -3
- package/build-module/navigation/edit/responsive-wrapper.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +2 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +4 -7
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js +5 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build-module/navigation/edit/use-inner-blocks.js +33 -0
- package/build-module/navigation/edit/use-inner-blocks.js.map +1 -0
- package/build-module/navigation/edit/utils.js +21 -0
- package/build-module/navigation/edit/utils.js.map +1 -0
- 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 +15 -10
- 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/edit.js +5 -2
- package/build-module/post-author/edit.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/edit.js +6 -1
- package/build-module/post-author-biography/edit.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-content/edit.js +5 -3
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-date/edit.js +9 -2
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-date/index.js +9 -0
- package/build-module/post-date/index.js.map +1 -1
- package/build-module/post-featured-image/edit.js +45 -16
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-featured-image/index.js +21 -0
- package/build-module/post-featured-image/index.js.map +1 -1
- package/build-module/post-navigation-link/index.js +3 -2
- package/build-module/post-navigation-link/index.js.map +1 -1
- package/build-module/post-template/edit.js +8 -4
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-template/index.js +14 -1
- package/build-module/post-template/index.js.map +1 -1
- package/build-module/post-terms/index.js +5 -3
- package/build-module/post-terms/index.js.map +1 -1
- package/build-module/post-title/index.js +2 -1
- package/build-module/post-title/index.js.map +1 -1
- package/build-module/preformatted/index.js +4 -2
- package/build-module/preformatted/index.js.map +1 -1
- package/build-module/pullquote/deprecated.js +134 -25
- package/build-module/pullquote/deprecated.js.map +1 -1
- package/build-module/pullquote/edit.js +1 -1
- package/build-module/pullquote/edit.js.map +1 -1
- package/build-module/pullquote/edit.native.js +0 -1
- package/build-module/pullquote/edit.native.js.map +1 -1
- package/build-module/pullquote/index.js +13 -6
- package/build-module/pullquote/index.js.map +1 -1
- package/build-module/pullquote/save.js +2 -2
- package/build-module/pullquote/save.js.map +1 -1
- package/build-module/pullquote/transforms.js +15 -34
- package/build-module/pullquote/transforms.js.map +1 -1
- package/build-module/query/deprecated.js +10 -8
- package/build-module/query/deprecated.js.map +1 -1
- package/build-module/query/edit/index.js +23 -12
- package/build-module/query/edit/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +42 -9
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +17 -12
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +6 -1
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/utils.js +32 -7
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query-no-results/edit.js +1 -1
- package/build-module/query-no-results/edit.js.map +1 -1
- package/build-module/query-title/edit.js +30 -9
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/query-title/index.js +11 -2
- package/build-module/query-title/index.js.map +1 -1
- package/build-module/query-title/variations.js +10 -0
- package/build-module/query-title/variations.js.map +1 -1
- package/build-module/quote/deprecated.js +13 -5
- package/build-module/quote/deprecated.js.map +1 -1
- package/build-module/quote/transforms.js +25 -40
- 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/edit.js +1 -1
- package/build-module/separator/edit.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 +46 -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/edit/index.js +5 -3
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/index.js +2 -2
- package/build-module/template-part/index.js.map +1 -1
- package/build-module/term-description/index.js +4 -0
- package/build-module/term-description/index.js.map +1 -1
- package/build-module/text-columns/edit.js +4 -2
- package/build-module/text-columns/edit.js.map +1 -1
- package/build-module/text-columns/save.js +4 -2
- package/build-module/text-columns/save.js.map +1 -1
- package/build-module/verse/index.js +1 -0
- package/build-module/verse/index.js.map +1 -1
- package/build-module/video/index.js +4 -0
- package/build-module/video/index.js.map +1 -1
- package/build-style/audio/style-rtl.css +3 -0
- package/build-style/audio/style.css +3 -0
- package/build-style/button/style-rtl.css +6 -6
- package/build-style/button/style.css +6 -6
- package/build-style/editor-rtl.css +115 -122
- package/build-style/editor.css +115 -122
- package/build-style/group/editor-rtl.css +27 -8
- package/build-style/group/editor.css +27 -8
- package/build-style/image/editor-rtl.css +21 -2
- package/build-style/image/editor.css +21 -2
- package/build-style/latest-posts/editor-rtl.css +3 -0
- package/build-style/latest-posts/editor.css +3 -0
- 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 +8 -4
- package/build-style/navigation/editor.css +8 -4
- package/build-style/navigation/style-rtl.css +17 -19
- package/build-style/navigation/style.css +17 -19
- 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/editor-rtl.css +7 -0
- package/build-style/query/editor.css +7 -0
- package/build-style/query-pagination/style-rtl.css +6 -0
- package/build-style/query-pagination/style.css +6 -0
- package/build-style/query-title/style-rtl.css +79 -0
- package/build-style/query-title/style.css +79 -0
- package/build-style/search/style-rtl.css +2 -0
- package/build-style/search/style.css +2 -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 +52 -35
- package/build-style/style.css +52 -35
- package/build-style/tag-cloud/style-rtl.css +1 -0
- package/build-style/tag-cloud/style.css +1 -0
- package/build-style/video/style-rtl.css +3 -0
- package/build-style/video/style.css +3 -0
- package/package.json +30 -30
- package/src/archives/block.json +9 -1
- package/src/archives/edit.js +12 -1
- package/src/archives/index.php +5 -3
- package/src/audio/block.json +4 -0
- package/src/audio/style.scss +2 -0
- package/src/audio/test/__snapshots__/edit.native.js.snap +16 -2
- package/src/block/edit.js +4 -4
- package/src/block/edit.native.js +4 -4
- package/src/button/block.json +1 -1
- package/src/button/deprecated.js +21 -22
- package/src/button/style.scss +6 -6
- package/src/calendar/edit.js +11 -4
- package/src/calendar/index.php +2 -2
- package/src/categories/block.json +14 -1
- package/src/categories/edit.js +2 -2
- package/src/code/block.json +4 -2
- package/src/column/block.json +13 -0
- package/src/columns/block.json +13 -0
- package/src/columns/deprecated.js +10 -4
- package/src/columns/edit.js +7 -3
- package/src/columns/edit.native.js +10 -4
- 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/resizable-cover.js +6 -0
- package/src/cover/index.php +2 -2
- package/src/cover/shared.js +2 -1
- package/src/embed/icons.js +1 -1
- package/src/file/test/__snapshots__/edit.native.js.snap +32 -4
- package/src/gallery/block.json +5 -0
- package/src/gallery/deprecated.js +4 -2
- package/src/gallery/edit.js +22 -2
- package/src/gallery/transforms.js +18 -5
- package/src/gallery/utils.js +11 -7
- package/src/group/block.json +10 -2
- package/src/group/deprecated.js +89 -2
- package/src/group/edit.js +15 -2
- package/src/group/editor.scss +28 -3
- package/src/group/transforms.js +7 -0
- package/src/group/variations.js +4 -3
- package/src/heading/block.json +3 -1
- package/src/heading/deprecated.js +4 -2
- package/src/home-link/edit.js +19 -20
- package/src/home-link/index.php +8 -17
- package/src/image/block.json +13 -7
- package/src/image/edit.js +19 -1
- package/src/image/editor.scss +39 -3
- package/src/image/index.php +1 -1
- package/src/image/test/edit.native.js +6 -10
- package/src/index.native.js +30 -12
- package/src/latest-posts/editor.scss +5 -0
- package/src/list/block.json +4 -0
- package/src/list/index.js +1 -1
- package/src/list/test/__snapshots__/edit.native.js.snap +133 -0
- package/src/list/test/edit.native.js +511 -7
- package/src/list/v2/edit.js +12 -4
- package/src/list/v2/tag-name.js +13 -0
- package/src/list/v2/tag-name.native.js +12 -0
- package/src/list/v2/transforms.js +1 -9
- package/src/list-item/edit.js +3 -2
- package/src/list-item/edit.native.js +148 -0
- package/src/list-item/hooks/index.js +1 -0
- package/src/list-item/hooks/use-copy.js +36 -0
- package/src/list-item/icons.native.js +34 -0
- package/src/list-item/list-style-type.native.js +146 -0
- package/src/list-item/style.native.scss +49 -0
- package/src/media-text/block.json +17 -0
- package/src/media-text/deprecated.js +564 -417
- package/src/media-text/edit.js +1 -0
- package/src/media-text/media-container.js +3 -1
- package/src/media-text/style.scss +2 -0
- package/src/media-text/test/media-container.js +24 -0
- package/src/navigation/block.json +1 -0
- package/src/navigation/deprecated.js +4 -2
- package/src/navigation/edit/index.js +234 -237
- package/src/navigation/edit/navigation-menu-selector.js +12 -26
- package/src/navigation/edit/placeholder/index.js +4 -2
- package/src/navigation/edit/responsive-wrapper.js +24 -3
- package/src/navigation/edit/unsaved-inner-blocks.js +3 -1
- package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +31 -37
- package/src/navigation/edit/use-create-navigation-menu.js +4 -0
- package/src/navigation/edit/use-inner-blocks.js +39 -0
- package/src/navigation/edit/utils.js +30 -0
- package/src/navigation/editor.scss +3 -2
- package/src/navigation/index.php +17 -16
- package/src/navigation/menu-items-to-blocks.js +3 -6
- package/src/navigation/style.scss +13 -22
- package/src/navigation/test/use-navigation-menu.js +18 -1
- package/src/navigation/use-navigation-menu.js +20 -13
- package/src/navigation-link/edit.js +9 -13
- package/src/navigation-link/index.php +1 -1
- package/src/navigation-submenu/edit.js +9 -13
- package/src/navigation-submenu/index.php +1 -1
- package/src/page-list/edit.js +6 -2
- package/src/page-list/index.php +4 -4
- 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/edit.js +6 -3
- package/src/post-author-biography/block.json +1 -0
- package/src/post-author-biography/edit.js +4 -1
- 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-content/edit.js +4 -4
- package/src/post-date/block.json +9 -0
- package/src/post-date/edit.js +12 -2
- package/src/post-date/index.php +10 -2
- package/src/post-date/style.scss +4 -0
- package/src/post-featured-image/block.json +21 -0
- package/src/post-featured-image/edit.js +66 -14
- package/src/post-featured-image/editor.scss +44 -53
- package/src/post-featured-image/index.php +64 -5
- package/src/post-featured-image/style.scss +1 -0
- package/src/post-navigation-link/block.json +3 -2
- package/src/post-template/block.json +15 -1
- package/src/post-template/edit.js +6 -1
- package/src/post-template/index.php +7 -4
- package/src/post-terms/block.json +5 -3
- package/src/post-title/block.json +2 -1
- package/src/post-title/index.php +2 -1
- package/src/post-title/style.scss +2 -0
- package/src/preformatted/block.json +4 -2
- package/src/preformatted/test/__snapshots__/edit.native.js.snap +16 -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/index.js +129 -65
- package/src/query/edit/inspector-controls/taxonomy-controls.js +18 -11
- package/src/query/edit/query-placeholder.js +17 -2
- package/src/query/editor.scss +9 -0
- package/src/query/utils.js +29 -7
- package/src/query-no-results/edit.js +1 -1
- package/src/query-pagination/style.scss +14 -0
- package/src/query-title/block.json +11 -2
- package/src/query-title/edit.js +51 -7
- package/src/query-title/index.php +28 -2
- package/src/query-title/style.scss +4 -0
- package/src/query-title/variations.js +13 -0
- package/src/quote/deprecated.js +6 -5
- package/src/quote/transforms.js +6 -24
- package/src/search/index.php +1 -1
- package/src/search/style.scss +2 -0
- package/src/search/test/__snapshots__/edit.native.js.snap +56 -7
- package/src/separator/block.json +1 -0
- package/src/separator/deprecated.js +2 -3
- package/src/separator/edit.js +1 -1
- package/src/separator/test/edit.js +5 -3
- package/src/site-logo/editor.scss +8 -66
- package/src/site-title/index.php +8 -9
- package/src/social-link/icons/reddit.js +1 -1
- package/src/social-link/index.php +2 -2
- 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 +48 -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/tag-cloud/style.scss +1 -0
- package/src/template-part/edit/index.js +4 -4
- package/src/template-part/index.js +3 -2
- package/src/term-description/block.json +4 -0
- package/src/text-columns/edit.js +2 -2
- package/src/text-columns/save.js +2 -2
- package/src/verse/block.json +1 -0
- package/src/video/block.json +4 -0
- package/src/video/style.scss +2 -0
|
@@ -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,SAAS,EAAE,SAA2B;AAAA,UAAzB;AAAEI,QAAAA,OAAF;AAAWE,QAAAA;AAAX,OAAyB;AACrC,aAAO,yBAAa,g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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,QAAM;AAAEC,IAAAA;AAAF,MAAYD,UAAlB;AACA,QAAM;AAAEE,IAAAA,WAAF;AAAeC,IAAAA,MAAf;AAAuB,OAAGC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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;AACLC,IAAAA,OADK;AAELC,IAAAA,KAFK;AAGLC,IAAAA,aAHK;AAILC,IAAAA,OAAO,EAAEC,OAAO,GAAG,KAJd;AA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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,kBAAEE,WAAW,EAAb,iDAAE,aAAeC;AAAtC,KAAP;AACA,GAH+B,EAG7B,EAH6B,CAAhC;AAIA,QAAMC,aAAa,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,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"]}
|
|
@@ -27,7 +27,7 @@ var _authorControl = _interopRequireDefault(require("./author-control"));
|
|
|
27
27
|
|
|
28
28
|
var _parentControl = _interopRequireDefault(require("./parent-control"));
|
|
29
29
|
|
|
30
|
-
var _taxonomyControls =
|
|
30
|
+
var _taxonomyControls = require("./taxonomy-controls");
|
|
31
31
|
|
|
32
32
|
var _stickyControl = _interopRequireDefault(require("./sticky-control"));
|
|
33
33
|
|
|
@@ -75,6 +75,7 @@ function QueryInspectorControls(_ref) {
|
|
|
75
75
|
postTypesTaxonomiesMap,
|
|
76
76
|
postTypesSelectOptions
|
|
77
77
|
} = (0, _utils.usePostTypes)();
|
|
78
|
+
const taxonomiesInfo = (0, _taxonomyControls.useTaxonomiesInfo)(postType);
|
|
78
79
|
const isPostTypeHierarchical = useIsPostTypeHierarchical(postType);
|
|
79
80
|
(0, _element.useEffect)(() => {
|
|
80
81
|
setShowSticky(postType === 'post');
|
|
@@ -119,7 +120,7 @@ function QueryInspectorControls(_ref) {
|
|
|
119
120
|
onChangeDebounced();
|
|
120
121
|
return onChangeDebounced.cancel;
|
|
121
122
|
}, [querySearch, onChangeDebounced]);
|
|
122
|
-
return (0, _element.createElement)(_blockEditor.InspectorControls, null, (0, _element.createElement)(_components.PanelBody, {
|
|
123
|
+
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.InspectorControls, null, (0, _element.createElement)(_components.PanelBody, {
|
|
123
124
|
title: (0, _i18n.__)('Settings')
|
|
124
125
|
}, (0, _element.createElement)(_components.ToggleControl, {
|
|
125
126
|
label: (0, _i18n.__)('Inherit query from template'),
|
|
@@ -154,22 +155,54 @@ function QueryInspectorControls(_ref) {
|
|
|
154
155
|
onChange: value => setQuery({
|
|
155
156
|
sticky: value
|
|
156
157
|
})
|
|
157
|
-
})), !inherit && (0, _element.createElement)(_components.
|
|
158
|
-
|
|
159
|
-
|
|
158
|
+
}))), !inherit && (0, _element.createElement)(_blockEditor.InspectorControls, null, (0, _element.createElement)(_components.__experimentalToolsPanel, {
|
|
159
|
+
className: "block-library-query-toolspanel__filters",
|
|
160
|
+
label: (0, _i18n.__)('Filters'),
|
|
161
|
+
resetAll: () => {
|
|
162
|
+
setQuery({
|
|
163
|
+
author: '',
|
|
164
|
+
parents: [],
|
|
165
|
+
search: '',
|
|
166
|
+
taxQuery: null
|
|
167
|
+
});
|
|
168
|
+
setQuerySearch('');
|
|
169
|
+
}
|
|
170
|
+
}, !!(taxonomiesInfo !== null && taxonomiesInfo !== void 0 && taxonomiesInfo.length) && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
|
|
171
|
+
label: (0, _i18n.__)('Taxonomies'),
|
|
172
|
+
hasValue: () => Object.values(taxQuery || {}).some(terms => !!terms.length),
|
|
173
|
+
onDeselect: () => setQuery({
|
|
174
|
+
taxQuery: null
|
|
175
|
+
})
|
|
176
|
+
}, (0, _element.createElement)(_taxonomyControls.TaxonomyControls, {
|
|
160
177
|
onChange: setQuery,
|
|
161
178
|
query: query
|
|
162
|
-
}), (0, _element.createElement)(
|
|
179
|
+
})), (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
|
|
180
|
+
hasValue: () => !!authorIds,
|
|
181
|
+
label: (0, _i18n.__)('Authors'),
|
|
182
|
+
onDeselect: () => setQuery({
|
|
183
|
+
author: ''
|
|
184
|
+
})
|
|
185
|
+
}, (0, _element.createElement)(_authorControl.default, {
|
|
163
186
|
value: authorIds,
|
|
164
187
|
onChange: setQuery
|
|
165
|
-
}), (0, _element.createElement)(_components.
|
|
188
|
+
})), (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
|
|
189
|
+
hasValue: () => !!querySearch,
|
|
190
|
+
label: (0, _i18n.__)('Keyword'),
|
|
191
|
+
onDeselect: () => setQuerySearch('')
|
|
192
|
+
}, (0, _element.createElement)(_components.TextControl, {
|
|
166
193
|
label: (0, _i18n.__)('Keyword'),
|
|
167
194
|
value: querySearch,
|
|
168
195
|
onChange: setQuerySearch
|
|
169
|
-
}), isPostTypeHierarchical && (0, _element.createElement)(
|
|
196
|
+
})), isPostTypeHierarchical && (0, _element.createElement)(_components.__experimentalToolsPanelItem, {
|
|
197
|
+
hasValue: () => !!(parents !== null && parents !== void 0 && parents.length),
|
|
198
|
+
label: (0, _i18n.__)('Parents'),
|
|
199
|
+
onDeselect: () => setQuery({
|
|
200
|
+
parents: []
|
|
201
|
+
})
|
|
202
|
+
}, (0, _element.createElement)(_parentControl.default, {
|
|
170
203
|
parents: parents,
|
|
171
204
|
postType: postType,
|
|
172
205
|
onChange: setQuery
|
|
173
|
-
})));
|
|
206
|
+
})))));
|
|
174
207
|
}
|
|
175
208
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/index.js"],"names":["useIsPostTypeHierarchical","postType","select","type","coreStore","getPostType","viewable","hierarchical","QueryInspectorControls","attributes","query","displayLayout","setQuery","setDisplayLayout","order","orderBy","author","authorIds","sticky","inherit","taxQuery","parents","showSticky","setShowSticky","postTypesTaxonomiesMap","postTypesSelectOptions","isPostTypeHierarchical","onPostTypeChange","newValue","updateQuery","supportedTaxonomies","updatedTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","includes","keys","length","undefined","querySearch","setQuerySearch","search","onChangeDebounced","cancel","value","columns","Math","max"],"mappings":";;;;;;;;;AAkBA;;AAfA;;AAKA;;AAQA;;AACA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AA9BA;AACA;AACA;;AAGA;AACA;AACA;;AAeA;AACA;AACA;AAQA,SAASA,yBAAT,CAAoCC,QAApC,EAA+C;AAC9C,SAAO,qBACJC,MAAF,IAAc;AACb,UAAMC,IAAI,GAAGD,MAAM,CAAEE,eAAF,CAAN,CAAoBC,WAApB,CAAiCJ,QAAjC,CAAb;AACA,WAAO,CAAAE,IAAI,SAAJ,IAAAA,IAAI,WAAJ,YAAAA,IAAI,CAAEG,QAAN,MAAkBH,IAAlB,aAAkBA,IAAlB,uBAAkBA,IAAI,CAAEI,YAAxB,CAAP;AACA,GAJK,EAKN,CAAEN,QAAF,CALM,CAAP;AAOA;;AAEc,SAASO,sBAAT,OAIX;AAAA,M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,EAAGO,SAAvB;AAAmC,IAAA,QAAQ,EAAGL;AAA9C,IAFD,EAGC,4BAAC,uBAAD;AACC,IAAA,KAAK,EAAG,cAAI,SAAJ,CADT;AAEC,IAAA,KAAK,EAAG8B,WAFT;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IAHD,EAQGjB,sBAAsB,IACvB,4BAAC,sBAAD;AACC,IAAA,OAAO,EAAGL,OADX;AAEC,IAAA,QAAQ,EAAGpB,QAFZ;AAGC,IAAA,QAAQ,EAAGW;AAHZ,IATF,CAvDF,CADD;AA2EA","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tTextControl,\n\tSelectControl,\n\tRangeControl,\n\tToggleControl,\n\tNotice,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls } from '@wordpress/block-editor';\nimport { useEffect, useState, useCallback } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport OrderControl from './order-control';\nimport AuthorControl from './author-control';\nimport ParentControl from './parent-control';\nimport TaxonomyControls from './taxonomy-controls';\nimport StickyControl from './sticky-control';\nimport { usePostTypes } from '../../utils';\n\nfunction useIsPostTypeHierarchical( postType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn type?.viewable && type?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n}\n\nexport default function QueryInspectorControls( {\n\tattributes: { query, displayLayout },\n\tsetQuery,\n\tsetDisplayLayout,\n} ) {\n\tconst {\n\t\torder,\n\t\torderBy,\n\t\tauthor: authorIds,\n\t\tpostType,\n\t\tsticky,\n\t\tinherit,\n\t\ttaxQuery,\n\t\tparents,\n\t} = query;\n\tconst [ showSticky, setShowSticky ] = useState( postType === 'post' );\n\tconst { postTypesTaxonomiesMap, postTypesSelectOptions } = usePostTypes();\n\tconst isPostTypeHierarchical = useIsPostTypeHierarchical( postType );\n\tuseEffect( () => {\n\t\tsetShowSticky( postType === 'post' );\n\t}, [ postType ] );\n\tconst onPostTypeChange = ( newValue ) => {\n\t\tconst updateQuery = { postType: newValue };\n\t\t// We need to dynamically update the `taxQuery` property,\n\t\t// by removing any not supported taxonomy from the query.\n\t\tconst supportedTaxonomies = postTypesTaxonomiesMap[ newValue ];\n\t\tconst updatedTaxQuery = Object.entries( taxQuery || {} ).reduce(\n\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\tif ( supportedTaxonomies.includes( taxonomySlug ) ) {\n\t\t\t\t\taccumulator[ taxonomySlug ] = terms;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tupdateQuery.taxQuery = !! Object.keys( updatedTaxQuery ).length\n\t\t\t? updatedTaxQuery\n\t\t\t: undefined;\n\n\t\tif ( newValue !== 'post' ) {\n\t\t\tupdateQuery.sticky = '';\n\t\t}\n\t\t// We need to reset `parents` because they are tied to each post type.\n\t\tupdateQuery.parents = [];\n\t\tsetQuery( updateQuery );\n\t};\n\tconst [ querySearch, setQuerySearch ] = useState( query.search );\n\tconst onChangeDebounced = useCallback(\n\t\tdebounce( () => {\n\t\t\tif ( query.search !== querySearch ) {\n\t\t\t\tsetQuery( { search: querySearch } );\n\t\t\t}\n\t\t}, 250 ),\n\t\t[ querySearch, query.search ]\n\t);\n\tuseEffect( () => {\n\t\tonChangeDebounced();\n\t\treturn onChangeDebounced.cancel;\n\t}, [ querySearch, onChangeDebounced ] );\n\treturn (\n\t\t<InspectorControls>\n\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Inherit query from template' ) }\n\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'\n\t\t\t\t\t) }\n\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\tonChange={ ( value ) => setQuery( { inherit: !! value } ) }\n\t\t\t\t/>\n\t\t\t\t{ ! inherit && (\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\toptions={ postTypesSelectOptions }\n\t\t\t\t\t\tvalue={ postType }\n\t\t\t\t\t\tlabel={ __( 'Post type' ) }\n\t\t\t\t\t\tonChange={ onPostTypeChange }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'WordPress contains different types of content and they are divided into collections called \"Post types\". By default there are a few different ones such as blog posts and pages, but plugins could add more.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ displayLayout?.type === 'flex' && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\tvalue={ displayLayout.columns }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetDisplayLayout( { columns: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tmin={ 2 }\n\t\t\t\t\t\t\tmax={ Math.max( 6, displayLayout.columns ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t{ displayLayout.columns > 6 && (\n\t\t\t\t\t\t\t<Notice status=\"warning\" isDismissible={ false }>\n\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t'This column count exceeds the recommended amount and may cause visual breakage.'\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t</Notice>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t{ ! inherit && (\n\t\t\t\t\t<OrderControl\n\t\t\t\t\t\t{ ...{ order, orderBy } }\n\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t\t{ ! inherit && showSticky && (\n\t\t\t\t\t<StickyControl\n\t\t\t\t\t\tvalue={ sticky }\n\t\t\t\t\t\tonChange={ ( value ) => setQuery( { sticky: value } ) }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t\t{ ! inherit && (\n\t\t\t\t<PanelBody title={ __( 'Filters' ) }>\n\t\t\t\t\t<TaxonomyControls onChange={ setQuery } query={ query } />\n\t\t\t\t\t<AuthorControl value={ authorIds } onChange={ setQuery } />\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\tvalue={ querySearch }\n\t\t\t\t\t\tonChange={ setQuerySearch }\n\t\t\t\t\t/>\n\t\t\t\t\t{ isPostTypeHierarchical && (\n\t\t\t\t\t\t<ParentControl\n\t\t\t\t\t\t\tparents={ parents }\n\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t) }\n\t\t</InspectorControls>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/query/edit/inspector-controls/index.js"],"names":["useIsPostTypeHierarchical","postType","select","type","coreStore","getPostType","viewable","hierarchical","QueryInspectorControls","attributes","query","displayLayout","setQuery","setDisplayLayout","order","orderBy","author","authorIds","sticky","inherit","taxQuery","parents","showSticky","setShowSticky","postTypesTaxonomiesMap","postTypesSelectOptions","taxonomiesInfo","isPostTypeHierarchical","onPostTypeChange","newValue","updateQuery","supportedTaxonomies","updatedTaxQuery","Object","entries","reduce","accumulator","taxonomySlug","terms","includes","keys","length","undefined","querySearch","setQuerySearch","search","onChangeDebounced","cancel","value","columns","Math","max","values","some"],"mappings":";;;;;;;;;AAoBA;;AAjBA;;AAKA;;AAUA;;AACA;;AAEA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAGA;AACA;AACA;;AAiBA;AACA;AACA;AAQA,SAASA,yBAAT,CAAoCC,Q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AM,EAAE;AAAV,KAAF;AAH5B,KAKC,4BAAC,sBAAD;AACC,IAAA,KAAK,EAAGC,SADT;AAEC,IAAA,QAAQ,EAAGL;AAFZ,IALD,CA/BD,EAyCC,4BAAC,wCAAD;AACC,IAAA,QAAQ,EAAG,MAAM,CAAC,CAAE+B,WADrB;AAEC,IAAA,KAAK,EAAG,cAAI,SAAJ,CAFT;AAGC,IAAA,UAAU,EAAG,MAAMC,cAAc,CAAE,EAAF;AAHlC,KAKC,4BAAC,uBAAD;AACC,IAAA,KAAK,EAAG,cAAI,SAAJ,CADT;AAEC,IAAA,KAAK,EAAGD,WAFT;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IALD,CAzCD,EAoDGjB,sBAAsB,IACvB,4BAAC,wCAAD;AACC,IAAA,QAAQ,EAAG,MAAM,CAAC,EAAEN,OAAF,aAAEA,OAAF,eAAEA,OAAO,CAAEoB,MAAX,CADnB;AAEC,IAAA,KAAK,EAAG,cAAI,SAAJ,CAFT;AAGC,IAAA,UAAU,EAAG,MAAM7B,QAAQ,CAAE;AAAES,MAAAA,OAAO,EAAE;AAAX,KAAF;AAH5B,KAKC,4BAAC,sBAAD;AACC,IAAA,OAAO,EAAGA,OADX;AAEC,IAAA,QAAQ,EAAGpB,QAFZ;AAGC,IAAA,QAAQ,EAAGW;AAHZ,IALD,CArDF,CADD,CAhEF,CADD;AAwIA","sourcesContent":["/**\n * External dependencies\n */\nimport { debounce } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tPanelBody,\n\tTextControl,\n\tSelectControl,\n\tRangeControl,\n\tToggleControl,\n\tNotice,\n\t__experimentalToolsPanel as ToolsPanel,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls } from '@wordpress/block-editor';\nimport { useEffect, useState, useCallback } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport OrderControl from './order-control';\nimport AuthorControl from './author-control';\nimport ParentControl from './parent-control';\nimport { TaxonomyControls, useTaxonomiesInfo } from './taxonomy-controls';\nimport StickyControl from './sticky-control';\nimport { usePostTypes } from '../../utils';\n\nfunction useIsPostTypeHierarchical( postType ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst type = select( coreStore ).getPostType( postType );\n\t\t\treturn type?.viewable && type?.hierarchical;\n\t\t},\n\t\t[ postType ]\n\t);\n}\n\nexport default function QueryInspectorControls( {\n\tattributes: { query, displayLayout },\n\tsetQuery,\n\tsetDisplayLayout,\n} ) {\n\tconst {\n\t\torder,\n\t\torderBy,\n\t\tauthor: authorIds,\n\t\tpostType,\n\t\tsticky,\n\t\tinherit,\n\t\ttaxQuery,\n\t\tparents,\n\t} = query;\n\tconst [ showSticky, setShowSticky ] = useState( postType === 'post' );\n\tconst { postTypesTaxonomiesMap, postTypesSelectOptions } = usePostTypes();\n\tconst taxonomiesInfo = useTaxonomiesInfo( postType );\n\tconst isPostTypeHierarchical = useIsPostTypeHierarchical( postType );\n\tuseEffect( () => {\n\t\tsetShowSticky( postType === 'post' );\n\t}, [ postType ] );\n\tconst onPostTypeChange = ( newValue ) => {\n\t\tconst updateQuery = { postType: newValue };\n\t\t// We need to dynamically update the `taxQuery` property,\n\t\t// by removing any not supported taxonomy from the query.\n\t\tconst supportedTaxonomies = postTypesTaxonomiesMap[ newValue ];\n\t\tconst updatedTaxQuery = Object.entries( taxQuery || {} ).reduce(\n\t\t\t( accumulator, [ taxonomySlug, terms ] ) => {\n\t\t\t\tif ( supportedTaxonomies.includes( taxonomySlug ) ) {\n\t\t\t\t\taccumulator[ taxonomySlug ] = terms;\n\t\t\t\t}\n\t\t\t\treturn accumulator;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\t\tupdateQuery.taxQuery = !! Object.keys( updatedTaxQuery ).length\n\t\t\t? updatedTaxQuery\n\t\t\t: undefined;\n\n\t\tif ( newValue !== 'post' ) {\n\t\t\tupdateQuery.sticky = '';\n\t\t}\n\t\t// We need to reset `parents` because they are tied to each post type.\n\t\tupdateQuery.parents = [];\n\t\tsetQuery( updateQuery );\n\t};\n\tconst [ querySearch, setQuerySearch ] = useState( query.search );\n\tconst onChangeDebounced = useCallback(\n\t\tdebounce( () => {\n\t\t\tif ( query.search !== querySearch ) {\n\t\t\t\tsetQuery( { search: querySearch } );\n\t\t\t}\n\t\t}, 250 ),\n\t\t[ querySearch, query.search ]\n\t);\n\tuseEffect( () => {\n\t\tonChangeDebounced();\n\t\treturn onChangeDebounced.cancel;\n\t}, [ querySearch, onChangeDebounced ] );\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Inherit query from template' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'Toggle to use the global query context that is set with the current template, such as an archive or search. Disable to customize the settings independently.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tchecked={ !! inherit }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetQuery( { inherit: !! value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t{ ! inherit && (\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\toptions={ postTypesSelectOptions }\n\t\t\t\t\t\t\tvalue={ postType }\n\t\t\t\t\t\t\tlabel={ __( 'Post type' ) }\n\t\t\t\t\t\t\tonChange={ onPostTypeChange }\n\t\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t\t'WordPress contains different types of content and they are divided into collections called \"Post types\". By default there are a few different ones such as blog posts and pages, but plugins could add more.'\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\t{ displayLayout?.type === 'flex' && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\t\tvalue={ displayLayout.columns }\n\t\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\t\tsetDisplayLayout( { columns: value } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tmin={ 2 }\n\t\t\t\t\t\t\t\tmax={ Math.max( 6, displayLayout.columns ) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t{ displayLayout.columns > 6 && (\n\t\t\t\t\t\t\t\t<Notice\n\t\t\t\t\t\t\t\t\tstatus=\"warning\"\n\t\t\t\t\t\t\t\t\tisDismissible={ false }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t\t\t'This column count exceeds the recommended amount and may cause visual breakage.'\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t</Notice>\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\t{ ! inherit && (\n\t\t\t\t\t\t<OrderControl\n\t\t\t\t\t\t\t{ ...{ order, orderBy } }\n\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t{ ! inherit && showSticky && (\n\t\t\t\t\t\t<StickyControl\n\t\t\t\t\t\t\tvalue={ sticky }\n\t\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\t\tsetQuery( { sticky: value } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ ! inherit && (\n\t\t\t\t<InspectorControls>\n\t\t\t\t\t<ToolsPanel\n\t\t\t\t\t\tclassName=\"block-library-query-toolspanel__filters\"\n\t\t\t\t\t\tlabel={ __( 'Filters' ) }\n\t\t\t\t\t\tresetAll={ () => {\n\t\t\t\t\t\t\tsetQuery( {\n\t\t\t\t\t\t\t\tauthor: '',\n\t\t\t\t\t\t\t\tparents: [],\n\t\t\t\t\t\t\t\tsearch: '',\n\t\t\t\t\t\t\t\ttaxQuery: null,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\tsetQuerySearch( '' );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ !! taxonomiesInfo?.length && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\tlabel={ __( 'Taxonomies' ) }\n\t\t\t\t\t\t\t\thasValue={ () =>\n\t\t\t\t\t\t\t\t\tObject.values( taxQuery || {} ).some(\n\t\t\t\t\t\t\t\t\t\t( terms ) => !! terms.length\n\t\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonDeselect={ () =>\n\t\t\t\t\t\t\t\t\tsetQuery( { taxQuery: null } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<TaxonomyControls\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t\tquery={ query }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! authorIds }\n\t\t\t\t\t\t\tlabel={ __( 'Authors' ) }\n\t\t\t\t\t\t\tonDeselect={ () => setQuery( { author: '' } ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<AuthorControl\n\t\t\t\t\t\t\t\tvalue={ authorIds }\n\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\thasValue={ () => !! querySearch }\n\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\tonDeselect={ () => setQuerySearch( '' ) }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\t\tlabel={ __( 'Keyword' ) }\n\t\t\t\t\t\t\t\tvalue={ querySearch }\n\t\t\t\t\t\t\t\tonChange={ setQuerySearch }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t{ isPostTypeHierarchical && (\n\t\t\t\t\t\t\t<ToolsPanelItem\n\t\t\t\t\t\t\t\thasValue={ () => !! parents?.length }\n\t\t\t\t\t\t\t\tlabel={ __( 'Parents' ) }\n\t\t\t\t\t\t\t\tonDeselect={ () => setQuery( { parents: [] } ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t<ParentControl\n\t\t\t\t\t\t\t\t\tparents={ parents }\n\t\t\t\t\t\t\t\t\tpostType={ postType }\n\t\t\t\t\t\t\t\t\tonChange={ setQuery }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ToolsPanelItem>\n\t\t\t\t\t\t) }\n\t\t\t\t\t</ToolsPanel>\n\t\t\t\t</InspectorControls>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.TaxonomyControls = TaxonomyControls;
|
|
7
|
+
exports.useTaxonomiesInfo = void 0;
|
|
7
8
|
|
|
8
9
|
var _element = require("@wordpress/element");
|
|
9
10
|
|
|
@@ -50,25 +51,22 @@ const getTermIdByTermValue = (termsMappedByName, termValue) => {
|
|
|
50
51
|
}
|
|
51
52
|
};
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
onChange,
|
|
56
|
-
query
|
|
57
|
-
} = _ref;
|
|
58
|
-
const taxonomies = (0, _utils.useTaxonomies)(query.postType);
|
|
54
|
+
const useTaxonomiesInfo = postType => {
|
|
55
|
+
const taxonomies = (0, _utils.useTaxonomies)(postType);
|
|
59
56
|
const taxonomiesInfo = (0, _data.useSelect)(select => {
|
|
60
57
|
const {
|
|
61
58
|
getEntityRecords
|
|
62
59
|
} = select(_coreData.store);
|
|
63
60
|
const termsQuery = {
|
|
61
|
+
context: 'view',
|
|
64
62
|
per_page: _constants.MAX_FETCHED_TERMS
|
|
65
63
|
};
|
|
66
64
|
|
|
67
|
-
const _taxonomiesInfo = taxonomies === null || taxonomies === void 0 ? void 0 : taxonomies.map(
|
|
65
|
+
const _taxonomiesInfo = taxonomies === null || taxonomies === void 0 ? void 0 : taxonomies.map(_ref => {
|
|
68
66
|
let {
|
|
69
67
|
slug,
|
|
70
68
|
name
|
|
71
|
-
} =
|
|
69
|
+
} = _ref;
|
|
72
70
|
|
|
73
71
|
const _terms = getEntityRecords('taxonomy', slug, termsQuery);
|
|
74
72
|
|
|
@@ -81,6 +79,17 @@ function TaxonomyControls(_ref) {
|
|
|
81
79
|
|
|
82
80
|
return _taxonomiesInfo;
|
|
83
81
|
}, [taxonomies]);
|
|
82
|
+
return taxonomiesInfo;
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
exports.useTaxonomiesInfo = useTaxonomiesInfo;
|
|
86
|
+
|
|
87
|
+
function TaxonomyControls(_ref2) {
|
|
88
|
+
let {
|
|
89
|
+
onChange,
|
|
90
|
+
query
|
|
91
|
+
} = _ref2;
|
|
92
|
+
const taxonomiesInfo = useTaxonomiesInfo(query.postType);
|
|
84
93
|
|
|
85
94
|
const onTermsChange = taxonomySlug => newTermValues => {
|
|
86
95
|
const taxonomyInfo = taxonomiesInfo.find(_ref3 => {
|
|
@@ -143,16 +152,15 @@ function TaxonomyControls(_ref) {
|
|
|
143
152
|
return null;
|
|
144
153
|
}
|
|
145
154
|
|
|
146
|
-
return (0, _element.createElement)(
|
|
155
|
+
return (0, _element.createElement)("div", {
|
|
147
156
|
key: slug,
|
|
157
|
+
className: "block-library-query-inspector__taxonomy-control"
|
|
158
|
+
}, (0, _element.createElement)(_components.FormTokenField, {
|
|
148
159
|
label: name,
|
|
149
160
|
value: getExistingTaxQueryValue(slug),
|
|
150
161
|
suggestions: terms.names,
|
|
151
162
|
onChange: onTermsChange(slug)
|
|
152
|
-
});
|
|
163
|
+
}));
|
|
153
164
|
}));
|
|
154
165
|
}
|
|
155
|
-
|
|
156
|
-
var _default = TaxonomyControls;
|
|
157
|
-
exports.default = _default;
|
|
158
166
|
//# sourceMappingURL=taxonomy-controls.js.map
|
|
@@ -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","
|
|
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;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8B,QAAAA,WAAW,CAACQ,IAAZ,CAAkB;AACjBzC,UAAAA,EAAE,EAAED,MADa;AAEjB2C,UAAAA,KAAK,EAAEvC,IAAI,CAACe;AAFK,SAAlB;AAIA;;AACD,aAAOe,WAAP;AACA,KAVK,EAWN,EAXM,CAAP;AAaA,GAlBD;;AAmBA,SACC,qDACG,CAAC,EAAE1B,cAAF,aAAEA,cAAF,eAAEA,cAAc,CAAEoC,MAAlB,CAAD,IACDpC,cAAc,CAACS,GAAf,CAAoB,SAA6B;AAAA;;AAAA,QAA3B;AAAEC,MAAAA,IAAF;AAAQC,MAAAA,IAAR;AAAcE,MAAAA;AAAd,KAA2B;;AAChD,QAAK,EAAEA,KAAF,aAAEA,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"]}
|