@wordpress/block-library 7.5.0 → 7.6.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 +6 -0
- package/README.md +3 -2
- package/babel-plugin.js +154 -0
- package/build/audio/edit.js +1 -1
- package/build/audio/edit.js.map +1 -1
- package/build/block/edit.js +10 -9
- package/build/block/edit.js.map +1 -1
- package/build/button/index.js +1 -0
- package/build/button/index.js.map +1 -1
- package/build/categories/edit.js +1 -1
- package/build/categories/edit.js.map +1 -1
- package/build/categories/index.js +1 -1
- package/build/comment-author-avatar/index.js +1 -0
- package/build/comment-author-avatar/index.js.map +1 -1
- package/build/comments-title/deprecated.js +110 -0
- package/build/comments-title/deprecated.js.map +1 -0
- package/build/comments-title/edit.js +35 -37
- package/build/comments-title/edit.js.map +1 -1
- package/build/comments-title/index.js +5 -8
- package/build/comments-title/index.js.map +1 -1
- package/build/cover/controls.native.js +2 -3
- package/build/cover/controls.native.js.map +1 -1
- package/build/cover/edit/block-controls.js +115 -0
- package/build/cover/edit/block-controls.js.map +1 -0
- package/build/cover/edit/cover-placeholder.js +49 -0
- package/build/cover/edit/cover-placeholder.js.map +1 -0
- package/build/cover/edit/index.js +333 -0
- package/build/cover/edit/index.js.map +1 -0
- package/build/cover/edit/inspector-controls.js +224 -0
- package/build/cover/edit/inspector-controls.js.map +1 -0
- package/build/cover/edit/resizable-cover.js +67 -0
- package/build/cover/edit/resizable-cover.js.map +1 -0
- package/build/cover/{use-cover-is-dark.js → edit/use-cover-is-dark.js} +0 -0
- package/build/cover/edit/use-cover-is-dark.js.map +1 -0
- package/build/cover/edit.native.js +0 -1
- package/build/cover/edit.native.js.map +1 -1
- package/build/cover/focal-point-settings-button.native.js.map +1 -1
- package/build/cover/shared.js +9 -0
- package/build/cover/shared.js.map +1 -1
- package/build/embed/embed-preview.js +1 -1
- package/build/embed/embed-preview.js.map +1 -1
- package/build/file/edit.native.js +0 -1
- package/build/file/edit.native.js.map +1 -1
- package/build/gallery/edit.js +2 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.js +1 -1
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/shared.js +2 -2
- package/build/gallery/shared.js.map +1 -1
- package/build/gallery/use-get-media.js +2 -1
- package/build/gallery/use-get-media.js.map +1 -1
- package/build/gallery/use-short-code-transform.js +19 -18
- package/build/gallery/use-short-code-transform.js.map +1 -1
- package/build/gallery/v1/gallery.js +1 -1
- package/build/gallery/v1/gallery.js.map +1 -1
- package/build/heading/edit.js +6 -2
- package/build/heading/edit.js.map +1 -1
- package/build/heading/index.js +1 -0
- package/build/heading/index.js.map +1 -1
- package/build/heading/transforms.js +1 -0
- package/build/heading/transforms.js.map +1 -1
- package/build/image/edit.js +5 -2
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +0 -1
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +1 -1
- package/build/image/image.js.map +1 -1
- package/build/index.js +46 -10
- package/build/index.js.map +1 -1
- package/build/is-block-metadata-experimental.js +18 -0
- package/build/is-block-metadata-experimental.js.map +1 -0
- package/build/latest-posts/edit.js +30 -4
- package/build/latest-posts/edit.js.map +1 -1
- package/build/list/transforms.js +6 -0
- package/build/list/transforms.js.map +1 -1
- package/build/list/v2/edit.js +2 -1
- package/build/list/v2/edit.js.map +1 -1
- package/build/list/v2/migrate.js +1 -0
- package/build/list/v2/migrate.js.map +1 -1
- package/build/list/v2/transforms.js +46 -9
- package/build/list/v2/transforms.js.map +1 -1
- package/build/list-item/edit.js +7 -9
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/index.js +24 -0
- package/build/list-item/hooks/index.js.map +1 -1
- package/build/list-item/hooks/use-backspace.js +59 -0
- package/build/list-item/hooks/use-backspace.js.map +1 -0
- package/build/list-item/hooks/use-enter.js +6 -9
- package/build/list-item/hooks/use-enter.js.map +1 -1
- package/build/list-item/hooks/use-indent-list-item.js +33 -39
- package/build/list-item/hooks/use-indent-list-item.js.map +1 -1
- package/build/list-item/hooks/use-space.js +54 -0
- package/build/list-item/hooks/use-space.js.map +1 -0
- package/build/list-item/hooks/use-split.js +30 -0
- package/build/list-item/hooks/use-split.js.map +1 -0
- package/build/list-item/index.js +1 -0
- package/build/list-item/index.js.map +1 -1
- package/build/list-item/utils.js +1 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/media-text/edit.native.js +2 -1
- package/build/media-text/edit.native.js.map +1 -1
- package/build/media-text/media-container.native.js +2 -4
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/media-text/transforms.js +137 -8
- package/build/media-text/transforms.js.map +1 -1
- package/build/navigation/edit/index.js +86 -81
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +1 -5
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/use-navigation-entities.js +3 -3
- package/build/navigation/use-navigation-entities.js.map +1 -1
- package/build/navigation-link/fallback-variations.js +1 -1
- package/build/navigation-link/fallback-variations.js.map +1 -1
- package/build/navigation-link/hooks.js +1 -1
- package/build/navigation-link/hooks.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +1 -1
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/edit.js +1 -1
- package/build/page-list/edit.js.map +1 -1
- package/build/post-author/edit.js +1 -1
- package/build/post-author/edit.js.map +1 -1
- package/build/post-author-name/index.js +1 -0
- package/build/post-author-name/index.js.map +1 -1
- package/build/post-comment/index.js +1 -0
- package/build/post-comment/index.js.map +1 -1
- package/build/post-comments/edit.js +34 -16
- package/build/post-comments/edit.js.map +1 -1
- package/build/post-comments-count/index.js +1 -0
- package/build/post-comments-count/index.js.map +1 -1
- package/build/post-comments-form/form.js +1 -1
- package/build/post-comments-form/form.js.map +1 -1
- package/build/post-comments-link/index.js +1 -0
- package/build/post-comments-link/index.js.map +1 -1
- package/build/post-featured-image/edit.js +1 -1
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-template/edit.js +7 -2
- package/build/post-template/edit.js.map +1 -1
- package/build/post-terms/edit.js +11 -2
- package/build/post-terms/edit.js.map +1 -1
- package/build/post-terms/hooks.js +33 -0
- package/build/post-terms/hooks.js.map +1 -0
- package/build/post-terms/index.js +12 -5
- package/build/post-terms/index.js.map +1 -1
- package/build/post-title/index.js +1 -1
- package/build/post-title/index.js.map +1 -1
- package/build/pullquote/edit.js +1 -1
- package/build/pullquote/edit.js.map +1 -1
- package/build/pullquote/edit.native.js +1 -1
- package/build/pullquote/edit.native.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +26 -17
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/parent-control.js +148 -0
- package/build/query/edit/inspector-controls/parent-control.js.map +1 -0
- package/build/query/edit/inspector-controls/sticky-control.js +41 -0
- package/build/query/edit/inspector-controls/sticky-control.js.map +1 -0
- package/build/query/index.js +2 -1
- package/build/query/index.js.map +1 -1
- package/build/query/utils.js +28 -2
- package/build/query/utils.js.map +1 -1
- package/build/query-title/index.js +1 -1
- package/build/query-title/index.js.map +1 -1
- package/build/query-title/variations.js +1 -1
- package/build/query-title/variations.js.map +1 -1
- package/build/quote/edit.js +3 -2
- package/build/quote/edit.js.map +1 -1
- package/build/quote/v2/edit.js +1 -1
- package/build/quote/v2/edit.js.map +1 -1
- package/build/search/edit.js +1 -0
- package/build/search/edit.js.map +1 -1
- package/build/site-logo/edit.js +1 -1
- package/build/site-logo/edit.js.map +1 -1
- package/build/table/edit.js +15 -2
- package/build/table/edit.js.map +1 -1
- package/build/table-of-contents/edit.js +138 -66
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/table-of-contents/index.js +13 -3
- package/build/table-of-contents/index.js.map +1 -1
- package/build/table-of-contents/list.js +16 -9
- package/build/table-of-contents/list.js.map +1 -1
- package/build/table-of-contents/save.js +40 -0
- package/build/table-of-contents/save.js.map +1 -0
- package/build/table-of-contents/utils.js +11 -77
- package/build/table-of-contents/utils.js.map +1 -1
- package/build/template-part/edit/index.js +7 -3
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/inner-blocks.js +3 -8
- package/build/template-part/edit/inner-blocks.js.map +1 -1
- package/build/video/edit.js +1 -1
- package/build/video/edit.js.map +1 -1
- package/build-module/audio/edit.js +2 -2
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/block/edit.js +11 -10
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/index.js +1 -0
- package/build-module/button/index.js.map +1 -1
- package/build-module/categories/edit.js +1 -1
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/categories/index.js +1 -1
- package/build-module/comment-author-avatar/index.js +1 -0
- package/build-module/comment-author-avatar/index.js.map +1 -1
- package/build-module/comments-title/deprecated.js +102 -0
- package/build-module/comments-title/deprecated.js.map +1 -0
- package/build-module/comments-title/edit.js +38 -40
- package/build-module/comments-title/edit.js.map +1 -1
- package/build-module/comments-title/index.js +4 -8
- package/build-module/comments-title/index.js.map +1 -1
- package/build-module/cover/controls.native.js +2 -3
- package/build-module/cover/controls.native.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +104 -0
- package/build-module/cover/edit/block-controls.js.map +1 -0
- package/build-module/cover/edit/cover-placeholder.js +38 -0
- package/build-module/cover/edit/cover-placeholder.js.map +1 -0
- package/build-module/cover/edit/index.js +307 -0
- package/build-module/cover/edit/index.js.map +1 -0
- package/build-module/cover/edit/inspector-controls.js +215 -0
- package/build-module/cover/edit/inspector-controls.js.map +1 -0
- package/build-module/cover/edit/resizable-cover.js +55 -0
- package/build-module/cover/edit/resizable-cover.js.map +1 -0
- package/build-module/cover/{use-cover-is-dark.js → edit/use-cover-is-dark.js} +0 -0
- package/build-module/cover/edit/use-cover-is-dark.js.map +1 -0
- package/build-module/cover/edit.native.js +0 -1
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/cover/focal-point-settings-button.native.js.map +1 -1
- package/build-module/cover/shared.js +7 -0
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/embed/embed-preview.js +2 -2
- package/build-module/embed/embed-preview.js.map +1 -1
- package/build-module/file/edit.native.js +0 -1
- package/build-module/file/edit.native.js.map +1 -1
- package/build-module/gallery/edit.js +2 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.js +2 -2
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/shared.js +2 -2
- package/build-module/gallery/shared.js.map +1 -1
- package/build-module/gallery/use-get-media.js +2 -1
- package/build-module/gallery/use-get-media.js.map +1 -1
- package/build-module/gallery/use-short-code-transform.js +19 -18
- package/build-module/gallery/use-short-code-transform.js.map +1 -1
- package/build-module/gallery/v1/gallery.js +2 -2
- package/build-module/gallery/v1/gallery.js.map +1 -1
- package/build-module/heading/edit.js +6 -2
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/heading/index.js +1 -0
- package/build-module/heading/index.js.map +1 -1
- package/build-module/heading/transforms.js +1 -0
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/image/edit.js +6 -3
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +0 -1
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +2 -2
- package/build-module/image/image.js.map +1 -1
- package/build-module/index.js +42 -10
- package/build-module/index.js.map +1 -1
- package/build-module/is-block-metadata-experimental.js +16 -0
- package/build-module/is-block-metadata-experimental.js.map +1 -0
- package/build-module/latest-posts/edit.js +29 -5
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/list/transforms.js +6 -0
- package/build-module/list/transforms.js.map +1 -1
- package/build-module/list/v2/edit.js +2 -1
- package/build-module/list/v2/edit.js.map +1 -1
- package/build-module/list/v2/migrate.js +1 -3
- package/build-module/list/v2/migrate.js.map +1 -1
- package/build-module/list/v2/transforms.js +46 -9
- package/build-module/list/v2/transforms.js.map +1 -1
- package/build-module/list-item/edit.js +8 -9
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/index.js +3 -0
- package/build-module/list-item/hooks/index.js.map +1 -1
- package/build-module/list-item/hooks/use-backspace.js +44 -0
- package/build-module/list-item/hooks/use-backspace.js.map +1 -0
- package/build-module/list-item/hooks/use-enter.js +6 -9
- package/build-module/list-item/hooks/use-enter.js.map +1 -1
- package/build-module/list-item/hooks/use-indent-list-item.js +33 -38
- package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -1
- package/build-module/list-item/hooks/use-space.js +40 -0
- package/build-module/list-item/hooks/use-space.js.map +1 -0
- package/build-module/list-item/hooks/use-split.js +19 -0
- package/build-module/list-item/hooks/use-split.js.map +1 -0
- package/build-module/list-item/index.js +1 -0
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/list-item/utils.js +1 -1
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/media-text/edit.native.js +2 -1
- package/build-module/media-text/edit.native.js.map +1 -1
- package/build-module/media-text/media-container.native.js +2 -4
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/media-text/transforms.js +137 -8
- package/build-module/media-text/transforms.js.map +1 -1
- package/build-module/navigation/edit/index.js +87 -82
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +2 -6
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/use-navigation-entities.js +1 -1
- package/build-module/navigation/use-navigation-entities.js.map +1 -1
- package/build-module/navigation-link/fallback-variations.js +1 -1
- package/build-module/navigation-link/fallback-variations.js.map +1 -1
- package/build-module/navigation-link/hooks.js +2 -2
- package/build-module/navigation-link/hooks.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +1 -1
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/edit.js +1 -1
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/post-author/edit.js +1 -1
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-author-name/index.js +1 -0
- package/build-module/post-author-name/index.js.map +1 -1
- package/build-module/post-comment/index.js +1 -0
- package/build-module/post-comment/index.js.map +1 -1
- package/build-module/post-comments/edit.js +35 -16
- package/build-module/post-comments/edit.js.map +1 -1
- package/build-module/post-comments-count/index.js +1 -0
- package/build-module/post-comments-count/index.js.map +1 -1
- package/build-module/post-comments-form/form.js +1 -1
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/post-comments-link/index.js +1 -0
- package/build-module/post-comments-link/index.js.map +1 -1
- package/build-module/post-featured-image/edit.js +1 -1
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-template/edit.js +7 -2
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-terms/edit.js +10 -3
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/post-terms/hooks.js +25 -0
- package/build-module/post-terms/hooks.js.map +1 -0
- package/build-module/post-terms/index.js +10 -8
- package/build-module/post-terms/index.js.map +1 -1
- package/build-module/post-title/index.js +1 -1
- package/build-module/post-title/index.js.map +1 -1
- package/build-module/pullquote/edit.js +2 -2
- package/build-module/pullquote/edit.js.map +1 -1
- package/build-module/pullquote/edit.native.js +2 -2
- package/build-module/pullquote/edit.native.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +24 -17
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/parent-control.js +135 -0
- package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -0
- package/build-module/query/edit/inspector-controls/sticky-control.js +31 -0
- package/build-module/query/edit/inspector-controls/sticky-control.js.map +1 -0
- package/build-module/query/index.js +2 -1
- package/build-module/query/index.js.map +1 -1
- package/build-module/query/utils.js +21 -0
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query-title/index.js +1 -1
- package/build-module/query-title/index.js.map +1 -1
- package/build-module/query-title/variations.js +2 -2
- package/build-module/query-title/variations.js.map +1 -1
- package/build-module/quote/edit.js +4 -3
- package/build-module/quote/edit.js.map +1 -1
- package/build-module/quote/v2/edit.js +2 -2
- package/build-module/quote/v2/edit.js.map +1 -1
- package/build-module/search/edit.js +1 -0
- package/build-module/search/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +1 -1
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/table/edit.js +17 -4
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table-of-contents/edit.js +136 -68
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/table-of-contents/index.js +12 -3
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-module/table-of-contents/list.js +18 -10
- package/build-module/table-of-contents/list.js.map +1 -1
- package/build-module/table-of-contents/save.js +28 -0
- package/build-module/table-of-contents/save.js.map +1 -0
- package/build-module/table-of-contents/utils.js +11 -73
- package/build-module/table-of-contents/utils.js.map +1 -1
- package/build-module/template-part/edit/index.js +8 -4
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/inner-blocks.js +4 -9
- package/build-module/template-part/edit/inner-blocks.js.map +1 -1
- package/build-module/video/edit.js +2 -2
- package/build-module/video/edit.js.map +1 -1
- package/build-style/editor-rtl.css +4 -6
- package/build-style/editor.css +4 -6
- package/build-style/image/editor-rtl.css +1 -1
- package/build-style/image/editor.css +1 -1
- package/build-style/post-comments/style-rtl.css +22 -0
- package/build-style/post-comments/style.css +22 -0
- package/build-style/post-comments-form/style-rtl.css +1 -3
- package/build-style/post-comments-form/style.css +1 -3
- package/build-style/separator/editor-rtl.css +1 -0
- package/build-style/separator/editor.css +1 -0
- package/build-style/style-rtl.css +23 -3
- package/build-style/style.css +23 -3
- package/build-style/video/editor-rtl.css +2 -5
- package/build-style/video/editor.css +2 -5
- package/build-types/table-of-contents/list.d.ts +12 -0
- package/build-types/table-of-contents/list.d.ts.map +1 -0
- package/build-types/table-of-contents/utils.d.ts +24 -0
- package/build-types/table-of-contents/utils.d.ts.map +1 -0
- package/package.json +30 -29
- package/src/audio/edit.js +4 -2
- package/src/avatar/block.json +0 -1
- package/src/avatar/index.php +2 -2
- package/src/block/edit.js +39 -42
- package/src/block/test/edit.native.js +1 -1
- package/src/button/block.json +1 -0
- package/src/categories/block.json +1 -1
- package/src/categories/edit.js +1 -1
- package/src/comment-author-avatar/block.json +1 -0
- package/src/comments-title/block.json +0 -6
- package/src/comments-title/deprecated.js +34 -0
- package/src/comments-title/edit.js +44 -100
- package/src/comments-title/index.js +3 -1
- package/src/comments-title/index.php +41 -23
- package/src/cover/controls.native.js +1 -2
- package/src/cover/edit/block-controls.js +119 -0
- package/src/cover/edit/cover-placeholder.js +39 -0
- package/src/cover/edit/index.js +381 -0
- package/src/cover/edit/inspector-controls.js +286 -0
- package/src/cover/edit/resizable-cover.js +55 -0
- package/src/cover/{use-cover-is-dark.js → edit/use-cover-is-dark.js} +0 -0
- package/src/cover/edit.native.js +0 -1
- package/src/cover/editor.scss +1 -1
- package/src/cover/focal-point-settings-button.native.js +1 -1
- package/src/cover/index.php +20 -37
- package/src/cover/shared.js +4 -0
- package/src/cover/test/block-controls.js +62 -0
- package/src/embed/embed-preview.js +4 -2
- package/src/file/edit.native.js +0 -1
- package/src/gallery/edit.js +2 -1
- package/src/gallery/gallery.js +2 -2
- package/src/gallery/shared.js +3 -2
- package/src/gallery/use-get-media.js +2 -1
- package/src/gallery/use-short-code-transform.js +19 -16
- package/src/gallery/v1/gallery.js +2 -2
- package/src/heading/block.json +1 -0
- package/src/heading/edit.js +5 -2
- package/src/image/edit.js +9 -1
- package/src/image/edit.native.js +0 -1
- package/src/image/editor.scss +1 -1
- package/src/image/image.js +8 -2
- package/src/image/test/edit.native.js +7 -7
- package/src/index.js +50 -27
- package/src/is-block-metadata-experimental.js +19 -0
- package/src/latest-posts/edit.js +27 -2
- package/src/latest-posts/index.php +12 -6
- package/src/list/transforms.js +7 -0
- package/src/list/v2/edit.js +1 -0
- package/src/list/v2/migrate.js +1 -1
- package/src/list/v2/transforms.js +35 -0
- package/src/list-item/block.json +2 -1
- package/src/list-item/edit.js +17 -10
- package/src/list-item/hooks/index.js +3 -0
- package/src/list-item/hooks/use-backspace.js +52 -0
- package/src/list-item/hooks/use-enter.js +9 -16
- package/src/list-item/hooks/use-indent-list-item.js +50 -63
- package/src/list-item/hooks/use-space.js +48 -0
- package/src/list-item/hooks/use-split.js +24 -0
- package/src/list-item/utils.js +1 -1
- package/src/media-text/edit.native.js +3 -1
- package/src/media-text/media-container.native.js +2 -4
- package/src/media-text/transforms.js +154 -0
- package/src/navigation/edit/index.js +175 -169
- package/src/navigation/edit/inner-blocks.js +1 -8
- package/src/navigation/index.php +40 -0
- package/src/navigation/use-navigation-entities.js +1 -1
- package/src/navigation-link/fallback-variations.js +1 -1
- package/src/navigation-link/hooks.js +2 -2
- package/src/navigation-link/test/__snapshots__/hooks.js.snap +4 -4
- package/src/page-list/convert-to-links-modal.js +1 -1
- package/src/page-list/edit.js +1 -4
- package/src/post-author/edit.js +24 -22
- package/src/post-author-name/block.json +1 -0
- package/src/post-comment/block.json +1 -0
- package/src/post-comments/edit.js +54 -22
- package/src/post-comments/style.scss +26 -0
- package/src/post-comments-count/block.json +1 -0
- package/src/post-comments-form/form.js +1 -4
- package/src/post-comments-form/style.scss +1 -4
- package/src/post-comments-link/block.json +1 -0
- package/src/post-featured-image/edit.js +1 -1
- package/src/post-template/edit.js +5 -0
- package/src/post-template/index.php +30 -0
- package/src/post-terms/edit.js +19 -0
- package/src/post-terms/hooks.js +27 -0
- package/src/post-terms/index.js +14 -7
- package/src/post-terms/index.php +40 -2
- package/src/post-title/index.js +1 -1
- package/src/pullquote/edit.js +2 -2
- package/src/pullquote/edit.native.js +2 -2
- package/src/query/block.json +2 -1
- package/src/query/edit/inspector-controls/index.js +25 -11
- package/src/query/edit/inspector-controls/parent-control.js +133 -0
- package/src/query/edit/inspector-controls/sticky-control.js +25 -0
- package/src/query/utils.js +22 -0
- package/src/query-title/index.js +1 -1
- package/src/query-title/variations.js +2 -2
- package/src/quote/edit.js +5 -2
- package/src/quote/v2/edit.js +4 -2
- package/src/search/edit.js +1 -0
- package/src/search/index.php +1 -1
- package/src/separator/editor.scss +1 -0
- package/src/site-logo/edit.js +1 -1
- package/src/table/edit.js +19 -4
- package/src/table-of-contents/block.json +9 -2
- package/src/table-of-contents/edit.js +155 -75
- package/src/table-of-contents/index.js +2 -0
- package/src/table-of-contents/list.tsx +46 -0
- package/src/table-of-contents/save.js +25 -0
- package/src/table-of-contents/utils.ts +71 -0
- package/src/tag-cloud/block.json +1 -1
- package/src/template-part/edit/index.js +25 -15
- package/src/template-part/edit/inner-blocks.js +2 -10
- package/src/video/edit.js +4 -2
- package/src/video/editor.scss +3 -6
- package/test/babel-plugin.js +67 -0
- package/tsconfig.json +11 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/build/cover/edit.js +0 -598
- package/build/cover/edit.js.map +0 -1
- package/build/cover/use-cover-is-dark.js.map +0 -1
- package/build/post-terms/variations.js +0 -37
- package/build/post-terms/variations.js.map +0 -1
- package/build-module/cover/edit.js +0 -575
- package/build-module/cover/edit.js.map +0 -1
- package/build-module/cover/use-cover-is-dark.js.map +0 -1
- package/build-module/post-terms/variations.js +0 -27
- package/build-module/post-terms/variations.js.map +0 -1
- package/src/cover/edit.js +0 -757
- package/src/post-terms/variations.js +0 -28
- package/src/table-of-contents/index.php +0 -346
- package/src/table-of-contents/list.js +0 -28
- package/src/table-of-contents/utils.js +0 -126
package/src/heading/edit.js
CHANGED
|
@@ -42,10 +42,13 @@ function HeadingEdit( {
|
|
|
42
42
|
} );
|
|
43
43
|
|
|
44
44
|
const { canGenerateAnchors } = useSelect( ( select ) => {
|
|
45
|
-
const
|
|
45
|
+
const { getGlobalBlockCount, getSettings } = select( blockEditorStore );
|
|
46
|
+
const settings = getSettings();
|
|
46
47
|
|
|
47
48
|
return {
|
|
48
|
-
canGenerateAnchors:
|
|
49
|
+
canGenerateAnchors:
|
|
50
|
+
!! settings.generateAnchors ||
|
|
51
|
+
getGlobalBlockCount( 'core/table-of-contents' ) > 0,
|
|
49
52
|
};
|
|
50
53
|
}, [] );
|
|
51
54
|
|
package/src/image/edit.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
store as blockEditorStore,
|
|
20
20
|
} from '@wordpress/block-editor';
|
|
21
21
|
import { useEffect, useRef, useState } from '@wordpress/element';
|
|
22
|
-
import { __ } from '@wordpress/i18n';
|
|
22
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
23
23
|
import { image as icon } from '@wordpress/icons';
|
|
24
24
|
|
|
25
25
|
/**
|
|
@@ -156,6 +156,14 @@ export function ImageEdit( {
|
|
|
156
156
|
has been deleted.
|
|
157
157
|
*/
|
|
158
158
|
function onImageError( isReplaced = false ) {
|
|
159
|
+
noticeOperations.removeAllNotices();
|
|
160
|
+
noticeOperations.createErrorNotice(
|
|
161
|
+
sprintf(
|
|
162
|
+
/* translators: %s url or missing image */
|
|
163
|
+
__( 'Error loading image: %s' ),
|
|
164
|
+
url
|
|
165
|
+
)
|
|
166
|
+
);
|
|
159
167
|
// If the image block was not replaced with an embed,
|
|
160
168
|
// clear the attributes and trigger the placeholder.
|
|
161
169
|
if ( ! isReplaced ) {
|
package/src/image/edit.native.js
CHANGED
package/src/image/editor.scss
CHANGED
package/src/image/image.js
CHANGED
|
@@ -33,7 +33,11 @@ import {
|
|
|
33
33
|
import { useEffect, useMemo, useState, useRef } from '@wordpress/element';
|
|
34
34
|
import { __, sprintf, isRTL } from '@wordpress/i18n';
|
|
35
35
|
import { getFilename } from '@wordpress/url';
|
|
36
|
-
import {
|
|
36
|
+
import {
|
|
37
|
+
createBlock,
|
|
38
|
+
getDefaultBlockName,
|
|
39
|
+
switchToBlockType,
|
|
40
|
+
} from '@wordpress/blocks';
|
|
37
41
|
import { crop, overlayText, upload } from '@wordpress/icons';
|
|
38
42
|
import { store as noticesStore } from '@wordpress/notices';
|
|
39
43
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -598,7 +602,9 @@ export default function Image( {
|
|
|
598
602
|
}
|
|
599
603
|
inlineToolbar
|
|
600
604
|
__unstableOnSplitAtEnd={ () =>
|
|
601
|
-
insertBlocksAfter(
|
|
605
|
+
insertBlocksAfter(
|
|
606
|
+
createBlock( getDefaultBlockName() )
|
|
607
|
+
)
|
|
602
608
|
}
|
|
603
609
|
/>
|
|
604
610
|
) }
|
|
@@ -87,7 +87,7 @@ describe( 'Image Block', () => {
|
|
|
87
87
|
|
|
88
88
|
fireEvent.press( screen.getByA11yLabel( /Image Block/ ) );
|
|
89
89
|
// Awaiting navigation event seemingly required due to React Navigation bug
|
|
90
|
-
// https://
|
|
90
|
+
// https://github.com/react-navigation/react-navigation/issues/9701
|
|
91
91
|
await act( () =>
|
|
92
92
|
fireEvent.press( screen.getByA11yLabel( 'Open Settings' ) )
|
|
93
93
|
);
|
|
@@ -113,7 +113,7 @@ describe( 'Image Block', () => {
|
|
|
113
113
|
|
|
114
114
|
fireEvent.press( screen.getByA11yLabel( /Image Block/ ) );
|
|
115
115
|
// Awaiting navigation event seemingly required due to React Navigation bug
|
|
116
|
-
// https://
|
|
116
|
+
// https://github.com/react-navigation/react-navigation/issues/9701
|
|
117
117
|
await act( () =>
|
|
118
118
|
fireEvent.press( screen.getByA11yLabel( 'Open Settings' ) )
|
|
119
119
|
);
|
|
@@ -139,7 +139,7 @@ describe( 'Image Block', () => {
|
|
|
139
139
|
|
|
140
140
|
fireEvent.press( screen.getByA11yLabel( /Image Block/ ) );
|
|
141
141
|
// Awaiting navigation event seemingly required due to React Navigation bug
|
|
142
|
-
// https://
|
|
142
|
+
// https://github.com/react-navigation/react-navigation/issues/9701
|
|
143
143
|
await act( () =>
|
|
144
144
|
fireEvent.press( screen.getByA11yLabel( 'Open Settings' ) )
|
|
145
145
|
);
|
|
@@ -172,7 +172,7 @@ describe( 'Image Block', () => {
|
|
|
172
172
|
|
|
173
173
|
fireEvent.press( screen.getByA11yLabel( /Image Block/ ) );
|
|
174
174
|
// Awaiting navigation event seemingly required due to React Navigation bug
|
|
175
|
-
// https://
|
|
175
|
+
// https://github.com/react-navigation/react-navigation/issues/9701
|
|
176
176
|
await act( () =>
|
|
177
177
|
fireEvent.press( screen.getByA11yLabel( 'Open Settings' ) )
|
|
178
178
|
);
|
|
@@ -212,7 +212,7 @@ describe( 'Image Block', () => {
|
|
|
212
212
|
|
|
213
213
|
fireEvent.press( screen.getByA11yLabel( /Image Block/ ) );
|
|
214
214
|
// Awaiting navigation event seemingly required due to React Navigation bug
|
|
215
|
-
// https://
|
|
215
|
+
// https://github.com/react-navigation/react-navigation/issues/9701
|
|
216
216
|
await act( () =>
|
|
217
217
|
fireEvent.press( screen.getByA11yLabel( 'Open Settings' ) )
|
|
218
218
|
);
|
|
@@ -239,7 +239,7 @@ describe( 'Image Block', () => {
|
|
|
239
239
|
|
|
240
240
|
const settingsButton = screen.getByA11yLabel( 'Open Settings' );
|
|
241
241
|
// Awaiting navigation event seemingly required due to React Navigation bug
|
|
242
|
-
// https://
|
|
242
|
+
// https://github.com/react-navigation/react-navigation/issues/9701
|
|
243
243
|
await act( () => fireEvent.press( settingsButton ) );
|
|
244
244
|
|
|
245
245
|
const linkTargetButton = screen.getByText( 'Open in new tab' );
|
|
@@ -270,7 +270,7 @@ describe( 'Image Block', () => {
|
|
|
270
270
|
|
|
271
271
|
const settingsButton = screen.getByA11yLabel( 'Open Settings' );
|
|
272
272
|
// Awaiting navigation event seemingly required due to React Navigation bug
|
|
273
|
-
// https://
|
|
273
|
+
// https://github.com/react-navigation/react-navigation/issues/9701
|
|
274
274
|
await act( () => fireEvent.press( settingsButton ) );
|
|
275
275
|
|
|
276
276
|
const linkTargetButton = screen.getByText( 'Open in new tab' );
|
package/src/index.js
CHANGED
|
@@ -12,6 +12,15 @@ import {
|
|
|
12
12
|
/**
|
|
13
13
|
* Internal dependencies
|
|
14
14
|
*/
|
|
15
|
+
// When IS_GUTENBERG_PLUGIN is set to false, imports of experimental blocks
|
|
16
|
+
// are transformed by packages/block-library/src/index.js as follows:
|
|
17
|
+
// import * as experimentalBlock from './experimental-block'
|
|
18
|
+
// becomes
|
|
19
|
+
// const experimentalBlock = null;
|
|
20
|
+
// This enables webpack to eliminate the experimental blocks code from the
|
|
21
|
+
// production build to make the final bundle smaller.
|
|
22
|
+
//
|
|
23
|
+
// See https://github.com/WordPress/gutenberg/pull/40655 for more context.
|
|
15
24
|
import * as archives from './archives';
|
|
16
25
|
import * as avatar from './avatar';
|
|
17
26
|
import * as audio from './audio';
|
|
@@ -99,6 +108,7 @@ import * as socialLink from './social-link';
|
|
|
99
108
|
import * as socialLinks from './social-links';
|
|
100
109
|
import * as spacer from './spacer';
|
|
101
110
|
import * as table from './table';
|
|
111
|
+
import * as tableOfContents from './table-of-contents';
|
|
102
112
|
import * as tagCloud from './tag-cloud';
|
|
103
113
|
import * as templatePart from './template-part';
|
|
104
114
|
import * as termDescription from './term-description';
|
|
@@ -106,6 +116,8 @@ import * as textColumns from './text-columns';
|
|
|
106
116
|
import * as verse from './verse';
|
|
107
117
|
import * as video from './video';
|
|
108
118
|
|
|
119
|
+
import isBlockMetadataExperimental from './is-block-metadata-experimental';
|
|
120
|
+
|
|
109
121
|
/**
|
|
110
122
|
* Function to register an individual block.
|
|
111
123
|
*
|
|
@@ -121,16 +133,9 @@ const registerBlock = ( block ) => {
|
|
|
121
133
|
};
|
|
122
134
|
|
|
123
135
|
/**
|
|
124
|
-
* Function to get all the
|
|
125
|
-
*
|
|
126
|
-
* @example
|
|
127
|
-
* ```js
|
|
128
|
-
* import { __experimentalGetCoreBlocks } from '@wordpress/block-library';
|
|
129
|
-
*
|
|
130
|
-
* const coreBlocks = __experimentalGetCoreBlocks();
|
|
131
|
-
* ```
|
|
136
|
+
* Function to get all the block-library blocks in an array
|
|
132
137
|
*/
|
|
133
|
-
|
|
138
|
+
const getAllBlocks = () => [
|
|
134
139
|
// Common blocks are grouped at the top to prioritize their display
|
|
135
140
|
// in various contexts — like the inserter and auto-complete components.
|
|
136
141
|
paragraph,
|
|
@@ -138,6 +143,7 @@ export const __experimentalGetCoreBlocks = () => [
|
|
|
138
143
|
heading,
|
|
139
144
|
gallery,
|
|
140
145
|
list,
|
|
146
|
+
listItem,
|
|
141
147
|
quote,
|
|
142
148
|
|
|
143
149
|
// Register all remaining core blocks.
|
|
@@ -151,6 +157,7 @@ export const __experimentalGetCoreBlocks = () => [
|
|
|
151
157
|
code,
|
|
152
158
|
column,
|
|
153
159
|
columns,
|
|
160
|
+
commentAuthorAvatar,
|
|
154
161
|
cover,
|
|
155
162
|
embed,
|
|
156
163
|
file,
|
|
@@ -175,7 +182,6 @@ export const __experimentalGetCoreBlocks = () => [
|
|
|
175
182
|
socialLinks,
|
|
176
183
|
spacer,
|
|
177
184
|
table,
|
|
178
|
-
// tableOfContents,
|
|
179
185
|
tagCloud,
|
|
180
186
|
textColumns,
|
|
181
187
|
verse,
|
|
@@ -196,6 +202,10 @@ export const __experimentalGetCoreBlocks = () => [
|
|
|
196
202
|
postFeaturedImage,
|
|
197
203
|
postContent,
|
|
198
204
|
postAuthor,
|
|
205
|
+
postAuthorName,
|
|
206
|
+
postComment,
|
|
207
|
+
postCommentsCount,
|
|
208
|
+
postCommentsLink,
|
|
199
209
|
postDate,
|
|
200
210
|
postTerms,
|
|
201
211
|
postNavigationLink,
|
|
@@ -220,6 +230,7 @@ export const __experimentalGetCoreBlocks = () => [
|
|
|
220
230
|
commentsPaginationPrevious,
|
|
221
231
|
postComments,
|
|
222
232
|
postCommentsForm,
|
|
233
|
+
tableOfContents,
|
|
223
234
|
homeLink,
|
|
224
235
|
logInOut,
|
|
225
236
|
termDescription,
|
|
@@ -227,6 +238,21 @@ export const __experimentalGetCoreBlocks = () => [
|
|
|
227
238
|
postAuthorBiography,
|
|
228
239
|
];
|
|
229
240
|
|
|
241
|
+
/**
|
|
242
|
+
* Function to get all the core blocks in an array.
|
|
243
|
+
*
|
|
244
|
+
* @example
|
|
245
|
+
* ```js
|
|
246
|
+
* import { __experimentalGetCoreBlocks } from '@wordpress/block-library';
|
|
247
|
+
*
|
|
248
|
+
* const coreBlocks = __experimentalGetCoreBlocks();
|
|
249
|
+
* ```
|
|
250
|
+
*/
|
|
251
|
+
export const __experimentalGetCoreBlocks = () =>
|
|
252
|
+
getAllBlocks().filter(
|
|
253
|
+
( { metadata } ) => ! isBlockMetadataExperimental( metadata )
|
|
254
|
+
);
|
|
255
|
+
|
|
230
256
|
/**
|
|
231
257
|
* Function to register core blocks provided by the block editor.
|
|
232
258
|
*
|
|
@@ -266,22 +292,19 @@ export const registerCoreBlocks = (
|
|
|
266
292
|
export const __experimentalRegisterExperimentalCoreBlocks = process.env
|
|
267
293
|
.IS_GUTENBERG_PLUGIN
|
|
268
294
|
? ( { enableFSEBlocks } = {} ) => {
|
|
269
|
-
[
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
]
|
|
284
|
-
: [] ),
|
|
285
|
-
].forEach( registerBlock );
|
|
295
|
+
const enabledExperiments = [
|
|
296
|
+
window.__experimentalEnableListBlockV2 ? 'list-v2' : null,
|
|
297
|
+
enableFSEBlocks ? 'fse' : null,
|
|
298
|
+
];
|
|
299
|
+
getAllBlocks()
|
|
300
|
+
.filter( ( { metadata } ) =>
|
|
301
|
+
isBlockMetadataExperimental( metadata )
|
|
302
|
+
)
|
|
303
|
+
.filter(
|
|
304
|
+
( { metadata: { __experimental } } ) =>
|
|
305
|
+
__experimental === true ||
|
|
306
|
+
enabledExperiments.includes( __experimental )
|
|
307
|
+
)
|
|
308
|
+
.forEach( registerBlock );
|
|
286
309
|
}
|
|
287
310
|
: undefined;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the block is experimental based on the metadata loaded
|
|
3
|
+
* from block.json.
|
|
4
|
+
*
|
|
5
|
+
* This function is in a separate file and uses the older JS syntax so
|
|
6
|
+
* that it can be imported in both:
|
|
7
|
+
* – block-library/src/index.js
|
|
8
|
+
* – block-library/src/babel-plugin.js
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} metadata Parsed block.json metadata.
|
|
11
|
+
* @return {boolean} Is the block experimental?
|
|
12
|
+
*/
|
|
13
|
+
module.exports = function isBlockMetadataExperimental( metadata ) {
|
|
14
|
+
return (
|
|
15
|
+
metadata &&
|
|
16
|
+
'__experimental' in metadata &&
|
|
17
|
+
metadata.__experimental !== false
|
|
18
|
+
);
|
|
19
|
+
};
|
package/src/latest-posts/edit.js
CHANGED
|
@@ -28,9 +28,11 @@ import {
|
|
|
28
28
|
useBlockProps,
|
|
29
29
|
store as blockEditorStore,
|
|
30
30
|
} from '@wordpress/block-editor';
|
|
31
|
-
import { useSelect } from '@wordpress/data';
|
|
31
|
+
import { useSelect, useDispatch } from '@wordpress/data';
|
|
32
32
|
import { pin, list, grid } from '@wordpress/icons';
|
|
33
33
|
import { store as coreStore } from '@wordpress/core-data';
|
|
34
|
+
import { store as noticeStore } from '@wordpress/notices';
|
|
35
|
+
import { useInstanceId } from '@wordpress/compose';
|
|
34
36
|
|
|
35
37
|
/**
|
|
36
38
|
* Internal dependencies
|
|
@@ -66,6 +68,7 @@ function getFeaturedImageDetails( post, size ) {
|
|
|
66
68
|
}
|
|
67
69
|
|
|
68
70
|
export default function LatestPostsEdit( { attributes, setAttributes } ) {
|
|
71
|
+
const instanceId = useInstanceId( LatestPostsEdit );
|
|
69
72
|
const {
|
|
70
73
|
postsToShow,
|
|
71
74
|
order,
|
|
@@ -148,6 +151,20 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
|
|
|
148
151
|
]
|
|
149
152
|
);
|
|
150
153
|
|
|
154
|
+
// If a user clicks to a link prevent redirection and show a warning.
|
|
155
|
+
const { createWarningNotice, removeNotice } = useDispatch( noticeStore );
|
|
156
|
+
let noticeId;
|
|
157
|
+
const showRedirectionPreventedNotice = ( event ) => {
|
|
158
|
+
event.preventDefault();
|
|
159
|
+
// Remove previous warning if any, to show one at a time per block.
|
|
160
|
+
removeNotice( noticeId );
|
|
161
|
+
noticeId = `block-library/core/latest-posts/redirection-prevented/${ instanceId }`;
|
|
162
|
+
createWarningNotice( __( 'Links are disabled in the editor.' ), {
|
|
163
|
+
id: noticeId,
|
|
164
|
+
type: 'snackbar',
|
|
165
|
+
} );
|
|
166
|
+
};
|
|
167
|
+
|
|
151
168
|
const imageSizeOptions = imageSizes
|
|
152
169
|
.filter( ( { slug } ) => slug !== 'full' )
|
|
153
170
|
.map( ( { name, slug } ) => ( {
|
|
@@ -466,7 +483,11 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
|
|
|
466
483
|
.join( ' ' ) }
|
|
467
484
|
{ /* translators: excerpt truncation character, default … */ }
|
|
468
485
|
{ __( ' … ' ) }
|
|
469
|
-
<a
|
|
486
|
+
<a
|
|
487
|
+
href={ post.link }
|
|
488
|
+
rel="noopener noreferrer"
|
|
489
|
+
onClick={ showRedirectionPreventedNotice }
|
|
490
|
+
>
|
|
470
491
|
{ __( 'Read more' ) }
|
|
471
492
|
</a>
|
|
472
493
|
</>
|
|
@@ -483,6 +504,9 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
|
|
|
483
504
|
className="wp-block-latest-posts__post-title"
|
|
484
505
|
href={ post.link }
|
|
485
506
|
rel="noreferrer noopener"
|
|
507
|
+
onClick={
|
|
508
|
+
showRedirectionPreventedNotice
|
|
509
|
+
}
|
|
486
510
|
>
|
|
487
511
|
{ featuredImage }
|
|
488
512
|
</a>
|
|
@@ -501,6 +525,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
|
|
|
501
525
|
}
|
|
502
526
|
: undefined
|
|
503
527
|
}
|
|
528
|
+
onClick={ showRedirectionPreventedNotice }
|
|
504
529
|
>
|
|
505
530
|
{ ! titleTrimmed ? __( '(no title)' ) : null }
|
|
506
531
|
</a>
|
|
@@ -37,11 +37,12 @@ function render_block_core_latest_posts( $attributes ) {
|
|
|
37
37
|
global $post, $block_core_latest_posts_excerpt_length;
|
|
38
38
|
|
|
39
39
|
$args = array(
|
|
40
|
-
'posts_per_page'
|
|
41
|
-
'post_status'
|
|
42
|
-
'order'
|
|
43
|
-
'orderby'
|
|
44
|
-
'
|
|
40
|
+
'posts_per_page' => $attributes['postsToShow'],
|
|
41
|
+
'post_status' => 'publish',
|
|
42
|
+
'order' => $attributes['order'],
|
|
43
|
+
'orderby' => $attributes['orderBy'],
|
|
44
|
+
'ignore_sticky_posts' => true,
|
|
45
|
+
'no_found_rows' => true,
|
|
45
46
|
);
|
|
46
47
|
|
|
47
48
|
$block_core_latest_posts_excerpt_length = $attributes['excerptLength'];
|
|
@@ -54,7 +55,12 @@ function render_block_core_latest_posts( $attributes ) {
|
|
|
54
55
|
$args['author'] = $attributes['selectedAuthor'];
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
$
|
|
58
|
+
$query = new WP_Query;
|
|
59
|
+
$recent_posts = $query->query( $args );
|
|
60
|
+
|
|
61
|
+
if ( isset( $attributes['displayFeaturedImage'] ) && $attributes['displayFeaturedImage'] ) {
|
|
62
|
+
update_post_thumbnail_cache( $query );
|
|
63
|
+
}
|
|
58
64
|
|
|
59
65
|
$list_items_markup = '';
|
|
60
66
|
|
package/src/list/transforms.js
CHANGED
package/src/list/v2/edit.js
CHANGED
|
@@ -134,6 +134,7 @@ function Edit( { attributes, setAttributes, clientId } ) {
|
|
|
134
134
|
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
135
135
|
allowedBlocks: [ 'core/list-item' ],
|
|
136
136
|
template: TEMPLATE,
|
|
137
|
+
templateInsertUpdatesSelection: true,
|
|
137
138
|
} );
|
|
138
139
|
useMigrateOnLoad( attributes, clientId );
|
|
139
140
|
const { ordered, reversed, start } = attributes;
|
package/src/list/v2/migrate.js
CHANGED
|
@@ -8,7 +8,7 @@ import { omit } from 'lodash';
|
|
|
8
8
|
*/
|
|
9
9
|
import { createBlock } from '@wordpress/blocks';
|
|
10
10
|
|
|
11
|
-
function createListBlockFromDOMElement( listElement ) {
|
|
11
|
+
export function createListBlockFromDOMElement( listElement ) {
|
|
12
12
|
const listAttributes = {
|
|
13
13
|
ordered: 'OL' === listElement.tagName,
|
|
14
14
|
start: listElement.getAttribute( 'start' )
|
|
@@ -9,6 +9,32 @@ import {
|
|
|
9
9
|
toHTMLString,
|
|
10
10
|
} from '@wordpress/rich-text';
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Internal dependencies
|
|
14
|
+
*/
|
|
15
|
+
import { createListBlockFromDOMElement } from './migrate';
|
|
16
|
+
|
|
17
|
+
function getListContentSchema( { phrasingContentSchema } ) {
|
|
18
|
+
const listContentSchema = {
|
|
19
|
+
...phrasingContentSchema,
|
|
20
|
+
ul: {},
|
|
21
|
+
ol: { attributes: [ 'type', 'start', 'reversed' ] },
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
// Recursion is needed.
|
|
25
|
+
// Possible: ul > li > ul.
|
|
26
|
+
// Impossible: ul > ul.
|
|
27
|
+
[ 'ul', 'ol' ].forEach( ( tag ) => {
|
|
28
|
+
listContentSchema[ tag ].children = {
|
|
29
|
+
li: {
|
|
30
|
+
children: listContentSchema,
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
} );
|
|
34
|
+
|
|
35
|
+
return listContentSchema;
|
|
36
|
+
}
|
|
37
|
+
|
|
12
38
|
const transforms = {
|
|
13
39
|
from: [
|
|
14
40
|
{
|
|
@@ -82,6 +108,15 @@ const transforms = {
|
|
|
82
108
|
);
|
|
83
109
|
},
|
|
84
110
|
} ) ),
|
|
111
|
+
{
|
|
112
|
+
type: 'raw',
|
|
113
|
+
selector: 'ol,ul',
|
|
114
|
+
schema: ( args ) => ( {
|
|
115
|
+
ol: getListContentSchema( args ).ol,
|
|
116
|
+
ul: getListContentSchema( args ).ul,
|
|
117
|
+
} ),
|
|
118
|
+
transform: createListBlockFromDOMElement,
|
|
119
|
+
},
|
|
85
120
|
],
|
|
86
121
|
to: [
|
|
87
122
|
...[ 'core/paragraph', 'core/heading' ].map( ( block ) => ( {
|
package/src/list-item/block.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://schemas.wp.org/trunk/block.json",
|
|
3
3
|
"apiVersion": 2,
|
|
4
|
+
"__experimental": "list-v2",
|
|
4
5
|
"name": "core/list-item",
|
|
5
6
|
"title": "List item",
|
|
6
7
|
"category": "text",
|
|
@@ -14,7 +15,7 @@
|
|
|
14
15
|
"content": {
|
|
15
16
|
"type": "string",
|
|
16
17
|
"source": "html",
|
|
17
|
-
|
|
18
|
+
"selector": "li",
|
|
18
19
|
"default": "",
|
|
19
20
|
"__experimentalRole": "content"
|
|
20
21
|
}
|
package/src/list-item/edit.js
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
BlockControls,
|
|
9
9
|
} from '@wordpress/block-editor';
|
|
10
10
|
import { isRTL, __ } from '@wordpress/i18n';
|
|
11
|
-
import { createBlock } from '@wordpress/blocks';
|
|
12
11
|
import { ToolbarButton } from '@wordpress/components';
|
|
13
12
|
import {
|
|
14
13
|
formatOutdent,
|
|
@@ -21,7 +20,14 @@ import { useMergeRefs } from '@wordpress/compose';
|
|
|
21
20
|
/**
|
|
22
21
|
* Internal dependencies
|
|
23
22
|
*/
|
|
24
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
useEnter,
|
|
25
|
+
useBackspace,
|
|
26
|
+
useSpace,
|
|
27
|
+
useIndentListItem,
|
|
28
|
+
useOutdentListItem,
|
|
29
|
+
useSplit,
|
|
30
|
+
} from './hooks';
|
|
25
31
|
|
|
26
32
|
function IndentUI( { clientId } ) {
|
|
27
33
|
const [ canIndent, indentListItem ] = useIndentListItem( clientId );
|
|
@@ -48,7 +54,6 @@ function IndentUI( { clientId } ) {
|
|
|
48
54
|
}
|
|
49
55
|
|
|
50
56
|
export default function ListItemEdit( {
|
|
51
|
-
name,
|
|
52
57
|
attributes,
|
|
53
58
|
setAttributes,
|
|
54
59
|
mergeBlocks,
|
|
@@ -61,11 +66,18 @@ export default function ListItemEdit( {
|
|
|
61
66
|
allowedBlocks: [ 'core/list' ],
|
|
62
67
|
} );
|
|
63
68
|
const useEnterRef = useEnter( { content, clientId } );
|
|
69
|
+
const useBackspaceRef = useBackspace( { clientId } );
|
|
70
|
+
const useSpaceRef = useSpace( clientId );
|
|
71
|
+
const onSplit = useSplit( clientId );
|
|
64
72
|
return (
|
|
65
73
|
<>
|
|
66
74
|
<li { ...innerBlocksProps }>
|
|
67
75
|
<RichText
|
|
68
|
-
ref={ useMergeRefs( [
|
|
76
|
+
ref={ useMergeRefs( [
|
|
77
|
+
useEnterRef,
|
|
78
|
+
useBackspaceRef,
|
|
79
|
+
useSpaceRef,
|
|
80
|
+
] ) }
|
|
69
81
|
identifier="content"
|
|
70
82
|
tagName="div"
|
|
71
83
|
onChange={ ( nextContent ) =>
|
|
@@ -74,12 +86,7 @@ export default function ListItemEdit( {
|
|
|
74
86
|
value={ content }
|
|
75
87
|
aria-label={ __( 'List text' ) }
|
|
76
88
|
placeholder={ placeholder || __( 'List' ) }
|
|
77
|
-
onSplit={
|
|
78
|
-
return createBlock( name, {
|
|
79
|
-
...attributes,
|
|
80
|
-
content: value,
|
|
81
|
-
} );
|
|
82
|
-
} }
|
|
89
|
+
onSplit={ onSplit }
|
|
83
90
|
onMerge={ mergeBlocks }
|
|
84
91
|
onReplace={ onReplace }
|
|
85
92
|
/>
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export { default as useOutdentListItem } from './use-outdent-list-item';
|
|
2
2
|
export { default as useIndentListItem } from './use-indent-list-item';
|
|
3
3
|
export { default as useEnter } from './use-enter';
|
|
4
|
+
export { default as useBackspace } from './use-backspace';
|
|
5
|
+
export { default as useSpace } from './use-space';
|
|
6
|
+
export { default as useSplit } from './use-split';
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRef } from '@wordpress/element';
|
|
5
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
6
|
+
import { BACKSPACE } from '@wordpress/keycodes';
|
|
7
|
+
import { useSelect } from '@wordpress/data';
|
|
8
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Internal dependencies
|
|
12
|
+
*/
|
|
13
|
+
import useOutdentListItem from './use-outdent-list-item';
|
|
14
|
+
|
|
15
|
+
export default function useBackspace( props ) {
|
|
16
|
+
const { getSelectionStart, getSelectionEnd } = useSelect(
|
|
17
|
+
blockEditorStore
|
|
18
|
+
);
|
|
19
|
+
const propsRef = useRef( props );
|
|
20
|
+
propsRef.current = props;
|
|
21
|
+
const [ canOutdent, outdentListItem ] = useOutdentListItem(
|
|
22
|
+
propsRef.current.clientId
|
|
23
|
+
);
|
|
24
|
+
return useRefEffect(
|
|
25
|
+
( element ) => {
|
|
26
|
+
function onKeyDown( event ) {
|
|
27
|
+
if ( event.defaultPrevented || event.keyCode !== BACKSPACE ) {
|
|
28
|
+
return;
|
|
29
|
+
}
|
|
30
|
+
// Handle only if we have a collapsed selection at the
|
|
31
|
+
// start of a list item and we can outdent.
|
|
32
|
+
if (
|
|
33
|
+
! canOutdent ||
|
|
34
|
+
[
|
|
35
|
+
getSelectionStart().offset,
|
|
36
|
+
getSelectionEnd().offset,
|
|
37
|
+
].some( ( offset ) => offset !== 0 )
|
|
38
|
+
) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
event.preventDefault();
|
|
42
|
+
outdentListItem();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
element.addEventListener( 'keydown', onKeyDown );
|
|
46
|
+
return () => {
|
|
47
|
+
element.removeEventListener( 'keydown', onKeyDown );
|
|
48
|
+
};
|
|
49
|
+
},
|
|
50
|
+
[ canOutdent ]
|
|
51
|
+
);
|
|
52
|
+
}
|