@wordpress/block-library 7.0.1 → 7.1.0-next.e230fbab09.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/README.md +16 -0
- package/build/audio/edit.js +4 -4
- package/build/audio/edit.js.map +1 -1
- package/build/audio/edit.native.js +4 -4
- package/build/audio/edit.native.js.map +1 -1
- package/build/audio/transforms.js +1 -1
- package/build/audio/transforms.js.map +1 -1
- package/build/block/edit.js +3 -9
- package/build/block/edit.js.map +1 -1
- package/build/button/edit.js +3 -2
- package/build/button/edit.js.map +1 -1
- package/build/button/edit.native.js +4 -4
- package/build/button/edit.native.js.map +1 -1
- package/build/buttons/transforms.js +8 -8
- package/build/buttons/transforms.js.map +1 -1
- package/build/categories/edit.js +15 -26
- package/build/categories/edit.js.map +1 -1
- package/build/code/index.js +0 -1
- package/build/code/index.js.map +1 -1
- package/build/columns/columnCalculations.native.js +1 -1
- package/build/columns/columnCalculations.native.js.map +1 -1
- package/build/columns/edit.js +1 -1
- package/build/columns/edit.js.map +1 -1
- package/build/columns/edit.native.js +3 -3
- package/build/columns/edit.native.js.map +1 -1
- package/build/columns/index.js +12 -0
- package/build/columns/index.js.map +1 -1
- package/build/comment-author-avatar/edit.js +17 -4
- package/build/comment-author-avatar/edit.js.map +1 -1
- package/build/comment-template/edit.js +94 -36
- package/build/comment-template/edit.js.map +1 -1
- package/build/comment-template/hooks.js +175 -0
- package/build/comment-template/hooks.js.map +1 -0
- package/build/comment-template/index.js +1 -1
- package/build/comment-template/util.js.map +1 -1
- package/build/comments-pagination-next/index.js +1 -1
- package/build/comments-pagination-numbers/index.js +1 -1
- package/build/comments-query-loop/edit/comments-inspector-controls.js +20 -9
- package/build/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
- package/build/comments-query-loop/edit.js +1 -19
- package/build/comments-query-loop/edit.js.map +1 -1
- package/build/comments-query-loop/index.js +5 -0
- package/build/comments-query-loop/index.js.map +1 -1
- package/build/cover/controls.native.js +5 -5
- package/build/cover/controls.native.js.map +1 -1
- package/build/cover/deprecated.js +188 -17
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit.js +29 -33
- package/build/cover/edit.js.map +1 -1
- package/build/cover/edit.native.js +15 -13
- package/build/cover/edit.native.js.map +1 -1
- package/build/cover/overlay-color-settings.native.js +7 -6
- package/build/cover/overlay-color-settings.native.js.map +1 -1
- package/build/cover/save.js +1 -1
- package/build/cover/save.js.map +1 -1
- package/build/cover/shared.js +2 -2
- package/build/cover/shared.js.map +1 -1
- package/build/cover/transforms.js +4 -2
- package/build/cover/transforms.js.map +1 -1
- package/build/embed/edit.js +1 -1
- package/build/embed/edit.js.map +1 -1
- package/build/embed/edit.native.js +1 -1
- package/build/embed/edit.native.js.map +1 -1
- package/build/embed/util.js +2 -2
- package/build/embed/util.js.map +1 -1
- package/build/embed/variations.js +1 -1
- package/build/embed/variations.js.map +1 -1
- package/build/file/edit.js +20 -17
- package/build/file/edit.js.map +1 -1
- package/build/file/edit.native.js +1 -1
- package/build/file/edit.native.js.map +1 -1
- package/build/file/save.js +7 -3
- package/build/file/save.js.map +1 -1
- package/build/freeform/edit.js +2 -2
- package/build/freeform/edit.js.map +1 -1
- package/build/gallery/edit.js +1 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.native.js +1 -1
- package/build/gallery/gallery.native.js.map +1 -1
- package/build/gallery/v1/edit.js +3 -3
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/gallery/v1/gallery-image.native.js +3 -3
- package/build/gallery/v1/gallery-image.native.js.map +1 -1
- package/build/gallery/v1/gallery.native.js +2 -2
- package/build/gallery/v1/gallery.native.js.map +1 -1
- package/build/group/index.js +4 -37
- package/build/group/index.js.map +1 -1
- package/build/group/transforms.js +45 -0
- package/build/group/transforms.js.map +1 -0
- package/build/heading/edit.js +14 -2
- package/build/heading/edit.js.map +1 -1
- package/build/home-link/edit.js +1 -1
- package/build/home-link/edit.js.map +1 -1
- package/build/image/deprecated.js +89 -5
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.js +7 -6
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +25 -10
- package/build/image/edit.native.js.map +1 -1
- package/build/image/save.js +0 -7
- package/build/image/save.js.map +1 -1
- package/build/image/transforms.js +1 -1
- package/build/image/transforms.js.map +1 -1
- package/build/index.js +3 -4
- package/build/index.js.map +1 -1
- package/build/index.native.js +2 -2
- package/build/index.native.js.map +1 -1
- package/build/latest-posts/edit.js +1 -0
- package/build/latest-posts/edit.js.map +1 -1
- package/build/media-text/edit.js +21 -2
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/edit.native.js +2 -2
- package/build/media-text/edit.native.js.map +1 -1
- package/build/media-text/media-container.native.js +1 -1
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/missing/edit.native.js +1 -1
- package/build/missing/edit.native.js.map +1 -1
- package/build/more/transforms.js +2 -2
- package/build/more/transforms.js.map +1 -1
- package/build/navigation/edit/index.js +144 -68
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +8 -3
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/navigation-menu-selector.js +82 -52
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/placeholder/index.js +32 -61
- package/build/navigation/edit/placeholder/index.js.map +1 -1
- package/build/navigation/edit/placeholder/placeholder-preview.js +3 -12
- package/build/navigation/edit/placeholder/placeholder-preview.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 +120 -0
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -0
- package/build/navigation/edit/use-create-navigation-menu.js +53 -4
- package/build/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build/navigation/edit/use-navigation-notice.js +3 -3
- package/build/navigation/edit/use-navigation-notice.js.map +1 -1
- package/build/navigation/menu-items-to-blocks.js +1 -1
- package/build/navigation/menu-items-to-blocks.js.map +1 -1
- package/build/navigation/use-navigation-entities.js +25 -49
- package/build/navigation/use-navigation-entities.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +8 -6
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation-link/fallback-variations.js +1 -1
- package/build/navigation-link/fallback-variations.js.map +1 -1
- package/build/navigation-link/hooks.js +2 -2
- package/build/navigation-link/hooks.js.map +1 -1
- package/build/navigation-submenu/edit.js +43 -11
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +13 -23
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/edit.js +19 -39
- package/build/page-list/edit.js.map +1 -1
- package/build/post-author-name/edit.js +2 -1
- package/build/post-author-name/edit.js.map +1 -1
- package/build/post-comments-form/edit.js +3 -1
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +7 -4
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-terms/edit.js +3 -1
- package/build/post-terms/edit.js.map +1 -1
- package/build/query-title/edit.js +0 -1
- package/build/query-title/edit.js.map +1 -1
- package/build/search/edit.js +4 -1
- package/build/search/edit.js.map +1 -1
- package/build/search/edit.native.js +1 -1
- package/build/search/edit.native.js.map +1 -1
- package/build/separator/save.js +4 -4
- package/build/separator/save.js.map +1 -1
- package/build/separator/separator-settings.native.js +1 -1
- package/build/separator/separator-settings.native.js.map +1 -1
- package/build/site-logo/edit.js +1 -1
- package/build/site-logo/edit.js.map +1 -1
- package/build/social-link/edit.native.js +11 -3
- package/build/social-link/edit.native.js.map +1 -1
- package/build/social-links/deprecated.js +1 -62
- package/build/social-links/deprecated.js.map +1 -1
- package/build/spacer/controls.js +5 -5
- package/build/spacer/controls.js.map +1 -1
- package/build/spacer/controls.native.js +5 -5
- package/build/spacer/controls.native.js.map +1 -1
- package/build/table/edit.js +2 -2
- package/build/table/edit.js.map +1 -1
- package/build/template-part/edit/index.js +36 -64
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/placeholder.js +64 -0
- package/build/template-part/edit/placeholder.js.map +1 -0
- package/build/template-part/edit/selection-modal.js +103 -0
- package/build/template-part/edit/selection-modal.js.map +1 -0
- package/build/template-part/edit/title-modal.js +54 -0
- package/build/template-part/edit/title-modal.js.map +1 -0
- package/build/template-part/edit/utils/hooks.js +156 -0
- package/build/template-part/edit/utils/hooks.js.map +1 -0
- package/build/template-part/index.js +3 -1
- package/build/template-part/index.js.map +1 -1
- package/build/video/edit.js +4 -4
- package/build/video/edit.js.map +1 -1
- package/build/video/edit.native.js +3 -3
- package/build/video/edit.native.js.map +1 -1
- package/build-module/audio/edit.js +4 -4
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/audio/edit.native.js +4 -4
- package/build-module/audio/edit.native.js.map +1 -1
- package/build-module/audio/transforms.js +1 -1
- package/build-module/audio/transforms.js.map +1 -1
- package/build-module/block/edit.js +5 -11
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/edit.js +3 -2
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/edit.native.js +6 -6
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/buttons/transforms.js +8 -8
- package/build-module/buttons/transforms.js.map +1 -1
- package/build-module/categories/edit.js +15 -25
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/code/index.js +0 -1
- package/build-module/code/index.js.map +1 -1
- package/build-module/columns/columnCalculations.native.js +1 -1
- package/build-module/columns/columnCalculations.native.js.map +1 -1
- package/build-module/columns/edit.js +1 -1
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/columns/edit.native.js +3 -3
- package/build-module/columns/edit.native.js.map +1 -1
- package/build-module/columns/index.js +12 -0
- package/build-module/columns/index.js.map +1 -1
- package/build-module/comment-author-avatar/edit.js +18 -6
- package/build-module/comment-author-avatar/edit.js.map +1 -1
- package/build-module/comment-template/edit.js +95 -37
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/comment-template/hooks.js +156 -0
- package/build-module/comment-template/hooks.js.map +1 -0
- package/build-module/comment-template/index.js +1 -1
- package/build-module/comment-template/util.js.map +1 -1
- package/build-module/comments-pagination-next/index.js +1 -1
- package/build-module/comments-pagination-numbers/index.js +1 -1
- package/build-module/comments-query-loop/edit/comments-inspector-controls.js +20 -9
- package/build-module/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
- package/build-module/comments-query-loop/edit.js +2 -19
- package/build-module/comments-query-loop/edit.js.map +1 -1
- package/build-module/comments-query-loop/index.js +5 -0
- package/build-module/comments-query-loop/index.js.map +1 -1
- package/build-module/cover/controls.native.js +5 -5
- package/build-module/cover/controls.native.js.map +1 -1
- package/build-module/cover/deprecated.js +190 -17
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit.js +31 -35
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/cover/edit.native.js +18 -16
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/cover/overlay-color-settings.native.js +7 -7
- package/build-module/cover/overlay-color-settings.native.js.map +1 -1
- package/build-module/cover/save.js +1 -1
- package/build-module/cover/save.js.map +1 -1
- package/build-module/cover/shared.js +2 -2
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/cover/transforms.js +4 -2
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/embed/edit.js +1 -1
- package/build-module/embed/edit.js.map +1 -1
- package/build-module/embed/edit.native.js +1 -1
- package/build-module/embed/edit.native.js.map +1 -1
- package/build-module/embed/util.js +2 -2
- package/build-module/embed/util.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/edit.js +21 -18
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/edit.native.js +1 -1
- package/build-module/file/edit.native.js.map +1 -1
- package/build-module/file/save.js +7 -3
- package/build-module/file/save.js.map +1 -1
- package/build-module/freeform/edit.js +2 -2
- package/build-module/freeform/edit.js.map +1 -1
- package/build-module/gallery/edit.js +1 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.native.js +1 -1
- package/build-module/gallery/gallery.native.js.map +1 -1
- package/build-module/gallery/v1/edit.js +3 -3
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/gallery/v1/gallery-image.native.js +3 -3
- package/build-module/gallery/v1/gallery-image.native.js.map +1 -1
- package/build-module/gallery/v1/gallery.native.js +2 -2
- package/build-module/gallery/v1/gallery.native.js.map +1 -1
- package/build-module/group/index.js +3 -36
- package/build-module/group/index.js.map +1 -1
- package/build-module/group/transforms.js +36 -0
- package/build-module/group/transforms.js.map +1 -0
- package/build-module/heading/edit.js +15 -3
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/home-link/edit.js +1 -1
- package/build-module/home-link/edit.js.map +1 -1
- package/build-module/image/deprecated.js +90 -7
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.js +7 -6
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +25 -10
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/save.js +0 -7
- package/build-module/image/save.js.map +1 -1
- package/build-module/image/transforms.js +1 -1
- package/build-module/image/transforms.js.map +1 -1
- package/build-module/index.js +4 -5
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +2 -2
- package/build-module/index.native.js.map +1 -1
- package/build-module/latest-posts/edit.js +1 -0
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/media-text/edit.js +20 -2
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/edit.native.js +2 -2
- package/build-module/media-text/edit.native.js.map +1 -1
- package/build-module/media-text/media-container.native.js +1 -1
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/missing/edit.native.js +1 -1
- package/build-module/missing/edit.native.js.map +1 -1
- package/build-module/more/transforms.js +2 -2
- package/build-module/more/transforms.js.map +1 -1
- package/build-module/navigation/edit/index.js +138 -68
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +8 -3
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-selector.js +82 -48
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/placeholder/index.js +33 -59
- package/build-module/navigation/edit/placeholder/index.js.map +1 -1
- package/build-module/navigation/edit/placeholder/placeholder-preview.js +3 -9
- package/build-module/navigation/edit/placeholder/placeholder-preview.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 +100 -0
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -0
- package/build-module/navigation/edit/use-create-navigation-menu.js +48 -5
- package/build-module/navigation/edit/use-create-navigation-menu.js.map +1 -1
- package/build-module/navigation/edit/use-navigation-notice.js +3 -3
- package/build-module/navigation/edit/use-navigation-notice.js.map +1 -1
- package/build-module/navigation/menu-items-to-blocks.js +1 -1
- package/build-module/navigation/menu-items-to-blocks.js.map +1 -1
- package/build-module/navigation/use-navigation-entities.js +26 -50
- package/build-module/navigation/use-navigation-entities.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +8 -6
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation-link/fallback-variations.js +1 -1
- package/build-module/navigation-link/fallback-variations.js.map +1 -1
- package/build-module/navigation-link/hooks.js +2 -2
- package/build-module/navigation-link/hooks.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +43 -12
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +15 -25
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/edit.js +21 -41
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/post-author-name/edit.js +2 -1
- package/build-module/post-author-name/edit.js.map +1 -1
- package/build-module/post-comments-form/edit.js +4 -2
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +9 -6
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-terms/edit.js +2 -1
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/query-title/edit.js +0 -1
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/search/edit.js +3 -1
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/edit.native.js +1 -1
- package/build-module/search/edit.native.js.map +1 -1
- package/build-module/separator/save.js +4 -4
- package/build-module/separator/save.js.map +1 -1
- package/build-module/separator/separator-settings.native.js +1 -1
- package/build-module/separator/separator-settings.native.js.map +1 -1
- package/build-module/site-logo/edit.js +1 -1
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/social-link/edit.native.js +11 -3
- package/build-module/social-link/edit.native.js.map +1 -1
- package/build-module/social-links/deprecated.js +1 -62
- package/build-module/social-links/deprecated.js.map +1 -1
- package/build-module/spacer/controls.js +5 -5
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/spacer/controls.native.js +5 -5
- package/build-module/spacer/controls.native.js.map +1 -1
- package/build-module/table/edit.js +2 -2
- package/build-module/table/edit.js.map +1 -1
- package/build-module/template-part/edit/index.js +37 -65
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/placeholder.js +52 -0
- package/build-module/template-part/edit/placeholder.js.map +1 -0
- package/build-module/template-part/edit/selection-modal.js +89 -0
- package/build-module/template-part/edit/selection-modal.js.map +1 -0
- package/build-module/template-part/edit/title-modal.js +46 -0
- package/build-module/template-part/edit/title-modal.js.map +1 -0
- package/build-module/template-part/edit/utils/hooks.js +135 -0
- package/build-module/template-part/edit/utils/hooks.js.map +1 -0
- package/build-module/template-part/index.js +2 -1
- package/build-module/template-part/index.js.map +1 -1
- package/build-module/video/edit.js +4 -4
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/edit.native.js +3 -3
- package/build-module/video/edit.native.js.map +1 -1
- package/build-style/button/editor-rtl.css +0 -3
- package/build-style/button/editor.css +0 -3
- package/build-style/code/style-rtl.css +2 -1
- package/build-style/code/style.css +2 -1
- package/build-style/code/theme-rtl.css +0 -3
- package/build-style/code/theme.css +0 -3
- package/build-style/comment-author-avatar/editor-rtl.css +83 -0
- package/build-style/comment-author-avatar/editor.css +83 -0
- package/build-style/common-rtl.css +1 -1
- package/build-style/common.css +1 -1
- package/build-style/cover/style-rtl.css +5 -5
- package/build-style/cover/style.css +5 -5
- package/build-style/editor-rtl.css +43 -84
- package/build-style/editor.css +43 -84
- package/build-style/image/editor-rtl.css +0 -16
- package/build-style/image/editor.css +0 -16
- package/build-style/image/style-rtl.css +4 -1
- package/build-style/image/style.css +4 -1
- package/build-style/navigation/editor-rtl.css +16 -0
- package/build-style/navigation/editor.css +16 -0
- package/build-style/navigation/style-rtl.css +14 -3
- package/build-style/navigation/style.css +14 -3
- package/build-style/page-list/editor-rtl.css +0 -9
- package/build-style/page-list/editor.css +0 -9
- package/build-style/style-rtl.css +32 -13
- package/build-style/style.css +32 -13
- package/build-style/tag-cloud/style-rtl.css +6 -2
- package/build-style/tag-cloud/style.css +6 -2
- package/build-style/template-part/editor-rtl.css +19 -56
- package/build-style/template-part/editor.css +19 -56
- package/build-style/theme-rtl.css +0 -3
- package/build-style/theme.css +0 -3
- package/package.json +32 -28
- package/src/archives/index.php +1 -1
- package/src/audio/edit.js +4 -4
- package/src/audio/edit.native.js +4 -4
- package/src/audio/transforms.js +1 -1
- package/src/block/edit.js +7 -22
- package/src/block/test/edit.native.js +9 -9
- package/src/button/edit.js +2 -1
- package/src/button/edit.native.js +5 -5
- package/src/button/editor.scss +0 -5
- package/src/buttons/test/edit.native.js +3 -3
- package/src/buttons/transforms.js +8 -8
- package/src/categories/edit.js +12 -22
- package/src/code/block.json +0 -1
- package/src/code/style.scss +4 -2
- package/src/code/theme.scss +0 -3
- package/src/columns/block.json +12 -0
- package/src/columns/columnCalculations.native.js +1 -1
- package/src/columns/edit.js +1 -1
- package/src/columns/edit.native.js +3 -3
- package/src/comment-author-avatar/edit.js +13 -8
- package/src/comment-author-avatar/editor.scss +7 -0
- package/src/comment-template/block.json +7 -1
- package/src/comment-template/edit.js +102 -40
- package/src/comment-template/hooks.js +151 -0
- package/src/comment-template/index.php +8 -0
- package/src/comment-template/util.js +1 -0
- package/src/comments-pagination-next/block.json +8 -1
- package/src/comments-pagination-next/index.php +6 -8
- package/src/comments-pagination-numbers/block.json +7 -1
- package/src/comments-pagination-numbers/index.php +3 -10
- package/src/comments-query-loop/block.json +5 -0
- package/src/comments-query-loop/edit/comments-inspector-controls.js +22 -4
- package/src/comments-query-loop/edit.js +1 -16
- package/src/common.scss +1 -1
- package/src/cover/controls.native.js +1 -1
- package/src/cover/deprecated.js +214 -1
- package/src/cover/edit.js +21 -36
- package/src/cover/edit.native.js +23 -15
- package/src/cover/overlay-color-settings.native.js +6 -7
- package/src/cover/save.js +4 -3
- package/src/cover/shared.js +2 -2
- package/src/cover/style.scss +5 -3
- package/src/cover/test/edit.native.js +39 -39
- package/src/cover/transforms.js +2 -0
- package/src/editor.scss +1 -0
- package/src/embed/edit.js +1 -1
- package/src/embed/edit.native.js +1 -1
- package/src/embed/test/index.native.js +105 -105
- package/src/embed/util.js +2 -2
- package/src/embed/variations.js +1 -1
- package/src/file/edit.js +19 -17
- package/src/file/edit.native.js +1 -1
- package/src/file/save.js +9 -3
- package/src/file/style.native.scss +1 -0
- package/src/freeform/edit.js +2 -2
- package/src/gallery/edit.js +1 -1
- package/src/gallery/gallery.native.js +1 -1
- package/src/gallery/index.php +1 -8
- package/src/gallery/test/__snapshots__/index.native.js.snap +164 -0
- package/src/gallery/test/helpers.native.js +293 -0
- package/src/gallery/test/index.native.js +583 -65
- package/src/gallery/v1/edit.js +3 -4
- package/src/gallery/v1/gallery-image.native.js +3 -3
- package/src/gallery/v1/gallery.native.js +2 -2
- package/src/group/block.json +1 -0
- package/src/group/index.js +2 -54
- package/src/group/transforms.js +52 -0
- package/src/heading/edit.js +18 -5
- package/src/home-link/edit.js +1 -1
- package/src/home-link/index.php +1 -19
- package/src/image/deprecated.js +105 -1
- package/src/image/edit.js +7 -6
- package/src/image/edit.native.js +25 -8
- package/src/image/editor.scss +0 -18
- package/src/image/save.js +0 -8
- package/src/image/style.scss +5 -1
- package/src/image/test/edit.native.js +1 -11
- package/src/image/transforms.js +1 -1
- package/src/index.js +2 -3
- package/src/index.native.js +2 -2
- package/src/latest-posts/edit.js +1 -0
- package/src/latest-posts/index.php +1 -1
- package/src/media-text/edit.js +20 -2
- package/src/media-text/edit.native.js +2 -2
- package/src/media-text/media-container.native.js +1 -1
- package/src/media-text/style.native.scss +1 -0
- package/src/missing/edit.native.js +1 -1
- package/src/missing/test/edit-integration.native.js +4 -4
- package/src/missing/test/edit.native.js +2 -2
- package/src/more/transforms.js +2 -2
- package/src/navigation/edit/index.js +212 -88
- package/src/navigation/edit/inner-blocks.js +11 -4
- package/src/navigation/edit/navigation-menu-selector.js +121 -58
- package/src/navigation/edit/placeholder/index.js +64 -111
- package/src/navigation/edit/placeholder/placeholder-preview.js +3 -10
- package/src/navigation/edit/unsaved-inner-blocks.js +3 -1
- package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +137 -0
- package/src/navigation/edit/use-create-navigation-menu.js +59 -8
- package/src/navigation/edit/use-navigation-notice.js +3 -3
- package/src/navigation/editor.scss +23 -1
- package/src/navigation/index.php +4 -4
- package/src/navigation/menu-items-to-blocks.js +1 -1
- package/src/navigation/style.scss +22 -3
- package/src/navigation/test/menu-items-to-blocks.js +1 -1
- package/src/navigation/use-navigation-entities.js +26 -60
- package/src/navigation/use-navigation-menu.js +11 -6
- package/src/navigation-link/fallback-variations.js +1 -1
- package/src/navigation-link/hooks.js +2 -2
- package/src/navigation-link/index.php +3 -22
- package/src/navigation-link/test/edit.js +5 -5
- package/src/navigation-submenu/edit.js +52 -14
- package/src/navigation-submenu/index.php +3 -21
- package/src/page-list/convert-to-links-modal.js +17 -31
- package/src/page-list/edit.js +35 -48
- package/src/page-list/editor.scss +0 -10
- package/src/page-list/index.php +4 -4
- package/src/post-author-name/edit.js +1 -0
- package/src/post-author-name/index.php +1 -1
- package/src/post-comments-form/edit.js +7 -3
- package/src/post-excerpt/edit.js +9 -12
- package/src/post-navigation-link/index.php +3 -3
- package/src/post-terms/edit.js +2 -1
- package/src/query-title/edit.js +0 -1
- package/src/search/edit.js +6 -0
- package/src/search/edit.native.js +1 -1
- package/src/search/index.php +8 -4
- package/src/search/test/edit.native.js +0 -1
- package/src/separator/save.js +4 -4
- package/src/separator/separator-settings.native.js +1 -1
- package/src/site-logo/edit.js +1 -1
- package/src/site-logo/index.php +1 -1
- package/src/social-link/edit.native.js +17 -8
- package/src/social-link/test/index.native.js +138 -0
- package/src/social-links/deprecated.js +0 -59
- package/src/spacer/controls.js +1 -1
- package/src/spacer/controls.native.js +1 -1
- package/src/table/edit.js +2 -2
- package/src/tag-cloud/style.scss +12 -7
- package/src/template-part/edit/index.js +61 -71
- package/src/template-part/edit/placeholder.js +78 -0
- package/src/template-part/edit/selection-modal.js +115 -0
- package/src/template-part/edit/title-modal.js +59 -0
- package/src/template-part/edit/utils/hooks.js +158 -0
- package/src/template-part/editor.scss +16 -74
- package/src/template-part/index.js +4 -1
- package/src/video/edit.js +4 -4
- package/src/video/edit.native.js +3 -3
- package/src/video/style.native.scss +1 -0
- package/build/navigation/edit/existing-menus-options.js +0 -62
- package/build/navigation/edit/existing-menus-options.js.map +0 -1
- package/build/navigation/use-convert-classic-menu.js +0 -59
- package/build/navigation/use-convert-classic-menu.js.map +0 -1
- package/build/template-part/edit/placeholder/index.js +0 -141
- package/build/template-part/edit/placeholder/index.js.map +0 -1
- package/build/template-part/edit/placeholder/patterns-setup.js +0 -100
- package/build/template-part/edit/placeholder/patterns-setup.js.map +0 -1
- package/build/template-part/edit/selection/index.js +0 -45
- package/build/template-part/edit/selection/index.js.map +0 -1
- package/build/template-part/edit/selection/template-part-previews.js +0 -317
- package/build/template-part/edit/selection/template-part-previews.js.map +0 -1
- package/build-module/navigation/edit/existing-menus-options.js +0 -53
- package/build-module/navigation/edit/existing-menus-options.js.map +0 -1
- package/build-module/navigation/use-convert-classic-menu.js +0 -47
- package/build-module/navigation/use-convert-classic-menu.js.map +0 -1
- package/build-module/template-part/edit/placeholder/index.js +0 -124
- package/build-module/template-part/edit/placeholder/index.js.map +0 -1
- package/build-module/template-part/edit/placeholder/patterns-setup.js +0 -91
- package/build-module/template-part/edit/placeholder/patterns-setup.js.map +0 -1
- package/build-module/template-part/edit/selection/index.js +0 -35
- package/build-module/template-part/edit/selection/index.js.map +0 -1
- package/build-module/template-part/edit/selection/template-part-previews.js +0 -298
- package/build-module/template-part/edit/selection/template-part-previews.js.map +0 -1
- package/src/navigation/edit/existing-menus-options.js +0 -70
- package/src/navigation/use-convert-classic-menu.js +0 -58
- package/src/template-part/edit/placeholder/index.js +0 -172
- package/src/template-part/edit/placeholder/patterns-setup.js +0 -124
- package/src/template-part/edit/selection/index.js +0 -37
- package/src/template-part/edit/selection/template-part-previews.js +0 -372
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useCallback, useMemo } from '@wordpress/element';
|
|
5
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
6
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
7
|
+
import { useDispatch } from '@wordpress/data';
|
|
8
|
+
import { parse } from '@wordpress/blocks';
|
|
9
|
+
import { useAsyncList } from '@wordpress/compose';
|
|
10
|
+
import {
|
|
11
|
+
__experimentalBlockPatternsList as BlockPatternsList,
|
|
12
|
+
store as blockEditorStore,
|
|
13
|
+
} from '@wordpress/block-editor';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
import {
|
|
19
|
+
useAlternativeBlockPatterns,
|
|
20
|
+
useAlternativeTemplateParts,
|
|
21
|
+
useCreateTemplatePartFromBlocks,
|
|
22
|
+
} from './utils/hooks';
|
|
23
|
+
import { createTemplatePartId } from './utils/create-template-part-id';
|
|
24
|
+
|
|
25
|
+
export default function TemplatePartSelectionModal( {
|
|
26
|
+
setAttributes,
|
|
27
|
+
onClose,
|
|
28
|
+
templatePartId = null,
|
|
29
|
+
area,
|
|
30
|
+
clientId,
|
|
31
|
+
} ) {
|
|
32
|
+
// When the templatePartId is undefined,
|
|
33
|
+
// it means the user is creating a new one from the placeholder.
|
|
34
|
+
const isReplacingTemplatePartContent = !! templatePartId;
|
|
35
|
+
const { templateParts } = useAlternativeTemplateParts(
|
|
36
|
+
area,
|
|
37
|
+
templatePartId
|
|
38
|
+
);
|
|
39
|
+
// We can map template parts to block patters to reuse the BlockPatternsList UI
|
|
40
|
+
const templartPartsAsBlockPatterns = useMemo( () => {
|
|
41
|
+
return templateParts.map( ( templatePart ) => ( {
|
|
42
|
+
name: createTemplatePartId( templatePart.theme, templatePart.slug ),
|
|
43
|
+
title: templatePart.title.rendered,
|
|
44
|
+
blocks: parse( templatePart.content.raw ),
|
|
45
|
+
templatePart,
|
|
46
|
+
} ) );
|
|
47
|
+
}, [ templateParts ] );
|
|
48
|
+
const shownTemplateParts = useAsyncList( templartPartsAsBlockPatterns );
|
|
49
|
+
const { createSuccessNotice } = useDispatch( noticesStore );
|
|
50
|
+
const blockPatterns = useAlternativeBlockPatterns( area, clientId );
|
|
51
|
+
const shownBlockPatterns = useAsyncList( blockPatterns );
|
|
52
|
+
const { replaceInnerBlocks } = useDispatch( blockEditorStore );
|
|
53
|
+
|
|
54
|
+
const onTemplatePartSelect = useCallback( ( templatePart ) => {
|
|
55
|
+
setAttributes( {
|
|
56
|
+
slug: templatePart.slug,
|
|
57
|
+
theme: templatePart.theme,
|
|
58
|
+
area: undefined,
|
|
59
|
+
} );
|
|
60
|
+
createSuccessNotice(
|
|
61
|
+
sprintf(
|
|
62
|
+
/* translators: %s: template part title. */
|
|
63
|
+
__( 'Template Part "%s" inserted.' ),
|
|
64
|
+
templatePart.title?.rendered || templatePart.slug
|
|
65
|
+
),
|
|
66
|
+
{
|
|
67
|
+
type: 'snackbar',
|
|
68
|
+
}
|
|
69
|
+
);
|
|
70
|
+
onClose();
|
|
71
|
+
}, [] );
|
|
72
|
+
|
|
73
|
+
const createFromBlocks = useCreateTemplatePartFromBlocks(
|
|
74
|
+
area,
|
|
75
|
+
setAttributes
|
|
76
|
+
);
|
|
77
|
+
|
|
78
|
+
return (
|
|
79
|
+
<>
|
|
80
|
+
<div className="block-library-template-part__selection-content">
|
|
81
|
+
{ !! templartPartsAsBlockPatterns.length && (
|
|
82
|
+
<div>
|
|
83
|
+
<h2>{ __( 'Existing template parts' ) }</h2>
|
|
84
|
+
<BlockPatternsList
|
|
85
|
+
blockPatterns={ templartPartsAsBlockPatterns }
|
|
86
|
+
shownPatterns={ shownTemplateParts }
|
|
87
|
+
onClickPattern={ ( pattern ) => {
|
|
88
|
+
onTemplatePartSelect( pattern.templatePart );
|
|
89
|
+
} }
|
|
90
|
+
/>
|
|
91
|
+
</div>
|
|
92
|
+
) }
|
|
93
|
+
|
|
94
|
+
{ !! blockPatterns.length && (
|
|
95
|
+
<div>
|
|
96
|
+
<h2>{ __( 'Patterns' ) }</h2>
|
|
97
|
+
<BlockPatternsList
|
|
98
|
+
blockPatterns={ blockPatterns }
|
|
99
|
+
shownPatterns={ shownBlockPatterns }
|
|
100
|
+
onClickPattern={ ( pattern, blocks ) => {
|
|
101
|
+
if ( isReplacingTemplatePartContent ) {
|
|
102
|
+
replaceInnerBlocks( clientId, blocks );
|
|
103
|
+
} else {
|
|
104
|
+
createFromBlocks( blocks, pattern.title );
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
onClose();
|
|
108
|
+
} }
|
|
109
|
+
/>
|
|
110
|
+
</div>
|
|
111
|
+
) }
|
|
112
|
+
</div>
|
|
113
|
+
</>
|
|
114
|
+
);
|
|
115
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useState } from '@wordpress/element';
|
|
5
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
6
|
+
import {
|
|
7
|
+
TextControl,
|
|
8
|
+
Flex,
|
|
9
|
+
FlexItem,
|
|
10
|
+
Button,
|
|
11
|
+
Modal,
|
|
12
|
+
} from '@wordpress/components';
|
|
13
|
+
|
|
14
|
+
export default function TitleModal( { areaLabel, onClose, onSubmit } ) {
|
|
15
|
+
// Restructure onCreate to set the blocks on local state.
|
|
16
|
+
// Add modal to confirm title and trigger onCreate.
|
|
17
|
+
const [ title, setTitle ] = useState( __( 'Untitled Template Part' ) );
|
|
18
|
+
|
|
19
|
+
const submitForCreation = ( event ) => {
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
onSubmit( title );
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<Modal
|
|
26
|
+
title={ sprintf(
|
|
27
|
+
// Translators: %s as template part area title ("Header", "Footer", etc.).
|
|
28
|
+
__( 'Name and create your new %s' ),
|
|
29
|
+
areaLabel.toLowerCase()
|
|
30
|
+
) }
|
|
31
|
+
closeLabel={ __( 'Cancel' ) }
|
|
32
|
+
overlayClassName="wp-block-template-part__placeholder-create-new__title-form"
|
|
33
|
+
onRequestClose={ onClose }
|
|
34
|
+
>
|
|
35
|
+
<form onSubmit={ submitForCreation }>
|
|
36
|
+
<TextControl
|
|
37
|
+
label={ __( 'Name' ) }
|
|
38
|
+
value={ title }
|
|
39
|
+
onChange={ setTitle }
|
|
40
|
+
/>
|
|
41
|
+
<Flex
|
|
42
|
+
className="wp-block-template-part__placeholder-create-new__title-form-actions"
|
|
43
|
+
justify="flex-end"
|
|
44
|
+
>
|
|
45
|
+
<FlexItem>
|
|
46
|
+
<Button
|
|
47
|
+
variant="primary"
|
|
48
|
+
type="submit"
|
|
49
|
+
disabled={ ! title.length }
|
|
50
|
+
aria-disabled={ ! title.length }
|
|
51
|
+
>
|
|
52
|
+
{ __( 'Create' ) }
|
|
53
|
+
</Button>
|
|
54
|
+
</FlexItem>
|
|
55
|
+
</Flex>
|
|
56
|
+
</form>
|
|
57
|
+
</Modal>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { find, kebabCase } from 'lodash';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
10
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
12
|
+
import { useMemo } from '@wordpress/element';
|
|
13
|
+
import { serialize } from '@wordpress/blocks';
|
|
14
|
+
import { __ } from '@wordpress/i18n';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal dependencies
|
|
18
|
+
*/
|
|
19
|
+
import { createTemplatePartId } from './create-template-part-id';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Retrieves the available template parts for the given area.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} area Template part area.
|
|
25
|
+
* @param {string} excludedId Template part ID to exclude.
|
|
26
|
+
*
|
|
27
|
+
* @return {{ templateParts: Array, isResolving: boolean }} array of template parts.
|
|
28
|
+
*/
|
|
29
|
+
export function useAlternativeTemplateParts( area, excludedId ) {
|
|
30
|
+
const { templateParts, isResolving } = useSelect( ( select ) => {
|
|
31
|
+
const { getEntityRecords, isResolving: _isResolving } = select(
|
|
32
|
+
coreStore
|
|
33
|
+
);
|
|
34
|
+
const query = { per_page: -1 };
|
|
35
|
+
return {
|
|
36
|
+
templateParts: getEntityRecords(
|
|
37
|
+
'postType',
|
|
38
|
+
'wp_template_part',
|
|
39
|
+
query
|
|
40
|
+
),
|
|
41
|
+
isLoading: _isResolving( 'getEntityRecords', [
|
|
42
|
+
'postType',
|
|
43
|
+
'wp_template_part',
|
|
44
|
+
query,
|
|
45
|
+
] ),
|
|
46
|
+
};
|
|
47
|
+
}, [] );
|
|
48
|
+
|
|
49
|
+
const filteredTemplateParts = useMemo( () => {
|
|
50
|
+
if ( ! templateParts ) {
|
|
51
|
+
return [];
|
|
52
|
+
}
|
|
53
|
+
return (
|
|
54
|
+
templateParts.filter(
|
|
55
|
+
( templatePart ) =>
|
|
56
|
+
createTemplatePartId(
|
|
57
|
+
templatePart.theme,
|
|
58
|
+
templatePart.slug
|
|
59
|
+
) !== excludedId &&
|
|
60
|
+
( ! area ||
|
|
61
|
+
'uncategorized' === area ||
|
|
62
|
+
templatePart.area === area )
|
|
63
|
+
) || []
|
|
64
|
+
);
|
|
65
|
+
}, [ templateParts, area ] );
|
|
66
|
+
|
|
67
|
+
return {
|
|
68
|
+
templateParts: filteredTemplateParts,
|
|
69
|
+
isResolving,
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Retrieves the available block patterns for the given area.
|
|
75
|
+
*
|
|
76
|
+
* @param {string} area Template part area.
|
|
77
|
+
* @param {string} clientId Block Client ID. (The container of the block can impact allowed blocks).
|
|
78
|
+
*
|
|
79
|
+
* @return {Array} array of block patterns.
|
|
80
|
+
*/
|
|
81
|
+
export function useAlternativeBlockPatterns( area, clientId ) {
|
|
82
|
+
return useSelect(
|
|
83
|
+
( select ) => {
|
|
84
|
+
const blockNameWithArea = area
|
|
85
|
+
? `core/template-part/${ area }`
|
|
86
|
+
: 'core/template-part';
|
|
87
|
+
const {
|
|
88
|
+
getBlockRootClientId,
|
|
89
|
+
__experimentalGetPatternsByBlockTypes,
|
|
90
|
+
} = select( blockEditorStore );
|
|
91
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
92
|
+
return __experimentalGetPatternsByBlockTypes(
|
|
93
|
+
blockNameWithArea,
|
|
94
|
+
rootClientId
|
|
95
|
+
);
|
|
96
|
+
},
|
|
97
|
+
[ area, clientId ]
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
export function useCreateTemplatePartFromBlocks( area, setAttributes ) {
|
|
102
|
+
const { saveEntityRecord } = useDispatch( coreStore );
|
|
103
|
+
|
|
104
|
+
return async ( blocks = [], title = __( 'Untitled Template Part' ) ) => {
|
|
105
|
+
// If we have `area` set from block attributes, means an exposed
|
|
106
|
+
// block variation was inserted. So add this prop to the template
|
|
107
|
+
// part entity on creation. Afterwards remove `area` value from
|
|
108
|
+
// block attributes.
|
|
109
|
+
const record = {
|
|
110
|
+
title,
|
|
111
|
+
slug: kebabCase( title ),
|
|
112
|
+
content: serialize( blocks ),
|
|
113
|
+
// `area` is filterable on the server and defaults to `UNCATEGORIZED`
|
|
114
|
+
// if provided value is not allowed.
|
|
115
|
+
area,
|
|
116
|
+
};
|
|
117
|
+
const templatePart = await saveEntityRecord(
|
|
118
|
+
'postType',
|
|
119
|
+
'wp_template_part',
|
|
120
|
+
record
|
|
121
|
+
);
|
|
122
|
+
setAttributes( {
|
|
123
|
+
slug: templatePart.slug,
|
|
124
|
+
theme: templatePart.theme,
|
|
125
|
+
area: undefined,
|
|
126
|
+
} );
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Retrieves the template part area object.
|
|
132
|
+
*
|
|
133
|
+
* @param {string} area Template part area identifier.
|
|
134
|
+
*
|
|
135
|
+
* @return {{icon: Object, label: string, tagName: string}} Template Part area.
|
|
136
|
+
*/
|
|
137
|
+
export function useTemplatePartArea( area ) {
|
|
138
|
+
return useSelect(
|
|
139
|
+
( select ) => {
|
|
140
|
+
// FIXME: @wordpress/block-library should not depend on @wordpress/editor.
|
|
141
|
+
// Blocks can be loaded into a *non-post* block editor.
|
|
142
|
+
// eslint-disable-next-line @wordpress/data-no-store-string-literals
|
|
143
|
+
const definedAreas = select(
|
|
144
|
+
'core/editor'
|
|
145
|
+
).__experimentalGetDefaultTemplatePartAreas();
|
|
146
|
+
|
|
147
|
+
const selectedArea = find( definedAreas, { area } );
|
|
148
|
+
const defaultArea = find( definedAreas, { area: 'uncategorized' } );
|
|
149
|
+
|
|
150
|
+
return {
|
|
151
|
+
icon: selectedArea?.icon || defaultArea?.icon,
|
|
152
|
+
label: selectedArea?.label || __( 'Template Part' ),
|
|
153
|
+
tagName: selectedArea?.area_tag ?? 'div',
|
|
154
|
+
};
|
|
155
|
+
},
|
|
156
|
+
[ area ]
|
|
157
|
+
);
|
|
158
|
+
}
|
|
@@ -1,82 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
.
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.wp-block-template-part__selection-preview-search-form {
|
|
11
|
-
border-bottom: $border-width solid $gray-300;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.wp-block-template-part__selection-preview-container {
|
|
15
|
-
background: $white;
|
|
16
|
-
padding-bottom: 16px;
|
|
17
|
-
|
|
18
|
-
.wp-block-template-part__selection-preview-item {
|
|
19
|
-
border-radius: $radius-block-ui;
|
|
20
|
-
cursor: pointer;
|
|
21
|
-
margin-top: $grid-unit-20;
|
|
22
|
-
transition: all 0.05s ease-in-out;
|
|
23
|
-
border: $border-width solid $gray-300;
|
|
24
|
-
width: 100%;
|
|
25
|
-
background-color: $white;
|
|
26
|
-
|
|
27
|
-
&:hover {
|
|
28
|
-
border: $border-width solid var(--wp-admin-theme-color);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&:focus {
|
|
32
|
-
box-shadow: inset 0 0 0 1px $white, 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
|
|
33
|
-
|
|
34
|
-
// Windows High Contrast mode will show this outline, but not the box-shadow.
|
|
35
|
-
outline: 2px solid transparent;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
&.is-placeholder {
|
|
39
|
-
min-height: 100px;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
.block-editor-block-preview__container {
|
|
43
|
-
border-bottom: $border-width solid $gray-300;
|
|
44
|
-
}
|
|
1
|
+
.block-editor-template-part__selection-modal {
|
|
2
|
+
// To keep modal dimensions consistent as subsections are navigated, width
|
|
3
|
+
// and height are used instead of max-(width/height).
|
|
4
|
+
@include break-small() {
|
|
5
|
+
width: calc(100% - #{ $grid-unit-20 * 2 });
|
|
6
|
+
height: calc(100% - #{ $header-height * 2 });
|
|
45
7
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
padding: $grid-unit-05;
|
|
49
|
-
font-size: $helptext-font-size;
|
|
50
|
-
text-align: left;
|
|
8
|
+
@include break-medium() {
|
|
9
|
+
width: $break-medium - $grid-unit-20 * 2;
|
|
51
10
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
padding: $grid-unit-20 $grid-unit-20 0;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
.wp-block-template-part__selection-panel-group-content {
|
|
58
|
-
padding: 0 $grid-unit-20;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.wp-block-template-part__selection-panel-group-title {
|
|
62
|
-
color: var(--wp-admin-theme-color);
|
|
63
|
-
text-transform: uppercase;
|
|
64
|
-
font-size: 11px;
|
|
65
|
-
font-weight: 500;
|
|
11
|
+
@include break-large() {
|
|
12
|
+
height: 70%;
|
|
66
13
|
}
|
|
67
14
|
}
|
|
68
15
|
|
|
69
|
-
.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// flex-end setting. Created issue https://github.com/WordPress/gutenberg/issues/33735 to
|
|
74
|
-
// attempt document this issue.
|
|
75
|
-
display: flex;
|
|
76
|
-
justify-content: flex-end;
|
|
16
|
+
.block-library-template-part__selection-content .block-editor-block-patterns-list {
|
|
17
|
+
display: grid;
|
|
18
|
+
grid-template-columns: 1fr 1fr;
|
|
19
|
+
grid-gap: $grid-unit-10;
|
|
77
20
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
21
|
+
.block-editor-block-patterns-list__list-item {
|
|
22
|
+
margin-bottom: 0;
|
|
81
23
|
}
|
|
82
24
|
}
|
|
@@ -10,6 +10,7 @@ import { store as coreDataStore } from '@wordpress/core-data';
|
|
|
10
10
|
import { select } from '@wordpress/data';
|
|
11
11
|
import { symbolFilled } from '@wordpress/icons';
|
|
12
12
|
import { addFilter } from '@wordpress/hooks';
|
|
13
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Internal dependencies
|
|
@@ -39,7 +40,9 @@ export const settings = {
|
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
return
|
|
43
|
+
return (
|
|
44
|
+
decodeEntities( entity.title?.rendered ) || startCase( entity.slug )
|
|
45
|
+
);
|
|
43
46
|
},
|
|
44
47
|
edit,
|
|
45
48
|
};
|
package/src/video/edit.js
CHANGED
|
@@ -91,9 +91,9 @@ function VideoEdit( {
|
|
|
91
91
|
|
|
92
92
|
function onSelectVideo( media ) {
|
|
93
93
|
if ( ! media || ! media.url ) {
|
|
94
|
-
//
|
|
94
|
+
// In this case there was an error
|
|
95
95
|
// previous attributes should be removed
|
|
96
|
-
// because they may be temporary blob urls
|
|
96
|
+
// because they may be temporary blob urls.
|
|
97
97
|
setAttributes( {
|
|
98
98
|
src: undefined,
|
|
99
99
|
id: undefined,
|
|
@@ -102,8 +102,8 @@ function VideoEdit( {
|
|
|
102
102
|
return;
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
//
|
|
106
|
-
// selected media
|
|
105
|
+
// Sets the block's attribute and updates the edit component from the
|
|
106
|
+
// selected media.
|
|
107
107
|
setAttributes( {
|
|
108
108
|
src: media.url,
|
|
109
109
|
id: media.id,
|
package/src/video/edit.native.js
CHANGED
|
@@ -84,7 +84,7 @@ class VideoEdit extends Component {
|
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
componentWillUnmount() {
|
|
87
|
-
//
|
|
87
|
+
// This action will only exist if the user pressed the trash button on the block holder.
|
|
88
88
|
if (
|
|
89
89
|
hasAction( 'blocks.onRemoveBlockCheckUpload' ) &&
|
|
90
90
|
this.state.isUploadInProgress
|
|
@@ -98,7 +98,7 @@ class VideoEdit extends Component {
|
|
|
98
98
|
|
|
99
99
|
static getDerivedStateFromProps( props, state ) {
|
|
100
100
|
// Avoid a UI flicker in the toolbar by insuring that isCaptionSelected
|
|
101
|
-
// is updated immediately any time the isSelected prop becomes false
|
|
101
|
+
// is updated immediately any time the isSelected prop becomes false.
|
|
102
102
|
return {
|
|
103
103
|
isCaptionSelected: props.isSelected && state.isCaptionSelected,
|
|
104
104
|
};
|
|
@@ -362,7 +362,7 @@ class VideoEdit extends Component {
|
|
|
362
362
|
clientId={ this.props.clientId }
|
|
363
363
|
isSelected={ this.state.isCaptionSelected }
|
|
364
364
|
onFocus={ this.onFocusCaption }
|
|
365
|
-
onBlur={ this.props.onBlur } //
|
|
365
|
+
onBlur={ this.props.onBlur } // Always assign onBlur as props.
|
|
366
366
|
insertBlocksAfter={ this.props.insertBlocksAfter }
|
|
367
367
|
/>
|
|
368
368
|
</View>
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = void 0;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
var _components = require("@wordpress/components");
|
|
11
|
-
|
|
12
|
-
var _i18n = require("@wordpress/i18n");
|
|
13
|
-
|
|
14
|
-
var _htmlEntities = require("@wordpress/html-entities");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
const ExistingMenusOptions = _ref => {
|
|
20
|
-
let {
|
|
21
|
-
showNavigationMenus,
|
|
22
|
-
showClassicMenus = false,
|
|
23
|
-
navigationMenus,
|
|
24
|
-
classicMenus,
|
|
25
|
-
onSelectNavigationMenu,
|
|
26
|
-
onSelectClassicMenu,
|
|
27
|
-
actionLabel
|
|
28
|
-
} = _ref;
|
|
29
|
-
const hasNavigationMenus = !!(navigationMenus !== null && navigationMenus !== void 0 && navigationMenus.length);
|
|
30
|
-
const hasClassicMenus = !!(classicMenus !== null && classicMenus !== void 0 && classicMenus.length);
|
|
31
|
-
/* translators: %s: The name of a menu. */
|
|
32
|
-
|
|
33
|
-
const createActionLabel = (0, _i18n.__)("Create from '%s'");
|
|
34
|
-
actionLabel = actionLabel || createActionLabel;
|
|
35
|
-
return (0, _element.createElement)(_element.Fragment, null, showNavigationMenus && hasNavigationMenus && (0, _element.createElement)(_components.MenuGroup, {
|
|
36
|
-
label: (0, _i18n.__)('Menus')
|
|
37
|
-
}, navigationMenus.map(menu => {
|
|
38
|
-
const label = (0, _htmlEntities.decodeEntities)(menu.title.rendered);
|
|
39
|
-
return (0, _element.createElement)(_components.MenuItem, {
|
|
40
|
-
onClick: () => {
|
|
41
|
-
onSelectNavigationMenu(menu);
|
|
42
|
-
},
|
|
43
|
-
key: menu.id,
|
|
44
|
-
"aria-label": (0, _i18n.sprintf)(actionLabel, label)
|
|
45
|
-
}, label);
|
|
46
|
-
})), showClassicMenus && hasClassicMenus && (0, _element.createElement)(_components.MenuGroup, {
|
|
47
|
-
label: (0, _i18n.__)('Classic Menus')
|
|
48
|
-
}, classicMenus.map(menu => {
|
|
49
|
-
const label = (0, _htmlEntities.decodeEntities)(menu.name);
|
|
50
|
-
return (0, _element.createElement)(_components.MenuItem, {
|
|
51
|
-
onClick: () => {
|
|
52
|
-
onSelectClassicMenu(menu);
|
|
53
|
-
},
|
|
54
|
-
key: menu.id,
|
|
55
|
-
"aria-label": (0, _i18n.sprintf)(createActionLabel, label)
|
|
56
|
-
}, label);
|
|
57
|
-
})));
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
var _default = ExistingMenusOptions;
|
|
61
|
-
exports.default = _default;
|
|
62
|
-
//# sourceMappingURL=existing-menus-options.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/navigation/edit/existing-menus-options.js"],"names":["ExistingMenusOptions","showNavigationMenus","showClassicMenus","navigationMenus","classicMenus","onSelectNavigationMenu","onSelectClassicMenu","actionLabel","hasNavigationMenus","length","hasClassicMenus","createActionLabel","map","menu","label","title","rendered","id","name"],"mappings":";;;;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAKA,MAAMA,oBAAoB,GAAG,QAQtB;AAAA,MARwB;AAC9BC,IAAAA,mBAD8B;AAE9BC,IAAAA,gBAAgB,GAAG,KAFW;AAG9BC,IAAAA,eAH8B;AAI9BC,IAAAA,YAJ8B;AAK9BC,IAAAA,sBAL8B;AAM9BC,IAAAA,mBAN8B;AAO9BC,IAAAA;AAP8B,GAQxB;AACN,QAAMC,kBAAkB,GAAG,CAAC,EAAEL,eAAF,aAAEA,eAAF,eAAEA,eAAe,CAAEM,MAAnB,CAA5B;AACA,QAAMC,eAAe,GAAG,CAAC,EAAEN,YAAF,aAAEA,YAAF,eAAEA,YAAY,CAAEK,MAAhB,CAAzB;AAEA;;AACA,QAAME,iBAAiB,GAAG,cAAI,kBAAJ,CAA1B;AAEAJ,EAAAA,WAAW,GAAGA,WAAW,IAAII,iBAA7B;AAEA,SACC,qDACGV,mBAAmB,IAAIO,kBAAvB,IACD,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,OAAJ;AAAnB,KACGL,eAAe,CAACS,GAAhB,CAAuBC,IAAF,IAAY;AAClC,UAAMC,KAAK,GAAG,kCAAgBD,IAAI,CAACE,KAAL,CAAWC,QAA3B,CAAd;AACA,WACC,4BAAC,oBAAD;AACC,MAAA,OAAO,EAAG,MAAM;AACfX,QAAAA,sBAAsB,CAAEQ,IAAF,CAAtB;AACA,OAHF;AAIC,MAAA,GAAG,EAAGA,IAAI,CAACI,EAJZ;AAKC,oBAAa,mBAASV,WAAT,EAAsBO,KAAtB;AALd,OAOGA,KAPH,CADD;AAWA,GAbC,CADH,CAFF,EAmBGZ,gBAAgB,IAAIQ,eAApB,IACD,4BAAC,qBAAD;AAAW,IAAA,KAAK,EAAG,cAAI,eAAJ;AAAnB,KACGN,YAAY,CAACQ,GAAb,CAAoBC,IAAF,IAAY;AAC/B,UAAMC,KAAK,GAAG,kCAAgBD,IAAI,CAACK,IAArB,CAAd;AACA,WACC,4BAAC,oBAAD;AACC,MAAA,OAAO,EAAG,MAAM;AACfZ,QAAAA,mBAAmB,CAAEO,IAAF,CAAnB;AACA,OAHF;AAIC,MAAA,GAAG,EAAGA,IAAI,CAACI,EAJZ;AAKC,oBAAa,mBACZN,iBADY,EAEZG,KAFY;AALd,OAUGA,KAVH,CADD;AAcA,GAhBC,CADH,CApBF,CADD;AA2CA,CA5DD;;eA8Ded,oB","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuGroup, MenuItem } from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { decodeEntities } from '@wordpress/html-entities';\n\nconst ExistingMenusOptions = ( {\n\tshowNavigationMenus,\n\tshowClassicMenus = false,\n\tnavigationMenus,\n\tclassicMenus,\n\tonSelectNavigationMenu,\n\tonSelectClassicMenu,\n\tactionLabel,\n} ) => {\n\tconst hasNavigationMenus = !! navigationMenus?.length;\n\tconst hasClassicMenus = !! classicMenus?.length;\n\n\t/* translators: %s: The name of a menu. */\n\tconst createActionLabel = __( \"Create from '%s'\" );\n\n\tactionLabel = actionLabel || createActionLabel;\n\n\treturn (\n\t\t<>\n\t\t\t{ showNavigationMenus && hasNavigationMenus && (\n\t\t\t\t<MenuGroup label={ __( 'Menus' ) }>\n\t\t\t\t\t{ navigationMenus.map( ( menu ) => {\n\t\t\t\t\t\tconst label = decodeEntities( menu.title.rendered );\n\t\t\t\t\t\treturn (\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\tonSelectNavigationMenu( menu );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tkey={ menu.id }\n\t\t\t\t\t\t\t\taria-label={ sprintf( actionLabel, label ) }\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ label }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t\t{ showClassicMenus && hasClassicMenus && (\n\t\t\t\t<MenuGroup label={ __( 'Classic Menus' ) }>\n\t\t\t\t\t{ classicMenus.map( ( menu ) => {\n\t\t\t\t\t\tconst label = decodeEntities( menu.name );\n\t\t\t\t\t\treturn (\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\tonSelectClassicMenu( menu );\n\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\tkey={ menu.id }\n\t\t\t\t\t\t\t\taria-label={ sprintf(\n\t\t\t\t\t\t\t\t\tcreateActionLabel,\n\t\t\t\t\t\t\t\t\tlabel\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{ label }\n\t\t\t\t\t\t\t</MenuItem>\n\t\t\t\t\t\t);\n\t\t\t\t\t} ) }\n\t\t\t\t</MenuGroup>\n\t\t\t) }\n\t\t</>\n\t);\n};\n\nexport default ExistingMenusOptions;\n"]}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = useConvertClassicMenu;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _useNavigationEntities = _interopRequireDefault(require("./use-navigation-entities"));
|
|
13
|
-
|
|
14
|
-
var _menuItemsToBlocks = _interopRequireDefault(require("./menu-items-to-blocks"));
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Internal dependencies
|
|
22
|
-
*/
|
|
23
|
-
function useConvertClassicMenu(onFinish) {
|
|
24
|
-
const [selectedMenu, setSelectedMenu] = (0, _element.useState)();
|
|
25
|
-
const [isAwaitingMenuItemResolution, setIsAwaitingMenuItemResolution] = (0, _element.useState)(false);
|
|
26
|
-
const [menuName, setMenuName] = (0, _element.useState)('');
|
|
27
|
-
const {
|
|
28
|
-
menuItems,
|
|
29
|
-
hasResolvedMenuItems
|
|
30
|
-
} = (0, _useNavigationEntities.default)(selectedMenu);
|
|
31
|
-
const createFromMenu = (0, _element.useCallback)(name => {
|
|
32
|
-
const {
|
|
33
|
-
innerBlocks: blocks
|
|
34
|
-
} = (0, _menuItemsToBlocks.default)(menuItems);
|
|
35
|
-
onFinish(blocks, name);
|
|
36
|
-
}, [menuItems, _menuItemsToBlocks.default, onFinish]);
|
|
37
|
-
(0, _element.useEffect)(() => {
|
|
38
|
-
// If the user selected a menu but we had to wait for menu items to
|
|
39
|
-
// finish resolving, then create the block once resolution finishes.
|
|
40
|
-
if (isAwaitingMenuItemResolution && hasResolvedMenuItems) {
|
|
41
|
-
createFromMenu(menuName);
|
|
42
|
-
setIsAwaitingMenuItemResolution(false);
|
|
43
|
-
}
|
|
44
|
-
}, [isAwaitingMenuItemResolution, hasResolvedMenuItems, menuName]);
|
|
45
|
-
return (0, _element.useCallback)((id, name) => {
|
|
46
|
-
setSelectedMenu(id); // If we have menu items, create the block right away.
|
|
47
|
-
|
|
48
|
-
if (hasResolvedMenuItems) {
|
|
49
|
-
createFromMenu(name);
|
|
50
|
-
return;
|
|
51
|
-
} // Otherwise, create the block when resolution finishes.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
setIsAwaitingMenuItemResolution(true); // Store the name to use later.
|
|
55
|
-
|
|
56
|
-
setMenuName(name);
|
|
57
|
-
}, [hasResolvedMenuItems, createFromMenu]);
|
|
58
|
-
}
|
|
59
|
-
//# sourceMappingURL=use-convert-classic-menu.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/navigation/use-convert-classic-menu.js"],"names":["useConvertClassicMenu","onFinish","selectedMenu","setSelectedMenu","isAwaitingMenuItemResolution","setIsAwaitingMenuItemResolution","menuName","setMenuName","menuItems","hasResolvedMenuItems","createFromMenu","name","innerBlocks","blocks","menuItemsToBlocks","id"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;AAIe,SAASA,qBAAT,CAAgCC,QAAhC,EAA2C;AACzD,QAAM,CAAEC,YAAF,EAAgBC,eAAhB,IAAoC,wBAA1C;AACA,QAAM,CACLC,4BADK,EAELC,+BAFK,IAGF,uBAAU,KAAV,CAHJ;AAIA,QAAM,CAAEC,QAAF,EAAYC,WAAZ,IAA4B,uBAAU,EAAV,CAAlC;AAEA,QAAM;AAAEC,IAAAA,SAAF;AAAaC,IAAAA;AAAb,MAAsC,oCAC3CP,YAD2C,CAA5C;AAIA,QAAMQ,cAAc,GAAG,0BACpBC,IAAF,IAAY;AACX,UAAM;AAAEC,MAAAA,WAAW,EAAEC;AAAf,QAA0B,gCAAmBL,SAAnB,CAAhC;AACAP,IAAAA,QAAQ,CAAEY,MAAF,EAAUF,IAAV,CAAR;AACA,GAJqB,EAKtB,CAAEH,SAAF,EAAaM,0BAAb,EAAgCb,QAAhC,CALsB,CAAvB;AAQA,0BAAW,MAAM;AAChB;AACA;AACA,QAAKG,4BAA4B,IAAIK,oBAArC,EAA4D;AAC3DC,MAAAA,cAAc,CAAEJ,QAAF,CAAd;AACAD,MAAAA,+BAA+B,CAAE,KAAF,CAA/B;AACA;AACD,GAPD,EAOG,CAAED,4BAAF,EAAgCK,oBAAhC,EAAsDH,QAAtD,CAPH;AASA,SAAO,0BACN,CAAES,EAAF,EAAMJ,IAAN,KAAgB;AACfR,IAAAA,eAAe,CAAEY,EAAF,CAAf,CADe,CAGf;;AACA,QAAKN,oBAAL,EAA4B;AAC3BC,MAAAA,cAAc,CAAEC,IAAF,CAAd;AACA;AACA,KAPc,CASf;;;AACAN,IAAAA,+BAA+B,CAAE,IAAF,CAA/B,CAVe,CAWf;;AACAE,IAAAA,WAAW,CAAEI,IAAF,CAAX;AACA,GAdK,EAeN,CAAEF,oBAAF,EAAwBC,cAAxB,CAfM,CAAP;AAiBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useState, useEffect } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport useNavigationEntities from './use-navigation-entities';\nimport menuItemsToBlocks from './menu-items-to-blocks';\n\nexport default function useConvertClassicMenu( onFinish ) {\n\tconst [ selectedMenu, setSelectedMenu ] = useState();\n\tconst [\n\t\tisAwaitingMenuItemResolution,\n\t\tsetIsAwaitingMenuItemResolution,\n\t] = useState( false );\n\tconst [ menuName, setMenuName ] = useState( '' );\n\n\tconst { menuItems, hasResolvedMenuItems } = useNavigationEntities(\n\t\tselectedMenu\n\t);\n\n\tconst createFromMenu = useCallback(\n\t\t( name ) => {\n\t\t\tconst { innerBlocks: blocks } = menuItemsToBlocks( menuItems );\n\t\t\tonFinish( blocks, name );\n\t\t},\n\t\t[ menuItems, menuItemsToBlocks, onFinish ]\n\t);\n\n\tuseEffect( () => {\n\t\t// If the user selected a menu but we had to wait for menu items to\n\t\t// finish resolving, then create the block once resolution finishes.\n\t\tif ( isAwaitingMenuItemResolution && hasResolvedMenuItems ) {\n\t\t\tcreateFromMenu( menuName );\n\t\t\tsetIsAwaitingMenuItemResolution( false );\n\t\t}\n\t}, [ isAwaitingMenuItemResolution, hasResolvedMenuItems, menuName ] );\n\n\treturn useCallback(\n\t\t( id, name ) => {\n\t\t\tsetSelectedMenu( id );\n\n\t\t\t// If we have menu items, create the block right away.\n\t\t\tif ( hasResolvedMenuItems ) {\n\t\t\t\tcreateFromMenu( name );\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\t// Otherwise, create the block when resolution finishes.\n\t\t\tsetIsAwaitingMenuItemResolution( true );\n\t\t\t// Store the name to use later.\n\t\t\tsetMenuName( name );\n\t\t},\n\t\t[ hasResolvedMenuItems, createFromMenu ]\n\t);\n}\n"]}
|