@wordpress/block-library 8.6.0 → 8.8.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 +4 -0
- package/build/buttons/index.js +1 -0
- package/build/buttons/index.js.map +1 -1
- package/build/buttons/transforms.js +1 -0
- package/build/buttons/transforms.js.map +1 -1
- package/build/column/index.js +2 -1
- package/build/column/index.js.map +1 -1
- package/build/columns/edit.js +28 -8
- package/build/columns/edit.js.map +1 -1
- package/build/columns/index.js +6 -1
- package/build/columns/index.js.map +1 -1
- package/build/columns/utils.js +4 -9
- package/build/columns/utils.js.map +1 -1
- package/build/cover/edit/index.js +46 -50
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +2 -2
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +32 -6
- package/build/cover/edit/resizable-cover-popover.js.map +1 -0
- package/build/cover/index.js +12 -0
- package/build/cover/index.js.map +1 -1
- package/build/details/edit.js +67 -0
- package/build/details/edit.js.map +1 -0
- package/build/details/index.js +110 -0
- package/build/details/index.js.map +1 -0
- package/build/details/save.js +33 -0
- package/build/details/save.js.map +1 -0
- package/build/details-content/edit.js +34 -0
- package/build/details-content/edit.js.map +1 -0
- package/build/details-content/index.js +94 -0
- package/build/details-content/index.js.map +1 -0
- package/build/details-content/save.js +20 -0
- package/build/details-content/save.js.map +1 -0
- package/build/details-summary/edit.js +42 -0
- package/build/details-summary/edit.js.map +1 -0
- package/build/details-summary/index.js +97 -0
- package/build/details-summary/index.js.map +1 -0
- package/build/details-summary/save.js +24 -0
- package/build/details-summary/save.js.map +1 -0
- package/build/embed/deprecated.js +4 -1
- package/build/embed/deprecated.js.map +1 -1
- package/build/embed/embed-link-settings.native.js +1 -1
- package/build/embed/embed-link-settings.native.js.map +1 -1
- package/build/embed/embed-placeholder.js +1 -1
- package/build/embed/embed-placeholder.js.map +1 -1
- package/build/embed/index.js +4 -1
- package/build/embed/index.js.map +1 -1
- package/build/embed/transforms.js +4 -1
- package/build/embed/transforms.js.map +1 -1
- package/build/embed/util.js +4 -1
- package/build/embed/util.js.map +1 -1
- package/build/file/edit.native.js +0 -2
- package/build/file/edit.native.js.map +1 -1
- package/build/gallery/edit.js +8 -5
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/use-get-media.native.js +2 -1
- package/build/gallery/use-get-media.native.js.map +1 -1
- package/build/gallery/use-image-sizes.js +1 -1
- package/build/gallery/use-image-sizes.js.map +1 -1
- package/build/group/deprecated.js +4 -2
- package/build/group/deprecated.js.map +1 -1
- package/build/group/edit.js +22 -5
- package/build/group/edit.js.map +1 -1
- package/build/group/placeholder.js +11 -1
- package/build/group/placeholder.js.map +1 -1
- package/build/group/variations.js +23 -3
- package/build/group/variations.js.map +1 -1
- package/build/image/edit.js +1 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +1 -1
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +8 -6
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +9 -2
- package/build/image/index.js.map +1 -1
- package/build/index.js +24 -6
- package/build/index.js.map +1 -1
- package/build/latest-posts/edit.js +1 -0
- package/build/latest-posts/edit.js.map +1 -1
- package/build/media-text/deprecated.js +228 -18
- package/build/media-text/deprecated.js.map +1 -1
- package/build/media-text/edit.js +3 -3
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/index.js +1 -1
- package/build/media-text/media-container.js +2 -6
- package/build/media-text/media-container.js.map +1 -1
- package/build/media-text/media-container.native.js +3 -3
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/navigation/deprecated.js +8 -11
- package/build/navigation/deprecated.js.map +1 -1
- package/build/navigation/edit/index.js +1 -12
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +1 -4
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +1 -14
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/index.js +0 -1
- package/build/navigation/index.js.map +1 -1
- package/build/post-author/index.js +0 -1
- package/build/post-author/index.js.map +1 -1
- package/build/post-date/edit.js +2 -1
- package/build/post-date/edit.js.map +1 -1
- package/build/post-date/index.js +4 -1
- package/build/post-date/index.js.map +1 -1
- package/build/post-date/variations.js +28 -0
- package/build/post-date/variations.js.map +1 -0
- package/build/post-excerpt/edit.js +39 -10
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/dimension-controls.js +4 -3
- package/build/post-featured-image/dimension-controls.js.map +1 -1
- package/build/post-featured-image/edit.js +8 -22
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-template/index.js +1 -1
- package/build/post-time-to-read/edit.js +1 -1
- package/build/post-time-to-read/edit.js.map +1 -1
- package/build/post-time-to-read/index.js +24 -1
- package/build/post-time-to-read/index.js.map +1 -1
- package/build/quote/index.js +1 -0
- package/build/quote/index.js.map +1 -1
- package/build/spacer/controls.js +25 -6
- package/build/spacer/controls.js.map +1 -1
- package/build/spacer/edit.js +27 -7
- package/build/spacer/edit.js.map +1 -1
- package/build/spacer/save.js +2 -2
- package/build/spacer/save.js.map +1 -1
- package/build/table/state.js +35 -35
- package/build/table/state.js.map +1 -1
- package/build/term-description/index.js +1 -2
- package/build/term-description/index.js.map +1 -1
- package/build/utils/clean-empty-object.js +5 -2
- package/build/utils/clean-empty-object.js.map +1 -1
- package/build-module/buttons/index.js +1 -0
- package/build-module/buttons/index.js.map +1 -1
- package/build-module/buttons/transforms.js +1 -0
- package/build-module/buttons/transforms.js.map +1 -1
- package/build-module/column/index.js +2 -1
- package/build-module/column/index.js.map +1 -1
- package/build-module/columns/edit.js +28 -8
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/columns/index.js +6 -1
- package/build-module/columns/index.js.map +1 -1
- package/build-module/columns/utils.js +4 -8
- package/build-module/columns/utils.js.map +1 -1
- package/build-module/cover/edit/index.js +48 -52
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +2 -2
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/edit/{resizable-cover.js → resizable-cover-popover.js} +31 -6
- package/build-module/cover/edit/resizable-cover-popover.js.map +1 -0
- package/build-module/cover/index.js +12 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/details/edit.js +52 -0
- package/build-module/details/edit.js.map +1 -0
- package/build-module/details/index.js +91 -0
- package/build-module/details/index.js.map +1 -0
- package/build-module/details/save.js +20 -0
- package/build-module/details/save.js.map +1 -0
- package/build-module/details-content/edit.js +23 -0
- package/build-module/details-content/edit.js.map +1 -0
- package/build-module/details-content/index.js +76 -0
- package/build-module/details-content/index.js.map +1 -0
- package/build-module/details-content/save.js +11 -0
- package/build-module/details-content/save.js.map +1 -0
- package/build-module/details-summary/edit.js +30 -0
- package/build-module/details-summary/edit.js.map +1 -0
- package/build-module/details-summary/index.js +79 -0
- package/build-module/details-summary/index.js.map +1 -0
- package/build-module/details-summary/save.js +16 -0
- package/build-module/details-summary/save.js.map +1 -0
- package/build-module/embed/deprecated.js +4 -1
- package/build-module/embed/deprecated.js.map +1 -1
- package/build-module/embed/embed-link-settings.native.js +1 -1
- package/build-module/embed/embed-link-settings.native.js.map +1 -1
- package/build-module/embed/embed-placeholder.js +1 -1
- package/build-module/embed/embed-placeholder.js.map +1 -1
- package/build-module/embed/index.js +4 -1
- package/build-module/embed/index.js.map +1 -1
- package/build-module/embed/transforms.js +4 -1
- package/build-module/embed/transforms.js.map +1 -1
- package/build-module/embed/util.js +4 -1
- package/build-module/embed/util.js.map +1 -1
- package/build-module/file/edit.native.js +0 -2
- package/build-module/file/edit.native.js.map +1 -1
- package/build-module/gallery/edit.js +8 -5
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/use-get-media.native.js +2 -1
- package/build-module/gallery/use-get-media.native.js.map +1 -1
- package/build-module/gallery/use-image-sizes.js +1 -1
- package/build-module/gallery/use-image-sizes.js.map +1 -1
- package/build-module/group/deprecated.js +4 -2
- package/build-module/group/deprecated.js.map +1 -1
- package/build-module/group/edit.js +21 -5
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/placeholder.js +11 -1
- package/build-module/group/placeholder.js.map +1 -1
- package/build-module/group/variations.js +24 -1
- package/build-module/group/variations.js.map +1 -1
- package/build-module/image/edit.js +1 -1
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +1 -1
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +8 -6
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +9 -2
- package/build-module/image/index.js.map +1 -1
- package/build-module/index.js +21 -6
- package/build-module/index.js.map +1 -1
- package/build-module/latest-posts/edit.js +1 -0
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/media-text/deprecated.js +227 -18
- package/build-module/media-text/deprecated.js.map +1 -1
- package/build-module/media-text/edit.js +3 -3
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/index.js +1 -1
- package/build-module/media-text/media-container.js +1 -5
- package/build-module/media-text/media-container.js.map +1 -1
- package/build-module/media-text/media-container.native.js +1 -1
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/navigation/deprecated.js +8 -10
- package/build-module/navigation/deprecated.js.map +1 -1
- package/build-module/navigation/edit/index.js +1 -12
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +1 -4
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +1 -14
- package/build-module/navigation/edit/unsaved-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/post-author/index.js +0 -1
- package/build-module/post-author/index.js.map +1 -1
- package/build-module/post-date/edit.js +2 -1
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-date/index.js +3 -1
- package/build-module/post-date/index.js.map +1 -1
- package/build-module/post-date/variations.js +18 -0
- package/build-module/post-date/variations.js.map +1 -0
- package/build-module/post-excerpt/edit.js +38 -11
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/dimension-controls.js +4 -3
- package/build-module/post-featured-image/dimension-controls.js.map +1 -1
- package/build-module/post-featured-image/edit.js +8 -22
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-template/index.js +1 -1
- package/build-module/post-time-to-read/edit.js +1 -1
- package/build-module/post-time-to-read/edit.js.map +1 -1
- package/build-module/post-time-to-read/index.js +24 -1
- package/build-module/post-time-to-read/index.js.map +1 -1
- package/build-module/quote/index.js +1 -0
- package/build-module/quote/index.js.map +1 -1
- package/build-module/spacer/controls.js +27 -9
- package/build-module/spacer/controls.js.map +1 -1
- package/build-module/spacer/edit.js +27 -8
- package/build-module/spacer/edit.js.map +1 -1
- package/build-module/spacer/save.js +3 -3
- package/build-module/spacer/save.js.map +1 -1
- package/build-module/table/state.js +35 -33
- package/build-module/table/state.js.map +1 -1
- package/build-module/term-description/index.js +1 -2
- package/build-module/term-description/index.js.map +1 -1
- package/build-module/utils/clean-empty-object.js +6 -3
- package/build-module/utils/clean-empty-object.js.map +1 -1
- package/build-style/categories/editor-rtl.css +5 -0
- package/build-style/categories/editor.css +5 -0
- package/build-style/categories/style-rtl.css +4 -0
- package/build-style/categories/style.css +4 -0
- package/build-style/columns/style-rtl.css +4 -1
- package/build-style/columns/style.css +4 -1
- package/build-style/common-rtl.css +1 -1
- package/build-style/common.css +1 -1
- package/build-style/cover/editor-rtl.css +11 -12
- package/build-style/cover/editor.css +11 -12
- package/build-style/cover/style-rtl.css +3 -2
- package/build-style/cover/style.css +3 -2
- package/build-style/details/style-rtl.css +91 -0
- package/build-style/details/style.css +91 -0
- package/build-style/details-summary/editor-rtl.css +91 -0
- package/build-style/details-summary/editor.css +91 -0
- package/build-style/details-summary/style-rtl.css +91 -0
- package/build-style/details-summary/style.css +91 -0
- package/build-style/editor-rtl.css +40 -48
- package/build-style/editor.css +40 -48
- package/build-style/file/style-rtl.css +4 -3
- package/build-style/file/style.css +4 -3
- package/build-style/navigation/style-rtl.css +2 -0
- package/build-style/navigation/style.css +2 -0
- package/build-style/post-excerpt/style-rtl.css +1 -1
- package/build-style/post-excerpt/style.css +1 -1
- package/build-style/post-featured-image/editor-rtl.css +1 -0
- package/build-style/post-featured-image/editor.css +1 -0
- package/build-style/post-template/style-rtl.css +1 -1
- package/build-style/post-template/style.css +1 -1
- package/build-style/post-time-to-read/style-rtl.css +91 -0
- package/build-style/post-time-to-read/style.css +91 -0
- package/build-style/pullquote/style-rtl.css +4 -1
- package/build-style/pullquote/style.css +4 -1
- package/build-style/search/style-rtl.css +8 -7
- package/build-style/search/style.css +8 -7
- package/build-style/shortcode/editor-rtl.css +15 -34
- package/build-style/shortcode/editor.css +15 -34
- package/build-style/spacer/editor-rtl.css +4 -2
- package/build-style/spacer/editor.css +4 -2
- package/build-style/style-rtl.css +44 -17
- package/build-style/style.css +44 -17
- package/package.json +31 -31
- package/src/buttons/block.json +1 -0
- package/src/categories/editor.scss +5 -0
- package/src/categories/style.scss +4 -0
- package/src/column/block.json +2 -1
- package/src/columns/block.json +6 -1
- package/src/columns/edit.js +35 -10
- package/src/columns/style.scss +5 -1
- package/src/columns/utils.js +8 -9
- package/src/comments/index.php +1 -0
- package/src/common.scss +1 -1
- package/src/cover/block.json +12 -0
- package/src/cover/edit/index.js +44 -37
- package/src/cover/edit/inspector-controls.js +4 -5
- package/src/cover/edit/resizable-cover-popover.js +82 -0
- package/src/cover/editor.scss +20 -13
- package/src/cover/index.php +9 -10
- package/src/cover/style.scss +2 -1
- package/src/cover/test/__snapshots__/transforms.native.js.snap +2 -2
- package/src/cover/test/edit.js +324 -0
- package/src/details/block.json +54 -0
- package/src/details/edit.js +59 -0
- package/src/details/index.js +35 -0
- package/src/details/save.js +15 -0
- package/src/details/style.scss +3 -0
- package/src/details-content/block.json +50 -0
- package/src/details-content/edit.js +29 -0
- package/src/details-content/index.js +23 -0
- package/src/details-content/save.js +12 -0
- package/src/details-summary/block.json +53 -0
- package/src/details-summary/edit.js +27 -0
- package/src/details-summary/editor.scss +3 -0
- package/src/details-summary/index.js +23 -0
- package/src/details-summary/save.js +13 -0
- package/src/details-summary/style.scss +3 -0
- package/src/editor.scss +1 -0
- package/src/embed/block.json +4 -1
- package/src/embed/embed-link-settings.native.js +1 -1
- package/src/embed/embed-placeholder.js +1 -1
- package/src/file/edit.native.js +0 -2
- package/src/file/style.scss +5 -2
- package/src/gallery/edit.js +5 -2
- package/src/gallery/test/use-get-media.native.js +24 -0
- package/src/gallery/use-get-media.native.js +1 -1
- package/src/gallery/use-image-sizes.js +1 -1
- package/src/group/deprecated.js +4 -2
- package/src/group/edit.js +27 -9
- package/src/group/placeholder.js +13 -1
- package/src/group/variations.js +14 -1
- package/src/home-link/index.php +2 -2
- package/src/image/block.json +9 -2
- package/src/image/edit.js +1 -1
- package/src/image/edit.native.js +1 -1
- package/src/image/image.js +15 -7
- package/src/image/index.php +7 -2
- package/src/image/test/__snapshots__/transforms.native.js.snap +1 -1
- package/src/index.js +13 -3
- package/src/latest-comments/style.scss +1 -1
- package/src/latest-posts/edit.js +3 -0
- package/src/media-text/block.json +1 -1
- package/src/media-text/deprecated.js +235 -3
- package/src/media-text/edit.js +7 -6
- package/src/media-text/media-container.js +1 -5
- package/src/media-text/media-container.native.js +1 -1
- package/src/media-text/test/__snapshots__/transforms.native.js.snap +4 -4
- package/src/navigation/block.json +0 -1
- package/src/navigation/deprecated.js +15 -19
- package/src/navigation/edit/index.js +0 -13
- package/src/navigation/edit/inner-blocks.js +0 -3
- package/src/navigation/edit/unsaved-inner-blocks.js +34 -46
- package/src/navigation/index.php +0 -4
- package/src/navigation/style.scss +6 -4
- package/src/navigation-link/index.php +2 -1
- package/src/navigation-submenu/index.php +30 -76
- package/src/paragraph/test/edit.native.js +356 -1
- package/src/post-author/block.json +0 -1
- package/src/post-author/index.php +1 -1
- package/src/post-date/edit.js +4 -1
- package/src/post-date/index.js +2 -0
- package/src/post-date/variations.js +20 -0
- package/src/post-excerpt/edit.js +48 -16
- package/src/post-excerpt/index.php +3 -3
- package/src/post-excerpt/style.scss +2 -1
- package/src/post-featured-image/dimension-controls.js +7 -3
- package/src/post-featured-image/edit.js +8 -29
- package/src/post-featured-image/editor.scss +1 -0
- package/src/post-template/block.json +1 -1
- package/src/post-template/style.scss +1 -1
- package/src/post-time-to-read/block.json +24 -1
- package/src/post-time-to-read/edit.js +1 -1
- package/src/post-time-to-read/index.php +3 -3
- package/src/post-time-to-read/style.scss +4 -0
- package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -2
- package/src/preformatted/test/edit.native.js +45 -2
- package/src/pullquote/style.scss +5 -1
- package/src/pullquote/test/edit.native.js +70 -0
- package/src/query-title/index.php +2 -5
- package/src/quote/block.json +1 -0
- package/src/quote/test/edit.native.js +92 -0
- package/src/search/index.php +1 -1
- package/src/search/style.scss +16 -12
- package/src/shortcode/editor.scss +26 -5
- package/src/spacer/controls.js +42 -17
- package/src/spacer/edit.js +41 -9
- package/src/spacer/editor.scss +2 -1
- package/src/spacer/save.js +3 -3
- package/src/style.scss +3 -0
- package/src/table/state.js +83 -66
- package/src/term-description/block.json +1 -2
- package/src/utils/clean-empty-object.js +4 -4
- package/src/verse/test/edit.native.js +33 -0
- package/src/video/test/__snapshots__/transforms.native.js.snap +1 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/build/cover/edit/resizable-cover.js.map +0 -1
- package/build/media-text/media-container-icon.js +0 -27
- package/build/media-text/media-container-icon.js.map +0 -1
- package/build-module/cover/edit/resizable-cover.js.map +0 -1
- package/build-module/media-text/media-container-icon.js +0 -17
- package/build-module/media-text/media-container-icon.js.map +0 -1
- package/src/cover/edit/resizable-cover.js +0 -61
- package/src/cover/test/block-controls.js +0 -62
- package/src/media-text/media-container-icon.js +0 -12
|
@@ -206,9 +206,7 @@ export default function CoverInspectorControls( {
|
|
|
206
206
|
isImgElement && (
|
|
207
207
|
<TextareaControl
|
|
208
208
|
__nextHasNoMarginBottom
|
|
209
|
-
label={ __(
|
|
210
|
-
'Alt text (alternative text)'
|
|
211
|
-
) }
|
|
209
|
+
label={ __( 'Alternative text' ) }
|
|
212
210
|
value={ alt }
|
|
213
211
|
onChange={ ( newAlt ) =>
|
|
214
212
|
setAttributes( { alt: newAlt } )
|
|
@@ -217,11 +215,12 @@ export default function CoverInspectorControls( {
|
|
|
217
215
|
<>
|
|
218
216
|
<ExternalLink href="https://www.w3.org/WAI/tutorials/images/decision-tree">
|
|
219
217
|
{ __(
|
|
220
|
-
'Describe the purpose of the image'
|
|
218
|
+
'Describe the purpose of the image.'
|
|
221
219
|
) }
|
|
222
220
|
</ExternalLink>
|
|
221
|
+
<br />
|
|
223
222
|
{ __(
|
|
224
|
-
'Leave empty if
|
|
223
|
+
'Leave empty if decorative.'
|
|
225
224
|
) }
|
|
226
225
|
</>
|
|
227
226
|
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useMemo, useState } from '@wordpress/element';
|
|
10
|
+
import { privateApis as blockEditorPrivateApis } from '@wordpress/block-editor';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { unlock } from '../../private-apis';
|
|
16
|
+
|
|
17
|
+
const RESIZABLE_BOX_ENABLE_OPTION = {
|
|
18
|
+
top: false,
|
|
19
|
+
right: false,
|
|
20
|
+
bottom: true,
|
|
21
|
+
left: false,
|
|
22
|
+
topRight: false,
|
|
23
|
+
bottomRight: false,
|
|
24
|
+
bottomLeft: false,
|
|
25
|
+
topLeft: false,
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default function ResizableCoverPopover( {
|
|
29
|
+
className,
|
|
30
|
+
height,
|
|
31
|
+
minHeight,
|
|
32
|
+
onResize,
|
|
33
|
+
onResizeStart,
|
|
34
|
+
onResizeStop,
|
|
35
|
+
showHandle,
|
|
36
|
+
size,
|
|
37
|
+
width,
|
|
38
|
+
...props
|
|
39
|
+
} ) {
|
|
40
|
+
const { ResizableBoxPopover } = unlock( blockEditorPrivateApis );
|
|
41
|
+
const [ isResizing, setIsResizing ] = useState( false );
|
|
42
|
+
const dimensions = useMemo(
|
|
43
|
+
() => ( { height, minHeight, width } ),
|
|
44
|
+
[ minHeight, height, width ]
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
const resizableBoxProps = {
|
|
48
|
+
className: classnames( className, { 'is-resizing': isResizing } ),
|
|
49
|
+
enable: RESIZABLE_BOX_ENABLE_OPTION,
|
|
50
|
+
onResizeStart: ( _event, _direction, elt ) => {
|
|
51
|
+
onResizeStart( elt.clientHeight );
|
|
52
|
+
onResize( elt.clientHeight );
|
|
53
|
+
},
|
|
54
|
+
onResize: ( _event, _direction, elt ) => {
|
|
55
|
+
onResize( elt.clientHeight );
|
|
56
|
+
if ( ! isResizing ) {
|
|
57
|
+
setIsResizing( true );
|
|
58
|
+
}
|
|
59
|
+
},
|
|
60
|
+
onResizeStop: ( _event, _direction, elt ) => {
|
|
61
|
+
onResizeStop( elt.clientHeight );
|
|
62
|
+
setIsResizing( false );
|
|
63
|
+
},
|
|
64
|
+
showHandle,
|
|
65
|
+
size,
|
|
66
|
+
__experimentalShowTooltip: true,
|
|
67
|
+
__experimentalTooltipProps: {
|
|
68
|
+
axis: 'y',
|
|
69
|
+
position: 'bottom',
|
|
70
|
+
isVisible: isResizing,
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<ResizableBoxPopover
|
|
76
|
+
className="block-library-cover__resizable-box-popover"
|
|
77
|
+
__unstableRefreshSize={ dimensions }
|
|
78
|
+
resizableBoxProps={ resizableBoxProps }
|
|
79
|
+
{ ...props }
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
}
|
package/src/cover/editor.scss
CHANGED
|
@@ -7,24 +7,23 @@
|
|
|
7
7
|
// Override default cover styles
|
|
8
8
|
// because we're not ready yet to show the cover block.
|
|
9
9
|
&.is-placeholder {
|
|
10
|
-
min-height: auto !important;
|
|
11
10
|
padding: 0 !important;
|
|
11
|
+
display: flex;
|
|
12
|
+
align-items: stretch;
|
|
13
|
+
overflow: visible;
|
|
14
|
+
min-height: 240px;
|
|
12
15
|
|
|
13
|
-
// Resizable placeholder for placeholder.
|
|
14
|
-
.block-library-cover__resize-container {
|
|
15
|
-
display: none;
|
|
16
|
-
}
|
|
17
16
|
.components-placeholder {
|
|
18
17
|
&.is-large {
|
|
19
|
-
min-height: 240px;
|
|
20
18
|
justify-content: flex-start;
|
|
21
19
|
z-index: z-index(".wp-block-cover.is-placeholder .components-placeholder.is-large");
|
|
22
|
-
+ .block-library-cover__resize-container {
|
|
23
|
-
min-height: 240px;
|
|
24
|
-
display: block;
|
|
25
|
-
}
|
|
26
20
|
}
|
|
27
21
|
}
|
|
22
|
+
|
|
23
|
+
// Allow focus outline/box-shadow to align with block's min height.
|
|
24
|
+
&:focus::after {
|
|
25
|
+
min-height: auto;
|
|
26
|
+
}
|
|
28
27
|
}
|
|
29
28
|
|
|
30
29
|
&.components-placeholder h2 {
|
|
@@ -88,9 +87,17 @@
|
|
|
88
87
|
min-height: 50px;
|
|
89
88
|
}
|
|
90
89
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
90
|
+
// Prevent resizable box popover form preventing inner block selection.
|
|
91
|
+
.components-popover.block-editor-block-popover.block-library-cover__resizable-box-popover {
|
|
92
|
+
// Additional specificity is required to overcome default block popover
|
|
93
|
+
// pointer events only for the intended wrappers. The default pointer events
|
|
94
|
+
// are still needed for the inner resize handles of the resizable box.
|
|
95
|
+
.components-popover__content > div,
|
|
96
|
+
.block-library-cover__resize-container {
|
|
97
|
+
// The inner drag handle will still have `pointer-events: all` allowing
|
|
98
|
+
// it to continue to be interacted with.
|
|
99
|
+
pointer-events: none;
|
|
100
|
+
}
|
|
94
101
|
}
|
|
95
102
|
|
|
96
103
|
// When uploading background images, show a transparent overlay.
|
package/src/cover/index.php
CHANGED
|
@@ -34,7 +34,7 @@ function render_block_core_cover( $attributes, $content ) {
|
|
|
34
34
|
|
|
35
35
|
/*
|
|
36
36
|
* Inserts the featured image between the (1st) cover 'background' `span` and 'inner_container' `div`,
|
|
37
|
-
* and removes eventual
|
|
37
|
+
* and removes eventual whitespace characters between the two (typically introduced at template level)
|
|
38
38
|
*/
|
|
39
39
|
$inner_container_start = '/<div\b[^>]+wp-block-cover__inner-container[\s|"][^>]*>/U';
|
|
40
40
|
if ( 1 === preg_match( $inner_container_start, $content, $matches, PREG_OFFSET_CAPTURE ) ) {
|
|
@@ -46,19 +46,18 @@ function render_block_core_cover( $attributes, $content ) {
|
|
|
46
46
|
update_post_thumbnail_cache();
|
|
47
47
|
}
|
|
48
48
|
$current_featured_image = get_the_post_thumbnail_url();
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if ( isset( $attributes['minHeight'] ) ) {
|
|
53
|
-
$height_unit = empty( $attributes['minHeightUnit'] ) ? 'px' : $attributes['minHeightUnit'];
|
|
54
|
-
$height = " min-height:{$attributes['minHeight']}{$height_unit}";
|
|
55
|
-
|
|
56
|
-
$styles .= $height;
|
|
49
|
+
if ( ! $current_featured_image ) {
|
|
50
|
+
return $content;
|
|
57
51
|
}
|
|
58
52
|
|
|
59
53
|
$processor = new WP_HTML_Tag_Processor( $content );
|
|
60
54
|
$processor->next_tag();
|
|
61
|
-
|
|
55
|
+
|
|
56
|
+
$styles = $processor->get_attribute( 'style' );
|
|
57
|
+
$merged_styles = ! empty( $styles ) ? $styles . ';' : '';
|
|
58
|
+
$merged_styles .= 'background-image:url(' . esc_url( $current_featured_image ) . ');';
|
|
59
|
+
|
|
60
|
+
$processor->set_attribute( 'style', $merged_styles );
|
|
62
61
|
$content = $processor->get_updated_html();
|
|
63
62
|
}
|
|
64
63
|
|
package/src/cover/style.scss
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
justify-content: center;
|
|
8
8
|
align-items: center;
|
|
9
9
|
padding: 1em;
|
|
10
|
+
overflow: hidden;
|
|
10
11
|
// This block has customizable padding, border-box makes that more predictable.
|
|
11
12
|
box-sizing: border-box;
|
|
12
13
|
// Keep the flex layout direction to the physical direction (LTR) in RTL languages.
|
|
@@ -203,7 +204,7 @@ video.wp-block-cover__video-background {
|
|
|
203
204
|
// Mobile Safari does not support fixed background attachment properly.
|
|
204
205
|
// See also https://stackoverflow.com/questions/24154666/background-size-cover-not-working-on-ios
|
|
205
206
|
// Chrome on Android does not appear to support the attachment at all: https://issuetracker.google.com/issues/36908439
|
|
206
|
-
@supports (-webkit-
|
|
207
|
+
@supports (-webkit-touch-callout: inherit) {
|
|
207
208
|
background-attachment: scroll;
|
|
208
209
|
}
|
|
209
210
|
|
|
@@ -30,7 +30,7 @@ exports[`Cover block transformations with Image to Image block 1`] = `
|
|
|
30
30
|
|
|
31
31
|
exports[`Cover block transformations with Image to Media & Text block 1`] = `
|
|
32
32
|
"<!-- wp:media-text {"mediaId":890,"mediaType":"image","backgroundColor":"luminous-vivid-orange"} -->
|
|
33
|
-
<div class="wp-block-media-text
|
|
33
|
+
<div class="wp-block-media-text is-stacked-on-mobile has-luminous-vivid-orange-background-color has-background"><figure class="wp-block-media-text__media"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-890 size-full"/></figure><div class="wp-block-media-text__content"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","className":"has-text-color has-very-light-gray-color","fontSize":"large"} -->
|
|
34
34
|
<p class="has-text-align-center has-text-color has-very-light-gray-color has-large-font-size">Cool cover</p>
|
|
35
35
|
<!-- /wp:paragraph --></div></div>
|
|
36
36
|
<!-- /wp:media-text -->"
|
|
@@ -60,7 +60,7 @@ exports[`Cover block transformations with Video to Group block 1`] = `
|
|
|
60
60
|
|
|
61
61
|
exports[`Cover block transformations with Video to Media & Text block 1`] = `
|
|
62
62
|
"<!-- wp:media-text {"mediaId":891,"mediaType":"video","backgroundColor":"luminous-vivid-orange"} -->
|
|
63
|
-
<div class="wp-block-media-text
|
|
63
|
+
<div class="wp-block-media-text is-stacked-on-mobile has-luminous-vivid-orange-background-color has-background"><figure class="wp-block-media-text__media"><video controls src="https://i.cloudup.com/YtZFJbuQCE.mov"></video></figure><div class="wp-block-media-text__content"><!-- wp:paragraph {"align":"center","placeholder":"Write title…","className":"has-text-color has-very-light-gray-color","fontSize":"large"} -->
|
|
64
64
|
<p class="has-text-align-center has-text-color has-very-light-gray-color has-large-font-size">Cool cover</p>
|
|
65
65
|
<!-- /wp:paragraph --></div></div>
|
|
66
66
|
<!-- /wp:media-text -->"
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { screen, fireEvent, act, within } from '@testing-library/react';
|
|
5
|
+
import userEvent from '@testing-library/user-event';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Internal dependencies
|
|
9
|
+
*/
|
|
10
|
+
import {
|
|
11
|
+
initializeEditor,
|
|
12
|
+
selectBlock,
|
|
13
|
+
} from 'test/integration/helpers/integration-test-editor';
|
|
14
|
+
|
|
15
|
+
async function setup( attributes ) {
|
|
16
|
+
const testBlock = { name: 'core/cover', attributes };
|
|
17
|
+
return initializeEditor( testBlock );
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
async function createAndSelectBlock() {
|
|
21
|
+
await userEvent.click(
|
|
22
|
+
screen.getByRole( 'button', {
|
|
23
|
+
name: 'Color: Black',
|
|
24
|
+
} )
|
|
25
|
+
);
|
|
26
|
+
await userEvent.click(
|
|
27
|
+
screen.getByRole( 'button', {
|
|
28
|
+
name: 'Select Cover',
|
|
29
|
+
} )
|
|
30
|
+
);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
describe( 'Cover block', () => {
|
|
34
|
+
describe( 'Editor canvas', () => {
|
|
35
|
+
test( 'shows placeholder if background image and color not set', async () => {
|
|
36
|
+
await setup();
|
|
37
|
+
|
|
38
|
+
expect(
|
|
39
|
+
screen.getByRole( 'group', {
|
|
40
|
+
name: 'To edit this block, you need permission to upload media.',
|
|
41
|
+
} )
|
|
42
|
+
).toBeInTheDocument();
|
|
43
|
+
} );
|
|
44
|
+
|
|
45
|
+
test( 'can set overlay color using color picker on block placeholder', async () => {
|
|
46
|
+
const { container } = await setup();
|
|
47
|
+
const colorPicker = screen.getByRole( 'button', {
|
|
48
|
+
name: 'Color: Black',
|
|
49
|
+
} );
|
|
50
|
+
await userEvent.click( colorPicker );
|
|
51
|
+
const color = colorPicker.style.backgroundColor;
|
|
52
|
+
expect(
|
|
53
|
+
screen.queryByRole( 'group', {
|
|
54
|
+
name: 'To edit this block, you need permission to upload media.',
|
|
55
|
+
} )
|
|
56
|
+
).not.toBeInTheDocument();
|
|
57
|
+
|
|
58
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
59
|
+
const overlay = container.getElementsByClassName(
|
|
60
|
+
'wp-block-cover__background'
|
|
61
|
+
);
|
|
62
|
+
expect( overlay[ 0 ] ).toHaveStyle(
|
|
63
|
+
`background-color: ${ color }`
|
|
64
|
+
);
|
|
65
|
+
} );
|
|
66
|
+
|
|
67
|
+
test( 'can have the title edited', async () => {
|
|
68
|
+
await setup();
|
|
69
|
+
|
|
70
|
+
await userEvent.click(
|
|
71
|
+
screen.getByRole( 'button', {
|
|
72
|
+
name: 'Color: Black',
|
|
73
|
+
} )
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
const title = screen.getByLabelText( 'Empty block;', {
|
|
77
|
+
exact: false,
|
|
78
|
+
} );
|
|
79
|
+
await userEvent.click( title );
|
|
80
|
+
await userEvent.keyboard( 'abc' );
|
|
81
|
+
expect( title ).toHaveTextContent( 'abc' );
|
|
82
|
+
} );
|
|
83
|
+
} );
|
|
84
|
+
|
|
85
|
+
describe( 'Block toolbar', () => {
|
|
86
|
+
test( 'full height toggle sets minHeight style attribute to 100vh when clicked', async () => {
|
|
87
|
+
await setup();
|
|
88
|
+
await createAndSelectBlock();
|
|
89
|
+
|
|
90
|
+
expect( screen.getByLabelText( 'Block: Cover' ) ).not.toHaveStyle(
|
|
91
|
+
'min-height: 100vh;'
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
await userEvent.click(
|
|
95
|
+
screen.getByLabelText( 'Toggle full height' )
|
|
96
|
+
);
|
|
97
|
+
|
|
98
|
+
expect( screen.getByLabelText( 'Block: Cover' ) ).toHaveStyle(
|
|
99
|
+
'min-height: 100vh;'
|
|
100
|
+
);
|
|
101
|
+
} );
|
|
102
|
+
|
|
103
|
+
test( 'content position button sets content position', async () => {
|
|
104
|
+
await setup();
|
|
105
|
+
await createAndSelectBlock();
|
|
106
|
+
|
|
107
|
+
await userEvent.click(
|
|
108
|
+
screen.getByLabelText( 'Change content position' )
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
expect( screen.getByLabelText( 'Block: Cover' ) ).not.toHaveClass(
|
|
112
|
+
'has-custom-content-position'
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
await act( async () =>
|
|
116
|
+
within( screen.getByRole( 'grid' ) )
|
|
117
|
+
.getByRole( 'gridcell', {
|
|
118
|
+
name: 'top left',
|
|
119
|
+
} )
|
|
120
|
+
.focus()
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
expect( screen.getByLabelText( 'Block: Cover' ) ).toHaveClass(
|
|
124
|
+
'has-custom-content-position'
|
|
125
|
+
);
|
|
126
|
+
expect( screen.getByLabelText( 'Block: Cover' ) ).toHaveClass(
|
|
127
|
+
'is-position-top-left'
|
|
128
|
+
);
|
|
129
|
+
} );
|
|
130
|
+
} );
|
|
131
|
+
|
|
132
|
+
describe( 'Inspector controls', () => {
|
|
133
|
+
describe( 'Media settings', () => {
|
|
134
|
+
test( 'does not display media settings panel if url is not set', async () => {
|
|
135
|
+
await setup();
|
|
136
|
+
expect(
|
|
137
|
+
screen.queryByRole( 'button', {
|
|
138
|
+
name: 'Media settings',
|
|
139
|
+
} )
|
|
140
|
+
).not.toBeInTheDocument();
|
|
141
|
+
} );
|
|
142
|
+
test( 'displays media settings panel if url is set', async () => {
|
|
143
|
+
await setup( {
|
|
144
|
+
url: 'http://localhost/my-image.jpg',
|
|
145
|
+
} );
|
|
146
|
+
|
|
147
|
+
await selectBlock( 'Block: Cover' );
|
|
148
|
+
expect(
|
|
149
|
+
screen.getByRole( 'button', {
|
|
150
|
+
name: 'Media settings',
|
|
151
|
+
} )
|
|
152
|
+
).toBeInTheDocument();
|
|
153
|
+
} );
|
|
154
|
+
} );
|
|
155
|
+
|
|
156
|
+
test( 'sets hasParallax attribute to true if fixed background toggled', async () => {
|
|
157
|
+
await setup( {
|
|
158
|
+
url: 'http://localhost/my-image.jpg',
|
|
159
|
+
} );
|
|
160
|
+
expect( screen.getByLabelText( 'Block: Cover' ) ).not.toHaveClass(
|
|
161
|
+
'has-parallax'
|
|
162
|
+
);
|
|
163
|
+
await selectBlock( 'Block: Cover' );
|
|
164
|
+
await userEvent.click(
|
|
165
|
+
screen.getByLabelText( 'Fixed background' )
|
|
166
|
+
);
|
|
167
|
+
expect( screen.getByLabelText( 'Block: Cover' ) ).toHaveClass(
|
|
168
|
+
'has-parallax'
|
|
169
|
+
);
|
|
170
|
+
} );
|
|
171
|
+
|
|
172
|
+
test( 'sets isRepeated attribute to true if repeated background toggled', async () => {
|
|
173
|
+
await setup( {
|
|
174
|
+
url: 'http://localhost/my-image.jpg',
|
|
175
|
+
} );
|
|
176
|
+
expect( screen.getByLabelText( 'Block: Cover' ) ).not.toHaveClass(
|
|
177
|
+
'is-repeated'
|
|
178
|
+
);
|
|
179
|
+
await selectBlock( 'Block: Cover' );
|
|
180
|
+
await userEvent.click(
|
|
181
|
+
screen.getByLabelText( 'Repeated background' )
|
|
182
|
+
);
|
|
183
|
+
expect( screen.getByLabelText( 'Block: Cover' ) ).toHaveClass(
|
|
184
|
+
'is-repeated'
|
|
185
|
+
);
|
|
186
|
+
} );
|
|
187
|
+
|
|
188
|
+
test( 'sets left focalPoint attribute when focal point values changed', async () => {
|
|
189
|
+
await setup( {
|
|
190
|
+
url: 'http://localhost/my-image.jpg',
|
|
191
|
+
} );
|
|
192
|
+
|
|
193
|
+
await selectBlock( 'Block: Cover' );
|
|
194
|
+
await userEvent.clear( screen.getByLabelText( 'Left' ) );
|
|
195
|
+
await userEvent.type( screen.getByLabelText( 'Left' ), '100' );
|
|
196
|
+
|
|
197
|
+
expect(
|
|
198
|
+
within( screen.getByLabelText( 'Block: Cover' ) ).getByRole(
|
|
199
|
+
'img'
|
|
200
|
+
)
|
|
201
|
+
).toHaveStyle( 'object-position: 100% 50%;' );
|
|
202
|
+
} );
|
|
203
|
+
|
|
204
|
+
test( 'sets alt attribute if text entered in alt text box', async () => {
|
|
205
|
+
await setup( {
|
|
206
|
+
url: 'http://localhost/my-image.jpg',
|
|
207
|
+
} );
|
|
208
|
+
|
|
209
|
+
await selectBlock( 'Block: Cover' );
|
|
210
|
+
await userEvent.type(
|
|
211
|
+
screen.getByLabelText( 'Alternative text' ),
|
|
212
|
+
'Me'
|
|
213
|
+
);
|
|
214
|
+
expect( screen.getByAltText( 'Me' ) ).toBeInTheDocument();
|
|
215
|
+
} );
|
|
216
|
+
|
|
217
|
+
test( 'clears media when clear media button clicked', async () => {
|
|
218
|
+
await setup( {
|
|
219
|
+
url: 'http://localhost/my-image.jpg',
|
|
220
|
+
} );
|
|
221
|
+
|
|
222
|
+
await selectBlock( 'Block: Cover' );
|
|
223
|
+
expect(
|
|
224
|
+
within( screen.getByLabelText( 'Block: Cover' ) ).getByRole(
|
|
225
|
+
'img'
|
|
226
|
+
)
|
|
227
|
+
).toBeInTheDocument();
|
|
228
|
+
|
|
229
|
+
await userEvent.click(
|
|
230
|
+
screen.getByRole( 'button', {
|
|
231
|
+
name: 'Clear Media',
|
|
232
|
+
} )
|
|
233
|
+
);
|
|
234
|
+
expect(
|
|
235
|
+
within( screen.queryByLabelText( 'Block: Cover' ) ).queryByRole(
|
|
236
|
+
'img'
|
|
237
|
+
)
|
|
238
|
+
).not.toBeInTheDocument();
|
|
239
|
+
} );
|
|
240
|
+
|
|
241
|
+
describe( 'Color panel', () => {
|
|
242
|
+
test( 'applies selected opacity to block when number control value changed', async () => {
|
|
243
|
+
const { container } = await setup();
|
|
244
|
+
|
|
245
|
+
await createAndSelectBlock();
|
|
246
|
+
|
|
247
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
248
|
+
const overlay = container.getElementsByClassName(
|
|
249
|
+
'wp-block-cover__background'
|
|
250
|
+
);
|
|
251
|
+
|
|
252
|
+
expect( overlay[ 0 ] ).toHaveClass( 'has-background-dim-100' );
|
|
253
|
+
|
|
254
|
+
await userEvent.click(
|
|
255
|
+
screen.getByRole( 'tab', {
|
|
256
|
+
name: 'Styles',
|
|
257
|
+
} )
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
fireEvent.change(
|
|
261
|
+
screen.getByRole( 'spinbutton', {
|
|
262
|
+
name: 'Overlay opacity',
|
|
263
|
+
} ),
|
|
264
|
+
{
|
|
265
|
+
target: { value: '40' },
|
|
266
|
+
}
|
|
267
|
+
);
|
|
268
|
+
|
|
269
|
+
expect( overlay[ 0 ] ).toHaveClass( 'has-background-dim-40' );
|
|
270
|
+
} );
|
|
271
|
+
|
|
272
|
+
test( 'applies selected opacity to block when slider moved', async () => {
|
|
273
|
+
const { container } = await setup();
|
|
274
|
+
|
|
275
|
+
await createAndSelectBlock();
|
|
276
|
+
|
|
277
|
+
// eslint-disable-next-line testing-library/no-node-access
|
|
278
|
+
const overlay = container.getElementsByClassName(
|
|
279
|
+
'wp-block-cover__background'
|
|
280
|
+
);
|
|
281
|
+
|
|
282
|
+
expect( overlay[ 0 ] ).toHaveClass( 'has-background-dim-100' );
|
|
283
|
+
|
|
284
|
+
await userEvent.click(
|
|
285
|
+
screen.getByRole( 'tab', {
|
|
286
|
+
name: 'Styles',
|
|
287
|
+
} )
|
|
288
|
+
);
|
|
289
|
+
|
|
290
|
+
fireEvent.change(
|
|
291
|
+
screen.getByRole( 'slider', {
|
|
292
|
+
name: 'Overlay opacity',
|
|
293
|
+
} ),
|
|
294
|
+
{ target: { value: 30 } }
|
|
295
|
+
);
|
|
296
|
+
|
|
297
|
+
expect( overlay[ 0 ] ).toHaveClass( 'has-background-dim-30' );
|
|
298
|
+
} );
|
|
299
|
+
} );
|
|
300
|
+
|
|
301
|
+
describe( 'Dimensions panel', () => {
|
|
302
|
+
test( 'sets minHeight attribute when number control value changed', async () => {
|
|
303
|
+
await setup();
|
|
304
|
+
await createAndSelectBlock();
|
|
305
|
+
await userEvent.click(
|
|
306
|
+
screen.getByRole( 'tab', {
|
|
307
|
+
name: 'Styles',
|
|
308
|
+
} )
|
|
309
|
+
);
|
|
310
|
+
await userEvent.clear(
|
|
311
|
+
screen.getByLabelText( 'Minimum height of cover' )
|
|
312
|
+
);
|
|
313
|
+
await userEvent.type(
|
|
314
|
+
screen.getByLabelText( 'Minimum height of cover' ),
|
|
315
|
+
'300'
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
expect( screen.getByLabelText( 'Block: Cover' ) ).toHaveStyle(
|
|
319
|
+
'min-height: 300px;'
|
|
320
|
+
);
|
|
321
|
+
} );
|
|
322
|
+
} );
|
|
323
|
+
} );
|
|
324
|
+
} );
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
|
+
"apiVersion": 2,
|
|
4
|
+
"__experimental": true,
|
|
5
|
+
"name": "core/details",
|
|
6
|
+
"title": "Details",
|
|
7
|
+
"category": "text",
|
|
8
|
+
"description": "A block that displays a summary and shows or hides additional content.",
|
|
9
|
+
"keywords": [ "disclosure", "summary", "hide", "transcript" ],
|
|
10
|
+
"textdomain": "default",
|
|
11
|
+
"attributes": {
|
|
12
|
+
"showContent": {
|
|
13
|
+
"type": "boolean",
|
|
14
|
+
"default": false
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"supports": {
|
|
18
|
+
"align": true,
|
|
19
|
+
"color": {
|
|
20
|
+
"gradients": true,
|
|
21
|
+
"link": true,
|
|
22
|
+
"__experimentalDefaultControls": {
|
|
23
|
+
"background": true,
|
|
24
|
+
"text": true,
|
|
25
|
+
"link": true
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
"__experimentalBorder": {
|
|
29
|
+
"radius": true,
|
|
30
|
+
"color": true,
|
|
31
|
+
"width": true,
|
|
32
|
+
"style": true
|
|
33
|
+
},
|
|
34
|
+
"html": false,
|
|
35
|
+
"spacing": {
|
|
36
|
+
"margin": true,
|
|
37
|
+
"padding": true
|
|
38
|
+
},
|
|
39
|
+
"typography": {
|
|
40
|
+
"fontSize": true,
|
|
41
|
+
"lineHeight": true,
|
|
42
|
+
"__experimentalFontFamily": true,
|
|
43
|
+
"__experimentalFontWeight": true,
|
|
44
|
+
"__experimentalFontStyle": true,
|
|
45
|
+
"__experimentalTextTransform": true,
|
|
46
|
+
"__experimentalTextDecoration": true,
|
|
47
|
+
"__experimentalLetterSpacing": true,
|
|
48
|
+
"__experimentalDefaultControls": {
|
|
49
|
+
"fontSize": true
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
"style": "wp-block-details"
|
|
54
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
useBlockProps,
|
|
6
|
+
useInnerBlocksProps,
|
|
7
|
+
store as blockEditorStore,
|
|
8
|
+
InspectorControls,
|
|
9
|
+
} from '@wordpress/block-editor';
|
|
10
|
+
import { useSelect } from '@wordpress/data';
|
|
11
|
+
import { PanelBody, ToggleControl } from '@wordpress/components';
|
|
12
|
+
import { __ } from '@wordpress/i18n';
|
|
13
|
+
|
|
14
|
+
const TEMPLATE = [ [ 'core/details-summary' ], [ 'core/details-content' ] ];
|
|
15
|
+
|
|
16
|
+
function DetailsEdit( { attributes, setAttributes, clientId } ) {
|
|
17
|
+
const { showContent } = attributes;
|
|
18
|
+
const blockProps = useBlockProps();
|
|
19
|
+
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
20
|
+
allowedBlocks: TEMPLATE,
|
|
21
|
+
template: TEMPLATE,
|
|
22
|
+
templateLock: 'all',
|
|
23
|
+
} );
|
|
24
|
+
|
|
25
|
+
// Check if either the block or the inner blocks are selected.
|
|
26
|
+
const hasSelection = useSelect( ( select ) => {
|
|
27
|
+
const { isBlockSelected, hasSelectedInnerBlock } =
|
|
28
|
+
select( blockEditorStore );
|
|
29
|
+
/* Sets deep to true to also find blocks inside the details content block. */
|
|
30
|
+
return (
|
|
31
|
+
hasSelectedInnerBlock( clientId, true ) ||
|
|
32
|
+
isBlockSelected( clientId )
|
|
33
|
+
);
|
|
34
|
+
}, [] );
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<>
|
|
38
|
+
<InspectorControls>
|
|
39
|
+
<PanelBody title={ __( 'Settings' ) }>
|
|
40
|
+
<ToggleControl
|
|
41
|
+
label={ __( 'Open by default' ) }
|
|
42
|
+
checked={ showContent }
|
|
43
|
+
onChange={ () =>
|
|
44
|
+
setAttributes( {
|
|
45
|
+
showContent: ! showContent,
|
|
46
|
+
} )
|
|
47
|
+
}
|
|
48
|
+
/>
|
|
49
|
+
</PanelBody>
|
|
50
|
+
</InspectorControls>
|
|
51
|
+
<details
|
|
52
|
+
{ ...innerBlocksProps }
|
|
53
|
+
open={ hasSelection || showContent }
|
|
54
|
+
></details>
|
|
55
|
+
</>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export default DetailsEdit;
|