@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
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useState } from '@wordpress/element';
|
|
10
|
+
import { ResizableBox } from '@wordpress/components';
|
|
11
|
+
|
|
12
|
+
const RESIZABLE_BOX_ENABLE_OPTION = {
|
|
13
|
+
top: false,
|
|
14
|
+
right: false,
|
|
15
|
+
bottom: true,
|
|
16
|
+
left: false,
|
|
17
|
+
topRight: false,
|
|
18
|
+
bottomRight: false,
|
|
19
|
+
bottomLeft: false,
|
|
20
|
+
topLeft: false,
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default function ResizableCover( {
|
|
24
|
+
className,
|
|
25
|
+
onResizeStart,
|
|
26
|
+
onResize,
|
|
27
|
+
onResizeStop,
|
|
28
|
+
...props
|
|
29
|
+
} ) {
|
|
30
|
+
const [ isResizing, setIsResizing ] = useState( false );
|
|
31
|
+
|
|
32
|
+
return (
|
|
33
|
+
<ResizableBox
|
|
34
|
+
className={ classnames( className, {
|
|
35
|
+
'is-resizing': isResizing,
|
|
36
|
+
} ) }
|
|
37
|
+
enable={ RESIZABLE_BOX_ENABLE_OPTION }
|
|
38
|
+
onResizeStart={ ( _event, _direction, elt ) => {
|
|
39
|
+
onResizeStart( elt.clientHeight );
|
|
40
|
+
onResize( elt.clientHeight );
|
|
41
|
+
} }
|
|
42
|
+
onResize={ ( _event, _direction, elt ) => {
|
|
43
|
+
onResize( elt.clientHeight );
|
|
44
|
+
if ( ! isResizing ) {
|
|
45
|
+
setIsResizing( true );
|
|
46
|
+
}
|
|
47
|
+
} }
|
|
48
|
+
onResizeStop={ ( _event, _direction, elt ) => {
|
|
49
|
+
onResizeStop( elt.clientHeight );
|
|
50
|
+
setIsResizing( false );
|
|
51
|
+
} }
|
|
52
|
+
{ ...props }
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import FastAverageColor from 'fast-average-color';
|
|
5
|
+
import { colord } from 'colord';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* WordPress dependencies
|
|
9
|
+
*/
|
|
10
|
+
import { useEffect, useState } from '@wordpress/element';
|
|
11
|
+
|
|
12
|
+
function retrieveFastAverageColor() {
|
|
13
|
+
if ( ! retrieveFastAverageColor.fastAverageColor ) {
|
|
14
|
+
retrieveFastAverageColor.fastAverageColor = new FastAverageColor();
|
|
15
|
+
}
|
|
16
|
+
return retrieveFastAverageColor.fastAverageColor;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* useCoverIsDark is a hook that returns a boolean variable specifying if the cover
|
|
21
|
+
* background is dark or not.
|
|
22
|
+
*
|
|
23
|
+
* @param {?string} url Url of the media background.
|
|
24
|
+
* @param {?number} dimRatio Transparency of the overlay color. If an image and
|
|
25
|
+
* color are set, dimRatio is used to decide what is used
|
|
26
|
+
* for background darkness checking purposes.
|
|
27
|
+
* @param {?string} overlayColor String containing the overlay color value if one exists.
|
|
28
|
+
* @param {?Object} elementRef If a media background is set, elementRef should contain a reference to a
|
|
29
|
+
* dom element that renders that media.
|
|
30
|
+
*
|
|
31
|
+
* @return {boolean} True if the cover background is considered "dark" and false otherwise.
|
|
32
|
+
*/
|
|
33
|
+
export default function useCoverIsDark(
|
|
34
|
+
url,
|
|
35
|
+
dimRatio = 50,
|
|
36
|
+
overlayColor,
|
|
37
|
+
elementRef
|
|
38
|
+
) {
|
|
39
|
+
const [ isDark, setIsDark ] = useState( false );
|
|
40
|
+
useEffect( () => {
|
|
41
|
+
// If opacity is lower than 50 the dominant color is the image or video color,
|
|
42
|
+
// so use that color for the dark mode computation.
|
|
43
|
+
if ( url && dimRatio <= 50 && elementRef.current ) {
|
|
44
|
+
retrieveFastAverageColor().getColorAsync(
|
|
45
|
+
elementRef.current,
|
|
46
|
+
( color ) => {
|
|
47
|
+
setIsDark( color.isDark );
|
|
48
|
+
}
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
}, [ url, url && dimRatio <= 50 && elementRef.current, setIsDark ] );
|
|
52
|
+
useEffect( () => {
|
|
53
|
+
// If opacity is greater than 50 the dominant color is the overlay color,
|
|
54
|
+
// so use that color for the dark mode computation.
|
|
55
|
+
if ( dimRatio > 50 || ! url ) {
|
|
56
|
+
if ( ! overlayColor ) {
|
|
57
|
+
// If no overlay color exists the overlay color is black (isDark )
|
|
58
|
+
setIsDark( true );
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
setIsDark( colord( overlayColor ).isDark() );
|
|
62
|
+
}
|
|
63
|
+
}, [ overlayColor, dimRatio > 50 || ! url, setIsDark ] );
|
|
64
|
+
useEffect( () => {
|
|
65
|
+
if ( ! url && ! overlayColor ) {
|
|
66
|
+
// Reset isDark.
|
|
67
|
+
setIsDark( false );
|
|
68
|
+
}
|
|
69
|
+
}, [ ! url && ! overlayColor, setIsDark ] );
|
|
70
|
+
return isDark;
|
|
71
|
+
}
|
package/src/cover/edit.native.js
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Platform,
|
|
10
10
|
} from 'react-native';
|
|
11
11
|
import Video from 'react-native-video';
|
|
12
|
+
import classnames from 'classnames/dedupe';
|
|
12
13
|
|
|
13
14
|
/**
|
|
14
15
|
* WordPress dependencies
|
|
@@ -47,7 +48,7 @@ import {
|
|
|
47
48
|
store as blockEditorStore,
|
|
48
49
|
} from '@wordpress/block-editor';
|
|
49
50
|
import { compose, withPreferredColorScheme } from '@wordpress/compose';
|
|
50
|
-
import { withSelect, withDispatch } from '@wordpress/data';
|
|
51
|
+
import { useDispatch, withSelect, withDispatch } from '@wordpress/data';
|
|
51
52
|
import {
|
|
52
53
|
useEffect,
|
|
53
54
|
useState,
|
|
@@ -71,6 +72,7 @@ import {
|
|
|
71
72
|
COVER_DEFAULT_HEIGHT,
|
|
72
73
|
} from './shared';
|
|
73
74
|
import Controls from './controls';
|
|
75
|
+
import useCoverIsDark from './use-cover-is-dark';
|
|
74
76
|
|
|
75
77
|
/**
|
|
76
78
|
* Constants
|
|
@@ -113,6 +115,7 @@ const Cover = ( {
|
|
|
113
115
|
customGradient,
|
|
114
116
|
gradient,
|
|
115
117
|
overlayColor,
|
|
118
|
+
isDark,
|
|
116
119
|
} = attributes;
|
|
117
120
|
const [ isScreenReaderEnabled, setIsScreenReaderEnabled ] = useState(
|
|
118
121
|
false
|
|
@@ -180,18 +183,6 @@ const Cover = ( {
|
|
|
180
183
|
|
|
181
184
|
const openMediaOptionsRef = useRef();
|
|
182
185
|
|
|
183
|
-
// Used to set a default color for its InnerBlocks
|
|
184
|
-
// since there's no system to inherit styles yet
|
|
185
|
-
// the RichText component will check if there are
|
|
186
|
-
// parent styles for the current block. If there are,
|
|
187
|
-
// it will use that color instead.
|
|
188
|
-
useEffect( () => {
|
|
189
|
-
// While we don't support theme colors.
|
|
190
|
-
if ( ! attributes.overlayColor || ( ! attributes.overlay && url ) ) {
|
|
191
|
-
setAttributes( { childrenStyles: styles.defaultColor } );
|
|
192
|
-
}
|
|
193
|
-
}, [ setAttributes ] );
|
|
194
|
-
|
|
195
186
|
// Initialize uploading flag to false, awaiting sync.
|
|
196
187
|
const [ isUploadInProgress, setIsUploadInProgress ] = useState( false );
|
|
197
188
|
|
|
@@ -257,6 +248,42 @@ const Cover = ( {
|
|
|
257
248
|
openGeneralSidebar();
|
|
258
249
|
}
|
|
259
250
|
|
|
251
|
+
const { __unstableMarkNextChangeAsNotPersistent } = useDispatch(
|
|
252
|
+
blockEditorStore
|
|
253
|
+
);
|
|
254
|
+
const isCoverDark = useCoverIsDark(
|
|
255
|
+
isDark,
|
|
256
|
+
url,
|
|
257
|
+
dimRatio,
|
|
258
|
+
overlayColorValue?.color
|
|
259
|
+
);
|
|
260
|
+
|
|
261
|
+
useEffect( () => {
|
|
262
|
+
// This side-effect should not create an undo level.
|
|
263
|
+
__unstableMarkNextChangeAsNotPersistent();
|
|
264
|
+
// Used to set a default color for its InnerBlocks
|
|
265
|
+
// since there's no system to inherit styles yet
|
|
266
|
+
// the RichText component will check if there are
|
|
267
|
+
// parent styles for the current block. If there are,
|
|
268
|
+
// it will use that color instead.
|
|
269
|
+
setAttributes( {
|
|
270
|
+
isDark: isCoverDark,
|
|
271
|
+
childrenStyles: isCoverDark
|
|
272
|
+
? styles.defaultColor
|
|
273
|
+
: styles.defaultColorLightMode,
|
|
274
|
+
} );
|
|
275
|
+
|
|
276
|
+
// Ensure that "is-light" is removed from "className" attribute if cover background is dark.
|
|
277
|
+
if ( isCoverDark && attributes.className?.includes( 'is-light' ) ) {
|
|
278
|
+
const className = classnames( attributes.className, {
|
|
279
|
+
'is-light': false,
|
|
280
|
+
} );
|
|
281
|
+
setAttributes( {
|
|
282
|
+
className: className !== '' ? className : undefined,
|
|
283
|
+
} );
|
|
284
|
+
}
|
|
285
|
+
}, [ isCoverDark ] );
|
|
286
|
+
|
|
260
287
|
const backgroundColor = getStylesFromColorScheme(
|
|
261
288
|
styles.backgroundSolid,
|
|
262
289
|
styles.backgroundSolidDark
|
|
@@ -375,7 +402,6 @@ const Cover = ( {
|
|
|
375
402
|
<TouchableWithoutFeedback
|
|
376
403
|
accessible={ ! isParentSelected }
|
|
377
404
|
onPress={ onMediaPressed }
|
|
378
|
-
onLongPress={ openMediaOptionsRef.current }
|
|
379
405
|
disabled={ ! isParentSelected }
|
|
380
406
|
>
|
|
381
407
|
<View style={ [ styles.background, backgroundColor ] }>
|
package/src/cover/editor.scss
CHANGED
|
@@ -41,7 +41,7 @@ function FocalPointSettingsButton( {
|
|
|
41
41
|
>
|
|
42
42
|
{ /*
|
|
43
43
|
* Wrapper View element used around Icon as workaround for SVG opacity
|
|
44
|
-
* issue: https://
|
|
44
|
+
* issue: https://github.com/react-native-svg/react-native-svg/issues/1345
|
|
45
45
|
*/ }
|
|
46
46
|
<View style={ disabled && styles.dimmedActionButton }>
|
|
47
47
|
<Icon icon={ chevronRight } />
|
package/src/cover/index.php
CHANGED
|
@@ -14,51 +14,23 @@
|
|
|
14
14
|
* @return string Returns the cover block markup, if useFeaturedImage is true.
|
|
15
15
|
*/
|
|
16
16
|
function render_block_core_cover( $attributes, $content ) {
|
|
17
|
-
if ( false === $attributes['useFeaturedImage'] ) {
|
|
17
|
+
if ( 'image' !== $attributes['backgroundType'] || false === $attributes['useFeaturedImage'] ) {
|
|
18
18
|
return $content;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
$
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
$is_img_element = ! ( $attributes['hasParallax'] || $attributes['isRepeated'] );
|
|
28
|
-
$is_image_background = 'image' === $attributes['backgroundType'];
|
|
29
|
-
|
|
30
|
-
if ( $is_image_background && ! $is_img_element ) {
|
|
31
|
-
$content = preg_replace(
|
|
32
|
-
'/class=\".*?\"/',
|
|
33
|
-
'${0} style="background-image:url(' . esc_url( $current_featured_image ) . ')"',
|
|
34
|
-
$content,
|
|
35
|
-
1
|
|
21
|
+
if ( ! ( $attributes['hasParallax'] || $attributes['isRepeated'] ) ) {
|
|
22
|
+
$attr = array(
|
|
23
|
+
'class' => 'wp-block-cover__image-background',
|
|
24
|
+
'data-object-fit' => 'cover',
|
|
36
25
|
);
|
|
37
|
-
}
|
|
38
26
|
|
|
39
|
-
if ( $is_image_background && $is_img_element ) {
|
|
40
|
-
$object_position = '';
|
|
41
27
|
if ( isset( $attributes['focalPoint'] ) ) {
|
|
42
|
-
$object_position
|
|
43
|
-
|
|
28
|
+
$object_position = round( $attributes['focalPoint']['x'] * 100 ) . '%' . ' ' . round( $attributes['focalPoint']['y'] * 100 ) . '%';
|
|
29
|
+
$attr['data-object-position'] = $object_position;
|
|
30
|
+
$attr['style'] = 'object-position: ' . $object_position;
|
|
44
31
|
}
|
|
45
32
|
|
|
46
|
-
$
|
|
47
|
-
class="wp-block-cover__image-background"
|
|
48
|
-
alt="%s"
|
|
49
|
-
src="%s"
|
|
50
|
-
style="object-position: %s"
|
|
51
|
-
data-object-fit="cover"
|
|
52
|
-
data-object-position="%s"
|
|
53
|
-
/>';
|
|
54
|
-
|
|
55
|
-
$image = sprintf(
|
|
56
|
-
$image_template,
|
|
57
|
-
esc_attr( get_the_post_thumbnail_caption() ),
|
|
58
|
-
esc_url( $current_featured_image ),
|
|
59
|
-
esc_attr( $object_position ),
|
|
60
|
-
esc_attr( $object_position )
|
|
61
|
-
);
|
|
33
|
+
$image = get_the_post_thumbnail( null, 'post-thumbnail', $attr );
|
|
62
34
|
|
|
63
35
|
$content = str_replace(
|
|
64
36
|
'</span><div',
|
|
@@ -66,6 +38,17 @@ function render_block_core_cover( $attributes, $content ) {
|
|
|
66
38
|
$content
|
|
67
39
|
);
|
|
68
40
|
|
|
41
|
+
} else {
|
|
42
|
+
if ( in_the_loop() ) {
|
|
43
|
+
update_post_thumbnail_cache();
|
|
44
|
+
}
|
|
45
|
+
$current_featured_image = get_the_post_thumbnail_url();
|
|
46
|
+
$content = preg_replace(
|
|
47
|
+
'/class=\".*?\"/',
|
|
48
|
+
'${0} style="background-image:url(' . esc_url( $current_featured_image ) . ')"',
|
|
49
|
+
$content,
|
|
50
|
+
1
|
|
51
|
+
);
|
|
69
52
|
}
|
|
70
53
|
|
|
71
54
|
return $content;
|
package/src/cover/save.js
CHANGED
|
@@ -19,10 +19,10 @@ import {
|
|
|
19
19
|
import {
|
|
20
20
|
IMAGE_BACKGROUND_TYPE,
|
|
21
21
|
VIDEO_BACKGROUND_TYPE,
|
|
22
|
-
backgroundImageStyles,
|
|
23
22
|
dimRatioToClass,
|
|
24
23
|
isContentPositionCenter,
|
|
25
24
|
getPositionClassName,
|
|
25
|
+
mediaPosition,
|
|
26
26
|
} from './shared';
|
|
27
27
|
|
|
28
28
|
export default function save( { attributes } ) {
|
|
@@ -61,9 +61,6 @@ export default function save( { attributes } ) {
|
|
|
61
61
|
const isImgElement = ! ( hasParallax || isRepeated );
|
|
62
62
|
|
|
63
63
|
const style = {
|
|
64
|
-
...( isImageBackground && ! isImgElement && ! useFeaturedImage
|
|
65
|
-
? backgroundImageStyles( url )
|
|
66
|
-
: {} ),
|
|
67
64
|
minHeight: minHeight || undefined,
|
|
68
65
|
};
|
|
69
66
|
|
|
@@ -75,8 +72,12 @@ export default function save( { attributes } ) {
|
|
|
75
72
|
const objectPosition =
|
|
76
73
|
// prettier-ignore
|
|
77
74
|
focalPoint && isImgElement
|
|
78
|
-
|
|
79
|
-
|
|
75
|
+
? mediaPosition(focalPoint)
|
|
76
|
+
: undefined;
|
|
77
|
+
|
|
78
|
+
const backgroundImage = url ? `url(${ url })` : undefined;
|
|
79
|
+
|
|
80
|
+
const backgroundPosition = mediaPosition( focalPoint );
|
|
80
81
|
|
|
81
82
|
const classes = classnames(
|
|
82
83
|
{
|
|
@@ -90,6 +91,15 @@ export default function save( { attributes } ) {
|
|
|
90
91
|
getPositionClassName( contentPosition )
|
|
91
92
|
);
|
|
92
93
|
|
|
94
|
+
const imgClasses = classnames(
|
|
95
|
+
'wp-block-cover__image-background',
|
|
96
|
+
id ? `wp-image-${ id }` : null,
|
|
97
|
+
{
|
|
98
|
+
'has-parallax': hasParallax,
|
|
99
|
+
'is-repeated': isRepeated,
|
|
100
|
+
}
|
|
101
|
+
);
|
|
102
|
+
|
|
93
103
|
const gradientValue = gradient || customGradient;
|
|
94
104
|
|
|
95
105
|
return (
|
|
@@ -116,20 +126,23 @@ export default function save( { attributes } ) {
|
|
|
116
126
|
|
|
117
127
|
{ ! useFeaturedImage &&
|
|
118
128
|
isImageBackground &&
|
|
119
|
-
|
|
120
|
-
|
|
129
|
+
url &&
|
|
130
|
+
( isImgElement ? (
|
|
121
131
|
<img
|
|
122
|
-
className={
|
|
123
|
-
'wp-block-cover__image-background',
|
|
124
|
-
id ? `wp-image-${ id }` : null
|
|
125
|
-
) }
|
|
132
|
+
className={ imgClasses }
|
|
126
133
|
alt={ alt }
|
|
127
134
|
src={ url }
|
|
128
135
|
style={ { objectPosition } }
|
|
129
136
|
data-object-fit="cover"
|
|
130
137
|
data-object-position={ objectPosition }
|
|
131
138
|
/>
|
|
132
|
-
)
|
|
139
|
+
) : (
|
|
140
|
+
<div
|
|
141
|
+
role="img"
|
|
142
|
+
className={ imgClasses }
|
|
143
|
+
style={ { backgroundPosition, backgroundImage } }
|
|
144
|
+
/>
|
|
145
|
+
) ) }
|
|
133
146
|
{ isVideoBackground && url && (
|
|
134
147
|
<video
|
|
135
148
|
className={ classnames(
|
package/src/cover/shared.js
CHANGED
|
@@ -21,11 +21,13 @@ export const VIDEO_BACKGROUND_TYPE = 'video';
|
|
|
21
21
|
export const COVER_MIN_HEIGHT = 50;
|
|
22
22
|
export const COVER_MAX_HEIGHT = 1000;
|
|
23
23
|
export const COVER_DEFAULT_HEIGHT = 300;
|
|
24
|
-
export
|
|
25
|
-
return url ? { backgroundImage: `url(${ url })` } : {};
|
|
26
|
-
}
|
|
24
|
+
export const DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 };
|
|
27
25
|
export const ALLOWED_MEDIA_TYPES = [ 'image', 'video' ];
|
|
28
26
|
|
|
27
|
+
export function mediaPosition( { x, y } = DEFAULT_FOCAL_POINT ) {
|
|
28
|
+
return `${ Math.round( x * 100 ) }% ${ Math.round( y * 100 ) }%`;
|
|
29
|
+
}
|
|
30
|
+
|
|
29
31
|
export function dimRatioToClass( ratio ) {
|
|
30
32
|
return ratio === 50 || ! ratio === undefined
|
|
31
33
|
? null
|
package/src/cover/style.scss
CHANGED
|
@@ -12,27 +12,6 @@
|
|
|
12
12
|
// This block has customizable padding, border-box makes that more predictable.
|
|
13
13
|
box-sizing: border-box;
|
|
14
14
|
|
|
15
|
-
&.has-parallax {
|
|
16
|
-
background-attachment: fixed;
|
|
17
|
-
|
|
18
|
-
// Mobile Safari does not support fixed background attachment properly.
|
|
19
|
-
// See also https://stackoverflow.com/questions/24154666/background-size-cover-not-working-on-ios
|
|
20
|
-
// Chrome on Android does not appear to support the attachment at all: https://issuetracker.google.com/issues/36908439
|
|
21
|
-
@supports (-webkit-overflow-scrolling: touch) {
|
|
22
|
-
background-attachment: scroll;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Remove the appearance of scrolling based on OS-level animation preferences.
|
|
26
|
-
@media (prefers-reduced-motion: reduce) {
|
|
27
|
-
background-attachment: scroll;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
&.is-repeated {
|
|
32
|
-
background-repeat: repeat;
|
|
33
|
-
background-size: auto;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
15
|
/**
|
|
37
16
|
* Set a default background color for has-background-dim _unless_ it includes another
|
|
38
17
|
* background-color class (e.g. has-green-background-color). The presence of another
|
|
@@ -96,10 +75,6 @@
|
|
|
96
75
|
}
|
|
97
76
|
}
|
|
98
77
|
|
|
99
|
-
.block-library-cover__padding-visualizer {
|
|
100
|
-
z-index: z-index(".block-library-cover__padding-visualizer");
|
|
101
|
-
}
|
|
102
|
-
|
|
103
78
|
// Apply max-width to floated items that have no intrinsic width
|
|
104
79
|
&.alignleft,
|
|
105
80
|
&.alignright {
|
|
@@ -200,7 +175,7 @@
|
|
|
200
175
|
}
|
|
201
176
|
|
|
202
177
|
// Extra specificity for in edit mode where other styles would override it otherwise.
|
|
203
|
-
|
|
178
|
+
.wp-block-cover__image-background,
|
|
204
179
|
video.wp-block-cover__video-background {
|
|
205
180
|
position: absolute;
|
|
206
181
|
top: 0;
|
|
@@ -220,6 +195,32 @@
|
|
|
220
195
|
}
|
|
221
196
|
}
|
|
222
197
|
|
|
198
|
+
.wp-block-cover-image,
|
|
199
|
+
.wp-block-cover,
|
|
200
|
+
.wp-block-cover__image-background,
|
|
201
|
+
video.wp-block-cover__video-background {
|
|
202
|
+
&.has-parallax {
|
|
203
|
+
background-attachment: fixed;
|
|
204
|
+
|
|
205
|
+
// Mobile Safari does not support fixed background attachment properly.
|
|
206
|
+
// See also https://stackoverflow.com/questions/24154666/background-size-cover-not-working-on-ios
|
|
207
|
+
// Chrome on Android does not appear to support the attachment at all: https://issuetracker.google.com/issues/36908439
|
|
208
|
+
@supports (-webkit-overflow-scrolling: touch) {
|
|
209
|
+
background-attachment: scroll;
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
// Remove the appearance of scrolling based on OS-level animation preferences.
|
|
213
|
+
@media (prefers-reduced-motion: reduce) {
|
|
214
|
+
background-attachment: scroll;
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
&.is-repeated {
|
|
219
|
+
background-repeat: repeat;
|
|
220
|
+
background-size: auto;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
223
224
|
.wp-block-cover__video-background {
|
|
224
225
|
z-index: z-index(".wp-block-cover__video-background");
|
|
225
226
|
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
3
|
exports[`color settings clears the selected overlay color and mantains the inner blocks 1`] = `
|
|
4
|
-
"<!-- wp:cover -->
|
|
5
|
-
<div class=\\"wp-block-cover\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-background-dim-100 has-background-dim\\"></span><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\"} -->
|
|
4
|
+
"<!-- wp:cover {\\"isDark\\":false} -->
|
|
5
|
+
<div class=\\"wp-block-cover is-light\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-background-dim-100 has-background-dim\\"></span><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\"} -->
|
|
6
6
|
<p class=\\"has-text-align-center\\"></p>
|
|
7
7
|
<!-- /wp:paragraph --></div></div>
|
|
8
8
|
<!-- /wp:cover -->"
|
|
@@ -17,16 +17,16 @@ exports[`color settings sets a color for the overlay background when the placeho
|
|
|
17
17
|
`;
|
|
18
18
|
|
|
19
19
|
exports[`color settings sets a gradient overlay background when a solid background was already selected 1`] = `
|
|
20
|
-
"<!-- wp:cover {\\"gradient\\":\\"light-green-cyan-to-vivid-green-cyan\\"} -->
|
|
21
|
-
<div class=\\"wp-block-cover\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-background-dim-100 has-background-dim has-background-gradient has-light-green-cyan-to-vivid-green-cyan-gradient-background\\"></span><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\"} -->
|
|
20
|
+
"<!-- wp:cover {\\"gradient\\":\\"light-green-cyan-to-vivid-green-cyan\\",\\"isDark\\":false} -->
|
|
21
|
+
<div class=\\"wp-block-cover is-light\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-background-dim-100 has-background-dim has-background-gradient has-light-green-cyan-to-vivid-green-cyan-gradient-background\\"></span><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\"} -->
|
|
22
22
|
<p class=\\"has-text-align-center\\"></p>
|
|
23
23
|
<!-- /wp:paragraph --></div></div>
|
|
24
24
|
<!-- /wp:cover -->"
|
|
25
25
|
`;
|
|
26
26
|
|
|
27
27
|
exports[`color settings toggles between solid colors and gradients 1`] = `
|
|
28
|
-
"<!-- wp:cover {\\"gradient\\":\\"light-green-cyan-to-vivid-green-cyan\\"} -->
|
|
29
|
-
<div class=\\"wp-block-cover\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-background-dim-100 has-background-dim has-background-gradient has-light-green-cyan-to-vivid-green-cyan-gradient-background\\"></span><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\"} -->
|
|
28
|
+
"<!-- wp:cover {\\"gradient\\":\\"light-green-cyan-to-vivid-green-cyan\\",\\"isDark\\":false} -->
|
|
29
|
+
<div class=\\"wp-block-cover is-light\\"><span aria-hidden=\\"true\\" class=\\"wp-block-cover__background has-background-dim-100 has-background-dim has-background-gradient has-light-green-cyan-to-vivid-green-cyan-gradient-background\\"></span><div class=\\"wp-block-cover__inner-container\\"><!-- wp:paragraph {\\"align\\":\\"center\\",\\"placeholder\\":\\"Write title…\\"} -->
|
|
30
30
|
<p class=\\"has-text-align-center\\"></p>
|
|
31
31
|
<!-- /wp:paragraph --></div></div>
|
|
32
32
|
<!-- /wp:cover -->"
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { render, screen, fireEvent } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
// Need to mock the BlockControls wrapper as this requires a slot to run
|
|
7
|
+
// so can't be easily unit tested.
|
|
8
|
+
jest.mock( '@wordpress/block-editor', () => ( {
|
|
9
|
+
...jest.requireActual( '@wordpress/block-editor' ),
|
|
10
|
+
BlockControls: ( { children } ) => <div>{ children }</div>,
|
|
11
|
+
} ) );
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Internal dependencies
|
|
15
|
+
*/
|
|
16
|
+
import CoverBlockControls from '../edit/block-controls';
|
|
17
|
+
|
|
18
|
+
const setAttributes = jest.fn();
|
|
19
|
+
const onSelectMedia = jest.fn();
|
|
20
|
+
|
|
21
|
+
const currentSettings = { hasInnerBlocks: true, url: undefined };
|
|
22
|
+
const defaultAttributes = {
|
|
23
|
+
contentPosition: undefined,
|
|
24
|
+
id: 1,
|
|
25
|
+
useFeaturedImage: false,
|
|
26
|
+
dimRatio: 50,
|
|
27
|
+
minHeight: 300,
|
|
28
|
+
minHeightUnit: 'px',
|
|
29
|
+
};
|
|
30
|
+
const defaultProps = {
|
|
31
|
+
attributes: defaultAttributes,
|
|
32
|
+
currentSettings,
|
|
33
|
+
setAttributes,
|
|
34
|
+
onSelectMedia,
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
beforeEach( () => {
|
|
38
|
+
setAttributes.mockClear();
|
|
39
|
+
onSelectMedia.mockClear();
|
|
40
|
+
} );
|
|
41
|
+
|
|
42
|
+
describe( 'Cover block controls', () => {
|
|
43
|
+
describe( 'Full height toggle', () => {
|
|
44
|
+
test( 'displays toggle full height button toggled off if minHeight not 100vh', () => {
|
|
45
|
+
render( <CoverBlockControls { ...defaultProps } /> );
|
|
46
|
+
expect(
|
|
47
|
+
screen.getByRole( 'button', {
|
|
48
|
+
pressed: false,
|
|
49
|
+
name: 'Toggle full height',
|
|
50
|
+
} )
|
|
51
|
+
).toBeInTheDocument();
|
|
52
|
+
} );
|
|
53
|
+
test( 'sets minHeight attributes to 100vh when clicked', () => {
|
|
54
|
+
render( <CoverBlockControls { ...defaultProps } /> );
|
|
55
|
+
fireEvent.click( screen.getByLabelText( 'Toggle full height' ) );
|
|
56
|
+
expect( setAttributes ).toHaveBeenCalledWith( {
|
|
57
|
+
minHeight: 100,
|
|
58
|
+
minHeightUnit: 'vh',
|
|
59
|
+
} );
|
|
60
|
+
} );
|
|
61
|
+
} );
|
|
62
|
+
} );
|