@wordpress/block-library 7.4.0 → 7.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +3 -2
- package/babel-plugin.js +154 -0
- package/build/audio/edit.js +4 -16
- package/build/audio/edit.js.map +1 -1
- package/build/block/edit.js +10 -9
- package/build/block/edit.js.map +1 -1
- package/build/button/deprecated.js +175 -35
- package/build/button/deprecated.js.map +1 -1
- package/build/button/edit.js +1 -1
- package/build/button/edit.js.map +1 -1
- package/build/button/edit.native.js +7 -3
- package/build/button/edit.native.js.map +1 -1
- package/build/button/index.js +1 -0
- package/build/button/index.js.map +1 -1
- package/build/button/save.js +1 -1
- package/build/button/save.js.map +1 -1
- package/build/categories/edit.js +1 -1
- package/build/categories/edit.js.map +1 -1
- package/build/categories/index.js +1 -1
- package/build/columns/index.js +3 -1
- package/build/columns/index.js.map +1 -1
- package/build/comment-author-avatar/index.js +1 -0
- package/build/comment-author-avatar/index.js.map +1 -1
- package/build/comment-template/edit.js +1 -3
- package/build/comment-template/edit.js.map +1 -1
- package/build/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
- package/{build-module/comments-query-loop → build/comments}/edit/comments-inspector-controls.js.map +1 -1
- package/build/{comments-query-loop → comments}/edit.js +3 -3
- package/build/comments/edit.js.map +1 -0
- package/build/{comments-query-loop → comments}/index.js +1 -1
- package/build/comments/index.js.map +1 -0
- package/build/{comments-query-loop → comments}/save.js +2 -2
- package/build/comments/save.js.map +1 -0
- package/build/comments-title/deprecated.js +110 -0
- package/build/comments-title/deprecated.js.map +1 -0
- package/build/comments-title/edit.js +35 -35
- package/build/comments-title/edit.js.map +1 -1
- package/build/comments-title/index.js +5 -8
- package/build/comments-title/index.js.map +1 -1
- package/build/cover/controls.native.js +2 -3
- package/build/cover/controls.native.js.map +1 -1
- package/build/cover/deprecated.js +212 -207
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit/block-controls.js +115 -0
- package/build/cover/edit/block-controls.js.map +1 -0
- package/build/cover/edit/cover-placeholder.js +49 -0
- package/build/cover/edit/cover-placeholder.js.map +1 -0
- package/build/cover/edit/index.js +343 -0
- package/build/cover/edit/index.js.map +1 -0
- package/build/cover/edit/inspector-controls.js +224 -0
- package/build/cover/edit/inspector-controls.js.map +1 -0
- package/build/cover/edit/resizable-cover.js +67 -0
- package/build/cover/edit/resizable-cover.js.map +1 -0
- package/build/cover/edit/use-cover-is-dark.js +81 -0
- package/build/cover/edit/use-cover-is-dark.js.map +1 -0
- package/build/cover/edit.native.js +36 -16
- package/build/cover/edit.native.js.map +1 -1
- package/build/cover/focal-point-settings-button.native.js.map +1 -1
- package/build/cover/save.js +18 -5
- package/build/cover/save.js.map +1 -1
- package/build/cover/shared.js +15 -9
- package/build/cover/shared.js.map +1 -1
- package/build/cover/transforms.js +77 -6
- package/build/cover/transforms.js.map +1 -1
- package/build/cover/use-cover-is-dark.native.js +60 -0
- package/build/cover/use-cover-is-dark.native.js.map +1 -0
- package/build/embed/embed-preview.js +1 -1
- package/build/embed/embed-preview.js.map +1 -1
- package/build/file/edit.js +1 -1
- package/build/file/edit.js.map +1 -1
- package/build/file/edit.native.js +0 -1
- package/build/file/edit.native.js.map +1 -1
- package/build/file/save.js +9 -1
- package/build/file/save.js.map +1 -1
- package/build/gallery/edit.js +2 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.js +1 -1
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/gap-styles.js +14 -4
- package/build/gallery/gap-styles.js.map +1 -1
- package/build/gallery/index.js +1 -1
- package/build/gallery/shared.js +2 -2
- package/build/gallery/shared.js.map +1 -1
- package/build/gallery/use-get-media.js +2 -1
- package/build/gallery/use-get-media.js.map +1 -1
- package/build/gallery/use-short-code-transform.js +19 -18
- package/build/gallery/use-short-code-transform.js.map +1 -1
- package/build/gallery/v1/gallery.js +1 -1
- package/build/gallery/v1/gallery.js.map +1 -1
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/edit.js +6 -2
- package/build/heading/edit.js.map +1 -1
- package/build/heading/index.js +1 -0
- package/build/heading/index.js.map +1 -1
- package/build/heading/transforms.js +9 -4
- package/build/heading/transforms.js.map +1 -1
- package/build/image/edit.js +5 -56
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +56 -4
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +4 -14
- package/build/image/image.js.map +1 -1
- package/build/index.js +48 -14
- package/build/index.js.map +1 -1
- package/build/is-block-metadata-experimental.js +18 -0
- package/build/is-block-metadata-experimental.js.map +1 -0
- package/build/latest-posts/edit.js +30 -4
- package/build/latest-posts/edit.js.map +1 -1
- package/build/latest-posts/edit.native.js +49 -0
- package/build/latest-posts/edit.native.js.map +1 -1
- package/build/list/transforms.js +6 -0
- package/build/list/transforms.js.map +1 -1
- package/build/list/v2/edit.js +2 -1
- package/build/list/v2/edit.js.map +1 -1
- package/build/list/v2/migrate.js +1 -0
- package/build/list/v2/migrate.js.map +1 -1
- package/build/list/v2/transforms.js +46 -9
- package/build/list/v2/transforms.js.map +1 -1
- package/build/list-item/edit.js +7 -9
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/index.js +24 -0
- package/build/list-item/hooks/index.js.map +1 -1
- package/build/list-item/hooks/use-backspace.js +59 -0
- package/build/list-item/hooks/use-backspace.js.map +1 -0
- package/build/list-item/hooks/use-enter.js +6 -9
- package/build/list-item/hooks/use-enter.js.map +1 -1
- package/build/list-item/hooks/use-indent-list-item.js +33 -39
- package/build/list-item/hooks/use-indent-list-item.js.map +1 -1
- package/build/list-item/hooks/use-space.js +54 -0
- package/build/list-item/hooks/use-space.js.map +1 -0
- package/build/list-item/hooks/use-split.js +44 -0
- package/build/list-item/hooks/use-split.js.map +1 -0
- package/build/list-item/index.js +1 -0
- package/build/list-item/index.js.map +1 -1
- package/build/list-item/utils.js +1 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/media-text/edit.native.js +2 -1
- package/build/media-text/edit.native.js.map +1 -1
- package/build/media-text/media-container.native.js +2 -4
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/media-text/transforms.js +137 -8
- package/build/media-text/transforms.js.map +1 -1
- package/build/navigation/edit/index.js +91 -109
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +6 -12
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/index.js +0 -1
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/use-navigation-entities.js +3 -3
- package/build/navigation/use-navigation-entities.js.map +1 -1
- package/build/navigation/view-modal.js +25 -0
- package/build/navigation/view-modal.js.map +1 -1
- package/build/navigation-link/edit.js +60 -35
- package/build/navigation-link/edit.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 +1 -1
- package/build/navigation-link/hooks.js.map +1 -1
- package/build/navigation-submenu/edit.js +14 -14
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +1 -1
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/edit.js +1 -1
- package/build/page-list/edit.js.map +1 -1
- package/build/paragraph/edit.js +10 -0
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/use-enter.js +94 -0
- package/build/paragraph/use-enter.js.map +1 -0
- package/build/post-author/edit.js +1 -1
- package/build/post-author/edit.js.map +1 -1
- package/build/post-author-name/index.js +4 -0
- package/build/post-author-name/index.js.map +1 -1
- package/build/post-author-name/transforms.js +41 -0
- package/build/post-author-name/transforms.js.map +1 -0
- package/build/post-comment/index.js +2 -1
- package/build/post-comment/index.js.map +1 -1
- package/build/post-comments/edit.js +138 -35
- package/build/post-comments/edit.js.map +1 -1
- package/build/post-comments/index.js +3 -2
- package/build/post-comments/index.js.map +1 -1
- package/build/post-comments-count/index.js +1 -0
- package/build/post-comments-count/index.js.map +1 -1
- package/build/post-comments-form/edit.js +38 -4
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-comments-form/form.js +58 -0
- package/build/post-comments-form/form.js.map +1 -0
- package/build/post-comments-form/index.js +1 -0
- package/build/post-comments-form/index.js.map +1 -1
- package/build/post-comments-link/index.js +1 -0
- package/build/post-comments-link/index.js.map +1 -1
- package/build/post-content/edit.js +1 -1
- package/build/post-content/edit.js.map +1 -1
- package/build/post-date/edit.js +13 -7
- package/build/post-date/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +1 -1
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +1 -1
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-template/edit.js +7 -2
- package/build/post-template/edit.js.map +1 -1
- package/build/post-terms/edit.js +35 -4
- package/build/post-terms/edit.js.map +1 -1
- package/build/post-terms/hooks.js +33 -0
- package/build/post-terms/hooks.js.map +1 -0
- package/build/post-terms/index.js +20 -5
- package/build/post-terms/index.js.map +1 -1
- package/build/post-title/index.js +1 -1
- package/build/post-title/index.js.map +1 -1
- package/build/pullquote/edit.js +1 -1
- package/build/pullquote/edit.js.map +1 -1
- package/build/pullquote/edit.native.js +1 -1
- package/build/pullquote/edit.native.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +26 -17
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/parent-control.js +148 -0
- package/build/query/edit/inspector-controls/parent-control.js.map +1 -0
- package/build/query/edit/inspector-controls/sticky-control.js +41 -0
- package/build/query/edit/inspector-controls/sticky-control.js.map +1 -0
- package/build/query/index.js +2 -1
- package/build/query/index.js.map +1 -1
- package/build/query/utils.js +28 -2
- package/build/query/utils.js.map +1 -1
- package/build/query-no-results/edit.js +1 -1
- package/build/query-no-results/edit.js.map +1 -1
- package/build/query-title/index.js +1 -1
- package/build/query-title/index.js.map +1 -1
- package/build/query-title/variations.js +1 -1
- package/build/query-title/variations.js.map +1 -1
- package/build/quote/edit.js +3 -2
- package/build/quote/edit.js.map +1 -1
- package/build/quote/index.js +1 -0
- package/build/quote/index.js.map +1 -1
- package/build/quote/v2/edit.js +1 -1
- package/build/quote/v2/edit.js.map +1 -1
- package/build/search/edit.js +2 -1
- package/build/search/edit.js.map +1 -1
- package/build/search/index.js +4 -0
- package/build/search/index.js.map +1 -1
- package/build/separator/index.js +3 -0
- package/build/separator/index.js.map +1 -1
- package/build/shortcode/edit.native.js +16 -13
- package/build/shortcode/edit.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-links/edit.js +2 -2
- package/build/social-links/edit.js.map +1 -1
- package/build/table/edit.js +15 -2
- package/build/table/edit.js.map +1 -1
- package/build/table-of-contents/edit.js +145 -65
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/table-of-contents/index.js +13 -3
- package/build/table-of-contents/index.js.map +1 -1
- package/build/table-of-contents/list.js +16 -9
- package/build/table-of-contents/list.js.map +1 -1
- package/build/table-of-contents/save.js +40 -0
- package/build/table-of-contents/save.js.map +1 -0
- package/build/table-of-contents/utils.js +11 -77
- package/build/table-of-contents/utils.js.map +1 -1
- package/build/template-part/edit/index.js +7 -3
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/inner-blocks.js +3 -8
- package/build/template-part/edit/inner-blocks.js.map +1 -1
- package/build/video/edit.js +4 -8
- package/build/video/edit.js.map +1 -1
- package/build-module/audio/edit.js +5 -17
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/block/edit.js +11 -10
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/deprecated.js +175 -35
- package/build-module/button/deprecated.js.map +1 -1
- package/build-module/button/edit.js +2 -2
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/edit.native.js +7 -3
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/button/index.js +1 -0
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/save.js +2 -2
- package/build-module/button/save.js.map +1 -1
- package/build-module/categories/edit.js +1 -1
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/categories/index.js +1 -1
- package/build-module/columns/index.js +3 -1
- package/build-module/columns/index.js.map +1 -1
- package/build-module/comment-author-avatar/index.js +1 -0
- package/build-module/comment-author-avatar/index.js.map +1 -1
- package/build-module/comment-template/edit.js +1 -3
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
- package/build-module/comments/edit/comments-inspector-controls.js.map +1 -0
- package/build-module/{comments-query-loop → comments}/edit.js +2 -2
- package/build-module/comments/edit.js.map +1 -0
- package/build-module/{comments-query-loop → comments}/index.js +1 -1
- package/build-module/comments/index.js.map +1 -0
- package/build-module/{comments-query-loop → comments}/save.js +1 -1
- package/build-module/comments/save.js.map +1 -0
- package/build-module/comments-title/deprecated.js +102 -0
- package/build-module/comments-title/deprecated.js.map +1 -0
- package/build-module/comments-title/edit.js +38 -38
- package/build-module/comments-title/edit.js.map +1 -1
- package/build-module/comments-title/index.js +4 -8
- package/build-module/comments-title/index.js.map +1 -1
- package/build-module/cover/controls.native.js +2 -3
- package/build-module/cover/controls.native.js.map +1 -1
- package/build-module/cover/deprecated.js +206 -198
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +104 -0
- package/build-module/cover/edit/block-controls.js.map +1 -0
- package/build-module/cover/edit/cover-placeholder.js +38 -0
- package/build-module/cover/edit/cover-placeholder.js.map +1 -0
- package/build-module/cover/edit/index.js +317 -0
- package/build-module/cover/edit/index.js.map +1 -0
- package/build-module/cover/edit/inspector-controls.js +215 -0
- package/build-module/cover/edit/inspector-controls.js.map +1 -0
- package/build-module/cover/edit/resizable-cover.js +55 -0
- package/build-module/cover/edit/resizable-cover.js.map +1 -0
- package/build-module/cover/edit/use-cover-is-dark.js +70 -0
- package/build-module/cover/edit/use-cover-is-dark.js.map +1 -0
- package/build-module/cover/edit.native.js +35 -17
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/cover/focal-point-settings-button.native.js.map +1 -1
- package/build-module/cover/save.js +19 -6
- package/build-module/cover/save.js.map +1 -1
- package/build-module/cover/shared.js +11 -5
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/cover/transforms.js +74 -6
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/cover/use-cover-is-dark.native.js +51 -0
- package/build-module/cover/use-cover-is-dark.native.js.map +1 -0
- package/build-module/embed/embed-preview.js +2 -2
- package/build-module/embed/embed-preview.js.map +1 -1
- package/build-module/file/edit.js +2 -2
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/edit.native.js +0 -1
- package/build-module/file/edit.native.js.map +1 -1
- package/build-module/file/save.js +7 -2
- package/build-module/file/save.js.map +1 -1
- package/build-module/gallery/edit.js +2 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.js +2 -2
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/gap-styles.js +14 -4
- package/build-module/gallery/gap-styles.js.map +1 -1
- package/build-module/gallery/index.js +1 -1
- package/build-module/gallery/shared.js +2 -2
- package/build-module/gallery/shared.js.map +1 -1
- package/build-module/gallery/use-get-media.js +2 -1
- package/build-module/gallery/use-get-media.js.map +1 -1
- package/build-module/gallery/use-short-code-transform.js +19 -18
- package/build-module/gallery/use-short-code-transform.js.map +1 -1
- package/build-module/gallery/v1/gallery.js +2 -2
- package/build-module/gallery/v1/gallery.js.map +1 -1
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/edit.js +6 -2
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/heading/index.js +1 -0
- package/build-module/heading/index.js.map +1 -1
- package/build-module/heading/transforms.js +9 -4
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/image/edit.js +4 -52
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +57 -6
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +6 -16
- package/build-module/image/image.js.map +1 -1
- package/build-module/index.js +43 -12
- package/build-module/index.js.map +1 -1
- package/build-module/is-block-metadata-experimental.js +16 -0
- package/build-module/is-block-metadata-experimental.js.map +1 -0
- package/build-module/latest-posts/edit.js +29 -5
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/latest-posts/edit.native.js +51 -2
- package/build-module/latest-posts/edit.native.js.map +1 -1
- package/build-module/list/transforms.js +6 -0
- package/build-module/list/transforms.js.map +1 -1
- package/build-module/list/v2/edit.js +2 -1
- package/build-module/list/v2/edit.js.map +1 -1
- package/build-module/list/v2/migrate.js +1 -3
- package/build-module/list/v2/migrate.js.map +1 -1
- package/build-module/list/v2/transforms.js +46 -9
- package/build-module/list/v2/transforms.js.map +1 -1
- package/build-module/list-item/edit.js +8 -9
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/index.js +3 -0
- package/build-module/list-item/hooks/index.js.map +1 -1
- package/build-module/list-item/hooks/use-backspace.js +44 -0
- package/build-module/list-item/hooks/use-backspace.js.map +1 -0
- package/build-module/list-item/hooks/use-enter.js +6 -9
- package/build-module/list-item/hooks/use-enter.js.map +1 -1
- package/build-module/list-item/hooks/use-indent-list-item.js +33 -38
- package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -1
- package/build-module/list-item/hooks/use-space.js +40 -0
- package/build-module/list-item/hooks/use-space.js.map +1 -0
- package/build-module/list-item/hooks/use-split.js +33 -0
- package/build-module/list-item/hooks/use-split.js.map +1 -0
- package/build-module/list-item/index.js +1 -0
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/list-item/utils.js +1 -1
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/media-text/edit.native.js +2 -1
- package/build-module/media-text/edit.native.js.map +1 -1
- package/build-module/media-text/media-container.native.js +2 -4
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/media-text/transforms.js +137 -8
- package/build-module/media-text/transforms.js.map +1 -1
- package/build-module/navigation/edit/index.js +93 -110
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +7 -13
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/index.js +0 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/use-navigation-entities.js +1 -1
- package/build-module/navigation/use-navigation-entities.js.map +1 -1
- package/build-module/navigation/view-modal.js +24 -0
- package/build-module/navigation/view-modal.js.map +1 -1
- package/build-module/navigation-link/edit.js +60 -36
- package/build-module/navigation-link/edit.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 +14 -14
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +1 -1
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/edit.js +1 -1
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/paragraph/edit.js +9 -0
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/use-enter.js +81 -0
- package/build-module/paragraph/use-enter.js.map +1 -0
- package/build-module/post-author/edit.js +1 -1
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-author-name/index.js +3 -0
- package/build-module/post-author-name/index.js.map +1 -1
- package/build-module/post-author-name/transforms.js +32 -0
- package/build-module/post-author-name/transforms.js.map +1 -0
- package/build-module/post-comment/index.js +2 -1
- package/build-module/post-comment/index.js.map +1 -1
- package/build-module/post-comments/edit.js +139 -37
- package/build-module/post-comments/edit.js.map +1 -1
- package/build-module/post-comments/index.js +3 -2
- package/build-module/post-comments/index.js.map +1 -1
- package/build-module/post-comments-count/index.js +1 -0
- package/build-module/post-comments-count/index.js.map +1 -1
- package/build-module/post-comments-form/edit.js +38 -6
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +45 -0
- package/build-module/post-comments-form/form.js.map +1 -0
- package/build-module/post-comments-form/index.js +1 -0
- package/build-module/post-comments-form/index.js.map +1 -1
- package/build-module/post-comments-link/index.js +1 -0
- package/build-module/post-comments-link/index.js.map +1 -1
- package/build-module/post-content/edit.js +1 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-date/edit.js +15 -9
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +1 -1
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +1 -1
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-template/edit.js +7 -2
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-terms/edit.js +35 -6
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/post-terms/hooks.js +25 -0
- package/build-module/post-terms/hooks.js.map +1 -0
- package/build-module/post-terms/index.js +18 -8
- package/build-module/post-terms/index.js.map +1 -1
- package/build-module/post-title/index.js +1 -1
- package/build-module/post-title/index.js.map +1 -1
- package/build-module/pullquote/edit.js +2 -2
- package/build-module/pullquote/edit.js.map +1 -1
- package/build-module/pullquote/edit.native.js +2 -2
- package/build-module/pullquote/edit.native.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +24 -17
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/parent-control.js +135 -0
- package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -0
- package/build-module/query/edit/inspector-controls/sticky-control.js +31 -0
- package/build-module/query/edit/inspector-controls/sticky-control.js.map +1 -0
- package/build-module/query/index.js +2 -1
- package/build-module/query/index.js.map +1 -1
- package/build-module/query/utils.js +21 -0
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query-no-results/edit.js +1 -1
- package/build-module/query-no-results/edit.js.map +1 -1
- package/build-module/query-title/index.js +1 -1
- package/build-module/query-title/index.js.map +1 -1
- package/build-module/query-title/variations.js +2 -2
- package/build-module/query-title/variations.js.map +1 -1
- package/build-module/quote/edit.js +4 -3
- package/build-module/quote/edit.js.map +1 -1
- package/build-module/quote/index.js +1 -0
- package/build-module/quote/index.js.map +1 -1
- package/build-module/quote/v2/edit.js +2 -2
- package/build-module/quote/v2/edit.js.map +1 -1
- package/build-module/search/edit.js +3 -2
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/index.js +4 -0
- package/build-module/search/index.js.map +1 -1
- package/build-module/separator/index.js +3 -0
- package/build-module/separator/index.js.map +1 -1
- package/build-module/shortcode/edit.native.js +17 -13
- package/build-module/shortcode/edit.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-links/edit.js +2 -2
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/table/edit.js +17 -4
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table-of-contents/edit.js +144 -68
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/table-of-contents/index.js +12 -3
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-module/table-of-contents/list.js +18 -10
- package/build-module/table-of-contents/list.js.map +1 -1
- package/build-module/table-of-contents/save.js +28 -0
- package/build-module/table-of-contents/save.js.map +1 -0
- package/build-module/table-of-contents/utils.js +11 -73
- package/build-module/table-of-contents/utils.js.map +1 -1
- package/build-module/template-part/edit/index.js +8 -4
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/inner-blocks.js +4 -9
- package/build-module/template-part/edit/inner-blocks.js.map +1 -1
- package/build-module/video/edit.js +5 -9
- package/build-module/video/edit.js.map +1 -1
- package/build-style/comment-content/style-rtl.css +81 -0
- package/build-style/comment-content/style.css +81 -0
- package/build-style/{comments-query-loop → comments}/editor-rtl.css +0 -0
- package/build-style/{comments-query-loop → comments}/editor.css +0 -0
- package/build-style/cover/style-rtl.css +32 -27
- package/build-style/cover/style.css +32 -27
- package/build-style/editor-rtl.css +16 -10
- package/build-style/editor.css +16 -10
- package/build-style/image/editor-rtl.css +1 -1
- package/build-style/image/editor.css +1 -1
- package/build-style/latest-posts/style-rtl.css +2 -0
- package/build-style/latest-posts/style.css +4 -0
- package/build-style/navigation/style-rtl.css +3 -0
- package/build-style/navigation/style.css +3 -0
- package/build-style/post-comments/editor-rtl.css +79 -0
- package/build-style/post-comments/editor.css +79 -0
- package/build-style/post-comments/style-rtl.css +27 -3
- package/build-style/post-comments/style.css +27 -3
- package/build-style/post-comments-form/editor-rtl.css +79 -0
- package/build-style/post-comments-form/editor.css +79 -0
- package/build-style/post-comments-form/style-rtl.css +1 -3
- package/build-style/post-comments-form/style.css +1 -3
- package/build-style/separator/editor-rtl.css +1 -0
- package/build-style/separator/editor.css +1 -0
- package/build-style/site-logo/style-rtl.css +4 -0
- package/build-style/site-logo/style.css +4 -0
- package/build-style/style-rtl.css +69 -33
- package/build-style/style.css +71 -33
- package/build-style/video/editor-rtl.css +2 -5
- package/build-style/video/editor.css +2 -5
- package/build-types/table-of-contents/list.d.ts +12 -0
- package/build-types/table-of-contents/list.d.ts.map +1 -0
- package/build-types/table-of-contents/utils.d.ts +24 -0
- package/build-types/table-of-contents/utils.d.ts.map +1 -0
- package/package.json +30 -29
- package/src/audio/edit.js +6 -9
- package/src/avatar/block.json +0 -1
- package/src/avatar/index.php +2 -2
- package/src/block/edit.js +39 -42
- package/src/block/test/edit.native.js +1 -1
- package/src/button/block.json +1 -0
- package/src/button/deprecated.js +145 -0
- package/src/button/edit.js +3 -1
- package/src/button/edit.native.js +6 -3
- package/src/button/save.js +3 -1
- package/src/buttons/test/__snapshots__/edit.native.js.snap +1 -1
- package/src/buttons/test/edit.native.js +1 -1
- package/src/categories/block.json +1 -1
- package/src/categories/edit.js +1 -1
- package/src/columns/block.json +3 -1
- package/src/comment-author-avatar/block.json +1 -0
- package/src/comment-author-name/index.php +7 -5
- package/src/comment-content/index.php +25 -3
- package/src/comment-content/style.scss +5 -0
- package/src/comment-edit-link/index.php +1 -4
- package/src/comment-reply-link/index.php +1 -4
- package/src/comment-template/edit.js +1 -5
- package/src/comment-template/index.php +4 -0
- package/src/{comments-query-loop → comments}/block.json +1 -1
- package/src/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
- package/src/{comments-query-loop → comments}/edit.js +2 -1
- package/src/{comments-query-loop → comments}/editor.scss +0 -0
- package/src/{comments-query-loop → comments}/index.js +0 -0
- package/src/{comments-query-loop → comments}/save.js +1 -3
- package/src/comments-pagination/index.php +4 -0
- package/src/comments-title/block.json +0 -6
- package/src/comments-title/deprecated.js +34 -0
- package/src/comments-title/edit.js +44 -84
- package/src/comments-title/index.js +3 -1
- package/src/comments-title/index.php +51 -22
- package/src/cover/controls.native.js +1 -2
- package/src/cover/deprecated.js +230 -183
- package/src/cover/edit/block-controls.js +119 -0
- package/src/cover/edit/cover-placeholder.js +39 -0
- package/src/cover/edit/index.js +393 -0
- package/src/cover/edit/inspector-controls.js +286 -0
- package/src/cover/edit/resizable-cover.js +55 -0
- package/src/cover/edit/use-cover-is-dark.js +71 -0
- package/src/cover/edit.native.js +40 -14
- package/src/cover/editor.scss +1 -1
- package/src/cover/focal-point-settings-button.native.js +1 -1
- package/src/cover/index.php +20 -37
- package/src/cover/save.js +26 -13
- package/src/cover/shared.js +5 -3
- package/src/cover/style.native.scss +4 -0
- package/src/cover/style.scss +27 -26
- package/src/cover/test/__snapshots__/edit.native.js.snap +6 -6
- package/src/cover/test/block-controls.js +62 -0
- package/src/cover/test/transforms.js +301 -0
- package/src/cover/transforms.js +112 -7
- package/src/cover/use-cover-is-dark.native.js +51 -0
- package/src/editor.scss +3 -1
- package/src/embed/embed-preview.js +4 -2
- package/src/file/edit.js +5 -1
- package/src/file/edit.native.js +0 -1
- package/src/file/save.js +14 -2
- package/src/gallery/block.json +1 -1
- package/src/gallery/edit.js +2 -1
- package/src/gallery/gallery.js +2 -2
- package/src/gallery/gap-styles.js +21 -6
- package/src/gallery/index.php +23 -12
- package/src/gallery/shared.js +3 -2
- package/src/gallery/use-get-media.js +2 -1
- package/src/gallery/use-short-code-transform.js +19 -16
- package/src/gallery/v1/gallery.js +2 -2
- package/src/group/block.json +1 -0
- package/src/heading/block.json +1 -0
- package/src/heading/edit.js +5 -2
- package/src/heading/transforms.js +4 -3
- package/src/image/edit.js +0 -44
- package/src/image/edit.native.js +65 -4
- package/src/image/editor.scss +1 -1
- package/src/image/image.js +10 -13
- package/src/image/styles.native.scss +11 -0
- package/src/image/test/edit.native.js +7 -7
- package/src/index.js +53 -33
- package/src/is-block-metadata-experimental.js +19 -0
- package/src/latest-posts/edit.js +27 -2
- package/src/latest-posts/edit.native.js +56 -1
- package/src/latest-posts/index.php +12 -6
- package/src/latest-posts/style.scss +4 -0
- package/src/list/transforms.js +7 -0
- package/src/list/v2/edit.js +1 -0
- package/src/list/v2/migrate.js +1 -1
- package/src/list/v2/transforms.js +35 -0
- package/src/list-item/block.json +2 -1
- package/src/list-item/edit.js +17 -10
- package/src/list-item/hooks/index.js +3 -0
- package/src/list-item/hooks/use-backspace.js +52 -0
- package/src/list-item/hooks/use-enter.js +9 -16
- package/src/list-item/hooks/use-indent-list-item.js +50 -63
- package/src/list-item/hooks/use-space.js +48 -0
- package/src/list-item/hooks/use-split.js +33 -0
- package/src/list-item/utils.js +1 -1
- package/src/media-text/edit.native.js +3 -1
- package/src/media-text/media-container.native.js +2 -4
- package/src/media-text/transforms.js +154 -0
- package/src/navigation/block.json +0 -1
- package/src/navigation/edit/index.js +181 -205
- package/src/navigation/edit/inner-blocks.js +6 -15
- package/src/navigation/index.php +40 -0
- package/src/navigation/style.scss +3 -0
- package/src/navigation/use-navigation-entities.js +1 -1
- package/src/navigation/view-modal.js +32 -0
- package/src/navigation-link/edit.js +75 -48
- package/src/navigation-link/fallback-variations.js +1 -1
- package/src/navigation-link/hooks.js +2 -2
- package/src/navigation-link/test/__snapshots__/hooks.js.snap +4 -4
- package/src/navigation-link/test/edit.js +0 -20
- package/src/navigation-submenu/edit.js +13 -17
- package/src/page-list/convert-to-links-modal.js +1 -1
- package/src/page-list/edit.js +1 -4
- package/src/paragraph/edit.js +6 -0
- package/src/paragraph/use-enter.js +103 -0
- package/src/post-author/edit.js +24 -22
- package/src/post-author/index.php +4 -3
- package/src/post-author-name/block.json +1 -0
- package/src/post-author-name/index.js +2 -0
- package/src/post-author-name/index.php +1 -1
- package/src/post-author-name/transforms.js +25 -0
- package/src/post-comment/block.json +2 -1
- package/src/post-comments/block.json +3 -2
- package/src/post-comments/edit.js +206 -44
- package/src/post-comments/editor.scss +3 -0
- package/src/post-comments/index.php +3 -1
- package/src/post-comments/style.scss +30 -5
- package/src/post-comments-count/block.json +1 -0
- package/src/post-comments-form/block.json +1 -0
- package/src/post-comments-form/edit.js +52 -23
- package/src/post-comments-form/editor.scss +3 -0
- package/src/post-comments-form/form.js +50 -0
- package/src/post-comments-form/index.php +10 -3
- package/src/post-comments-form/style.scss +1 -4
- package/src/post-comments-link/block.json +1 -0
- package/src/post-content/edit.js +15 -1
- package/src/post-date/edit.js +4 -3
- package/src/post-excerpt/edit.js +14 -1
- package/src/post-featured-image/edit.js +1 -1
- package/src/post-template/edit.js +5 -0
- package/src/post-template/index.php +30 -0
- package/src/post-terms/block.json +8 -0
- package/src/post-terms/edit.js +47 -1
- package/src/post-terms/hooks.js +27 -0
- package/src/post-terms/index.js +14 -7
- package/src/post-terms/index.php +50 -2
- package/src/post-title/index.js +1 -1
- package/src/pullquote/edit.js +2 -2
- package/src/pullquote/edit.native.js +2 -2
- package/src/query/block.json +2 -1
- package/src/query/edit/inspector-controls/index.js +25 -11
- package/src/query/edit/inspector-controls/parent-control.js +133 -0
- package/src/query/edit/inspector-controls/sticky-control.js +25 -0
- package/src/query/utils.js +22 -0
- package/src/query-no-results/edit.js +1 -1
- package/src/query-pagination/index.php +0 -1
- package/src/query-title/index.js +1 -1
- package/src/query-title/variations.js +2 -2
- package/src/quote/block.json +1 -0
- package/src/quote/edit.js +5 -2
- package/src/quote/v2/edit.js +4 -2
- package/src/search/block.json +4 -0
- package/src/search/edit.js +4 -1
- package/src/search/index.php +29 -16
- package/src/separator/block.json +3 -0
- package/src/separator/editor.scss +1 -0
- package/src/shortcode/edit.native.js +29 -15
- package/src/shortcode/style.native.scss +11 -4
- package/src/shortcode/test/__snapshots__/edit.native.js.snap +9 -0
- package/src/shortcode/test/edit.native.js +58 -40
- package/src/site-logo/edit.js +1 -1
- package/src/site-logo/style.scss +6 -0
- package/src/social-links/edit.js +11 -10
- package/src/table/edit.js +19 -4
- package/src/table-of-contents/block.json +9 -2
- package/src/table-of-contents/edit.js +170 -77
- package/src/table-of-contents/index.js +2 -0
- package/src/table-of-contents/list.tsx +46 -0
- package/src/table-of-contents/save.js +25 -0
- package/src/table-of-contents/utils.ts +71 -0
- package/src/tag-cloud/block.json +1 -1
- package/src/template-part/edit/index.js +25 -15
- package/src/template-part/edit/inner-blocks.js +2 -10
- package/src/video/edit.js +7 -6
- package/src/video/editor.scss +3 -6
- package/test/babel-plugin.js +67 -0
- package/tsconfig.json +11 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/build/comments-query-loop/edit/comments-inspector-controls.js.map +0 -1
- package/build/comments-query-loop/edit.js.map +0 -1
- package/build/comments-query-loop/index.js.map +0 -1
- package/build/comments-query-loop/save.js.map +0 -1
- package/build/cover/edit.js +0 -665
- package/build/cover/edit.js.map +0 -1
- package/build/navigation-area/edit.js +0 -110
- package/build/navigation-area/edit.js.map +0 -1
- package/build/navigation-area/index.js +0 -62
- package/build/navigation-area/index.js.map +0 -1
- package/build/navigation-area/inner-blocks.js +0 -34
- package/build/navigation-area/inner-blocks.js.map +0 -1
- package/build/navigation-area/save.js +0 -18
- package/build/navigation-area/save.js.map +0 -1
- package/build/post-terms/variations.js +0 -37
- package/build/post-terms/variations.js.map +0 -1
- package/build-module/comments-query-loop/edit.js.map +0 -1
- package/build-module/comments-query-loop/index.js.map +0 -1
- package/build-module/comments-query-loop/save.js.map +0 -1
- package/build-module/cover/edit.js +0 -642
- package/build-module/cover/edit.js.map +0 -1
- package/build-module/navigation-area/edit.js +0 -94
- package/build-module/navigation-area/edit.js.map +0 -1
- package/build-module/navigation-area/index.js +0 -48
- package/build-module/navigation-area/index.js.map +0 -1
- package/build-module/navigation-area/inner-blocks.js +0 -26
- package/build-module/navigation-area/inner-blocks.js.map +0 -1
- package/build-module/navigation-area/save.js +0 -10
- package/build-module/navigation-area/save.js.map +0 -1
- package/build-module/post-terms/variations.js +0 -27
- package/build-module/post-terms/variations.js.map +0 -1
- package/src/cover/edit.js +0 -822
- package/src/navigation-area/block.json +0 -23
- package/src/navigation-area/edit.js +0 -111
- package/src/navigation-area/index.js +0 -26
- package/src/navigation-area/index.php +0 -22
- package/src/navigation-area/inner-blocks.js +0 -24
- package/src/navigation-area/save.js +0 -8
- package/src/post-terms/variations.js +0 -28
- package/src/table-of-contents/index.php +0 -346
- package/src/table-of-contents/list.js +0 -28
- package/src/table-of-contents/utils.js +0 -126
|
@@ -11,12 +11,15 @@ var _edit = _interopRequireDefault(require("./edit"));
|
|
|
11
11
|
|
|
12
12
|
var _icon = _interopRequireDefault(require("./icon"));
|
|
13
13
|
|
|
14
|
+
var _save = _interopRequireDefault(require("./save"));
|
|
15
|
+
|
|
14
16
|
/**
|
|
15
17
|
* Internal dependencies
|
|
16
18
|
*/
|
|
17
19
|
const metadata = {
|
|
18
20
|
$schema: "https://schemas.wp.org/trunk/block.json",
|
|
19
21
|
apiVersion: 2,
|
|
22
|
+
__experimental: true,
|
|
20
23
|
name: "core/table-of-contents",
|
|
21
24
|
title: "Table of Contents",
|
|
22
25
|
category: "layout",
|
|
@@ -24,15 +27,21 @@ const metadata = {
|
|
|
24
27
|
keywords: ["document outline", "summary"],
|
|
25
28
|
textdomain: "default",
|
|
26
29
|
attributes: {
|
|
30
|
+
headings: {
|
|
31
|
+
type: "array",
|
|
32
|
+
items: {
|
|
33
|
+
type: "object"
|
|
34
|
+
}
|
|
35
|
+
},
|
|
27
36
|
onlyIncludeCurrentPage: {
|
|
28
37
|
type: "boolean",
|
|
29
38
|
"default": false
|
|
30
39
|
}
|
|
31
40
|
},
|
|
32
|
-
usesContext: ["postId"],
|
|
33
41
|
supports: {
|
|
34
42
|
html: false
|
|
35
|
-
}
|
|
43
|
+
},
|
|
44
|
+
example: {}
|
|
36
45
|
};
|
|
37
46
|
exports.metadata = metadata;
|
|
38
47
|
const {
|
|
@@ -41,7 +50,8 @@ const {
|
|
|
41
50
|
exports.name = name;
|
|
42
51
|
const settings = {
|
|
43
52
|
icon: _icon.default,
|
|
44
|
-
edit: _edit.default
|
|
53
|
+
edit: _edit.default,
|
|
54
|
+
save: _save.default
|
|
45
55
|
};
|
|
46
56
|
exports.settings = settings;
|
|
47
57
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/table-of-contents/index.js"],"names":["name","metadata","settings","icon","edit"],"mappings":";;;;;;;;;AAIA;;AACA;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/table-of-contents/index.js"],"names":["name","metadata","settings","icon","edit","save"],"mappings":";;;;;;;;;AAIA;;AACA;;AACA;;AANA;AACA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,MAAM;AAAEA,EAAAA;AAAF,IAAWC,QAAjB;;AAIO,MAAMC,QAAQ,GAAG;AACvBC,EAAAA,IAAI,EAAJA,aADuB;AAEvBC,EAAAA,IAAI,EAAJA,aAFuB;AAGvBC,EAAAA,IAAI,EAAJA;AAHuB,CAAjB","sourcesContent":["/**\n * Internal dependencies\n */\nimport metadata from './block.json';\nimport edit from './edit';\nimport icon from './icon';\nimport save from './save';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n};\n"]}
|
|
@@ -7,28 +7,35 @@ exports.default = TableOfContentsList;
|
|
|
7
7
|
|
|
8
8
|
var _element = require("@wordpress/element");
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* WordPress dependencies
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Internal dependencies
|
|
16
|
+
*/
|
|
10
17
|
const ENTRY_CLASS_NAME = 'wp-block-table-of-contents__entry';
|
|
11
18
|
|
|
12
19
|
function TableOfContentsList(_ref) {
|
|
13
20
|
let {
|
|
14
21
|
nestedHeadingList
|
|
15
22
|
} = _ref;
|
|
16
|
-
return nestedHeadingList.map((
|
|
23
|
+
return (0, _element.createElement)(_element.Fragment, null, nestedHeadingList.map((node, index) => {
|
|
17
24
|
const {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
} =
|
|
21
|
-
const entry =
|
|
25
|
+
content,
|
|
26
|
+
link
|
|
27
|
+
} = node.heading;
|
|
28
|
+
const entry = link ? (0, _element.createElement)("a", {
|
|
22
29
|
className: ENTRY_CLASS_NAME,
|
|
23
|
-
href:
|
|
30
|
+
href: link
|
|
24
31
|
}, content) : (0, _element.createElement)("span", {
|
|
25
32
|
className: ENTRY_CLASS_NAME
|
|
26
33
|
}, content);
|
|
27
34
|
return (0, _element.createElement)("li", {
|
|
28
35
|
key: index
|
|
29
|
-
}, entry,
|
|
30
|
-
nestedHeadingList:
|
|
36
|
+
}, entry, node.children ? (0, _element.createElement)("ol", null, (0, _element.createElement)(TableOfContentsList, {
|
|
37
|
+
nestedHeadingList: node.children
|
|
31
38
|
})) : null);
|
|
32
|
-
});
|
|
39
|
+
}));
|
|
33
40
|
}
|
|
34
41
|
//# sourceMappingURL=list.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/table-of-contents/list.
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/table-of-contents/list.tsx"],"names":["ENTRY_CLASS_NAME","TableOfContentsList","nestedHeadingList","map","node","index","content","link","heading","entry","children"],"mappings":";;;;;;;;;AAAA;AACA;AACA;;AAGA;AACA;AACA;AAGA,MAAMA,gBAAgB,GAAG,mCAAzB;;AAEe,SAASC,mBAAT,OAIA;AAAA,MAJ8B;AAC5CC,IAAAA;AAD4C,GAI9B;AACd,SACC,qDACGA,iBAAiB,CAACC,GAAlB,CAAuB,CAAEC,IAAF,EAAQC,KAAR,KAAmB;AAC3C,UAAM;AAAEC,MAAAA,OAAF;AAAWC,MAAAA;AAAX,QAAoBH,IAAI,CAACI,OAA/B;AAEA,UAAMC,KAAK,GAAGF,IAAI,GACjB;AAAG,MAAA,SAAS,EAAGP,gBAAf;AAAkC,MAAA,IAAI,EAAGO;AAAzC,OACGD,OADH,CADiB,GAKjB;AAAM,MAAA,SAAS,EAAGN;AAAlB,OAAuCM,OAAvC,CALD;AAQA,WACC;AAAI,MAAA,GAAG,EAAGD;AAAV,OACGI,KADH,EAEGL,IAAI,CAACM,QAAL,GACD,wCACC,4BAAC,mBAAD;AACC,MAAA,iBAAiB,EAAGN,IAAI,CAACM;AAD1B,MADD,CADC,GAME,IARL,CADD;AAYA,GAvBC,CADH,CADD;AA4BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport type { WPElement } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport type { NestedHeadingData } from './utils';\n\nconst ENTRY_CLASS_NAME = 'wp-block-table-of-contents__entry';\n\nexport default function TableOfContentsList( {\n\tnestedHeadingList,\n}: {\n\tnestedHeadingList: NestedHeadingData[];\n} ): WPElement {\n\treturn (\n\t\t<>\n\t\t\t{ nestedHeadingList.map( ( node, index ) => {\n\t\t\t\tconst { content, link } = node.heading;\n\n\t\t\t\tconst entry = link ? (\n\t\t\t\t\t<a className={ ENTRY_CLASS_NAME } href={ link }>\n\t\t\t\t\t\t{ content }\n\t\t\t\t\t</a>\n\t\t\t\t) : (\n\t\t\t\t\t<span className={ ENTRY_CLASS_NAME }>{ content }</span>\n\t\t\t\t);\n\n\t\t\t\treturn (\n\t\t\t\t\t<li key={ index }>\n\t\t\t\t\t\t{ entry }\n\t\t\t\t\t\t{ node.children ? (\n\t\t\t\t\t\t\t<ol>\n\t\t\t\t\t\t\t\t<TableOfContentsList\n\t\t\t\t\t\t\t\t\tnestedHeadingList={ node.children }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t</ol>\n\t\t\t\t\t\t) : null }\n\t\t\t\t\t</li>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = save;
|
|
9
|
+
|
|
10
|
+
var _element = require("@wordpress/element");
|
|
11
|
+
|
|
12
|
+
var _blockEditor = require("@wordpress/block-editor");
|
|
13
|
+
|
|
14
|
+
var _list = _interopRequireDefault(require("./list"));
|
|
15
|
+
|
|
16
|
+
var _utils = require("./utils");
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* WordPress dependencies
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Internal dependencies
|
|
24
|
+
*/
|
|
25
|
+
function save(_ref) {
|
|
26
|
+
let {
|
|
27
|
+
attributes: {
|
|
28
|
+
headings = []
|
|
29
|
+
}
|
|
30
|
+
} = _ref;
|
|
31
|
+
|
|
32
|
+
if (headings.length === 0) {
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (0, _element.createElement)("nav", _blockEditor.useBlockProps.save(), (0, _element.createElement)("ol", null, (0, _element.createElement)(_list.default, {
|
|
37
|
+
nestedHeadingList: (0, _utils.linearToNestedHeadingList)(headings)
|
|
38
|
+
})));
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=save.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/table-of-contents/save.js"],"names":["save","attributes","headings","length","useBlockProps"],"mappings":";;;;;;;;;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;AAIe,SAASA,IAAT,OAAmD;AAAA,MAApC;AAAEC,IAAAA,UAAU,EAAE;AAAEC,MAAAA,QAAQ,GAAG;AAAb;AAAd,GAAoC;;AACjE,MAAKA,QAAQ,CAACC,MAAT,KAAoB,CAAzB,EAA6B;AAC5B,WAAO,IAAP;AACA;;AACD,SACC,mCAAUC,2BAAcJ,IAAd,EAAV,EACC,wCACC,4BAAC,aAAD;AACC,IAAA,iBAAiB,EAAG,sCAA2BE,QAA3B;AADrB,IADD,CADD,CADD;AASA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useBlockProps } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport TableOfContentsList from './list';\nimport { linearToNestedHeadingList } from './utils';\n\nexport default function save( { attributes: { headings = [] } } ) {\n\tif ( headings.length === 0 ) {\n\t\treturn null;\n\t}\n\treturn (\n\t\t<nav { ...useBlockProps.save() }>\n\t\t\t<ol>\n\t\t\t\t<TableOfContentsList\n\t\t\t\t\tnestedHeadingList={ linearToNestedHeadingList( headings ) }\n\t\t\t\t/>\n\t\t\t</ol>\n\t\t</nav>\n\t);\n}\n"]}
|
|
@@ -3,84 +3,17 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getHeadingsFromContent = getHeadingsFromContent;
|
|
7
|
-
exports.getHeadingsFromHeadingElements = getHeadingsFromHeadingElements;
|
|
8
6
|
exports.linearToNestedHeadingList = linearToNestedHeadingList;
|
|
9
7
|
|
|
10
|
-
/**
|
|
11
|
-
* @typedef WPHeadingData
|
|
12
|
-
*
|
|
13
|
-
* @property {string} anchor The anchor link to the heading, or '' if none.
|
|
14
|
-
* @property {string} content The plain text content of the heading.
|
|
15
|
-
* @property {number} level The heading level.
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Extracts text, anchor, and level from a list of heading elements.
|
|
20
|
-
*
|
|
21
|
-
* @param {NodeList} headingElements The list of heading elements.
|
|
22
|
-
*
|
|
23
|
-
* @return {WPHeadingData[]} The list of heading parameters.
|
|
24
|
-
*/
|
|
25
|
-
function getHeadingsFromHeadingElements(headingElements) {
|
|
26
|
-
return [...headingElements].map(heading => ({
|
|
27
|
-
// A little hacky, but since we know at this point that the tag will
|
|
28
|
-
// be an H1-H6, we can just grab the 2nd character of the tag name and
|
|
29
|
-
// convert it to an integer. Should be faster than conditionals.
|
|
30
|
-
level: parseInt(heading.tagName[1], 10),
|
|
31
|
-
anchor: heading.hasAttribute('id') ? `#${heading.id}` : '',
|
|
32
|
-
content: heading.textContent
|
|
33
|
-
}));
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Extracts heading data from the provided content.
|
|
37
|
-
*
|
|
38
|
-
* @param {string} content The content to extract heading data from.
|
|
39
|
-
*
|
|
40
|
-
* @return {WPHeadingData[]} The list of heading parameters.
|
|
41
|
-
*/
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
function getHeadingsFromContent(content) {
|
|
45
|
-
// Create a temporary container to put the post content into, so we can
|
|
46
|
-
// use the DOM to find all the headings.
|
|
47
|
-
const tempPostContentDOM = document.createElement('div');
|
|
48
|
-
tempPostContentDOM.innerHTML = content; // Remove template elements so that headings inside them aren't counted.
|
|
49
|
-
// This is only needed for IE11, which doesn't recognize the element and
|
|
50
|
-
// treats it like a div.
|
|
51
|
-
|
|
52
|
-
for (const template of tempPostContentDOM.querySelectorAll('template')) {
|
|
53
|
-
template.remove();
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const headingElements = tempPostContentDOM.querySelectorAll('h1:not(:empty), h2:not(:empty), h3:not(:empty), h4:not(:empty), h5:not(:empty), h6:not(:empty)');
|
|
57
|
-
return getHeadingsFromHeadingElements(headingElements);
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* @typedef WPNestedHeadingData
|
|
61
|
-
*
|
|
62
|
-
* @property {WPHeadingData} heading The heading content, anchor,
|
|
63
|
-
* and level.
|
|
64
|
-
* @property {number} index The index of this heading
|
|
65
|
-
* node in the entire nested
|
|
66
|
-
* list of heading data.
|
|
67
|
-
* @property {WPNestedHeadingData[]|null} children The sub-headings of this
|
|
68
|
-
* heading, if any.
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
8
|
/**
|
|
72
9
|
* Takes a flat list of heading parameters and nests them based on each header's
|
|
73
10
|
* immediate parent's level.
|
|
74
11
|
*
|
|
75
|
-
* @param
|
|
76
|
-
* @param {number} index The current list index.
|
|
12
|
+
* @param headingList The flat list of headings to nest.
|
|
77
13
|
*
|
|
78
|
-
* @return
|
|
14
|
+
* @return The nested list of headings.
|
|
79
15
|
*/
|
|
80
|
-
|
|
81
|
-
|
|
82
16
|
function linearToNestedHeadingList(headingList) {
|
|
83
|
-
let index = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
|
|
84
17
|
const nestedHeadingList = [];
|
|
85
18
|
headingList.forEach((heading, key) => {
|
|
86
19
|
if (heading.content === '') {
|
|
@@ -89,13 +22,15 @@ function linearToNestedHeadingList(headingList) {
|
|
|
89
22
|
|
|
90
23
|
|
|
91
24
|
if (heading.level === headingList[0].level) {
|
|
25
|
+
var _headingList;
|
|
26
|
+
|
|
92
27
|
// Check that the next iteration will return a value.
|
|
93
28
|
// If it does and the next level is greater than the current level,
|
|
94
29
|
// the next iteration becomes a child of the current iteration.
|
|
95
|
-
if (headingList[key + 1]
|
|
96
|
-
// We
|
|
97
|
-
// We then use this
|
|
98
|
-
// This prevents duplicate nodes.
|
|
30
|
+
if (((_headingList = headingList[key + 1]) === null || _headingList === void 0 ? void 0 : _headingList.level) > heading.level) {
|
|
31
|
+
// We must calculate the last index before the next iteration that
|
|
32
|
+
// has the same level (siblings). We then use this index to slice
|
|
33
|
+
// the array for use in recursion. This prevents duplicate nodes.
|
|
99
34
|
let endOfSlice = headingList.length;
|
|
100
35
|
|
|
101
36
|
for (let i = key + 1; i < headingList.length; i++) {
|
|
@@ -103,19 +38,18 @@ function linearToNestedHeadingList(headingList) {
|
|
|
103
38
|
endOfSlice = i;
|
|
104
39
|
break;
|
|
105
40
|
}
|
|
106
|
-
} // We found a child node: Push a new node onto the return array
|
|
41
|
+
} // We found a child node: Push a new node onto the return array
|
|
42
|
+
// with children.
|
|
107
43
|
|
|
108
44
|
|
|
109
45
|
nestedHeadingList.push({
|
|
110
46
|
heading,
|
|
111
|
-
|
|
112
|
-
children: linearToNestedHeadingList(headingList.slice(key + 1, endOfSlice), index + key + 1)
|
|
47
|
+
children: linearToNestedHeadingList(headingList.slice(key + 1, endOfSlice))
|
|
113
48
|
});
|
|
114
49
|
} else {
|
|
115
50
|
// No child node: Push a new node onto the return array.
|
|
116
51
|
nestedHeadingList.push({
|
|
117
52
|
heading,
|
|
118
|
-
index: index + key,
|
|
119
53
|
children: null
|
|
120
54
|
});
|
|
121
55
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/table-of-contents/utils.
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/table-of-contents/utils.ts"],"names":["linearToNestedHeadingList","headingList","nestedHeadingList","forEach","heading","key","content","level","endOfSlice","length","i","push","children","slice"],"mappings":";;;;;;;AAgBA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASA,yBAAT,CACNC,WADM,EAEgB;AACtB,QAAMC,iBAAsC,GAAG,EAA/C;AAEAD,EAAAA,WAAW,CAACE,OAAZ,CAAqB,CAAEC,OAAF,EAAWC,GAAX,KAAoB;AACxC,QAAKD,OAAO,CAACE,OAAR,KAAoB,EAAzB,EAA8B;AAC7B;AACA,KAHuC,CAKxC;;;AACA,QAAKF,OAAO,CAACG,KAAR,KAAkBN,WAAW,CAAE,CAAF,CAAX,CAAiBM,KAAxC,EAAgD;AAAA;;AAC/C;AACA;AACA;AACA,UAAK,iBAAAN,WAAW,CAAEI,GAAG,GAAG,CAAR,CAAX,8DAAwBE,KAAxB,IAAgCH,OAAO,CAACG,KAA7C,EAAqD;AACpD;AACA;AACA;AACA,YAAIC,UAAU,GAAGP,WAAW,CAACQ,MAA7B;;AACA,aAAM,IAAIC,CAAC,GAAGL,GAAG,GAAG,CAApB,EAAuBK,CAAC,GAAGT,WAAW,CAACQ,MAAvC,EAA+CC,CAAC,EAAhD,EAAqD;AACpD,cAAKT,WAAW,CAAES,CAAF,CAAX,CAAiBH,KAAjB,KAA2BH,OAAO,CAACG,KAAxC,EAAgD;AAC/CC,YAAAA,UAAU,GAAGE,CAAb;AACA;AACA;AACD,SAVmD,CAYpD;AACA;;;AACAR,QAAAA,iBAAiB,CAACS,IAAlB,CAAwB;AACvBP,UAAAA,OADuB;AAEvBQ,UAAAA,QAAQ,EAAEZ,yBAAyB,CAClCC,WAAW,CAACY,KAAZ,CAAmBR,GAAG,GAAG,CAAzB,EAA4BG,UAA5B,CADkC;AAFZ,SAAxB;AAMA,OApBD,MAoBO;AACN;AACAN,QAAAA,iBAAiB,CAACS,IAAlB,CAAwB;AACvBP,UAAAA,OADuB;AAEvBQ,UAAAA,QAAQ,EAAE;AAFa,SAAxB;AAIA;AACD;AACD,GAtCD;AAwCA,SAAOV,iBAAP;AACA","sourcesContent":["export interface HeadingData {\n\t/** The plain text content of the heading. */\n\tcontent: string;\n\t/** The heading level. */\n\tlevel: number;\n\t/** Link to the heading. */\n\tlink: string;\n}\n\nexport interface NestedHeadingData {\n\t/** The heading content, level, and link. */\n\theading: HeadingData;\n\t/** The sub-headings of this heading, if any. */\n\tchildren: NestedHeadingData[] | null;\n}\n\n/**\n * Takes a flat list of heading parameters and nests them based on each header's\n * immediate parent's level.\n *\n * @param headingList The flat list of headings to nest.\n *\n * @return The nested list of headings.\n */\nexport function linearToNestedHeadingList(\n\theadingList: HeadingData[]\n): NestedHeadingData[] {\n\tconst nestedHeadingList: NestedHeadingData[] = [];\n\n\theadingList.forEach( ( heading, key ) => {\n\t\tif ( heading.content === '' ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Make sure we are only working with the same level as the first iteration in our set.\n\t\tif ( heading.level === headingList[ 0 ].level ) {\n\t\t\t// Check that the next iteration will return a value.\n\t\t\t// If it does and the next level is greater than the current level,\n\t\t\t// the next iteration becomes a child of the current iteration.\n\t\t\tif ( headingList[ key + 1 ]?.level > heading.level ) {\n\t\t\t\t// We must calculate the last index before the next iteration that\n\t\t\t\t// has the same level (siblings). We then use this index to slice\n\t\t\t\t// the array for use in recursion. This prevents duplicate nodes.\n\t\t\t\tlet endOfSlice = headingList.length;\n\t\t\t\tfor ( let i = key + 1; i < headingList.length; i++ ) {\n\t\t\t\t\tif ( headingList[ i ].level === heading.level ) {\n\t\t\t\t\t\tendOfSlice = i;\n\t\t\t\t\t\tbreak;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// We found a child node: Push a new node onto the return array\n\t\t\t\t// with children.\n\t\t\t\tnestedHeadingList.push( {\n\t\t\t\t\theading,\n\t\t\t\t\tchildren: linearToNestedHeadingList(\n\t\t\t\t\t\theadingList.slice( key + 1, endOfSlice )\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\t// No child node: Push a new node onto the return array.\n\t\t\t\tnestedHeadingList.push( {\n\t\t\t\t\theading,\n\t\t\t\t\tchildren: null,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t} );\n\n\treturn nestedHeadingList;\n}\n"]}
|
|
@@ -94,7 +94,12 @@ function TemplatePartEdit(_ref) {
|
|
|
94
94
|
const blockPatterns = (0, _hooks.useAlternativeBlockPatterns)(area, clientId);
|
|
95
95
|
const hasReplacements = !!templateParts.length || !!blockPatterns.length;
|
|
96
96
|
const areaObject = (0, _hooks.useTemplatePartArea)(area);
|
|
97
|
-
const
|
|
97
|
+
const hasBlockOverlay = (0, _blockEditor.__experimentalUseBlockOverlayActive)(clientId);
|
|
98
|
+
const blockProps = (0, _blockEditor.useBlockProps)({
|
|
99
|
+
className: hasBlockOverlay ? 'block-editor-block-content-overlay' : undefined
|
|
100
|
+
}, {
|
|
101
|
+
__unstableIsDisabled: hasBlockOverlay
|
|
102
|
+
});
|
|
98
103
|
const isPlaceholder = !slug;
|
|
99
104
|
const isEntityAvailable = !isPlaceholder && !isMissing && isResolved;
|
|
100
105
|
const TagName = tagName || areaObject.tagName; // We don't want to render a missing state if we have any inner blocks.
|
|
@@ -122,12 +127,11 @@ function TemplatePartEdit(_ref) {
|
|
|
122
127
|
clientId: clientId,
|
|
123
128
|
setAttributes: setAttributes,
|
|
124
129
|
onOpenSelectionModal: () => setIsTemplatePartSelectionOpen(true)
|
|
125
|
-
})), isEntityAvailable && hasReplacements && (0, _element.createElement)(_blockEditor.BlockControls, null, (0, _element.createElement)(_components.ToolbarGroup, {
|
|
130
|
+
})), isEntityAvailable && hasReplacements && (area === 'header' || area === 'footer') && (0, _element.createElement)(_blockEditor.BlockControls, null, (0, _element.createElement)(_components.ToolbarGroup, {
|
|
126
131
|
className: "wp-block-template-part__block-control-group"
|
|
127
132
|
}, (0, _element.createElement)(_components.ToolbarButton, {
|
|
128
133
|
onClick: () => setIsTemplatePartSelectionOpen(true)
|
|
129
134
|
}, (0, _i18n.__)('Replace')))), isEntityAvailable && (0, _element.createElement)(_innerBlocks.default, {
|
|
130
|
-
clientId: clientId,
|
|
131
135
|
tagName: TagName,
|
|
132
136
|
blockProps: blockProps,
|
|
133
137
|
postId: templatePartId,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/index.js"],"names":["TemplatePartEdit","attributes","setAttributes","clientId","slug","theme","tagName","layout","templatePartId","hasAlreadyRendered","RecursionProvider","isTemplatePartSelectionOpen","setIsTemplatePartSelectionOpen","isResolved","innerBlocks","isMissing","area","select","getEditedEntityRecord","hasFinishedResolution","coreStore","getBlocks","blockEditorStore","getEntityArgs","entityRecord","_area","hasResolvedEntity","templateParts","blockPatterns","hasReplacements","length","areaObject","bl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AI,aAAJ,CAFO,EAGPoB,UAAU,CAACK,KAAX,CAAiBC,WAAjB,EAHO,CAFT;AAOC,IAAA,UAAU,EAAG,cAAI,QAAJ,CAPd;AAQC,IAAA,cAAc,EAAG,MAChBzB,8BAA8B,CAAE,KAAF;AAThC,KAYC,4BAAC,uBAAD;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"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/index.js"],"names":["TemplatePartEdit","attributes","setAttributes","clientId","slug","theme","tagName","layout","templatePartId","hasAlreadyRendered","RecursionProvider","isTemplatePartSelectionOpen","setIsTemplatePartSelectionOpen","isResolved","innerBlocks","isMissing","area","select","getEditedEntityRecord","hasFinishedResolution","coreStore","getBlocks","blockEditorStore","getEntityArgs","entityRecord","_area","hasResolvedEntity","templateParts","blockPatterns","hasReplacements","length","areaObject","hasBlockOverlay","blockProps","className","undefined","__unstableIsDisabled","isPlaceholder","isEntityAvailable","TagName","label","toLowerCase"],"mappings":";;;;;;;;;AAyBA;;AAtBA;;AAKA;;AACA;;AAQA;;AAMA;;AACA;;AAMA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAnCA;AACA;AACA;;AAGA;AACA;AACA;;AAoBA;AACA;AACA;AAYe,SAASA,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,GAAG,gDAAsBH,KAAtB,EAA6BD,IAA7B,CAAvB;AACA,QAAM,CAAEK,kBAAF,EAAsBC,iBAAtB,IAA4C,sDACjDF,cADiD,CAAlD;AAGA,QAAM,CACLG,2BADK,EAELC,8BAFK,IAGF,uBAAU,KAAV,CAHJ,CANG,CAWH;AACA;AACA;;AACA,QAAM;AAAEC,IAAAA,UAAF;AAAcC,IAAAA,WAAd;AAA2BC,IAAAA,SAA3B;AAAsCC,IAAAA;AAAtC,MAA+C,qBAClDC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA,qBAAF;AAAyBC,MAAAA;AAAzB,QAAmDF,MAAM,CA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AAS,EAAC;AAAxB,KACC,4BAAC,yBAAD;AACC,IAAA,OAAO,EAAG,MACTJ,8BAA8B,CAAE,IAAF;AAFhC,KAKG,cAAI,SAAJ,CALH,CADD,CADD,CAxBH,EAoCG0B,iBAAiB,IAClB,4BAAC,oBAAD;AACC,IAAA,OAAO,EAAGC,OADX;AAEC,IAAA,UAAU,EAAGN,UAFd;AAGC,IAAA,MAAM,EAAGzB,cAHV;AAIC,IAAA,cAAc,EAAGM,WAAW,CAACgB,MAAZ,GAAqB,CAJvC;AAKC,IAAA,MAAM,EAAGvB;AALV,IArCF,EA6CG,CAAE8B,aAAF,IAAmB,CAAExB,UAArB,IACD,4BAAC,OAAD,EAAcoB,UAAd,EACC,4BAAC,mBAAD,OADD,CA9CF,EAkDGtB,2BAA2B,IAC5B,4BAAC,iBAAD;AACC,IAAA,SAAS,EAAC,6CADX;AAEC,IAAA,KAAK,EAAG,oBACP;AACA,kBAAI,aAAJ,CAFO,EAGPoB,UAAU,CAACS,KAAX,CAAiBC,WAAjB,EAHO,CAFT;AAOC,IAAA,UAAU,EAAG,cAAI,QAAJ,CAPd;AAQC,IAAA,cAAc,EAAG,MAChB7B,8BAA8B,CAAE,KAAF;AAThC,KAYC,4BAAC,uBAAD;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,CAnDF,CADD;AA6EA","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\t__experimentalUseBlockOverlayActive as useBlockOverlayActive,\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 hasBlockOverlay = useBlockOverlayActive( clientId );\n\tconst blockProps = useBlockProps(\n\t\t{\n\t\t\tclassName: hasBlockOverlay\n\t\t\t\t? 'block-editor-block-content-overlay'\n\t\t\t\t: undefined,\n\t\t},\n\t\t{ __unstableIsDisabled: hasBlockOverlay }\n\t);\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 &&\n\t\t\t\thasReplacements &&\n\t\t\t\t( area === 'header' || area === 'footer' ) && (\n\t\t\t\t\t<BlockControls>\n\t\t\t\t\t\t<ToolbarGroup className=\"wp-block-template-part__block-control-group\">\n\t\t\t\t\t\t\t<ToolbarButton\n\t\t\t\t\t\t\t\tonClick={ () =>\n\t\t\t\t\t\t\t\t\tsetIsTemplatePartSelectionOpen( true )\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t{ __( 'Replace' ) }\n\t\t\t\t\t\t\t</ToolbarButton>\n\t\t\t\t\t\t</ToolbarGroup>\n\t\t\t\t\t</BlockControls>\n\t\t\t\t) }\n\t\t\t{ isEntityAvailable && (\n\t\t\t\t<TemplatePartInnerBlocks\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"]}
|
|
@@ -21,9 +21,8 @@ function TemplatePartInnerBlocks(_ref) {
|
|
|
21
21
|
postId: id,
|
|
22
22
|
hasInnerBlocks,
|
|
23
23
|
layout,
|
|
24
|
-
tagName,
|
|
25
|
-
blockProps
|
|
26
|
-
clientId
|
|
24
|
+
tagName: TagName,
|
|
25
|
+
blockProps
|
|
27
26
|
} = _ref;
|
|
28
27
|
const themeSupportsLayout = (0, _data.useSelect)(select => {
|
|
29
28
|
var _getSettings;
|
|
@@ -45,10 +44,6 @@ function TemplatePartInnerBlocks(_ref) {
|
|
|
45
44
|
renderAppender: hasInnerBlocks ? undefined : _blockEditor.InnerBlocks.ButtonBlockAppender,
|
|
46
45
|
__experimentalLayout: themeSupportsLayout ? usedLayout : undefined
|
|
47
46
|
});
|
|
48
|
-
return (0, _element.createElement)(
|
|
49
|
-
clientId: clientId,
|
|
50
|
-
tagName: tagName,
|
|
51
|
-
wrapperProps: innerBlocksProps
|
|
52
|
-
});
|
|
47
|
+
return (0, _element.createElement)(TagName, innerBlocksProps);
|
|
53
48
|
}
|
|
54
49
|
//# sourceMappingURL=inner-blocks.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/inner-blocks.js"],"names":["TemplatePartInnerBlocks","postId","id","hasInnerBlocks","layout","tagName","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/template-part/edit/inner-blocks.js"],"names":["TemplatePartInnerBlocks","postId","id","hasInnerBlocks","layout","tagName","TagName","blockProps","themeSupportsLayout","select","getSettings","blockEditorStore","supportsLayout","defaultLayout","usedLayout","inherit","blocks","onInput","onChange","innerBlocksProps","value","renderAppender","undefined","InnerBlocks","ButtonBlockAppender","__experimentalLayout"],"mappings":";;;;;;;;;AAGA;;AACA;;AAMA;;AAVA;AACA;AACA;AAUe,SAASA,uBAAT,OAMX;AAAA,MAN6C;AAChDC,IAAAA,MAAM,EAAEC,EADwC;AAEhDC,IAAAA,cAFgD;AAGhDC,IAAAA,MAHgD;AAIhDC,IAAAA,OAAO,EAAEC,OAJuC;AAKhDC,IAAAA;AALgD,GAM7C;AACH,QAAMC,mBAAmB,GAAG,qBAAaC,MAAF,IAAc;AAAA;;AACpD,UAAM;AAAEC,MAAAA;AAAF,QAAkBD,MAAM,CAAEE,kBAAF,CAA9B;AACA,2BAAOD,WAAW,EAAlB,iDAAO,aAAeE,cAAtB;AACA,GAH2B,EAGzB,EAHyB,CAA5B;AAIA,QAAMC,aAAa,GAAG,6BAAY,QAAZ,KAA0B,EAAhD;AACA,QAAMC,UAAU,GAAG,CAAC,CAAEV,MAAH,IAAaA,MAAM,CAACW,OAApB,GAA8BF,aAA9B,GAA8CT,MAAjE;AAEA,QAAM,CAAEY,MAAF,EAAUC,OAAV,EAAmBC,QAAnB,IAAgC,oCACrC,UADqC,EAErC,kBAFqC,EAGrC;AAAEhB,IAAAA;AAAF,GAHqC,CAAtC;AAMA,QAAMiB,gBAAgB,GAAG,sCAAqBZ,UAArB,EAAiC;AACzDa,IAAAA,KAAK,EAAEJ,MADkD;AAEzDC,IAAAA,OAFyD;AAGzDC,IAAAA,QAHyD;AAIzDG,IAAAA,cAAc,EAAElB,cAAc,GAC3BmB,SAD2B,GAE3BC,yBAAYC,mBAN0C;AAOzDC,IAAAA,oBAAoB,EAAEjB,mBAAmB,GAAGM,UAAH,GAAgBQ;AAPA,GAAjC,CAAzB;AAUA,SAAO,4BAAC,OAAD,EAAcH,gBAAd,CAAP;AACA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityBlockEditor } from '@wordpress/core-data';\nimport {\n\tInnerBlocks,\n\tuseInnerBlocksProps,\n\tuseSetting,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\nexport default function TemplatePartInnerBlocks( {\n\tpostId: id,\n\thasInnerBlocks,\n\tlayout,\n\ttagName: TagName,\n\tblockProps,\n} ) {\n\tconst themeSupportsLayout = useSelect( ( select ) => {\n\t\tconst { getSettings } = select( blockEditorStore );\n\t\treturn getSettings()?.supportsLayout;\n\t}, [] );\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = !! layout && layout.inherit ? defaultLayout : layout;\n\n\tconst [ blocks, onInput, onChange ] = useEntityBlockEditor(\n\t\t'postType',\n\t\t'wp_template_part',\n\t\t{ id }\n\t);\n\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tvalue: blocks,\n\t\tonInput,\n\t\tonChange,\n\t\trenderAppender: hasInnerBlocks\n\t\t\t? undefined\n\t\t\t: InnerBlocks.ButtonBlockAppender,\n\t\t__experimentalLayout: themeSupportsLayout ? usedLayout : undefined,\n\t} );\n\n\treturn <TagName { ...innerBlocksProps } />;\n}\n"]}
|
package/build/video/edit.js
CHANGED
|
@@ -72,7 +72,7 @@ function VideoEdit(_ref) {
|
|
|
72
72
|
tracks
|
|
73
73
|
} = attributes;
|
|
74
74
|
const isTemporaryVideo = !id && (0, _blob.isBlobURL)(src);
|
|
75
|
-
const mediaUpload = (0, _data.useSelect)(select => select(_blockEditor.store).getSettings().mediaUpload);
|
|
75
|
+
const mediaUpload = (0, _data.useSelect)(select => select(_blockEditor.store).getSettings().mediaUpload, []);
|
|
76
76
|
(0, _element.useEffect)(() => {
|
|
77
77
|
if (!id && (0, _blob.isBlobURL)(src)) {
|
|
78
78
|
const file = (0, _blob.getBlobByURL)(src);
|
|
@@ -81,12 +81,8 @@ function VideoEdit(_ref) {
|
|
|
81
81
|
mediaUpload({
|
|
82
82
|
filesList: [file],
|
|
83
83
|
onFileChange: _ref2 => {
|
|
84
|
-
let [
|
|
85
|
-
|
|
86
|
-
}] = _ref2;
|
|
87
|
-
setAttributes({
|
|
88
|
-
src: url
|
|
89
|
-
});
|
|
84
|
+
let [media] = _ref2;
|
|
85
|
+
return onSelectVideo(media);
|
|
90
86
|
},
|
|
91
87
|
onError: message => {
|
|
92
88
|
noticeOperations.createErrorNotice(message);
|
|
@@ -258,7 +254,7 @@ function VideoEdit(_ref) {
|
|
|
258
254
|
caption: value
|
|
259
255
|
}),
|
|
260
256
|
inlineToolbar: true,
|
|
261
|
-
__unstableOnSplitAtEnd: () => insertBlocksAfter((0, _blocks.createBlock)(
|
|
257
|
+
__unstableOnSplitAtEnd: () => insertBlocksAfter((0, _blocks.createBlock)((0, _blocks.getDefaultBlockName)()))
|
|
262
258
|
})));
|
|
263
259
|
}
|
|
264
260
|
|
package/build/video/edit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/video/edit.js"],"names":["ALLOWED_MEDIA_TYPES","VIDEO_POSTER_ALLOWED_MEDIA_TYPES","VideoEdit","isSelected","noticeUI","attributes","className","setAttributes","insertBlocksAfter","onReplace","noticeOperations","instanceId","videoPlayer","posterImageButton","id","caption","controls","poster","src","tracks","isTemporaryVideo","mediaUpload","select","blockEditorStore","getSettings","file","filesList","onFileChange","url","onError","message","createErrorNotice","allowedTypes","current","load","onSelectVideo","media","undefined","image","icon","onSelectURL","newSrc","embedBlock","onUploadError","removeAllNotices","classes","blockProps","onSelectPoster","onRemovePoster","focus","videoPosterDescription","newTracks","open","RichText","isEmpty","value"],"mappings":";;;;;;;;;AA6BA;;AA1BA;;AAKA;;AACA;;AAQA;;AAaA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA1CA;AACA;AACA;;AAGA;AACA;AACA;;AA6BA;AACA;AACA;AAMA,MAAMA,mBAAmB,GAAG,CAAE,OAAF,CAA5B;AACA,MAAMC,gCAAgC,GAAG,CAAE,OAAF,CAAzC;;AAEA,SAASC,SAAT,OASI;AAAA,MATgB;AACnBC,IAAAA,UADmB;AAEnBC,IAAAA,QAFmB;AAGnBC,IAAAA,UAHmB;AAInBC,IAAAA,SAJmB;AAKnBC,IAAAA,aALmB;AAMnBC,IAAAA,iBANmB;AAOnBC,IAAAA,SAPmB;AAQnBC,IAAAA;AARmB,GAShB;AACH,QAAMC,UAAU,GAAG,4BAAeT,SAAf,CAAnB;AACA,QAAMU,WAAW,GAAG,sBAApB;AACA,QAAMC,iBAAiB,GAAG,sBAA1B;AACA,QAAM;AAAEC,IAAAA,EAAF;AAAMC,IAAAA,OAAN;AAAeC,IAAAA,QAAf;AAAyBC,IAAAA,MAAzB;AAAiCC,IAAAA,GAAjC;AAAsCC,IAAAA;AAAtC,MAAiDd,UAAvD;AACA,QAAMe,gBAAgB,GAAG,CAAEN,EAAF,IAAQ,qBAAWI,GAAX,CAAjC;AACA,QAAMG,WAAW,GAAG,qBACjBC,MA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,UAAnC,KACD,4BAAC,qBAAD;AACC,IAAA,OAAO,EAAC,YADT;AAEC,kBAAa,cAAI,oBAAJ,CAFd;AAGC,IAAA,WAAW,EAAG,cAAI,aAAJ,CAHf;AAIC,IAAA,KAAK,EAAGY,OAJT;AAKC,IAAA,QAAQ,EAAKwC,KAAF,IACVhD,aAAa,CAAE;AAAEQ,MAAAA,OAAO,EAAEwC;AAAX,KAAF,CANf;AAQC,IAAA,aAAa,MARd;AASC,IAAA,sBAAsB,EAAG,MACxB/C,iBAAiB,CAAE,yBAAa,gBAAb,CAAF;AAVnB,IAlBF,CA7ED,CADD;AAiHA;;eAEc,6BAAaN,SAAb,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL } from '@wordpress/blob';\nimport {\n\tBaseControl,\n\tButton,\n\tDisabled,\n\tPanelBody,\n\tSpinner,\n\twithNotices,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadCheck,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { video as icon } from '@wordpress/icons';\nimport { createBlock } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { createUpgradedEmbedBlock } from '../embed/util';\nimport VideoCommonSettings from './edit-common-settings';\nimport TracksEditor from './tracks-editor';\nimport Tracks from './tracks';\n\nconst ALLOWED_MEDIA_TYPES = [ 'video' ];\nconst VIDEO_POSTER_ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nfunction VideoEdit( {\n\tisSelected,\n\tnoticeUI,\n\tattributes,\n\tclassName,\n\tsetAttributes,\n\tinsertBlocksAfter,\n\tonReplace,\n\tnoticeOperations,\n} ) {\n\tconst instanceId = useInstanceId( VideoEdit );\n\tconst videoPlayer = useRef();\n\tconst posterImageButton = useRef();\n\tconst { id, caption, controls, poster, src, tracks } = attributes;\n\tconst isTemporaryVideo = ! id && isBlobURL( src );\n\tconst mediaUpload = useSelect(\n\t\t( select ) => select( blockEditorStore ).getSettings().mediaUpload\n\t);\n\n\tuseEffect( () => {\n\t\tif ( ! id && isBlobURL( src ) ) {\n\t\t\tconst file = getBlobByURL( src );\n\t\t\tif ( file ) {\n\t\t\t\tmediaUpload( {\n\t\t\t\t\tfilesList: [ file ],\n\t\t\t\t\tonFileChange: ( [ { url } ] ) => {\n\t\t\t\t\t\tsetAttributes( { src: url } );\n\t\t\t\t\t},\n\t\t\t\t\tonError: ( message ) => {\n\t\t\t\t\t\tnoticeOperations.createErrorNotice( message );\n\t\t\t\t\t},\n\t\t\t\t\tallowedTypes: ALLOWED_MEDIA_TYPES,\n\t\t\t\t} );\n\t\t\t}\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t// Placeholder may be rendered.\n\t\tif ( videoPlayer.current ) {\n\t\t\tvideoPlayer.current.load();\n\t\t}\n\t}, [ poster ] );\n\n\tfunction onSelectVideo( media ) {\n\t\tif ( ! media || ! media.url ) {\n\t\t\t// In this case there was an error\n\t\t\t// previous attributes should be removed\n\t\t\t// because they may be temporary blob urls.\n\t\t\tsetAttributes( {\n\t\t\t\tsrc: undefined,\n\t\t\t\tid: undefined,\n\t\t\t\tposter: undefined,\n\t\t\t} );\n\t\t\treturn;\n\t\t}\n\n\t\t// Sets the block's attribute and updates the edit component from the\n\t\t// selected media.\n\t\tsetAttributes( {\n\t\t\tsrc: media.url,\n\t\t\tid: media.id,\n\t\t\tposter:\n\t\t\t\tmedia.image?.src !== media.icon ? media.image?.src : undefined,\n\t\t} );\n\t}\n\n\tfunction onSelectURL( newSrc ) {\n\t\tif ( newSrc !== src ) {\n\t\t\t// Check if there's an embed block that handles this URL.\n\t\t\tconst embedBlock = createUpgradedEmbedBlock( {\n\t\t\t\tattributes: { url: newSrc },\n\t\t\t} );\n\t\t\tif ( undefined !== embedBlock ) {\n\t\t\t\tonReplace( embedBlock );\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tsetAttributes( { src: newSrc, id: undefined, poster: undefined } );\n\t\t}\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tnoticeOperations.removeAllNotices();\n\t\tnoticeOperations.createErrorNotice( message );\n\t}\n\n\tconst classes = classnames( className, {\n\t\t'is-transient': isTemporaryVideo,\n\t} );\n\n\tconst blockProps = useBlockProps( {\n\t\tclassName: classes,\n\t} );\n\n\tif ( ! src ) {\n\t\treturn (\n\t\t\t<div { ...blockProps }>\n\t\t\t\t<MediaPlaceholder\n\t\t\t\t\ticon={ <BlockIcon icon={ icon } /> }\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\tvalue={ attributes }\n\t\t\t\t\tnotices={ noticeUI }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</div>\n\t\t);\n\t}\n\n\tfunction onSelectPoster( image ) {\n\t\tsetAttributes( { poster: image.url } );\n\t}\n\n\tfunction onRemovePoster() {\n\t\tsetAttributes( { poster: undefined } );\n\n\t\t// Move focus back to the Media Upload button.\n\t\tposterImageButton.current.focus();\n\t}\n\n\tconst videoPosterDescription = `video-block__poster-image-description-${ instanceId }`;\n\n\treturn (\n\t\t<>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<TracksEditor\n\t\t\t\t\ttracks={ tracks }\n\t\t\t\t\tonChange={ ( newTracks ) => {\n\t\t\t\t\t\tsetAttributes( { tracks: newTracks } );\n\t\t\t\t\t} }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<BlockControls group=\"other\">\n\t\t\t\t<MediaReplaceFlow\n\t\t\t\t\tmediaId={ id }\n\t\t\t\t\tmediaURL={ src }\n\t\t\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\t\t\taccept=\"video/*\"\n\t\t\t\t\tonSelect={ onSelectVideo }\n\t\t\t\t\tonSelectURL={ onSelectURL }\n\t\t\t\t\tonError={ onUploadError }\n\t\t\t\t/>\n\t\t\t</BlockControls>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t<VideoCommonSettings\n\t\t\t\t\t\tsetAttributes={ setAttributes }\n\t\t\t\t\t\tattributes={ attributes }\n\t\t\t\t\t/>\n\t\t\t\t\t<MediaUploadCheck>\n\t\t\t\t\t\t<BaseControl className=\"editor-video-poster-control\">\n\t\t\t\t\t\t\t<BaseControl.VisualLabel>\n\t\t\t\t\t\t\t\t{ __( 'Poster image' ) }\n\t\t\t\t\t\t\t</BaseControl.VisualLabel>\n\t\t\t\t\t\t\t<MediaUpload\n\t\t\t\t\t\t\t\ttitle={ __( 'Select poster image' ) }\n\t\t\t\t\t\t\t\tonSelect={ onSelectPoster }\n\t\t\t\t\t\t\t\tallowedTypes={\n\t\t\t\t\t\t\t\t\tVIDEO_POSTER_ALLOWED_MEDIA_TYPES\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\trender={ ( { open } ) => (\n\t\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\t\tvariant=\"primary\"\n\t\t\t\t\t\t\t\t\t\tonClick={ open }\n\t\t\t\t\t\t\t\t\t\tref={ posterImageButton }\n\t\t\t\t\t\t\t\t\t\taria-describedby={\n\t\t\t\t\t\t\t\t\t\t\tvideoPosterDescription\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t{ ! poster\n\t\t\t\t\t\t\t\t\t\t\t? __( 'Select' )\n\t\t\t\t\t\t\t\t\t\t\t: __( 'Replace' ) }\n\t\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t<p id={ videoPosterDescription } hidden>\n\t\t\t\t\t\t\t\t{ poster\n\t\t\t\t\t\t\t\t\t? sprintf(\n\t\t\t\t\t\t\t\t\t\t\t/* translators: %s: poster image URL. */\n\t\t\t\t\t\t\t\t\t\t\t__(\n\t\t\t\t\t\t\t\t\t\t\t\t'The current poster image url is %s'\n\t\t\t\t\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t\t\t\t\tposter\n\t\t\t\t\t\t\t\t\t )\n\t\t\t\t\t\t\t\t\t: __(\n\t\t\t\t\t\t\t\t\t\t\t'There is no poster image currently selected'\n\t\t\t\t\t\t\t\t\t ) }\n\t\t\t\t\t\t\t</p>\n\t\t\t\t\t\t\t{ !! poster && (\n\t\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\t\tonClick={ onRemovePoster }\n\t\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t{ __( 'Remove' ) }\n\t\t\t\t\t\t\t\t</Button>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</BaseControl>\n\t\t\t\t\t</MediaUploadCheck>\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t<figure { ...blockProps }>\n\t\t\t\t{ /*\n\t\t\t\t\tDisable the video tag if the block is not selected\n\t\t\t\t\tso the user clicking on it won't play the\n\t\t\t\t\tvideo when the controls are enabled.\n\t\t\t\t*/ }\n\t\t\t\t<Disabled isDisabled={ ! isSelected }>\n\t\t\t\t\t<video\n\t\t\t\t\t\tcontrols={ controls }\n\t\t\t\t\t\tposter={ poster }\n\t\t\t\t\t\tsrc={ src }\n\t\t\t\t\t\tref={ videoPlayer }\n\t\t\t\t\t>\n\t\t\t\t\t\t<Tracks tracks={ tracks } />\n\t\t\t\t\t</video>\n\t\t\t\t</Disabled>\n\t\t\t\t{ isTemporaryVideo && <Spinner /> }\n\t\t\t\t{ ( ! RichText.isEmpty( caption ) || isSelected ) && (\n\t\t\t\t\t<RichText\n\t\t\t\t\t\ttagName=\"figcaption\"\n\t\t\t\t\t\taria-label={ __( 'Video caption text' ) }\n\t\t\t\t\t\tplaceholder={ __( 'Add caption' ) }\n\t\t\t\t\t\tvalue={ caption }\n\t\t\t\t\t\tonChange={ ( value ) =>\n\t\t\t\t\t\t\tsetAttributes( { caption: value } )\n\t\t\t\t\t\t}\n\t\t\t\t\t\tinlineToolbar\n\t\t\t\t\t\t__unstableOnSplitAtEnd={ () =>\n\t\t\t\t\t\t\tinsertBlocksAfter( createBlock( 'core/paragraph' ) )\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</figure>\n\t\t</>\n\t);\n}\n\nexport default withNotices( VideoEdit );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/video/edit.js"],"names":["ALLOWED_MEDIA_TYPES","VIDEO_POSTER_ALLOWED_MEDIA_TYPES","VideoEdit","isSelected","noticeUI","attributes","className","setAttributes","insertBlocksAfter","onReplace","noticeOperations","instanceId","videoPlayer","posterImageButton","id","caption","controls","poster","src","tracks","isTemporaryVideo","mediaUpload","select","blockEditorStore","getSettings","file","filesList","onFileChange","media","onSelectVideo","onError","message","createErrorNotice","allowedTypes","current","load","url","undefined","image","icon","onSelectURL","newSrc","embedBlock","onUploadError","removeAllNotices","classes","blockProps","onSelectPoster","onRemovePoster","focus","videoPosterDescription","newTracks","open","RichText","isEmpty","value"],"mappings":";;;;;;;;;AA6BA;;AA1BA;;AAKA;;AACA;;AAQA;;AAaA;;AACA;;AACA;;AACA;;AACA;;AAKA;;AACA;;AACA;;AACA;;AA1CA;AACA;AACA;;AAGA;AACA;AACA;;AA6BA;AACA;AACA;AAMA,MAAMA,mBAAmB,GAAG,CAAE,OAAF,CAA5B;AACA,MAAMC,gCAAgC,GA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CAzBD,EAsCG,CAAC,CAAEA,MAAH,IACD,4BAAC,kBAAD;AACC,IAAA,OAAO,EAAG+B,cADX;AAEC,IAAA,OAAO,EAAC;AAFT,KAIG,cAAI,QAAJ,CAJH,CAvCF,CADD,CALD,CADD,CApBD,EA6EC,sCAAaF,UAAb,EAMC,4BAAC,oBAAD;AAAU,IAAA,UAAU,EAAG,CAAE3C;AAAzB,KACC;AACC,IAAA,QAAQ,EAAGa,QADZ;AAEC,IAAA,MAAM,EAAGC,MAFV;AAGC,IAAA,GAAG,EAAGC,GAHP;AAIC,IAAA,GAAG,EAAGN;AAJP,KAMC,4BAAC,eAAD;AAAQ,IAAA,MAAM,EAAGO;AAAjB,IAND,CADD,CAND,EAgBGC,gBAAgB,IAAI,4BAAC,mBAAD,OAhBvB,EAiBG,CAAE,CAAEiC,sBAASC,OAAT,CAAkBvC,OAAlB,CAAF,IAAiCZ,UAAnC,KACD,4BAAC,qBAAD;AACC,IAAA,OAAO,EAAC,YADT;AAEC,kBAAa,cAAI,oBAAJ,CAFd;AAGC,IAAA,WAAW,EAAG,cAAI,aAAJ,CAHf;AAIC,IAAA,KAAK,EAAGY,OAJT;AAKC,IAAA,QAAQ,EAAKwC,KAAF,IACVhD,aAAa,CAAE;AAAEQ,MAAAA,OAAO,EAAEwC;AAAX,KAAF,CANf;AAQC,IAAA,aAAa,MARd;AASC,IAAA,sBAAsB,EAAG,MACxB/C,iBAAiB,CAChB,yBAAa,kCAAb,CADgB;AAVnB,IAlBF,CA7ED,CADD;AAmHA;;eAEc,6BAAaN,SAAb,C","sourcesContent":["/**\n * External dependencies\n */\nimport classnames from 'classnames';\n\n/**\n * WordPress dependencies\n */\nimport { getBlobByURL, isBlobURL } from '@wordpress/blob';\nimport {\n\tBaseControl,\n\tButton,\n\tDisabled,\n\tPanelBody,\n\tSpinner,\n\twithNotices,\n} from '@wordpress/components';\nimport {\n\tBlockControls,\n\tBlockIcon,\n\tInspectorControls,\n\tMediaPlaceholder,\n\tMediaUpload,\n\tMediaUploadCheck,\n\tMediaReplaceFlow,\n\tRichText,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useRef, useEffect } from '@wordpress/element';\nimport { __, sprintf } from '@wordpress/i18n';\nimport { useInstanceId } from '@wordpress/compose';\nimport { useSelect } from '@wordpress/data';\nimport { video as icon } from '@wordpress/icons';\nimport { createBlock, getDefaultBlockName } 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\t[]\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: ( [ media ] ) => onSelectVideo( media ),\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={ __( '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(\n\t\t\t\t\t\t\t\tcreateBlock( getDefaultBlockName() )\n\t\t\t\t\t\t\t)\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</figure>\n\t\t</>\n\t);\n}\n\nexport default withNotices( VideoEdit );\n"]}
|
|
@@ -15,7 +15,7 @@ import { useEffect } from '@wordpress/element';
|
|
|
15
15
|
import { __, _x } from '@wordpress/i18n';
|
|
16
16
|
import { useSelect } from '@wordpress/data';
|
|
17
17
|
import { audio as icon } from '@wordpress/icons';
|
|
18
|
-
import { createBlock } from '@wordpress/blocks';
|
|
18
|
+
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
|
|
19
19
|
/**
|
|
20
20
|
* Internal dependencies
|
|
21
21
|
*/
|
|
@@ -57,22 +57,10 @@ function AudioEdit(_ref) {
|
|
|
57
57
|
mediaUpload({
|
|
58
58
|
filesList: [file],
|
|
59
59
|
onFileChange: _ref2 => {
|
|
60
|
-
let [
|
|
61
|
-
|
|
62
|
-
url
|
|
63
|
-
}] = _ref2;
|
|
64
|
-
setAttributes({
|
|
65
|
-
id: mediaId,
|
|
66
|
-
src: url
|
|
67
|
-
});
|
|
68
|
-
},
|
|
69
|
-
onError: e => {
|
|
70
|
-
setAttributes({
|
|
71
|
-
src: undefined,
|
|
72
|
-
id: undefined
|
|
73
|
-
});
|
|
74
|
-
noticeOperations.createErrorNotice(e);
|
|
60
|
+
let [media] = _ref2;
|
|
61
|
+
return onSelectAudio(media);
|
|
75
62
|
},
|
|
63
|
+
onError: e => onUploadError(e),
|
|
76
64
|
allowedTypes: ALLOWED_MEDIA_TYPES
|
|
77
65
|
});
|
|
78
66
|
}
|
|
@@ -215,7 +203,7 @@ function AudioEdit(_ref) {
|
|
|
215
203
|
caption: value
|
|
216
204
|
}),
|
|
217
205
|
inlineToolbar: true,
|
|
218
|
-
__unstableOnSplitAtEnd: () => insertBlocksAfter(createBlock(
|
|
206
|
+
__unstableOnSplitAtEnd: () => insertBlocksAfter(createBlock(getDefaultBlockName()))
|
|
219
207
|
})));
|
|
220
208
|
}
|
|
221
209
|
|