@wordpress/block-library 7.19.0 → 8.1.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 +8 -0
- package/build/audio/edit.native.js +1 -3
- package/build/audio/edit.native.js.map +1 -1
- package/build/audio/index.js +2 -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/user-control.js +1 -0
- package/build/avatar/user-control.js.map +1 -1
- package/build/block/edit.js +14 -2
- package/build/block/edit.js.map +1 -1
- package/build/block/edit.native.js +14 -6
- package/build/block/edit.native.js.map +1 -1
- package/build/block/index.js +1 -2
- package/build/block/index.js.map +1 -1
- package/build/button/edit.native.js.map +1 -1
- package/build/categories/edit.js +1 -1
- package/build/categories/edit.js.map +1 -1
- package/build/code/transforms.js +1 -1
- package/build/code/transforms.js.map +1 -1
- package/build/columns/edit.js +1 -0
- package/build/columns/edit.js.map +1 -1
- package/build/columns/edit.native.js +13 -30
- package/build/columns/edit.native.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/cover/edit/inspector-controls.js +3 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/cover/edit.native.js +24 -16
- package/build/cover/edit.native.js.map +1 -1
- package/build/embed/embed-controls.native.js +1 -0
- package/build/embed/embed-controls.native.js.map +1 -1
- package/build/embed/embed-preview.native.js +1 -3
- package/build/embed/embed-preview.native.js.map +1 -1
- package/build/file/inspector.js +1 -0
- package/build/file/inspector.js.map +1 -1
- package/build/freeform/edit.js +21 -6
- package/build/freeform/edit.js.map +1 -1
- package/build/freeform/modal.js +97 -0
- package/build/freeform/modal.js.map +1 -0
- package/build/gallery/edit.js +38 -15
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.js +2 -16
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/gallery.native.js +1 -3
- package/build/gallery/gallery.native.js.map +1 -1
- package/build/gallery/shared.js +4 -10
- package/build/gallery/shared.js.map +1 -1
- package/build/gallery/transforms.js +1 -7
- package/build/gallery/transforms.js.map +1 -1
- package/build/gallery/use-get-media.js +1 -1
- package/build/gallery/use-get-media.js.map +1 -1
- package/build/gallery/use-get-media.native.js +3 -1
- package/build/gallery/use-get-media.native.js.map +1 -1
- package/build/gallery/v1/edit.js +22 -15
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/gallery/v1/gallery.native.js +1 -3
- package/build/gallery/v1/gallery.native.js.map +1 -1
- package/build/gallery/v1/shared.js +4 -1
- package/build/gallery/v1/shared.js.map +1 -1
- package/build/group/edit.js +1 -2
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +3 -1
- package/build/group/index.js.map +1 -1
- package/build/group/placeholder.js +5 -26
- package/build/group/placeholder.js.map +1 -1
- package/build/heading/deprecated.js +152 -69
- package/build/heading/deprecated.js.map +1 -1
- package/build/heading/index.js +1 -2
- package/build/heading/index.js.map +1 -1
- package/build/heading/transforms.js +1 -2
- package/build/heading/transforms.js.map +1 -1
- package/build/html/index.js +1 -1
- package/build/image/edit.js +8 -5
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +3 -2
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +13 -8
- package/build/image/image.js.map +1 -1
- package/build/index.js +3 -1
- 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/transforms.js +1 -9
- package/build/list/transforms.js.map +1 -1
- package/build/list/utils.js +5 -2
- package/build/list/utils.js.map +1 -1
- package/build/list-item/index.js +4 -1
- package/build/list-item/index.js.map +1 -1
- package/build/list-item/transforms.js +22 -0
- package/build/list-item/transforms.js.map +1 -0
- package/build/list-item/utils.js +77 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/media-text/edit.js +5 -2
- package/build/media-text/edit.js.map +1 -1
- package/build/missing/edit.native.js +2 -2
- package/build/missing/edit.native.js.map +1 -1
- package/build/navigation/edit/are-blocks-dirty.js +52 -0
- package/build/navigation/edit/are-blocks-dirty.js.map +1 -0
- package/build/navigation/edit/index.js +95 -117
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/menu-inspector-controls.js +94 -0
- package/build/navigation/edit/menu-inspector-controls.js.map +1 -0
- package/build/navigation/edit/navigation-menu-selector.js +2 -4
- package/build/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +11 -7
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/edit/utils.js +81 -0
- package/build/navigation/edit/utils.js.map +1 -1
- package/build/navigation/view-modal.js +6 -2
- package/build/navigation/view-modal.js.map +1 -1
- package/build/navigation-link/edit.js +46 -356
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/link-ui.js +222 -0
- package/build/navigation-link/link-ui.js.map +1 -0
- package/build/navigation-link/transforms.js +12 -0
- package/build/navigation-link/transforms.js.map +1 -1
- package/build/navigation-link/update-attributes.js +108 -0
- package/build/navigation-link/update-attributes.js.map +1 -0
- package/build/navigation-submenu/edit.js +49 -245
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/constants.js +15 -0
- package/build/page-list/constants.js.map +1 -0
- package/build/page-list/convert-to-links-modal.js +22 -86
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/convert-to-navigation-links.js +76 -0
- package/build/page-list/convert-to-navigation-links.js.map +1 -0
- package/build/page-list/edit.js +143 -78
- package/build/page-list/edit.js.map +1 -1
- package/build/page-list/index.js +35 -3
- package/build/page-list/index.js.map +1 -1
- package/build/page-list-item/edit.js +91 -0
- package/build/page-list-item/edit.js.map +1 -0
- package/build/page-list-item/index.js +85 -0
- package/build/page-list-item/index.js.map +1 -0
- package/build/page-list-item/init.js +16 -0
- package/build/page-list-item/init.js.map +1 -0
- package/build/paragraph/index.js +1 -7
- package/build/paragraph/index.js.map +1 -1
- package/build/post-author/edit.js +3 -2
- package/build/post-author/edit.js.map +1 -1
- package/build/post-featured-image/overlay.js +1 -1
- package/build/post-featured-image/overlay.js.map +1 -1
- package/build/post-template/index.js +8 -0
- package/build/post-template/index.js.map +1 -1
- package/build/preformatted/transforms.js +3 -1
- package/build/preformatted/transforms.js.map +1 -1
- package/build/query/deprecated.js +192 -21
- package/build/query/deprecated.js.map +1 -1
- package/build/query/edit/index.js +2 -1
- package/build/query/edit/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +11 -5
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +101 -37
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query/edit/query-content.js +2 -3
- package/build/query/edit/query-content.js.map +1 -1
- package/build/query/edit/query-placeholder.js +16 -27
- package/build/query/edit/query-placeholder.js.map +1 -1
- package/build/query/index.js +0 -8
- package/build/query/index.js.map +1 -1
- package/build/query/utils.js +73 -9
- package/build/query/utils.js.map +1 -1
- package/build/rss/edit.js +3 -0
- package/build/rss/edit.js.map +1 -1
- package/build/search/edit.js +2 -2
- package/build/search/edit.js.map +1 -1
- package/build/search/edit.native.js +22 -22
- package/build/search/edit.native.js.map +1 -1
- package/build/search/index.js +9 -1
- package/build/search/index.js.map +1 -1
- package/build/site-logo/edit.js +17 -9
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-logo/index.js +1 -0
- package/build/site-logo/index.js.map +1 -1
- package/build/site-title/index.js +1 -0
- package/build/site-title/index.js.map +1 -1
- package/build/social-link/edit.js.map +1 -1
- package/build/social-link/social-list.js +4 -12
- package/build/social-link/social-list.js.map +1 -1
- package/build/social-links/edit.js +0 -1
- package/build/social-links/edit.js.map +1 -1
- package/build/table/edit.js +3 -1
- package/build/table/edit.js.map +1 -1
- package/build/table/index.js +17 -1
- package/build/table/index.js.map +1 -1
- package/build/table/save.js +4 -2
- package/build/table/save.js.map +1 -1
- package/build/table/state.js +24 -12
- package/build/table/state.js.map +1 -1
- package/build/table/transforms.js +3 -2
- package/build/table/transforms.js.map +1 -1
- package/build/table-of-contents/edit.js +3 -3
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/tag-cloud/edit.js +2 -1
- package/build/tag-cloud/edit.js.map +1 -1
- package/build/template-part/edit/advanced-controls.js +11 -1
- package/build/template-part/edit/advanced-controls.js.map +1 -1
- package/build/template-part/edit/import-controls.js +160 -0
- package/build/template-part/edit/import-controls.js.map +1 -0
- package/build/template-part/edit/index.js +2 -1
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/selection-modal.js +5 -2
- package/build/template-part/edit/selection-modal.js.map +1 -1
- package/build/template-part/edit/utils/hooks.js +2 -6
- package/build/template-part/edit/utils/hooks.js.map +1 -1
- package/build/template-part/edit/utils/transformers.js +48 -0
- package/build/template-part/edit/utils/transformers.js.map +1 -0
- package/build/text-columns/edit.js +1 -0
- package/build/text-columns/edit.js.map +1 -1
- package/build/utils/transformation-categories.native.js +1 -1
- package/build/utils/transformation-categories.native.js.map +1 -1
- package/build/video/edit.js +1 -1
- package/build/video/edit.js.map +1 -1
- package/build/video/edit.native.js +1 -3
- package/build/video/edit.native.js.map +1 -1
- package/build-module/audio/edit.native.js +1 -2
- package/build-module/audio/edit.native.js.map +1 -1
- package/build-module/audio/index.js +2 -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/user-control.js +1 -0
- package/build-module/avatar/user-control.js.map +1 -1
- package/build-module/block/edit.js +14 -2
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/edit.native.js +14 -6
- package/build-module/block/edit.native.js.map +1 -1
- package/build-module/block/index.js +1 -2
- package/build-module/block/index.js.map +1 -1
- package/build-module/button/edit.native.js +2 -1
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/categories/edit.js +1 -1
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/code/transforms.js +1 -1
- package/build-module/code/transforms.js.map +1 -1
- package/build-module/columns/edit.js +1 -0
- package/build-module/columns/edit.js.map +1 -1
- package/build-module/columns/edit.native.js +13 -29
- package/build-module/columns/edit.native.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/cover/edit/inspector-controls.js +5 -3
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/cover/edit.native.js +22 -14
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/embed/embed-controls.native.js +2 -1
- package/build-module/embed/embed-controls.native.js.map +1 -1
- package/build-module/embed/embed-preview.native.js +1 -2
- package/build-module/embed/embed-preview.native.js.map +1 -1
- package/build-module/file/inspector.js +1 -0
- package/build-module/file/inspector.js.map +1 -1
- package/build-module/freeform/edit.js +22 -8
- package/build-module/freeform/edit.js.map +1 -1
- package/build-module/freeform/modal.js +90 -0
- package/build-module/freeform/modal.js.map +1 -0
- package/build-module/gallery/edit.js +39 -15
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.js +3 -16
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/gallery.native.js +1 -2
- package/build-module/gallery/gallery.native.js.map +1 -1
- package/build-module/gallery/shared.js +5 -11
- package/build-module/gallery/shared.js.map +1 -1
- package/build-module/gallery/transforms.js +1 -6
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/gallery/use-get-media.js +1 -1
- package/build-module/gallery/use-get-media.js.map +1 -1
- package/build-module/gallery/use-get-media.native.js +3 -1
- package/build-module/gallery/use-get-media.native.js.map +1 -1
- package/build-module/gallery/v1/edit.js +23 -16
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/gallery/v1/gallery.native.js +1 -2
- package/build-module/gallery/v1/gallery.native.js.map +1 -1
- package/build-module/gallery/v1/shared.js +5 -2
- package/build-module/gallery/v1/shared.js.map +1 -1
- package/build-module/group/edit.js +1 -3
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +3 -1
- package/build-module/group/index.js.map +1 -1
- package/build-module/group/placeholder.js +5 -26
- package/build-module/group/placeholder.js.map +1 -1
- package/build-module/heading/deprecated.js +152 -69
- package/build-module/heading/deprecated.js.map +1 -1
- package/build-module/heading/index.js +1 -2
- package/build-module/heading/index.js.map +1 -1
- package/build-module/heading/transforms.js +1 -2
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/html/index.js +1 -1
- package/build-module/image/edit.js +9 -6
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +2 -1
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +14 -9
- package/build-module/image/image.js.map +1 -1
- package/build-module/index.js +2 -1
- 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/transforms.js +1 -9
- package/build-module/list/transforms.js.map +1 -1
- package/build-module/list/utils.js +5 -2
- package/build-module/list/utils.js.map +1 -1
- package/build-module/list-item/index.js +3 -1
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/list-item/transforms.js +13 -0
- package/build-module/list-item/transforms.js.map +1 -0
- package/build-module/list-item/utils.js +78 -1
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/media-text/edit.js +6 -3
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/missing/edit.native.js +2 -2
- package/build-module/missing/edit.native.js.map +1 -1
- package/build-module/navigation/edit/are-blocks-dirty.js +44 -0
- package/build-module/navigation/edit/are-blocks-dirty.js.map +1 -0
- package/build-module/navigation/edit/index.js +95 -118
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/menu-inspector-controls.js +80 -0
- package/build-module/navigation/edit/menu-inspector-controls.js.map +1 -0
- package/build-module/navigation/edit/navigation-menu-selector.js +2 -4
- package/build-module/navigation/edit/navigation-menu-selector.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +9 -6
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/edit/utils.js +75 -0
- package/build-module/navigation/edit/utils.js.map +1 -1
- package/build-module/navigation/view-modal.js +6 -2
- package/build-module/navigation/view-modal.js.map +1 -1
- package/build-module/navigation-link/edit.js +49 -357
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/link-ui.js +206 -0
- package/build-module/navigation-link/link-ui.js.map +1 -0
- package/build-module/navigation-link/transforms.js +12 -0
- package/build-module/navigation-link/transforms.js.map +1 -1
- package/build-module/navigation-link/update-attributes.js +97 -0
- package/build-module/navigation-link/update-attributes.js.map +1 -0
- package/build-module/navigation-submenu/edit.js +52 -246
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/constants.js +6 -0
- package/build-module/page-list/constants.js.map +1 -0
- package/build-module/page-list/convert-to-links-modal.js +20 -81
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/convert-to-navigation-links.js +66 -0
- package/build-module/page-list/convert-to-navigation-links.js.map +1 -0
- package/build-module/page-list/edit.js +146 -82
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/page-list/index.js +36 -4
- package/build-module/page-list/index.js.map +1 -1
- package/build-module/page-list-item/edit.js +77 -0
- package/build-module/page-list-item/edit.js.map +1 -0
- package/build-module/page-list-item/index.js +68 -0
- package/build-module/page-list-item/index.js.map +1 -0
- package/build-module/page-list-item/init.js +6 -0
- package/build-module/page-list-item/init.js.map +1 -0
- package/build-module/paragraph/index.js +1 -7
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/post-author/edit.js +3 -2
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-featured-image/overlay.js +1 -1
- package/build-module/post-featured-image/overlay.js.map +1 -1
- package/build-module/post-template/index.js +8 -0
- package/build-module/post-template/index.js.map +1 -1
- package/build-module/preformatted/transforms.js +3 -1
- package/build-module/preformatted/transforms.js.map +1 -1
- package/build-module/query/deprecated.js +185 -21
- package/build-module/query/deprecated.js.map +1 -1
- package/build-module/query/edit/index.js +2 -1
- package/build-module/query/edit/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +11 -5
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +99 -35
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query/edit/query-content.js +1 -1
- package/build-module/query/edit/query-content.js.map +1 -1
- package/build-module/query/edit/query-placeholder.js +15 -27
- package/build-module/query/edit/query-placeholder.js.map +1 -1
- package/build-module/query/index.js +0 -8
- package/build-module/query/index.js.map +1 -1
- package/build-module/query/utils.js +69 -8
- package/build-module/query/utils.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 +2 -2
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/edit.native.js +20 -20
- package/build-module/search/edit.native.js.map +1 -1
- package/build-module/search/index.js +8 -1
- package/build-module/search/index.js.map +1 -1
- package/build-module/site-logo/edit.js +17 -8
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-logo/index.js +1 -0
- package/build-module/site-logo/index.js.map +1 -1
- package/build-module/site-title/index.js +1 -0
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-link/edit.js +2 -2
- package/build-module/social-link/edit.js.map +1 -1
- package/build-module/social-link/social-list.js +2 -11
- package/build-module/social-link/social-list.js.map +1 -1
- package/build-module/social-links/edit.js +0 -1
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/table/edit.js +3 -1
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table/index.js +17 -1
- package/build-module/table/index.js.map +1 -1
- package/build-module/table/save.js +4 -2
- package/build-module/table/save.js.map +1 -1
- package/build-module/table/state.js +25 -13
- package/build-module/table/state.js.map +1 -1
- package/build-module/table/transforms.js +3 -2
- package/build-module/table/transforms.js.map +1 -1
- package/build-module/table-of-contents/edit.js +3 -3
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/tag-cloud/edit.js +3 -2
- package/build-module/tag-cloud/edit.js.map +1 -1
- package/build-module/template-part/edit/advanced-controls.js +10 -1
- package/build-module/template-part/edit/advanced-controls.js.map +1 -1
- package/build-module/template-part/edit/import-controls.js +146 -0
- package/build-module/template-part/edit/import-controls.js.map +1 -0
- package/build-module/template-part/edit/index.js +2 -1
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/selection-modal.js +6 -3
- package/build-module/template-part/edit/selection-modal.js.map +1 -1
- package/build-module/template-part/edit/utils/hooks.js +3 -7
- package/build-module/template-part/edit/utils/hooks.js.map +1 -1
- package/build-module/template-part/edit/utils/transformers.js +40 -0
- package/build-module/template-part/edit/utils/transformers.js.map +1 -0
- package/build-module/text-columns/edit.js +1 -0
- package/build-module/text-columns/edit.js.map +1 -1
- package/build-module/utils/transformation-categories.native.js +1 -1
- package/build-module/utils/transformation-categories.native.js.map +1 -1
- package/build-module/video/edit.js +1 -1
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/edit.native.js +1 -2
- package/build-module/video/edit.native.js.map +1 -1
- package/build-style/archives/editor-rtl.css +15 -3
- package/build-style/archives/editor.css +15 -3
- package/build-style/archives/style-rtl.css +15 -3
- package/build-style/archives/style.css +15 -3
- package/build-style/audio/editor-rtl.css +15 -3
- package/build-style/audio/editor.css +15 -3
- package/build-style/audio/style-rtl.css +15 -3
- package/build-style/audio/style.css +15 -3
- package/build-style/audio/theme-rtl.css +15 -3
- package/build-style/audio/theme.css +15 -3
- package/build-style/avatar/editor-rtl.css +15 -3
- package/build-style/avatar/editor.css +15 -3
- package/build-style/avatar/style-rtl.css +15 -3
- package/build-style/avatar/style.css +15 -3
- package/build-style/block/editor-rtl.css +25 -3
- package/build-style/block/editor.css +25 -3
- package/build-style/button/editor-rtl.css +15 -3
- package/build-style/button/editor.css +15 -3
- package/build-style/button/style-rtl.css +15 -3
- package/build-style/button/style.css +15 -3
- package/build-style/buttons/editor-rtl.css +15 -3
- package/build-style/buttons/editor.css +15 -3
- package/build-style/buttons/style-rtl.css +15 -3
- package/build-style/buttons/style.css +15 -3
- package/build-style/calendar/style-rtl.css +15 -3
- package/build-style/calendar/style.css +15 -3
- package/build-style/categories/editor-rtl.css +15 -3
- package/build-style/categories/editor.css +15 -3
- package/build-style/categories/style-rtl.css +15 -3
- package/build-style/categories/style.css +15 -3
- package/build-style/classic-rtl.css +15 -3
- package/build-style/classic.css +15 -3
- package/build-style/code/editor-rtl.css +15 -3
- package/build-style/code/editor.css +15 -3
- package/build-style/code/style-rtl.css +15 -3
- package/build-style/code/style.css +15 -3
- package/build-style/code/theme-rtl.css +15 -3
- package/build-style/code/theme.css +15 -3
- package/build-style/columns/editor-rtl.css +15 -3
- package/build-style/columns/editor.css +15 -3
- package/build-style/columns/style-rtl.css +15 -3
- package/build-style/columns/style.css +15 -3
- package/build-style/comment-author-avatar/editor-rtl.css +15 -3
- package/build-style/comment-author-avatar/editor.css +15 -3
- package/build-style/comment-content/style-rtl.css +15 -3
- package/build-style/comment-content/style.css +15 -3
- package/build-style/comment-template/style-rtl.css +15 -3
- package/build-style/comment-template/style.css +15 -3
- package/build-style/comments/editor-rtl.css +15 -3
- package/build-style/comments/editor.css +15 -3
- package/build-style/comments/style-rtl.css +15 -3
- package/build-style/comments/style.css +15 -3
- package/build-style/comments-pagination/editor-rtl.css +15 -3
- package/build-style/comments-pagination/editor.css +15 -3
- package/build-style/comments-pagination/style-rtl.css +15 -3
- package/build-style/comments-pagination/style.css +15 -3
- package/build-style/comments-pagination-numbers/editor-rtl.css +15 -3
- package/build-style/comments-pagination-numbers/editor.css +15 -3
- package/build-style/comments-title/editor-rtl.css +15 -3
- package/build-style/comments-title/editor.css +15 -3
- package/build-style/common-rtl.css +20 -4
- package/build-style/common.css +20 -4
- package/build-style/cover/editor-rtl.css +15 -3
- package/build-style/cover/editor.css +15 -3
- package/build-style/cover/style-rtl.css +17 -4
- package/build-style/cover/style.css +17 -4
- package/build-style/editor-elements-rtl.css +15 -3
- package/build-style/editor-elements.css +15 -3
- package/build-style/editor-rtl.css +46 -29
- package/build-style/editor.css +46 -29
- package/build-style/elements-rtl.css +15 -3
- package/build-style/elements.css +15 -3
- package/build-style/embed/editor-rtl.css +15 -3
- package/build-style/embed/editor.css +15 -3
- package/build-style/embed/style-rtl.css +15 -3
- package/build-style/embed/style.css +15 -3
- package/build-style/embed/theme-rtl.css +15 -3
- package/build-style/embed/theme.css +15 -3
- package/build-style/file/editor-rtl.css +15 -3
- package/build-style/file/editor.css +15 -3
- package/build-style/file/style-rtl.css +15 -3
- package/build-style/file/style.css +15 -3
- package/build-style/freeform/editor-rtl.css +15 -3
- package/build-style/freeform/editor.css +15 -3
- package/build-style/gallery/editor-rtl.css +16 -4
- package/build-style/gallery/editor.css +16 -4
- package/build-style/gallery/style-rtl.css +19 -5
- package/build-style/gallery/style.css +19 -5
- package/build-style/gallery/theme-rtl.css +15 -3
- package/build-style/gallery/theme.css +15 -3
- package/build-style/group/editor-rtl.css +15 -3
- package/build-style/group/editor.css +15 -3
- package/build-style/group/style-rtl.css +15 -3
- package/build-style/group/style.css +15 -3
- package/build-style/group/theme-rtl.css +15 -3
- package/build-style/group/theme.css +15 -3
- package/build-style/heading/style-rtl.css +15 -3
- package/build-style/heading/style.css +15 -3
- package/build-style/html/editor-rtl.css +15 -3
- package/build-style/html/editor.css +15 -3
- package/build-style/image/editor-rtl.css +15 -12
- package/build-style/image/editor.css +15 -12
- package/build-style/image/style-rtl.css +15 -3
- package/build-style/image/style.css +15 -3
- package/build-style/image/theme-rtl.css +15 -3
- package/build-style/image/theme.css +15 -3
- package/build-style/latest-comments/style-rtl.css +15 -3
- package/build-style/latest-comments/style.css +15 -3
- package/build-style/latest-posts/editor-rtl.css +15 -3
- package/build-style/latest-posts/editor.css +15 -3
- package/build-style/latest-posts/style-rtl.css +15 -3
- package/build-style/latest-posts/style.css +15 -3
- package/build-style/list/style-rtl.css +15 -3
- package/build-style/list/style.css +15 -3
- package/build-style/media-text/editor-rtl.css +15 -3
- package/build-style/media-text/editor.css +15 -3
- package/build-style/media-text/style-rtl.css +15 -3
- package/build-style/media-text/style.css +15 -3
- package/build-style/more/editor-rtl.css +15 -3
- package/build-style/more/editor.css +15 -3
- package/build-style/navigation/editor-rtl.css +15 -9
- package/build-style/navigation/editor.css +15 -9
- package/build-style/navigation/style-rtl.css +15 -4
- package/build-style/navigation/style.css +15 -4
- package/build-style/navigation-link/editor-rtl.css +15 -3
- package/build-style/navigation-link/editor.css +15 -3
- package/build-style/navigation-link/style-rtl.css +15 -3
- package/build-style/navigation-link/style.css +15 -3
- package/build-style/navigation-submenu/editor-rtl.css +15 -3
- package/build-style/navigation-submenu/editor.css +15 -3
- package/build-style/nextpage/editor-rtl.css +15 -3
- package/build-style/nextpage/editor.css +15 -3
- package/build-style/page-list/editor-rtl.css +19 -3
- package/build-style/page-list/editor.css +19 -3
- package/build-style/page-list/style-rtl.css +15 -3
- package/build-style/page-list/style.css +15 -3
- package/build-style/paragraph/editor-rtl.css +15 -3
- package/build-style/paragraph/editor.css +15 -3
- package/build-style/paragraph/style-rtl.css +15 -3
- package/build-style/paragraph/style.css +15 -3
- package/build-style/post-author/style-rtl.css +15 -3
- package/build-style/post-author/style.css +15 -3
- package/build-style/post-comments-form/editor-rtl.css +15 -3
- package/build-style/post-comments-form/editor.css +15 -3
- package/build-style/post-comments-form/style-rtl.css +15 -3
- package/build-style/post-comments-form/style.css +15 -3
- package/build-style/post-date/style-rtl.css +15 -3
- package/build-style/post-date/style.css +15 -3
- package/build-style/post-excerpt/editor-rtl.css +15 -3
- package/build-style/post-excerpt/editor.css +15 -3
- package/build-style/post-excerpt/style-rtl.css +15 -3
- package/build-style/post-excerpt/style.css +15 -3
- package/build-style/post-featured-image/editor-rtl.css +15 -3
- package/build-style/post-featured-image/editor.css +15 -3
- package/build-style/post-featured-image/style-rtl.css +15 -3
- package/build-style/post-featured-image/style.css +15 -3
- package/build-style/post-navigation-link/style-rtl.css +15 -3
- package/build-style/post-navigation-link/style.css +15 -3
- package/build-style/post-template/editor-rtl.css +15 -3
- package/build-style/post-template/editor.css +15 -3
- package/build-style/post-template/style-rtl.css +15 -3
- package/build-style/post-template/style.css +15 -3
- package/build-style/post-terms/style-rtl.css +15 -3
- package/build-style/post-terms/style.css +15 -3
- package/build-style/post-title/style-rtl.css +15 -3
- package/build-style/post-title/style.css +15 -3
- package/build-style/preformatted/style-rtl.css +15 -3
- package/build-style/preformatted/style.css +15 -3
- package/build-style/pullquote/editor-rtl.css +15 -3
- package/build-style/pullquote/editor.css +15 -3
- package/build-style/pullquote/style-rtl.css +15 -3
- package/build-style/pullquote/style.css +15 -3
- package/build-style/pullquote/theme-rtl.css +15 -3
- package/build-style/pullquote/theme.css +15 -3
- package/build-style/query/editor-rtl.css +15 -3
- package/build-style/query/editor.css +15 -3
- package/build-style/query-pagination/editor-rtl.css +15 -3
- package/build-style/query-pagination/editor.css +15 -3
- package/build-style/query-pagination/style-rtl.css +15 -3
- package/build-style/query-pagination/style.css +15 -3
- package/build-style/query-pagination-numbers/editor-rtl.css +15 -3
- package/build-style/query-pagination-numbers/editor.css +15 -3
- package/build-style/query-title/style-rtl.css +15 -3
- package/build-style/query-title/style.css +15 -3
- package/build-style/quote/style-rtl.css +15 -3
- package/build-style/quote/style.css +15 -3
- package/build-style/quote/theme-rtl.css +15 -3
- package/build-style/quote/theme.css +15 -3
- package/build-style/read-more/style-rtl.css +15 -3
- package/build-style/read-more/style.css +15 -3
- package/build-style/reset-rtl.css +15 -3
- package/build-style/reset.css +15 -3
- package/build-style/rss/editor-rtl.css +15 -3
- package/build-style/rss/editor.css +15 -3
- package/build-style/rss/style-rtl.css +15 -3
- package/build-style/rss/style.css +15 -3
- package/build-style/search/editor-rtl.css +15 -3
- package/build-style/search/editor.css +15 -3
- package/build-style/search/style-rtl.css +15 -3
- package/build-style/search/style.css +15 -3
- package/build-style/search/theme-rtl.css +15 -3
- package/build-style/search/theme.css +15 -3
- package/build-style/separator/editor-rtl.css +15 -3
- package/build-style/separator/editor.css +15 -3
- package/build-style/separator/style-rtl.css +15 -3
- package/build-style/separator/style.css +15 -3
- package/build-style/separator/theme-rtl.css +15 -3
- package/build-style/separator/theme.css +15 -3
- package/build-style/shortcode/editor-rtl.css +16 -4
- package/build-style/shortcode/editor.css +16 -4
- package/build-style/site-logo/editor-rtl.css +15 -3
- package/build-style/site-logo/editor.css +15 -3
- package/build-style/site-logo/style-rtl.css +15 -3
- package/build-style/site-logo/style.css +15 -3
- package/build-style/site-tagline/editor-rtl.css +15 -3
- package/build-style/site-tagline/editor.css +15 -3
- package/build-style/site-title/editor-rtl.css +15 -3
- package/build-style/site-title/editor.css +15 -3
- package/build-style/site-title/style-rtl.css +15 -3
- package/build-style/site-title/style.css +15 -3
- package/build-style/social-link/editor-rtl.css +15 -3
- package/build-style/social-link/editor.css +15 -3
- package/build-style/social-links/editor-rtl.css +15 -3
- package/build-style/social-links/editor.css +15 -3
- package/build-style/social-links/style-rtl.css +15 -3
- package/build-style/social-links/style.css +15 -3
- package/build-style/spacer/editor-rtl.css +15 -3
- package/build-style/spacer/editor.css +15 -3
- package/build-style/spacer/style-rtl.css +15 -3
- package/build-style/spacer/style.css +15 -3
- package/build-style/style-rtl.css +36 -10
- package/build-style/style.css +36 -10
- package/build-style/table/editor-rtl.css +15 -11
- package/build-style/table/editor.css +15 -11
- package/build-style/table/style-rtl.css +21 -3
- package/build-style/table/style.css +21 -3
- package/build-style/table/theme-rtl.css +15 -9
- package/build-style/table/theme.css +15 -9
- package/build-style/tag-cloud/style-rtl.css +15 -3
- package/build-style/tag-cloud/style.css +15 -3
- package/build-style/template-part/editor-rtl.css +30 -4
- package/build-style/template-part/editor.css +30 -4
- package/build-style/template-part/theme-rtl.css +15 -3
- package/build-style/template-part/theme.css +15 -3
- package/build-style/text-columns/editor-rtl.css +15 -3
- package/build-style/text-columns/editor.css +15 -3
- package/build-style/text-columns/style-rtl.css +15 -3
- package/build-style/text-columns/style.css +15 -3
- package/build-style/theme-rtl.css +15 -9
- package/build-style/theme.css +15 -9
- package/build-style/verse/style-rtl.css +19 -4
- package/build-style/verse/style.css +19 -4
- package/build-style/video/editor-rtl.css +15 -3
- package/build-style/video/editor.css +15 -3
- package/build-style/video/style-rtl.css +17 -4
- package/build-style/video/style.css +17 -4
- package/build-style/video/theme-rtl.css +15 -3
- package/build-style/video/theme.css +15 -3
- package/package.json +32 -30
- package/src/audio/edit.native.js +1 -2
- package/src/audio/index.js +1 -0
- package/src/avatar/edit.js +1 -0
- package/src/avatar/user-control.js +1 -0
- package/src/block/block.json +1 -2
- package/src/block/edit.js +14 -3
- package/src/block/edit.native.js +24 -12
- package/src/block/editor.scss +17 -0
- package/src/block/index.php +1 -2
- package/src/block/test/edit.native.js +28 -32
- package/src/button/edit.native.js +1 -0
- package/src/buttons/test/edit.native.js +40 -51
- package/src/categories/edit.js +1 -1
- package/src/code/transforms.js +3 -1
- package/src/columns/edit.js +1 -0
- package/src/columns/edit.native.js +18 -26
- package/src/comment-author-avatar/edit.js +1 -0
- package/src/comments/index.php +0 -1
- package/src/cover/edit/inspector-controls.js +6 -4
- package/src/cover/edit.native.js +32 -19
- package/src/cover/test/edit.native.js +73 -126
- package/src/embed/embed-controls.native.js +1 -0
- package/src/embed/embed-preview.native.js +1 -2
- package/src/embed/test/index.native.js +237 -231
- package/src/file/inspector.js +1 -0
- package/src/file/test/__snapshots__/edit.native.js.snap +2 -6
- package/src/freeform/edit.js +48 -29
- package/src/freeform/modal.js +111 -0
- package/src/gallery/edit.js +32 -7
- package/src/gallery/gallery.js +3 -13
- package/src/gallery/gallery.native.js +1 -2
- package/src/gallery/shared.js +7 -11
- package/src/gallery/transforms.js +1 -6
- package/src/gallery/use-get-media.js +1 -1
- package/src/gallery/use-get-media.native.js +2 -1
- package/src/gallery/v1/edit.js +8 -7
- package/src/gallery/v1/gallery.native.js +1 -2
- package/src/gallery/v1/shared.js +7 -2
- package/src/group/block.json +3 -1
- package/src/group/edit.js +2 -6
- package/src/group/placeholder.js +6 -25
- package/src/group/test/__snapshots__/edit.native.js.snap +1 -1
- package/src/heading/block.json +1 -2
- package/src/heading/deprecated.js +209 -136
- package/src/heading/index.php +52 -0
- package/src/heading/test/__snapshots__/index.native.js.snap +7 -0
- package/src/heading/test/index.native.js +44 -0
- package/src/home-link/index.php +1 -1
- package/src/html/block.json +1 -1
- package/src/image/edit.js +7 -2
- package/src/image/edit.native.js +2 -1
- package/src/image/editor.scss +0 -11
- package/src/image/image.js +14 -8
- package/src/image/test/edit.native.js +14 -10
- package/src/index.js +2 -0
- package/src/latest-comments/edit.js +1 -0
- package/src/latest-posts/edit.js +2 -0
- package/src/latest-posts/test/__snapshots__/edit.native.js.snap +3 -0
- package/src/latest-posts/test/edit.native.js +49 -0
- package/src/list/test/edit.native.js +53 -45
- package/src/list/transforms.js +0 -11
- package/src/list/utils.js +6 -2
- package/src/list-item/index.js +2 -0
- package/src/list-item/transforms.js +17 -0
- package/src/list-item/utils.js +10 -1
- package/src/media-text/edit.js +6 -3
- package/src/missing/edit.native.js +13 -6
- package/src/missing/test/edit-integration.native.js +10 -12
- package/src/more/test/__snapshots__/edit.native.js.snap +7 -0
- package/src/more/test/edit.native.js +41 -0
- package/src/navigation/edit/are-blocks-dirty.js +51 -0
- package/src/navigation/edit/index.js +229 -298
- package/src/navigation/edit/menu-inspector-controls.js +119 -0
- package/src/navigation/edit/navigation-menu-selector.js +6 -7
- package/src/navigation/edit/test/are-blocks-dirty.js +121 -0
- package/src/navigation/edit/unsaved-inner-blocks.js +12 -7
- package/src/navigation/edit/utils.js +82 -0
- package/src/navigation/editor.scss +0 -7
- package/src/navigation/index.php +89 -10
- package/src/navigation/style.scss +0 -1
- package/src/navigation/view-modal.js +11 -1
- package/src/navigation-link/edit.js +62 -386
- package/src/navigation-link/index.php +64 -0
- package/src/navigation-link/link-ui.js +213 -0
- package/src/navigation-link/test/edit.js +23 -82
- package/src/navigation-link/transforms.js +14 -0
- package/src/navigation-link/update-attributes.js +99 -0
- package/src/navigation-submenu/edit.js +85 -276
- package/src/navigation-submenu/index.php +72 -0
- package/src/page-list/block.json +24 -2
- package/src/page-list/constants.js +8 -0
- package/src/page-list/convert-to-links-modal.js +19 -76
- package/src/page-list/convert-to-navigation-links.js +60 -0
- package/src/page-list/edit.js +187 -118
- package/src/page-list/editor.scss +4 -0
- package/src/page-list/index.js +8 -2
- package/src/page-list/index.php +18 -10
- package/src/page-list/test/convert-to-links-modal.js +28 -34
- package/src/page-list-item/block.json +51 -0
- package/src/page-list-item/edit.js +102 -0
- package/src/page-list-item/index.js +24 -0
- package/src/page-list-item/init.js +6 -0
- package/src/paragraph/index.js +0 -6
- package/src/post-author/edit.js +3 -2
- package/src/post-content/index.php +1 -2
- package/src/post-featured-image/index.php +7 -2
- package/src/post-featured-image/overlay.js +1 -1
- package/src/post-template/block.json +8 -0
- package/src/preformatted/transforms.js +4 -1
- package/src/query/block.json +0 -8
- package/src/query/deprecated.js +257 -86
- package/src/query/edit/index.js +1 -0
- package/src/query/edit/inspector-controls/index.js +50 -38
- package/src/query/edit/inspector-controls/taxonomy-controls.js +102 -38
- package/src/query/edit/query-content.js +2 -1
- package/src/query/edit/query-placeholder.js +14 -25
- package/src/query/utils.js +59 -1
- package/src/rss/edit.js +3 -0
- package/src/search/edit.js +2 -2
- package/src/search/edit.native.js +31 -27
- package/src/search/index.js +5 -1
- package/src/separator/test/__snapshots__/edit.native.js.snap +7 -0
- package/src/separator/test/edit.native.js +41 -0
- package/src/shortcode/test/edit.native.js +15 -18
- package/src/site-logo/edit.js +13 -5
- package/src/site-logo/index.js +1 -0
- package/src/site-title/index.js +1 -0
- package/src/social-link/edit.js +3 -3
- package/src/social-link/social-list.js +2 -7
- package/src/social-link/test/index.native.js +10 -16
- package/src/social-links/edit.js +0 -1
- package/src/social-links/test/edit.native.js +4 -3
- package/src/spacer/test/index.native.js +39 -36
- package/src/table/block.json +15 -0
- package/src/table/edit.js +2 -1
- package/src/table/editor.scss +0 -4
- package/src/table/index.js +1 -0
- package/src/table/save.js +5 -1
- package/src/table/state.js +22 -7
- package/src/table/style.scss +8 -0
- package/src/table/theme.scss +0 -8
- package/src/table/transforms.js +2 -1
- package/src/table-of-contents/edit.js +3 -3
- package/src/tag-cloud/edit.js +3 -2
- package/src/template-part/edit/advanced-controls.js +12 -0
- package/src/template-part/edit/import-controls.js +180 -0
- package/src/template-part/edit/index.js +1 -0
- package/src/template-part/edit/selection-modal.js +4 -3
- package/src/template-part/edit/utils/hooks.js +7 -3
- package/src/template-part/edit/utils/transformers.js +37 -0
- package/src/template-part/editor.scss +20 -2
- package/src/template-part/index.php +1 -2
- package/src/text-columns/edit.js +1 -0
- package/src/utils/transformation-categories.native.js +1 -0
- package/src/verse/style.scss +4 -1
- package/src/verse/test/__snapshots__/edit.native.js.snap +13 -0
- package/src/verse/test/edit.native.js +40 -33
- package/src/video/edit.js +1 -1
- package/src/video/edit.native.js +1 -2
- package/test/babel-plugin.js +35 -35
- package/tsconfig.tsbuildinfo +1 -1
- package/build/query/constants.js +0 -16
- package/build/query/constants.js.map +0 -1
- package/build-module/query/constants.js +0 -7
- package/build-module/query/constants.js.map +0 -1
- package/src/query/constants.js +0 -7
|
@@ -4,7 +4,7 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
4
4
|
/**
|
|
5
5
|
* External dependencies
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { get, isEmpty, map } from 'lodash';
|
|
8
8
|
/**
|
|
9
9
|
* WordPress dependencies
|
|
10
10
|
*/
|
|
@@ -181,7 +181,7 @@ function GalleryEdit(props) {
|
|
|
181
181
|
|
|
182
182
|
function onRemoveImage(index) {
|
|
183
183
|
return () => {
|
|
184
|
-
const newImages = filter(
|
|
184
|
+
const newImages = images.filter((img, i) => index !== i);
|
|
185
185
|
setSelectedImage();
|
|
186
186
|
setAttributes({
|
|
187
187
|
images: newImages,
|
|
@@ -195,8 +195,11 @@ function GalleryEdit(props) {
|
|
|
195
195
|
// string, so ensure comparison works correctly by converting the
|
|
196
196
|
// newImage.id to a string.
|
|
197
197
|
const newImageId = newImage.id.toString();
|
|
198
|
-
const currentImage = find(
|
|
199
|
-
|
|
198
|
+
const currentImage = images.find(_ref2 => {
|
|
199
|
+
let {
|
|
200
|
+
id
|
|
201
|
+
} = _ref2;
|
|
202
|
+
return id === newImageId;
|
|
200
203
|
});
|
|
201
204
|
const currentImageCaption = currentImage ? currentImage.caption : newImage.caption;
|
|
202
205
|
|
|
@@ -204,8 +207,11 @@ function GalleryEdit(props) {
|
|
|
204
207
|
return currentImageCaption;
|
|
205
208
|
}
|
|
206
209
|
|
|
207
|
-
const attachment = find(
|
|
208
|
-
|
|
210
|
+
const attachment = attachmentCaptions.find(_ref3 => {
|
|
211
|
+
let {
|
|
212
|
+
id
|
|
213
|
+
} = _ref3;
|
|
214
|
+
return id === newImageId;
|
|
209
215
|
}); // If the attachment caption is updated.
|
|
210
216
|
|
|
211
217
|
if (attachment && attachment.caption !== newImage.caption) {
|
|
@@ -275,16 +281,16 @@ function GalleryEdit(props) {
|
|
|
275
281
|
|
|
276
282
|
function getImagesSizeOptions() {
|
|
277
283
|
const resizedImageSizes = Object.values(resizedImages);
|
|
278
|
-
return map(filter(
|
|
284
|
+
return map(imageSizes.filter(_ref4 => {
|
|
279
285
|
let {
|
|
280
286
|
slug
|
|
281
|
-
} =
|
|
287
|
+
} = _ref4;
|
|
282
288
|
return resizedImageSizes.some(sizes => sizes[slug]);
|
|
283
|
-
}),
|
|
289
|
+
}), _ref5 => {
|
|
284
290
|
let {
|
|
285
291
|
name,
|
|
286
292
|
slug
|
|
287
|
-
} =
|
|
293
|
+
} = _ref5;
|
|
288
294
|
return {
|
|
289
295
|
value: slug,
|
|
290
296
|
label: name
|
|
@@ -312,22 +318,22 @@ function GalleryEdit(props) {
|
|
|
312
318
|
}
|
|
313
319
|
|
|
314
320
|
useEffect(() => {
|
|
315
|
-
if (Platform.OS === 'web' && images && images.length > 0 && images.every(
|
|
321
|
+
if (Platform.OS === 'web' && images && images.length > 0 && images.every(_ref6 => {
|
|
316
322
|
let {
|
|
317
323
|
url
|
|
318
|
-
} =
|
|
324
|
+
} = _ref6;
|
|
319
325
|
return isBlobURL(url);
|
|
320
326
|
})) {
|
|
321
|
-
const filesList = map(images,
|
|
327
|
+
const filesList = map(images, _ref7 => {
|
|
322
328
|
let {
|
|
323
329
|
url
|
|
324
|
-
} =
|
|
330
|
+
} = _ref7;
|
|
325
331
|
return getBlobByURL(url);
|
|
326
332
|
});
|
|
327
|
-
images.forEach(
|
|
333
|
+
images.forEach(_ref8 => {
|
|
328
334
|
let {
|
|
329
335
|
url
|
|
330
|
-
} =
|
|
336
|
+
} = _ref8;
|
|
331
337
|
return revokeBlobURL(url);
|
|
332
338
|
});
|
|
333
339
|
mediaUpload({
|
|
@@ -388,6 +394,7 @@ function GalleryEdit(props) {
|
|
|
388
394
|
return createElement(Fragment, null, createElement(InspectorControls, null, createElement(PanelBody, {
|
|
389
395
|
title: __('Settings')
|
|
390
396
|
}, images.length > 1 && createElement(RangeControl, _extends({
|
|
397
|
+
__nextHasNoMarginBottom: true,
|
|
391
398
|
label: __('Columns'),
|
|
392
399
|
value: columns,
|
|
393
400
|
onChange: setColumnsNumber,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/gallery/v1/edit.js"],"names":["filter","find","get","isEmpty","map","compose","PanelBody","SelectControl","ToggleControl","withNotices","RangeControl","MediaPlaceholder","InspectorControls","useBlockProps","store","blockEditorStore","Platform","useEffect","useState","useMemo","__","getBlobByURL","isBlobURL","revokeBlobURL","useDispatch","useSelect","withViewportMatch","View","coreStore","sharedIcon","pickRelevantMediaFiles","defaultColumnsNumberV1","Gallery","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_MEDIA","LINK_DESTINATION_NONE","MAX_COLUMNS","linkOptions","value","label","ALLOWED_MEDIA_TYPES","PLACEHOLDER_TEXT","select","web","native","MOBILE_CONTROL_PROPS_RANGE_CONTROL","type","GalleryEdit","props","attributes","clientId","isSelected","noticeUI","noticeOperations","onFocus","columns","imageCrop","images","linkTo","sizeSlug","selectedImage","setSelectedImage","attachmentCaptions","setAttachmentCaptions","__unstableMarkNextChangeAsNotPersistent","imageSizes","mediaUpload","getMedia","wasBlockJustInserted","settings","getSettings","resizedImages","ids","reduce","currentResizedImages","id","image","sizes","currentSizes","size","defaultUrl","slug","mediaDetailsUrl","parseInt","onFocusGalleryCaption","setAttributes","newAttrs","Error","onSelectImage","index","onDeselectImage","onMove","oldIndex","newIndex","newImages","splice","onMoveForward","length","onMoveBackward","onRemoveImage","img","i","Math","min","selectCaption","newImage","newImageId","toString","currentImage","currentImageCaption","caption","attachment","onSelectImages","onUploadError","message","removeAllNotices","createErrorNotice","setLinkTo","setColumnsNumber","toggleImageCrop","getImageCropHelp","checked","setImageAttributes","newAttributes","slice","getImagesSizeOptions","resizedImageSizes","Object","values","some","name","updateImagesSize","newSizeSlug","updatedImages","url","OS","every","filesList","forEach","onFileChange","allowedTypes","window","wp","media","view","defaultProps","link","hasImages","hasImageIds","mediaPlaceholder","title","instructions","undefined","blockProps","imageSizeOptions","shouldShowSizeOptions","isNarrow"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,MAAT,EAAiBC,IAAjB,EAAuBC,GAAvB,EAA4BC,OAA5B,EAAqCC,GAArC,QAAgD,QAAhD;AAEA;AACA;AACA;;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SACCC,SADD,EAECC,aAFD,EAGCC,aAHD,EAICC,WAJD,EAKCC,YALD,QAMO,uBANP;AAOA,SACCC,gBADD,EAECC,iBAFD,EAGCC,aAHD,EAICC,KAAK,IAAIC,gBAJV,QAKO,yBALP;AAMA,SAASC,QAA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AK,EAAGvI,EAAE,CAAE,YAAF,CADX;AAEC,IAAA,KAAK,EAAGuC,QAFT;AAGC,IAAA,OAAO,EAAG+F,gBAHX;AAIC,IAAA,QAAQ,EAAGvB,gBAJZ;AAKC,IAAA,gBAAgB,EAAG;AALpB,IA1BF,CADD,CADD,EAsCG/E,QAtCH,EAuCC,cAAC,OAAD,eACMJ,KADN;AAEC,IAAA,aAAa,EAAGY,aAFjB;AAGC,IAAA,gBAAgB,EAAGyF,gBAHpB;AAIC,IAAA,cAAc,EAAGnD,cAJlB;AAKC,IAAA,aAAa,EAAGF,aALjB;AAMC,IAAA,aAAa,EAAGG,aANjB;AAOC,IAAA,aAAa,EAAGX,aAPjB;AAQC,IAAA,eAAe,EAAGE,eARnB;AASC,IAAA,oBAAoB,EAAGgC,kBATxB;AAUC,IAAA,UAAU,EAAG+B,UAVd,CAWC;AAXD;AAYC,IAAA,qBAAqB,EAAGrE;AAZzB,KAvCD,CADD;AAwDA;;AAED,eAAe/E,OAAO,CAAE,CACvBI,WADuB,EAEvBiB,iBAAiB,CAAE;AAAEkI,EAAAA,QAAQ,EAAE;AAAZ,CAAF,CAFM,CAAF,CAAP,CAGV7G,WAHU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { filter, find, get, isEmpty, map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport {\n\tPanelBody,\n\tSelectControl,\n\tToggleControl,\n\twithNotices,\n\tRangeControl,\n} from '@wordpress/components';\nimport {\n\tMediaPlaceholder,\n\tInspectorControls,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Platform, useEffect, useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { withViewportMatch } from '@wordpress/viewport';\nimport { View } from '@wordpress/primitives';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { sharedIcon } from '../shared-icon';\nimport { pickRelevantMediaFiles } from './shared';\nimport { defaultColumnsNumberV1 } from '../deprecated';\nimport Gallery from './gallery';\nimport {\n\tLINK_DESTINATION_ATTACHMENT,\n\tLINK_DESTINATION_MEDIA,\n\tLINK_DESTINATION_NONE,\n} from './constants';\n\nconst MAX_COLUMNS = 8;\nconst linkOptions = [\n\t{ value: LINK_DESTINATION_ATTACHMENT, label: __( 'Attachment Page' ) },\n\t{ value: LINK_DESTINATION_MEDIA, label: __( 'Media File' ) },\n\t{ value: LINK_DESTINATION_NONE, label: __( 'None' ) },\n];\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nconst PLACEHOLDER_TEXT = Platform.select( {\n\tweb: __(\n\t\t'Drag images, upload new ones or select files from your library.'\n\t),\n\tnative: __( 'ADD MEDIA' ),\n} );\n\nconst MOBILE_CONTROL_PROPS_RANGE_CONTROL = Platform.select( {\n\tweb: {},\n\tnative: { type: 'stepper' },\n} );\n\nfunction GalleryEdit( props ) {\n\tconst {\n\t\tattributes,\n\t\tclientId,\n\t\tisSelected,\n\t\tnoticeUI,\n\t\tnoticeOperations,\n\t\tonFocus,\n\t} = props;\n\tconst {\n\t\tcolumns = defaultColumnsNumberV1( attributes ),\n\t\timageCrop,\n\t\timages,\n\t\tlinkTo,\n\t\tsizeSlug,\n\t} = attributes;\n\tconst [ selectedImage, setSelectedImage ] = useState();\n\tconst [ attachmentCaptions, setAttachmentCaptions ] = useState();\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { imageSizes, mediaUpload, getMedia, wasBlockJustInserted } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\n\t\t\treturn {\n\t\t\t\timageSizes: settings.imageSizes,\n\t\t\t\tmediaUpload: settings.mediaUpload,\n\t\t\t\tgetMedia: select( coreStore ).getMedia,\n\t\t\t\twasBlockJustInserted: select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).wasBlockJustInserted( clientId, 'inserter_menu' ),\n\t\t\t};\n\t\t} );\n\n\tconst resizedImages = useMemo( () => {\n\t\tif ( isSelected ) {\n\t\t\treturn ( attributes.ids ?? [] ).reduce(\n\t\t\t\t( currentResizedImages, id ) => {\n\t\t\t\t\tif ( ! id ) {\n\t\t\t\t\t\treturn currentResizedImages;\n\t\t\t\t\t}\n\t\t\t\t\tconst image = getMedia( id );\n\t\t\t\t\tconst sizes = imageSizes.reduce( ( currentSizes, size ) => {\n\t\t\t\t\t\tconst defaultUrl = get( image, [\n\t\t\t\t\t\t\t'sizes',\n\t\t\t\t\t\t\tsize.slug,\n\t\t\t\t\t\t\t'url',\n\t\t\t\t\t\t] );\n\t\t\t\t\t\tconst mediaDetailsUrl = get( image, [\n\t\t\t\t\t\t\t'media_details',\n\t\t\t\t\t\t\t'sizes',\n\t\t\t\t\t\t\tsize.slug,\n\t\t\t\t\t\t\t'source_url',\n\t\t\t\t\t\t] );\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...currentSizes,\n\t\t\t\t\t\t\t[ size.slug ]: defaultUrl || mediaDetailsUrl,\n\t\t\t\t\t\t};\n\t\t\t\t\t}, {} );\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...currentResizedImages,\n\t\t\t\t\t\t[ parseInt( id, 10 ) ]: sizes,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t}\n\t\treturn {};\n\t}, [ isSelected, attributes.ids, imageSizes ] );\n\n\tfunction onFocusGalleryCaption() {\n\t\tsetSelectedImage();\n\t}\n\n\tfunction setAttributes( newAttrs ) {\n\t\tif ( newAttrs.ids ) {\n\t\t\tthrow new Error(\n\t\t\t\t'The \"ids\" attribute should not be changed directly. It is managed automatically when \"images\" attribute changes'\n\t\t\t);\n\t\t}\n\n\t\tif ( newAttrs.images ) {\n\t\t\tnewAttrs = {\n\t\t\t\t...newAttrs,\n\t\t\t\t// Unlike images[ n ].id which is a string, always ensure the\n\t\t\t\t// ids array contains numbers as per its attribute type.\n\t\t\t\tids: map( newAttrs.images, ( { id } ) => parseInt( id, 10 ) ),\n\t\t\t};\n\t\t}\n\n\t\tprops.setAttributes( newAttrs );\n\t}\n\n\tfunction onSelectImage( index ) {\n\t\treturn () => {\n\t\t\tsetSelectedImage( index );\n\t\t};\n\t}\n\n\tfunction onDeselectImage() {\n\t\treturn () => {\n\t\t\tsetSelectedImage();\n\t\t};\n\t}\n\n\tfunction onMove( oldIndex, newIndex ) {\n\t\tconst newImages = [ ...images ];\n\t\tnewImages.splice( newIndex, 1, images[ oldIndex ] );\n\t\tnewImages.splice( oldIndex, 1, images[ newIndex ] );\n\t\tsetSelectedImage( newIndex );\n\t\tsetAttributes( { images: newImages } );\n\t}\n\n\tfunction onMoveForward( oldIndex ) {\n\t\treturn () => {\n\t\t\tif ( oldIndex === images.length - 1 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonMove( oldIndex, oldIndex + 1 );\n\t\t};\n\t}\n\n\tfunction onMoveBackward( oldIndex ) {\n\t\treturn () => {\n\t\t\tif ( oldIndex === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonMove( oldIndex, oldIndex - 1 );\n\t\t};\n\t}\n\n\tfunction onRemoveImage( index ) {\n\t\treturn () => {\n\t\t\tconst newImages = filter( images, ( img, i ) => index !== i );\n\t\t\tsetSelectedImage();\n\t\t\tsetAttributes( {\n\t\t\t\timages: newImages,\n\t\t\t\tcolumns: attributes.columns\n\t\t\t\t\t? Math.min( newImages.length, attributes.columns )\n\t\t\t\t\t: attributes.columns,\n\t\t\t} );\n\t\t};\n\t}\n\n\tfunction selectCaption( newImage ) {\n\t\t// The image id in both the images and attachmentCaptions arrays is a\n\t\t// string, so ensure comparison works correctly by converting the\n\t\t// newImage.id to a string.\n\t\tconst newImageId = newImage.id.toString();\n\t\tconst currentImage = find( images, { id: newImageId } );\n\t\tconst currentImageCaption = currentImage\n\t\t\t? currentImage.caption\n\t\t\t: newImage.caption;\n\n\t\tif ( ! attachmentCaptions ) {\n\t\t\treturn currentImageCaption;\n\t\t}\n\n\t\tconst attachment = find( attachmentCaptions, {\n\t\t\tid: newImageId,\n\t\t} );\n\n\t\t// If the attachment caption is updated.\n\t\tif ( attachment && attachment.caption !== newImage.caption ) {\n\t\t\treturn newImage.caption;\n\t\t}\n\n\t\treturn currentImageCaption;\n\t}\n\n\tfunction onSelectImages( newImages ) {\n\t\tsetAttachmentCaptions(\n\t\t\tnewImages.map( ( newImage ) => ( {\n\t\t\t\t// Store the attachmentCaption id as a string for consistency\n\t\t\t\t// with the type of the id in the images attribute.\n\t\t\t\tid: newImage.id.toString(),\n\t\t\t\tcaption: newImage.caption,\n\t\t\t} ) )\n\t\t);\n\t\tsetAttributes( {\n\t\t\timages: newImages.map( ( newImage ) => ( {\n\t\t\t\t...pickRelevantMediaFiles( newImage, sizeSlug ),\n\t\t\t\tcaption: selectCaption( newImage, images, attachmentCaptions ),\n\t\t\t\t// The id value is stored in a data attribute, so when the\n\t\t\t\t// block is parsed it's converted to a string. Converting\n\t\t\t\t// to a string here ensures it's type is consistent.\n\t\t\t\tid: newImage.id.toString(),\n\t\t\t} ) ),\n\t\t\tcolumns: attributes.columns\n\t\t\t\t? Math.min( newImages.length, attributes.columns )\n\t\t\t\t: attributes.columns,\n\t\t} );\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tnoticeOperations.removeAllNotices();\n\t\tnoticeOperations.createErrorNotice( message );\n\t}\n\n\tfunction setLinkTo( value ) {\n\t\tsetAttributes( { linkTo: value } );\n\t}\n\n\tfunction setColumnsNumber( value ) {\n\t\tsetAttributes( { columns: value } );\n\t}\n\n\tfunction toggleImageCrop() {\n\t\tsetAttributes( { imageCrop: ! imageCrop } );\n\t}\n\n\tfunction getImageCropHelp( checked ) {\n\t\treturn checked\n\t\t\t? __( 'Thumbnails are cropped to align.' )\n\t\t\t: __( 'Thumbnails are not cropped.' );\n\t}\n\n\tfunction setImageAttributes( index, newAttributes ) {\n\t\tif ( ! images[ index ] ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\timages: [\n\t\t\t\t...images.slice( 0, index ),\n\t\t\t\t{\n\t\t\t\t\t...images[ index ],\n\t\t\t\t\t...newAttributes,\n\t\t\t\t},\n\t\t\t\t...images.slice( index + 1 ),\n\t\t\t],\n\t\t} );\n\t}\n\n\tfunction getImagesSizeOptions() {\n\t\tconst resizedImageSizes = Object.values( resizedImages );\n\t\treturn map(\n\t\t\tfilter( imageSizes, ( { slug } ) =>\n\t\t\t\tresizedImageSizes.some( ( sizes ) => sizes[ slug ] )\n\t\t\t),\n\t\t\t( { name, slug } ) => ( { value: slug, label: name } )\n\t\t);\n\t}\n\n\tfunction updateImagesSize( newSizeSlug ) {\n\t\tconst updatedImages = map( images, ( image ) => {\n\t\t\tif ( ! image.id ) {\n\t\t\t\treturn image;\n\t\t\t}\n\t\t\tconst url = get( resizedImages, [\n\t\t\t\tparseInt( image.id, 10 ),\n\t\t\t\tnewSizeSlug,\n\t\t\t] );\n\t\t\treturn {\n\t\t\t\t...image,\n\t\t\t\t...( url && { url } ),\n\t\t\t};\n\t\t} );\n\n\t\tsetAttributes( { images: updatedImages, sizeSlug: newSizeSlug } );\n\t}\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tPlatform.OS === 'web' &&\n\t\t\timages &&\n\t\t\timages.length > 0 &&\n\t\t\timages.every( ( { url } ) => isBlobURL( url ) )\n\t\t) {\n\t\t\tconst filesList = map( images, ( { url } ) => getBlobByURL( url ) );\n\t\t\timages.forEach( ( { url } ) => revokeBlobURL( url ) );\n\t\t\tmediaUpload( {\n\t\t\t\tfilesList,\n\t\t\t\tonFileChange: onSelectImages,\n\t\t\t\tallowedTypes: [ 'image' ],\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t// Deselect images when deselecting the block.\n\t\tif ( ! isSelected ) {\n\t\t\tsetSelectedImage();\n\t\t}\n\t}, [ isSelected ] );\n\n\tuseEffect( () => {\n\t\t// linkTo attribute must be saved so blocks don't break when changing\n\t\t// image_default_link_type in options.php.\n\t\tif ( ! linkTo ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tlinkTo:\n\t\t\t\t\twindow?.wp?.media?.view?.settings?.defaultProps?.link ||\n\t\t\t\t\tLINK_DESTINATION_NONE,\n\t\t\t} );\n\t\t}\n\t}, [ linkTo ] );\n\n\tconst hasImages = !! images.length;\n\tconst hasImageIds = hasImages && images.some( ( image ) => !! image.id );\n\n\tconst mediaPlaceholder = (\n\t\t<MediaPlaceholder\n\t\t\taddToGallery={ hasImageIds }\n\t\t\tisAppender={ hasImages }\n\t\t\tdisableMediaButtons={ hasImages && ! isSelected }\n\t\t\ticon={ ! hasImages && sharedIcon }\n\t\t\tlabels={ {\n\t\t\t\ttitle: ! hasImages && __( 'Gallery' ),\n\t\t\t\tinstructions: ! hasImages && PLACEHOLDER_TEXT,\n\t\t\t} }\n\t\t\tonSelect={ onSelectImages }\n\t\t\taccept=\"image/*\"\n\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\tmultiple\n\t\t\tvalue={ hasImageIds ? images : {} }\n\t\t\tonError={ onUploadError }\n\t\t\tnotices={ hasImages ? undefined : noticeUI }\n\t\t\tonFocus={ onFocus }\n\t\t\tautoOpenMediaUpload={\n\t\t\t\t! hasImages && isSelected && wasBlockJustInserted\n\t\t\t}\n\t\t/>\n\t);\n\n\tconst blockProps = useBlockProps();\n\n\tif ( ! hasImages ) {\n\t\treturn <View { ...blockProps }>{ mediaPlaceholder }</View>;\n\t}\n\n\tconst imageSizeOptions = getImagesSizeOptions();\n\tconst shouldShowSizeOptions = hasImages && ! isEmpty( imageSizeOptions );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t{ images.length > 1 && (\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\tvalue={ columns }\n\t\t\t\t\t\t\tonChange={ setColumnsNumber }\n\t\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\t\tmax={ Math.min( MAX_COLUMNS, images.length ) }\n\t\t\t\t\t\t\t{ ...MOBILE_CONTROL_PROPS_RANGE_CONTROL }\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Crop images' ) }\n\t\t\t\t\t\tchecked={ !! imageCrop }\n\t\t\t\t\t\tonChange={ toggleImageCrop }\n\t\t\t\t\t\thelp={ getImageCropHelp }\n\t\t\t\t\t/>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\tlabel={ __( 'Link to' ) }\n\t\t\t\t\t\tvalue={ linkTo }\n\t\t\t\t\t\tonChange={ setLinkTo }\n\t\t\t\t\t\toptions={ linkOptions }\n\t\t\t\t\t\thideCancelButton={ true }\n\t\t\t\t\t/>\n\t\t\t\t\t{ shouldShowSizeOptions && (\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ __( 'Image size' ) }\n\t\t\t\t\t\t\tvalue={ sizeSlug }\n\t\t\t\t\t\t\toptions={ imageSizeOptions }\n\t\t\t\t\t\t\tonChange={ updateImagesSize }\n\t\t\t\t\t\t\thideCancelButton={ true }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ noticeUI }\n\t\t\t<Gallery\n\t\t\t\t{ ...props }\n\t\t\t\tselectedImage={ selectedImage }\n\t\t\t\tmediaPlaceholder={ mediaPlaceholder }\n\t\t\t\tonMoveBackward={ onMoveBackward }\n\t\t\t\tonMoveForward={ onMoveForward }\n\t\t\t\tonRemoveImage={ onRemoveImage }\n\t\t\t\tonSelectImage={ onSelectImage }\n\t\t\t\tonDeselectImage={ onDeselectImage }\n\t\t\t\tonSetImageAttributes={ setImageAttributes }\n\t\t\t\tblockProps={ blockProps }\n\t\t\t\t// This prop is used by gallery.native.js.\n\t\t\t\tonFocusGalleryCaption={ onFocusGalleryCaption }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default compose( [\n\twithNotices,\n\twithViewportMatch( { isNarrow: '< small' } ),\n] )( GalleryEdit );\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/gallery/v1/edit.js"],"names":["get","isEmpty","map","compose","PanelBody","SelectControl","ToggleControl","withNotices","RangeControl","MediaPlaceholder","InspectorControls","useBlockProps","store","blockEditorStore","Platform","useEffect","useState","useMemo","__","getBlobByURL","isBlobURL","revokeBlobURL","useDispatch","useSelect","withViewportMatch","View","coreStore","sharedIcon","pickRelevantMediaFiles","defaultColumnsNumberV1","Gallery","LINK_DESTINATION_ATTACHMENT","LINK_DESTINATION_MEDIA","LINK_DESTINATION_NONE","MAX_COLUMNS","linkOptions","value","label","ALLOWED_MEDIA_TYPES","PLACEHOLDER_TEXT","select","web","native","MOBILE_CONTROL_PROPS_RANGE_CONTROL","type","GalleryEdit","props","attributes","clientId","isSelected","noticeUI","noticeOperations","onFocus","columns","imageCrop","images","linkTo","sizeSlug","selectedImage","setSelectedImage","attachmentCaptions","setAttachmentCaptions","__unstableMarkNextChangeAsNotPersistent","imageSizes","mediaUpload","getMedia","wasBlockJustInserted","settings","getSettings","resizedImages","ids","reduce","currentResizedImages","id","image","sizes","currentSizes","size","defaultUrl","slug","mediaDetailsUrl","parseInt","onFocusGalleryCaption","setAttributes","newAttrs","Error","onSelectImage","index","onDeselectImage","onMove","oldIndex","newIndex","newImages","splice","onMoveForward","length","onMoveBackward","onRemoveImage","filter","img","i","Math","min","selectCaption","newImage","newImageId","toString","currentImage","find","currentImageCaption","caption","attachment","onSelectImages","onUploadError","message","removeAllNotices","createErrorNotice","setLinkTo","setColumnsNumber","toggleImageCrop","getImageCropHelp","checked","setImageAttributes","newAttributes","slice","getImagesSizeOptions","resizedImageSizes","Object","values","some","name","updateImagesSize","newSizeSlug","updatedImages","url","OS","every","filesList","forEach","onFileChange","allowedTypes","window","wp","media","view","defaultProps","link","hasImages","hasImageIds","mediaPlaceholder","title","instructions","undefined","blockProps","imageSizeOptions","shouldShowSizeOptions","isNarrow"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,GAAT,EAAcC,OAAd,EAAuBC,GAAvB,QAAkC,QAAlC;AAEA;AACA;AACA;;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,SACCC,SADD,EAECC,aAFD,EAGCC,aAHD,EAICC,WAJD,EAKCC,YALD,QAMO,uBANP;AAOA,SACCC,gBADD,EAECC,iBAFD,EAGCC,aAHD,EAICC,KAAK,IAAIC,gBAJV,QAKO,yBALP;AAMA,SAASC,QAAT,EAAmBC,SAAnB,EAA8BC,QAA9B,EAAwCC,OAAxC,QAAuD,oBAAvD;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,YAAT,EAAuBC,SAAvB,EAAkCC,aAAlC,QAAuD,iBAAvD;AACA,SAASC,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SAASC,iBAAT,QAAkC,qBAAlC;AACA,SAASC,IAAT,QAAqB,uBAArB;AACA,SAASb,KAAK,IAAIc,SAAlB,QAAmC,sBAAnC;AAEA;AACA;AACA;;AACA,SAASC,UAAT,QAA2B,gBAA3B;AACA,SAASC,sBAAT,QAAuC,UAAvC;AACA,SAASC,sBAAT,QAAuC,eAAvC;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,SACCC,2BADD,EAECC,sBAFD,EAGCC,qBAHD,QAIO,aAJP;AAMA,MAAMC,WAAW,GAAG,CAApB;AACA,MAAMC,WAAW,GAAG,CACnB;AAAEC,EAAAA,KAAK,EAAEL,2BAAT;AAAsCM,EAAAA,KAAK,EAAEnB,EAAE,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qBAAqB,EAAGvE;AAZzB,KAxCD,CADD;AAyDA;;AAED,eAAe/E,OAAO,CAAE,CACvBI,WADuB,EAEvBiB,iBAAiB,CAAE;AAAEoI,EAAAA,QAAQ,EAAE;AAAZ,CAAF,CAFM,CAAF,CAAP,CAGV/G,WAHU,CAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { get, isEmpty, map } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { compose } from '@wordpress/compose';\nimport {\n\tPanelBody,\n\tSelectControl,\n\tToggleControl,\n\twithNotices,\n\tRangeControl,\n} from '@wordpress/components';\nimport {\n\tMediaPlaceholder,\n\tInspectorControls,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { Platform, useEffect, useState, useMemo } from '@wordpress/element';\nimport { __ } from '@wordpress/i18n';\nimport { getBlobByURL, isBlobURL, revokeBlobURL } from '@wordpress/blob';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { withViewportMatch } from '@wordpress/viewport';\nimport { View } from '@wordpress/primitives';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { sharedIcon } from '../shared-icon';\nimport { pickRelevantMediaFiles } from './shared';\nimport { defaultColumnsNumberV1 } from '../deprecated';\nimport Gallery from './gallery';\nimport {\n\tLINK_DESTINATION_ATTACHMENT,\n\tLINK_DESTINATION_MEDIA,\n\tLINK_DESTINATION_NONE,\n} from './constants';\n\nconst MAX_COLUMNS = 8;\nconst linkOptions = [\n\t{ value: LINK_DESTINATION_ATTACHMENT, label: __( 'Attachment Page' ) },\n\t{ value: LINK_DESTINATION_MEDIA, label: __( 'Media File' ) },\n\t{ value: LINK_DESTINATION_NONE, label: __( 'None' ) },\n];\nconst ALLOWED_MEDIA_TYPES = [ 'image' ];\n\nconst PLACEHOLDER_TEXT = Platform.select( {\n\tweb: __(\n\t\t'Drag images, upload new ones or select files from your library.'\n\t),\n\tnative: __( 'ADD MEDIA' ),\n} );\n\nconst MOBILE_CONTROL_PROPS_RANGE_CONTROL = Platform.select( {\n\tweb: {},\n\tnative: { type: 'stepper' },\n} );\n\nfunction GalleryEdit( props ) {\n\tconst {\n\t\tattributes,\n\t\tclientId,\n\t\tisSelected,\n\t\tnoticeUI,\n\t\tnoticeOperations,\n\t\tonFocus,\n\t} = props;\n\tconst {\n\t\tcolumns = defaultColumnsNumberV1( attributes ),\n\t\timageCrop,\n\t\timages,\n\t\tlinkTo,\n\t\tsizeSlug,\n\t} = attributes;\n\tconst [ selectedImage, setSelectedImage ] = useState();\n\tconst [ attachmentCaptions, setAttachmentCaptions ] = useState();\n\tconst { __unstableMarkNextChangeAsNotPersistent } =\n\t\tuseDispatch( blockEditorStore );\n\n\tconst { imageSizes, mediaUpload, getMedia, wasBlockJustInserted } =\n\t\tuseSelect( ( select ) => {\n\t\t\tconst settings = select( blockEditorStore ).getSettings();\n\n\t\t\treturn {\n\t\t\t\timageSizes: settings.imageSizes,\n\t\t\t\tmediaUpload: settings.mediaUpload,\n\t\t\t\tgetMedia: select( coreStore ).getMedia,\n\t\t\t\twasBlockJustInserted: select(\n\t\t\t\t\tblockEditorStore\n\t\t\t\t).wasBlockJustInserted( clientId, 'inserter_menu' ),\n\t\t\t};\n\t\t} );\n\n\tconst resizedImages = useMemo( () => {\n\t\tif ( isSelected ) {\n\t\t\treturn ( attributes.ids ?? [] ).reduce(\n\t\t\t\t( currentResizedImages, id ) => {\n\t\t\t\t\tif ( ! id ) {\n\t\t\t\t\t\treturn currentResizedImages;\n\t\t\t\t\t}\n\t\t\t\t\tconst image = getMedia( id );\n\t\t\t\t\tconst sizes = imageSizes.reduce( ( currentSizes, size ) => {\n\t\t\t\t\t\tconst defaultUrl = get( image, [\n\t\t\t\t\t\t\t'sizes',\n\t\t\t\t\t\t\tsize.slug,\n\t\t\t\t\t\t\t'url',\n\t\t\t\t\t\t] );\n\t\t\t\t\t\tconst mediaDetailsUrl = get( image, [\n\t\t\t\t\t\t\t'media_details',\n\t\t\t\t\t\t\t'sizes',\n\t\t\t\t\t\t\tsize.slug,\n\t\t\t\t\t\t\t'source_url',\n\t\t\t\t\t\t] );\n\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t...currentSizes,\n\t\t\t\t\t\t\t[ size.slug ]: defaultUrl || mediaDetailsUrl,\n\t\t\t\t\t\t};\n\t\t\t\t\t}, {} );\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...currentResizedImages,\n\t\t\t\t\t\t[ parseInt( id, 10 ) ]: sizes,\n\t\t\t\t\t};\n\t\t\t\t},\n\t\t\t\t{}\n\t\t\t);\n\t\t}\n\t\treturn {};\n\t}, [ isSelected, attributes.ids, imageSizes ] );\n\n\tfunction onFocusGalleryCaption() {\n\t\tsetSelectedImage();\n\t}\n\n\tfunction setAttributes( newAttrs ) {\n\t\tif ( newAttrs.ids ) {\n\t\t\tthrow new Error(\n\t\t\t\t'The \"ids\" attribute should not be changed directly. It is managed automatically when \"images\" attribute changes'\n\t\t\t);\n\t\t}\n\n\t\tif ( newAttrs.images ) {\n\t\t\tnewAttrs = {\n\t\t\t\t...newAttrs,\n\t\t\t\t// Unlike images[ n ].id which is a string, always ensure the\n\t\t\t\t// ids array contains numbers as per its attribute type.\n\t\t\t\tids: map( newAttrs.images, ( { id } ) => parseInt( id, 10 ) ),\n\t\t\t};\n\t\t}\n\n\t\tprops.setAttributes( newAttrs );\n\t}\n\n\tfunction onSelectImage( index ) {\n\t\treturn () => {\n\t\t\tsetSelectedImage( index );\n\t\t};\n\t}\n\n\tfunction onDeselectImage() {\n\t\treturn () => {\n\t\t\tsetSelectedImage();\n\t\t};\n\t}\n\n\tfunction onMove( oldIndex, newIndex ) {\n\t\tconst newImages = [ ...images ];\n\t\tnewImages.splice( newIndex, 1, images[ oldIndex ] );\n\t\tnewImages.splice( oldIndex, 1, images[ newIndex ] );\n\t\tsetSelectedImage( newIndex );\n\t\tsetAttributes( { images: newImages } );\n\t}\n\n\tfunction onMoveForward( oldIndex ) {\n\t\treturn () => {\n\t\t\tif ( oldIndex === images.length - 1 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonMove( oldIndex, oldIndex + 1 );\n\t\t};\n\t}\n\n\tfunction onMoveBackward( oldIndex ) {\n\t\treturn () => {\n\t\t\tif ( oldIndex === 0 ) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tonMove( oldIndex, oldIndex - 1 );\n\t\t};\n\t}\n\n\tfunction onRemoveImage( index ) {\n\t\treturn () => {\n\t\t\tconst newImages = images.filter( ( img, i ) => index !== i );\n\t\t\tsetSelectedImage();\n\t\t\tsetAttributes( {\n\t\t\t\timages: newImages,\n\t\t\t\tcolumns: attributes.columns\n\t\t\t\t\t? Math.min( newImages.length, attributes.columns )\n\t\t\t\t\t: attributes.columns,\n\t\t\t} );\n\t\t};\n\t}\n\n\tfunction selectCaption( newImage ) {\n\t\t// The image id in both the images and attachmentCaptions arrays is a\n\t\t// string, so ensure comparison works correctly by converting the\n\t\t// newImage.id to a string.\n\t\tconst newImageId = newImage.id.toString();\n\t\tconst currentImage = images.find( ( { id } ) => id === newImageId );\n\t\tconst currentImageCaption = currentImage\n\t\t\t? currentImage.caption\n\t\t\t: newImage.caption;\n\n\t\tif ( ! attachmentCaptions ) {\n\t\t\treturn currentImageCaption;\n\t\t}\n\n\t\tconst attachment = attachmentCaptions.find(\n\t\t\t( { id } ) => id === newImageId\n\t\t);\n\n\t\t// If the attachment caption is updated.\n\t\tif ( attachment && attachment.caption !== newImage.caption ) {\n\t\t\treturn newImage.caption;\n\t\t}\n\n\t\treturn currentImageCaption;\n\t}\n\n\tfunction onSelectImages( newImages ) {\n\t\tsetAttachmentCaptions(\n\t\t\tnewImages.map( ( newImage ) => ( {\n\t\t\t\t// Store the attachmentCaption id as a string for consistency\n\t\t\t\t// with the type of the id in the images attribute.\n\t\t\t\tid: newImage.id.toString(),\n\t\t\t\tcaption: newImage.caption,\n\t\t\t} ) )\n\t\t);\n\t\tsetAttributes( {\n\t\t\timages: newImages.map( ( newImage ) => ( {\n\t\t\t\t...pickRelevantMediaFiles( newImage, sizeSlug ),\n\t\t\t\tcaption: selectCaption( newImage, images, attachmentCaptions ),\n\t\t\t\t// The id value is stored in a data attribute, so when the\n\t\t\t\t// block is parsed it's converted to a string. Converting\n\t\t\t\t// to a string here ensures it's type is consistent.\n\t\t\t\tid: newImage.id.toString(),\n\t\t\t} ) ),\n\t\t\tcolumns: attributes.columns\n\t\t\t\t? Math.min( newImages.length, attributes.columns )\n\t\t\t\t: attributes.columns,\n\t\t} );\n\t}\n\n\tfunction onUploadError( message ) {\n\t\tnoticeOperations.removeAllNotices();\n\t\tnoticeOperations.createErrorNotice( message );\n\t}\n\n\tfunction setLinkTo( value ) {\n\t\tsetAttributes( { linkTo: value } );\n\t}\n\n\tfunction setColumnsNumber( value ) {\n\t\tsetAttributes( { columns: value } );\n\t}\n\n\tfunction toggleImageCrop() {\n\t\tsetAttributes( { imageCrop: ! imageCrop } );\n\t}\n\n\tfunction getImageCropHelp( checked ) {\n\t\treturn checked\n\t\t\t? __( 'Thumbnails are cropped to align.' )\n\t\t\t: __( 'Thumbnails are not cropped.' );\n\t}\n\n\tfunction setImageAttributes( index, newAttributes ) {\n\t\tif ( ! images[ index ] ) {\n\t\t\treturn;\n\t\t}\n\n\t\tsetAttributes( {\n\t\t\timages: [\n\t\t\t\t...images.slice( 0, index ),\n\t\t\t\t{\n\t\t\t\t\t...images[ index ],\n\t\t\t\t\t...newAttributes,\n\t\t\t\t},\n\t\t\t\t...images.slice( index + 1 ),\n\t\t\t],\n\t\t} );\n\t}\n\n\tfunction getImagesSizeOptions() {\n\t\tconst resizedImageSizes = Object.values( resizedImages );\n\t\treturn map(\n\t\t\timageSizes.filter( ( { slug } ) =>\n\t\t\t\tresizedImageSizes.some( ( sizes ) => sizes[ slug ] )\n\t\t\t),\n\t\t\t( { name, slug } ) => ( { value: slug, label: name } )\n\t\t);\n\t}\n\n\tfunction updateImagesSize( newSizeSlug ) {\n\t\tconst updatedImages = map( images, ( image ) => {\n\t\t\tif ( ! image.id ) {\n\t\t\t\treturn image;\n\t\t\t}\n\t\t\tconst url = get( resizedImages, [\n\t\t\t\tparseInt( image.id, 10 ),\n\t\t\t\tnewSizeSlug,\n\t\t\t] );\n\t\t\treturn {\n\t\t\t\t...image,\n\t\t\t\t...( url && { url } ),\n\t\t\t};\n\t\t} );\n\n\t\tsetAttributes( { images: updatedImages, sizeSlug: newSizeSlug } );\n\t}\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\tPlatform.OS === 'web' &&\n\t\t\timages &&\n\t\t\timages.length > 0 &&\n\t\t\timages.every( ( { url } ) => isBlobURL( url ) )\n\t\t) {\n\t\t\tconst filesList = map( images, ( { url } ) => getBlobByURL( url ) );\n\t\t\timages.forEach( ( { url } ) => revokeBlobURL( url ) );\n\t\t\tmediaUpload( {\n\t\t\t\tfilesList,\n\t\t\t\tonFileChange: onSelectImages,\n\t\t\t\tallowedTypes: [ 'image' ],\n\t\t\t} );\n\t\t}\n\t}, [] );\n\n\tuseEffect( () => {\n\t\t// Deselect images when deselecting the block.\n\t\tif ( ! isSelected ) {\n\t\t\tsetSelectedImage();\n\t\t}\n\t}, [ isSelected ] );\n\n\tuseEffect( () => {\n\t\t// linkTo attribute must be saved so blocks don't break when changing\n\t\t// image_default_link_type in options.php.\n\t\tif ( ! linkTo ) {\n\t\t\t__unstableMarkNextChangeAsNotPersistent();\n\t\t\tsetAttributes( {\n\t\t\t\tlinkTo:\n\t\t\t\t\twindow?.wp?.media?.view?.settings?.defaultProps?.link ||\n\t\t\t\t\tLINK_DESTINATION_NONE,\n\t\t\t} );\n\t\t}\n\t}, [ linkTo ] );\n\n\tconst hasImages = !! images.length;\n\tconst hasImageIds = hasImages && images.some( ( image ) => !! image.id );\n\n\tconst mediaPlaceholder = (\n\t\t<MediaPlaceholder\n\t\t\taddToGallery={ hasImageIds }\n\t\t\tisAppender={ hasImages }\n\t\t\tdisableMediaButtons={ hasImages && ! isSelected }\n\t\t\ticon={ ! hasImages && sharedIcon }\n\t\t\tlabels={ {\n\t\t\t\ttitle: ! hasImages && __( 'Gallery' ),\n\t\t\t\tinstructions: ! hasImages && PLACEHOLDER_TEXT,\n\t\t\t} }\n\t\t\tonSelect={ onSelectImages }\n\t\t\taccept=\"image/*\"\n\t\t\tallowedTypes={ ALLOWED_MEDIA_TYPES }\n\t\t\tmultiple\n\t\t\tvalue={ hasImageIds ? images : {} }\n\t\t\tonError={ onUploadError }\n\t\t\tnotices={ hasImages ? undefined : noticeUI }\n\t\t\tonFocus={ onFocus }\n\t\t\tautoOpenMediaUpload={\n\t\t\t\t! hasImages && isSelected && wasBlockJustInserted\n\t\t\t}\n\t\t/>\n\t);\n\n\tconst blockProps = useBlockProps();\n\n\tif ( ! hasImages ) {\n\t\treturn <View { ...blockProps }>{ mediaPlaceholder }</View>;\n\t}\n\n\tconst imageSizeOptions = getImagesSizeOptions();\n\tconst shouldShowSizeOptions = hasImages && ! isEmpty( imageSizeOptions );\n\n\treturn (\n\t\t<>\n\t\t\t<InspectorControls>\n\t\t\t\t<PanelBody title={ __( 'Settings' ) }>\n\t\t\t\t\t{ images.length > 1 && (\n\t\t\t\t\t\t<RangeControl\n\t\t\t\t\t\t\t__nextHasNoMarginBottom\n\t\t\t\t\t\t\tlabel={ __( 'Columns' ) }\n\t\t\t\t\t\t\tvalue={ columns }\n\t\t\t\t\t\t\tonChange={ setColumnsNumber }\n\t\t\t\t\t\t\tmin={ 1 }\n\t\t\t\t\t\t\tmax={ Math.min( MAX_COLUMNS, images.length ) }\n\t\t\t\t\t\t\t{ ...MOBILE_CONTROL_PROPS_RANGE_CONTROL }\n\t\t\t\t\t\t\trequired\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t\t<ToggleControl\n\t\t\t\t\t\tlabel={ __( 'Crop images' ) }\n\t\t\t\t\t\tchecked={ !! imageCrop }\n\t\t\t\t\t\tonChange={ toggleImageCrop }\n\t\t\t\t\t\thelp={ getImageCropHelp }\n\t\t\t\t\t/>\n\t\t\t\t\t<SelectControl\n\t\t\t\t\t\tlabel={ __( 'Link to' ) }\n\t\t\t\t\t\tvalue={ linkTo }\n\t\t\t\t\t\tonChange={ setLinkTo }\n\t\t\t\t\t\toptions={ linkOptions }\n\t\t\t\t\t\thideCancelButton={ true }\n\t\t\t\t\t/>\n\t\t\t\t\t{ shouldShowSizeOptions && (\n\t\t\t\t\t\t<SelectControl\n\t\t\t\t\t\t\tlabel={ __( 'Image size' ) }\n\t\t\t\t\t\t\tvalue={ sizeSlug }\n\t\t\t\t\t\t\toptions={ imageSizeOptions }\n\t\t\t\t\t\t\tonChange={ updateImagesSize }\n\t\t\t\t\t\t\thideCancelButton={ true }\n\t\t\t\t\t\t/>\n\t\t\t\t\t) }\n\t\t\t\t</PanelBody>\n\t\t\t</InspectorControls>\n\t\t\t{ noticeUI }\n\t\t\t<Gallery\n\t\t\t\t{ ...props }\n\t\t\t\tselectedImage={ selectedImage }\n\t\t\t\tmediaPlaceholder={ mediaPlaceholder }\n\t\t\t\tonMoveBackward={ onMoveBackward }\n\t\t\t\tonMoveForward={ onMoveForward }\n\t\t\t\tonRemoveImage={ onRemoveImage }\n\t\t\t\tonSelectImage={ onSelectImage }\n\t\t\t\tonDeselectImage={ onDeselectImage }\n\t\t\t\tonSetImageAttributes={ setImageAttributes }\n\t\t\t\tblockProps={ blockProps }\n\t\t\t\t// This prop is used by gallery.native.js.\n\t\t\t\tonFocusGalleryCaption={ onFocusGalleryCaption }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default compose( [\n\twithNotices,\n\twithViewportMatch( { isNarrow: '< small' } ),\n] )( GalleryEdit );\n"]}
|
|
@@ -4,7 +4,6 @@ import { createElement } from "@wordpress/element";
|
|
|
4
4
|
* External dependencies
|
|
5
5
|
*/
|
|
6
6
|
import { View } from 'react-native';
|
|
7
|
-
import { isEmpty } from 'lodash';
|
|
8
7
|
/**
|
|
9
8
|
* Internal dependencies
|
|
10
9
|
*/
|
|
@@ -121,7 +120,7 @@ export const Gallery = props => {
|
|
|
121
120
|
clientId: clientId,
|
|
122
121
|
isSelected: isCaptionSelected,
|
|
123
122
|
accessible: true,
|
|
124
|
-
accessibilityLabelCreator: caption =>
|
|
123
|
+
accessibilityLabelCreator: caption => !caption ?
|
|
125
124
|
/* translators: accessibility text. Empty gallery caption. */
|
|
126
125
|
'Gallery caption. Empty' : sprintf(
|
|
127
126
|
/* translators: accessibility text. %s: gallery caption. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/gallery/v1/gallery.native.js"],"names":["View","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/gallery/v1/gallery.native.js"],"names":["View","GalleryImage","defaultColumnsNumberV1","styles","Tiles","__","sprintf","BlockCaption","store","blockEditorStore","useState","useEffect","mediaUploadSync","useSelect","alignmentHelpers","TILE_SPACING","MAX_DISPLAYED_COLUMNS","MAX_DISPLAYED_COLUMNS_NARROW","isFullWidth","Gallery","props","isCaptionSelected","setIsCaptionSelected","isRTL","select","getSettings","clientId","selectedImage","mediaPlaceholder","onBlur","onMoveBackward","onMoveForward","onRemoveImage","onSelectImage","onSetImageAttributes","onFocusGalleryCaption","attributes","isSelected","isNarrow","onFocus","insertBlocksAfter","align","columns","imageCrop","images","displayedColumns","Math","min","selectImage","index","focusGalleryCaption","flex","galleryTilesContainerSelected","undefined","map","img","ariaLabel","length","id","url","alt","parseInt","attrs","caption","fullWidth"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,IAAT,QAAqB,cAArB;AAEA;AACA;AACA;;AACA,OAAOC,YAAP,MAAyB,iBAAzB;AACA,SAASC,sBAAT,QAAuC,eAAvC;AACA,OAAOC,MAAP,MAAmB,uBAAnB;AACA,OAAOC,KAAP,MAAkB,SAAlB;AAEA;AACA;AACA;;AACA,SAASC,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SACCC,YADD,EAECC,KAAK,IAAIC,gBAFV,QAGO,yBAHP;A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**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * Internal dependencies\n */\nimport GalleryImage from './gallery-image';\nimport { defaultColumnsNumberV1 } from '../deprecated';\nimport styles from './gallery-styles.scss';\nimport Tiles from './tiles';\n\n/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport {\n\tBlockCaption,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { useState, useEffect } from '@wordpress/element';\nimport { mediaUploadSync } from '@wordpress/react-native-bridge';\nimport { useSelect } from '@wordpress/data';\nimport { alignmentHelpers } from '@wordpress/components';\n\nconst TILE_SPACING = 15;\n\n// we must limit displayed columns since readable content max-width is 580px\nconst MAX_DISPLAYED_COLUMNS = 4;\nconst MAX_DISPLAYED_COLUMNS_NARROW = 2;\n\nconst { isFullWidth } = alignmentHelpers;\n\nexport const Gallery = ( props ) => {\n\tconst [ isCaptionSelected, setIsCaptionSelected ] = useState( false );\n\tuseEffect( mediaUploadSync, [] );\n\n\tconst isRTL = useSelect( ( select ) => {\n\t\treturn !! select( blockEditorStore ).getSettings().isRTL;\n\t}, [] );\n\n\tconst {\n\t\tclientId,\n\t\tselectedImage,\n\t\tmediaPlaceholder,\n\t\tonBlur,\n\t\tonMoveBackward,\n\t\tonMoveForward,\n\t\tonRemoveImage,\n\t\tonSelectImage,\n\t\tonSetImageAttributes,\n\t\tonFocusGalleryCaption,\n\t\tattributes,\n\t\tisSelected,\n\t\tisNarrow,\n\t\tonFocus,\n\t\tinsertBlocksAfter,\n\t} = props;\n\n\tconst {\n\t\talign,\n\t\tcolumns = defaultColumnsNumberV1( attributes ),\n\t\timageCrop,\n\t\timages,\n\t} = attributes;\n\n\t// limit displayed columns when isNarrow is true (i.e. when viewport width is\n\t// less than \"small\", where small = 600)\n\tconst displayedColumns = isNarrow\n\t\t? Math.min( columns, MAX_DISPLAYED_COLUMNS_NARROW )\n\t\t: Math.min( columns, MAX_DISPLAYED_COLUMNS );\n\n\tconst selectImage = ( index ) => {\n\t\treturn () => {\n\t\t\tif ( isCaptionSelected ) {\n\t\t\t\tsetIsCaptionSelected( false );\n\t\t\t}\n\t\t\t// We need to fully invoke the curried function here.\n\t\t\tonSelectImage( index )();\n\t\t};\n\t};\n\n\tconst focusGalleryCaption = () => {\n\t\tif ( ! isCaptionSelected ) {\n\t\t\tsetIsCaptionSelected( true );\n\t\t}\n\t\tonFocusGalleryCaption();\n\t};\n\n\treturn (\n\t\t<View style={ { flex: 1 } }>\n\t\t\t<Tiles\n\t\t\t\tcolumns={ displayedColumns }\n\t\t\t\tspacing={ TILE_SPACING }\n\t\t\t\tstyle={\n\t\t\t\t\tisSelected\n\t\t\t\t\t\t? styles.galleryTilesContainerSelected\n\t\t\t\t\t\t: undefined\n\t\t\t\t}\n\t\t\t>\n\t\t\t\t{ images.map( ( img, index ) => {\n\t\t\t\t\tconst ariaLabel = sprintf(\n\t\t\t\t\t\t/* translators: 1: the order number of the image. 2: the total number of images. */\n\t\t\t\t\t\t__( 'image %1$d of %2$d in gallery' ),\n\t\t\t\t\t\tindex + 1,\n\t\t\t\t\t\timages.length\n\t\t\t\t\t);\n\n\t\t\t\t\treturn (\n\t\t\t\t\t\t<GalleryImage\n\t\t\t\t\t\t\tkey={ img.id ? `${ img.id }-${ index }` : img.url }\n\t\t\t\t\t\t\turl={ img.url }\n\t\t\t\t\t\t\talt={ img.alt }\n\t\t\t\t\t\t\tid={ parseInt( img.id, 10 ) } // make id an integer explicitly\n\t\t\t\t\t\t\tisCropped={ imageCrop }\n\t\t\t\t\t\t\tisFirstItem={ index === 0 }\n\t\t\t\t\t\t\tisLastItem={ index + 1 === images.length }\n\t\t\t\t\t\t\tisSelected={ isSelected && selectedImage === index }\n\t\t\t\t\t\t\tisBlockSelected={ isSelected }\n\t\t\t\t\t\t\tonMoveBackward={ onMoveBackward( index ) }\n\t\t\t\t\t\t\tonMoveForward={ onMoveForward( index ) }\n\t\t\t\t\t\t\tonRemove={ onRemoveImage( index ) }\n\t\t\t\t\t\t\tonSelect={ selectImage( index ) }\n\t\t\t\t\t\t\tonSelectBlock={ onFocus }\n\t\t\t\t\t\t\tsetAttributes={ ( attrs ) =>\n\t\t\t\t\t\t\t\tonSetImageAttributes( index, attrs )\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tcaption={ img.caption }\n\t\t\t\t\t\t\taria-label={ ariaLabel }\n\t\t\t\t\t\t\tisRTL={ isRTL }\n\t\t\t\t\t\t/>\n\t\t\t\t\t);\n\t\t\t\t} ) }\n\t\t\t</Tiles>\n\t\t\t<View style={ isFullWidth( align ) && styles.fullWidth }>\n\t\t\t\t{ mediaPlaceholder }\n\t\t\t</View>\n\t\t\t<BlockCaption\n\t\t\t\tclientId={ clientId }\n\t\t\t\tisSelected={ isCaptionSelected }\n\t\t\t\taccessible={ true }\n\t\t\t\taccessibilityLabelCreator={ ( caption ) =>\n\t\t\t\t\t! caption\n\t\t\t\t\t\t? /* translators: accessibility text. Empty gallery caption. */\n\t\t\t\t\t\t 'Gallery caption. Empty'\n\t\t\t\t\t\t: sprintf(\n\t\t\t\t\t\t\t\t/* translators: accessibility text. %s: gallery caption. */\n\t\t\t\t\t\t\t\t__( 'Gallery caption. %s' ),\n\t\t\t\t\t\t\t\tcaption\n\t\t\t\t\t\t )\n\t\t\t\t}\n\t\t\t\tonFocus={ focusGalleryCaption }\n\t\t\t\tonBlur={ onBlur } // Always assign onBlur as props.\n\t\t\t\tinsertBlocksAfter={ insertBlocksAfter }\n\t\t\t/>\n\t\t</View>\n\t);\n};\n\nexport default Gallery;\n"]}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { get
|
|
4
|
+
import { get } from 'lodash';
|
|
5
5
|
export const pickRelevantMediaFiles = function (image) {
|
|
6
6
|
let sizeSlug = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'large';
|
|
7
|
-
const imageProps =
|
|
7
|
+
const imageProps = Object.fromEntries(Object.entries(image !== null && image !== void 0 ? image : {}).filter(_ref => {
|
|
8
|
+
let [key] = _ref;
|
|
9
|
+
return ['alt', 'id', 'link', 'caption'].includes(key);
|
|
10
|
+
}));
|
|
8
11
|
imageProps.url = get(image, ['sizes', sizeSlug, 'url']) || get(image, ['media_details', 'sizes', sizeSlug, 'source_url']) || image.url;
|
|
9
12
|
const fullUrl = get(image, ['sizes', 'full', 'url']) || get(image, ['media_details', 'sizes', 'full', 'source_url']);
|
|
10
13
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/gallery/v1/shared.js"],"names":["get","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/gallery/v1/shared.js"],"names":["get","pickRelevantMediaFiles","image","sizeSlug","imageProps","Object","fromEntries","entries","filter","key","includes","url","fullUrl"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,GAAT,QAAoB,QAApB;AAEA,OAAO,MAAMC,sBAAsB,GAAG,UAAEC,KAAF,EAAiC;AAAA,MAAxBC,QAAwB,uEAAb,OAAa;AACtE,QAAMC,UAAU,GAAGC,MAAM,CAACC,WAAP,CAClBD,MAAM,CAACE,OAAP,CAAgBL,KAAhB,aAAgBA,KAAhB,cAAgBA,KAAhB,GAAyB,EAAzB,EAA8BM,MAA9B,CAAsC;AAAA,QAAE,CAAEC,GAAF,CAAF;AAAA,WACrC,CAAE,KAAF,EAAS,IAAT,EAAe,MAAf,EAAuB,SAAvB,EAAmCC,QAAnC,CAA6CD,GAA7C,CADqC;AAAA,GAAtC,CADkB,CAAnB;AAMAL,EAAAA,UAAU,CAACO,GAAX,GACCX,GAAG,CAAEE,KAAF,EAAS,CAAE,OAAF,EAAWC,QAAX,EAAqB,KAArB,CAAT,CAAH,IACAH,GAAG,CAAEE,KAAF,EAAS,CAAE,eAAF,EAAmB,OAAnB,EAA4BC,QAA5B,EAAsC,YAAtC,CAAT,CADH,IAEAD,KAAK,CAACS,GAHP;AAIA,QAAMC,OAAO,GACZZ,GAAG,CAAEE,KAAF,EAAS,CAAE,OAAF,EAAW,MAAX,EAAmB,KAAnB,CAAT,CAAH,IACAF,GAAG,CAAEE,KAAF,EAAS,CAAE,eAAF,EAAmB,OAAnB,EAA4B,MAA5B,EAAoC,YAApC,CAAT,CAFJ;;AAGA,MAAKU,OAAL,EAAe;AACdR,IAAAA,UAAU,CAACQ,OAAX,GAAqBA,OAArB;AACA;;AACD,SAAOR,UAAP;AACA,CAlBM","sourcesContent":["/**\n * External dependencies\n */\nimport { get } from 'lodash';\n\nexport const pickRelevantMediaFiles = ( image, sizeSlug = 'large' ) => {\n\tconst imageProps = Object.fromEntries(\n\t\tObject.entries( image ?? {} ).filter( ( [ key ] ) =>\n\t\t\t[ 'alt', 'id', 'link', 'caption' ].includes( key )\n\t\t)\n\t);\n\n\timageProps.url =\n\t\tget( image, [ 'sizes', sizeSlug, 'url' ] ) ||\n\t\tget( image, [ 'media_details', 'sizes', sizeSlug, 'source_url' ] ) ||\n\t\timage.url;\n\tconst fullUrl =\n\t\tget( image, [ 'sizes', 'full', 'url' ] ) ||\n\t\tget( image, [ 'media_details', 'sizes', 'full', 'source_url' ] );\n\tif ( fullUrl ) {\n\t\timageProps.fullUrl = fullUrl;\n\t}\n\treturn imageProps;\n};\n"]}
|
|
@@ -7,7 +7,6 @@ import { useDispatch, useSelect } from '@wordpress/data';
|
|
|
7
7
|
import { InnerBlocks, useBlockProps, InspectorControls, useInnerBlocksProps, useSetting, store as blockEditorStore } from '@wordpress/block-editor';
|
|
8
8
|
import { SelectControl } from '@wordpress/components';
|
|
9
9
|
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import { useCallback } from '@wordpress/element';
|
|
11
10
|
/**
|
|
12
11
|
* Internal dependencies
|
|
13
12
|
*/
|
|
@@ -129,11 +128,10 @@ function GroupEdit(_ref2) {
|
|
|
129
128
|
const {
|
|
130
129
|
selectBlock
|
|
131
130
|
} = useDispatch(blockEditorStore);
|
|
132
|
-
const updateSelection = useCallback(newClientId => selectBlock(newClientId, -1), [selectBlock]);
|
|
133
131
|
|
|
134
132
|
const selectVariation = nextVariation => {
|
|
135
133
|
setAttributes(nextVariation.attributes);
|
|
136
|
-
|
|
134
|
+
selectBlock(clientId, -1);
|
|
137
135
|
setShowPlaceholder(false);
|
|
138
136
|
};
|
|
139
137
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/group/edit.js"],"names":["useDispatch","useSelect","InnerBlocks","useBlockProps","InspectorControls","useInnerBlocksProps","useSetting","store","blockEditorStore","SelectControl","__","useCallback","GroupPlaceHolder","useShouldShowPlaceHolder","GroupEditControls","tagName","onSelectTagName","htmlElementMessages","header","main","section","article","aside","footer","label","value","GroupEdit","attributes","name","setAttributes","clientId","__unstableLayoutClassNames","layoutClassNames","hasInnerBlocks","themeSupportsLayout","select","getBlock","getSettings","block","innerBlocks","length","supportsLayout","TagName","templateLock","layout","defaultLayout","usedLayout","type","layoutSupportEnabled","blockProps","className","showPlaceholder","setShowPlaceholder","usedLayoutType","innerBlocksProps","renderAppender","undefined","ButtonBlockAppender","__experimentalLayout","__unstableDisableLayoutClassNames","selectBlock","updateSelection","newClientId","selectVariation","nextVariation"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SACCC,WADD,EAECC,aAFD,EAGCC,iBAHD,EAICC,mBAJD,EAKCC,UALD,EAMCC,KAAK,IAAIC,gBANV,QAOO,yBAPP;AAQA,SAASC,aAAT,QAA8B,uBAA9B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,WAAT,QAA4B,oBAA5B;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,IAA2BC,wBAA3B,QAA2D,eAA3D;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,iBAAT,OAA2D;AAAA,MAA/B;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,GA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AGrB,QADZ;AAEC,IAAA,IAAI,EAAGF,IAFR;AAGC,IAAA,QAAQ,EAAGmC;AAHZ,IARF,EAcGf,oBAAoB,IAAI,CAAEG,eAA1B,IACD,cAAC,OAAD,EAAcG,gBAAd,CAfF,EAmBG,CAAEN,oBAAF,IAA0B,CAAEG,eAA5B,IACD,cAAC,OAAD,EAAcF,UAAd,EACC,qBAAUK,gBAAV,CADD,CApBF,CADD;AA2BA;;AAED,eAAe5B,SAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tInnerBlocks,\n\tuseBlockProps,\n\tInspectorControls,\n\tuseInnerBlocksProps,\n\tuseSetting,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { useCallback } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\nimport GroupPlaceHolder, { useShouldShowPlaceHolder } from './placeholder';\n\n/**\n * Render inspector controls for the Group block.\n *\n * @param {Object} props Component props.\n * @param {string} props.tagName The HTML tag name.\n * @param {Function} props.onSelectTagName onChange function for the SelectControl.\n *\n * @return {JSX.Element} The control group.\n */\nfunction GroupEditControls( { tagName, onSelectTagName } ) {\n\tconst htmlElementMessages = {\n\t\theader: __(\n\t\t\t'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'\n\t\t),\n\t\tmain: __(\n\t\t\t'The <main> element should be used for the primary content of your document only. '\n\t\t),\n\t\tsection: __(\n\t\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t\t),\n\t\tarticle: __(\n\t\t\t'The <article> element should represent a self-contained, syndicatable portion of the document.'\n\t\t),\n\t\taside: __(\n\t\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t\t),\n\t\tfooter: __(\n\t\t\t'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'\n\t\t),\n\t};\n\treturn (\n\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\toptions={ [\n\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t{ label: '<header>', value: 'header' },\n\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t{ label: '<article>', value: 'article' },\n\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t{ label: '<footer>', value: 'footer' },\n\t\t\t\t] }\n\t\t\t\tvalue={ tagName }\n\t\t\t\tonChange={ onSelectTagName }\n\t\t\t\thelp={ htmlElementMessages[ tagName ] }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction GroupEdit( {\n\tattributes,\n\tname,\n\tsetAttributes,\n\tclientId,\n\t__unstableLayoutClassNames: layoutClassNames,\n} ) {\n\tconst { hasInnerBlocks, themeSupportsLayout } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getSettings } = select( blockEditorStore );\n\t\t\tconst block = getBlock( clientId );\n\t\t\treturn {\n\t\t\t\thasInnerBlocks: !! ( block && block.innerBlocks.length ),\n\t\t\t\tthemeSupportsLayout: getSettings()?.supportsLayout,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { tagName: TagName = 'div', templateLock, layout = {} } = attributes;\n\n\t// Layout settings.\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = ! layout?.type\n\t\t? { ...defaultLayout, ...layout, type: 'default' }\n\t\t: { ...defaultLayout, ...layout };\n\tconst { type = 'default' } = usedLayout;\n\tconst layoutSupportEnabled = themeSupportsLayout || type === 'flex';\n\n\t// Hooks.\n\tconst blockProps = useBlockProps( {\n\t\tclassName: ! layoutSupportEnabled ? layoutClassNames : null,\n\t} );\n\tconst [ showPlaceholder, setShowPlaceholder ] = useShouldShowPlaceHolder( {\n\t\tattributes,\n\t\tusedLayoutType: usedLayout?.type,\n\t\thasInnerBlocks,\n\t} );\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\tlayoutSupportEnabled\n\t\t\t? blockProps\n\t\t\t: { className: 'wp-block-group__inner-container' },\n\t\t{\n\t\t\ttemplateLock,\n\t\t\trenderAppender: hasInnerBlocks\n\t\t\t\t? undefined\n\t\t\t\t: InnerBlocks.ButtonBlockAppender,\n\t\t\t__experimentalLayout: layoutSupportEnabled ? usedLayout : undefined,\n\t\t\t__unstableDisableLayoutClassNames: ! layoutSupportEnabled,\n\t\t}\n\t);\n\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\tconst updateSelection = useCallback(\n\t\t( newClientId ) => selectBlock( newClientId, -1 ),\n\t\t[ selectBlock ]\n\t);\n\tconst selectVariation = ( nextVariation ) => {\n\t\tsetAttributes( nextVariation.attributes );\n\t\tupdateSelection( clientId );\n\t\tsetShowPlaceholder( false );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<GroupEditControls\n\t\t\t\ttagName={ TagName }\n\t\t\t\tonSelectTagName={ ( value ) =>\n\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ showPlaceholder && (\n\t\t\t\t<GroupPlaceHolder\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonSelect={ selectVariation }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ layoutSupportEnabled && ! showPlaceholder && (\n\t\t\t\t<TagName { ...innerBlocksProps } />\n\t\t\t) }\n\t\t\t{ /* Ideally this is not needed but it's there for backward compatibility reason\n\t\t\t\tto keep this div for themes that might rely on its presence */ }\n\t\t\t{ ! layoutSupportEnabled && ! showPlaceholder && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default GroupEdit;\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/group/edit.js"],"names":["useDispatch","useSelect","InnerBlocks","useBlockProps","InspectorControls","useInnerBlocksProps","useSetting","store","blockEditorStore","SelectControl","__","GroupPlaceHolder","useShouldShowPlaceHolder","GroupEditControls","tagName","onSelectTagName","htmlElementMessages","header","main","section","article","aside","footer","label","value","GroupEdit","attributes","name","setAttributes","clientId","__unstableLayoutClassNames","layoutClassNames","hasInnerBlocks","themeSupportsLayout","select","getBlock","getSettings","block","innerBlocks","length","supportsLayout","TagName","templateLock","layout","defaultLayout","usedLayout","type","layoutSupportEnabled","blockProps","className","showPlaceholder","setShowPlaceholder","usedLayoutType","innerBlocksProps","renderAppender","undefined","ButtonBlockAppender","__experimentalLayout","__unstableDisableLayoutClassNames","selectBlock","selectVariation","nextVariation"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,SAAtB,QAAuC,iBAAvC;AACA,SACCC,WADD,EAECC,aAFD,EAGCC,iBAHD,EAICC,mBAJD,EAKCC,UALD,EAMCC,KAAK,IAAIC,gBANV,QAOO,yBAPP;AAQA,SAASC,aAAT,QAA8B,uBAA9B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;;AACA,OAAOC,gBAAP,IAA2BC,wBAA3B,QAA2D,eAA3D;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,SAASC,iBAAT,OAA2D;AAAA,MAA/B;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,GAA+B;AAC1D,QAAMC,mBAAmB,GAAG;AAC3BC,IAAAA,MAAM,EAAEP,EAAE,CACT,qHADS,CADiB;AAI3BQ,IAAAA,IAAI,EAAER,EAAE,CACP,mFADO,CAJmB;AAO3BS,IAAAA,OAAO,EAAET,EAAE,CACV,kIADU,CAPgB;AAU3BU,IAAAA,OAAO,EAAEV,EAAE,CACV,gGADU,CAVgB;AAa3BW,IAAAA,KAAK,EAAEX,EAAE,CACR,uI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AAgB,GAAGhD,mBAAmB,CAC3C0C,oBAAoB,GACjBC,UADiB,GAEjB;AAAEC,IAAAA,SAAS,EAAE;AAAb,GAHwC,EAI3C;AACCP,IAAAA,YADD;AAECY,IAAAA,cAAc,EAAEtB,cAAc,GAC3BuB,SAD2B,GAE3BrD,WAAW,CAACsD,mBAJhB;AAKCC,IAAAA,oBAAoB,EAAEV,oBAAoB,GAAGF,UAAH,GAAgBU,SAL3D;AAMCG,IAAAA,iCAAiC,EAAE,CAAEX;AANtC,GAJ2C,CAA5C;AAcA,QAAM;AAAEY,IAAAA;AAAF,MAAkB3D,WAAW,CAAEQ,gBAAF,CAAnC;;AAEA,QAAMoD,eAAe,GAAKC,aAAF,IAAqB;AAC5CjC,IAAAA,aAAa,CAAEiC,aAAa,CAACnC,UAAhB,CAAb;AACAiC,IAAAA,WAAW,CAAE9B,QAAF,EAAY,CAAC,CAAb,CAAX;AACAsB,IAAAA,kBAAkB,CAAE,KAAF,CAAlB;AACA,GAJD;;AAMA,SACC,8BACC,cAAC,iBAAD;AACC,IAAA,OAAO,EAAGV,OADX;AAEC,IAAA,eAAe,EAAKjB,KAAF,IACjBI,aAAa,CAAE;AAAEd,MAAAA,OAAO,EAAEU;AAAX,KAAF;AAHf,IADD,EAOG0B,eAAe,IAChB,cAAC,gBAAD;AACC,IAAA,QAAQ,EAAGrB,QADZ;AAEC,IAAA,IAAI,EAAGF,IAFR;AAGC,IAAA,QAAQ,EAAGiC;AAHZ,IARF,EAcGb,oBAAoB,IAAI,CAAEG,eAA1B,IACD,cAAC,OAAD,EAAcG,gBAAd,CAfF,EAmBG,CAAEN,oBAAF,IAA0B,CAAEG,eAA5B,IACD,cAAC,OAAD,EAAcF,UAAd,EACC,qBAAUK,gBAAV,CADD,CApBF,CADD;AA2BA;;AAED,eAAe5B,SAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport {\n\tInnerBlocks,\n\tuseBlockProps,\n\tInspectorControls,\n\tuseInnerBlocksProps,\n\tuseSetting,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\nimport { SelectControl } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport GroupPlaceHolder, { useShouldShowPlaceHolder } from './placeholder';\n\n/**\n * Render inspector controls for the Group block.\n *\n * @param {Object} props Component props.\n * @param {string} props.tagName The HTML tag name.\n * @param {Function} props.onSelectTagName onChange function for the SelectControl.\n *\n * @return {JSX.Element} The control group.\n */\nfunction GroupEditControls( { tagName, onSelectTagName } ) {\n\tconst htmlElementMessages = {\n\t\theader: __(\n\t\t\t'The <header> element should represent introductory content, typically a group of introductory or navigational aids.'\n\t\t),\n\t\tmain: __(\n\t\t\t'The <main> element should be used for the primary content of your document only. '\n\t\t),\n\t\tsection: __(\n\t\t\t\"The <section> element should represent a standalone portion of the document that can't be better represented by another element.\"\n\t\t),\n\t\tarticle: __(\n\t\t\t'The <article> element should represent a self-contained, syndicatable portion of the document.'\n\t\t),\n\t\taside: __(\n\t\t\t\"The <aside> element should represent a portion of a document whose content is only indirectly related to the document's main content.\"\n\t\t),\n\t\tfooter: __(\n\t\t\t'The <footer> element should represent a footer for its nearest sectioning element (e.g.: <section>, <article>, <main> etc.).'\n\t\t),\n\t};\n\treturn (\n\t\t<InspectorControls __experimentalGroup=\"advanced\">\n\t\t\t<SelectControl\n\t\t\t\tlabel={ __( 'HTML element' ) }\n\t\t\t\toptions={ [\n\t\t\t\t\t{ label: __( 'Default (<div>)' ), value: 'div' },\n\t\t\t\t\t{ label: '<header>', value: 'header' },\n\t\t\t\t\t{ label: '<main>', value: 'main' },\n\t\t\t\t\t{ label: '<section>', value: 'section' },\n\t\t\t\t\t{ label: '<article>', value: 'article' },\n\t\t\t\t\t{ label: '<aside>', value: 'aside' },\n\t\t\t\t\t{ label: '<footer>', value: 'footer' },\n\t\t\t\t] }\n\t\t\t\tvalue={ tagName }\n\t\t\t\tonChange={ onSelectTagName }\n\t\t\t\thelp={ htmlElementMessages[ tagName ] }\n\t\t\t/>\n\t\t</InspectorControls>\n\t);\n}\n\nfunction GroupEdit( {\n\tattributes,\n\tname,\n\tsetAttributes,\n\tclientId,\n\t__unstableLayoutClassNames: layoutClassNames,\n} ) {\n\tconst { hasInnerBlocks, themeSupportsLayout } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, getSettings } = select( blockEditorStore );\n\t\t\tconst block = getBlock( clientId );\n\t\t\treturn {\n\t\t\t\thasInnerBlocks: !! ( block && block.innerBlocks.length ),\n\t\t\t\tthemeSupportsLayout: getSettings()?.supportsLayout,\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { tagName: TagName = 'div', templateLock, layout = {} } = attributes;\n\n\t// Layout settings.\n\tconst defaultLayout = useSetting( 'layout' ) || {};\n\tconst usedLayout = ! layout?.type\n\t\t? { ...defaultLayout, ...layout, type: 'default' }\n\t\t: { ...defaultLayout, ...layout };\n\tconst { type = 'default' } = usedLayout;\n\tconst layoutSupportEnabled = themeSupportsLayout || type === 'flex';\n\n\t// Hooks.\n\tconst blockProps = useBlockProps( {\n\t\tclassName: ! layoutSupportEnabled ? layoutClassNames : null,\n\t} );\n\tconst [ showPlaceholder, setShowPlaceholder ] = useShouldShowPlaceHolder( {\n\t\tattributes,\n\t\tusedLayoutType: usedLayout?.type,\n\t\thasInnerBlocks,\n\t} );\n\tconst innerBlocksProps = useInnerBlocksProps(\n\t\tlayoutSupportEnabled\n\t\t\t? blockProps\n\t\t\t: { className: 'wp-block-group__inner-container' },\n\t\t{\n\t\t\ttemplateLock,\n\t\t\trenderAppender: hasInnerBlocks\n\t\t\t\t? undefined\n\t\t\t\t: InnerBlocks.ButtonBlockAppender,\n\t\t\t__experimentalLayout: layoutSupportEnabled ? usedLayout : undefined,\n\t\t\t__unstableDisableLayoutClassNames: ! layoutSupportEnabled,\n\t\t}\n\t);\n\n\tconst { selectBlock } = useDispatch( blockEditorStore );\n\n\tconst selectVariation = ( nextVariation ) => {\n\t\tsetAttributes( nextVariation.attributes );\n\t\tselectBlock( clientId, -1 );\n\t\tsetShowPlaceholder( false );\n\t};\n\n\treturn (\n\t\t<>\n\t\t\t<GroupEditControls\n\t\t\t\ttagName={ TagName }\n\t\t\t\tonSelectTagName={ ( value ) =>\n\t\t\t\t\tsetAttributes( { tagName: value } )\n\t\t\t\t}\n\t\t\t/>\n\t\t\t{ showPlaceholder && (\n\t\t\t\t<GroupPlaceHolder\n\t\t\t\t\tclientId={ clientId }\n\t\t\t\t\tname={ name }\n\t\t\t\t\tonSelect={ selectVariation }\n\t\t\t\t/>\n\t\t\t) }\n\t\t\t{ layoutSupportEnabled && ! showPlaceholder && (\n\t\t\t\t<TagName { ...innerBlocksProps } />\n\t\t\t) }\n\t\t\t{ /* Ideally this is not needed but it's there for backward compatibility reason\n\t\t\t\tto keep this div for themes that might rely on its presence */ }\n\t\t\t{ ! layoutSupportEnabled && ! showPlaceholder && (\n\t\t\t\t<TagName { ...blockProps }>\n\t\t\t\t\t<div { ...innerBlocksProps } />\n\t\t\t\t</TagName>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default GroupEdit;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/group/index.js"],"names":["__","group","icon","initBlock","deprecated","edit","save","transforms","variations","name","metadata","settings","example","attributes","style","color","text","background","innerBlocks","customTextColor","fontSize","content","init"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,IAAlB,QAA8B,kBAA9B;AAEA;AACA;AACA;;AACA,OAAOC,SAAP,MAAsB,qBAAtB;AACA,OAAOC,UAAP,MAAuB,cAAvB;AACA,OAAOC,IAAP,MAAiB,QAAjB
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/group/index.js"],"names":["__","group","icon","initBlock","deprecated","edit","save","transforms","variations","name","metadata","settings","example","attributes","style","color","text","background","inner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Ae,EAAE,SADN;AAEXC,QAAAA,QAAQ,EAAE,OAFC;AAGXC,QAAAA,OAAO,EAAErB,EAAE,CAAE,QAAF;AAHA;AAFb,KAjBY,EAyBZ;AACCS,MAAAA,IAAI,EAAE,gBADP;AAECI,MAAAA,UAAU,EAAE;AACXM,QAAAA,eAAe,EAAE,SADN;AAEXC,QAAAA,QAAQ,EAAE,OAFC;AAGXC,QAAAA,OAAO,EAAErB,EAAE,CAAE,OAAF;AAHA;AAFb,KAzBY,EAiCZ;AACCS,MAAAA,IAAI,EAAE,gBADP;AAECI,MAAAA,UAAU,EAAE;AACXM,QAAAA,eAAe,EAAE,SADN;AAEXC,QAAAA,QAAQ,EAAE,OAFC;AAGXC,QAAAA,OAAO,EAAErB,EAAE,CAAE,OAAF;AAHA;AAFb,KAjCY,EAyCZ;AACCS,MAAAA,IAAI,EAAE,gBADP;AAECI,MAAAA,UAAU,EAAE;AACXM,QAAAA,eAAe,EAAE,SADN;AAEXC,QAAAA,QAAQ,EAAE,OAFC;AAGXC,QAAAA,OAAO,EAAErB,EAAE,CAAE,MAAF;AAHA;AAFb,KAzCY;AATL,GAFc;AA8DvBO,EAAAA,UA9DuB;AA+DvBF,EAAAA,IA/DuB;AAgEvBC,EAAAA,IAhEuB;AAiEvBF,EAAAA,UAjEuB;AAkEvBI,EAAAA;AAlEuB,CAAjB;AAqEP,OAAO,MAAMc,IAAI,GAAG,MAAMnB,SAAS,CAAE;AAAEM,EAAAA,IAAF;AAAQC,EAAAA,QAAR;AAAkBC,EAAAA;AAAlB,CAAF,CAA5B","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { group as icon } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport initBlock from '../utils/init-block';\nimport deprecated from './deprecated';\nimport edit from './edit';\nimport metadata from './block.json';\nimport save from './save';\nimport transforms from './transforms';\nimport variations from './variations';\n\nconst { name } = metadata;\n\nexport { metadata, name };\n\nexport const settings = {\n\ticon,\n\texample: {\n\t\tattributes: {\n\t\t\tstyle: {\n\t\t\t\tcolor: {\n\t\t\t\t\ttext: '#000000',\n\t\t\t\t\tbackground: '#ffffff',\n\t\t\t\t},\n\t\t\t},\n\t\t},\n\t\tinnerBlocks: [\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcustomTextColor: '#cf2e2e',\n\t\t\t\t\tfontSize: 'large',\n\t\t\t\t\tcontent: __( 'One.' ),\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcustomTextColor: '#ff6900',\n\t\t\t\t\tfontSize: 'large',\n\t\t\t\t\tcontent: __( 'Two.' ),\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcustomTextColor: '#fcb900',\n\t\t\t\t\tfontSize: 'large',\n\t\t\t\t\tcontent: __( 'Three.' ),\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcustomTextColor: '#00d084',\n\t\t\t\t\tfontSize: 'large',\n\t\t\t\t\tcontent: __( 'Four.' ),\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcustomTextColor: '#0693e3',\n\t\t\t\t\tfontSize: 'large',\n\t\t\t\t\tcontent: __( 'Five.' ),\n\t\t\t\t},\n\t\t\t},\n\t\t\t{\n\t\t\t\tname: 'core/paragraph',\n\t\t\t\tattributes: {\n\t\t\t\t\tcustomTextColor: '#9b51e0',\n\t\t\t\t\tfontSize: 'large',\n\t\t\t\t\tcontent: __( 'Six.' ),\n\t\t\t\t},\n\t\t\t},\n\t\t],\n\t},\n\ttransforms,\n\tedit,\n\tsave,\n\tdeprecated,\n\tvariations,\n};\n\nexport const init = () => initBlock( { name, metadata, settings } );\n"]}
|
|
@@ -26,8 +26,7 @@ const getGroupPlaceholderIcons = function () {
|
|
|
26
26
|
height: "32",
|
|
27
27
|
viewBox: "0 0 44 32"
|
|
28
28
|
}, createElement(Path, {
|
|
29
|
-
d: "M42 0H2C.9 0 0 .9 0 2v28c0 1.1.9 2 2 2h40c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2z"
|
|
30
|
-
|
|
29
|
+
d: "M42 0H2C.9 0 0 .9 0 2v28c0 1.1.9 2 2 2h40c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2z"
|
|
31
30
|
})),
|
|
32
31
|
'group-row': createElement(SVG, {
|
|
33
32
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -35,8 +34,7 @@ const getGroupPlaceholderIcons = function () {
|
|
|
35
34
|
height: "32",
|
|
36
35
|
viewBox: "0 0 44 32"
|
|
37
36
|
}, createElement(Path, {
|
|
38
|
-
d: "M42 0H23.5c-.6 0-1 .4-1 1v30c0 .6.4 1 1 1H42c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2zM20.5 0H2C.9 0 0 .9 0 2v28c0 1.1.9 2 2 2h18.5c.6 0 1-.4 1-1V1c0-.6-.4-1-1-1z"
|
|
39
|
-
|
|
37
|
+
d: "M42 0H23.5c-.6 0-1 .4-1 1v30c0 .6.4 1 1 1H42c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2zM20.5 0H2C.9 0 0 .9 0 2v28c0 1.1.9 2 2 2h18.5c.6 0 1-.4 1-1V1c0-.6-.4-1-1-1z"
|
|
40
38
|
})),
|
|
41
39
|
'group-stack': createElement(SVG, {
|
|
42
40
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -44,8 +42,7 @@ const getGroupPlaceholderIcons = function () {
|
|
|
44
42
|
height: "32",
|
|
45
43
|
viewBox: "0 0 44 32"
|
|
46
44
|
}, createElement(Path, {
|
|
47
|
-
d: "M42 0H2C.9 0 0 .9 0 2v12.5c0 .6.4 1 1 1h42c.6 0 1-.4 1-1V2c0-1.1-.9-2-2-2zm1 16.5H1c-.6 0-1 .4-1 1V30c0 1.1.9 2 2 2h40c1.1 0 2-.9 2-2V17.5c0-.6-.4-1-1-1z"
|
|
48
|
-
|
|
45
|
+
d: "M42 0H2C.9 0 0 .9 0 2v12.5c0 .6.4 1 1 1h42c.6 0 1-.4 1-1V2c0-1.1-.9-2-2-2zm1 16.5H1c-.6 0-1 .4-1 1V30c0 1.1.9 2 2 2h40c1.1 0 2-.9 2-2V17.5c0-.6-.4-1-1-1z"
|
|
49
46
|
}))
|
|
50
47
|
};
|
|
51
48
|
return icons === null || icons === void 0 ? void 0 : icons[name];
|
|
@@ -110,28 +107,10 @@ function GroupPlaceHolder(_ref2) {
|
|
|
110
107
|
name,
|
|
111
108
|
onSelect
|
|
112
109
|
} = _ref2;
|
|
113
|
-
const
|
|
114
|
-
defaultVariation,
|
|
115
|
-
variations
|
|
116
|
-
} = useSelect(select => {
|
|
117
|
-
const {
|
|
118
|
-
getBlockVariations,
|
|
119
|
-
getDefaultBlockVariation
|
|
120
|
-
} = select(blocksStore);
|
|
121
|
-
return {
|
|
122
|
-
defaultVariation: getDefaultBlockVariation(name, 'block'),
|
|
123
|
-
variations: getBlockVariations(name, 'block') || []
|
|
124
|
-
};
|
|
125
|
-
}, [name]);
|
|
110
|
+
const variations = useSelect(select => select(blocksStore).getBlockVariations(name, 'block'), [name]);
|
|
126
111
|
const blockProps = useBlockProps({
|
|
127
112
|
className: 'wp-block-group__placeholder'
|
|
128
113
|
});
|
|
129
|
-
|
|
130
|
-
const selectVariation = function () {
|
|
131
|
-
let nextVariation = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : defaultVariation;
|
|
132
|
-
return onSelect(nextVariation);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
114
|
return createElement("div", blockProps, createElement(Placeholder, {
|
|
136
115
|
instructions: __('Group blocks together. Select a layout:')
|
|
137
116
|
}, createElement("ul", {
|
|
@@ -144,7 +123,7 @@ function GroupPlaceHolder(_ref2) {
|
|
|
144
123
|
variant: "tertiary",
|
|
145
124
|
icon: getGroupPlaceholderIcons(variation.name),
|
|
146
125
|
iconSize: 44,
|
|
147
|
-
onClick: () =>
|
|
126
|
+
onClick: () => onSelect(variation),
|
|
148
127
|
className: "wp-block-group-placeholder__variation-button",
|
|
149
128
|
label: `${variation.title}: ${variation.description}`
|
|
150
129
|
}))))));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/group/placeholder.js"],"names":["useSelect","useBlockProps","__","store","blocksStore","Path","SVG","Button","Placeholder","useState","useEffect","getGroupPlaceholderIcons","name","icons","group","useShouldShowPlaceHolder","attributes","style","undefined","backgroundColor","textColor","fontSize","usedLayoutType","hasInnerBlocks","showPlaceholder","setShowPlaceholder","GroupPlaceHolder","onSelect","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/group/placeholder.js"],"names":["useSelect","useBlockProps","__","store","blocksStore","Path","SVG","Button","Placeholder","useState","useEffect","getGroupPlaceholderIcons","name","icons","group","useShouldShowPlaceHolder","attributes","style","undefined","backgroundColor","textColor","fontSize","usedLayoutType","hasInnerBlocks","showPlaceholder","setShowPlaceholder","GroupPlaceHolder","onSelect","variations","select","getBlockVariations","blockProps","className","map","variation","title","description"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,SAAT,QAA0B,iBAA1B;AACA,SAASC,aAAT,QAA8B,yBAA9B;AACA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,KAAK,IAAIC,WAAlB,QAAqC,mBAArC;AACA,SAASC,IAAT,EAAeC,GAAf,EAAoBC,MAApB,EAA4BC,WAA5B,QAA+C,uBAA/C;AACA,SAASC,QAAT,EAAmBC,SAAnB,QAAoC,oBAApC;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,wBAAwB,GAAG,YAAsB;AAAA,MAApBC,IAAoB,uEAAb,OAAa;A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tB;AAApB,KACC,cAAC,MAAD;AACC,IAAA,OAAO,EAAC,UADT;AAEC,IAAA,IAAI,EAAGD,wBAAwB,CAC9BuB,SAAS,CAACtB,IADoB,CAFhC;AAKC,IAAA,QAAQ,EAAG,EALZ;AAMC,IAAA,OAAO,EAAG,MAAMe,QAAQ,CAAEO,SAAF,CANzB;AAOC,IAAA,SAAS,EAAC,8CAPX;AAQC,IAAA,KAAK,EAAI,GAAGA,SAAS,CAACC,KAAO,KAAKD,SAAS,CAACE,WAAa;AAR1D,IADD,CADC,CALH,CATD,CADD,CADD;AAmCA;;AAED,eAAeV,gBAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useBlockProps } from '@wordpress/block-editor';\nimport { __ } from '@wordpress/i18n';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { Path, SVG, Button, Placeholder } from '@wordpress/components';\nimport { useState, useEffect } from '@wordpress/element';\n\n/**\n * Returns a custom variation icon.\n *\n * @param {string} name The block variation name.\n *\n * @return {JSX.Element} The SVG element.\n */\nconst getGroupPlaceholderIcons = ( name = 'group' ) => {\n\tconst icons = {\n\t\tgroup: (\n\t\t\t<SVG\n\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\twidth=\"44\"\n\t\t\t\theight=\"32\"\n\t\t\t\tviewBox=\"0 0 44 32\"\n\t\t\t>\n\t\t\t\t<Path d=\"M42 0H2C.9 0 0 .9 0 2v28c0 1.1.9 2 2 2h40c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2z\" />\n\t\t\t</SVG>\n\t\t),\n\t\t'group-row': (\n\t\t\t<SVG\n\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\twidth=\"44\"\n\t\t\t\theight=\"32\"\n\t\t\t\tviewBox=\"0 0 44 32\"\n\t\t\t>\n\t\t\t\t<Path d=\"M42 0H23.5c-.6 0-1 .4-1 1v30c0 .6.4 1 1 1H42c1.1 0 2-.9 2-2V2c0-1.1-.9-2-2-2zM20.5 0H2C.9 0 0 .9 0 2v28c0 1.1.9 2 2 2h18.5c.6 0 1-.4 1-1V1c0-.6-.4-1-1-1z\" />\n\t\t\t</SVG>\n\t\t),\n\t\t'group-stack': (\n\t\t\t<SVG\n\t\t\t\txmlns=\"http://www.w3.org/2000/svg\"\n\t\t\t\twidth=\"44\"\n\t\t\t\theight=\"32\"\n\t\t\t\tviewBox=\"0 0 44 32\"\n\t\t\t>\n\t\t\t\t<Path d=\"M42 0H2C.9 0 0 .9 0 2v12.5c0 .6.4 1 1 1h42c.6 0 1-.4 1-1V2c0-1.1-.9-2-2-2zm1 16.5H1c-.6 0-1 .4-1 1V30c0 1.1.9 2 2 2h40c1.1 0 2-.9 2-2V17.5c0-.6-.4-1-1-1z\" />\n\t\t\t</SVG>\n\t\t),\n\t};\n\treturn icons?.[ name ];\n};\n\n/**\n * A custom hook to tell the Group block whether to show the variation placeholder.\n *\n * @param {Object} props Arguments to pass to hook.\n * @param {Object} [props.attributes] The block's attributes.\n * @param {string} [props.usedLayoutType] The block's current layout type.\n * @param {boolean} [props.hasInnerBlocks] Whether the block has inner blocks.\n *\n * @return {[boolean, Function]} A state value and setter function.\n */\nexport function useShouldShowPlaceHolder( {\n\tattributes = {\n\t\tstyle: undefined,\n\t\tbackgroundColor: undefined,\n\t\ttextColor: undefined,\n\t\tfontSize: undefined,\n\t},\n\tusedLayoutType = '',\n\thasInnerBlocks = false,\n} ) {\n\tconst { style, backgroundColor, textColor, fontSize } = attributes;\n\t/*\n\t * Shows the placeholder when no known styles are set,\n\t * or when a non-default layout has been selected.\n\t * Should the Group block support more style presets in the\n\t * future, e.g., attributes.spacingSize, we can add them to the\n\t * condition.\n\t */\n\tconst [ showPlaceholder, setShowPlaceholder ] = useState(\n\t\t! hasInnerBlocks &&\n\t\t\t! backgroundColor &&\n\t\t\t! fontSize &&\n\t\t\t! textColor &&\n\t\t\t! style &&\n\t\t\tusedLayoutType !== 'flex'\n\t);\n\n\tuseEffect( () => {\n\t\tif (\n\t\t\t!! hasInnerBlocks ||\n\t\t\t!! backgroundColor ||\n\t\t\t!! fontSize ||\n\t\t\t!! textColor ||\n\t\t\t!! style ||\n\t\t\tusedLayoutType === 'flex'\n\t\t) {\n\t\t\tsetShowPlaceholder( false );\n\t\t}\n\t}, [\n\t\tbackgroundColor,\n\t\tfontSize,\n\t\ttextColor,\n\t\tstyle,\n\t\tusedLayoutType,\n\t\thasInnerBlocks,\n\t] );\n\n\treturn [ showPlaceholder, setShowPlaceholder ];\n}\n\n/**\n * Display group variations if none is selected.\n *\n * @param {Object} props Component props.\n * @param {string} props.name The block's name.\n * @param {Function} props.onSelect Function to set block's attributes.\n *\n * @return {JSX.Element} The placeholder.\n */\nfunction GroupPlaceHolder( { name, onSelect } ) {\n\tconst variations = useSelect(\n\t\t( select ) => select( blocksStore ).getBlockVariations( name, 'block' ),\n\t\t[ name ]\n\t);\n\tconst blockProps = useBlockProps( {\n\t\tclassName: 'wp-block-group__placeholder',\n\t} );\n\treturn (\n\t\t<div { ...blockProps }>\n\t\t\t<Placeholder\n\t\t\t\tinstructions={ __( 'Group blocks together. Select a layout:' ) }\n\t\t\t>\n\t\t\t\t{ /*\n\t\t\t\t * Taken from BlockVariationPicker component.\n\t\t\t\t * Disable reason: The `list` ARIA role is redundant but\n\t\t\t\t * Safari+VoiceOver won't announce the list otherwise.\n\t\t\t\t */\n\t\t\t\t/* eslint-disable jsx-a11y/no-redundant-roles */ }\n\t\t\t\t<ul\n\t\t\t\t\trole=\"list\"\n\t\t\t\t\tclassName=\"wp-block-group-placeholder__variations\"\n\t\t\t\t\taria-label={ __( 'Block variations' ) }\n\t\t\t\t>\n\t\t\t\t\t{ variations.map( ( variation ) => (\n\t\t\t\t\t\t<li key={ variation.name }>\n\t\t\t\t\t\t\t<Button\n\t\t\t\t\t\t\t\tvariant=\"tertiary\"\n\t\t\t\t\t\t\t\ticon={ getGroupPlaceholderIcons(\n\t\t\t\t\t\t\t\t\tvariation.name\n\t\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t\t\ticonSize={ 44 }\n\t\t\t\t\t\t\t\tonClick={ () => onSelect( variation ) }\n\t\t\t\t\t\t\t\tclassName=\"wp-block-group-placeholder__variation-button\"\n\t\t\t\t\t\t\t\tlabel={ `${ variation.title }: ${ variation.description }` }\n\t\t\t\t\t\t\t/>\n\t\t\t\t\t\t</li>\n\t\t\t\t\t) ) }\n\t\t\t\t</ul>\n\t\t\t\t{ /* eslint-enable jsx-a11y/no-redundant-roles */ }\n\t\t\t</Placeholder>\n\t\t</div>\n\t);\n}\n\nexport default GroupPlaceHolder;\n"]}
|