@wordpress/block-library 11.0.2-next.v.202609171837.0 → 11.2.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 +44 -1
- package/build/accordion/block.json +4 -1
- package/build/accordion-heading/block.json +1 -0
- package/build/accordion-item/block.json +7 -1
- package/build/accordion-panel/block.json +9 -1
- package/build/archives/block.json +12 -0
- package/build/audio/block.json +8 -0
- package/build/audio/edit.cjs +2 -1
- package/build/audio/edit.cjs.map +2 -2
- package/build/avatar/block.json +4 -0
- package/build/avatar/edit.cjs +31 -1
- package/build/avatar/edit.cjs.map +3 -3
- package/build/breadcrumbs/block.json +3 -0
- package/build/breadcrumbs/edit.cjs.map +3 -3
- package/build/button/block.json +6 -0
- package/build/button/edit.cjs +9 -6
- package/build/button/edit.cjs.map +2 -2
- package/build/buttons/block.json +15 -1
- package/build/categories/block.json +12 -1
- package/build/code/block.json +13 -0
- package/build/column/block.json +9 -0
- package/build/column/edit.cjs +5 -0
- package/build/column/edit.cjs.map +2 -2
- package/build/columns/block.json +13 -0
- package/build/columns/edit.cjs +21 -112
- package/build/columns/edit.cjs.map +3 -3
- package/build/comment-author-name/block.json +3 -0
- package/build/comment-content/block.json +5 -0
- package/build/comment-date/block.json +3 -0
- package/build/comment-edit-link/block.json +3 -0
- package/build/comment-reply-link/block.json +3 -0
- package/build/comments/block.json +10 -0
- package/build/comments/edit/placeholder.cjs +95 -87
- package/build/comments/edit/placeholder.cjs.map +2 -2
- package/build/comments-pagination/block.json +14 -0
- package/build/comments-pagination-next/block.json +3 -0
- package/build/comments-pagination-numbers/block.json +3 -0
- package/build/comments-pagination-previous/block.json +6 -0
- package/build/comments-title/block.json +3 -0
- package/build/cover/block.json +2 -1
- package/build/cover/edit/index.cjs +30 -6
- package/build/cover/edit/index.cjs.map +2 -2
- package/build/cover/edit/inspector-controls.cjs +56 -14
- package/build/cover/edit/inspector-controls.cjs.map +2 -2
- package/build/cover/embed-video-utils.cjs +9 -8
- package/build/cover/embed-video-utils.cjs.map +2 -2
- package/build/cover/view.cjs +21 -0
- package/build/cover/view.cjs.map +7 -0
- package/build/details/block.json +14 -0
- package/build/embed/block.json +6 -1
- package/build/file/block.json +14 -0
- package/build/footnotes/block.json +13 -0
- package/build/gallery/block.json +22 -0
- package/build/gallery/dynamic-gallery.cjs +32 -93
- package/build/gallery/dynamic-gallery.cjs.map +3 -3
- package/build/gallery/edit.cjs +104 -42
- package/build/gallery/edit.cjs.map +2 -2
- package/build/gallery/order-controls.cjs +107 -0
- package/build/gallery/order-controls.cjs.map +7 -0
- package/build/gallery/order-images.cjs +92 -0
- package/build/gallery/order-images.cjs.map +7 -0
- package/build/gallery/order-options.cjs +62 -0
- package/build/gallery/order-options.cjs.map +7 -0
- package/build/gallery/use-dynamic-gallery.cjs +1 -7
- package/build/gallery/use-dynamic-gallery.cjs.map +2 -2
- package/build/gallery/use-get-media.cjs +2 -3
- package/build/gallery/use-get-media.cjs.map +2 -2
- package/build/group/block.json +1 -0
- package/build/group/edit.cjs +3 -3
- package/build/group/edit.cjs.map +2 -2
- package/build/heading/block.json +14 -0
- package/build/home-link/block.json +30 -0
- package/build/home-link/edit.cjs.map +3 -3
- package/build/icon/components/custom-inserter/index.cjs +3 -1
- package/build/icon/components/custom-inserter/index.cjs.map +2 -2
- package/build/icon/edit.cjs +49 -5
- package/build/icon/edit.cjs.map +2 -2
- package/build/image/image.cjs +10 -8
- package/build/image/image.cjs.map +3 -3
- package/build/image/use-open-image-media-editor-modal.cjs +32 -8
- package/build/image/use-open-image-media-editor-modal.cjs.map +2 -2
- package/build/image/view.cjs +44 -50
- package/build/image/view.cjs.map +2 -2
- package/build/latest-comments/block.json +20 -0
- package/build/latest-posts/block.json +14 -0
- package/build/list/block.json +12 -1
- package/build/list-item/block.json +8 -1
- package/build/list-item/index.cjs +4 -0
- package/build/list-item/index.cjs.map +3 -3
- package/build/loginout/block.json +14 -0
- package/build/math/block.json +14 -0
- package/build/media-text/block.json +19 -0
- package/build/navigation/edit/index.cjs +1 -4
- package/build/navigation/edit/index.cjs.map +2 -2
- package/build/navigation-link/link-ui/index.cjs +33 -19
- package/build/navigation-link/link-ui/index.cjs.map +2 -2
- package/build/navigation-link/link-ui/page-creator.cjs.map +3 -3
- package/build/navigation-link/shared/controls.cjs.map +3 -3
- package/build/navigation-link/shared/index.cjs +5 -0
- package/build/navigation-link/shared/index.cjs.map +2 -2
- package/build/navigation-link/shared/use-block-suggestions.cjs +141 -0
- package/build/navigation-link/shared/use-block-suggestions.cjs.map +7 -0
- package/build/navigation-link/shared/use-link-preview.cjs +13 -13
- package/build/navigation-link/shared/use-link-preview.cjs.map +2 -2
- package/build/navigation-overlay-close/block.json +7 -0
- package/build/navigation-submenu/block.json +6 -0
- package/build/navigation-submenu/edit.cjs +9 -1
- package/build/navigation-submenu/edit.cjs.map +3 -3
- package/build/page-list/block.json +14 -0
- package/build/paragraph/block.json +1 -0
- package/build/paragraph/edit.cjs +1 -2
- package/build/paragraph/edit.cjs.map +2 -2
- package/build/playlist/block.json +1 -0
- package/build/post-author-biography/block.json +5 -0
- package/build/post-author-name/block.json +5 -0
- package/build/post-comments-count/block.json +3 -0
- package/build/post-comments-form/block.json +15 -0
- package/build/post-content/block.json +4 -1
- package/build/post-date/block.json +3 -0
- package/build/post-excerpt/block.json +9 -0
- package/build/post-featured-image/block.json +1 -0
- package/build/post-featured-image/edit.cjs +12 -10
- package/build/post-featured-image/edit.cjs.map +2 -2
- package/build/post-navigation-link/block.json +30 -0
- package/build/post-navigation-link/edit.cjs +13 -2
- package/build/post-navigation-link/edit.cjs.map +3 -3
- package/build/post-template/block.json +13 -1
- package/build/post-terms/block.json +10 -0
- package/build/post-time-to-read/block.json +10 -0
- package/build/post-title/block.json +14 -0
- package/build/preformatted/block.json +11 -0
- package/build/pullquote/block.json +3 -1
- package/build/query-no-results/block.json +14 -2
- package/build/query-pagination/block.json +20 -0
- package/build/query-pagination-next/block.json +3 -0
- package/build/query-pagination-numbers/block.json +3 -0
- package/build/query-pagination-previous/block.json +3 -0
- package/build/query-title/block.json +3 -0
- package/build/query-total/block.json +10 -0
- package/build/quote/block.json +3 -0
- package/build/read-more/block.json +11 -0
- package/build/rss/block.json +10 -0
- package/build/search/block.json +2 -1
- package/build/site-tagline/block.json +12 -1
- package/build/site-title/block.json +11 -1
- package/build/social-links/block.json +4 -0
- package/build/social-links/edit.cjs +2 -3
- package/build/social-links/edit.cjs.map +2 -2
- package/build/tab-list/block.json +4 -0
- package/build/tab-list/edit.cjs +3 -1
- package/build/tab-list/edit.cjs.map +3 -3
- package/build/tab-list/save.cjs +3 -1
- package/build/tab-list/save.cjs.map +3 -3
- package/build/tab-panel/block.json +25 -0
- package/build/tab-panel/controls.cjs.map +3 -3
- package/build/tab-panels/block.json +21 -1
- package/build/table-of-contents/block.json +7 -0
- package/build/tabs/block.json +27 -1
- package/build/tag-cloud/block.json +19 -0
- package/build/template-part/edit/selection-modal.cjs.map +1 -1
- package/build/term-count/block.json +12 -0
- package/build/term-description/block.json +13 -0
- package/build/term-name/block.json +16 -1
- package/build/term-template/block.json +14 -1
- package/build/utils/search-patterns.cjs +7 -43
- package/build/utils/search-patterns.cjs.map +3 -3
- package/build/utils/style-state.cjs +4 -6
- package/build/utils/style-state.cjs.map +2 -2
- package/build/utils/waveform-utils.cjs +2 -2
- package/build/utils/waveform-utils.cjs.map +2 -2
- package/build/verse/block.json +4 -0
- package/build/video/block.json +12 -0
- package/build/video/edit.cjs +30 -14
- package/build/video/edit.cjs.map +3 -3
- package/build/video/index.cjs +0 -2
- package/build/video/index.cjs.map +3 -3
- package/build/video/save.cjs +5 -1
- package/build/video/save.cjs.map +3 -3
- package/build-module/accordion/block.json +4 -1
- package/build-module/accordion-heading/block.json +1 -0
- package/build-module/accordion-item/block.json +7 -1
- package/build-module/accordion-panel/block.json +9 -1
- package/build-module/archives/block.json +12 -0
- package/build-module/audio/block.json +8 -0
- package/build-module/audio/edit.mjs +2 -1
- package/build-module/audio/edit.mjs.map +2 -2
- package/build-module/avatar/block.json +4 -0
- package/build-module/avatar/edit.mjs +33 -2
- package/build-module/avatar/edit.mjs.map +2 -2
- package/build-module/breadcrumbs/block.json +3 -0
- package/build-module/breadcrumbs/edit.mjs +3 -3
- package/build-module/breadcrumbs/edit.mjs.map +2 -2
- package/build-module/button/block.json +6 -0
- package/build-module/button/edit.mjs +11 -7
- package/build-module/button/edit.mjs.map +2 -2
- package/build-module/buttons/block.json +15 -1
- package/build-module/categories/block.json +12 -1
- package/build-module/code/block.json +13 -0
- package/build-module/column/block.json +9 -0
- package/build-module/column/edit.mjs +5 -0
- package/build-module/column/edit.mjs.map +2 -2
- package/build-module/columns/block.json +13 -0
- package/build-module/columns/edit.mjs +22 -122
- package/build-module/columns/edit.mjs.map +2 -2
- package/build-module/comment-author-name/block.json +3 -0
- package/build-module/comment-content/block.json +5 -0
- package/build-module/comment-date/block.json +3 -0
- package/build-module/comment-edit-link/block.json +3 -0
- package/build-module/comment-reply-link/block.json +3 -0
- package/build-module/comments/block.json +10 -0
- package/build-module/comments/edit/placeholder.mjs +95 -87
- package/build-module/comments/edit/placeholder.mjs.map +2 -2
- package/build-module/comments-pagination/block.json +14 -0
- package/build-module/comments-pagination-next/block.json +3 -0
- package/build-module/comments-pagination-numbers/block.json +3 -0
- package/build-module/comments-pagination-previous/block.json +6 -0
- package/build-module/comments-title/block.json +3 -0
- package/build-module/cover/block.json +2 -1
- package/build-module/cover/edit/index.mjs +36 -7
- package/build-module/cover/edit/index.mjs.map +2 -2
- package/build-module/cover/edit/inspector-controls.mjs +62 -16
- package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
- package/build-module/cover/embed-video-utils.mjs +9 -8
- package/build-module/cover/embed-video-utils.mjs.map +2 -2
- package/build-module/cover/view.mjs +19 -0
- package/build-module/cover/view.mjs.map +7 -0
- package/build-module/details/block.json +14 -0
- package/build-module/embed/block.json +6 -1
- package/build-module/file/block.json +14 -0
- package/build-module/footnotes/block.json +13 -0
- package/build-module/gallery/block.json +22 -0
- package/build-module/gallery/dynamic-gallery.mjs +33 -97
- package/build-module/gallery/dynamic-gallery.mjs.map +2 -2
- package/build-module/gallery/edit.mjs +111 -44
- package/build-module/gallery/edit.mjs.map +2 -2
- package/build-module/gallery/order-controls.mjs +87 -0
- package/build-module/gallery/order-controls.mjs.map +7 -0
- package/build-module/gallery/order-images.mjs +66 -0
- package/build-module/gallery/order-images.mjs.map +7 -0
- package/build-module/gallery/order-options.mjs +33 -0
- package/build-module/gallery/order-options.mjs.map +7 -0
- package/build-module/gallery/use-dynamic-gallery.mjs +1 -7
- package/build-module/gallery/use-dynamic-gallery.mjs.map +2 -2
- package/build-module/gallery/use-get-media.mjs +2 -3
- package/build-module/gallery/use-get-media.mjs.map +2 -2
- package/build-module/group/block.json +1 -0
- package/build-module/group/edit.mjs +4 -4
- package/build-module/group/edit.mjs.map +2 -2
- package/build-module/heading/block.json +14 -0
- package/build-module/home-link/block.json +30 -0
- package/build-module/home-link/edit.mjs +2 -2
- package/build-module/home-link/edit.mjs.map +2 -2
- package/build-module/icon/components/custom-inserter/index.mjs +3 -1
- package/build-module/icon/components/custom-inserter/index.mjs.map +2 -2
- package/build-module/icon/edit.mjs +50 -6
- package/build-module/icon/edit.mjs.map +2 -2
- package/build-module/image/image.mjs +12 -10
- package/build-module/image/image.mjs.map +2 -2
- package/build-module/image/use-open-image-media-editor-modal.mjs +32 -8
- package/build-module/image/use-open-image-media-editor-modal.mjs.map +2 -2
- package/build-module/image/view.mjs +44 -50
- package/build-module/image/view.mjs.map +2 -2
- package/build-module/latest-comments/block.json +20 -0
- package/build-module/latest-posts/block.json +14 -0
- package/build-module/list/block.json +12 -1
- package/build-module/list-item/block.json +8 -1
- package/build-module/list-item/index.mjs +4 -0
- package/build-module/list-item/index.mjs.map +2 -2
- package/build-module/loginout/block.json +14 -0
- package/build-module/math/block.json +14 -0
- package/build-module/media-text/block.json +19 -0
- package/build-module/navigation/edit/index.mjs +1 -4
- package/build-module/navigation/edit/index.mjs.map +2 -2
- package/build-module/navigation-link/link-ui/index.mjs +39 -20
- package/build-module/navigation-link/link-ui/index.mjs.map +2 -2
- package/build-module/navigation-link/link-ui/page-creator.mjs +2 -2
- package/build-module/navigation-link/link-ui/page-creator.mjs.map +2 -2
- package/build-module/navigation-link/shared/controls.mjs +2 -2
- package/build-module/navigation-link/shared/controls.mjs.map +2 -2
- package/build-module/navigation-link/shared/index.mjs +6 -0
- package/build-module/navigation-link/shared/index.mjs.map +2 -2
- package/build-module/navigation-link/shared/use-block-suggestions.mjs +120 -0
- package/build-module/navigation-link/shared/use-block-suggestions.mjs.map +7 -0
- package/build-module/navigation-link/shared/use-link-preview.mjs +13 -13
- package/build-module/navigation-link/shared/use-link-preview.mjs.map +2 -2
- package/build-module/navigation-overlay-close/block.json +7 -0
- package/build-module/navigation-submenu/block.json +6 -0
- package/build-module/navigation-submenu/edit.mjs +11 -2
- package/build-module/navigation-submenu/edit.mjs.map +2 -2
- package/build-module/page-list/block.json +14 -0
- package/build-module/paragraph/block.json +1 -0
- package/build-module/paragraph/edit.mjs +1 -2
- package/build-module/paragraph/edit.mjs.map +2 -2
- package/build-module/playlist/block.json +1 -0
- package/build-module/post-author-biography/block.json +5 -0
- package/build-module/post-author-name/block.json +5 -0
- package/build-module/post-comments-count/block.json +3 -0
- package/build-module/post-comments-form/block.json +15 -0
- package/build-module/post-content/block.json +4 -1
- package/build-module/post-date/block.json +3 -0
- package/build-module/post-excerpt/block.json +9 -0
- package/build-module/post-featured-image/block.json +1 -0
- package/build-module/post-featured-image/edit.mjs +12 -10
- package/build-module/post-featured-image/edit.mjs.map +2 -2
- package/build-module/post-navigation-link/block.json +30 -0
- package/build-module/post-navigation-link/edit.mjs +17 -3
- package/build-module/post-navigation-link/edit.mjs.map +2 -2
- package/build-module/post-template/block.json +13 -1
- package/build-module/post-terms/block.json +10 -0
- package/build-module/post-time-to-read/block.json +10 -0
- package/build-module/post-title/block.json +14 -0
- package/build-module/preformatted/block.json +11 -0
- package/build-module/pullquote/block.json +3 -1
- package/build-module/query-no-results/block.json +14 -2
- package/build-module/query-pagination/block.json +20 -0
- package/build-module/query-pagination-next/block.json +3 -0
- package/build-module/query-pagination-numbers/block.json +3 -0
- package/build-module/query-pagination-previous/block.json +3 -0
- package/build-module/query-title/block.json +3 -0
- package/build-module/query-total/block.json +10 -0
- package/build-module/quote/block.json +3 -0
- package/build-module/read-more/block.json +11 -0
- package/build-module/rss/block.json +10 -0
- package/build-module/search/block.json +2 -1
- package/build-module/site-tagline/block.json +12 -1
- package/build-module/site-title/block.json +11 -1
- package/build-module/social-links/block.json +4 -0
- package/build-module/social-links/edit.mjs +2 -3
- package/build-module/social-links/edit.mjs.map +2 -2
- package/build-module/tab-list/block.json +4 -0
- package/build-module/tab-list/edit.mjs +4 -1
- package/build-module/tab-list/edit.mjs.map +2 -2
- package/build-module/tab-list/save.mjs +4 -1
- package/build-module/tab-list/save.mjs.map +2 -2
- package/build-module/tab-panel/block.json +25 -0
- package/build-module/tab-panel/controls.mjs +2 -2
- package/build-module/tab-panel/controls.mjs.map +2 -2
- package/build-module/tab-panels/block.json +21 -1
- package/build-module/table-of-contents/block.json +7 -0
- package/build-module/tabs/block.json +27 -1
- package/build-module/tag-cloud/block.json +19 -0
- package/build-module/template-part/edit/selection-modal.mjs.map +1 -1
- package/build-module/term-count/block.json +12 -0
- package/build-module/term-description/block.json +13 -0
- package/build-module/term-name/block.json +16 -1
- package/build-module/term-template/block.json +14 -1
- package/build-module/utils/search-patterns.mjs +7 -32
- package/build-module/utils/search-patterns.mjs.map +2 -2
- package/build-module/utils/style-state.mjs +6 -4
- package/build-module/utils/style-state.mjs.map +2 -2
- package/build-module/utils/waveform-utils.mjs +1 -1
- package/build-module/utils/waveform-utils.mjs.map +1 -1
- package/build-module/verse/block.json +4 -0
- package/build-module/video/block.json +12 -0
- package/build-module/video/edit.mjs +32 -15
- package/build-module/video/edit.mjs.map +2 -2
- package/build-module/video/index.mjs +0 -2
- package/build-module/video/index.mjs.map +2 -2
- package/build-module/video/save.mjs +7 -2
- package/build-module/video/save.mjs.map +2 -2
- package/build-style/avatar/editor-rtl.css +4 -0
- package/build-style/avatar/editor.css +4 -0
- package/build-style/comments-pagination/style-rtl.css +3 -0
- package/build-style/comments-pagination/style.css +3 -0
- package/build-style/common-rtl.css +32 -1
- package/build-style/common.css +35 -2
- package/build-style/editor-rtl.css +23 -6
- package/build-style/editor.css +23 -6
- package/build-style/embed/style-rtl.css +4 -1
- package/build-style/embed/style.css +4 -1
- package/build-style/gallery/editor-rtl.css +1 -3
- package/build-style/gallery/editor.css +1 -3
- package/build-style/image/editor-rtl.css +6 -0
- package/build-style/image/editor.css +6 -0
- package/build-style/image/style-rtl.css +11 -2
- package/build-style/image/style.css +11 -2
- package/build-style/media-text/style-rtl.css +4 -1
- package/build-style/media-text/style.css +4 -1
- package/build-style/navigation/style-rtl.css +18 -3
- package/build-style/navigation/style.css +18 -3
- package/build-style/navigation-link/editor-rtl.css +3 -1
- package/build-style/navigation-link/editor.css +3 -1
- package/build-style/navigation-overlay-close/style-rtl.css +1 -1
- package/build-style/navigation-overlay-close/style.css +1 -1
- package/build-style/navigation-submenu/editor-rtl.css +3 -1
- package/build-style/navigation-submenu/editor.css +3 -1
- package/build-style/post-navigation-link/style-rtl.css +3 -0
- package/build-style/post-navigation-link/style.css +3 -0
- package/build-style/query-pagination/style-rtl.css +3 -0
- package/build-style/query-pagination/style.css +3 -0
- package/build-style/style-rtl.css +94 -13
- package/build-style/style.css +97 -14
- package/build-style/tab-panel/style-rtl.css +2 -0
- package/build-style/tab-panel/style.css +2 -0
- package/build-style/table/editor-rtl.css +6 -1
- package/build-style/table/editor.css +6 -1
- package/build-style/table/style-rtl.css +4 -2
- package/build-style/table/style.css +4 -2
- package/build-style/tag-cloud/style-rtl.css +1 -1
- package/build-style/tag-cloud/style.css +1 -1
- package/build-style/verse/style-rtl.css +8 -1
- package/build-style/verse/style.css +8 -1
- package/build-types/gallery/order-controls.d.ts +58 -0
- package/build-types/gallery/order-controls.d.ts.map +1 -0
- package/build-types/gallery/order-options.d.ts +67 -0
- package/build-types/gallery/order-options.d.ts.map +1 -0
- package/package.json +46 -44
- package/src/accordion/README.md +3 -0
- package/src/accordion/block.json +4 -1
- package/src/accordion-heading/README.md +1 -0
- package/src/accordion-heading/block.json +1 -0
- package/src/accordion-item/README.md +5 -0
- package/src/accordion-item/block.json +7 -1
- package/src/accordion-panel/README.md +7 -0
- package/src/accordion-panel/block.json +9 -1
- package/src/archives/README.md +6 -0
- package/src/archives/block.json +12 -0
- package/src/audio/README.md +4 -0
- package/src/audio/block.json +8 -0
- package/src/audio/edit.jsx +2 -1
- package/src/avatar/README.md +2 -0
- package/src/avatar/block.json +4 -0
- package/src/avatar/edit.jsx +48 -2
- package/src/avatar/editor.scss +4 -0
- package/src/avatar/index.php +5 -3
- package/src/breadcrumbs/README.md +2 -0
- package/src/breadcrumbs/block.json +3 -0
- package/src/breadcrumbs/edit.jsx +3 -3
- package/src/breadcrumbs/index.php +1 -1
- package/src/button/README.md +4 -0
- package/src/button/block.json +6 -0
- package/src/button/edit.jsx +47 -52
- package/src/button/index.php +47 -0
- package/src/buttons/README.md +8 -0
- package/src/buttons/block.json +15 -1
- package/src/categories/README.md +6 -0
- package/src/categories/block.json +12 -1
- package/src/code/README.md +7 -0
- package/src/code/block.json +13 -0
- package/src/column/README.md +4 -0
- package/src/column/block.json +9 -0
- package/src/column/edit.jsx +6 -0
- package/src/columns/README.md +7 -0
- package/src/columns/block.json +13 -0
- package/src/columns/edit.jsx +1 -131
- package/src/comment-author-name/README.md +2 -0
- package/src/comment-author-name/block.json +3 -0
- package/src/comment-content/README.md +4 -0
- package/src/comment-content/block.json +5 -0
- package/src/comment-date/README.md +2 -0
- package/src/comment-date/block.json +3 -0
- package/src/comment-edit-link/README.md +2 -0
- package/src/comment-edit-link/block.json +3 -0
- package/src/comment-reply-link/README.md +2 -0
- package/src/comment-reply-link/block.json +3 -0
- package/src/comments/README.md +5 -0
- package/src/comments/block.json +10 -0
- package/src/comments/edit/placeholder.jsx +5 -1
- package/src/comments-pagination/README.md +6 -0
- package/src/comments-pagination/block.json +14 -0
- package/src/comments-pagination/style.scss +3 -0
- package/src/comments-pagination-next/README.md +2 -0
- package/src/comments-pagination-next/block.json +3 -0
- package/src/comments-pagination-numbers/README.md +2 -0
- package/src/comments-pagination-numbers/block.json +3 -0
- package/src/comments-pagination-previous/README.md +2 -0
- package/src/comments-pagination-previous/block.json +6 -0
- package/src/comments-title/README.md +2 -0
- package/src/comments-title/block.json +3 -0
- package/src/common.scss +38 -0
- package/src/cover/README.md +1 -0
- package/src/cover/block.json +2 -1
- package/src/cover/edit/index.jsx +41 -6
- package/src/cover/edit/inspector-controls.jsx +74 -14
- package/src/cover/embed-video-utils.js +18 -10
- package/src/cover/index.php +44 -15
- package/src/cover/test/edit.browser.test.js +200 -4
- package/src/cover/test/embed-video-utils.test.js +48 -0
- package/src/cover/view.js +22 -0
- package/src/details/README.md +8 -0
- package/src/details/block.json +14 -0
- package/src/embed/README.md +4 -0
- package/src/embed/block.json +6 -1
- package/src/embed/style.scss +7 -1
- package/src/file/README.md +8 -0
- package/src/file/block.json +14 -0
- package/src/footnotes/README.md +7 -0
- package/src/footnotes/block.json +13 -0
- package/src/gallery/README.md +17 -0
- package/src/gallery/block.json +22 -0
- package/src/gallery/dynamic-gallery.jsx +11 -91
- package/src/gallery/edit.jsx +147 -49
- package/src/gallery/editor.scss +5 -9
- package/src/gallery/order-controls.tsx +143 -0
- package/src/gallery/order-images.js +111 -0
- package/src/gallery/order-options.ts +75 -0
- package/src/gallery/test/edit.jsdom.test.js +87 -10
- package/src/gallery/test/order-images.js +162 -0
- package/src/gallery/use-dynamic-gallery.js +1 -9
- package/src/gallery/use-get-media.js +7 -2
- package/src/group/README.md +1 -0
- package/src/group/block.json +1 -0
- package/src/group/edit.jsx +5 -5
- package/src/heading/README.md +8 -0
- package/src/heading/block.json +14 -0
- package/src/home-link/README.md +11 -0
- package/src/home-link/block.json +30 -0
- package/src/home-link/edit.jsx +2 -2
- package/src/icon/components/custom-inserter/index.jsx +5 -1
- package/src/icon/edit.jsx +68 -7
- package/src/icon/index.php +10 -1
- package/src/image/editor.scss +8 -0
- package/src/image/image.jsx +13 -11
- package/src/image/index.php +3 -4
- package/src/image/style.scss +14 -2
- package/src/image/test/use-open-image-media-editor-modal.jsdom.test.js +201 -0
- package/src/image/use-open-image-media-editor-modal.js +37 -4
- package/src/image/view.js +64 -68
- package/src/latest-comments/README.md +8 -0
- package/src/latest-comments/block.json +20 -0
- package/src/latest-posts/README.md +8 -0
- package/src/latest-posts/block.json +14 -0
- package/src/list/README.md +6 -0
- package/src/list/block.json +12 -1
- package/src/list-item/README.md +6 -0
- package/src/list-item/block.json +8 -1
- package/src/list-item/index.js +5 -0
- package/src/loginout/README.md +8 -0
- package/src/loginout/block.json +14 -0
- package/src/math/README.md +8 -0
- package/src/math/block.json +14 -0
- package/src/media-text/README.md +18 -0
- package/src/media-text/block.json +19 -0
- package/src/media-text/style.scss +5 -1
- package/src/navigation/edit/index.jsx +2 -4
- package/src/navigation/style.scss +40 -4
- package/src/navigation/test/use-navigation-menu.jsdom.test.js +1 -1
- package/src/navigation-link/README.md +1 -1
- package/src/navigation-link/editor.scss +6 -1
- package/src/navigation-link/link-ui/index.jsx +60 -27
- package/src/navigation-link/link-ui/page-creator.jsx +2 -2
- package/src/navigation-link/link-ui/test/get-suggestions-query.jsdom.test.js +67 -0
- package/src/navigation-link/shared/controls.jsx +2 -2
- package/src/navigation-link/shared/index.js +4 -0
- package/src/navigation-link/shared/test/use-block-suggestions.jsdom.test.js +158 -0
- package/src/navigation-link/shared/test/use-entity-binding.jsdom.test.js +1 -7
- package/src/navigation-link/shared/test/use-link-preview.jsdom.test.js +22 -22
- package/src/navigation-link/shared/use-block-suggestions.js +192 -0
- package/src/navigation-link/shared/use-link-preview.js +15 -14
- package/src/navigation-overlay-close/README.md +1 -0
- package/src/navigation-overlay-close/block.json +7 -0
- package/src/navigation-overlay-close/style.scss +1 -1
- package/src/navigation-submenu/README.md +7 -0
- package/src/navigation-submenu/block.json +6 -0
- package/src/navigation-submenu/edit.jsx +11 -1
- package/src/navigation-submenu/editor.scss +6 -1
- package/src/navigation-submenu/index.php +11 -0
- package/src/page-list/README.md +8 -0
- package/src/page-list/block.json +14 -0
- package/src/paragraph/README.md +1 -0
- package/src/paragraph/block.json +1 -0
- package/src/paragraph/edit.jsx +1 -3
- package/src/playlist/README.md +1 -0
- package/src/playlist/block.json +1 -0
- package/src/playlist/test/edit-component.jsdom.test.jsx +11 -11
- package/src/playlist-track/test/edit.jsdom.test.jsx +3 -3
- package/src/post-author-biography/README.md +4 -0
- package/src/post-author-biography/block.json +5 -0
- package/src/post-author-name/README.md +4 -0
- package/src/post-author-name/block.json +5 -0
- package/src/post-comments-count/README.md +2 -0
- package/src/post-comments-count/block.json +3 -0
- package/src/post-comments-form/README.md +8 -0
- package/src/post-comments-form/block.json +15 -0
- package/src/post-content/README.md +3 -0
- package/src/post-content/block.json +4 -1
- package/src/post-date/README.md +2 -0
- package/src/post-date/block.json +3 -0
- package/src/post-excerpt/README.md +7 -0
- package/src/post-excerpt/block.json +9 -0
- package/src/post-featured-image/block.json +1 -0
- package/src/post-featured-image/edit.jsx +13 -11
- package/src/post-navigation-link/README.md +12 -0
- package/src/post-navigation-link/block.json +30 -0
- package/src/post-navigation-link/edit.jsx +23 -2
- package/src/post-navigation-link/index.php +94 -5
- package/src/post-navigation-link/style.scss +2 -0
- package/src/post-template/README.md +7 -0
- package/src/post-template/block.json +13 -1
- package/src/post-terms/README.md +8 -0
- package/src/post-terms/block.json +10 -0
- package/src/post-time-to-read/README.md +8 -0
- package/src/post-time-to-read/block.json +10 -0
- package/src/post-title/README.md +8 -0
- package/src/post-title/block.json +14 -0
- package/src/preformatted/README.md +9 -0
- package/src/preformatted/block.json +11 -0
- package/src/pullquote/README.md +2 -0
- package/src/pullquote/block.json +3 -1
- package/src/query-no-results/README.md +10 -0
- package/src/query-no-results/block.json +14 -2
- package/src/query-pagination/README.md +6 -0
- package/src/query-pagination/block.json +20 -0
- package/src/query-pagination/style.scss +3 -0
- package/src/query-pagination-next/README.md +2 -0
- package/src/query-pagination-next/block.json +3 -0
- package/src/query-pagination-numbers/README.md +2 -0
- package/src/query-pagination-numbers/block.json +3 -0
- package/src/query-pagination-previous/README.md +2 -0
- package/src/query-pagination-previous/block.json +3 -0
- package/src/query-title/README.md +2 -0
- package/src/query-title/block.json +3 -0
- package/src/query-total/README.md +8 -0
- package/src/query-total/block.json +10 -0
- package/src/quote/README.md +3 -0
- package/src/quote/block.json +3 -0
- package/src/read-more/README.md +8 -0
- package/src/read-more/block.json +11 -0
- package/src/rss/README.md +8 -0
- package/src/rss/block.json +10 -0
- package/src/search/README.md +1 -0
- package/src/search/block.json +2 -1
- package/src/site-tagline/README.md +9 -0
- package/src/site-tagline/block.json +12 -1
- package/src/site-title/README.md +8 -0
- package/src/site-title/block.json +11 -1
- package/src/social-links/README.md +3 -0
- package/src/social-links/block.json +4 -0
- package/src/social-links/edit.jsx +2 -3
- package/src/tab-list/README.md +2 -0
- package/src/tab-list/block.json +4 -0
- package/src/tab-list/edit.jsx +3 -0
- package/src/tab-list/save.jsx +3 -0
- package/src/tab-panel/README.md +9 -0
- package/src/tab-panel/block.json +25 -0
- package/src/tab-panel/controls.jsx +2 -2
- package/src/tab-panel/style.scss +5 -2
- package/src/tab-panels/README.md +9 -0
- package/src/tab-panels/block.json +21 -1
- package/src/table/editor.scss +8 -2
- package/src/table/style.scss +4 -4
- package/src/table-of-contents/README.md +6 -0
- package/src/table-of-contents/block.json +7 -0
- package/src/tabs/README.md +11 -0
- package/src/tabs/block.json +27 -1
- package/src/tag-cloud/README.md +9 -0
- package/src/tag-cloud/block.json +19 -0
- package/src/tag-cloud/style.scss +1 -1
- package/src/template-part/edit/selection-modal.jsx +1 -1
- package/src/template-part/index.php +16 -3
- package/src/term-count/README.md +10 -0
- package/src/term-count/block.json +12 -0
- package/src/term-description/README.md +8 -0
- package/src/term-description/block.json +13 -0
- package/src/term-name/README.md +9 -0
- package/src/term-name/block.json +16 -1
- package/src/term-name/index.php +1 -1
- package/src/term-template/README.md +8 -0
- package/src/term-template/block.json +14 -1
- package/src/utils/search-patterns.js +9 -53
- package/src/utils/style-state.js +6 -4
- package/src/utils/test/{search-patterns.js → search-patterns.jsdom.test.js} +1 -22
- package/src/utils/test/waveform-player-auto-init.jsdom.test.js +25 -0
- package/src/utils/test/waveform-player-dependency.jsdom.test.js +7 -60
- package/src/utils/test/waveform-utils.browser.test.js +3 -15
- package/src/utils/waveform-utils.js +1 -1
- package/src/verse/README.md +4 -0
- package/src/verse/block.json +4 -0
- package/src/verse/style.scss +11 -2
- package/src/video/README.md +11 -0
- package/src/video/block.json +12 -0
- package/src/video/edit.jsx +65 -49
- package/src/video/index.js +0 -2
- package/src/video/save.jsx +10 -1
- package/build/columns/utils.cjs +0 -112
- package/build/columns/utils.cjs.map +0 -7
- package/build/video/variations.cjs +0 -75
- package/build/video/variations.cjs.map +0 -7
- package/build-module/columns/utils.mjs +0 -78
- package/build-module/columns/utils.mjs.map +0 -7
- package/build-module/video/variations.mjs +0 -50
- package/build-module/video/variations.mjs.map +0 -7
- package/src/columns/test/utils.js +0 -331
- package/src/columns/utils.js +0 -176
- package/src/video/test/variations.js +0 -63
- package/src/video/variations.js +0 -62
|
@@ -25,8 +25,10 @@ __export(shared_exports, {
|
|
|
25
25
|
LinkUI: () => import_link_ui.LinkUI,
|
|
26
26
|
buildNavigationLinkEntityBinding: () => import_use_entity_binding.buildNavigationLinkEntityBinding,
|
|
27
27
|
getInvalidLinkHelpText: () => import_controls.getInvalidLinkHelpText,
|
|
28
|
+
isBlockSuggestion: () => import_use_block_suggestions.isBlockSuggestion,
|
|
28
29
|
selectLabelText: () => import_select_label_text.selectLabelText,
|
|
29
30
|
updateAttributes: () => import_update_attributes.updateAttributes,
|
|
31
|
+
useBlockSuggestions: () => import_use_block_suggestions.useBlockSuggestions,
|
|
30
32
|
useEnableLinkStatusValidation: () => import_use_enable_link_status_validation.useEnableLinkStatusValidation,
|
|
31
33
|
useEntityBinding: () => import_use_entity_binding.useEntityBinding,
|
|
32
34
|
useHandleLinkChange: () => import_use_handle_link_change.useHandleLinkChange,
|
|
@@ -46,6 +48,7 @@ var import_use_enable_link_status_validation = require("./use-enable-link-status
|
|
|
46
48
|
var import_use_is_dragging_within = require("./use-is-dragging-within.cjs");
|
|
47
49
|
var import_select_label_text = require("./select-label-text.cjs");
|
|
48
50
|
var import_use_link_preview = require("./use-link-preview.cjs");
|
|
51
|
+
var import_use_block_suggestions = require("./use-block-suggestions.cjs");
|
|
49
52
|
// Annotate the CommonJS export names for ESM import in node:
|
|
50
53
|
0 && (module.exports = {
|
|
51
54
|
Controls,
|
|
@@ -53,8 +56,10 @@ var import_use_link_preview = require("./use-link-preview.cjs");
|
|
|
53
56
|
LinkUI,
|
|
54
57
|
buildNavigationLinkEntityBinding,
|
|
55
58
|
getInvalidLinkHelpText,
|
|
59
|
+
isBlockSuggestion,
|
|
56
60
|
selectLabelText,
|
|
57
61
|
updateAttributes,
|
|
62
|
+
useBlockSuggestions,
|
|
58
63
|
useEnableLinkStatusValidation,
|
|
59
64
|
useEntityBinding,
|
|
60
65
|
useHandleLinkChange,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation-link/shared/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Shared components for Navigation Link and Navigation Submenu blocks.\n *\n * This module provides common functionality that can be used by both blocks\n * to reduce code duplication and ensure consistent behavior.\n */\n\nexport { Controls, getInvalidLinkHelpText } from './controls';\nexport { updateAttributes } from './update-attributes';\nexport {\n\tuseEntityBinding,\n\tbuildNavigationLinkEntityBinding,\n} from './use-entity-binding';\nexport { LinkUI } from '../link-ui';\nexport { useHandleLinkChange } from './use-handle-link-change';\nexport { useIsInvalidLink } from './use-is-invalid-link';\nexport { InvalidDraftDisplay } from './invalid-draft-display';\nexport { useEnableLinkStatusValidation } from './use-enable-link-status-validation';\nexport { useIsDraggingWithin } from './use-is-dragging-within';\nexport { selectLabelText } from './select-label-text';\nexport { useLinkPreview } from './use-link-preview';\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,sBAAiD;AACjD,+BAAiC;AACjC,gCAGO;AACP,qBAAuB;AACvB,oCAAoC;AACpC,iCAAiC;AACjC,mCAAoC;AACpC,+CAA8C;AAC9C,oCAAoC;AACpC,+BAAgC;AAChC,8BAA+B;",
|
|
4
|
+
"sourcesContent": ["/**\n * Shared components for Navigation Link and Navigation Submenu blocks.\n *\n * This module provides common functionality that can be used by both blocks\n * to reduce code duplication and ensure consistent behavior.\n */\n\nexport { Controls, getInvalidLinkHelpText } from './controls';\nexport { updateAttributes } from './update-attributes';\nexport {\n\tuseEntityBinding,\n\tbuildNavigationLinkEntityBinding,\n} from './use-entity-binding';\nexport { LinkUI } from '../link-ui';\nexport { useHandleLinkChange } from './use-handle-link-change';\nexport { useIsInvalidLink } from './use-is-invalid-link';\nexport { InvalidDraftDisplay } from './invalid-draft-display';\nexport { useEnableLinkStatusValidation } from './use-enable-link-status-validation';\nexport { useIsDraggingWithin } from './use-is-dragging-within';\nexport { selectLabelText } from './select-label-text';\nexport { useLinkPreview } from './use-link-preview';\nexport {\n\tisBlockSuggestion,\n\tuseBlockSuggestions,\n} from './use-block-suggestions';\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAOA,sBAAiD;AACjD,+BAAiC;AACjC,gCAGO;AACP,qBAAuB;AACvB,oCAAoC;AACpC,iCAAiC;AACjC,mCAAoC;AACpC,+CAA8C;AAC9C,oCAAoC;AACpC,+BAAgC;AAChC,8BAA+B;AAC/B,mCAGO;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// packages/block-library/src/navigation-link/shared/use-block-suggestions.js
|
|
21
|
+
var use_block_suggestions_exports = {};
|
|
22
|
+
__export(use_block_suggestions_exports, {
|
|
23
|
+
BLOCK_SUGGESTION_TYPE: () => BLOCK_SUGGESTION_TYPE,
|
|
24
|
+
addBlockSuggestions: () => addBlockSuggestions,
|
|
25
|
+
isBlockSuggestion: () => isBlockSuggestion,
|
|
26
|
+
useBlockSuggestions: () => useBlockSuggestions
|
|
27
|
+
});
|
|
28
|
+
module.exports = __toCommonJS(use_block_suggestions_exports);
|
|
29
|
+
var import_i18n = require("@wordpress/i18n");
|
|
30
|
+
var import_a11y = require("@wordpress/a11y");
|
|
31
|
+
var import_element = require("@wordpress/element");
|
|
32
|
+
var import_data = require("@wordpress/data");
|
|
33
|
+
var import_blocks = require("@wordpress/blocks");
|
|
34
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
35
|
+
var import_lock_unlock = require("../../lock-unlock.cjs");
|
|
36
|
+
var { searchItems, normalizeString } = (0, import_lock_unlock.unlock)(import_block_editor.privateApis);
|
|
37
|
+
var BLOCK_SUGGESTION_TYPE = "block";
|
|
38
|
+
function isBlockSuggestion(suggestion) {
|
|
39
|
+
return suggestion?.type === BLOCK_SUGGESTION_TYPE && typeof suggestion.blockItemId === "string";
|
|
40
|
+
}
|
|
41
|
+
var EXCLUDED_BLOCK_NAMES = ["core/navigation-link"];
|
|
42
|
+
var SEARCH_FIELDS = [
|
|
43
|
+
{ get: (item) => item.title },
|
|
44
|
+
{ get: (item) => item.keywords }
|
|
45
|
+
];
|
|
46
|
+
function addBlockSuggestions(suggestions, blockItems, searchTerm) {
|
|
47
|
+
if (!searchTerm?.trim()) {
|
|
48
|
+
return suggestions;
|
|
49
|
+
}
|
|
50
|
+
const matches = searchItems(blockItems, searchTerm, {
|
|
51
|
+
fields: SEARCH_FIELDS,
|
|
52
|
+
filter: (item) => !item.isDisabled && !EXCLUDED_BLOCK_NAMES.includes(item.name)
|
|
53
|
+
});
|
|
54
|
+
if (!matches.length) {
|
|
55
|
+
return suggestions;
|
|
56
|
+
}
|
|
57
|
+
const search = normalizeString(searchTerm.trim());
|
|
58
|
+
const before = [];
|
|
59
|
+
const after = [];
|
|
60
|
+
for (const item of matches) {
|
|
61
|
+
const suggestion = {
|
|
62
|
+
id: item.id,
|
|
63
|
+
blockItemId: item.id,
|
|
64
|
+
type: BLOCK_SUGGESTION_TYPE,
|
|
65
|
+
title: item.title,
|
|
66
|
+
icon: (0, import_element.createElement)(import_block_editor.BlockIcon, { icon: item.icon }),
|
|
67
|
+
typeLabel: (0, import_i18n.__)("Block")
|
|
68
|
+
};
|
|
69
|
+
if (normalizeString(item.title).startsWith(search)) {
|
|
70
|
+
before.push(suggestion);
|
|
71
|
+
} else {
|
|
72
|
+
after.push(suggestion);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
return [...before, ...suggestions, ...after];
|
|
76
|
+
}
|
|
77
|
+
function useBlockSuggestions({
|
|
78
|
+
clientId,
|
|
79
|
+
isEnabled,
|
|
80
|
+
onBlockInsert,
|
|
81
|
+
onClose
|
|
82
|
+
}) {
|
|
83
|
+
const {
|
|
84
|
+
getBlockIndex,
|
|
85
|
+
getBlockOrder,
|
|
86
|
+
getBlockRootClientId,
|
|
87
|
+
getInserterItems
|
|
88
|
+
} = (0, import_data.useSelect)(import_block_editor.store);
|
|
89
|
+
const { insertBlock, replaceBlock } = (0, import_data.useDispatch)(import_block_editor.store);
|
|
90
|
+
const transformSuggestions = (0, import_element.useCallback)(
|
|
91
|
+
(suggestions, { isInitialSuggestions, searchTerm }) => isInitialSuggestions ? suggestions : addBlockSuggestions(
|
|
92
|
+
suggestions,
|
|
93
|
+
getInserterItems(getBlockRootClientId(clientId)),
|
|
94
|
+
searchTerm
|
|
95
|
+
),
|
|
96
|
+
[clientId, getBlockRootClientId, getInserterItems]
|
|
97
|
+
);
|
|
98
|
+
const insertBlockFromSuggestion = (itemId) => {
|
|
99
|
+
const rootClientId = getBlockRootClientId(clientId);
|
|
100
|
+
const item = getInserterItems(rootClientId).find(
|
|
101
|
+
({ id }) => id === itemId
|
|
102
|
+
);
|
|
103
|
+
if (!item) {
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const block = (0, import_blocks.createBlock)(
|
|
107
|
+
item.name,
|
|
108
|
+
item.initialAttributes,
|
|
109
|
+
(0, import_blocks.createBlocksFromInnerBlocksTemplate)(item.innerBlocks)
|
|
110
|
+
);
|
|
111
|
+
const index = getBlockIndex(clientId);
|
|
112
|
+
if (onBlockInsert) {
|
|
113
|
+
insertBlock(block, index, rootClientId, false);
|
|
114
|
+
onBlockInsert(block);
|
|
115
|
+
} else if (getBlockOrder(clientId).length) {
|
|
116
|
+
insertBlock(block, index, rootClientId);
|
|
117
|
+
onClose?.();
|
|
118
|
+
} else {
|
|
119
|
+
replaceBlock(clientId, block);
|
|
120
|
+
}
|
|
121
|
+
(0, import_a11y.speak)(
|
|
122
|
+
(0, import_i18n.sprintf)(
|
|
123
|
+
/* translators: %s: The title of the block that was added. */
|
|
124
|
+
(0, import_i18n.__)("%s block added."),
|
|
125
|
+
item.title
|
|
126
|
+
)
|
|
127
|
+
);
|
|
128
|
+
};
|
|
129
|
+
return {
|
|
130
|
+
transformSuggestions: isEnabled ? transformSuggestions : void 0,
|
|
131
|
+
insertBlockFromSuggestion
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
135
|
+
0 && (module.exports = {
|
|
136
|
+
BLOCK_SUGGESTION_TYPE,
|
|
137
|
+
addBlockSuggestions,
|
|
138
|
+
isBlockSuggestion,
|
|
139
|
+
useBlockSuggestions
|
|
140
|
+
});
|
|
141
|
+
//# sourceMappingURL=use-block-suggestions.cjs.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/navigation-link/shared/use-block-suggestions.js"],
|
|
4
|
+
"sourcesContent": ["import { __, sprintf } from '@wordpress/i18n';\nimport { speak } from '@wordpress/a11y';\nimport { createElement, useCallback } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tcreateBlock,\n\tcreateBlocksFromInnerBlocksTemplate,\n} from '@wordpress/blocks';\nimport {\n\tBlockIcon,\n\tstore as blockEditorStore,\n\tprivateApis as blockEditorPrivateApis,\n} from '@wordpress/block-editor';\nimport { unlock } from '../../lock-unlock';\n\nconst { searchItems, normalizeString } = unlock( blockEditorPrivateApis );\n\n/**\n * The `type` of a suggestion that inserts a block rather than setting a link.\n */\nexport const BLOCK_SUGGESTION_TYPE = 'block';\n\n/**\n * Whether a suggestion inserts a block rather than setting a link.\n *\n * The `type` alone is not enough: a site can register a post type called\n * \"block\", whose results arrive with that type. Only a block suggestion\n * carries the inserter item it was made from.\n *\n * @param {Object} suggestion A link suggestion.\n * @return {boolean} Whether it is a block suggestion.\n */\nexport function isBlockSuggestion( suggestion ) {\n\treturn (\n\t\tsuggestion?.type === BLOCK_SUGGESTION_TYPE &&\n\t\ttypeof suggestion.blockItemId === 'string'\n\t);\n}\n\n/**\n * The link variations are left out: searching already finds the pages, posts\n * and terms they would link to.\n */\nconst EXCLUDED_BLOCK_NAMES = [ 'core/navigation-link' ];\n\n// Match on what a block is called, not on its description or category, which\n// would list blocks for words that only happen to describe them.\nconst SEARCH_FIELDS = [\n\t{ get: ( item ) => item.title },\n\t{ get: ( item ) => item.keywords },\n];\n\n/**\n * Adds the blocks that match a search to the link suggestions.\n *\n * A block whose title starts with the search is what was asked for by name,\n * so it goes before the links. Any other matching block goes after them.\n *\n * @param {Array} suggestions Link suggestions.\n * @param {Array} blockItems Inserter items the Navigation allows.\n * @param {string} searchTerm What the user typed.\n * @return {Array} The suggestions, with any matching blocks added.\n */\nexport function addBlockSuggestions( suggestions, blockItems, searchTerm ) {\n\tif ( ! searchTerm?.trim() ) {\n\t\treturn suggestions;\n\t}\n\n\tconst matches = searchItems( blockItems, searchTerm, {\n\t\tfields: SEARCH_FIELDS,\n\t\tfilter: ( item ) =>\n\t\t\t! item.isDisabled && ! EXCLUDED_BLOCK_NAMES.includes( item.name ),\n\t} );\n\n\tif ( ! matches.length ) {\n\t\treturn suggestions;\n\t}\n\n\tconst search = normalizeString( searchTerm.trim() );\n\tconst before = [];\n\tconst after = [];\n\n\tfor ( const item of matches ) {\n\t\tconst suggestion = {\n\t\t\tid: item.id,\n\t\t\tblockItemId: item.id,\n\t\t\ttype: BLOCK_SUGGESTION_TYPE,\n\t\t\ttitle: item.title,\n\t\t\ticon: createElement( BlockIcon, { icon: item.icon } ),\n\t\t\ttypeLabel: __( 'Block' ),\n\t\t};\n\n\t\tif ( normalizeString( item.title ).startsWith( search ) ) {\n\t\t\tbefore.push( suggestion );\n\t\t} else {\n\t\t\tafter.push( suggestion );\n\t\t}\n\t}\n\n\treturn [ ...before, ...suggestions, ...after ];\n}\n\n/**\n * Lists the blocks a Navigation allows in a link's search results, and\n * inserts the one that is chosen.\n *\n * The allowed blocks are read when a search runs, not subscribed to, so an\n * open link UI does no work as the editor changes.\n *\n * @param {Object} options Hook options.\n * @param {string} options.clientId Client ID of the link or submenu.\n * @param {boolean} options.isEnabled Whether to list blocks at all.\n * @param {Function=} options.onBlockInsert Called with the inserted block by a\n * caller that tracks the new link,\n * such as the list view.\n * @param {Function=} options.onClose Closes the link UI.\n * @return {{ transformSuggestions: Function|undefined, insertBlockFromSuggestion: Function }}\n * The `transformSuggestions` to give LinkControl, and the handler for a chosen\n * block suggestion.\n */\nexport function useBlockSuggestions( {\n\tclientId,\n\tisEnabled,\n\tonBlockInsert,\n\tonClose,\n} ) {\n\tconst {\n\t\tgetBlockIndex,\n\t\tgetBlockOrder,\n\t\tgetBlockRootClientId,\n\t\tgetInserterItems,\n\t} = useSelect( blockEditorStore );\n\tconst { insertBlock, replaceBlock } = useDispatch( blockEditorStore );\n\n\tconst transformSuggestions = useCallback(\n\t\t( suggestions, { isInitialSuggestions, searchTerm } ) =>\n\t\t\tisInitialSuggestions\n\t\t\t\t? suggestions\n\t\t\t\t: addBlockSuggestions(\n\t\t\t\t\t\tsuggestions,\n\t\t\t\t\t\tgetInserterItems( getBlockRootClientId( clientId ) ),\n\t\t\t\t\t\tsearchTerm\n\t\t\t\t\t),\n\t\t[ clientId, getBlockRootClientId, getInserterItems ]\n\t);\n\n\tconst insertBlockFromSuggestion = ( itemId ) => {\n\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\tconst item = getInserterItems( rootClientId ).find(\n\t\t\t( { id } ) => id === itemId\n\t\t);\n\n\t\tif ( ! item ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst block = createBlock(\n\t\t\titem.name,\n\t\t\titem.initialAttributes,\n\t\t\tcreateBlocksFromInnerBlocksTemplate( item.innerBlocks )\n\t\t);\n\t\tconst index = getBlockIndex( clientId );\n\n\t\tif ( onBlockInsert ) {\n\t\t\t// A caller that tracks the new link, such as the list view, removes\n\t\t\t// it itself once told about the block, as with the \"Add block\" pane.\n\t\t\tinsertBlock( block, index, rootClientId, false );\n\t\t\tonBlockInsert( block );\n\t\t} else if ( getBlockOrder( clientId ).length ) {\n\t\t\t// A submenu keeps its items, so the block goes before it, where the\n\t\t\t// \"Add block\" pane puts it.\n\t\t\tinsertBlock( block, index, rootClientId );\n\t\t\tonClose?.();\n\t\t} else {\n\t\t\t// An empty link is replaced by the block.\n\t\t\treplaceBlock( clientId, block );\n\t\t}\n\n\t\tspeak(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: The title of the block that was added. */\n\t\t\t\t__( '%s block added.' ),\n\t\t\t\titem.title\n\t\t\t)\n\t\t);\n\t};\n\n\treturn {\n\t\ttransformSuggestions: isEnabled ? transformSuggestions : undefined,\n\t\tinsertBlockFromSuggestion,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4B;AAC5B,kBAAsB;AACtB,qBAA2C;AAC3C,kBAAuC;AACvC,oBAGO;AACP,0BAIO;AACP,yBAAuB;AAEvB,IAAM,EAAE,aAAa,gBAAgB,QAAI,2BAAQ,oBAAAA,WAAuB;AAKjE,IAAM,wBAAwB;AAY9B,SAAS,kBAAmB,YAAa;AAC/C,SACC,YAAY,SAAS,yBACrB,OAAO,WAAW,gBAAgB;AAEpC;AAMA,IAAM,uBAAuB,CAAE,sBAAuB;AAItD,IAAM,gBAAgB;AAAA,EACrB,EAAE,KAAK,CAAE,SAAU,KAAK,MAAM;AAAA,EAC9B,EAAE,KAAK,CAAE,SAAU,KAAK,SAAS;AAClC;AA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AAAA,IACH,CAAE,UAAU,sBAAsB,gBAAiB;AAAA,EACpD;AAEA,QAAM,4BAA4B,CAAE,WAAY;AAC/C,UAAM,eAAe,qBAAsB,QAAS;AACpD,UAAM,OAAO,iBAAkB,YAAa,EAAE;AAAA,MAC7C,CAAE,EAAE,GAAG,MAAO,OAAO;AAAA,IACtB;AAEA,QAAK,CAAE,MAAO;AACb;AAAA,IACD;AAEA,UAAM,YAAQ;AAAA,MACb,KAAK;AAAA,MACL,KAAK;AAAA,UACL,mDAAqC,KAAK,WAAY;AAAA,IACvD;AACA,UAAM,QAAQ,cAAe,QAAS;AAEtC,QAAK,eAAgB;AAGpB,kBAAa,OAAO,OAAO,cAAc,KAAM;AAC/C,oBAAe,KAAM;AAAA,IACtB,WAAY,cAAe,QAAS,EAAE,QAAS;AAG9C,kBAAa,OAAO,OAAO,YAAa;AACxC,gBAAU;AAAA,IACX,OAAO;AAEN,mBAAc,UAAU,KAAM;AAAA,IAC/B;AAEA;AAAA,UACC;AAAA;AAAA,YAEC,gBAAI,iBAAkB;AAAA,QACtB,KAAK;AAAA,MACN;AAAA,IACD;AAAA,EACD;AAEA,SAAO;AAAA,IACN,sBAAsB,YAAY,uBAAuB;AAAA,IACzD;AAAA,EACD;AACD;",
|
|
6
|
+
"names": ["blockEditorPrivateApis", "blockEditorStore"]
|
|
7
|
+
}
|
|
@@ -98,24 +98,24 @@ function computeBadges({
|
|
|
98
98
|
if (isExternal) {
|
|
99
99
|
badges.push({
|
|
100
100
|
label: (0, import_i18n.__)("External link"),
|
|
101
|
-
intent: "
|
|
101
|
+
intent: "none"
|
|
102
102
|
});
|
|
103
103
|
} else if (isHashLink(url)) {
|
|
104
104
|
badges.push({
|
|
105
105
|
label: (0, import_i18n.__)("Internal link"),
|
|
106
|
-
intent: "
|
|
106
|
+
intent: "none"
|
|
107
107
|
});
|
|
108
108
|
} else if (isHomepage(url, homeUrl)) {
|
|
109
109
|
badges.push({
|
|
110
110
|
label: (0, import_i18n.__)("Homepage"),
|
|
111
|
-
intent: "
|
|
111
|
+
intent: "none"
|
|
112
112
|
});
|
|
113
113
|
} else if (type && type !== "custom") {
|
|
114
|
-
badges.push({ label: capitalize(type), intent: "
|
|
114
|
+
badges.push({ label: capitalize(type), intent: "none" });
|
|
115
115
|
} else {
|
|
116
116
|
badges.push({
|
|
117
117
|
label: (0, import_i18n.__)("Page"),
|
|
118
|
-
intent: "
|
|
118
|
+
intent: "none"
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
121
|
}
|
|
@@ -126,18 +126,18 @@ function computeBadges({
|
|
|
126
126
|
(0, import_i18n.__)("Missing %s"),
|
|
127
127
|
type
|
|
128
128
|
),
|
|
129
|
-
intent: "
|
|
129
|
+
intent: "high"
|
|
130
130
|
});
|
|
131
131
|
} else if (!url) {
|
|
132
|
-
badges.push({ label: (0, import_i18n.__)("No link selected"), intent: "
|
|
132
|
+
badges.push({ label: (0, import_i18n.__)("No link selected"), intent: "high" });
|
|
133
133
|
} else if (entityStatus) {
|
|
134
134
|
const statusMap = {
|
|
135
|
-
publish: { label: (0, import_i18n.__)("Published"), intent: "
|
|
136
|
-
future: { label: (0, import_i18n.__)("Scheduled"), intent: "
|
|
137
|
-
draft: { label: (0, import_i18n.__)("Draft"), intent: "
|
|
138
|
-
pending: { label: (0, import_i18n.__)("Pending"), intent: "
|
|
139
|
-
private: { label: (0, import_i18n.__)("Private"), intent: "
|
|
140
|
-
trash: { label: (0, import_i18n.__)("
|
|
135
|
+
publish: { label: (0, import_i18n.__)("Published"), intent: "stable" },
|
|
136
|
+
future: { label: (0, import_i18n.__)("Scheduled"), intent: "informational" },
|
|
137
|
+
draft: { label: (0, import_i18n.__)("Draft"), intent: "low" },
|
|
138
|
+
pending: { label: (0, import_i18n.__)("Pending"), intent: "low" },
|
|
139
|
+
private: { label: (0, import_i18n.__)("Private"), intent: "informational" },
|
|
140
|
+
trash: { label: (0, import_i18n.__)("Trashed"), intent: "high" }
|
|
141
141
|
};
|
|
142
142
|
const badge = statusMap[entityStatus];
|
|
143
143
|
if (badge) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation-link/shared/use-link-preview.js"],
|
|
4
|
-
"sourcesContent": ["import { __, sprintf } from '@wordpress/i18n';\nimport { safeDecodeURI } from '@wordpress/url';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { unlock } from '../../lock-unlock';\n\nconst { useRemoteUrlData, isHashLink, isRelativePath } = unlock(\n\tblockEditorPrivateApis\n);\n\n/**\n * Capitalize the first letter of a string.\n *\n * @param {string} str - The string to capitalize\n * @return {string} Capitalized string\n */\nfunction capitalize( str ) {\n\treturn str.charAt( 0 ).toUpperCase() + str.slice( 1 );\n}\n\n/**\n * Check if a URL points to the site homepage.\n * Handles protocol (http/https) and trailing slash variations.\n * Does not match subdomains unless they are the site URL.\n *\n * @param {string} url - The URL to check\n * @param {string} homeUrl - The WordPress site URL\n * @return {boolean} True if url is the homepage\n */\nexport function isHomepage( url, homeUrl ) {\n\tif ( url === '/' ) {\n\t\treturn true;\n\t}\n\tif ( ! url || ! homeUrl ) {\n\t\treturn false;\n\t}\n\ttry {\n\t\tconst urlParsed = new URL( url, homeUrl );\n\t\tconst homeParsed = new URL( homeUrl );\n\n\t\t// Same host, i.e. sub.homepage.com or homepage.com\n\t\tif ( urlParsed.hostname !== homeParsed.hostname ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Path must match site root (normalize trailing slash)\n\t\tconst urlPath = urlParsed.pathname.replace( /\\/$/, '' );\n\t\tconst homePath = homeParsed.pathname.replace( /\\/$/, '' );\n\n\t\treturn urlPath === homePath;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Compute display URL - strips site URL if internal, shows full URL if external.\n *\n * @param {Object} options - Parameters object\n * @param {string} options.linkUrl - The URL to process\n * @param {string} options.homeUrl - The WordPress site URL (required for internal/external detection)\n * @return {Object} Object with displayUrl and isExternal flag\n */\nexport function computeDisplayUrl( { linkUrl, homeUrl } = {} ) {\n\tif ( ! linkUrl ) {\n\t\treturn { displayUrl: '', isExternal: false };\n\t}\n\n\tlet displayUrl = safeDecodeURI( linkUrl );\n\tlet isExternal = false;\n\n\t// Check hash links and relative paths first - these are always internal\n\tif ( isRelativePath( linkUrl ) || isHashLink( linkUrl ) ) {\n\t\treturn { displayUrl, isExternal: false };\n\t}\n\n\t// Try to parse as a full URL to determine if it's actually external\n\t// This must happen before trusting the type attribute\n\ttry {\n\t\tconst parsedUrl = new URL( linkUrl );\n\t\t// Compare by host (not origin) so http/https to same site both count as internal\n\t\tconst siteHost = new URL( homeUrl ).host;\n\n\t\tif ( parsedUrl.host === siteHost ) {\n\t\t\t// Show only the pathname (and search/hash if present)\n\t\t\tlet path = parsedUrl.pathname + parsedUrl.search + parsedUrl.hash;\n\t\t\t// Remove trailing slash\n\t\t\tif ( path.endsWith( '/' ) && path.length > 1 ) {\n\t\t\t\tpath = path.slice( 0, -1 );\n\t\t\t}\n\t\t\tdisplayUrl = path;\n\t\t} else {\n\t\t\t// Different host - this is an external link\n\t\t\tisExternal = true;\n\t\t}\n\t} catch {\n\t\t// URL parsing failed - treat as external (e.g. no homeUrl, or URL without protocol)\n\t\tisExternal = true;\n\t}\n\n\treturn { displayUrl, isExternal };\n}\n\n/**\n * Compute badges for the link preview.\n *\n * @param {Object} options - Options object\n * @param {string} options.url - Link URL\n * @param {string} options.homeUrl - WordPress site URL (for homepage detection)\n * @param {string} options.type - Entity type (page, post, etc.)\n * @param {boolean} options.isExternal - Whether link is external\n * @param {string} options.entityStatus - Entity status (publish, draft, etc.)\n * @param {boolean} options.hasBinding - Whether link has entity binding\n * @param {boolean} options.isEntityAvailable - Whether bound entity exists\n * @return {Array} Array of badge objects with label and intent\n */\nexport function computeBadges( {\n\turl,\n\thomeUrl,\n\ttype,\n\tisExternal,\n\tentityStatus,\n\thasBinding,\n\tisEntityAvailable,\n} ) {\n\tconst badges = [];\n\t// Kind badge\n\tif ( url ) {\n\t\tif ( isExternal ) {\n\t\t\tbadges.push( {\n\t\t\t\tlabel: __( 'External link' ),\n\t\t\t\tintent: '
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4B;AAC5B,iBAA8B;AAC9B,0BAAsD;AACtD,kBAA0B;AAC1B,uBAAuC;AACvC,yBAAuB;AAEvB,IAAM,EAAE,kBAAkB,YAAY,eAAe,QAAI;AAAA,EACxD,oBAAAA;AACD;AAQA,SAAS,WAAY,KAAM;AAC1B,SAAO,IAAI,OAAQ,CAAE,EAAE,YAAY,IAAI,IAAI,MAAO,CAAE;AACrD;AAWO,SAAS,WAAY,KAAK,SAAU;AAC1C,MAAK,QAAQ,KAAM;AAClB,WAAO;AAAA,EACR;AACA,MAAK,CAAE,OAAO,CAAE,SAAU;AACzB,WAAO;AAAA,EACR;AACA,MAAI;AACH,UAAM,YAAY,IAAI,IAAK,KAAK,OAAQ;AACxC,UAAM,aAAa,IAAI,IAAK,OAAQ;AAGpC,QAAK,UAAU,aAAa,WAAW,UAAW;AACjD,aAAO;AAAA,IACR;AAGA,UAAM,UAAU,UAAU,SAAS,QAAS,OAAO,EAAG;AACtD,UAAM,WAAW,WAAW,SAAS,QAAS,OAAO,EAAG;AAExD,WAAO,YAAY;AAAA,EACpB,QAAQ;AACP,WAAO;AAAA,EACR;AACD;AAUO,SAAS,kBAAmB,EAAE,SAAS,QAAQ,IAAI,CAAC,GAAI;AAC9D,MAAK,CAAE,SAAU;AAChB,WAAO,EAAE,YAAY,IAAI,YAAY,MAAM;AAAA,EAC5C;AAEA,MAAI,iBAAa,0BAAe,OAAQ;AACxC,MAAI,aAAa;AAGjB,MAAK,eAAgB,OAAQ,KAAK,WAAY,OAAQ,GAAI;AACzD,WAAO,EAAE,YAAY,YAAY,MAAM;AAAA,EACxC;AAIA,MAAI;AACH,UAAM,YAAY,IAAI,IAAK,OAAQ;AAEnC,UAAM,WAAW,IAAI,IAAK,OAAQ,EAAE;AAEpC,QAAK,UAAU,SAAS,UAAW;AAElC,UAAI,OAAO,UAAU,WAAW,UAAU,SAAS,UAAU;AAE7D,UAAK,KAAK,SAAU,GAAI,KAAK,KAAK,SAAS,GAAI;AAC9C,eAAO,KAAK,MAAO,GAAG,EAAG;AAAA,MAC1B;AACA,mBAAa;AAAA,IACd,OAAO;AAEN,mBAAa;AAAA,IACd;AAAA,EACD,QAAQ;AAEP,iBAAa;AAAA,EACd;AAEA,SAAO,EAAE,YAAY,WAAW;AACjC;
|
|
4
|
+
"sourcesContent": ["import { __, sprintf } from '@wordpress/i18n';\nimport { safeDecodeURI } from '@wordpress/url';\nimport { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { unlock } from '../../lock-unlock';\n\nconst { useRemoteUrlData, isHashLink, isRelativePath } = unlock(\n\tblockEditorPrivateApis\n);\n\n/**\n * Capitalize the first letter of a string.\n *\n * @param {string} str - The string to capitalize\n * @return {string} Capitalized string\n */\nfunction capitalize( str ) {\n\treturn str.charAt( 0 ).toUpperCase() + str.slice( 1 );\n}\n\n/**\n * Check if a URL points to the site homepage.\n * Handles protocol (http/https) and trailing slash variations.\n * Does not match subdomains unless they are the site URL.\n *\n * @param {string} url - The URL to check\n * @param {string} homeUrl - The WordPress site URL\n * @return {boolean} True if url is the homepage\n */\nexport function isHomepage( url, homeUrl ) {\n\tif ( url === '/' ) {\n\t\treturn true;\n\t}\n\tif ( ! url || ! homeUrl ) {\n\t\treturn false;\n\t}\n\ttry {\n\t\tconst urlParsed = new URL( url, homeUrl );\n\t\tconst homeParsed = new URL( homeUrl );\n\n\t\t// Same host, i.e. sub.homepage.com or homepage.com\n\t\tif ( urlParsed.hostname !== homeParsed.hostname ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Path must match site root (normalize trailing slash)\n\t\tconst urlPath = urlParsed.pathname.replace( /\\/$/, '' );\n\t\tconst homePath = homeParsed.pathname.replace( /\\/$/, '' );\n\n\t\treturn urlPath === homePath;\n\t} catch {\n\t\treturn false;\n\t}\n}\n\n/**\n * Compute display URL - strips site URL if internal, shows full URL if external.\n *\n * @param {Object} options - Parameters object\n * @param {string} options.linkUrl - The URL to process\n * @param {string} options.homeUrl - The WordPress site URL (required for internal/external detection)\n * @return {Object} Object with displayUrl and isExternal flag\n */\nexport function computeDisplayUrl( { linkUrl, homeUrl } = {} ) {\n\tif ( ! linkUrl ) {\n\t\treturn { displayUrl: '', isExternal: false };\n\t}\n\n\tlet displayUrl = safeDecodeURI( linkUrl );\n\tlet isExternal = false;\n\n\t// Check hash links and relative paths first - these are always internal\n\tif ( isRelativePath( linkUrl ) || isHashLink( linkUrl ) ) {\n\t\treturn { displayUrl, isExternal: false };\n\t}\n\n\t// Try to parse as a full URL to determine if it's actually external\n\t// This must happen before trusting the type attribute\n\ttry {\n\t\tconst parsedUrl = new URL( linkUrl );\n\t\t// Compare by host (not origin) so http/https to same site both count as internal\n\t\tconst siteHost = new URL( homeUrl ).host;\n\n\t\tif ( parsedUrl.host === siteHost ) {\n\t\t\t// Show only the pathname (and search/hash if present)\n\t\t\tlet path = parsedUrl.pathname + parsedUrl.search + parsedUrl.hash;\n\t\t\t// Remove trailing slash\n\t\t\tif ( path.endsWith( '/' ) && path.length > 1 ) {\n\t\t\t\tpath = path.slice( 0, -1 );\n\t\t\t}\n\t\t\tdisplayUrl = path;\n\t\t} else {\n\t\t\t// Different host - this is an external link\n\t\t\tisExternal = true;\n\t\t}\n\t} catch {\n\t\t// URL parsing failed - treat as external (e.g. no homeUrl, or URL without protocol)\n\t\tisExternal = true;\n\t}\n\n\treturn { displayUrl, isExternal };\n}\n\n/**\n * Compute badges for the link preview.\n *\n * @param {Object} options - Options object\n * @param {string} options.url - Link URL\n * @param {string} options.homeUrl - WordPress site URL (for homepage detection)\n * @param {string} options.type - Entity type (page, post, etc.)\n * @param {boolean} options.isExternal - Whether link is external\n * @param {string} options.entityStatus - Entity status (publish, draft, etc.)\n * @param {boolean} options.hasBinding - Whether link has entity binding\n * @param {boolean} options.isEntityAvailable - Whether bound entity exists\n * @return {Array} Array of badge objects with label and `@wordpress/ui`\n * `Badge` intent\n */\nexport function computeBadges( {\n\turl,\n\thomeUrl,\n\ttype,\n\tisExternal,\n\tentityStatus,\n\thasBinding,\n\tisEntityAvailable,\n} ) {\n\tconst badges = [];\n\t// Kind badge\n\tif ( url ) {\n\t\tif ( isExternal ) {\n\t\t\tbadges.push( {\n\t\t\t\tlabel: __( 'External link' ),\n\t\t\t\tintent: 'none',\n\t\t\t} );\n\t\t} else if ( isHashLink( url ) ) {\n\t\t\t// Hash links should be detected before type check\n\t\t\t// because they're not entity links even if type is set\n\t\t\tbadges.push( {\n\t\t\t\tlabel: __( 'Internal link' ),\n\t\t\t\tintent: 'none',\n\t\t\t} );\n\t\t} else if ( isHomepage( url, homeUrl ) ) {\n\t\t\tbadges.push( {\n\t\t\t\tlabel: __( 'Homepage' ),\n\t\t\t\tintent: 'none',\n\t\t\t} );\n\t\t} else if ( type && type !== 'custom' ) {\n\t\t\t// Show entity type badge (page, post, category, etc.)\n\t\t\t// but not 'custom' since that's just a manual link\n\t\t\tbadges.push( { label: capitalize( type ), intent: 'none' } );\n\t\t} else {\n\t\t\t// Internal link (not external, not hash, not entity)\n\t\t\tbadges.push( {\n\t\t\t\tlabel: __( 'Page' ),\n\t\t\t\tintent: 'none',\n\t\t\t} );\n\t\t}\n\t}\n\n\t// Status badge\n\tif ( hasBinding && ! isEntityAvailable ) {\n\t\tbadges.push( {\n\t\t\tlabel: sprintf(\n\t\t\t\t/* translators: %s is the entity type (e.g., \"page\", \"post\", \"category\") */\n\t\t\t\t__( 'Missing %s' ),\n\t\t\t\ttype\n\t\t\t),\n\t\t\tintent: 'high',\n\t\t} );\n\t} else if ( ! url ) {\n\t\tbadges.push( { label: __( 'No link selected' ), intent: 'high' } );\n\t} else if ( entityStatus ) {\n\t\tconst statusMap = {\n\t\t\tpublish: { label: __( 'Published' ), intent: 'stable' },\n\t\t\tfuture: { label: __( 'Scheduled' ), intent: 'informational' },\n\t\t\tdraft: { label: __( 'Draft' ), intent: 'low' },\n\t\t\tpending: { label: __( 'Pending' ), intent: 'low' },\n\t\t\tprivate: { label: __( 'Private' ), intent: 'informational' },\n\t\t\ttrash: { label: __( 'Trashed' ), intent: 'high' },\n\t\t};\n\t\tconst badge = statusMap[ entityStatus ];\n\t\tif ( badge ) {\n\t\t\tbadges.push( badge );\n\t\t}\n\t}\n\n\treturn badges;\n}\n\n/**\n * Returns an entity record's display title: the rendered title, \"(no title)\"\n * for an untitled entity, or the record's name.\n *\n * @param {Object} entityRecord The entity record.\n * @return {string|undefined} The display title.\n */\nfunction getEntityTitle( entityRecord ) {\n\tconst title = entityRecord?.title;\n\n\t// Some entity types use a plain string for the title.\n\tif ( typeof title === 'string' ) {\n\t\treturn title;\n\t}\n\n\t// Posts and pages expose `title` as a { raw, rendered } object.\n\tif ( title && 'rendered' in title ) {\n\t\treturn title.rendered || __( '(no title)' );\n\t}\n\n\treturn entityRecord?.name;\n}\n\n/**\n * Hook to compute link preview data for display.\n *\n * This hook takes raw link data and entity information and computes\n * presentation-ready preview data including formatted title, URL, and badges.\n *\n * @param {Object} options - Options object\n * @param {string} options.url - Link URL\n * @param {string} options.type - Entity type (page, post, etc.)\n * @param {Object} options.entityRecord - Entity record\n * @param {boolean} options.hasBinding - Whether link has entity binding\n * @param {boolean} options.isEntityAvailable - Whether bound entity exists\n * @return {Object} Preview data object with title, url, image, and badges\n */\nexport function useLinkPreview( {\n\turl,\n\tentityRecord,\n\ttype,\n\thasBinding,\n\tisEntityAvailable,\n} ) {\n\t// Get the WordPress homepage URL from settings\n\tconst homeUrl = useSelect( ( select ) => {\n\t\treturn select( coreDataStore ).getEntityRecord(\n\t\t\t'root',\n\t\t\t'__unstableBase'\n\t\t)?.home;\n\t}, [] );\n\n\tconst title = getEntityTitle( entityRecord );\n\n\t// Fetch rich URL data if we don't have a title. Internal links should have passed a title.\n\tconst { richData } = useRemoteUrlData( title ? null : url );\n\n\t// Compute display URL and external flag\n\tconst { displayUrl, isExternal } = computeDisplayUrl( {\n\t\tlinkUrl: url,\n\t\thomeUrl,\n\t} );\n\n\tconst image = useSelect(\n\t\t( select ) => {\n\t\t\t// Only fetch for post-type entities with featured media\n\t\t\tif ( ! entityRecord?.featured_media ) {\n\t\t\t\treturn null;\n\t\t\t}\n\n\t\t\tconst { getEntityRecord } = select( coreDataStore );\n\n\t\t\t// Get the media entity to fetch the image URL\n\t\t\tconst media = getEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'attachment',\n\t\t\t\tentityRecord.featured_media\n\t\t\t);\n\n\t\t\t// Return the thumbnail or medium size URL, fallback to source_url\n\t\t\treturn (\n\t\t\t\tmedia?.media_details?.sizes?.thumbnail?.source_url ||\n\t\t\t\tmedia?.media_details?.sizes?.medium?.source_url ||\n\t\t\t\tmedia?.source_url ||\n\t\t\t\tnull\n\t\t\t);\n\t\t},\n\t\t[ entityRecord?.featured_media ]\n\t);\n\n\t// Compute badges\n\tconst badges = computeBadges( {\n\t\turl,\n\t\thomeUrl,\n\t\ttype,\n\t\tisExternal,\n\t\tentityStatus: entityRecord?.status,\n\t\thasBinding,\n\t\tisEntityAvailable,\n\t} );\n\n\t// Get display title - use provided title, fallback to rich data, or URL\n\tconst displayTitle = url\n\t\t? title || richData?.title || safeDecodeURI( url )\n\t\t: __( 'Add link' );\n\n\treturn {\n\t\ttitle: displayTitle,\n\t\turl: displayUrl,\n\t\timage,\n\t\tbadges,\n\t};\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAA4B;AAC5B,iBAA8B;AAC9B,0BAAsD;AACt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YAAM,QAAQ;AAAA,QACb;AAAA,QACA;AAAA,QACA,aAAa;AAAA,MACd;AAGA,aACC,OAAO,eAAe,OAAO,WAAW,cACxC,OAAO,eAAe,OAAO,QAAQ,cACrC,OAAO,cACP;AAAA,IAEF;AAAA,IACA,CAAE,cAAc,cAAe;AAAA,EAChC;AAGA,QAAM,SAAS,cAAe;AAAA,IAC7B;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc,cAAc;AAAA,IAC5B;AAAA,IACA;AAAA,EACD,CAAE;AAGF,QAAM,eAAe,MAClB,SAAS,UAAU,aAAS,0BAAe,GAAI,QAC/C,gBAAI,UAAW;AAElB,SAAO;AAAA,IACN,OAAO;AAAA,IACP,KAAK;AAAA,IACL;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
6
|
"names": ["blockEditorPrivateApis", "coreDataStore"]
|
|
7
7
|
}
|
|
@@ -83,10 +83,16 @@
|
|
|
83
83
|
"fontSize": true
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
|
+
"shadow": {
|
|
87
|
+
"__experimentalSkipSerialization": true
|
|
88
|
+
},
|
|
86
89
|
"interactivity": {
|
|
87
90
|
"clientNavigation": true
|
|
88
91
|
}
|
|
89
92
|
},
|
|
93
|
+
"selectors": {
|
|
94
|
+
"shadow": ".wp-block-navigation-submenu > .wp-block-navigation__submenu-container"
|
|
95
|
+
},
|
|
90
96
|
"editorStyle": "wp-block-navigation-submenu-editor",
|
|
91
97
|
"style": "wp-block-navigation-submenu"
|
|
92
98
|
}
|
|
@@ -192,8 +192,16 @@ function NavigationSubmenuEdit({
|
|
|
192
192
|
const allowedBlocks = parentCount >= maxNestingLevel ? ALLOWED_BLOCKS.filter(
|
|
193
193
|
(blockName) => blockName !== "core/navigation-submenu"
|
|
194
194
|
) : ALLOWED_BLOCKS;
|
|
195
|
+
const shadowProps = (0, import_block_editor.__experimentalGetShadowClassesAndStyles)(attributes);
|
|
195
196
|
const navigationChildBlockProps = (0, import_utils.getNavigationChildBlockProps)(innerBlocksColors);
|
|
196
|
-
const
|
|
197
|
+
const submenuBlockProps = {
|
|
198
|
+
...navigationChildBlockProps,
|
|
199
|
+
style: {
|
|
200
|
+
...navigationChildBlockProps.style,
|
|
201
|
+
...shadowProps.style
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
const innerBlocksProps = (0, import_block_editor.useInnerBlocksProps)(submenuBlockProps, {
|
|
197
205
|
allowedBlocks,
|
|
198
206
|
defaultBlock: import_constants.DEFAULT_BLOCK,
|
|
199
207
|
directInsert: true,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/navigation-submenu/edit.jsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tInspectorControls,\n\tuseInnerBlocksProps,\n\tRichText,\n\tuseBlockProps,\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { link as linkIcon, removeSubmenu } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\nimport { ItemSubmenuIcon } from './icons';\nimport {\n\tControls,\n\tLinkUI,\n\tuseEntityBinding,\n\tuseHandleLinkChange,\n\tuseIsInvalidLink,\n\tInvalidDraftDisplay,\n\tuseEnableLinkStatusValidation,\n\tuseIsDraggingWithin,\n\tselectLabelText,\n} from '../navigation-link/shared';\nimport {\n\tgetColors,\n\tgetNavigationChildBlockProps,\n} from '../navigation/edit/utils';\nimport { DEFAULT_BLOCK } from '../navigation/constants';\n\nconst ALLOWED_BLOCKS = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n\t'core/page-list',\n\t'core/loginout',\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 */\n\nexport default function NavigationSubmenuEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { label, url, description, kind, type, id } = attributes;\n\n\tconst { showSubmenuIcon, maxNestingLevel, submenuVisibility } = context;\n\tconst blockEditingMode = useBlockEditingMode();\n\n\t// Force click-only behavior in contentOnly mode to prevent hover dropdowns\n\tconst openSubmenusOnClick =\n\t\tblockEditingMode !== 'default' ? true : submenuVisibility === 'click';\n\n\t// URL binding logic\n\tconst { hasUrlBinding, isBoundEntityAvailable, entityRecord } =\n\t\tuseEntityBinding( {\n\t\t\tclientId,\n\t\t\tattributes,\n\t\t} );\n\n\tconst handleLinkChange = useHandleLinkChange( {\n\t\tclientId,\n\t\tattributes,\n\t\tsetAttributes,\n\t\tallowTextUpdate: true,\n\t} );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent, replaceBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add text…' );\n\tconst ref = useRef();\n\n\tconst {\n\t\tparentCount,\n\t\tisParentOfSelectedBlock,\n\t\tisImmediateParentOfSelectedBlock,\n\t\thasChildren,\n\t\tselectedBlockHasChildren,\n\t\tonlyDescendantIsEmptyLink,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetBlock,\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet _onlyDescendantIsEmptyLink;\n\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\tconst selectedBlockChildren = getBlockOrder( selectedBlockId );\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 ( selectedBlockChildren?.length === 1 ) {\n\t\t\t\tconst singleBlock = getBlock( selectedBlockChildren[ 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\tparentCount: getBlockParentsByBlockName(\n\t\t\t\t\tclientId,\n\t\t\t\t\t'core/navigation-submenu'\n\t\t\t\t).length,\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\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tselectedBlockHasChildren: !! selectedBlockChildren?.length,\n\t\t\t\tonlyDescendantIsEmptyLink: _onlyDescendantIsEmptyLink,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst validateLinkStatus = useEnableLinkStatusValidation( clientId );\n\n\tconst prevHasChildren = usePrevious( hasChildren );\n\n\t// Check if the submenu's parent link is invalid or draft\n\tconst [ isInvalid, isDraft ] = useIsInvalidLink(\n\t\tkind,\n\t\ttype,\n\t\tid,\n\t\tvalidateLinkStatus\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/**\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( ref );\n\t\t\t}\n\t\t}\n\t}, [ url ] );\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, parentCount > 0 );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If we don't stop propagation, this event bubbles up to the parent submenu item\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( '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': hasChildren,\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( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t\t'open-on-click': openSubmenusOnClick,\n\t\t\t'open-always': submenuVisibility === 'always',\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 =\n\t\tparentCount >= maxNestingLevel\n\t\t\t? ALLOWED_BLOCKS.filter(\n\t\t\t\t\t( blockName ) => blockName !== 'core/navigation-submenu'\n\t\t\t\t)\n\t\t\t: ALLOWED_BLOCKS;\n\n\tconst navigationChildBlockProps =\n\t\tgetNavigationChildBlockProps( innerBlocksColors );\n\tconst innerBlocksProps = useInnerBlocksProps( navigationChildBlockProps, {\n\t\tallowedBlocks,\n\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\tdirectInsert: true,\n\n\t\t// Ensure block toolbar is not too far removed from item\n\t\t// being edited.\n\t\t// see: https://github.com/WordPress/gutenberg/pull/34615.\n\t\t__experimentalCaptureToolbars: true,\n\n\t\trenderAppender:\n\t\t\tisSelected ||\n\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t! selectedBlockHasChildren ) ||\n\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\thasChildren\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: false,\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\tuseEffect( () => {\n\t\t// If block becomes empty, transform to Navigation Link.\n\t\tif ( ! hasChildren && prevHasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToLink();\n\t\t}\n\t}, [ hasChildren, prevHasChildren ] );\n\n\tconst canConvertToLink =\n\t\t! selectedBlockHasChildren || onlyDescendantIsEmptyLink;\n\n\treturn (\n\t\t<>\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={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t} }\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\tdisabled={ ! canConvertToLink }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"content\">\n\t\t\t\t<Controls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisLinkEditable={ ! openSubmenusOnClick }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<ParentElement className=\"wp-block-navigation-item__content\">\n\t\t\t\t\t{ ! isInvalid && ! isDraft && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { label: labelValue } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\t\taria-label={ __( 'Navigation link text' ) }\n\t\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\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\t{ description && (\n\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t\t\t</span>\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{ ( isInvalid || isDraft ) && (\n\t\t\t\t\t\t<InvalidDraftDisplay\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\tisInvalid={ isInvalid }\n\t\t\t\t\t\t\tisDraft={ isDraft }\n\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\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<LinkUI\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tentity={ {\n\t\t\t\t\t\t\t\tentityRecord,\n\t\t\t\t\t\t\t\thasBinding: hasUrlBinding,\n\t\t\t\t\t\t\t\tisEntityAvailable: isBoundEntityAvailable,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { url: '' } );\n\t\t\t\t\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonChange={ handleLinkChange }\n\t\t\t\t\t\t/>\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</>\n\t);\n}\n"],
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAuC;AACvC,wBAA4C;AAC5C,sBAAiD;AACjD,kBAAmB;AACnB,
|
|
6
|
-
"names": ["import_icons", "blockEditorStore", "clsx", "linkIcon"]
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { ToolbarButton, ToolbarGroup } from '@wordpress/components';\nimport { displayShortcut, isKeyboardEvent } from '@wordpress/keycodes';\nimport { __ } from '@wordpress/i18n';\nimport {\n\tBlockControls,\n\tInnerBlocks,\n\tInspectorControls,\n\tuseInnerBlocksProps,\n\tRichText,\n\tuseBlockProps,\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n\tgetColorClassName,\n\t__experimentalGetShadowClassesAndStyles as getShadowClassesAndStyles,\n} from '@wordpress/block-editor';\nimport { isURL, prependHTTP } from '@wordpress/url';\nimport { useState, useEffect, useRef } from '@wordpress/element';\nimport { link as linkIcon, removeSubmenu } from '@wordpress/icons';\nimport { speak } from '@wordpress/a11y';\nimport { createBlock } from '@wordpress/blocks';\nimport { useMergeRefs, usePrevious } from '@wordpress/compose';\nimport { ItemSubmenuIcon } from './icons';\nimport {\n\tControls,\n\tLinkUI,\n\tuseEntityBinding,\n\tuseHandleLinkChange,\n\tuseIsInvalidLink,\n\tInvalidDraftDisplay,\n\tuseEnableLinkStatusValidation,\n\tuseIsDraggingWithin,\n\tselectLabelText,\n} from '../navigation-link/shared';\nimport {\n\tgetColors,\n\tgetNavigationChildBlockProps,\n} from '../navigation/edit/utils';\nimport { DEFAULT_BLOCK } from '../navigation/constants';\n\nconst ALLOWED_BLOCKS = [\n\t'core/navigation-link',\n\t'core/navigation-submenu',\n\t'core/page-list',\n\t'core/loginout',\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 */\n\nexport default function NavigationSubmenuEdit( {\n\tattributes,\n\tisSelected,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tcontext,\n\tclientId,\n} ) {\n\tconst { label, url, description, kind, type, id } = attributes;\n\n\tconst { showSubmenuIcon, maxNestingLevel, submenuVisibility } = context;\n\tconst blockEditingMode = useBlockEditingMode();\n\n\t// Force click-only behavior in contentOnly mode to prevent hover dropdowns\n\tconst openSubmenusOnClick =\n\t\tblockEditingMode !== 'default' ? true : submenuVisibility === 'click';\n\n\t// URL binding logic\n\tconst { hasUrlBinding, isBoundEntityAvailable, entityRecord } =\n\t\tuseEntityBinding( {\n\t\t\tclientId,\n\t\t\tattributes,\n\t\t} );\n\n\tconst handleLinkChange = useHandleLinkChange( {\n\t\tclientId,\n\t\tattributes,\n\t\tsetAttributes,\n\t\tallowTextUpdate: true,\n\t} );\n\n\tconst { __unstableMarkNextChangeAsNotPersistent, replaceBlock } =\n\t\tuseDispatch( blockEditorStore );\n\tconst [ isLinkOpen, setIsLinkOpen ] = useState( false );\n\t// Use internal state instead of a ref to make sure that the component\n\t// re-renders when the popover's anchor updates.\n\tconst [ popoverAnchor, setPopoverAnchor ] = useState( null );\n\tconst listItemRef = useRef( null );\n\tconst isDraggingWithin = useIsDraggingWithin( listItemRef );\n\tconst itemLabelPlaceholder = __( 'Add text…' );\n\tconst ref = useRef();\n\n\tconst {\n\t\tparentCount,\n\t\tisParentOfSelectedBlock,\n\t\tisImmediateParentOfSelectedBlock,\n\t\thasChildren,\n\t\tselectedBlockHasChildren,\n\t\tonlyDescendantIsEmptyLink,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\thasSelectedInnerBlock,\n\t\t\t\tgetSelectedBlockClientId,\n\t\t\t\tgetBlockParentsByBlockName,\n\t\t\t\tgetBlock,\n\t\t\t\tgetBlockCount,\n\t\t\t\tgetBlockOrder,\n\t\t\t} = select( blockEditorStore );\n\n\t\t\tlet _onlyDescendantIsEmptyLink;\n\n\t\t\tconst selectedBlockId = getSelectedBlockClientId();\n\n\t\t\tconst selectedBlockChildren = getBlockOrder( selectedBlockId );\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 ( selectedBlockChildren?.length === 1 ) {\n\t\t\t\tconst singleBlock = getBlock( selectedBlockChildren[ 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\tparentCount: getBlockParentsByBlockName(\n\t\t\t\t\tclientId,\n\t\t\t\t\t'core/navigation-submenu'\n\t\t\t\t).length,\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\thasChildren: !! getBlockCount( clientId ),\n\t\t\t\tselectedBlockHasChildren: !! selectedBlockChildren?.length,\n\t\t\t\tonlyDescendantIsEmptyLink: _onlyDescendantIsEmptyLink,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst validateLinkStatus = useEnableLinkStatusValidation( clientId );\n\n\tconst prevHasChildren = usePrevious( hasChildren );\n\n\t// Check if the submenu's parent link is invalid or draft\n\tconst [ isInvalid, isDraft ] = useIsInvalidLink(\n\t\tkind,\n\t\ttype,\n\t\tid,\n\t\tvalidateLinkStatus\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/**\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( ref );\n\t\t\t}\n\t\t}\n\t}, [ url ] );\n\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t} = getColors( context, parentCount > 0 );\n\n\tfunction onKeyDown( event ) {\n\t\tif ( isKeyboardEvent.primary( event, 'k' ) ) {\n\t\t\t// Required to prevent the command center from opening,\n\t\t\t// as it shares the CMD+K shortcut.\n\t\t\t// See https://github.com/WordPress/gutenberg/pull/59845.\n\t\t\tevent.preventDefault();\n\t\t\t// If we don't stop propagation, this event bubbles up to the parent submenu item\n\t\t\tevent.stopPropagation();\n\t\t\tsetIsLinkOpen( true );\n\t\t}\n\t}\n\n\tconst blockProps = useBlockProps( {\n\t\tref: useMergeRefs( [ setPopoverAnchor, listItemRef ] ),\n\t\tclassName: clsx( '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': hasChildren,\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( 'background-color', backgroundColor ) ]:\n\t\t\t\t!! backgroundColor,\n\t\t\t'open-on-click': openSubmenusOnClick,\n\t\t\t'open-always': submenuVisibility === 'always',\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 =\n\t\tparentCount >= maxNestingLevel\n\t\t\t? ALLOWED_BLOCKS.filter(\n\t\t\t\t\t( blockName ) => blockName !== 'core/navigation-submenu'\n\t\t\t\t)\n\t\t\t: ALLOWED_BLOCKS;\n\n\t// Shadow serialization is skipped so the shadow lands on the dropdown, not the item.\n\tconst shadowProps = getShadowClassesAndStyles( attributes );\n\tconst navigationChildBlockProps =\n\t\tgetNavigationChildBlockProps( innerBlocksColors );\n\tconst submenuBlockProps = {\n\t\t...navigationChildBlockProps,\n\t\tstyle: {\n\t\t\t...navigationChildBlockProps.style,\n\t\t\t...shadowProps.style,\n\t\t},\n\t};\n\tconst innerBlocksProps = useInnerBlocksProps( submenuBlockProps, {\n\t\tallowedBlocks,\n\t\tdefaultBlock: DEFAULT_BLOCK,\n\t\tdirectInsert: true,\n\n\t\t// Ensure block toolbar is not too far removed from item\n\t\t// being edited.\n\t\t// see: https://github.com/WordPress/gutenberg/pull/34615.\n\t\t__experimentalCaptureToolbars: true,\n\n\t\trenderAppender:\n\t\t\tisSelected ||\n\t\t\t( isImmediateParentOfSelectedBlock &&\n\t\t\t\t! selectedBlockHasChildren ) ||\n\t\t\t// Show the appender while dragging to allow inserting element between item and the appender.\n\t\t\thasChildren\n\t\t\t\t? InnerBlocks.ButtonBlockAppender\n\t\t\t\t: false,\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\tuseEffect( () => {\n\t\t// If block becomes empty, transform to Navigation Link.\n\t\tif ( ! hasChildren && prevHasChildren ) {\n\t\t\t// This side-effect should not create an undo level as those should\n\t\t\t// only be created via user interactions.\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\ttransformToLink();\n\t\t}\n\t}, [ hasChildren, prevHasChildren ] );\n\n\tconst canConvertToLink =\n\t\t! selectedBlockHasChildren || onlyDescendantIsEmptyLink;\n\n\treturn (\n\t\t<>\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={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\n\t\t\t\t\t\t\t} }\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\tdisabled={ ! canConvertToLink }\n\t\t\t\t\t/>\n\t\t\t\t</ToolbarGroup>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls group=\"content\">\n\t\t\t\t<Controls\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tisLinkEditable={ ! openSubmenusOnClick }\n\t\t\t\t/>\n\t\t\t</InspectorControls>\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<ParentElement className=\"wp-block-navigation-item__content\">\n\t\t\t\t\t{ ! isInvalid && ! isDraft && (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<RichText\n\t\t\t\t\t\t\t\tref={ ref }\n\t\t\t\t\t\t\t\tidentifier=\"label\"\n\t\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\n\t\t\t\t\t\t\t\tvalue={ label }\n\t\t\t\t\t\t\t\tonChange={ ( labelValue ) =>\n\t\t\t\t\t\t\t\t\tsetAttributes( { label: labelValue } )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t\t\t\t\taria-label={ __( 'Navigation link text' ) }\n\t\t\t\t\t\t\t\tplaceholder={ itemLabelPlaceholder }\n\t\t\t\t\t\t\t\twithoutInteractiveFormatting\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tif ( ! openSubmenusOnClick && ! url ) {\n\t\t\t\t\t\t\t\t\t\tsetIsLinkOpen( true );\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\t{ description && (\n\t\t\t\t\t\t\t\t<span className=\"wp-block-navigation-item__description\">\n\t\t\t\t\t\t\t\t\t{ description }\n\t\t\t\t\t\t\t\t</span>\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{ ( isInvalid || isDraft ) && (\n\t\t\t\t\t\t<InvalidDraftDisplay\n\t\t\t\t\t\t\tlabel={ label }\n\t\t\t\t\t\t\tisInvalid={ isInvalid }\n\t\t\t\t\t\t\tisDraft={ isDraft }\n\t\t\t\t\t\t\tclassName=\"wp-block-navigation-item__label\"\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<LinkUI\n\t\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\t\tlink={ attributes }\n\t\t\t\t\t\t\tentity={ {\n\t\t\t\t\t\t\t\tentityRecord,\n\t\t\t\t\t\t\t\thasBinding: hasUrlBinding,\n\t\t\t\t\t\t\t\tisEntityAvailable: isBoundEntityAvailable,\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonClose={ () => {\n\t\t\t\t\t\t\t\tsetIsLinkOpen( false );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tanchor={ popoverAnchor }\n\t\t\t\t\t\t\tonRemove={ () => {\n\t\t\t\t\t\t\t\tsetAttributes( { url: '' } );\n\t\t\t\t\t\t\t\tspeak( __( 'Link removed.' ), 'assertive' );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\tonChange={ handleLinkChange }\n\t\t\t\t\t\t/>\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</>\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAAuC;AACvC,wBAA4C;AAC5C,sBAAiD;AACjD,kBAAmB;AACnB,0BAWO;AACP,iBAAmC;AACnC,qBAA4C;AAC5C,mBAAgD;AAChD,kBAAsB;AACtB,oBAA4B;AAC5B,qBAA0C;AAC1C,IAAAA,gBAAgC;AAChC,oBAUO;AACP,mBAGO;AACP,uBAA8B;AAqR1B;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,CAAE,uBAAuB,CAAE,KAAM;AACrC,gCAAe,IAAK;AAAA,gBACrB;AAAA,cACD;AAAA;AAAA,UACD;AAAA,UACE,eACD,4CAAC,UAAK,WAAU,yCACb,uBACH;AAAA,WAEF;AAAA,SAEG,aAAa,YAChB;AAAA,UAAC;AAAA;AAAA,YACA;AAAA,YACA;AAAA,YACA;AAAA,YACA,WAAU;AAAA;AAAA,QACX;AAAA,QAEC,CAAE,uBAAuB,cAC1B;AAAA,UAAC;AAAA;AAAA,YACA;AAAA,YACA,MAAO;AAAA,YACP,QAAS;AAAA,cACR;AAAA,cACA,YAAY;AAAA,cACZ,mBAAmB;AAAA,YACpB;AAAA,YACA,SAAU,MAAM;AACf,4BAAe,KAAM;AAAA,YACtB;AAAA,YACA,QAAS;AAAA,YACT,UAAW,MAAM;AAChB,4BAAe,EAAE,KAAK,GAAG,CAAE;AAC3B,yCAAO,gBAAI,eAAgB,GAAG,WAAY;AAAA,YAC3C;AAAA,YACA,UAAW;AAAA;AAAA,QACZ;AAAA,SAEF;AAAA,OACI,mBAAmB,wBACtB,4CAAC,UAAK,WAAU,qCACf,sDAAC,iCAAgB,GAClB;AAAA,MAED,4CAAC,SAAM,GAAG,kBAAmB;AAAA,OAC9B;AAAA,KACD;AAEF;",
|
|
6
|
+
"names": ["import_icons", "blockEditorStore", "clsx", "getShadowClassesAndStyles", "linkIcon"]
|
|
7
7
|
}
|
|
@@ -51,6 +51,15 @@
|
|
|
51
51
|
"interactivity": {
|
|
52
52
|
"clientNavigation": true
|
|
53
53
|
},
|
|
54
|
+
"background": {
|
|
55
|
+
"backgroundImage": true,
|
|
56
|
+
"backgroundSize": true,
|
|
57
|
+
"gradient": true,
|
|
58
|
+
"__experimentalDefaultControls": {
|
|
59
|
+
"backgroundImage": true,
|
|
60
|
+
"gradient": true
|
|
61
|
+
}
|
|
62
|
+
},
|
|
54
63
|
"color": {
|
|
55
64
|
"text": true,
|
|
56
65
|
"background": true,
|
|
@@ -76,6 +85,11 @@
|
|
|
76
85
|
"margin": false
|
|
77
86
|
}
|
|
78
87
|
},
|
|
88
|
+
"shadow": true,
|
|
89
|
+
"dimensions": {
|
|
90
|
+
"minHeight": true,
|
|
91
|
+
"minWidth": true
|
|
92
|
+
},
|
|
79
93
|
"contentRole": true
|
|
80
94
|
},
|
|
81
95
|
"editorStyle": "wp-block-page-list-editor",
|
package/build/paragraph/edit.cjs
CHANGED
|
@@ -42,7 +42,6 @@ var import_blocks = require("@wordpress/blocks");
|
|
|
42
42
|
var import_icons = require("@wordpress/icons");
|
|
43
43
|
var import_use_enter = require("./use-enter.cjs");
|
|
44
44
|
var import_deprecated_attributes = __toESM(require("./deprecated-attributes.cjs"));
|
|
45
|
-
var import_lock_unlock = require("../lock-unlock.cjs");
|
|
46
45
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
47
46
|
function ParagraphRTLControl({ direction, setDirection }) {
|
|
48
47
|
return (0, import_i18n.isRTL)() && /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
@@ -64,7 +63,7 @@ function DropCapControl({ clientId, attributes, setAttributes, name }) {
|
|
|
64
63
|
const [isDropCapFeatureEnabled] = (0, import_block_editor.useSettings)("typography.dropCap");
|
|
65
64
|
const hasSelectedStyleState = (0, import_data.useSelect)(
|
|
66
65
|
(select) => {
|
|
67
|
-
const {
|
|
66
|
+
const { hasSelectedBlockStyleState } = select(import_block_editor.store);
|
|
68
67
|
return hasSelectedBlockStyleState(clientId);
|
|
69
68
|
},
|
|
70
69
|
[clientId]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/paragraph/edit.jsx"],
|
|
4
|
-
"sourcesContent": ["import clsx from 'clsx';\nimport { __, _x, isRTL } from '@wordpress/i18n';\nimport {\n\tToolbarButton,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tuseSettings,\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { formatLTR } from '@wordpress/icons';\nimport { useOnEnter } from './use-enter';\nimport useDeprecatedAlign from './deprecated-attributes';\
|
|
5
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAA8B;AAC9B,wBAIO;AACP,0BAQO;AACP,kBAA0B;AAC1B,oBAAgC;AAChC,mBAA0B;AAC1B,uBAA2B;AAC3B,mCAA+B;
|
|
4
|
+
"sourcesContent": ["import clsx from 'clsx';\nimport { __, _x, isRTL } from '@wordpress/i18n';\nimport {\n\tToolbarButton,\n\tToggleControl,\n\t__experimentalToolsPanelItem as ToolsPanelItem,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tInspectorControls,\n\tRichText,\n\tuseBlockProps,\n\tuseSettings,\n\tuseBlockEditingMode,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { getBlockSupport } from '@wordpress/blocks';\nimport { formatLTR } from '@wordpress/icons';\nimport { useOnEnter } from './use-enter';\nimport useDeprecatedAlign from './deprecated-attributes';\n\nfunction ParagraphRTLControl( { direction, setDirection } ) {\n\treturn (\n\t\tisRTL() && (\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ formatLTR }\n\t\t\t\ttitle={ _x( 'Left to right', 'editor button' ) }\n\t\t\t\tisActive={ direction === 'ltr' }\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tsetDirection( direction === 'ltr' ? undefined : 'ltr' );\n\t\t\t\t} }\n\t\t\t/>\n\t\t)\n\t);\n}\n\nfunction hasDropCapDisabled( align ) {\n\treturn align === ( isRTL() ? 'left' : 'right' ) || align === 'center';\n}\n\nfunction DropCapControl( { clientId, attributes, setAttributes, name } ) {\n\t// Please do not add a useSelect call to the paragraph block unconditionally.\n\t// Every useSelect added to a (frequently used) block will degrade load\n\t// and type performance. By moving it within InspectorControls, the subscription is\n\t// now only added for the selected block(s).\n\tconst [ isDropCapFeatureEnabled ] = useSettings( 'typography.dropCap' );\n\tconst hasSelectedStyleState = useSelect(\n\t\t( select ) => {\n\t\t\tconst { hasSelectedBlockStyleState } = select( blockEditorStore );\n\n\t\t\treturn hasSelectedBlockStyleState( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( ! isDropCapFeatureEnabled || hasSelectedStyleState ) {\n\t\treturn null;\n\t}\n\n\tconst { style, dropCap } = attributes;\n\tconst textAlign = style?.typography?.textAlign;\n\n\tlet helpText;\n\tif ( hasDropCapDisabled( textAlign ) ) {\n\t\thelpText = __( 'Not available for aligned text.' );\n\t} else if ( dropCap ) {\n\t\thelpText = __( 'Showing large initial letter.' );\n\t} else {\n\t\thelpText = __( 'Show a large initial letter.' );\n\t}\n\n\tconst isDropCapControlEnabledByDefault = getBlockSupport(\n\t\tname,\n\t\t'typography.defaultControls.dropCap',\n\t\tfalse\n\t);\n\n\treturn (\n\t\t<InspectorControls group=\"typography\">\n\t\t\t<ToolsPanelItem\n\t\t\t\thasValue={ () => !! dropCap }\n\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\tisShownByDefault={ isDropCapControlEnabledByDefault }\n\t\t\t\tonDeselect={ () => setAttributes( { dropCap: false } ) }\n\t\t\t\tresetAllFilter={ () => ( { dropCap: false } ) }\n\t\t\t\tpanelId={ clientId }\n\t\t\t>\n\t\t\t\t<ToggleControl\n\t\t\t\t\tlabel={ __( 'Drop cap' ) }\n\t\t\t\t\tchecked={ !! dropCap }\n\t\t\t\t\tonChange={ () => setAttributes( { dropCap: ! dropCap } ) }\n\t\t\t\t\thelp={ helpText }\n\t\t\t\t\tdisabled={ hasDropCapDisabled( textAlign ) }\n\t\t\t\t/>\n\t\t\t</ToolsPanelItem>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction ParagraphBlock( {\n\tattributes,\n\tmergeBlocks,\n\tonReplace,\n\tonRemove,\n\tsetAttributes,\n\tclientId,\n\tisSelected: isSingleSelected,\n\tname,\n} ) {\n\tconst { content, direction, dropCap, placeholder, style } = attributes;\n\tconst textAlign = style?.typography?.textAlign;\n\tuseDeprecatedAlign( attributes.align, style, setAttributes );\n\tconst blockProps = useBlockProps( {\n\t\tref: useOnEnter( { clientId, content } ),\n\t\tclassName: clsx( {\n\t\t\t'has-drop-cap': hasDropCapDisabled( textAlign ) ? false : dropCap,\n\t\t} ),\n\t\tstyle: { direction },\n\t\t'aria-label': RichText.isEmpty( content )\n\t\t\t? __(\n\t\t\t\t\t'Empty block; start writing or type forward slash to choose a block'\n\t\t\t\t)\n\t\t\t: __( 'Block: Paragraph' ),\n\t} );\n\tconst blockEditingMode = useBlockEditingMode();\n\n\treturn (\n\t\t<>\n\t\t\t{ blockEditingMode === 'default' && (\n\t\t\t\t<BlockControls group=\"block\">\n\t\t\t\t\t<ParagraphRTLControl\n\t\t\t\t\t\tdirection={ direction }\n\t\t\t\t\t\tsetDirection={ ( newDirection ) =>\n\t\t\t\t\t\t\tsetAttributes( { direction: newDirection } )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isSingleSelected && (\n\t\t\t\t<DropCapControl\n\t\t\t\t\tname={ name }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t<RichText\n\t\t\t\tidentifier=\"content\"\n\t\t\t\ttagName=\"p\"\n\t\t\t\t{ ...blockProps }\n\t\t\t\tvalue={ content }\n\t\t\t\tonChange={ ( newContent ) =>\n\t\t\t\t\tsetAttributes( { content: newContent } )\n\t\t\t\t}\n\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\tonReplace={ onReplace }\n\t\t\t\tonRemove={ onRemove }\n\t\t\t\tdata-empty={ RichText.isEmpty( content ) }\n\t\t\t\tplaceholder={ placeholder || __( 'Type / to choose a block' ) }\n\t\t\t\tdata-custom-placeholder={ placeholder ? true : undefined }\n\t\t\t\t__unstableEmbedURLOnPaste\n\t\t\t\t__unstableAllowPrefixTransformations\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default ParagraphBlock;\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAiB;AACjB,kBAA8B;AAC9B,wBAIO;AACP,0BAQO;AACP,kBAA0B;AAC1B,oBAAgC;AAChC,mBAA0B;AAC1B,uBAA2B;AAC3B,mCAA+B;AAK5B;AAHH,SAAS,oBAAqB,EAAE,WAAW,aAAa,GAAI;AAC3D,aACC,mBAAM,KACL;AAAA,IAAC;AAAA;AAAA,MACA,MAAO;AAAA,MACP,WAAQ,gBAAI,iBAAiB,eAAgB;AAAA,MAC7C,UAAW,cAAc;AAAA,MACzB,SAAU,MAAM;AACf,qBAAc,cAAc,QAAQ,SAAY,KAAM;AAAA,MACvD;AAAA;AAAA,EACD;AAGH;AAEA,SAAS,mBAAoB,OAAQ;AACpC,SAAO,eAAY,mBAAM,IAAI,SAAS,YAAa,UAAU;AAC9D;AAEA,SAAS,eAAgB,EAAE,UAAU,YAAY,eAAe,KAAK,GAAI;AAKxE,QAAM,CAAE,uBAAwB,QAAI,iCAAa,oBAAqB;AACtE,QAAM,4BAAwB;AAAA,IAC7B,CAAE,WAAY;AACb,YAAM,EAAE,2BAA2B,IAAI,OAAQ,oBAAAA,KAAiB;AAEhE,aAAO,2BAA4B,QAAS;AAAA,IAC7C;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,MAAK,CAAE,2BAA2B,uBAAwB;AACzD,WAAO;AAAA,EACR;AAEA,QAAM,EAAE,OAAO,QAAQ,IAAI;AAC3B,QAAM,YAA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