@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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/navigation-submenu/edit.js"],"names":["classnames","escape","pull","useSelect","useDispatch","PanelBody","Popover","TextControl","TextareaControl","ToolbarButton","ToolbarGroup","displayShortcut","isKeyboardEvent","__","sprintf","BlockControls","InnerBlocks","useInnerBlocksProps","InspectorControls","RichText","__experimentalLinkControl","LinkControl","useBlockProps","store","blockEditorStore","getColorClassName","isURL","prependHTTP","safeDecodeURI","Fragment","useState","useEffect","useRef","createInterpolateElement","placeCaretAtHorizontalEdge","link","linkIcon","removeSubmenu","coreStore","speak","createBlock","ItemSubmenuIcon","ALLOWED_BLOCKS","DEFAULT_BLOCK","name","MAX_NESTING","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","getSuggestionsQuery","type","kind","subtype","getColors","context","isSubMenu","textColor","customTextColor","backgroundColor","customBackgroundColor","overlayTextColor","customOverlayTextColor","overlayBackgroundColor","customOverlayBackgroundColor","style","colors","color","text","background","updateNavigationLinkBlockAttributes","updatedValue","setAttributes","blockAttributes","label","originalLabel","originalKind","originalType","title","url","opensInNewTab","id","newKind","newType","normalizedTitle","replace","normalizedURL","escapeTitle","isBuiltInType","indexOf","isCustomLink","encodeURI","undefined","Number","isInteger","NavigationSubmenuEdit","attributes","isSelected","mergeBlocks","onReplace","clientId","description","rel","showSubmenuIcon","openSubmenusOnClick","saveEntityRecord","__unstableMarkNextChangeAsNotPersistent","replaceBlock","isLinkOpen","setIsLinkOpen","listItemRef","itemLabelPlaceholder","ref","isAtMaxNesting","isTopLevelItem","isParentOfSelectedBlock","isImmediateParentOfSelectedBlock","hasDescendants","selectedBlockHasDescendants","userCanCreatePages","userCanCreatePosts","onlyDescendantIsEmptyLink","select","getClientIdsOfDescendants","hasSelectedInnerBlock","getSelectedBlockClientId","getBlockParentsByBlockName","getBlock","_onlyDescendantIsEmptyLink","selectedBlockId","descendants","length","selectedBlockDescendants","singleBlock","canUser","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","userCanCreate","handleCreate","pageTitle","postType","page","status","rendered","onKeyDown","primary","blockProps","className","innerBlocksColors","innerBlocksProps","allowedBlocks","__experimentalDefaultBlock","__experimentalDirectInsert","__experimentalCaptureToolbars","renderAppender","ButtonBlockAppender","ParentElement","transformToLink","newLinkBlock","canConvertToLink","descriptionValue","titleValue","relValue","labelValue","searchTerm","format","mark"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,MAAT,EAAiBC,IAAjB,QAA6B,QAA7B;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,SADD,EAECC,OAFD,EAGCC,WAHD,EAICC,eAJD,EAKCC,aALD,EAMC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MAAM;AAChBxB,MAAAA,aAAa,CAAE;AAAEO,QAAAA,GAAG,EAAE;AAAP,OAAF,CAAb;AACAlD,MAAAA,KAAK,CAAE1B,EAAE,CAAE,eAAF,CAAJ,EAAyB,WAAzB,CAAL;AACA;AAxCF,IALD,CA9BF,CAFD,EAkFG,CAAEoG,eAAe,IAAIC,mBAArB,KACD;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,cAAC,eAAD,OADD,CAnFF,EAuFC,qBAAUsD,gBAAV,CAvFD,CAvDD,CADD;AAmJA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { escape, pull } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tPanelBody,\n\tPopover,\n\tTextControl,\n\tTextareaControl,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tRichText,\n\t__experimentalLinkControl as LinkControl,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP, safeDecodeURI } from '@wordpress/url';\nimport {\n\tFragment,\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tcreateInterpolateElement,\n} from '@wordpress/element';\nimport { placeCaretAtHorizontalEdge } from '@wordpress/dom';\nimport { link as linkIcon, removeSubmenu } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { speak } from '@wordpress/a11y';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { ItemSubmenuIcon } from './icons';\nimport { name } from './block.json';\n\nconst ALLOWED_BLOCKS = [ 'core/navigation-link', 'core/navigation-submenu' ];\n\nconst DEFAULT_BLOCK = {\n\tname: 'core/navigation-link',\n};\n\nconst MAX_NESTING = 5;\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that\n\t\t// doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\n/**\n * Given the Link block's type attribute, return the query params to give to\n * /wp/v2/search.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {{ type?: string, subtype?: string }} Search query params.\n */\nfunction getSuggestionsQuery( type, kind ) {\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\tcase 'page':\n\t\t\treturn { type: 'post', subtype: type };\n\t\tcase 'category':\n\t\t\treturn { type: 'term', subtype: 'category' };\n\t\tcase 'tag':\n\t\t\treturn { type: 'term', subtype: 'post_tag' };\n\t\tcase 'post_format':\n\t\t\treturn { type: 'post-format' };\n\t\tdefault:\n\t\t\tif ( kind === 'taxonomy' ) {\n\t\t\t\treturn { type: 'term', subtype: type };\n\t\t\t}\n\t\t\tif ( kind === 'post-type' ) {\n\t\t\t\treturn { type: 'post', subtype: type };\n\t\t\t}\n\t\t\treturn {};\n\t}\n}\n\n/**\n * Determine the colors for a menu.\n *\n * Order of priority is:\n * 1: Overlay custom colors (if submenu)\n * 2: Overlay theme colors (if submenu)\n * 3: Custom colors\n * 4: Theme colors\n * 5: Global styles\n *\n * @param {Object} context\n * @param {boolean} isSubMenu\n */\nfunction getColors( context, isSubMenu ) {\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t\toverlayTextColor,\n\t\tcustomOverlayTextColor,\n\t\toverlayBackgroundColor,\n\t\tcustomOverlayBackgroundColor,\n\t\tstyle,\n\t} = context;\n\n\tconst colors = {};\n\n\tif ( isSubMenu && !! customOverlayTextColor ) {\n\t\tcolors.customTextColor = customOverlayTextColor;\n\t} else if ( isSubMenu && !! overlayTextColor ) {\n\t\tcolors.textColor = overlayTextColor;\n\t} else if ( !! customTextColor ) {\n\t\tcolors.customTextColor = customTextColor;\n\t} else if ( !! textColor ) {\n\t\tcolors.textColor = textColor;\n\t} else if ( !! style?.color?.text ) {\n\t\tcolors.customTextColor = style.color.text;\n\t}\n\n\tif ( isSubMenu && !! customOverlayBackgroundColor ) {\n\t\tcolors.customBackgroundColor = customOverlayBackgroundColor;\n\t} else if ( isSubMenu && !! overlayBackgroundColor ) {\n\t\tcolors.backgroundColor = overlayBackgroundColor;\n\t} else if ( !! customBackgroundColor ) {\n\t\tcolors.customBackgroundColor = customBackgroundColor;\n\t} else if ( !! backgroundColor ) {\n\t\tcolors.backgroundColor = backgroundColor;\n\t} else if ( !! style?.color?.background ) {\n\t\tcolors.customTextColor = style.color.background;\n\t}\n\n\treturn colors;\n}\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n * @property {string} [title] Link title attribute.\n */\n\n/**\n * Link Control onChange handler that updates block attributes when a setting is changed.\n *\n * @param {Object} updatedValue New block attributes to update.\n * @param {Function} setAttributes Block attribute update function.\n * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.\n *\n */\nexport const updateNavigationLinkBlockAttributes = (\n\tupdatedValue = {},\n\tsetAttributes,\n\tblockAttributes = {}\n) => {\n\tconst {\n\t\tlabel: originalLabel = '',\n\t\tkind: originalKind = '',\n\t\ttype: originalType = '',\n\t} = blockAttributes;\n\tconst {\n\t\ttitle = '',\n\t\turl = '',\n\t\topensInNewTab,\n\t\tid,\n\t\tkind: newKind = originalKind,\n\t\ttype: newType = originalType,\n\t} = updatedValue;\n\n\tconst normalizedTitle = title.replace( /http(s?):\\/\\//gi, '' );\n\tconst normalizedURL = url.replace( /http(s?):\\/\\//gi, '' );\n\tconst escapeTitle =\n\t\ttitle !== '' &&\n\t\tnormalizedTitle !== normalizedURL &&\n\t\toriginalLabel !== title;\n\tconst label = escapeTitle\n\t\t? escape( title )\n\t\t: originalLabel || escape( normalizedURL );\n\n\t// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use \"tag\" in favor of \"post_tag\"\n\tconst type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );\n\n\tconst isBuiltInType =\n\t\t[ 'post', 'page', 'tag', 'category' ].indexOf( type ) > -1;\n\n\tconst isCustomLink =\n\t\t( ! newKind && ! isBuiltInType ) || newKind === 'custom';\n\tconst kind = isCustomLink ? 'custom' : newKind;\n\n\tsetAttributes( {\n\t\t// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.\n\t\t...( url && { url: encodeURI( safeDecodeURI( url ) ) } ),\n\t\t...( label && { label } ),\n\t\t...( undefined !== opensInNewTab && { opensInNewTab } ),\n\t\t...( id && Number.isInteger( id ) && { id } ),\n\t\t...( kind && { kind } ),\n\t\t...( type && type !== 'URL' && { type } ),\n\t} );\n};\n\nexport default function NavigationSubmenuEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst {\n\t\tlabel,\n\t\ttype,\n\t\topensInNewTab,\n\t\turl,\n\t\tdescription,\n\t\trel,\n\t\ttitle,\n\t\tkind,\n\t} = attributes;\n\tconst link = {\n\t\turl,\n\t\topensInNewTab,\n\t};\n\tconst { showSubmenuIcon, openSubmenusOnClick } = context;\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\tconst {\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlock,\n\t} = useDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add text…' );\n\tconst ref = useRef();\n\n\tconst {\n\t\tisAtMaxNesting,\n\t\tisTopLevelItem,\n\t\tisParentOfSelectedBlock,\n\t\tisImmediateParentOfSelectedBlock,\n\t\thasDescendants,\n\t\tselectedBlockHasDescendants,\n\t\tuserCanCreatePages,\n\t\tuserCanCreatePosts,\n\t\tonlyDescendantIsEmptyLink,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetBlock,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet _onlyDescendantIsEmptyLink;\n\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\tconst descendants = getClientIdsOfDescendants( [ clientId ] )\n\t\t\t\t.length;\n\n\t\t\tconst selectedBlockDescendants = getClientIdsOfDescendants( [\n\t\t\t\tselectedBlockId,\n\t\t\t] );\n\n\t\t\t// Check for a single descendant in the submenu. If that block\n\t\t\t// is a link block in a \"placeholder\" state with no label then\n\t\t\t// we can consider as an \"empty\" link.\n\t\t\tif ( selectedBlockDescendants?.length === 1 ) {\n\t\t\t\tconst singleBlock = getBlock( selectedBlockDescendants[ 0 ] );\n\n\t\t\t\t_onlyDescendantIsEmptyLink =\n\t\t\t\t\tsingleBlock?.name === 'core/navigation-link' &&\n\t\t\t\t\t! singleBlock?.attributes?.label;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tisAtMaxNesting:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, name ).length >=\n\t\t\t\t\tMAX_NESTING,\n\t\t\t\tisTopLevelItem:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, name ).length === 0,\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\tisImmediateParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasDescendants: !! descendants,\n\t\t\t\tselectedBlockHasDescendants: !! selectedBlockDescendants?.length,\n\t\t\t\tuserCanCreatePages: select( coreStore ).canUser(\n\t\t\t\t\t'create',\n\t\t\t\t\t'pages'\n\t\t\t\t),\n\t\t\t\tuserCanCreatePosts: select( coreStore ).canUser(\n\t\t\t\t\t'create',\n\t\t\t\t\t'posts'\n\t\t\t\t),\n\t\t\t\tonlyDescendantIsEmptyLink: _onlyDescendantIsEmptyLink,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Show the LinkControl on mount if the URL is empty\n\t// ( When adding a new menu item)\n\t// This can't be done in the useState call because it conflicts\n\t// with the autofocus behavior of the BlockListBlock component.\n\tuseEffect( () => {\n\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}, [] );\n\n\t// Store the colors from context as attributes for rendering.\n\tuseEffect( () => {\n\t\t// This side-effect should not create an undo level as those should\n\t\t// only be created via user interactions. Mark this change as\n\t\t// not persistent to avoid undo level creation.\n\t\t// See https://github.com/WordPress/gutenberg/issues/34564.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( { isTopLevelItem } );\n\t}, [ isTopLevelItem ] );\n\n\t/**\n\t * The hook shouldn't be necessary but due to a focus loss happening\n\t * when selecting a suggestion in the link popover, we force close on block unselection.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsLinkOpen( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\tif ( isLinkOpen && url ) {\n\t\t\t// Does this look like a URL and have something TLD-ish?\n\t\t\tif (\n\t\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t\t) {\n\t\t\t\t// Focus and select the label text.\n\t\t\t\tselectLabelText();\n\t\t\t} else {\n\t\t\t\t// Focus it (but do not select).\n\t\t\t\tplaceCaretAtHorizontalEdge( ref.current, true );\n\t\t\t}\n\t\t}\n\t}, [ url ] );\n\n\t/**\n\t * Focus the Link label text and select it.\n\t */\n\tfunction selectLabelText() {\n\t\tref.current.focus();\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst selection = defaultView.getSelection();\n\t\tconst range = ownerDocument.createRange();\n\t\t// Get the range of the current ref contents so we can add this range to the selection.\n\t\trange.selectNodeContents( ref.current );\n\t\tselection.removeAllRanges();\n\t\tselection.addRange( range );\n\t}\n\n\tlet userCanCreate = false;\n\tif ( ! type || type === 'page' ) {\n\t\tuserCanCreate = userCanCreatePages;\n\t} else if ( type === 'post' ) {\n\t\tuserCanCreate = userCanCreatePosts;\n\t}\n\n\tasync function handleCreate( pageTitle ) {\n\t\tconst postType = type || 'page';\n\n\t\tconst page = await saveEntityRecord( 'postType', postType, {\n\t\t\ttitle: pageTitle,\n\t\t\tstatus: 'draft',\n\t\t} );\n\n\t\treturn {\n\t\t\tid: page.id,\n\t\t\ttype: postType,\n\t\t\ttitle: page.title.rendered,\n\t\t\turl: page.link,\n\t\t\tkind: 'post-type',\n\t\t};\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, ! isTopLevelItem );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: listItemRef,\n\t\tclassName: classnames( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasDescendants,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName(\n\t\t\t\t'background-color',\n\t\t\t\tbackgroundColor\n\t\t\t) ]: !! backgroundColor,\n\t\t\t'open-on-click': openSubmenusOnClick,\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\t// Always use overlay colors for submenus.\n\tconst innerBlocksColors = getColors( context, true );\n\n\tif ( isAtMaxNesting ) {\n\t\tpull( ALLOWED_BLOCKS, 'core/navigation-submenu' );\n\t}\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tclassName: classnames( 'wp-block-navigation__submenu-container', {\n\t\t\t\t'is-parent-of-selected-block': isParentOfSelectedBlock,\n\t\t\t\t'has-text-color': !! (\n\t\t\t\t\tinnerBlocksColors.textColor ||\n\t\t\t\t\tinnerBlocksColors.customTextColor\n\t\t\t\t),\n\t\t\t\t[ `has-${ innerBlocksColors.textColor }-color` ]: !! innerBlocksColors.textColor,\n\t\t\t\t'has-background': !! (\n\t\t\t\t\tinnerBlocksColors.backgroundColor ||\n\t\t\t\t\tinnerBlocksColors.customBackgroundColor\n\t\t\t\t),\n\t\t\t\t[ `has-${ innerBlocksColors.backgroundColor }-background-color` ]: !! innerBlocksColors.backgroundColor,\n\t\t\t} ),\n\t\t\tstyle: {\n\t\t\t\tcolor: innerBlocksColors.customTextColor,\n\t\t\t\tbackgroundColor: innerBlocksColors.customBackgroundColor,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t\t\t__experimentalDefaultBlock: DEFAULT_BLOCK,\n\t\t\t__experimentalDirectInsert: true,\n\n\t\t\t// Ensure block toolbar is not too far removed from item\n\t\t\t// being edited.\n\t\t\t// see: https://github.com/WordPress/gutenberg/pull/34615.\n\t\t\t__experimentalCaptureToolbars: true,\n\n\t\t\trenderAppender:\n\t\t\t\tisSelected ||\n\t\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t\t! selectedBlockHasDescendants ) ||\n\t\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\t\thasDescendants\n\t\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t\t: false,\n\t\t}\n\t);\n\n\tconst ParentElement = openSubmenusOnClick ? 'button' : 'a';\n\n\tfunction transformToLink() {\n\t\tconst newLinkBlock = createBlock( 'core/navigation-link', attributes );\n\t\treplaceBlock( clientId, newLinkBlock );\n\t}\n\n\tconst canConvertToLink =\n\t\t! selectedBlockHasDescendants || onlyDescendantIsEmptyLink;\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ ! openSubmenusOnClick && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\tonClick={ () => setIsLinkOpen( true ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"revert\"\n\t\t\t\t\t\ticon={ removeSubmenu }\n\t\t\t\t\t\ttitle={ __( 'Convert to Link' ) }\n\t\t\t\t\t\tonClick={ transformToLink }\n\t\t\t\t\t\tclassName=\"wp-block-navigation__submenu__revert\"\n\t\t\t\t\t\tisDisabled={ ! canConvertToLink }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\tvalue={ description || '' }\n\t\t\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdescription: descriptionValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\t\tonChange={ ( titleValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { title: titleValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Link title' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<ParentElement className=\"wp-block-navigation-item__content\">\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t{\n\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { label: labelValue } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\taria-label={ __( 'Navigation link text' ) }\n\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\tallowedFormats={ [\n\t\t\t\t\t\t\t\t'core/bold',\n\t\t\t\t\t\t\t\t'core/italic',\n\t\t\t\t\t\t\t\t'core/image',\n\t\t\t\t\t\t\t\t'core/strikethrough',\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t\t{ ! openSubmenusOnClick && isLinkOpen && (\n\t\t\t\t\t\t<Popover\n\t\t\t\t\t\t\tposition=\"bottom center\"\n\t\t\t\t\t\t\tonClose={ () => setIsLinkOpen( false ) }\n\t\t\t\t\t\t\tanchorRef={ listItemRef.current }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LinkControl\n\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-link__inline-link-input\"\n\t\t\t\t\t\t\t\tvalue={ link }\n\t\t\t\t\t\t\t\tshowInitialSuggestions={ true }\n\t\t\t\t\t\t\t\twithCreateSuggestion={ userCanCreate }\n\t\t\t\t\t\t\t\tcreateSuggestion={ handleCreate }\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText={ ( searchTerm ) => {\n\t\t\t\t\t\t\t\t\tlet format;\n\t\t\t\t\t\t\t\t\tif ( type === 'post' ) {\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t\t\t\t\t\t\tformat = __(\n\t\t\t\t\t\t\t\t\t\t\t'Create draft post: <mark>%s</mark>'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t\t\t\t\t\t\tformat = __(\n\t\t\t\t\t\t\t\t\t\t\t'Create draft page: <mark>%s</mark>'\n\t\t\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\treturn createInterpolateElement(\n\t\t\t\t\t\t\t\t\t\tsprintf( format, searchTerm ),\n\t\t\t\t\t\t\t\t\t\t{ mark: <mark /> }\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\tnoDirectEntry={ !! type }\n\t\t\t\t\t\t\t\tnoURLSuggestion={ !! type }\n\t\t\t\t\t\t\t\tsuggestionsQuery={ getSuggestionsQuery(\n\t\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t\tkind\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tonChange={ ( updatedValue ) =>\n\t\t\t\t\t\t\t\t\tupdateNavigationLinkBlockAttributes(\n\t\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\t\tattributes\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\tonRemove={ () => {\n\t\t\t\t\t\t\t\t\tsetAttributes( { url: '' } );\n\t\t\t\t\t\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover>\n\t\t\t\t\t) }\n\t\t\t\t</ParentElement>\n\t\t\t\t{ ( showSubmenuIcon || openSubmenusOnClick ) && (\n\t\t\t\t\t<span className=\"wp-block-navigation__submenu-icon\">\n\t\t\t\t\t\t<ItemSubmenuIcon />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</Fragment>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/navigation-submenu/edit.js"],"names":["classnames","escape","without","useSelect","useDispatch","PanelBody","Popover","TextControl","TextareaControl","ToolbarButton","ToolbarGroup","displayShortcut","isKeyboardEvent","__","sprintf","BlockControls","InnerBlocks","useInnerBlocksProps","InspectorControls","RichText","__experimentalLinkControl","LinkControl","useBlockProps","store","blockEditorStore","getColorClassName","isURL","prependHTTP","safeDecodeURI","Fragment","useState","useEffect","useRef","createInterpolateElement","placeCaretAtHorizontalEdge","link","linkIcon","removeSubmenu","coreStore","speak","createBlock","ItemSubmenuIcon","ALLOWED_BLOCKS","DEFAULT_BLOCK","name","useIsDraggingWithin","elementRef","isDraggingWithin","setIsDraggingWithin","ownerDocument","current","handleDragStart","event","handleDragEnter","handleDragEnd","contains","target","addEventListener","removeEventListener","getSuggestionsQuery","type","kind","subtype","getColors","context","isSubMenu","textColor","customTextColor","backgroundColor","customBackgroundColor","overlayTextColor","customOverlayTextColor","overlayBackgroundColor","customOverlayBackgroundColor","style","colors","color","text","background","updateNavigationLinkBlockAttributes","updatedValue","setAttributes","blockAttributes","label","originalLabel","originalKind","originalType","title","url","opensInNewTab","id","newKind","newType","normalizedTitle","replace","normalizedURL","escapeTitle","isBuiltInType","indexOf","isCustomLink","encodeURI","undefined","Number","isInteger","NavigationSubmenuEdit","attributes","isSelected","mergeBlocks","onReplace","clientId","description","rel","showSubmenuIcon","maxNestingLevel","openSubmenusOnClick","saveEntityRecord","__unstableMarkNextChangeAsNotPersistent","replaceBlock","isLinkOpen","setIsLinkOpen","listItemRef","itemLabelPlaceholder","ref","isAtMaxNesting","isTopLevelItem","isParentOfSelectedBlock","isImmediateParentOfSelectedBlock","hasDescendants","selectedBlockHasDescendants","userCanCreatePages","userCanCreatePosts","onlyDescendantIsEmptyLink","select","getClientIdsOfDescendants","hasSelectedInnerBlock","getSelectedBlockClientId","getBlockParentsByBlockName","getBlock","_onlyDescendantIsEmptyLink","selectedBlockId","descendants","length","selectedBlockDescendants","singleBlock","canUser","test","selectLabelText","focus","defaultView","selection","getSelection","range","createRange","selectNodeContents","removeAllRanges","addRange","userCanCreate","handleCreate","pageTitle","postType","page","status","rendered","onKeyDown","primary","blockProps","className","innerBlocksColors","allowedBlocks","innerBlocksProps","__experimentalDefaultBlock","__experimentalDirectInsert","__experimentalCaptureToolbars","renderAppender","ButtonBlockAppender","ParentElement","transformToLink","newLinkBlock","canConvertToLink","descriptionValue","titleValue","relValue","labelValue","searchTerm","format","mark"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AACA,SAASC,MAAT,EAAiBC,OAAjB,QAAgC,QAAhC;AAEA;AACA;AACA;;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,SADD,EAECC,OAFD,EAGCC,WAHD,EAICC,eAJD,EAKCC,aALD,EAMCC,YAND,QAOO,uBAPP;AAQA,SAASC,eAAT,EAA0BC,eAA1B,QAAiD,qBAAjD;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,aADD,EAECC,WAFD,EAGCC,mBAHD,EAICC,iBAJD,EAKCC,QALD,EAMCC,yBAAyB,IAAIC,WAN9B,EAOCC,aAPD,EAQCC,KAAK,IAAIC,gBARV,EASCC,iBATD,QAUO,yBAVP;AAWA,SAASC,KAAT,EAAgBC,WAAhB,EAA6BC,aAA7B,QAAkD,gBAAlD;AACA,SACCC,QADD,EAECC,QAFD,EAGCC,SAHD,EAICC,MAJD,EAKCC,wBALD,QAMO,oBANP;AAOA,SAASC,0BAAT,QAA2C,gBAA3C;AACA,SAASC,IAAI,IAAIC,QAAjB,EAA2BC,aAA3B,QAAgD,kBAAhD;AACA,SAASd,KAAK,IAAIe,SAAlB,QAAmC,sBAAnC;AACA,SAASC,KAAT,QAAsB,iBAAtB;AACA,SAASC,WAAT,QAA4B,mBAA5B;AAEA;AACA;AACA;;AACA,SAASC,eAAT,QAAgC,SAAhC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAGA,MAAMC,cAAc,GAAG,CAAE,sBAAF,EAA0B,yBAA1B,CAAvB;AAEA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,IAAI,EAAE;AADe,CAAtB;A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,EAAE;AAAR,OAF8B,CAA/B;AAIA,KAvBF;AAwBC,IAAA,aAAa,EAAG,CAAC,CAAE7H,IAxBpB;AAyBC,IAAA,eAAe,EAAG,CAAC,CAAEA,IAzBtB;AA0BC,IAAA,gBAAgB,EAAGD,mBAAmB,CACrCC,IADqC,EAErCC,IAFqC,CA1BvC;AA8BC,IAAA,QAAQ,EAAKmB,YAAF,IACVD,mCAAmC,CAClCC,YADkC,EAElCC,aAFkC,EAGlCwB,UAHkC,CA/BrC;AAqCC,IAAA,QAAQ,EAAG,MAAM;AAChBxB,MAAAA,aAAa,CAAE;AAAEO,QAAAA,GAAG,EAAE;AAAP,OAAF,CAAb;AACAjD,MAAAA,KAAK,CAAE1B,EAAE,CAAE,eAAF,CAAJ,EAAyB,WAAzB,CAAL;AACA;AAxCF,IALD,CA9BF,CAFD,EAkFG,CAAEmG,eAAe,IAAIE,mBAArB,KACD;AAAM,IAAA,SAAS,EAAC;AAAhB,KACC,cAAC,eAAD,OADD,CAnFF,EAuFC,qBAAUuD,gBAAV,CAvFD,CAvDD,CADD;AAmJA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\nimport { escape, without } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tPanelBody,\n\tPopover,\n\tTextControl,\n\tTextareaControl,\n\tToolbarButton,\n\tToolbarGroup,\n} from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tuseInnerBlocksProps,\n\tInspectorControls,\n\tRichText,\n\t__experimentalLinkControl as LinkControl,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP, safeDecodeURI } from '@wordpress/url';\nimport {\n\tFragment,\n\tuseState,\n\tuseEffect,\n\tuseRef,\n\tcreateInterpolateElement,\n} from '@wordpress/element';\nimport { placeCaretAtHorizontalEdge } from '@wordpress/dom';\nimport { link as linkIcon, removeSubmenu } from '@wordpress/icons';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { speak } from '@wordpress/a11y';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { ItemSubmenuIcon } from './icons';\nimport { name } from './block.json';\n\nconst ALLOWED_BLOCKS = [ 'core/navigation-link', 'core/navigation-submenu' ];\n\nconst DEFAULT_BLOCK = {\n\tname: 'core/navigation-link',\n};\n\n/**\n * A React hook to determine if it's dragging within the target element.\n *\n * @typedef {import('@wordpress/element').RefObject} RefObject\n *\n * @param {RefObject<HTMLElement>} elementRef The target elementRef object.\n *\n * @return {boolean} Is dragging within the target element.\n */\nconst useIsDraggingWithin = ( elementRef ) => {\n\tconst [ isDraggingWithin, setIsDraggingWithin ] = useState( false );\n\n\tuseEffect( () => {\n\t\tconst { ownerDocument } = elementRef.current;\n\n\t\tfunction handleDragStart( event ) {\n\t\t\t// Check the first time when the dragging starts.\n\t\t\thandleDragEnter( event );\n\t\t}\n\n\t\t// Set to false whenever the user cancel the drag event by either releasing the mouse or press Escape.\n\t\tfunction handleDragEnd() {\n\t\t\tsetIsDraggingWithin( false );\n\t\t}\n\n\t\tfunction handleDragEnter( event ) {\n\t\t\t// Check if the current target is inside the item element.\n\t\t\tif ( elementRef.current.contains( event.target ) ) {\n\t\t\t\tsetIsDraggingWithin( true );\n\t\t\t} else {\n\t\t\t\tsetIsDraggingWithin( false );\n\t\t\t}\n\t\t}\n\n\t\t// Bind these events to the document to catch all drag events.\n\t\t// Ideally, we can also use `event.relatedTarget`, but sadly that\n\t\t// doesn't work in Safari.\n\t\townerDocument.addEventListener( 'dragstart', handleDragStart );\n\t\townerDocument.addEventListener( 'dragend', handleDragEnd );\n\t\townerDocument.addEventListener( 'dragenter', handleDragEnter );\n\n\t\treturn () => {\n\t\t\townerDocument.removeEventListener( 'dragstart', handleDragStart );\n\t\t\townerDocument.removeEventListener( 'dragend', handleDragEnd );\n\t\t\townerDocument.removeEventListener( 'dragenter', handleDragEnter );\n\t\t};\n\t}, [] );\n\n\treturn isDraggingWithin;\n};\n\n/**\n * Given the Link block's type attribute, return the query params to give to\n * /wp/v2/search.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {{ type?: string, subtype?: string }} Search query params.\n */\nfunction getSuggestionsQuery( type, kind ) {\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\tcase 'page':\n\t\t\treturn { type: 'post', subtype: type };\n\t\tcase 'category':\n\t\t\treturn { type: 'term', subtype: 'category' };\n\t\tcase 'tag':\n\t\t\treturn { type: 'term', subtype: 'post_tag' };\n\t\tcase 'post_format':\n\t\t\treturn { type: 'post-format' };\n\t\tdefault:\n\t\t\tif ( kind === 'taxonomy' ) {\n\t\t\t\treturn { type: 'term', subtype: type };\n\t\t\t}\n\t\t\tif ( kind === 'post-type' ) {\n\t\t\t\treturn { type: 'post', subtype: type };\n\t\t\t}\n\t\t\treturn {};\n\t}\n}\n\n/**\n * Determine the colors for a menu.\n *\n * Order of priority is:\n * 1: Overlay custom colors (if submenu)\n * 2: Overlay theme colors (if submenu)\n * 3: Custom colors\n * 4: Theme colors\n * 5: Global styles\n *\n * @param {Object} context\n * @param {boolean} isSubMenu\n */\nfunction getColors( context, isSubMenu ) {\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t\toverlayTextColor,\n\t\tcustomOverlayTextColor,\n\t\toverlayBackgroundColor,\n\t\tcustomOverlayBackgroundColor,\n\t\tstyle,\n\t} = context;\n\n\tconst colors = {};\n\n\tif ( isSubMenu && !! customOverlayTextColor ) {\n\t\tcolors.customTextColor = customOverlayTextColor;\n\t} else if ( isSubMenu && !! overlayTextColor ) {\n\t\tcolors.textColor = overlayTextColor;\n\t} else if ( !! customTextColor ) {\n\t\tcolors.customTextColor = customTextColor;\n\t} else if ( !! textColor ) {\n\t\tcolors.textColor = textColor;\n\t} else if ( !! style?.color?.text ) {\n\t\tcolors.customTextColor = style.color.text;\n\t}\n\n\tif ( isSubMenu && !! customOverlayBackgroundColor ) {\n\t\tcolors.customBackgroundColor = customOverlayBackgroundColor;\n\t} else if ( isSubMenu && !! overlayBackgroundColor ) {\n\t\tcolors.backgroundColor = overlayBackgroundColor;\n\t} else if ( !! customBackgroundColor ) {\n\t\tcolors.customBackgroundColor = customBackgroundColor;\n\t} else if ( !! backgroundColor ) {\n\t\tcolors.backgroundColor = backgroundColor;\n\t} else if ( !! style?.color?.background ) {\n\t\tcolors.customTextColor = style.color.background;\n\t}\n\n\treturn colors;\n}\n\n/**\n * @typedef {'post-type'|'custom'|'taxonomy'|'post-type-archive'} WPNavigationLinkKind\n */\n\n/**\n * Navigation Link Block Attributes\n *\n * @typedef {Object} WPNavigationLinkBlockAttributes\n *\n * @property {string} [label] Link text.\n * @property {WPNavigationLinkKind} [kind] Kind is used to differentiate between term and post ids to check post draft status.\n * @property {string} [type] The type such as post, page, tag, category and other custom types.\n * @property {string} [rel] The relationship of the linked URL.\n * @property {number} [id] A post or term id.\n * @property {boolean} [opensInNewTab] Sets link target to _blank when true.\n * @property {string} [url] Link href.\n * @property {string} [title] Link title attribute.\n */\n\n/**\n * Link Control onChange handler that updates block attributes when a setting is changed.\n *\n * @param {Object} updatedValue New block attributes to update.\n * @param {Function} setAttributes Block attribute update function.\n * @param {WPNavigationLinkBlockAttributes} blockAttributes Current block attributes.\n *\n */\nexport const updateNavigationLinkBlockAttributes = (\n\tupdatedValue = {},\n\tsetAttributes,\n\tblockAttributes = {}\n) => {\n\tconst {\n\t\tlabel: originalLabel = '',\n\t\tkind: originalKind = '',\n\t\ttype: originalType = '',\n\t} = blockAttributes;\n\tconst {\n\t\ttitle = '',\n\t\turl = '',\n\t\topensInNewTab,\n\t\tid,\n\t\tkind: newKind = originalKind,\n\t\ttype: newType = originalType,\n\t} = updatedValue;\n\n\tconst normalizedTitle = title.replace( /http(s?):\\/\\//gi, '' );\n\tconst normalizedURL = url.replace( /http(s?):\\/\\//gi, '' );\n\tconst escapeTitle =\n\t\ttitle !== '' &&\n\t\tnormalizedTitle !== normalizedURL &&\n\t\toriginalLabel !== title;\n\tconst label = escapeTitle\n\t\t? escape( title )\n\t\t: originalLabel || escape( normalizedURL );\n\n\t// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use \"tag\" in favor of \"post_tag\"\n\tconst type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );\n\n\tconst isBuiltInType =\n\t\t[ 'post', 'page', 'tag', 'category' ].indexOf( type ) > -1;\n\n\tconst isCustomLink =\n\t\t( ! newKind && ! isBuiltInType ) || newKind === 'custom';\n\tconst kind = isCustomLink ? 'custom' : newKind;\n\n\tsetAttributes( {\n\t\t// Passed `url` may already be encoded. To prevent double encoding, decodeURI is executed to revert to the original string.\n\t\t...( url && { url: encodeURI( safeDecodeURI( url ) ) } ),\n\t\t...( label && { label } ),\n\t\t...( undefined !== opensInNewTab && { opensInNewTab } ),\n\t\t...( id && Number.isInteger( id ) && { id } ),\n\t\t...( kind && { kind } ),\n\t\t...( type && type !== 'URL' && { type } ),\n\t} );\n};\n\nexport default function NavigationSubmenuEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst {\n\t\tlabel,\n\t\ttype,\n\t\topensInNewTab,\n\t\turl,\n\t\tdescription,\n\t\trel,\n\t\ttitle,\n\t\tkind,\n\t} = attributes;\n\tconst link = {\n\t\turl,\n\t\topensInNewTab,\n\t};\n\tconst { showSubmenuIcon, maxNestingLevel, openSubmenusOnClick } = context;\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\tconst {\n\t\t__unstableMarkNextChangeAsNotPersistent,\n\t\treplaceBlock,\n\t} = useDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add text…' );\n\tconst ref = useRef();\n\n\tconst {\n\t\tisAtMaxNesting,\n\t\tisTopLevelItem,\n\t\tisParentOfSelectedBlock,\n\t\tisImmediateParentOfSelectedBlock,\n\t\thasDescendants,\n\t\tselectedBlockHasDescendants,\n\t\tuserCanCreatePages,\n\t\tuserCanCreatePosts,\n\t\tonlyDescendantIsEmptyLink,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetClientIdsOfDescendants,\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetBlock,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet _onlyDescendantIsEmptyLink;\n\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\tconst descendants = getClientIdsOfDescendants( [ clientId ] )\n\t\t\t\t.length;\n\n\t\t\tconst selectedBlockDescendants = getClientIdsOfDescendants( [\n\t\t\t\tselectedBlockId,\n\t\t\t] );\n\n\t\t\t// Check for a single descendant in the submenu. If that block\n\t\t\t// is a link block in a \"placeholder\" state with no label then\n\t\t\t// we can consider as an \"empty\" link.\n\t\t\tif ( selectedBlockDescendants?.length === 1 ) {\n\t\t\t\tconst singleBlock = getBlock( selectedBlockDescendants[ 0 ] );\n\n\t\t\t\t_onlyDescendantIsEmptyLink =\n\t\t\t\t\tsingleBlock?.name === 'core/navigation-link' &&\n\t\t\t\t\t! singleBlock?.attributes?.label;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\tisAtMaxNesting:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, name ).length >=\n\t\t\t\t\tmaxNestingLevel,\n\t\t\t\tisTopLevelItem:\n\t\t\t\t\tgetBlockParentsByBlockName( clientId, name ).length === 0,\n\t\t\t\tisParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\ttrue\n\t\t\t\t),\n\t\t\t\tisImmediateParentOfSelectedBlock: hasSelectedInnerBlock(\n\t\t\t\t\tclientId,\n\t\t\t\t\tfalse\n\t\t\t\t),\n\t\t\t\thasDescendants: !! descendants,\n\t\t\t\tselectedBlockHasDescendants: !! selectedBlockDescendants?.length,\n\t\t\t\tuserCanCreatePages: select( coreStore ).canUser(\n\t\t\t\t\t'create',\n\t\t\t\t\t'pages'\n\t\t\t\t),\n\t\t\t\tuserCanCreatePosts: select( coreStore ).canUser(\n\t\t\t\t\t'create',\n\t\t\t\t\t'posts'\n\t\t\t\t),\n\t\t\t\tonlyDescendantIsEmptyLink: _onlyDescendantIsEmptyLink,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\t// Show the LinkControl on mount if the URL is empty\n\t// ( When adding a new menu item)\n\t// This can't be done in the useState call because it conflicts\n\t// with the autofocus behavior of the BlockListBlock component.\n\tuseEffect( () => {\n\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}, [] );\n\n\t// Store the colors from context as attributes for rendering.\n\tuseEffect( () => {\n\t\t// This side-effect should not create an undo level as those should\n\t\t// only be created via user interactions. Mark this change as\n\t\t// not persistent to avoid undo level creation.\n\t\t// See https://github.com/WordPress/gutenberg/issues/34564.\n\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\tsetAttributes( { isTopLevelItem } );\n\t}, [ isTopLevelItem ] );\n\n\t/**\n\t * The hook shouldn't be necessary but due to a focus loss happening\n\t * when selecting a suggestion in the link popover, we force close on block unselection.\n\t */\n\tuseEffect( () => {\n\t\tif ( ! isSelected ) {\n\t\t\tsetIsLinkOpen( false );\n\t\t}\n\t}, [ isSelected ] );\n\n\t// If the LinkControl popover is open and the URL has changed, close the LinkControl and focus the label text.\n\tuseEffect( () => {\n\t\tif ( isLinkOpen && url ) {\n\t\t\t// Does this look like a URL and have something TLD-ish?\n\t\t\tif (\n\t\t\t\tisURL( prependHTTP( label ) ) &&\n\t\t\t\t/^.+\\.[a-z]+/.test( label )\n\t\t\t) {\n\t\t\t\t// Focus and select the label text.\n\t\t\t\tselectLabelText();\n\t\t\t} else {\n\t\t\t\t// Focus it (but do not select).\n\t\t\t\tplaceCaretAtHorizontalEdge( ref.current, true );\n\t\t\t}\n\t\t}\n\t}, [ url ] );\n\n\t/**\n\t * Focus the Link label text and select it.\n\t */\n\tfunction selectLabelText() {\n\t\tref.current.focus();\n\t\tconst { ownerDocument } = ref.current;\n\t\tconst { defaultView } = ownerDocument;\n\t\tconst selection = defaultView.getSelection();\n\t\tconst range = ownerDocument.createRange();\n\t\t// Get the range of the current ref contents so we can add this range to the selection.\n\t\trange.selectNodeContents( ref.current );\n\t\tselection.removeAllRanges();\n\t\tselection.addRange( range );\n\t}\n\n\tlet userCanCreate = false;\n\tif ( ! type || type === 'page' ) {\n\t\tuserCanCreate = userCanCreatePages;\n\t} else if ( type === 'post' ) {\n\t\tuserCanCreate = userCanCreatePosts;\n\t}\n\n\tasync function handleCreate( pageTitle ) {\n\t\tconst postType = type || 'page';\n\n\t\tconst page = await saveEntityRecord( 'postType', postType, {\n\t\t\ttitle: pageTitle,\n\t\t\tstatus: 'draft',\n\t\t} );\n\n\t\treturn {\n\t\t\tid: page.id,\n\t\t\ttype: postType,\n\t\t\ttitle: page.title.rendered,\n\t\t\turl: page.link,\n\t\t\tkind: 'post-type',\n\t\t};\n\t}\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, ! isTopLevelItem );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: listItemRef,\n\t\tclassName: classnames( 'wp-block-navigation-item', {\n\t\t\t'is-editing': isSelected || isParentOfSelectedBlock,\n\t\t\t'is-dragging-within': isDraggingWithin,\n\t\t\t'has-link': !! url,\n\t\t\t'has-child': hasDescendants,\n\t\t\t'has-text-color': !! textColor || !! customTextColor,\n\t\t\t[ getColorClassName( 'color', textColor ) ]: !! textColor,\n\t\t\t'has-background': !! backgroundColor || customBackgroundColor,\n\t\t\t[ getColorClassName(\n\t\t\t\t'background-color',\n\t\t\t\tbackgroundColor\n\t\t\t) ]: !! backgroundColor,\n\t\t\t'open-on-click': openSubmenusOnClick,\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: ! textColor && customTextColor,\n\t\t\tbackgroundColor: ! backgroundColor && customBackgroundColor,\n\t\t},\n\t\tonKeyDown,\n\t} );\n\n\t// Always use overlay colors for submenus.\n\tconst innerBlocksColors = getColors( context, true );\n\n\tconst allowedBlocks = isAtMaxNesting\n\t\t? without( ALLOWED_BLOCKS, 'core/navigation-submenu' )\n\t\t: ALLOWED_BLOCKS;\n\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\t{\n\t\t\tclassName: classnames( 'wp-block-navigation__submenu-container', {\n\t\t\t\t'is-parent-of-selected-block': isParentOfSelectedBlock,\n\t\t\t\t'has-text-color': !! (\n\t\t\t\t\tinnerBlocksColors.textColor ||\n\t\t\t\t\tinnerBlocksColors.customTextColor\n\t\t\t\t),\n\t\t\t\t[ `has-${ innerBlocksColors.textColor }-color` ]: !! innerBlocksColors.textColor,\n\t\t\t\t'has-background': !! (\n\t\t\t\t\tinnerBlocksColors.backgroundColor ||\n\t\t\t\t\tinnerBlocksColors.customBackgroundColor\n\t\t\t\t),\n\t\t\t\t[ `has-${ innerBlocksColors.backgroundColor }-background-color` ]: !! innerBlocksColors.backgroundColor,\n\t\t\t} ),\n\t\t\tstyle: {\n\t\t\t\tcolor: innerBlocksColors.customTextColor,\n\t\t\t\tbackgroundColor: innerBlocksColors.customBackgroundColor,\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\tallowedBlocks,\n\t\t\t__experimentalDefaultBlock: DEFAULT_BLOCK,\n\t\t\t__experimentalDirectInsert: true,\n\n\t\t\t// Ensure block toolbar is not too far removed from item\n\t\t\t// being edited.\n\t\t\t// see: https://github.com/WordPress/gutenberg/pull/34615.\n\t\t\t__experimentalCaptureToolbars: true,\n\n\t\t\trenderAppender:\n\t\t\t\tisSelected ||\n\t\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t\t! selectedBlockHasDescendants ) ||\n\t\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\t\thasDescendants\n\t\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t\t: false,\n\t\t}\n\t);\n\n\tconst ParentElement = openSubmenusOnClick ? 'button' : 'a';\n\n\tfunction transformToLink() {\n\t\tconst newLinkBlock = createBlock( 'core/navigation-link', attributes );\n\t\treplaceBlock( clientId, newLinkBlock );\n\t}\n\n\tconst canConvertToLink =\n\t\t! selectedBlockHasDescendants || onlyDescendantIsEmptyLink;\n\n\treturn (\n\t\t<Fragment>\n\t\t\t<BlockControls>\n\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t{ ! openSubmenusOnClick && (\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tname=\"link\"\n\t\t\t\t\t\t\ticon={ linkIcon }\n\t\t\t\t\t\t\ttitle={ __( 'Link' ) }\n\t\t\t\t\t\t\tshortcut={ displayShortcut.primary( 'k' ) }\n\t\t\t\t\t\t\tonClick={ () => setIsLinkOpen( true ) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\n\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\tname=\"revert\"\n\t\t\t\t\t\ticon={ removeSubmenu }\n\t\t\t\t\t\ttitle={ __( 'Convert to Link' ) }\n\t\t\t\t\t\tonClick={ transformToLink }\n\t\t\t\t\t\tclassName=\"wp-block-navigation__submenu__revert\"\n\t\t\t\t\t\tisDisabled={ ! canConvertToLink }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<TextareaControl\n\t\t\t\t\t\tvalue={ description || '' }\n\t\t\t\t\t\tonChange={ ( descriptionValue ) => {\n\t\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\t\tdescription: descriptionValue,\n\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Description' ) }\n\t\t\t\t\t\thelp={ __(\n\t\t\t\t\t\t\t'The description will be displayed in the menu if the current theme supports it.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ title || '' }\n\t\t\t\t\t\tonChange={ ( titleValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { title: titleValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Link title' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ rel || '' }\n\t\t\t\t\t\tonChange={ ( relValue ) => {\n\t\t\t\t\t\t\tsetAttributes( { rel: relValue } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tlabel={ __( 'Link rel' ) }\n\t\t\t\t\t\tautoComplete=\"off\"\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ /* eslint-disable jsx-a11y/anchor-is-valid */ }\n\t\t\t\t<ParentElement className=\"wp-block-navigation-item__content\">\n\t\t\t\t\t{ /* eslint-enable */ }\n\t\t\t\t\t{\n\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\tsetAttributes( { label: labelValue } )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\taria-label={ __( 'Navigation link text' ) }\n\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\tallowedFormats={ [\n\t\t\t\t\t\t\t\t'core/bold',\n\t\t\t\t\t\t\t\t'core/italic',\n\t\t\t\t\t\t\t\t'core/image',\n\t\t\t\t\t\t\t\t'core/strikethrough',\n\t\t\t\t\t\t\t] }\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t}\n\t\t\t\t\t{ ! openSubmenusOnClick && isLinkOpen && (\n\t\t\t\t\t\t<Popover\n\t\t\t\t\t\t\tposition=\"bottom center\"\n\t\t\t\t\t\t\tonClose={ () => setIsLinkOpen( false ) }\n\t\t\t\t\t\t\tanchorRef={ listItemRef.current }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<LinkControl\n\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-link__inline-link-input\"\n\t\t\t\t\t\t\t\tvalue={ link }\n\t\t\t\t\t\t\t\tshowInitialSuggestions={ true }\n\t\t\t\t\t\t\t\twithCreateSuggestion={ userCanCreate }\n\t\t\t\t\t\t\t\tcreateSuggestion={ handleCreate }\n\t\t\t\t\t\t\t\tcreateSuggestionButtonText={ ( searchTerm ) => {\n\t\t\t\t\t\t\t\t\tlet format;\n\t\t\t\t\t\t\t\t\tif ( type === 'post' ) {\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t\t\t\t\t\t\tformat = __(\n\t\t\t\t\t\t\t\t\t\t\t'Create draft post: <mark>%s</mark>'\n\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\t\t/* translators: %s: search term. */\n\t\t\t\t\t\t\t\t\t\tformat = __(\n\t\t\t\t\t\t\t\t\t\t\t'Create draft page: <mark>%s</mark>'\n\t\t\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\treturn createInterpolateElement(\n\t\t\t\t\t\t\t\t\t\tsprintf( format, searchTerm ),\n\t\t\t\t\t\t\t\t\t\t{ mark: <mark /> }\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\tnoDirectEntry={ !! type }\n\t\t\t\t\t\t\t\tnoURLSuggestion={ !! type }\n\t\t\t\t\t\t\t\tsuggestionsQuery={ getSuggestionsQuery(\n\t\t\t\t\t\t\t\t\ttype,\n\t\t\t\t\t\t\t\t\tkind\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\tonChange={ ( updatedValue ) =>\n\t\t\t\t\t\t\t\t\tupdateNavigationLinkBlockAttributes(\n\t\t\t\t\t\t\t\t\t\tupdatedValue,\n\t\t\t\t\t\t\t\t\t\tsetAttributes,\n\t\t\t\t\t\t\t\t\t\tattributes\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\tonRemove={ () => {\n\t\t\t\t\t\t\t\t\tsetAttributes( { url: '' } );\n\t\t\t\t\t\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</Popover>\n\t\t\t\t\t) }\n\t\t\t\t</ParentElement>\n\t\t\t\t{ ( showSubmenuIcon || openSubmenusOnClick ) && (\n\t\t\t\t\t<span className=\"wp-block-navigation__submenu-icon\">\n\t\t\t\t\t\t<ItemSubmenuIcon />\n\t\t\t\t\t</span>\n\t\t\t\t) }\n\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t</div>\n\t\t</Fragment>\n\t);\n}\n"]}
|
|
@@ -48,7 +48,7 @@ const metadata = {
|
|
|
48
48
|
type: "boolean"
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
|
-
usesContext: ["textColor", "customTextColor", "backgroundColor", "customBackgroundColor", "overlayTextColor", "customOverlayTextColor", "overlayBackgroundColor", "customOverlayBackgroundColor", "fontSize", "customFontSize", "showSubmenuIcon", "openSubmenusOnClick", "style"],
|
|
51
|
+
usesContext: ["textColor", "customTextColor", "backgroundColor", "customBackgroundColor", "overlayTextColor", "customOverlayTextColor", "overlayBackgroundColor", "customOverlayBackgroundColor", "fontSize", "customFontSize", "showSubmenuIcon", "maxNestingLevel", "openSubmenusOnClick", "style"],
|
|
52
52
|
supports: {
|
|
53
53
|
reusable: false,
|
|
54
54
|
html: false
|
|
@@ -8,8 +8,8 @@ import { Placeholder, TextControl, Button } from '@wordpress/components';
|
|
|
8
8
|
import { useState } from '@wordpress/element';
|
|
9
9
|
import { blockDefault } from '@wordpress/icons';
|
|
10
10
|
import { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';
|
|
11
|
-
const ALLOWED_BLOCKS = ['core/
|
|
12
|
-
const TEMPLATE = [['core/
|
|
11
|
+
const ALLOWED_BLOCKS = ['core/avatar', 'core/comment-author-name', 'core/comment-content', 'core/comment-date', 'core/comment-edit-link', 'core/comment-reply-link'];
|
|
12
|
+
const TEMPLATE = [['core/avatar'], ['core/comment-author-name'], ['core/comment-date'], ['core/comment-content'], ['core/comment-reply-link'], ['core/comment-edit-link']];
|
|
13
13
|
export default function Edit(_ref) {
|
|
14
14
|
let {
|
|
15
15
|
attributes: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-comment/edit.js"],"names":["__","_x","Placeholder","TextControl","Button","useState","blockDefault","useBlockProps","useInnerBlocksProps","ALLOWED_BLOCKS","TEMPLATE","Edit","attributes","commentId","setAttributes","commentIdInput","setCommentIdInput","blockProps","innerBlocksProps","template","allowedBlocks","val","parseInt"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,WAAT,EAAsBC,WAAtB,EAAmCC,MAAnC,QAAiD,uBAAjD;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASC,aAAT,EAAwBC,mBAAxB,QAAmD,yBAAnD;AAEA,MAAMC,cAAc,GAAG,CACtB,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-comment/edit.js"],"names":["__","_x","Placeholder","TextControl","Button","useState","blockDefault","useBlockProps","useInnerBlocksProps","ALLOWED_BLOCKS","TEMPLATE","Edit","attributes","commentId","setAttributes","commentIdInput","setCommentIdInput","blockProps","innerBlocksProps","template","allowedBlocks","val","parseInt"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,EAAb,QAAuB,iBAAvB;AACA,SAASC,WAAT,EAAsBC,WAAtB,EAAmCC,MAAnC,QAAiD,uBAAjD;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASC,aAAT,EAAwBC,mBAAxB,QAAmD,yBAAnD;AAEA,MAAMC,cAAc,GAAG,CACtB,aADsB,EAEtB,0BAFsB,EAGtB,sBAHsB,EAItB,mBAJsB,EAKtB,wBALsB,EAMtB,yBANsB,CAAvB;AAQA,MAAMC,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,eAAe,SAASC,IAAT,OAA8D;AAAA,MAA/C;AAAEC,IAAAA,UAAU,EAAE;AAAEC,MAAAA;AAAF,KAAd;AAA6BC,IAAAA;AAA7B,GAA+C;AAC5E,QAAM,CAAEC,cAAF,EAAkBC,iBAAlB,IAAwCX,QAAQ,CAAEQ,SAAF,CAAtD;AACA,QAAMI,UAAU,GAAGV,aAAa,EAAhC;AACA,QAAMW,gBAAgB,GAAGV,mBAAmB,CAAES,UAAF,EAAc;AACzDE,IAAAA,QAAQ,EAAET,QAD+C;AAEzDU,IAAAA,aAAa,EAAEX;AAF0C,GAAd,CAA5C;;AAKA,MAAK,CAAEI,SAAP,EAAmB;AAClB,WACC,qBAAUI,UAAV,EACC,cAAC,WAAD;AACC,MAAA,IAAI,EAAGX,YADR;AAEC,MAAA,KAAK,EAAGL,EAAE,CAAE,cAAF,EAAkB,aAAlB,CAFX;AAGC,MAAA,YAAY,EAAGD,EAAE,CAChB,0CADgB;AAHlB,OAOC,cAAC,WAAD;AACC,MAAA,KAAK,EAAGa,SADT;AAEC,MAAA,QAAQ,EAAKQ,GAAF,IACVL,iBAAiB,CAAEM,QAAQ,CAAED,GAAF,CAAV;AAHnB,MAPD,EAcC,cAAC,MAAD;AACC,MAAA,OAAO,EAAC,SADT;AAEC,MAAA,OAAO,EAAG,MAAM;AACfP,QAAAA,aAAa,CAAE;AAAED,UAAAA,SAAS,EAAEE;AAAb,SAAF,CAAb;AACA;AAJF,OAMGf,EAAE,CAAE,MAAF,CANL,CAdD,CADD,CADD;AA2BA;;AAED,SAAO,qBAAUkB,gBAAV,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _x } from '@wordpress/i18n';\nimport { Placeholder, TextControl, Button } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\nimport { blockDefault } from '@wordpress/icons';\nimport { useBlockProps, useInnerBlocksProps } from '@wordpress/block-editor';\n\nconst ALLOWED_BLOCKS = [\n\t'core/avatar',\n\t'core/comment-author-name',\n\t'core/comment-content',\n\t'core/comment-date',\n\t'core/comment-edit-link',\n\t'core/comment-reply-link',\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\nexport default function Edit( { attributes: { commentId }, setAttributes } ) {\n\tconst [ commentIdInput, setCommentIdInput ] = useState( commentId );\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\ttemplate: TEMPLATE,\n\t\tallowedBlocks: ALLOWED_BLOCKS,\n\t} );\n\n\tif ( ! commentId ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<Placeholder\n\t\t\t\t\ticon={ blockDefault }\n\t\t\t\t\tlabel={ _x( 'Post Comment', 'block title' ) }\n\t\t\t\t\tinstructions={ __(\n\t\t\t\t\t\t'To show a comment, input the comment ID.'\n\t\t\t\t\t) }\n\t\t\t\t>\n\t\t\t\t\t<TextControl\n\t\t\t\t\t\tvalue={ commentId }\n\t\t\t\t\t\tonChange={ ( val ) =>\n\t\t\t\t\t\t\tsetCommentIdInput( parseInt( val ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\n\t\t\t\t\t<Button\n\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tsetAttributes( { commentId: commentIdInput } );\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Save' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t</Placeholder>\n\t\t\t</div>\n\t\t);\n\t}\n\n\treturn <div { ...innerBlocksProps } />;\n}\n"]}
|
|
@@ -30,6 +30,7 @@ export default function PostCommentsFormEdit(_ref) {
|
|
|
30
30
|
[`has-text-align-${textAlign}`]: textAlign
|
|
31
31
|
})
|
|
32
32
|
});
|
|
33
|
+
const isInSiteEditor = postType === undefined || postId === undefined;
|
|
33
34
|
return createElement(Fragment, null, createElement(BlockControls, {
|
|
34
35
|
group: "block"
|
|
35
36
|
}, createElement(AlignmentControl, {
|
|
@@ -39,8 +40,8 @@ export default function PostCommentsFormEdit(_ref) {
|
|
|
39
40
|
textAlign: nextAlign
|
|
40
41
|
});
|
|
41
42
|
}
|
|
42
|
-
})), createElement("div", blockProps, !commentStatus && createElement(Warning, null, __('Post Comments Form block: comments are not enabled for this post type.')), 'open' !== commentStatus && createElement(Warning, null, sprintf(
|
|
43
|
+
})), createElement("div", blockProps, !commentStatus && !isInSiteEditor && createElement(Warning, null, __('Post Comments Form block: comments are not enabled for this post type.')), 'open' !== commentStatus && !isInSiteEditor && createElement(Warning, null, sprintf(
|
|
43
44
|
/* translators: 1: Post type (i.e. "post", "page") */
|
|
44
|
-
__('Post Comments Form block: comments to this %s are not allowed.'), postType)), 'open' === commentStatus && __('Post Comments Form')));
|
|
45
|
+
__('Post Comments Form block: comments to this %s are not allowed.'), postType)), ('open' === commentStatus || isInSiteEditor) && __('Post Comments Form')));
|
|
45
46
|
}
|
|
46
47
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-comments-form/edit.js"],"names":["classnames","AlignmentControl","BlockControls","Warning","useBlockProps","useEntityProp","__","sprintf","PostCommentsFormEdit","attributes","context","setAttributes","textAlign","postId","postType","commentStatus","blockProps","className","nextAlign"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,gBADD,EAECC,aAFD,EAGCC,OAHD,EAICC,aAJD,QAKO,yBALP;AAMA,SAASC,aAAT,QAA8B,sBAA9B;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AAEA,eAAe,SAASC,oBAAT,OAIX;AAAA,MAJ0C;AAC7CC,IAAAA,UAD6C;AAE7CC,IAAAA,OAF6C;AAG7CC,IAAAA;AAH6C,GAI1C;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAgBH,UAAtB;AACA,QAAM;AAAEI,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAuBJ,OAA7B;AACA,QAAM,CAAEK,aAAF,IAAoBV,aAAa,CACtC,UADsC,EAEtCS,QAFsC,EAGtC,gBAHsC,EAItCD,MAJsC,CAAvC;AAMA,QAAMG,UAAU,GAAGZ,aAAa,CAAE;AACjCa,IAAAA,SAAS,EAAEjB,UAAU,CAAE;AACtB,OAAG,kBAAkBY,SAAW,EAAhC,GAAqCA;AADf,KAAF;AADY,GAAF,CAAhC;AAMA,SACC,8BACC,cAAC,aAAD;AAAe,IAAA,KAAK,EAAC;AAArB,KACC,cAAC,gBAAD;AACC,IAAA,KAAK,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-comments-form/edit.js"],"names":["classnames","AlignmentControl","BlockControls","Warning","useBlockProps","useEntityProp","__","sprintf","PostCommentsFormEdit","attributes","context","setAttributes","textAlign","postId","postType","commentStatus","blockProps","className","isInSiteEditor","undefined","nextAlign"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SACCC,gBADD,EAECC,aAFD,EAGCC,OAHD,EAICC,aAJD,QAKO,yBALP;AAMA,SAASC,aAAT,QAA8B,sBAA9B;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AAEA,eAAe,SAASC,oBAAT,OAIX;AAAA,MAJ0C;AAC7CC,IAAAA,UAD6C;AAE7CC,IAAAA,OAF6C;AAG7CC,IAAAA;AAH6C,GAI1C;AACH,QAAM;AAAEC,IAAAA;AAAF,MAAgBH,UAAtB;AACA,QAAM;AAAEI,IAAAA,MAAF;AAAUC,IAAAA;AAAV,MAAuBJ,OAA7B;AACA,QAAM,CAAEK,aAAF,IAAoBV,aAAa,CACtC,UADsC,EAEtCS,QAFsC,EAGtC,gBAHsC,EAItCD,MAJsC,CAAvC;AAMA,QAAMG,UAAU,GAAGZ,aAAa,CAAE;AACjCa,IAAAA,SAAS,EAAEjB,UAAU,CAAE;AACtB,OAAG,kBAAkBY,SAAW,EAAhC,GAAqCA;AADf,KAAF;AADY,GAAF,CAAhC;AAMA,QAAMM,cAAc,GAAGJ,QAAQ,KAAKK,SAAb,IAA0BN,MAAM,KAAKM,SAA5D;AAEA,SACC,8BACC,cAAC,aAAD;AAAe,IAAA,KAAK,EAAC;AAArB,KACC,cAAC,gBAAD;AACC,IAAA,KAAK,EAAGP,SADT;AAEC,IAAA,QAAQ,EAAKQ,SAAF,IAAiB;AAC3BT,MAAAA,aAAa,CAAE;AAAEC,QAAAA,SAAS,EAAEQ;AAAb,OAAF,CAAb;AACA;AAJF,IADD,CADD,EASC,qBAAUJ,UAAV,EACG,CAAED,aAAF,IAAmB,CAAEG,cAArB,IACD,cAAC,OAAD,QACGZ,EAAE,CACH,wEADG,CADL,CAFF,EASG,WAAWS,aAAX,IAA4B,CAAEG,cAA9B,IACD,cAAC,OAAD,QACGX,OAAO;AACR;AACAD,EAAAA,EAAE,CACD,gEADC,CAFM,EAKRQ,QALQ,CADV,CAVF,EAqBG,CAAE,WAAWC,aAAX,IAA4BG,cAA9B,KACDZ,EAAE,CAAE,oBAAF,CAtBJ,CATD,CADD;AAoCA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tWarning,\n\tuseBlockProps,\n} from '@wordpress/block-editor';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { __, sprintf } from '@wordpress/i18n';\n\nexport default function PostCommentsFormEdit( {\n\tattributes,\n\tcontext,\n\tsetAttributes,\n} ) {\n\tconst { textAlign } = attributes;\n\tconst { postId, postType } = context;\n\tconst [ commentStatus ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'comment_status',\n\t\tpostId\n\t);\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\n\tconst isInSiteEditor = postType === undefined || postId === undefined;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t{ ! commentStatus && ! isInSiteEditor && (\n\t\t\t\t\t<Warning>\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Post Comments Form block: comments are not enabled for this post type.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Warning>\n\t\t\t\t) }\n\n\t\t\t\t{ 'open' !== commentStatus && ! isInSiteEditor && (\n\t\t\t\t\t<Warning>\n\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t/* translators: 1: Post type (i.e. \"post\", \"page\") */\n\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t'Post Comments Form block: comments to this %s are not allowed.'\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\tpostType\n\t\t\t\t\t\t) }\n\t\t\t\t\t</Warning>\n\t\t\t\t) }\n\n\t\t\t\t{ ( 'open' === commentStatus || isInSiteEditor ) &&\n\t\t\t\t\t__( 'Post Comments Form' ) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -8,14 +8,15 @@ import classnames from 'classnames';
|
|
|
8
8
|
* WordPress dependencies
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { useEntityProp } from '@wordpress/core-data';
|
|
11
|
+
import { useEntityProp, store as coreStore } from '@wordpress/core-data';
|
|
12
12
|
import { useRef } from '@wordpress/element';
|
|
13
|
-
import {
|
|
14
|
-
import { AlignmentControl, BlockControls, InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
|
15
|
-
import { Dropdown, ToolbarGroup, ToolbarButton, ToggleControl, DateTimePicker, PanelBody
|
|
13
|
+
import { dateI18n, __experimentalGetSettings as getDateSettings } from '@wordpress/date';
|
|
14
|
+
import { AlignmentControl, BlockControls, InspectorControls, useBlockProps, __experimentalDateFormatPicker as DateFormatPicker } from '@wordpress/block-editor';
|
|
15
|
+
import { Dropdown, ToolbarGroup, ToolbarButton, ToggleControl, DateTimePicker, PanelBody } from '@wordpress/components';
|
|
16
16
|
import { __, sprintf } from '@wordpress/i18n';
|
|
17
17
|
import { edit } from '@wordpress/icons';
|
|
18
18
|
import { DOWN } from '@wordpress/keycodes';
|
|
19
|
+
import { useSelect } from '@wordpress/data';
|
|
19
20
|
export default function PostDateEdit(_ref) {
|
|
20
21
|
let {
|
|
21
22
|
attributes: {
|
|
@@ -25,38 +26,27 @@ export default function PostDateEdit(_ref) {
|
|
|
25
26
|
},
|
|
26
27
|
context: {
|
|
27
28
|
postId,
|
|
28
|
-
postType,
|
|
29
|
+
postType: postTypeSlug,
|
|
29
30
|
queryId
|
|
30
31
|
},
|
|
31
32
|
setAttributes
|
|
32
33
|
} = _ref;
|
|
33
|
-
const isDescendentOfQueryLoop = Number.isFinite(queryId);
|
|
34
|
-
const [siteFormat] = useEntityProp('root', 'site', 'date_format');
|
|
35
|
-
const [date, setDate] = useEntityProp('postType', postType, 'date', postId);
|
|
36
|
-
|
|
37
|
-
const settings = __experimentalGetSettings(); // To know if the current time format is a 12 hour time, look for "a".
|
|
38
|
-
// Also make sure this "a" is not escaped by a "/".
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const is12Hour = /a(?!\\)/i.test(settings.formats.time.toLowerCase() // Test only for the lower case "a".
|
|
42
|
-
.replace(/\\\\/g, '') // Replace "//" with empty strings.
|
|
43
|
-
.split('').reverse().join('') // Reverse the string and test for "a" not followed by a slash.
|
|
44
|
-
);
|
|
45
|
-
const formatOptions = Object.values(settings.formats).map(formatOption => ({
|
|
46
|
-
key: formatOption,
|
|
47
|
-
name: dateI18n(formatOption, date)
|
|
48
|
-
}));
|
|
49
|
-
const resolvedFormat = format || siteFormat || settings.formats.date;
|
|
50
34
|
const blockProps = useBlockProps({
|
|
51
35
|
className: classnames({
|
|
52
36
|
[`has-text-align-${textAlign}`]: textAlign
|
|
53
37
|
})
|
|
54
38
|
});
|
|
55
39
|
const timeRef = useRef();
|
|
40
|
+
const isDescendentOfQueryLoop = Number.isFinite(queryId);
|
|
41
|
+
const dateSettings = getDateSettings();
|
|
42
|
+
const [siteFormat = dateSettings.formats.date] = useEntityProp('root', 'site', 'date_format');
|
|
43
|
+
const [siteTimeFormat = dateSettings.formats.time] = useEntityProp('root', 'site', 'time_format');
|
|
44
|
+
const [date, setDate] = useEntityProp('postType', postTypeSlug, 'date', postId);
|
|
45
|
+
const postType = useSelect(select => postTypeSlug ? select(coreStore).getPostType(postTypeSlug) : null, [postTypeSlug]);
|
|
56
46
|
let postDate = date ? createElement("time", {
|
|
57
47
|
dateTime: dateI18n('c', date),
|
|
58
48
|
ref: timeRef
|
|
59
|
-
}, dateI18n(
|
|
49
|
+
}, dateI18n(format || siteFormat, date)) : __('Post Date');
|
|
60
50
|
|
|
61
51
|
if (isLink && date) {
|
|
62
52
|
postDate = createElement("a", {
|
|
@@ -81,7 +71,7 @@ export default function PostDateEdit(_ref) {
|
|
|
81
71
|
renderContent: () => createElement(DateTimePicker, {
|
|
82
72
|
currentDate: date,
|
|
83
73
|
onChange: setDate,
|
|
84
|
-
is12Hour:
|
|
74
|
+
is12Hour: is12HourFormat(siteTimeFormat)
|
|
85
75
|
}),
|
|
86
76
|
renderToggle: _ref2 => {
|
|
87
77
|
let {
|
|
@@ -105,29 +95,28 @@ export default function PostDateEdit(_ref) {
|
|
|
105
95
|
});
|
|
106
96
|
}
|
|
107
97
|
}))), createElement(InspectorControls, null, createElement(PanelBody, {
|
|
108
|
-
title: __('
|
|
109
|
-
}, createElement(
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
format: selectedItem.key
|
|
119
|
-
});
|
|
120
|
-
},
|
|
121
|
-
value: formatOptions.find(option => option.key === resolvedFormat)
|
|
122
|
-
})), createElement(PanelBody, {
|
|
123
|
-
title: __('Link settings')
|
|
124
|
-
}, createElement(ToggleControl, {
|
|
125
|
-
label: sprintf( // translators: %s: Name of the post type e.g: "post".
|
|
126
|
-
__('Link to %s'), postType),
|
|
98
|
+
title: __('Settings')
|
|
99
|
+
}, createElement(DateFormatPicker, {
|
|
100
|
+
format: format,
|
|
101
|
+
defaultFormat: siteFormat,
|
|
102
|
+
onChange: nextFormat => setAttributes({
|
|
103
|
+
format: nextFormat
|
|
104
|
+
})
|
|
105
|
+
}), createElement(ToggleControl, {
|
|
106
|
+
label: postType !== null && postType !== void 0 && postType.labels.singular_name ? sprintf( // translators: %s: Name of the post type e.g: "post".
|
|
107
|
+
__('Link to %s'), postType.labels.singular_name.toLowerCase()) : __('Link to post'),
|
|
127
108
|
onChange: () => setAttributes({
|
|
128
109
|
isLink: !isLink
|
|
129
110
|
}),
|
|
130
111
|
checked: isLink
|
|
131
112
|
}))), createElement("div", blockProps, postDate));
|
|
132
113
|
}
|
|
114
|
+
export function is12HourFormat(format) {
|
|
115
|
+
// To know if the time format is a 12 hour time, look for any of the 12 hour
|
|
116
|
+
// format characters: 'a', 'A', 'g', and 'h'. The character must be
|
|
117
|
+
// unescaped, i.e. not preceded by a '\'. Coincidentally, 'aAgh' is how I
|
|
118
|
+
// feel when working with regular expressions.
|
|
119
|
+
// https://www.php.net/manual/en/datetime.format.php
|
|
120
|
+
return /(?:^|[^\\])[aAgh]/.test(format);
|
|
121
|
+
}
|
|
133
122
|
//# sourceMappingURL=edit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-date/edit.js"],"names":["classnames","useEntityProp","useRef","__experimentalGetSettings","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-date/edit.js"],"names":["classnames","useEntityProp","store","coreStore","useRef","dateI18n","__experimentalGetSettings","getDateSettings","AlignmentControl","BlockControls","InspectorControls","useBlockProps","__experimentalDateFormatPicker","DateFormatPicker","Dropdown","ToolbarGroup","ToolbarButton","ToggleControl","DateTimePicker","PanelBody","__","sprintf","edit","DOWN","useSelect","PostDateEdit","attributes","textAlign","format","isLink","context","postId","postType","postTypeSlug","queryId","setAttributes","blockProps","className","timeRef","isDescendentOfQueryLoop","Number","isFinite","dateSettings","siteFormat","formats","date","siteTimeFormat","time","setDate","select","getPostType","postDate","event","preventDefault","nextAlign","anchorRef","current","is12HourFormat","isOpen","onToggle","openOnArrowDown","keyCode","nextFormat","labels","singular_name","toLowerCase","test"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,aAAT,EAAwBC,KAAK,IAAIC,SAAjC,QAAkD,sBAAlD;AACA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SACCC,QADD,EAECC,yBAAyB,IAAIC,eAF9B,QAGO,iBAHP;AAIA,SACCC,gBADD,EAECC,aAFD,EAGCC,iBAHD,EAICC,aAJD,EAKCC,8BAA8B,IAAIC,gBALnC,QAMO,yBANP;AAOA,SACCC,QADD,EAECC,YAFD,EAGCC,aAHD,EAICC,aAJD,EAKCC,cALD,EAMCC,SAND,QAOO,uBAPP;AAQA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,IAAT,QAAqB,kBAArB;AACA,SAASC,IAAT,QAAqB,qBAArB;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA,eAAe,SAASC,YAAT,OAIX;AAAA,MAJkC;AACrCC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,SAAF;AAAaC,MAAAA,MAAb;AAAqBC,MAAAA;AAArB,KADyB;AAErCC,IAAAA,OAAO,EAAE;AAAEC,MA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C,cAAC,SAAD;AAAW,IAAA,KAAK,EAAGxC,EAAE,CAAE,UAAF;AAArB,KACC,cAAC,gBAAD;AACC,IAAA,MAAM,EAAGQ,MADV;AAEC,IAAA,aAAa,EAAGe,UAFjB;AAGC,IAAA,QAAQ,EAAKmB,UAAF,IACV3B,aAAa,CAAE;AAAEP,MAAAA,MAAM,EAAEkC;AAAV,KAAF;AAJf,IADD,EAQC,cAAC,aAAD;AACC,IAAA,KAAK,EACJ9B,QAAQ,SAAR,IAAAA,QAAQ,WAAR,IAAAA,QAAQ,CAAE+B,MAAV,CAAiBC,aAAjB,GACG3C,OAAO,EACP;AACAD,IAAAA,EAAE,CAAE,YAAF,CAFK,EAGPY,QAAQ,CAAC+B,MAAT,CAAgBC,aAAhB,CAA8BC,WAA9B,EAHO,CADV,GAMG7C,EAAE,CAAE,cAAF,CARP;AAUC,IAAA,QAAQ,EAAG,MAAMe,aAAa,CAAE;AAAEN,MAAAA,MAAM,EAAE,CAAEA;AAAZ,KAAF,CAV/B;AAWC,IAAA,OAAO,EAAGA;AAXX,IARD,CADD,CA3CD,EAoEC,qBAAUO,UAAV,EAAyBe,QAAzB,CApED,CADD;AAwEA;AAED,OAAO,SAASM,cAAT,CAAyB7B,MAAzB,EAAkC;AACxC;AACA;AACA;AACA;AACA;AACA,SAAO,oBAAoBsC,IAApB,CAA0BtC,MAA1B,CAAP;AACA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useRef } from '@wordpress/element';\nimport {\n\tdateI18n,\n\t__experimentalGetSettings as getDateSettings,\n} from '@wordpress/date';\nimport {\n\tAlignmentControl,\n\tBlockControls,\n\tInspectorControls,\n\tuseBlockProps,\n\t__experimentalDateFormatPicker as DateFormatPicker,\n} from '@wordpress/block-editor';\nimport {\n\tDropdown,\n\tToolbarGroup,\n\tToolbarButton,\n\tToggleControl,\n\tDateTimePicker,\n\tPanelBody,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { edit } from '@wordpress/icons';\nimport { DOWN } from '@wordpress/keycodes';\nimport { useSelect } from '@wordpress/data';\n\nexport default function PostDateEdit( {\n\tattributes: { textAlign, format, isLink },\n\tcontext: { postId, postType: postTypeSlug, queryId },\n\tsetAttributes,\n} ) {\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classnames( {\n\t\t\t[ `has-text-align-${ textAlign }` ]: textAlign,\n\t\t} ),\n\t} );\n\tconst timeRef = useRef();\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst dateSettings = getDateSettings();\n\tconst [ siteFormat = dateSettings.formats.date ] = useEntityProp(\n\t\t'root',\n\t\t'site',\n\t\t'date_format'\n\t);\n\tconst [ siteTimeFormat = dateSettings.formats.time ] = useEntityProp(\n\t\t'root',\n\t\t'site',\n\t\t'time_format'\n\t);\n\tconst [ date, setDate ] = useEntityProp(\n\t\t'postType',\n\t\tpostTypeSlug,\n\t\t'date',\n\t\tpostId\n\t);\n\tconst postType = useSelect(\n\t\t( select ) =>\n\t\t\tpostTypeSlug\n\t\t\t\t? select( coreStore ).getPostType( postTypeSlug )\n\t\t\t\t: null,\n\t\t[ postTypeSlug ]\n\t);\n\n\tlet postDate = date ? (\n\t\t<time dateTime={ dateI18n( 'c', date ) } ref={ timeRef }>\n\t\t\t{ dateI18n( format || siteFormat, date ) }\n\t\t</time>\n\t) : (\n\t\t__( 'Post Date' )\n\t);\n\n\tif ( isLink && date ) {\n\t\tpostDate = (\n\t\t\t<a\n\t\t\t\thref=\"#post-date-pseudo-link\"\n\t\t\t\tonClick={ ( event ) => event.preventDefault() }\n\t\t\t>\n\t\t\t\t{ postDate }\n\t\t\t</a>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<AlignmentControl\n\t\t\t\t\tvalue={ textAlign }\n\t\t\t\t\tonChange={ ( nextAlign ) => {\n\t\t\t\t\t\tsetAttributes( { textAlign: nextAlign } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t\t{ date && ! isDescendentOfQueryLoop && (\n\t\t\t\t\t<ToolbarGroup>\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tpopoverProps={ { anchorRef: timeRef.current } }\n\t\t\t\t\t\t\trenderContent={ () => (\n\t\t\t\t\t\t\t\t<DateTimePicker\n\t\t\t\t\t\t\t\t\tcurrentDate={ date }\n\t\t\t\t\t\t\t\t\tonChange={ setDate }\n\t\t\t\t\t\t\t\t\tis12Hour={ is12HourFormat(\n\t\t\t\t\t\t\t\t\t\tsiteTimeFormat\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => {\n\t\t\t\t\t\t\t\tconst openOnArrowDown = ( event ) => {\n\t\t\t\t\t\t\t\t\tif ( ! isOpen && event.keyCode === DOWN ) {\n\t\t\t\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\t\t\t\tonToggle();\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\t\t\t\ticon={ edit }\n\t\t\t\t\t\t\t\t\t\ttitle={ __( 'Change Date' ) }\n\t\t\t\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\t\t\t\tonKeyDown={ openOnArrowDown }\n\t\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t) }\n\t\t\t</BlockControls>\n\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<DateFormatPicker\n\t\t\t\t\t\tformat={ format }\n\t\t\t\t\t\tdefaultFormat={ siteFormat }\n\t\t\t\t\t\tonChange={ ( nextFormat ) =>\n\t\t\t\t\t\t\tsetAttributes( { format: nextFormat } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={\n\t\t\t\t\t\t\tpostType?.labels.singular_name\n\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"post\".\n\t\t\t\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\t\t\t\tpostType.labels.singular_name.toLowerCase()\n\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t: __( 'Link to post' )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tonChange={ () => setAttributes( { isLink: ! isLink } ) }\n\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\n\t\t\t<div { ...blockProps }>{ postDate }</div>\n\t\t</>\n\t);\n}\n\nexport function is12HourFormat( format ) {\n\t// To know if the time format is a 12 hour time, look for any of the 12 hour\n\t// format characters: 'a', 'A', 'g', and 'h'. The character must be\n\t// unescaped, i.e. not preceded by a '\\'. Coincidentally, 'aAgh' is how I\n\t// feel when working with regular expressions.\n\t// https://www.php.net/manual/en/datetime.format.php\n\treturn /(?:^|[^\\\\])[aAgh]/.test( format );\n}\n"]}
|
|
@@ -158,7 +158,8 @@ function PostFeaturedImageDisplay(_ref) {
|
|
|
158
158
|
// We have a Featured image so show a Placeholder if is loading.
|
|
159
159
|
image = !media ? placeholderChip : createElement("img", {
|
|
160
160
|
src: mediaUrl,
|
|
161
|
-
alt: media.alt_text
|
|
161
|
+
alt: media.alt_text ? sprintf( // translators: %s: The image's alt text.
|
|
162
|
+
__('Featured image: %s'), media.alt_text) : __('Featured image'),
|
|
162
163
|
style: {
|
|
163
164
|
height,
|
|
164
165
|
objectFit: height && scale
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/post-featured-image/edit.js"],"names":["useEntityProp","store","coreStore","useSelect","useDispatch","MenuItem","ToggleControl","PanelBody","Placeholder","Button","InspectorControls","BlockControls","MediaPlaceholder","MediaReplaceFlow","useBlockProps","blockEditorStore","__","sprintf","upload","SVG","Path","noticesStore","DimensionControls","placeholderIllustration","ALLOWED_MEDIA_TYPES","placeholderChip","getMediaSourceUrlBySizeSlug","media","slug","media_details","sizes","source_url","PostFeaturedImageDisplay","clientId","attributes","setAttributes","context","postId","postType","queryId","isDescendentOfQueryLoop","Number","isFinite","isLink","height","width","scale","sizeSlug","featuredImage","setFeaturedImage","select","getMedia","mediaUrl","imageSizes","getSettings","imageSizeOptions","filter","map","name","value","label","blockProps","style","placeholder","content","onSelectImage","id","createErrorNotice","onUploadError","message","type","controls","image","open","alt_text","objectFit","PostFeaturedImageEdit","props"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,aAAT,EAAwBC,KAAK,IAAIC,SAAjC,QAAkD,sBAAlD;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SACCC,QADD,EAECC,aAFD,EAGCC,SAHD,EAICC,WAJD,EAKCC,MALD,QAMO,uBANP;AAOA,SACCC,iBADD,EAECC,aAFD,EAGCC,gBAHD,EAICC,gBAJD,EAKCC,aALD,EAMCb,KAAK,IAAIc,gBANV,QAOO,yBAPP;AAQA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,MAAT,QAAuB,kBAAvB;AACA,SAASC,GAAT,EAAcC,IAAd,QAA0B,uBAA1B;AACA,SAASnB,KAAK,IAAIoB,YAAlB,QAAsC,oBAAtC;AAEA;AACA;AACA;;AACA,OAAOC,iBAAP,MAA8B,sBAA9B;AAEA,MAAMC,uBAAuB,GAC5B,cAAC,GAAD;AACC,EAAA,SAAS,EAAC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E+D,KAAK,CAACzC,OAAR,2CAAE,eAAeC,MAAjB,CAAL,EAA+B;AAC9B,WAAO,qBAAUwB,UAAV,EAAyBpC,eAAzB,CAAP;AACA;;AACD,SAAO,cAAC,wBAAD,EAA+BoD,KAA/B,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tMenuItem,\n\tToggleControl,\n\tPanelBody,\n\tPlaceholder,\n\tButton,\n} from '@wordpress/components';\nimport {\n\tInspectorControls,\n\tBlockControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { upload } from '@wordpress/icons';\nimport { SVG, Path } from '@wordpress/primitives';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport DimensionControls from './dimension-controls';\n\nconst placeholderIllustration = (\n\t<SVG\n\t\tclassName=\"components-placeholder__illustration\"\n\t\tfill=\"none\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\tviewBox=\"0 0 60 60\"\n\t\tpreserveAspectRatio=\"none\"\n\t>\n\t\t<Path vectorEffect=\"non-scaling-stroke\" d=\"M60 60 0 0\" />\n\t</SVG>\n);\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\nconst placeholderChip = (\n\t<div className=\"wp-block-post-featured-image__placeholder\">\n\t\t{ placeholderIllustration }\n\t</div>\n);\n\nfunction getMediaSourceUrlBySizeSlug( media, slug ) {\n\treturn (\n\t\tmedia?.media_details?.sizes?.[ slug ]?.source_url || media?.source_url\n\t);\n}\n\nfunction PostFeaturedImageDisplay( {\n\tclientId,\n\tattributes,\n\tsetAttributes,\n\tcontext: { postId, postType, queryId },\n} ) {\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst { isLink, height, width, scale, sizeSlug } = attributes;\n\tconst [ featuredImage, setFeaturedImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\n\tconst media = useSelect(\n\t\t( select ) =>\n\t\t\tfeaturedImage &&\n\t\t\tselect( coreStore ).getMedia( featuredImage, { context: 'view' } ),\n\t\t[ featuredImage ]\n\t);\n\tconst mediaUrl = getMediaSourceUrlBySizeSlug( media, sizeSlug );\n\n\tconst imageSizes = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().imageSizes,\n\t\t[]\n\t);\n\tconst imageSizeOptions = imageSizes\n\t\t.filter( ( { slug } ) => {\n\t\t\treturn media?.media_details?.sizes?.[ slug ]?.source_url;\n\t\t} )\n\t\t.map( ( { name, slug } ) => ( {\n\t\t\tvalue: slug,\n\t\t\tlabel: name,\n\t\t} ) );\n\n\tconst blockProps = useBlockProps( {\n\t\tstyle: { width, height },\n\t} );\n\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder className=\"block-editor-media-placeholder\">\n\t\t\t\t{ placeholderIllustration }\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst onSelectImage = ( value ) => {\n\t\tif ( value?.id ) {\n\t\t\tsetFeaturedImage( value.id );\n\t\t}\n\t};\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message[ 2 ], { type: 'snackbar' } );\n\t};\n\n\tconst controls = (\n\t\t<>\n\t\t\t<DimensionControls\n\t\t\t\tclientId={ clientId }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\timageSizeOptions={ imageSizeOptions }\n\t\t\t/>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"post\".\n\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\tpostType\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ () => setAttributes( { isLink: ! isLink } ) }\n\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\tlet image;\n\tif ( ! featuredImage && isDescendentOfQueryLoop ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ controls }\n\t\t\t\t<div { ...blockProps }>{ placeholderChip }</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tconst label = __( 'Add a featured image' );\n\n\tif ( ! featuredImage ) {\n\t\timage = (\n\t\t\t<MediaPlaceholder\n\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\taccept=\"image/*\"\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tonError={ onUploadError }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t\tmediaLibraryButton={ ( { open } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\ttooltipPosition=\"top center\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t} else {\n\t\t// We have a Featured image so show a Placeholder if is loading.\n\t\timage = ! media ? (\n\t\t\tplaceholderChip\n\t\t) : (\n\t\t\t<img\n\t\t\t\tsrc={ mediaUrl }\n\t\t\t\talt={ media.alt_text || __( 'Featured image' ) }\n\t\t\t\tstyle={ { height, objectFit: height && scale } }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ controls }\n\t\t\t{ !! media && ! isDescendentOfQueryLoop && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\tmediaId={ featuredImage }\n\t\t\t\t\t\tmediaURL={ mediaUrl }\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t>\n\t\t\t\t\t\t<MenuItem onClick={ () => setFeaturedImage( 0 ) }>\n\t\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MediaReplaceFlow>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<figure { ...blockProps }>{ image }</figure>\n\t\t</>\n\t);\n}\n\nexport default function PostFeaturedImageEdit( props ) {\n\tconst blockProps = useBlockProps();\n\tif ( ! props.context?.postId ) {\n\t\treturn <div { ...blockProps }>{ placeholderChip }</div>;\n\t}\n\treturn <PostFeaturedImageDisplay { ...props } />;\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/post-featured-image/edit.js"],"names":["useEntityProp","store","coreStore","useSelect","useDispatch","MenuItem","ToggleControl","PanelBody","Placeholder","Button","InspectorControls","BlockControls","MediaPlaceholder","MediaReplaceFlow","useBlockProps","blockEditorStore","__","sprintf","upload","SVG","Path","noticesStore","DimensionControls","placeholderIllustration","ALLOWED_MEDIA_TYPES","placeholderChip","getMediaSourceUrlBySizeSlug","media","slug","media_details","sizes","source_url","PostFeaturedImageDisplay","clientId","attributes","setAttributes","context","postId","postType","queryId","isDescendentOfQueryLoop","Number","isFinite","isLink","height","width","scale","sizeSlug","featuredImage","setFeaturedImage","select","getMedia","mediaUrl","imageSizes","getSettings","imageSizeOptions","filter","map","name","value","label","blockProps","style","placeholder","content","onSelectImage","id","createErrorNotice","onUploadError","message","type","controls","image","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KAAK,EAAG;AAAE4B,QAAAA,MAAF;AAAU+B,QAAAA,SAAS,EAAE/B,MAAM,IAAIE;AAA/B;AAXT,MAHD;AAiBA;;AAED,SACC,8BACGyB,QADH,EAEG,CAAC,CAAE5C,KAAH,IAAY,CAAEa,uBAAd,IACD,cAAC,aAAD;AAAe,IAAA,KAAK,EAAC;AAArB,KACC,cAAC,gBAAD;AACC,IAAA,OAAO,EAAGQ,aADX;AAEC,IAAA,QAAQ,EAAGI,QAFZ;AAGC,IAAA,YAAY,EAAG5B,mBAHhB;AAIC,IAAA,MAAM,EAAC,SAJR;AAKC,IAAA,QAAQ,EAAGyC,aALZ;AAMC,IAAA,OAAO,EAAGG;AANX,KAQC,cAAC,QAAD;AAAU,IAAA,OAAO,EAAG,MAAMnB,gBAAgB,CAAE,CAAF;AAA1C,KACGjC,EAAE,CAAE,OAAF,CADL,CARD,CADD,CAHF,EAkBC,wBAAa6C,UAAb,EAA4BW,KAA5B,CAlBD,CADD;AAsBA;;AAED,eAAe,SAASI,qBAAT,CAAgCC,KAAhC,EAAwC;AAAA;;AACtD,QAAMhB,UAAU,GAAG/C,aAAa,EAAhC;;AACA,MAAK,oBAAE+D,KAAK,CAACzC,OAAR,2CAAE,eAAeC,MAAjB,CAAL,EAA+B;AAC9B,WAAO,qBAAUwB,UAAV,EAAyBpC,eAAzB,CAAP;AACA;;AACD,SAAO,cAAC,wBAAD,EAA+BoD,KAA/B,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityProp, store as coreStore } from '@wordpress/core-data';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport {\n\tMenuItem,\n\tToggleControl,\n\tPanelBody,\n\tPlaceholder,\n\tButton,\n} from '@wordpress/components';\nimport {\n\tInspectorControls,\n\tBlockControls,\n\tMediaPlaceholder,\n\tMediaReplaceFlow,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { upload } from '@wordpress/icons';\nimport { SVG, Path } from '@wordpress/primitives';\nimport { store as noticesStore } from '@wordpress/notices';\n\n/**\n * Internal dependencies\n */\nimport DimensionControls from './dimension-controls';\n\nconst placeholderIllustration = (\n\t<SVG\n\t\tclassName=\"components-placeholder__illustration\"\n\t\tfill=\"none\"\n\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\tviewBox=\"0 0 60 60\"\n\t\tpreserveAspectRatio=\"none\"\n\t>\n\t\t<Path vectorEffect=\"non-scaling-stroke\" d=\"M60 60 0 0\" />\n\t</SVG>\n);\n\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\nconst placeholderChip = (\n\t<div className=\"wp-block-post-featured-image__placeholder\">\n\t\t{ placeholderIllustration }\n\t</div>\n);\n\nfunction getMediaSourceUrlBySizeSlug( media, slug ) {\n\treturn (\n\t\tmedia?.media_details?.sizes?.[ slug ]?.source_url || media?.source_url\n\t);\n}\n\nfunction PostFeaturedImageDisplay( {\n\tclientId,\n\tattributes,\n\tsetAttributes,\n\tcontext: { postId, postType, queryId },\n} ) {\n\tconst isDescendentOfQueryLoop = Number.isFinite( queryId );\n\tconst { isLink, height, width, scale, sizeSlug } = attributes;\n\tconst [ featuredImage, setFeaturedImage ] = useEntityProp(\n\t\t'postType',\n\t\tpostType,\n\t\t'featured_media',\n\t\tpostId\n\t);\n\n\tconst media = useSelect(\n\t\t( select ) =>\n\t\t\tfeaturedImage &&\n\t\t\tselect( coreStore ).getMedia( featuredImage, { context: 'view' } ),\n\t\t[ featuredImage ]\n\t);\n\tconst mediaUrl = getMediaSourceUrlBySizeSlug( media, sizeSlug );\n\n\tconst imageSizes = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().imageSizes,\n\t\t[]\n\t);\n\tconst imageSizeOptions = imageSizes\n\t\t.filter( ( { slug } ) => {\n\t\t\treturn media?.media_details?.sizes?.[ slug ]?.source_url;\n\t\t} )\n\t\t.map( ( { name, slug } ) => ( {\n\t\t\tvalue: slug,\n\t\t\tlabel: name,\n\t\t} ) );\n\n\tconst blockProps = useBlockProps( {\n\t\tstyle: { width, height },\n\t} );\n\n\tconst placeholder = ( content ) => {\n\t\treturn (\n\t\t\t<Placeholder className=\"block-editor-media-placeholder\">\n\t\t\t\t{ placeholderIllustration }\n\t\t\t\t{ content }\n\t\t\t</Placeholder>\n\t\t);\n\t};\n\n\tconst onSelectImage = ( value ) => {\n\t\tif ( value?.id ) {\n\t\t\tsetFeaturedImage( value.id );\n\t\t}\n\t};\n\n\tconst { createErrorNotice } = useDispatch( noticesStore );\n\tconst onUploadError = ( message ) => {\n\t\tcreateErrorNotice( message[ 2 ], { type: 'snackbar' } );\n\t};\n\n\tconst controls = (\n\t\t<>\n\t\t\t<DimensionControls\n\t\t\t\tclientId={ clientId }\n\t\t\t\tattributes={ attributes }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\timageSizeOptions={ imageSizeOptions }\n\t\t\t/>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Link settings' ) }>\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ sprintf(\n\t\t\t\t\t\t\t// translators: %s: Name of the post type e.g: \"post\".\n\t\t\t\t\t\t\t__( 'Link to %s' ),\n\t\t\t\t\t\t\tpostType\n\t\t\t\t\t\t) }\n\t\t\t\t\t\tonChange={ () => setAttributes( { isLink: ! isLink } ) }\n\t\t\t\t\t\tchecked={ isLink }\n\t\t\t\t\t/>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t</>\n\t);\n\tlet image;\n\tif ( ! featuredImage && isDescendentOfQueryLoop ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ controls }\n\t\t\t\t<div { ...blockProps }>{ placeholderChip }</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tconst label = __( 'Add a featured image' );\n\n\tif ( ! featuredImage ) {\n\t\timage = (\n\t\t\t<MediaPlaceholder\n\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\taccept=\"image/*\"\n\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\tonError={ onUploadError }\n\t\t\t\tplaceholder={ placeholder }\n\t\t\t\tmediaLibraryButton={ ( { open } ) => {\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\ticon={ upload }\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\tshowTooltip\n\t\t\t\t\t\t\ttooltipPosition=\"top center\"\n\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\topen();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} }\n\t\t\t/>\n\t\t);\n\t} else {\n\t\t// We have a Featured image so show a Placeholder if is loading.\n\t\timage = ! media ? (\n\t\t\tplaceholderChip\n\t\t) : (\n\t\t\t<img\n\t\t\t\tsrc={ mediaUrl }\n\t\t\t\talt={\n\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t// translators: %s: The image's alt text.\n\t\t\t\t\t\t\t\t__( 'Featured image: %s' ),\n\t\t\t\t\t\t\t\tmedia.alt_text\n\t\t\t\t\t\t )\n\t\t\t\t\t\t: __( 'Featured image' )\n\t\t\t\t}\n\t\t\t\tstyle={ { height, objectFit: height && scale } }\n\t\t\t/>\n\t\t);\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ controls }\n\t\t\t{ !! media && ! isDescendentOfQueryLoop && (\n\t\t\t\t<BlockControls group=\"other\">\n\t\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\t\tmediaId={ featuredImage }\n\t\t\t\t\t\tmediaURL={ mediaUrl }\n\t\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\t\taccept=\"image/*\"\n\t\t\t\t\t\tonSelect={ onSelectImage }\n\t\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t\t>\n\t\t\t\t\t\t<MenuItem onClick={ () => setFeaturedImage( 0 ) }>\n\t\t\t\t\t\t\t{ __( 'Reset' ) }\n\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t</MediaReplaceFlow>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t<figure { ...blockProps }>{ image }</figure>\n\t\t</>\n\t);\n}\n\nexport default function PostFeaturedImageEdit( props ) {\n\tconst blockProps = useBlockProps();\n\tif ( ! props.context?.postId ) {\n\t\treturn <div { ...blockProps }>{ placeholderChip }</div>;\n\t}\n\treturn <PostFeaturedImageDisplay { ...props } />;\n}\n"]}
|
|
@@ -37,7 +37,7 @@ const metadata = {
|
|
|
37
37
|
supports: {
|
|
38
38
|
align: ["left", "right", "center", "wide", "full"],
|
|
39
39
|
color: {
|
|
40
|
-
__experimentalDuotone: "img",
|
|
40
|
+
__experimentalDuotone: "img, .wp-block-post-featured-image__placeholder, .components-placeholder__illustration, .components-placeholder::before",
|
|
41
41
|
text: false,
|
|
42
42
|
background: false
|
|
43
43
|
},
|