@wordpress/block-library 8.0.0 → 8.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 +4 -0
- package/LICENSE.md +1 -1
- package/build/archives/edit.js +1 -0
- package/build/archives/edit.js.map +1 -1
- package/build/audio/edit.js +2 -0
- package/build/audio/edit.js.map +1 -1
- package/build/categories/edit.js +1 -1
- package/build/categories/edit.js.map +1 -1
- package/build/comments/edit/comments-inspector-controls.js +9 -3
- package/build/comments/edit/comments-inspector-controls.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +1 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/embed/embed-preview.js +1 -0
- package/build/embed/embed-preview.js.map +1 -1
- package/build/file/inspector.js +1 -0
- package/build/file/inspector.js.map +1 -1
- package/build/freeform/edit.js +21 -6
- package/build/freeform/edit.js.map +1 -1
- package/build/freeform/modal.js +97 -0
- package/build/freeform/modal.js.map +1 -0
- package/build/gallery/edit.js +15 -2
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.js +3 -16
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/v1/edit.js +2 -0
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/group/edit.js +1 -0
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +3 -0
- package/build/group/index.js.map +1 -1
- package/build/image/image.js +7 -10
- package/build/image/image.js.map +1 -1
- package/build/latest-posts/edit.js +11 -8
- package/build/latest-posts/edit.js.map +1 -1
- package/build/media-text/edit.js +1 -0
- package/build/media-text/edit.js.map +1 -1
- package/build/missing/edit.native.js +2 -2
- package/build/missing/edit.native.js.map +1 -1
- package/build/navigation/edit/index.js +9 -7
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +81 -22
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +15 -10
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/utils.js +81 -0
- package/build/navigation/edit/utils.js.map +1 -1
- package/build/navigation/leaf-more-menu.js +95 -0
- package/build/navigation/leaf-more-menu.js.map +1 -0
- package/build/navigation-link/edit.js +10 -61
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/update-attributes.js +3 -3
- package/build/navigation-link/update-attributes.js.map +1 -1
- package/build/navigation-submenu/edit.js +7 -72
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/edit.js +16 -15
- package/build/page-list/edit.js.map +1 -1
- package/build/page-list/index.js +29 -2
- package/build/page-list/index.js.map +1 -1
- package/build/page-list-item/edit.js +9 -5
- package/build/page-list-item/edit.js.map +1 -1
- package/build/page-list-item/index.js +2 -1
- package/build/page-list-item/index.js.map +1 -1
- package/build/post-author/edit.js +2 -0
- package/build/post-author/edit.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +1 -0
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-featured-image/overlay.js +0 -1
- package/build/post-featured-image/overlay.js.map +1 -1
- package/build/query/edit/index.js +2 -1
- package/build/query/edit/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +11 -5
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/order-control.js +1 -0
- package/build/query/edit/inspector-controls/order-control.js.map +1 -1
- package/build/query/edit/inspector-controls/sticky-control.js +1 -0
- package/build/query/edit/inspector-controls/sticky-control.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +101 -37
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query/edit/query-content.js +10 -4
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/edit/query-placeholder.js +17 -12
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/utils.js +73 -1
- package/build/query/utils.js.map +1 -1
- package/build/search/edit.js +2 -2
- package/build/search/edit.js.map +1 -1
- package/build/social-link/edit.js +2 -1
- package/build/social-link/edit.js.map +1 -1
- package/build/social-links/edit.js +0 -1
- package/build/social-links/edit.js.map +1 -1
- package/build/table/edit.js +1 -0
- package/build/table/edit.js.map +1 -1
- package/build/table-of-contents/edit.js +1 -1
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/tag-cloud/edit.js +1 -0
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js +23 -2
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/import-controls.js +160 -0
- package/build/template-part/edit/import-controls.js.map +1 -0
- package/build/template-part/edit/index.js +2 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/utils/transformers.js +48 -0
- package/build/template-part/edit/utils/transformers.js.map +1 -0
- package/build/video/edit-common-settings.js +6 -5
- package/build/video/edit-common-settings.js.map +1 -1
- package/build/video/edit.js +1 -0
- package/build/video/edit.js.map +1 -1
- package/build/video/tracks-editor.js +1 -0
- 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 +2 -0
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/categories/edit.js +1 -1
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/comments/edit/comments-inspector-controls.js +9 -3
- package/build-module/comments/edit/comments-inspector-controls.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +3 -3
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/embed/embed-preview.js +1 -0
- package/build-module/embed/embed-preview.js.map +1 -1
- package/build-module/file/inspector.js +1 -0
- package/build-module/file/inspector.js.map +1 -1
- package/build-module/freeform/edit.js +22 -8
- package/build-module/freeform/edit.js.map +1 -1
- package/build-module/freeform/modal.js +90 -0
- package/build-module/freeform/modal.js.map +1 -0
- package/build-module/gallery/edit.js +16 -3
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.js +4 -16
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/v1/edit.js +2 -0
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/group/edit.js +1 -0
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +3 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/image/image.js +7 -10
- package/build-module/image/image.js.map +1 -1
- package/build-module/latest-posts/edit.js +12 -9
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/media-text/edit.js +1 -0
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/missing/edit.native.js +2 -2
- package/build-module/missing/edit.native.js.map +1 -1
- package/build-module/navigation/edit/index.js +9 -7
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +80 -25
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +16 -11
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/utils.js +75 -0
- package/build-module/navigation/edit/utils.js.map +1 -1
- package/build-module/navigation/leaf-more-menu.js +76 -0
- package/build-module/navigation/leaf-more-menu.js.map +1 -0
- package/build-module/navigation-link/edit.js +10 -62
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/update-attributes.js +3 -3
- package/build-module/navigation-link/update-attributes.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +6 -72
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/edit.js +17 -15
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/page-list/index.js +30 -3
- package/build-module/page-list/index.js.map +1 -1
- package/build-module/page-list-item/edit.js +9 -6
- package/build-module/page-list-item/edit.js.map +1 -1
- package/build-module/page-list-item/index.js +2 -1
- package/build-module/page-list-item/index.js.map +1 -1
- package/build-module/post-author/edit.js +2 -0
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +1 -0
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-featured-image/overlay.js +0 -1
- package/build-module/post-featured-image/overlay.js.map +1 -1
- package/build-module/query/edit/index.js +2 -1
- package/build-module/query/edit/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +11 -5
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/order-control.js +1 -0
- package/build-module/query/edit/inspector-controls/order-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/sticky-control.js +1 -0
- package/build-module/query/edit/inspector-controls/sticky-control.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +99 -35
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query/edit/query-content.js +9 -2
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +16 -12
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/utils.js +69 -0
- package/build-module/query/utils.js.map +1 -1
- package/build-module/search/edit.js +2 -2
- package/build-module/search/edit.js.map +1 -1
- package/build-module/social-link/edit.js +4 -3
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-links/edit.js +0 -1
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/table/edit.js +1 -0
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table-of-contents/edit.js +1 -1
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/tag-cloud/edit.js +1 -0
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js +22 -2
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/import-controls.js +146 -0
- package/build-module/template-part/edit/import-controls.js.map +1 -0
- package/build-module/template-part/edit/index.js +2 -1
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/utils/transformers.js +40 -0
- package/build-module/template-part/edit/utils/transformers.js.map +1 -0
- package/build-module/video/edit-common-settings.js +6 -5
- package/build-module/video/edit-common-settings.js.map +1 -1
- package/build-module/video/edit.js +1 -0
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/tracks-editor.js +1 -0
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/archives/editor-rtl.css +3 -3
- package/build-style/archives/editor.css +3 -3
- package/build-style/archives/style-rtl.css +3 -3
- package/build-style/archives/style.css +3 -3
- package/build-style/audio/editor-rtl.css +3 -3
- package/build-style/audio/editor.css +3 -3
- package/build-style/audio/style-rtl.css +3 -3
- package/build-style/audio/style.css +3 -3
- package/build-style/audio/theme-rtl.css +3 -3
- package/build-style/audio/theme.css +3 -3
- package/build-style/avatar/editor-rtl.css +3 -3
- package/build-style/avatar/editor.css +3 -3
- package/build-style/avatar/style-rtl.css +3 -3
- package/build-style/avatar/style.css +3 -3
- package/build-style/block/editor-rtl.css +3 -3
- package/build-style/block/editor.css +3 -3
- package/build-style/button/editor-rtl.css +3 -3
- package/build-style/button/editor.css +3 -3
- package/build-style/button/style-rtl.css +3 -3
- package/build-style/button/style.css +3 -3
- package/build-style/buttons/editor-rtl.css +3 -3
- package/build-style/buttons/editor.css +3 -3
- package/build-style/buttons/style-rtl.css +3 -3
- package/build-style/buttons/style.css +3 -3
- package/build-style/calendar/style-rtl.css +3 -3
- package/build-style/calendar/style.css +3 -3
- package/build-style/categories/editor-rtl.css +3 -3
- package/build-style/categories/editor.css +3 -3
- package/build-style/categories/style-rtl.css +3 -3
- package/build-style/categories/style.css +3 -3
- package/build-style/classic-rtl.css +3 -3
- package/build-style/classic.css +3 -3
- package/build-style/code/editor-rtl.css +3 -3
- package/build-style/code/editor.css +3 -3
- package/build-style/code/style-rtl.css +3 -3
- package/build-style/code/style.css +3 -3
- package/build-style/code/theme-rtl.css +3 -3
- package/build-style/code/theme.css +3 -3
- package/build-style/columns/editor-rtl.css +3 -3
- package/build-style/columns/editor.css +3 -3
- package/build-style/columns/style-rtl.css +3 -3
- package/build-style/columns/style.css +3 -3
- package/build-style/comment-author-avatar/editor-rtl.css +3 -3
- package/build-style/comment-author-avatar/editor.css +3 -3
- package/build-style/comment-content/style-rtl.css +3 -3
- package/build-style/comment-content/style.css +3 -3
- package/build-style/comment-template/style-rtl.css +3 -3
- package/build-style/comment-template/style.css +3 -3
- package/build-style/comments/editor-rtl.css +3 -3
- package/build-style/comments/editor.css +3 -3
- package/build-style/comments/style-rtl.css +3 -3
- package/build-style/comments/style.css +3 -3
- package/build-style/comments-pagination/editor-rtl.css +3 -3
- package/build-style/comments-pagination/editor.css +3 -3
- package/build-style/comments-pagination/style-rtl.css +3 -3
- package/build-style/comments-pagination/style.css +3 -3
- package/build-style/comments-pagination-numbers/editor-rtl.css +3 -3
- package/build-style/comments-pagination-numbers/editor.css +3 -3
- package/build-style/comments-title/editor-rtl.css +3 -3
- package/build-style/comments-title/editor.css +3 -3
- package/build-style/common-rtl.css +3 -3
- package/build-style/common.css +3 -3
- package/build-style/cover/editor-rtl.css +3 -3
- package/build-style/cover/editor.css +3 -3
- package/build-style/cover/style-rtl.css +3 -3
- package/build-style/cover/style.css +3 -3
- package/build-style/editor-elements-rtl.css +3 -3
- package/build-style/editor-elements.css +3 -3
- package/build-style/editor-rtl.css +7 -9
- package/build-style/editor.css +7 -9
- package/build-style/elements-rtl.css +3 -3
- package/build-style/elements.css +3 -3
- package/build-style/embed/editor-rtl.css +3 -3
- package/build-style/embed/editor.css +3 -3
- package/build-style/embed/style-rtl.css +3 -3
- package/build-style/embed/style.css +3 -3
- package/build-style/embed/theme-rtl.css +3 -3
- package/build-style/embed/theme.css +3 -3
- package/build-style/file/editor-rtl.css +3 -3
- package/build-style/file/editor.css +3 -3
- package/build-style/file/style-rtl.css +3 -3
- package/build-style/file/style.css +3 -3
- package/build-style/freeform/editor-rtl.css +3 -3
- package/build-style/freeform/editor.css +3 -3
- package/build-style/gallery/editor-rtl.css +3 -3
- package/build-style/gallery/editor.css +3 -3
- package/build-style/gallery/style-rtl.css +3 -3
- package/build-style/gallery/style.css +3 -3
- package/build-style/gallery/theme-rtl.css +3 -3
- package/build-style/gallery/theme.css +3 -3
- package/build-style/group/editor-rtl.css +3 -3
- package/build-style/group/editor.css +3 -3
- package/build-style/group/style-rtl.css +3 -3
- package/build-style/group/style.css +3 -3
- package/build-style/group/theme-rtl.css +3 -3
- package/build-style/group/theme.css +3 -3
- package/build-style/heading/style-rtl.css +3 -3
- package/build-style/heading/style.css +3 -3
- package/build-style/html/editor-rtl.css +3 -3
- package/build-style/html/editor.css +3 -3
- package/build-style/image/editor-rtl.css +3 -3
- package/build-style/image/editor.css +3 -3
- package/build-style/image/style-rtl.css +3 -3
- package/build-style/image/style.css +3 -3
- package/build-style/image/theme-rtl.css +3 -3
- package/build-style/image/theme.css +3 -3
- package/build-style/latest-comments/style-rtl.css +3 -3
- package/build-style/latest-comments/style.css +3 -3
- package/build-style/latest-posts/editor-rtl.css +3 -3
- package/build-style/latest-posts/editor.css +3 -3
- package/build-style/latest-posts/style-rtl.css +3 -3
- package/build-style/latest-posts/style.css +3 -3
- package/build-style/list/style-rtl.css +3 -3
- package/build-style/list/style.css +3 -3
- package/build-style/media-text/editor-rtl.css +3 -3
- package/build-style/media-text/editor.css +3 -3
- package/build-style/media-text/style-rtl.css +3 -3
- package/build-style/media-text/style.css +3 -3
- package/build-style/more/editor-rtl.css +3 -3
- package/build-style/more/editor.css +3 -3
- package/build-style/navigation/editor-rtl.css +3 -9
- package/build-style/navigation/editor.css +3 -9
- package/build-style/navigation/style-rtl.css +3 -4
- package/build-style/navigation/style.css +3 -4
- package/build-style/navigation-link/editor-rtl.css +3 -3
- package/build-style/navigation-link/editor.css +3 -3
- package/build-style/navigation-link/style-rtl.css +3 -3
- package/build-style/navigation-link/style.css +3 -3
- package/build-style/navigation-submenu/editor-rtl.css +3 -3
- package/build-style/navigation-submenu/editor.css +3 -3
- package/build-style/nextpage/editor-rtl.css +3 -3
- package/build-style/nextpage/editor.css +3 -3
- package/build-style/page-list/editor-rtl.css +7 -3
- package/build-style/page-list/editor.css +7 -3
- package/build-style/page-list/style-rtl.css +3 -3
- package/build-style/page-list/style.css +3 -3
- package/build-style/paragraph/editor-rtl.css +3 -3
- package/build-style/paragraph/editor.css +3 -3
- package/build-style/paragraph/style-rtl.css +3 -3
- package/build-style/paragraph/style.css +3 -3
- package/build-style/post-author/style-rtl.css +3 -3
- package/build-style/post-author/style.css +3 -3
- package/build-style/post-comments-form/editor-rtl.css +3 -3
- package/build-style/post-comments-form/editor.css +3 -3
- package/build-style/post-comments-form/style-rtl.css +3 -3
- package/build-style/post-comments-form/style.css +3 -3
- package/build-style/post-date/style-rtl.css +3 -3
- package/build-style/post-date/style.css +3 -3
- package/build-style/post-excerpt/editor-rtl.css +3 -3
- package/build-style/post-excerpt/editor.css +3 -3
- package/build-style/post-excerpt/style-rtl.css +3 -3
- package/build-style/post-excerpt/style.css +3 -3
- package/build-style/post-featured-image/editor-rtl.css +3 -3
- package/build-style/post-featured-image/editor.css +3 -3
- package/build-style/post-featured-image/style-rtl.css +3 -3
- package/build-style/post-featured-image/style.css +3 -3
- package/build-style/post-navigation-link/style-rtl.css +3 -3
- package/build-style/post-navigation-link/style.css +3 -3
- package/build-style/post-template/editor-rtl.css +3 -3
- package/build-style/post-template/editor.css +3 -3
- package/build-style/post-template/style-rtl.css +3 -3
- package/build-style/post-template/style.css +3 -3
- package/build-style/post-terms/style-rtl.css +3 -3
- package/build-style/post-terms/style.css +3 -3
- package/build-style/post-title/style-rtl.css +3 -3
- package/build-style/post-title/style.css +3 -3
- package/build-style/preformatted/style-rtl.css +3 -3
- package/build-style/preformatted/style.css +3 -3
- package/build-style/pullquote/editor-rtl.css +3 -3
- package/build-style/pullquote/editor.css +3 -3
- package/build-style/pullquote/style-rtl.css +3 -3
- package/build-style/pullquote/style.css +3 -3
- package/build-style/pullquote/theme-rtl.css +3 -3
- package/build-style/pullquote/theme.css +3 -3
- package/build-style/query/editor-rtl.css +3 -3
- package/build-style/query/editor.css +3 -3
- package/build-style/query-pagination/editor-rtl.css +3 -3
- package/build-style/query-pagination/editor.css +3 -3
- package/build-style/query-pagination/style-rtl.css +3 -3
- package/build-style/query-pagination/style.css +3 -3
- package/build-style/query-pagination-numbers/editor-rtl.css +3 -3
- package/build-style/query-pagination-numbers/editor.css +3 -3
- package/build-style/query-title/style-rtl.css +3 -3
- package/build-style/query-title/style.css +3 -3
- package/build-style/quote/style-rtl.css +3 -3
- package/build-style/quote/style.css +3 -3
- package/build-style/quote/theme-rtl.css +3 -3
- package/build-style/quote/theme.css +3 -3
- package/build-style/read-more/style-rtl.css +3 -3
- package/build-style/read-more/style.css +3 -3
- package/build-style/reset-rtl.css +3 -3
- package/build-style/reset.css +3 -3
- package/build-style/rss/editor-rtl.css +3 -3
- package/build-style/rss/editor.css +3 -3
- package/build-style/rss/style-rtl.css +3 -3
- package/build-style/rss/style.css +3 -3
- package/build-style/search/editor-rtl.css +3 -3
- package/build-style/search/editor.css +3 -3
- package/build-style/search/style-rtl.css +3 -3
- package/build-style/search/style.css +3 -3
- package/build-style/search/theme-rtl.css +3 -3
- package/build-style/search/theme.css +3 -3
- package/build-style/separator/editor-rtl.css +3 -3
- package/build-style/separator/editor.css +3 -3
- package/build-style/separator/style-rtl.css +3 -3
- package/build-style/separator/style.css +3 -3
- package/build-style/separator/theme-rtl.css +3 -3
- package/build-style/separator/theme.css +3 -3
- package/build-style/shortcode/editor-rtl.css +3 -3
- package/build-style/shortcode/editor.css +3 -3
- package/build-style/site-logo/editor-rtl.css +3 -3
- package/build-style/site-logo/editor.css +3 -3
- package/build-style/site-logo/style-rtl.css +3 -3
- package/build-style/site-logo/style.css +3 -3
- package/build-style/site-tagline/editor-rtl.css +3 -3
- package/build-style/site-tagline/editor.css +3 -3
- package/build-style/site-title/editor-rtl.css +3 -3
- package/build-style/site-title/editor.css +3 -3
- package/build-style/site-title/style-rtl.css +3 -3
- package/build-style/site-title/style.css +3 -3
- package/build-style/social-link/editor-rtl.css +3 -3
- package/build-style/social-link/editor.css +3 -3
- package/build-style/social-links/editor-rtl.css +3 -3
- package/build-style/social-links/editor.css +3 -3
- package/build-style/social-links/style-rtl.css +3 -3
- package/build-style/social-links/style.css +3 -3
- package/build-style/spacer/editor-rtl.css +3 -3
- package/build-style/spacer/editor.css +3 -3
- package/build-style/spacer/style-rtl.css +3 -3
- package/build-style/spacer/style.css +3 -3
- package/build-style/style-rtl.css +13 -5
- package/build-style/style.css +13 -5
- package/build-style/table/editor-rtl.css +3 -3
- package/build-style/table/editor.css +3 -3
- package/build-style/table/style-rtl.css +9 -3
- package/build-style/table/style.css +9 -3
- package/build-style/table/theme-rtl.css +3 -9
- package/build-style/table/theme.css +3 -9
- package/build-style/tag-cloud/style-rtl.css +3 -3
- package/build-style/tag-cloud/style.css +3 -3
- package/build-style/template-part/editor-rtl.css +3 -3
- package/build-style/template-part/editor.css +3 -3
- package/build-style/template-part/theme-rtl.css +3 -3
- package/build-style/template-part/theme.css +3 -3
- package/build-style/text-columns/editor-rtl.css +3 -3
- package/build-style/text-columns/editor.css +3 -3
- package/build-style/text-columns/style-rtl.css +3 -3
- package/build-style/text-columns/style.css +3 -3
- package/build-style/theme-rtl.css +3 -9
- package/build-style/theme.css +3 -9
- package/build-style/verse/style-rtl.css +7 -4
- package/build-style/verse/style.css +7 -4
- package/build-style/video/editor-rtl.css +3 -3
- package/build-style/video/editor.css +3 -3
- package/build-style/video/style-rtl.css +3 -3
- package/build-style/video/style.css +3 -3
- package/build-style/video/theme-rtl.css +3 -3
- package/build-style/video/theme.css +3 -3
- package/package.json +29 -29
- package/src/archives/edit.js +1 -0
- package/src/audio/edit.js +2 -0
- package/src/categories/edit.js +1 -1
- package/src/comments/edit/comments-inspector-controls.js +12 -2
- package/src/comments/index.php +0 -1
- package/src/cover/edit/inspector-controls.js +4 -4
- package/src/embed/embed-preview.js +1 -0
- package/src/file/inspector.js +1 -0
- package/src/freeform/edit.js +48 -29
- package/src/freeform/modal.js +111 -0
- package/src/gallery/edit.js +19 -2
- package/src/gallery/gallery.js +4 -13
- package/src/gallery/v1/edit.js +2 -0
- package/src/group/block.json +3 -0
- package/src/group/edit.js +1 -0
- package/src/image/image.js +27 -36
- package/src/latest-posts/edit.js +6 -7
- package/src/latest-posts/test/__snapshots__/edit.native.js.snap +3 -0
- package/src/latest-posts/test/edit.native.js +49 -0
- package/src/media-text/edit.js +1 -0
- package/src/missing/edit.native.js +13 -6
- package/src/more/test/__snapshots__/edit.native.js.snap +7 -0
- package/src/more/test/edit.native.js +41 -0
- package/src/navigation/edit/index.js +6 -4
- package/src/navigation/edit/menu-inspector-controls.js +115 -44
- package/src/navigation/edit/navigation-menu-selector.js +24 -11
- package/src/navigation/edit/utils.js +82 -0
- package/src/navigation/editor.scss +0 -7
- package/src/navigation/index.php +32 -0
- package/src/navigation/leaf-more-menu.js +93 -0
- package/src/navigation/style.scss +0 -1
- package/src/navigation-link/edit.js +23 -65
- package/src/navigation-link/index.php +62 -3
- package/src/navigation-link/update-attributes.js +1 -1
- package/src/navigation-submenu/edit.js +29 -100
- package/src/navigation-submenu/index.php +34 -2
- package/src/page-list/block.json +18 -1
- package/src/page-list/edit.js +30 -22
- package/src/page-list/editor.scss +4 -0
- package/src/page-list/index.js +8 -2
- package/src/page-list/index.php +14 -10
- package/src/page-list-item/block.json +2 -1
- package/src/page-list-item/edit.js +17 -9
- package/src/post-author/edit.js +2 -0
- package/src/post-featured-image/dimension-controls.js +1 -0
- package/src/post-featured-image/overlay.js +0 -1
- package/src/query/edit/index.js +1 -0
- package/src/query/edit/inspector-controls/index.js +50 -38
- package/src/query/edit/inspector-controls/order-control.js +1 -0
- package/src/query/edit/inspector-controls/sticky-control.js +1 -0
- package/src/query/edit/inspector-controls/taxonomy-controls.js +102 -38
- package/src/query/edit/query-content.js +15 -1
- package/src/query/edit/query-placeholder.js +15 -14
- package/src/query/utils.js +59 -1
- package/src/rss/index.php +1 -1
- package/src/search/edit.js +2 -2
- package/src/separator/test/__snapshots__/edit.native.js.snap +7 -0
- package/src/separator/test/edit.native.js +41 -0
- package/src/social-link/edit.js +5 -4
- package/src/social-links/edit.js +0 -1
- package/src/table/edit.js +1 -0
- package/src/table/style.scss +8 -0
- package/src/table/theme.scss +0 -8
- package/src/table-of-contents/edit.js +1 -1
- package/src/tag-cloud/edit.js +1 -0
- package/src/template-part/edit/advanced-controls.js +36 -0
- package/src/template-part/edit/import-controls.js +180 -0
- package/src/template-part/edit/index.js +1 -0
- package/src/template-part/edit/utils/transformers.js +37 -0
- package/src/verse/style.scss +4 -1
- package/src/verse/test/__snapshots__/edit.native.js.snap +13 -0
- package/src/verse/test/edit.native.js +40 -33
- package/src/video/edit-common-settings.js +6 -5
- package/src/video/edit.js +1 -0
- package/src/video/tracks-editor.js +1 -0
- package/tsconfig.tsbuildinfo +1 -1
- package/build/query/constants.js +0 -16
- package/build/query/constants.js.map +0 -1
- package/build-module/query/constants.js +0 -7
- package/build-module/query/constants.js.map +0 -1
- package/src/query/constants.js +0 -7
|
@@ -3,8 +3,9 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
3
3
|
/**
|
|
4
4
|
* WordPress dependencies
|
|
5
5
|
*/
|
|
6
|
-
import { __experimentalOffCanvasEditor as OffCanvasEditor, InspectorControls } from '@wordpress/block-editor';
|
|
7
|
-
import { PanelBody,
|
|
6
|
+
import { __experimentalOffCanvasEditor as OffCanvasEditor, InspectorControls, store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
|
+
import { PanelBody, __experimentalHStack as HStack, __experimentalHeading as Heading, Spinner } from '@wordpress/components';
|
|
8
|
+
import { useSelect } from '@wordpress/data';
|
|
8
9
|
import { __ } from '@wordpress/i18n';
|
|
9
10
|
/**
|
|
10
11
|
* Internal dependencies
|
|
@@ -12,32 +13,57 @@ import { __ } from '@wordpress/i18n';
|
|
|
12
13
|
|
|
13
14
|
import ManageMenusButton from './manage-menus-button';
|
|
14
15
|
import NavigationMenuSelector from './navigation-menu-selector';
|
|
16
|
+
import { LeafMoreMenu } from '../leaf-more-menu';
|
|
17
|
+
/* translators: %s: The name of a menu. */
|
|
15
18
|
|
|
16
|
-
const
|
|
17
|
-
var _window, _window2;
|
|
19
|
+
const actionLabel = __("Switch to '%s'");
|
|
18
20
|
|
|
21
|
+
const ExperimentMainContent = _ref => {
|
|
19
22
|
let {
|
|
23
|
+
clientId,
|
|
24
|
+
currentMenuId,
|
|
25
|
+
isLoading,
|
|
26
|
+
isNavigationMenuMissing
|
|
27
|
+
} = _ref;
|
|
28
|
+
// Provide a hierarchy of clientIds for the given Navigation block (clientId).
|
|
29
|
+
// This is required else the list view will display the entire block tree.
|
|
30
|
+
const clientIdsTree = useSelect(select => {
|
|
31
|
+
const {
|
|
32
|
+
__unstableGetClientIdsTree
|
|
33
|
+
} = select(blockEditorStore);
|
|
34
|
+
return __unstableGetClientIdsTree(clientId);
|
|
35
|
+
}, [clientId]);
|
|
36
|
+
|
|
37
|
+
if (currentMenuId && isNavigationMenuMissing) {
|
|
38
|
+
return createElement("p", null, __('Select or create a menu'));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
if (isLoading) {
|
|
42
|
+
return createElement(Spinner, null);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return createElement(OffCanvasEditor, {
|
|
46
|
+
blocks: clientIdsTree,
|
|
47
|
+
isExpanded: true,
|
|
48
|
+
selectBlockInCanvas: false,
|
|
49
|
+
LeafMoreMenu: LeafMoreMenu
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const ExperimentControls = props => {
|
|
54
|
+
const {
|
|
20
55
|
createNavigationMenuIsSuccess,
|
|
21
56
|
createNavigationMenuIsError,
|
|
22
57
|
currentMenuId = null,
|
|
23
|
-
innerBlocks,
|
|
24
|
-
isManageMenusButtonDisabled,
|
|
25
58
|
onCreateNew,
|
|
26
59
|
onSelectClassicMenu,
|
|
27
60
|
onSelectNavigationMenu
|
|
28
|
-
} =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return createElement(InspectorControls, {
|
|
36
|
-
__experimentalGroup: menuControlsSlot
|
|
37
|
-
}, createElement(PanelBody, {
|
|
38
|
-
title: isOffCanvasNavigationEditorEnabled ? null : __('Menu')
|
|
39
|
-
}, createElement(Fragment, null, isOffCanvasNavigationEditorEnabled && createElement(VisuallyHidden, {
|
|
40
|
-
as: "h2"
|
|
61
|
+
} = props;
|
|
62
|
+
return createElement(Fragment, null, createElement(HStack, {
|
|
63
|
+
className: "wp-block-navigation-off-canvas-editor__header"
|
|
64
|
+
}, createElement(Heading, {
|
|
65
|
+
className: "wp-block-navigation-off-canvas-editor__title",
|
|
66
|
+
level: 2
|
|
41
67
|
}, __('Menu')), createElement(NavigationMenuSelector, {
|
|
42
68
|
currentMenuId: currentMenuId,
|
|
43
69
|
onSelectClassicMenu: onSelectClassicMenu,
|
|
@@ -46,13 +72,42 @@ const MenuInspectorControls = _ref => {
|
|
|
46
72
|
createNavigationMenuIsSuccess: createNavigationMenuIsSuccess,
|
|
47
73
|
createNavigationMenuIsError: createNavigationMenuIsError,
|
|
48
74
|
actionLabel: actionLabel
|
|
49
|
-
}),
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
75
|
+
})), createElement(ExperimentMainContent, props));
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const DefaultControls = props => {
|
|
79
|
+
const {
|
|
80
|
+
createNavigationMenuIsSuccess,
|
|
81
|
+
createNavigationMenuIsError,
|
|
82
|
+
currentMenuId = null,
|
|
83
|
+
isManageMenusButtonDisabled,
|
|
84
|
+
onCreateNew,
|
|
85
|
+
onSelectClassicMenu,
|
|
86
|
+
onSelectNavigationMenu
|
|
87
|
+
} = props;
|
|
88
|
+
return createElement(Fragment, null, createElement(NavigationMenuSelector, {
|
|
89
|
+
currentMenuId: currentMenuId,
|
|
90
|
+
onSelectClassicMenu: onSelectClassicMenu,
|
|
91
|
+
onSelectNavigationMenu: onSelectNavigationMenu,
|
|
92
|
+
onCreateNew: onCreateNew,
|
|
93
|
+
createNavigationMenuIsSuccess: createNavigationMenuIsSuccess,
|
|
94
|
+
createNavigationMenuIsError: createNavigationMenuIsError,
|
|
95
|
+
actionLabel: actionLabel
|
|
96
|
+
}), createElement(ManageMenusButton, {
|
|
54
97
|
disabled: isManageMenusButtonDisabled
|
|
55
|
-
}))
|
|
98
|
+
}));
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const MenuInspectorControls = props => {
|
|
102
|
+
var _window;
|
|
103
|
+
|
|
104
|
+
const isOffCanvasNavigationEditorEnabled = ((_window = window) === null || _window === void 0 ? void 0 : _window.__experimentalEnableOffCanvasNavigationEditor) === true;
|
|
105
|
+
const menuControlsSlot = isOffCanvasNavigationEditorEnabled ? 'list' : undefined;
|
|
106
|
+
return createElement(InspectorControls, {
|
|
107
|
+
__experimentalGroup: menuControlsSlot
|
|
108
|
+
}, createElement(PanelBody, {
|
|
109
|
+
title: isOffCanvasNavigationEditorEnabled ? null : __('Menu')
|
|
110
|
+
}, isOffCanvasNavigationEditorEnabled ? createElement(ExperimentControls, props) : createElement(DefaultControls, props)));
|
|
56
111
|
};
|
|
57
112
|
|
|
58
113
|
export default MenuInspectorControls;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/navigation/edit/menu-inspector-controls.js"],"names":["__experimentalOffCanvasEditor","OffCanvasEditor","InspectorControls","PanelBody","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/navigation/edit/menu-inspector-controls.js"],"names":["__experimentalOffCanvasEditor","OffCanvasEditor","InspectorControls","store","blockEditorStore","PanelBody","__experimentalHStack","HStack","__experimentalHeading","Heading","Spinner","useSelect","__","ManageMenusButton","NavigationMenuSelector","LeafMoreMenu","actionLabel","ExperimentMainContent","clientId","currentMenuId","isLoading","isNavigationMenuMissing","clientIdsTree","select","__unstableGetClientIdsTree","ExperimentControls","props","createNavigationMenuIsSuccess","createNavigationMenuIsError","onCreateNew","onSelectClassicMenu","onSelectNavigationMenu","DefaultControls","isManageMenusButtonDisabled","MenuInspectorControls","isOffCanvasNavigationEditorEnabled","window","__experimentalEnableOffCanvasNavigationEditor","menuControlsSlot","undefined"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,6BAA6B,IAAIC,eADlC,EAECC,iBAFD,EAGCC,KAAK,IAAIC,gBAHV,QAIO,yBAJP;AAKA,SACCC,SADD,EAECC,oBAAoB,IAAIC,MAFzB,EAGCC,qBAAqB,IAAIC,OAH1B,EAICC,OAJD,QAKO,uBALP;AAMA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,iBAAP,MAA8B,uBAA9B;AACA,OAAOC,sBAAP,MAAmC,4BAAnC;AACA,SAASC,YAAT,QAA6B,mBAA7B;AAEA;;AACA,MAAMC,WAAW,GAAGJ,EAAE,CAAE,gBAAF,CAAtB;;AAEA,MAAMK,qBAAqB,GAAG,QAKvB;AAAA,MALyB;AAC/BC,IAAAA,QAD+B;AAE/BC,IAAAA,aAF+B;AAG/BC,IAAAA,SAH+B;AAI/BC,IAAAA;AAJ+B,GAKzB;AACN;AACA;AACA,QAAMC,aAAa,GAAGX,SAAS,CAC5BY,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAAiCD,MAAM,CAAEnB,gBAAF,CAA7C;AACA,WAAOoB,0BAA0B,CAAEN,QAAF,CAAjC;AACA,GAJ6B,EAK9B,CAAEA,QAAF,CAL8B,CAA/B;;AAQA,MAAKC,aAAa,IAAIE,uBAAtB,EAAgD;AAC/C,WAAO,yBAAKT,EAAE,CAAE,yBAAF,CAAP,CAAP;AACA;;AAED,MAAKQ,SAAL,EAAiB;AAChB,WAAO,cAAC,OAAD,OAAP;AACA;;AAED,SACC,cAAC,eAAD;AACC,IAAA,MAAM,EAAGE,aADV;AAEC,IAAA,UAAU,EAAG,IAFd;AAGC,IAAA,mBAAmB,EAAG,KAHvB;AAIC,IAAA,YAAY,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AC,iBAAD;AAAmB,IAAA,QAAQ,EAAGiB;AAA9B,IAVD,CADD;AAcA,CAzBD;;AA2BA,MAAMC,qBAAqB,GAAKR,KAAF,IAAa;AAAA;;AAC1C,QAAMS,kCAAkC,GACvC,YAAAC,MAAM,UAAN,0CAAQC,6CAAR,MAA0D,IAD3D;AAEA,QAAMC,gBAAgB,GAAGH,kCAAkC,GACxD,MADwD,GAExDI,SAFH;AAIA,SACC,cAAC,iBAAD;AAAmB,IAAA,mBAAmB,EAAGD;AAAzC,KACC,cAAC,SAAD;AACC,IAAA,KAAK,EACJH,kCAAkC,GAAG,IAAH,GAAUvB,EAAE,CAAE,MAAF;AAFhD,KAKGuB,kCAAkC,GACnC,cAAC,kBAAD,EAAyBT,KAAzB,CADmC,GAGnC,cAAC,eAAD,EAAsBA,KAAtB,CARF,CADD,CADD;AAeA,CAtBD;;AAwBA,eAAeQ,qBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\t__experimentalOffCanvasEditor as OffCanvasEditor,\n\tInspectorControls,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tPanelBody,\n\t__experimentalHStack as HStack,\n\t__experimentalHeading as Heading,\n\tSpinner,\n} from '@wordpress/components';\nimport { useSelect } from '@wordpress/data';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport ManageMenusButton from './manage-menus-button';\nimport NavigationMenuSelector from './navigation-menu-selector';\nimport { LeafMoreMenu } from '../leaf-more-menu';\n\n/* translators: %s: The name of a menu. */\nconst actionLabel = __( \"Switch to '%s'\" );\n\nconst ExperimentMainContent = ( {\n\tclientId,\n\tcurrentMenuId,\n\tisLoading,\n\tisNavigationMenuMissing,\n} ) => {\n\t// Provide a hierarchy of clientIds for the given Navigation block (clientId).\n\t// This is required else the list view will display the entire block tree.\n\tconst clientIdsTree = useSelect(\n\t\t( select ) => {\n\t\t\tconst { __unstableGetClientIdsTree } = select( blockEditorStore );\n\t\t\treturn __unstableGetClientIdsTree( clientId );\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tif ( currentMenuId && isNavigationMenuMissing ) {\n\t\treturn <p>{ __( 'Select or create a menu' ) }</p>;\n\t}\n\n\tif ( isLoading ) {\n\t\treturn <Spinner />;\n\t}\n\n\treturn (\n\t\t<OffCanvasEditor\n\t\t\tblocks={ clientIdsTree }\n\t\t\tisExpanded={ true }\n\t\t\tselectBlockInCanvas={ false }\n\t\t\tLeafMoreMenu={ LeafMoreMenu }\n\t\t/>\n\t);\n};\n\nconst ExperimentControls = ( props ) => {\n\tconst {\n\t\tcreateNavigationMenuIsSuccess,\n\t\tcreateNavigationMenuIsError,\n\t\tcurrentMenuId = null,\n\t\tonCreateNew,\n\t\tonSelectClassicMenu,\n\t\tonSelectNavigationMenu,\n\t} = props;\n\n\treturn (\n\t\t<>\n\t\t\t<HStack className=\"wp-block-navigation-off-canvas-editor__header\">\n\t\t\t\t<Heading\n\t\t\t\t\tclassName=\"wp-block-navigation-off-canvas-editor__title\"\n\t\t\t\t\tlevel={ 2 }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Menu' ) }\n\t\t\t\t</Heading>\n\t\t\t\t<NavigationMenuSelector\n\t\t\t\t\tcurrentMenuId={ currentMenuId }\n\t\t\t\t\tonSelectClassicMenu={ onSelectClassicMenu }\n\t\t\t\t\tonSelectNavigationMenu={ onSelectNavigationMenu }\n\t\t\t\t\tonCreateNew={ onCreateNew }\n\t\t\t\t\tcreateNavigationMenuIsSuccess={\n\t\t\t\t\t\tcreateNavigationMenuIsSuccess\n\t\t\t\t\t}\n\t\t\t\t\tcreateNavigationMenuIsError={ createNavigationMenuIsError }\n\t\t\t\t\tactionLabel={ actionLabel }\n\t\t\t\t/>\n\t\t\t</HStack>\n\t\t\t<ExperimentMainContent { ...props } />\n\t\t</>\n\t);\n};\n\nconst DefaultControls = ( props ) => {\n\tconst {\n\t\tcreateNavigationMenuIsSuccess,\n\t\tcreateNavigationMenuIsError,\n\t\tcurrentMenuId = null,\n\t\tisManageMenusButtonDisabled,\n\t\tonCreateNew,\n\t\tonSelectClassicMenu,\n\t\tonSelectNavigationMenu,\n\t} = props;\n\n\treturn (\n\t\t<>\n\t\t\t<NavigationMenuSelector\n\t\t\t\tcurrentMenuId={ currentMenuId }\n\t\t\t\tonSelectClassicMenu={ onSelectClassicMenu }\n\t\t\t\tonSelectNavigationMenu={ onSelectNavigationMenu }\n\t\t\t\tonCreateNew={ onCreateNew }\n\t\t\t\tcreateNavigationMenuIsSuccess={ createNavigationMenuIsSuccess }\n\t\t\t\tcreateNavigationMenuIsError={ createNavigationMenuIsError }\n\t\t\t\tactionLabel={ actionLabel }\n\t\t\t/>\n\t\t\t<ManageMenusButton disabled={ isManageMenusButtonDisabled } />\n\t\t</>\n\t);\n};\n\nconst MenuInspectorControls = ( props ) => {\n\tconst isOffCanvasNavigationEditorEnabled =\n\t\twindow?.__experimentalEnableOffCanvasNavigationEditor === true;\n\tconst menuControlsSlot = isOffCanvasNavigationEditorEnabled\n\t\t? 'list'\n\t\t: undefined;\n\n\treturn (\n\t\t<InspectorControls __experimentalGroup={ menuControlsSlot }>\n\t\t\t<PanelBody\n\t\t\t\ttitle={\n\t\t\t\t\tisOffCanvasNavigationEditorEnabled ? null : __( 'Menu' )\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ isOffCanvasNavigationEditorEnabled ? (\n\t\t\t\t\t<ExperimentControls { ...props } />\n\t\t\t\t) : (\n\t\t\t\t\t<DefaultControls { ...props } />\n\t\t\t\t) }\n\t\t\t</PanelBody>\n\t\t</InspectorControls>\n\t);\n};\n\nexport default MenuInspectorControls;\n"]}
|
|
@@ -5,7 +5,7 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
5
5
|
*/
|
|
6
6
|
import { MenuGroup, MenuItem, MenuItemsChoice, DropdownMenu, Button, VisuallyHidden } from '@wordpress/components';
|
|
7
7
|
import { useEntityProp } from '@wordpress/core-data';
|
|
8
|
-
import { Icon, chevronUp, chevronDown } from '@wordpress/icons';
|
|
8
|
+
import { Icon, chevronUp, chevronDown, moreVertical } from '@wordpress/icons';
|
|
9
9
|
import { __, sprintf } from '@wordpress/i18n';
|
|
10
10
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
11
11
|
import { useEffect, useMemo, useState } from '@wordpress/element';
|
|
@@ -17,6 +17,8 @@ import useNavigationMenu from '../use-navigation-menu';
|
|
|
17
17
|
import useNavigationEntities from '../use-navigation-entities';
|
|
18
18
|
|
|
19
19
|
function NavigationMenuSelector(_ref) {
|
|
20
|
+
var _window;
|
|
21
|
+
|
|
20
22
|
let {
|
|
21
23
|
currentMenuId,
|
|
22
24
|
onSelectNavigationMenu,
|
|
@@ -27,8 +29,9 @@ function NavigationMenuSelector(_ref) {
|
|
|
27
29
|
createNavigationMenuIsError,
|
|
28
30
|
toggleProps = {}
|
|
29
31
|
} = _ref;
|
|
30
|
-
|
|
32
|
+
const isOffCanvasNavigationEditorEnabled = ((_window = window) === null || _window === void 0 ? void 0 : _window.__experimentalEnableOffCanvasNavigationEditor) === true;
|
|
31
33
|
/* translators: %s: The name of a menu. */
|
|
34
|
+
|
|
32
35
|
const createActionLabel = __("Create from '%s'");
|
|
33
36
|
|
|
34
37
|
const [selectorLabel, setSelectorLabel] = useState('');
|
|
@@ -57,7 +60,9 @@ function NavigationMenuSelector(_ref) {
|
|
|
57
60
|
const label = decodeEntities(title.rendered);
|
|
58
61
|
|
|
59
62
|
if (id === currentMenuId && !isCreatingMenu) {
|
|
60
|
-
setSelectorLabel(
|
|
63
|
+
setSelectorLabel(
|
|
64
|
+
/* translators: %s is the name of a navigation menu. */
|
|
65
|
+
sprintf(__('You are currently editing %s'), label));
|
|
61
66
|
setEnableOptions(shouldEnableMenuSelector);
|
|
62
67
|
}
|
|
63
68
|
|
|
@@ -79,7 +84,7 @@ function NavigationMenuSelector(_ref) {
|
|
|
79
84
|
if (!hasResolvedNavigationMenus) {
|
|
80
85
|
setSelectorLabel(__('Loading …'));
|
|
81
86
|
} else if (noMenuSelected || noBlockMenus || menuUnavailable) {
|
|
82
|
-
setSelectorLabel(__('
|
|
87
|
+
setSelectorLabel(__('Choose a Navigation menu'));
|
|
83
88
|
setEnableOptions(shouldEnableMenuSelector);
|
|
84
89
|
}
|
|
85
90
|
|
|
@@ -103,7 +108,7 @@ function NavigationMenuSelector(_ref) {
|
|
|
103
108
|
}
|
|
104
109
|
};
|
|
105
110
|
|
|
106
|
-
if (!hasNavigationMenus && !hasClassicMenus) {
|
|
111
|
+
if (!hasNavigationMenus && !hasClassicMenus && !isOffCanvasNavigationEditorEnabled) {
|
|
107
112
|
return createElement(Button, {
|
|
108
113
|
className: "wp-block-navigation__navigation-selector-button--createnew",
|
|
109
114
|
isBusy: !enableOptions,
|
|
@@ -119,13 +124,13 @@ function NavigationMenuSelector(_ref) {
|
|
|
119
124
|
}
|
|
120
125
|
|
|
121
126
|
return createElement(DropdownMenu, {
|
|
122
|
-
className:
|
|
127
|
+
className: isOffCanvasNavigationEditorEnabled ? '' : 'wp-block-navigation__navigation-selector',
|
|
123
128
|
label: selectorLabel,
|
|
124
|
-
text:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
+
text: isOffCanvasNavigationEditorEnabled ? '' : selectorLabel,
|
|
130
|
+
icon: isOffCanvasNavigationEditorEnabled ? moreVertical : null,
|
|
131
|
+
toggleProps: isOffCanvasNavigationEditorEnabled ? {
|
|
132
|
+
isSmall: true
|
|
133
|
+
} : toggleProps
|
|
129
134
|
}, _ref3 => {
|
|
130
135
|
let {
|
|
131
136
|
onClose
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/navigation/edit/navigation-menu-selector.js"],"names":["MenuGroup","MenuItem","MenuItemsChoice","DropdownMenu","Button","VisuallyHidden","useEntityProp","Icon","chevronUp","chevronDown","__","sprintf","decodeEntities","useEffect","useMemo","useState","useNavigationMenu","useNavigationEntities","NavigationMenuSelector","currentMenuId","onSelectNavigationMenu","onSelectClassicMenu","onCreateNew","actionLabel","createNavigationMenuIsSuccess","createNavigationMenuIsError","toggleProps","createActionLabel","selectorLabel","setSelectorLabel","isPressed","setIsPressed","enableOptions","setEnableOptions","isCreatingMenu","setIsCreatingMenu","menus","classicMenus","navigationMenus","hasResolvedNavigationMenus","isNavigationMenuResolved","canUserCreateNavigationMenu","canSwitchNavigationMenu","currentTitle","shouldEnableMenuSelector","menuChoices","map","id","title","label","rendered","value","ariaLabel","hasNavigationMenus","length","hasClassicMenus","showNavigationMenus","showClassicMenus","noMenuSelected","noBlockMenus","menuUnavailable","className","children","isBusy","disabled","__experimentalIsFocusable","onClick","onClose","menuId","menu","name"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,SADD,EAECC,QAFD,EAGCC,eAHD,EAICC,YAJD,EAKCC,MALD,EAMCC,cAND,QAOO,uBAPP;AAQA,SAASC,aAAT,QAA8B,sBAA9B;AACA,SAASC,IAAT,EAAeC,SAAf,EAA0BC,WAA1B,QAA6C,kBAA7C;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,cAAT,QAA+B,0BAA/B;AACA,SAASC,SAAT,EAAoBC,OAApB,EAA6BC,QAA7B,QAA6C,oBAA7C;AAEA;AACA;AACA;;AACA,OAAOC,iBAAP,MAA8B,wBAA9B;AACA,OAAOC,qBAAP,MAAkC,4BAAlC;;AAEA,SAASC,sBAAT,OASI;AAAA,MAT6B;AAChCC,IAAAA,aADgC;AAEhCC,IAAAA,sBAFgC;AAGhCC,IAAAA,mBAHgC;AAIhCC,IAAAA,WAJgC;AAKhCC,IAAAA,WALgC;AAMhCC,IAAAA,6BANgC;AAOhCC,IAAAA,2BAPgC;AAQhCC,IAAAA,WAAW,GAAG;AARkB,GAS7B;;AACH;AACA,QAAMC,iBAAiB,GAAGjB,EAAE,CAAE,kBAAF,CAA5B;;AAEA,QAAM,CAAEkB,aAAF,EAAiBC,gBAAjB,IAAsCd,QAAQ,CAAE,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,eAAeQ,sBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tMenuGroup,\n\tMenuItem,\n\tMenuItemsChoice,\n\tDropdownMenu,\n\tButton,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { Icon, chevronUp, chevronDown } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useNavigationMenu from '../use-navigation-menu';\nimport useNavigationEntities from '../use-navigation-entities';\n\nfunction NavigationMenuSelector( {\n\tcurrentMenuId,\n\tonSelectNavigationMenu,\n\tonSelectClassicMenu,\n\tonCreateNew,\n\tactionLabel,\n\tcreateNavigationMenuIsSuccess,\n\tcreateNavigationMenuIsError,\n\ttoggleProps = {},\n} ) {\n\t/* translators: %s: The name of a menu. */\n\tconst createActionLabel = __( \"Create from '%s'\" );\n\n\tconst [ selectorLabel, setSelectorLabel ] = useState( '' );\n\tconst [ isPressed, setIsPressed ] = useState( false );\n\tconst [ enableOptions, setEnableOptions ] = useState( false );\n\tconst [ isCreatingMenu, setIsCreatingMenu ] = useState( false );\n\n\tactionLabel = actionLabel || createActionLabel;\n\n\tconst { menus: classicMenus } = useNavigationEntities();\n\n\tconst {\n\t\tnavigationMenus,\n\t\thasResolvedNavigationMenus,\n\t\tisNavigationMenuResolved,\n\t\tcanUserCreateNavigationMenu,\n\t\tcanSwitchNavigationMenu,\n\t} = useNavigationMenu();\n\n\tconst [ currentTitle ] = useEntityProp(\n\t\t'postType',\n\t\t'wp_navigation',\n\t\t'title'\n\t);\n\n\tconst shouldEnableMenuSelector =\n\t\t( canSwitchNavigationMenu || canUserCreateNavigationMenu ) &&\n\t\thasResolvedNavigationMenus &&\n\t\t! isCreatingMenu;\n\n\tconst menuChoices = useMemo( () => {\n\t\treturn (\n\t\t\tnavigationMenus?.map( ( { id, title } ) => {\n\t\t\t\tconst label = decodeEntities( title.rendered );\n\t\t\t\tif ( id === currentMenuId && ! isCreatingMenu ) {\n\t\t\t\t\tsetSelectorLabel( currentTitle );\n\t\t\t\t\tsetEnableOptions( shouldEnableMenuSelector );\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tvalue: id,\n\t\t\t\t\tlabel,\n\t\t\t\t\tariaLabel: sprintf( actionLabel, label ),\n\t\t\t\t};\n\t\t\t} ) || []\n\t\t);\n\t}, [\n\t\tcurrentTitle,\n\t\tcurrentMenuId,\n\t\tnavigationMenus,\n\t\tcreateNavigationMenuIsSuccess,\n\t\tisNavigationMenuResolved,\n\t\thasResolvedNavigationMenus,\n\t] );\n\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\tconst hasClassicMenus = !! classicMenus?.length;\n\tconst showNavigationMenus = !! canSwitchNavigationMenu;\n\tconst showClassicMenus = !! canUserCreateNavigationMenu;\n\n\tconst noMenuSelected = hasNavigationMenus && ! currentMenuId;\n\tconst noBlockMenus = ! hasNavigationMenus && hasResolvedNavigationMenus;\n\tconst menuUnavailable =\n\t\thasResolvedNavigationMenus && currentMenuId === null;\n\n\tuseEffect( () => {\n\t\tif ( ! hasResolvedNavigationMenus ) {\n\t\t\tsetSelectorLabel( __( 'Loading …' ) );\n\t\t} else if ( noMenuSelected || noBlockMenus || menuUnavailable ) {\n\t\t\tsetSelectorLabel( __( 'Select menu' ) );\n\t\t\tsetEnableOptions( shouldEnableMenuSelector );\n\t\t}\n\n\t\tif (\n\t\t\tisCreatingMenu &&\n\t\t\t( createNavigationMenuIsSuccess || createNavigationMenuIsError )\n\t\t) {\n\t\t\tsetIsCreatingMenu( false );\n\t\t}\n\t}, [\n\t\tcurrentMenuId,\n\t\thasNavigationMenus,\n\t\thasResolvedNavigationMenus,\n\t\tcreateNavigationMenuIsSuccess,\n\t\tisNavigationMenuResolved,\n\t] );\n\n\ttoggleProps = {\n\t\t...toggleProps,\n\t\tclassName: 'wp-block-navigation__navigation-selector-button',\n\t\tchildren: (\n\t\t\t<>\n\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t{ __( 'Select Menu' ) }\n\t\t\t\t</VisuallyHidden>\n\t\t\t\t<Icon\n\t\t\t\t\ticon={ isPressed ? chevronUp : chevronDown }\n\t\t\t\t\tclassName=\"wp-block-navigation__navigation-selector-button__icon\"\n\t\t\t\t/>\n\t\t\t</>\n\t\t),\n\t\tisBusy: ! enableOptions,\n\t\tdisabled: ! enableOptions,\n\t\t__experimentalIsFocusable: true,\n\t\tonClick: () => {\n\t\t\tsetIsPressed( ! isPressed );\n\t\t},\n\t};\n\n\tif ( ! hasNavigationMenus && ! hasClassicMenus ) {\n\t\treturn (\n\t\t\t<Button\n\t\t\t\tclassName=\"wp-block-navigation__navigation-selector-button--createnew\"\n\t\t\t\tisBusy={ ! enableOptions }\n\t\t\t\tdisabled={ ! enableOptions }\n\t\t\t\t__experimentalIsFocusable\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tonCreateNew();\n\t\t\t\t\tsetIsCreatingMenu( true );\n\t\t\t\t\tsetSelectorLabel( __( 'Loading …' ) );\n\t\t\t\t\tsetEnableOptions( false );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Create new menu' ) }\n\t\t\t</Button>\n\t\t);\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName=\"wp-block-navigation__navigation-selector\"\n\t\t\tlabel={ selectorLabel }\n\t\t\ttext={\n\t\t\t\t<span className=\"wp-block-navigation__navigation-selector-button__label\">\n\t\t\t\t\t{ selectorLabel }\n\t\t\t\t</span>\n\t\t\t}\n\t\t\ticon={ null }\n\t\t\ttoggleProps={ toggleProps }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t{ showNavigationMenus && hasNavigationMenus && (\n\t\t\t\t\t\t<MenuGroup label={ __( 'Menus' ) }>\n\t\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\t\tvalue={ currentMenuId }\n\t\t\t\t\t\t\t\tonSelect={ ( menuId ) => {\n\t\t\t\t\t\t\t\t\tonSelectNavigationMenu( menuId );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tchoices={ menuChoices }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t\t{ showClassicMenus && hasClassicMenus && (\n\t\t\t\t\t\t<MenuGroup label={ __( 'Import Classic Menus' ) }>\n\t\t\t\t\t\t\t{ classicMenus?.map( ( menu ) => {\n\t\t\t\t\t\t\t\tconst label = decodeEntities( menu.name );\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetSelectorLabel(\n\t\t\t\t\t\t\t\t\t\t\t\t__( 'Loading …' )\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\tsetEnableOptions( false );\n\t\t\t\t\t\t\t\t\t\t\tonSelectClassicMenu( menu );\n\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tkey={ menu.id }\n\t\t\t\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t\t\t\tcreateActionLabel,\n\t\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ canUserCreateNavigationMenu && (\n\t\t\t\t\t\t<MenuGroup label={ __( 'Tools' ) }>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\tonCreateNew();\n\t\t\t\t\t\t\t\t\tsetIsCreatingMenu( true );\n\t\t\t\t\t\t\t\t\tsetSelectorLabel( __( 'Loading …' ) );\n\t\t\t\t\t\t\t\t\tsetEnableOptions( false );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Create new menu' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nexport default NavigationMenuSelector;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/navigation/edit/navigation-menu-selector.js"],"names":["MenuGroup","MenuItem","MenuItemsChoice","DropdownMenu","Button","VisuallyHidden","useEntityProp","Icon","chevronUp","chevronDown","moreVertical","__","sprintf","decodeEntities","useEffect","useMemo","useState","useNavigationMenu","useNavigationEntities","NavigationMenuSelector","currentMenuId","onSelectNavigationMenu","onSelectClassicMenu","onCreateNew","actionLabel","createNavigationMenuIsSuccess","createNavigationMenuIsError","toggleProps","isOffCanvasNavigationEditorEnabled","window","__experimentalEnableOffCanvasNavigationEditor","createActionLabel","selectorLabel","setSelectorLabel","isPressed","setIsPressed","enableOptions","setEnableOptions","isCreatingMenu","setIsCreatingMenu","menus","classicMenus","navigationMenus","hasResolvedNavigationMenus","isNavigationMenuResolved","canUserCreateNavigationMenu","canSwitchNavigationMenu","currentTitle","shouldEnableMenuSelector","menuChoices","map","id","title","label","rendered","value","ariaLabel","hasNavigationMenus","length","hasClassicMenus","showNavigationMenus","showClassicMenus","noMenuSelected","noBlockMenus","menuUnavailable","className","children","isBusy","disabled","__experimentalIsFocusable","onClick","isSmall","onClose","menuId","menu","name"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,SADD,EAECC,QAFD,EAGCC,eAHD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,OAJF;AAKC,MAAA,OAAO,EAAGxB;AALX,MADD,CAFF,EAYGY,gBAAgB,IAAIF,eAApB,IACD,cAAC,SAAD;AAAW,MAAA,KAAK,EAAGhD,EAAE,CAAE,sBAAF;AAArB,OACG8B,YADH,aACGA,YADH,uBACGA,YAAY,CAAES,GAAd,CAAqBwB,IAAF,IAAY;AAChC,YAAMrB,KAAK,GAAGxC,cAAc,CAAE6D,IAAI,CAACC,IAAP,CAA5B;AACA,aACC,cAAC,QAAD;AACC,QAAA,OAAO,EAAG,MAAM;AACf1C,UAAAA,gBAAgB,CACftB,EAAE,CAAE,WAAF,CADa,CAAhB;AAGA0B,UAAAA,gBAAgB,CAAE,KAAF,CAAhB;AACAf,UAAAA,mBAAmB,CAAEoD,IAAF,CAAnB;AACAF,UAAAA,OAAO;AACP,SARF;AASC,QAAA,GAAG,EAAGE,IAAI,CAACvB,EATZ;AAUC,sBAAavC,OAAO,CACnBmB,iBADmB,EAEnBsB,KAFmB;AAVrB,SAeGA,KAfH,CADD;AAmBA,KArBC,CADH,CAbF,EAuCGR,2BAA2B,IAC5B,cAAC,SAAD;AAAW,MAAA,KAAK,EAAGlC,EAAE,CAAE,OAAF;AAArB,OACC,cAAC,QAAD;AACC,MAAA,OAAO,EAAG,MAAM;AACf6D,QAAAA,OAAO;AACPjD,QAAAA,WAAW;AACXgB,QAAAA,iBAAiB,CAAE,IAAF,CAAjB;AACAN,QAAAA,gBAAgB,CAAEtB,EAAE,CAAE,WAAF,CAAJ,CAAhB;AACA0B,QAAAA,gBAAgB,CAAE,KAAF,CAAhB;AACA;AAPF,OASG1B,EAAE,CAAE,iBAAF,CATL,CADD,CAxCF,CADC;AAAA,GAfH,CADD;AA2EA;;AAED,eAAeQ,sBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tMenuGroup,\n\tMenuItem,\n\tMenuItemsChoice,\n\tDropdownMenu,\n\tButton,\n\tVisuallyHidden,\n} from '@wordpress/components';\nimport { useEntityProp } from '@wordpress/core-data';\nimport { Icon, chevronUp, chevronDown, moreVertical } from '@wordpress/icons';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { useEffect, useMemo, useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useNavigationMenu from '../use-navigation-menu';\nimport useNavigationEntities from '../use-navigation-entities';\n\nfunction NavigationMenuSelector( {\n\tcurrentMenuId,\n\tonSelectNavigationMenu,\n\tonSelectClassicMenu,\n\tonCreateNew,\n\tactionLabel,\n\tcreateNavigationMenuIsSuccess,\n\tcreateNavigationMenuIsError,\n\ttoggleProps = {},\n} ) {\n\tconst isOffCanvasNavigationEditorEnabled =\n\t\twindow?.__experimentalEnableOffCanvasNavigationEditor === true;\n\t/* translators: %s: The name of a menu. */\n\tconst createActionLabel = __( \"Create from '%s'\" );\n\n\tconst [ selectorLabel, setSelectorLabel ] = useState( '' );\n\tconst [ isPressed, setIsPressed ] = useState( false );\n\tconst [ enableOptions, setEnableOptions ] = useState( false );\n\tconst [ isCreatingMenu, setIsCreatingMenu ] = useState( false );\n\n\tactionLabel = actionLabel || createActionLabel;\n\n\tconst { menus: classicMenus } = useNavigationEntities();\n\n\tconst {\n\t\tnavigationMenus,\n\t\thasResolvedNavigationMenus,\n\t\tisNavigationMenuResolved,\n\t\tcanUserCreateNavigationMenu,\n\t\tcanSwitchNavigationMenu,\n\t} = useNavigationMenu();\n\n\tconst [ currentTitle ] = useEntityProp(\n\t\t'postType',\n\t\t'wp_navigation',\n\t\t'title'\n\t);\n\n\tconst shouldEnableMenuSelector =\n\t\t( canSwitchNavigationMenu || canUserCreateNavigationMenu ) &&\n\t\thasResolvedNavigationMenus &&\n\t\t! isCreatingMenu;\n\n\tconst menuChoices = useMemo( () => {\n\t\treturn (\n\t\t\tnavigationMenus?.map( ( { id, title } ) => {\n\t\t\t\tconst label = decodeEntities( title.rendered );\n\t\t\t\tif ( id === currentMenuId && ! isCreatingMenu ) {\n\t\t\t\t\tsetSelectorLabel(\n\t\t\t\t\t\t/* translators: %s is the name of a navigation menu. */\n\t\t\t\t\t\tsprintf( __( 'You are currently editing %s' ), label )\n\t\t\t\t\t);\n\t\t\t\t\tsetEnableOptions( shouldEnableMenuSelector );\n\t\t\t\t}\n\t\t\t\treturn {\n\t\t\t\t\tvalue: id,\n\t\t\t\t\tlabel,\n\t\t\t\t\tariaLabel: sprintf( actionLabel, label ),\n\t\t\t\t};\n\t\t\t} ) || []\n\t\t);\n\t}, [\n\t\tcurrentTitle,\n\t\tcurrentMenuId,\n\t\tnavigationMenus,\n\t\tcreateNavigationMenuIsSuccess,\n\t\tisNavigationMenuResolved,\n\t\thasResolvedNavigationMenus,\n\t] );\n\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\tconst hasClassicMenus = !! classicMenus?.length;\n\tconst showNavigationMenus = !! canSwitchNavigationMenu;\n\tconst showClassicMenus = !! canUserCreateNavigationMenu;\n\n\tconst noMenuSelected = hasNavigationMenus && ! currentMenuId;\n\tconst noBlockMenus = ! hasNavigationMenus && hasResolvedNavigationMenus;\n\tconst menuUnavailable =\n\t\thasResolvedNavigationMenus && currentMenuId === null;\n\n\tuseEffect( () => {\n\t\tif ( ! hasResolvedNavigationMenus ) {\n\t\t\tsetSelectorLabel( __( 'Loading …' ) );\n\t\t} else if ( noMenuSelected || noBlockMenus || menuUnavailable ) {\n\t\t\tsetSelectorLabel( __( 'Choose a Navigation menu' ) );\n\t\t\tsetEnableOptions( shouldEnableMenuSelector );\n\t\t}\n\n\t\tif (\n\t\t\tisCreatingMenu &&\n\t\t\t( createNavigationMenuIsSuccess || createNavigationMenuIsError )\n\t\t) {\n\t\t\tsetIsCreatingMenu( false );\n\t\t}\n\t}, [\n\t\tcurrentMenuId,\n\t\thasNavigationMenus,\n\t\thasResolvedNavigationMenus,\n\t\tcreateNavigationMenuIsSuccess,\n\t\tisNavigationMenuResolved,\n\t] );\n\n\ttoggleProps = {\n\t\t...toggleProps,\n\t\tclassName: 'wp-block-navigation__navigation-selector-button',\n\t\tchildren: (\n\t\t\t<>\n\t\t\t\t<VisuallyHidden as=\"span\">\n\t\t\t\t\t{ __( 'Select Menu' ) }\n\t\t\t\t</VisuallyHidden>\n\t\t\t\t<Icon\n\t\t\t\t\ticon={ isPressed ? chevronUp : chevronDown }\n\t\t\t\t\tclassName=\"wp-block-navigation__navigation-selector-button__icon\"\n\t\t\t\t/>\n\t\t\t</>\n\t\t),\n\t\tisBusy: ! enableOptions,\n\t\tdisabled: ! enableOptions,\n\t\t__experimentalIsFocusable: true,\n\t\tonClick: () => {\n\t\t\tsetIsPressed( ! isPressed );\n\t\t},\n\t};\n\n\tif (\n\t\t! hasNavigationMenus &&\n\t\t! hasClassicMenus &&\n\t\t! isOffCanvasNavigationEditorEnabled\n\t) {\n\t\treturn (\n\t\t\t<Button\n\t\t\t\tclassName=\"wp-block-navigation__navigation-selector-button--createnew\"\n\t\t\t\tisBusy={ ! enableOptions }\n\t\t\t\tdisabled={ ! enableOptions }\n\t\t\t\t__experimentalIsFocusable\n\t\t\t\tonClick={ () => {\n\t\t\t\t\tonCreateNew();\n\t\t\t\t\tsetIsCreatingMenu( true );\n\t\t\t\t\tsetSelectorLabel( __( 'Loading …' ) );\n\t\t\t\t\tsetEnableOptions( false );\n\t\t\t\t} }\n\t\t\t>\n\t\t\t\t{ __( 'Create new menu' ) }\n\t\t\t</Button>\n\t\t);\n\t}\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\tclassName={\n\t\t\t\tisOffCanvasNavigationEditorEnabled\n\t\t\t\t\t? ''\n\t\t\t\t\t: 'wp-block-navigation__navigation-selector'\n\t\t\t}\n\t\t\tlabel={ selectorLabel }\n\t\t\ttext={ isOffCanvasNavigationEditorEnabled ? '' : selectorLabel }\n\t\t\ticon={ isOffCanvasNavigationEditorEnabled ? moreVertical : null }\n\t\t\ttoggleProps={\n\t\t\t\tisOffCanvasNavigationEditorEnabled\n\t\t\t\t\t? { isSmall: true }\n\t\t\t\t\t: toggleProps\n\t\t\t}\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<>\n\t\t\t\t\t{ showNavigationMenus && hasNavigationMenus && (\n\t\t\t\t\t\t<MenuGroup label={ __( 'Menus' ) }>\n\t\t\t\t\t\t\t<MenuItemsChoice\n\t\t\t\t\t\t\t\tvalue={ currentMenuId }\n\t\t\t\t\t\t\t\tonSelect={ ( menuId ) => {\n\t\t\t\t\t\t\t\t\tonSelectNavigationMenu( menuId );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tchoices={ menuChoices }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t\t{ showClassicMenus && hasClassicMenus && (\n\t\t\t\t\t\t<MenuGroup label={ __( 'Import Classic Menus' ) }>\n\t\t\t\t\t\t\t{ classicMenus?.map( ( menu ) => {\n\t\t\t\t\t\t\t\tconst label = decodeEntities( menu.name );\n\t\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\t\t\tsetSelectorLabel(\n\t\t\t\t\t\t\t\t\t\t\t\t__( 'Loading …' )\n\t\t\t\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\t\t\t\tsetEnableOptions( false );\n\t\t\t\t\t\t\t\t\t\t\tonSelectClassicMenu( menu );\n\t\t\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\t\tkey={ menu.id }\n\t\t\t\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t\t\t\tcreateActionLabel,\n\t\t\t\t\t\t\t\t\t\t\tlabel\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} ) }\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\n\t\t\t\t\t{ canUserCreateNavigationMenu && (\n\t\t\t\t\t\t<MenuGroup label={ __( 'Tools' ) }>\n\t\t\t\t\t\t\t<MenuItem\n\t\t\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t\t\tonCreateNew();\n\t\t\t\t\t\t\t\t\tsetIsCreatingMenu( true );\n\t\t\t\t\t\t\t\t\tsetSelectorLabel( __( 'Loading …' ) );\n\t\t\t\t\t\t\t\t\tsetEnableOptions( false );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Create new menu' ) }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t</MenuGroup>\n\t\t\t\t\t) }\n\t\t\t\t</>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n}\n\nexport default NavigationMenuSelector;\n"]}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
1
6
|
function getComputedStyle(node) {
|
|
2
7
|
return node.ownerDocument.defaultView.getComputedStyle(node);
|
|
3
8
|
}
|
|
@@ -18,4 +23,74 @@ export function detectColors(colorsDetectionElement, setColor, setBackground) {
|
|
|
18
23
|
|
|
19
24
|
setBackground(backgroundColor);
|
|
20
25
|
}
|
|
26
|
+
/**
|
|
27
|
+
* Determine the colors for a menu.
|
|
28
|
+
*
|
|
29
|
+
* Order of priority is:
|
|
30
|
+
* 1: Overlay custom colors (if submenu)
|
|
31
|
+
* 2: Overlay theme colors (if submenu)
|
|
32
|
+
* 3: Custom colors
|
|
33
|
+
* 4: Theme colors
|
|
34
|
+
* 5: Global styles
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} context
|
|
37
|
+
* @param {boolean} isSubMenu
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
export function getColors(context, isSubMenu) {
|
|
41
|
+
var _style$color, _style$color2;
|
|
42
|
+
|
|
43
|
+
const {
|
|
44
|
+
textColor,
|
|
45
|
+
customTextColor,
|
|
46
|
+
backgroundColor,
|
|
47
|
+
customBackgroundColor,
|
|
48
|
+
overlayTextColor,
|
|
49
|
+
customOverlayTextColor,
|
|
50
|
+
overlayBackgroundColor,
|
|
51
|
+
customOverlayBackgroundColor,
|
|
52
|
+
style
|
|
53
|
+
} = context;
|
|
54
|
+
const colors = {};
|
|
55
|
+
|
|
56
|
+
if (isSubMenu && !!customOverlayTextColor) {
|
|
57
|
+
colors.customTextColor = customOverlayTextColor;
|
|
58
|
+
} else if (isSubMenu && !!overlayTextColor) {
|
|
59
|
+
colors.textColor = overlayTextColor;
|
|
60
|
+
} else if (!!customTextColor) {
|
|
61
|
+
colors.customTextColor = customTextColor;
|
|
62
|
+
} else if (!!textColor) {
|
|
63
|
+
colors.textColor = textColor;
|
|
64
|
+
} else if (!!(style !== null && style !== void 0 && (_style$color = style.color) !== null && _style$color !== void 0 && _style$color.text)) {
|
|
65
|
+
colors.customTextColor = style.color.text;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
if (isSubMenu && !!customOverlayBackgroundColor) {
|
|
69
|
+
colors.customBackgroundColor = customOverlayBackgroundColor;
|
|
70
|
+
} else if (isSubMenu && !!overlayBackgroundColor) {
|
|
71
|
+
colors.backgroundColor = overlayBackgroundColor;
|
|
72
|
+
} else if (!!customBackgroundColor) {
|
|
73
|
+
colors.customBackgroundColor = customBackgroundColor;
|
|
74
|
+
} else if (!!backgroundColor) {
|
|
75
|
+
colors.backgroundColor = backgroundColor;
|
|
76
|
+
} else if (!!(style !== null && style !== void 0 && (_style$color2 = style.color) !== null && _style$color2 !== void 0 && _style$color2.background)) {
|
|
77
|
+
colors.customTextColor = style.color.background;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return colors;
|
|
81
|
+
}
|
|
82
|
+
export function getNavigationChildBlockProps(innerBlocksColors) {
|
|
83
|
+
return {
|
|
84
|
+
className: classnames('wp-block-navigation__submenu-container', {
|
|
85
|
+
'has-text-color': !!(innerBlocksColors.textColor || innerBlocksColors.customTextColor),
|
|
86
|
+
[`has-${innerBlocksColors.textColor}-color`]: !!innerBlocksColors.textColor,
|
|
87
|
+
'has-background': !!(innerBlocksColors.backgroundColor || innerBlocksColors.customBackgroundColor),
|
|
88
|
+
[`has-${innerBlocksColors.backgroundColor}-background-color`]: !!innerBlocksColors.backgroundColor
|
|
89
|
+
}),
|
|
90
|
+
style: {
|
|
91
|
+
color: innerBlocksColors.customTextColor,
|
|
92
|
+
backgroundColor: innerBlocksColors.customBackgroundColor
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
}
|
|
21
96
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/navigation/edit/utils.js"],"names":["getComputedStyle","node","ownerDocument","defaultView","detectColors","colorsDetectionElement","setColor","setBackground","color","backgroundColorNode","backgroundColor","parentNode","nodeType","ELEMENT_NODE"],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/navigation/edit/utils.js"],"names":["classnames","getComputedStyle","node","ownerDocument","defaultView","detectColors","colorsDetectionElement","setColor","setBackground","color","backgroundColorNode","backgroundColor","parentNode","nodeType","ELEMENT_NODE","getColors","context","isSubMenu","textColor","customTextColor","customBackgroundColor","overlayTextColor","customOverlayTextColor","overlayBackgroundColor","customOverlayBackgroundColor","style","colors","text","background","getNavigationChildBlockProps","innerBlocksColors","className"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;;AAEA,SAASC,gBAAT,CAA2BC,IAA3B,EAAkC;AACjC,SAAOA,IAAI,CAACC,aAAL,CAAmBC,WAAnB,CAA+BH,gBAA/B,CAAiDC,IAAjD,CAA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G,OAAOW,iBAAiB,CAACZ,SAAW,QAAvC,GACC,CAAC,CAAEY,iBAAiB,CAACZ,SAL0C;AAMhE,wBAAkB,CAAC,EAClBY,iBAAiB,CAACnB,eAAlB,IACAmB,iBAAiB,CAACV,qBAFA,CAN6C;AAUhE,OAAG,OAAOU,iBAAiB,CAACnB,eAAiB,mBAA7C,GACC,CAAC,CAAEmB,iBAAiB,CAACnB;AAX0C,KAA5C,CADf;AAcNc,IAAAA,KAAK,EAAE;AACNhB,MAAAA,KAAK,EAAEqB,iBAAiB,CAACX,eADnB;AAENR,MAAAA,eAAe,EAAEmB,iBAAiB,CAACV;AAF7B;AAdD,GAAP;AAmBA","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\nfunction getComputedStyle( node ) {\n\treturn node.ownerDocument.defaultView.getComputedStyle( node );\n}\n\nexport function detectColors(\n\tcolorsDetectionElement,\n\tsetColor,\n\tsetBackground\n) {\n\tif ( ! colorsDetectionElement ) {\n\t\treturn;\n\t}\n\tsetColor( getComputedStyle( colorsDetectionElement ).color );\n\n\tlet backgroundColorNode = colorsDetectionElement;\n\tlet backgroundColor =\n\t\tgetComputedStyle( backgroundColorNode ).backgroundColor;\n\twhile (\n\t\tbackgroundColor === 'rgba(0, 0, 0, 0)' &&\n\t\tbackgroundColorNode.parentNode &&\n\t\tbackgroundColorNode.parentNode.nodeType ===\n\t\t\tbackgroundColorNode.parentNode.ELEMENT_NODE\n\t) {\n\t\tbackgroundColorNode = backgroundColorNode.parentNode;\n\t\tbackgroundColor =\n\t\t\tgetComputedStyle( backgroundColorNode ).backgroundColor;\n\t}\n\n\tsetBackground( backgroundColor );\n}\n\n/**\n * Determine the colors for a menu.\n *\n * Order of priority is:\n * 1: Overlay custom colors (if submenu)\n * 2: Overlay theme colors (if submenu)\n * 3: Custom colors\n * 4: Theme colors\n * 5: Global styles\n *\n * @param {Object} context\n * @param {boolean} isSubMenu\n */\nexport function getColors( context, isSubMenu ) {\n\tconst {\n\t\ttextColor,\n\t\tcustomTextColor,\n\t\tbackgroundColor,\n\t\tcustomBackgroundColor,\n\t\toverlayTextColor,\n\t\tcustomOverlayTextColor,\n\t\toverlayBackgroundColor,\n\t\tcustomOverlayBackgroundColor,\n\t\tstyle,\n\t} = context;\n\n\tconst colors = {};\n\n\tif ( isSubMenu && !! customOverlayTextColor ) {\n\t\tcolors.customTextColor = customOverlayTextColor;\n\t} else if ( isSubMenu && !! overlayTextColor ) {\n\t\tcolors.textColor = overlayTextColor;\n\t} else if ( !! customTextColor ) {\n\t\tcolors.customTextColor = customTextColor;\n\t} else if ( !! textColor ) {\n\t\tcolors.textColor = textColor;\n\t} else if ( !! style?.color?.text ) {\n\t\tcolors.customTextColor = style.color.text;\n\t}\n\n\tif ( isSubMenu && !! customOverlayBackgroundColor ) {\n\t\tcolors.customBackgroundColor = customOverlayBackgroundColor;\n\t} else if ( isSubMenu && !! overlayBackgroundColor ) {\n\t\tcolors.backgroundColor = overlayBackgroundColor;\n\t} else if ( !! customBackgroundColor ) {\n\t\tcolors.customBackgroundColor = customBackgroundColor;\n\t} else if ( !! backgroundColor ) {\n\t\tcolors.backgroundColor = backgroundColor;\n\t} else if ( !! style?.color?.background ) {\n\t\tcolors.customTextColor = style.color.background;\n\t}\n\n\treturn colors;\n}\n\nexport function getNavigationChildBlockProps( innerBlocksColors ) {\n\treturn {\n\t\tclassName: classnames( 'wp-block-navigation__submenu-container', {\n\t\t\t'has-text-color': !! (\n\t\t\t\tinnerBlocksColors.textColor || innerBlocksColors.customTextColor\n\t\t\t),\n\t\t\t[ `has-${ innerBlocksColors.textColor }-color` ]:\n\t\t\t\t!! innerBlocksColors.textColor,\n\t\t\t'has-background': !! (\n\t\t\t\tinnerBlocksColors.backgroundColor ||\n\t\t\t\tinnerBlocksColors.customBackgroundColor\n\t\t\t),\n\t\t\t[ `has-${ innerBlocksColors.backgroundColor }-background-color` ]:\n\t\t\t\t!! innerBlocksColors.backgroundColor,\n\t\t} ),\n\t\tstyle: {\n\t\t\tcolor: innerBlocksColors.customTextColor,\n\t\t\tbackgroundColor: innerBlocksColors.customBackgroundColor,\n\t\t},\n\t};\n}\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
|
+
import { createElement } from "@wordpress/element";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* WordPress dependencies
|
|
6
|
+
*/
|
|
7
|
+
import { createBlock } from '@wordpress/blocks';
|
|
8
|
+
import { addSubmenu, moreVertical } from '@wordpress/icons';
|
|
9
|
+
import { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';
|
|
10
|
+
import { useDispatch } from '@wordpress/data';
|
|
11
|
+
import { store as blockEditorStore, BlockTitle } from '@wordpress/block-editor';
|
|
12
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
13
|
+
const POPOVER_PROPS = {
|
|
14
|
+
className: 'block-editor-block-settings-menu__popover',
|
|
15
|
+
position: 'bottom right',
|
|
16
|
+
variant: 'toolbar'
|
|
17
|
+
};
|
|
18
|
+
export const LeafMoreMenu = props => {
|
|
19
|
+
const {
|
|
20
|
+
clientId,
|
|
21
|
+
block
|
|
22
|
+
} = props;
|
|
23
|
+
const {
|
|
24
|
+
insertBlock,
|
|
25
|
+
replaceBlock,
|
|
26
|
+
removeBlocks,
|
|
27
|
+
replaceInnerBlocks
|
|
28
|
+
} = useDispatch(blockEditorStore);
|
|
29
|
+
const label = sprintf(
|
|
30
|
+
/* translators: %s: block name */
|
|
31
|
+
__('Remove %s'), BlockTitle({
|
|
32
|
+
clientId,
|
|
33
|
+
maximumLength: 25
|
|
34
|
+
}));
|
|
35
|
+
return createElement(DropdownMenu, _extends({
|
|
36
|
+
icon: moreVertical,
|
|
37
|
+
label: __('Options'),
|
|
38
|
+
className: "block-editor-block-settings-menu",
|
|
39
|
+
popoverProps: POPOVER_PROPS,
|
|
40
|
+
noIcons: true
|
|
41
|
+
}, props), _ref => {
|
|
42
|
+
let {
|
|
43
|
+
onClose
|
|
44
|
+
} = _ref;
|
|
45
|
+
return createElement(MenuGroup, null, createElement(MenuItem, {
|
|
46
|
+
icon: addSubmenu,
|
|
47
|
+
onClick: () => {
|
|
48
|
+
const updateSelectionOnInsert = false;
|
|
49
|
+
const newLink = createBlock('core/navigation-link');
|
|
50
|
+
|
|
51
|
+
if (block.name === 'core/navigation-submenu') {
|
|
52
|
+
insertBlock(newLink, block.innerBlocks.length, clientId, updateSelectionOnInsert);
|
|
53
|
+
} else {
|
|
54
|
+
// Convert to a submenu if the block currently isn't one.
|
|
55
|
+
const newSubmenu = createBlock('core/navigation-submenu', block.attributes, block.innerBlocks); // The following must happen as two independent actions.
|
|
56
|
+
// Why? Because the offcanvas editor relies on the getLastInsertedBlocksClientIds
|
|
57
|
+
// selector to determine which block is "active". As the UX needs the newLink to be
|
|
58
|
+
// the "active" block it must be the last block to be inserted.
|
|
59
|
+
// Therefore the Submenu is first created and **then** the newLink is inserted
|
|
60
|
+
// thus ensuring it is the last inserted block.
|
|
61
|
+
|
|
62
|
+
replaceBlock(clientId, newSubmenu);
|
|
63
|
+
replaceInnerBlocks(newSubmenu.clientId, [newLink], updateSelectionOnInsert);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
onClose();
|
|
67
|
+
}
|
|
68
|
+
}, __('Add submenu item')), createElement(MenuItem, {
|
|
69
|
+
onClick: () => {
|
|
70
|
+
removeBlocks([clientId], false);
|
|
71
|
+
onClose();
|
|
72
|
+
}
|
|
73
|
+
}, label));
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
//# sourceMappingURL=leaf-more-menu.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/navigation/leaf-more-menu.js"],"names":["createBlock","addSubmenu","moreVertical","DropdownMenu","MenuItem","MenuGroup","useDispatch","store","blockEditorStore","BlockTitle","__","sprintf","POPOVER_PROPS","className","position","variant","LeafMoreMenu","props","clientId","block","insertBlock","replaceBlock","removeBlocks","replaceInnerBlocks","label","maximumLength","onClose","updateSelectionOnInsert","newLink","name","innerBlocks","length","newSubmenu","attributes"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,mBAA5B;AACA,SAASC,UAAT,EAAqBC,YAArB,QAAyC,kBAAzC;AACA,SAASC,YAAT,EAAuBC,QAAvB,EAAiCC,SAAjC,QAAkD,uBAAlD;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,gBAAlB,EAAoCC,UAApC,QAAsD,yBAAtD;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AAEA,MAAMC,aAAa,GAAG;AACrBC,EAAAA,SAAS,EAAE,2CADU;AAErBC,EAAAA,QAAQ,EAAE,cAFW;AAGrBC,EAAAA,OAAO,EAAE;AAHY,CAAtB;AAMA,OAAO,MAAMC,YAAY,GAAKC,KAAF,IAAa;AACxC,QAAM;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,MAAsBF,KAA5B;AAEA,QAAM;AAAEG,IAAAA,WAAF;AAAeC,IAAAA,YAAf;AAA6BC,IAAAA,YAA7B;AAA2CC,IAAAA;AAA3C,MACLjB,WAAW,CAAEE,gBAAF,CADZ;AAGA,QAAMgB,KAAK,GAAGb,OAAO;AACpB;AACAD,EAAAA,EAAE,CAAE,WAAF,CAFkB,EAGpBD,UAAU,CAAE;AAAES,IAAAA,QAAF;AAAYO,IAAAA,aAAa,EAAE;AAA3B,GAAF,CAHU,CAArB;AAMA,SACC,cAAC,YAAD;AACC,IAAA,IAAI,EAAGvB,YADR;AAEC,IAAA,KAAK,EAAGQ,EAAE,CAAE,SAAF,CAFX;AAGC,IAAA,SAAS,EAAC,kCAHX;AAIC,IAAA,YAAY,EAAGE,aAJhB;AAKC,IAAA,OAAO;AALR,KAMMK,KANN,GAQG;AAAA,QAAE;AAAES,MAAAA;AAAF,KAAF;AAAA,WACD,cAAC,SAAD,QACC,cAAC,QAAD;AACC,MAAA,IAAI,EAAGzB,UADR;AAEC,MAAA,OAAO,EAAG,MAAM;AACf,cAAM0B,uBAAuB,GAAG,KAAhC;AACA,cAAMC,OAAO,GAAG5B,WAAW,CAC1B,sBAD0B,CAA3B;;AAGA,YAAKmB,KAAK,CAACU,IAAN,KAAe,yBAApB,EAAgD;AAC/CT,UAAAA,WAAW,CACVQ,OADU,EAEVT,KAAK,CAACW,WAAN,CAAkBC,MAFR,EAGVb,QAHU,EAIVS,uBAJU,CAAX;AAMA,SAPD,MAOO;AACN;AACA,gBAAMK,UAAU,GAAGhC,WAAW,CAC7B,yBAD6B,EAE7BmB,KAAK,CAACc,UAFuB,EAG7Bd,KAAK,CAACW,WAHuB,CAA9B,CAFM,CAQN;AACA;AACA;AACA;AACA;AACA;;AACAT,UAAAA,YAAY,CAAEH,QAAF,EAAYc,UAAZ,CAAZ;AAEAT,UAAAA,kBAAkB,CACjBS,UAAU,CAACd,QADM,EAEjB,CAAEU,OAAF,CAFiB,EAGjBD,uBAHiB,CAAlB;AAKA;;AACDD,QAAAA,OAAO;AACP;AArCF,OAuCGhB,EAAE,CAAE,kBAAF,CAvCL,CADD,EA0CC,cAAC,QAAD;AACC,MAAA,OAAO,EAAG,MAAM;AACfY,QAAAA,YAAY,CAAE,CAAEJ,QAAF,CAAF,EAAgB,KAAhB,CAAZ;AACAQ,QAAAA,OAAO;AACP;AAJF,OAMGF,KANH,CA1CD,CADC;AAAA,GARH,CADD;AAgEA,CA5EM","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock } from '@wordpress/blocks';\nimport { addSubmenu, moreVertical } from '@wordpress/icons';\nimport { DropdownMenu, MenuItem, MenuGroup } from '@wordpress/components';\nimport { useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore, BlockTitle } from '@wordpress/block-editor';\nimport { __, sprintf } from '@wordpress/i18n';\n\nconst POPOVER_PROPS = {\n\tclassName: 'block-editor-block-settings-menu__popover',\n\tposition: 'bottom right',\n\tvariant: 'toolbar',\n};\n\nexport const LeafMoreMenu = ( props ) => {\n\tconst { clientId, block } = props;\n\n\tconst { insertBlock, replaceBlock, removeBlocks, replaceInnerBlocks } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst label = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__( 'Remove %s' ),\n\t\tBlockTitle( { clientId, maximumLength: 25 } )\n\t);\n\n\treturn (\n\t\t<DropdownMenu\n\t\t\ticon={ moreVertical }\n\t\t\tlabel={ __( 'Options' ) }\n\t\t\tclassName=\"block-editor-block-settings-menu\"\n\t\t\tpopoverProps={ POPOVER_PROPS }\n\t\t\tnoIcons\n\t\t\t{ ...props }\n\t\t>\n\t\t\t{ ( { onClose } ) => (\n\t\t\t\t<MenuGroup>\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\ticon={ addSubmenu }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tconst updateSelectionOnInsert = false;\n\t\t\t\t\t\t\tconst newLink = createBlock(\n\t\t\t\t\t\t\t\t'core/navigation-link'\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\tif ( block.name === 'core/navigation-submenu' ) {\n\t\t\t\t\t\t\t\tinsertBlock(\n\t\t\t\t\t\t\t\t\tnewLink,\n\t\t\t\t\t\t\t\t\tblock.innerBlocks.length,\n\t\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\t\tupdateSelectionOnInsert\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Convert to a submenu if the block currently isn't one.\n\t\t\t\t\t\t\t\tconst newSubmenu = createBlock(\n\t\t\t\t\t\t\t\t\t'core/navigation-submenu',\n\t\t\t\t\t\t\t\t\tblock.attributes,\n\t\t\t\t\t\t\t\t\tblock.innerBlocks\n\t\t\t\t\t\t\t\t);\n\n\t\t\t\t\t\t\t\t// The following must happen as two independent actions.\n\t\t\t\t\t\t\t\t// Why? Because the offcanvas editor relies on the getLastInsertedBlocksClientIds\n\t\t\t\t\t\t\t\t// selector to determine which block is \"active\". As the UX needs the newLink to be\n\t\t\t\t\t\t\t\t// the \"active\" block it must be the last block to be inserted.\n\t\t\t\t\t\t\t\t// Therefore the Submenu is first created and **then** the newLink is inserted\n\t\t\t\t\t\t\t\t// thus ensuring it is the last inserted block.\n\t\t\t\t\t\t\t\treplaceBlock( clientId, newSubmenu );\n\n\t\t\t\t\t\t\t\treplaceInnerBlocks(\n\t\t\t\t\t\t\t\t\tnewSubmenu.clientId,\n\t\t\t\t\t\t\t\t\t[ newLink ],\n\t\t\t\t\t\t\t\t\tupdateSelectionOnInsert\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ __( 'Add submenu item' ) }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t\t<MenuItem\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\tremoveBlocks( [ clientId ], false );\n\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t} }\n\t\t\t\t\t>\n\t\t\t\t\t\t{ label }\n\t\t\t\t\t</MenuItem>\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</DropdownMenu>\n\t);\n};\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createElement } from "@wordpress/element";
|
|
1
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* External dependencies
|
|
@@ -16,7 +16,7 @@ import { displayShortcut, isKeyboardEvent, ENTER } from '@wordpress/keycodes';
|
|
|
16
16
|
import { __ } from '@wordpress/i18n';
|
|
17
17
|
import { BlockControls, InspectorControls, RichText, useBlockProps, store as blockEditorStore, getColorClassName, useInnerBlocksProps } from '@wordpress/block-editor';
|
|
18
18
|
import { isURL, prependHTTP } from '@wordpress/url';
|
|
19
|
-
import {
|
|
19
|
+
import { useState, useEffect, useRef } from '@wordpress/element';
|
|
20
20
|
import { placeCaretAtHorizontalEdge, __unstableStripHTML as stripHTML } from '@wordpress/dom';
|
|
21
21
|
import { link as linkIcon, addSubmenu } from '@wordpress/icons';
|
|
22
22
|
import { store as coreStore, useResourcePermissions } from '@wordpress/core-data';
|
|
@@ -93,6 +93,7 @@ const {
|
|
|
93
93
|
};
|
|
94
94
|
import { LinkUI } from './link-ui';
|
|
95
95
|
import { updateAttributes } from './update-attributes';
|
|
96
|
+
import { getColors } from '../navigation/edit/utils';
|
|
96
97
|
/**
|
|
97
98
|
* A React hook to determine if it's dragging within the target element.
|
|
98
99
|
*
|
|
@@ -143,63 +144,6 @@ const useIsDraggingWithin = elementRef => {
|
|
|
143
144
|
}, []);
|
|
144
145
|
return isDraggingWithin;
|
|
145
146
|
};
|
|
146
|
-
/**
|
|
147
|
-
* Determine the colors for a menu.
|
|
148
|
-
*
|
|
149
|
-
* Order of priority is:
|
|
150
|
-
* 1: Overlay custom colors (if submenu)
|
|
151
|
-
* 2: Overlay theme colors (if submenu)
|
|
152
|
-
* 3: Custom colors
|
|
153
|
-
* 4: Theme colors
|
|
154
|
-
* 5: Global styles
|
|
155
|
-
*
|
|
156
|
-
* @param {Object} context
|
|
157
|
-
* @param {boolean} isSubMenu
|
|
158
|
-
*/
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
function getColors(context, isSubMenu) {
|
|
162
|
-
var _style$color, _style$color2;
|
|
163
|
-
|
|
164
|
-
const {
|
|
165
|
-
textColor,
|
|
166
|
-
customTextColor,
|
|
167
|
-
backgroundColor,
|
|
168
|
-
customBackgroundColor,
|
|
169
|
-
overlayTextColor,
|
|
170
|
-
customOverlayTextColor,
|
|
171
|
-
overlayBackgroundColor,
|
|
172
|
-
customOverlayBackgroundColor,
|
|
173
|
-
style
|
|
174
|
-
} = context;
|
|
175
|
-
const colors = {};
|
|
176
|
-
|
|
177
|
-
if (isSubMenu && !!customOverlayTextColor) {
|
|
178
|
-
colors.customTextColor = customOverlayTextColor;
|
|
179
|
-
} else if (isSubMenu && !!overlayTextColor) {
|
|
180
|
-
colors.textColor = overlayTextColor;
|
|
181
|
-
} else if (!!customTextColor) {
|
|
182
|
-
colors.customTextColor = customTextColor;
|
|
183
|
-
} else if (!!textColor) {
|
|
184
|
-
colors.textColor = textColor;
|
|
185
|
-
} else if (!!(style !== null && style !== void 0 && (_style$color = style.color) !== null && _style$color !== void 0 && _style$color.text)) {
|
|
186
|
-
colors.customTextColor = style.color.text;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
if (isSubMenu && !!customOverlayBackgroundColor) {
|
|
190
|
-
colors.customBackgroundColor = customOverlayBackgroundColor;
|
|
191
|
-
} else if (isSubMenu && !!overlayBackgroundColor) {
|
|
192
|
-
colors.backgroundColor = overlayBackgroundColor;
|
|
193
|
-
} else if (!!customBackgroundColor) {
|
|
194
|
-
colors.customBackgroundColor = customBackgroundColor;
|
|
195
|
-
} else if (!!backgroundColor) {
|
|
196
|
-
colors.backgroundColor = backgroundColor;
|
|
197
|
-
} else if (!!(style !== null && style !== void 0 && (_style$color2 = style.color) !== null && _style$color2 !== void 0 && _style$color2.background)) {
|
|
198
|
-
colors.customTextColor = style.color.background;
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
return colors;
|
|
202
|
-
}
|
|
203
147
|
|
|
204
148
|
const useIsInvalidLink = (kind, type, id) => {
|
|
205
149
|
const isPostType = kind === 'post-type' || type === 'post' || type === 'page';
|
|
@@ -463,7 +407,10 @@ export default function NavigationLinkEdit(_ref) {
|
|
|
463
407
|
const DEFAULT_BLOCK = {
|
|
464
408
|
name: 'core/navigation-link'
|
|
465
409
|
};
|
|
466
|
-
const innerBlocksProps = useInnerBlocksProps(blockProps,
|
|
410
|
+
const innerBlocksProps = useInnerBlocksProps({ ...blockProps,
|
|
411
|
+
className: 'remove-outline' // Remove the outline from the inner blocks container.
|
|
412
|
+
|
|
413
|
+
}, {
|
|
467
414
|
allowedBlocks: ALLOWED_BLOCKS,
|
|
468
415
|
__experimentalDefaultBlock: DEFAULT_BLOCK,
|
|
469
416
|
__experimentalDirectInsert: true,
|
|
@@ -507,13 +454,14 @@ export default function NavigationLinkEdit(_ref) {
|
|
|
507
454
|
}), createElement(TextControl, {
|
|
508
455
|
value: url || '',
|
|
509
456
|
onChange: urlValue => {
|
|
510
|
-
|
|
457
|
+
updateAttributes({
|
|
511
458
|
url: urlValue
|
|
512
|
-
});
|
|
459
|
+
}, setAttributes, attributes);
|
|
513
460
|
},
|
|
514
461
|
label: __('URL'),
|
|
515
462
|
autoComplete: "off"
|
|
516
463
|
}), createElement(TextareaControl, {
|
|
464
|
+
__nextHasNoMarginBottom: true,
|
|
517
465
|
value: description || '',
|
|
518
466
|
onChange: descriptionValue => {
|
|
519
467
|
setAttributes({
|