@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,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/image/view.js"],
|
|
4
|
-
"sourcesContent": ["import {\n\tstore,\n\tgetContext,\n\tgetElement,\n\tgetConfig,\n\twithSyncEvent,\n\twithScope,\n} from '@wordpress/interactivity';\nimport { IMAGE_PRELOAD_DELAY } from './constants';\n\n/**\n * Tracks whether user is touching screen; used to differentiate behavior for\n * touch and mouse input.\n *\n * @type {boolean}\n */\nlet isTouching = false;\n\n/**\n * Tracks the last time the screen was touched; used to differentiate behavior\n * for touch and mouse input.\n *\n * @type {number}\n */\nlet lastTouchTime = 0;\n\nconst touchStartEvent = {\n\tstartX: 0,\n\tstartY: 0,\n\tstartTime: 0,\n};\n\nconst focusableSelectors = [\n\t'.wp-lightbox-close-button',\n\t'.wp-lightbox-navigation-button',\n];\n\n/**\n * Returns the appropriate src URL for an image.\n *\n * @param {string} uploadedSrc - Full size image src.\n * @return {string} The source URL.\n */\nfunction getImageSrc( { uploadedSrc } ) {\n\treturn (\n\t\tuploadedSrc ||\n\t\t'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='\n\t);\n}\n\n/**\n * Returns the appropriate srcset for an image.\n *\n * @param {string} lightboxSrcset - Image srcset.\n * @return {string} The srcset value.\n */\nfunction getImageSrcset( { lightboxSrcset } ) {\n\treturn lightboxSrcset || '';\n}\n\nconst { state, actions, callbacks } = store(\n\t'core/image',\n\t{\n\t\tstate: {\n\t\t\tselectedImageId: null,\n\t\t\tselectedGalleryId: null,\n\t\t\tpreloadTimers: new Map(),\n\t\t\tpreloadedImageIds: new Set(),\n\t\t\tget galleryImages() {\n\t\t\t\tif ( ! state.selectedGalleryId ) {\n\t\t\t\t\treturn [ state.selectedImageId ];\n\t\t\t\t}\n\n\t\t\t\t// Get all images in this gallery and sort by galleryOrder\n\t\t\t\treturn Object.entries( state.metadata )\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t( [ , value ] ) =>\n\t\t\t\t\t\t\tvalue.galleryId === state.selectedGalleryId\n\t\t\t\t\t)\n\t\t\t\t\t.sort( ( [ , a ], [ , b ] ) => {\n\t\t\t\t\t\tconst orderA = a.order ?? 0;\n\t\t\t\t\t\tconst orderB = b.order ?? 0;\n\t\t\t\t\t\treturn orderA - orderB;\n\t\t\t\t\t} )\n\t\t\t\t\t.map( ( [ key ] ) => key );\n\t\t\t},\n\t\t\tget selectedImageIndex() {\n\t\t\t\treturn state.galleryImages.findIndex(\n\t\t\t\t\t( id ) => id === state.selectedImageId\n\t\t\t\t);\n\t\t\t},\n\t\t\tget selectedImage() {\n\t\t\t\treturn state.metadata[ state.selectedImageId ];\n\t\t\t},\n\t\t\tget hasNavigationIcon() {\n\t\t\t\tconst { navigationButtonType } = state.selectedImage;\n\t\t\t\treturn (\n\t\t\t\t\tnavigationButtonType === 'icon' ||\n\t\t\t\t\tnavigationButtonType === 'both'\n\t\t\t\t);\n\t\t\t},\n\t\t\tget hasNavigationText() {\n\t\t\t\tconst { navigationButtonType } = state.selectedImage;\n\t\t\t\treturn (\n\t\t\t\t\tnavigationButtonType === 'text' ||\n\t\t\t\t\tnavigationButtonType === 'both'\n\t\t\t\t);\n\t\t\t},\n\t\t\tget thisImage() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\treturn state.metadata[ imageId ];\n\t\t\t},\n\t\t\tget hasNavigation() {\n\t\t\t\treturn state.galleryImages.length > 1;\n\t\t\t},\n\t\t\tget hasNextImage() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.selectedImageIndex + 1 < state.galleryImages.length\n\t\t\t\t);\n\t\t\t},\n\t\t\tget hasPreviousImage() {\n\t\t\t\treturn state.selectedImageIndex - 1 >= 0;\n\t\t\t},\n\t\t\tget overlayOpened() {\n\t\t\t\treturn state.selectedImageId !== null;\n\t\t\t},\n\t\t\tget roleAttribute() {\n\t\t\t\treturn state.overlayOpened ? 'dialog' : null;\n\t\t\t},\n\t\t\tget ariaModal() {\n\t\t\t\treturn state.overlayOpened ? 'true' : null;\n\t\t\t},\n\t\t\tget ariaLabel() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.selectedImage.customAriaLabel ||\n\t\t\t\t\tgetConfig().defaultAriaLabel\n\t\t\t\t);\n\t\t\t},\n\t\t\tget closeButtonAriaLabel() {\n\t\t\t\treturn state.hasNavigationText\n\t\t\t\t\t? undefined\n\t\t\t\t\t: getConfig().closeButtonText;\n\t\t\t},\n\t\t\tget prevButtonAriaLabel() {\n\t\t\t\treturn state.hasNavigationText\n\t\t\t\t\t? undefined\n\t\t\t\t\t: getConfig().prevButtonText;\n\t\t\t},\n\t\t\tget nextButtonAriaLabel() {\n\t\t\t\treturn state.hasNavigationText\n\t\t\t\t\t? undefined\n\t\t\t\t\t: getConfig().nextButtonText;\n\t\t\t},\n\t\t\tget enlargedSrc() {\n\t\t\t\treturn getImageSrc( state.selectedImage );\n\t\t\t},\n\t\t\tget enlargedSrcset() {\n\t\t\t\treturn getImageSrcset( state.selectedImage );\n\t\t\t},\n\t\t\tget figureStyles() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.overlayOpened &&\n\t\t\t\t\t`${ state.selectedImage.figureStyles?.replace(\n\t\t\t\t\t\t/margin[^;]*;?/g,\n\t\t\t\t\t\t''\n\t\t\t\t\t) };`\n\t\t\t\t);\n\t\t\t},\n\t\t\tget imgStyles() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.overlayOpened &&\n\t\t\t\t\t`${ state.selectedImage.imgStyles?.replace(\n\t\t\t\t\t\t/;$/,\n\t\t\t\t\t\t''\n\t\t\t\t\t) }; object-fit:cover;`\n\t\t\t\t);\n\t\t\t},\n\t\t\tget isContentHidden() {\n\t\t\t\tconst ctx = getContext();\n\t\t\t\treturn (\n\t\t\t\t\tstate.overlayEnabled &&\n\t\t\t\t\tstate.selectedImageId === ctx.imageId\n\t\t\t\t);\n\t\t\t},\n\t\t\tget isContentVisible() {\n\t\t\t\tconst ctx = getContext();\n\t\t\t\treturn (\n\t\t\t\t\t! state.overlayEnabled &&\n\t\t\t\t\tstate.selectedImageId === ctx.imageId\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\tactions: {\n\t\t\tshowLightbox() {\n\t\t\t\tconst { imageId } = getContext();\n\n\t\t\t\t// Bails out if the image has not loaded yet.\n\t\t\t\tif ( ! state.metadata[ imageId ].imageRef?.complete ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Stores the positions of the scroll to fix it until the overlay is\n\t\t\t\t// closed.\n\t\t\t\tstate.scrollTopReset = document.documentElement.scrollTop;\n\t\t\t\tstate.scrollLeftReset = document.documentElement.scrollLeft;\n\n\t\t\t\t// Sets the selected image and gallery and enables the overlay.\n\t\t\t\tstate.selectedImageId = imageId;\n\t\t\t\tconst { galleryId } = getContext( 'core/gallery' ) || {};\n\t\t\t\tstate.selectedGalleryId = galleryId || null;\n\t\t\t\tstate.overlayEnabled = true;\n\n\t\t\t\t// Computes the styles of the overlay for the animation.\n\t\t\t\tcallbacks.setOverlayStyles();\n\t\t\t},\n\t\t\thideLightbox() {\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\tstate.overlayEnabled = false;\n\n\t\t\t\t\t// Waits until the close animation has completed before allowing a\n\t\t\t\t\t// user to scroll again. The duration of this animation is defined in\n\t\t\t\t\t// the `styles.scss` file, but in any case we should wait a few\n\t\t\t\t\t// milliseconds longer than the duration, otherwise a user may scroll\n\t\t\t\t\t// too soon and cause the animation to look sloppy.\n\t\t\t\t\tsetTimeout( function () {\n\t\t\t\t\t\t// Delays before changing the focus. Otherwise the focus ring will\n\t\t\t\t\t\t// appear on Firefox before the image has finished animating, which\n\t\t\t\t\t\t// looks broken.\n\t\t\t\t\t\tstate.selectedImage.buttonRef.focus( {\n\t\t\t\t\t\t\tpreventScroll: true,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Resets the selected image and gallery ids.\n\t\t\t\t\t\tstate.selectedImageId = null;\n\t\t\t\t\t\tstate.selectedGalleryId = null;\n\t\t\t\t\t}, 450 );\n\t\t\t\t}\n\t\t\t},\n\t\t\tshowPreviousImage: withSyncEvent( ( event ) => {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tconst nextIndex = state.hasPreviousImage\n\t\t\t\t\t? state.selectedImageIndex - 1\n\t\t\t\t\t: state.galleryImages.length - 1;\n\t\t\t\tstate.selectedImageId = state.galleryImages[ nextIndex ];\n\t\t\t\tcallbacks.setOverlayStyles();\n\t\t\t} ),\n\t\t\tshowNextImage: withSyncEvent( ( event ) => {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tconst nextIndex = state.hasNextImage\n\t\t\t\t\t? state.selectedImageIndex + 1\n\t\t\t\t\t: 0;\n\t\t\t\tstate.selectedImageId = state.galleryImages[ nextIndex ];\n\t\t\t\tcallbacks.setOverlayStyles();\n\t\t\t} ),\n\t\t\thandleKeydown: withSyncEvent( ( event ) => {\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\tif ( event.key === 'Escape' ) {\n\t\t\t\t\t\tactions.hideLightbox();\n\t\t\t\t\t} else if ( event.key === 'ArrowLeft' ) {\n\t\t\t\t\t\tactions.showPreviousImage( event );\n\t\t\t\t\t} else if ( event.key === 'ArrowRight' ) {\n\t\t\t\t\t\tactions.showNextImage( event );\n\t\t\t\t\t} else if ( event.key === 'Tab' ) {\n\t\t\t\t\t\t// Traps focus within the overlay.\n\t\t\t\t\t\tconst focusableElements = Array.from(\n\t\t\t\t\t\t\tdocument.querySelectorAll( focusableSelectors )\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst firstFocusableElement = focusableElements[ 0 ];\n\t\t\t\t\t\tconst lastFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ focusableElements.length - 1 ];\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\t\tevent.target === firstFocusableElement\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tlastFocusableElement.focus();\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\t\tevent.target === lastFocusableElement\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tfirstFocusableElement.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} ),\n\t\t\thandleTouchMove: withSyncEvent( ( event ) => {\n\t\t\t\t// On mobile devices, prevents triggering the scroll event because\n\t\t\t\t// otherwise the page jumps around when it resets the scroll position.\n\t\t\t\t// This also means that closing the lightbox requires that a user\n\t\t\t\t// perform a simple tap. This may be changed in the future if there is a\n\t\t\t\t// better alternative to override or reset the scroll position during\n\t\t\t\t// swipe actions.\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} ),\n\t\t\thandleTouchStart( event ) {\n\t\t\t\tisTouching = true;\n\t\t\t\tconst t = event.touches && event.touches[ 0 ];\n\t\t\t\tif ( t ) {\n\t\t\t\t\ttouchStartEvent.startX = t.clientX;\n\t\t\t\t\ttouchStartEvent.startY = t.clientY;\n\t\t\t\t\ttouchStartEvent.startTime = Date.now();\n\t\t\t\t}\n\t\t\t},\n\t\t\thandleTouchEnd: withSyncEvent( ( event ) => {\n\t\t\t\tconst touchEndEvent =\n\t\t\t\t\t( event.changedTouches && event.changedTouches[ 0 ] ) ||\n\t\t\t\t\t( event.touches && event.touches[ 0 ] );\n\t\t\t\tconst now = Date.now();\n\n\t\t\t\tif ( touchEndEvent && state.overlayEnabled ) {\n\t\t\t\t\tconst deltaX =\n\t\t\t\t\t\ttouchEndEvent.clientX - touchStartEvent.startX;\n\t\t\t\t\tconst deltaY =\n\t\t\t\t\t\ttouchEndEvent.clientY - touchStartEvent.startY;\n\t\t\t\t\tconst absDeltaX = Math.abs( deltaX );\n\t\t\t\t\tconst absDeltaY = Math.abs( deltaY );\n\t\t\t\t\tconst elapsedMs = now - touchStartEvent.startTime;\n\t\t\t\t\tconst isHorizontalSwipe =\n\t\t\t\t\t\t// Swipe distance is greater than 50px\n\t\t\t\t\t\tabsDeltaX > 50 &&\n\t\t\t\t\t\t// Horizontal movement is much larger than the vertical movement\n\t\t\t\t\t\tabsDeltaX > absDeltaY * 1.5 &&\n\t\t\t\t\t\t// Fast action of less than 800ms\n\t\t\t\t\t\telapsedMs < 800;\n\n\t\t\t\t\tif ( isHorizontalSwipe ) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tif ( deltaX < 0 ) {\n\t\t\t\t\t\t\tactions.showNextImage( event );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tactions.showPreviousImage( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlastTouchTime = now;\n\t\t\t\tisTouching = false;\n\t\t\t} ),\n\t\t\thandleScroll() {\n\t\t\t\t// Prevents scrolling behaviors that trigger content shift while the\n\t\t\t\t// lightbox is open. It would be better to accomplish through CSS alone,\n\t\t\t\t// but using overflow: hidden is currently the only way to do so and\n\t\t\t\t// that causes a layout to shift and prevents the zoom animation from\n\t\t\t\t// working in some cases because it's not possible to account for the\n\t\t\t\t// layout shift when doing the animation calculations. Instead, it uses\n\t\t\t\t// JavaScript to prevent and reset the scrolling behavior.\n\t\t\t\tif ( state.overlayOpened ) {\n\t\t\t\t\t// Avoids overriding the scroll behavior on mobile devices because\n\t\t\t\t\t// doing so breaks the pinch to zoom functionality, and users should\n\t\t\t\t\t// be able to zoom in further on the high-res image.\n\t\t\t\t\tif ( ! isTouching && Date.now() - lastTouchTime > 450 ) {\n\t\t\t\t\t\t// It doesn't rely on `event.preventDefault()` to prevent scrolling\n\t\t\t\t\t\t// because the scroll event can't be canceled, so it resets the\n\t\t\t\t\t\t// position instead.\n\t\t\t\t\t\twindow.scrollTo(\n\t\t\t\t\t\t\tstate.scrollLeftReset,\n\t\t\t\t\t\t\tstate.scrollTopReset\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tpreloadImage() {\n\t\t\t\tconst { imageId } = getContext();\n\n\t\t\t\t// Bails if it has already been preloaded. This could help\n\t\t\t\t// prevent unnecessary preloading of the same image multiple times,\n\t\t\t\t// leading to duplicate link elements in the document head.\n\t\t\t\tif ( state.preloadedImageIds.has( imageId ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Link element to preload the image.\n\t\t\t\tconst imageMetadata = state.metadata[ imageId ];\n\t\t\t\tconst imageLink = document.createElement( 'link' );\n\t\t\t\timageLink.rel = 'preload';\n\t\t\t\timageLink.as = 'image';\n\t\t\t\timageLink.href = getImageSrc( imageMetadata );\n\n\t\t\t\t// Apply srcset if available for responsive preloading\n\t\t\t\tconst srcset = getImageSrcset( imageMetadata );\n\t\t\t\tif ( srcset ) {\n\t\t\t\t\timageLink.setAttribute( 'imagesrcset', srcset );\n\t\t\t\t\timageLink.setAttribute( 'imagesizes', '100vw' );\n\t\t\t\t}\n\n\t\t\t\tdocument.head.appendChild( imageLink );\n\t\t\t\tstate.preloadedImageIds.add( imageId );\n\t\t\t},\n\t\t\tpreloadImageWithDelay() {\n\t\t\t\tconst { imageId } = getContext();\n\n\t\t\t\tactions.cancelPreload();\n\n\t\t\t\t// Set a new timer to preload the image after a short delay.\n\t\t\t\tconst timerId = setTimeout(\n\t\t\t\t\twithScope( () => {\n\t\t\t\t\t\tactions.preloadImage();\n\t\t\t\t\t\tstate.preloadTimers.delete( imageId );\n\t\t\t\t\t} ),\n\t\t\t\t\tIMAGE_PRELOAD_DELAY\n\t\t\t\t);\n\t\t\t\tstate.preloadTimers.set( imageId, timerId );\n\t\t\t},\n\t\t\tcancelPreload() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\tif ( state.preloadTimers.has( imageId ) ) {\n\t\t\t\t\tclearTimeout( state.preloadTimers.get( imageId ) );\n\t\t\t\t\tstate.preloadTimers.delete( imageId );\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\tcallbacks: {\n\t\t\tsetOverlayStyles() {\n\t\t\t\tif ( ! state.overlayEnabled ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet {\n\t\t\t\t\tnaturalWidth,\n\t\t\t\t\tnaturalHeight,\n\t\t\t\t\toffsetWidth: originalWidth,\n\t\t\t\t\toffsetHeight: originalHeight,\n\t\t\t\t} = state.selectedImage.imageRef;\n\t\t\t\tlet { x: screenPosX, y: screenPosY } =\n\t\t\t\t\tstate.selectedImage.imageRef.getBoundingClientRect();\n\n\t\t\t\t// Natural ratio of the image clicked to open the lightbox.\n\t\t\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\t\t\t// Original ratio of the image clicked to open the lightbox.\n\t\t\t\tlet originalRatio = originalWidth / originalHeight;\n\n\t\t\t\t// If it has object-fit: contain, recalculates the original sizes\n\t\t\t\t// and the screen position without the blank spaces.\n\t\t\t\tif ( state.selectedImage.scaleAttr === 'contain' ) {\n\t\t\t\t\tif ( naturalRatio > originalRatio ) {\n\t\t\t\t\t\tconst heightWithoutSpace = originalWidth / naturalRatio;\n\t\t\t\t\t\t// Recalculates screen position without the top space.\n\t\t\t\t\t\tscreenPosY +=\n\t\t\t\t\t\t\t( originalHeight - heightWithoutSpace ) / 2;\n\t\t\t\t\t\toriginalHeight = heightWithoutSpace;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst widthWithoutSpace = originalHeight * naturalRatio;\n\t\t\t\t\t\t// Recalculates screen position without the left space.\n\t\t\t\t\t\tscreenPosX += ( originalWidth - widthWithoutSpace ) / 2;\n\t\t\t\t\t\toriginalWidth = widthWithoutSpace;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\toriginalRatio = originalWidth / originalHeight;\n\n\t\t\t\t// Typically, it uses the image's full-sized dimensions. If those\n\t\t\t\t// dimensions have not been set (i.e. an external image with only one\n\t\t\t\t// size), the image's dimensions in the lightbox are the same\n\t\t\t\t// as those of the image in the content.\n\t\t\t\tlet imgMaxWidth = parseFloat(\n\t\t\t\t\tstate.selectedImage.targetWidth &&\n\t\t\t\t\t\tstate.selectedImage.targetWidth !== 'none'\n\t\t\t\t\t\t? state.selectedImage.targetWidth\n\t\t\t\t\t\t: naturalWidth\n\t\t\t\t);\n\t\t\t\tlet imgMaxHeight = parseFloat(\n\t\t\t\t\tstate.selectedImage.targetHeight &&\n\t\t\t\t\t\tstate.selectedImage.targetHeight !== 'none'\n\t\t\t\t\t\t? state.selectedImage.targetHeight\n\t\t\t\t\t\t: naturalHeight\n\t\t\t\t);\n\n\t\t\t\t// Ratio of the biggest image stored in the database.\n\t\t\t\tlet imgRatio = imgMaxWidth / imgMaxHeight;\n\t\t\t\tlet containerMaxWidth = imgMaxWidth;\n\t\t\t\tlet containerMaxHeight = imgMaxHeight;\n\t\t\t\tlet containerWidth = imgMaxWidth;\n\t\t\t\tlet containerHeight = imgMaxHeight;\n\n\t\t\t\t// Checks if the target image has a different ratio than the original\n\t\t\t\t// one (thumbnail). Recalculates the width and height.\n\t\t\t\tif ( naturalRatio.toFixed( 2 ) !== imgRatio.toFixed( 2 ) ) {\n\t\t\t\t\tif ( naturalRatio > imgRatio ) {\n\t\t\t\t\t\t// If the width is reached before the height, it keeps the maxWidth\n\t\t\t\t\t\t// and recalculates the height unless the difference between the\n\t\t\t\t\t\t// maxHeight and the reducedHeight is higher than the maxWidth,\n\t\t\t\t\t\t// where it keeps the reducedHeight and recalculate the width.\n\t\t\t\t\t\tconst reducedHeight = imgMaxWidth / naturalRatio;\n\t\t\t\t\t\tif ( imgMaxHeight - reducedHeight > imgMaxWidth ) {\n\t\t\t\t\t\t\timgMaxHeight = reducedHeight;\n\t\t\t\t\t\t\timgMaxWidth = reducedHeight * naturalRatio;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\timgMaxHeight = imgMaxWidth / naturalRatio;\n\t\t\t\t\t\t}\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If the height is reached before the width, it keeps the maxHeight\n\t\t\t\t\t\t// and recalculate the width unlesss the difference between the\n\t\t\t\t\t\t// maxWidth and the reducedWidth is higher than the maxHeight, where\n\t\t\t\t\t\t// it keeps the reducedWidth and recalculate the height.\n\t\t\t\t\t\tconst reducedWidth = imgMaxHeight * naturalRatio;\n\t\t\t\t\t\tif ( imgMaxWidth - reducedWidth > imgMaxHeight ) {\n\t\t\t\t\t\t\timgMaxWidth = reducedWidth;\n\t\t\t\t\t\t\timgMaxHeight = reducedWidth / naturalRatio;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\timgMaxWidth = imgMaxHeight * naturalRatio;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tcontainerWidth = imgMaxWidth;\n\t\t\t\t\tcontainerHeight = imgMaxHeight;\n\t\t\t\t\timgRatio = imgMaxWidth / imgMaxHeight;\n\n\t\t\t\t\t// Calculates the max size of the container.\n\t\t\t\t\tif ( originalRatio > imgRatio ) {\n\t\t\t\t\t\tcontainerMaxWidth = imgMaxWidth;\n\t\t\t\t\t\tcontainerMaxHeight = containerMaxWidth / originalRatio;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tcontainerMaxHeight = imgMaxHeight;\n\t\t\t\t\t\tcontainerMaxWidth = containerMaxHeight * originalRatio;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// If the image has been pixelated on purpose, it keeps that size.\n\t\t\t\tif (\n\t\t\t\t\toriginalWidth > containerWidth ||\n\t\t\t\t\toriginalHeight > containerHeight\n\t\t\t\t) {\n\t\t\t\t\tcontainerWidth = originalWidth;\n\t\t\t\t\tcontainerHeight = originalHeight;\n\t\t\t\t}\n\n\t\t\t\t// Calculates the final lightbox image size and the scale factor.\n\t\t\t\t// MaxWidth is either the window container (accounting for padding) or\n\t\t\t\t// the image resolution.\n\n\t\t\t\t// 480px width or less\n\t\t\t\tlet horizontalPadding = 0;\n\t\t\t\tlet verticalPadding = 160;\n\t\t\t\t// Greater than 480px wide and less than or equal to 960px\n\t\t\t\tif ( 480 < window.innerWidth ) {\n\t\t\t\t\thorizontalPadding = 80;\n\t\t\t\t\tverticalPadding = 160;\n\t\t\t\t}\n\t\t\t\t// Greater than 960px wide\n\t\t\t\tif ( 960 < window.innerWidth ) {\n\t\t\t\t\thorizontalPadding = state.hasNavigation ? 320 : 80;\n\t\t\t\t\tverticalPadding = 80;\n\t\t\t\t}\n\n\t\t\t\tconst targetMaxWidth = Math.min(\n\t\t\t\t\twindow.innerWidth - horizontalPadding,\n\t\t\t\t\tcontainerWidth\n\t\t\t\t);\n\t\t\t\tconst targetMaxHeight = Math.min(\n\t\t\t\t\twindow.innerHeight - verticalPadding,\n\t\t\t\t\tcontainerHeight\n\t\t\t\t);\n\t\t\t\tconst targetContainerRatio = targetMaxWidth / targetMaxHeight;\n\n\t\t\t\tif ( originalRatio > targetContainerRatio ) {\n\t\t\t\t\t// If targetMaxWidth is reached before targetMaxHeight.\n\t\t\t\t\tcontainerWidth = targetMaxWidth;\n\t\t\t\t\tcontainerHeight = containerWidth / originalRatio;\n\t\t\t\t} else {\n\t\t\t\t\t// If targetMaxHeight is reached before targetMaxWidth.\n\t\t\t\t\tcontainerHeight = targetMaxHeight;\n\t\t\t\t\tcontainerWidth = containerHeight * originalRatio;\n\t\t\t\t}\n\n\t\t\t\tconst containerScale = originalWidth / containerWidth;\n\t\t\t\tconst lightboxImgWidth =\n\t\t\t\t\timgMaxWidth * ( containerWidth / containerMaxWidth );\n\t\t\t\tconst lightboxImgHeight =\n\t\t\t\t\timgMaxHeight * ( containerHeight / containerMaxHeight );\n\n\t\t\t\t// As of this writing, using the calculations above will render the\n\t\t\t\t// lightbox with a small, erroneous whitespace on the left side of the\n\t\t\t\t// image in iOS Safari, perhaps due to an inconsistency in how browsers\n\t\t\t\t// handle absolute positioning and CSS transformation. In any case,\n\t\t\t\t// adding 1 pixel to the container width and height solves the problem,\n\t\t\t\t// though this can be removed if the issue is fixed in the future.\n\t\t\t\tstate.overlayStyles = `\n\t\t\t\t\t--wp--lightbox-initial-top-position: ${ screenPosY }px;\n\t\t\t\t\t--wp--lightbox-initial-left-position: ${ screenPosX }px;\n\t\t\t\t\t--wp--lightbox-container-width: ${ containerWidth + 1 }px;\n\t\t\t\t\t--wp--lightbox-container-height: ${ containerHeight + 1 }px;\n\t\t\t\t\t--wp--lightbox-image-width: ${ lightboxImgWidth }px;\n\t\t\t\t\t--wp--lightbox-image-height: ${ lightboxImgHeight }px;\n\t\t\t\t\t--wp--lightbox-scale: ${ containerScale };\n\t\t\t\t\t--wp--lightbox-scrollbar-width: ${\n\t\t\t\t\t\twindow.innerWidth - document.documentElement.clientWidth\n\t\t\t\t\t}px;\n\t\t\t\t`;\n\t\t\t},\n\t\t\tsetButtonStyles() {\n\t\t\t\tconst { ref } = getElement();\n\n\t\t\t\t// This guard prevents errors in images with the `srcset`\n\t\t\t\t// attribute, which can dispatch `load` events even after DOM\n\t\t\t\t// removal. Preact doesn't automatically clean up `load` event\n\t\t\t\t// listeners on unmounted `img` elements (see\n\t\t\t\t// https://github.com/preactjs/preact/issues/3141).\n\t\t\t\tif ( ! ref ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { imageId } = getContext();\n\n\t\t\t\tstate.metadata[ imageId ].imageRef = ref;\n\t\t\t\tstate.metadata[ imageId ].currentSrc = ref.currentSrc;\n\n\t\t\t\tconst {\n\t\t\t\t\tnaturalWidth,\n\t\t\t\t\tnaturalHeight,\n\t\t\t\t\toffsetWidth,\n\t\t\t\t\toffsetHeight,\n\t\t\t\t} = ref;\n\n\t\t\t\t// If the image isn't loaded yet, it can't calculate where the button\n\t\t\t\t// should be.\n\t\t\t\tif ( naturalWidth === 0 || naturalHeight === 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst figure = ref.parentElement;\n\t\t\t\tconst figureWidth = ref.parentElement.clientWidth;\n\n\t\t\t\t// It needs special handling for the height because a caption will cause\n\t\t\t\t// the figure to be taller than the image, which means it needs to\n\t\t\t\t// account for that when calculating the placement of the button in the\n\t\t\t\t// top right corner of the image.\n\t\t\t\tlet figureHeight = ref.parentElement.clientHeight;\n\t\t\t\tconst caption = figure.querySelector( 'figcaption' );\n\t\t\t\tif ( caption ) {\n\t\t\t\t\tconst captionComputedStyle =\n\t\t\t\t\t\twindow.getComputedStyle( caption );\n\t\t\t\t\tif (\n\t\t\t\t\t\t! [ 'absolute', 'fixed' ].includes(\n\t\t\t\t\t\t\tcaptionComputedStyle.position\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tfigureHeight =\n\t\t\t\t\t\t\tfigureHeight -\n\t\t\t\t\t\t\tcaption.offsetHeight -\n\t\t\t\t\t\t\tparseFloat( captionComputedStyle.marginTop ) -\n\t\t\t\t\t\t\tparseFloat( captionComputedStyle.marginBottom );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst buttonOffsetTop = figureHeight - offsetHeight;\n\t\t\t\tconst buttonOffsetRight = figureWidth - offsetWidth;\n\n\t\t\t\tlet buttonTop = buttonOffsetTop + 16;\n\t\t\t\tlet buttonRight = buttonOffsetRight + 16;\n\n\t\t\t\t// In the case of an image with object-fit: contain, the size of the\n\t\t\t\t// <img> element can be larger than the image itself, so it needs to\n\t\t\t\t// calculate where to place the button.\n\t\t\t\tif ( state.metadata[ imageId ].scaleAttr === 'contain' ) {\n\t\t\t\t\t// Natural ratio of the image.\n\t\t\t\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\t\t\t\t// Offset ratio of the image.\n\t\t\t\t\tconst offsetRatio = offsetWidth / offsetHeight;\n\n\t\t\t\t\tif ( naturalRatio >= offsetRatio ) {\n\t\t\t\t\t\t// If it reaches the width first, it keeps the width and compute the\n\t\t\t\t\t\t// height.\n\t\t\t\t\t\tconst referenceHeight = offsetWidth / naturalRatio;\n\t\t\t\t\t\tbuttonTop =\n\t\t\t\t\t\t\t( offsetHeight - referenceHeight ) / 2 +\n\t\t\t\t\t\t\tbuttonOffsetTop +\n\t\t\t\t\t\t\t16;\n\t\t\t\t\t\tbuttonRight = buttonOffsetRight + 16;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If it reaches the height first, it keeps the height and compute\n\t\t\t\t\t\t// the width.\n\t\t\t\t\t\tconst referenceWidth = offsetHeight * naturalRatio;\n\t\t\t\t\t\tbuttonTop = buttonOffsetTop + 16;\n\t\t\t\t\t\tbuttonRight =\n\t\t\t\t\t\t\t( offsetWidth - referenceWidth ) / 2 +\n\t\t\t\t\t\t\tbuttonOffsetRight +\n\t\t\t\t\t\t\t16;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tstate.metadata[ imageId ].buttonTop = buttonTop;\n\t\t\t\tstate.metadata[ imageId ].buttonRight = buttonRight;\n\t\t\t},\n\t\t\tsetOverlayFocus() {\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\t// Moves the focus to the dialog when it opens.\n\t\t\t\t\tconst { ref } = getElement();\n\t\t\t\t\tref.focus();\n\t\t\t\t}\n\t\t\t},\n\t\t\tsetInertElements() {\n\t\t\t\t// Makes all children of the document inert exempt .wp-lightbox-overlay.\n\t\t\t\tdocument\n\t\t\t\t\t.querySelectorAll( 'body > :not(.wp-lightbox-overlay)' )\n\t\t\t\t\t.forEach( ( el ) => {\n\t\t\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\t\t\tel.setAttribute( 'inert', '' );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tel.removeAttribute( 'inert' );\n\t\t\t\t\t\t}\n\t\t\t\t\t} );\n\t\t\t},\n\t\t\tinitTriggerButton() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\tconst { ref } = getElement();\n\t\t\t\tstate.metadata[ imageId ].buttonRef = ref;\n\t\t\t},\n\t\t},\n\t},\n\t{ lock: true }\n);\n"],
|
|
5
|
-
"mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,2BAA2B;AAQpC,IAAI,aAAa;AAQjB,IAAI,gBAAgB;AAEpB,IAAM,kBAAkB;AAAA,EACvB,QAAQ;AAAA,EACR,QAAQ;AAAA,EACR,WAAW;AACZ;
|
|
4
|
+
"sourcesContent": ["import {\n\tstore,\n\tgetContext,\n\tgetElement,\n\tgetConfig,\n\twithSyncEvent,\n\twithScope,\n} from '@wordpress/interactivity';\nimport { IMAGE_PRELOAD_DELAY } from './constants';\n\n/**\n * Tracks whether user is touching screen; used to differentiate behavior for\n * touch and mouse input.\n *\n * @type {boolean}\n */\nlet isTouching = false;\n\n/**\n * Tracks the last time the screen was touched; used to differentiate behavior\n * for touch and mouse input.\n *\n * @type {number}\n */\nlet lastTouchTime = 0;\n\nconst touchStartEvent = {\n\tstartX: 0,\n\tstartY: 0,\n\tstartTime: 0,\n};\n\n/**\n * Elements made inert while the lightbox is open, so only those are restored\n * when it closes.\n *\n * @type {Element[]}\n */\nlet inertElements = [];\n\nconst focusableSelectors = [\n\t'.wp-lightbox-close-button',\n\t'.wp-lightbox-navigation-button',\n];\n\n/**\n * Returns the appropriate src URL for an image.\n *\n * @param {string} uploadedSrc - Full size image src.\n * @return {string} The source URL.\n */\nfunction getImageSrc( { uploadedSrc } ) {\n\treturn (\n\t\tuploadedSrc ||\n\t\t'data:image/gif;base64,R0lGODlhAQABAAD/ACwAAAAAAQABAAACADs='\n\t);\n}\n\n/**\n * Returns the appropriate srcset for an image.\n *\n * @param {string} lightboxSrcset - Image srcset.\n * @return {string} The srcset value.\n */\nfunction getImageSrcset( { lightboxSrcset } ) {\n\treturn lightboxSrcset || '';\n}\n\nconst { state, actions, callbacks } = store(\n\t'core/image',\n\t{\n\t\tstate: {\n\t\t\tselectedImageId: null,\n\t\t\tselectedGalleryId: null,\n\t\t\tpreloadTimers: new Map(),\n\t\t\tpreloadedImageIds: new Set(),\n\t\t\tget galleryImages() {\n\t\t\t\tif ( ! state.selectedGalleryId ) {\n\t\t\t\t\treturn [ state.selectedImageId ];\n\t\t\t\t}\n\n\t\t\t\t// Get all images in this gallery and sort by galleryOrder\n\t\t\t\treturn Object.entries( state.metadata )\n\t\t\t\t\t.filter(\n\t\t\t\t\t\t( [ , value ] ) =>\n\t\t\t\t\t\t\tvalue.galleryId === state.selectedGalleryId\n\t\t\t\t\t)\n\t\t\t\t\t.sort( ( [ , a ], [ , b ] ) => {\n\t\t\t\t\t\tconst orderA = a.order ?? 0;\n\t\t\t\t\t\tconst orderB = b.order ?? 0;\n\t\t\t\t\t\treturn orderA - orderB;\n\t\t\t\t\t} )\n\t\t\t\t\t.map( ( [ key ] ) => key );\n\t\t\t},\n\t\t\tget selectedImageIndex() {\n\t\t\t\treturn state.galleryImages.findIndex(\n\t\t\t\t\t( id ) => id === state.selectedImageId\n\t\t\t\t);\n\t\t\t},\n\t\t\tget selectedImage() {\n\t\t\t\treturn state.metadata[ state.selectedImageId ];\n\t\t\t},\n\t\t\tget hasNavigationIcon() {\n\t\t\t\tconst { navigationButtonType } = state.selectedImage;\n\t\t\t\treturn (\n\t\t\t\t\tnavigationButtonType === 'icon' ||\n\t\t\t\t\tnavigationButtonType === 'both'\n\t\t\t\t);\n\t\t\t},\n\t\t\tget hasNavigationText() {\n\t\t\t\tconst { navigationButtonType } = state.selectedImage;\n\t\t\t\treturn (\n\t\t\t\t\tnavigationButtonType === 'text' ||\n\t\t\t\t\tnavigationButtonType === 'both'\n\t\t\t\t);\n\t\t\t},\n\t\t\tget thisImage() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\treturn state.metadata[ imageId ];\n\t\t\t},\n\t\t\tget hasNavigation() {\n\t\t\t\treturn state.galleryImages.length > 1;\n\t\t\t},\n\t\t\tget hasNextImage() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.selectedImageIndex + 1 < state.galleryImages.length\n\t\t\t\t);\n\t\t\t},\n\t\t\tget hasPreviousImage() {\n\t\t\t\treturn state.selectedImageIndex - 1 >= 0;\n\t\t\t},\n\t\t\tget overlayOpened() {\n\t\t\t\treturn state.selectedImageId !== null;\n\t\t\t},\n\t\t\tget roleAttribute() {\n\t\t\t\treturn state.overlayOpened ? 'dialog' : null;\n\t\t\t},\n\t\t\tget ariaModal() {\n\t\t\t\treturn state.overlayOpened ? 'true' : null;\n\t\t\t},\n\t\t\tget ariaLabel() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.selectedImage.customAriaLabel ||\n\t\t\t\t\tgetConfig().defaultAriaLabel\n\t\t\t\t);\n\t\t\t},\n\t\t\tget closeButtonAriaLabel() {\n\t\t\t\treturn state.hasNavigationText\n\t\t\t\t\t? undefined\n\t\t\t\t\t: getConfig().closeButtonText;\n\t\t\t},\n\t\t\tget prevButtonAriaLabel() {\n\t\t\t\treturn state.hasNavigationText\n\t\t\t\t\t? undefined\n\t\t\t\t\t: getConfig().prevButtonText;\n\t\t\t},\n\t\t\tget nextButtonAriaLabel() {\n\t\t\t\treturn state.hasNavigationText\n\t\t\t\t\t? undefined\n\t\t\t\t\t: getConfig().nextButtonText;\n\t\t\t},\n\t\t\tget enlargedSrc() {\n\t\t\t\treturn getImageSrc( state.selectedImage );\n\t\t\t},\n\t\t\tget enlargedSrcset() {\n\t\t\t\treturn getImageSrcset( state.selectedImage );\n\t\t\t},\n\t\t\tget figureStyles() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.overlayOpened &&\n\t\t\t\t\t`${ state.selectedImage.figureStyles?.replace(\n\t\t\t\t\t\t/margin[^;]*;?/g,\n\t\t\t\t\t\t''\n\t\t\t\t\t) };`\n\t\t\t\t);\n\t\t\t},\n\t\t\tget imgStyles() {\n\t\t\t\treturn (\n\t\t\t\t\tstate.overlayOpened &&\n\t\t\t\t\t`${ state.selectedImage.imgStyles?.replace(\n\t\t\t\t\t\t/;$/,\n\t\t\t\t\t\t''\n\t\t\t\t\t) }; object-fit:cover;`\n\t\t\t\t);\n\t\t\t},\n\t\t\tget isContentHidden() {\n\t\t\t\tconst ctx = getContext();\n\t\t\t\treturn (\n\t\t\t\t\tstate.overlayEnabled &&\n\t\t\t\t\tstate.selectedImageId === ctx.imageId\n\t\t\t\t);\n\t\t\t},\n\t\t\tget isContentVisible() {\n\t\t\t\tconst ctx = getContext();\n\t\t\t\treturn (\n\t\t\t\t\t! state.overlayEnabled &&\n\t\t\t\t\tstate.selectedImageId === ctx.imageId\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\tactions: {\n\t\t\tshowLightbox() {\n\t\t\t\tconst { imageId } = getContext();\n\n\t\t\t\t// Bails out if the image has not loaded yet.\n\t\t\t\tif ( ! state.metadata[ imageId ].imageRef?.complete ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Stores the positions of the scroll to fix it until the overlay is\n\t\t\t\t// closed.\n\t\t\t\tstate.scrollTopReset = document.documentElement.scrollTop;\n\t\t\t\tstate.scrollLeftReset = document.documentElement.scrollLeft;\n\n\t\t\t\t// Sets the selected image and gallery and enables the overlay.\n\t\t\t\tstate.selectedImageId = imageId;\n\t\t\t\tconst { galleryId } = getContext( 'core/gallery' ) || {};\n\t\t\t\tstate.selectedGalleryId = galleryId || null;\n\t\t\t\tstate.overlayEnabled = true;\n\n\t\t\t\t// Computes the styles of the overlay for the animation.\n\t\t\t\tcallbacks.setOverlayStyles();\n\t\t\t},\n\t\t\thideLightbox() {\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\tstate.overlayEnabled = false;\n\n\t\t\t\t\t// Waits until the close animation has completed before allowing a\n\t\t\t\t\t// user to scroll again. The duration of this animation is defined in\n\t\t\t\t\t// the `styles.scss` file, but in any case we should wait a few\n\t\t\t\t\t// milliseconds longer than the duration, otherwise a user may scroll\n\t\t\t\t\t// too soon and cause the animation to look sloppy.\n\t\t\t\t\tsetTimeout( function () {\n\t\t\t\t\t\t// Delays before changing the focus. Otherwise the focus ring will\n\t\t\t\t\t\t// appear on Firefox before the image has finished animating, which\n\t\t\t\t\t\t// looks broken.\n\t\t\t\t\t\tstate.selectedImage.buttonRef.focus( {\n\t\t\t\t\t\t\tpreventScroll: true,\n\t\t\t\t\t\t} );\n\n\t\t\t\t\t\t// Resets the selected image and gallery ids.\n\t\t\t\t\t\tstate.selectedImageId = null;\n\t\t\t\t\t\tstate.selectedGalleryId = null;\n\t\t\t\t\t}, 450 );\n\t\t\t\t}\n\t\t\t},\n\t\t\tshowPreviousImage: withSyncEvent( ( event ) => {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tconst nextIndex = state.hasPreviousImage\n\t\t\t\t\t? state.selectedImageIndex - 1\n\t\t\t\t\t: state.galleryImages.length - 1;\n\t\t\t\tstate.selectedImageId = state.galleryImages[ nextIndex ];\n\t\t\t\tcallbacks.setOverlayStyles();\n\t\t\t} ),\n\t\t\tshowNextImage: withSyncEvent( ( event ) => {\n\t\t\t\tevent.stopPropagation();\n\t\t\t\tconst nextIndex = state.hasNextImage\n\t\t\t\t\t? state.selectedImageIndex + 1\n\t\t\t\t\t: 0;\n\t\t\t\tstate.selectedImageId = state.galleryImages[ nextIndex ];\n\t\t\t\tcallbacks.setOverlayStyles();\n\t\t\t} ),\n\t\t\thandleKeydown: withSyncEvent( ( event ) => {\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\tif ( event.key === 'Escape' ) {\n\t\t\t\t\t\tactions.hideLightbox();\n\t\t\t\t\t} else if ( event.key === 'ArrowLeft' ) {\n\t\t\t\t\t\tactions.showPreviousImage( event );\n\t\t\t\t\t} else if ( event.key === 'ArrowRight' ) {\n\t\t\t\t\t\tactions.showNextImage( event );\n\t\t\t\t\t} else if ( event.key === 'Tab' ) {\n\t\t\t\t\t\t// Traps focus within the overlay.\n\t\t\t\t\t\tconst focusableElements = Array.from(\n\t\t\t\t\t\t\tdocument.querySelectorAll( focusableSelectors )\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst firstFocusableElement = focusableElements[ 0 ];\n\t\t\t\t\t\tconst lastFocusableElement =\n\t\t\t\t\t\t\tfocusableElements[ focusableElements.length - 1 ];\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tevent.shiftKey &&\n\t\t\t\t\t\t\tevent.target === firstFocusableElement\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tlastFocusableElement.focus();\n\t\t\t\t\t\t} else if (\n\t\t\t\t\t\t\t! event.shiftKey &&\n\t\t\t\t\t\t\tevent.target === lastFocusableElement\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\t\tfirstFocusableElement.focus();\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t} ),\n\t\t\thandleTouchMove: withSyncEvent( ( event ) => {\n\t\t\t\t// On mobile devices, prevents triggering the scroll event because\n\t\t\t\t// otherwise the page jumps around when it resets the scroll position.\n\t\t\t\t// This also means that closing the lightbox requires that a user\n\t\t\t\t// perform a simple tap. This may be changed in the future if there is a\n\t\t\t\t// better alternative to override or reset the scroll position during\n\t\t\t\t// swipe actions.\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t}\n\t\t\t} ),\n\t\t\thandleTouchStart( event ) {\n\t\t\t\tisTouching = true;\n\t\t\t\tconst t = event.touches && event.touches[ 0 ];\n\t\t\t\tif ( t ) {\n\t\t\t\t\ttouchStartEvent.startX = t.clientX;\n\t\t\t\t\ttouchStartEvent.startY = t.clientY;\n\t\t\t\t\ttouchStartEvent.startTime = Date.now();\n\t\t\t\t}\n\t\t\t},\n\t\t\thandleTouchEnd: withSyncEvent( ( event ) => {\n\t\t\t\tconst touchEndEvent =\n\t\t\t\t\t( event.changedTouches && event.changedTouches[ 0 ] ) ||\n\t\t\t\t\t( event.touches && event.touches[ 0 ] );\n\t\t\t\tconst now = Date.now();\n\n\t\t\t\tif ( touchEndEvent && state.overlayEnabled ) {\n\t\t\t\t\tconst deltaX =\n\t\t\t\t\t\ttouchEndEvent.clientX - touchStartEvent.startX;\n\t\t\t\t\tconst deltaY =\n\t\t\t\t\t\ttouchEndEvent.clientY - touchStartEvent.startY;\n\t\t\t\t\tconst absDeltaX = Math.abs( deltaX );\n\t\t\t\t\tconst absDeltaY = Math.abs( deltaY );\n\t\t\t\t\tconst elapsedMs = now - touchStartEvent.startTime;\n\t\t\t\t\tconst isHorizontalSwipe =\n\t\t\t\t\t\t// Swipe distance is greater than 50px\n\t\t\t\t\t\tabsDeltaX > 50 &&\n\t\t\t\t\t\t// Horizontal movement is much larger than the vertical movement\n\t\t\t\t\t\tabsDeltaX > absDeltaY * 1.5 &&\n\t\t\t\t\t\t// Fast action of less than 800ms\n\t\t\t\t\t\telapsedMs < 800;\n\n\t\t\t\t\tif ( isHorizontalSwipe ) {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tif ( deltaX < 0 ) {\n\t\t\t\t\t\t\tactions.showNextImage( event );\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tactions.showPreviousImage( event );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tlastTouchTime = now;\n\t\t\t\tisTouching = false;\n\t\t\t} ),\n\t\t\thandleScroll() {\n\t\t\t\t// Prevents scrolling behaviors that trigger content shift while the\n\t\t\t\t// lightbox is open. It would be better to accomplish through CSS alone,\n\t\t\t\t// but using overflow: hidden is currently the only way to do so and\n\t\t\t\t// that causes a layout to shift and prevents the zoom animation from\n\t\t\t\t// working in some cases because it's not possible to account for the\n\t\t\t\t// layout shift when doing the animation calculations. Instead, it uses\n\t\t\t\t// JavaScript to prevent and reset the scrolling behavior.\n\t\t\t\tif ( state.overlayOpened ) {\n\t\t\t\t\t// Avoids overriding the scroll behavior on mobile devices because\n\t\t\t\t\t// doing so breaks the pinch to zoom functionality, and users should\n\t\t\t\t\t// be able to zoom in further on the high-res image.\n\t\t\t\t\tif ( ! isTouching && Date.now() - lastTouchTime > 450 ) {\n\t\t\t\t\t\t// It doesn't rely on `event.preventDefault()` to prevent scrolling\n\t\t\t\t\t\t// because the scroll event can't be canceled, so it resets the\n\t\t\t\t\t\t// position instead.\n\t\t\t\t\t\twindow.scrollTo(\n\t\t\t\t\t\t\tstate.scrollLeftReset,\n\t\t\t\t\t\t\tstate.scrollTopReset\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t},\n\t\t\tpreloadImage() {\n\t\t\t\tconst { imageId } = getContext();\n\n\t\t\t\t// Bails if it has already been preloaded. This could help\n\t\t\t\t// prevent unnecessary preloading of the same image multiple times,\n\t\t\t\t// leading to duplicate link elements in the document head.\n\t\t\t\tif ( state.preloadedImageIds.has( imageId ) ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\t// Link element to preload the image.\n\t\t\t\tconst imageMetadata = state.metadata[ imageId ];\n\t\t\t\tconst imageLink = document.createElement( 'link' );\n\t\t\t\timageLink.rel = 'preload';\n\t\t\t\timageLink.as = 'image';\n\t\t\t\timageLink.href = getImageSrc( imageMetadata );\n\n\t\t\t\t// Apply srcset if available for responsive preloading\n\t\t\t\tconst srcset = getImageSrcset( imageMetadata );\n\t\t\t\tif ( srcset ) {\n\t\t\t\t\timageLink.setAttribute( 'imagesrcset', srcset );\n\t\t\t\t\timageLink.setAttribute( 'imagesizes', '100vw' );\n\t\t\t\t}\n\n\t\t\t\tdocument.head.appendChild( imageLink );\n\t\t\t\tstate.preloadedImageIds.add( imageId );\n\t\t\t},\n\t\t\tpreloadImageWithDelay() {\n\t\t\t\tconst { imageId } = getContext();\n\n\t\t\t\tactions.cancelPreload();\n\n\t\t\t\t// Set a new timer to preload the image after a short delay.\n\t\t\t\tconst timerId = setTimeout(\n\t\t\t\t\twithScope( () => {\n\t\t\t\t\t\tactions.preloadImage();\n\t\t\t\t\t\tstate.preloadTimers.delete( imageId );\n\t\t\t\t\t} ),\n\t\t\t\t\tIMAGE_PRELOAD_DELAY\n\t\t\t\t);\n\t\t\t\tstate.preloadTimers.set( imageId, timerId );\n\t\t\t},\n\t\t\tcancelPreload() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\tif ( state.preloadTimers.has( imageId ) ) {\n\t\t\t\t\tclearTimeout( state.preloadTimers.get( imageId ) );\n\t\t\t\t\tstate.preloadTimers.delete( imageId );\n\t\t\t\t}\n\t\t\t},\n\t\t},\n\t\tcallbacks: {\n\t\t\tsetOverlayStyles() {\n\t\t\t\tif ( ! state.overlayEnabled ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tlet {\n\t\t\t\t\tnaturalWidth,\n\t\t\t\t\tnaturalHeight,\n\t\t\t\t\toffsetWidth: originalWidth,\n\t\t\t\t\toffsetHeight: originalHeight,\n\t\t\t\t} = state.selectedImage.imageRef;\n\t\t\t\tlet { x: screenPosX, y: screenPosY } =\n\t\t\t\t\tstate.selectedImage.imageRef.getBoundingClientRect();\n\n\t\t\t\t// Natural ratio of the image clicked to open the lightbox.\n\t\t\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\t\t\t// Original ratio of the image clicked to open the lightbox.\n\t\t\t\tconst originalRatio = originalWidth / originalHeight;\n\n\t\t\t\t// If it has object-fit: contain, recalculates the original sizes\n\t\t\t\t// and the screen position without the blank spaces.\n\t\t\t\tif ( state.selectedImage.scaleAttr === 'contain' ) {\n\t\t\t\t\tif ( naturalRatio > originalRatio ) {\n\t\t\t\t\t\tconst heightWithoutSpace = originalWidth / naturalRatio;\n\t\t\t\t\t\t// Recalculates screen position without the top space.\n\t\t\t\t\t\tscreenPosY +=\n\t\t\t\t\t\t\t( originalHeight - heightWithoutSpace ) / 2;\n\t\t\t\t\t\toriginalHeight = heightWithoutSpace;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst widthWithoutSpace = originalHeight * naturalRatio;\n\t\t\t\t\t\t// Recalculates screen position without the left space.\n\t\t\t\t\t\tscreenPosX += ( originalWidth - widthWithoutSpace ) / 2;\n\t\t\t\t\t\toriginalWidth = widthWithoutSpace;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\t// Typically, it uses the image's full-sized dimensions. If those\n\t\t\t\t// dimensions have not been set (i.e. an external image with only one\n\t\t\t\t// size), the image's dimensions in the lightbox are the same\n\t\t\t\t// as those of the image in the content.\n\t\t\t\tconst imgMaxWidth = parseFloat(\n\t\t\t\t\tstate.selectedImage.targetWidth &&\n\t\t\t\t\t\tstate.selectedImage.targetWidth !== 'none'\n\t\t\t\t\t\t? state.selectedImage.targetWidth\n\t\t\t\t\t\t: naturalWidth\n\t\t\t\t);\n\t\t\t\tconst imgMaxHeight = parseFloat(\n\t\t\t\t\tstate.selectedImage.targetHeight &&\n\t\t\t\t\t\tstate.selectedImage.targetHeight !== 'none'\n\t\t\t\t\t\t? state.selectedImage.targetHeight\n\t\t\t\t\t\t: naturalHeight\n\t\t\t\t);\n\n\t\t\t\t// Ratio of the biggest image stored in the database.\n\t\t\t\tconst fullSizeRatio = imgMaxWidth / imgMaxHeight;\n\t\t\t\tlet containerWidth = imgMaxWidth;\n\t\t\t\tlet containerHeight = imgMaxHeight;\n\n\t\t\t\t// If the image has been pixelated on purpose, it keeps that size.\n\t\t\t\tif (\n\t\t\t\t\toriginalWidth > containerWidth ||\n\t\t\t\t\toriginalHeight > containerHeight\n\t\t\t\t) {\n\t\t\t\t\tcontainerWidth = originalWidth;\n\t\t\t\t\tcontainerHeight = originalHeight;\n\t\t\t\t}\n\n\t\t\t\t// Calculates the final lightbox image size and the scale factor.\n\t\t\t\t// MaxWidth is either the window container (accounting for padding) or\n\t\t\t\t// the image resolution.\n\n\t\t\t\t// 480px width or less\n\t\t\t\tlet horizontalPadding = 0;\n\t\t\t\tlet verticalPadding = 160;\n\t\t\t\t// Greater than 480px wide and less than or equal to 960px\n\t\t\t\tif ( 480 < window.innerWidth ) {\n\t\t\t\t\thorizontalPadding = 80;\n\t\t\t\t\tverticalPadding = 160;\n\t\t\t\t}\n\t\t\t\t// Greater than 960px wide\n\t\t\t\tif ( 960 < window.innerWidth ) {\n\t\t\t\t\thorizontalPadding = state.hasNavigation ? 320 : 80;\n\t\t\t\t\tverticalPadding = 80;\n\t\t\t\t}\n\n\t\t\t\tconst targetMaxWidth = Math.min(\n\t\t\t\t\twindow.innerWidth - horizontalPadding,\n\t\t\t\t\tcontainerWidth\n\t\t\t\t);\n\t\t\t\tconst targetMaxHeight = Math.min(\n\t\t\t\t\twindow.innerHeight - verticalPadding,\n\t\t\t\t\tcontainerHeight\n\t\t\t\t);\n\t\t\t\tconst targetContainerRatio = targetMaxWidth / targetMaxHeight;\n\n\t\t\t\tif ( fullSizeRatio > targetContainerRatio ) {\n\t\t\t\t\t// If targetMaxWidth is reached before targetMaxHeight.\n\t\t\t\t\tcontainerWidth = targetMaxWidth;\n\t\t\t\t\tcontainerHeight = containerWidth / fullSizeRatio;\n\t\t\t\t} else {\n\t\t\t\t\t// If targetMaxHeight is reached before targetMaxWidth.\n\t\t\t\t\tcontainerHeight = targetMaxHeight;\n\t\t\t\t\tcontainerWidth = containerHeight * fullSizeRatio;\n\t\t\t\t}\n\n\t\t\t\tconst hasCroppedSource =\n\t\t\t\t\tnaturalRatio.toFixed( 2 ) !== fullSizeRatio.toFixed( 2 );\n\t\t\t\tconst sourceRatio = hasCroppedSource\n\t\t\t\t\t? naturalRatio\n\t\t\t\t\t: fullSizeRatio;\n\n\t\t\t\t// Include any crop already applied to the thumbnail file.\n\t\t\t\tconst containerScale = Math.max(\n\t\t\t\t\toriginalWidth / containerWidth,\n\t\t\t\t\toriginalHeight / containerHeight,\n\t\t\t\t\toriginalWidth / ( containerHeight * sourceRatio ),\n\t\t\t\t\t( originalHeight * sourceRatio ) / containerWidth\n\t\t\t\t);\n\t\t\t\tconst thumbnailWidth = originalWidth / containerScale;\n\t\t\t\tconst thumbnailHeight = originalHeight / containerScale;\n\t\t\t\tconst cropX = ( containerWidth - thumbnailWidth ) / 2;\n\t\t\t\tconst cropY = ( containerHeight - thumbnailHeight ) / 2;\n\t\t\t\tscreenPosX -= cropX * containerScale;\n\t\t\t\tscreenPosY -= cropY * containerScale;\n\n\t\t\t\t// As of this writing, using the calculations above will render the\n\t\t\t\t// lightbox with a small, erroneous whitespace on the left side of the\n\t\t\t\t// image in iOS Safari, perhaps due to an inconsistency in how browsers\n\t\t\t\t// handle absolute positioning and CSS transformation. In any case,\n\t\t\t\t// adding 1 pixel to the container width and height solves the problem,\n\t\t\t\t// though this can be removed if the issue is fixed in the future.\n\t\t\t\tstate.overlayStyles = `\n\t\t\t\t\t--wp--lightbox-initial-top-position: ${ screenPosY }px;\n\t\t\t\t\t--wp--lightbox-initial-left-position: ${ screenPosX }px;\n\t\t\t\t\t--wp--lightbox-container-width: ${ containerWidth + 1 }px;\n\t\t\t\t\t--wp--lightbox-container-height: ${ containerHeight + 1 }px;\n\t\t\t\t\t--wp--lightbox-image-width: ${ containerWidth }px;\n\t\t\t\t\t--wp--lightbox-image-height: ${ containerHeight }px;\n\t\t\t\t\t--wp--lightbox-initial-clip: inset(${ cropY }px ${ cropX }px);\n\t\t\t\t\t--wp--lightbox-thumbnail-width: ${\n\t\t\t\t\t\thasCroppedSource ? thumbnailWidth : containerWidth\n\t\t\t\t\t}px;\n\t\t\t\t\t--wp--lightbox-thumbnail-height: ${\n\t\t\t\t\t\thasCroppedSource ? thumbnailHeight : containerHeight\n\t\t\t\t\t}px;\n\t\t\t\t\t--wp--lightbox-scale: ${ containerScale };\n\t\t\t\t\t--wp--lightbox-scrollbar-width: ${\n\t\t\t\t\t\twindow.innerWidth - document.documentElement.clientWidth\n\t\t\t\t\t}px;\n\t\t\t\t`;\n\t\t\t},\n\t\t\tsetButtonStyles() {\n\t\t\t\tconst { ref } = getElement();\n\n\t\t\t\t// This guard prevents errors in images with the `srcset`\n\t\t\t\t// attribute, which can dispatch `load` events even after DOM\n\t\t\t\t// removal. Preact doesn't automatically clean up `load` event\n\t\t\t\t// listeners on unmounted `img` elements (see\n\t\t\t\t// https://github.com/preactjs/preact/issues/3141).\n\t\t\t\tif ( ! ref ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst { imageId } = getContext();\n\n\t\t\t\tstate.metadata[ imageId ].imageRef = ref;\n\t\t\t\tstate.metadata[ imageId ].currentSrc = ref.currentSrc;\n\n\t\t\t\tconst {\n\t\t\t\t\tnaturalWidth,\n\t\t\t\t\tnaturalHeight,\n\t\t\t\t\toffsetWidth,\n\t\t\t\t\toffsetHeight,\n\t\t\t\t} = ref;\n\n\t\t\t\t// If the image isn't loaded yet, it can't calculate where the button\n\t\t\t\t// should be.\n\t\t\t\tif ( naturalWidth === 0 || naturalHeight === 0 ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst figure = ref.parentElement;\n\t\t\t\tconst figureWidth = ref.parentElement.clientWidth;\n\n\t\t\t\t// It needs special handling for the height because a caption will cause\n\t\t\t\t// the figure to be taller than the image, which means it needs to\n\t\t\t\t// account for that when calculating the placement of the button in the\n\t\t\t\t// top right corner of the image.\n\t\t\t\tlet figureHeight = ref.parentElement.clientHeight;\n\t\t\t\tconst caption = figure.querySelector( 'figcaption' );\n\t\t\t\tif ( caption ) {\n\t\t\t\t\tconst captionComputedStyle =\n\t\t\t\t\t\twindow.getComputedStyle( caption );\n\t\t\t\t\tif (\n\t\t\t\t\t\t! [ 'absolute', 'fixed' ].includes(\n\t\t\t\t\t\t\tcaptionComputedStyle.position\n\t\t\t\t\t\t)\n\t\t\t\t\t) {\n\t\t\t\t\t\tfigureHeight =\n\t\t\t\t\t\t\tfigureHeight -\n\t\t\t\t\t\t\tcaption.offsetHeight -\n\t\t\t\t\t\t\tparseFloat( captionComputedStyle.marginTop ) -\n\t\t\t\t\t\t\tparseFloat( captionComputedStyle.marginBottom );\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tconst buttonOffsetTop = figureHeight - offsetHeight;\n\t\t\t\tconst buttonOffsetRight = figureWidth - offsetWidth;\n\n\t\t\t\tlet buttonTop = buttonOffsetTop + 16;\n\t\t\t\tlet buttonRight = buttonOffsetRight + 16;\n\n\t\t\t\t// In the case of an image with object-fit: contain, the size of the\n\t\t\t\t// <img> element can be larger than the image itself, so it needs to\n\t\t\t\t// calculate where to place the button.\n\t\t\t\tif ( state.metadata[ imageId ].scaleAttr === 'contain' ) {\n\t\t\t\t\t// Natural ratio of the image.\n\t\t\t\t\tconst naturalRatio = naturalWidth / naturalHeight;\n\t\t\t\t\t// Offset ratio of the image.\n\t\t\t\t\tconst offsetRatio = offsetWidth / offsetHeight;\n\n\t\t\t\t\tif ( naturalRatio >= offsetRatio ) {\n\t\t\t\t\t\t// If it reaches the width first, it keeps the width and compute the\n\t\t\t\t\t\t// height.\n\t\t\t\t\t\tconst referenceHeight = offsetWidth / naturalRatio;\n\t\t\t\t\t\tbuttonTop =\n\t\t\t\t\t\t\t( offsetHeight - referenceHeight ) / 2 +\n\t\t\t\t\t\t\tbuttonOffsetTop +\n\t\t\t\t\t\t\t16;\n\t\t\t\t\t\tbuttonRight = buttonOffsetRight + 16;\n\t\t\t\t\t} else {\n\t\t\t\t\t\t// If it reaches the height first, it keeps the height and compute\n\t\t\t\t\t\t// the width.\n\t\t\t\t\t\tconst referenceWidth = offsetHeight * naturalRatio;\n\t\t\t\t\t\tbuttonTop = buttonOffsetTop + 16;\n\t\t\t\t\t\tbuttonRight =\n\t\t\t\t\t\t\t( offsetWidth - referenceWidth ) / 2 +\n\t\t\t\t\t\t\tbuttonOffsetRight +\n\t\t\t\t\t\t\t16;\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tstate.metadata[ imageId ].buttonTop = buttonTop;\n\t\t\t\tstate.metadata[ imageId ].buttonRight = buttonRight;\n\t\t\t},\n\t\t\tsetOverlayFocus() {\n\t\t\t\tif ( state.overlayEnabled ) {\n\t\t\t\t\t// Moves the focus to the dialog when it opens.\n\t\t\t\t\tconst { ref } = getElement();\n\t\t\t\t\tref.focus();\n\t\t\t\t}\n\t\t\t},\n\t\t\tsetInertElements() {\n\t\t\t\tif ( ! state.overlayEnabled ) {\n\t\t\t\t\tinertElements.forEach( ( el ) =>\n\t\t\t\t\t\tel.removeAttribute( 'inert' )\n\t\t\t\t\t);\n\t\t\t\t\tinertElements = [];\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Inerts the overlay's siblings at each level, not its ancestors.\n\t\t\t\tconst { ref } = getElement();\n\t\t\t\tlet node = ref;\n\t\t\t\twhile ( node && node !== document.body && node.parentElement ) {\n\t\t\t\t\tfor ( const sibling of node.parentElement.children ) {\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tsibling !== node &&\n\t\t\t\t\t\t\t! sibling.hasAttribute( 'inert' )\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\tsibling.setAttribute( 'inert', '' );\n\t\t\t\t\t\t\tinertElements.push( sibling );\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t\tnode = node.parentElement;\n\t\t\t\t}\n\t\t\t},\n\t\t\tinitTriggerButton() {\n\t\t\t\tconst { imageId } = getContext();\n\t\t\t\tconst { ref } = getElement();\n\t\t\t\tstate.metadata[ imageId ].buttonRef = ref;\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|
|
|
49
49
|
"link": true
|
|
50
50
|
}
|
|
51
51
|
},
|
|
52
|
+
"dimensions": {
|
|
53
|
+
"minHeight": true,
|
|
54
|
+
"minWidth": true
|
|
55
|
+
},
|
|
52
56
|
"html": false,
|
|
53
57
|
"spacing": {
|
|
54
58
|
"margin": true,
|
|
55
59
|
"padding": true
|
|
56
60
|
},
|
|
61
|
+
"__experimentalBorder": {
|
|
62
|
+
"color": true,
|
|
63
|
+
"radius": true,
|
|
64
|
+
"style": true,
|
|
65
|
+
"width": true
|
|
66
|
+
},
|
|
57
67
|
"shadow": true,
|
|
58
68
|
"typography": {
|
|
59
69
|
"fontSize": true,
|
|
@@ -58,6 +58,15 @@
|
|
|
58
58
|
"fontSize": true
|
|
59
59
|
}
|
|
60
60
|
},
|
|
61
|
+
"background": {
|
|
62
|
+
"backgroundImage": true,
|
|
63
|
+
"backgroundSize": true,
|
|
64
|
+
"gradient": true,
|
|
65
|
+
"__experimentalDefaultControls": {
|
|
66
|
+
"backgroundImage": true,
|
|
67
|
+
"gradient": true
|
|
68
|
+
}
|
|
69
|
+
},
|
|
61
70
|
"color": {
|
|
62
71
|
"gradients": true,
|
|
63
72
|
"link": true,
|
|
@@ -74,6 +83,7 @@
|
|
|
74
83
|
"padding": false
|
|
75
84
|
}
|
|
76
85
|
},
|
|
86
|
+
"shadow": true,
|
|
77
87
|
"__unstablePasteTextInline": true,
|
|
78
88
|
"__experimentalOnMerge": true,
|
|
79
89
|
"__experimentalSlashInserter": true,
|
|
@@ -83,7 +93,8 @@
|
|
|
83
93
|
"listView": true
|
|
84
94
|
},
|
|
85
95
|
"selectors": {
|
|
86
|
-
"border": ".wp-block-list:not(.wp-block-list .wp-block-list)"
|
|
96
|
+
"border": ".wp-block-list:not(.wp-block-list .wp-block-list)",
|
|
97
|
+
"shadow": ".wp-block-list:not(.wp-block-list .wp-block-list)"
|
|
87
98
|
},
|
|
88
99
|
"editorStyle": "wp-block-list-editor",
|
|
89
100
|
"style": "wp-block-list"
|
|
@@ -24,6 +24,11 @@
|
|
|
24
24
|
"html": false,
|
|
25
25
|
"className": false,
|
|
26
26
|
"splitting": true,
|
|
27
|
+
"background": {
|
|
28
|
+
"backgroundImage": true,
|
|
29
|
+
"backgroundSize": true,
|
|
30
|
+
"gradient": true
|
|
31
|
+
},
|
|
27
32
|
"__experimentalBorder": {
|
|
28
33
|
"color": true,
|
|
29
34
|
"radius": true,
|
|
@@ -46,6 +51,7 @@
|
|
|
46
51
|
"padding": false
|
|
47
52
|
}
|
|
48
53
|
},
|
|
54
|
+
"shadow": true,
|
|
49
55
|
"typography": {
|
|
50
56
|
"fontSize": true,
|
|
51
57
|
"lineHeight": true,
|
|
@@ -65,6 +71,7 @@
|
|
|
65
71
|
},
|
|
66
72
|
"selectors": {
|
|
67
73
|
"root": ".wp-block-list > li",
|
|
68
|
-
"border": ".wp-block-list:not(.wp-block-list .wp-block-list) > li"
|
|
74
|
+
"border": ".wp-block-list:not(.wp-block-list .wp-block-list) > li",
|
|
75
|
+
"shadow": ".wp-block-list:not(.wp-block-list .wp-block-list) > li"
|
|
69
76
|
}
|
|
70
77
|
}
|
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
// packages/block-library/src/list-item/index.js
|
|
2
2
|
import { listItem as icon } from "@wordpress/icons";
|
|
3
3
|
import { privateApis } from "@wordpress/block-editor";
|
|
4
|
+
import { privateApis as blocksPrivateApis } from "@wordpress/blocks";
|
|
4
5
|
import initBlock from "../utils/init-block.mjs";
|
|
5
6
|
import metadata from "./block.json";
|
|
6
7
|
import edit from "./edit.mjs";
|
|
7
8
|
import save from "./save.mjs";
|
|
8
9
|
import transforms from "./transforms.mjs";
|
|
9
10
|
import { unlock } from "../lock-unlock.mjs";
|
|
11
|
+
var { editableRootKey } = unlock(blocksPrivateApis);
|
|
10
12
|
var { name } = metadata;
|
|
11
13
|
var settings = {
|
|
12
14
|
icon,
|
|
15
|
+
// Opt into the editing host behaviour privately, like the paragraph.
|
|
16
|
+
[editableRootKey]: true,
|
|
13
17
|
edit,
|
|
14
18
|
save,
|
|
15
19
|
merge(attributes, attributesToMerge) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/list-item/index.js"],
|
|
4
|
-
"sourcesContent": ["import { listItem as icon } from '@wordpress/icons';\nimport { privateApis } from '@wordpress/block-editor';\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\nimport transforms from './transforms';\nimport { unlock } from '../lock-unlock';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\tedit,\n\tsave,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\t...attributes,\n\t\t\tcontent: attributes.content + attributesToMerge.content,\n\t\t};\n\t},\n\ttransforms,\n\t[ unlock( privateApis ).requiresWrapperOnCopy ]: true,\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst { content } = attributes;\n\n\t\tconst customName = attributes?.metadata?.name;\n\t\tconst hasContent = content?.trim().length > 0;\n\n\t\t// In the list view, use the block's content as the label.\n\t\t// If the content is empty, fall back to the default label.\n\t\tif ( context === 'list-view' && ( customName || hasContent ) ) {\n\t\t\treturn customName || content;\n\t\t}\n\n\t\tif ( context === 'breadcrumb' && customName ) {\n\t\t\treturn customName;\n\t\t}\n\t},\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,YAAY,YAAY;AACjC,SAAS,mBAAmB;AAC5B,OAAO,eAAe;AACtB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AACvB,SAAS,cAAc;AAEvB,IAAM,EAAE,KAAK,IAAI;AAIV,IAAM,WAAW;AAAA,EACvB;AAAA,
|
|
4
|
+
"sourcesContent": ["import { listItem as icon } from '@wordpress/icons';\nimport { privateApis } from '@wordpress/block-editor';\nimport { privateApis as blocksPrivateApis } from '@wordpress/blocks';\nimport initBlock from '../utils/init-block';\nimport metadata from './block.json';\nimport edit from './edit';\nimport save from './save';\nimport transforms from './transforms';\nimport { unlock } from '../lock-unlock';\n\nconst { editableRootKey } = unlock( blocksPrivateApis );\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\t// Opt into the editing host behaviour privately, like the paragraph.\n\t[ editableRootKey ]: true,\n\tedit,\n\tsave,\n\tmerge( attributes, attributesToMerge ) {\n\t\treturn {\n\t\t\t...attributes,\n\t\t\tcontent: attributes.content + attributesToMerge.content,\n\t\t};\n\t},\n\ttransforms,\n\t[ unlock( privateApis ).requiresWrapperOnCopy ]: true,\n\t__experimentalLabel( attributes, { context } ) {\n\t\tconst { content } = attributes;\n\n\t\tconst customName = attributes?.metadata?.name;\n\t\tconst hasContent = content?.trim().length > 0;\n\n\t\t// In the list view, use the block's content as the label.\n\t\t// If the content is empty, fall back to the default label.\n\t\tif ( context === 'list-view' && ( customName || hasContent ) ) {\n\t\t\treturn customName || content;\n\t\t}\n\n\t\tif ( context === 'breadcrumb' && customName ) {\n\t\t\treturn customName;\n\t\t}\n\t},\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,YAAY,YAAY;AACjC,SAAS,mBAAmB;AAC5B,SAAS,eAAe,yBAAyB;AACjD,OAAO,eAAe;AACtB,OAAO,cAAc;AACrB,OAAO,UAAU;AACjB,OAAO,UAAU;AACjB,OAAO,gBAAgB;AACvB,SAAS,cAAc;AAEvB,IAAM,EAAE,gBAAgB,IAAI,OAAQ,iBAAkB;AAEtD,IAAM,EAAE,KAAK,IAAI;AAIV,IAAM,WAAW;AAAA,EACvB;AAAA;AAAA,EAEA,CAAE,eAAgB,GAAG;AAAA,EACrB;AAAA,EACA;AAAA,EACA,MAAO,YAAY,mBAAoB;AACtC,WAAO;AAAA,MACN,GAAG;AAAA,MACH,SAAS,WAAW,UAAU,kBAAkB;AAAA,IACjD;AAAA,EACD;AAAA,EACA;AAAA,EACA,CAAE,OAAQ,WAAY,EAAE,qBAAsB,GAAG;AAAA,EACjD,oBAAqB,YAAY,EAAE,QAAQ,GAAI;AAC9C,UAAM,EAAE,QAAQ,IAAI;AAEpB,UAAM,aAAa,YAAY,UAAU;AACzC,UAAM,aAAa,SAAS,KAAK,EAAE,SAAS;AAI5C,QAAK,YAAY,gBAAiB,cAAc,aAAe;AAC9D,aAAO,cAAc;AAAA,IACtB;AAEA,QAAK,YAAY,gBAAgB,YAAa;AAC7C,aAAO;AAAA,IACR;AAAA,EACD;AACD;AAEO,IAAM,OAAO,MAAM,UAAW,EAAE,MAAM,UAAU,SAAS,CAAE;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -100,6 +100,11 @@
|
|
|
100
100
|
"anchor": true,
|
|
101
101
|
"align": [ "wide", "full" ],
|
|
102
102
|
"html": false,
|
|
103
|
+
"background": {
|
|
104
|
+
"backgroundImage": true,
|
|
105
|
+
"backgroundSize": true,
|
|
106
|
+
"gradient": true
|
|
107
|
+
},
|
|
103
108
|
"__experimentalBorder": {
|
|
104
109
|
"color": true,
|
|
105
110
|
"radius": true,
|
|
@@ -122,10 +127,15 @@
|
|
|
122
127
|
"text": true
|
|
123
128
|
}
|
|
124
129
|
},
|
|
130
|
+
"dimensions": {
|
|
131
|
+
"minHeight": true,
|
|
132
|
+
"minWidth": true
|
|
133
|
+
},
|
|
125
134
|
"spacing": {
|
|
126
135
|
"margin": true,
|
|
127
136
|
"padding": true
|
|
128
137
|
},
|
|
138
|
+
"shadow": true,
|
|
129
139
|
"typography": {
|
|
130
140
|
"fontSize": true,
|
|
131
141
|
"lineHeight": true,
|
|
@@ -139,11 +149,19 @@
|
|
|
139
149
|
"fontSize": true
|
|
140
150
|
}
|
|
141
151
|
},
|
|
152
|
+
"filter": {
|
|
153
|
+
"duotone": true
|
|
154
|
+
},
|
|
142
155
|
"interactivity": {
|
|
143
156
|
"clientNavigation": true
|
|
144
157
|
},
|
|
145
158
|
"allowedBlocks": true
|
|
146
159
|
},
|
|
160
|
+
"selectors": {
|
|
161
|
+
"filter": {
|
|
162
|
+
"duotone": ".wp-block-media-text > .wp-block-media-text__media img, .wp-block-media-text > .wp-block-media-text__media video"
|
|
163
|
+
}
|
|
164
|
+
},
|
|
147
165
|
"editorStyle": "wp-block-media-text-editor",
|
|
148
166
|
"style": "wp-block-media-text"
|
|
149
167
|
}
|
|
@@ -21,38 +21,41 @@ import { VisuallyHidden } from "@wordpress/ui";
|
|
|
21
21
|
import { isURL } from "@wordpress/url";
|
|
22
22
|
import { LinkUIPageCreator } from "./page-creator.mjs";
|
|
23
23
|
import LinkUIBlockInserter from "./block-inserter.mjs";
|
|
24
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
isBlockSuggestion,
|
|
26
|
+
useBlockSuggestions,
|
|
27
|
+
useEntityBinding,
|
|
28
|
+
useLinkPreview
|
|
29
|
+
} from "../shared/index.mjs";
|
|
25
30
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
26
|
-
function
|
|
27
|
-
const perPage = 20;
|
|
31
|
+
function getOwnTypeSearchOptions(type, kind) {
|
|
28
32
|
switch (type) {
|
|
29
33
|
case "post":
|
|
30
34
|
case "page":
|
|
31
|
-
return { type: "post", subtype: type
|
|
35
|
+
return { type: "post", subtype: type };
|
|
32
36
|
case "category":
|
|
33
|
-
return { type: "term", subtype: "category"
|
|
37
|
+
return { type: "term", subtype: "category" };
|
|
34
38
|
case "tag":
|
|
35
|
-
return { type: "term", subtype: "post_tag"
|
|
39
|
+
return { type: "term", subtype: "post_tag" };
|
|
36
40
|
case "post_format":
|
|
37
|
-
return { type: "post-format"
|
|
41
|
+
return { type: "post-format" };
|
|
38
42
|
default:
|
|
39
43
|
if (kind === "taxonomy") {
|
|
40
|
-
return { type: "term", subtype: type
|
|
44
|
+
return { type: "term", subtype: type };
|
|
41
45
|
}
|
|
42
46
|
if (kind === "post-type") {
|
|
43
|
-
return { type: "post", subtype: type
|
|
47
|
+
return { type: "post", subtype: type };
|
|
44
48
|
}
|
|
45
|
-
return {
|
|
46
|
-
// for custom link which has no type
|
|
47
|
-
// always show pages as initial suggestions
|
|
48
|
-
initialSuggestionsSearchOptions: {
|
|
49
|
-
type: "post",
|
|
50
|
-
subtype: "page",
|
|
51
|
-
perPage
|
|
52
|
-
}
|
|
53
|
-
};
|
|
49
|
+
return { type: "post", subtype: "page" };
|
|
54
50
|
}
|
|
55
51
|
}
|
|
52
|
+
function getSuggestionsQuery(type, kind) {
|
|
53
|
+
const ownType = getOwnTypeSearchOptions(type, kind);
|
|
54
|
+
return {
|
|
55
|
+
preferTypes: [ownType.subtype ? ownType : ownType.type],
|
|
56
|
+
initialSuggestionsSearchOptions: { ...ownType, perPage: 20 }
|
|
57
|
+
};
|
|
58
|
+
}
|
|
56
59
|
function UnforwardedLinkUI(props, ref) {
|
|
57
60
|
const { label, url, opensInNewTab, type, kind, id } = props.link;
|
|
58
61
|
const { entityRecord, hasBinding, isEntityAvailable } = props.entity || {};
|
|
@@ -138,6 +141,13 @@ function UnforwardedLinkUI(props, ref) {
|
|
|
138
141
|
}
|
|
139
142
|
}, [shouldFocusPane]);
|
|
140
143
|
const blockEditingMode = useBlockEditingMode();
|
|
144
|
+
const canAddBlock = blockEditingMode !== "disabled";
|
|
145
|
+
const { transformSuggestions, insertBlockFromSuggestion } = useBlockSuggestions({
|
|
146
|
+
clientId,
|
|
147
|
+
isEnabled: canAddBlock && !link?.url?.length,
|
|
148
|
+
onBlockInsert: props.onBlockInsert,
|
|
149
|
+
onClose: props.onClose
|
|
150
|
+
});
|
|
141
151
|
return /* @__PURE__ */ jsxs(
|
|
142
152
|
Popover,
|
|
143
153
|
{
|
|
@@ -172,7 +182,16 @@ function UnforwardedLinkUI(props, ref) {
|
|
|
172
182
|
noDirectEntry: !!type,
|
|
173
183
|
noURLSuggestion: !!type,
|
|
174
184
|
suggestionsQuery: getSuggestionsQuery(type, kind),
|
|
175
|
-
|
|
185
|
+
transformSuggestions,
|
|
186
|
+
onChange: (updatedValue) => {
|
|
187
|
+
if (isBlockSuggestion(updatedValue)) {
|
|
188
|
+
insertBlockFromSuggestion(
|
|
189
|
+
updatedValue.blockItemId
|
|
190
|
+
);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
props.onChange(updatedValue);
|
|
194
|
+
},
|
|
176
195
|
onInputChange: (value) => {
|
|
177
196
|
searchInputValueRef.current = value;
|
|
178
197
|
},
|
|
@@ -197,7 +216,7 @@ function UnforwardedLinkUI(props, ref) {
|
|
|
197
216
|
setAddingPage(true);
|
|
198
217
|
},
|
|
199
218
|
canAddPage: blockEditingMode !== "disabled" && permissions?.canCreate && type === "page",
|
|
200
|
-
canAddBlock
|
|
219
|
+
canAddBlock
|
|
201
220
|
}
|
|
202
221
|
);
|
|
203
222
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation-link/link-ui/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { __unstableStripHTML as stripHTML, focus } from '@wordpress/dom';\nimport {\n\tPopover,\n\tButton,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { LinkControl, useBlockEditingMode } from '@wordpress/block-editor';\nimport {\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n} from '@wordpress/element';\nimport { useResourcePermissions } from '@wordpress/core-data';\nimport { plus } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { isURL } from '@wordpress/url';\nimport { LinkUIPageCreator } from './page-creator';\nimport LinkUIBlockInserter from './block-inserter';\nimport { useEntityBinding, useLinkPreview } from '../shared';\n\n/**\n * Given the Link block's type attribute, return the query params to give to\n * /wp/v2/search.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {{ type?: string, subtype?: string }} Search query params.\n */\nexport function getSuggestionsQuery( type, kind ) {\n\t// How many results to show initially and per search.\n\tconst perPage = 20;\n\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\tcase 'page':\n\t\t\treturn { type: 'post', subtype: type, perPage };\n\t\tcase 'category':\n\t\t\treturn { type: 'term', subtype: 'category', perPage };\n\t\tcase 'tag':\n\t\t\treturn { type: 'term', subtype: 'post_tag', perPage };\n\t\tcase 'post_format':\n\t\t\treturn { type: 'post-format', perPage };\n\t\tdefault:\n\t\t\tif ( kind === 'taxonomy' ) {\n\t\t\t\treturn { type: 'term', subtype: type, perPage };\n\t\t\t}\n\t\t\tif ( kind === 'post-type' ) {\n\t\t\t\treturn { type: 'post', subtype: type, perPage };\n\t\t\t}\n\t\t\treturn {\n\t\t\t\t// for custom link which has no type\n\t\t\t\t// always show pages as initial suggestions\n\t\t\t\tinitialSuggestionsSearchOptions: {\n\t\t\t\t\ttype: 'post',\n\t\t\t\t\tsubtype: 'page',\n\t\t\t\t\tperPage,\n\t\t\t\t},\n\t\t\t};\n\t}\n}\n\nfunction UnforwardedLinkUI( props, ref ) {\n\tconst { label, url, opensInNewTab, type, kind, id } = props.link;\n\n\tconst { entityRecord, hasBinding, isEntityAvailable } = props.entity || {};\n\n\tconst { image, badges } = useLinkPreview( {\n\t\turl,\n\t\tentityRecord,\n\t\ttype,\n\t\thasBinding,\n\t\tisEntityAvailable,\n\t} );\n\n\tconst { clientId } = props;\n\tconst postType = type || 'page';\n\n\tconst [ addingBlock, setAddingBlock ] = useState( false );\n\tconst [ addingPage, setAddingPage ] = useState( false );\n\tconst [ shouldFocusPane, setShouldFocusPane ] = useState( null );\n\t// Stable initial value for LinkControl's uncontrolled inputValue prop.\n\t// We track the search with the searchInputValueRef, then update the\n\t// initialSearchValue state with the observed searchInputValueRef\n\t// when mounting the LinkControl. If LinkControl becomes a fully\n\t// controlled component, then we can remove this extra complexity.\n\tconst [ initialSearchValue, setInitialSearchValue ] = useState( '' );\n\t// Tracks the live search input between renders without causing re-renders.\n\tconst searchInputValueRef = useRef( '' );\n\t// Call this instead of setting searchInputValueRef.current and\n\t// setInitialSearchValue separately, to keep both in sync.\n\tconst updateSearchValue = ( value ) => {\n\t\tsearchInputValueRef.current = value;\n\t\tsetInitialSearchValue( value );\n\t};\n\tconst linkControlWrapperRef = useRef();\n\tconst addPageButtonRef = useRef();\n\tconst addBlockButtonRef = useRef();\n\tconst permissions = useResourcePermissions( {\n\t\tkind: 'postType',\n\t\tname: postType,\n\t} );\n\n\t// Use the entity binding hook to get binding status\n\tconst { isBoundEntityAvailable } = useEntityBinding( {\n\t\tclientId,\n\t\tattributes: props.link,\n\t} );\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/50976#issuecomment-1568226407.\n\tconst link = useMemo(\n\t\t() => ( {\n\t\t\turl,\n\t\t\topensInNewTab,\n\t\t\ttitle: label && stripHTML( label ),\n\t\t\tentityTitle: entityRecord?.title?.rendered || entityRecord?.name,\n\t\t\tkind,\n\t\t\ttype,\n\t\t\tid,\n\t\t\timage,\n\t\t\tbadges,\n\t\t} ),\n\t\t[\n\t\t\tlabel,\n\t\t\topensInNewTab,\n\t\t\turl,\n\t\t\tkind,\n\t\t\ttype,\n\t\t\tid,\n\t\t\timage,\n\t\t\tbadges,\n\t\t\tentityRecord,\n\t\t]\n\t);\n\n\tconst handlePageCreated = ( pageLink ) => {\n\t\t// Set the new page as the current link\n\t\tprops.onChange( pageLink );\n\t\t// Return to main Link UI and focus the first focusable element\n\t\tsetAddingPage( false );\n\t\tsetShouldFocusPane( true );\n\t\t// Clear search input value\n\t\tupdateSearchValue( '' );\n\t};\n\n\tconst dialogTitleId = useInstanceId(\n\t\tLinkUI,\n\t\t'link-ui-link-control__title'\n\t);\n\tconst dialogDescriptionId = useInstanceId(\n\t\tLinkUI,\n\t\t'link-ui-link-control__description'\n\t);\n\n\t// Focus management when transitioning between panes\n\tuseEffect( () => {\n\t\tif ( shouldFocusPane && linkControlWrapperRef.current ) {\n\t\t\t// If we have a specific element to focus, focus it\n\t\t\tif ( shouldFocusPane?.current ) {\n\t\t\t\t// Focus the specific element passed\n\t\t\t\tshouldFocusPane.current.focus();\n\t\t\t} else {\n\t\t\t\t// Focus the first tabbable element (keyboard-accessible, excluding tabindex=\"-1\")\n\t\t\t\tconst tabbableElements = focus.tabbable.find(\n\t\t\t\t\tlinkControlWrapperRef.current\n\t\t\t\t);\n\t\t\t\tconst nextFocusTarget =\n\t\t\t\t\ttabbableElements[ 0 ] || linkControlWrapperRef.current;\n\t\t\t\tnextFocusTarget.focus();\n\t\t\t}\n\n\t\t\t// Reset the state\n\t\t\tsetShouldFocusPane( false );\n\t\t}\n\t}, [ shouldFocusPane ] );\n\n\tconst blockEditingMode = useBlockEditingMode();\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ ref }\n\t\t\tplacement=\"bottom\"\n\t\t\tonClose={ props.onClose }\n\t\t\tanchor={ props.anchor }\n\t\t\tshift\n\t\t>\n\t\t\t{ ! addingBlock && ! addingPage && (\n\t\t\t\t<div\n\t\t\t\t\tref={ linkControlWrapperRef }\n\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\taria-labelledby={ dialogTitleId }\n\t\t\t\t\taria-describedby={ dialogDescriptionId }\n\t\t\t\t>\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t<h2 id={ dialogTitleId }>{ __( 'Add link' ) }</h2>\n\n\t\t\t\t\t\t<p id={ dialogDescriptionId }>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Search for and add a link to your Navigation.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\thasTextControl\n\t\t\t\t\t\thasRichPreviews\n\t\t\t\t\t\tvalue={ link }\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t\twithCreateSuggestion={ false }\n\t\t\t\t\t\tnoDirectEntry={ !! type }\n\t\t\t\t\t\tnoURLSuggestion={ !! type }\n\t\t\t\t\t\tsuggestionsQuery={ getSuggestionsQuery( type, kind ) }\n\t\t\t\t\t\tonChange={ props.onChange }\n\t\t\t\t\t\tonInputChange={ ( value ) => {\n\t\t\t\t\t\t\t// Observe the input value so we can pass the value to the page creator\n\t\t\t\t\t\t\t// and restore it on back button click\n\t\t\t\t\t\t\tsearchInputValueRef.current = value;\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tinputValue={ initialSearchValue }\n\t\t\t\t\t\tonRemove={ props.onRemove }\n\t\t\t\t\t\tonCancel={ props.onCancel }\n\t\t\t\t\t\thandleEntities={ isBoundEntityAvailable }\n\t\t\t\t\t\tforceIsEditingLink={ link?.url ? false : undefined }\n\t\t\t\t\t\trenderControlBottom={ () => {\n\t\t\t\t\t\t\t// Don't show the tools when there is submitted link (preview state).\n\t\t\t\t\t\t\tif ( link?.url?.length ) {\n\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<LinkUITools\n\t\t\t\t\t\t\t\t\taddPageButtonRef={ addPageButtonRef }\n\t\t\t\t\t\t\t\t\taddBlockButtonRef={ addBlockButtonRef }\n\t\t\t\t\t\t\t\t\tsetAddingBlock={ () => {\n\t\t\t\t\t\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tsetAddingPage={ () => {\n\t\t\t\t\t\t\t\t\t\tsetAddingPage( true );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tcanAddPage={\n\t\t\t\t\t\t\t\t\t\tblockEditingMode !== 'disabled' &&\n\t\t\t\t\t\t\t\t\t\tpermissions?.canCreate &&\n\t\t\t\t\t\t\t\t\t\ttype === 'page'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcanAddBlock={\n\t\t\t\t\t\t\t\t\t\tblockEditingMode !== 'disabled'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ addingBlock && (\n\t\t\t\t<LinkUIBlockInserter\n\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\tonBack={ () => {\n\t\t\t\t\t\tsetAddingBlock( false );\n\t\t\t\t\t\tsetShouldFocusPane( addBlockButtonRef );\n\t\t\t\t\t\tupdateSearchValue( searchInputValueRef.current );\n\t\t\t\t\t} }\n\t\t\t\t\tonBlockInsert={ props?.onBlockInsert }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ addingPage && (\n\t\t\t\t<LinkUIPageCreator\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tonBack={ () => {\n\t\t\t\t\t\tsetAddingPage( false );\n\t\t\t\t\t\tsetShouldFocusPane( addPageButtonRef );\n\t\t\t\t\t\tupdateSearchValue( searchInputValueRef.current );\n\t\t\t\t\t} }\n\t\t\t\t\tonPageCreated={ handlePageCreated }\n\t\t\t\t\tinitialTitle={\n\t\t\t\t\t\tsearchInputValueRef.current &&\n\t\t\t\t\t\t! isURL( searchInputValueRef.current )\n\t\t\t\t\t\t\t? searchInputValueRef.current\n\t\t\t\t\t\t\t: ''\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nexport const LinkUI = forwardRef( UnforwardedLinkUI );\n\nconst LinkUITools = ( {\n\taddPageButtonRef,\n\taddBlockButtonRef,\n\tsetAddingBlock,\n\tsetAddingPage,\n\tcanAddPage,\n\tcanAddBlock,\n} ) => {\n\tconst blockInserterAriaRole = 'listbox';\n\n\t// Don't render anything if neither button should be shown\n\tif ( ! canAddPage && ! canAddBlock ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 0 } className=\"link-ui-tools\">\n\t\t\t{ canAddPage && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ addPageButtonRef }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tsetAddingPage( true );\n\t\t\t\t\t} }\n\t\t\t\t\taria-haspopup={ blockInserterAriaRole }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Create page' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ canAddBlock && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ addBlockButtonRef }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t\t} }\n\t\t\t\t\taria-haspopup={ blockInserterAriaRole }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Add block' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</VStack>\n\t);\n};\n\nexport default LinkUITools;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,uBAAuB,WAAW,aAAa;AACxD;AAAA,EACC;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,OAClB;AACP,SAAS,UAAU;AACnB,SAAS,aAAa,2BAA2B;AACjD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,8BAA8B;AACvC,SAAS,YAAY;AACrB,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,aAAa;AACtB,SAAS,yBAAyB;AAClC,OAAO,yBAAyB;AAChC,
|
|
4
|
+
"sourcesContent": ["import { __unstableStripHTML as stripHTML, focus } from '@wordpress/dom';\nimport {\n\tPopover,\n\tButton,\n\t__experimentalVStack as VStack,\n} from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { LinkControl, useBlockEditingMode } from '@wordpress/block-editor';\nimport {\n\tuseMemo,\n\tuseState,\n\tuseRef,\n\tuseEffect,\n\tforwardRef,\n} from '@wordpress/element';\nimport { useResourcePermissions } from '@wordpress/core-data';\nimport { plus } from '@wordpress/icons';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/ui';\nimport { isURL } from '@wordpress/url';\nimport { LinkUIPageCreator } from './page-creator';\nimport LinkUIBlockInserter from './block-inserter';\nimport {\n\tisBlockSuggestion,\n\tuseBlockSuggestions,\n\tuseEntityBinding,\n\tuseLinkPreview,\n} from '../shared';\n\n/**\n * Given the Link block's type attribute, return the query params for that one\n * entity type.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {{ type: string, subtype?: string }} Search query params.\n */\nfunction getOwnTypeSearchOptions( type, kind ) {\n\tswitch ( type ) {\n\t\tcase 'post':\n\t\tcase 'page':\n\t\t\treturn { type: 'post', subtype: type };\n\t\tcase 'category':\n\t\t\treturn { type: 'term', subtype: 'category' };\n\t\tcase 'tag':\n\t\t\treturn { type: 'term', subtype: 'post_tag' };\n\t\tcase 'post_format':\n\t\t\treturn { type: 'post-format' };\n\t\tdefault:\n\t\t\tif ( kind === 'taxonomy' ) {\n\t\t\t\treturn { type: 'term', subtype: type };\n\t\t\t}\n\t\t\tif ( kind === 'post-type' ) {\n\t\t\t\treturn { type: 'post', subtype: type };\n\t\t\t}\n\t\t\t// for custom link which has no type\n\t\t\t// always show pages as initial suggestions\n\t\t\treturn { type: 'post', subtype: 'page' };\n\t}\n}\n\n/**\n * Given the Link block's type attribute, return the query params to give to\n * /wp/v2/search.\n *\n * @param {string} type Link block's type attribute.\n * @param {string} kind Link block's entity of kind (post-type|taxonomy)\n * @return {Object} Search query params.\n */\nexport function getSuggestionsQuery( type, kind ) {\n\tconst ownType = getOwnTypeSearchOptions( type, kind );\n\n\treturn {\n\t\tpreferTypes: [ ownType.subtype ? ownType : ownType.type ],\n\t\tinitialSuggestionsSearchOptions: { ...ownType, perPage: 20 },\n\t};\n}\n\nfunction UnforwardedLinkUI( props, ref ) {\n\tconst { label, url, opensInNewTab, type, kind, id } = props.link;\n\n\tconst { entityRecord, hasBinding, isEntityAvailable } = props.entity || {};\n\n\tconst { image, badges } = useLinkPreview( {\n\t\turl,\n\t\tentityRecord,\n\t\ttype,\n\t\thasBinding,\n\t\tisEntityAvailable,\n\t} );\n\n\tconst { clientId } = props;\n\tconst postType = type || 'page';\n\n\tconst [ addingBlock, setAddingBlock ] = useState( false );\n\tconst [ addingPage, setAddingPage ] = useState( false );\n\tconst [ shouldFocusPane, setShouldFocusPane ] = useState( null );\n\t// Stable initial value for LinkControl's uncontrolled inputValue prop.\n\t// We track the search with the searchInputValueRef, then update the\n\t// initialSearchValue state with the observed searchInputValueRef\n\t// when mounting the LinkControl. If LinkControl becomes a fully\n\t// controlled component, then we can remove this extra complexity.\n\tconst [ initialSearchValue, setInitialSearchValue ] = useState( '' );\n\t// Tracks the live search input between renders without causing re-renders.\n\tconst searchInputValueRef = useRef( '' );\n\t// Call this instead of setting searchInputValueRef.current and\n\t// setInitialSearchValue separately, to keep both in sync.\n\tconst updateSearchValue = ( value ) => {\n\t\tsearchInputValueRef.current = value;\n\t\tsetInitialSearchValue( value );\n\t};\n\tconst linkControlWrapperRef = useRef();\n\tconst addPageButtonRef = useRef();\n\tconst addBlockButtonRef = useRef();\n\tconst permissions = useResourcePermissions( {\n\t\tkind: 'postType',\n\t\tname: postType,\n\t} );\n\n\t// Use the entity binding hook to get binding status\n\tconst { isBoundEntityAvailable } = useEntityBinding( {\n\t\tclientId,\n\t\tattributes: props.link,\n\t} );\n\n\t// Memoize link value to avoid overriding the LinkControl's internal state.\n\t// This is a temporary fix. See https://github.com/WordPress/gutenberg/issues/50976#issuecomment-1568226407.\n\tconst link = useMemo(\n\t\t() => ( {\n\t\t\turl,\n\t\t\topensInNewTab,\n\t\t\ttitle: label && stripHTML( label ),\n\t\t\tentityTitle: entityRecord?.title?.rendered || entityRecord?.name,\n\t\t\tkind,\n\t\t\ttype,\n\t\t\tid,\n\t\t\timage,\n\t\t\tbadges,\n\t\t} ),\n\t\t[\n\t\t\tlabel,\n\t\t\topensInNewTab,\n\t\t\turl,\n\t\t\tkind,\n\t\t\ttype,\n\t\t\tid,\n\t\t\timage,\n\t\t\tbadges,\n\t\t\tentityRecord,\n\t\t]\n\t);\n\n\tconst handlePageCreated = ( pageLink ) => {\n\t\t// Set the new page as the current link\n\t\tprops.onChange( pageLink );\n\t\t// Return to main Link UI and focus the first focusable element\n\t\tsetAddingPage( false );\n\t\tsetShouldFocusPane( true );\n\t\t// Clear search input value\n\t\tupdateSearchValue( '' );\n\t};\n\n\tconst dialogTitleId = useInstanceId(\n\t\tLinkUI,\n\t\t'link-ui-link-control__title'\n\t);\n\tconst dialogDescriptionId = useInstanceId(\n\t\tLinkUI,\n\t\t'link-ui-link-control__description'\n\t);\n\n\t// Focus management when transitioning between panes\n\tuseEffect( () => {\n\t\tif ( shouldFocusPane && linkControlWrapperRef.current ) {\n\t\t\t// If we have a specific element to focus, focus it\n\t\t\tif ( shouldFocusPane?.current ) {\n\t\t\t\t// Focus the specific element passed\n\t\t\t\tshouldFocusPane.current.focus();\n\t\t\t} else {\n\t\t\t\t// Focus the first tabbable element (keyboard-accessible, excluding tabindex=\"-1\")\n\t\t\t\tconst tabbableElements = focus.tabbable.find(\n\t\t\t\t\tlinkControlWrapperRef.current\n\t\t\t\t);\n\t\t\t\tconst nextFocusTarget =\n\t\t\t\t\ttabbableElements[ 0 ] || linkControlWrapperRef.current;\n\t\t\t\tnextFocusTarget.focus();\n\t\t\t}\n\n\t\t\t// Reset the state\n\t\t\tsetShouldFocusPane( false );\n\t\t}\n\t}, [ shouldFocusPane ] );\n\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst canAddBlock = blockEditingMode !== 'disabled';\n\n\t// Blocks are listed in the search results only when the \"Add block\"\n\t// button would be shown: the link has no URL yet and the block is not\n\t// locked.\n\tconst { transformSuggestions, insertBlockFromSuggestion } =\n\t\tuseBlockSuggestions( {\n\t\t\tclientId,\n\t\t\tisEnabled: canAddBlock && ! link?.url?.length,\n\t\t\tonBlockInsert: props.onBlockInsert,\n\t\t\tonClose: props.onClose,\n\t\t} );\n\n\treturn (\n\t\t<Popover\n\t\t\tref={ ref }\n\t\t\tplacement=\"bottom\"\n\t\t\tonClose={ props.onClose }\n\t\t\tanchor={ props.anchor }\n\t\t\tshift\n\t\t>\n\t\t\t{ ! addingBlock && ! addingPage && (\n\t\t\t\t<div\n\t\t\t\t\tref={ linkControlWrapperRef }\n\t\t\t\t\trole=\"dialog\"\n\t\t\t\t\taria-labelledby={ dialogTitleId }\n\t\t\t\t\taria-describedby={ dialogDescriptionId }\n\t\t\t\t>\n\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t<h2 id={ dialogTitleId }>{ __( 'Add link' ) }</h2>\n\n\t\t\t\t\t\t<p id={ dialogDescriptionId }>\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'Search for and add a link to your Navigation.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t<LinkControl\n\t\t\t\t\t\thasTextControl\n\t\t\t\t\t\thasRichPreviews\n\t\t\t\t\t\tvalue={ link }\n\t\t\t\t\t\tshowInitialSuggestions\n\t\t\t\t\t\twithCreateSuggestion={ false }\n\t\t\t\t\t\tnoDirectEntry={ !! type }\n\t\t\t\t\t\tnoURLSuggestion={ !! type }\n\t\t\t\t\t\tsuggestionsQuery={ getSuggestionsQuery( type, kind ) }\n\t\t\t\t\t\ttransformSuggestions={ transformSuggestions }\n\t\t\t\t\t\tonChange={ ( updatedValue ) => {\n\t\t\t\t\t\t\tif ( isBlockSuggestion( updatedValue ) ) {\n\t\t\t\t\t\t\t\tinsertBlockFromSuggestion(\n\t\t\t\t\t\t\t\t\tupdatedValue.blockItemId\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\tprops.onChange( updatedValue );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonInputChange={ ( value ) => {\n\t\t\t\t\t\t\t// Observe the input value so we can pass the value to the page creator\n\t\t\t\t\t\t\t// and restore it on back button click\n\t\t\t\t\t\t\tsearchInputValueRef.current = value;\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tinputValue={ initialSearchValue }\n\t\t\t\t\t\tonRemove={ props.onRemove }\n\t\t\t\t\t\tonCancel={ props.onCancel }\n\t\t\t\t\t\thandleEntities={ isBoundEntityAvailable }\n\t\t\t\t\t\tforceIsEditingLink={ link?.url ? false : undefined }\n\t\t\t\t\t\trenderControlBottom={ () => {\n\t\t\t\t\t\t\t// Don't show the tools when there is submitted link (preview state).\n\t\t\t\t\t\t\tif ( link?.url?.length ) {\n\t\t\t\t\t\t\t\treturn null;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\t\t<LinkUITools\n\t\t\t\t\t\t\t\t\taddPageButtonRef={ addPageButtonRef }\n\t\t\t\t\t\t\t\t\taddBlockButtonRef={ addBlockButtonRef }\n\t\t\t\t\t\t\t\t\tsetAddingBlock={ () => {\n\t\t\t\t\t\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tsetAddingPage={ () => {\n\t\t\t\t\t\t\t\t\t\tsetAddingPage( true );\n\t\t\t\t\t\t\t\t\t} }\n\t\t\t\t\t\t\t\t\tcanAddPage={\n\t\t\t\t\t\t\t\t\t\tblockEditingMode !== 'disabled' &&\n\t\t\t\t\t\t\t\t\t\tpermissions?.canCreate &&\n\t\t\t\t\t\t\t\t\t\ttype === 'page'\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\tcanAddBlock={ canAddBlock }\n\t\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t} }\n\t\t\t\t\t/>\n\t\t\t\t</div>\n\t\t\t) }\n\n\t\t\t{ addingBlock && (\n\t\t\t\t<LinkUIBlockInserter\n\t\t\t\t\tclientId={ props.clientId }\n\t\t\t\t\tonBack={ () => {\n\t\t\t\t\t\tsetAddingBlock( false );\n\t\t\t\t\t\tsetShouldFocusPane( addBlockButtonRef );\n\t\t\t\t\t\tupdateSearchValue( searchInputValueRef.current );\n\t\t\t\t\t} }\n\t\t\t\t\tonBlockInsert={ props?.onBlockInsert }\n\t\t\t\t/>\n\t\t\t) }\n\n\t\t\t{ addingPage && (\n\t\t\t\t<LinkUIPageCreator\n\t\t\t\t\tpostType={ postType }\n\t\t\t\t\tonBack={ () => {\n\t\t\t\t\t\tsetAddingPage( false );\n\t\t\t\t\t\tsetShouldFocusPane( addPageButtonRef );\n\t\t\t\t\t\tupdateSearchValue( searchInputValueRef.current );\n\t\t\t\t\t} }\n\t\t\t\t\tonPageCreated={ handlePageCreated }\n\t\t\t\t\tinitialTitle={\n\t\t\t\t\t\tsearchInputValueRef.current &&\n\t\t\t\t\t\t! isURL( searchInputValueRef.current )\n\t\t\t\t\t\t\t? searchInputValueRef.current\n\t\t\t\t\t\t\t: ''\n\t\t\t\t\t}\n\t\t\t\t/>\n\t\t\t) }\n\t\t</Popover>\n\t);\n}\n\nexport const LinkUI = forwardRef( UnforwardedLinkUI );\n\nconst LinkUITools = ( {\n\taddPageButtonRef,\n\taddBlockButtonRef,\n\tsetAddingBlock,\n\tsetAddingPage,\n\tcanAddPage,\n\tcanAddBlock,\n} ) => {\n\tconst blockInserterAriaRole = 'listbox';\n\n\t// Don't render anything if neither button should be shown\n\tif ( ! canAddPage && ! canAddBlock ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<VStack spacing={ 0 } className=\"link-ui-tools\">\n\t\t\t{ canAddPage && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ addPageButtonRef }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tsetAddingPage( true );\n\t\t\t\t\t} }\n\t\t\t\t\taria-haspopup={ blockInserterAriaRole }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Create page' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t\t{ canAddBlock && (\n\t\t\t\t<Button\n\t\t\t\t\t__next40pxDefaultSize\n\t\t\t\t\tref={ addBlockButtonRef }\n\t\t\t\t\ticon={ plus }\n\t\t\t\t\tonClick={ ( e ) => {\n\t\t\t\t\t\te.preventDefault();\n\t\t\t\t\t\tsetAddingBlock( true );\n\t\t\t\t\t} }\n\t\t\t\t\taria-haspopup={ blockInserterAriaRole }\n\t\t\t\t>\n\t\t\t\t\t{ __( 'Add block' ) }\n\t\t\t\t</Button>\n\t\t\t) }\n\t\t</VStack>\n\t);\n};\n\nexport default LinkUITools;\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,uBAAuB,WAAW,aAAa;AACxD;AAAA,EACC;AAAA,EACA;AAAA,EACA,wBAAwB;AAAA,OAClB;AACP,SAAS,UAAU;AACnB,SAAS,aAAa,2BAA2B;AACjD;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,SAAS,8BAA8B;AACvC,SAAS,YAAY;AACrB,SAAS,qBAAqB;AAC9B,SAAS,sBAAsB;AAC/B,SAAS,aAAa;AACtB,SAAS,yBAAyB;AAClC,OAAO,yBAAyB;AAChC;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAmMF,SACC,KADD;AAzLL,SAAS,wBAAyB,MAAM,MAAO;AAC9C,UAAS,MAAO;AAAA,IACf,KAAK;AAAA,IACL,KAAK;AACJ,aAAO,EAAE,MAAM,QAAQ,SAA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KAAM;AAAA,QACN,MAAO;AAAA,QACP,SAAU,CAAE,MAAO;AAClB,YAAE,eAAe;AACjB,wBAAe,IAAK;AAAA,QACrB;AAAA,QACA,iBAAgB;AAAA,QAEd,aAAI,aAAc;AAAA;AAAA,IACrB;AAAA,IAEC,eACD;AAAA,MAAC;AAAA;AAAA,QACA,uBAAqB;AAAA,QACrB,KAAM;AAAA,QACN,MAAO;AAAA,QACP,SAAU,CAAE,MAAO;AAClB,YAAE,eAAe;AACjB,yBAAgB,IAAK;AAAA,QACtB;AAAA,QACA,iBAAgB;AAAA,QAEd,aAAI,WAAY;AAAA;AAAA,IACnB;AAAA,KAEF;AAEF;AAEA,IAAO,kBAAQ;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -13,14 +13,20 @@ import { useEnableLinkStatusValidation } from "./use-enable-link-status-validati
|
|
|
13
13
|
import { useIsDraggingWithin } from "./use-is-dragging-within.mjs";
|
|
14
14
|
import { selectLabelText } from "./select-label-text.mjs";
|
|
15
15
|
import { useLinkPreview } from "./use-link-preview.mjs";
|
|
16
|
+
import {
|
|
17
|
+
isBlockSuggestion,
|
|
18
|
+
useBlockSuggestions
|
|
19
|
+
} from "./use-block-suggestions.mjs";
|
|
16
20
|
export {
|
|
17
21
|
Controls,
|
|
18
22
|
InvalidDraftDisplay,
|
|
19
23
|
LinkUI,
|
|
20
24
|
buildNavigationLinkEntityBinding,
|
|
21
25
|
getInvalidLinkHelpText,
|
|
26
|
+
isBlockSuggestion,
|
|
22
27
|
selectLabelText,
|
|
23
28
|
updateAttributes,
|
|
29
|
+
useBlockSuggestions,
|
|
24
30
|
useEnableLinkStatusValidation,
|
|
25
31
|
useEntityBinding,
|
|
26
32
|
useHandleLinkChange,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/navigation-link/shared/index.js"],
|
|
4
|
-
"sourcesContent": ["/**\n * Shared components for Navigation Link and Navigation Submenu blocks.\n *\n * This module provides common functionality that can be used by both blocks\n * to reduce code duplication and ensure consistent behavior.\n */\n\nexport { Controls, getInvalidLinkHelpText } from './controls';\nexport { updateAttributes } from './update-attributes';\nexport {\n\tuseEntityBinding,\n\tbuildNavigationLinkEntityBinding,\n} from './use-entity-binding';\nexport { LinkUI } from '../link-ui';\nexport { useHandleLinkChange } from './use-handle-link-change';\nexport { useIsInvalidLink } from './use-is-invalid-link';\nexport { InvalidDraftDisplay } from './invalid-draft-display';\nexport { useEnableLinkStatusValidation } from './use-enable-link-status-validation';\nexport { useIsDraggingWithin } from './use-is-dragging-within';\nexport { selectLabelText } from './select-label-text';\nexport { useLinkPreview } from './use-link-preview';\n"],
|
|
5
|
-
"mappings": ";AAOA,SAAS,UAAU,8BAA8B;AACjD,SAAS,wBAAwB;AACjC;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,SAAS,cAAc;AACvB,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,qCAAqC;AAC9C,SAAS,2BAA2B;AACpC,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;",
|
|
4
|
+
"sourcesContent": ["/**\n * Shared components for Navigation Link and Navigation Submenu blocks.\n *\n * This module provides common functionality that can be used by both blocks\n * to reduce code duplication and ensure consistent behavior.\n */\n\nexport { Controls, getInvalidLinkHelpText } from './controls';\nexport { updateAttributes } from './update-attributes';\nexport {\n\tuseEntityBinding,\n\tbuildNavigationLinkEntityBinding,\n} from './use-entity-binding';\nexport { LinkUI } from '../link-ui';\nexport { useHandleLinkChange } from './use-handle-link-change';\nexport { useIsInvalidLink } from './use-is-invalid-link';\nexport { InvalidDraftDisplay } from './invalid-draft-display';\nexport { useEnableLinkStatusValidation } from './use-enable-link-status-validation';\nexport { useIsDraggingWithin } from './use-is-dragging-within';\nexport { selectLabelText } from './select-label-text';\nexport { useLinkPreview } from './use-link-preview';\nexport {\n\tisBlockSuggestion,\n\tuseBlockSuggestions,\n} from './use-block-suggestions';\n"],
|
|
5
|
+
"mappings": ";AAOA,SAAS,UAAU,8BAA8B;AACjD,SAAS,wBAAwB;AACjC;AAAA,EACC;AAAA,EACA;AAAA,OACM;AACP,SAAS,cAAc;AACvB,SAAS,2BAA2B;AACpC,SAAS,wBAAwB;AACjC,SAAS,2BAA2B;AACpC,SAAS,qCAAqC;AAC9C,SAAS,2BAA2B;AACpC,SAAS,uBAAuB;AAChC,SAAS,sBAAsB;AAC/B;AAAA,EACC;AAAA,EACA;AAAA,OACM;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|