@wordpress/block-library 8.13.0 → 8.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/build/archives/index.js +5 -1
- package/build/archives/index.js.map +1 -1
- package/build/audio/index.js +5 -1
- package/build/audio/index.js.map +1 -1
- package/build/avatar/edit.js +1 -0
- package/build/avatar/edit.js.map +1 -1
- package/build/avatar/index.js +1 -1
- package/build/block/edit.js +1 -1
- package/build/block/edit.js.map +1 -1
- package/build/block/edit.native.js +6 -9
- package/build/block/edit.native.js.map +1 -1
- package/build/block/index.js +2 -1
- package/build/block/index.js.map +1 -1
- package/build/buttons/edit.js +7 -3
- package/build/buttons/edit.js.map +1 -1
- package/build/categories/index.js +5 -1
- package/build/categories/index.js.map +1 -1
- package/build/code/index.js +5 -1
- package/build/code/index.js.map +1 -1
- package/build/column/edit.native.js +1 -4
- package/build/column/edit.native.js.map +1 -1
- package/build/column/index.js +1 -0
- package/build/column/index.js.map +1 -1
- package/build/columns/edit.js +1 -0
- package/build/columns/edit.js.map +1 -1
- package/build/comment-author-avatar/edit.js +1 -0
- package/build/comment-author-avatar/edit.js.map +1 -1
- package/build/comments/index.js +1 -0
- package/build/comments/index.js.map +1 -1
- package/build/cover/deprecated.js +4 -2
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +2 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/index.js +1 -0
- package/build/cover/index.js.map +1 -1
- package/build/details/index.js +5 -1
- package/build/details/index.js.map +1 -1
- package/build/embed/embed-placeholder.native.js +37 -13
- package/build/embed/embed-placeholder.native.js.map +1 -1
- package/build/embed/util.js +9 -8
- package/build/embed/util.js.map +1 -1
- package/build/file/inspector.js +1 -0
- package/build/file/inspector.js.map +1 -1
- package/build/file/{interactivity.js → view-interactivity.js} +6 -2
- package/build/file/view-interactivity.js.map +1 -0
- package/build/footnotes/edit.js +20 -1
- package/build/footnotes/edit.js.map +1 -1
- package/build/footnotes/format.js +19 -16
- package/build/footnotes/format.js.map +1 -1
- package/build/footnotes/index.js +0 -1
- package/build/footnotes/index.js.map +1 -1
- package/build/gallery/edit.js +1 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/index.js +3 -1
- package/build/gallery/index.js.map +1 -1
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/index.js +5 -1
- package/build/heading/index.js.map +1 -1
- package/build/heading/transforms.js +5 -1
- package/build/heading/transforms.js.map +1 -1
- package/build/image/deprecated.js +453 -175
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.js +0 -4
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +96 -43
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +6 -0
- package/build/image/index.js.map +1 -1
- package/build/image/save.js +8 -1
- package/build/image/save.js.map +1 -1
- package/build/image/utils.js +18 -0
- package/build/image/utils.js.map +1 -1
- package/build/image/{interactivity.js → view-interactivity.js} +86 -44
- package/build/image/view-interactivity.js.map +1 -0
- package/build/index.js +12 -3
- package/build/index.js.map +1 -1
- package/build/latest-comments/edit.js +1 -0
- package/build/latest-comments/edit.js.map +1 -1
- package/build/latest-posts/edit.js +2 -0
- package/build/latest-posts/edit.js.map +1 -1
- package/build/list/edit.js +4 -4
- package/build/list/edit.js.map +1 -1
- package/build/list/index.js +5 -1
- package/build/list/index.js.map +1 -1
- package/build/list-item/utils.js +6 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/media-text/index.js +1 -0
- package/build/media-text/index.js.map +1 -1
- package/build/media-text/media-container.native.js +2 -1
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/missing/edit.js +22 -8
- package/build/missing/edit.js.map +1 -1
- package/build/missing/edit.native.js +7 -5
- package/build/missing/edit.native.js.map +1 -1
- package/build/navigation/constants.js +10 -4
- package/build/navigation/constants.js.map +1 -1
- package/build/navigation/edit/index.js +17 -3
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +2 -2
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +0 -1
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +2 -2
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js +10 -15
- package/build/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +33 -45
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation/view-interactivity.js +185 -0
- package/build/navigation/view-interactivity.js.map +1 -0
- package/build/navigation-link/edit.js +12 -18
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/link-ui.js +12 -2
- package/build/navigation-link/link-ui.js.map +1 -1
- package/build/navigation-submenu/edit.js +2 -2
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +3 -3
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/edit.js +34 -39
- package/build/page-list/edit.js.map +1 -1
- package/build/page-list/use-convert-to-navigation-links.js +2 -15
- package/build/page-list/use-convert-to-navigation-links.js.map +1 -1
- package/build/paragraph/index.js +1 -0
- package/build/paragraph/index.js.map +1 -1
- package/build/paragraph/transforms.js +1 -0
- package/build/paragraph/transforms.js.map +1 -1
- package/build/post-comments-form/index.js +1 -0
- package/build/post-comments-form/index.js.map +1 -1
- package/build/post-navigation-link/index.js +1 -0
- package/build/post-navigation-link/index.js.map +1 -1
- package/build/post-time-to-read/index.js +5 -1
- package/build/post-time-to-read/index.js.map +1 -1
- package/build/query-pagination/edit.js +1 -1
- package/build/query-pagination/edit.js.map +1 -1
- package/build/query-pagination-numbers/index.js +1 -1
- package/build/query-title/edit.js +43 -1
- package/build/query-title/edit.js.map +1 -1
- package/build/quote/index.js +1 -0
- package/build/quote/index.js.map +1 -1
- package/build/quote/transforms.js +8 -0
- package/build/quote/transforms.js.map +1 -1
- package/build/rss/edit.js +3 -0
- package/build/rss/edit.js.map +1 -1
- package/build/search/edit.js +4 -3
- package/build/search/edit.js.map +1 -1
- package/build/search/index.js +1 -0
- package/build/search/index.js.map +1 -1
- package/build/site-logo/edit.js +1 -0
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-logo/index.js +5 -1
- package/build/site-logo/index.js.map +1 -1
- package/build/site-tagline/icon.js +1 -1
- package/build/site-tagline/icon.js.map +1 -1
- package/build/site-tagline/index.js +5 -1
- package/build/site-tagline/index.js.map +1 -1
- package/build/site-title/index.js +5 -1
- package/build/site-title/index.js.map +1 -1
- package/build/social-links/index.js +3 -1
- package/build/social-links/index.js.map +1 -1
- package/build/table/index.js +5 -1
- package/build/table/index.js.map +1 -1
- package/build/tag-cloud/edit.js +1 -0
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/template-part/edit/index.js +1 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build/term-description/index.js +1 -0
- package/build/term-description/index.js.map +1 -1
- package/build/text-columns/edit.js +1 -0
- package/build/text-columns/edit.js.map +1 -1
- package/build/verse/index.js +5 -1
- package/build/verse/index.js.map +1 -1
- package/build/video/deprecated.js +5 -1
- package/build/video/deprecated.js.map +1 -1
- package/build/video/index.js +5 -1
- package/build/video/index.js.map +1 -1
- package/build-module/archives/index.js +5 -1
- package/build-module/archives/index.js.map +1 -1
- package/build-module/audio/index.js +5 -1
- package/build-module/audio/index.js.map +1 -1
- package/build-module/avatar/edit.js +1 -0
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/avatar/index.js +1 -1
- package/build-module/block/edit.js +1 -1
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/edit.native.js +7 -9
- package/build-module/block/edit.native.js.map +1 -1
- package/build-module/block/index.js +2 -1
- package/build-module/block/index.js.map +1 -1
- package/build-module/buttons/edit.js +7 -3
- package/build-module/buttons/edit.js.map +1 -1
- package/build-module/categories/index.js +5 -1
- package/build-module/categories/index.js.map +1 -1
- package/build-module/code/index.js +5 -1
- package/build-module/code/index.js.map +1 -1
- package/build-module/column/edit.native.js +1 -4
- package/build-module/column/edit.native.js.map +1 -1
- package/build-module/column/index.js +1 -0
- package/build-module/column/index.js.map +1 -1
- package/build-module/columns/edit.js +1 -0
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/comment-author-avatar/edit.js +1 -0
- package/build-module/comment-author-avatar/edit.js.map +1 -1
- package/build-module/comments/index.js +1 -0
- package/build-module/comments/index.js.map +1 -1
- package/build-module/cover/deprecated.js +4 -2
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +2 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/index.js +1 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/details/index.js +5 -1
- package/build-module/details/index.js.map +1 -1
- package/build-module/embed/embed-placeholder.native.js +37 -14
- package/build-module/embed/embed-placeholder.native.js.map +1 -1
- package/build-module/embed/util.js +6 -6
- package/build-module/embed/util.js.map +1 -1
- package/build-module/file/inspector.js +1 -0
- package/build-module/file/inspector.js.map +1 -1
- package/build-module/file/{interactivity.js → view-interactivity.js} +6 -2
- package/build-module/file/view-interactivity.js.map +1 -0
- package/build-module/footnotes/edit.js +18 -2
- package/build-module/footnotes/edit.js.map +1 -1
- package/build-module/footnotes/format.js +19 -16
- package/build-module/footnotes/format.js.map +1 -1
- package/build-module/footnotes/index.js +0 -1
- package/build-module/footnotes/index.js.map +1 -1
- package/build-module/gallery/edit.js +1 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/index.js +3 -1
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/index.js +5 -1
- package/build-module/heading/index.js.map +1 -1
- package/build-module/heading/transforms.js +5 -1
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/image/deprecated.js +454 -176
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.js +0 -4
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +96 -46
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +6 -0
- package/build-module/image/index.js.map +1 -1
- package/build-module/image/save.js +8 -1
- package/build-module/image/save.js.map +1 -1
- package/build-module/image/utils.js +16 -0
- package/build-module/image/utils.js.map +1 -1
- package/build-module/image/{interactivity.js → view-interactivity.js} +86 -44
- package/build-module/image/view-interactivity.js.map +1 -0
- package/build-module/index.js +12 -3
- package/build-module/index.js.map +1 -1
- package/build-module/latest-comments/edit.js +1 -0
- package/build-module/latest-comments/edit.js.map +1 -1
- package/build-module/latest-posts/edit.js +2 -0
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/list/edit.js +4 -4
- package/build-module/list/edit.js.map +1 -1
- package/build-module/list/index.js +5 -1
- package/build-module/list/index.js.map +1 -1
- package/build-module/list-item/utils.js +6 -1
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/media-text/index.js +1 -0
- package/build-module/media-text/index.js.map +1 -1
- package/build-module/media-text/media-container.native.js +2 -1
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/missing/edit.js +22 -8
- package/build-module/missing/edit.js.map +1 -1
- package/build-module/missing/edit.native.js +8 -6
- package/build-module/missing/edit.native.js.map +1 -1
- package/build-module/navigation/constants.js +8 -3
- package/build-module/navigation/constants.js.map +1 -1
- package/build-module/navigation/edit/index.js +18 -4
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +2 -2
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +0 -1
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +2 -2
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js +10 -14
- package/build-module/navigation/edit/use-convert-classic-menu-to-block-menu.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +35 -47
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation/view-interactivity.js +182 -0
- package/build-module/navigation/view-interactivity.js.map +1 -0
- package/build-module/navigation-link/edit.js +13 -19
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +13 -3
- package/build-module/navigation-link/link-ui.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +2 -2
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +3 -3
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/edit.js +34 -39
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/page-list/use-convert-to-navigation-links.js +3 -16
- package/build-module/page-list/use-convert-to-navigation-links.js.map +1 -1
- package/build-module/paragraph/index.js +1 -0
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/paragraph/transforms.js +1 -0
- package/build-module/paragraph/transforms.js.map +1 -1
- package/build-module/post-comments-form/index.js +1 -0
- package/build-module/post-comments-form/index.js.map +1 -1
- package/build-module/post-navigation-link/index.js +1 -0
- package/build-module/post-navigation-link/index.js.map +1 -1
- package/build-module/post-time-to-read/index.js +5 -1
- package/build-module/post-time-to-read/index.js.map +1 -1
- package/build-module/query-pagination/edit.js +1 -1
- package/build-module/query-pagination/edit.js.map +1 -1
- package/build-module/query-pagination-numbers/index.js +1 -1
- package/build-module/query-title/edit.js +44 -3
- package/build-module/query-title/edit.js.map +1 -1
- package/build-module/quote/index.js +1 -0
- package/build-module/quote/index.js.map +1 -1
- package/build-module/quote/transforms.js +8 -0
- package/build-module/quote/transforms.js.map +1 -1
- package/build-module/rss/edit.js +3 -0
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/search/edit.js +4 -3
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/index.js +1 -0
- package/build-module/search/index.js.map +1 -1
- package/build-module/site-logo/edit.js +1 -0
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-logo/index.js +5 -1
- package/build-module/site-logo/index.js.map +1 -1
- package/build-module/site-tagline/icon.js +1 -1
- package/build-module/site-tagline/icon.js.map +1 -1
- package/build-module/site-tagline/index.js +5 -1
- package/build-module/site-tagline/index.js.map +1 -1
- package/build-module/site-title/index.js +5 -1
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-links/index.js +3 -1
- package/build-module/social-links/index.js.map +1 -1
- package/build-module/table/index.js +5 -1
- package/build-module/table/index.js.map +1 -1
- package/build-module/tag-cloud/edit.js +1 -0
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/template-part/edit/index.js +1 -1
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/term-description/index.js +1 -0
- package/build-module/term-description/index.js.map +1 -1
- package/build-module/text-columns/edit.js +1 -0
- package/build-module/text-columns/edit.js.map +1 -1
- package/build-module/verse/index.js +5 -1
- package/build-module/verse/index.js.map +1 -1
- package/build-module/video/deprecated.js +5 -1
- package/build-module/video/deprecated.js.map +1 -1
- package/build-module/video/index.js +5 -1
- package/build-module/video/index.js.map +1 -1
- package/build-style/details/style-rtl.css +4 -2
- package/build-style/details/style.css +4 -2
- package/build-style/footnotes/style-rtl.css +4 -3
- package/build-style/footnotes/style.css +4 -3
- package/build-style/image/style-rtl.css +16 -2
- package/build-style/image/style.css +16 -2
- package/build-style/navigation/style-rtl.css +14 -2
- package/build-style/navigation/style.css +14 -2
- package/build-style/query-pagination/style-rtl.css +4 -2
- package/build-style/query-pagination/style.css +4 -2
- package/build-style/style-rtl.css +42 -11
- package/build-style/style.css +42 -11
- package/package.json +33 -37
- package/src/archives/block.json +5 -1
- package/src/audio/block.json +5 -1
- package/src/audio/test/__snapshots__/edit.native.js.snap +58 -33
- package/src/avatar/block.json +1 -1
- package/src/avatar/edit.js +1 -0
- package/src/block/block.json +2 -1
- package/src/block/edit.js +2 -2
- package/src/block/edit.native.js +8 -12
- package/src/block/editor.native.scss +2 -2
- package/src/block/test/edit.native.js +4 -4
- package/src/buttons/edit.js +4 -4
- package/src/categories/block.json +5 -1
- package/src/code/block.json +5 -1
- package/src/column/block.json +1 -0
- package/src/column/edit.native.js +4 -10
- package/src/column/editor.native.scss +0 -4
- package/src/columns/edit.js +1 -0
- package/src/comment-author-avatar/edit.js +1 -0
- package/src/comment-template/index.php +5 -2
- package/src/comments/block.json +1 -0
- package/src/cover/block.json +1 -0
- package/src/cover/deprecated.js +2 -0
- package/src/cover/edit/inspector-controls.js +1 -0
- package/src/details/block.json +5 -1
- package/src/embed/embed-placeholder.native.js +80 -47
- package/src/embed/styles.native.scss +54 -18
- package/src/embed/test/index.native.js +5 -5
- package/src/embed/util.js +4 -6
- package/src/file/index.php +4 -3
- package/src/file/inspector.js +1 -0
- package/src/file/test/__snapshots__/edit.native.js.snap +58 -33
- package/src/file/{interactivity.js → view-interactivity.js} +4 -1
- package/src/footnotes/block.json +0 -1
- package/src/footnotes/edit.js +21 -2
- package/src/footnotes/format.js +22 -20
- package/src/footnotes/index.php +11 -9
- package/src/footnotes/style.scss +6 -3
- package/src/gallery/block.json +3 -1
- package/src/gallery/edit.js +1 -1
- package/src/gallery/test/index.native.js +17 -16
- package/src/group/block.json +1 -0
- package/src/heading/block.json +5 -1
- package/src/heading/test/index.native.js +18 -0
- package/src/home-link/index.php +15 -2
- package/src/image/block.json +6 -0
- package/src/image/deprecated.js +597 -320
- package/src/image/edit.js +0 -4
- package/src/image/image.js +131 -62
- package/src/image/index.php +47 -8
- package/src/image/save.js +9 -1
- package/src/image/style.scss +15 -2
- package/src/image/test/edit.native.js +1 -1
- package/src/image/utils.js +16 -0
- package/src/image/{interactivity.js → view-interactivity.js} +99 -50
- package/src/index.js +18 -1
- package/src/latest-comments/edit.js +1 -0
- package/src/latest-posts/edit.js +2 -0
- package/src/latest-posts/index.php +1 -1
- package/src/list/block.json +5 -1
- package/src/list/edit.js +6 -4
- package/src/list/test/edit.native.js +129 -33
- package/src/media-text/block.json +1 -0
- package/src/media-text/media-container.native.js +1 -0
- package/src/missing/edit.js +31 -11
- package/src/missing/edit.native.js +12 -10
- package/src/missing/style.native.scss +19 -12
- package/src/missing/test/__snapshots__/edit.native.js.snap +21 -13
- package/src/navigation/constants.js +12 -6
- package/src/navigation/edit/index.js +30 -3
- package/src/navigation/edit/inner-blocks.js +2 -2
- package/src/navigation/edit/menu-inspector-controls.js +0 -1
- package/src/navigation/edit/unsaved-inner-blocks.js +2 -2
- package/src/navigation/edit/use-convert-classic-menu-to-block-menu.js +17 -21
- package/src/navigation/index.php +43 -16
- package/src/navigation/style.scss +27 -8
- package/src/navigation/use-navigation-menu.js +39 -63
- package/src/navigation/view-interactivity.js +196 -0
- package/src/navigation-link/edit.js +61 -61
- package/src/navigation-link/link-ui.js +14 -2
- package/src/navigation-submenu/edit.js +2 -2
- package/src/navigation-submenu/index.php +2 -12
- package/src/page-list/convert-to-links-modal.js +3 -3
- package/src/page-list/edit.js +65 -62
- package/src/page-list/use-convert-to-navigation-links.js +3 -20
- package/src/paragraph/block.json +1 -0
- package/src/paragraph/test/__snapshots__/edit.native.js.snap +1 -0
- package/src/paragraph/test/edit.native.js +26 -0
- package/src/post-comments-form/block.json +1 -0
- package/src/post-navigation-link/block.json +1 -0
- package/src/post-template/index.php +4 -2
- package/src/post-time-to-read/block.json +5 -1
- package/src/post-title/index.php +6 -3
- package/src/preformatted/test/__snapshots__/edit.native.js.snap +2 -0
- package/src/query-pagination/edit.js +17 -14
- package/src/query-pagination-numbers/block.json +1 -1
- package/src/query-title/edit.js +48 -6
- package/src/quote/block.json +1 -0
- package/src/quote/test/__snapshots__/transforms.native.js.snap +10 -0
- package/src/quote/test/transforms.native.js +5 -1
- package/src/quote/transforms.js +13 -0
- package/src/rss/edit.js +3 -0
- package/src/search/block.json +1 -0
- package/src/search/edit.js +4 -3
- package/src/search/index.php +22 -4
- package/src/search/test/__snapshots__/edit.native.js.snap +7 -0
- package/src/site-logo/block.json +5 -1
- package/src/site-logo/edit.js +1 -0
- package/src/site-tagline/block.json +5 -1
- package/src/site-tagline/icon.js +1 -1
- package/src/site-title/block.json +5 -1
- package/src/social-links/block.json +3 -1
- package/src/table/block.json +5 -1
- package/src/tag-cloud/edit.js +1 -0
- package/src/template-part/edit/index.js +1 -1
- package/src/template-part/index.php +9 -15
- package/src/term-description/block.json +1 -0
- package/src/text-columns/edit.js +1 -0
- package/src/verse/block.json +5 -1
- package/src/video/block.json +5 -1
- package/build/file/interactivity.js.map +0 -1
- package/build/gallery/shared-icon.native.js +0 -38
- package/build/gallery/shared-icon.native.js.map +0 -1
- package/build/heading/heading-level-icon.js +0 -61
- package/build/heading/heading-level-icon.js.map +0 -1
- package/build/image/interactivity.js.map +0 -1
- package/build/navigation/interactivity.js +0 -167
- package/build/navigation/interactivity.js.map +0 -1
- package/build/utils/interactivity/constants.js +0 -9
- package/build/utils/interactivity/constants.js.map +0 -1
- package/build/utils/interactivity/directives.js +0 -222
- package/build/utils/interactivity/directives.js.map +0 -1
- package/build/utils/interactivity/hooks.js +0 -159
- package/build/utils/interactivity/hooks.js.map +0 -1
- package/build/utils/interactivity/hydration.js +0 -34
- package/build/utils/interactivity/hydration.js.map +0 -1
- package/build/utils/interactivity/index.js +0 -32
- package/build/utils/interactivity/index.js.map +0 -1
- package/build/utils/interactivity/portals.js +0 -108
- package/build/utils/interactivity/portals.js.map +0 -1
- package/build/utils/interactivity/store.js +0 -66
- package/build/utils/interactivity/store.js.map +0 -1
- package/build/utils/interactivity/utils.js +0 -87
- package/build/utils/interactivity/utils.js.map +0 -1
- package/build/utils/interactivity/vdom.js +0 -119
- package/build/utils/interactivity/vdom.js.map +0 -1
- package/build-module/file/interactivity.js.map +0 -1
- package/build-module/gallery/shared-icon.native.js +0 -24
- package/build-module/gallery/shared-icon.native.js.map +0 -1
- package/build-module/heading/heading-level-icon.js +0 -53
- package/build-module/heading/heading-level-icon.js.map +0 -1
- package/build-module/image/interactivity.js.map +0 -1
- package/build-module/navigation/interactivity.js +0 -164
- package/build-module/navigation/interactivity.js.map +0 -1
- package/build-module/utils/interactivity/constants.js +0 -2
- package/build-module/utils/interactivity/constants.js.map +0 -1
- package/build-module/utils/interactivity/directives.js +0 -209
- package/build-module/utils/interactivity/directives.js.map +0 -1
- package/build-module/utils/interactivity/hooks.js +0 -145
- package/build-module/utils/interactivity/hooks.js.map +0 -1
- package/build-module/utils/interactivity/hydration.js +0 -21
- package/build-module/utils/interactivity/hydration.js.map +0 -1
- package/build-module/utils/interactivity/index.js +0 -15
- package/build-module/utils/interactivity/index.js.map +0 -1
- package/build-module/utils/interactivity/portals.js +0 -100
- package/build-module/utils/interactivity/portals.js.map +0 -1
- package/build-module/utils/interactivity/store.js +0 -55
- package/build-module/utils/interactivity/store.js.map +0 -1
- package/build-module/utils/interactivity/utils.js +0 -75
- package/build-module/utils/interactivity/utils.js.map +0 -1
- package/build-module/utils/interactivity/vdom.js +0 -107
- package/build-module/utils/interactivity/vdom.js.map +0 -1
- package/src/gallery/shared-icon.native.js +0 -23
- package/src/heading/heading-level-icon.js +0 -48
- package/src/navigation/interactivity.js +0 -169
- package/src/utils/interactivity/constants.js +0 -1
- package/src/utils/interactivity/directives.js +0 -200
- package/src/utils/interactivity/hooks.js +0 -145
- package/src/utils/interactivity/hydration.js +0 -22
- package/src/utils/interactivity/index.js +0 -15
- package/src/utils/interactivity/portals.js +0 -98
- package/src/utils/interactivity/store.js +0 -45
- package/src/utils/interactivity/utils.js +0 -66
- package/src/utils/interactivity/vdom.js +0 -111
package/src/image/edit.js
CHANGED
|
@@ -183,8 +183,6 @@ export function ImageEdit( {
|
|
|
183
183
|
// Reset the dimension attributes if changing to a different image.
|
|
184
184
|
if ( ! media.id || media.id !== id ) {
|
|
185
185
|
additionalAttributes = {
|
|
186
|
-
width: undefined,
|
|
187
|
-
height: undefined,
|
|
188
186
|
// Fallback to size "full" if there's no default image size.
|
|
189
187
|
// It means the image is smaller, and the block will use a full-size URL.
|
|
190
188
|
sizeSlug: hasDefaultSize( media, imageDefaultSize )
|
|
@@ -248,8 +246,6 @@ export function ImageEdit( {
|
|
|
248
246
|
setAttributes( {
|
|
249
247
|
url: newURL,
|
|
250
248
|
id: undefined,
|
|
251
|
-
width: undefined,
|
|
252
|
-
height: undefined,
|
|
253
249
|
sizeSlug: imageDefaultSize,
|
|
254
250
|
} );
|
|
255
251
|
}
|
package/src/image/image.js
CHANGED
|
@@ -4,13 +4,15 @@
|
|
|
4
4
|
import { isBlobURL } from '@wordpress/blob';
|
|
5
5
|
import {
|
|
6
6
|
ExternalLink,
|
|
7
|
-
PanelBody,
|
|
8
7
|
ResizableBox,
|
|
9
8
|
Spinner,
|
|
10
9
|
TextareaControl,
|
|
11
10
|
TextControl,
|
|
12
11
|
ToolbarButton,
|
|
13
12
|
ToolbarGroup,
|
|
13
|
+
__experimentalToolsPanel as ToolsPanel,
|
|
14
|
+
__experimentalToolsPanelItem as ToolsPanelItem,
|
|
15
|
+
__experimentalUseCustomUnits as useCustomUnits,
|
|
14
16
|
} from '@wordpress/components';
|
|
15
17
|
import { useViewportMatch, usePrevious } from '@wordpress/compose';
|
|
16
18
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
@@ -18,7 +20,6 @@ import {
|
|
|
18
20
|
BlockControls,
|
|
19
21
|
InspectorControls,
|
|
20
22
|
RichText,
|
|
21
|
-
__experimentalImageSizeControl as ImageSizeControl,
|
|
22
23
|
__experimentalImageURLInputUI as ImageURLInputUI,
|
|
23
24
|
MediaReplaceFlow,
|
|
24
25
|
store as blockEditorStore,
|
|
@@ -26,6 +27,7 @@ import {
|
|
|
26
27
|
__experimentalImageEditor as ImageEditor,
|
|
27
28
|
__experimentalGetElementClassName,
|
|
28
29
|
__experimentalUseBorderProps as useBorderProps,
|
|
30
|
+
privateApis as blockEditorPrivateApis,
|
|
29
31
|
} from '@wordpress/block-editor';
|
|
30
32
|
import {
|
|
31
33
|
useEffect,
|
|
@@ -34,7 +36,7 @@ import {
|
|
|
34
36
|
useRef,
|
|
35
37
|
useCallback,
|
|
36
38
|
} from '@wordpress/element';
|
|
37
|
-
import { __, sprintf, isRTL } from '@wordpress/i18n';
|
|
39
|
+
import { __, _x, sprintf, isRTL } from '@wordpress/i18n';
|
|
38
40
|
import { getFilename } from '@wordpress/url';
|
|
39
41
|
import {
|
|
40
42
|
createBlock,
|
|
@@ -53,6 +55,7 @@ import { store as coreStore } from '@wordpress/core-data';
|
|
|
53
55
|
/**
|
|
54
56
|
* Internal dependencies
|
|
55
57
|
*/
|
|
58
|
+
import { unlock } from '../lock-unlock';
|
|
56
59
|
import { createUpgradedEmbedBlock } from '../embed/util';
|
|
57
60
|
import useClientWidth from './use-client-width';
|
|
58
61
|
import { isExternalImage } from './edit';
|
|
@@ -61,6 +64,22 @@ import { isExternalImage } from './edit';
|
|
|
61
64
|
* Module constants
|
|
62
65
|
*/
|
|
63
66
|
import { MIN_SIZE, ALLOWED_MEDIA_TYPES } from './constants';
|
|
67
|
+
import { evalAspectRatio } from './utils';
|
|
68
|
+
|
|
69
|
+
const { DimensionsTool, ResolutionTool } = unlock( blockEditorPrivateApis );
|
|
70
|
+
|
|
71
|
+
const scaleOptions = [
|
|
72
|
+
{
|
|
73
|
+
value: 'cover',
|
|
74
|
+
label: _x( 'Cover', 'Scale option for dimensions control' ),
|
|
75
|
+
help: __( 'Image covers the space evenly.' ),
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
value: 'contain',
|
|
79
|
+
label: _x( 'Contain', 'Scale option for dimensions control' ),
|
|
80
|
+
help: __( 'Image is contained without distortion.' ),
|
|
81
|
+
},
|
|
82
|
+
];
|
|
64
83
|
|
|
65
84
|
export default function Image( {
|
|
66
85
|
temporaryURL,
|
|
@@ -90,6 +109,8 @@ export default function Image( {
|
|
|
90
109
|
title,
|
|
91
110
|
width,
|
|
92
111
|
height,
|
|
112
|
+
aspectRatio,
|
|
113
|
+
scale,
|
|
93
114
|
linkTarget,
|
|
94
115
|
sizeSlug,
|
|
95
116
|
} = attributes;
|
|
@@ -272,8 +293,6 @@ export default function Image( {
|
|
|
272
293
|
|
|
273
294
|
setAttributes( {
|
|
274
295
|
url: newUrl,
|
|
275
|
-
width: undefined,
|
|
276
|
-
height: undefined,
|
|
277
296
|
sizeSlug: newSizeSlug,
|
|
278
297
|
} );
|
|
279
298
|
}
|
|
@@ -329,6 +348,13 @@ export default function Image( {
|
|
|
329
348
|
);
|
|
330
349
|
}
|
|
331
350
|
|
|
351
|
+
// TODO: Can allow more units after figuring out how they should interact
|
|
352
|
+
// with the ResizableBox and ImageEditor components. Calculations later on
|
|
353
|
+
// for those components are currently assuming px units.
|
|
354
|
+
const dimensionsUnitsOptions = useCustomUnits( {
|
|
355
|
+
availableUnits: [ 'px' ],
|
|
356
|
+
} );
|
|
357
|
+
|
|
332
358
|
const controls = (
|
|
333
359
|
<>
|
|
334
360
|
<BlockControls group="block">
|
|
@@ -407,41 +433,78 @@ export default function Image( {
|
|
|
407
433
|
</BlockControls>
|
|
408
434
|
) }
|
|
409
435
|
<InspectorControls>
|
|
410
|
-
<
|
|
436
|
+
<ToolsPanel
|
|
437
|
+
label={ __( 'Settings' ) }
|
|
438
|
+
resetAll={ () =>
|
|
439
|
+
setAttributes( {
|
|
440
|
+
width: undefined,
|
|
441
|
+
height: undefined,
|
|
442
|
+
scale: undefined,
|
|
443
|
+
aspectRatio: undefined,
|
|
444
|
+
} )
|
|
445
|
+
}
|
|
446
|
+
>
|
|
411
447
|
{ ! multiImageSelection && (
|
|
412
|
-
<
|
|
413
|
-
__nextHasNoMarginBottom
|
|
448
|
+
<ToolsPanelItem
|
|
414
449
|
label={ __( 'Alternative text' ) }
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
<ExternalLink href="https://www.w3.org/WAI/tutorials/images/decision-tree">
|
|
420
|
-
{ __(
|
|
421
|
-
'Describe the purpose of the image.'
|
|
422
|
-
) }
|
|
423
|
-
</ExternalLink>
|
|
424
|
-
<br />
|
|
425
|
-
{ __( 'Leave empty if decorative.' ) }
|
|
426
|
-
</>
|
|
450
|
+
isShownByDefault={ true }
|
|
451
|
+
hasValue={ () => alt !== '' }
|
|
452
|
+
onDeselect={ () =>
|
|
453
|
+
setAttributes( { alt: undefined } )
|
|
427
454
|
}
|
|
428
|
-
|
|
455
|
+
>
|
|
456
|
+
<TextareaControl
|
|
457
|
+
label={ __( 'Alternative text' ) }
|
|
458
|
+
value={ alt }
|
|
459
|
+
onChange={ updateAlt }
|
|
460
|
+
help={
|
|
461
|
+
<>
|
|
462
|
+
<ExternalLink href="https://www.w3.org/WAI/tutorials/images/decision-tree">
|
|
463
|
+
{ __(
|
|
464
|
+
'Describe the purpose of the image.'
|
|
465
|
+
) }
|
|
466
|
+
</ExternalLink>
|
|
467
|
+
<br />
|
|
468
|
+
{ __( 'Leave empty if decorative.' ) }
|
|
469
|
+
</>
|
|
470
|
+
}
|
|
471
|
+
__nextHasNoMarginBottom
|
|
472
|
+
/>
|
|
473
|
+
</ToolsPanelItem>
|
|
429
474
|
) }
|
|
430
|
-
<
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
475
|
+
<DimensionsTool
|
|
476
|
+
value={ {
|
|
477
|
+
width: width && `${ width }px`,
|
|
478
|
+
height: height && `${ height }px`,
|
|
479
|
+
scale,
|
|
480
|
+
aspectRatio,
|
|
481
|
+
} }
|
|
482
|
+
onChange={ ( newValue ) => {
|
|
483
|
+
// Rebuilding the object forces setting `undefined`
|
|
484
|
+
// for values that are removed since setAttributes
|
|
485
|
+
// doesn't do anything with keys that aren't set.
|
|
486
|
+
setAttributes( {
|
|
487
|
+
width:
|
|
488
|
+
newValue.width &&
|
|
489
|
+
parseInt( newValue.width, 10 ),
|
|
490
|
+
height:
|
|
491
|
+
newValue.height &&
|
|
492
|
+
parseInt( newValue.height, 10 ),
|
|
493
|
+
scale: newValue.scale,
|
|
494
|
+
aspectRatio: newValue.aspectRatio,
|
|
495
|
+
} );
|
|
496
|
+
} }
|
|
497
|
+
defaultScale="cover"
|
|
498
|
+
defaultAspectRatio="auto"
|
|
499
|
+
scaleOptions={ scaleOptions }
|
|
500
|
+
unitsOptions={ dimensionsUnitsOptions }
|
|
501
|
+
/>
|
|
502
|
+
<ResolutionTool
|
|
503
|
+
value={ sizeSlug }
|
|
504
|
+
onChange={ updateImage }
|
|
505
|
+
options={ imageSizeOptions }
|
|
443
506
|
/>
|
|
444
|
-
</
|
|
507
|
+
</ToolsPanel>
|
|
445
508
|
</InspectorControls>
|
|
446
509
|
<InspectorControls group="advanced">
|
|
447
510
|
<TextControl
|
|
@@ -483,9 +546,6 @@ export default function Image( {
|
|
|
483
546
|
|
|
484
547
|
const borderProps = useBorderProps( attributes );
|
|
485
548
|
const isRounded = attributes.className?.includes( 'is-style-rounded' );
|
|
486
|
-
const hasCustomBorder =
|
|
487
|
-
!! borderProps.className ||
|
|
488
|
-
( borderProps.style && Object.keys( borderProps.style ).length > 0 );
|
|
489
549
|
|
|
490
550
|
let img = (
|
|
491
551
|
// Disable reason: Image itself is not meant to be interactive, but
|
|
@@ -504,25 +564,20 @@ export default function Image( {
|
|
|
504
564
|
} }
|
|
505
565
|
ref={ imageRef }
|
|
506
566
|
className={ borderProps.className }
|
|
507
|
-
style={
|
|
567
|
+
style={ {
|
|
568
|
+
width:
|
|
569
|
+
( width && height ) || aspectRatio ? '100%' : 'inherit',
|
|
570
|
+
height:
|
|
571
|
+
( width && height ) || aspectRatio ? '100%' : 'inherit',
|
|
572
|
+
objectFit: scale,
|
|
573
|
+
...borderProps.style,
|
|
574
|
+
} }
|
|
508
575
|
/>
|
|
509
576
|
{ temporaryURL && <Spinner /> }
|
|
510
577
|
</>
|
|
511
578
|
/* eslint-enable jsx-a11y/no-noninteractive-element-interactions, jsx-a11y/click-events-have-key-events */
|
|
512
579
|
);
|
|
513
580
|
|
|
514
|
-
let imageWidthWithinContainer;
|
|
515
|
-
let imageHeightWithinContainer;
|
|
516
|
-
|
|
517
|
-
if ( clientWidth && naturalWidth && naturalHeight ) {
|
|
518
|
-
const exceedMaxWidth = naturalWidth > clientWidth;
|
|
519
|
-
const ratio = naturalHeight / naturalWidth;
|
|
520
|
-
imageWidthWithinContainer = exceedMaxWidth ? clientWidth : naturalWidth;
|
|
521
|
-
imageHeightWithinContainer = exceedMaxWidth
|
|
522
|
-
? clientWidth * ratio
|
|
523
|
-
: naturalHeight;
|
|
524
|
-
}
|
|
525
|
-
|
|
526
581
|
// clientWidth needs to be a number for the image Cropper to work, but sometimes it's 0
|
|
527
582
|
// So we try using the imageRef width first and fallback to clientWidth.
|
|
528
583
|
const fallbackClientWidth = imageRef.current?.width || clientWidth;
|
|
@@ -546,13 +601,18 @@ export default function Image( {
|
|
|
546
601
|
borderProps={ isRounded ? undefined : borderProps }
|
|
547
602
|
/>
|
|
548
603
|
);
|
|
549
|
-
} else if ( ! isResizable
|
|
550
|
-
img = <div style={ { width, height } }>{ img }</div>;
|
|
604
|
+
} else if ( ! isResizable ) {
|
|
605
|
+
img = <div style={ { width, height, aspectRatio } }>{ img }</div>;
|
|
551
606
|
} else {
|
|
552
|
-
const
|
|
553
|
-
|
|
607
|
+
const ratio =
|
|
608
|
+
( aspectRatio && evalAspectRatio( aspectRatio ) ) ||
|
|
609
|
+
( width && height && width / height ) ||
|
|
610
|
+
naturalWidth / naturalHeight ||
|
|
611
|
+
1;
|
|
612
|
+
|
|
613
|
+
const currentWidth = ! width && height ? height * ratio : width;
|
|
614
|
+
const currentHeight = ! height && width ? width / ratio : height;
|
|
554
615
|
|
|
555
|
-
const ratio = naturalWidth / naturalHeight;
|
|
556
616
|
const minWidth =
|
|
557
617
|
naturalWidth < naturalHeight ? MIN_SIZE : MIN_SIZE * ratio;
|
|
558
618
|
const minHeight =
|
|
@@ -600,16 +660,24 @@ export default function Image( {
|
|
|
600
660
|
|
|
601
661
|
img = (
|
|
602
662
|
<ResizableBox
|
|
663
|
+
style={ {
|
|
664
|
+
display: 'block',
|
|
665
|
+
objectFit: scale,
|
|
666
|
+
aspectRatio:
|
|
667
|
+
! width && ! height && aspectRatio
|
|
668
|
+
? aspectRatio
|
|
669
|
+
: undefined,
|
|
670
|
+
} }
|
|
603
671
|
size={ {
|
|
604
|
-
width:
|
|
605
|
-
height:
|
|
672
|
+
width: currentWidth ?? 'auto',
|
|
673
|
+
height: currentHeight ?? 'auto',
|
|
606
674
|
} }
|
|
607
675
|
showHandle={ isSelected }
|
|
608
676
|
minWidth={ minWidth }
|
|
609
677
|
maxWidth={ maxWidthBuffer }
|
|
610
678
|
minHeight={ minHeight }
|
|
611
679
|
maxHeight={ maxWidthBuffer / ratio }
|
|
612
|
-
lockAspectRatio
|
|
680
|
+
lockAspectRatio={ ratio }
|
|
613
681
|
enable={ {
|
|
614
682
|
top: false,
|
|
615
683
|
right: showRightHandle,
|
|
@@ -617,11 +685,12 @@ export default function Image( {
|
|
|
617
685
|
left: showLeftHandle,
|
|
618
686
|
} }
|
|
619
687
|
onResizeStart={ onResizeStart }
|
|
620
|
-
onResizeStop={ ( event, direction, elt
|
|
688
|
+
onResizeStop={ ( event, direction, elt ) => {
|
|
621
689
|
onResizeStop();
|
|
622
690
|
setAttributes( {
|
|
623
|
-
width:
|
|
624
|
-
height:
|
|
691
|
+
width: elt.offsetWidth,
|
|
692
|
+
height: elt.offsetHeight,
|
|
693
|
+
aspectRatio: undefined,
|
|
625
694
|
} );
|
|
626
695
|
} }
|
|
627
696
|
resizeRatio={ align === 'center' ? 2 : 1 }
|
package/src/image/index.php
CHANGED
|
@@ -9,11 +9,12 @@
|
|
|
9
9
|
* Renders the `core/image` block on the server,
|
|
10
10
|
* adding a data-id attribute to the element if core/gallery has added on pre-render.
|
|
11
11
|
*
|
|
12
|
-
* @param array
|
|
13
|
-
* @param string
|
|
12
|
+
* @param array $attributes The block attributes.
|
|
13
|
+
* @param string $content The block content.
|
|
14
|
+
* @param WP_Block $block The block object.
|
|
14
15
|
* @return string Returns the block content with the data-id attribute added.
|
|
15
16
|
*/
|
|
16
|
-
function render_block_core_image( $attributes, $content ) {
|
|
17
|
+
function render_block_core_image( $attributes, $content, $block ) {
|
|
17
18
|
|
|
18
19
|
$processor = new WP_HTML_Tag_Processor( $content );
|
|
19
20
|
$processor->next_tag( 'img' );
|
|
@@ -30,14 +31,52 @@ function render_block_core_image( $attributes, $content ) {
|
|
|
30
31
|
$processor->set_attribute( 'data-id', $attributes['data-id'] );
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
$should_load_view_script = false;
|
|
35
|
+
$experiments = get_option( 'gutenberg-experiments' );
|
|
36
|
+
$link_destination = isset( $attributes['linkDestination'] ) ? $attributes['linkDestination'] : 'none';
|
|
37
|
+
// Get the lightbox setting from the block attributes.
|
|
38
|
+
if ( isset( $attributes['behaviors']['lightbox'] ) ) {
|
|
39
|
+
$lightbox_settings = $attributes['behaviors']['lightbox'];
|
|
40
|
+
// If the lightbox setting is not set in the block attributes, get it from the theme.json file.
|
|
41
|
+
} else {
|
|
42
|
+
$theme_data = WP_Theme_JSON_Resolver_Gutenberg::get_merged_data()->get_data();
|
|
43
|
+
if ( isset( $theme_data['behaviors']['blocks'][ $block->name ]['lightbox'] ) ) {
|
|
44
|
+
$lightbox_settings = $theme_data['behaviors']['blocks'][ $block->name ]['lightbox'];
|
|
45
|
+
} else {
|
|
46
|
+
$lightbox_settings = null;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// If the lightbox is enabled, the image is not linked, and the Interactivity API is enabled, load the view script.
|
|
51
|
+
if ( isset( $lightbox_settings['enabled'] ) &&
|
|
52
|
+
true === $lightbox_settings['enabled'] &&
|
|
53
|
+
'none' === $link_destination &&
|
|
54
|
+
! empty( $experiments['gutenberg-interactivity-api-core-blocks'] )
|
|
55
|
+
) {
|
|
56
|
+
$should_load_view_script = true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
$view_js_file = 'wp-block-image-view';
|
|
60
|
+
if ( ! wp_script_is( $view_js_file ) ) {
|
|
61
|
+
$script_handles = $block->block_type->view_script_handles;
|
|
62
|
+
|
|
63
|
+
// If the script is not needed, and it is still in the `view_script_handles`, remove it.
|
|
64
|
+
if ( ! $should_load_view_script && in_array( $view_js_file, $script_handles, true ) ) {
|
|
65
|
+
$block->block_type->view_script_handles = array_diff( $script_handles, array( $view_js_file ) );
|
|
66
|
+
}
|
|
67
|
+
// If the script is needed, but it was previously removed, add it again.
|
|
68
|
+
if ( $should_load_view_script && ! in_array( $view_js_file, $script_handles, true ) ) {
|
|
69
|
+
$block->block_type->view_script_handles = array_merge( $script_handles, array( $view_js_file ) );
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
33
73
|
return $processor->get_updated_html();
|
|
34
74
|
}
|
|
35
75
|
|
|
36
|
-
/**
|
|
37
|
-
|
|
38
|
-
|
|
76
|
+
/**
|
|
77
|
+
* Registers the `core/image` block on server.
|
|
78
|
+
*/
|
|
39
79
|
function register_block_core_image() {
|
|
40
|
-
|
|
41
80
|
register_block_type_from_metadata(
|
|
42
81
|
__DIR__ . '/image',
|
|
43
82
|
array(
|
|
@@ -45,4 +84,4 @@ function register_block_core_image() {
|
|
|
45
84
|
)
|
|
46
85
|
);
|
|
47
86
|
}
|
|
48
|
-
add_action( 'init', 'register_block_core_image' );
|
|
87
|
+
add_action( 'init', 'register_block_core_image' );
|
package/src/image/save.js
CHANGED
|
@@ -24,6 +24,8 @@ export default function save( { attributes } ) {
|
|
|
24
24
|
linkClass,
|
|
25
25
|
width,
|
|
26
26
|
height,
|
|
27
|
+
aspectRatio,
|
|
28
|
+
scale,
|
|
27
29
|
id,
|
|
28
30
|
linkTarget,
|
|
29
31
|
sizeSlug,
|
|
@@ -52,7 +54,13 @@ export default function save( { attributes } ) {
|
|
|
52
54
|
src={ url }
|
|
53
55
|
alt={ alt }
|
|
54
56
|
className={ imageClasses || undefined }
|
|
55
|
-
style={
|
|
57
|
+
style={ {
|
|
58
|
+
...borderProps.style,
|
|
59
|
+
aspectRatio,
|
|
60
|
+
objectFit: scale,
|
|
61
|
+
width,
|
|
62
|
+
height,
|
|
63
|
+
} }
|
|
56
64
|
width={ width }
|
|
57
65
|
height={ height }
|
|
58
66
|
title={ title }
|
package/src/image/style.scss
CHANGED
|
@@ -184,11 +184,12 @@
|
|
|
184
184
|
width: 100vw;
|
|
185
185
|
height: 100vh;
|
|
186
186
|
visibility: hidden;
|
|
187
|
+
cursor: zoom-out;
|
|
187
188
|
|
|
188
189
|
.close-button {
|
|
189
190
|
position: absolute;
|
|
190
|
-
top: 12.5px;
|
|
191
|
-
right: 12.5px;
|
|
191
|
+
top: calc(env(safe-area-inset-top) + 12.5px);
|
|
192
|
+
right: calc(env(safe-area-inset-right) + 12.5px);
|
|
192
193
|
padding: 0;
|
|
193
194
|
cursor: pointer;
|
|
194
195
|
z-index: 5000000;
|
|
@@ -231,6 +232,18 @@
|
|
|
231
232
|
}
|
|
232
233
|
|
|
233
234
|
&.fade {
|
|
235
|
+
.wp-block-image {
|
|
236
|
+
padding: 40px 0;
|
|
237
|
+
|
|
238
|
+
@media screen and (min-width: 480px) {
|
|
239
|
+
padding: 40px;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
@media screen and (min-width: 1920px) {
|
|
243
|
+
padding: 40px 80px;
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
234
247
|
&.active {
|
|
235
248
|
visibility: visible;
|
|
236
249
|
animation: both turn-on-visibility 0.25s;
|
|
@@ -442,7 +442,7 @@ describe( 'Image Block', () => {
|
|
|
442
442
|
<!-- /wp:image -->`;
|
|
443
443
|
const screen = await initializeEditor( { initialHtml } );
|
|
444
444
|
|
|
445
|
-
fireEvent.press( screen.getByText( '
|
|
445
|
+
fireEvent.press( screen.getByText( 'Add image' ) );
|
|
446
446
|
fireEvent.press( screen.getByText( 'WordPress Media Library' ) );
|
|
447
447
|
|
|
448
448
|
const expectedHtml = `<!-- wp:image {"id":${ IMAGE.id },"sizeSlug":"large","linkDestination":"none"} -->
|
package/src/image/utils.js
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { NEW_TAB_REL } from './constants';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Evaluates a CSS aspect-ratio property value as a number.
|
|
8
|
+
*
|
|
9
|
+
* Degenerate or invalid ratios behave as 'auto'. And 'auto' ratios return NaN.
|
|
10
|
+
*
|
|
11
|
+
* @see https://drafts.csswg.org/css-sizing-4/#aspect-ratio
|
|
12
|
+
*
|
|
13
|
+
* @param {string} value CSS aspect-ratio property value.
|
|
14
|
+
* @return {number} Numerical aspect ratio or NaN if invalid.
|
|
15
|
+
*/
|
|
16
|
+
export function evalAspectRatio( value ) {
|
|
17
|
+
const [ width, height = 1 ] = value.split( '/' ).map( Number );
|
|
18
|
+
const aspectRatio = width / height;
|
|
19
|
+
return aspectRatio === Infinity || aspectRatio === 0 ? NaN : aspectRatio;
|
|
20
|
+
}
|
|
21
|
+
|
|
6
22
|
export function removeNewTabRel( currentRel ) {
|
|
7
23
|
let newRel = currentRel;
|
|
8
24
|
|