@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":["isEmpty","useSelect","BlockControls","useBlockProps","__experimentalUseNoRecursiveRenders","useNoRecursiveRenders","Warning","store","blockEditorStore","Dropdown","ToolbarGroup","ToolbarButton","Spinner","__","sprintf","coreStore","TemplatePartPlaceholder","TemplatePartSelection","TemplatePartAdvancedControls","TemplatePartInnerBlocks","createTemplatePartId","TemplatePartEdit","attributes","setAttributes","clientId","slug","theme","tagName","layout","templatePartId","hasAlreadyRendered","RecursionProvider","isResolved","innerBlocks","isMissing","defaultWrapper","area","enableSelection","hasResolvedReplacements","select","getEditedEntityRecord","getEntityRecords","hasFinishedResolution","getBlocks","getEntityArgs","entityRecord","_area","availableReplacementArgs","matchingReplacements","_enableSelection","length","hasResolvedEntity","defaultWrapperElement","__experimentalGetDefaultTemplatePartAreas","find","value","area_tag","blockProps","isPlaceholder","isEntityAvailable","TagName","isOpen","onToggle","onClose"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,aADD,EAECC,aAFD,EAGCC,mCAAmC,IAAIC,qBAHxC,EAICC,OAJD,EAKCC,KAAK,IAAIC,gBALV,QAMO,yBANP;AAOA,SACCC,QADD,EAECC,YAFD,EAGCC,aAHD,EAICC,OAJD,QAKO,uBALP;AAMA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASP,KAAK,IAAIQ,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,eAApC;AACA,OAAOC,qBAAP,MAAkC,aAAlC;AACA,SAASC,4BAAT,QAA6C,qBAA7C;AACA,OAAOC,uBAAP,MAAoC,gBAApC;AACA,SAASC,oBAAT,QAAqC,iCAArC;AAEA,eAAe,SAASC,gBAAT,OAIX;AAAA,MAJsC;AACzCC,IAAAA,UADyC;AAEzCC,IAAAA,aAFyC;AAGzCC,IAAAA;AAHyC,GAItC;AACH,QAAM;AAAEC,IAAAA,IAAF;AAAQC,IAAAA,KAAR;AAAeC,IAAAA,OAAf;AAAwBC,IAAAA,MAAM,GAAG;AAAjC,MAAwCN,UAA9C;AACA,QAAMO,cAAc,GAAGT,oBAAoB,CAAEM,KAAF,EAASD,IAAT,CAA3C;AAEA,QAAM,CAAEK,kBAAF,EAAsBC,iBAAtB,IAA4C1B,qBAAqB,CACtEwB,cADsE,CAAvE,CAJG,CAQH;AACA;AACA;;AACA,QAAM;AACLG,IAAAA,UADK;AAELC,IAAAA,WAFK;AAGLC,IAAAA,SAHK;AAILC,IAAAA,cAJK;AAKLC,IAAAA,IALK;AAMLC,IAAAA,eANK;AAOLC,IAAAA;AAPK,MAQFrC,SAAS,CACVsC,MAAF,IAAc;AAAA;;AACb,U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,MAAM,EAAGtB;AANV,IA/CF,EAwDG,CAAE8B,aAAF,IAAmB,CAAE1B,UAArB,IACD,cAAC,OAAD,EAAcyB,UAAd,EACC,cAAC,OAAD,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":["isEmpty","useSelect","BlockControls","useBlockProps","__experimentalUseNoRecursiveRenders","useNoRecursiveRenders","Warning","store","blockEditorStore","ToolbarGroup","ToolbarButton","Spinner","Modal","__","sprintf","coreStore","useState","TemplatePartPlaceholder","TemplatePartSelectionModal","TemplatePartAdvancedControls","TemplatePartInnerBlocks","createTemplatePartId","useAlternativeBlockPatterns","useAlternativeTemplateParts","useTemplatePartArea","TemplatePartEdit","attributes","setAttributes","clientId","slug","theme","tagName","layout","templatePartId","hasAlreadyRendered","RecursionProvider","isTemplatePartSelectionOpen","setIsTemplatePartSelectionOpen","isResolved","innerBlocks","isMissing","area","select","getEditedEntityRecord","hasFinishedResolution","getBlocks","getEntityArgs","entityRecord","_area","hasResolvedEntity","templateParts","blockPatterns","hasReplacements","length","areaObject","blockProps","isPlaceholder","isEntityAvailable","TagName","label","toLowerCase"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SACCC,aADD,EAECC,aAFD,EAGCC,mCAAmC,IAAIC,qBAHxC,EAICC,OAJD,EAKCC,KAAK,IAAIC,gBALV,QAMO,yBANP;AAOA,SACCC,YADD,EAECC,aAFD,EAGCC,OAHD,EAICC,KAJD,QAKO,uBALP;AAMA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASP,KAAK,IAAIQ,SAAlB,QAAmC,sBAAnC;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,eAApC;AACA,OAAOC,0BAAP,MAAuC,mBAAvC;AACA,SAASC,4BAAT,QAA6C,qBAA7C;AACA,OAAOC,uBAAP,MAAoC,gBAApC;AACA,SAASC,oBAAT,QAAqC,iCAArC;AACA,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AAX,CAAiBC,WAAjB,EAHc,CAFhB;AAOC,IAAA,UAAU,EAAG/C,EAAE,CAAE,QAAF,CAPhB;AAQC,IAAA,cAAc,EAAG,MAChBwB,8BAA8B,CAAE,KAAF;AAThC,KAYC,cAAC,0BAAD;AACC,IAAA,cAAc,EAAGJ,cADlB;AAEC,IAAA,QAAQ,EAAGL,QAFZ;AAGC,IAAA,IAAI,EAAGa,IAHR;AAIC,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,52 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
7
|
+
import { Placeholder, Button, Spinner } from '@wordpress/components';
|
|
8
|
+
import { useState } from '@wordpress/element';
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { useAlternativeBlockPatterns, useAlternativeTemplateParts, useCreateTemplatePartFromBlocks, useTemplatePartArea } from './utils/hooks';
|
|
14
|
+
import TitleModal from './title-modal';
|
|
15
|
+
export default function TemplatePartPlaceholder(_ref) {
|
|
16
|
+
let {
|
|
17
|
+
area,
|
|
18
|
+
clientId,
|
|
19
|
+
templatePartId,
|
|
20
|
+
onOpenSelectionModal,
|
|
21
|
+
setAttributes
|
|
22
|
+
} = _ref;
|
|
23
|
+
const {
|
|
24
|
+
templateParts,
|
|
25
|
+
isResolving
|
|
26
|
+
} = useAlternativeTemplateParts(area, templatePartId);
|
|
27
|
+
const blockPatterns = useAlternativeBlockPatterns(area, clientId);
|
|
28
|
+
const [showTitleModal, setShowTitleModal] = useState(false);
|
|
29
|
+
const areaObject = useTemplatePartArea(area);
|
|
30
|
+
const createFromBlocks = useCreateTemplatePartFromBlocks(area, setAttributes);
|
|
31
|
+
return createElement(Placeholder, {
|
|
32
|
+
icon: areaObject.icon,
|
|
33
|
+
label: areaObject.label,
|
|
34
|
+
instructions: sprintf( // Translators: %s as template part area title ("Header", "Footer", etc.).
|
|
35
|
+
__('Choose an existing %s or create a new one.'), areaObject.label.toLowerCase())
|
|
36
|
+
}, isResolving && createElement(Spinner, null), !isResolving && !!(templateParts.length || blockPatterns.length) && createElement(Button, {
|
|
37
|
+
variant: "primary",
|
|
38
|
+
onClick: onOpenSelectionModal
|
|
39
|
+
}, __('Choose')), !isResolving && createElement(Button, {
|
|
40
|
+
variant: "secondary",
|
|
41
|
+
onClick: () => {
|
|
42
|
+
setShowTitleModal(true);
|
|
43
|
+
}
|
|
44
|
+
}, __('Start blank')), showTitleModal && createElement(TitleModal, {
|
|
45
|
+
areaLabel: areaObject.label,
|
|
46
|
+
onClose: () => setShowTitleModal(false),
|
|
47
|
+
onSubmit: title => {
|
|
48
|
+
createFromBlocks([], title);
|
|
49
|
+
}
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=placeholder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/placeholder.js"],"names":["__","sprintf","Placeholder","Button","Spinner","useState","useAlternativeBlockPatterns","useAlternativeTemplateParts","useCreateTemplatePartFromBlocks","useTemplatePartArea","TitleModal","TemplatePartPlaceholder","area","clientId","templatePartId","onOpenSelectionModal","setAttributes","templateParts","isResolving","blockPatterns","showTitleModal","setShowTitleModal","areaObject","createFromBlocks","icon","label","toLowerCase","length","title"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,WAAT,EAAsBC,MAAtB,EAA8BC,OAA9B,QAA6C,uBAA7C;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,SACCC,2BADD,EAECC,2BAFD,EAGCC,+BAHD,EAICC,mBAJD,QAKO,eALP;AAMA,OAAOC,UAAP,MAAuB,eAAvB;AAEA,eAAe,SAASC,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,MAAiCX,2BAA2B,CACjEK,IADiE,EAEjEE,cAFiE,CAAlE;AAIA,QAAMK,aAAa,GAAGb,2BAA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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,89 @@
|
|
|
1
|
+
import { createElement, Fragment } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useCallback, useMemo } from '@wordpress/element';
|
|
7
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
8
|
+
import { store as noticesStore } from '@wordpress/notices';
|
|
9
|
+
import { useDispatch } from '@wordpress/data';
|
|
10
|
+
import { parse } from '@wordpress/blocks';
|
|
11
|
+
import { useAsyncList } from '@wordpress/compose';
|
|
12
|
+
import { __experimentalBlockPatternsList as BlockPatternsList, store as blockEditorStore } from '@wordpress/block-editor';
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import { useAlternativeBlockPatterns, useAlternativeTemplateParts, useCreateTemplatePartFromBlocks } from './utils/hooks';
|
|
18
|
+
import { createTemplatePartId } from './utils/create-template-part-id';
|
|
19
|
+
export default function TemplatePartSelectionModal(_ref) {
|
|
20
|
+
let {
|
|
21
|
+
setAttributes,
|
|
22
|
+
onClose,
|
|
23
|
+
templatePartId = null,
|
|
24
|
+
area,
|
|
25
|
+
clientId
|
|
26
|
+
} = _ref;
|
|
27
|
+
// When the templatePartId is undefined,
|
|
28
|
+
// it means the user is creating a new one from the placeholder.
|
|
29
|
+
const isReplacingTemplatePartContent = !!templatePartId;
|
|
30
|
+
const {
|
|
31
|
+
templateParts
|
|
32
|
+
} = useAlternativeTemplateParts(area, templatePartId); // We can map template parts to block patters to reuse the BlockPatternsList UI
|
|
33
|
+
|
|
34
|
+
const templartPartsAsBlockPatterns = useMemo(() => {
|
|
35
|
+
return templateParts.map(templatePart => ({
|
|
36
|
+
name: createTemplatePartId(templatePart.theme, templatePart.slug),
|
|
37
|
+
title: templatePart.title.rendered,
|
|
38
|
+
blocks: parse(templatePart.content.raw),
|
|
39
|
+
templatePart
|
|
40
|
+
}));
|
|
41
|
+
}, [templateParts]);
|
|
42
|
+
const shownTemplateParts = useAsyncList(templartPartsAsBlockPatterns);
|
|
43
|
+
const {
|
|
44
|
+
createSuccessNotice
|
|
45
|
+
} = useDispatch(noticesStore);
|
|
46
|
+
const blockPatterns = useAlternativeBlockPatterns(area, clientId);
|
|
47
|
+
const shownBlockPatterns = useAsyncList(blockPatterns);
|
|
48
|
+
const {
|
|
49
|
+
replaceInnerBlocks
|
|
50
|
+
} = useDispatch(blockEditorStore);
|
|
51
|
+
const onTemplatePartSelect = useCallback(templatePart => {
|
|
52
|
+
var _templatePart$title;
|
|
53
|
+
|
|
54
|
+
setAttributes({
|
|
55
|
+
slug: templatePart.slug,
|
|
56
|
+
theme: templatePart.theme,
|
|
57
|
+
area: undefined
|
|
58
|
+
});
|
|
59
|
+
createSuccessNotice(sprintf(
|
|
60
|
+
/* translators: %s: template part title. */
|
|
61
|
+
__('Template Part "%s" inserted.'), ((_templatePart$title = templatePart.title) === null || _templatePart$title === void 0 ? void 0 : _templatePart$title.rendered) || templatePart.slug), {
|
|
62
|
+
type: 'snackbar'
|
|
63
|
+
});
|
|
64
|
+
onClose();
|
|
65
|
+
}, []);
|
|
66
|
+
const createFromBlocks = useCreateTemplatePartFromBlocks(area, setAttributes);
|
|
67
|
+
return createElement(Fragment, null, createElement("div", {
|
|
68
|
+
className: "block-library-template-part__selection-content"
|
|
69
|
+
}, !!templartPartsAsBlockPatterns.length && createElement("div", null, createElement("h2", null, __('Existing template parts')), createElement(BlockPatternsList, {
|
|
70
|
+
blockPatterns: templartPartsAsBlockPatterns,
|
|
71
|
+
shownPatterns: shownTemplateParts,
|
|
72
|
+
onClickPattern: pattern => {
|
|
73
|
+
onTemplatePartSelect(pattern.templatePart);
|
|
74
|
+
}
|
|
75
|
+
})), !!blockPatterns.length && createElement("div", null, createElement("h2", null, __('Patterns')), createElement(BlockPatternsList, {
|
|
76
|
+
blockPatterns: blockPatterns,
|
|
77
|
+
shownPatterns: shownBlockPatterns,
|
|
78
|
+
onClickPattern: (pattern, blocks) => {
|
|
79
|
+
if (isReplacingTemplatePartContent) {
|
|
80
|
+
replaceInnerBlocks(clientId, blocks);
|
|
81
|
+
} else {
|
|
82
|
+
createFromBlocks(blocks, pattern.title);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
onClose();
|
|
86
|
+
}
|
|
87
|
+
}))));
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=selection-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/selection-modal.js"],"names":["useCallback","useMemo","__","sprintf","store","noticesStore","useDispatch","parse","useAsyncList","__experimentalBlockPatternsList","BlockPatternsList","blockEditorStore","useAlternativeBlockPatterns","useAlternativeTemplateParts","useCreateTemplatePartFromBlocks","createTemplatePartId","TemplatePartSelectionModal","setAttributes","onClose","templatePartId","area","clientId","isReplacingTemplatePartContent","templateParts","templartPartsAsBlockPatterns","map","templatePart","name","theme","slug","title","rendered","blocks","content","raw","shownTemplateParts","createSuccessNotice","blockPatterns","shownBlockPatterns","replaceInnerBlocks","onTemplatePartSelect","undefined","type","createFromBlocks","length","pattern"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,OAAtB,QAAqC,oBAArC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,KAAK,IAAIC,YAAlB,QAAsC,oBAAtC;AACA,SAASC,WAAT,QAA4B,iBAA5B;AACA,SAASC,KAAT,QAAsB,mBAAtB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SACCC,+BAA+B,IAAIC,iB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Z,CAAlB;AACA,OAFD,MAEO;AACNW,QAAAA,gBAAgB,CAAEX,MAAF,EAAUa,OAAO,CAACf,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,46 @@
|
|
|
1
|
+
import { createElement } from "@wordpress/element";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* WordPress dependencies
|
|
5
|
+
*/
|
|
6
|
+
import { useState } from '@wordpress/element';
|
|
7
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
8
|
+
import { TextControl, Flex, FlexItem, Button, Modal } from '@wordpress/components';
|
|
9
|
+
export default function TitleModal(_ref) {
|
|
10
|
+
let {
|
|
11
|
+
areaLabel,
|
|
12
|
+
onClose,
|
|
13
|
+
onSubmit
|
|
14
|
+
} = _ref;
|
|
15
|
+
// Restructure onCreate to set the blocks on local state.
|
|
16
|
+
// Add modal to confirm title and trigger onCreate.
|
|
17
|
+
const [title, setTitle] = useState(__('Untitled Template Part'));
|
|
18
|
+
|
|
19
|
+
const submitForCreation = event => {
|
|
20
|
+
event.preventDefault();
|
|
21
|
+
onSubmit(title);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
return createElement(Modal, {
|
|
25
|
+
title: sprintf( // Translators: %s as template part area title ("Header", "Footer", etc.).
|
|
26
|
+
__('Name and create your new %s'), areaLabel.toLowerCase()),
|
|
27
|
+
closeLabel: __('Cancel'),
|
|
28
|
+
overlayClassName: "wp-block-template-part__placeholder-create-new__title-form",
|
|
29
|
+
onRequestClose: onClose
|
|
30
|
+
}, createElement("form", {
|
|
31
|
+
onSubmit: submitForCreation
|
|
32
|
+
}, createElement(TextControl, {
|
|
33
|
+
label: __('Name'),
|
|
34
|
+
value: title,
|
|
35
|
+
onChange: setTitle
|
|
36
|
+
}), createElement(Flex, {
|
|
37
|
+
className: "wp-block-template-part__placeholder-create-new__title-form-actions",
|
|
38
|
+
justify: "flex-end"
|
|
39
|
+
}, createElement(FlexItem, null, createElement(Button, {
|
|
40
|
+
variant: "primary",
|
|
41
|
+
type: "submit",
|
|
42
|
+
disabled: !title.length,
|
|
43
|
+
"aria-disabled": !title.length
|
|
44
|
+
}, __('Create'))))));
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=title-modal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/title-modal.js"],"names":["useState","__","sprintf","TextControl","Flex","FlexItem","Button","Modal","TitleModal","areaLabel","onClose","onSubmit","title","setTitle","submitForCreation","event","preventDefault","toLowerCase","length"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,QAAT,QAAyB,oBAAzB;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,WADD,EAECC,IAFD,EAGCC,QAHD,EAICC,MAJD,EAKCC,KALD,QAMO,uBANP;AAQA,eAAe,SAASC,UAAT,OAAwD;AAAA,MAAnC;AAAEC,IAAAA,SAAF;AAAaC,IAAAA,OAAb;AAAsBC,IAAAA;AAAtB,GAAmC;AACtE;AACA;AACA,QAAM,CAAEC,KAAF,EAASC,QAAT,IAAsBb,QAAQ,CAAEC,EAAE,CAAE,wBAAF,CAAJ,CAApC;;AAEA,QAAMa,iBAAiB,GAAKC,KAAF,IAAa;AACtCA,IAAAA,KAAK,CAACC,cAAN;AACAL,IAAAA,QAAQ,CAAEC,KAAF,CAAR;AACA,GAHD;;AAKA,SACC,cAAC,KAAD;AACC,IAAA,KAAK,EAAGV,OAAO,EACd;AACAD,IAAAA,EAAE,CAAE,6BAAF,CAFY,EAGdQ,SAAS,CAACQ,WAAV,EAHc,CADhB;AAMC,IAAA,UAAU,EAAGhB,EAAE,CAAE,QAAF,CANhB;AAOC,IAAA,gBAAgB,EAAC,4DAPlB;AAQC,IAAA,cAAc,EAAGS;AARlB,KAUC;AAAM,IAAA,QAAQ,EAAGI;AAAjB,KACC,cAAC,WAAD;AACC,IAAA,KAAK,EAAGb,EAAE,CAAE,MAAF,CADX;AAEC,IAAA,KAAK,EAAGW,KAFT;AAGC,IAAA,QAAQ,EAAGC;AAHZ,IADD,EAMC,cAAC,IAAD;AACC,IAAA,SAAS,EAAC,oEADX;AAEC,IAAA,OAAO,EAAC;AAFT,KAIC,cAAC,QAAD,QACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,SADT;AAEC,IAAA,IAAI,EAAC,QAFN;AAGC,IAAA,QAAQ,EAAG,CAAED,KAAK,CAACM,MAHpB;AAIC,qBAAgB,CAAEN,KAAK,CAACM;AAJzB,KAMGjB,EAAE,CAAE,QAAF,CANL,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,135 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { find, kebabCase } from 'lodash';
|
|
5
|
+
/**
|
|
6
|
+
* WordPress dependencies
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { useDispatch, useSelect } from '@wordpress/data';
|
|
10
|
+
import { store as coreStore } from '@wordpress/core-data';
|
|
11
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
12
|
+
import { useMemo } from '@wordpress/element';
|
|
13
|
+
import { serialize } from '@wordpress/blocks';
|
|
14
|
+
import { __ } from '@wordpress/i18n';
|
|
15
|
+
/**
|
|
16
|
+
* Internal dependencies
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { createTemplatePartId } from './create-template-part-id';
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves the available template parts for the given area.
|
|
22
|
+
*
|
|
23
|
+
* @param {string} area Template part area.
|
|
24
|
+
* @param {string} excludedId Template part ID to exclude.
|
|
25
|
+
*
|
|
26
|
+
* @return {{ templateParts: Array, isResolving: boolean }} array of template parts.
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
export function useAlternativeTemplateParts(area, excludedId) {
|
|
30
|
+
const {
|
|
31
|
+
templateParts,
|
|
32
|
+
isResolving
|
|
33
|
+
} = useSelect(select => {
|
|
34
|
+
const {
|
|
35
|
+
getEntityRecords,
|
|
36
|
+
isResolving: _isResolving
|
|
37
|
+
} = select(coreStore);
|
|
38
|
+
const query = {
|
|
39
|
+
per_page: -1
|
|
40
|
+
};
|
|
41
|
+
return {
|
|
42
|
+
templateParts: getEntityRecords('postType', 'wp_template_part', query),
|
|
43
|
+
isLoading: _isResolving('getEntityRecords', ['postType', 'wp_template_part', query])
|
|
44
|
+
};
|
|
45
|
+
}, []);
|
|
46
|
+
const filteredTemplateParts = useMemo(() => {
|
|
47
|
+
if (!templateParts) {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return templateParts.filter(templatePart => createTemplatePartId(templatePart.theme, templatePart.slug) !== excludedId && (!area || 'uncategorized' === area || templatePart.area === area)) || [];
|
|
52
|
+
}, [templateParts, area]);
|
|
53
|
+
return {
|
|
54
|
+
templateParts: filteredTemplateParts,
|
|
55
|
+
isResolving
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Retrieves the available block patterns for the given area.
|
|
60
|
+
*
|
|
61
|
+
* @param {string} area Template part area.
|
|
62
|
+
* @param {string} clientId Block Client ID. (The container of the block can impact allowed blocks).
|
|
63
|
+
*
|
|
64
|
+
* @return {Array} array of block patterns.
|
|
65
|
+
*/
|
|
66
|
+
|
|
67
|
+
export function useAlternativeBlockPatterns(area, clientId) {
|
|
68
|
+
return useSelect(select => {
|
|
69
|
+
const blockNameWithArea = area ? `core/template-part/${area}` : 'core/template-part';
|
|
70
|
+
const {
|
|
71
|
+
getBlockRootClientId,
|
|
72
|
+
__experimentalGetPatternsByBlockTypes
|
|
73
|
+
} = select(blockEditorStore);
|
|
74
|
+
const rootClientId = getBlockRootClientId(clientId);
|
|
75
|
+
return __experimentalGetPatternsByBlockTypes(blockNameWithArea, rootClientId);
|
|
76
|
+
}, [area, clientId]);
|
|
77
|
+
}
|
|
78
|
+
export function useCreateTemplatePartFromBlocks(area, setAttributes) {
|
|
79
|
+
const {
|
|
80
|
+
saveEntityRecord
|
|
81
|
+
} = useDispatch(coreStore);
|
|
82
|
+
return async function () {
|
|
83
|
+
let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
84
|
+
let title = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : __('Untitled Template Part');
|
|
85
|
+
// If we have `area` set from block attributes, means an exposed
|
|
86
|
+
// block variation was inserted. So add this prop to the template
|
|
87
|
+
// part entity on creation. Afterwards remove `area` value from
|
|
88
|
+
// block attributes.
|
|
89
|
+
const record = {
|
|
90
|
+
title,
|
|
91
|
+
slug: kebabCase(title),
|
|
92
|
+
content: serialize(blocks),
|
|
93
|
+
// `area` is filterable on the server and defaults to `UNCATEGORIZED`
|
|
94
|
+
// if provided value is not allowed.
|
|
95
|
+
area
|
|
96
|
+
};
|
|
97
|
+
const templatePart = await saveEntityRecord('postType', 'wp_template_part', record);
|
|
98
|
+
setAttributes({
|
|
99
|
+
slug: templatePart.slug,
|
|
100
|
+
theme: templatePart.theme,
|
|
101
|
+
area: undefined
|
|
102
|
+
});
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Retrieves the template part area object.
|
|
107
|
+
*
|
|
108
|
+
* @param {string} area Template part area identifier.
|
|
109
|
+
*
|
|
110
|
+
* @return {{icon: Object, label: string, tagName: string}} Template Part area.
|
|
111
|
+
*/
|
|
112
|
+
|
|
113
|
+
export function useTemplatePartArea(area) {
|
|
114
|
+
return useSelect(select => {
|
|
115
|
+
var _selectedArea$area_ta;
|
|
116
|
+
|
|
117
|
+
// FIXME: @wordpress/block-library should not depend on @wordpress/editor.
|
|
118
|
+
// Blocks can be loaded into a *non-post* block editor.
|
|
119
|
+
// eslint-disable-next-line @wordpress/data-no-store-string-literals
|
|
120
|
+
const definedAreas = select('core/editor').__experimentalGetDefaultTemplatePartAreas();
|
|
121
|
+
|
|
122
|
+
const selectedArea = find(definedAreas, {
|
|
123
|
+
area
|
|
124
|
+
});
|
|
125
|
+
const defaultArea = find(definedAreas, {
|
|
126
|
+
area: 'uncategorized'
|
|
127
|
+
});
|
|
128
|
+
return {
|
|
129
|
+
icon: (selectedArea === null || selectedArea === void 0 ? void 0 : selectedArea.icon) || (defaultArea === null || defaultArea === void 0 ? void 0 : defaultArea.icon),
|
|
130
|
+
label: (selectedArea === null || selectedArea === void 0 ? void 0 : selectedArea.label) || __('Template Part'),
|
|
131
|
+
tagName: (_selectedArea$area_ta = selectedArea === null || selectedArea === void 0 ? void 0 : selectedArea.area_tag) !== null && _selectedArea$area_ta !== void 0 ? _selectedArea$area_ta : 'div'
|
|
132
|
+
};
|
|
133
|
+
}, [area]);
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=hooks.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/utils/hooks.js"],"names":["find","kebabCase","useDispatch","useSelect","store","coreStore","blockEditorStore","useMemo","serialize","__","createTemplatePartId","useAlternativeTemplateParts","area","excludedId","templateParts","isResolving","select","getEntityRecords","_isResolving","query","per_page","isLoading","filteredTemplateParts","filter","templatePart","theme","slug","useAlternativeBlockPatterns","clientId","blockNameWithArea","getBlockRootClientId","__experimentalGetPatternsByBlockTypes","rootClientId","useCreateTemplatePartFromBlocks","setAttributes","saveEntityRecord","blocks","title","record","content","undefined","useTemplatePartArea","definedAreas","__experimentalGetDefaultTemplatePartAreas","selectedArea","defaultArea","icon","label","tagName","area_tag"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,IAAT,EAAeC,SAAf,QAAgC,QAAhC;AAEA;AACA;AACA;;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,SAAlB,QAAmC,sBAAn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AAAA,IAAI,EAAE4B;AAHQ,KAAF,CAAb;AAKA,GAvBD;AAwBA;AAED;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,mBAAT,CAA8B7B,IAA9B,EAAqC;AAC3C,SAAOT,SAAS,CACba,MAAF,IAAc;AAAA;;AACb;AACA;AACA;AACA,UAAM0B,YAAY,GAAG1B,MAAM,CAC1B,aAD0B,CAAN,CAEnB2B,yCAFmB,EAArB;;AAIA,UAAMC,YAAY,GAAG5C,IAAI,CAAE0C,YAAF,EAAgB;AAAE9B,MAAAA;AAAF,KAAhB,CAAzB;AACA,UAAMiC,WAAW,GAAG7C,IAAI,CAAE0C,YAAF,EAAgB;AAAE9B,MAAAA,IAAI,EAAE;AAAR,KAAhB,CAAxB;AAEA,WAAO;AACNkC,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,KAAuBtC,EAAE,CAAE,eAAF,CAF1B;AAGNuC,MAAAA,OAAO,2BAAEJ,YAAF,aAAEA,YAAF,uBAAEA,YAAY,CAAEK,QAAhB,yEAA4B;AAH7B,KAAP;AAKA,GAjBc,EAkBf,CAAErC,IAAF,CAlBe,CAAhB;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"]}
|
|
@@ -10,6 +10,7 @@ import { store as coreDataStore } from '@wordpress/core-data';
|
|
|
10
10
|
import { select } from '@wordpress/data';
|
|
11
11
|
import { symbolFilled } from '@wordpress/icons';
|
|
12
12
|
import { addFilter } from '@wordpress/hooks';
|
|
13
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
13
14
|
/**
|
|
14
15
|
* Internal dependencies
|
|
15
16
|
*/
|
|
@@ -71,7 +72,7 @@ export const settings = {
|
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
74
|
|
|
74
|
-
return
|
|
75
|
+
return decodeEntities((_entity$title = entity.title) === null || _entity$title === void 0 ? void 0 : _entity$title.rendered) || startCase(entity.slug);
|
|
75
76
|
},
|
|
76
77
|
edit
|
|
77
78
|
}; // 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":["startCase","store","coreDataStore","select","symbolFilled","addFilter","edit","enhanceTemplatePartVariations","name","metadata","settings","icon","__experimentalLabel","slug","theme","entity","getEntityRecord","title","rendered","DISALLOWED_PARENTS","can","blockType","rootClientId","getBlock","getBlockParentsByBlockName","disallowedParentType","hasDisallowedParent","length"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,sBAAvC;AACA,SAASC,MAAT,QAAuB,iBAAvB;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASC,SAAT,QAA0B,kBAA1B;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,SAASC,6BAAT,QAA8C,cAA9C;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBC,EAAAA,IAAI,
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/index.js"],"names":["startCase","store","coreDataStore","select","symbolFilled","addFilter","decodeEntities","edit","enhanceTemplatePartVariations","name","metadata","settings","icon","__experimentalLabel","slug","theme","entity","getEntityRecord","title","rendered","DISALLOWED_PARENTS","can","blockType","rootClientId","getBlock","getBlockParentsByBlockName","disallowedParentType","hasDisallowedParent","length"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,QAA1B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,aAAlB,QAAuC,sBAAvC;AACA,SAASC,MAAT,QAAuB,iBAAvB;AACA,SAASC,YAAT,QAA6B,kBAA7B;AACA,SAASC,SAAT,QAA0B,kBAA1B;AACA,SAASC,cAAT,QAA+B,0BAA/B;AAEA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,OAAOC,IAAP,MAAiB,QAAjB;AACA,SAASC,6BAAT,QAA8C,cAA9C;AAEA,MAAM;AAAEC,EAAAA;AAAF,IAAWC,QAAjB;AACA,SAASA,QAAT,EAAmBD,IAAnB;AAEA,OAAO,MAAME,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAER,YADiB;AAEvBS,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,GAAGb,MAAM,CAAED,aAAF,CAAN,CAAwBe,eAAxB,CACd,UADc,EAEd,kBAFc,EAGdF,KAAK,GAAG,IAAR,GAAeD,IAHD,CAAf;;AAKA,QAAK,CAAEE,MAAP,EAAgB;AACf;AACA;;AAED,WACCV,cAAc,kBAAEU,MAAM,CAACE,KAAT,kDAAE,cAAcC,QAAhB,CAAd,IAA4CnB,SAAS,CAAEgB,MAAM,CAACF,IAAT,CADtD;AAGA,GArBsB;AAsBvBP,EAAAA;AAtBuB,CAAjB,C,CAyBP;;AACAF,SAAS,CACR,0BADQ,EAER,oBAFQ,EAGRG,6BAHQ,CAAT,C,CAMA;;AACA,MAAMY,kBAAkB,GAAG,CAAE,oBAAF,EAAwB,mBAAxB,CAA3B;AACAf,SAAS,CACR,0CADQ,EAER,sCAFQ,EAGR,CACCgB,GADD,EAECC,SAFD,EAGCC,YAHD,YAKK;AAAA,MADJ;AAAEC,IAAAA,QAAF;AAAYC,IAAAA;AAAZ,GACI;;AACJ,MAAKH,SAAS,CAACb,IAAV,KAAmB,oBAAxB,EAA+C;AAC9C,WAAOY,GAAP;AACA;;AAED,OAAM,MAAMK,oBAAZ,IAAoCN,kBAApC,EAAyD;AAAA;;AACxD,UAAMO,mBAAmB,GACxB,cAAAH,QAAQ,CAAED,YAAF,CAAR,wDAA0Bd,IAA1B,MAAmCiB,oBAAnC,IACAD,0BAA0B,CAAEF,YAAF,EAAgBG,oBAAhB,CAA1B,CACEE,MAHH;;AAIA,QAAKD,mBAAL,EAA2B;AAC1B,aAAO,KAAP;AACA;AACD;;AACD,SAAO,IAAP;AACA,CAvBO,CAAT","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"]}
|
|
@@ -86,17 +86,17 @@ function VideoEdit(_ref) {
|
|
|
86
86
|
var _media$image, _media$image2;
|
|
87
87
|
|
|
88
88
|
if (!media || !media.url) {
|
|
89
|
-
//
|
|
89
|
+
// In this case there was an error
|
|
90
90
|
// previous attributes should be removed
|
|
91
|
-
// because they may be temporary blob urls
|
|
91
|
+
// because they may be temporary blob urls.
|
|
92
92
|
setAttributes({
|
|
93
93
|
src: undefined,
|
|
94
94
|
id: undefined,
|
|
95
95
|
poster: undefined
|
|
96
96
|
});
|
|
97
97
|
return;
|
|
98
|
-
} //
|
|
99
|
-
// selected media
|
|
98
|
+
} // Sets the block's attribute and updates the edit component from the
|
|
99
|
+
// selected media.
|
|
100
100
|
|
|
101
101
|
|
|
102
102
|
setAttributes({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/video/edit.js"],"names":["classnames","getBlobByURL","isBlobURL","BaseControl","Button","Disabled","PanelBody","Spinner","withNotices","BlockControls","BlockIcon","InspectorControls","MediaPlaceholder","MediaUpload","MediaUploadCheck","MediaReplaceFlow","RichText","useBlockProps","store","blockEditorStore","useRef","useEffect","__","sprintf","useInstanceId","useSelect","video","icon","createBlock","createUpgradedEmbedBlock","VideoCommonSettings","TracksEditor","Tracks","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","getSettings","file","filesList","onFileChange","url","onError","message","createErrorNotice","allowedTypes","current","load","onSelectVideo","media","undefined","image","onSelectURL","newSrc","embedBlock","onUploadError","removeAllNotices","classes","blockProps","onSelectPoster","onRemovePoster","focus","videoPosterDescription","newTracks","open","isEmpty","value"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,YAAT,EAAuBC,SAAvB,QAAwC,iBAAxC;AACA,SACCC,WADD,EAECC,MAFD,EAGCC,QAHD,EAICC,SAJD,EAKCC,OALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SACCC,aADD,EAECC,SAFD,EAGCC,iBAHD,EAICC,gBAJD,EAKCC,WALD,EAMCC,gBAND,EAOCC,gBAPD,EAQCC,QARD,EASCC,aATD,EA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Q,CAACoE,OAAT,CAAkBpC,OAAlB,CAAF,IAAiCZ,UAAnC,KACD,cAAC,QAAD;AACC,IAAA,OAAO,EAAC,YADT;AAEC,kBAAad,EAAE,CAAE,oBAAF,CAFhB;AAGC,IAAA,WAAW,EAAGA,EAAE,CAAE,aAAF,CAHjB;AAIC,IAAA,KAAK,EAAG0B,OAJT;AAKC,IAAA,QAAQ,EAAKqC,KAAF,IACV7C,aAAa,CAAE;AAAEQ,MAAAA,OAAO,EAAEqC;AAAX,KAAF,CANf;AAQC,IAAA,aAAa,MARd;AASC,IAAA,sBAAsB,EAAG,MACxB5C,iBAAiB,CAAEb,WAAW,CAAE,gBAAF,CAAb;AAVnB,IAlBF,CA7ED,CADD;AAiHA;;AAED,eAAepB,WAAW,CAAE2B,SAAF,CAA1B","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":["classnames","getBlobByURL","isBlobURL","BaseControl","Button","Disabled","PanelBody","Spinner","withNotices","BlockControls","BlockIcon","InspectorControls","MediaPlaceholder","MediaUpload","MediaUploadCheck","MediaReplaceFlow","RichText","useBlockProps","store","blockEditorStore","useRef","useEffect","__","sprintf","useInstanceId","useSelect","video","icon","createBlock","createUpgradedEmbedBlock","VideoCommonSettings","TracksEditor","Tracks","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","getSettings","file","filesList","onFileChange","url","onError","message","createErrorNotice","allowedTypes","current","load","onSelectVideo","media","undefined","image","onSelectURL","newSrc","embedBlock","onUploadError","removeAllNotices","classes","blockProps","onSelectPoster","onRemovePoster","focus","videoPosterDescription","newTracks","open","isEmpty","value"],"mappings":";;AAAA;AACA;AACA;AACA,OAAOA,UAAP,MAAuB,YAAvB;AAEA;AACA;AACA;;AACA,SAASC,YAAT,EAAuBC,SAAvB,QAAwC,iBAAxC;AACA,SACCC,WADD,EAECC,MAFD,EAGCC,QAHD,EAICC,SAJD,EAKCC,OALD,EAMCC,WAND,QAOO,uBAPP;AAQA,SACCC,aADD,EAECC,SAFD,EAGCC,iBAHD,EAICC,gBAJD,EAKCC,WALD,EAMCC,gBAND,EAOCC,gBAPD,EAQCC,QARD,EASCC,aATD,EAUCC,KAAK,IAAIC,gBAVV,QAWO,yBAXP;AAYA,SAASC,MAAT,EAAiBC,SAAjB,QAAkC,oBAAlC;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,aAAT,QAA8B,oBAA9B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,IAAlB,QAA8B,kBAA9B;AACA,SAASC,WAAT,QAA4B,mBAA5B;AAEA;AACA;AACA;;AACA,SAASC,wBAAT,QAAyC,eAAzC;AACA,OAAOC,mBAAP,MAAgC,wBAAhC;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,OAAOC,MAAP,MAAmB,UAAnB;AAEA,MAAMC,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,GAAGpB,aAAa,CAAEW,SAAF,CAAhC;AACA,QAAMU,WAAW,GAAGzB,MAAM,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FT,KAIGzD,EAAE,CAAE,QAAF,CAJL,CAvCF,CADD,CALD,CADD,CApBD,EA6EC,wBAAauD,UAAb,EAMC,cAAC,QAAD;AAAU,IAAA,UAAU,EAAG,CAAEzC;AAAzB,KACC;AACC,IAAA,QAAQ,EAAGa,QADZ;AAEC,IAAA,MAAM,EAAGC,MAFV;AAGC,IAAA,GAAG,EAAGC,GAHP;AAIC,IAAA,GAAG,EAAGN;AAJP,KAMC,cAAC,MAAD;AAAQ,IAAA,MAAM,EAAGO;AAAjB,IAND,CADD,CAND,EAgBGC,gBAAgB,IAAI,cAAC,OAAD,OAhBvB,EAiBG,CAAE,CAAErC,QAAQ,CAACoE,OAAT,CAAkBpC,OAAlB,CAAF,IAAiCZ,UAAnC,KACD,cAAC,QAAD;AACC,IAAA,OAAO,EAAC,YADT;AAEC,kBAAad,EAAE,CAAE,oBAAF,CAFhB;AAGC,IAAA,WAAW,EAAGA,EAAE,CAAE,aAAF,CAHjB;AAIC,IAAA,KAAK,EAAG0B,OAJT;AAKC,IAAA,QAAQ,EAAKqC,KAAF,IACV7C,aAAa,CAAE;AAAEQ,MAAAA,OAAO,EAAEqC;AAAX,KAAF,CANf;AAQC,IAAA,aAAa,MARd;AASC,IAAA,sBAAsB,EAAG,MACxB5C,iBAAiB,CAAEb,WAAW,CAAE,gBAAF,CAAb;AAVnB,IAlBF,CA7ED,CADD;AAiHA;;AAED,eAAepB,WAAW,CAAE2B,SAAF,CAA1B","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"]}
|
|
@@ -61,7 +61,7 @@ class VideoEdit extends Component {
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
componentWillUnmount() {
|
|
64
|
-
//
|
|
64
|
+
// This action will only exist if the user pressed the trash button on the block holder.
|
|
65
65
|
if (hasAction('blocks.onRemoveBlockCheckUpload') && this.state.isUploadInProgress) {
|
|
66
66
|
doAction('blocks.onRemoveBlockCheckUpload', this.props.attributes.id);
|
|
67
67
|
}
|
|
@@ -69,7 +69,7 @@ class VideoEdit extends Component {
|
|
|
69
69
|
|
|
70
70
|
static getDerivedStateFromProps(props, state) {
|
|
71
71
|
// Avoid a UI flicker in the toolbar by insuring that isCaptionSelected
|
|
72
|
-
// is updated immediately any time the isSelected prop becomes false
|
|
72
|
+
// is updated immediately any time the isSelected prop becomes false.
|
|
73
73
|
return {
|
|
74
74
|
isCaptionSelected: props.isSelected && state.isCaptionSelected
|
|
75
75
|
};
|
|
@@ -318,7 +318,7 @@ class VideoEdit extends Component {
|
|
|
318
318
|
clientId: this.props.clientId,
|
|
319
319
|
isSelected: this.state.isCaptionSelected,
|
|
320
320
|
onFocus: this.onFocusCaption,
|
|
321
|
-
onBlur: this.props.onBlur //
|
|
321
|
+
onBlur: this.props.onBlur // Always assign onBlur as props.
|
|
322
322
|
,
|
|
323
323
|
insertBlocksAfter: this.props.insertBlocksAfter
|
|
324
324
|
})));
|