@wordpress/block-library 7.16.0 → 7.18.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 +4 -1
- package/build/archives/edit.js +1 -0
- package/build/archives/edit.js.map +1 -1
- package/build/audio/edit.js +44 -4
- package/build/audio/edit.js.map +1 -1
- package/build/button/edit.js +1 -1
- package/build/button/edit.js.map +1 -1
- package/build/buttons/edit.native.js +1 -1
- package/build/buttons/edit.native.js.map +1 -1
- package/build/comment-template/edit.js +40 -32
- package/build/comment-template/edit.js.map +1 -1
- package/build/comment-template/index.js +6 -2
- package/build/comment-template/index.js.map +1 -1
- package/build/comments/edit/placeholder.js +1 -4
- package/build/comments/edit/placeholder.js.map +1 -1
- package/build/comments/index.js +5 -1
- package/build/comments/index.js.map +1 -1
- package/build/comments-title/edit.js +18 -1
- package/build/comments-title/edit.js.map +1 -1
- package/build/cover/edit/index.js +2 -2
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +3 -7
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/edit/use-cover-is-dark.js +8 -7
- package/build/cover/edit/use-cover-is-dark.js.map +1 -1
- package/build/embed/deprecated.js +43 -4
- package/build/embed/deprecated.js.map +1 -1
- package/build/embed/variations.js +1 -1
- package/build/embed/variations.js.map +1 -1
- package/build/file/deprecated.js +108 -4
- package/build/file/deprecated.js.map +1 -1
- package/build/file/transforms.js +3 -9
- package/build/file/transforms.js.map +1 -1
- package/build/gallery/deprecated.js +148 -23
- package/build/gallery/deprecated.js.map +1 -1
- package/build/gallery/gallery.js +3 -2
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/transforms.js +3 -3
- package/build/gallery/transforms.js.map +1 -1
- package/build/gallery/use-image-sizes.js +2 -1
- package/build/gallery/use-image-sizes.js.map +1 -1
- package/build/gallery/v1/edit.js +3 -2
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/group/edit.js +7 -3
- package/build/group/edit.js.map +1 -1
- package/build/image/edit.native.js +1 -1
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +33 -12
- package/build/image/image.js.map +1 -1
- package/build/image/transforms.js +1 -7
- package/build/image/transforms.js.map +1 -1
- package/build/latest-posts/edit.js +1 -1
- package/build/latest-posts/edit.js.map +1 -1
- package/build/list/transforms.js +9 -1
- package/build/list/transforms.js.map +1 -1
- package/build/list/utils.js +4 -8
- package/build/list/utils.js.map +1 -1
- package/build/list-item/edit.js +3 -2
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/edit.native.js +3 -2
- package/build/list-item/edit.native.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +19 -22
- package/build/list-item/hooks/use-merge.js.map +1 -1
- package/build/list-item/hooks/use-outdent-list-item.js +24 -10
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/list-item/index.js +14 -1
- package/build/list-item/index.js.map +1 -1
- package/build/list-item/utils.js +14 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/navigation/edit/index.js +45 -31
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +3 -5
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +3 -1
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +25 -8
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js +1 -1
- package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build/navigation/index.js +4 -1
- package/build/navigation/index.js.map +1 -1
- package/build/navigation-link/edit.js +5 -3
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +4 -4
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/edit.js +29 -10
- package/build/page-list/edit.js.map +1 -1
- package/build/page-list/index.js +1 -5
- package/build/page-list/index.js.map +1 -1
- package/build/paragraph/edit.js +3 -11
- package/build/paragraph/edit.js.map +1 -1
- package/build/pattern/edit.js +11 -4
- package/build/pattern/edit.js.map +1 -1
- package/build/post-comments-count/index.js +4 -0
- package/build/post-comments-count/index.js.map +1 -1
- package/build/post-comments-form/form.js +1 -2
- package/build/post-comments-form/form.js.map +1 -1
- package/build/post-comments-form/index.js +4 -0
- package/build/post-comments-form/index.js.map +1 -1
- package/build/post-comments-link/index.js +4 -0
- package/build/post-comments-link/index.js.map +1 -1
- package/build/post-content/edit.js +14 -6
- package/build/post-content/edit.js.map +1 -1
- package/build/pullquote/deprecated.js +6 -6
- package/build/pullquote/deprecated.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +2 -2
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +79 -104
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/search/edit.js +3 -4
- package/build/search/edit.js.map +1 -1
- package/build/site-logo/edit.js +7 -10
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-tagline/edit.js +21 -9
- package/build/site-tagline/edit.js.map +1 -1
- package/build/site-title/edit/index.js +20 -8
- package/build/site-title/edit/index.js.map +1 -1
- package/build/social-link/edit.js +11 -2
- package/build/social-link/edit.js.map +1 -1
- package/build/social-link/index.js +3 -0
- package/build/social-link/index.js.map +1 -1
- package/build/spacer/controls.js +3 -7
- package/build/spacer/controls.js.map +1 -1
- package/build/table/deprecated.js +282 -27
- package/build/table/deprecated.js.map +1 -1
- package/build/table/state.js +2 -2
- package/build/table/state.js.map +1 -1
- package/build/table-of-contents/edit.js +1 -4
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/tag-cloud/edit.js +1 -1
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/tag-cloud/index.js +8 -0
- package/build/tag-cloud/index.js.map +1 -1
- package/build/utils/clean-empty-object.js +5 -4
- package/build/utils/clean-empty-object.js.map +1 -1
- package/build/video/deprecated.js +159 -0
- package/build/video/deprecated.js.map +1 -0
- package/build/video/edit.js +41 -5
- package/build/video/edit.js.map +1 -1
- package/build/video/index.js +3 -0
- package/build/video/index.js.map +1 -1
- package/build/video/tracks-editor.js +3 -28
- package/build/video/tracks-editor.js.map +1 -1
- package/build-module/archives/edit.js +1 -0
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/audio/edit.js +46 -7
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/button/edit.js +1 -1
- package/build-module/button/edit.js.map +1 -1
- package/build-module/buttons/edit.native.js +1 -1
- package/build-module/buttons/edit.native.js.map +1 -1
- package/build-module/comment-template/edit.js +38 -30
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/comment-template/index.js +6 -2
- package/build-module/comment-template/index.js.map +1 -1
- package/build-module/comments/edit/placeholder.js +1 -3
- package/build-module/comments/edit/placeholder.js.map +1 -1
- package/build-module/comments/index.js +5 -1
- package/build-module/comments/index.js.map +1 -1
- package/build-module/comments-title/edit.js +18 -2
- package/build-module/comments-title/edit.js.map +1 -1
- package/build-module/cover/edit/index.js +2 -2
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +4 -8
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/edit/use-cover-is-dark.js +7 -7
- package/build-module/cover/edit/use-cover-is-dark.js.map +1 -1
- package/build-module/embed/deprecated.js +44 -5
- package/build-module/embed/deprecated.js.map +1 -1
- package/build-module/embed/variations.js +1 -1
- package/build-module/embed/variations.js.map +1 -1
- package/build-module/file/deprecated.js +108 -4
- package/build-module/file/deprecated.js.map +1 -1
- package/build-module/file/transforms.js +3 -8
- package/build-module/file/transforms.js.map +1 -1
- package/build-module/gallery/deprecated.js +147 -25
- package/build-module/gallery/deprecated.js.map +1 -1
- package/build-module/gallery/gallery.js +3 -2
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/transforms.js +4 -4
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/gallery/use-image-sizes.js +3 -2
- package/build-module/gallery/use-image-sizes.js.map +1 -1
- package/build-module/gallery/v1/edit.js +4 -3
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/group/edit.js +7 -3
- package/build-module/group/edit.js.map +1 -1
- package/build-module/image/edit.native.js +1 -1
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +36 -15
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/transforms.js +1 -6
- package/build-module/image/transforms.js.map +1 -1
- package/build-module/latest-posts/edit.js +2 -2
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/list/transforms.js +9 -1
- package/build-module/list/transforms.js.map +1 -1
- package/build-module/list/utils.js +5 -9
- package/build-module/list/utils.js.map +1 -1
- package/build-module/list-item/edit.js +3 -2
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/edit.native.js +3 -2
- package/build-module/list-item/edit.native.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +19 -21
- package/build-module/list-item/hooks/use-merge.js.map +1 -1
- package/build-module/list-item/hooks/use-outdent-list-item.js +24 -9
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/list-item/index.js +14 -1
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/list-item/utils.js +14 -1
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/navigation/edit/index.js +45 -31
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +3 -5
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +3 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +25 -8
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js +1 -1
- package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build-module/navigation/index.js +4 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation-link/edit.js +5 -4
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +4 -4
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/edit.js +29 -10
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/page-list/index.js +1 -5
- package/build-module/page-list/index.js.map +1 -1
- package/build-module/paragraph/edit.js +3 -10
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/pattern/edit.js +10 -3
- package/build-module/pattern/edit.js.map +1 -1
- package/build-module/post-comments-count/index.js +4 -0
- package/build-module/post-comments-count/index.js.map +1 -1
- package/build-module/post-comments-form/form.js +2 -3
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/post-comments-form/index.js +4 -0
- package/build-module/post-comments-form/index.js.map +1 -1
- package/build-module/post-comments-link/index.js +4 -0
- package/build-module/post-comments-link/index.js.map +1 -1
- package/build-module/post-content/edit.js +14 -6
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/pullquote/deprecated.js +7 -7
- package/build-module/pullquote/deprecated.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +4 -4
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +81 -102
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/search/edit.js +4 -5
- package/build-module/search/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +8 -11
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-tagline/edit.js +23 -11
- package/build-module/site-tagline/edit.js.map +1 -1
- package/build-module/site-title/edit/index.js +22 -10
- package/build-module/site-title/edit/index.js.map +1 -1
- package/build-module/social-link/edit.js +11 -2
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-link/index.js +3 -0
- package/build-module/social-link/index.js.map +1 -1
- package/build-module/spacer/controls.js +4 -8
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/table/deprecated.js +282 -27
- package/build-module/table/deprecated.js.map +1 -1
- package/build-module/table/state.js +3 -3
- package/build-module/table/state.js.map +1 -1
- package/build-module/table-of-contents/edit.js +1 -3
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/tag-cloud/edit.js +1 -1
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/tag-cloud/index.js +8 -0
- package/build-module/tag-cloud/index.js.map +1 -1
- package/build-module/utils/clean-empty-object.js +5 -5
- package/build-module/utils/clean-empty-object.js.map +1 -1
- package/build-module/video/deprecated.js +147 -0
- package/build-module/video/deprecated.js.map +1 -0
- package/build-module/video/edit.js +45 -9
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/index.js +2 -0
- package/build-module/video/index.js.map +1 -1
- package/build-module/video/tracks-editor.js +4 -29
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/archives/style-rtl.css +4 -0
- package/build-style/archives/style.css +4 -0
- package/build-style/button/style-rtl.css +1 -0
- package/build-style/button/style.css +1 -0
- package/build-style/comment-template/style-rtl.css +1 -0
- package/build-style/comment-template/style.css +1 -0
- package/build-style/comments/editor-rtl.css +1 -0
- package/build-style/comments/editor.css +1 -0
- package/build-style/comments/style-rtl.css +1 -0
- package/build-style/comments/style.css +1 -0
- package/build-style/cover/editor-rtl.css +4 -0
- package/build-style/cover/editor.css +4 -0
- package/build-style/editor-rtl.css +13 -21
- package/build-style/editor.css +13 -21
- package/build-style/group/editor-rtl.css +1 -0
- package/build-style/group/editor.css +1 -0
- package/build-style/image/editor-rtl.css +1 -1
- package/build-style/image/editor.css +1 -1
- package/build-style/navigation/editor-rtl.css +5 -4
- package/build-style/navigation/editor.css +5 -4
- package/build-style/navigation/style-rtl.css +3 -1
- package/build-style/navigation/style.css +3 -1
- package/build-style/paragraph/editor-rtl.css +0 -16
- package/build-style/paragraph/editor.css +0 -16
- package/build-style/post-comments-form/style-rtl.css +3 -0
- package/build-style/post-comments-form/style.css +3 -0
- package/build-style/site-logo/editor-rtl.css +1 -0
- package/build-style/site-logo/editor.css +1 -0
- package/build-style/style-rtl.css +16 -1
- package/build-style/style.css +16 -1
- package/build-style/tag-cloud/style-rtl.css +3 -0
- package/build-style/tag-cloud/style.css +3 -0
- package/package.json +29 -28
- package/src/archives/edit.js +1 -0
- package/src/archives/style.scss +5 -0
- package/src/audio/edit.js +79 -24
- package/src/avatar/index.php +1 -1
- package/src/button/edit.js +1 -1
- package/src/button/style.scss +2 -0
- package/src/buttons/edit.native.js +1 -1
- package/src/code/test/__snapshots__/edit.native.js.snap +13 -0
- package/src/code/test/edit.native.js +46 -32
- package/src/comment-template/block.json +6 -2
- package/src/comment-template/edit.js +47 -34
- package/src/comment-template/style.scss +2 -0
- package/src/comments/block.json +5 -1
- package/src/comments/edit/placeholder.js +1 -7
- package/src/comments/style.scss +2 -0
- package/src/comments-title/edit.js +24 -1
- package/src/cover/edit/index.js +2 -7
- package/src/cover/edit/inspector-controls.js +11 -13
- package/src/cover/edit/use-cover-is-dark.js +11 -11
- package/src/cover/editor.scss +7 -0
- package/src/embed/deprecated.js +53 -26
- package/src/embed/variations.js +1 -1
- package/src/file/deprecated.js +130 -2
- package/src/file/transforms.js +3 -8
- package/src/gallery/deprecated.js +129 -4
- package/src/gallery/gallery.js +2 -0
- package/src/gallery/index.php +19 -10
- package/src/gallery/transforms.js +8 -5
- package/src/gallery/use-image-sizes.js +3 -2
- package/src/gallery/v1/edit.js +4 -3
- package/src/group/edit.js +10 -2
- package/src/group/editor.scss +1 -0
- package/src/image/edit.native.js +1 -1
- package/src/image/editor.scss +4 -1
- package/src/image/image.js +75 -33
- package/src/image/transforms.js +1 -7
- package/src/latest-posts/edit.js +2 -2
- package/src/list/test/edit.native.js +102 -3
- package/src/list/transforms.js +11 -0
- package/src/list/utils.js +3 -11
- package/src/list-item/block.json +14 -1
- package/src/list-item/edit.js +2 -1
- package/src/list-item/edit.native.js +2 -1
- package/src/list-item/hooks/use-merge.js +4 -23
- package/src/list-item/hooks/use-outdent-list-item.js +9 -8
- package/src/navigation/block.json +4 -1
- package/src/navigation/edit/index.js +61 -37
- package/src/navigation/edit/inner-blocks.js +2 -5
- package/src/navigation/edit/unsaved-inner-blocks.js +9 -2
- package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +32 -5
- package/src/navigation/edit/use-create-navigation-menu.js +2 -5
- package/src/navigation/editor.scss +5 -4
- package/src/navigation/index.php +103 -6
- package/src/navigation/style.scss +3 -1
- package/src/navigation-link/edit.js +6 -5
- package/src/navigation-link/index.php +8 -1
- package/src/navigation-submenu/edit.js +7 -5
- package/src/navigation-submenu/index.php +8 -1
- package/src/page-list/block.json +1 -5
- package/src/page-list/edit.js +36 -22
- package/src/page-list/index.php +8 -6
- package/src/paragraph/edit.js +1 -14
- package/src/paragraph/editor.scss +0 -20
- package/src/pattern/edit.js +10 -3
- package/src/post-comments-count/block.json +4 -0
- package/src/post-comments-form/block.json +4 -0
- package/src/post-comments-form/form.js +2 -3
- package/src/post-comments-form/style.scss +3 -0
- package/src/post-comments-link/block.json +4 -0
- package/src/post-content/edit.js +8 -4
- package/src/pullquote/deprecated.js +7 -7
- package/src/query/edit/inspector-controls/index.js +4 -3
- package/src/query/edit/inspector-controls/taxonomy-controls.js +82 -87
- package/src/rss/index.php +3 -3
- package/src/search/edit.js +7 -2
- package/src/search/index.php +21 -13
- package/src/site-logo/edit.js +12 -10
- package/src/site-logo/editor.scss +1 -0
- package/src/site-tagline/edit.js +25 -18
- package/src/site-title/edit/index.js +26 -12
- package/src/social-link/block.json +3 -0
- package/src/social-link/edit.js +8 -1
- package/src/social-link/index.php +11 -7
- package/src/spacer/controls.js +10 -12
- package/src/table/deprecated.js +587 -348
- package/src/table/state.js +3 -3
- package/src/table-of-contents/edit.js +1 -3
- package/src/tag-cloud/block.json +8 -0
- package/src/tag-cloud/edit.js +1 -1
- package/src/tag-cloud/style.scss +3 -0
- package/src/template-part/index.php +4 -0
- package/src/utils/clean-empty-object.js +5 -6
- package/src/video/deprecated.js +57 -0
- package/src/video/edit.js +71 -23
- package/src/video/index.js +2 -0
- package/src/video/tracks-editor.js +12 -28
- package/build/paragraph/drop-zone.js +0 -99
- package/build/paragraph/drop-zone.js.map +0 -1
- package/build-module/paragraph/drop-zone.js +0 -88
- package/build-module/paragraph/drop-zone.js.map +0 -1
- package/src/paragraph/drop-zone.js +0 -105
|
@@ -86,6 +86,7 @@ function Navigation( {
|
|
|
86
86
|
openSubmenusOnClick,
|
|
87
87
|
overlayMenu,
|
|
88
88
|
showSubmenuIcon,
|
|
89
|
+
templateLock,
|
|
89
90
|
layout: {
|
|
90
91
|
justifyContent,
|
|
91
92
|
orientation = 'horizontal',
|
|
@@ -107,7 +108,7 @@ function Navigation( {
|
|
|
107
108
|
|
|
108
109
|
// Preload classic menus, so that they don't suddenly pop-in when viewing
|
|
109
110
|
// the Select Menu dropdown.
|
|
110
|
-
useNavigationEntities();
|
|
111
|
+
const { menus: classicMenus } = useNavigationEntities();
|
|
111
112
|
|
|
112
113
|
const [ showNavigationMenuStatusNotice, hideNavigationMenuStatusNotice ] =
|
|
113
114
|
useNavigationNotice( {
|
|
@@ -216,6 +217,20 @@ function Navigation( {
|
|
|
216
217
|
const navMenuResolvedButMissing =
|
|
217
218
|
hasResolvedNavigationMenus && isNavigationMenuMissing;
|
|
218
219
|
|
|
220
|
+
const {
|
|
221
|
+
convert: convertClassicMenu,
|
|
222
|
+
status: classicMenuConversionStatus,
|
|
223
|
+
error: classicMenuConversionError,
|
|
224
|
+
} = useConvertClassicToBlockMenu( clientId );
|
|
225
|
+
|
|
226
|
+
const isConvertingClassicMenu =
|
|
227
|
+
classicMenuConversionStatus === CLASSIC_MENU_CONVERSION_PENDING;
|
|
228
|
+
|
|
229
|
+
// Only autofallback to published menus.
|
|
230
|
+
const fallbackNavigationMenus = navigationMenus?.filter(
|
|
231
|
+
( menu ) => menu.status === 'publish'
|
|
232
|
+
);
|
|
233
|
+
|
|
219
234
|
// Attempt to retrieve and prioritize any existing navigation menu unless:
|
|
220
235
|
// - the are uncontrolled inner blocks already present in the block.
|
|
221
236
|
// - the user is creating a new menu.
|
|
@@ -228,23 +243,17 @@ function Navigation( {
|
|
|
228
243
|
hasUncontrolledInnerBlocks ||
|
|
229
244
|
isCreatingNavigationMenu ||
|
|
230
245
|
ref ||
|
|
231
|
-
!
|
|
246
|
+
! fallbackNavigationMenus?.length
|
|
232
247
|
) {
|
|
233
248
|
return;
|
|
234
249
|
}
|
|
235
250
|
|
|
236
|
-
|
|
251
|
+
fallbackNavigationMenus.sort( ( menuA, menuB ) => {
|
|
237
252
|
const menuADate = new Date( menuA.date );
|
|
238
253
|
const menuBDate = new Date( menuB.date );
|
|
239
254
|
return menuADate.getTime() < menuBDate.getTime();
|
|
240
255
|
} );
|
|
241
256
|
|
|
242
|
-
// Only autofallback to published menus.
|
|
243
|
-
const fallbackNavigationMenus = navigationMenus.filter(
|
|
244
|
-
( menu ) => menu.status === 'publish'
|
|
245
|
-
);
|
|
246
|
-
if ( fallbackNavigationMenus.length === 0 ) return;
|
|
247
|
-
|
|
248
257
|
/**
|
|
249
258
|
* This fallback displays (both in editor and on front)
|
|
250
259
|
* a list of pages only if no menu (user assigned or
|
|
@@ -256,16 +265,26 @@ function Navigation( {
|
|
|
256
265
|
setRef( fallbackNavigationMenus[ 0 ].id );
|
|
257
266
|
}, [ navigationMenus ] );
|
|
258
267
|
|
|
259
|
-
|
|
268
|
+
useEffect( () => {
|
|
269
|
+
if (
|
|
270
|
+
! hasResolvedNavigationMenus ||
|
|
271
|
+
isConvertingClassicMenu ||
|
|
272
|
+
fallbackNavigationMenus?.length > 0 ||
|
|
273
|
+
classicMenus?.length !== 1
|
|
274
|
+
) {
|
|
275
|
+
return;
|
|
276
|
+
}
|
|
260
277
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
278
|
+
// If there's non fallback navigation menus and
|
|
279
|
+
// only one classic menu then create a new navigation menu based on it.
|
|
280
|
+
convertClassicMenu(
|
|
281
|
+
classicMenus[ 0 ].id,
|
|
282
|
+
classicMenus[ 0 ].name,
|
|
283
|
+
'publish'
|
|
284
|
+
);
|
|
285
|
+
}, [ hasResolvedNavigationMenus ] );
|
|
266
286
|
|
|
267
|
-
const
|
|
268
|
-
classicMenuConversionStatus === CLASSIC_MENU_CONVERSION_PENDING;
|
|
287
|
+
const navRef = useRef();
|
|
269
288
|
|
|
270
289
|
// The standard HTML5 tag for the block wrapper.
|
|
271
290
|
const TagName = 'nav';
|
|
@@ -280,10 +299,11 @@ function Navigation( {
|
|
|
280
299
|
! isCreatingNavigationMenu &&
|
|
281
300
|
! isConvertingClassicMenu &&
|
|
282
301
|
hasResolvedNavigationMenus &&
|
|
302
|
+
classicMenus?.length === 0 &&
|
|
283
303
|
! hasUncontrolledInnerBlocks;
|
|
284
304
|
|
|
285
305
|
useEffect( () => {
|
|
286
|
-
if ( isPlaceholder
|
|
306
|
+
if ( isPlaceholder ) {
|
|
287
307
|
/**
|
|
288
308
|
* this fallback only displays (both in editor and on front)
|
|
289
309
|
* the list of pages block if no menu is available as a fallback.
|
|
@@ -461,24 +481,22 @@ function Navigation( {
|
|
|
461
481
|
|
|
462
482
|
// Prompt the user to publish the menu they have set as a draft
|
|
463
483
|
const isDraftNavigationMenu = navigationMenu?.status === 'draft';
|
|
464
|
-
useEffect(
|
|
484
|
+
useEffect( () => {
|
|
465
485
|
hideMenuAutoPublishDraftNotice();
|
|
466
|
-
if ( ! isDraftNavigationMenu )
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
);
|
|
477
|
-
} catch {
|
|
486
|
+
if ( ! isDraftNavigationMenu ) {
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
editEntityRecord(
|
|
490
|
+
'postType',
|
|
491
|
+
'wp_navigation',
|
|
492
|
+
navigationMenu?.id,
|
|
493
|
+
{ status: 'publish' },
|
|
494
|
+
{ throwOnError: true }
|
|
495
|
+
).catch( () => {
|
|
478
496
|
showMenuAutoPublishDraftNotice(
|
|
479
|
-
__( 'Error
|
|
497
|
+
__( 'Error occurred while publishing the navigation menu.' )
|
|
480
498
|
);
|
|
481
|
-
}
|
|
499
|
+
} );
|
|
482
500
|
}, [ isDraftNavigationMenu, navigationMenu ] );
|
|
483
501
|
|
|
484
502
|
const stylingInspectorControls = (
|
|
@@ -642,7 +660,8 @@ function Navigation( {
|
|
|
642
660
|
onSelectClassicMenu={ async ( classicMenu ) => {
|
|
643
661
|
const navMenu = await convertClassicMenu(
|
|
644
662
|
classicMenu.id,
|
|
645
|
-
classicMenu.name
|
|
663
|
+
classicMenu.name,
|
|
664
|
+
'draft'
|
|
646
665
|
);
|
|
647
666
|
if ( navMenu ) {
|
|
648
667
|
handleUpdateMenu( navMenu.id, {
|
|
@@ -686,6 +705,7 @@ function Navigation( {
|
|
|
686
705
|
<UnsavedInnerBlocks
|
|
687
706
|
blocks={ uncontrolledInnerBlocks }
|
|
688
707
|
clientId={ clientId }
|
|
708
|
+
templateLock={ templateLock }
|
|
689
709
|
navigationMenus={ navigationMenus }
|
|
690
710
|
hasSelection={ isSelected || isInnerBlockSelected }
|
|
691
711
|
hasSavedUnsavedInnerBlocks={
|
|
@@ -723,7 +743,8 @@ function Navigation( {
|
|
|
723
743
|
onSelectClassicMenu={ async ( classicMenu ) => {
|
|
724
744
|
const navMenu = await convertClassicMenu(
|
|
725
745
|
classicMenu.id,
|
|
726
|
-
classicMenu.name
|
|
746
|
+
classicMenu.name,
|
|
747
|
+
'draft'
|
|
727
748
|
);
|
|
728
749
|
if ( navMenu ) {
|
|
729
750
|
handleUpdateMenu( navMenu.id, {
|
|
@@ -808,7 +829,8 @@ function Navigation( {
|
|
|
808
829
|
onSelectClassicMenu={ async ( classicMenu ) => {
|
|
809
830
|
const navMenu = await convertClassicMenu(
|
|
810
831
|
classicMenu.id,
|
|
811
|
-
classicMenu.name
|
|
832
|
+
classicMenu.name,
|
|
833
|
+
'draft'
|
|
812
834
|
);
|
|
813
835
|
if ( navMenu ) {
|
|
814
836
|
handleUpdateMenu( navMenu.id, {
|
|
@@ -836,7 +858,8 @@ function Navigation( {
|
|
|
836
858
|
onSelectClassicMenu={ async ( classicMenu ) => {
|
|
837
859
|
const navMenu = await convertClassicMenu(
|
|
838
860
|
classicMenu.id,
|
|
839
|
-
classicMenu.name
|
|
861
|
+
classicMenu.name,
|
|
862
|
+
'draft'
|
|
840
863
|
);
|
|
841
864
|
if ( navMenu ) {
|
|
842
865
|
handleUpdateMenu( navMenu.id, {
|
|
@@ -921,6 +944,7 @@ function Navigation( {
|
|
|
921
944
|
hasCustomPlaceholder={
|
|
922
945
|
!! CustomPlaceholder
|
|
923
946
|
}
|
|
947
|
+
templateLock={ templateLock }
|
|
924
948
|
orientation={ orientation }
|
|
925
949
|
/>
|
|
926
950
|
) }
|
|
@@ -40,6 +40,7 @@ export default function NavigationInnerBlocks( {
|
|
|
40
40
|
clientId,
|
|
41
41
|
hasCustomPlaceholder,
|
|
42
42
|
orientation,
|
|
43
|
+
templateLock,
|
|
43
44
|
} ) {
|
|
44
45
|
const {
|
|
45
46
|
isImmediateParentOfSelectedBlock,
|
|
@@ -115,6 +116,7 @@ export default function NavigationInnerBlocks( {
|
|
|
115
116
|
__experimentalDefaultBlock: DEFAULT_BLOCK,
|
|
116
117
|
__experimentalDirectInsert: shouldDirectInsert,
|
|
117
118
|
orientation,
|
|
119
|
+
templateLock,
|
|
118
120
|
|
|
119
121
|
// As an exception to other blocks which feature nesting, show
|
|
120
122
|
// the block appender even when a child block is selected.
|
|
@@ -129,11 +131,6 @@ export default function NavigationInnerBlocks( {
|
|
|
129
131
|
parentOrChildHasSelection
|
|
130
132
|
? InnerBlocks.ButtonBlockAppender
|
|
131
133
|
: false,
|
|
132
|
-
|
|
133
|
-
// Template lock set to false here so that the Nav
|
|
134
|
-
// Block on the experimental menus screen does not
|
|
135
|
-
// inherit templateLock={ 'all' }.
|
|
136
|
-
templateLock: false,
|
|
137
134
|
__experimentalLayout: LAYOUT,
|
|
138
135
|
placeholder: showPlaceholder ? placeholder : undefined,
|
|
139
136
|
}
|
|
@@ -172,8 +172,15 @@ export default function UnsavedInnerBlocks( {
|
|
|
172
172
|
|
|
173
173
|
return (
|
|
174
174
|
<>
|
|
175
|
-
|
|
176
|
-
|
|
175
|
+
{ isSaving ? (
|
|
176
|
+
<Spinner
|
|
177
|
+
className={
|
|
178
|
+
'wp-block-navigation__uncontrolled-inner-blocks-loading-indicator'
|
|
179
|
+
}
|
|
180
|
+
/>
|
|
181
|
+
) : (
|
|
182
|
+
<Wrapper { ...innerBlocksProps } />
|
|
183
|
+
) }
|
|
177
184
|
</>
|
|
178
185
|
);
|
|
179
186
|
}
|
|
@@ -17,6 +17,10 @@ export const CLASSIC_MENU_CONVERSION_ERROR = 'error';
|
|
|
17
17
|
export const CLASSIC_MENU_CONVERSION_PENDING = 'pending';
|
|
18
18
|
export const CLASSIC_MENU_CONVERSION_IDLE = 'idle';
|
|
19
19
|
|
|
20
|
+
// This is needed to ensure that multiple components using this hook
|
|
21
|
+
// do not import the same classic menu twice.
|
|
22
|
+
let classicMenuBeingConvertedId = null;
|
|
23
|
+
|
|
20
24
|
function useConvertClassicToBlockMenu( clientId ) {
|
|
21
25
|
/*
|
|
22
26
|
* The wp_navigation post is created as a draft so the changes on the frontend and
|
|
@@ -32,7 +36,11 @@ function useConvertClassicToBlockMenu( clientId ) {
|
|
|
32
36
|
const [ status, setStatus ] = useState( CLASSIC_MENU_CONVERSION_IDLE );
|
|
33
37
|
const [ error, setError ] = useState( null );
|
|
34
38
|
|
|
35
|
-
async function convertClassicMenuToBlockMenu(
|
|
39
|
+
async function convertClassicMenuToBlockMenu(
|
|
40
|
+
menuId,
|
|
41
|
+
menuName,
|
|
42
|
+
postStatus = 'publish'
|
|
43
|
+
) {
|
|
36
44
|
let navigationMenu;
|
|
37
45
|
let classicMenuItems;
|
|
38
46
|
|
|
@@ -76,7 +84,8 @@ function useConvertClassicToBlockMenu( clientId ) {
|
|
|
76
84
|
try {
|
|
77
85
|
navigationMenu = await createNavigationMenu(
|
|
78
86
|
menuName,
|
|
79
|
-
innerBlocks
|
|
87
|
+
innerBlocks,
|
|
88
|
+
postStatus
|
|
80
89
|
);
|
|
81
90
|
|
|
82
91
|
/**
|
|
@@ -91,7 +100,7 @@ function useConvertClassicToBlockMenu( clientId ) {
|
|
|
91
100
|
'wp_navigation',
|
|
92
101
|
navigationMenu.id,
|
|
93
102
|
{
|
|
94
|
-
status:
|
|
103
|
+
status: postStatus,
|
|
95
104
|
},
|
|
96
105
|
{ throwOnError: true }
|
|
97
106
|
);
|
|
@@ -111,7 +120,15 @@ function useConvertClassicToBlockMenu( clientId ) {
|
|
|
111
120
|
return navigationMenu;
|
|
112
121
|
}
|
|
113
122
|
|
|
114
|
-
const convert = useCallback( async ( menuId, menuName ) => {
|
|
123
|
+
const convert = useCallback( async ( menuId, menuName, postStatus ) => {
|
|
124
|
+
// Check whether this classic menu is being imported already.
|
|
125
|
+
if ( classicMenuBeingConvertedId === menuId ) {
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Set the ID for the currently importing classic menu.
|
|
130
|
+
classicMenuBeingConvertedId = menuId;
|
|
131
|
+
|
|
115
132
|
if ( ! menuId || ! menuName ) {
|
|
116
133
|
setError( 'Unable to convert menu. Missing menu details.' );
|
|
117
134
|
setStatus( CLASSIC_MENU_CONVERSION_ERROR );
|
|
@@ -121,15 +138,25 @@ function useConvertClassicToBlockMenu( clientId ) {
|
|
|
121
138
|
setStatus( CLASSIC_MENU_CONVERSION_PENDING );
|
|
122
139
|
setError( null );
|
|
123
140
|
|
|
124
|
-
return await convertClassicMenuToBlockMenu(
|
|
141
|
+
return await convertClassicMenuToBlockMenu(
|
|
142
|
+
menuId,
|
|
143
|
+
menuName,
|
|
144
|
+
postStatus
|
|
145
|
+
)
|
|
125
146
|
.then( ( navigationMenu ) => {
|
|
126
147
|
setStatus( CLASSIC_MENU_CONVERSION_SUCCESS );
|
|
148
|
+
// Reset the ID for the currently importing classic menu.
|
|
149
|
+
classicMenuBeingConvertedId = null;
|
|
127
150
|
return navigationMenu;
|
|
128
151
|
} )
|
|
129
152
|
.catch( ( err ) => {
|
|
130
153
|
setError( err?.message );
|
|
154
|
+
// Reset the ID for the currently importing classic menu.
|
|
131
155
|
setStatus( CLASSIC_MENU_CONVERSION_ERROR );
|
|
132
156
|
|
|
157
|
+
// Reset the ID for the currently importing classic menu.
|
|
158
|
+
classicMenuBeingConvertedId = null;
|
|
159
|
+
|
|
133
160
|
// Rethrow error for debugging.
|
|
134
161
|
throw new Error(
|
|
135
162
|
sprintf(
|
|
@@ -16,10 +16,7 @@ export const CREATE_NAVIGATION_MENU_ERROR = 'error';
|
|
|
16
16
|
export const CREATE_NAVIGATION_MENU_PENDING = 'pending';
|
|
17
17
|
export const CREATE_NAVIGATION_MENU_IDLE = 'idle';
|
|
18
18
|
|
|
19
|
-
export default function useCreateNavigationMenu(
|
|
20
|
-
clientId,
|
|
21
|
-
postStatus = 'publish'
|
|
22
|
-
) {
|
|
19
|
+
export default function useCreateNavigationMenu( clientId ) {
|
|
23
20
|
const [ status, setStatus ] = useState( CREATE_NAVIGATION_MENU_IDLE );
|
|
24
21
|
const [ value, setValue ] = useState( null );
|
|
25
22
|
const [ error, setError ] = useState( null );
|
|
@@ -30,7 +27,7 @@ export default function useCreateNavigationMenu(
|
|
|
30
27
|
// This callback uses data from the two placeholder steps and only creates
|
|
31
28
|
// a new navigation menu when the user completes the final step.
|
|
32
29
|
const create = useCallback(
|
|
33
|
-
async ( title = null, blocks = [] ) => {
|
|
30
|
+
async ( title = null, blocks = [], postStatus ) => {
|
|
34
31
|
// Guard against creating Navigations without a title.
|
|
35
32
|
// Note you can pass no title, but if one is passed it must be
|
|
36
33
|
// a string otherwise the title may end up being empty.
|
|
@@ -261,10 +261,6 @@ $color-control-label-height: 20px;
|
|
|
261
261
|
}
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
-
.wp-block-navigation-placeholder .components-spinner {
|
|
265
|
-
margin-top: 0;
|
|
266
|
-
}
|
|
267
|
-
|
|
268
264
|
// Unselected state.
|
|
269
265
|
.wp-block-navigation-placeholder__preview {
|
|
270
266
|
display: flex;
|
|
@@ -291,6 +287,7 @@ $color-control-label-height: 20px;
|
|
|
291
287
|
bottom: 0;
|
|
292
288
|
left: 0;
|
|
293
289
|
pointer-events: none;
|
|
290
|
+
border: $border-width dashed currentColor;
|
|
294
291
|
@include placeholder-style();
|
|
295
292
|
|
|
296
293
|
// Inherit border radius from style variations.
|
|
@@ -566,6 +563,10 @@ body.editor-styles-wrapper
|
|
|
566
563
|
padding: $grid-unit-10 $grid-unit-15;
|
|
567
564
|
}
|
|
568
565
|
|
|
566
|
+
.wp-block-navigation .wp-block-navigation__uncontrolled-inner-blocks-loading-indicator {
|
|
567
|
+
margin-top: 0;
|
|
568
|
+
}
|
|
569
|
+
|
|
569
570
|
@keyframes fadeouthalf {
|
|
570
571
|
0% {
|
|
571
572
|
opacity: 1;
|
package/src/navigation/index.php
CHANGED
|
@@ -248,6 +248,99 @@ function block_core_navigation_render_submenu_icon() {
|
|
|
248
248
|
return '<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 12 12" fill="none" aria-hidden="true" focusable="false"><path d="M1.50002 4L6.00002 8L10.5 4" stroke-width="1.5"></path></svg>';
|
|
249
249
|
}
|
|
250
250
|
|
|
251
|
+
/**
|
|
252
|
+
* Get the classic navigation menu to use as a fallback.
|
|
253
|
+
*
|
|
254
|
+
* @return object WP_Term The classic navigation.
|
|
255
|
+
*/
|
|
256
|
+
function block_core_navigation_get_classic_menu_fallback() {
|
|
257
|
+
$classic_nav_menus = wp_get_nav_menus();
|
|
258
|
+
|
|
259
|
+
// If menus exist.
|
|
260
|
+
if ( $classic_nav_menus && ! is_wp_error( $classic_nav_menus ) && count( $classic_nav_menus ) === 1 ) {
|
|
261
|
+
// Use the first classic menu only. Handles simple use case where user has a single
|
|
262
|
+
// classic menu and switches to a block theme. In future this maybe expanded to
|
|
263
|
+
// determine the most appropriate classic menu to be used based on location.
|
|
264
|
+
return $classic_nav_menus[0];
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Converts a classic navigation to blocks.
|
|
270
|
+
*
|
|
271
|
+
* @param object $classic_nav_menu WP_Term The classic navigation object to convert.
|
|
272
|
+
* @return array the normalized parsed blocks.
|
|
273
|
+
*/
|
|
274
|
+
function block_core_navigation_get_classic_menu_fallback_blocks( $classic_nav_menu ) {
|
|
275
|
+
// BEGIN: Code that already exists in wp_nav_menu().
|
|
276
|
+
$menu_items = wp_get_nav_menu_items( $classic_nav_menu->term_id, array( 'update_post_term_cache' => false ) );
|
|
277
|
+
|
|
278
|
+
// Set up the $menu_item variables.
|
|
279
|
+
_wp_menu_item_classes_by_context( $menu_items );
|
|
280
|
+
|
|
281
|
+
$sorted_menu_items = array();
|
|
282
|
+
foreach ( (array) $menu_items as $menu_item ) {
|
|
283
|
+
$sorted_menu_items[ $menu_item->menu_order ] = $menu_item;
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
unset( $menu_items, $menu_item );
|
|
287
|
+
|
|
288
|
+
// END: Code that already exists in wp_nav_menu().
|
|
289
|
+
|
|
290
|
+
$menu_items_by_parent_id = array();
|
|
291
|
+
foreach ( $sorted_menu_items as $menu_item ) {
|
|
292
|
+
$menu_items_by_parent_id[ $menu_item->menu_item_parent ][] = $menu_item;
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
$inner_blocks = block_core_navigation_parse_blocks_from_menu_items(
|
|
296
|
+
isset( $menu_items_by_parent_id[0] )
|
|
297
|
+
? $menu_items_by_parent_id[0]
|
|
298
|
+
: array(),
|
|
299
|
+
$menu_items_by_parent_id
|
|
300
|
+
);
|
|
301
|
+
|
|
302
|
+
return serialize_blocks( $inner_blocks );
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* If there's a the classic menu then use it as a fallback.
|
|
307
|
+
*
|
|
308
|
+
* @return array the normalized parsed blocks.
|
|
309
|
+
*/
|
|
310
|
+
function block_core_navigation_maybe_use_classic_menu_fallback() {
|
|
311
|
+
// See if we have a classic menu.
|
|
312
|
+
$classic_nav_menu = block_core_navigation_get_classic_menu_fallback();
|
|
313
|
+
|
|
314
|
+
if ( ! $classic_nav_menu ) {
|
|
315
|
+
return;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
// If we have a classic menu then convert it to blocks.
|
|
319
|
+
$classic_nav_menu_blocks = block_core_navigation_get_classic_menu_fallback_blocks( $classic_nav_menu );
|
|
320
|
+
|
|
321
|
+
if ( empty( $classic_nav_menu_blocks ) ) {
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// Create a new navigation menu from the classic menu.
|
|
326
|
+
$wp_insert_post_result = wp_insert_post(
|
|
327
|
+
array(
|
|
328
|
+
'post_content' => $classic_nav_menu_blocks,
|
|
329
|
+
'post_title' => $classic_nav_menu->slug,
|
|
330
|
+
'post_name' => $classic_nav_menu->slug,
|
|
331
|
+
'post_status' => 'publish',
|
|
332
|
+
'post_type' => 'wp_navigation',
|
|
333
|
+
),
|
|
334
|
+
true // So that we can check whether the result is an error.
|
|
335
|
+
);
|
|
336
|
+
|
|
337
|
+
if ( is_wp_error( $wp_insert_post_result ) ) {
|
|
338
|
+
return;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
// Fetch the most recently published navigation which will be the classic one created above.
|
|
342
|
+
return block_core_navigation_get_most_recently_published_navigation();
|
|
343
|
+
}
|
|
251
344
|
|
|
252
345
|
/**
|
|
253
346
|
* Finds the most recently published `wp_navigation` Post.
|
|
@@ -255,7 +348,8 @@ function block_core_navigation_render_submenu_icon() {
|
|
|
255
348
|
* @return WP_Post|null the first non-empty Navigation or null.
|
|
256
349
|
*/
|
|
257
350
|
function block_core_navigation_get_most_recently_published_navigation() {
|
|
258
|
-
|
|
351
|
+
|
|
352
|
+
// Default to the most recently created menu.
|
|
259
353
|
$parsed_args = array(
|
|
260
354
|
'post_type' => 'wp_navigation',
|
|
261
355
|
'no_found_rows' => true,
|
|
@@ -307,9 +401,6 @@ function block_core_navigation_get_fallback_blocks() {
|
|
|
307
401
|
$page_list_fallback = array(
|
|
308
402
|
array(
|
|
309
403
|
'blockName' => 'core/page-list',
|
|
310
|
-
'attrs' => array(
|
|
311
|
-
'__unstableMaxPages' => 4,
|
|
312
|
-
),
|
|
313
404
|
),
|
|
314
405
|
);
|
|
315
406
|
|
|
@@ -322,7 +413,13 @@ function block_core_navigation_get_fallback_blocks() {
|
|
|
322
413
|
|
|
323
414
|
$navigation_post = block_core_navigation_get_most_recently_published_navigation();
|
|
324
415
|
|
|
325
|
-
//
|
|
416
|
+
// If there are no navigation posts then try to find a classic menu
|
|
417
|
+
// and convert it into a block based navigation menu.
|
|
418
|
+
if ( ! $navigation_post ) {
|
|
419
|
+
$navigation_post = block_core_navigation_maybe_use_classic_menu_fallback();
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// Use the first non-empty Navigation as fallback if available.
|
|
326
423
|
if ( $navigation_post ) {
|
|
327
424
|
$maybe_fallback = block_core_navigation_filter_out_empty_blocks( parse_blocks( $navigation_post->post_content ) );
|
|
328
425
|
|
|
@@ -649,7 +746,7 @@ function render_block_core_navigation( $attributes, $content, $block ) {
|
|
|
649
746
|
$toggle_aria_label_close,
|
|
650
747
|
esc_attr( implode( ' ', $responsive_container_classes ) ),
|
|
651
748
|
esc_attr( implode( ' ', $open_button_classes ) ),
|
|
652
|
-
safecss_filter_attr( $colors['overlay_inline_styles'] ),
|
|
749
|
+
esc_attr( safecss_filter_attr( $colors['overlay_inline_styles'] ) ),
|
|
653
750
|
__( 'Menu' ),
|
|
654
751
|
$toggle_button_content,
|
|
655
752
|
$toggle_close_button_content
|
|
@@ -359,7 +359,9 @@ button.wp-block-navigation-item__content {
|
|
|
359
359
|
|
|
360
360
|
// Provide a default padding for submenus who should always have some, regardless of the top level menu items.
|
|
361
361
|
:where(.wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-item a:not(.wp-element-button)),
|
|
362
|
-
:where(.wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-submenu a:not(.wp-element-button))
|
|
362
|
+
:where(.wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-submenu a:not(.wp-element-button)),
|
|
363
|
+
:where(.wp-block-navigation .wp-block-navigation__submenu-container .wp-block-navigation-submenu button.wp-block-navigation-item__content),
|
|
364
|
+
:where(.wp-block-navigation .wp-block-navigation__submenu-container .wp-block-pages-list__item button.wp-block-navigation-item__content) {
|
|
363
365
|
padding: 0.5em 1em;
|
|
364
366
|
}
|
|
365
367
|
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import
|
|
5
|
+
import escapeHtml from 'escape-html';
|
|
6
|
+
import { unescape } from 'lodash';
|
|
6
7
|
|
|
7
8
|
/**
|
|
8
9
|
* WordPress dependencies
|
|
@@ -262,8 +263,8 @@ export const updateNavigationLinkBlockAttributes = (
|
|
|
262
263
|
// - https://github.com/WordPress/gutenberg/pull/41063
|
|
263
264
|
// - https://github.com/WordPress/gutenberg/pull/18617.
|
|
264
265
|
const label = useNewLabel
|
|
265
|
-
?
|
|
266
|
-
: originalLabel ||
|
|
266
|
+
? escapeHtml( newLabel )
|
|
267
|
+
: originalLabel || escapeHtml( newUrlWithoutHttp );
|
|
267
268
|
|
|
268
269
|
// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use "tag" in favor of "post_tag"
|
|
269
270
|
const type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );
|
|
@@ -467,7 +468,7 @@ export default function NavigationLinkEdit( {
|
|
|
467
468
|
const [ popoverAnchor, setPopoverAnchor ] = useState( null );
|
|
468
469
|
const listItemRef = useRef( null );
|
|
469
470
|
const isDraggingWithin = useIsDraggingWithin( listItemRef );
|
|
470
|
-
const itemLabelPlaceholder = __( 'Add
|
|
471
|
+
const itemLabelPlaceholder = __( 'Add label…' );
|
|
471
472
|
const ref = useRef();
|
|
472
473
|
|
|
473
474
|
const pagesPermissions = useResourcePermissions( 'pages' );
|
|
@@ -846,7 +847,7 @@ export default function NavigationLinkEdit( {
|
|
|
846
847
|
) }
|
|
847
848
|
{ isLinkOpen && (
|
|
848
849
|
<Popover
|
|
849
|
-
|
|
850
|
+
placement="bottom"
|
|
850
851
|
onClose={ () => setIsLinkOpen( false ) }
|
|
851
852
|
anchor={ popoverAnchor }
|
|
852
853
|
shift
|
|
@@ -98,7 +98,14 @@ function block_core_navigation_link_build_css_font_sizes( $context ) {
|
|
|
98
98
|
$font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
|
|
99
99
|
} elseif ( $has_custom_font_size ) {
|
|
100
100
|
// Add the custom font size inline style.
|
|
101
|
-
$font_sizes['inline_styles'] = sprintf(
|
|
101
|
+
$font_sizes['inline_styles'] = sprintf(
|
|
102
|
+
'font-size: %s;',
|
|
103
|
+
wp_get_typography_font_size_value(
|
|
104
|
+
array(
|
|
105
|
+
'size' => $context['style']['typography']['fontSize'],
|
|
106
|
+
)
|
|
107
|
+
)
|
|
108
|
+
);
|
|
102
109
|
}
|
|
103
110
|
|
|
104
111
|
return $font_sizes;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
import classnames from 'classnames';
|
|
5
|
-
import
|
|
5
|
+
import escapeHtml from 'escape-html';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* WordPress dependencies
|
|
@@ -248,8 +248,8 @@ export const updateNavigationLinkBlockAttributes = (
|
|
|
248
248
|
normalizedTitle !== normalizedURL &&
|
|
249
249
|
originalLabel !== title;
|
|
250
250
|
const label = escapeTitle
|
|
251
|
-
?
|
|
252
|
-
: originalLabel ||
|
|
251
|
+
? escapeHtml( title )
|
|
252
|
+
: originalLabel || escapeHtml( normalizedURL );
|
|
253
253
|
|
|
254
254
|
// In https://github.com/WordPress/gutenberg/pull/24670 we decided to use "tag" in favor of "post_tag"
|
|
255
255
|
const type = newType === 'post_tag' ? 'tag' : newType.replace( '-', '_' );
|
|
@@ -486,7 +486,9 @@ export default function NavigationSubmenuEdit( {
|
|
|
486
486
|
const innerBlocksColors = getColors( context, true );
|
|
487
487
|
|
|
488
488
|
const allowedBlocks = isAtMaxNesting
|
|
489
|
-
?
|
|
489
|
+
? ALLOWED_BLOCKS.filter(
|
|
490
|
+
( blockName ) => blockName !== 'core/navigation-submenu'
|
|
491
|
+
)
|
|
490
492
|
: ALLOWED_BLOCKS;
|
|
491
493
|
|
|
492
494
|
const innerBlocksProps = useInnerBlocksProps(
|
|
@@ -631,7 +633,7 @@ export default function NavigationSubmenuEdit( {
|
|
|
631
633
|
}
|
|
632
634
|
{ ! openSubmenusOnClick && isLinkOpen && (
|
|
633
635
|
<Popover
|
|
634
|
-
|
|
636
|
+
placement="bottom"
|
|
635
637
|
onClose={ () => setIsLinkOpen( false ) }
|
|
636
638
|
anchor={ popoverAnchor }
|
|
637
639
|
shift
|
|
@@ -98,7 +98,14 @@ function block_core_navigation_submenu_build_css_font_sizes( $context ) {
|
|
|
98
98
|
$font_sizes['css_classes'][] = sprintf( 'has-%s-font-size', $context['fontSize'] );
|
|
99
99
|
} elseif ( $has_custom_font_size ) {
|
|
100
100
|
// Add the custom font size inline style.
|
|
101
|
-
$font_sizes['inline_styles'] = sprintf(
|
|
101
|
+
$font_sizes['inline_styles'] = sprintf(
|
|
102
|
+
'font-size: %s;',
|
|
103
|
+
wp_get_typography_font_size_value(
|
|
104
|
+
array(
|
|
105
|
+
'size' => $context['style']['typography']['fontSize'],
|
|
106
|
+
)
|
|
107
|
+
)
|
|
108
|
+
);
|
|
102
109
|
}
|
|
103
110
|
|
|
104
111
|
return $font_sizes;
|
package/src/page-list/block.json
CHANGED
|
@@ -7,11 +7,7 @@
|
|
|
7
7
|
"description": "Display a list of all pages.",
|
|
8
8
|
"keywords": [ "menu", "navigation" ],
|
|
9
9
|
"textdomain": "default",
|
|
10
|
-
"attributes": {
|
|
11
|
-
"__unstableMaxPages": {
|
|
12
|
-
"type": "number"
|
|
13
|
-
}
|
|
14
|
-
},
|
|
10
|
+
"attributes": {},
|
|
15
11
|
"usesContext": [
|
|
16
12
|
"textColor",
|
|
17
13
|
"customTextColor",
|