@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 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/index.js"],"names":["TemplatePartEdit","attributes","setAttributes","clientId","slug","theme","tagName","layout","templatePartId","hasAlreadyRendered","RecursionProvider","isResolved","innerBlocks","isMissing","defaultWrapper","area","enableSelection","hasResolvedReplacements","select","getEditedEntityRecord","getEntityRecords","hasFinishedResolution","coreStore","getBlocks","blockEditorStore","getEntityArgs","entityRecord","_area","availableReplacementArgs","matchingReplacements","_enableSelection","length","hasResolvedEntity","defaultWrapperElement","__experimentalGetDefaultTemplatePartAreas","find","value","area_tag","blockProps","isPlaceholder","isEntityAvailable","TagName","isOpen","onToggle","onClose"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AAOA;;AAMA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAhCA;AACA;AACA;;AAGA;AAC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C,yBAAgBD,MADjB;AAEC,QAAA,OAAO,EAAGC;AAFX,SAIG,cAAI,SAAJ,CAJH,CADc;AAAA,KAJhB;AAYC,IAAA,aAAa,EAAG;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aACf,4BAAC,kBAAD;AACC,QAAA,aAAa,EAAG1C,aADjB;AAEC,QAAA,OAAO,EAAG0C,OAFX;AAGC,QAAA,IAAI,EAAG7B,IAHR;AAIC,QAAA,cAAc,EAAGP;AAJlB,QADe;AAAA;AAZjB,IADD,CADD,CApBF,EA8CGgC,iBAAiB,IAClB,4BAAC,oBAAD;AACC,IAAA,QAAQ,EAAGrC,QADZ;AAEC,IAAA,OAAO,EAAGsC,OAFX;AAGC,IAAA,UAAU,EAAGH,UAHd;AAIC,IAAA,MAAM,EAAG9B,cAJV;AAKC,IAAA,cAAc,EAAGI,WAAW,CAACmB,MAAZ,GAAqB,CALvC;AAMC,IAAA,MAAM,EAAGxB;AANV,IA/CF,EAwDG,CAAEgC,aAAF,IAAmB,CAAE5B,UAArB,IACD,4BAAC,OAAD,EAAc2B,UAAd,EACC,4BAAC,mBAAD,OADD,CAzDF,CADD;AAgEA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tuseBlockProps,\n\t__experimentalUseNoRecursiveRenders as useNoRecursiveRenders,\n\tWarning,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tDropdown,\n\tToolbarGroup,\n\tToolbarButton,\n\tSpinner,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartPlaceholder from './placeholder';\nimport TemplatePartSelection from './selection';\nimport { TemplatePartAdvancedControls } from './advanced-controls';\nimport TemplatePartInnerBlocks from './inner-blocks';\nimport { createTemplatePartId } from './utils/create-template-part-id';\n\nexport default function TemplatePartEdit( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst { slug, theme, tagName, layout = {} } = attributes;\n\tconst templatePartId = createTemplatePartId( theme, slug );\n\n\tconst [ hasAlreadyRendered, RecursionProvider ] = useNoRecursiveRenders(\n\t\ttemplatePartId\n\t);\n\n\t// Set the postId block attribute if it did not exist,\n\t// but wait until the inner blocks have loaded to allow\n\t// new edits to trigger this.\n\tconst {\n\t\tisResolved,\n\t\tinnerBlocks,\n\t\tisMissing,\n\t\tdefaultWrapper,\n\t\tarea,\n\t\tenableSelection,\n\t\thasResolvedReplacements,\n\t} = useSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetEditedEntityRecord,\n\t\t\t\tgetEntityRecords,\n\t\t\t\thasFinishedResolution,\n\t\t\t} = select( coreStore );\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\tconst getEntityArgs = [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\ttemplatePartId,\n\t\t\t];\n\t\t\tconst entityRecord = templatePartId\n\t\t\t\t? getEditedEntityRecord( ...getEntityArgs )\n\t\t\t\t: null;\n\t\t\tconst _area = entityRecord?.area || attributes.area;\n\n\t\t\t// Check whether other entities exist for switching/selection.\n\t\t\tconst availableReplacementArgs = [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\t_area && 'uncategorized' !== _area && { area: _area },\n\t\t\t];\n\t\t\tconst matchingReplacements = getEntityRecords(\n\t\t\t\t...availableReplacementArgs\n\t\t\t);\n\t\t\tconst _enableSelection = templatePartId\n\t\t\t\t? matchingReplacements?.length > 1\n\t\t\t\t: matchingReplacements?.length > 0;\n\n\t\t\tconst hasResolvedEntity = templatePartId\n\t\t\t\t? hasFinishedResolution(\n\t\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\t\tgetEntityArgs\n\t\t\t\t )\n\t\t\t\t: false;\n\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 defaultWrapperElement = select( 'core/editor' )\n\t\t\t\t.__experimentalGetDefaultTemplatePartAreas()\n\t\t\t\t.find( ( { area: value } ) => value === _area )?.area_tag;\n\n\t\t\treturn {\n\t\t\t\tinnerBlocks: getBlocks( clientId ),\n\t\t\t\tisResolved: hasResolvedEntity,\n\t\t\t\tisMissing: hasResolvedEntity && isEmpty( entityRecord ),\n\t\t\t\tdefaultWrapper: defaultWrapperElement || 'div',\n\t\t\t\tarea: _area,\n\t\t\t\tenableSelection: _enableSelection,\n\t\t\t\thasResolvedReplacements: hasFinishedResolution(\n\t\t\t\t\t'getEntityRecords',\n\t\t\t\t\tavailableReplacementArgs\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t[ templatePartId, clientId ]\n\t);\n\n\tconst blockProps = useBlockProps();\n\tconst isPlaceholder = ! slug;\n\tconst isEntityAvailable = ! isPlaceholder && ! isMissing && isResolved;\n\tconst TagName = tagName || defaultWrapper;\n\n\t// We don't want to render a missing state if we have any inner blocks.\n\t// A new template part is automatically created if we have any inner blocks but no entity.\n\tif (\n\t\tinnerBlocks.length === 0 &&\n\t\t( ( slug && ! theme ) || ( slug && isMissing ) )\n\t) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: Template part slug */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Template part has been deleted or is unavailable: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tslug\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\tif ( isEntityAvailable && hasAlreadyRendered ) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RecursionProvider>\n\t\t\t<TemplatePartAdvancedControls\n\t\t\t\ttagName={ tagName }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tisEntityAvailable={ isEntityAvailable }\n\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\tdefaultWrapper={ defaultWrapper }\n\t\t\t/>\n\t\t\t{ isPlaceholder && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<TemplatePartPlaceholder\n\t\t\t\t\t\tarea={ attributes.area }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tenableSelection={ enableSelection }\n\t\t\t\t\t\thasResolvedReplacements={ hasResolvedReplacements }\n\t\t\t\t\t/>\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t\t{ isEntityAvailable && enableSelection && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup className=\"wp-block-template-part__block-control-group\">\n\t\t\t\t\t\t<Dropdown\n\t\t\t\t\t\t\tclassName=\"wp-block-template-part__preview-dropdown-button\"\n\t\t\t\t\t\t\tcontentClassName=\"wp-block-template-part__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<ToolbarButton\n\t\t\t\t\t\t\t\t\taria-expanded={ isOpen }\n\t\t\t\t\t\t\t\t\tonClick={ onToggle }\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Replace' ) }\n\t\t\t\t\t\t\t\t</ToolbarButton>\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\ttemplatePartId={ templatePartId }\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</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isEntityAvailable && (\n\t\t\t\t<TemplatePartInnerBlocks\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\ttagName={ TagName }\n\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\tpostId={ templatePartId }\n\t\t\t\t\thasInnerBlocks={ innerBlocks.length > 0 }\n\t\t\t\t\tlayout={ layout }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! isPlaceholder && ! isResolved && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/index.js"],"names":["TemplatePartEdit","attributes","setAttributes","clientId","slug","theme","tagName","layout","templatePartId","hasAlreadyRendered","RecursionProvider","isTemplatePartSelectionOpen","setIsTemplatePartSelectionOpen","isResolved","innerBlocks","isMissing","area","select","getEditedEntityRecord","hasFinishedResolution","coreStore","getBlocks","blockEditorStore","getEntityArgs","entityRecord","_area","hasResolvedEntity","templateParts","blockPatterns","hasReplacements","length","areaObject","blockProps","isPlaceholder","isEntityAvailable","TagName","label","toLowerCase"],"mappings":";;;;;;;;;AAwBA;;AArBA;;AAKA;;AACA;;AAOA;;AAMA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAlCA;AACA;AACA;;AAGA;AACA;AACA;;AAmBA;AACA;AACA;AAYe,SAASA,gBAAT,OAIX;AAAA,MAJsC;AACzCC,IAAAA,UADyC;AAEzCC,IAAAA,aAFyC;AAGzCC,IAA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AIC,IAAA,aAAa,EAAGd,aAJjB;AAKC,IAAA,OAAO,EAAG,MACTU,8BAA8B,CAAE,KAAF;AANhC,IAZD,CAlDF,CADD;AA4EA","sourcesContent":["/**\n * External dependencies\n */\nimport { isEmpty } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport {\n\tBlockControls,\n\tuseBlockProps,\n\t__experimentalUseNoRecursiveRenders as useNoRecursiveRenders,\n\tWarning,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport {\n\tToolbarGroup,\n\tToolbarButton,\n\tSpinner,\n\tModal,\n} from '@wordpress/components';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport TemplatePartPlaceholder from './placeholder';\nimport TemplatePartSelectionModal from './selection-modal';\nimport { TemplatePartAdvancedControls } from './advanced-controls';\nimport TemplatePartInnerBlocks from './inner-blocks';\nimport { createTemplatePartId } from './utils/create-template-part-id';\nimport {\n\tuseAlternativeBlockPatterns,\n\tuseAlternativeTemplateParts,\n\tuseTemplatePartArea,\n} from './utils/hooks';\n\nexport default function TemplatePartEdit( {\n\tattributes,\n\tsetAttributes,\n\tclientId,\n} ) {\n\tconst { slug, theme, tagName, layout = {} } = attributes;\n\tconst templatePartId = createTemplatePartId( theme, slug );\n\tconst [ hasAlreadyRendered, RecursionProvider ] = useNoRecursiveRenders(\n\t\ttemplatePartId\n\t);\n\tconst [\n\t\tisTemplatePartSelectionOpen,\n\t\tsetIsTemplatePartSelectionOpen,\n\t] = useState( false );\n\n\t// Set the postId block attribute if it did not exist,\n\t// but wait until the inner blocks have loaded to allow\n\t// new edits to trigger this.\n\tconst { isResolved, innerBlocks, isMissing, area } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getEditedEntityRecord, hasFinishedResolution } = select(\n\t\t\t\tcoreStore\n\t\t\t);\n\t\t\tconst { getBlocks } = select( blockEditorStore );\n\n\t\t\tconst getEntityArgs = [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\ttemplatePartId,\n\t\t\t];\n\t\t\tconst entityRecord = templatePartId\n\t\t\t\t? getEditedEntityRecord( ...getEntityArgs )\n\t\t\t\t: null;\n\t\t\tconst _area = entityRecord?.area || attributes.area;\n\t\t\tconst hasResolvedEntity = templatePartId\n\t\t\t\t? hasFinishedResolution(\n\t\t\t\t\t\t'getEditedEntityRecord',\n\t\t\t\t\t\tgetEntityArgs\n\t\t\t\t )\n\t\t\t\t: false;\n\n\t\t\treturn {\n\t\t\t\tinnerBlocks: getBlocks( clientId ),\n\t\t\t\tisResolved: hasResolvedEntity,\n\t\t\t\tisMissing: hasResolvedEntity && isEmpty( entityRecord ),\n\t\t\t\tarea: _area,\n\t\t\t};\n\t\t},\n\t\t[ templatePartId, clientId ]\n\t);\n\tconst { templateParts } = useAlternativeTemplateParts(\n\t\tarea,\n\t\ttemplatePartId\n\t);\n\tconst blockPatterns = useAlternativeBlockPatterns( area, clientId );\n\tconst hasReplacements = !! templateParts.length || !! blockPatterns.length;\n\tconst areaObject = useTemplatePartArea( area );\n\tconst blockProps = useBlockProps();\n\tconst isPlaceholder = ! slug;\n\tconst isEntityAvailable = ! isPlaceholder && ! isMissing && isResolved;\n\tconst TagName = tagName || areaObject.tagName;\n\n\t// We don't want to render a missing state if we have any inner blocks.\n\t// A new template part is automatically created if we have any inner blocks but no entity.\n\tif (\n\t\tinnerBlocks.length === 0 &&\n\t\t( ( slug && ! theme ) || ( slug && isMissing ) )\n\t) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t/* translators: %s: Template part slug */\n\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t'Template part has been deleted or is unavailable: %s'\n\t\t\t\t\t\t),\n\t\t\t\t\t\tslug\n\t\t\t\t\t) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\tif ( isEntityAvailable && hasAlreadyRendered ) {\n\t\treturn (\n\t\t\t<TagName { ...blockProps }>\n\t\t\t\t<Warning>\n\t\t\t\t\t{ __( 'Block cannot be rendered inside itself.' ) }\n\t\t\t\t</Warning>\n\t\t\t</TagName>\n\t\t);\n\t}\n\n\treturn (\n\t\t<RecursionProvider>\n\t\t\t<TemplatePartAdvancedControls\n\t\t\t\ttagName={ tagName }\n\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\tisEntityAvailable={ isEntityAvailable }\n\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\tdefaultWrapper={ areaObject.tagName }\n\t\t\t/>\n\t\t\t{ isPlaceholder && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<TemplatePartPlaceholder\n\t\t\t\t\t\tarea={ attributes.area }\n\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tonOpenSelectionModal={ () =>\n\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t\t{ isEntityAvailable && hasReplacements && (\n\t\t\t\t<BlockControls>\n\t\t\t\t\t<ToolbarGroup className=\"wp-block-template-part__block-control-group\">\n\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Replace' ) }\n\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t</BlockControls>\n\t\t\t) }\n\t\t\t{ isEntityAvailable && (\n\t\t\t\t<TemplatePartInnerBlocks\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\ttagName={ TagName }\n\t\t\t\t\tblockProps={ blockProps }\n\t\t\t\t\tpostId={ templatePartId }\n\t\t\t\t\thasInnerBlocks={ innerBlocks.length > 0 }\n\t\t\t\t\tlayout={ layout }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ ! isPlaceholder && ! isResolved && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<Spinner />\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t\t{ isTemplatePartSelectionOpen && (\n\t\t\t\t<Modal\n\t\t\t\t\tclassName=\"block-editor-template-part__selection-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__( 'Choose a %s' ),\n\t\t\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t\t\t) }\n\t\t\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\t\t\tonRequestClose={ () =>\n\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t}\n\t\t\t\t>\n\t\t\t\t\t<TemplatePartSelectionModal\n\t\t\t\t\t\ttemplatePartId={ templatePartId }\n\t\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\t\tarea={ area }\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tonClose={ () =>\n\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( false )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t</Modal>\n\t\t\t) }\n\t\t</RecursionProvider>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
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 _i18n = require("@wordpress/i18n");
|
|
13
|
+
|
|
14
|
+
var _components = require("@wordpress/components");
|
|
15
|
+
|
|
16
|
+
var _hooks = require("./utils/hooks");
|
|
17
|
+
|
|
18
|
+
var _titleModal = _interopRequireDefault(require("./title-modal"));
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* WordPress dependencies
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Internal dependencies
|
|
26
|
+
*/
|
|
27
|
+
function TemplatePartPlaceholder(_ref) {
|
|
28
|
+
let {
|
|
29
|
+
area,
|
|
30
|
+
clientId,
|
|
31
|
+
templatePartId,
|
|
32
|
+
onOpenSelectionModal,
|
|
33
|
+
setAttributes
|
|
34
|
+
} = _ref;
|
|
35
|
+
const {
|
|
36
|
+
templateParts,
|
|
37
|
+
isResolving
|
|
38
|
+
} = (0, _hooks.useAlternativeTemplateParts)(area, templatePartId);
|
|
39
|
+
const blockPatterns = (0, _hooks.useAlternativeBlockPatterns)(area, clientId);
|
|
40
|
+
const [showTitleModal, setShowTitleModal] = (0, _element.useState)(false);
|
|
41
|
+
const areaObject = (0, _hooks.useTemplatePartArea)(area);
|
|
42
|
+
const createFromBlocks = (0, _hooks.useCreateTemplatePartFromBlocks)(area, setAttributes);
|
|
43
|
+
return (0, _element.createElement)(_components.Placeholder, {
|
|
44
|
+
icon: areaObject.icon,
|
|
45
|
+
label: areaObject.label,
|
|
46
|
+
instructions: (0, _i18n.sprintf)( // Translators: %s as template part area title ("Header", "Footer", etc.).
|
|
47
|
+
(0, _i18n.__)('Choose an existing %s or create a new one.'), areaObject.label.toLowerCase())
|
|
48
|
+
}, isResolving && (0, _element.createElement)(_components.Spinner, null), !isResolving && !!(templateParts.length || blockPatterns.length) && (0, _element.createElement)(_components.Button, {
|
|
49
|
+
variant: "primary",
|
|
50
|
+
onClick: onOpenSelectionModal
|
|
51
|
+
}, (0, _i18n.__)('Choose')), !isResolving && (0, _element.createElement)(_components.Button, {
|
|
52
|
+
variant: "secondary",
|
|
53
|
+
onClick: () => {
|
|
54
|
+
setShowTitleModal(true);
|
|
55
|
+
}
|
|
56
|
+
}, (0, _i18n.__)('Start blank')), showTitleModal && (0, _element.createElement)(_titleModal.default, {
|
|
57
|
+
areaLabel: areaObject.label,
|
|
58
|
+
onClose: () => setShowTitleModal(false),
|
|
59
|
+
onSubmit: title => {
|
|
60
|
+
createFromBlocks([], title);
|
|
61
|
+
}
|
|
62
|
+
}));
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=placeholder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/placeholder.js"],"names":["TemplatePartPlaceholder","area","clientId","templatePartId","onOpenSelectionModal","setAttributes","templateParts","isResolving","blockPatterns","showTitleModal","setShowTitleModal","areaObject","createFromBlocks","icon","label","toLowerCase","length","title"],"mappings":";;;;;;;;;AAKA;;AAFA;;AACA;;AAMA;;AAMA;;AAhBA;AACA;AACA;;AAKA;AACA;AACA;AASe,SAASA,uBAAT,OAMX;AAAA,MAN6C;AAChDC,IAAAA,IADgD;AAEhDC,IAAAA,QAFgD;AAGhDC,IAAAA,cAHgD;AAIhDC,IAAAA,oBAJgD;AAKhDC,IAAAA;AALgD,GAM7C;AACH,QAAM;AAAEC,IAAAA,aAAF;AAAiBC,IAAAA;AAAjB,MAAiC,wCACtCN,IADsC,EAEtCE,cAFsC,CAAvC;AAIA,QAAMK,aAAa,GAAG,wCAA6BP,IAA7B,EAAmCC,QAAnC,CAAtB;AACA,QAAM,CAAEO,cAAF,EAAkBC,iBAAlB,IAAwC,uBAAU,KAAV,CAA9C;AACA,QAAMC,UAAU,GAAG,gCAAqBV,IAArB,CAAnB;AACA,QAAMW,gBAAgB,GAAG,4CACxBX,IADwB,EAExBI,aAFwB,CAAzB;AAKA,SACC,4BAAC,uBAAD;AACC,IAAA,IAAI,EAAGM,UAAU,CAACE,IADnB;AAEC,IAAA,KAAK,EAAGF,UAAU,CAACG,KAFpB;AAGC,IAAA,YAAY,EAAG,oBACd;AACA,kBAAI,4CAAJ,CAFc,EAGdH,UAAU,CAACG,KAAX,CAAiBC,WAAjB,EAHc;AAHhB,KASGR,WAAW,IAAI,4BAAC,mBAAD,OATlB,EAWG,CAAEA,WAAF,IACD,CAAC,EAAID,aAAa,CAACU,MAAd,IAAwBR,aAAa,CAACQ,MAA1C,CADA,IAEA,4BAAC,kBAAD;AAAQ,IAAA,OAAO,EAAC,SAAhB;AAA0B,IAAA,OAAO,EAAGZ;AAApC,KACG,cAAI,QAAJ,CADH,CAbH,EAkBG,CAAEG,WAAF,IACD,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,WADT;AAEC,IAAA,OAAO,EAAG,MAAM;AACfG,MAAAA,iBAAiB,CAAE,IAAF,CAAjB;AACA;AAJF,KAMG,cAAI,aAAJ,CANH,CAnBF,EA4BGD,cAAc,IACf,4BAAC,mBAAD;AACC,IAAA,SAAS,EAAGE,UAAU,CAACG,KADxB;AAEC,IAAA,OAAO,EAAG,MAAMJ,iBAAiB,CAAE,KAAF,CAFlC;AAGC,IAAA,QAAQ,EAAKO,KAAF,IAAa;AACvBL,MAAAA,gBAAgB,CAAE,EAAF,EAAMK,KAAN,CAAhB;AACA;AALF,IA7BF,CADD;AAwCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Placeholder, Button, Spinner } from '@wordpress/components';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseAlternativeBlockPatterns,\n\tuseAlternativeTemplateParts,\n\tuseCreateTemplatePartFromBlocks,\n\tuseTemplatePartArea,\n} from './utils/hooks';\nimport TitleModal from './title-modal';\n\nexport default function TemplatePartPlaceholder( {\n\tarea,\n\tclientId,\n\ttemplatePartId,\n\tonOpenSelectionModal,\n\tsetAttributes,\n} ) {\n\tconst { templateParts, isResolving } = useAlternativeTemplateParts(\n\t\tarea,\n\t\ttemplatePartId\n\t);\n\tconst blockPatterns = useAlternativeBlockPatterns( area, clientId );\n\tconst [ showTitleModal, setShowTitleModal ] = useState( false );\n\tconst areaObject = useTemplatePartArea( area );\n\tconst createFromBlocks = useCreateTemplatePartFromBlocks(\n\t\tarea,\n\t\tsetAttributes\n\t);\n\n\treturn (\n\t\t<Placeholder\n\t\t\ticon={ areaObject.icon }\n\t\t\tlabel={ areaObject.label }\n\t\t\tinstructions={ sprintf(\n\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t__( 'Choose an existing %s or create a new one.' ),\n\t\t\t\tareaObject.label.toLowerCase()\n\t\t\t) }\n\t\t>\n\t\t\t{ isResolving && <Spinner /> }\n\n\t\t\t{ ! isResolving &&\n\t\t\t\t!! ( templateParts.length || blockPatterns.length ) && (\n\t\t\t\t\t<Button variant=\"primary\" onClick={ onOpenSelectionModal }>\n\t\t\t\t\t\t{ __( 'Choose' ) }\n\t\t\t\t\t</Button>\n\t\t\t\t) }\n\n\t\t\t{ ! isResolving && (\n\t\t\t\t<Button\n\t\t\t\t\tvariant=\"secondary\"\n\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\tsetShowTitleModal( true );\n\t\t\t\t\t} }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Start blank' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ showTitleModal && (\n\t\t\t\t<TitleModal\n\t\t\t\t\tareaLabel={ areaObject.label }\n\t\t\t\t\tonClose={ () => setShowTitleModal( false ) }\n\t\t\t\t\tonSubmit={ ( title ) => {\n\t\t\t\t\t\tcreateFromBlocks( [], title );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Placeholder>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = TemplatePartSelectionModal;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _i18n = require("@wordpress/i18n");
|
|
11
|
+
|
|
12
|
+
var _notices = require("@wordpress/notices");
|
|
13
|
+
|
|
14
|
+
var _data = require("@wordpress/data");
|
|
15
|
+
|
|
16
|
+
var _blocks = require("@wordpress/blocks");
|
|
17
|
+
|
|
18
|
+
var _compose = require("@wordpress/compose");
|
|
19
|
+
|
|
20
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
21
|
+
|
|
22
|
+
var _hooks = require("./utils/hooks");
|
|
23
|
+
|
|
24
|
+
var _createTemplatePartId = require("./utils/create-template-part-id");
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* WordPress dependencies
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Internal dependencies
|
|
32
|
+
*/
|
|
33
|
+
function TemplatePartSelectionModal(_ref) {
|
|
34
|
+
let {
|
|
35
|
+
setAttributes,
|
|
36
|
+
onClose,
|
|
37
|
+
templatePartId = null,
|
|
38
|
+
area,
|
|
39
|
+
clientId
|
|
40
|
+
} = _ref;
|
|
41
|
+
// When the templatePartId is undefined,
|
|
42
|
+
// it means the user is creating a new one from the placeholder.
|
|
43
|
+
const isReplacingTemplatePartContent = !!templatePartId;
|
|
44
|
+
const {
|
|
45
|
+
templateParts
|
|
46
|
+
} = (0, _hooks.useAlternativeTemplateParts)(area, templatePartId); // We can map template parts to block patters to reuse the BlockPatternsList UI
|
|
47
|
+
|
|
48
|
+
const templartPartsAsBlockPatterns = (0, _element.useMemo)(() => {
|
|
49
|
+
return templateParts.map(templatePart => ({
|
|
50
|
+
name: (0, _createTemplatePartId.createTemplatePartId)(templatePart.theme, templatePart.slug),
|
|
51
|
+
title: templatePart.title.rendered,
|
|
52
|
+
blocks: (0, _blocks.parse)(templatePart.content.raw),
|
|
53
|
+
templatePart
|
|
54
|
+
}));
|
|
55
|
+
}, [templateParts]);
|
|
56
|
+
const shownTemplateParts = (0, _compose.useAsyncList)(templartPartsAsBlockPatterns);
|
|
57
|
+
const {
|
|
58
|
+
createSuccessNotice
|
|
59
|
+
} = (0, _data.useDispatch)(_notices.store);
|
|
60
|
+
const blockPatterns = (0, _hooks.useAlternativeBlockPatterns)(area, clientId);
|
|
61
|
+
const shownBlockPatterns = (0, _compose.useAsyncList)(blockPatterns);
|
|
62
|
+
const {
|
|
63
|
+
replaceInnerBlocks
|
|
64
|
+
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
65
|
+
const onTemplatePartSelect = (0, _element.useCallback)(templatePart => {
|
|
66
|
+
var _templatePart$title;
|
|
67
|
+
|
|
68
|
+
setAttributes({
|
|
69
|
+
slug: templatePart.slug,
|
|
70
|
+
theme: templatePart.theme,
|
|
71
|
+
area: undefined
|
|
72
|
+
});
|
|
73
|
+
createSuccessNotice((0, _i18n.sprintf)(
|
|
74
|
+
/* translators: %s: template part title. */
|
|
75
|
+
(0, _i18n.__)('Template Part "%s" inserted.'), ((_templatePart$title = templatePart.title) === null || _templatePart$title === void 0 ? void 0 : _templatePart$title.rendered) || templatePart.slug), {
|
|
76
|
+
type: 'snackbar'
|
|
77
|
+
});
|
|
78
|
+
onClose();
|
|
79
|
+
}, []);
|
|
80
|
+
const createFromBlocks = (0, _hooks.useCreateTemplatePartFromBlocks)(area, setAttributes);
|
|
81
|
+
return (0, _element.createElement)(_element.Fragment, null, (0, _element.createElement)("div", {
|
|
82
|
+
className: "block-library-template-part__selection-content"
|
|
83
|
+
}, !!templartPartsAsBlockPatterns.length && (0, _element.createElement)("div", null, (0, _element.createElement)("h2", null, (0, _i18n.__)('Existing template parts')), (0, _element.createElement)(_blockEditor.__experimentalBlockPatternsList, {
|
|
84
|
+
blockPatterns: templartPartsAsBlockPatterns,
|
|
85
|
+
shownPatterns: shownTemplateParts,
|
|
86
|
+
onClickPattern: pattern => {
|
|
87
|
+
onTemplatePartSelect(pattern.templatePart);
|
|
88
|
+
}
|
|
89
|
+
})), !!blockPatterns.length && (0, _element.createElement)("div", null, (0, _element.createElement)("h2", null, (0, _i18n.__)('Patterns')), (0, _element.createElement)(_blockEditor.__experimentalBlockPatternsList, {
|
|
90
|
+
blockPatterns: blockPatterns,
|
|
91
|
+
shownPatterns: shownBlockPatterns,
|
|
92
|
+
onClickPattern: (pattern, blocks) => {
|
|
93
|
+
if (isReplacingTemplatePartContent) {
|
|
94
|
+
replaceInnerBlocks(clientId, blocks);
|
|
95
|
+
} else {
|
|
96
|
+
createFromBlocks(blocks, pattern.title);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
onClose();
|
|
100
|
+
}
|
|
101
|
+
}))));
|
|
102
|
+
}
|
|
103
|
+
//# sourceMappingURL=selection-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/selection-modal.js"],"names":["TemplatePartSelectionModal","setAttributes","onClose","templatePartId","area","clientId","isReplacingTemplatePartContent","templateParts","templartPartsAsBlockPatterns","map","templatePart","name","theme","slug","title","rendered","blocks","content","raw","shownTemplateParts","createSuccessNotice","noticesStore","blockPatterns","shownBlockPatterns","replaceInnerBlocks","blockEditorStore","onTemplatePartSelect","undefined","type","createFromBlocks","length","pattern"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAQA;;AAKA;;AAtBA;AACA;AACA;;AAYA;AACA;AACA;AAQe,SAASA,0BAAT,OAMX;AAAA,MANgD;AACnDC,IAAAA,aADmD;AAEnDC,IAAAA,OAFmD;AAGnDC,IAAAA,cAAc,GAAG,IAHkC;AAInDC,IAAAA,IAJmD;AAKnDC,IAAAA;AALmD,GAMhD;AACH;AACA;AACA,QAAMC,8BAA8B,GAAG,CAAC,CAAEH,cAA1C;AACA,QAAM;AAAEI,IAAAA;AAAF,MAAoB,wCACzBH,IADyB,EAEzBD,c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ACxBzB,IADwB,EAExBH,aAFwB,CAAzB;AAKA,SACC,qDACC;AAAK,IAAA,SAAS,EAAC;AAAf,KACG,CAAC,CAAEO,4BAA4B,CAACsB,MAAhC,IACD,yCACC,wCAAM,cAAI,yBAAJ,CAAN,CADD,EAEC,4BAAC,4CAAD;AACC,IAAA,aAAa,EAAGtB,4BADjB;AAEC,IAAA,aAAa,EAAGW,kBAFjB;AAGC,IAAA,cAAc,EAAKY,OAAF,IAAe;AAC/BL,MAAAA,oBAAoB,CAAEK,OAAO,CAACrB,YAAV,CAApB;AACA;AALF,IAFD,CAFF,EAcG,CAAC,CAAEY,aAAa,CAACQ,MAAjB,IACD,yCACC,wCAAM,cAAI,UAAJ,CAAN,CADD,EAEC,4BAAC,4CAAD;AACC,IAAA,aAAa,EAAGR,aADjB;AAEC,IAAA,aAAa,EAAGC,kBAFjB;AAGC,IAAA,cAAc,EAAG,CAAEQ,OAAF,EAAWf,MAAX,KAAuB;AACvC,UAAKV,8BAAL,EAAsC;AACrCkB,QAAAA,kBAAkB,CAAEnB,QAAF,EAAYW,MAAZ,CAAlB;AACA,OAFD,MAEO;AACNa,QAAAA,gBAAgB,CAAEb,MAAF,EAAUe,OAAO,CAACjB,KAAlB,CAAhB;AACA;;AAEDZ,MAAAA,OAAO;AACP;AAXF,IAFD,CAfF,CADD,CADD;AAqCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useMemo } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { useDispatch } from '@wordpress/data';\nimport { parse } from '@wordpress/blocks';\nimport { useAsyncList } from '@wordpress/compose';\nimport {\n\t__experimentalBlockPatternsList as BlockPatternsList,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseAlternativeBlockPatterns,\n\tuseAlternativeTemplateParts,\n\tuseCreateTemplatePartFromBlocks,\n} from './utils/hooks';\nimport { createTemplatePartId } from './utils/create-template-part-id';\n\nexport default function TemplatePartSelectionModal( {\n\tsetAttributes,\n\tonClose,\n\ttemplatePartId = null,\n\tarea,\n\tclientId,\n} ) {\n\t// When the templatePartId is undefined,\n\t// it means the user is creating a new one from the placeholder.\n\tconst isReplacingTemplatePartContent = !! templatePartId;\n\tconst { templateParts } = useAlternativeTemplateParts(\n\t\tarea,\n\t\ttemplatePartId\n\t);\n\t// We can map template parts to block patters to reuse the BlockPatternsList UI\n\tconst templartPartsAsBlockPatterns = useMemo( () => {\n\t\treturn templateParts.map( ( templatePart ) => ( {\n\t\t\tname: createTemplatePartId( templatePart.theme, templatePart.slug ),\n\t\t\ttitle: templatePart.title.rendered,\n\t\t\tblocks: parse( templatePart.content.raw ),\n\t\t\ttemplatePart,\n\t\t} ) );\n\t}, [ templateParts ] );\n\tconst shownTemplateParts = useAsyncList( templartPartsAsBlockPatterns );\n\tconst { createSuccessNotice } = useDispatch( noticesStore );\n\tconst blockPatterns = useAlternativeBlockPatterns( area, clientId );\n\tconst shownBlockPatterns = useAsyncList( blockPatterns );\n\tconst { replaceInnerBlocks } = useDispatch( blockEditorStore );\n\n\tconst onTemplatePartSelect = useCallback( ( templatePart ) => {\n\t\tsetAttributes( {\n\t\t\tslug: templatePart.slug,\n\t\t\ttheme: templatePart.theme,\n\t\t\tarea: undefined,\n\t\t} );\n\t\tcreateSuccessNotice(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %s: template part title. */\n\t\t\t\t__( 'Template Part \"%s\" inserted.' ),\n\t\t\t\ttemplatePart.title?.rendered || templatePart.slug\n\t\t\t),\n\t\t\t{\n\t\t\t\ttype: 'snackbar',\n\t\t\t}\n\t\t);\n\t\tonClose();\n\t}, [] );\n\n\tconst createFromBlocks = useCreateTemplatePartFromBlocks(\n\t\tarea,\n\t\tsetAttributes\n\t);\n\n\treturn (\n\t\t<>\n\t\t\t<div className=\"block-library-template-part__selection-content\">\n\t\t\t\t{ !! templartPartsAsBlockPatterns.length && (\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<h2>{ __( 'Existing template parts' ) }</h2>\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tblockPatterns={ templartPartsAsBlockPatterns }\n\t\t\t\t\t\t\tshownPatterns={ shownTemplateParts }\n\t\t\t\t\t\t\tonClickPattern={ ( pattern ) => {\n\t\t\t\t\t\t\t\tonTemplatePartSelect( pattern.templatePart );\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\n\t\t\t\t{ !! blockPatterns.length && (\n\t\t\t\t\t<div>\n\t\t\t\t\t\t<h2>{ __( 'Patterns' ) }</h2>\n\t\t\t\t\t\t<BlockPatternsList\n\t\t\t\t\t\t\tblockPatterns={ blockPatterns }\n\t\t\t\t\t\t\tshownPatterns={ shownBlockPatterns }\n\t\t\t\t\t\t\tonClickPattern={ ( pattern, blocks ) => {\n\t\t\t\t\t\t\t\tif ( isReplacingTemplatePartContent ) {\n\t\t\t\t\t\t\t\t\treplaceInnerBlocks( clientId, blocks );\n\t\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t\tcreateFromBlocks( blocks, pattern.title );\n\t\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t\tonClose();\n\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t/>\n\t\t\t\t\t</div>\n\t\t\t\t) }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = TitleModal;
|
|
7
|
+
|
|
8
|
+
var _element = require("@wordpress/element");
|
|
9
|
+
|
|
10
|
+
var _i18n = require("@wordpress/i18n");
|
|
11
|
+
|
|
12
|
+
var _components = require("@wordpress/components");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* WordPress dependencies
|
|
16
|
+
*/
|
|
17
|
+
function TitleModal(_ref) {
|
|
18
|
+
let {
|
|
19
|
+
areaLabel,
|
|
20
|
+
onClose,
|
|
21
|
+
onSubmit
|
|
22
|
+
} = _ref;
|
|
23
|
+
// Restructure onCreate to set the blocks on local state.
|
|
24
|
+
// Add modal to confirm title and trigger onCreate.
|
|
25
|
+
const [title, setTitle] = (0, _element.useState)((0, _i18n.__)('Untitled Template Part'));
|
|
26
|
+
|
|
27
|
+
const submitForCreation = event => {
|
|
28
|
+
event.preventDefault();
|
|
29
|
+
onSubmit(title);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return (0, _element.createElement)(_components.Modal, {
|
|
33
|
+
title: (0, _i18n.sprintf)( // Translators: %s as template part area title ("Header", "Footer", etc.).
|
|
34
|
+
(0, _i18n.__)('Name and create your new %s'), areaLabel.toLowerCase()),
|
|
35
|
+
closeLabel: (0, _i18n.__)('Cancel'),
|
|
36
|
+
overlayClassName: "wp-block-template-part__placeholder-create-new__title-form",
|
|
37
|
+
onRequestClose: onClose
|
|
38
|
+
}, (0, _element.createElement)("form", {
|
|
39
|
+
onSubmit: submitForCreation
|
|
40
|
+
}, (0, _element.createElement)(_components.TextControl, {
|
|
41
|
+
label: (0, _i18n.__)('Name'),
|
|
42
|
+
value: title,
|
|
43
|
+
onChange: setTitle
|
|
44
|
+
}), (0, _element.createElement)(_components.Flex, {
|
|
45
|
+
className: "wp-block-template-part__placeholder-create-new__title-form-actions",
|
|
46
|
+
justify: "flex-end"
|
|
47
|
+
}, (0, _element.createElement)(_components.FlexItem, null, (0, _element.createElement)(_components.Button, {
|
|
48
|
+
variant: "primary",
|
|
49
|
+
type: "submit",
|
|
50
|
+
disabled: !title.length,
|
|
51
|
+
"aria-disabled": !title.length
|
|
52
|
+
}, (0, _i18n.__)('Create'))))));
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=title-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/title-modal.js"],"names":["TitleModal","areaLabel","onClose","onSubmit","title","setTitle","submitForCreation","event","preventDefault","toLowerCase","length"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AALA;AACA;AACA;AAWe,SAASA,UAAT,OAAwD;AAAA,MAAnC;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,OAAb;AAAsBC,IAAAA;AAAtB,GAAmC;AACtE;AACA;AACA,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsB,uBAAU,cAAI,wBAAJ,CAAV,CAA5B;;AAEA,QAAMC,iBAAiB,GAAKC,KAAF,IAAa;AACtCA,IAAAA,KAAK,CAACC,cAAN;AACAL,IAAAA,QAAQ,CAAEC,KAAF,CAAR;AACA,GAHD;;AAKA,SACC,4BAAC,iBAAD;AACC,IAAA,KAAK,EAAG,oBACP;AACA,kBAAI,6BAAJ,CAFO,EAGPH,SAAS,CAACQ,WAAV,EAHO,CADT;AAMC,IAAA,UAAU,EAAG,cAAI,QAAJ,CANd;AAOC,IAAA,gBAAgB,EAAC,4DAPlB;AAQC,IAAA,cAAc,EAAGP;AARlB,KAUC;AAAM,IAAA,QAAQ,EAAGI;AAAjB,KACC,4BAAC,uBAAD;AACC,IAAA,KAAK,EAAG,cAAI,MAAJ,CADT;AAEC,IAAA,KAAK,EAAGF,KAFT;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IADD,EAMC,4BAAC,gBAAD;AACC,IAAA,SAAS,EAAC,oEADX;AAEC,IAAA,OAAO,EAAC;AAFT,KAIC,4BAAC,oBAAD,QACC,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,QAAQ,EAAG,CAAED,KAAK,CAACM,MAHpB;AAIC,qBAAgB,CAAEN,KAAK,CAACM;AAJzB,KAMG,cAAI,QAAJ,CANH,CADD,CAJD,CAND,CAVD,CADD;AAmCA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useState } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tTextControl,\n\tFlex,\n\tFlexItem,\n\tButton,\n\tModal,\n} from '@wordpress/components';\n\nexport default function TitleModal( { areaLabel, onClose, onSubmit } ) {\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\n\tconst submitForCreation = ( event ) => {\n\t\tevent.preventDefault();\n\t\tonSubmit( title );\n\t};\n\n\treturn (\n\t\t<Modal\n\t\t\ttitle={ sprintf(\n\t\t\t\t// Translators: %s as template part area title (\"Header\", \"Footer\", etc.).\n\t\t\t\t__( 'Name and create your new %s' ),\n\t\t\t\tareaLabel.toLowerCase()\n\t\t\t) }\n\t\t\tcloseLabel={ __( 'Cancel' ) }\n\t\t\toverlayClassName=\"wp-block-template-part__placeholder-create-new__title-form\"\n\t\t\tonRequestClose={ onClose }\n\t\t>\n\t\t\t<form onSubmit={ submitForCreation }>\n\t\t\t\t<TextControl\n\t\t\t\t\tlabel={ __( 'Name' ) }\n\t\t\t\t\tvalue={ title }\n\t\t\t\t\tonChange={ setTitle }\n\t\t\t\t/>\n\t\t\t\t<Flex\n\t\t\t\t\tclassName=\"wp-block-template-part__placeholder-create-new__title-form-actions\"\n\t\t\t\t\tjustify=\"flex-end\"\n\t\t\t\t>\n\t\t\t\t\t<FlexItem>\n\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\ttype=\"submit\"\n\t\t\t\t\t\t\tdisabled={ ! title.length }\n\t\t\t\t\t\t\taria-disabled={ ! title.length }\n\t\t\t\t\t\t>\n\t\t\t\t\t\t\t{ __( 'Create' ) }\n\t\t\t\t\t\t</Button>\n\t\t\t\t\t</FlexItem>\n\t\t\t\t</Flex>\n\t\t\t</form>\n\t\t</Modal>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.useAlternativeBlockPatterns = useAlternativeBlockPatterns;
|
|
7
|
+
exports.useAlternativeTemplateParts = useAlternativeTemplateParts;
|
|
8
|
+
exports.useCreateTemplatePartFromBlocks = useCreateTemplatePartFromBlocks;
|
|
9
|
+
exports.useTemplatePartArea = useTemplatePartArea;
|
|
10
|
+
|
|
11
|
+
var _lodash = require("lodash");
|
|
12
|
+
|
|
13
|
+
var _data = require("@wordpress/data");
|
|
14
|
+
|
|
15
|
+
var _coreData = require("@wordpress/core-data");
|
|
16
|
+
|
|
17
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
18
|
+
|
|
19
|
+
var _element = require("@wordpress/element");
|
|
20
|
+
|
|
21
|
+
var _blocks = require("@wordpress/blocks");
|
|
22
|
+
|
|
23
|
+
var _i18n = require("@wordpress/i18n");
|
|
24
|
+
|
|
25
|
+
var _createTemplatePartId = require("./create-template-part-id");
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* External dependencies
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* WordPress dependencies
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
/**
|
|
36
|
+
* Internal dependencies
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Retrieves the available template parts for the given area.
|
|
41
|
+
*
|
|
42
|
+
* @param {string} area Template part area.
|
|
43
|
+
* @param {string} excludedId Template part ID to exclude.
|
|
44
|
+
*
|
|
45
|
+
* @return {{ templateParts: Array, isResolving: boolean }} array of template parts.
|
|
46
|
+
*/
|
|
47
|
+
function useAlternativeTemplateParts(area, excludedId) {
|
|
48
|
+
const {
|
|
49
|
+
templateParts,
|
|
50
|
+
isResolving
|
|
51
|
+
} = (0, _data.useSelect)(select => {
|
|
52
|
+
const {
|
|
53
|
+
getEntityRecords,
|
|
54
|
+
isResolving: _isResolving
|
|
55
|
+
} = select(_coreData.store);
|
|
56
|
+
const query = {
|
|
57
|
+
per_page: -1
|
|
58
|
+
};
|
|
59
|
+
return {
|
|
60
|
+
templateParts: getEntityRecords('postType', 'wp_template_part', query),
|
|
61
|
+
isLoading: _isResolving('getEntityRecords', ['postType', 'wp_template_part', query])
|
|
62
|
+
};
|
|
63
|
+
}, []);
|
|
64
|
+
const filteredTemplateParts = (0, _element.useMemo)(() => {
|
|
65
|
+
if (!templateParts) {
|
|
66
|
+
return [];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return templateParts.filter(templatePart => (0, _createTemplatePartId.createTemplatePartId)(templatePart.theme, templatePart.slug) !== excludedId && (!area || 'uncategorized' === area || templatePart.area === area)) || [];
|
|
70
|
+
}, [templateParts, area]);
|
|
71
|
+
return {
|
|
72
|
+
templateParts: filteredTemplateParts,
|
|
73
|
+
isResolving
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Retrieves the available block patterns for the given area.
|
|
78
|
+
*
|
|
79
|
+
* @param {string} area Template part area.
|
|
80
|
+
* @param {string} clientId Block Client ID. (The container of the block can impact allowed blocks).
|
|
81
|
+
*
|
|
82
|
+
* @return {Array} array of block patterns.
|
|
83
|
+
*/
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
function useAlternativeBlockPatterns(area, clientId) {
|
|
87
|
+
return (0, _data.useSelect)(select => {
|
|
88
|
+
const blockNameWithArea = area ? `core/template-part/${area}` : 'core/template-part';
|
|
89
|
+
const {
|
|
90
|
+
getBlockRootClientId,
|
|
91
|
+
__experimentalGetPatternsByBlockTypes
|
|
92
|
+
} = select(_blockEditor.store);
|
|
93
|
+
const rootClientId = getBlockRootClientId(clientId);
|
|
94
|
+
return __experimentalGetPatternsByBlockTypes(blockNameWithArea, rootClientId);
|
|
95
|
+
}, [area, clientId]);
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function useCreateTemplatePartFromBlocks(area, setAttributes) {
|
|
99
|
+
const {
|
|
100
|
+
saveEntityRecord
|
|
101
|
+
} = (0, _data.useDispatch)(_coreData.store);
|
|
102
|
+
return async function () {
|
|
103
|
+
let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
104
|
+
let title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : (0, _i18n.__)('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: (0, _lodash.kebabCase)(title),
|
|
112
|
+
content: (0, _blocks.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('postType', 'wp_template_part', record);
|
|
118
|
+
setAttributes({
|
|
119
|
+
slug: templatePart.slug,
|
|
120
|
+
theme: templatePart.theme,
|
|
121
|
+
area: undefined
|
|
122
|
+
});
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Retrieves the template part area object.
|
|
127
|
+
*
|
|
128
|
+
* @param {string} area Template part area identifier.
|
|
129
|
+
*
|
|
130
|
+
* @return {{icon: Object, label: string, tagName: string}} Template Part area.
|
|
131
|
+
*/
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
function useTemplatePartArea(area) {
|
|
135
|
+
return (0, _data.useSelect)(select => {
|
|
136
|
+
var _selectedArea$area_ta;
|
|
137
|
+
|
|
138
|
+
// FIXME: @wordpress/block-library should not depend on @wordpress/editor.
|
|
139
|
+
// Blocks can be loaded into a *non-post* block editor.
|
|
140
|
+
// eslint-disable-next-line @wordpress/data-no-store-string-literals
|
|
141
|
+
const definedAreas = select('core/editor').__experimentalGetDefaultTemplatePartAreas();
|
|
142
|
+
|
|
143
|
+
const selectedArea = (0, _lodash.find)(definedAreas, {
|
|
144
|
+
area
|
|
145
|
+
});
|
|
146
|
+
const defaultArea = (0, _lodash.find)(definedAreas, {
|
|
147
|
+
area: 'uncategorized'
|
|
148
|
+
});
|
|
149
|
+
return {
|
|
150
|
+
icon: (selectedArea === null || selectedArea === void 0 ? void 0 : selectedArea.icon) || (defaultArea === null || defaultArea === void 0 ? void 0 : defaultArea.icon),
|
|
151
|
+
label: (selectedArea === null || selectedArea === void 0 ? void 0 : selectedArea.label) || (0, _i18n.__)('Template Part'),
|
|
152
|
+
tagName: (_selectedArea$area_ta = selectedArea === null || selectedArea === void 0 ? void 0 : selectedArea.area_tag) !== null && _selectedArea$area_ta !== void 0 ? _selectedArea$area_ta : 'div'
|
|
153
|
+
};
|
|
154
|
+
}, [area]);
|
|
155
|
+
}
|
|
156
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/utils/hooks.js"],"names":["useAlternativeTemplateParts","area","excludedId","templateParts","isResolving","select","getEntityRecords","_isResolving","coreStore","query","per_page","isLoading","filteredTemplateParts","filter","templatePart","theme","slug","useAlternativeBlockPatterns","clientId","blockNameWithArea","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","blockEditorStore","rootClientId","useCreateTemplatePartFromBlocks","setAttributes","saveEntityRecord","blocks","title","record","content","undefined","useTemplatePartArea","definedAreas","__experimentalGetDefaultTemplatePartAreas","selectedArea","defaultArea","icon","label","tagName","area_tag"],"mappings":";;;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AAlBA;AACA;AACA;;AAGA;AACA;AACA;;AAQA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,2BAAT,CAAsCC,IAAtC,EAA4CC,UAA5C,EAAyD;AAC/D,QAA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N,EAAoB;AAAEhC,MAAAA,IAAI,EAAE;AAAR,KAApB,CAApB;AAEA,WAAO;AACNoC,MAAAA,IAAI,EAAE,CAAAF,YAAY,SAAZ,IAAAA,YAAY,WAAZ,YAAAA,YAAY,CAAEE,IAAd,MAAsBD,WAAtB,aAAsBA,WAAtB,uBAAsBA,WAAW,CAAEC,IAAnC,CADA;AAENC,MAAAA,KAAK,EAAE,CAAAH,YAAY,SAAZ,IAAAA,YAAY,WAAZ,YAAAA,YAAY,CAAEG,KAAd,KAAuB,cAAI,eAAJ,CAFxB;AAGNC,MAAAA,OAAO,2BAAEJ,YAAF,aAAEA,YAAF,uBAAEA,YAAY,CAAEK,QAAhB,yEAA4B;AAH7B,KAAP;AAKA,GAjBK,EAkBN,CAAEvC,IAAF,CAlBM,CAAP;AAoBA","sourcesContent":["/**\n * External dependencies\n */\nimport { find, kebabCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useMemo } from '@wordpress/element';\nimport { serialize } from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport { createTemplatePartId } from './create-template-part-id';\n\n/**\n * Retrieves the available template parts for the given area.\n *\n * @param {string} area Template part area.\n * @param {string} excludedId Template part ID to exclude.\n *\n * @return {{ templateParts: Array, isResolving: boolean }} array of template parts.\n */\nexport function useAlternativeTemplateParts( area, excludedId ) {\n\tconst { templateParts, isResolving } = useSelect( ( select ) => {\n\t\tconst { getEntityRecords, isResolving: _isResolving } = select(\n\t\t\tcoreStore\n\t\t);\n\t\tconst query = { per_page: -1 };\n\t\treturn {\n\t\t\ttemplateParts: getEntityRecords(\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\tquery\n\t\t\t),\n\t\t\tisLoading: _isResolving( 'getEntityRecords', [\n\t\t\t\t'postType',\n\t\t\t\t'wp_template_part',\n\t\t\t\tquery,\n\t\t\t] ),\n\t\t};\n\t}, [] );\n\n\tconst filteredTemplateParts = useMemo( () => {\n\t\tif ( ! templateParts ) {\n\t\t\treturn [];\n\t\t}\n\t\treturn (\n\t\t\ttemplateParts.filter(\n\t\t\t\t( templatePart ) =>\n\t\t\t\t\tcreateTemplatePartId(\n\t\t\t\t\t\ttemplatePart.theme,\n\t\t\t\t\t\ttemplatePart.slug\n\t\t\t\t\t) !== excludedId &&\n\t\t\t\t\t( ! area ||\n\t\t\t\t\t\t'uncategorized' === area ||\n\t\t\t\t\t\ttemplatePart.area === area )\n\t\t\t) || []\n\t\t);\n\t}, [ templateParts, area ] );\n\n\treturn {\n\t\ttemplateParts: filteredTemplateParts,\n\t\tisResolving,\n\t};\n}\n\n/**\n * Retrieves the available block patterns for the given area.\n *\n * @param {string} area Template part area.\n * @param {string} clientId Block Client ID. (The container of the block can impact allowed blocks).\n *\n * @return {Array} array of block patterns.\n */\nexport function useAlternativeBlockPatterns( area, clientId ) {\n\treturn useSelect(\n\t\t( select ) => {\n\t\t\tconst blockNameWithArea = area\n\t\t\t\t? `core/template-part/${ area }`\n\t\t\t\t: 'core/template-part';\n\t\t\tconst {\n\t\t\t\tgetBlockRootClientId,\n\t\t\t\t__experimentalGetPatternsByBlockTypes,\n\t\t\t} = select( blockEditorStore );\n\t\t\tconst rootClientId = getBlockRootClientId( clientId );\n\t\t\treturn __experimentalGetPatternsByBlockTypes(\n\t\t\t\tblockNameWithArea,\n\t\t\t\trootClientId\n\t\t\t);\n\t\t},\n\t\t[ area, clientId ]\n\t);\n}\n\nexport function useCreateTemplatePartFromBlocks( area, setAttributes ) {\n\tconst { saveEntityRecord } = useDispatch( coreStore );\n\n\treturn async ( blocks = [], title = __( 'Untitled Template Part' ) ) => {\n\t\t// If we have `area` set from block attributes, means an exposed\n\t\t// block variation was inserted. So add this prop to the template\n\t\t// part entity on creation. Afterwards remove `area` value from\n\t\t// block attributes.\n\t\tconst record = {\n\t\t\ttitle,\n\t\t\tslug: kebabCase( title ),\n\t\t\tcontent: serialize( blocks ),\n\t\t\t// `area` is filterable on the server and defaults to `UNCATEGORIZED`\n\t\t\t// if provided value is not allowed.\n\t\t\tarea,\n\t\t};\n\t\tconst templatePart = await saveEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\trecord\n\t\t);\n\t\tsetAttributes( {\n\t\t\tslug: templatePart.slug,\n\t\t\ttheme: templatePart.theme,\n\t\t\tarea: undefined,\n\t\t} );\n\t};\n}\n\n/**\n * Retrieves the template part area object.\n *\n * @param {string} area Template part area identifier.\n *\n * @return {{icon: Object, label: string, tagName: string}} Template Part area.\n */\nexport function useTemplatePartArea( area ) {\n\treturn 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\ticon: selectedArea?.icon || defaultArea?.icon,\n\t\t\t\tlabel: selectedArea?.label || __( 'Template Part' ),\n\t\t\t\ttagName: selectedArea?.area_tag ?? 'div',\n\t\t\t};\n\t\t},\n\t\t[ area ]\n\t);\n}\n"]}
|
|
@@ -17,6 +17,8 @@ var _icons = require("@wordpress/icons");
|
|
|
17
17
|
|
|
18
18
|
var _hooks = require("@wordpress/hooks");
|
|
19
19
|
|
|
20
|
+
var _htmlEntities = require("@wordpress/html-entities");
|
|
21
|
+
|
|
20
22
|
var _edit = _interopRequireDefault(require("./edit"));
|
|
21
23
|
|
|
22
24
|
var _variations = require("./variations");
|
|
@@ -88,7 +90,7 @@ const settings = {
|
|
|
88
90
|
return;
|
|
89
91
|
}
|
|
90
92
|
|
|
91
|
-
return (0,
|
|
93
|
+
return (0, _htmlEntities.decodeEntities)((_entity$title = entity.title) === null || _entity$title === void 0 ? void 0 : _entity$title.rendered) || (0, _lodash.startCase)(entity.slug);
|
|
92
94
|
},
|
|
93
95
|
edit: _edit.default
|
|
94
96
|
}; // Importing this file includes side effects. This is whitelisted in block-library/package.json under sideEffects
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/template-part/index.js"],"names":["name","metadata","settings","icon","symbolFilled","__experimentalLabel","slug","theme","entity","coreDataStore","getEntityRecord","title","rendered","edit","enhanceTemplatePartVariations","DISALLOWED_PARENTS","can","blockType","rootClientId","getBlock","getBlockParentsByBlockName","disallowedParentType","hasDisallowedParent","length"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AAMA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/index.js"],"names":["name","metadata","settings","icon","symbolFilled","__experimentalLabel","slug","theme","entity","coreDataStore","getEntityRecord","title","rendered","edit","enhanceTemplatePartVariations","DISALLOWED_PARENTS","can","blockType","rootClientId","getBlock","getBlockParentsByBlockName","disallowedParentType","hasDisallowedParent","length"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;AACA;;AACA;;AAMA;;AACA;;AAnBA;AACA;AACA;;AAGA;AACA;AACA;;AAOA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAGO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAEC,mBADiB;AAEvBC,EAAAA,mBAAmB,EAAE,QAAuB;AAAA;;AAAA,QAArB;AAAEC,MAAAA,IAAF;AAAQC,MAAAA;AAAR,KAAqB;;AAC3C;AACA;AACA,QAAK,CAAED,IAAP,EAAc;AACb;AACA;;AAED,UAAME,MAAM,GAAG,kBAAQC,eAAR,EAAwBC,eAAxB,CACd,UADc,EAEd,kBAFc,EAGdH,KAAK,GAAG,IAAR,GAAeD,IAHD,CAAf;;AAKA,QAAK,CAAEE,MAAP,EAAgB;AACf;AACA;;AAED,WACC,mDAAgBA,MAAM,CAACG,KAAvB,kDAAgB,cAAcC,QAA9B,KAA4C,uBAAWJ,MAAM,CAACF,IAAlB,CAD7C;AAGA,GArBsB;AAsBvBO,EAAAA,IAAI,EAAJA;AAtBuB,CAAjB,C,CAyBP;;;AACA,sBACC,0BADD,EAEC,oBAFD,EAGCC,yCAHD,E,CAMA;;AACA,MAAMC,kBAAkB,GAAG,CAAE,oBAAF,EAAwB,mBAAxB,CAA3B;AACA,sBACC,0CADD,EAEC,sCAFD,EAGC,CACCC,GADD,EAECC,SAFD,EAGCC,YAHD,YAKK;AAAA,MADJ;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GACI;;AACJ,MAAKH,SAAS,CAACjB,IAAV,KAAmB,oBAAxB,EAA+C;AAC9C,WAAOgB,GAAP;AACA;;AAED,OAAM,MAAMK,oBAAZ,IAAoCN,kBAApC,EAAyD;AAAA;;AACxD,UAAMO,mBAAmB,GACxB,cAAAH,QAAQ,CAAED,YAAF,CAAR,wDAA0BlB,IAA1B,MAAmCqB,oBAAnC,IACAD,0BAA0B,CAAEF,YAAF,EAAgBG,oBAAhB,CAA1B,CACEE,MAHH;;AAIA,QAAKD,mBAAL,EAA2B;AAC1B,aAAO,KAAP;AACA;AACD;;AACD,SAAO,IAAP;AACA,CAvBF","sourcesContent":["/**\n * External dependencies\n */\nimport { startCase } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\nimport { select } from '@wordpress/data';\nimport { symbolFilled } from '@wordpress/icons';\nimport { addFilter } from '@wordpress/hooks';\nimport { decodeEntities } from '@wordpress/html-entities';\n\n/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport { enhanceTemplatePartVariations } from './variations';\n\nconst { name } = metadata;\nexport { metadata, name };\n\nexport const settings = {\n\ticon: symbolFilled,\n\t__experimentalLabel: ( { slug, theme } ) => {\n\t\t// Attempt to find entity title if block is a template part.\n\t\t// Require slug to request, otherwise entity is uncreated and will throw 404.\n\t\tif ( ! slug ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst entity = select( coreDataStore ).getEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_template_part',\n\t\t\ttheme + '//' + slug\n\t\t);\n\t\tif ( ! entity ) {\n\t\t\treturn;\n\t\t}\n\n\t\treturn (\n\t\t\tdecodeEntities( entity.title?.rendered ) || startCase( entity.slug )\n\t\t);\n\t},\n\tedit,\n};\n\n// Importing this file includes side effects. This is whitelisted in block-library/package.json under sideEffects\naddFilter(\n\t'blocks.registerBlockType',\n\t'core/template-part',\n\tenhanceTemplatePartVariations\n);\n\n// Prevent adding template parts inside post templates.\nconst DISALLOWED_PARENTS = [ 'core/post-template', 'core/post-content' ];\naddFilter(\n\t'blockEditor.__unstableCanInsertBlockType',\n\t'removeTemplatePartsFromPostTemplates',\n\t(\n\t\tcan,\n\t\tblockType,\n\t\trootClientId,\n\t\t{ getBlock, getBlockParentsByBlockName }\n\t) => {\n\t\tif ( blockType.name !== 'core/template-part' ) {\n\t\t\treturn can;\n\t\t}\n\n\t\tfor ( const disallowedParentType of DISALLOWED_PARENTS ) {\n\t\t\tconst hasDisallowedParent =\n\t\t\t\tgetBlock( rootClientId )?.name === disallowedParentType ||\n\t\t\t\tgetBlockParentsByBlockName( rootClientId, disallowedParentType )\n\t\t\t\t\t.length;\n\t\t\tif ( hasDisallowedParent ) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t}\n\t\treturn true;\n\t}\n);\n"]}
|
package/build/video/edit.js
CHANGED
|
@@ -107,17 +107,17 @@ function VideoEdit(_ref) {
|
|
|
107
107
|
var _media$image, _media$image2;
|
|
108
108
|
|
|
109
109
|
if (!media || !media.url) {
|
|
110
|
-
//
|
|
110
|
+
// In this case there was an error
|
|
111
111
|
// previous attributes should be removed
|
|
112
|
-
// because they may be temporary blob urls
|
|
112
|
+
// because they may be temporary blob urls.
|
|
113
113
|
setAttributes({
|
|
114
114
|
src: undefined,
|
|
115
115
|
id: undefined,
|
|
116
116
|
poster: undefined
|
|
117
117
|
});
|
|
118
118
|
return;
|
|
119
|
-
} //
|
|
120
|
-
// selected media
|
|
119
|
+
} // Sets the block's attribute and updates the edit component from the
|
|
120
|
+
// selected media.
|
|
121
121
|
|
|
122
122
|
|
|
123
123
|
setAttributes({
|
package/build/video/edit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/video/edit.js"],"names":["ALLOWED_MEDIA_TYPES","VIDEO_POSTER_ALLOWED_MEDIA_TYPES","VideoEdit","isSelected","noticeUI","attributes","className","setAttributes","insertBlocksAfter","onReplace","noticeOperations","instanceId","videoPlayer","posterImageButton","id","caption","controls","poster","src","tracks","isTemporaryVideo","mediaUpload","select","blockEditorStore","getSettings","file","filesList","onFileChange","url","onError","message","createErrorNotice","allowedTypes","current","load","onSelectVideo","media","undefined","image","icon","onSelectURL","newSrc","embedBlock","onUploadError","removeAllNotices","classes","blockProps","onSelectPoster","onRemovePoster","focus","videoPosterDescription","newTracks","open","RichText","isEmpty","value"],"mappings":";;;;;;;;;AA6BA;;AA1BA;;AAKA;;AACA;;AAQA;;AAaA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA1CA;AACA;AACA;;AAGA;AACA;AACA;;AA6BA;AACA;AACA;AAMA,MAAMA,mBAAmB,GAAG,CAAE,OAAF,CAA5B;AACA,MAAMC,gCAAgC,GAAG,CAAE,OAAF,CAAzC;;AAEA,SAASC,SAAT,OASI;AAAA,MATgB;AACnBC,IAAAA,UADmB;AAEnBC,IAAAA,QAFmB;AAGnBC,IAAAA,UAHmB;AAInBC,IAAAA,SAJmB;AAKnBC,IAAAA,aALmB;AAMnBC,IAAAA,i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AJ,CAJH,CAvCF,CADD,CALD,CADD,CApBD,EA6EC,sCAAaF,UAAb,EAMC,4BAAC,oBAAD;AAAU,IAAA,UAAU,EAAG,CAAE3C;AAAzB,KACC;AACC,IAAA,QAAQ,EAAGa,QADZ;AAEC,IAAA,MAAM,EAAGC,MAFV;AAGC,IAAA,GAAG,EAAGC,GAHP;AAIC,IAAA,GAAG,EAAGN;AAJP,KAMC,4BAAC,eAAD;AAAQ,IAAA,MAAM,EAAGO;AAAjB,IAND,CADD,CAND,EAgBGC,gBAAgB,IAAI,4BAAC,mBAAD,OAhBvB,EAiBG,CAAE,CAAEiC,sBAASC,OAAT,CAAkBvC,OAAlB,CAAF,IAAiCZ,UAAnC,KACD,4BAAC,qBAAD;AACC,IAAA,OAAO,EAAC,YADT;AAEC,kBAAa,cAAI,oBAAJ,CAFd;AAGC,IAAA,WAAW,EAAG,cAAI,aAAJ,CAHf;AAIC,IAAA,KAAK,EAAGY,OAJT;AAKC,IAAA,QAAQ,EAAKwC,KAAF,IACVhD,aAAa,CAAE;AAAEQ,MAAAA,OAAO,EAAEwC;AAAX,KAAF,CANf;AAQC,IAAA,aAAa,MARd;AASC,IAAA,sBAAsB,EAAG,MACxB/C,iBAAiB,CAAE,yBAAa,gBAAb,CAAF;AAVnB,IAlBF,CA7ED,CADD;AAiHA;;eAEc,6BAAaN,SAAb,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL } from '@wordpress/blob';\nimport {\n\tBaseControl,\n\tButton,\n\tDisabled,\n\tPanelBody,\n\tSpinner,\n\twithNotices,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadCheck,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { video as icon } from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport VideoCommonSettings from './edit-common-settings';\nimport TracksEditor from './tracks-editor';\nimport Tracks from './tracks';\n\nconst ALLOWED_MEDIA_TYPES = [ 'video' ];\nconst VIDEO_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nfunction VideoEdit( {\n\tisSelected,\n\tnoticeUI,\n\tattributes,\n\tclassName,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tonReplace,\n\tnoticeOperations,\n} ) {\n\tconst instanceId = useInstanceId( VideoEdit );\n\tconst videoPlayer = useRef();\n\tconst posterImageButton = useRef();\n\tconst { id, caption, controls, poster, src, tracks } = attributes;\n\tconst isTemporaryVideo = ! id && isBlobURL( src );\n\tconst mediaUpload = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().mediaUpload\n\t);\n\n\tuseEffect( () => {\n\t\tif ( ! id && isBlobURL( src ) ) {\n\t\t\tconst file = getBlobByURL( src );\n\t\t\tif ( file ) {\n\t\t\t\tmediaUpload( {\n\t\t\t\t\tfilesList: [ file ],\n\t\t\t\t\tonFileChange: ( [ { url } ] ) => {\n\t\t\t\t\t\tsetAttributes( { src: url } );\n\t\t\t\t\t},\n\t\t\t\t\tonError: ( message ) => {\n\t\t\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t\t\t},\n\t\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t// Placeholder may be rendered.\n\t\tif ( videoPlayer.current ) {\n\t\t\tvideoPlayer.current.load();\n\t\t}\n\t}, [ poster ] );\n\n\tfunction onSelectVideo( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// in this case there was an error\n\t\t\t// previous attributes should be removed\n\t\t\t// because they may be temporary blob urls\n\t\t\tsetAttributes( {\n\t\t\t\tsrc: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\t// sets the block's attribute and updates the edit component from the\n\t\t// selected media\n\t\tsetAttributes( {\n\t\t\tsrc: media.url,\n\t\t\tid: media.id,\n\t\t\tposter:\n\t\t\t\tmedia.image?.src !== media.icon ? media.image?.src : undefined,\n\t\t} );\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url: newSrc },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( { src: newSrc, id: undefined, poster: undefined } );\n\t\t}\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tnoticeOperations.removeAllNotices();\n\t\tnoticeOperations.createErrorNotice( message );\n\t}\n\n\tconst classes = classnames( className, {\n\t\t'is-transient': isTemporaryVideo,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tnotices={ noticeUI }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tfunction onSelectPoster( image ) {\n\t\tsetAttributes( { poster: image.url } );\n\t}\n\n\tfunction onRemovePoster() {\n\t\tsetAttributes( { poster: undefined } );\n\n\t\t// Move focus back to the Media Upload button.\n\t\tposterImageButton.current.focus();\n\t}\n\n\tconst videoPosterDescription = `video-block__poster-image-description-${ instanceId }`;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<TracksEditor\n\t\t\t\t\ttracks={ tracks }\n\t\t\t\t\tonChange={ ( newTracks ) => {\n\t\t\t\t\t\tsetAttributes( { tracks: newTracks } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Video settings' ) }>\n\t\t\t\t\t<VideoCommonSettings\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t/>\n\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t<BaseControl className=\"editor-video-poster-control\">\n\t\t\t\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t\t\t\t{ __( 'Poster image' ) }\n\t\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\t\ttitle={ __( 'Select poster image' ) }\n\t\t\t\t\t\t\t\tonSelect={ onSelectPoster }\n\t\t\t\t\t\t\t\tallowedTypes={\n\t\t\t\t\t\t\t\t\tVIDEO_POSTER_ALLOWED_MEDIA_TYPES\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\tref={ posterImageButton }\n\t\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\t\tvideoPosterDescription\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{ ! poster\n\t\t\t\t\t\t\t\t\t\t\t? __( 'Select' )\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Replace' ) }\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\t<p id={ videoPosterDescription } hidden>\n\t\t\t\t\t\t\t\t{ poster\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: poster image URL. */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'The current poster image url is %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tposter\n\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\t'There is no poster image currently selected'\n\t\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t{ !! poster && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tonClick={ onRemovePoster }\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /*\n\t\t\t\t\tDisable the video tag if the block is not selected\n\t\t\t\t\tso the user clicking on it won't play the\n\t\t\t\t\tvideo when the controls are enabled.\n\t\t\t\t*/ }\n\t\t\t\t<Disabled isDisabled={ ! isSelected }>\n\t\t\t\t\t<video\n\t\t\t\t\t\tcontrols={ controls }\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\tref={ videoPlayer }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Tracks tracks={ tracks } />\n\t\t\t\t\t</video>\n\t\t\t\t</Disabled>\n\t\t\t\t{ isTemporaryVideo && <Spinner /> }\n\t\t\t\t{ ( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\taria-label={ __( 'Video caption text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter( createBlock( 'core/paragraph' ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</figure>\n\t\t</>\n\t);\n}\n\nexport default withNotices( VideoEdit );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/video/edit.js"],"names":["ALLOWED_MEDIA_TYPES","VIDEO_POSTER_ALLOWED_MEDIA_TYPES","VideoEdit","isSelected","noticeUI","attributes","className","setAttributes","insertBlocksAfter","onReplace","noticeOperations","instanceId","videoPlayer","posterImageButton","id","caption","controls","poster","src","tracks","isTemporaryVideo","mediaUpload","select","blockEditorStore","getSettings","file","filesList","onFileChange","url","onError","message","createErrorNotice","allowedTypes","current","load","onSelectVideo","media","undefined","image","icon","onSelectURL","newSrc","embedBlock","onUploadError","removeAllNotices","classes","blockProps","onSelectPoster","onRemovePoster","focus","videoPosterDescription","newTracks","open","RichText","isEmpty","value"],"mappings":";;;;;;;;;AA6BA;;AA1BA;;AAKA;;AACA;;AAQA;;AAaA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA1CA;AACA;AACA;;AAGA;AACA;AACA;;AA6BA;AACA;AACA;AAMA,MAAMA,mBAAmB,GAAG,CAAE,OAAF,CAA5B;AACA,MAAMC,gCAAgC,GAAG,CAAE,OAAF,CAAzC;;AAEA,SAASC,SAAT,OASI;AAAA,MATgB;AACnBC,IAAAA,UADmB;AAEnBC,IAAAA,QAFmB;AAGnBC,IAAAA,UAHmB;AAInBC,IAAAA,SAJmB;AAKnBC,IAAAA,aALmB;AAMnBC,IAAAA,iBANmB;AAOnBC,IAAAA,SAPmB;AAQnBC,IAAAA;AARmB,GAShB;AACH,QAAMC,UAAU,GAAG,4BAAeT,SAAf,CAAnB;AACA,QAAMU,WAAW,GAAG,sBAApB;AACA,QAAMC,iBAAiB,GAAG,sBAA1B;AACA,QAAM;AAAEC,IAAAA,EAAF;AAAMC,IAAAA,OAAN;AAAeC,IAAAA,QAAf;AAAyBC,IAAAA,MAAzB;AAAiCC,IAAAA,GAAjC;AAAsCC,IAAAA;AAAtC,MAAiDd,UAAvD;AACA,QAAMe,gBAAgB,GAAG,CAAEN,EAAF,IAAQ,qBAAWI,GAAX,CAAjC;AACA,QAAMG,WAAW,GAAG,qBACjBC,MAAF,IAAcA,MAAM,CAAEC,kBAAF,CAAN,CAA2BC,WAA3B,GAAyCH,WADpC,CAApB;AAIA,0BAAW,MAAM;AAChB,QAAK,CAAEP,EAAF,IAAQ,qBAAWI,GAAX,CAAb,EAAgC;AAC/B,YAAMO,IAAI,GAAG,wBAAcP,GAA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,KAAF,IACVhD,aAAa,CAAE;AAAEQ,MAAAA,OAAO,EAAEwC;AAAX,KAAF,CANf;AAQC,IAAA,aAAa,MARd;AASC,IAAA,sBAAsB,EAAG,MACxB/C,iBAAiB,CAAE,yBAAa,gBAAb,CAAF;AAVnB,IAlBF,CA7ED,CADD;AAiHA;;eAEc,6BAAaN,SAAb,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL } from '@wordpress/blob';\nimport {\n\tBaseControl,\n\tButton,\n\tDisabled,\n\tPanelBody,\n\tSpinner,\n\twithNotices,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadCheck,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { video as icon } from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport VideoCommonSettings from './edit-common-settings';\nimport TracksEditor from './tracks-editor';\nimport Tracks from './tracks';\n\nconst ALLOWED_MEDIA_TYPES = [ 'video' ];\nconst VIDEO_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nfunction VideoEdit( {\n\tisSelected,\n\tnoticeUI,\n\tattributes,\n\tclassName,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tonReplace,\n\tnoticeOperations,\n} ) {\n\tconst instanceId = useInstanceId( VideoEdit );\n\tconst videoPlayer = useRef();\n\tconst posterImageButton = useRef();\n\tconst { id, caption, controls, poster, src, tracks } = attributes;\n\tconst isTemporaryVideo = ! id && isBlobURL( src );\n\tconst mediaUpload = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().mediaUpload\n\t);\n\n\tuseEffect( () => {\n\t\tif ( ! id && isBlobURL( src ) ) {\n\t\t\tconst file = getBlobByURL( src );\n\t\t\tif ( file ) {\n\t\t\t\tmediaUpload( {\n\t\t\t\t\tfilesList: [ file ],\n\t\t\t\t\tonFileChange: ( [ { url } ] ) => {\n\t\t\t\t\t\tsetAttributes( { src: url } );\n\t\t\t\t\t},\n\t\t\t\t\tonError: ( message ) => {\n\t\t\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t\t\t},\n\t\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t// Placeholder may be rendered.\n\t\tif ( videoPlayer.current ) {\n\t\t\tvideoPlayer.current.load();\n\t\t}\n\t}, [ poster ] );\n\n\tfunction onSelectVideo( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error\n\t\t\t// previous attributes should be removed\n\t\t\t// because they may be temporary blob urls.\n\t\t\tsetAttributes( {\n\t\t\t\tsrc: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media.\n\t\tsetAttributes( {\n\t\t\tsrc: media.url,\n\t\t\tid: media.id,\n\t\t\tposter:\n\t\t\t\tmedia.image?.src !== media.icon ? media.image?.src : undefined,\n\t\t} );\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url: newSrc },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( { src: newSrc, id: undefined, poster: undefined } );\n\t\t}\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tnoticeOperations.removeAllNotices();\n\t\tnoticeOperations.createErrorNotice( message );\n\t}\n\n\tconst classes = classnames( className, {\n\t\t'is-transient': isTemporaryVideo,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tnotices={ noticeUI }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tfunction onSelectPoster( image ) {\n\t\tsetAttributes( { poster: image.url } );\n\t}\n\n\tfunction onRemovePoster() {\n\t\tsetAttributes( { poster: undefined } );\n\n\t\t// Move focus back to the Media Upload button.\n\t\tposterImageButton.current.focus();\n\t}\n\n\tconst videoPosterDescription = `video-block__poster-image-description-${ instanceId }`;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<TracksEditor\n\t\t\t\t\ttracks={ tracks }\n\t\t\t\t\tonChange={ ( newTracks ) => {\n\t\t\t\t\t\tsetAttributes( { tracks: newTracks } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Video settings' ) }>\n\t\t\t\t\t<VideoCommonSettings\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t/>\n\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t<BaseControl className=\"editor-video-poster-control\">\n\t\t\t\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t\t\t\t{ __( 'Poster image' ) }\n\t\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\t\ttitle={ __( 'Select poster image' ) }\n\t\t\t\t\t\t\t\tonSelect={ onSelectPoster }\n\t\t\t\t\t\t\t\tallowedTypes={\n\t\t\t\t\t\t\t\t\tVIDEO_POSTER_ALLOWED_MEDIA_TYPES\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\tref={ posterImageButton }\n\t\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\t\tvideoPosterDescription\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{ ! poster\n\t\t\t\t\t\t\t\t\t\t\t? __( 'Select' )\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Replace' ) }\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\t<p id={ videoPosterDescription } hidden>\n\t\t\t\t\t\t\t\t{ poster\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: poster image URL. */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'The current poster image url is %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tposter\n\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\t'There is no poster image currently selected'\n\t\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t{ !! poster && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tonClick={ onRemovePoster }\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /*\n\t\t\t\t\tDisable the video tag if the block is not selected\n\t\t\t\t\tso the user clicking on it won't play the\n\t\t\t\t\tvideo when the controls are enabled.\n\t\t\t\t*/ }\n\t\t\t\t<Disabled isDisabled={ ! isSelected }>\n\t\t\t\t\t<video\n\t\t\t\t\t\tcontrols={ controls }\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\tref={ videoPlayer }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Tracks tracks={ tracks } />\n\t\t\t\t\t</video>\n\t\t\t\t</Disabled>\n\t\t\t\t{ isTemporaryVideo && <Spinner /> }\n\t\t\t\t{ ( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\taria-label={ __( 'Video caption text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter( createBlock( 'core/paragraph' ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</figure>\n\t\t</>\n\t);\n}\n\nexport default withNotices( VideoEdit );\n"]}
|