@wordpress/block-library 7.1.0 → 7.3.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 +13 -0
- package/README.md +1 -1
- package/build/archives/edit.js +21 -1
- package/build/archives/edit.js.map +1 -1
- package/build/archives/index.js +5 -1
- package/build/archives/index.js.map +1 -1
- package/build/audio/edit.native.js +0 -5
- package/build/audio/edit.native.js.map +1 -1
- package/build/avatar/edit.js +211 -0
- package/build/avatar/edit.js.map +1 -0
- package/build/avatar/hooks.js +111 -0
- package/build/avatar/hooks.js.map +1 -0
- package/build/avatar/index.js +83 -0
- package/build/avatar/index.js.map +1 -0
- package/build/avatar/user-control.js +63 -0
- package/build/avatar/user-control.js.map +1 -0
- package/build/block/edit.js +2 -1
- package/build/block/edit.js.map +1 -1
- package/build/column/index.js +3 -1
- package/build/column/index.js.map +1 -1
- package/build/comment-author-avatar/index.js +4 -3
- package/build/comment-author-avatar/index.js.map +1 -1
- package/build/comment-author-name/index.js +7 -3
- package/build/comment-author-name/index.js.map +1 -1
- package/build/comment-content/index.js +1 -1
- package/build/comment-date/edit.js +10 -25
- package/build/comment-date/edit.js.map +1 -1
- package/build/comment-date/index.js +7 -3
- 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/edit.js +86 -66
- package/build/comment-template/edit.js.map +1 -1
- package/build/comment-template/hooks.js +7 -23
- package/build/comment-template/hooks.js.map +1 -1
- package/build/comment-template/index.js +2 -2
- package/build/comments-pagination-next/index.js +2 -2
- package/build/comments-pagination-numbers/index.js +1 -1
- package/build/comments-pagination-previous/index.js +1 -1
- package/build/comments-query-loop/edit/comments-inspector-controls.js +2 -69
- package/build/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
- package/build/comments-query-loop/edit.js +22 -1
- package/build/comments-query-loop/edit.js.map +1 -1
- package/build/comments-query-loop/index.js +1 -23
- package/build/comments-query-loop/index.js.map +1 -1
- package/build/cover/edit.js +58 -39
- package/build/cover/edit.js.map +1 -1
- package/build/cover/index.js +5 -0
- package/build/cover/index.js.map +1 -1
- package/build/cover/save.js +3 -2
- package/build/cover/save.js.map +1 -1
- package/build/embed/variations.js +2 -2
- package/build/embed/variations.js.map +1 -1
- package/build/gallery/edit.js +18 -5
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.js +1 -1
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/gap-styles.js +35 -0
- package/build/gallery/gap-styles.js.map +1 -0
- package/build/gallery/index.js +18 -1
- package/build/gallery/index.js.map +1 -1
- package/build/group/edit.js +3 -1
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +1 -1
- package/build/group/variations.js +30 -9
- package/build/group/variations.js.map +1 -1
- package/build/heading/edit.js +1 -1
- package/build/heading/edit.js.map +1 -1
- package/build/html/edit.js +3 -2
- package/build/html/edit.js.map +1 -1
- package/build/image/edit.native.js +8 -10
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +3 -1
- package/build/image/image.js.map +1 -1
- package/build/index.js +10 -4
- package/build/index.js.map +1 -1
- package/build/list/deprecated.js +2 -2
- package/build/list/deprecated.js.map +1 -1
- package/build/list/index.js +5 -7
- package/build/list/index.js.map +1 -1
- package/build/list/v2/deprecated.js +117 -0
- package/build/list/v2/deprecated.js.map +1 -0
- package/build/list/v2/edit.js +188 -0
- package/build/list/v2/edit.js.map +1 -0
- package/build/list/v2/index.js +36 -0
- package/build/list/v2/index.js.map +1 -0
- package/build/list/v2/migrate.js +85 -0
- package/build/list/v2/migrate.js.map +1 -0
- package/build/list/v2/save.js +34 -0
- package/build/list/v2/save.js.map +1 -0
- package/build/list/v2/transforms.js +121 -0
- package/build/list/v2/transforms.js.map +1 -0
- package/build/list-item/edit.js +96 -0
- package/build/list-item/edit.js.map +1 -0
- package/build/list-item/hooks/index.js +32 -0
- package/build/list-item/hooks/index.js.map +1 -0
- package/build/list-item/hooks/use-enter.js +93 -0
- package/build/list-item/hooks/use-enter.js.map +1 -0
- package/build/list-item/hooks/use-indent-list-item.js +74 -0
- package/build/list-item/hooks/use-indent-list-item.js.map +1 -0
- package/build/list-item/hooks/use-outdent-list-item.js +77 -0
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -0
- package/build/list-item/index.js +67 -0
- package/build/list-item/index.js.map +1 -0
- package/build/list-item/save.js +23 -0
- package/build/list-item/save.js.map +1 -0
- package/build/list-item/utils.js +16 -0
- package/build/list-item/utils.js.map +1 -0
- package/build/media-text/edit.js +3 -1
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/media-container.native.js +1 -16
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/navigation/edit/index.js +36 -17
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-delete-control.js +1 -1
- package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +34 -7
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/index.js +9 -1
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/use-navigation-entities.js +26 -54
- package/build/navigation/use-navigation-entities.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +1 -0
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation-link/edit.js +95 -37
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/index.js +1 -1
- package/build/navigation-submenu/edit.js +5 -9
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/navigation-submenu/index.js +1 -1
- package/build/post-comment/edit.js +2 -2
- package/build/post-comment/edit.js.map +1 -1
- package/build/post-comments-form/edit.js +3 -2
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-date/edit.js +31 -37
- package/build/post-date/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +2 -1
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-featured-image/index.js +1 -1
- package/build/post-template/edit.js +7 -2
- package/build/post-template/edit.js.map +1 -1
- package/build/post-terms/edit.js +3 -1
- package/build/post-terms/edit.js.map +1 -1
- package/build/post-terms/variations.js +1 -1
- package/build/post-terms/variations.js.map +1 -1
- package/build/pullquote/edit.js +5 -3
- package/build/pullquote/edit.js.map +1 -1
- package/build/query/variations.js +4 -4
- package/build/query/variations.js.map +1 -1
- package/build/query-no-results/edit.js +28 -0
- package/build/query-no-results/edit.js.map +1 -0
- package/build/query-no-results/index.js +54 -0
- package/build/query-no-results/index.js.map +1 -0
- package/build/query-no-results/save.js +18 -0
- package/build/query-no-results/save.js.map +1 -0
- package/build/query-pagination/edit.js +1 -1
- package/build/query-pagination/edit.js.map +1 -1
- package/build/query-pagination-numbers/index.js +19 -1
- package/build/query-pagination-numbers/index.js.map +1 -1
- package/build/quote/index.js +15 -8
- package/build/quote/index.js.map +1 -1
- package/build/quote/v2/deprecated.js +133 -0
- package/build/quote/v2/deprecated.js.map +1 -0
- package/build/quote/v2/edit.js +131 -0
- package/build/quote/v2/edit.js.map +1 -0
- package/build/quote/v2/index.js +49 -0
- package/build/quote/v2/index.js.map +1 -0
- package/build/quote/v2/save.js +43 -0
- package/build/quote/v2/save.js.map +1 -0
- package/build/quote/v2/transforms.js +156 -0
- package/build/quote/v2/transforms.js.map +1 -0
- package/build/read-more/index.js +1 -1
- package/build/rss/edit.js +6 -1
- package/build/rss/edit.js.map +1 -1
- package/build/search/edit.js +2 -3
- package/build/search/edit.js.map +1 -1
- package/build/separator/deprecated.js +83 -0
- package/build/separator/deprecated.js.map +1 -0
- package/build/separator/edit.js +31 -23
- package/build/separator/edit.js.map +1 -1
- package/build/separator/index.js +17 -7
- package/build/separator/index.js.map +1 -1
- package/build/separator/save.js +18 -13
- package/build/separator/save.js.map +1 -1
- package/build/separator/use-deprecated-opacity.js +39 -0
- package/build/separator/use-deprecated-opacity.js.map +1 -0
- package/build/site-logo/edit.js +3 -2
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-logo/index.js +1 -1
- package/build/social-links/edit.js +14 -3
- package/build/social-links/edit.js.map +1 -1
- package/build/social-links/index.js +2 -1
- package/build/social-links/index.js.map +1 -1
- package/build/spacer/controls.js +6 -16
- package/build/spacer/controls.js.map +1 -1
- package/build/spacer/controls.native.js +3 -1
- package/build/spacer/controls.native.js.map +1 -1
- package/build/spacer/edit.js +4 -5
- package/build/spacer/edit.js.map +1 -1
- package/build/table/deprecated.js +1 -1
- package/build/table/deprecated.js.map +1 -1
- package/build/tag-cloud/edit.js +58 -2
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/tag-cloud/index.js +8 -0
- package/build/tag-cloud/index.js.map +1 -1
- package/build/template-part/edit/utils/hooks.js +5 -2
- package/build/template-part/edit/utils/hooks.js.map +1 -1
- package/build-module/archives/edit.js +22 -2
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/archives/index.js +5 -1
- package/build-module/archives/index.js.map +1 -1
- package/build-module/audio/edit.native.js +0 -5
- package/build-module/audio/edit.native.js.map +1 -1
- package/build-module/avatar/edit.js +195 -0
- package/build-module/avatar/edit.js.map +1 -0
- package/build-module/avatar/hooks.js +99 -0
- package/build-module/avatar/hooks.js.map +1 -0
- package/build-module/avatar/index.js +70 -0
- package/build-module/avatar/index.js.map +1 -0
- package/build-module/avatar/user-control.js +52 -0
- package/build-module/avatar/user-control.js.map +1 -0
- package/build-module/block/edit.js +4 -3
- package/build-module/block/edit.js.map +1 -1
- package/build-module/column/index.js +3 -1
- package/build-module/column/index.js.map +1 -1
- package/build-module/comment-author-avatar/index.js +4 -3
- package/build-module/comment-author-avatar/index.js.map +1 -1
- package/build-module/comment-author-name/index.js +7 -3
- package/build-module/comment-author-name/index.js.map +1 -1
- package/build-module/comment-content/index.js +1 -1
- package/build-module/comment-date/edit.js +13 -30
- package/build-module/comment-date/edit.js.map +1 -1
- package/build-module/comment-date/index.js +7 -3
- 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/edit.js +86 -66
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/comment-template/hooks.js +7 -23
- package/build-module/comment-template/hooks.js.map +1 -1
- package/build-module/comment-template/index.js +2 -2
- package/build-module/comments-pagination-next/index.js +2 -2
- package/build-module/comments-pagination-numbers/index.js +1 -1
- package/build-module/comments-pagination-previous/index.js +1 -1
- package/build-module/comments-query-loop/edit/comments-inspector-controls.js +4 -70
- package/build-module/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
- package/build-module/comments-query-loop/edit.js +22 -1
- package/build-module/comments-query-loop/edit.js.map +1 -1
- package/build-module/comments-query-loop/index.js +1 -23
- package/build-module/comments-query-loop/index.js.map +1 -1
- package/build-module/cover/edit.js +58 -41
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/cover/index.js +5 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/save.js +3 -2
- package/build-module/cover/save.js.map +1 -1
- package/build-module/embed/variations.js +2 -2
- package/build-module/embed/variations.js.map +1 -1
- package/build-module/gallery/edit.js +17 -5
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.js +1 -1
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/gap-styles.js +28 -0
- package/build-module/gallery/gap-styles.js.map +1 -0
- package/build-module/gallery/index.js +18 -1
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/group/edit.js +3 -1
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +1 -1
- package/build-module/group/variations.js +29 -9
- package/build-module/group/variations.js.map +1 -1
- package/build-module/heading/edit.js +1 -1
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/html/edit.js +4 -3
- package/build-module/html/edit.js.map +1 -1
- package/build-module/image/edit.native.js +8 -10
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +3 -1
- package/build-module/image/image.js.map +1 -1
- package/build-module/index.js +7 -4
- package/build-module/index.js.map +1 -1
- package/build-module/list/deprecated.js +2 -2
- package/build-module/list/deprecated.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/deprecated.js +104 -0
- package/build-module/list/v2/deprecated.js.map +1 -0
- package/build-module/list/v2/edit.js +168 -0
- package/build-module/list/v2/edit.js.map +1 -0
- package/build-module/list/v2/index.js +21 -0
- package/build-module/list/v2/index.js.map +1 -0
- package/build-module/list/v2/migrate.js +77 -0
- package/build-module/list/v2/migrate.js.map +1 -0
- package/build-module/list/v2/save.js +23 -0
- package/build-module/list/v2/save.js.map +1 -0
- package/build-module/list/v2/transforms.js +111 -0
- package/build-module/list/v2/transforms.js.map +1 -0
- package/build-module/list-item/edit.js +83 -0
- package/build-module/list-item/edit.js.map +1 -0
- package/build-module/list-item/hooks/index.js +4 -0
- package/build-module/list-item/hooks/index.js.map +1 -0
- package/build-module/list-item/hooks/use-enter.js +77 -0
- package/build-module/list-item/hooks/use-enter.js.map +1 -0
- package/build-module/list-item/hooks/use-indent-list-item.js +62 -0
- package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -0
- package/build-module/list-item/hooks/use-outdent-list-item.js +66 -0
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -0
- package/build-module/list-item/index.js +53 -0
- package/build-module/list-item/index.js.map +1 -0
- package/build-module/list-item/save.js +15 -0
- package/build-module/list-item/save.js.map +1 -0
- package/build-module/list-item/utils.js +8 -0
- package/build-module/list-item/utils.js.map +1 -0
- package/build-module/media-text/edit.js +3 -1
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/media-container.native.js +1 -14
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/navigation/edit/index.js +37 -17
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-delete-control.js +1 -1
- package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +35 -8
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/index.js +9 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/use-navigation-entities.js +27 -54
- package/build-module/navigation/use-navigation-entities.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +1 -0
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation-link/edit.js +95 -36
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/index.js +1 -1
- package/build-module/navigation-submenu/edit.js +6 -10
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/navigation-submenu/index.js +1 -1
- package/build-module/post-comment/edit.js +2 -2
- package/build-module/post-comment/edit.js.map +1 -1
- package/build-module/post-comments-form/edit.js +3 -2
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-date/edit.js +32 -43
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +2 -1
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-featured-image/index.js +1 -1
- package/build-module/post-template/edit.js +7 -2
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-terms/edit.js +4 -2
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/post-terms/variations.js +3 -3
- package/build-module/post-terms/variations.js.map +1 -1
- package/build-module/pullquote/edit.js +6 -3
- package/build-module/pullquote/edit.js.map +1 -1
- package/build-module/query/variations.js +4 -4
- package/build-module/query/variations.js.map +1 -1
- package/build-module/query-no-results/edit.js +18 -0
- package/build-module/query-no-results/edit.js.map +1 -0
- package/build-module/query-no-results/index.js +40 -0
- package/build-module/query-no-results/index.js.map +1 -0
- package/build-module/query-no-results/save.js +10 -0
- package/build-module/query-no-results/save.js.map +1 -0
- package/build-module/query-pagination/edit.js +1 -1
- package/build-module/query-pagination/edit.js.map +1 -1
- package/build-module/query-pagination-numbers/index.js +19 -1
- package/build-module/query-pagination-numbers/index.js.map +1 -1
- package/build-module/quote/index.js +13 -1
- package/build-module/quote/index.js.map +1 -1
- package/build-module/quote/v2/deprecated.js +116 -0
- package/build-module/quote/v2/deprecated.js.map +1 -0
- package/build-module/quote/v2/edit.js +115 -0
- package/build-module/quote/v2/edit.js.map +1 -0
- package/build-module/quote/v2/index.js +33 -0
- package/build-module/quote/v2/index.js.map +1 -0
- package/build-module/quote/v2/save.js +30 -0
- package/build-module/quote/v2/save.js.map +1 -0
- package/build-module/quote/v2/transforms.js +147 -0
- package/build-module/quote/v2/transforms.js.map +1 -0
- package/build-module/read-more/index.js +1 -1
- package/build-module/rss/edit.js +5 -1
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/search/edit.js +2 -3
- package/build-module/search/edit.js.map +1 -1
- package/build-module/separator/deprecated.js +70 -0
- package/build-module/separator/deprecated.js.map +1 -0
- package/build-module/separator/edit.js +31 -22
- package/build-module/separator/edit.js.map +1 -1
- package/build-module/separator/index.js +16 -7
- package/build-module/separator/index.js.map +1 -1
- package/build-module/separator/save.js +19 -14
- package/build-module/separator/save.js.map +1 -1
- package/build-module/separator/use-deprecated-opacity.js +30 -0
- package/build-module/separator/use-deprecated-opacity.js.map +1 -0
- package/build-module/site-logo/edit.js +3 -2
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-logo/index.js +1 -1
- package/build-module/social-links/edit.js +15 -4
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/social-links/index.js +2 -1
- package/build-module/social-links/index.js.map +1 -1
- package/build-module/spacer/controls.js +8 -19
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/spacer/controls.native.js +2 -1
- package/build-module/spacer/controls.native.js.map +1 -1
- package/build-module/spacer/edit.js +3 -3
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/table/deprecated.js +1 -1
- package/build-module/table/deprecated.js.map +1 -1
- package/build-module/tag-cloud/edit.js +60 -4
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/tag-cloud/index.js +8 -0
- package/build-module/tag-cloud/index.js.map +1 -1
- package/build-module/template-part/edit/utils/hooks.js +5 -2
- package/build-module/template-part/edit/utils/hooks.js.map +1 -1
- package/build-style/avatar/editor-rtl.css +83 -0
- package/build-style/avatar/editor.css +83 -0
- package/build-style/avatar/style-rtl.css +79 -0
- package/build-style/avatar/style.css +79 -0
- package/build-style/editor-rtl.css +53 -11
- package/build-style/editor.css +53 -11
- package/build-style/gallery/editor-rtl.css +0 -1
- package/build-style/gallery/editor.css +0 -1
- package/build-style/gallery/style-rtl.css +102 -169
- package/build-style/gallery/style.css +102 -169
- package/build-style/group/editor-rtl.css +26 -0
- package/build-style/group/editor.css +26 -0
- package/build-style/heading/style-rtl.css +0 -8
- package/build-style/heading/style.css +0 -8
- package/build-style/image/style-rtl.css +2 -0
- package/build-style/image/style.css +2 -0
- package/build-style/list/style-rtl.css +1 -1
- package/build-style/list/style.css +1 -1
- package/build-style/navigation/style-rtl.css +11 -9
- package/build-style/navigation/style.css +11 -9
- package/build-style/navigation-link/editor-rtl.css +13 -0
- package/build-style/navigation-link/editor.css +13 -0
- package/build-style/navigation-link/style-rtl.css +3 -0
- package/build-style/navigation-link/style.css +3 -0
- package/build-style/paragraph/style-rtl.css +0 -4
- package/build-style/paragraph/style.css +0 -4
- package/build-style/pullquote/style-rtl.css +0 -4
- package/build-style/pullquote/style.css +0 -4
- package/build-style/quote/style-rtl.css +1 -0
- package/build-style/quote/style.css +1 -0
- package/build-style/reset-rtl.css +1 -1
- package/build-style/reset.css +1 -1
- package/build-style/separator/editor-rtl.css +3 -0
- package/build-style/separator/editor.css +3 -0
- package/build-style/separator/theme-rtl.css +7 -1
- package/build-style/separator/theme.css +7 -1
- package/build-style/site-logo/editor-rtl.css +3 -1
- package/build-style/site-logo/editor.css +3 -1
- package/build-style/style-rtl.css +124 -195
- package/build-style/style.css +124 -195
- package/build-style/template-part/editor-rtl.css +0 -9
- package/build-style/template-part/editor.css +0 -9
- package/build-style/theme-rtl.css +7 -1
- package/build-style/theme.css +7 -1
- package/package.json +28 -28
- package/src/archives/block.json +5 -1
- package/src/archives/edit.js +20 -2
- package/src/archives/index.php +4 -4
- package/src/audio/edit.native.js +0 -5
- package/src/avatar/block.json +53 -0
- package/src/avatar/edit.js +230 -0
- package/src/avatar/editor.scss +9 -0
- package/src/avatar/hooks.js +96 -0
- package/src/avatar/index.js +18 -0
- package/src/avatar/index.php +146 -0
- package/src/avatar/style.scss +5 -0
- package/src/avatar/user-control.js +56 -0
- package/src/block/edit.js +21 -11
- package/src/column/block.json +3 -1
- package/src/comment-author-avatar/block.json +4 -3
- package/src/comment-author-name/block.json +7 -3
- package/src/comment-author-name/index.php +3 -0
- package/src/comment-content/block.json +1 -1
- package/src/comment-date/block.json +7 -3
- package/src/comment-date/edit.js +20 -30
- package/src/comment-date/index.php +6 -1
- package/src/comment-edit-link/block.json +5 -1
- package/src/comment-edit-link/index.php +3 -0
- package/src/comment-reply-link/block.json +5 -1
- package/src/comment-reply-link/index.php +4 -1
- package/src/comment-template/block.json +2 -8
- package/src/comment-template/edit.js +77 -64
- package/src/comment-template/hooks.js +8 -24
- package/src/comment-template/index.php +1 -3
- package/src/comments-pagination-next/block.json +2 -9
- package/src/comments-pagination-numbers/block.json +2 -8
- package/src/comments-pagination-previous/block.json +2 -2
- package/src/comments-query-loop/block.json +1 -23
- package/src/comments-query-loop/edit/comments-inspector-controls.js +2 -83
- package/src/comments-query-loop/edit.js +54 -1
- package/src/cover/block.json +5 -0
- package/src/cover/edit.js +103 -60
- package/src/cover/index.php +85 -0
- package/src/cover/save.js +18 -14
- package/src/editor.scss +1 -0
- package/src/embed/variations.js +2 -2
- package/src/gallery/block.json +18 -1
- package/src/gallery/deprecated.scss +2 -2
- package/src/gallery/edit.js +15 -8
- package/src/gallery/editor.scss +0 -1
- package/src/gallery/gallery.js +8 -7
- package/src/gallery/gap-styles.js +26 -0
- package/src/gallery/index.php +43 -1
- package/src/gallery/style.scss +11 -44
- package/src/group/block.json +1 -1
- package/src/group/edit.js +4 -1
- package/src/group/editor.scss +31 -0
- package/src/group/variations.js +21 -4
- package/src/heading/edit.js +1 -1
- package/src/heading/style.scss +0 -3
- package/src/html/edit.js +22 -30
- package/src/image/edit.native.js +7 -11
- package/src/image/image.js +4 -1
- package/src/image/style.scss +3 -0
- package/src/index.js +19 -14
- package/src/list/deprecated.js +2 -2
- package/src/list/index.js +6 -1
- package/src/list/style.scss +1 -2
- package/src/list/test/migrate.js +159 -0
- package/src/list/v2/deprecated.js +89 -0
- package/src/list/v2/edit.js +186 -0
- package/src/list/v2/index.js +22 -0
- package/src/list/v2/migrate.js +87 -0
- package/src/list/v2/save.js +18 -0
- package/src/list/v2/transforms.js +116 -0
- package/src/list-item/block.json +26 -0
- package/src/list-item/edit.js +93 -0
- package/src/list-item/hooks/index.js +3 -0
- package/src/list-item/hooks/use-enter.js +94 -0
- package/src/list-item/hooks/use-indent-list-item.js +89 -0
- package/src/list-item/hooks/use-outdent-list-item.js +95 -0
- package/src/list-item/index.js +27 -0
- package/src/list-item/save.js +13 -0
- package/src/list-item/utils.js +14 -0
- package/src/media-text/edit.js +1 -1
- package/src/media-text/media-container.native.js +1 -14
- package/src/navigation/block.json +9 -1
- package/src/navigation/edit/index.js +50 -14
- package/src/navigation/edit/navigation-menu-delete-control.js +1 -1
- package/src/navigation/edit/unsaved-inner-blocks.js +57 -8
- package/src/navigation/index.php +28 -3
- package/src/navigation/style.scss +15 -13
- package/src/navigation/use-navigation-entities.js +37 -73
- package/src/navigation/use-navigation-menu.js +4 -0
- package/src/navigation-link/block.json +1 -0
- package/src/navigation-link/edit.js +156 -64
- package/src/navigation-link/editor.scss +11 -0
- package/src/navigation-link/index.php +8 -0
- package/src/navigation-link/style.scss +6 -0
- package/src/navigation-submenu/block.json +1 -0
- package/src/navigation-submenu/edit.js +7 -9
- package/src/paragraph/style.scss +0 -5
- package/src/post-author/index.php +0 -1
- package/src/post-comment/edit.js +2 -2
- package/src/post-comments-form/edit.js +6 -3
- package/src/post-date/edit.js +63 -52
- package/src/post-date/index.php +1 -1
- package/src/post-date/test/edit.js +17 -0
- package/src/post-featured-image/block.json +1 -1
- package/src/post-featured-image/edit.js +9 -1
- package/src/post-featured-image/index.php +2 -1
- package/src/post-template/edit.js +7 -1
- package/src/post-terms/edit.js +4 -1
- package/src/post-terms/variations.js +3 -3
- package/src/pullquote/edit.js +4 -3
- package/src/pullquote/style.scss +0 -5
- package/src/query/variations.js +4 -0
- package/src/query-no-results/block.json +20 -0
- package/src/query-no-results/edit.js +28 -0
- package/src/query-no-results/index.js +20 -0
- package/src/query-no-results/index.php +59 -0
- package/src/query-no-results/save.js +8 -0
- package/src/query-pagination/edit.js +1 -1
- package/src/query-pagination/index.php +9 -2
- package/src/query-pagination-numbers/block.json +19 -1
- package/src/quote/block.json +8 -0
- package/src/quote/index.js +6 -1
- package/src/quote/style.scss +1 -0
- package/src/quote/v2/deprecated.js +107 -0
- package/src/quote/v2/edit.js +136 -0
- package/src/quote/v2/index.js +36 -0
- package/src/quote/v2/save.js +26 -0
- package/src/quote/v2/test/migrate.js +92 -0
- package/src/quote/v2/transforms.js +155 -0
- package/src/read-more/block.json +1 -1
- package/src/reset.scss +1 -1
- package/src/rss/edit.js +3 -1
- package/src/rss/index.php +14 -1
- package/src/search/edit.js +1 -2
- package/src/separator/block.json +13 -6
- package/src/separator/deprecated.js +57 -0
- package/src/separator/deprecated.scss +6 -0
- package/src/separator/edit.js +36 -14
- package/src/separator/editor.scss +6 -0
- package/src/separator/index.js +2 -0
- package/src/separator/save.js +22 -14
- package/src/separator/test/edit.js +113 -0
- package/src/separator/theme.scss +7 -1
- package/src/separator/use-deprecated-opacity.js +41 -0
- package/src/site-logo/block.json +1 -1
- package/src/site-logo/edit.js +2 -1
- package/src/site-logo/editor.scss +3 -1
- package/src/site-logo/index.php +0 -4
- package/src/social-link/index.php +1 -2
- package/src/social-links/block.json +2 -1
- package/src/social-links/edit.js +15 -5
- package/src/spacer/controls.js +12 -18
- package/src/spacer/controls.native.js +2 -1
- package/src/spacer/edit.js +3 -6
- package/src/spacer/test/__snapshots__/index.native.js.snap +31 -0
- package/src/spacer/test/index.native.js +180 -0
- package/src/style.scss +1 -0
- package/src/table/deprecated.js +5 -1
- package/src/tag-cloud/block.json +8 -0
- package/src/tag-cloud/edit.js +82 -2
- package/src/tag-cloud/index.php +6 -0
- package/src/template-part/edit/utils/hooks.js +6 -1
- package/src/template-part/editor.scss +0 -10
- package/build/navigation/edit/use-list-view-modal.js +0 -73
- package/build/navigation/edit/use-list-view-modal.js.map +0 -1
- package/build/separator/separator-settings.js +0 -36
- package/build/separator/separator-settings.js.map +0 -1
- package/build-module/navigation/edit/use-list-view-modal.js +0 -63
- package/build-module/navigation/edit/use-list-view-modal.js.map +0 -1
- package/build-module/separator/separator-settings.js +0 -27
- package/build-module/separator/separator-settings.js.map +0 -1
- package/src/navigation/edit/use-list-view-modal.js +0 -72
- package/src/separator/separator-settings.js +0 -24
|
@@ -30,10 +30,14 @@ var _hooks = require("./hooks");
|
|
|
30
30
|
/**
|
|
31
31
|
* Internal dependencies
|
|
32
32
|
*/
|
|
33
|
-
const TEMPLATE = [['core/
|
|
33
|
+
const TEMPLATE = [['core/avatar'], ['core/comment-author-name'], ['core/comment-date'], ['core/comment-content'], ['core/comment-reply-link'], ['core/comment-edit-link']];
|
|
34
34
|
/**
|
|
35
35
|
* Function that returns a comment structure that will be rendered with default placehoders.
|
|
36
36
|
*
|
|
37
|
+
* Each comment has a `commentId` property that is always a negative number in
|
|
38
|
+
* case of the placeholders. This is to ensure that the comment does not
|
|
39
|
+
* conflict with the actual (real) comments.
|
|
40
|
+
*
|
|
37
41
|
* @param {Object} settings Discussion Settings.
|
|
38
42
|
* @param {number} [settings.perPage] - Comments per page setting or block attribute.
|
|
39
43
|
* @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.
|
|
@@ -58,15 +62,16 @@ const getCommentsPlaceholder = _ref => {
|
|
|
58
62
|
|
|
59
63
|
if (!threadComments || defaultCommentsToShow === 1) {
|
|
60
64
|
// If displaying threaded comments is disabled, we only show one comment
|
|
65
|
+
// A commentId is negative in order to avoid conflicts with the actual comments.
|
|
61
66
|
return [{
|
|
62
|
-
commentId:
|
|
67
|
+
commentId: -1,
|
|
63
68
|
children: []
|
|
64
69
|
}];
|
|
65
70
|
} else if (defaultCommentsToShow === 2) {
|
|
66
71
|
return [{
|
|
67
|
-
commentId:
|
|
72
|
+
commentId: -1,
|
|
68
73
|
children: [{
|
|
69
|
-
commentId:
|
|
74
|
+
commentId: -2,
|
|
70
75
|
children: []
|
|
71
76
|
}]
|
|
72
77
|
}];
|
|
@@ -74,11 +79,11 @@ const getCommentsPlaceholder = _ref => {
|
|
|
74
79
|
|
|
75
80
|
|
|
76
81
|
return [{
|
|
77
|
-
commentId:
|
|
82
|
+
commentId: -1,
|
|
78
83
|
children: [{
|
|
79
|
-
commentId:
|
|
84
|
+
commentId: -2,
|
|
80
85
|
children: [{
|
|
81
|
-
commentId:
|
|
86
|
+
commentId: -3,
|
|
82
87
|
children: []
|
|
83
88
|
}]
|
|
84
89
|
}]
|
|
@@ -87,13 +92,13 @@ const getCommentsPlaceholder = _ref => {
|
|
|
87
92
|
/**
|
|
88
93
|
* Component which renders the inner blocks of the Comment Template.
|
|
89
94
|
*
|
|
90
|
-
* @param {Object} props
|
|
91
|
-
* @param {Array} [props.comment]
|
|
92
|
-
* @param {Array} [props.
|
|
93
|
-
* @param {Array} [props.
|
|
94
|
-
* @param {Array} [props.
|
|
95
|
-
* @param {Array} [props.blocks]
|
|
96
|
-
*
|
|
95
|
+
* @param {Object} props Component props.
|
|
96
|
+
* @param {Array} [props.comment] - A comment object.
|
|
97
|
+
* @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.
|
|
98
|
+
* @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.
|
|
99
|
+
* @param {Array} [props.firstCommentId] - ID of the first comment in the array.
|
|
100
|
+
* @param {Array} [props.blocks] - Array of blocks returned from
|
|
101
|
+
* getBlocks() in parent .
|
|
97
102
|
* @return {WPElement} Inner blocks of the Comment Template
|
|
98
103
|
*/
|
|
99
104
|
|
|
@@ -103,9 +108,9 @@ function CommentTemplateInnerBlocks(_ref2) {
|
|
|
103
108
|
|
|
104
109
|
let {
|
|
105
110
|
comment,
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
111
|
+
activeCommentId,
|
|
112
|
+
setActiveCommentId,
|
|
113
|
+
firstCommentId,
|
|
109
114
|
blocks
|
|
110
115
|
} = _ref2;
|
|
111
116
|
const {
|
|
@@ -114,24 +119,25 @@ function CommentTemplateInnerBlocks(_ref2) {
|
|
|
114
119
|
} = (0, _blockEditor.useInnerBlocksProps)({}, {
|
|
115
120
|
template: TEMPLATE
|
|
116
121
|
});
|
|
117
|
-
return (0, _element.createElement)("li", innerBlocksProps, comment === (
|
|
122
|
+
return (0, _element.createElement)("li", innerBlocksProps, comment.commentId === (activeCommentId || firstCommentId) ? children : null, (0, _element.createElement)(MemoizedCommentTemplatePreview, {
|
|
118
123
|
blocks: blocks,
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
isHidden: comment === (
|
|
124
|
+
commentId: comment.commentId,
|
|
125
|
+
setActiveCommentId: setActiveCommentId,
|
|
126
|
+
isHidden: comment.commentId === (activeCommentId || firstCommentId)
|
|
122
127
|
}), (comment === null || comment === void 0 ? void 0 : (_comment$children = comment.children) === null || _comment$children === void 0 ? void 0 : _comment$children.length) > 0 ? (0, _element.createElement)(CommentsList, {
|
|
123
128
|
comments: comment.children,
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
blocks: blocks
|
|
129
|
+
activeCommentId: activeCommentId,
|
|
130
|
+
setActiveCommentId: setActiveCommentId,
|
|
131
|
+
blocks: blocks,
|
|
132
|
+
firstCommentId: firstCommentId
|
|
127
133
|
}) : null);
|
|
128
134
|
}
|
|
129
135
|
|
|
130
136
|
const CommentTemplatePreview = _ref3 => {
|
|
131
137
|
let {
|
|
132
138
|
blocks,
|
|
133
|
-
|
|
134
|
-
|
|
139
|
+
commentId,
|
|
140
|
+
setActiveCommentId,
|
|
135
141
|
isHidden
|
|
136
142
|
} = _ref3;
|
|
137
143
|
const blockPreviewProps = (0, _blockEditor.__experimentalUseBlockPreview)({
|
|
@@ -139,7 +145,7 @@ const CommentTemplatePreview = _ref3 => {
|
|
|
139
145
|
});
|
|
140
146
|
|
|
141
147
|
const handleOnClick = () => {
|
|
142
|
-
|
|
148
|
+
setActiveCommentId(commentId);
|
|
143
149
|
}; // We have to hide the preview block if the `comment` props points to
|
|
144
150
|
// the curently active block!
|
|
145
151
|
// Or, to put it differently, every preview block is visible unless it is the
|
|
@@ -163,13 +169,14 @@ const MemoizedCommentTemplatePreview = (0, _element.memo)(CommentTemplatePreview
|
|
|
163
169
|
/**
|
|
164
170
|
* Component that renders a list of (nested) comments. It is called recursively.
|
|
165
171
|
*
|
|
166
|
-
* @param {Object} props
|
|
167
|
-
* @param {Array} [props.comments]
|
|
168
|
-
* @param {Array} [props.blockProps]
|
|
169
|
-
* @param {Array} [props.
|
|
170
|
-
* @param {Array} [props.
|
|
171
|
-
* @param {Array} [props.blocks]
|
|
172
|
-
*
|
|
172
|
+
* @param {Object} props Component props.
|
|
173
|
+
* @param {Array} [props.comments] - Array of comment objects.
|
|
174
|
+
* @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.
|
|
175
|
+
* @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.
|
|
176
|
+
* @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.
|
|
177
|
+
* @param {Array} [props.blocks] - Array of blocks returned from getBlocks() in parent.
|
|
178
|
+
* @param {Object} [props.firstCommentId] - The ID of the first comment in the array of
|
|
179
|
+
* comment objects.
|
|
173
180
|
* @return {WPElement} List of comments.
|
|
174
181
|
*/
|
|
175
182
|
|
|
@@ -177,39 +184,55 @@ const CommentsList = _ref4 => {
|
|
|
177
184
|
let {
|
|
178
185
|
comments,
|
|
179
186
|
blockProps,
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
blocks
|
|
187
|
+
activeCommentId,
|
|
188
|
+
setActiveCommentId,
|
|
189
|
+
blocks,
|
|
190
|
+
firstCommentId
|
|
183
191
|
} = _ref4;
|
|
184
|
-
return (0, _element.createElement)("ol", blockProps, comments && comments.map((
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
192
|
+
return (0, _element.createElement)("ol", blockProps, comments && comments.map((_ref5, index) => {
|
|
193
|
+
let {
|
|
194
|
+
commentId,
|
|
195
|
+
...comment
|
|
196
|
+
} = _ref5;
|
|
197
|
+
return (0, _element.createElement)(_blockEditor.BlockContextProvider, {
|
|
198
|
+
key: comment.commentId || index,
|
|
199
|
+
value: {
|
|
200
|
+
// If the commentId is negative it means that this comment is a
|
|
201
|
+
// "placeholder" and that the block is most likely being used in the
|
|
202
|
+
// site editor. In this case, we have to set the commentId to `null`
|
|
203
|
+
// because otherwise the (non-existent) comment with a negative ID
|
|
204
|
+
// would be reqested from the REST API.
|
|
205
|
+
commentId: commentId < 0 ? null : commentId
|
|
206
|
+
}
|
|
207
|
+
}, (0, _element.createElement)(CommentTemplateInnerBlocks, {
|
|
208
|
+
comment: {
|
|
209
|
+
commentId,
|
|
210
|
+
...comment
|
|
211
|
+
},
|
|
212
|
+
activeCommentId: activeCommentId,
|
|
213
|
+
setActiveCommentId: setActiveCommentId,
|
|
214
|
+
blocks: blocks,
|
|
215
|
+
firstCommentId: firstCommentId
|
|
216
|
+
}));
|
|
217
|
+
}));
|
|
194
218
|
};
|
|
195
219
|
|
|
196
|
-
function CommentTemplateEdit(
|
|
220
|
+
function CommentTemplateEdit(_ref6) {
|
|
221
|
+
var _commentTree$;
|
|
222
|
+
|
|
197
223
|
let {
|
|
198
224
|
clientId,
|
|
199
225
|
context: {
|
|
200
|
-
postId
|
|
201
|
-
'comments/perPage': perPage,
|
|
202
|
-
'comments/order': order,
|
|
203
|
-
'comments/defaultPage': defaultPage,
|
|
204
|
-
'comments/inherit': inherit
|
|
226
|
+
postId
|
|
205
227
|
}
|
|
206
|
-
} =
|
|
228
|
+
} = _ref6;
|
|
207
229
|
const blockProps = (0, _blockEditor.useBlockProps)();
|
|
208
|
-
const [
|
|
230
|
+
const [activeCommentId, setActiveCommentId] = (0, _element.useState)();
|
|
209
231
|
const {
|
|
210
232
|
commentOrder,
|
|
211
233
|
threadCommentsDepth,
|
|
212
|
-
threadComments
|
|
234
|
+
threadComments,
|
|
235
|
+
commentsPerPage
|
|
213
236
|
} = (0, _data.useSelect)(select => {
|
|
214
237
|
const {
|
|
215
238
|
getSettings
|
|
@@ -217,10 +240,7 @@ function CommentTemplateEdit(_ref5) {
|
|
|
217
240
|
return getSettings().__experimentalDiscussionSettings;
|
|
218
241
|
});
|
|
219
242
|
const commentQuery = (0, _hooks.useCommentQueryArgs)({
|
|
220
|
-
postId
|
|
221
|
-
perPage,
|
|
222
|
-
defaultPage,
|
|
223
|
-
inherit
|
|
243
|
+
postId
|
|
224
244
|
});
|
|
225
245
|
const {
|
|
226
246
|
topLevelComments,
|
|
@@ -237,11 +257,10 @@ function CommentTemplateEdit(_ref5) {
|
|
|
237
257
|
topLevelComments: commentQuery ? getEntityRecords('root', 'comment', commentQuery) : null,
|
|
238
258
|
blocks: getBlocks(clientId)
|
|
239
259
|
};
|
|
240
|
-
}, [clientId, commentQuery]);
|
|
241
|
-
order = inherit || !order ? commentOrder : order; // Generate a tree structure of comment IDs.
|
|
260
|
+
}, [clientId, commentQuery]); // Generate a tree structure of comment IDs.
|
|
242
261
|
|
|
243
262
|
let commentTree = (0, _hooks.useCommentTree)( // Reverse the order of top comments if needed.
|
|
244
|
-
|
|
263
|
+
commentOrder === 'desc' && topLevelComments ? [...topLevelComments].reverse() : topLevelComments);
|
|
245
264
|
|
|
246
265
|
if (!topLevelComments) {
|
|
247
266
|
return (0, _element.createElement)("p", blockProps, (0, _element.createElement)(_components.Spinner, null));
|
|
@@ -249,7 +268,7 @@ function CommentTemplateEdit(_ref5) {
|
|
|
249
268
|
|
|
250
269
|
if (!postId) {
|
|
251
270
|
commentTree = getCommentsPlaceholder({
|
|
252
|
-
perPage,
|
|
271
|
+
perPage: commentsPerPage,
|
|
253
272
|
threadComments,
|
|
254
273
|
threadCommentsDepth
|
|
255
274
|
});
|
|
@@ -263,8 +282,9 @@ function CommentTemplateEdit(_ref5) {
|
|
|
263
282
|
comments: commentTree,
|
|
264
283
|
blockProps: blockProps,
|
|
265
284
|
blocks: blocks,
|
|
266
|
-
|
|
267
|
-
|
|
285
|
+
activeCommentId: activeCommentId,
|
|
286
|
+
setActiveCommentId: setActiveCommentId,
|
|
287
|
+
firstCommentId: (_commentTree$ = commentTree[0]) === null || _commentTree$ === void 0 ? void 0 : _commentTree$.commentId
|
|
268
288
|
});
|
|
269
289
|
}
|
|
270
290
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comment-template/edit.js"],"names":["TEMPLATE","getCommentsPlaceholder","perPage","threadComments","threadCommentsDepth","commentsDepth","Math","min","defaultCommentsToShow","commentId","children","CommentTemplateInnerBlocks","comment","activeComment","setActiveComment","firstComment","blocks","innerBlocksProps","template","length","CommentTemplatePreview","isHidden","blockPreviewProps","handleOnClick","style","display","undefined","MemoizedCommentTemplatePreview","CommentsList","comments","blockProps","map","index","CommentTemplateEdit","clientId","context","postId","order","defaultPage","inherit","commentOrder","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","commentQuery","topLevelComments","getEntityRecords","coreStore","getBlocks","commentTree","reverse"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,CAChB,C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B,UAAR,EACC,4BAAC,mBAAD,OADD,CADD;AAKA;;AAED,MAAK,CAAEM,MAAP,EAAgB;AACfc,IAAAA,WAAW,GAAGjD,sBAAsB,CAAE;AACrCC,MAAAA,OADqC;AAErCC,MAAAA,cAFqC;AAGrCC,MAAAA;AAHqC,KAAF,CAApC;AAKA;;AAED,MAAK,CAAE8C,WAAW,CAAC/B,MAAnB,EAA4B;AAC3B,WAAO,iCAAQW,UAAR,OAAwB,cAAI,mBAAJ,CAAxB,CAAP;AACA;;AAED,SACC,4BAAC,YAAD;AACC,IAAA,QAAQ,EAAGoB,WADZ;AAEC,IAAA,UAAU,EAAGpB,UAFd;AAGC,IAAA,MAAM,EAAGd,MAHV;AAIC,IAAA,aAAa,EAAGH,aAJjB;AAKC,IAAA,gBAAgB,EAAGC;AALpB,IADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBlockPreview as useBlockPreview,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCommentQueryArgs, useCommentTree } from './hooks';\n\nconst TEMPLATE = [\n\t[ 'core/comment-author-avatar' ],\n\t[ 'core/comment-author-name' ],\n\t[ 'core/comment-date' ],\n\t[ 'core/comment-content' ],\n\t[ 'core/comment-reply-link' ],\n\t[ 'core/comment-edit-link' ],\n];\n\n/**\n * Function that returns a comment structure that will be rendered with default placehoders.\n *\n * @param {Object} settings Discussion Settings.\n * @param {number} [settings.perPage] - Comments per page setting or block attribute.\n * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.\n * @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.\n *\n * @typedef {{id: null, children: EmptyComment[]}} EmptyComment\n * @return {EmptyComment[]} \t\tInner blocks of the Comment Template\n */\nconst getCommentsPlaceholder = ( {\n\tperPage,\n\tthreadComments,\n\tthreadCommentsDepth,\n} ) => {\n\t// In case that `threadCommentsDepth` is falsy, we default to a somewhat\n\t// arbitrary value of 3.\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\tconst commentsDepth = Math.min( threadCommentsDepth || 3, 3 );\n\n\t// We set a limit in order not to overload the editor of empty comments.\n\tconst defaultCommentsToShow =\n\t\tperPage <= commentsDepth ? perPage : commentsDepth;\n\tif ( ! threadComments || defaultCommentsToShow === 1 ) {\n\t\t// If displaying threaded comments is disabled, we only show one comment\n\t\treturn [ { commentId: null, children: [] } ];\n\t} else if ( defaultCommentsToShow === 2 ) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tcommentId: null,\n\t\t\t\tchildren: [ { commentId: null, children: [] } ],\n\t\t\t},\n\t\t];\n\t}\n\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\treturn [\n\t\t{\n\t\t\tcommentId: null,\n\t\t\tchildren: [\n\t\t\t\t{\n\t\t\t\t\tcommentId: null,\n\t\t\t\t\tchildren: [ { commentId: null, children: [] } ],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n};\n\n/**\n * Component which renders the inner blocks of the Comment Template.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comment] - A comment object.\n * @param {Array} [props.activeComment] - The block that is currently active.\n * @param {Array} [props.setActiveComment] - The setter for activeComment.\n * @param {Array} [props.firstComment] - First comment in the array.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tInner blocks of the Comment Template\n */\nfunction CommentTemplateInnerBlocks( {\n\tcomment,\n\tactiveComment,\n\tsetActiveComment,\n\tfirstComment,\n\tblocks,\n} ) {\n\tconst { children, ...innerBlocksProps } = useInnerBlocksProps(\n\t\t{},\n\t\t{ template: TEMPLATE }\n\t);\n\treturn (\n\t\t<li { ...innerBlocksProps }>\n\t\t\t{ comment === ( activeComment || firstComment ) ? children : null }\n\n\t\t\t{ /* To avoid flicker when switching active block contexts, a preview\n\t\t\tis ALWAYS rendered and the preview for the active block is hidden.\n\t\t\tThis ensures that when switching the active block, the component is not\n\t\t\tmounted again but rather it only toggles the `isHidden` prop.\n\n\t\t\tThe same strategy is used for preventing the flicker in the Post Template\n\t\t\tblock. */ }\n\t\t\t<MemoizedCommentTemplatePreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tcomment={ comment }\n\t\t\t\tsetActiveComment={ setActiveComment }\n\t\t\t\tisHidden={ comment === ( activeComment || firstComment ) }\n\t\t\t/>\n\n\t\t\t{ comment?.children?.length > 0 ? (\n\t\t\t\t<CommentsList\n\t\t\t\t\tcomments={ comment.children }\n\t\t\t\t\tactiveComment={ activeComment }\n\t\t\t\t\tsetActiveComment={ setActiveComment }\n\t\t\t\t\tblocks={ blocks }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t</li>\n\t);\n}\n\nconst CommentTemplatePreview = ( {\n\tblocks,\n\tcomment,\n\tsetActiveComment,\n\tisHidden,\n} ) => {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveComment( comment );\n\t};\n\n\t// We have to hide the preview block if the `comment` props points to\n\t// the curently active block!\n\n\t// Or, to put it differently, every preview block is visible unless it is the\n\t// currently active block - in this case we render its inner blocks.\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\tstyle={ style }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t/>\n\t);\n};\n\nconst MemoizedCommentTemplatePreview = memo( CommentTemplatePreview );\n\n/**\n * Component that renders a list of (nested) comments. It is called recursively.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comments] - Array of comment objects.\n * @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.\n * @param {Array} [props.activeComment] - The block that is currently active.\n * @param {Array} [props.setActiveComment] - The setter for activeComment.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tList of comments.\n */\nconst CommentsList = ( {\n\tcomments,\n\tblockProps,\n\tactiveComment,\n\tsetActiveComment,\n\tblocks,\n} ) => (\n\t<ol { ...blockProps }>\n\t\t{ comments &&\n\t\t\tcomments.map( ( comment, index ) => (\n\t\t\t\t<BlockContextProvider\n\t\t\t\t\tkey={ comment.commentId || index }\n\t\t\t\t\tvalue={ comment }\n\t\t\t\t>\n\t\t\t\t\t<CommentTemplateInnerBlocks\n\t\t\t\t\t\tcomment={ comment }\n\t\t\t\t\t\tactiveComment={ activeComment }\n\t\t\t\t\t\tsetActiveComment={ setActiveComment }\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tfirstComment={ comments[ 0 ] }\n\t\t\t\t\t/>\n\t\t\t\t</BlockContextProvider>\n\t\t\t) ) }\n\t</ol>\n);\n\nexport default function CommentTemplateEdit( {\n\tclientId,\n\tcontext: {\n\t\tpostId,\n\t\t'comments/perPage': perPage,\n\t\t'comments/order': order,\n\t\t'comments/defaultPage': defaultPage,\n\t\t'comments/inherit': inherit,\n\t},\n} ) {\n\tconst blockProps = useBlockProps();\n\n\tconst [ activeComment, setActiveComment ] = useState();\n\tconst { commentOrder, threadCommentsDepth, threadComments } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getSettings } = select( blockEditorStore );\n\t\t\treturn getSettings().__experimentalDiscussionSettings;\n\t\t}\n\t);\n\n\tconst commentQuery = useCommentQueryArgs( {\n\t\tpostId,\n\t\tperPage,\n\t\tdefaultPage,\n\t\tinherit,\n\t} );\n\n\tconst { topLevelComments, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\t// Request only top-level comments. Replies are embedded.\n\t\t\t\ttopLevelComments: commentQuery\n\t\t\t\t\t? getEntityRecords( 'root', 'comment', commentQuery )\n\t\t\t\t\t: null,\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId, commentQuery ]\n\t);\n\n\torder = inherit || ! order ? commentOrder : order;\n\n\t// Generate a tree structure of comment IDs.\n\tlet commentTree = useCommentTree(\n\t\t// Reverse the order of top comments if needed.\n\t\torder === 'desc' && topLevelComments\n\t\t\t? [ ...topLevelComments ].reverse()\n\t\t\t: topLevelComments\n\t);\n\n\tif ( ! topLevelComments ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! postId ) {\n\t\tcommentTree = getCommentsPlaceholder( {\n\t\t\tperPage,\n\t\t\tthreadComments,\n\t\t\tthreadCommentsDepth,\n\t\t} );\n\t}\n\n\tif ( ! commentTree.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No results found.' ) }</p>;\n\t}\n\n\treturn (\n\t\t<CommentsList\n\t\t\tcomments={ commentTree }\n\t\t\tblockProps={ blockProps }\n\t\t\tblocks={ blocks }\n\t\t\tactiveComment={ activeComment }\n\t\t\tsetActiveComment={ setActiveComment }\n\t\t/>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comment-template/edit.js"],"names":["TEMPLATE","getCommentsPlaceholder","perPage","threadComments","threadCommentsDepth","commentsDepth","Math","min","defaultCommentsToShow","commentId","children","CommentTemplateInnerBlocks","comment","activeCommentId","setActiveCommentId","firstCommentId","blocks","innerBlocksProps","template","length","CommentTemplatePreview","isHidden","blockPreviewProps","handleOnClick","style","display","undefined","MemoizedCommentTemplatePreview","CommentsList","comments","blockProps","map","index","CommentTemplateEdit","clientId","context","postId","commentOrder","commentsPerPage","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","commentQuery","topLevelComments","getEntityRecords","coreStore","getBlocks","commentTree","reverse"],"mappings":";;;;;;;;;AAGA;;;;AACA;;AACA;;AACA;;AAOA;;AACA;;AAKA;;AAnBA;AACA;AACA;;AAcA;AACA;AACA;AAGA,MAAMA,QAAQ,GAAG,CAChB,CAAE,aAAF,CADgB,EAEhB,CAAE,0BAAF,CAFgB,EAGhB,CAAE,mBAAF,CAHgB,EAIhB,CAAE,sBAAF,CAJgB,EAKhB,CAAE,yBAAF,CALgB,EAMhB,CAAE,wBAAF,CANgB,CAAjB;AASA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,sBAAsB,GAAG,QAIxB;AAAA,MAJ0B;AAChCC,IAAAA,OADgC;AAEhCC,IAAAA,cAFgC;AAGhCC,IAAAA;AAHgC,GAI1B;AACN;AACA;AACA;AACA,QAAMC,aAAa,GAAGC,IAAI,CAACC,GAAL,CAAUH,mBAAmB,IAAI,CAAjC,EAAoC,CAApC,CAAtB,CAJM,CAMN;;AACA,QAAMI,qBAAqB,GAC1BN,OAAO,IAAIG,aAAX,GAA2BH,OAA3B,GAAqCG,aADtC;;AAEA,MAAK,CAAEF,cAAF,IAAoBK,qBAAqB,KAAK,CAAnD,EAAuD;AACtD;AACA;AACA,WAAO,CAAE;AAAEC,MAAAA,SAAS,EAAE,CAAC,CAAd;AAAiBC,MAAAA,QAAQ,EAAE;AAA3B,KAAF,CAAP;AACA,GAJD,MAIO,IAAKF,qBAAqB,KAAK,CAA/B,EAAmC;AACzC,WAAO,CACN;AACCC,MAAAA,SAAS,EAAE,CAAC,CADb;AAECC,MAAAA,QAAQ,EAAE,CAAE;AAAED,QAAAA,SAAS,EAAE,CAAC,CAAd;AAAiBC,QAAAA,QAAQ,EAAE;AAA3B,OAAF;AAFX,KADM,CAAP;AAMA,GApBK,CAsBN;;;AAC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AJG;AAKN3B,MAAAA,MAAM,EAAE+B,SAAS,CAAEb,QAAF;AALX,KAAP;AAOA,GAZmC,EAapC,CAAEA,QAAF,EAAYS,YAAZ,CAboC,CAArC,CAlBG,CAkCH;;AACA,MAAIK,WAAW,GAAG,4BACjB;AACAX,EAAAA,YAAY,KAAK,MAAjB,IAA2BO,gBAA3B,GACG,CAAE,GAAGA,gBAAL,EAAwBK,OAAxB,EADH,GAEGL,gBAJc,CAAlB;;AAOA,MAAK,CAAEA,gBAAP,EAA0B;AACzB,WACC,iCAAQd,UAAR,EACC,4BAAC,mBAAD,OADD,CADD;AAKA;;AAED,MAAK,CAAEM,MAAP,EAAgB;AACfY,IAAAA,WAAW,GAAG/C,sBAAsB,CAAE;AACrCC,MAAAA,OAAO,EAAEoC,eAD4B;AAErCnC,MAAAA,cAFqC;AAGrCC,MAAAA;AAHqC,KAAF,CAApC;AAKA;;AAED,MAAK,CAAE4C,WAAW,CAAC7B,MAAnB,EAA4B;AAC3B,WAAO,iCAAQW,UAAR,OAAwB,cAAI,mBAAJ,CAAxB,CAAP;AACA;;AAED,SACC,4BAAC,YAAD;AACC,IAAA,QAAQ,EAAGkB,WADZ;AAEC,IAAA,UAAU,EAAGlB,UAFd;AAGC,IAAA,MAAM,EAAGd,MAHV;AAIC,IAAA,eAAe,EAAGH,eAJnB;AAKC,IAAA,kBAAkB,EAAGC,kBALtB;AAMC,IAAA,cAAc,mBAAGkC,WAAW,CAAE,CAAF,CAAd,kDAAG,cAAkBvC;AANpC,IADD;AAUA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, memo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockContextProvider,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tstore as blockEditorStore,\n\t__experimentalUseBlockPreview as useBlockPreview,\n} from '@wordpress/block-editor';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { useCommentQueryArgs, useCommentTree } from './hooks';\n\nconst TEMPLATE = [\n\t[ 'core/avatar' ],\n\t[ 'core/comment-author-name' ],\n\t[ 'core/comment-date' ],\n\t[ 'core/comment-content' ],\n\t[ 'core/comment-reply-link' ],\n\t[ 'core/comment-edit-link' ],\n];\n\n/**\n * Function that returns a comment structure that will be rendered with default placehoders.\n *\n * Each comment has a `commentId` property that is always a negative number in\n * case of the placeholders. This is to ensure that the comment does not\n * conflict with the actual (real) comments.\n *\n * @param {Object} settings Discussion Settings.\n * @param {number} [settings.perPage] - Comments per page setting or block attribute.\n * @param {boolean} [settings.threadComments] - Enable threaded (nested) comments setting.\n * @param {number} [settings.threadCommentsDepth] - Level deep of threaded comments.\n *\n * @typedef {{id: null, children: EmptyComment[]}} EmptyComment\n * @return {EmptyComment[]} \t\tInner blocks of the Comment Template\n */\nconst getCommentsPlaceholder = ( {\n\tperPage,\n\tthreadComments,\n\tthreadCommentsDepth,\n} ) => {\n\t// In case that `threadCommentsDepth` is falsy, we default to a somewhat\n\t// arbitrary value of 3.\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\tconst commentsDepth = Math.min( threadCommentsDepth || 3, 3 );\n\n\t// We set a limit in order not to overload the editor of empty comments.\n\tconst defaultCommentsToShow =\n\t\tperPage <= commentsDepth ? perPage : commentsDepth;\n\tif ( ! threadComments || defaultCommentsToShow === 1 ) {\n\t\t// If displaying threaded comments is disabled, we only show one comment\n\t\t// A commentId is negative in order to avoid conflicts with the actual comments.\n\t\treturn [ { commentId: -1, children: [] } ];\n\t} else if ( defaultCommentsToShow === 2 ) {\n\t\treturn [\n\t\t\t{\n\t\t\t\tcommentId: -1,\n\t\t\t\tchildren: [ { commentId: -2, children: [] } ],\n\t\t\t},\n\t\t];\n\t}\n\n\t// In case that the value is set but larger than 3 we truncate it to 3.\n\treturn [\n\t\t{\n\t\t\tcommentId: -1,\n\t\t\tchildren: [\n\t\t\t\t{\n\t\t\t\t\tcommentId: -2,\n\t\t\t\t\tchildren: [ { commentId: -3, children: [] } ],\n\t\t\t\t},\n\t\t\t],\n\t\t},\n\t];\n};\n\n/**\n * Component which renders the inner blocks of the Comment Template.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comment] - A comment object.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.firstCommentId] - ID of the first comment in the array.\n * @param {Array} [props.blocks] - Array of blocks returned from\n * getBlocks() in parent .\n * @return {WPElement} \t\tInner blocks of the Comment Template\n */\nfunction CommentTemplateInnerBlocks( {\n\tcomment,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tfirstCommentId,\n\tblocks,\n} ) {\n\tconst { children, ...innerBlocksProps } = useInnerBlocksProps(\n\t\t{},\n\t\t{ template: TEMPLATE }\n\t);\n\n\treturn (\n\t\t<li { ...innerBlocksProps }>\n\t\t\t{ comment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t? children\n\t\t\t\t: null }\n\n\t\t\t{ /* To avoid flicker when switching active block contexts, a preview\n\t\t\tis ALWAYS rendered and the preview for the active block is hidden.\n\t\t\tThis ensures that when switching the active block, the component is not\n\t\t\tmounted again but rather it only toggles the `isHidden` prop.\n\n\t\t\tThe same strategy is used for preventing the flicker in the Post Template\n\t\t\tblock. */ }\n\t\t\t<MemoizedCommentTemplatePreview\n\t\t\t\tblocks={ blocks }\n\t\t\t\tcommentId={ comment.commentId }\n\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\tisHidden={\n\t\t\t\t\tcomment.commentId === ( activeCommentId || firstCommentId )\n\t\t\t\t}\n\t\t\t/>\n\n\t\t\t{ comment?.children?.length > 0 ? (\n\t\t\t\t<CommentsList\n\t\t\t\t\tcomments={ comment.children }\n\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t/>\n\t\t\t) : null }\n\t\t</li>\n\t);\n}\n\nconst CommentTemplatePreview = ( {\n\tblocks,\n\tcommentId,\n\tsetActiveCommentId,\n\tisHidden,\n} ) => {\n\tconst blockPreviewProps = useBlockPreview( {\n\t\tblocks,\n\t} );\n\n\tconst handleOnClick = () => {\n\t\tsetActiveCommentId( commentId );\n\t};\n\n\t// We have to hide the preview block if the `comment` props points to\n\t// the curently active block!\n\n\t// Or, to put it differently, every preview block is visible unless it is the\n\t// currently active block - in this case we render its inner blocks.\n\tconst style = {\n\t\tdisplay: isHidden ? 'none' : undefined,\n\t};\n\n\treturn (\n\t\t<div\n\t\t\t{ ...blockPreviewProps }\n\t\t\ttabIndex={ 0 }\n\t\t\trole=\"button\"\n\t\t\tstyle={ style }\n\t\t\t// eslint-disable-next-line jsx-a11y/no-noninteractive-element-to-interactive-role\n\t\t\tonClick={ handleOnClick }\n\t\t\tonKeyPress={ handleOnClick }\n\t\t/>\n\t);\n};\n\nconst MemoizedCommentTemplatePreview = memo( CommentTemplatePreview );\n\n/**\n * Component that renders a list of (nested) comments. It is called recursively.\n *\n * @param {Object} props Component props.\n * @param {Array} [props.comments] - Array of comment objects.\n * @param {Array} [props.blockProps] - Props from parent's `useBlockProps()`.\n * @param {Array} [props.activeCommentId] - The ID of the comment that is currently active.\n * @param {Array} [props.setActiveCommentId] - The setter for activeCommentId.\n * @param {Array} [props.blocks] - Array of blocks returned from getBlocks() in parent.\n * @param {Object} [props.firstCommentId] - The ID of the first comment in the array of\n * comment objects.\n * @return {WPElement} \t\tList of comments.\n */\nconst CommentsList = ( {\n\tcomments,\n\tblockProps,\n\tactiveCommentId,\n\tsetActiveCommentId,\n\tblocks,\n\tfirstCommentId,\n} ) => (\n\t<ol { ...blockProps }>\n\t\t{ comments &&\n\t\t\tcomments.map( ( { commentId, ...comment }, index ) => (\n\t\t\t\t<BlockContextProvider\n\t\t\t\t\tkey={ comment.commentId || index }\n\t\t\t\t\tvalue={ {\n\t\t\t\t\t\t// If the commentId is negative it means that this comment is a\n\t\t\t\t\t\t// \"placeholder\" and that the block is most likely being used in the\n\t\t\t\t\t\t// site editor. In this case, we have to set the commentId to `null`\n\t\t\t\t\t\t// because otherwise the (non-existent) comment with a negative ID\n\t\t\t\t\t\t// would be reqested from the REST API.\n\t\t\t\t\t\tcommentId: commentId < 0 ? null : commentId,\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t<CommentTemplateInnerBlocks\n\t\t\t\t\t\tcomment={ { commentId, ...comment } }\n\t\t\t\t\t\tactiveCommentId={ activeCommentId }\n\t\t\t\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\t\t\t\tblocks={ blocks }\n\t\t\t\t\t\tfirstCommentId={ firstCommentId }\n\t\t\t\t\t/>\n\t\t\t\t</BlockContextProvider>\n\t\t\t) ) }\n\t</ol>\n);\n\nexport default function CommentTemplateEdit( {\n\tclientId,\n\tcontext: { postId },\n} ) {\n\tconst blockProps = useBlockProps();\n\n\tconst [ activeCommentId, setActiveCommentId ] = useState();\n\tconst {\n\t\tcommentOrder,\n\t\tthreadCommentsDepth,\n\t\tthreadComments,\n\t\tcommentsPerPage,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings().__experimentalDiscussionSettings;\n\t} );\n\n\tconst commentQuery = useCommentQueryArgs( {\n\t\tpostId,\n\t} );\n\n\tconst { topLevelComments, blocks } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEntityRecords } = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\treturn {\n\t\t\t\t// Request only top-level comments. Replies are embedded.\n\t\t\t\ttopLevelComments: commentQuery\n\t\t\t\t\t? getEntityRecords( 'root', 'comment', commentQuery )\n\t\t\t\t\t: null,\n\t\t\t\tblocks: getBlocks( clientId ),\n\t\t\t};\n\t\t},\n\t\t[ clientId, commentQuery ]\n\t);\n\n\t// Generate a tree structure of comment IDs.\n\tlet commentTree = useCommentTree(\n\t\t// Reverse the order of top comments if needed.\n\t\tcommentOrder === 'desc' && topLevelComments\n\t\t\t? [ ...topLevelComments ].reverse()\n\t\t\t: topLevelComments\n\t);\n\n\tif ( ! topLevelComments ) {\n\t\treturn (\n\t\t\t<p { ...blockProps }>\n\t\t\t\t<Spinner />\n\t\t\t</p>\n\t\t);\n\t}\n\n\tif ( ! postId ) {\n\t\tcommentTree = getCommentsPlaceholder( {\n\t\t\tperPage: commentsPerPage,\n\t\t\tthreadComments,\n\t\t\tthreadCommentsDepth,\n\t\t} );\n\t}\n\n\tif ( ! commentTree.length ) {\n\t\treturn <p { ...blockProps }> { __( 'No results found.' ) }</p>;\n\t}\n\n\treturn (\n\t\t<CommentsList\n\t\t\tcomments={ commentTree }\n\t\t\tblockProps={ blockProps }\n\t\t\tblocks={ blocks }\n\t\t\tactiveCommentId={ activeCommentId }\n\t\t\tsetActiveCommentId={ setActiveCommentId }\n\t\t\tfirstCommentId={ commentTree[ 0 ]?.commentId }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -25,21 +25,15 @@ var _apiFetch = _interopRequireDefault(require("@wordpress/api-fetch"));
|
|
|
25
25
|
* Return an object with the query args needed to fetch the default page of
|
|
26
26
|
* comments.
|
|
27
27
|
*
|
|
28
|
-
* @param {Object}
|
|
29
|
-
* @param {number}
|
|
30
|
-
*
|
|
31
|
-
* @param {string} props.defaultPage Page shown by default (newest/oldest).
|
|
32
|
-
* @param {boolean} props.inherit Overwrite props with values from WP
|
|
33
|
-
* discussion settings.
|
|
28
|
+
* @param {Object} props Hook props.
|
|
29
|
+
* @param {number} props.postId ID of the post that contains the comments.
|
|
30
|
+
* discussion settings.
|
|
34
31
|
*
|
|
35
32
|
* @return {Object} Query args to retrieve the comments.
|
|
36
33
|
*/
|
|
37
34
|
const useCommentQueryArgs = _ref => {
|
|
38
35
|
let {
|
|
39
|
-
postId
|
|
40
|
-
perPage,
|
|
41
|
-
defaultPage,
|
|
42
|
-
inherit
|
|
36
|
+
postId
|
|
43
37
|
} = _ref;
|
|
44
38
|
// Initialize the query args that are not going to change.
|
|
45
39
|
const queryArgs = {
|
|
@@ -51,8 +45,8 @@ const useCommentQueryArgs = _ref => {
|
|
|
51
45
|
}; // Get the Discussion settings that may be needed to query the comments.
|
|
52
46
|
|
|
53
47
|
const {
|
|
54
|
-
commentsPerPage,
|
|
55
|
-
defaultCommentsPage
|
|
48
|
+
commentsPerPage: perPage,
|
|
49
|
+
defaultCommentsPage: defaultPage
|
|
56
50
|
} = (0, _data.useSelect)(select => {
|
|
57
51
|
const {
|
|
58
52
|
getSettings
|
|
@@ -61,17 +55,7 @@ const useCommentQueryArgs = _ref => {
|
|
|
61
55
|
__experimentalDiscussionSettings
|
|
62
56
|
} = getSettings();
|
|
63
57
|
return __experimentalDiscussionSettings;
|
|
64
|
-
}); //
|
|
65
|
-
|
|
66
|
-
if (inherit) {
|
|
67
|
-
perPage = commentsPerPage;
|
|
68
|
-
defaultPage = defaultCommentsPage;
|
|
69
|
-
} // If a block props is not set, use the settings value to generate the
|
|
70
|
-
// appropriate query arg.
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
perPage = perPage || commentsPerPage;
|
|
74
|
-
defaultPage = defaultPage || defaultCommentsPage; // Get the number of the default page.
|
|
58
|
+
}); // Get the number of the default page.
|
|
75
59
|
|
|
76
60
|
const page = useDefaultPageIndex({
|
|
77
61
|
defaultPage,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comment-template/hooks.js"],"names":["useCommentQueryArgs","postId","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comment-template/hooks.js"],"names":["useCommentQueryArgs","postId","queryArgs","status","order","context","parent","_embed","commentsPerPage","perPage","defaultCommentsPage","defaultPage","select","getSettings","blockEditorStore","__experimentalDiscussionSettings","page","useDefaultPageIndex","post","per_page","defaultPages","setDefaultPages","key","path","_fields","method","parse","then","res","parseInt","headers","get","useCommentTree","topLevelComments","commentTree","map","id","_embedded","children","commentId","child"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AAPA;AACA;AACA;;AAOA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMA,mBAAmB,GAAG,QAAkB;AAAA,MAAhB;AAAEC,IAAAA;AAAF,GAAgB;AACpD;AACA,QAAMC,SAAS,GAAG;AACjBC,IAAAA,MAAM,EAAE,SADS;AAEjBC,IAAAA,KAAK,EAAE,KAFU;AAGjBC,IAAAA,OAAO,EAAE,OAHQ;AAIjBC,IAAAA,MAAM,EAAE,CAJS;AAKjBC,IAAAA,MAAM,EAAE;AALS,GAAlB,CAFoD,CAUpD;;AACA,QAAM;AACLC,IAAAA,eAAe,EAAEC,OADZ;AAELC,IAAAA,mBAAmB,EAAEC;AAFhB,MAGF,qBAAaC,MAAF,IAAc;AAC5B,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEE,kBAAF,CAA9B;AACA,UAAM;AAAEC,MAAAA;AAAF,QAAuCF,WAAW,EAAxD;AACA,WAAOE,gCAAP;AACA,GAJG,CAHJ,CAXoD,CAoBpD;;AACA,QAAMC,IAAI,GAAGC,mBAAmB,CAAE;AACjCN,IAAAA,WADiC;AAEjCV,IAAAA,MAFiC;AAGjCQ,IAAAA,OAHiC;AAIjCP,IAAAA;AAJiC,GAAF,CAAhC,CArBoD,CA4BpD;AACA;;AACA,SAAO,sBAAS,MAAM;AACrB,WAAOc,IAAI,GACR,EACA,GAAGd,SADH;AAEAgB,MAAAA,IAAI,EAAEjB,MAFN;AAGAkB,MAAAA,QAAQ,EAAEV,OAHV;AAIAO,MAAAA;AAJA,KADQ,GAOR,IAPH;AAQA,GATM,EASJ,CAAEf,MAAF,EAAUQ,OAAV,EAAmBO,IAAnB,CATI,CAAP;AAUA,CAxCM;AA0CP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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ACnB,MACCD,gBADD,aACCA,gBADD,uBACCA,gBAAgB,CAAEE,GAAlB,CAAuB,SAAyB;AAAA,QAAvB;AAAEC,MAAAA,EAAF;AAAMC,MAAAA;AAAN,KAAuB;AAC/C,UAAM,CAAEC,QAAF,IAAe,CAAAD,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEC,QAAX,KAAuB,CAAE,EAAF,CAA5C;AACA,WAAO;AACNC,MAAAA,SAAS,EAAEH,EADL;AAENE,MAAAA,QAAQ,EAAEA,QAAQ,CAACH,GAAT,CAAgBK,KAAF,KAAe;AACtCD,QAAAA,SAAS,EAAEC,KAAK,CAACJ;AADqB,OAAf,CAAd;AAFJ,KAAP;AAMA,GARD,CAFkB,EAWnB,CAAEH,gBAAF,CAXmB,CAApB;AAcA,SAAOC,WAAP;AACA,CAhBM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState, useEffect, useMemo } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Return an object with the query args needed to fetch the default page of\n * comments.\n *\n * @param {Object} props Hook props.\n * @param {number} props.postId ID of the post that contains the comments.\n * discussion settings.\n *\n * @return {Object} Query args to retrieve the comments.\n */\nexport const useCommentQueryArgs = ( { postId } ) => {\n\t// Initialize the query args that are not going to change.\n\tconst queryArgs = {\n\t\tstatus: 'approve',\n\t\torder: 'asc',\n\t\tcontext: 'embed',\n\t\tparent: 0,\n\t\t_embed: 'children',\n\t};\n\n\t// Get the Discussion settings that may be needed to query the comments.\n\tconst {\n\t\tcommentsPerPage: perPage,\n\t\tdefaultCommentsPage: defaultPage,\n\t} = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\tconst { __experimentalDiscussionSettings } = getSettings();\n\t\treturn __experimentalDiscussionSettings;\n\t} );\n\n\t// Get the number of the default page.\n\tconst page = useDefaultPageIndex( {\n\t\tdefaultPage,\n\t\tpostId,\n\t\tperPage,\n\t\tqueryArgs,\n\t} );\n\n\t// Merge, memoize and return all query arguments, unless the default page's\n\t// number is not known yet.\n\treturn useMemo( () => {\n\t\treturn page\n\t\t\t? {\n\t\t\t\t\t...queryArgs,\n\t\t\t\t\tpost: postId,\n\t\t\t\t\tper_page: perPage,\n\t\t\t\t\tpage,\n\t\t\t }\n\t\t\t: null;\n\t}, [ postId, perPage, page ] );\n};\n\n/**\n * Return the index of the default page, depending on whether `defaultPage` is\n * `newest` or `oldest`. In the first case, the only way to know the page's\n * index is by using the `X-WP-TotalPages` header, which forces to make an\n * additional request.\n *\n * @param {Object} props Hook props.\n * @param {string} props.defaultPage Page shown by default (newest/oldest).\n * @param {number} props.postId ID of the post that contains the comments.\n * @param {number} props.perPage The number of comments included per page.\n * @param {Object} props.queryArgs Other query args.\n *\n * @return {number} Index of the default comments page.\n */\nconst useDefaultPageIndex = ( { defaultPage, postId, perPage, queryArgs } ) => {\n\t// Store the default page indices.\n\tconst [ defaultPages, setDefaultPages ] = useState( {} );\n\tconst key = `${ postId }_${ perPage }`;\n\tconst page = defaultPages[ key ] || 0;\n\n\tuseEffect( () => {\n\t\t// Do nothing if the page is already known or not the newest page.\n\t\tif ( page || defaultPage !== 'newest' ) {\n\t\t\treturn;\n\t\t}\n\t\t// We need to fetch comments to know the index. Use HEAD and limit\n\t\t// fields just to ID, to make this call as light as possible.\n\t\tapiFetch( {\n\t\t\tpath: addQueryArgs( '/wp/v2/comments', {\n\t\t\t\t...queryArgs,\n\t\t\t\tpost: postId,\n\t\t\t\tper_page: perPage,\n\t\t\t\t_fields: 'id',\n\t\t\t} ),\n\t\t\tmethod: 'HEAD',\n\t\t\tparse: false,\n\t\t} ).then( ( res ) => {\n\t\t\tsetDefaultPages( {\n\t\t\t\t...defaultPages,\n\t\t\t\t[ key ]: parseInt( res.headers.get( 'X-WP-TotalPages' ) ),\n\t\t\t} );\n\t\t} );\n\t}, [ defaultPage, postId, perPage, setDefaultPages ] );\n\n\t// The oldest one is always the first one.\n\treturn defaultPage === 'newest' ? page : 1;\n};\n\n/**\n * Generate a tree structure of comment IDs from a list of comment entities. The\n * children of each comment are obtained from `_embedded`.\n *\n * @typedef {{ commentId: number, children: CommentNode }} CommentNode\n *\n * @param {Object[]} topLevelComments List of comment entities.\n * @return {{ commentTree: CommentNode[]}} Tree of comment IDs.\n */\nexport const useCommentTree = ( topLevelComments ) => {\n\tconst commentTree = useMemo(\n\t\t() =>\n\t\t\ttopLevelComments?.map( ( { id, _embedded } ) => {\n\t\t\t\tconst [ children ] = _embedded?.children || [ [] ];\n\t\t\t\treturn {\n\t\t\t\t\tcommentId: id,\n\t\t\t\t\tchildren: children.map( ( child ) => ( {\n\t\t\t\t\t\tcommentId: child.id,\n\t\t\t\t\t} ) ),\n\t\t\t\t};\n\t\t\t} ),\n\t\t[ topLevelComments ]\n\t);\n\n\treturn commentTree;\n};\n"]}
|
|
@@ -27,9 +27,9 @@ const metadata = {
|
|
|
27
27
|
title: "Comment Template",
|
|
28
28
|
category: "design",
|
|
29
29
|
parent: ["core/comments-query-loop"],
|
|
30
|
-
description: "Contains the block elements used to
|
|
30
|
+
description: "Contains the block elements used to display a comment, like the title, date, author, avatar and more.",
|
|
31
31
|
textdomain: "default",
|
|
32
|
-
usesContext: ["
|
|
32
|
+
usesContext: ["postId"],
|
|
33
33
|
supports: {
|
|
34
34
|
reusable: false,
|
|
35
35
|
html: false,
|
|
@@ -25,14 +25,14 @@ const metadata = {
|
|
|
25
25
|
title: "Next Page",
|
|
26
26
|
category: "theme",
|
|
27
27
|
parent: ["core/comments-pagination"],
|
|
28
|
-
description: "Displays the next
|
|
28
|
+
description: "Displays the next comment's page link.",
|
|
29
29
|
textdomain: "default",
|
|
30
30
|
attributes: {
|
|
31
31
|
label: {
|
|
32
32
|
type: "string"
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
|
-
usesContext: ["postId", "comments/
|
|
35
|
+
usesContext: ["postId", "comments/paginationArrow"],
|
|
36
36
|
supports: {
|
|
37
37
|
reusable: false,
|
|
38
38
|
html: false,
|
|
@@ -27,7 +27,7 @@ const metadata = {
|
|
|
27
27
|
parent: ["core/comments-pagination"],
|
|
28
28
|
description: "Displays a list of page numbers for comments pagination.",
|
|
29
29
|
textdomain: "default",
|
|
30
|
-
usesContext: ["postId"
|
|
30
|
+
usesContext: ["postId"],
|
|
31
31
|
supports: {
|
|
32
32
|
reusable: false,
|
|
33
33
|
html: false
|
|
@@ -25,7 +25,7 @@ const metadata = {
|
|
|
25
25
|
title: "Previous Page",
|
|
26
26
|
category: "theme",
|
|
27
27
|
parent: ["core/comments-pagination"],
|
|
28
|
-
description: "Displays the previous
|
|
28
|
+
description: "Displays the previous comment's page link.",
|
|
29
29
|
textdomain: "default",
|
|
30
30
|
attributes: {
|
|
31
31
|
label: {
|
|
@@ -16,81 +16,14 @@ var _blockEditor = require("@wordpress/block-editor");
|
|
|
16
16
|
/**
|
|
17
17
|
* WordPress dependencies
|
|
18
18
|
*/
|
|
19
|
-
const orderOptions = [{
|
|
20
|
-
label: (0, _i18n.__)('Newest to oldest'),
|
|
21
|
-
value: 'desc'
|
|
22
|
-
}, {
|
|
23
|
-
label: (0, _i18n.__)('Oldest to newest'),
|
|
24
|
-
value: 'asc'
|
|
25
|
-
}];
|
|
26
|
-
const defaultPageOptions = [{
|
|
27
|
-
label: (0, _i18n.__)('Newest'),
|
|
28
|
-
value: 'newest'
|
|
29
|
-
}, {
|
|
30
|
-
label: (0, _i18n.__)('Oldest'),
|
|
31
|
-
value: 'oldest'
|
|
32
|
-
}];
|
|
33
|
-
|
|
34
19
|
function CommentsInspectorControls(_ref) {
|
|
35
20
|
let {
|
|
36
21
|
attributes: {
|
|
37
|
-
TagName
|
|
38
|
-
perPage,
|
|
39
|
-
order,
|
|
40
|
-
inherit,
|
|
41
|
-
defaultPage
|
|
22
|
+
TagName
|
|
42
23
|
},
|
|
43
24
|
setAttributes
|
|
44
25
|
} = _ref;
|
|
45
|
-
return (0, _element.createElement)(_blockEditor.InspectorControls, null, (0, _element.createElement)(
|
|
46
|
-
title: (0, _i18n.__)('Settings')
|
|
47
|
-
}, (0, _element.createElement)(_components.ToggleControl, {
|
|
48
|
-
label: (0, _i18n.__)('Inherit from Discussion Settings'),
|
|
49
|
-
checked: inherit,
|
|
50
|
-
onChange: () => {
|
|
51
|
-
setAttributes({
|
|
52
|
-
inherit: !inherit
|
|
53
|
-
});
|
|
54
|
-
}
|
|
55
|
-
}), !inherit && (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_components.SelectControl, {
|
|
56
|
-
label: (0, _i18n.__)('Order by'),
|
|
57
|
-
value: order,
|
|
58
|
-
options: orderOptions,
|
|
59
|
-
onChange: value => {
|
|
60
|
-
setAttributes({
|
|
61
|
-
order: value
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
}), (0, _element.createElement)(_components.SelectControl, {
|
|
65
|
-
label: (0, _i18n.__)('Default page'),
|
|
66
|
-
value: defaultPage,
|
|
67
|
-
options: defaultPageOptions,
|
|
68
|
-
onChange: value => {
|
|
69
|
-
setAttributes({
|
|
70
|
-
defaultPage: value
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
}), (0, _element.createElement)(_components.__experimentalNumberControl, {
|
|
74
|
-
__unstableInputWidth: "60px",
|
|
75
|
-
label: (0, _i18n.__)('Items per Page'),
|
|
76
|
-
labelPosition: "edge",
|
|
77
|
-
min: 1,
|
|
78
|
-
max: 100,
|
|
79
|
-
onChange: value => {
|
|
80
|
-
const num = parseInt(value, 10);
|
|
81
|
-
|
|
82
|
-
if (isNaN(num) || num < 1 || num > 100) {
|
|
83
|
-
return;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
setAttributes({
|
|
87
|
-
perPage: num
|
|
88
|
-
});
|
|
89
|
-
},
|
|
90
|
-
step: "1",
|
|
91
|
-
value: perPage,
|
|
92
|
-
isDragEnabled: false
|
|
93
|
-
}))), (0, _element.createElement)(_blockEditor.InspectorControls, {
|
|
26
|
+
return (0, _element.createElement)(_blockEditor.InspectorControls, null, (0, _element.createElement)(_blockEditor.InspectorControls, {
|
|
94
27
|
__experimentalGroup: "advanced"
|
|
95
28
|
}, (0, _element.createElement)(_components.SelectControl, {
|
|
96
29
|
label: (0, _i18n.__)('HTML element'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/edit/comments-inspector-controls.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/comments-query-loop/edit/comments-inspector-controls.js"],"names":["CommentsInspectorControls","attributes","TagName","setAttributes","label","value","tagName"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKe,SAASA,yBAAT,OAGX;AAAA,MAH+C;AAClDC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KADsC;AAElDC,IAAAA;AAFkD,GAG/C;AACH,SACC,4BAAC,8BAAD,QACC,4BAAC,8BAAD;AAAmB,IAAA,mBAAmB,EAAC;AAAvC,KACC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAG,cAAI,cAAJ,CADT;AAEC,IAAA,OAAO,EAAG,CACT;AAAEC,MAAAA,KAAK,EAAE,cAAI,iBAAJ,CAAT;AAAkCC,MAAAA,KAAK,EAAE;AAAzC,KADS,EAET;AAAED,MAAAA,KAAK,EAAE,WAAT;AAAsBC,MAAAA,KAAK,EAAE;AAA7B,KAFS,EAGT;AAAED,MAAAA,KAAK,EAAE,SAAT;AAAoBC,MAAAA,KAAK,EAAE;AAA3B,KAHS,CAFX;AAOC,IAAA,KAAK,EAAGH,OAPT;AAQC,IAAA,QAAQ,EAAKG,KAAF,IACVF,aAAa,CAAE;AAAEG,MAAAA,OAAO,EAAED;AAAX,KAAF;AATf,IADD,CADD,CADD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { InspectorControls } from '@wordpress/block-editor';\n\nexport default function CommentsInspectorControls( {\n\tattributes: { TagName },\n\tsetAttributes,\n} ) {\n\treturn (\n\t\t<InspectorControls>\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: '<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</InspectorControls>\n\t);\n}\n"]}
|
|
@@ -20,7 +20,28 @@ var _commentsInspectorControls = _interopRequireDefault(require("./edit/comments
|
|
|
20
20
|
/**
|
|
21
21
|
* Internal dependencies
|
|
22
22
|
*/
|
|
23
|
-
const TEMPLATE = [['core/comment-template'
|
|
23
|
+
const TEMPLATE = [['core/comment-template', {}, [['core/columns', {}, [['core/column', {
|
|
24
|
+
width: '40px'
|
|
25
|
+
}, [['core/avatar', {
|
|
26
|
+
size: 40,
|
|
27
|
+
style: {
|
|
28
|
+
border: {
|
|
29
|
+
radius: '20px'
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}]]], ['core/column', {}, [['core/comment-author-name'], ['core/group', {
|
|
33
|
+
layout: {
|
|
34
|
+
type: 'flex'
|
|
35
|
+
},
|
|
36
|
+
style: {
|
|
37
|
+
spacing: {
|
|
38
|
+
margin: {
|
|
39
|
+
top: '0px',
|
|
40
|
+
bottom: '0px'
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}, [['core/comment-date'], ['core/comment-edit-link']]], ['core/comment-content'], ['core/comment-reply-link']]]]]]], ['core/comments-pagination']];
|
|
24
45
|
|
|
25
46
|
function CommentsQueryLoopEdit(_ref) {
|
|
26
47
|
let {
|