@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
|
@@ -1,141 +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 = TemplatePartPlaceholder;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
|
-
var _i18n = require("@wordpress/i18n");
|
|
15
|
-
|
|
16
|
-
var _data = require("@wordpress/data");
|
|
17
|
-
|
|
18
|
-
var _components = require("@wordpress/components");
|
|
19
|
-
|
|
20
|
-
var _blocks = require("@wordpress/blocks");
|
|
21
|
-
|
|
22
|
-
var _coreData = require("@wordpress/core-data");
|
|
23
|
-
|
|
24
|
-
var _selection = _interopRequireDefault(require("../selection"));
|
|
25
|
-
|
|
26
|
-
var _patternsSetup = _interopRequireDefault(require("./patterns-setup"));
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* External dependencies
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* WordPress dependencies
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Internal dependencies
|
|
38
|
-
*/
|
|
39
|
-
const PLACEHOLDER_STEPS = {
|
|
40
|
-
initial: 1,
|
|
41
|
-
patterns: 2
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
function TemplatePartPlaceholder(_ref) {
|
|
45
|
-
let {
|
|
46
|
-
area,
|
|
47
|
-
clientId,
|
|
48
|
-
setAttributes,
|
|
49
|
-
enableSelection,
|
|
50
|
-
hasResolvedReplacements
|
|
51
|
-
} = _ref;
|
|
52
|
-
const {
|
|
53
|
-
saveEntityRecord
|
|
54
|
-
} = (0, _data.useDispatch)(_coreData.store);
|
|
55
|
-
const [step, setStep] = (0, _element.useState)(PLACEHOLDER_STEPS.initial);
|
|
56
|
-
const {
|
|
57
|
-
areaIcon,
|
|
58
|
-
areaLabel
|
|
59
|
-
} = (0, _data.useSelect)(select => {
|
|
60
|
-
// FIXME: @wordpress/block-library should not depend on @wordpress/editor.
|
|
61
|
-
// Blocks can be loaded into a *non-post* block editor.
|
|
62
|
-
// eslint-disable-next-line @wordpress/data-no-store-string-literals
|
|
63
|
-
const definedAreas = select('core/editor').__experimentalGetDefaultTemplatePartAreas();
|
|
64
|
-
|
|
65
|
-
const selectedArea = (0, _lodash.find)(definedAreas, {
|
|
66
|
-
area
|
|
67
|
-
});
|
|
68
|
-
const defaultArea = (0, _lodash.find)(definedAreas, {
|
|
69
|
-
area: 'uncategorized'
|
|
70
|
-
});
|
|
71
|
-
return {
|
|
72
|
-
areaIcon: (selectedArea === null || selectedArea === void 0 ? void 0 : selectedArea.icon) || (defaultArea === null || defaultArea === void 0 ? void 0 : defaultArea.icon),
|
|
73
|
-
areaLabel: (selectedArea === null || selectedArea === void 0 ? void 0 : selectedArea.label) || (0, _i18n.__)('Template Part')
|
|
74
|
-
};
|
|
75
|
-
}, [area]);
|
|
76
|
-
const onCreate = (0, _element.useCallback)(async function () {
|
|
77
|
-
let startingBlocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
78
|
-
let title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0, _i18n.__)('Untitled Template Part');
|
|
79
|
-
// If we have `area` set from block attributes, means an exposed
|
|
80
|
-
// block variation was inserted. So add this prop to the template
|
|
81
|
-
// part entity on creation. Afterwards remove `area` value from
|
|
82
|
-
// block attributes.
|
|
83
|
-
const record = {
|
|
84
|
-
title,
|
|
85
|
-
slug: (0, _lodash.kebabCase)(title),
|
|
86
|
-
content: (0, _blocks.serialize)(startingBlocks),
|
|
87
|
-
// `area` is filterable on the server and defaults to `UNCATEGORIZED`
|
|
88
|
-
// if provided value is not allowed.
|
|
89
|
-
area
|
|
90
|
-
};
|
|
91
|
-
const templatePart = await saveEntityRecord('postType', 'wp_template_part', record);
|
|
92
|
-
setAttributes({
|
|
93
|
-
slug: templatePart.slug,
|
|
94
|
-
theme: templatePart.theme,
|
|
95
|
-
area: undefined
|
|
96
|
-
});
|
|
97
|
-
}, [setAttributes, area]);
|
|
98
|
-
return (0, _element.createElement)(_element.Fragment, null, step === PLACEHOLDER_STEPS.initial && (0, _element.createElement)(_components.Placeholder, {
|
|
99
|
-
icon: areaIcon,
|
|
100
|
-
label: areaLabel,
|
|
101
|
-
instructions: enableSelection ? (0, _i18n.sprintf)( // Translators: %s as template part area title ("Header", "Footer", etc.).
|
|
102
|
-
(0, _i18n.__)('Choose an existing %s or create a new one.'), areaLabel.toLowerCase()) : (0, _i18n.sprintf)( // Translators: %s as template part area title ("Header", "Footer", etc.).
|
|
103
|
-
(0, _i18n.__)('Create a new %s.'), areaLabel.toLowerCase())
|
|
104
|
-
}, !hasResolvedReplacements ? (0, _element.createElement)(_components.Spinner, null) : (0, _element.createElement)(_components.Dropdown, {
|
|
105
|
-
contentClassName: "wp-block-template-part__placeholder-preview-dropdown-content",
|
|
106
|
-
position: "bottom right left",
|
|
107
|
-
renderToggle: _ref2 => {
|
|
108
|
-
let {
|
|
109
|
-
isOpen,
|
|
110
|
-
onToggle
|
|
111
|
-
} = _ref2;
|
|
112
|
-
return (0, _element.createElement)(_element.Fragment, null, enableSelection && (0, _element.createElement)(_components.Button, {
|
|
113
|
-
variant: "primary",
|
|
114
|
-
onClick: onToggle,
|
|
115
|
-
"aria-expanded": isOpen
|
|
116
|
-
}, (0, _i18n.__)('Choose existing')), (0, _element.createElement)(_components.Button, {
|
|
117
|
-
variant: enableSelection ? 'tertiary' : 'primary',
|
|
118
|
-
onClick: () => setStep(PLACEHOLDER_STEPS.patterns)
|
|
119
|
-
}, (0, _i18n.sprintf)( // Translators: %s as template part area title ("Header", "Footer", etc.).
|
|
120
|
-
(0, _i18n.__)('New %s'), areaLabel.toLowerCase())));
|
|
121
|
-
},
|
|
122
|
-
renderContent: _ref3 => {
|
|
123
|
-
let {
|
|
124
|
-
onClose
|
|
125
|
-
} = _ref3;
|
|
126
|
-
return (0, _element.createElement)(_selection.default, {
|
|
127
|
-
setAttributes: setAttributes,
|
|
128
|
-
onClose: onClose,
|
|
129
|
-
area: area
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
})), step === PLACEHOLDER_STEPS.patterns && (0, _element.createElement)(_patternsSetup.default, {
|
|
133
|
-
area: area,
|
|
134
|
-
areaLabel: areaLabel,
|
|
135
|
-
areaIcon: areaIcon,
|
|
136
|
-
onCreate: onCreate,
|
|
137
|
-
clientId: clientId,
|
|
138
|
-
resetPlaceholder: () => setStep(PLACEHOLDER_STEPS.initial)
|
|
139
|
-
}));
|
|
140
|
-
}
|
|
141
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/placeholder/index.js"],"names":["PLACEHOLDER_STEPS","initial","patterns","TemplatePartPlaceholder","area","clientId","setAttributes","enableSelection","hasResolvedReplacements","saveEntityRecord","coreStore","step","setStep","areaIcon","areaLabel","select","definedAreas","__experimentalGetDefaultTemplatePartAreas","selectedArea","defaultArea","icon","label","onCreate","startingBlocks","title","record","slug","content","templatePart","theme","undefined","toLowerCase","isOpen","onToggle","onClose"],"mappings":"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","sourcesContent":["/**\n * External dependencies\n */\nimport { find, kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useCallback, useState } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { Placeholder, Dropdown, Button, Spinner } from '@wordpress/components';\nimport { serialize } from '@wordpress/blocks';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartSelection from '../selection';\nimport PatternsSetup from './patterns-setup';\n\nconst PLACEHOLDER_STEPS = {\n\tinitial: 1,\n\tpatterns: 2,\n};\n\nexport default function TemplatePartPlaceholder( {\n\tarea,\n\tclientId,\n\tsetAttributes,\n\tenableSelection,\n\thasResolvedReplacements,\n} ) {\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\tconst [ step, setStep ] = useState( PLACEHOLDER_STEPS.initial );\n\n\tconst { areaIcon, areaLabel } = useSelect(\n\t\t( select ) => {\n\t\t\t// FIXME: @wordpress/block-library should not depend on @wordpress/editor.\n\t\t\t// Blocks can be loaded into a *non-post* block editor.\n\t\t\t// eslint-disable-next-line @wordpress/data-no-store-string-literals\n\t\t\tconst definedAreas = select(\n\t\t\t\t'core/editor'\n\t\t\t).__experimentalGetDefaultTemplatePartAreas();\n\n\t\t\tconst selectedArea = find( definedAreas, { area } );\n\t\t\tconst defaultArea = find( definedAreas, { area: 'uncategorized' } );\n\n\t\t\treturn {\n\t\t\t\tareaIcon: selectedArea?.icon || defaultArea?.icon,\n\t\t\t\tareaLabel: selectedArea?.label || __( 'Template Part' ),\n\t\t\t};\n\t\t},\n\t\t[ area ]\n\t);\n\n\tconst onCreate = useCallback(\n\t\tasync (\n\t\t\tstartingBlocks = [],\n\t\t\ttitle = __( 'Untitled Template Part' )\n\t\t) => {\n\t\t\t// If we have `area` set from block attributes, means an exposed\n\t\t\t// block variation was inserted. So add this prop to the template\n\t\t\t// part entity on creation. Afterwards remove `area` value from\n\t\t\t// block attributes.\n\t\t\tconst record = {\n\t\t\t\ttitle,\n\t\t\t\tslug: kebabCase( title ),\n\t\t\t\tcontent: serialize( startingBlocks ),\n\t\t\t\t// `area` is filterable on the server and defaults to `UNCATEGORIZED`\n\t\t\t\t// if provided value is not allowed.\n\t\t\t\tarea,\n\t\t\t};\n\t\t\tconst templatePart = await saveEntityRecord(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\trecord\n\t\t\t);\n\t\t\tsetAttributes( {\n\t\t\t\tslug: templatePart.slug,\n\t\t\t\ttheme: templatePart.theme,\n\t\t\t\tarea: undefined,\n\t\t\t} );\n\t\t},\n\t\t[ setAttributes, area ]\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t{ step === PLACEHOLDER_STEPS.initial && (\n\t\t\t\t<Placeholder\n\t\t\t\t\ticon={ areaIcon }\n\t\t\t\t\tlabel={ areaLabel }\n\t\t\t\t\tinstructions={\n\t\t\t\t\t\tenableSelection\n\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t'Choose an existing %s or create a new one.'\n\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\tareaLabel.toLowerCase()\n\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t\t\t\t__( 'Create a new %s.' ),\n\t\t\t\t\t\t\t\t\tareaLabel.toLowerCase()\n\t\t\t\t\t\t\t )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t{ ! hasResolvedReplacements ? (\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tcontentClassName=\"wp-block-template-part__placeholder-preview-dropdown-content\"\n\t\t\t\t\t\t\tposition=\"bottom right left\"\n\t\t\t\t\t\t\trenderToggle={ ( { isOpen, onToggle } ) => (\n\t\t\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t\t\t{ enableSelection && (\n\t\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t\t{ __( 'Choose existing' ) }\n\t\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant={\n\t\t\t\t\t\t\t\t\t\t\tenableSelection\n\t\t\t\t\t\t\t\t\t\t\t\t? 'tertiary'\n\t\t\t\t\t\t\t\t\t\t\t\t: 'primary'\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\t\t\tsetStep(\n\t\t\t\t\t\t\t\t\t\t\t\tPLACEHOLDER_STEPS.patterns\n\t\t\t\t\t\t\t\t\t\t\t)\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{ sprintf(\n\t\t\t\t\t\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t\t\t\t\t\t__( 'New %s' ),\n\t\t\t\t\t\t\t\t\t\t\tareaLabel.toLowerCase()\n\t\t\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t</>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\trenderContent={ ( { onClose } ) => (\n\t\t\t\t\t\t\t\t<TemplatePartSelection\n\t\t\t\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\t\t\t\t\tarea={ area }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</Placeholder>\n\t\t\t) }\n\t\t\t{ step === PLACEHOLDER_STEPS.patterns && (\n\t\t\t\t<PatternsSetup\n\t\t\t\t\tarea={ area }\n\t\t\t\t\tareaLabel={ areaLabel }\n\t\t\t\t\tareaIcon={ areaIcon }\n\t\t\t\t\tonCreate={ onCreate }\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tresetPlaceholder={ () =>\n\t\t\t\t\t\tsetStep( PLACEHOLDER_STEPS.initial )\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = PatternsSetup;
|
|
7
|
-
|
|
8
|
-
var _element = require("@wordpress/element");
|
|
9
|
-
|
|
10
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
11
|
-
|
|
12
|
-
var _i18n = require("@wordpress/i18n");
|
|
13
|
-
|
|
14
|
-
var _components = require("@wordpress/components");
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
function PatternsSetup(_ref) {
|
|
20
|
-
let {
|
|
21
|
-
area,
|
|
22
|
-
areaLabel,
|
|
23
|
-
areaIcon,
|
|
24
|
-
clientId,
|
|
25
|
-
onCreate,
|
|
26
|
-
resetPlaceholder
|
|
27
|
-
} = _ref;
|
|
28
|
-
const blockNameWithArea = area ? `core/template-part/${area}` : 'core/template-part'; // Restructure onCreate to set the blocks on local state.
|
|
29
|
-
// Add modal to confirm title and trigger onCreate.
|
|
30
|
-
|
|
31
|
-
const [title, setTitle] = (0, _element.useState)((0, _i18n.__)('Untitled Template Part'));
|
|
32
|
-
const [startingBlocks, setStartingBlocks] = (0, _element.useState)([]);
|
|
33
|
-
const [isTitleStep, setIsTitleStep] = (0, _element.useState)(false);
|
|
34
|
-
|
|
35
|
-
const selectPattern = selectedPattern => {
|
|
36
|
-
setStartingBlocks(selectedPattern);
|
|
37
|
-
setIsTitleStep(true);
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const submitForCreation = event => {
|
|
41
|
-
event.preventDefault();
|
|
42
|
-
onCreate(startingBlocks, title);
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)(_blockEditor.__experimentalBlockPatternSetup, {
|
|
46
|
-
clientId: clientId,
|
|
47
|
-
startBlankComponent: (0, _element.createElement)(StartBlankComponent, {
|
|
48
|
-
setTitleStep: setIsTitleStep,
|
|
49
|
-
areaLabel: areaLabel,
|
|
50
|
-
areaIcon: areaIcon
|
|
51
|
-
}),
|
|
52
|
-
onBlockPatternSelect: selectPattern,
|
|
53
|
-
filterPatternsFn: pattern => {
|
|
54
|
-
var _pattern$blockTypes, _pattern$blockTypes$s;
|
|
55
|
-
|
|
56
|
-
return pattern === null || pattern === void 0 ? void 0 : (_pattern$blockTypes = pattern.blockTypes) === null || _pattern$blockTypes === void 0 ? void 0 : (_pattern$blockTypes$s = _pattern$blockTypes.some) === null || _pattern$blockTypes$s === void 0 ? void 0 : _pattern$blockTypes$s.call(_pattern$blockTypes, blockType => blockType === blockNameWithArea);
|
|
57
|
-
}
|
|
58
|
-
}), isTitleStep && (0, _element.createElement)(_components.Modal, {
|
|
59
|
-
title: (0, _i18n.sprintf)( // Translators: %s as template part area title ("Header", "Footer", etc.).
|
|
60
|
-
(0, _i18n.__)('Name and create your new %s'), areaLabel.toLowerCase()),
|
|
61
|
-
closeLabel: (0, _i18n.__)('Cancel'),
|
|
62
|
-
onRequestClose: resetPlaceholder,
|
|
63
|
-
overlayClassName: "wp-block-template-part__placeholder-create-new__title-form"
|
|
64
|
-
}, (0, _element.createElement)("form", {
|
|
65
|
-
onSubmit: submitForCreation
|
|
66
|
-
}, (0, _element.createElement)(_components.TextControl, {
|
|
67
|
-
label: (0, _i18n.__)('Name'),
|
|
68
|
-
value: title,
|
|
69
|
-
onChange: setTitle
|
|
70
|
-
}), (0, _element.createElement)(_components.Flex, {
|
|
71
|
-
className: "wp-block-template-part__placeholder-create-new__title-form-actions",
|
|
72
|
-
justify: "flex-end"
|
|
73
|
-
}, (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.Button, {
|
|
74
|
-
variant: "secondary",
|
|
75
|
-
onClick: resetPlaceholder
|
|
76
|
-
}, (0, _i18n.__)('Cancel'))), (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.Button, {
|
|
77
|
-
variant: "primary",
|
|
78
|
-
type: "submit",
|
|
79
|
-
disabled: !title.length,
|
|
80
|
-
"aria-disabled": !title.length
|
|
81
|
-
}, (0, _i18n.__)('Create')))))));
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
function StartBlankComponent(_ref2) {
|
|
85
|
-
let {
|
|
86
|
-
setTitleStep,
|
|
87
|
-
areaLabel,
|
|
88
|
-
areaIcon
|
|
89
|
-
} = _ref2;
|
|
90
|
-
(0, _element.useEffect)(() => {
|
|
91
|
-
setTitleStep(true);
|
|
92
|
-
}, []);
|
|
93
|
-
return (0, _element.createElement)(_components.Placeholder, {
|
|
94
|
-
label: areaLabel,
|
|
95
|
-
icon: areaIcon,
|
|
96
|
-
instructions: (0, _i18n.sprintf)( // Translators: %s as template part area title ("Header", "Footer", "Template Part", etc.).
|
|
97
|
-
(0, _i18n.__)('Creating your new %s…'), areaLabel.toLowerCase())
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
//# sourceMappingURL=patterns-setup.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/placeholder/patterns-setup.js"],"names":["PatternsSetup","area","areaLabel","areaIcon","clientId","onCreate","resetPlaceholder","blockNameWithArea","title","setTitle","startingBlocks","setStartingBlocks","isTitleStep","setIsTitleStep","selectPattern","selectedPattern","submitForCreation","event","preventDefault","pattern","blockTypes","some","blockType","toLowerCase","length","StartBlankComponent","setTitleStep"],"mappings":"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","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __experimentalBlockPatternSetup as BlockPatternSetup } from '@wordpress/block-editor';\nimport { useEffect, useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tTextControl,\n\tFlex,\n\tFlexItem,\n\tButton,\n\tModal,\n\tPlaceholder,\n} from '@wordpress/components';\n\nexport default function PatternsSetup( {\n\tarea,\n\tareaLabel,\n\tareaIcon,\n\tclientId,\n\tonCreate,\n\tresetPlaceholder,\n} ) {\n\tconst blockNameWithArea = area\n\t\t? `core/template-part/${ area }`\n\t\t: 'core/template-part';\n\n\t// Restructure onCreate to set the blocks on local state.\n\t// Add modal to confirm title and trigger onCreate.\n\tconst [ title, setTitle ] = useState( __( 'Untitled Template Part' ) );\n\tconst [ startingBlocks, setStartingBlocks ] = useState( [] );\n\tconst [ isTitleStep, setIsTitleStep ] = useState( false );\n\n\tconst selectPattern = ( selectedPattern ) => {\n\t\tsetStartingBlocks( selectedPattern );\n\t\tsetIsTitleStep( true );\n\t};\n\n\tconst submitForCreation = ( event ) => {\n\t\tevent.preventDefault();\n\t\tonCreate( startingBlocks, title );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<BlockPatternSetup\n\t\t\t\tclientId={ clientId }\n\t\t\t\tstartBlankComponent={\n\t\t\t\t\t<StartBlankComponent\n\t\t\t\t\t\tsetTitleStep={ setIsTitleStep }\n\t\t\t\t\t\tareaLabel={ areaLabel }\n\t\t\t\t\t\tareaIcon={ areaIcon }\n\t\t\t\t\t/>\n\t\t\t\t}\n\t\t\t\tonBlockPatternSelect={ selectPattern }\n\t\t\t\tfilterPatternsFn={ ( pattern ) =>\n\t\t\t\t\tpattern?.blockTypes?.some?.(\n\t\t\t\t\t\t( blockType ) => blockType === blockNameWithArea\n\t\t\t\t\t)\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ isTitleStep && (\n\t\t\t\t<Modal\n\t\t\t\t\ttitle={ sprintf(\n\t\t\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t\t\t__( 'Name and create your new %s' ),\n\t\t\t\t\t\tareaLabel.toLowerCase()\n\t\t\t\t\t) }\n\t\t\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\t\t\tonRequestClose={ resetPlaceholder }\n\t\t\t\t\toverlayClassName=\"wp-block-template-part__placeholder-create-new__title-form\"\n\t\t\t\t>\n\t\t\t\t\t<form onSubmit={ submitForCreation }>\n\t\t\t\t\t\t<TextControl\n\t\t\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\t\t\tvalue={ title }\n\t\t\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t\t\t/>\n\t\t\t\t\t\t<Flex\n\t\t\t\t\t\t\tclassName=\"wp-block-template-part__placeholder-create-new__title-form-actions\"\n\t\t\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\t\t\t\t\tonClick={ resetPlaceholder }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Cancel' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\t\t\tdisabled={ ! title.length }\n\t\t\t\t\t\t\t\t\taria-disabled={ ! title.length }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t</FlexItem>\n\t\t\t\t\t\t</Flex>\n\t\t\t\t\t</form>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nfunction StartBlankComponent( { setTitleStep, areaLabel, areaIcon } ) {\n\tuseEffect( () => {\n\t\tsetTitleStep( true );\n\t}, [] );\n\treturn (\n\t\t<Placeholder\n\t\t\tlabel={ areaLabel }\n\t\t\ticon={ areaIcon }\n\t\t\tinstructions={ sprintf(\n\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", \"Template Part\", etc.).\n\t\t\t\t__( 'Creating your new %s…' ),\n\t\t\t\tareaLabel.toLowerCase()\n\t\t\t) }\n\t\t/>\n\t);\n}\n"]}
|
|
@@ -1,45 +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 = TemplatePartSelection;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _components = require("@wordpress/components");
|
|
13
|
-
|
|
14
|
-
var _templatePartPreviews = _interopRequireDefault(require("./template-part-previews"));
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* WordPress dependencies
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* Internal dependencies
|
|
22
|
-
*/
|
|
23
|
-
function TemplatePartSelection(_ref) {
|
|
24
|
-
let {
|
|
25
|
-
setAttributes,
|
|
26
|
-
onClose,
|
|
27
|
-
area,
|
|
28
|
-
templatePartId = null
|
|
29
|
-
} = _ref;
|
|
30
|
-
const [filterValue, setFilterValue] = (0, _element.useState)('');
|
|
31
|
-
return (0, _element.createElement)("div", null, (0, _element.createElement)(_components.SearchControl, {
|
|
32
|
-
value: filterValue,
|
|
33
|
-
onChange: setFilterValue,
|
|
34
|
-
className: "wp-block-template-part__selection-preview-search-form"
|
|
35
|
-
}), (0, _element.createElement)("div", {
|
|
36
|
-
className: "wp-block-template-part__selection-preview-container"
|
|
37
|
-
}, (0, _element.createElement)(_templatePartPreviews.default, {
|
|
38
|
-
setAttributes: setAttributes,
|
|
39
|
-
filterValue: filterValue,
|
|
40
|
-
onClose: onClose,
|
|
41
|
-
area: area,
|
|
42
|
-
templatePartId: templatePartId
|
|
43
|
-
})));
|
|
44
|
-
}
|
|
45
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/selection/index.js"],"names":["TemplatePartSelection","setAttributes","onClose","area","templatePartId","filterValue","setFilterValue"],"mappings":";;;;;;;;;AAIA;;AADA;;AAMA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGe,SAASA,qBAAT,OAKX;AAAA,MAL2C;AAC9CC,IAAAA,aAD8C;AAE9CC,IAAAA,OAF8C;AAG9CC,IAAAA,IAH8C;AAI9CC,IAAAA,cAAc,GAAG;AAJ6B,GAK3C;AACH,QAAM,CAAEC,WAAF,EAAeC,cAAf,IAAkC,uBAAU,EAAV,CAAxC;AACA,SACC,yCACC,4BAAC,yBAAD;AACC,IAAA,KAAK,EAAGD,WADT;AAEC,IAAA,QAAQ,EAAGC,cAFZ;AAGC,IAAA,SAAS,EAAC;AAHX,IADD,EAMC;AAAK,IAAA,SAAS,EAAC;AAAf,KACC,4BAAC,6BAAD;AACC,IAAA,aAAa,EAAGL,aADjB;AAEC,IAAA,WAAW,EAAGI,WAFf;AAGC,IAAA,OAAO,EAAGH,OAHX;AAIC,IAAA,IAAI,EAAGC,IAJR;AAKC,IAAA,cAAc,EAAGC;AALlB,IADD,CAND,CADD;AAkBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { SearchControl } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartPreviews from './template-part-previews';\n\nexport default function TemplatePartSelection( {\n\tsetAttributes,\n\tonClose,\n\tarea,\n\ttemplatePartId = null,\n} ) {\n\tconst [ filterValue, setFilterValue ] = useState( '' );\n\treturn (\n\t\t<div>\n\t\t\t<SearchControl\n\t\t\t\tvalue={ filterValue }\n\t\t\t\tonChange={ setFilterValue }\n\t\t\t\tclassName=\"wp-block-template-part__selection-preview-search-form\"\n\t\t\t/>\n\t\t\t<div className=\"wp-block-template-part__selection-preview-container\">\n\t\t\t\t<TemplatePartPreviews\n\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\tfilterValue={ filterValue }\n\t\t\t\t\tonClose={ onClose }\n\t\t\t\t\tarea={ area }\n\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t</div>\n\t);\n}\n"]}
|
|
@@ -1,317 +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 = TemplatePartPreviews;
|
|
9
|
-
|
|
10
|
-
var _element = require("@wordpress/element");
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
|
-
var _lodash = require("lodash");
|
|
15
|
-
|
|
16
|
-
var _data = require("@wordpress/data");
|
|
17
|
-
|
|
18
|
-
var _blocks = require("@wordpress/blocks");
|
|
19
|
-
|
|
20
|
-
var _keycodes = require("@wordpress/keycodes");
|
|
21
|
-
|
|
22
|
-
var _i18n = require("@wordpress/i18n");
|
|
23
|
-
|
|
24
|
-
var _blockEditor = require("@wordpress/block-editor");
|
|
25
|
-
|
|
26
|
-
var _components = require("@wordpress/components");
|
|
27
|
-
|
|
28
|
-
var _compose = require("@wordpress/compose");
|
|
29
|
-
|
|
30
|
-
var _notices = require("@wordpress/notices");
|
|
31
|
-
|
|
32
|
-
var _coreData = require("@wordpress/core-data");
|
|
33
|
-
|
|
34
|
-
var _createTemplatePartId = require("../utils/create-template-part-id");
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* External dependencies
|
|
38
|
-
*/
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* WordPress dependencies
|
|
42
|
-
*/
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Internal dependencies
|
|
46
|
-
*/
|
|
47
|
-
function getAreaGroupTitle(areaLabel) {
|
|
48
|
-
return (0, _i18n.sprintf)( // Translators: %s for the area the template part is assigned to (Header, Footer, General, etc.)
|
|
49
|
-
(0, _i18n.__)('Area: %s'), areaLabel);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
function PreviewPlaceholder() {
|
|
53
|
-
return (0, _element.createElement)("div", {
|
|
54
|
-
className: "wp-block-template-part__selection-preview-item is-placeholder",
|
|
55
|
-
tabIndex: 0
|
|
56
|
-
});
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
function TemplatePartItem(_ref) {
|
|
60
|
-
let {
|
|
61
|
-
templatePart,
|
|
62
|
-
setAttributes,
|
|
63
|
-
onClose,
|
|
64
|
-
composite
|
|
65
|
-
} = _ref;
|
|
66
|
-
const {
|
|
67
|
-
slug,
|
|
68
|
-
theme,
|
|
69
|
-
title: {
|
|
70
|
-
rendered: title
|
|
71
|
-
}
|
|
72
|
-
} = templatePart; // The 'raw' property is not defined for a brief period in the save cycle.
|
|
73
|
-
// The fallback prevents an error in the parse function while saving.
|
|
74
|
-
|
|
75
|
-
const content = templatePart.content.raw || '';
|
|
76
|
-
const blocks = (0, _element.useMemo)(() => (0, _blocks.parse)(content), [content]);
|
|
77
|
-
const {
|
|
78
|
-
createSuccessNotice
|
|
79
|
-
} = (0, _data.useDispatch)(_notices.store);
|
|
80
|
-
const onClick = (0, _element.useCallback)(() => {
|
|
81
|
-
setAttributes({
|
|
82
|
-
slug,
|
|
83
|
-
theme,
|
|
84
|
-
area: undefined
|
|
85
|
-
});
|
|
86
|
-
createSuccessNotice((0, _i18n.sprintf)(
|
|
87
|
-
/* translators: %s: template part title. */
|
|
88
|
-
(0, _i18n.__)('Template Part "%s" inserted.'), title || slug), {
|
|
89
|
-
type: 'snackbar'
|
|
90
|
-
});
|
|
91
|
-
onClose();
|
|
92
|
-
}, [slug, theme]);
|
|
93
|
-
return (0, _element.createElement)(_components.__unstableCompositeItem, (0, _extends2.default)({
|
|
94
|
-
as: "div",
|
|
95
|
-
className: "wp-block-template-part__selection-preview-item",
|
|
96
|
-
role: "option",
|
|
97
|
-
onClick: onClick,
|
|
98
|
-
onKeyDown: event => {
|
|
99
|
-
if (_keycodes.ENTER === event.keyCode || _keycodes.SPACE === event.keyCode) {
|
|
100
|
-
onClick();
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
tabIndex: 0,
|
|
104
|
-
"aria-label": title || slug
|
|
105
|
-
}, composite), (0, _element.createElement)(_blockEditor.BlockPreview, {
|
|
106
|
-
blocks: blocks
|
|
107
|
-
}), (0, _element.createElement)("div", {
|
|
108
|
-
className: "wp-block-template-part__selection-preview-item-title"
|
|
109
|
-
}, title || slug));
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
function PanelGroup(_ref2) {
|
|
113
|
-
let {
|
|
114
|
-
title,
|
|
115
|
-
icon,
|
|
116
|
-
children
|
|
117
|
-
} = _ref2;
|
|
118
|
-
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("div", {
|
|
119
|
-
className: "wp-block-template-part__selection-panel-group-header"
|
|
120
|
-
}, (0, _element.createElement)("span", {
|
|
121
|
-
className: "wp-block-template-part__selection-panel-group-title"
|
|
122
|
-
}, title), (0, _element.createElement)(_components.Icon, {
|
|
123
|
-
icon: icon
|
|
124
|
-
})), (0, _element.createElement)("div", {
|
|
125
|
-
className: "wp-block-template-part__selection-panel-group-content"
|
|
126
|
-
}, children));
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function TemplatePartsByArea(_ref3) {
|
|
130
|
-
let {
|
|
131
|
-
templateParts,
|
|
132
|
-
setAttributes,
|
|
133
|
-
onClose,
|
|
134
|
-
composite,
|
|
135
|
-
area = 'uncategorized',
|
|
136
|
-
labelsByArea
|
|
137
|
-
} = _ref3;
|
|
138
|
-
const {
|
|
139
|
-
templatePartsByArea,
|
|
140
|
-
templatePartsToShow
|
|
141
|
-
} = (0, _element.useMemo)(() => {
|
|
142
|
-
const _templatePartsToShow = templateParts.filter(templatePart => 'uncategorized' === area || templatePart.area === area) || [];
|
|
143
|
-
|
|
144
|
-
const _templatePartsByArea = Object.values((0, _lodash.groupBy)(_templatePartsToShow, 'area'));
|
|
145
|
-
|
|
146
|
-
const orderedTemplatePartsToShow = (0, _lodash.flatten)(_templatePartsToShow);
|
|
147
|
-
return {
|
|
148
|
-
templatePartsByArea: _templatePartsByArea,
|
|
149
|
-
templatePartsToShow: orderedTemplatePartsToShow
|
|
150
|
-
};
|
|
151
|
-
}, [templateParts, area]);
|
|
152
|
-
const currentShownTPs = (0, _compose.useAsyncList)(templatePartsToShow);
|
|
153
|
-
|
|
154
|
-
if (!templatePartsToShow.length) {
|
|
155
|
-
return (0, _element.createElement)(PanelGroup, {
|
|
156
|
-
title: getAreaGroupTitle(labelsByArea[area] || labelsByArea.uncategorized)
|
|
157
|
-
}, (0, _i18n.sprintf)( // Translators: %s for the template part variation ("Header", "Footer", "Template Part").
|
|
158
|
-
(0, _i18n.__)('There is no other %s available. If you are looking for another type of template part, try searching for it using the input above.'), area && area !== 'uncategorized' ? labelsByArea[area] || area : (0, _i18n.__)('Template Part')));
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
return templatePartsByArea.map(templatePartList => {
|
|
162
|
-
return (0, _element.createElement)(PanelGroup, {
|
|
163
|
-
key: templatePartList[0].area,
|
|
164
|
-
title: getAreaGroupTitle(labelsByArea[templatePartList[0].area] || labelsByArea.uncategorized)
|
|
165
|
-
}, templatePartList.map(templatePart => {
|
|
166
|
-
return currentShownTPs.includes(templatePart) ? (0, _element.createElement)(TemplatePartItem, {
|
|
167
|
-
key: templatePart.id,
|
|
168
|
-
templatePart: templatePart,
|
|
169
|
-
setAttributes: setAttributes,
|
|
170
|
-
onClose: onClose,
|
|
171
|
-
composite: composite
|
|
172
|
-
}) : (0, _element.createElement)(PreviewPlaceholder, {
|
|
173
|
-
key: templatePart.id
|
|
174
|
-
});
|
|
175
|
-
}));
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
function TemplatePartSearchResults(_ref4) {
|
|
180
|
-
let {
|
|
181
|
-
templateParts,
|
|
182
|
-
setAttributes,
|
|
183
|
-
filterValue,
|
|
184
|
-
onClose,
|
|
185
|
-
composite,
|
|
186
|
-
labelsByArea
|
|
187
|
-
} = _ref4;
|
|
188
|
-
const {
|
|
189
|
-
filteredTPs,
|
|
190
|
-
groupedResults
|
|
191
|
-
} = (0, _element.useMemo)(() => {
|
|
192
|
-
// Filter based on value.
|
|
193
|
-
// Remove diacritics and convert to lowercase to normalize.
|
|
194
|
-
const normalizedFilterValue = (0, _lodash.deburr)(filterValue).toLowerCase();
|
|
195
|
-
const searchResults = templateParts.filter(_ref5 => {
|
|
196
|
-
let {
|
|
197
|
-
title: {
|
|
198
|
-
rendered: title
|
|
199
|
-
},
|
|
200
|
-
area
|
|
201
|
-
} = _ref5;
|
|
202
|
-
return (0, _lodash.deburr)(title).toLowerCase().includes(normalizedFilterValue) || // Since diacritics can be used in theme names, remove them for the comparison.
|
|
203
|
-
(0, _lodash.deburr)(labelsByArea[area]).toLowerCase().includes(normalizedFilterValue);
|
|
204
|
-
}); // Order based on value location.
|
|
205
|
-
|
|
206
|
-
searchResults.sort((a, b) => {
|
|
207
|
-
// First prioritize index found in title.
|
|
208
|
-
// Deburr for diacritics.
|
|
209
|
-
const indexInTitleA = (0, _lodash.deburr)(a.title.rendered).toLowerCase().indexOf(normalizedFilterValue);
|
|
210
|
-
const indexInTitleB = (0, _lodash.deburr)(b.title.rendered).toLowerCase().indexOf(normalizedFilterValue);
|
|
211
|
-
|
|
212
|
-
if (indexInTitleA !== -1 && indexInTitleB !== -1) {
|
|
213
|
-
return indexInTitleA - indexInTitleB;
|
|
214
|
-
} else if (indexInTitleA !== -1) {
|
|
215
|
-
return -1;
|
|
216
|
-
} else if (indexInTitleB !== -1) {
|
|
217
|
-
return 1;
|
|
218
|
-
} // Second prioritize index found in area.
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
return (0, _lodash.deburr)(labelsByArea[a.area]).toLowerCase().indexOf(normalizedFilterValue) - (0, _lodash.deburr)(labelsByArea[b.area]).toLowerCase().indexOf(normalizedFilterValue);
|
|
222
|
-
}); // Group filtered results together if their neighbors share the same area.
|
|
223
|
-
// This helps not show redundant panel groups side by side in the results.
|
|
224
|
-
|
|
225
|
-
const _groupedResults = [];
|
|
226
|
-
|
|
227
|
-
for (let i = 0; i < searchResults.length; i++) {
|
|
228
|
-
if (i !== 0 && searchResults[i].area === searchResults[i - 1].area) {
|
|
229
|
-
_groupedResults[_groupedResults.length - 1].push(searchResults[i]);
|
|
230
|
-
} else {
|
|
231
|
-
_groupedResults.push([searchResults[i]]);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
return {
|
|
236
|
-
filteredTPs: searchResults,
|
|
237
|
-
groupedResults: _groupedResults
|
|
238
|
-
};
|
|
239
|
-
}, [filterValue, templateParts]);
|
|
240
|
-
const currentShownTPs = (0, _compose.useAsyncList)(filteredTPs);
|
|
241
|
-
return groupedResults.map(group => (0, _element.createElement)(PanelGroup, {
|
|
242
|
-
key: group[0].id,
|
|
243
|
-
title: getAreaGroupTitle(labelsByArea[group[0].area] || labelsByArea.uncategorized)
|
|
244
|
-
}, group.map(templatePart => currentShownTPs.includes(templatePart) ? (0, _element.createElement)(TemplatePartItem, {
|
|
245
|
-
key: templatePart.id,
|
|
246
|
-
templatePart: templatePart,
|
|
247
|
-
setAttributes: setAttributes,
|
|
248
|
-
onClose: onClose,
|
|
249
|
-
composite: composite
|
|
250
|
-
}) : (0, _element.createElement)(PreviewPlaceholder, {
|
|
251
|
-
key: templatePart.id
|
|
252
|
-
}))));
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
function TemplatePartPreviews(_ref6) {
|
|
256
|
-
let {
|
|
257
|
-
setAttributes,
|
|
258
|
-
filterValue,
|
|
259
|
-
onClose,
|
|
260
|
-
area,
|
|
261
|
-
templatePartId
|
|
262
|
-
} = _ref6;
|
|
263
|
-
const composite = (0, _components.__unstableUseCompositeState)();
|
|
264
|
-
const {
|
|
265
|
-
templateParts,
|
|
266
|
-
labelsByArea
|
|
267
|
-
} = (0, _data.useSelect)(select => {
|
|
268
|
-
const _templateParts = (select(_coreData.store).getEntityRecords('postType', 'wp_template_part', {
|
|
269
|
-
per_page: -1
|
|
270
|
-
}) || []).filter(templatePart => (0, _createTemplatePartId.createTemplatePartId)(templatePart.theme, templatePart.slug) !== templatePartId); // FIXME: @wordpress/block-library should not depend on @wordpress/editor.
|
|
271
|
-
// Blocks can be loaded into a *non-post* block editor.
|
|
272
|
-
// eslint-disable-next-line @wordpress/data-no-store-string-literals
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
const definedAreas = select('core/editor').__experimentalGetDefaultTemplatePartAreas();
|
|
276
|
-
|
|
277
|
-
const _labelsByArea = {};
|
|
278
|
-
definedAreas.forEach(item => {
|
|
279
|
-
_labelsByArea[item.area] = item.label;
|
|
280
|
-
});
|
|
281
|
-
return {
|
|
282
|
-
templateParts: _templateParts,
|
|
283
|
-
labelsByArea: _labelsByArea
|
|
284
|
-
};
|
|
285
|
-
}, []);
|
|
286
|
-
|
|
287
|
-
if (!templateParts || !templateParts.length) {
|
|
288
|
-
return (0, _element.createElement)(PanelGroup, null, (0, _i18n.__)('There are no existing template parts to select.'));
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
if (filterValue) {
|
|
292
|
-
return (0, _element.createElement)(_components.__unstableComposite, (0, _extends2.default)({}, composite, {
|
|
293
|
-
role: "listbox",
|
|
294
|
-
"aria-label": (0, _i18n.__)('List of template parts')
|
|
295
|
-
}), (0, _element.createElement)(TemplatePartSearchResults, {
|
|
296
|
-
templateParts: templateParts,
|
|
297
|
-
setAttributes: setAttributes,
|
|
298
|
-
filterValue: filterValue,
|
|
299
|
-
onClose: onClose,
|
|
300
|
-
composite: composite,
|
|
301
|
-
labelsByArea: labelsByArea
|
|
302
|
-
}));
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return (0, _element.createElement)(_components.__unstableComposite, (0, _extends2.default)({}, composite, {
|
|
306
|
-
role: "listbox",
|
|
307
|
-
"aria-label": (0, _i18n.__)('List of template parts')
|
|
308
|
-
}), (0, _element.createElement)(TemplatePartsByArea, {
|
|
309
|
-
templateParts: templateParts,
|
|
310
|
-
setAttributes: setAttributes,
|
|
311
|
-
onClose: onClose,
|
|
312
|
-
composite: composite,
|
|
313
|
-
area: area,
|
|
314
|
-
labelsByArea: labelsByArea
|
|
315
|
-
}));
|
|
316
|
-
}
|
|
317
|
-
//# sourceMappingURL=template-part-previews.js.map
|