@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
|
@@ -1,12 +1,44 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, test } from 'vitest';
|
|
1
|
+
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
|
2
2
|
import { userEvent } from 'vitest/browser';
|
|
3
|
+
import {
|
|
4
|
+
cleanup as cleanupBrowser,
|
|
5
|
+
render as renderBrowser,
|
|
6
|
+
} from 'vitest-browser-react';
|
|
3
7
|
import { screen, act, within, waitFor } from '@testing-library/react';
|
|
4
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
createBlock,
|
|
10
|
+
getBlockTypes,
|
|
11
|
+
unregisterBlockType,
|
|
12
|
+
} from '@wordpress/blocks';
|
|
13
|
+
import { createElement, useState } from '@wordpress/element';
|
|
14
|
+
import { dispatch, select } from '@wordpress/data';
|
|
15
|
+
import {
|
|
16
|
+
store as richTextStore,
|
|
17
|
+
unregisterFormatType,
|
|
18
|
+
} from '@wordpress/rich-text';
|
|
19
|
+
import {
|
|
20
|
+
BlockInspector,
|
|
21
|
+
privateApis as blockEditorPrivateApis,
|
|
22
|
+
store as blockEditorStore,
|
|
23
|
+
} from '@wordpress/block-editor';
|
|
5
24
|
import {
|
|
6
25
|
initializeEditor,
|
|
7
26
|
selectBlock,
|
|
8
27
|
} from '@wordpress/integration-tests/helpers/integration-test-editor';
|
|
9
28
|
import { registerCoreBlocks } from '@wordpress/block-library';
|
|
29
|
+
// Keep the matrix popover above the block toolbar, as in the editor.
|
|
30
|
+
import '../../../../block-editor/src/components/block-popover/style.scss';
|
|
31
|
+
import '../../../../components/src/popover/style.scss';
|
|
32
|
+
import { unlock } from '../../lock-unlock';
|
|
33
|
+
import { getMediaColor } from '../edit/color-utils';
|
|
34
|
+
|
|
35
|
+
vi.mock( import( '../edit/color-utils' ), { spy: true } );
|
|
36
|
+
|
|
37
|
+
const {
|
|
38
|
+
ExperimentalBlockCanvas: BlockCanvas,
|
|
39
|
+
ExperimentalBlockEditorProvider: BlockEditorProvider,
|
|
40
|
+
openMediaEditorModalKey,
|
|
41
|
+
} = unlock( blockEditorPrivateApis );
|
|
10
42
|
const defaultSettings = {
|
|
11
43
|
__experimentalFeatures: {
|
|
12
44
|
color: {
|
|
@@ -207,6 +239,154 @@ describe( 'Cover block', () => {
|
|
|
207
239
|
} );
|
|
208
240
|
} );
|
|
209
241
|
|
|
242
|
+
describe( 'media editor Undo', () => {
|
|
243
|
+
const originalUrl =
|
|
244
|
+
'data:image/svg+xml,' +
|
|
245
|
+
encodeURIComponent(
|
|
246
|
+
'<svg xmlns="http://www.w3.org/2000/svg" width="10" height="10"><rect width="10" height="10" fill="black"/></svg>'
|
|
247
|
+
);
|
|
248
|
+
const updatedImage = { id: 11, url: `${ originalUrl }#edited` };
|
|
249
|
+
|
|
250
|
+
beforeEach( () => {
|
|
251
|
+
vi.mocked( getMediaColor ).mockResolvedValue( '#ffffff' );
|
|
252
|
+
} );
|
|
253
|
+
|
|
254
|
+
afterEach( async () => {
|
|
255
|
+
await cleanupBrowser();
|
|
256
|
+
getBlockTypes().forEach( ( { name } ) =>
|
|
257
|
+
unregisterBlockType( name )
|
|
258
|
+
);
|
|
259
|
+
select( richTextStore )
|
|
260
|
+
.getFormatTypes()
|
|
261
|
+
.forEach( ( { name } ) => unregisterFormatType( name ) );
|
|
262
|
+
} );
|
|
263
|
+
|
|
264
|
+
async function openMediaEditor( initialAttributes = {} ) {
|
|
265
|
+
const openModal = vi.fn();
|
|
266
|
+
const block = createBlock( 'core/cover', {
|
|
267
|
+
id: 10,
|
|
268
|
+
url: originalUrl,
|
|
269
|
+
backgroundType: 'image',
|
|
270
|
+
sizeSlug: 'medium',
|
|
271
|
+
overlayColor: 'black',
|
|
272
|
+
isDark: true,
|
|
273
|
+
isUserOverlayColor: false,
|
|
274
|
+
...initialAttributes,
|
|
275
|
+
} );
|
|
276
|
+
function TestEditor() {
|
|
277
|
+
const [ blocks, setBlocks ] = useState( [ block ] );
|
|
278
|
+
return createElement(
|
|
279
|
+
BlockEditorProvider,
|
|
280
|
+
{
|
|
281
|
+
value: blocks,
|
|
282
|
+
onInput: setBlocks,
|
|
283
|
+
onChange: setBlocks,
|
|
284
|
+
useSubRegistry: false,
|
|
285
|
+
settings: {
|
|
286
|
+
...defaultSettings,
|
|
287
|
+
[ openMediaEditorModalKey ]: openModal,
|
|
288
|
+
},
|
|
289
|
+
},
|
|
290
|
+
createElement( BlockInspector ),
|
|
291
|
+
createElement( BlockCanvas, {
|
|
292
|
+
height: '100%',
|
|
293
|
+
shouldIframe: false,
|
|
294
|
+
} )
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
await renderBrowser( createElement( TestEditor ) );
|
|
298
|
+
await userEvent.click( screen.getByLabelText( 'Block: Cover' ) );
|
|
299
|
+
await userEvent.click(
|
|
300
|
+
screen.getByRole( 'button', { name: 'Edit image' } )
|
|
301
|
+
);
|
|
302
|
+
const { clientId } = select( blockEditorStore ).getBlocks()[ 0 ];
|
|
303
|
+
return {
|
|
304
|
+
...openModal.mock.calls[ 0 ][ 0 ],
|
|
305
|
+
getAttributes: () =>
|
|
306
|
+
select( blockEditorStore ).getBlockAttributes( clientId ),
|
|
307
|
+
editAttributes: ( attributes ) =>
|
|
308
|
+
dispatch( blockEditorStore ).updateBlockAttributes(
|
|
309
|
+
clientId,
|
|
310
|
+
attributes
|
|
311
|
+
),
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
test( 'restores only the previous image without reverting Cover settings', async () => {
|
|
316
|
+
const { onUpdate, onUndo, getAttributes, editAttributes } =
|
|
317
|
+
await openMediaEditor();
|
|
318
|
+
await act( () => onUpdate( updatedImage ) );
|
|
319
|
+
expect( getAttributes() ).toMatchObject( {
|
|
320
|
+
id: 11,
|
|
321
|
+
sizeSlug: 'full',
|
|
322
|
+
overlayColor: 'white',
|
|
323
|
+
isDark: false,
|
|
324
|
+
} );
|
|
325
|
+
await act( () =>
|
|
326
|
+
editAttributes( { dimRatio: 75, sizeSlug: 'large' } )
|
|
327
|
+
);
|
|
328
|
+
const beforeUndo = getAttributes();
|
|
329
|
+
|
|
330
|
+
act( () => onUndo() );
|
|
331
|
+
|
|
332
|
+
expect( getAttributes() ).toEqual( {
|
|
333
|
+
...beforeUndo,
|
|
334
|
+
id: 10,
|
|
335
|
+
url: originalUrl,
|
|
336
|
+
} );
|
|
337
|
+
} );
|
|
338
|
+
|
|
339
|
+
test( 'preserves an overlay chosen after saving when undoing the media update', async () => {
|
|
340
|
+
const { onUpdate, onUndo, getAttributes, editAttributes } =
|
|
341
|
+
await openMediaEditor();
|
|
342
|
+
await act( () => onUpdate( updatedImage ) );
|
|
343
|
+
await act( () =>
|
|
344
|
+
editAttributes( {
|
|
345
|
+
overlayColor: undefined,
|
|
346
|
+
customOverlayColor: '#000000',
|
|
347
|
+
isUserOverlayColor: true,
|
|
348
|
+
dimRatio: 90,
|
|
349
|
+
isDark: true,
|
|
350
|
+
} )
|
|
351
|
+
);
|
|
352
|
+
|
|
353
|
+
const beforeUndo = getAttributes();
|
|
354
|
+
act( () => onUndo() );
|
|
355
|
+
|
|
356
|
+
expect( getAttributes() ).toEqual( {
|
|
357
|
+
...beforeUndo,
|
|
358
|
+
id: 10,
|
|
359
|
+
url: originalUrl,
|
|
360
|
+
} );
|
|
361
|
+
} );
|
|
362
|
+
|
|
363
|
+
test( 'does not reapply a media update when Undo runs before its color loads', async () => {
|
|
364
|
+
const { onUpdate, onUndo, getAttributes } = await openMediaEditor();
|
|
365
|
+
const previous = getAttributes();
|
|
366
|
+
let resolveColor;
|
|
367
|
+
vi.mocked( getMediaColor ).mockReturnValueOnce(
|
|
368
|
+
new Promise( ( resolve ) => {
|
|
369
|
+
resolveColor = resolve;
|
|
370
|
+
} )
|
|
371
|
+
);
|
|
372
|
+
let updatePromise;
|
|
373
|
+
act( () => {
|
|
374
|
+
updatePromise = onUpdate( updatedImage );
|
|
375
|
+
} );
|
|
376
|
+
|
|
377
|
+
act( () => onUndo() );
|
|
378
|
+
await act( async () => {
|
|
379
|
+
resolveColor( '#ffffff' );
|
|
380
|
+
await updatePromise;
|
|
381
|
+
} );
|
|
382
|
+
|
|
383
|
+
expect( getAttributes() ).toEqual( previous );
|
|
384
|
+
expect(
|
|
385
|
+
screen.getByRole( 'button', { name: 'Edit image' } )
|
|
386
|
+
).toBeEnabled();
|
|
387
|
+
} );
|
|
388
|
+
} );
|
|
389
|
+
|
|
210
390
|
describe( 'Inspector controls', () => {
|
|
211
391
|
describe( 'Media settings', () => {
|
|
212
392
|
test( 'does not display media settings panel if url is not set', async () => {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
getBackgroundEmbedHtml,
|
|
4
|
+
getBackgroundVideoSrc,
|
|
5
|
+
} from '../embed-video-utils';
|
|
6
|
+
|
|
7
|
+
const YOUTUBE_SRC = 'https://www.youtube.com/embed/abc123?feature=oembed';
|
|
8
|
+
const VIMEO_SRC = 'https://player.vimeo.com/video/123456';
|
|
9
|
+
|
|
10
|
+
describe( 'getBackgroundVideoSrc', () => {
|
|
11
|
+
it( 'adds autoplay by default', () => {
|
|
12
|
+
const url = new URL( getBackgroundVideoSrc( YOUTUBE_SRC ) );
|
|
13
|
+
|
|
14
|
+
expect( url.searchParams.get( 'autoplay' ) ).toBe( '1' );
|
|
15
|
+
expect( url.searchParams.get( 'loop' ) ).toBe( '1' );
|
|
16
|
+
} );
|
|
17
|
+
|
|
18
|
+
it( 'leaves out autoplay when autoplay is disabled', () => {
|
|
19
|
+
const url = new URL(
|
|
20
|
+
getBackgroundVideoSrc( YOUTUBE_SRC, { autoplay: false } )
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
expect( url.searchParams.has( 'autoplay' ) ).toBe( false );
|
|
24
|
+
expect( url.searchParams.get( 'loop' ) ).toBe( '1' );
|
|
25
|
+
} );
|
|
26
|
+
|
|
27
|
+
it( 'uses Vimeo background mode only when autoplay is enabled', () => {
|
|
28
|
+
const autoplayUrl = new URL( getBackgroundVideoSrc( VIMEO_SRC ) );
|
|
29
|
+
const pausedUrl = new URL(
|
|
30
|
+
getBackgroundVideoSrc( VIMEO_SRC, { autoplay: false } )
|
|
31
|
+
);
|
|
32
|
+
|
|
33
|
+
expect( autoplayUrl.searchParams.get( 'background' ) ).toBe( '1' );
|
|
34
|
+
expect( pausedUrl.searchParams.has( 'background' ) ).toBe( false );
|
|
35
|
+
expect( pausedUrl.searchParams.has( 'autoplay' ) ).toBe( false );
|
|
36
|
+
} );
|
|
37
|
+
} );
|
|
38
|
+
|
|
39
|
+
describe( 'getBackgroundEmbedHtml', () => {
|
|
40
|
+
it( 'passes the autoplay option through to the iframe src', () => {
|
|
41
|
+
const html = `<iframe src="${ YOUTUBE_SRC }"></iframe>`;
|
|
42
|
+
|
|
43
|
+
expect( getBackgroundEmbedHtml( html ) ).toContain( 'autoplay=1' );
|
|
44
|
+
expect(
|
|
45
|
+
getBackgroundEmbedHtml( html, { autoplay: false } )
|
|
46
|
+
).not.toContain( 'autoplay' );
|
|
47
|
+
} );
|
|
48
|
+
} );
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { getContext, store } from '@wordpress/interactivity';
|
|
2
|
+
import { prefersReducedMotion } from '@wordpress/a11y';
|
|
3
|
+
|
|
4
|
+
store(
|
|
5
|
+
'core/cover',
|
|
6
|
+
{
|
|
7
|
+
state: {
|
|
8
|
+
get videoSrc() {
|
|
9
|
+
const { src, reducedMotionSrc } = getContext();
|
|
10
|
+
|
|
11
|
+
// The server renders the autoplaying source, so it is only
|
|
12
|
+
// replaced for a visitor who has asked for reduced motion.
|
|
13
|
+
if ( reducedMotionSrc && prefersReducedMotion() ) {
|
|
14
|
+
return reducedMotionSrc;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
return src;
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{ lock: true }
|
|
22
|
+
);
|
package/src/details/README.md
CHANGED
|
@@ -41,6 +41,8 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
|
|
|
41
41
|
- `margin`: `true`
|
|
42
42
|
- `padding`: `true`
|
|
43
43
|
- `blockGap`: `true`
|
|
44
|
+
- [`dimensions`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#dimensions):
|
|
45
|
+
- `minWidth`: `true`
|
|
44
46
|
- [`typography`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography):
|
|
45
47
|
- [`fontSize`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-fontsize): `true`
|
|
46
48
|
- [`lineHeight`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-lineheight): `true`
|
package/src/details/block.json
CHANGED
package/src/embed/README.md
CHANGED
|
@@ -28,8 +28,12 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
|
|
|
28
28
|
|
|
29
29
|
- [`anchor`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#anchor): `true`
|
|
30
30
|
- [`align`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#align): `true`
|
|
31
|
+
- [`dimensions`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#dimensions):
|
|
32
|
+
- `minHeight`: `true`
|
|
33
|
+
- `minWidth`: `true`
|
|
31
34
|
- [`spacing`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#spacing):
|
|
32
35
|
- `margin`: `true`
|
|
36
|
+
- `padding`: `true`
|
|
33
37
|
- [`interactivity`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#interactivity):
|
|
34
38
|
- `clientNavigation`: `true`
|
|
35
39
|
|
package/src/embed/block.json
CHANGED
|
@@ -43,8 +43,13 @@
|
|
|
43
43
|
"supports": {
|
|
44
44
|
"anchor": true,
|
|
45
45
|
"align": true,
|
|
46
|
+
"dimensions": {
|
|
47
|
+
"minHeight": true,
|
|
48
|
+
"minWidth": true
|
|
49
|
+
},
|
|
46
50
|
"spacing": {
|
|
47
|
-
"margin": true
|
|
51
|
+
"margin": true,
|
|
52
|
+
"padding": true
|
|
48
53
|
},
|
|
49
54
|
"interactivity": {
|
|
50
55
|
"clientNavigation": true
|
package/src/embed/style.scss
CHANGED
|
@@ -17,7 +17,9 @@
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
// Supply a min-width when inside a cover block, to prevent it from collapsing.
|
|
20
|
-
|
|
20
|
+
// :root :where() matches Global Styles specificity so a minimum set there can
|
|
21
|
+
// win, since block library styles load first.
|
|
22
|
+
:root :where(.wp-block-cover .wp-block-embed) {
|
|
21
23
|
min-width: 320px;
|
|
22
24
|
min-height: 240px;
|
|
23
25
|
}
|
|
@@ -25,6 +27,10 @@
|
|
|
25
27
|
// Allow embeds to grow and shrink inside flex group blocks (Stack/Row), preventing collapse while fitting available space.
|
|
26
28
|
.wp-block-group.is-layout-flex .wp-block-embed {
|
|
27
29
|
flex: 1 1 0%;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
// Lowered like the cover minimums above.
|
|
33
|
+
:root :where(.wp-block-group.is-layout-flex .wp-block-embed) {
|
|
28
34
|
min-width: 0;
|
|
29
35
|
}
|
|
30
36
|
|
package/src/file/README.md
CHANGED
|
@@ -40,10 +40,14 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
|
|
|
40
40
|
- [`spacing`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#spacing):
|
|
41
41
|
- `margin`: `true`
|
|
42
42
|
- `padding`: `true`
|
|
43
|
+
- [`dimensions`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#dimensions):
|
|
44
|
+
- `minHeight`: `true`
|
|
45
|
+
- `minWidth`: `true`
|
|
43
46
|
- [`color`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color):
|
|
44
47
|
- [`gradients`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-gradients): `true`
|
|
45
48
|
- [`link`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-link): `true`
|
|
46
49
|
- [`text`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-text): `false`
|
|
50
|
+
- [`shadow`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#shadow): `true`
|
|
47
51
|
- [`interactivity`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#interactivity): `true`
|
|
48
52
|
|
|
49
53
|
## Block Markup
|
package/src/file/block.json
CHANGED
|
@@ -78,6 +78,10 @@
|
|
|
78
78
|
"margin": true,
|
|
79
79
|
"padding": true
|
|
80
80
|
},
|
|
81
|
+
"dimensions": {
|
|
82
|
+
"minHeight": true,
|
|
83
|
+
"minWidth": true
|
|
84
|
+
},
|
|
81
85
|
"color": {
|
|
82
86
|
"gradients": true,
|
|
83
87
|
"link": true,
|
|
@@ -99,6 +103,7 @@
|
|
|
99
103
|
"style": true
|
|
100
104
|
}
|
|
101
105
|
},
|
|
106
|
+
"shadow": true,
|
|
102
107
|
"interactivity": true
|
|
103
108
|
},
|
|
104
109
|
"editorStyle": "wp-block-file-editor",
|
package/src/footnotes/README.md
CHANGED
|
@@ -36,6 +36,9 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
|
|
|
36
36
|
- [`spacing`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#spacing):
|
|
37
37
|
- `margin`: `true`
|
|
38
38
|
- `padding`: `true`
|
|
39
|
+
- [`dimensions`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#dimensions):
|
|
40
|
+
- `minHeight`: `true`
|
|
41
|
+
- `minWidth`: `true`
|
|
39
42
|
- [`typography`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography):
|
|
40
43
|
- [`fontSize`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-fontsize): `true`
|
|
41
44
|
- [`lineHeight`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#typography-lineheight): `true`
|
package/src/footnotes/block.json
CHANGED
package/src/gallery/README.md
CHANGED
|
@@ -56,6 +56,10 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
|
|
|
56
56
|
- [`text`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-text): `false`
|
|
57
57
|
- [`background`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-background): `true`
|
|
58
58
|
- [`gradients`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#color-gradients): `true`
|
|
59
|
+
- [`shadow`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#shadow): `true`
|
|
60
|
+
- [`dimensions`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#dimensions):
|
|
61
|
+
- `minHeight`: `true`
|
|
62
|
+
- `minWidth`: `true`
|
|
59
63
|
- [`layout`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout):
|
|
60
64
|
- [`allowSwitching`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-allowswitching): `false`
|
|
61
65
|
- [`allowInheriting`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-allowinheriting): `false`
|
|
@@ -66,6 +70,8 @@ _Defined via the [`supports`](https://developer.wordpress.org/block-editor/refer
|
|
|
66
70
|
- [`allowWrap`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-allowwrap): `false`
|
|
67
71
|
- [`allowSizingOnChildren`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-allowsizingonchildren): `true`
|
|
68
72
|
- [`default`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#layout-default): `{"type":"flex"}`
|
|
73
|
+
- [`filter`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#filter):
|
|
74
|
+
- [`duotone`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#filter-duotone): `true`
|
|
69
75
|
- [`interactivity`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#interactivity):
|
|
70
76
|
- `clientNavigation`: `true`
|
|
71
77
|
- [`listView`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-supports/#listview): `true`
|
|
@@ -87,6 +93,13 @@ _Defined via the [`usesContext` and `providesContext`](https://developer.wordpre
|
|
|
87
93
|
- `fixedHeight` → attribute `fixedHeight`
|
|
88
94
|
- `navigationButtonType` → attribute `navigationButtonType`
|
|
89
95
|
|
|
96
|
+
## CSS Selectors
|
|
97
|
+
|
|
98
|
+
_Defined via the [`selectors`](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-selectors/) property in block.json._
|
|
99
|
+
|
|
100
|
+
- **filter**:
|
|
101
|
+
- duotone: `.wp-block-gallery :where(img)`
|
|
102
|
+
|
|
90
103
|
## Block Markup
|
|
91
104
|
|
|
92
105
|
This is a [**hybrid block**](https://developer.wordpress.org/block-editor/getting-started/fundamentals/static-dynamic-rendering/). It saves static markup that the server may enhance during rendering.
|
package/src/gallery/block.json
CHANGED
|
@@ -166,6 +166,11 @@
|
|
|
166
166
|
"background": true,
|
|
167
167
|
"gradients": true
|
|
168
168
|
},
|
|
169
|
+
"shadow": true,
|
|
170
|
+
"dimensions": {
|
|
171
|
+
"minHeight": true,
|
|
172
|
+
"minWidth": true
|
|
173
|
+
},
|
|
169
174
|
"layout": {
|
|
170
175
|
"allowSwitching": false,
|
|
171
176
|
"allowInheriting": false,
|
|
@@ -179,11 +184,19 @@
|
|
|
179
184
|
"type": "flex"
|
|
180
185
|
}
|
|
181
186
|
},
|
|
187
|
+
"filter": {
|
|
188
|
+
"duotone": true
|
|
189
|
+
},
|
|
182
190
|
"interactivity": {
|
|
183
191
|
"clientNavigation": true
|
|
184
192
|
},
|
|
185
193
|
"listView": true
|
|
186
194
|
},
|
|
195
|
+
"selectors": {
|
|
196
|
+
"filter": {
|
|
197
|
+
"duotone": ".wp-block-gallery :where(img)"
|
|
198
|
+
}
|
|
199
|
+
},
|
|
187
200
|
"editorStyle": "wp-block-gallery-editor",
|
|
188
201
|
"style": "wp-block-gallery"
|
|
189
202
|
}
|
|
@@ -5,11 +5,8 @@ import {
|
|
|
5
5
|
Notice,
|
|
6
6
|
PanelBody,
|
|
7
7
|
Placeholder,
|
|
8
|
-
SelectControl as WCSelectControl,
|
|
9
8
|
Spinner,
|
|
10
9
|
ToolbarButton,
|
|
11
|
-
__experimentalToolsPanel as ToolsPanel,
|
|
12
|
-
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
13
10
|
__experimentalConfirmDialog as ConfirmDialog,
|
|
14
11
|
} from '@wordpress/components';
|
|
15
12
|
import {
|
|
@@ -21,52 +18,7 @@ import {
|
|
|
21
18
|
import { sharedIcon } from './shared-icon';
|
|
22
19
|
import { isGalleryFlexLayout } from './shared';
|
|
23
20
|
import { Caption } from '../utils/caption';
|
|
24
|
-
import {
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Ordering options for a dynamic gallery source. Each value is a composite
|
|
28
|
-
* `"orderby/order"` string mapping to the matching `/wp/v2/media` collection
|
|
29
|
-
* params. `menu_order` is deliberately omitted — it isn't a valid REST `orderby`
|
|
30
|
-
* value, so the editor preview couldn't reproduce it (see `dynamic-source.js`).
|
|
31
|
-
*/
|
|
32
|
-
const ORDER_OPTIONS = [
|
|
33
|
-
{ label: __( 'Newest to oldest' ), value: 'date/desc' },
|
|
34
|
-
{ label: __( 'Oldest to newest' ), value: 'date/asc' },
|
|
35
|
-
{
|
|
36
|
-
/* translators: Label for ordering images by title in ascending order. */
|
|
37
|
-
label: __( 'A → Z' ),
|
|
38
|
-
value: 'title/asc',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
/* translators: Label for ordering images by title in descending order. */
|
|
42
|
-
label: __( 'Z → A' ),
|
|
43
|
-
value: 'title/desc',
|
|
44
|
-
},
|
|
45
|
-
];
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* "Order by" control for a dynamic gallery, mirroring the Query Loop block's
|
|
49
|
-
* `OrderControl`: a single `SelectControl` whose value composites `orderby` and
|
|
50
|
-
* `order`, split apart again on change.
|
|
51
|
-
*
|
|
52
|
-
* @param {Object} props
|
|
53
|
-
* @param {string} props.orderby Current `orderby` value.
|
|
54
|
-
* @param {string} props.order Current `order` value (`asc`/`desc`).
|
|
55
|
-
* @param {Function} props.onChange Called with `{ orderby, order }` on change.
|
|
56
|
-
*/
|
|
57
|
-
function OrderControl( { orderby, order, onChange } ) {
|
|
58
|
-
return (
|
|
59
|
-
<WCSelectControl
|
|
60
|
-
label={ __( 'Order by' ) }
|
|
61
|
-
value={ `${ orderby }/${ order }` }
|
|
62
|
-
options={ ORDER_OPTIONS }
|
|
63
|
-
onChange={ ( value ) => {
|
|
64
|
-
const [ newOrderby, newOrder ] = value.split( '/' );
|
|
65
|
-
onChange( { orderby: newOrderby, order: newOrder } );
|
|
66
|
-
} }
|
|
67
|
-
/>
|
|
68
|
-
);
|
|
69
|
-
}
|
|
21
|
+
import { MAX_IMAGES } from './dynamic-source';
|
|
70
22
|
|
|
71
23
|
/**
|
|
72
24
|
* Confirmation for leaving dynamic mode, shown from both the block toolbar and
|
|
@@ -101,32 +53,23 @@ function DetachGalleryDialog( { onConfirm, onCancel } ) {
|
|
|
101
53
|
/**
|
|
102
54
|
* The Gallery block's "Source" inspector panel.
|
|
103
55
|
*
|
|
104
|
-
* In dynamic mode it shows the resolved source
|
|
105
|
-
* from it
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
56
|
+
* In dynamic mode it shows the resolved source and a control to detach the
|
|
57
|
+
* gallery from it. In static mode it offers the entry point into dynamic mode.
|
|
58
|
+
* Either direction is a one-way change, so both are behind a confirmation
|
|
59
|
+
* dialog this panel owns. Rendered inside the block's `InspectorControls`,
|
|
60
|
+
* alongside the Settings panel, which owns the ordering for both modes.
|
|
109
61
|
*
|
|
110
62
|
* @param {Object} props
|
|
111
|
-
* @param {Object} props.dynamic
|
|
112
|
-
* @param {
|
|
113
|
-
* @param {boolean} props.hasImages Whether the gallery has manually-added images.
|
|
63
|
+
* @param {Object} props.dynamic The `useDynamicGallery` result.
|
|
64
|
+
* @param {boolean} props.hasImages Whether the gallery has manually-added images.
|
|
114
65
|
*/
|
|
115
|
-
export function GallerySourcePanel( {
|
|
116
|
-
dynamic,
|
|
117
|
-
dropdownMenuProps,
|
|
118
|
-
hasImages,
|
|
119
|
-
} ) {
|
|
66
|
+
export function GallerySourcePanel( { dynamic, hasImages } ) {
|
|
120
67
|
const {
|
|
121
68
|
dynamicContent,
|
|
122
69
|
canUseDynamicSource,
|
|
123
70
|
sourceDescriptor,
|
|
124
|
-
sourceOrderby,
|
|
125
|
-
sourceOrder,
|
|
126
|
-
setSourceOrder,
|
|
127
71
|
convertToStatic,
|
|
128
72
|
enableDynamicMode,
|
|
129
|
-
resetSource,
|
|
130
73
|
isResolvingDynamic,
|
|
131
74
|
hasMoreImagesThanCap,
|
|
132
75
|
dynamicMediaTotal,
|
|
@@ -149,11 +92,7 @@ export function GallerySourcePanel( {
|
|
|
149
92
|
if ( isDynamic ) {
|
|
150
93
|
return (
|
|
151
94
|
<>
|
|
152
|
-
<
|
|
153
|
-
label={ __( 'Source' ) }
|
|
154
|
-
resetAll={ resetSource }
|
|
155
|
-
dropdownMenuProps={ dropdownMenuProps }
|
|
156
|
-
>
|
|
95
|
+
<PanelBody title={ __( 'Source' ) }>
|
|
157
96
|
<div className="wp-block-gallery__source-settings">
|
|
158
97
|
<p className="wp-block-gallery__source-description">
|
|
159
98
|
{ sourceDescriptor?.description ??
|
|
@@ -188,26 +127,7 @@ export function GallerySourcePanel( {
|
|
|
188
127
|
) }
|
|
189
128
|
</Notice>
|
|
190
129
|
) }
|
|
191
|
-
|
|
192
|
-
isShownByDefault
|
|
193
|
-
label={ __( 'Order by' ) }
|
|
194
|
-
hasValue={ () =>
|
|
195
|
-
sourceOrderby !== DEFAULT_ORDERBY ||
|
|
196
|
-
sourceOrder !== DEFAULT_ORDER
|
|
197
|
-
}
|
|
198
|
-
onDeselect={ () =>
|
|
199
|
-
setSourceOrder( undefined, undefined )
|
|
200
|
-
}
|
|
201
|
-
>
|
|
202
|
-
<OrderControl
|
|
203
|
-
orderby={ sourceOrderby }
|
|
204
|
-
order={ sourceOrder }
|
|
205
|
-
onChange={ ( { orderby, order } ) =>
|
|
206
|
-
setSourceOrder( orderby, order )
|
|
207
|
-
}
|
|
208
|
-
/>
|
|
209
|
-
</ToolsPanelItem>
|
|
210
|
-
</ToolsPanel>
|
|
130
|
+
</PanelBody>
|
|
211
131
|
{ isConfirmingDetach && (
|
|
212
132
|
<DetachGalleryDialog
|
|
213
133
|
onConfirm={ () => {
|