@wordpress/block-library 11.1.0 → 11.2.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 +32 -0
- package/build/accordion-heading/block.json +1 -0
- package/build/archives/block.json +3 -0
- package/build/audio/edit.cjs +2 -1
- package/build/audio/edit.cjs.map +2 -2
- package/build/avatar/block.json +4 -0
- package/build/avatar/edit.cjs +31 -1
- package/build/avatar/edit.cjs.map +3 -3
- package/build/button/block.json +6 -0
- package/build/button/edit.cjs +9 -6
- package/build/button/edit.cjs.map +2 -2
- package/build/buttons/block.json +6 -1
- package/build/code/block.json +4 -0
- package/build/column/edit.cjs +5 -0
- package/build/column/edit.cjs.map +2 -2
- package/build/columns/block.json +4 -0
- package/build/columns/edit.cjs +21 -112
- package/build/columns/edit.cjs.map +3 -3
- package/build/comments/edit/placeholder.cjs +95 -87
- package/build/comments/edit/placeholder.cjs.map +2 -2
- package/build/comments-pagination/block.json +11 -0
- package/build/cover/block.json +2 -1
- package/build/cover/edit/index.cjs +26 -5
- package/build/cover/edit/index.cjs.map +2 -2
- package/build/cover/edit/inspector-controls.cjs +4 -1
- package/build/cover/edit/inspector-controls.cjs.map +2 -2
- package/build/cover/embed-video-utils.cjs +9 -8
- package/build/cover/embed-video-utils.cjs.map +2 -2
- package/build/cover/view.cjs +21 -0
- package/build/cover/view.cjs.map +7 -0
- package/build/details/block.json +3 -0
- package/build/embed/block.json +6 -1
- package/build/file/block.json +5 -0
- package/build/footnotes/block.json +4 -0
- package/build/gallery/block.json +13 -0
- package/build/gallery/dynamic-gallery.cjs +32 -93
- package/build/gallery/dynamic-gallery.cjs.map +3 -3
- package/build/gallery/edit.cjs +103 -40
- package/build/gallery/edit.cjs.map +2 -2
- package/build/gallery/order-controls.cjs +107 -0
- package/build/gallery/order-controls.cjs.map +7 -0
- package/build/gallery/order-images.cjs +92 -0
- package/build/gallery/order-images.cjs.map +7 -0
- package/build/gallery/order-options.cjs +62 -0
- package/build/gallery/order-options.cjs.map +7 -0
- package/build/gallery/use-dynamic-gallery.cjs +1 -7
- package/build/gallery/use-dynamic-gallery.cjs.map +2 -2
- package/build/gallery/use-get-media.cjs +2 -3
- package/build/gallery/use-get-media.cjs.map +2 -2
- package/build/group/edit.cjs +3 -3
- package/build/group/edit.cjs.map +2 -2
- package/build/heading/block.json +5 -0
- package/build/home-link/block.json +12 -0
- package/build/icon/components/custom-inserter/index.cjs +3 -1
- package/build/icon/components/custom-inserter/index.cjs.map +2 -2
- package/build/icon/edit.cjs +49 -5
- package/build/icon/edit.cjs.map +2 -2
- package/build/image/use-open-image-media-editor-modal.cjs +32 -28
- package/build/image/use-open-image-media-editor-modal.cjs.map +2 -2
- package/build/image/view.cjs +44 -50
- package/build/image/view.cjs.map +2 -2
- package/build/latest-comments/block.json +10 -0
- package/build/latest-posts/block.json +4 -0
- package/build/list/block.json +12 -1
- package/build/list-item/block.json +8 -1
- package/build/list-item/index.cjs +4 -0
- package/build/list-item/index.cjs.map +3 -3
- package/build/loginout/block.json +4 -0
- package/build/math/block.json +4 -0
- package/build/media-text/block.json +18 -0
- package/build/navigation-link/link-ui/index.cjs +33 -19
- package/build/navigation-link/link-ui/index.cjs.map +2 -2
- package/build/navigation-link/shared/index.cjs +5 -0
- package/build/navigation-link/shared/index.cjs.map +2 -2
- package/build/navigation-link/shared/use-block-suggestions.cjs +141 -0
- package/build/navigation-link/shared/use-block-suggestions.cjs.map +7 -0
- package/build/page-list/block.json +4 -0
- package/build/paragraph/block.json +1 -0
- package/build/post-author-biography/block.json +1 -0
- package/build/post-comments-form/block.json +5 -0
- package/build/post-content/block.json +2 -1
- package/build/post-excerpt/block.json +4 -0
- package/build/post-featured-image/block.json +1 -0
- package/build/post-featured-image/edit.cjs +1 -1
- package/build/post-featured-image/edit.cjs.map +2 -2
- package/build/post-terms/block.json +4 -0
- package/build/post-time-to-read/block.json +4 -0
- package/build/post-title/block.json +4 -0
- package/build/preformatted/block.json +4 -0
- package/build/pullquote/block.json +2 -1
- package/build/query-no-results/block.json +4 -0
- package/build/query-pagination/block.json +17 -0
- package/build/query-total/block.json +4 -0
- package/build/quote/block.json +2 -0
- package/build/read-more/block.json +5 -0
- package/build/rss/block.json +4 -0
- package/build/search/block.json +2 -1
- package/build/site-tagline/block.json +4 -0
- package/build/site-title/block.json +4 -0
- package/build/social-links/block.json +1 -0
- package/build/tab-list/block.json +4 -0
- package/build/tab-list/edit.cjs +3 -1
- package/build/tab-list/edit.cjs.map +3 -3
- package/build/tab-list/save.cjs +3 -1
- package/build/tab-list/save.cjs.map +3 -3
- package/build/tab-panels/block.json +3 -0
- package/build/tabs/block.json +3 -0
- package/build/term-count/block.json +5 -0
- package/build/term-description/block.json +4 -0
- package/build/term-name/block.json +6 -1
- package/build/term-template/block.json +4 -0
- package/build/utils/waveform-utils.cjs +2 -2
- package/build/utils/waveform-utils.cjs.map +2 -2
- package/build/verse/block.json +4 -0
- package/build/video/block.json +7 -1
- package/build/video/edit.cjs +10 -2
- package/build/video/edit.cjs.map +2 -2
- package/build-module/accordion-heading/block.json +1 -0
- package/build-module/archives/block.json +3 -0
- package/build-module/audio/edit.mjs +2 -1
- package/build-module/audio/edit.mjs.map +2 -2
- package/build-module/avatar/block.json +4 -0
- package/build-module/avatar/edit.mjs +33 -2
- package/build-module/avatar/edit.mjs.map +2 -2
- package/build-module/button/block.json +6 -0
- package/build-module/button/edit.mjs +11 -7
- package/build-module/button/edit.mjs.map +2 -2
- package/build-module/buttons/block.json +6 -1
- package/build-module/code/block.json +4 -0
- package/build-module/column/edit.mjs +5 -0
- package/build-module/column/edit.mjs.map +2 -2
- package/build-module/columns/block.json +4 -0
- package/build-module/columns/edit.mjs +22 -122
- package/build-module/columns/edit.mjs.map +2 -2
- package/build-module/comments/edit/placeholder.mjs +95 -87
- package/build-module/comments/edit/placeholder.mjs.map +2 -2
- package/build-module/comments-pagination/block.json +11 -0
- package/build-module/cover/block.json +2 -1
- package/build-module/cover/edit/index.mjs +32 -6
- package/build-module/cover/edit/index.mjs.map +2 -2
- package/build-module/cover/edit/inspector-controls.mjs +5 -2
- package/build-module/cover/edit/inspector-controls.mjs.map +2 -2
- package/build-module/cover/embed-video-utils.mjs +9 -8
- package/build-module/cover/embed-video-utils.mjs.map +2 -2
- package/build-module/cover/view.mjs +19 -0
- package/build-module/cover/view.mjs.map +7 -0
- package/build-module/details/block.json +3 -0
- package/build-module/embed/block.json +6 -1
- package/build-module/file/block.json +5 -0
- package/build-module/footnotes/block.json +4 -0
- package/build-module/gallery/block.json +13 -0
- package/build-module/gallery/dynamic-gallery.mjs +33 -97
- package/build-module/gallery/dynamic-gallery.mjs.map +2 -2
- package/build-module/gallery/edit.mjs +110 -42
- package/build-module/gallery/edit.mjs.map +2 -2
- package/build-module/gallery/order-controls.mjs +87 -0
- package/build-module/gallery/order-controls.mjs.map +7 -0
- package/build-module/gallery/order-images.mjs +66 -0
- package/build-module/gallery/order-images.mjs.map +7 -0
- package/build-module/gallery/order-options.mjs +33 -0
- package/build-module/gallery/order-options.mjs.map +7 -0
- package/build-module/gallery/use-dynamic-gallery.mjs +1 -7
- package/build-module/gallery/use-dynamic-gallery.mjs.map +2 -2
- package/build-module/gallery/use-get-media.mjs +2 -3
- package/build-module/gallery/use-get-media.mjs.map +2 -2
- package/build-module/group/edit.mjs +4 -4
- package/build-module/group/edit.mjs.map +2 -2
- package/build-module/heading/block.json +5 -0
- package/build-module/home-link/block.json +12 -0
- package/build-module/icon/components/custom-inserter/index.mjs +3 -1
- package/build-module/icon/components/custom-inserter/index.mjs.map +2 -2
- package/build-module/icon/edit.mjs +50 -6
- package/build-module/icon/edit.mjs.map +2 -2
- package/build-module/image/use-open-image-media-editor-modal.mjs +32 -28
- package/build-module/image/use-open-image-media-editor-modal.mjs.map +2 -2
- package/build-module/image/view.mjs +44 -50
- package/build-module/image/view.mjs.map +2 -2
- package/build-module/latest-comments/block.json +10 -0
- package/build-module/latest-posts/block.json +4 -0
- package/build-module/list/block.json +12 -1
- package/build-module/list-item/block.json +8 -1
- package/build-module/list-item/index.mjs +4 -0
- package/build-module/list-item/index.mjs.map +2 -2
- package/build-module/loginout/block.json +4 -0
- package/build-module/math/block.json +4 -0
- package/build-module/media-text/block.json +18 -0
- package/build-module/navigation-link/link-ui/index.mjs +39 -20
- package/build-module/navigation-link/link-ui/index.mjs.map +2 -2
- package/build-module/navigation-link/shared/index.mjs +6 -0
- package/build-module/navigation-link/shared/index.mjs.map +2 -2
- package/build-module/navigation-link/shared/use-block-suggestions.mjs +120 -0
- package/build-module/navigation-link/shared/use-block-suggestions.mjs.map +7 -0
- package/build-module/page-list/block.json +4 -0
- package/build-module/paragraph/block.json +1 -0
- package/build-module/post-author-biography/block.json +1 -0
- package/build-module/post-comments-form/block.json +5 -0
- package/build-module/post-content/block.json +2 -1
- package/build-module/post-excerpt/block.json +4 -0
- package/build-module/post-featured-image/block.json +1 -0
- package/build-module/post-featured-image/edit.mjs +1 -1
- package/build-module/post-featured-image/edit.mjs.map +2 -2
- package/build-module/post-terms/block.json +4 -0
- package/build-module/post-time-to-read/block.json +4 -0
- package/build-module/post-title/block.json +4 -0
- package/build-module/preformatted/block.json +4 -0
- package/build-module/pullquote/block.json +2 -1
- package/build-module/query-no-results/block.json +4 -0
- package/build-module/query-pagination/block.json +17 -0
- package/build-module/query-total/block.json +4 -0
- package/build-module/quote/block.json +2 -0
- package/build-module/read-more/block.json +5 -0
- package/build-module/rss/block.json +4 -0
- package/build-module/search/block.json +2 -1
- package/build-module/site-tagline/block.json +4 -0
- package/build-module/site-title/block.json +4 -0
- package/build-module/social-links/block.json +1 -0
- package/build-module/tab-list/block.json +4 -0
- package/build-module/tab-list/edit.mjs +4 -1
- package/build-module/tab-list/edit.mjs.map +2 -2
- package/build-module/tab-list/save.mjs +4 -1
- package/build-module/tab-list/save.mjs.map +2 -2
- package/build-module/tab-panels/block.json +3 -0
- package/build-module/tabs/block.json +3 -0
- package/build-module/term-count/block.json +5 -0
- package/build-module/term-description/block.json +4 -0
- package/build-module/term-name/block.json +6 -1
- package/build-module/term-template/block.json +4 -0
- package/build-module/utils/waveform-utils.mjs +1 -1
- package/build-module/utils/waveform-utils.mjs.map +1 -1
- package/build-module/verse/block.json +4 -0
- package/build-module/video/block.json +7 -1
- package/build-module/video/edit.mjs +10 -2
- package/build-module/video/edit.mjs.map +2 -2
- package/build-style/avatar/editor-rtl.css +4 -0
- package/build-style/avatar/editor.css +4 -0
- package/build-style/comments-pagination/style-rtl.css +3 -0
- package/build-style/comments-pagination/style.css +3 -0
- package/build-style/common-rtl.css +32 -1
- package/build-style/common.css +35 -2
- package/build-style/editor-rtl.css +11 -4
- package/build-style/editor.css +11 -4
- package/build-style/embed/style-rtl.css +4 -1
- package/build-style/embed/style.css +4 -1
- package/build-style/gallery/editor-rtl.css +1 -3
- package/build-style/gallery/editor.css +1 -3
- package/build-style/image/style-rtl.css +11 -2
- package/build-style/image/style.css +11 -2
- package/build-style/media-text/style-rtl.css +4 -1
- package/build-style/media-text/style.css +4 -1
- package/build-style/query-pagination/style-rtl.css +3 -0
- package/build-style/query-pagination/style.css +3 -0
- package/build-style/style-rtl.css +70 -9
- package/build-style/style.css +73 -10
- package/build-style/table/editor-rtl.css +6 -1
- package/build-style/table/editor.css +6 -1
- package/build-style/table/style-rtl.css +4 -2
- package/build-style/table/style.css +4 -2
- package/build-style/tag-cloud/style-rtl.css +1 -1
- package/build-style/tag-cloud/style.css +1 -1
- package/build-style/verse/style-rtl.css +8 -1
- package/build-style/verse/style.css +8 -1
- package/build-types/gallery/order-controls.d.ts +58 -0
- package/build-types/gallery/order-controls.d.ts.map +1 -0
- package/build-types/gallery/order-options.d.ts +67 -0
- package/build-types/gallery/order-options.d.ts.map +1 -0
- package/package.json +44 -41
- package/src/accordion-heading/README.md +1 -0
- package/src/accordion-heading/block.json +1 -0
- package/src/archives/README.md +2 -0
- package/src/archives/block.json +3 -0
- package/src/audio/edit.jsx +2 -1
- package/src/avatar/README.md +2 -0
- package/src/avatar/block.json +4 -0
- package/src/avatar/edit.jsx +48 -2
- package/src/avatar/editor.scss +4 -0
- package/src/avatar/index.php +5 -3
- package/src/breadcrumbs/index.php +1 -1
- package/src/button/README.md +4 -0
- package/src/button/block.json +6 -0
- package/src/button/edit.jsx +47 -52
- package/src/button/index.php +47 -0
- package/src/buttons/README.md +4 -0
- package/src/buttons/block.json +6 -1
- package/src/code/README.md +3 -0
- package/src/code/block.json +4 -0
- package/src/column/edit.jsx +6 -0
- package/src/columns/README.md +3 -0
- package/src/columns/block.json +4 -0
- package/src/columns/edit.jsx +1 -131
- package/src/comments/edit/placeholder.jsx +5 -1
- package/src/comments-pagination/README.md +4 -0
- package/src/comments-pagination/block.json +11 -0
- package/src/comments-pagination/style.scss +3 -0
- package/src/common.scss +38 -0
- package/src/cover/README.md +1 -0
- package/src/cover/block.json +2 -1
- package/src/cover/edit/index.jsx +38 -6
- package/src/cover/edit/inspector-controls.jsx +10 -1
- package/src/cover/embed-video-utils.js +18 -10
- package/src/cover/index.php +44 -15
- package/src/cover/test/edit.browser.test.js +182 -2
- package/src/cover/test/embed-video-utils.test.js +48 -0
- package/src/cover/view.js +22 -0
- package/src/details/README.md +2 -0
- package/src/details/block.json +3 -0
- package/src/embed/README.md +4 -0
- package/src/embed/block.json +6 -1
- package/src/embed/style.scss +7 -1
- package/src/file/README.md +4 -0
- package/src/file/block.json +5 -0
- package/src/footnotes/README.md +3 -0
- package/src/footnotes/block.json +4 -0
- package/src/gallery/README.md +13 -0
- package/src/gallery/block.json +13 -0
- package/src/gallery/dynamic-gallery.jsx +11 -91
- package/src/gallery/edit.jsx +146 -47
- package/src/gallery/editor.scss +5 -9
- package/src/gallery/order-controls.tsx +143 -0
- package/src/gallery/order-images.js +111 -0
- package/src/gallery/order-options.ts +75 -0
- package/src/gallery/test/edit.jsdom.test.js +87 -10
- package/src/gallery/test/order-images.js +162 -0
- package/src/gallery/use-dynamic-gallery.js +1 -9
- package/src/gallery/use-get-media.js +7 -2
- package/src/group/edit.jsx +5 -5
- package/src/heading/README.md +4 -0
- package/src/heading/block.json +5 -0
- package/src/home-link/README.md +6 -0
- package/src/home-link/block.json +12 -0
- package/src/icon/components/custom-inserter/index.jsx +5 -1
- package/src/icon/edit.jsx +68 -7
- package/src/icon/index.php +1 -1
- package/src/image/index.php +3 -4
- package/src/image/style.scss +14 -2
- package/src/image/test/use-open-image-media-editor-modal.jsdom.test.js +122 -60
- package/src/image/use-open-image-media-editor-modal.js +37 -41
- package/src/image/view.js +64 -68
- package/src/latest-comments/README.md +3 -0
- package/src/latest-comments/block.json +10 -0
- package/src/latest-posts/README.md +3 -0
- package/src/latest-posts/block.json +4 -0
- package/src/list/README.md +6 -0
- package/src/list/block.json +12 -1
- package/src/list-item/README.md +6 -0
- package/src/list-item/block.json +8 -1
- package/src/list-item/index.js +5 -0
- package/src/loginout/README.md +3 -0
- package/src/loginout/block.json +4 -0
- package/src/math/README.md +3 -0
- package/src/math/block.json +4 -0
- package/src/media-text/README.md +17 -0
- package/src/media-text/block.json +18 -0
- package/src/media-text/style.scss +5 -1
- package/src/navigation/test/use-navigation-menu.jsdom.test.js +1 -1
- package/src/navigation-link/README.md +1 -1
- package/src/navigation-link/link-ui/index.jsx +60 -27
- package/src/navigation-link/link-ui/test/get-suggestions-query.jsdom.test.js +67 -0
- package/src/navigation-link/shared/index.js +4 -0
- package/src/navigation-link/shared/test/use-block-suggestions.jsdom.test.js +158 -0
- package/src/navigation-link/shared/test/use-entity-binding.jsdom.test.js +1 -7
- package/src/navigation-link/shared/use-block-suggestions.js +192 -0
- package/src/page-list/README.md +3 -0
- package/src/page-list/block.json +4 -0
- package/src/paragraph/README.md +1 -0
- package/src/paragraph/block.json +1 -0
- package/src/playlist/test/edit-component.jsdom.test.jsx +11 -11
- package/src/playlist-track/test/edit.jsdom.test.jsx +3 -3
- package/src/post-author-biography/README.md +1 -0
- package/src/post-author-biography/block.json +1 -0
- package/src/post-comments-form/README.md +3 -0
- package/src/post-comments-form/block.json +5 -0
- package/src/post-content/README.md +1 -0
- package/src/post-content/block.json +2 -1
- package/src/post-excerpt/README.md +3 -0
- package/src/post-excerpt/block.json +4 -0
- package/src/post-featured-image/block.json +1 -0
- package/src/post-featured-image/edit.jsx +2 -2
- package/src/post-terms/README.md +3 -0
- package/src/post-terms/block.json +4 -0
- package/src/post-time-to-read/README.md +3 -0
- package/src/post-time-to-read/block.json +4 -0
- package/src/post-title/README.md +3 -0
- package/src/post-title/block.json +4 -0
- package/src/preformatted/README.md +3 -0
- package/src/preformatted/block.json +4 -0
- package/src/pullquote/README.md +1 -0
- package/src/pullquote/block.json +2 -1
- package/src/query-no-results/README.md +3 -0
- package/src/query-no-results/block.json +4 -0
- package/src/query-pagination/README.md +4 -0
- package/src/query-pagination/block.json +17 -0
- package/src/query-pagination/style.scss +3 -0
- package/src/query-total/README.md +3 -0
- package/src/query-total/block.json +4 -0
- package/src/quote/README.md +2 -0
- package/src/quote/block.json +2 -0
- package/src/read-more/README.md +3 -0
- package/src/read-more/block.json +5 -0
- package/src/rss/README.md +3 -0
- package/src/rss/block.json +4 -0
- package/src/search/README.md +1 -0
- package/src/search/block.json +2 -1
- package/src/site-tagline/README.md +3 -0
- package/src/site-tagline/block.json +4 -0
- package/src/site-title/README.md +3 -0
- package/src/site-title/block.json +4 -0
- package/src/social-links/README.md +1 -0
- package/src/social-links/block.json +1 -0
- package/src/tab-list/README.md +2 -0
- package/src/tab-list/block.json +4 -0
- package/src/tab-list/edit.jsx +3 -0
- package/src/tab-list/save.jsx +3 -0
- package/src/tab-panels/README.md +2 -0
- package/src/tab-panels/block.json +3 -0
- package/src/table/editor.scss +8 -2
- package/src/table/style.scss +4 -4
- package/src/tabs/README.md +2 -0
- package/src/tabs/block.json +3 -0
- package/src/tag-cloud/style.scss +1 -1
- package/src/template-part/index.php +16 -3
- package/src/term-count/README.md +4 -0
- package/src/term-count/block.json +5 -0
- package/src/term-description/README.md +3 -0
- package/src/term-description/block.json +4 -0
- package/src/term-name/README.md +4 -0
- package/src/term-name/block.json +6 -1
- package/src/term-template/README.md +3 -0
- package/src/term-template/block.json +4 -0
- package/src/utils/test/waveform-player-auto-init.jsdom.test.js +25 -0
- package/src/utils/test/waveform-player-dependency.jsdom.test.js +7 -60
- package/src/utils/test/waveform-utils.browser.test.js +3 -15
- package/src/utils/waveform-utils.js +1 -1
- package/src/verse/README.md +4 -0
- package/src/verse/block.json +4 -0
- package/src/verse/style.scss +11 -2
- package/src/video/README.md +4 -0
- package/src/video/block.json +7 -1
- package/src/video/edit.jsx +13 -2
- package/build/columns/utils.cjs +0 -112
- package/build/columns/utils.cjs.map +0 -7
- package/build-module/columns/utils.mjs +0 -78
- package/build-module/columns/utils.mjs.map +0 -7
- package/src/columns/test/utils.js +0 -331
- package/src/columns/utils.js +0 -176
package/src/columns/edit.jsx
CHANGED
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import clsx from 'clsx';
|
|
2
2
|
import { __ } from '@wordpress/i18n';
|
|
3
3
|
import {
|
|
4
|
-
Notice,
|
|
5
|
-
RangeControl,
|
|
6
4
|
ToggleControl,
|
|
7
5
|
__experimentalToolsPanel as ToolsPanel,
|
|
8
6
|
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
9
|
-
__experimentalVStack as VStack,
|
|
10
7
|
} from '@wordpress/components';
|
|
11
8
|
import {
|
|
12
9
|
InspectorControls,
|
|
@@ -19,122 +16,16 @@ import {
|
|
|
19
16
|
} from '@wordpress/block-editor';
|
|
20
17
|
import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
|
|
21
18
|
import {
|
|
22
|
-
createBlock,
|
|
23
19
|
createBlocksFromInnerBlocksTemplate,
|
|
24
20
|
store as blocksStore,
|
|
25
21
|
} from '@wordpress/blocks';
|
|
26
|
-
import {
|
|
27
|
-
hasExplicitPercentColumnWidths,
|
|
28
|
-
getMappedColumnWidths,
|
|
29
|
-
getRedistributedColumnWidths,
|
|
30
|
-
toWidthPrecision,
|
|
31
|
-
} from './utils';
|
|
32
22
|
import { useToolsPanelDropdownMenuProps } from '../utils/hooks';
|
|
33
23
|
|
|
34
24
|
const DEFAULT_BLOCK = {
|
|
35
25
|
name: 'core/column',
|
|
36
26
|
};
|
|
37
27
|
|
|
38
|
-
function ColumnInspectorControls( {
|
|
39
|
-
clientId,
|
|
40
|
-
setAttributes,
|
|
41
|
-
isStackedOnMobile,
|
|
42
|
-
} ) {
|
|
43
|
-
const { count, canInsertColumnBlock, minCount } = useSelect(
|
|
44
|
-
( select ) => {
|
|
45
|
-
const { canInsertBlockType, canRemoveBlock, getBlockOrder } =
|
|
46
|
-
select( blockEditorStore );
|
|
47
|
-
const blockOrder = getBlockOrder( clientId );
|
|
48
|
-
|
|
49
|
-
// Get the indexes of columns for which removal is prevented.
|
|
50
|
-
// The highest index will be used to determine the minimum column count.
|
|
51
|
-
const preventRemovalBlockIndexes = blockOrder.reduce(
|
|
52
|
-
( acc, blockId, index ) => {
|
|
53
|
-
if ( ! canRemoveBlock( blockId ) ) {
|
|
54
|
-
acc.push( index );
|
|
55
|
-
}
|
|
56
|
-
return acc;
|
|
57
|
-
},
|
|
58
|
-
[]
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
return {
|
|
62
|
-
count: blockOrder.length,
|
|
63
|
-
canInsertColumnBlock: canInsertBlockType(
|
|
64
|
-
'core/column',
|
|
65
|
-
clientId
|
|
66
|
-
),
|
|
67
|
-
minCount: Math.max( ...preventRemovalBlockIndexes ) + 1,
|
|
68
|
-
};
|
|
69
|
-
},
|
|
70
|
-
[ clientId ]
|
|
71
|
-
);
|
|
72
|
-
const { getBlocks } = useSelect( blockEditorStore );
|
|
73
|
-
const { replaceInnerBlocks } = useDispatch( blockEditorStore );
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Updates the column count, including necessary revisions to child Column
|
|
77
|
-
* blocks to grant required or redistribute available space.
|
|
78
|
-
*
|
|
79
|
-
* @param {number} previousColumns Previous column count.
|
|
80
|
-
* @param {number} newColumns New column count.
|
|
81
|
-
*/
|
|
82
|
-
function updateColumns( previousColumns, newColumns ) {
|
|
83
|
-
let innerBlocks = getBlocks( clientId );
|
|
84
|
-
const hasExplicitWidths = hasExplicitPercentColumnWidths( innerBlocks );
|
|
85
|
-
|
|
86
|
-
// Redistribute available width for existing inner blocks.
|
|
87
|
-
const isAddingColumn = newColumns > previousColumns;
|
|
88
|
-
|
|
89
|
-
if ( isAddingColumn && hasExplicitWidths ) {
|
|
90
|
-
// If adding a new column, assign width to the new column equal to
|
|
91
|
-
// as if it were `1 / columns` of the total available space.
|
|
92
|
-
const newColumnWidth = toWidthPrecision( 100 / newColumns );
|
|
93
|
-
const newlyAddedColumns = newColumns - previousColumns;
|
|
94
|
-
|
|
95
|
-
// Redistribute in consideration of pending block insertion as
|
|
96
|
-
// constraining the available working width.
|
|
97
|
-
const widths = getRedistributedColumnWidths(
|
|
98
|
-
innerBlocks,
|
|
99
|
-
100 - newColumnWidth * newlyAddedColumns
|
|
100
|
-
);
|
|
101
|
-
|
|
102
|
-
innerBlocks = [
|
|
103
|
-
...getMappedColumnWidths( innerBlocks, widths ),
|
|
104
|
-
...Array.from( {
|
|
105
|
-
length: newlyAddedColumns,
|
|
106
|
-
} ).map( () => {
|
|
107
|
-
return createBlock( 'core/column', {
|
|
108
|
-
width: `${ newColumnWidth }%`,
|
|
109
|
-
} );
|
|
110
|
-
} ),
|
|
111
|
-
];
|
|
112
|
-
} else if ( isAddingColumn ) {
|
|
113
|
-
innerBlocks = [
|
|
114
|
-
...innerBlocks,
|
|
115
|
-
...Array.from( {
|
|
116
|
-
length: newColumns - previousColumns,
|
|
117
|
-
} ).map( () => {
|
|
118
|
-
return createBlock( 'core/column' );
|
|
119
|
-
} ),
|
|
120
|
-
];
|
|
121
|
-
} else if ( newColumns < previousColumns ) {
|
|
122
|
-
// The removed column will be the last of the inner blocks.
|
|
123
|
-
innerBlocks = innerBlocks.slice(
|
|
124
|
-
0,
|
|
125
|
-
-( previousColumns - newColumns )
|
|
126
|
-
);
|
|
127
|
-
if ( hasExplicitWidths ) {
|
|
128
|
-
// Redistribute as if block is already removed.
|
|
129
|
-
const widths = getRedistributedColumnWidths( innerBlocks, 100 );
|
|
130
|
-
|
|
131
|
-
innerBlocks = getMappedColumnWidths( innerBlocks, widths );
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
replaceInnerBlocks( clientId, innerBlocks );
|
|
136
|
-
}
|
|
137
|
-
|
|
28
|
+
function ColumnInspectorControls( { setAttributes, isStackedOnMobile } ) {
|
|
138
29
|
const dropdownMenuProps = useToolsPanelDropdownMenuProps();
|
|
139
30
|
|
|
140
31
|
return (
|
|
@@ -147,26 +38,6 @@ function ColumnInspectorControls( {
|
|
|
147
38
|
} }
|
|
148
39
|
dropdownMenuProps={ dropdownMenuProps }
|
|
149
40
|
>
|
|
150
|
-
{ canInsertColumnBlock && (
|
|
151
|
-
<VStack spacing={ 4 } style={ { gridColumn: '1 / -1' } }>
|
|
152
|
-
<RangeControl
|
|
153
|
-
label={ __( 'Columns' ) }
|
|
154
|
-
value={ count }
|
|
155
|
-
onChange={ ( value ) =>
|
|
156
|
-
updateColumns( count, Math.max( minCount, value ) )
|
|
157
|
-
}
|
|
158
|
-
min={ Math.max( 1, minCount ) }
|
|
159
|
-
max={ Math.max( 6, count ) }
|
|
160
|
-
/>
|
|
161
|
-
{ count > 6 && (
|
|
162
|
-
<Notice status="warning" isDismissible={ false }>
|
|
163
|
-
{ __(
|
|
164
|
-
'This column count exceeds the recommended amount and may cause visual breakage.'
|
|
165
|
-
) }
|
|
166
|
-
</Notice>
|
|
167
|
-
) }
|
|
168
|
-
</VStack>
|
|
169
|
-
) }
|
|
170
41
|
<ToolsPanelItem
|
|
171
42
|
label={ __( 'Stack on mobile' ) }
|
|
172
43
|
isShownByDefault
|
|
@@ -243,7 +114,6 @@ function ColumnsEditContainer( { attributes, setAttributes, clientId } ) {
|
|
|
243
114
|
</BlockControls>
|
|
244
115
|
<InspectorControls>
|
|
245
116
|
<ColumnInspectorControls
|
|
246
|
-
clientId={ clientId }
|
|
247
117
|
setAttributes={ setAttributes }
|
|
248
118
|
isStackedOnMobile={ isStackedOnMobile }
|
|
249
119
|
/>
|
|
@@ -3,6 +3,7 @@ import { __, _x, sprintf } from '@wordpress/i18n';
|
|
|
3
3
|
import { useSelect } from '@wordpress/data';
|
|
4
4
|
import { useEntityProp } from '@wordpress/core-data';
|
|
5
5
|
import { createInterpolateElement } from '@wordpress/element';
|
|
6
|
+
import { inertValue } from '@wordpress/react-inert-value';
|
|
6
7
|
import CommentsForm from '../../post-comments-form/form';
|
|
7
8
|
|
|
8
9
|
export default function PostCommentsPlaceholder( { postType, postId } ) {
|
|
@@ -17,7 +18,10 @@ export default function PostCommentsPlaceholder( { postType, postId } ) {
|
|
|
17
18
|
);
|
|
18
19
|
|
|
19
20
|
return (
|
|
20
|
-
<div
|
|
21
|
+
<div
|
|
22
|
+
className="wp-block-comments__legacy-placeholder"
|
|
23
|
+
inert={ inertValue( true ) }
|
|
24
|
+
>
|
|
21
25
|
<h3>
|
|
22
26
|
{
|
|
23
27
|
/* translators: %s: Post title. */
|
|
@@ -43,6 +43,10 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
|
|
|
43
43
|
- [`allowSwitching`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-allowswitching): `false`
|
|
44
44
|
- [`allowInheriting`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-allowinheriting): `false`
|
|
45
45
|
- [`default`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-default): `{"type":"flex"}`
|
|
46
|
+
- [`spacing`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#spacing):
|
|
47
|
+
- `padding`: `true`
|
|
48
|
+
- `margin`: `true`
|
|
49
|
+
- `blockGap`: `true`
|
|
46
50
|
- [`typography`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography):
|
|
47
51
|
- [`fontSize`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-fontsize): `true`
|
|
48
52
|
- [`lineHeight`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-lineheight): `true`
|
|
@@ -50,6 +50,11 @@
|
|
|
50
50
|
"type": "flex"
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
|
+
"spacing": {
|
|
54
|
+
"padding": true,
|
|
55
|
+
"margin": true,
|
|
56
|
+
"blockGap": true
|
|
57
|
+
},
|
|
53
58
|
"typography": {
|
|
54
59
|
"fontSize": true,
|
|
55
60
|
"lineHeight": true,
|
|
@@ -63,6 +68,12 @@
|
|
|
63
68
|
"fontSize": true
|
|
64
69
|
}
|
|
65
70
|
},
|
|
71
|
+
"__experimentalBorder": {
|
|
72
|
+
"color": true,
|
|
73
|
+
"radius": true,
|
|
74
|
+
"style": true,
|
|
75
|
+
"width": true
|
|
76
|
+
},
|
|
66
77
|
"interactivity": {
|
|
67
78
|
"clientNavigation": true
|
|
68
79
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
$pagination-margin: 0.5em;
|
|
2
2
|
.wp-block-comments-pagination {
|
|
3
|
+
// This block has customizable padding, border-box makes that more predictable.
|
|
4
|
+
box-sizing: border-box;
|
|
5
|
+
|
|
3
6
|
// Increased specificity to override blocks default margin.
|
|
4
7
|
> .wp-block-comments-pagination-next,
|
|
5
8
|
> .wp-block-comments-pagination-previous,
|
package/src/common.scss
CHANGED
|
@@ -243,3 +243,41 @@ html :where(.is-position-sticky) {
|
|
|
243
243
|
--wp-admin--admin-bar--position-offset: 0px;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
+
|
|
247
|
+
// Polyfill for two parts of MathML that MathML Core leaves out and that
|
|
248
|
+
// converted LaTeX relies on: the `columnalign` attribute on table cells,
|
|
249
|
+
// which `aligned` and `cases` need, and the `menclose` lines that `\overline`
|
|
250
|
+
// and `\underline` produce. Firefox and Safari render both natively, so the
|
|
251
|
+
// feature query limits the rules to Chromium, which implements MathML Core
|
|
252
|
+
// only. The rules key on the standard attributes, so they apply to any MathML
|
|
253
|
+
// that carries them and can go once Chromium renders them itself.
|
|
254
|
+
// Feature query from https://github.com/ronkok/Temml/blob/v0.10.34/dist/Temml-Local.css#L64-L65
|
|
255
|
+
//
|
|
256
|
+
// The rules live here because both the Math block and the inline math format
|
|
257
|
+
// produce this MathML.
|
|
258
|
+
//
|
|
259
|
+
// Mathematical notation is written left to right in every language, so
|
|
260
|
+
// nothing here is flipped for RTL.
|
|
261
|
+
/*!rtl:begin:ignore*/
|
|
262
|
+
@supports (not (-webkit-backdrop-filter: blur(1px))) and (not (-moz-appearance: none)) {
|
|
263
|
+
// Plain `text-align` does not move a cell's content in Chromium, the
|
|
264
|
+
// `-webkit-` values do.
|
|
265
|
+
mtd[columnalign="right"] {
|
|
266
|
+
text-align: -webkit-right;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
mtd[columnalign="left"] {
|
|
270
|
+
text-align: -webkit-left;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
menclose[notation~="top"] {
|
|
274
|
+
padding-top: 0.1em;
|
|
275
|
+
border-top: 0.065em solid;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
menclose[notation~="bottom"] {
|
|
279
|
+
padding-bottom: 0.1em;
|
|
280
|
+
border-bottom: 0.065em solid;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/*!rtl:end:ignore*/
|
package/src/cover/README.md
CHANGED
|
@@ -160,6 +160,7 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
|
|
|
160
160
|
- [`allowJustification`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-allowjustification): `false`
|
|
161
161
|
- [`interactivity`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#interactivity):
|
|
162
162
|
- `clientNavigation`: `true`
|
|
163
|
+
- `interactive`: `true`
|
|
163
164
|
- [`filter`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#filter):
|
|
164
165
|
- [`duotone`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#filter-duotone): `true`
|
|
165
166
|
- [`allowedBlocks`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#allowedblocks): `true`
|
package/src/cover/block.json
CHANGED
package/src/cover/edit/index.jsx
CHANGED
|
@@ -9,7 +9,12 @@ import {
|
|
|
9
9
|
useState,
|
|
10
10
|
} from '@wordpress/element';
|
|
11
11
|
import { Placeholder, SandBox, Spinner } from '@wordpress/components';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
compose,
|
|
14
|
+
useMergeRefs,
|
|
15
|
+
useReducedMotion,
|
|
16
|
+
useResizeObserver,
|
|
17
|
+
} from '@wordpress/compose';
|
|
13
18
|
import {
|
|
14
19
|
withColors,
|
|
15
20
|
ColorPalette,
|
|
@@ -445,6 +450,8 @@ function CoverEdit( {
|
|
|
445
450
|
[ url, backgroundType ]
|
|
446
451
|
);
|
|
447
452
|
|
|
453
|
+
const prefersReducedMotion = useReducedMotion();
|
|
454
|
+
|
|
448
455
|
// Compute embed HTML for editor display via SandBox
|
|
449
456
|
const embedHtml = useMemo( () => {
|
|
450
457
|
if (
|
|
@@ -453,8 +460,10 @@ function CoverEdit( {
|
|
|
453
460
|
) {
|
|
454
461
|
return null;
|
|
455
462
|
}
|
|
456
|
-
return getBackgroundEmbedHtml( embedPreview.html
|
|
457
|
-
|
|
463
|
+
return getBackgroundEmbedHtml( embedPreview.html, {
|
|
464
|
+
autoplay: ! prefersReducedMotion,
|
|
465
|
+
} );
|
|
466
|
+
}, [ embedPreview, backgroundType, prefersReducedMotion ] );
|
|
458
467
|
|
|
459
468
|
// Set while the media editor has pointed the cover at a freshly
|
|
460
469
|
// generated file the browser hasn't finished loading; cleared by the
|
|
@@ -513,7 +522,11 @@ function CoverEdit( {
|
|
|
513
522
|
);
|
|
514
523
|
|
|
515
524
|
const ref = useRef();
|
|
516
|
-
|
|
525
|
+
// State, not a ref, so that the element is there on the next render.
|
|
526
|
+
const [ dropZoneElement, setDropZoneElement ] = useState( null );
|
|
527
|
+
const blockProps = useBlockProps( {
|
|
528
|
+
ref: useMergeRefs( [ ref, setDropZoneElement ] ),
|
|
529
|
+
} );
|
|
517
530
|
|
|
518
531
|
const innerBlocksProps = useInnerBlocksProps(
|
|
519
532
|
{
|
|
@@ -522,12 +535,20 @@ function CoverEdit( {
|
|
|
522
535
|
{
|
|
523
536
|
allowedBlocks,
|
|
524
537
|
templateLock,
|
|
525
|
-
dropZoneElement
|
|
538
|
+
dropZoneElement,
|
|
526
539
|
}
|
|
527
540
|
);
|
|
528
541
|
|
|
529
542
|
const mediaElement = useRef();
|
|
530
543
|
const editMediaButtonRef = useRef();
|
|
544
|
+
|
|
545
|
+
// `autoPlay` only applies when the video loads, so pause a video that is
|
|
546
|
+
// already playing when the user turns on reduced motion.
|
|
547
|
+
useEffect( () => {
|
|
548
|
+
if ( prefersReducedMotion && isVideoBackground ) {
|
|
549
|
+
mediaElement.current?.pause();
|
|
550
|
+
}
|
|
551
|
+
}, [ prefersReducedMotion, isVideoBackground ] );
|
|
531
552
|
const currentSettings = {
|
|
532
553
|
isVideoBackground,
|
|
533
554
|
isImageBackground,
|
|
@@ -543,11 +564,18 @@ function CoverEdit( {
|
|
|
543
564
|
return;
|
|
544
565
|
}
|
|
545
566
|
|
|
567
|
+
const previousImage = { id, url: propsRef.current.attributes.url };
|
|
568
|
+
let isUndone = false;
|
|
546
569
|
openMediaEditorModal( {
|
|
547
570
|
id,
|
|
548
571
|
onClose: () => {
|
|
549
572
|
editMediaButtonRef.current?.focus();
|
|
550
573
|
},
|
|
574
|
+
onUndo: () => {
|
|
575
|
+
isUndone = true;
|
|
576
|
+
setIsSwappingMedia( false );
|
|
577
|
+
setAttributes( previousImage );
|
|
578
|
+
},
|
|
551
579
|
onUpdate: async ( { id: newId, url: newUrl } ) => {
|
|
552
580
|
if ( typeof newId !== 'number' ) {
|
|
553
581
|
return;
|
|
@@ -569,6 +597,10 @@ function CoverEdit( {
|
|
|
569
597
|
if ( newUrl ) {
|
|
570
598
|
const averageBackgroundColor =
|
|
571
599
|
await getMediaColor( newUrl );
|
|
600
|
+
// Snackbar Undo can run while the image color is loading.
|
|
601
|
+
if ( isUndone ) {
|
|
602
|
+
return;
|
|
603
|
+
}
|
|
572
604
|
|
|
573
605
|
// Read latest values after await to avoid stale closures.
|
|
574
606
|
const {
|
|
@@ -836,7 +868,7 @@ function CoverEdit( {
|
|
|
836
868
|
<video
|
|
837
869
|
ref={ mediaElement }
|
|
838
870
|
className="wp-block-cover__video-background"
|
|
839
|
-
autoPlay
|
|
871
|
+
autoPlay={ ! prefersReducedMotion }
|
|
840
872
|
muted
|
|
841
873
|
loop
|
|
842
874
|
src={ url }
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
__experimentalUnitControl as UnitControl,
|
|
11
11
|
__experimentalParseQuantityAndUnitFromRawValue as parseQuantityAndUnitFromRawValue,
|
|
12
12
|
} from '@wordpress/components';
|
|
13
|
-
import { useInstanceId } from '@wordpress/compose';
|
|
13
|
+
import { useInstanceId, useReducedMotion } from '@wordpress/compose';
|
|
14
14
|
import {
|
|
15
15
|
InspectorControls,
|
|
16
16
|
useSettings,
|
|
@@ -227,6 +227,8 @@ export default function CoverInspectorControls( {
|
|
|
227
227
|
|
|
228
228
|
const showFocalPointPicker = isVideoBackground || isImageBackground;
|
|
229
229
|
|
|
230
|
+
const prefersReducedMotion = useReducedMotion();
|
|
231
|
+
|
|
230
232
|
const imperativeFocalPointPreview = ( value ) => {
|
|
231
233
|
const [ styleOfRef, property ] = mediaElement.current
|
|
232
234
|
? [ mediaElement.current.style, 'objectPosition' ]
|
|
@@ -396,8 +398,15 @@ export default function CoverInspectorControls( {
|
|
|
396
398
|
}
|
|
397
399
|
>
|
|
398
400
|
<FocalPointPicker
|
|
401
|
+
// `autoPlay` only applies when the
|
|
402
|
+
// video loads, so remount the picker
|
|
403
|
+
// to stop a preview that is already
|
|
404
|
+
// playing when the user turns on
|
|
405
|
+
// reduced motion.
|
|
406
|
+
key={ prefersReducedMotion }
|
|
399
407
|
label={ __( 'Focal point' ) }
|
|
400
408
|
url={ url }
|
|
409
|
+
autoPlay={ ! prefersReducedMotion }
|
|
401
410
|
value={ focalPoint }
|
|
402
411
|
onDragStart={ imperativeFocalPointPreview }
|
|
403
412
|
onDrag={ imperativeFocalPointPreview }
|
|
@@ -94,17 +94,19 @@ function findVideoEmbedProvider(
|
|
|
94
94
|
/**
|
|
95
95
|
* Modifies embed HTML to use background video parameters.
|
|
96
96
|
*
|
|
97
|
-
* @param {string}
|
|
97
|
+
* @param {string} html The original embed HTML.
|
|
98
|
+
* @param {Object} options Options.
|
|
99
|
+
* @param {boolean} options.autoplay Whether the video should start playing on load.
|
|
98
100
|
* @return {string|null} The modified embed HTML, or null if not possible.
|
|
99
101
|
*/
|
|
100
|
-
export function getBackgroundEmbedHtml( html ) {
|
|
102
|
+
export function getBackgroundEmbedHtml( html, { autoplay = true } = {} ) {
|
|
101
103
|
const srcMatch = html?.match( /src=["']([^"']+)["']/ );
|
|
102
104
|
if ( ! srcMatch ) {
|
|
103
105
|
return null;
|
|
104
106
|
}
|
|
105
107
|
|
|
106
108
|
const iframeSrc = srcMatch[ 1 ];
|
|
107
|
-
const backgroundSrc = getBackgroundVideoSrc( iframeSrc );
|
|
109
|
+
const backgroundSrc = getBackgroundVideoSrc( iframeSrc, { autoplay } );
|
|
108
110
|
return html.replace( iframeSrc, backgroundSrc );
|
|
109
111
|
}
|
|
110
112
|
|
|
@@ -150,10 +152,12 @@ export function detectProviderFromSrc( src ) {
|
|
|
150
152
|
* Modifies an iframe src URL to add background video parameters.
|
|
151
153
|
* Automatically detects the provider from the URL.
|
|
152
154
|
*
|
|
153
|
-
* @param {string}
|
|
155
|
+
* @param {string} src The iframe src URL.
|
|
156
|
+
* @param {Object} options Options.
|
|
157
|
+
* @param {boolean} options.autoplay Whether the video should start playing on load.
|
|
154
158
|
* @return {string} The modified URL.
|
|
155
159
|
*/
|
|
156
|
-
export function getBackgroundVideoSrc( src ) {
|
|
160
|
+
export function getBackgroundVideoSrc( src, { autoplay = true } = {} ) {
|
|
157
161
|
if ( ! src ) {
|
|
158
162
|
return src;
|
|
159
163
|
}
|
|
@@ -164,11 +168,14 @@ export function getBackgroundVideoSrc( src ) {
|
|
|
164
168
|
// Detect provider from the iframe src URL
|
|
165
169
|
const provider = detectProviderFromSrc( src );
|
|
166
170
|
|
|
171
|
+
if ( autoplay ) {
|
|
172
|
+
url.searchParams.set( 'autoplay', '1' );
|
|
173
|
+
}
|
|
174
|
+
|
|
167
175
|
// Add provider-specific parameters for background video behavior
|
|
168
176
|
switch ( provider ) {
|
|
169
177
|
case 'youtube':
|
|
170
178
|
// YouTube parameters for background video
|
|
171
|
-
url.searchParams.set( 'autoplay', '1' );
|
|
172
179
|
url.searchParams.set( 'mute', '1' );
|
|
173
180
|
url.searchParams.set( 'loop', '1' );
|
|
174
181
|
url.searchParams.set( 'controls', '0' );
|
|
@@ -185,24 +192,25 @@ export function getBackgroundVideoSrc( src ) {
|
|
|
185
192
|
|
|
186
193
|
case 'vimeo':
|
|
187
194
|
// Vimeo parameters for background video
|
|
188
|
-
url.searchParams.set( 'autoplay', '1' );
|
|
189
195
|
url.searchParams.set( 'muted', '1' );
|
|
190
196
|
url.searchParams.set( 'loop', '1' );
|
|
191
|
-
|
|
197
|
+
// Vimeo's background mode always autoplays, so it can only be
|
|
198
|
+
// used when autoplay is allowed.
|
|
199
|
+
if ( autoplay ) {
|
|
200
|
+
url.searchParams.set( 'background', '1' );
|
|
201
|
+
}
|
|
192
202
|
url.searchParams.set( 'controls', '0' );
|
|
193
203
|
break;
|
|
194
204
|
|
|
195
205
|
case 'videopress':
|
|
196
206
|
case 'wordpress-tv':
|
|
197
207
|
// VideoPress parameters
|
|
198
|
-
url.searchParams.set( 'autoplay', '1' );
|
|
199
208
|
url.searchParams.set( 'loop', '1' );
|
|
200
209
|
url.searchParams.set( 'muted', '1' );
|
|
201
210
|
break;
|
|
202
211
|
|
|
203
212
|
default:
|
|
204
213
|
// Generic parameters that might work for other providers
|
|
205
|
-
url.searchParams.set( 'autoplay', '1' );
|
|
206
214
|
url.searchParams.set( 'muted', '1' );
|
|
207
215
|
url.searchParams.set( 'loop', '1' );
|
|
208
216
|
break;
|
package/src/cover/index.php
CHANGED
|
@@ -26,6 +26,10 @@ function render_block_core_cover( $attributes, $content ) {
|
|
|
26
26
|
) {
|
|
27
27
|
$url = $attributes['url'];
|
|
28
28
|
|
|
29
|
+
// The view script decides whether the embed may autoplay, so it is only
|
|
30
|
+
// needed for embed backgrounds.
|
|
31
|
+
wp_enqueue_script_module( '@wordpress/block-library/cover/view' );
|
|
32
|
+
|
|
29
33
|
// Use WordPress's native oEmbed processing (includes caching).
|
|
30
34
|
$oembed_html = wp_oembed_get( $url );
|
|
31
35
|
|
|
@@ -50,7 +54,8 @@ function render_block_core_cover( $attributes, $content ) {
|
|
|
50
54
|
}
|
|
51
55
|
|
|
52
56
|
// Modify iframe src to add background video parameters based on provider.
|
|
53
|
-
$parsed_url
|
|
57
|
+
$parsed_url = wp_parse_url( $iframe_src );
|
|
58
|
+
$reduced_motion_src = null;
|
|
54
59
|
if ( $parsed_url && isset( $parsed_url['host'] ) ) {
|
|
55
60
|
// Parse existing query parameters.
|
|
56
61
|
$query_params = array();
|
|
@@ -58,9 +63,12 @@ function render_block_core_cover( $attributes, $content ) {
|
|
|
58
63
|
parse_str( $parsed_url['query'], $query_params );
|
|
59
64
|
}
|
|
60
65
|
|
|
61
|
-
// Add background video parameters based on provider.
|
|
66
|
+
// Add background video parameters based on provider. The
|
|
67
|
+
// autoplay parameters are kept separate so a source without
|
|
68
|
+
// them can also be built, which the view script swaps in for
|
|
69
|
+
// a visitor who has asked for reduced motion.
|
|
70
|
+
$autoplay_params = array();
|
|
62
71
|
if ( 'youtube' === $provider ) {
|
|
63
|
-
$query_params['autoplay'] = '1';
|
|
64
72
|
$query_params['mute'] = '1';
|
|
65
73
|
$query_params['loop'] = '1';
|
|
66
74
|
$query_params['controls'] = '0';
|
|
@@ -74,32 +82,53 @@ function render_block_core_cover( $attributes, $content ) {
|
|
|
74
82
|
if ( $video_id ) {
|
|
75
83
|
$query_params['playlist'] = $video_id;
|
|
76
84
|
}
|
|
85
|
+
|
|
86
|
+
$autoplay_params['autoplay'] = '1';
|
|
77
87
|
} elseif ( 'vimeo' === $provider ) {
|
|
78
|
-
$query_params['autoplay'] = '1';
|
|
79
88
|
$query_params['muted'] = '1';
|
|
80
89
|
$query_params['loop'] = '1';
|
|
81
|
-
$query_params['background'] = '1';
|
|
82
90
|
$query_params['controls'] = '0';
|
|
83
91
|
$query_params['transparent'] = '0';
|
|
92
|
+
|
|
93
|
+
// Vimeo's background mode always autoplays, so it can only
|
|
94
|
+
// be used when autoplay is allowed.
|
|
95
|
+
$autoplay_params['autoplay'] = '1';
|
|
96
|
+
$autoplay_params['background'] = '1';
|
|
84
97
|
} elseif ( 'videopress' === $provider || 'wordpress-tv' === $provider ) {
|
|
85
|
-
$query_params['
|
|
86
|
-
$query_params['
|
|
87
|
-
|
|
98
|
+
$query_params['loop'] = '1';
|
|
99
|
+
$query_params['muted'] = '1';
|
|
100
|
+
|
|
101
|
+
$autoplay_params['autoplay'] = '1';
|
|
88
102
|
}
|
|
89
103
|
|
|
90
104
|
// Rebuild the URL with new parameters.
|
|
91
|
-
$
|
|
105
|
+
$iframe_base = $parsed_url['scheme'] . '://' . $parsed_url['host'];
|
|
92
106
|
if ( isset( $parsed_url['path'] ) ) {
|
|
93
|
-
$
|
|
94
|
-
}
|
|
95
|
-
if ( ! empty( $query_params ) ) {
|
|
96
|
-
$iframe_src .= '?' . http_build_query( $query_params );
|
|
107
|
+
$iframe_base .= $parsed_url['path'];
|
|
97
108
|
}
|
|
109
|
+
|
|
110
|
+
$reduced_motion_src = empty( $query_params )
|
|
111
|
+
? $iframe_base
|
|
112
|
+
: $iframe_base . '?' . http_build_query( $query_params );
|
|
113
|
+
|
|
114
|
+
$iframe_src = empty( $autoplay_params )
|
|
115
|
+
? $reduced_motion_src
|
|
116
|
+
: $iframe_base . '?' . http_build_query( array_merge( $query_params, $autoplay_params ) );
|
|
98
117
|
}
|
|
99
118
|
|
|
100
|
-
// Build the iframe HTML that will replace the figure.
|
|
119
|
+
// Build the iframe HTML that will replace the figure. The server
|
|
120
|
+
// renders the autoplaying source, and the view script swaps in the
|
|
121
|
+
// one without autoplay for a visitor who prefers reduced motion.
|
|
101
122
|
$iframe_html = sprintf(
|
|
102
|
-
'<div class="wp-block-cover__video-background wp-block-cover__embed-background"><iframe src="%s" title="Background video" frameborder="0" allow="autoplay; fullscreen"></iframe></div>',
|
|
123
|
+
'<div class="wp-block-cover__video-background wp-block-cover__embed-background" data-wp-interactive="core/cover" data-wp-context=\'%s\'><iframe src="%s" data-wp-bind--src="state.videoSrc" title="Background video" frameborder="0" allow="autoplay; fullscreen"></iframe></div>',
|
|
124
|
+
esc_attr(
|
|
125
|
+
wp_json_encode(
|
|
126
|
+
array(
|
|
127
|
+
'src' => $iframe_src,
|
|
128
|
+
'reducedMotionSrc' => $reduced_motion_src,
|
|
129
|
+
)
|
|
130
|
+
)
|
|
131
|
+
),
|
|
103
132
|
esc_url( $iframe_src )
|
|
104
133
|
);
|
|
105
134
|
|