@wordpress/block-library 7.2.0 → 7.3.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 +2 -0
- package/README.md +1 -1
- package/build/archives/edit.js +21 -1
- package/build/archives/edit.js.map +1 -1
- package/build/archives/index.js +5 -1
- package/build/archives/index.js.map +1 -1
- package/build/audio/edit.native.js +0 -5
- package/build/audio/edit.native.js.map +1 -1
- package/build/avatar/edit.js +17 -11
- package/build/avatar/edit.js.map +1 -1
- package/build/block/edit.js +2 -1
- package/build/block/edit.js.map +1 -1
- package/build/column/index.js +1 -0
- package/build/column/index.js.map +1 -1
- package/build/comment-author-avatar/index.js +3 -3
- package/build/comment-author-name/index.js +7 -3
- package/build/comment-author-name/index.js.map +1 -1
- package/build/comment-content/index.js +1 -1
- package/build/comment-date/index.js +7 -3
- package/build/comment-date/index.js.map +1 -1
- package/build/comment-edit-link/index.js +5 -1
- package/build/comment-edit-link/index.js.map +1 -1
- package/build/comment-reply-link/index.js +5 -1
- package/build/comment-reply-link/index.js.map +1 -1
- package/build/comment-template/edit.js +7 -14
- package/build/comment-template/edit.js.map +1 -1
- package/build/comment-template/hooks.js +7 -23
- package/build/comment-template/hooks.js.map +1 -1
- package/build/comment-template/index.js +2 -2
- package/build/comments-pagination-next/index.js +2 -2
- package/build/comments-pagination-numbers/index.js +1 -1
- package/build/comments-pagination-previous/index.js +1 -1
- package/build/comments-query-loop/edit/comments-inspector-controls.js +2 -69
- package/build/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
- package/build/comments-query-loop/edit.js +22 -1
- package/build/comments-query-loop/edit.js.map +1 -1
- package/build/comments-query-loop/index.js +1 -23
- package/build/comments-query-loop/index.js.map +1 -1
- package/build/cover/edit.js +35 -6
- package/build/cover/edit.js.map +1 -1
- package/build/cover/index.js +5 -0
- package/build/cover/index.js.map +1 -1
- package/build/cover/save.js +3 -2
- package/build/cover/save.js.map +1 -1
- package/build/gallery/gap-styles.js +8 -2
- package/build/gallery/gap-styles.js.map +1 -1
- package/build/gallery/index.js +1 -0
- package/build/gallery/index.js.map +1 -1
- package/build/group/edit.js +3 -1
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +2 -4
- package/build/group/index.js.map +1 -1
- package/build/group/variations.js +31 -9
- package/build/group/variations.js.map +1 -1
- package/build/heading/edit.js +1 -1
- package/build/heading/edit.js.map +1 -1
- package/build/html/edit.js +3 -2
- package/build/html/edit.js.map +1 -1
- package/build/image/edit.native.js +8 -10
- package/build/image/edit.native.js.map +1 -1
- package/build/index.js +3 -3
- package/build/index.js.map +1 -1
- package/build/list/deprecated.js +2 -2
- package/build/list/deprecated.js.map +1 -1
- package/build/list/v2/deprecated.js +117 -0
- package/build/list/v2/deprecated.js.map +1 -0
- package/build/list/v2/edit.js +106 -3
- package/build/list/v2/edit.js.map +1 -1
- package/build/list/v2/index.js +4 -1
- package/build/list/v2/index.js.map +1 -1
- package/build/list/v2/migrate.js +85 -0
- package/build/list/v2/migrate.js.map +1 -0
- package/build/list-item/edit.js +59 -10
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/index.js +32 -0
- package/build/list-item/hooks/index.js.map +1 -0
- package/build/list-item/hooks/use-enter.js +93 -0
- package/build/list-item/hooks/use-enter.js.map +1 -0
- package/build/list-item/hooks/use-indent-list-item.js +74 -0
- package/build/list-item/hooks/use-indent-list-item.js.map +1 -0
- package/build/list-item/hooks/use-outdent-list-item.js +77 -0
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -0
- package/build/list-item/index.js +1 -1
- package/build/list-item/index.js.map +1 -1
- package/build/list-item/utils.js +16 -0
- package/build/list-item/utils.js.map +1 -0
- package/build/media-text/media-container.native.js +1 -16
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/navigation/edit/index.js +36 -17
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/navigation-menu-delete-control.js +1 -1
- package/build/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build/navigation/edit/unsaved-inner-blocks.js +34 -7
- package/build/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build/navigation/index.js +9 -1
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +1 -0
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation-link/edit.js +9 -5
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/index.js +1 -1
- package/build/navigation-submenu/edit.js +5 -9
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/navigation-submenu/index.js +1 -1
- package/build/post-comment/edit.js +2 -2
- package/build/post-comment/edit.js.map +1 -1
- package/build/post-comments-form/edit.js +3 -2
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-featured-image/index.js +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 +3 -1
- package/build/post-terms/edit.js.map +1 -1
- package/build/post-terms/variations.js +1 -1
- package/build/post-terms/variations.js.map +1 -1
- package/build/query-pagination/edit.js +1 -1
- package/build/query-pagination/edit.js.map +1 -1
- package/build/query-pagination-numbers/index.js +19 -1
- package/build/query-pagination-numbers/index.js.map +1 -1
- package/build/quote/index.js +15 -8
- package/build/quote/index.js.map +1 -1
- package/build/quote/v2/deprecated.js +133 -0
- package/build/quote/v2/deprecated.js.map +1 -0
- package/build/quote/v2/edit.js +131 -0
- package/build/quote/v2/edit.js.map +1 -0
- package/build/quote/v2/index.js +49 -0
- package/build/quote/v2/index.js.map +1 -0
- package/build/quote/v2/save.js +43 -0
- package/build/quote/v2/save.js.map +1 -0
- package/build/quote/v2/transforms.js +156 -0
- package/build/quote/v2/transforms.js.map +1 -0
- package/build/read-more/index.js +1 -1
- package/build/rss/edit.js +6 -1
- package/build/rss/edit.js.map +1 -1
- package/build/site-logo/edit.js +3 -2
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-logo/index.js +1 -1
- package/build/social-links/index.js +1 -0
- package/build/social-links/index.js.map +1 -1
- package/build/spacer/controls.native.js +1 -1
- package/build/spacer/controls.native.js.map +1 -1
- package/build/template-part/edit/utils/hooks.js +5 -2
- package/build/template-part/edit/utils/hooks.js.map +1 -1
- package/build-module/archives/edit.js +22 -2
- package/build-module/archives/edit.js.map +1 -1
- package/build-module/archives/index.js +5 -1
- package/build-module/archives/index.js.map +1 -1
- package/build-module/audio/edit.native.js +0 -5
- package/build-module/audio/edit.native.js.map +1 -1
- package/build-module/avatar/edit.js +16 -11
- package/build-module/avatar/edit.js.map +1 -1
- package/build-module/block/edit.js +4 -3
- package/build-module/block/edit.js.map +1 -1
- package/build-module/column/index.js +1 -0
- package/build-module/column/index.js.map +1 -1
- package/build-module/comment-author-avatar/index.js +3 -3
- package/build-module/comment-author-name/index.js +7 -3
- package/build-module/comment-author-name/index.js.map +1 -1
- package/build-module/comment-content/index.js +1 -1
- package/build-module/comment-date/index.js +7 -3
- package/build-module/comment-date/index.js.map +1 -1
- package/build-module/comment-edit-link/index.js +5 -1
- package/build-module/comment-edit-link/index.js.map +1 -1
- package/build-module/comment-reply-link/index.js +5 -1
- package/build-module/comment-reply-link/index.js.map +1 -1
- package/build-module/comment-template/edit.js +7 -14
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/comment-template/hooks.js +7 -23
- package/build-module/comment-template/hooks.js.map +1 -1
- package/build-module/comment-template/index.js +2 -2
- package/build-module/comments-pagination-next/index.js +2 -2
- package/build-module/comments-pagination-numbers/index.js +1 -1
- package/build-module/comments-pagination-previous/index.js +1 -1
- package/build-module/comments-query-loop/edit/comments-inspector-controls.js +4 -70
- package/build-module/comments-query-loop/edit/comments-inspector-controls.js.map +1 -1
- package/build-module/comments-query-loop/edit.js +22 -1
- package/build-module/comments-query-loop/edit.js.map +1 -1
- package/build-module/comments-query-loop/index.js +1 -23
- package/build-module/comments-query-loop/index.js.map +1 -1
- package/build-module/cover/edit.js +36 -8
- package/build-module/cover/edit.js.map +1 -1
- package/build-module/cover/index.js +5 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/save.js +3 -2
- package/build-module/cover/save.js.map +1 -1
- package/build-module/gallery/gap-styles.js +8 -2
- package/build-module/gallery/gap-styles.js.map +1 -1
- package/build-module/gallery/index.js +1 -0
- package/build-module/gallery/index.js.map +1 -1
- package/build-module/group/edit.js +3 -1
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +2 -4
- package/build-module/group/index.js.map +1 -1
- package/build-module/group/variations.js +30 -9
- package/build-module/group/variations.js.map +1 -1
- package/build-module/heading/edit.js +1 -1
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/html/edit.js +4 -3
- package/build-module/html/edit.js.map +1 -1
- package/build-module/image/edit.native.js +8 -10
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/index.js +3 -3
- package/build-module/index.js.map +1 -1
- package/build-module/list/deprecated.js +2 -2
- package/build-module/list/deprecated.js.map +1 -1
- package/build-module/list/v2/deprecated.js +104 -0
- package/build-module/list/v2/deprecated.js.map +1 -0
- package/build-module/list/v2/edit.js +104 -5
- package/build-module/list/v2/edit.js.map +1 -1
- package/build-module/list/v2/index.js +3 -1
- package/build-module/list/v2/index.js.map +1 -1
- package/build-module/list/v2/migrate.js +77 -0
- package/build-module/list/v2/migrate.js.map +1 -0
- package/build-module/list-item/edit.js +59 -13
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/index.js +4 -0
- package/build-module/list-item/hooks/index.js.map +1 -0
- package/build-module/list-item/hooks/use-enter.js +77 -0
- package/build-module/list-item/hooks/use-enter.js.map +1 -0
- package/build-module/list-item/hooks/use-indent-list-item.js +62 -0
- package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -0
- package/build-module/list-item/hooks/use-outdent-list-item.js +66 -0
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -0
- package/build-module/list-item/index.js +1 -1
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/list-item/utils.js +8 -0
- package/build-module/list-item/utils.js.map +1 -0
- package/build-module/media-text/media-container.native.js +1 -14
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/navigation/edit/index.js +37 -17
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/navigation-menu-delete-control.js +1 -1
- package/build-module/navigation/edit/navigation-menu-delete-control.js.map +1 -1
- package/build-module/navigation/edit/unsaved-inner-blocks.js +35 -8
- package/build-module/navigation/edit/unsaved-inner-blocks.js.map +1 -1
- package/build-module/navigation/index.js +9 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +1 -0
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation-link/edit.js +9 -5
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/index.js +1 -1
- package/build-module/navigation-submenu/edit.js +6 -10
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/navigation-submenu/index.js +1 -1
- package/build-module/post-comment/edit.js +2 -2
- package/build-module/post-comment/edit.js.map +1 -1
- package/build-module/post-comments-form/edit.js +3 -2
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-featured-image/index.js +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 +4 -2
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/post-terms/variations.js +3 -3
- package/build-module/post-terms/variations.js.map +1 -1
- package/build-module/query-pagination/edit.js +1 -1
- package/build-module/query-pagination/edit.js.map +1 -1
- package/build-module/query-pagination-numbers/index.js +19 -1
- package/build-module/query-pagination-numbers/index.js.map +1 -1
- package/build-module/quote/index.js +13 -1
- package/build-module/quote/index.js.map +1 -1
- package/build-module/quote/v2/deprecated.js +116 -0
- package/build-module/quote/v2/deprecated.js.map +1 -0
- package/build-module/quote/v2/edit.js +115 -0
- package/build-module/quote/v2/edit.js.map +1 -0
- package/build-module/quote/v2/index.js +33 -0
- package/build-module/quote/v2/index.js.map +1 -0
- package/build-module/quote/v2/save.js +30 -0
- package/build-module/quote/v2/save.js.map +1 -0
- package/build-module/quote/v2/transforms.js +147 -0
- package/build-module/quote/v2/transforms.js.map +1 -0
- package/build-module/read-more/index.js +1 -1
- package/build-module/rss/edit.js +5 -1
- package/build-module/rss/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +3 -2
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-logo/index.js +1 -1
- package/build-module/social-links/index.js +1 -0
- package/build-module/social-links/index.js.map +1 -1
- package/build-module/spacer/controls.native.js +1 -1
- package/build-module/spacer/controls.native.js.map +1 -1
- package/build-module/template-part/edit/utils/hooks.js +5 -2
- package/build-module/template-part/edit/utils/hooks.js.map +1 -1
- package/build-style/avatar/editor-rtl.css +4 -0
- package/build-style/avatar/editor.css +4 -0
- package/build-style/avatar/style-rtl.css +79 -0
- package/build-style/avatar/style.css +79 -0
- package/build-style/editor-rtl.css +30 -9
- package/build-style/editor.css +30 -9
- package/build-style/group/editor-rtl.css +26 -0
- package/build-style/group/editor.css +26 -0
- package/build-style/heading/style-rtl.css +0 -8
- package/build-style/heading/style.css +0 -8
- package/build-style/list/style-rtl.css +1 -1
- package/build-style/list/style.css +1 -1
- package/build-style/navigation/style-rtl.css +11 -9
- package/build-style/navigation/style.css +11 -9
- package/build-style/navigation-link/style-rtl.css +3 -0
- package/build-style/navigation-link/style.css +3 -0
- package/build-style/paragraph/style-rtl.css +0 -4
- package/build-style/paragraph/style.css +0 -4
- package/build-style/quote/style-rtl.css +1 -0
- package/build-style/quote/style.css +1 -0
- package/build-style/reset-rtl.css +1 -1
- package/build-style/reset.css +1 -1
- package/build-style/style-rtl.css +20 -22
- package/build-style/style.css +20 -22
- package/build-style/template-part/editor-rtl.css +0 -9
- package/build-style/template-part/editor.css +0 -9
- package/package.json +28 -28
- package/src/archives/block.json +5 -1
- package/src/archives/edit.js +20 -2
- package/src/archives/index.php +4 -4
- package/src/audio/edit.native.js +0 -5
- package/src/avatar/edit.js +21 -13
- package/src/avatar/editor.scss +6 -0
- package/src/avatar/index.php +2 -2
- package/src/avatar/style.scss +5 -0
- package/src/block/edit.js +21 -11
- package/src/column/block.json +1 -0
- package/src/comment-author-avatar/block.json +3 -3
- package/src/comment-author-name/block.json +7 -3
- package/src/comment-author-name/index.php +3 -0
- package/src/comment-content/block.json +1 -1
- package/src/comment-date/block.json +7 -3
- package/src/comment-date/index.php +6 -1
- package/src/comment-edit-link/block.json +5 -1
- package/src/comment-edit-link/index.php +3 -0
- package/src/comment-reply-link/block.json +5 -1
- package/src/comment-reply-link/index.php +4 -1
- package/src/comment-template/block.json +2 -8
- package/src/comment-template/edit.js +12 -20
- package/src/comment-template/hooks.js +8 -24
- package/src/comment-template/index.php +1 -3
- package/src/comments-pagination-next/block.json +2 -9
- package/src/comments-pagination-numbers/block.json +2 -8
- package/src/comments-pagination-previous/block.json +2 -2
- package/src/comments-query-loop/block.json +1 -23
- package/src/comments-query-loop/edit/comments-inspector-controls.js +2 -83
- package/src/comments-query-loop/edit.js +54 -1
- package/src/cover/block.json +5 -0
- package/src/cover/edit.js +77 -29
- package/src/cover/index.php +85 -0
- package/src/cover/save.js +18 -14
- package/src/gallery/block.json +1 -0
- package/src/gallery/gap-styles.js +9 -4
- package/src/gallery/index.php +7 -6
- package/src/group/block.json +2 -4
- package/src/group/edit.js +4 -1
- package/src/group/editor.scss +31 -0
- package/src/group/variations.js +21 -4
- package/src/heading/edit.js +1 -1
- package/src/heading/style.scss +0 -3
- package/src/html/edit.js +22 -30
- package/src/image/edit.native.js +7 -11
- package/src/index.js +15 -15
- package/src/list/deprecated.js +2 -2
- package/src/list/style.scss +1 -2
- package/src/list/test/migrate.js +159 -0
- package/src/list/v2/deprecated.js +89 -0
- package/src/list/v2/edit.js +110 -1
- package/src/list/v2/index.js +2 -0
- package/src/list/v2/migrate.js +87 -0
- package/src/list-item/edit.js +69 -23
- package/src/list-item/hooks/index.js +3 -0
- package/src/list-item/hooks/use-enter.js +94 -0
- package/src/list-item/hooks/use-indent-list-item.js +89 -0
- package/src/list-item/hooks/use-outdent-list-item.js +95 -0
- package/src/list-item/index.js +1 -1
- package/src/list-item/utils.js +14 -0
- package/src/media-text/media-container.native.js +1 -14
- package/src/navigation/block.json +9 -1
- package/src/navigation/edit/index.js +50 -14
- package/src/navigation/edit/navigation-menu-delete-control.js +1 -1
- package/src/navigation/edit/unsaved-inner-blocks.js +57 -8
- package/src/navigation/index.php +6 -1
- package/src/navigation/style.scss +15 -13
- package/src/navigation/use-navigation-menu.js +4 -0
- package/src/navigation-link/block.json +1 -0
- package/src/navigation-link/edit.js +43 -35
- package/src/navigation-link/index.php +8 -0
- package/src/navigation-link/style.scss +6 -0
- package/src/navigation-submenu/block.json +1 -0
- package/src/navigation-submenu/edit.js +7 -9
- package/src/paragraph/style.scss +0 -5
- package/src/post-author/index.php +0 -1
- package/src/post-comment/edit.js +2 -2
- package/src/post-comments-form/edit.js +6 -3
- package/src/post-featured-image/block.json +1 -1
- package/src/post-template/edit.js +7 -1
- package/src/post-terms/edit.js +4 -1
- package/src/post-terms/variations.js +3 -3
- package/src/query-pagination/edit.js +1 -1
- package/src/query-pagination/index.php +9 -2
- package/src/query-pagination-numbers/block.json +19 -1
- package/src/quote/block.json +8 -0
- package/src/quote/index.js +6 -1
- package/src/quote/style.scss +1 -0
- package/src/quote/v2/deprecated.js +107 -0
- package/src/quote/v2/edit.js +136 -0
- package/src/quote/v2/index.js +36 -0
- package/src/quote/v2/save.js +26 -0
- package/src/quote/v2/test/migrate.js +92 -0
- package/src/quote/v2/transforms.js +155 -0
- package/src/read-more/block.json +1 -1
- package/src/reset.scss +1 -1
- package/src/rss/edit.js +3 -1
- package/src/rss/index.php +14 -1
- package/src/site-logo/block.json +1 -1
- package/src/site-logo/edit.js +2 -1
- package/src/site-logo/index.php +0 -4
- package/src/social-link/index.php +1 -2
- package/src/social-links/block.json +1 -0
- package/src/spacer/controls.native.js +1 -1
- package/src/spacer/test/__snapshots__/index.native.js.snap +31 -0
- package/src/spacer/test/index.native.js +180 -0
- package/src/style.scss +1 -0
- package/src/template-part/edit/utils/hooks.js +6 -1
- package/src/template-part/editor.scss +0 -10
- package/build/navigation/edit/use-list-view-modal.js +0 -73
- package/build/navigation/edit/use-list-view-modal.js.map +0 -1
- package/build-module/navigation/edit/use-list-view-modal.js +0 -63
- package/build-module/navigation/edit/use-list-view-modal.js.map +0 -1
- package/src/navigation/edit/use-list-view-modal.js +0 -72
package/src/index.js
CHANGED
|
@@ -191,6 +191,7 @@ export const __experimentalGetCoreBlocks = () => [
|
|
|
191
191
|
siteTagline,
|
|
192
192
|
query,
|
|
193
193
|
templatePart,
|
|
194
|
+
avatar,
|
|
194
195
|
postTitle,
|
|
195
196
|
postExcerpt,
|
|
196
197
|
postFeaturedImage,
|
|
@@ -204,7 +205,21 @@ export const __experimentalGetCoreBlocks = () => [
|
|
|
204
205
|
queryPaginationNext,
|
|
205
206
|
queryPaginationNumbers,
|
|
206
207
|
queryPaginationPrevious,
|
|
208
|
+
queryNoResults,
|
|
209
|
+
readMore,
|
|
210
|
+
commentAuthorName,
|
|
211
|
+
commentContent,
|
|
212
|
+
commentDate,
|
|
213
|
+
commentEditLink,
|
|
214
|
+
commentReplyLink,
|
|
215
|
+
commentTemplate,
|
|
216
|
+
commentsQueryLoop,
|
|
217
|
+
commentsPagination,
|
|
218
|
+
commentsPaginationNext,
|
|
219
|
+
commentsPaginationNumbers,
|
|
220
|
+
commentsPaginationPrevious,
|
|
207
221
|
postComments,
|
|
222
|
+
homeLink,
|
|
208
223
|
logInOut,
|
|
209
224
|
termDescription,
|
|
210
225
|
queryTitle,
|
|
@@ -252,31 +267,16 @@ export const __experimentalRegisterExperimentalCoreBlocks = process.env
|
|
|
252
267
|
? ( { enableFSEBlocks } = {} ) => {
|
|
253
268
|
[
|
|
254
269
|
// Experimental blocks.
|
|
255
|
-
avatar,
|
|
256
|
-
homeLink,
|
|
257
270
|
postAuthorName,
|
|
258
|
-
queryNoResults,
|
|
259
271
|
// Full Site Editing blocks.
|
|
260
272
|
...( enableFSEBlocks
|
|
261
273
|
? [
|
|
262
274
|
commentAuthorAvatar,
|
|
263
|
-
commentAuthorName,
|
|
264
|
-
commentContent,
|
|
265
|
-
commentDate,
|
|
266
|
-
commentEditLink,
|
|
267
|
-
commentReplyLink,
|
|
268
|
-
commentTemplate,
|
|
269
|
-
commentsQueryLoop,
|
|
270
|
-
commentsPagination,
|
|
271
|
-
commentsPaginationNext,
|
|
272
|
-
commentsPaginationNumbers,
|
|
273
|
-
commentsPaginationPrevious,
|
|
274
275
|
navigationArea,
|
|
275
276
|
postComment,
|
|
276
277
|
postCommentsCount,
|
|
277
278
|
postCommentsForm,
|
|
278
279
|
postCommentsLink,
|
|
279
|
-
readMore,
|
|
280
280
|
]
|
|
281
281
|
: [] ),
|
|
282
282
|
].forEach( registerBlock );
|
package/src/list/deprecated.js
CHANGED
|
@@ -8,7 +8,7 @@ import { RichText, useBlockProps } from '@wordpress/block-editor';
|
|
|
8
8
|
*/
|
|
9
9
|
import migrateFontFamily from '../utils/migrate-font-family';
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const v0 = {
|
|
12
12
|
attributes: {
|
|
13
13
|
ordered: {
|
|
14
14
|
type: 'boolean',
|
|
@@ -76,4 +76,4 @@ const v1 = {
|
|
|
76
76
|
*
|
|
77
77
|
* See block-deprecation.md
|
|
78
78
|
*/
|
|
79
|
-
export default [
|
|
79
|
+
export default [ v0 ];
|
package/src/list/style.scss
CHANGED
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { registerBlockType, serialize } from '@wordpress/blocks';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { migrateToListV2 } from '../v2/migrate';
|
|
10
|
+
import * as listItem from '../../list-item';
|
|
11
|
+
import * as list from '../../list';
|
|
12
|
+
import listV2 from '../../list/v2';
|
|
13
|
+
|
|
14
|
+
describe( 'Migrate list block', () => {
|
|
15
|
+
beforeAll( () => {
|
|
16
|
+
const prev = window.__experimentalEnableListBlockV2;
|
|
17
|
+
|
|
18
|
+
// force list and list item block registration.
|
|
19
|
+
registerBlockType(
|
|
20
|
+
{ name: listItem.name, ...listItem.metadata },
|
|
21
|
+
listItem.settings
|
|
22
|
+
);
|
|
23
|
+
registerBlockType( { name: list.name, ...list.metadata }, listV2 );
|
|
24
|
+
|
|
25
|
+
window.__experimentalEnableListBlockV2 = prev;
|
|
26
|
+
} );
|
|
27
|
+
|
|
28
|
+
it( 'should migrate the values attribute to inner blocks', () => {
|
|
29
|
+
const [ updatedAttributes, updatedInnerBlocks ] = migrateToListV2( {
|
|
30
|
+
values:
|
|
31
|
+
'<li>test</li><li>test</li><li>test<ol><li>test test</li><li>test est eesssss</li></ol></li>',
|
|
32
|
+
ordered: false,
|
|
33
|
+
} );
|
|
34
|
+
|
|
35
|
+
expect( updatedAttributes ).toEqual( {
|
|
36
|
+
ordered: false,
|
|
37
|
+
// Ideally the values attributes shouldn't be here
|
|
38
|
+
// but since we didn't enable v2 by default yet,
|
|
39
|
+
// we're keeping the old default value in block.json
|
|
40
|
+
values: '',
|
|
41
|
+
} );
|
|
42
|
+
expect( serialize( updatedInnerBlocks ) )
|
|
43
|
+
.toEqual( `<!-- wp:list-item -->
|
|
44
|
+
<li>test</li>
|
|
45
|
+
<!-- /wp:list-item -->
|
|
46
|
+
|
|
47
|
+
<!-- wp:list-item -->
|
|
48
|
+
<li>test</li>
|
|
49
|
+
<!-- /wp:list-item -->
|
|
50
|
+
|
|
51
|
+
<!-- wp:list-item -->
|
|
52
|
+
<li>test<!-- wp:list {\"ordered\":true} -->
|
|
53
|
+
<ol><!-- wp:list-item -->
|
|
54
|
+
<li>test test</li>
|
|
55
|
+
<!-- /wp:list-item -->
|
|
56
|
+
|
|
57
|
+
<!-- wp:list-item -->
|
|
58
|
+
<li>test est eesssss</li>
|
|
59
|
+
<!-- /wp:list-item --></ol>
|
|
60
|
+
<!-- /wp:list --></li>
|
|
61
|
+
<!-- /wp:list-item -->` );
|
|
62
|
+
} );
|
|
63
|
+
|
|
64
|
+
it( 'should handle empty space properly', () => {
|
|
65
|
+
const [ updatedAttributes, updatedInnerBlocks ] = migrateToListV2( {
|
|
66
|
+
values: `<li>Europe</li>
|
|
67
|
+
<li>
|
|
68
|
+
\tAfrica
|
|
69
|
+
<ol>
|
|
70
|
+
<li>Algeria</li>
|
|
71
|
+
</ol>
|
|
72
|
+
\t
|
|
73
|
+
</li>`,
|
|
74
|
+
ordered: false,
|
|
75
|
+
} );
|
|
76
|
+
|
|
77
|
+
expect( updatedAttributes ).toEqual( {
|
|
78
|
+
ordered: false,
|
|
79
|
+
// Ideally the values attributes shouldn't be here
|
|
80
|
+
// but since we didn't enable v2 by default yet,
|
|
81
|
+
// we're keeping the old default value in block.json
|
|
82
|
+
values: '',
|
|
83
|
+
} );
|
|
84
|
+
expect( serialize( updatedInnerBlocks ) )
|
|
85
|
+
.toEqual( `<!-- wp:list-item -->
|
|
86
|
+
<li>Europe</li>
|
|
87
|
+
<!-- /wp:list-item -->
|
|
88
|
+
|
|
89
|
+
<!-- wp:list-item -->
|
|
90
|
+
<li>Africa<!-- wp:list {\"ordered\":true} -->
|
|
91
|
+
<ol><!-- wp:list-item -->
|
|
92
|
+
<li>Algeria</li>
|
|
93
|
+
<!-- /wp:list-item --></ol>
|
|
94
|
+
<!-- /wp:list --></li>
|
|
95
|
+
<!-- /wp:list-item -->` );
|
|
96
|
+
} );
|
|
97
|
+
|
|
98
|
+
it( 'should handle formats properly', () => {
|
|
99
|
+
const [ updatedAttributes, updatedInnerBlocks ] = migrateToListV2( {
|
|
100
|
+
values: `<li>Europe<ul><li>France<ul><li>Lyon <strong>Rhone</strong>s</li><li>Paris <em>Ile de france</em><ul><li><em>1er</em></li></ul></li></ul></li></ul></li></ul></li>`,
|
|
101
|
+
ordered: false,
|
|
102
|
+
} );
|
|
103
|
+
|
|
104
|
+
expect( updatedAttributes ).toEqual( {
|
|
105
|
+
ordered: false,
|
|
106
|
+
// Ideally the values attributes shouldn't be here
|
|
107
|
+
// but since we didn't enable v2 by default yet,
|
|
108
|
+
// we're keeping the old default value in block.json
|
|
109
|
+
values: '',
|
|
110
|
+
} );
|
|
111
|
+
expect( serialize( updatedInnerBlocks ) )
|
|
112
|
+
.toEqual( `<!-- wp:list-item -->
|
|
113
|
+
<li>Europe<!-- wp:list -->
|
|
114
|
+
<ul><!-- wp:list-item -->
|
|
115
|
+
<li>France<!-- wp:list -->
|
|
116
|
+
<ul><!-- wp:list-item -->
|
|
117
|
+
<li>Lyon <strong>Rhone</strong>s</li>
|
|
118
|
+
<!-- /wp:list-item -->
|
|
119
|
+
|
|
120
|
+
<!-- wp:list-item -->
|
|
121
|
+
<li>Paris <em>Ile de france</em><!-- wp:list -->
|
|
122
|
+
<ul><!-- wp:list-item -->
|
|
123
|
+
<li><em>1er</em></li>
|
|
124
|
+
<!-- /wp:list-item --></ul>
|
|
125
|
+
<!-- /wp:list --></li>
|
|
126
|
+
<!-- /wp:list-item --></ul>
|
|
127
|
+
<!-- /wp:list --></li>
|
|
128
|
+
<!-- /wp:list-item --></ul>
|
|
129
|
+
<!-- /wp:list --></li>
|
|
130
|
+
<!-- /wp:list-item -->` );
|
|
131
|
+
} );
|
|
132
|
+
|
|
133
|
+
it( 'should not add random space', () => {
|
|
134
|
+
const [ updatedAttributes, updatedInnerBlocks ] = migrateToListV2( {
|
|
135
|
+
values: `<li>Europe<ul><li>F<strong>ranc</strong>e<ul><li>Paris</li></ul></li></ul></li>`,
|
|
136
|
+
ordered: false,
|
|
137
|
+
} );
|
|
138
|
+
|
|
139
|
+
expect( updatedAttributes ).toEqual( {
|
|
140
|
+
ordered: false,
|
|
141
|
+
// Ideally the values attributes shouldn't be here
|
|
142
|
+
// but since we didn't enable v2 by default yet,
|
|
143
|
+
// we're keeping the old default value in block.json
|
|
144
|
+
values: '',
|
|
145
|
+
} );
|
|
146
|
+
expect( serialize( updatedInnerBlocks ) )
|
|
147
|
+
.toEqual( `<!-- wp:list-item -->
|
|
148
|
+
<li>Europe<!-- wp:list -->
|
|
149
|
+
<ul><!-- wp:list-item -->
|
|
150
|
+
<li>F<strong>ranc</strong>e<!-- wp:list -->
|
|
151
|
+
<ul><!-- wp:list-item -->
|
|
152
|
+
<li>Paris</li>
|
|
153
|
+
<!-- /wp:list-item --></ul>
|
|
154
|
+
<!-- /wp:list --></li>
|
|
155
|
+
<!-- /wp:list-item --></ul>
|
|
156
|
+
<!-- /wp:list --></li>
|
|
157
|
+
<!-- /wp:list-item -->` );
|
|
158
|
+
} );
|
|
159
|
+
} );
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { RichText, useBlockProps } from '@wordpress/block-editor';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
import initialDeprecations from '../deprecated';
|
|
10
|
+
import { migrateToListV2 } from './migrate';
|
|
11
|
+
|
|
12
|
+
const v1 = {
|
|
13
|
+
attributes: {
|
|
14
|
+
ordered: {
|
|
15
|
+
type: 'boolean',
|
|
16
|
+
default: false,
|
|
17
|
+
__experimentalRole: 'content',
|
|
18
|
+
},
|
|
19
|
+
values: {
|
|
20
|
+
type: 'string',
|
|
21
|
+
source: 'html',
|
|
22
|
+
selector: 'ol,ul',
|
|
23
|
+
multiline: 'li',
|
|
24
|
+
__unstableMultilineWrapperTags: [ 'ol', 'ul' ],
|
|
25
|
+
default: '',
|
|
26
|
+
__experimentalRole: 'content',
|
|
27
|
+
},
|
|
28
|
+
type: {
|
|
29
|
+
type: 'string',
|
|
30
|
+
},
|
|
31
|
+
start: {
|
|
32
|
+
type: 'number',
|
|
33
|
+
},
|
|
34
|
+
reversed: {
|
|
35
|
+
type: 'boolean',
|
|
36
|
+
},
|
|
37
|
+
placeholder: {
|
|
38
|
+
type: 'string',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
supports: {
|
|
42
|
+
anchor: true,
|
|
43
|
+
className: false,
|
|
44
|
+
typography: {
|
|
45
|
+
fontSize: true,
|
|
46
|
+
__experimentalFontFamily: true,
|
|
47
|
+
lineHeight: true,
|
|
48
|
+
__experimentalFontStyle: true,
|
|
49
|
+
__experimentalFontWeight: true,
|
|
50
|
+
__experimentalLetterSpacing: true,
|
|
51
|
+
__experimentalTextTransform: true,
|
|
52
|
+
__experimentalDefaultControls: {
|
|
53
|
+
fontSize: true,
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
color: {
|
|
57
|
+
gradients: true,
|
|
58
|
+
link: true,
|
|
59
|
+
__experimentalDefaultControls: {
|
|
60
|
+
background: true,
|
|
61
|
+
text: true,
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
__unstablePasteTextInline: true,
|
|
65
|
+
__experimentalSelector: 'ol,ul',
|
|
66
|
+
__experimentalSlashInserter: true,
|
|
67
|
+
},
|
|
68
|
+
save( { attributes } ) {
|
|
69
|
+
const { ordered, values, type, reversed, start } = attributes;
|
|
70
|
+
const TagName = ordered ? 'ol' : 'ul';
|
|
71
|
+
|
|
72
|
+
return (
|
|
73
|
+
<TagName { ...useBlockProps.save( { type, reversed, start } ) }>
|
|
74
|
+
<RichText.Content value={ values } multiline="li" />
|
|
75
|
+
</TagName>
|
|
76
|
+
);
|
|
77
|
+
},
|
|
78
|
+
migrate: migrateToListV2,
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* New deprecations need to be placed first
|
|
83
|
+
* for them to have higher priority.
|
|
84
|
+
*
|
|
85
|
+
* Old deprecations may need to be updated as well.
|
|
86
|
+
*
|
|
87
|
+
* See block-deprecation.md
|
|
88
|
+
*/
|
|
89
|
+
export default [ v1, ...initialDeprecations ];
|
package/src/list/v2/edit.js
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { last } from 'lodash';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* WordPress dependencies
|
|
3
8
|
*/
|
|
@@ -5,29 +10,132 @@ import {
|
|
|
5
10
|
BlockControls,
|
|
6
11
|
useBlockProps,
|
|
7
12
|
useInnerBlocksProps,
|
|
13
|
+
store as blockEditorStore,
|
|
8
14
|
} from '@wordpress/block-editor';
|
|
9
15
|
import { ToolbarButton } from '@wordpress/components';
|
|
16
|
+
import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
|
|
10
17
|
import { isRTL, __ } from '@wordpress/i18n';
|
|
11
18
|
import {
|
|
12
19
|
formatListBullets,
|
|
13
20
|
formatListBulletsRTL,
|
|
14
21
|
formatListNumbered,
|
|
15
22
|
formatListNumberedRTL,
|
|
23
|
+
formatOutdent,
|
|
24
|
+
formatOutdentRTL,
|
|
16
25
|
} from '@wordpress/icons';
|
|
26
|
+
import { createBlock } from '@wordpress/blocks';
|
|
27
|
+
import { useCallback, useEffect } from '@wordpress/element';
|
|
28
|
+
import deprecated from '@wordpress/deprecated';
|
|
17
29
|
|
|
18
30
|
/**
|
|
19
31
|
* Internal dependencies
|
|
20
32
|
*/
|
|
21
33
|
import OrderedListSettings from '../ordered-list-settings';
|
|
34
|
+
import { migrateToListV2 } from './migrate';
|
|
22
35
|
|
|
23
36
|
const TEMPLATE = [ [ 'core/list-item' ] ];
|
|
24
37
|
|
|
25
|
-
|
|
38
|
+
/**
|
|
39
|
+
* At the moment, deprecations don't handle create blocks from attributes
|
|
40
|
+
* (like when using CPT templates). For this reason, this hook is necessary
|
|
41
|
+
* to avoid breaking templates using the old list block format.
|
|
42
|
+
*
|
|
43
|
+
* @param {Object} attributes Block attributes.
|
|
44
|
+
* @param {string} clientId Block client ID.
|
|
45
|
+
*/
|
|
46
|
+
function useMigrateOnLoad( attributes, clientId ) {
|
|
47
|
+
const registry = useRegistry();
|
|
48
|
+
const { updateBlockAttributes, replaceInnerBlocks } = useDispatch(
|
|
49
|
+
blockEditorStore
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
useEffect( () => {
|
|
53
|
+
// As soon as the block is loaded, migrate it to the new version.
|
|
54
|
+
|
|
55
|
+
if ( ! attributes.values ) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const [ newAttributes, newInnerBlocks ] = migrateToListV2( attributes );
|
|
60
|
+
|
|
61
|
+
deprecated( 'Value attribute on the list block', {
|
|
62
|
+
since: '6.0',
|
|
63
|
+
version: '6.5',
|
|
64
|
+
alternative: 'inner blocks',
|
|
65
|
+
} );
|
|
66
|
+
|
|
67
|
+
registry.batch( () => {
|
|
68
|
+
updateBlockAttributes( clientId, newAttributes );
|
|
69
|
+
replaceInnerBlocks( clientId, newInnerBlocks );
|
|
70
|
+
} );
|
|
71
|
+
}, [ attributes.values ] );
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function useOutdentList( clientId ) {
|
|
75
|
+
const { canOutdent } = useSelect(
|
|
76
|
+
( innerSelect ) => {
|
|
77
|
+
const { getBlockRootClientId, getBlock } = innerSelect(
|
|
78
|
+
blockEditorStore
|
|
79
|
+
);
|
|
80
|
+
const parentId = getBlockRootClientId( clientId );
|
|
81
|
+
return {
|
|
82
|
+
canOutdent:
|
|
83
|
+
!! parentId &&
|
|
84
|
+
getBlock( parentId ).name === 'core/list-item',
|
|
85
|
+
};
|
|
86
|
+
},
|
|
87
|
+
[ clientId ]
|
|
88
|
+
);
|
|
89
|
+
const { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );
|
|
90
|
+
const { getBlockRootClientId, getBlockAttributes, getBlock } = useSelect(
|
|
91
|
+
blockEditorStore
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
return [
|
|
95
|
+
canOutdent,
|
|
96
|
+
useCallback( () => {
|
|
97
|
+
const parentBlockId = getBlockRootClientId( clientId );
|
|
98
|
+
const parentBlockAttributes = getBlockAttributes( parentBlockId );
|
|
99
|
+
// Create a new parent block without the inner blocks.
|
|
100
|
+
const newParentBlock = createBlock(
|
|
101
|
+
'core/list-item',
|
|
102
|
+
parentBlockAttributes
|
|
103
|
+
);
|
|
104
|
+
const { innerBlocks } = getBlock( clientId );
|
|
105
|
+
// Replace the parent block with a new parent block without inner blocks,
|
|
106
|
+
// and make the inner blocks siblings of the parent.
|
|
107
|
+
replaceBlocks(
|
|
108
|
+
[ parentBlockId ],
|
|
109
|
+
[ newParentBlock, ...innerBlocks ]
|
|
110
|
+
);
|
|
111
|
+
// Select the last child of the list being outdent.
|
|
112
|
+
selectionChange( last( innerBlocks ).clientId );
|
|
113
|
+
}, [ clientId ] ),
|
|
114
|
+
];
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
function IndentUI( { clientId } ) {
|
|
118
|
+
const [ canOutdent, outdentList ] = useOutdentList( clientId );
|
|
119
|
+
return (
|
|
120
|
+
<>
|
|
121
|
+
<ToolbarButton
|
|
122
|
+
icon={ isRTL() ? formatOutdentRTL : formatOutdent }
|
|
123
|
+
title={ __( 'Outdent' ) }
|
|
124
|
+
describedBy={ __( 'Outdent list item' ) }
|
|
125
|
+
disabled={ ! canOutdent }
|
|
126
|
+
onClick={ outdentList }
|
|
127
|
+
/>
|
|
128
|
+
</>
|
|
129
|
+
);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function Edit( { attributes, setAttributes, clientId } ) {
|
|
26
133
|
const blockProps = useBlockProps();
|
|
27
134
|
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
28
135
|
allowedBlocks: [ 'core/list-item' ],
|
|
29
136
|
template: TEMPLATE,
|
|
30
137
|
} );
|
|
138
|
+
useMigrateOnLoad( attributes, clientId );
|
|
31
139
|
const { ordered, reversed, start } = attributes;
|
|
32
140
|
const TagName = ordered ? 'ol' : 'ul';
|
|
33
141
|
|
|
@@ -51,6 +159,7 @@ function Edit( { attributes, setAttributes } ) {
|
|
|
51
159
|
setAttributes( { ordered: true } );
|
|
52
160
|
} }
|
|
53
161
|
/>
|
|
162
|
+
<IndentUI clientId={ clientId } />
|
|
54
163
|
</BlockControls>
|
|
55
164
|
);
|
|
56
165
|
|
package/src/list/v2/index.js
CHANGED
|
@@ -9,12 +9,14 @@ import { list as icon } from '@wordpress/icons';
|
|
|
9
9
|
import edit from './edit';
|
|
10
10
|
import save from './save';
|
|
11
11
|
import transforms from './transforms';
|
|
12
|
+
import deprecated from './deprecated';
|
|
12
13
|
|
|
13
14
|
const settings = {
|
|
14
15
|
icon,
|
|
15
16
|
edit,
|
|
16
17
|
save,
|
|
17
18
|
transforms,
|
|
19
|
+
deprecated,
|
|
18
20
|
};
|
|
19
21
|
|
|
20
22
|
export default settings;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { omit } from 'lodash';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { createBlock } from '@wordpress/blocks';
|
|
10
|
+
|
|
11
|
+
function createListBlockFromDOMElement( listElement ) {
|
|
12
|
+
const listAttributes = {
|
|
13
|
+
ordered: 'OL' === listElement.tagName,
|
|
14
|
+
start: listElement.getAttribute( 'start' )
|
|
15
|
+
? parseInt( listElement.getAttribute( 'start' ), 10 )
|
|
16
|
+
: undefined,
|
|
17
|
+
reversed:
|
|
18
|
+
listElement.getAttribute( 'reversed' ) === true ? true : undefined,
|
|
19
|
+
type: listElement.getAttribute( 'type' ) ?? undefined,
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const innerBlocks = Array.from( listElement.children ).map(
|
|
23
|
+
( listItem ) => {
|
|
24
|
+
const children = Array.from( listItem.childNodes ).filter(
|
|
25
|
+
( node ) =>
|
|
26
|
+
node.nodeType !== node.TEXT_NODE ||
|
|
27
|
+
node.textContent.trim().length !== 0
|
|
28
|
+
);
|
|
29
|
+
children.reverse();
|
|
30
|
+
const [ nestedList, ...nodes ] = children;
|
|
31
|
+
|
|
32
|
+
const hasNestedList =
|
|
33
|
+
nestedList.tagName === 'UL' || nestedList.tagName === 'OL';
|
|
34
|
+
if ( ! hasNestedList ) {
|
|
35
|
+
return createBlock( 'core/list-item', {
|
|
36
|
+
content: listItem.innerHTML,
|
|
37
|
+
} );
|
|
38
|
+
}
|
|
39
|
+
const htmlNodes = nodes.map( ( node ) => {
|
|
40
|
+
if ( node.nodeType === node.TEXT_NODE ) {
|
|
41
|
+
return node.textContent;
|
|
42
|
+
}
|
|
43
|
+
return node.outerHTML;
|
|
44
|
+
} );
|
|
45
|
+
htmlNodes.reverse();
|
|
46
|
+
const childAttributes = {
|
|
47
|
+
content: htmlNodes.join( '' ).trim(),
|
|
48
|
+
};
|
|
49
|
+
const childInnerBlocks = [
|
|
50
|
+
createListBlockFromDOMElement( nestedList ),
|
|
51
|
+
];
|
|
52
|
+
return createBlock(
|
|
53
|
+
'core/list-item',
|
|
54
|
+
childAttributes,
|
|
55
|
+
childInnerBlocks
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
return createBlock( 'core/list', listAttributes, innerBlocks );
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function migrateToListV2( attributes ) {
|
|
64
|
+
const { values, start, reversed, ordered, type } = attributes;
|
|
65
|
+
|
|
66
|
+
const list = document.createElement( ordered ? 'ol' : 'ul' );
|
|
67
|
+
list.innerHTML = values;
|
|
68
|
+
if ( start ) {
|
|
69
|
+
list.setAttribute( 'start', start );
|
|
70
|
+
}
|
|
71
|
+
if ( reversed ) {
|
|
72
|
+
list.setAttribute( 'reversed', true );
|
|
73
|
+
}
|
|
74
|
+
if ( type ) {
|
|
75
|
+
list.setAttribute( 'type', type );
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const listBlock = createListBlockFromDOMElement( list );
|
|
79
|
+
|
|
80
|
+
return [
|
|
81
|
+
{
|
|
82
|
+
...omit( attributes, [ 'values' ] ),
|
|
83
|
+
...listBlock.attributes,
|
|
84
|
+
},
|
|
85
|
+
listBlock.innerBlocks,
|
|
86
|
+
];
|
|
87
|
+
}
|
package/src/list-item/edit.js
CHANGED
|
@@ -5,9 +5,47 @@ import {
|
|
|
5
5
|
RichText,
|
|
6
6
|
useBlockProps,
|
|
7
7
|
useInnerBlocksProps,
|
|
8
|
+
BlockControls,
|
|
8
9
|
} from '@wordpress/block-editor';
|
|
9
|
-
import { __ } from '@wordpress/i18n';
|
|
10
|
+
import { isRTL, __ } from '@wordpress/i18n';
|
|
10
11
|
import { createBlock } from '@wordpress/blocks';
|
|
12
|
+
import { ToolbarButton } from '@wordpress/components';
|
|
13
|
+
import {
|
|
14
|
+
formatOutdent,
|
|
15
|
+
formatOutdentRTL,
|
|
16
|
+
formatIndentRTL,
|
|
17
|
+
formatIndent,
|
|
18
|
+
} from '@wordpress/icons';
|
|
19
|
+
import { useMergeRefs } from '@wordpress/compose';
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Internal dependencies
|
|
23
|
+
*/
|
|
24
|
+
import { useEnter, useIndentListItem, useOutdentListItem } from './hooks';
|
|
25
|
+
|
|
26
|
+
function IndentUI( { clientId } ) {
|
|
27
|
+
const [ canIndent, indentListItem ] = useIndentListItem( clientId );
|
|
28
|
+
const [ canOutdent, outdentListItem ] = useOutdentListItem( clientId );
|
|
29
|
+
|
|
30
|
+
return (
|
|
31
|
+
<>
|
|
32
|
+
<ToolbarButton
|
|
33
|
+
icon={ isRTL() ? formatOutdentRTL : formatOutdent }
|
|
34
|
+
title={ __( 'Outdent' ) }
|
|
35
|
+
describedBy={ __( 'Outdent list item' ) }
|
|
36
|
+
disabled={ ! canOutdent }
|
|
37
|
+
onClick={ outdentListItem }
|
|
38
|
+
/>
|
|
39
|
+
<ToolbarButton
|
|
40
|
+
icon={ isRTL() ? formatIndentRTL : formatIndent }
|
|
41
|
+
title={ __( 'Indent' ) }
|
|
42
|
+
describedBy={ __( 'Indent list item' ) }
|
|
43
|
+
isDisabled={ ! canIndent }
|
|
44
|
+
onClick={ indentListItem }
|
|
45
|
+
/>
|
|
46
|
+
</>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
11
49
|
|
|
12
50
|
export default function ListItemEdit( {
|
|
13
51
|
name,
|
|
@@ -15,33 +53,41 @@ export default function ListItemEdit( {
|
|
|
15
53
|
setAttributes,
|
|
16
54
|
mergeBlocks,
|
|
17
55
|
onReplace,
|
|
56
|
+
clientId,
|
|
18
57
|
} ) {
|
|
58
|
+
const { placeholder, content } = attributes;
|
|
19
59
|
const blockProps = useBlockProps();
|
|
20
60
|
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
21
61
|
allowedBlocks: [ 'core/list' ],
|
|
22
62
|
} );
|
|
23
|
-
|
|
63
|
+
const useEnterRef = useEnter( { content, clientId } );
|
|
24
64
|
return (
|
|
25
|
-
|
|
26
|
-
<
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
65
|
+
<>
|
|
66
|
+
<li { ...innerBlocksProps }>
|
|
67
|
+
<RichText
|
|
68
|
+
ref={ useMergeRefs( [ useEnterRef ] ) }
|
|
69
|
+
identifier="content"
|
|
70
|
+
tagName="div"
|
|
71
|
+
onChange={ ( nextContent ) =>
|
|
72
|
+
setAttributes( { content: nextContent } )
|
|
73
|
+
}
|
|
74
|
+
value={ content }
|
|
75
|
+
aria-label={ __( 'List text' ) }
|
|
76
|
+
placeholder={ placeholder || __( 'List' ) }
|
|
77
|
+
onSplit={ ( value ) => {
|
|
78
|
+
return createBlock( name, {
|
|
79
|
+
...attributes,
|
|
80
|
+
content: value,
|
|
81
|
+
} );
|
|
82
|
+
} }
|
|
83
|
+
onMerge={ mergeBlocks }
|
|
84
|
+
onReplace={ onReplace }
|
|
85
|
+
/>
|
|
86
|
+
{ innerBlocksProps.children }
|
|
87
|
+
</li>
|
|
88
|
+
<BlockControls group="block">
|
|
89
|
+
<IndentUI clientId={ clientId } />
|
|
90
|
+
</BlockControls>
|
|
91
|
+
</>
|
|
46
92
|
);
|
|
47
93
|
}
|