@wordpress/block-library 7.8.0 → 7.11.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/build/audio/edit.js +1 -0
- package/build/audio/edit.js.map +1 -1
- package/build/audio/save.js +2 -1
- package/build/audio/save.js.map +1 -1
- package/build/avatar/hooks.js +2 -2
- package/build/avatar/hooks.js.map +1 -1
- package/build/button/edit.js +3 -2
- package/build/button/edit.js.map +1 -1
- package/build/button/index.js +1 -24
- package/build/button/index.js.map +1 -1
- package/build/button/save.js +1 -1
- package/build/button/save.js.map +1 -1
- package/build/buttons/edit.js +1 -1
- package/build/buttons/edit.js.map +1 -1
- package/build/columns/edit.native.js +1 -1
- package/build/columns/edit.native.js.map +1 -1
- package/build/columns/variations.js +2 -2
- package/build/columns/variations.js.map +1 -1
- package/build/comment-author-name/edit.js +3 -5
- package/build/comment-author-name/edit.js.map +1 -1
- package/build/comment-author-name/index.js +0 -4
- package/build/comment-author-name/index.js.map +1 -1
- package/build/comment-date/edit.js +4 -4
- package/build/comment-date/edit.js.map +1 -1
- package/build/comment-date/index.js +0 -4
- package/build/comment-date/index.js.map +1 -1
- package/build/comment-edit-link/index.js +0 -4
- package/build/comment-edit-link/index.js.map +1 -1
- package/build/comment-reply-link/index.js +0 -4
- package/build/comment-reply-link/index.js.map +1 -1
- package/build/comment-template/index.js +1 -1
- package/build/comments/deprecated.js +65 -0
- package/build/comments/deprecated.js.map +1 -0
- package/build/comments/edit/comments-legacy.js +73 -0
- package/build/comments/edit/comments-legacy.js.map +1 -0
- package/build/comments/{edit.js → edit/index.js} +17 -30
- package/build/comments/edit/index.js.map +1 -0
- package/build/comments/edit/placeholder.js +117 -0
- package/build/comments/edit/placeholder.js.map +1 -0
- package/build/comments/edit/template.js +39 -0
- package/build/comments/edit/template.js.map +1 -0
- package/build/comments/index.js +11 -3
- package/build/comments/index.js.map +1 -1
- package/build/comments/save.js +12 -4
- package/build/comments/save.js.map +1 -1
- package/build/comments-pagination/index.js +1 -1
- package/build/comments-title/deprecated.js +1 -4
- package/build/comments-title/deprecated.js.map +1 -1
- package/build/comments-title/index.js +1 -1
- package/build/cover/edit/block-controls.js +2 -12
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/cover/edit/cover-placeholder.js +3 -1
- package/build/cover/edit/cover-placeholder.js.map +1 -1
- package/build/cover/edit/index.js +19 -4
- package/build/cover/edit/index.js.map +1 -1
- package/build/cover/index.js +1 -0
- package/build/cover/index.js.map +1 -1
- package/build/cover/transforms.js +3 -2
- package/build/cover/transforms.js.map +1 -1
- package/build/embed/embed-placeholder.native.js +1 -3
- package/build/embed/embed-placeholder.native.js.map +1 -1
- package/build/embed/embed-preview.js +1 -0
- package/build/embed/embed-preview.js.map +1 -1
- package/build/embed/icons.js +21 -1
- package/build/embed/icons.js.map +1 -1
- package/build/embed/save.js +1 -0
- package/build/embed/save.js.map +1 -1
- package/build/embed/variations.js +11 -0
- package/build/embed/variations.js.map +1 -1
- package/build/file/edit.js +1 -1
- package/build/file/edit.js.map +1 -1
- package/build/file/save.js +1 -1
- package/build/file/save.js.map +1 -1
- package/build/gallery/edit.js +11 -19
- 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/save.js +1 -1
- package/build/gallery/save.js.map +1 -1
- package/build/gallery/transforms.js +32 -22
- package/build/gallery/transforms.js.map +1 -1
- package/build/gallery/use-get-media.js +7 -18
- package/build/gallery/use-get-media.js.map +1 -1
- package/build/gallery/use-get-media.native.js +59 -0
- package/build/gallery/use-get-media.native.js.map +1 -0
- package/build/gallery/v1/edit.js +3 -3
- package/build/gallery/v1/edit.js.map +1 -1
- package/build/gallery/v1/gallery-image.js +1 -0
- package/build/gallery/v1/gallery-image.js.map +1 -1
- package/build/gallery/v1/gallery.js +1 -1
- package/build/gallery/v1/gallery.js.map +1 -1
- package/build/gallery/v1/save.js +10 -2
- package/build/gallery/v1/save.js.map +1 -1
- package/build/group/edit.js +1 -3
- package/build/group/edit.js.map +1 -1
- package/build/group/index.js +2 -0
- package/build/group/index.js.map +1 -1
- package/build/group/variations.js +1 -1
- package/build/group/variations.js.map +1 -1
- package/build/heading/heading-level-dropdown.js +2 -1
- package/build/heading/heading-level-dropdown.js.map +1 -1
- package/build/heading/index.js +9 -4
- package/build/heading/index.js.map +1 -1
- package/build/html/edit.js +11 -20
- package/build/html/edit.js.map +1 -1
- package/build/html/preview.js +48 -0
- package/build/html/preview.js.map +1 -0
- package/build/image/deprecated.js +77 -9
- package/build/image/deprecated.js.map +1 -1
- package/build/image/edit.js +3 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +20 -9
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +28 -20
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +7 -1
- package/build/image/index.js.map +1 -1
- package/build/image/save.js +9 -2
- package/build/image/save.js.map +1 -1
- package/build/index.js +1 -3
- package/build/index.js.map +1 -1
- package/build/index.native.js +3 -13
- package/build/index.native.js.map +1 -1
- package/build/latest-posts/edit.js +1 -1
- package/build/latest-posts/edit.js.map +1 -1
- package/build/list/transforms.js +4 -63
- package/build/list/transforms.js.map +1 -1
- package/build/list/v2/transforms.js +31 -42
- package/build/list/v2/transforms.js.map +1 -1
- package/build/list-item/edit.js +14 -9
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/index.js +8 -8
- package/build/list-item/hooks/index.js.map +1 -1
- package/build/list-item/hooks/use-enter.js +7 -4
- package/build/list-item/hooks/use-enter.js.map +1 -1
- package/build/list-item/hooks/use-merge.js +174 -0
- package/build/list-item/hooks/use-merge.js.map +1 -0
- package/build/list-item/hooks/use-outdent-list-item.js +93 -36
- package/build/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build/list-item/utils.js +125 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/media-text/deprecated.js +134 -7
- package/build/media-text/deprecated.js.map +1 -1
- package/build/media-text/edit.js +2 -2
- package/build/media-text/edit.js.map +1 -1
- package/build/media-text/save.js +13 -0
- package/build/media-text/save.js.map +1 -1
- package/build/more/edit.js +2 -4
- package/build/more/edit.js.map +1 -1
- package/build/more/save.js +1 -7
- package/build/more/save.js.map +1 -1
- package/build/navigation/edit/index.js +1 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/index.js +9 -0
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/use-navigation-menu.js +16 -74
- package/build/navigation/use-navigation-menu.js.map +1 -1
- package/build/navigation/view.js +6 -1
- package/build/navigation/view.js.map +1 -1
- package/build/navigation-link/edit.js +5 -4
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/hooks.js +0 -16
- package/build/navigation-link/hooks.js.map +1 -1
- package/build/navigation-link/index.js +1 -1
- package/build/navigation-link/index.js.map +1 -1
- package/build/navigation-submenu/edit.js +2 -1
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/navigation-submenu/view.js +6 -1
- package/build/navigation-submenu/view.js.map +1 -1
- package/build/nextpage/edit.js +1 -3
- package/build/nextpage/edit.js.map +1 -1
- package/build/page-list/edit.js +10 -3
- package/build/page-list/edit.js.map +1 -1
- package/build/paragraph/edit.js +7 -11
- package/build/paragraph/edit.js.map +1 -1
- package/build/post-comments-form/edit.js +4 -37
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-comments-form/form.js +47 -3
- package/build/post-comments-form/form.js.map +1 -1
- package/build/post-terms/edit.js +3 -2
- package/build/post-terms/edit.js.map +1 -1
- package/build/post-terms/index.js +1 -1
- package/build/post-terms/index.js.map +1 -1
- package/build/post-title/index.js +1 -0
- package/build/post-title/index.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +1 -1
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/index.js +1 -1
- package/build/query/index.js.map +1 -1
- package/build/query-no-results/edit.js +1 -1
- package/build/query-no-results/edit.js.map +1 -1
- package/build/query-pagination-next/edit.js +2 -1
- package/build/query-pagination-next/edit.js.map +1 -1
- package/build/query-pagination-previous/edit.js +2 -1
- package/build/query-pagination-previous/edit.js.map +1 -1
- package/build/quote/deprecated.js +168 -36
- package/build/quote/deprecated.js.map +1 -1
- package/build/quote/edit.js +76 -39
- package/build/quote/edit.js.map +1 -1
- package/build/quote/index.js +9 -45
- package/build/quote/index.js.map +1 -1
- package/build/quote/save.js +1 -5
- package/build/quote/save.js.map +1 -1
- package/build/quote/transforms.js +110 -158
- package/build/quote/transforms.js.map +1 -1
- package/build/search/edit.js +1 -1
- package/build/search/edit.js.map +1 -1
- package/build/site-logo/edit.js +5 -13
- package/build/site-logo/edit.js.map +1 -1
- package/build/site-title/edit/level-toolbar.js +2 -1
- package/build/site-title/edit/level-toolbar.js.map +1 -1
- package/build/social-link/icons/index.js +13 -0
- package/build/social-link/icons/index.js.map +1 -1
- package/build/social-link/icons/whatsapp.js +25 -0
- package/build/social-link/icons/whatsapp.js.map +1 -0
- package/build/social-link/variations.js +7 -0
- package/build/social-link/variations.js.map +1 -1
- package/build/table/edit.js +1 -0
- package/build/table/edit.js.map +1 -1
- package/build/table/save.js +2 -1
- package/build/table/save.js.map +1 -1
- package/build/template-part/edit/index.js +17 -8
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/selection-modal.js +33 -13
- package/build/template-part/edit/selection-modal.js.map +1 -1
- package/build/template-part/edit/utils/search.js +94 -0
- package/build/template-part/edit/utils/search.js.map +1 -0
- package/build/template-part/index.js +1 -1
- package/build/template-part/index.js.map +1 -1
- package/build/template-part/variations.js +0 -16
- package/build/template-part/variations.js.map +1 -1
- package/build/utils/clean-empty-object.js +5 -3
- package/build/utils/clean-empty-object.js.map +1 -1
- package/build/video/edit.js +1 -0
- package/build/video/edit.js.map +1 -1
- package/build/video/save.js +1 -0
- package/build/video/save.js.map +1 -1
- package/build/video/tracks-editor.js +9 -11
- package/build/video/tracks-editor.js.map +1 -1
- package/build-module/audio/edit.js +2 -1
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/audio/save.js +3 -2
- package/build-module/audio/save.js.map +1 -1
- package/build-module/avatar/hooks.js +2 -2
- package/build-module/avatar/hooks.js.map +1 -1
- package/build-module/button/edit.js +4 -3
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/index.js +1 -24
- package/build-module/button/index.js.map +1 -1
- package/build-module/button/save.js +2 -2
- package/build-module/button/save.js.map +1 -1
- package/build-module/buttons/edit.js +2 -2
- package/build-module/buttons/edit.js.map +1 -1
- package/build-module/columns/edit.native.js +2 -2
- package/build-module/columns/edit.native.js.map +1 -1
- package/build-module/columns/variations.js +2 -2
- package/build-module/columns/variations.js.map +1 -1
- package/build-module/comment-author-name/edit.js +3 -5
- package/build-module/comment-author-name/edit.js.map +1 -1
- package/build-module/comment-author-name/index.js +0 -4
- package/build-module/comment-author-name/index.js.map +1 -1
- package/build-module/comment-date/edit.js +4 -4
- package/build-module/comment-date/edit.js.map +1 -1
- package/build-module/comment-date/index.js +0 -4
- package/build-module/comment-date/index.js.map +1 -1
- package/build-module/comment-edit-link/index.js +0 -4
- package/build-module/comment-edit-link/index.js.map +1 -1
- package/build-module/comment-reply-link/index.js +0 -4
- package/build-module/comment-reply-link/index.js.map +1 -1
- package/build-module/comment-template/index.js +1 -1
- package/build-module/comments/deprecated.js +54 -0
- package/build-module/comments/deprecated.js.map +1 -0
- package/build-module/comments/edit/comments-legacy.js +59 -0
- package/build-module/comments/edit/comments-legacy.js.map +1 -0
- package/build-module/comments/edit/index.js +37 -0
- package/build-module/comments/edit/index.js.map +1 -0
- package/build-module/comments/edit/placeholder.js +102 -0
- package/build-module/comments/edit/placeholder.js.map +1 -0
- package/build-module/comments/edit/template.js +32 -0
- package/build-module/comments/edit/template.js.map +1 -0
- package/build-module/comments/index.js +10 -3
- package/build-module/comments/index.js.map +1 -1
- package/build-module/comments/save.js +9 -4
- package/build-module/comments/save.js.map +1 -1
- package/build-module/comments-pagination/index.js +1 -1
- package/build-module/comments-title/deprecated.js +1 -4
- package/build-module/comments-title/deprecated.js.map +1 -1
- package/build-module/comments-title/index.js +1 -1
- package/build-module/cover/edit/block-controls.js +3 -13
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/cover/edit/cover-placeholder.js +3 -1
- package/build-module/cover/edit/cover-placeholder.js.map +1 -1
- package/build-module/cover/edit/index.js +19 -4
- package/build-module/cover/edit/index.js.map +1 -1
- package/build-module/cover/index.js +1 -0
- package/build-module/cover/index.js.map +1 -1
- package/build-module/cover/transforms.js +3 -2
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/embed/embed-placeholder.native.js +1 -2
- package/build-module/embed/embed-placeholder.native.js.map +1 -1
- package/build-module/embed/embed-preview.js +2 -1
- package/build-module/embed/embed-preview.js.map +1 -1
- package/build-module/embed/icons.js +19 -0
- package/build-module/embed/icons.js.map +1 -1
- package/build-module/embed/save.js +2 -1
- package/build-module/embed/save.js.map +1 -1
- package/build-module/embed/variations.js +12 -1
- package/build-module/embed/variations.js.map +1 -1
- package/build-module/file/edit.js +2 -2
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/save.js +2 -2
- package/build-module/file/save.js.map +1 -1
- package/build-module/gallery/edit.js +11 -18
- 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/save.js +2 -2
- package/build-module/gallery/save.js.map +1 -1
- package/build-module/gallery/transforms.js +33 -23
- package/build-module/gallery/transforms.js.map +1 -1
- package/build-module/gallery/use-get-media.js +6 -16
- package/build-module/gallery/use-get-media.js.map +1 -1
- package/build-module/gallery/use-get-media.native.js +50 -0
- package/build-module/gallery/use-get-media.native.js.map +1 -0
- package/build-module/gallery/v1/edit.js +4 -4
- package/build-module/gallery/v1/edit.js.map +1 -1
- package/build-module/gallery/v1/gallery-image.js +2 -1
- package/build-module/gallery/v1/gallery-image.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/gallery/v1/save.js +8 -3
- package/build-module/gallery/v1/save.js.map +1 -1
- package/build-module/group/edit.js +1 -3
- package/build-module/group/edit.js.map +1 -1
- package/build-module/group/index.js +2 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/group/variations.js +2 -2
- package/build-module/group/variations.js.map +1 -1
- package/build-module/heading/heading-level-dropdown.js +2 -1
- package/build-module/heading/heading-level-dropdown.js.map +1 -1
- package/build-module/heading/index.js +9 -4
- package/build-module/heading/index.js.map +1 -1
- package/build-module/html/edit.js +12 -23
- package/build-module/html/edit.js.map +1 -1
- package/build-module/html/preview.js +38 -0
- package/build-module/html/preview.js.map +1 -0
- package/build-module/image/deprecated.js +77 -9
- package/build-module/image/deprecated.js.map +1 -1
- package/build-module/image/edit.js +5 -3
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +20 -9
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +30 -22
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +7 -1
- package/build-module/image/index.js.map +1 -1
- package/build-module/image/save.js +10 -3
- package/build-module/image/save.js.map +1 -1
- package/build-module/index.js +1 -2
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js +3 -13
- package/build-module/index.native.js.map +1 -1
- package/build-module/latest-posts/edit.js +2 -2
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/list/transforms.js +4 -63
- package/build-module/list/transforms.js.map +1 -1
- package/build-module/list/v2/transforms.js +32 -44
- package/build-module/list/v2/transforms.js.map +1 -1
- package/build-module/list-item/edit.js +14 -10
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/index.js +1 -1
- package/build-module/list-item/hooks/index.js.map +1 -1
- package/build-module/list-item/hooks/use-enter.js +7 -4
- package/build-module/list-item/hooks/use-enter.js.map +1 -1
- package/build-module/list-item/hooks/use-merge.js +160 -0
- package/build-module/list-item/hooks/use-merge.js.map +1 -0
- package/build-module/list-item/hooks/use-outdent-list-item.js +88 -33
- package/build-module/list-item/hooks/use-outdent-list-item.js.map +1 -1
- package/build-module/list-item/utils.js +123 -2
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/media-text/deprecated.js +134 -8
- package/build-module/media-text/deprecated.js.map +1 -1
- package/build-module/media-text/edit.js +2 -2
- package/build-module/media-text/edit.js.map +1 -1
- package/build-module/media-text/save.js +13 -0
- package/build-module/media-text/save.js.map +1 -1
- package/build-module/more/edit.js +2 -4
- package/build-module/more/edit.js.map +1 -1
- package/build-module/more/save.js +1 -6
- package/build-module/more/save.js.map +1 -1
- package/build-module/navigation/edit/index.js +1 -1
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/index.js +9 -0
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/use-navigation-menu.js +17 -75
- package/build-module/navigation/use-navigation-menu.js.map +1 -1
- package/build-module/navigation/view.js +6 -1
- package/build-module/navigation/view.js.map +1 -1
- package/build-module/navigation-link/edit.js +5 -4
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/hooks.js +0 -13
- package/build-module/navigation-link/hooks.js.map +1 -1
- package/build-module/navigation-link/index.js +1 -1
- package/build-module/navigation-link/index.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +2 -1
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/navigation-submenu/view.js +6 -1
- package/build-module/navigation-submenu/view.js.map +1 -1
- package/build-module/nextpage/edit.js +1 -3
- package/build-module/nextpage/edit.js.map +1 -1
- package/build-module/page-list/edit.js +10 -3
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/paragraph/edit.js +8 -12
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/post-comments-form/edit.js +5 -35
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +46 -5
- package/build-module/post-comments-form/form.js.map +1 -1
- package/build-module/post-terms/edit.js +3 -2
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/post-terms/index.js +1 -1
- package/build-module/post-terms/index.js.map +1 -1
- package/build-module/post-title/index.js +1 -0
- package/build-module/post-title/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +1 -1
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/index.js +1 -1
- package/build-module/query/index.js.map +1 -1
- package/build-module/query-no-results/edit.js +2 -2
- package/build-module/query-no-results/edit.js.map +1 -1
- package/build-module/query-pagination-next/edit.js +2 -1
- package/build-module/query-pagination-next/edit.js.map +1 -1
- package/build-module/query-pagination-previous/edit.js +2 -1
- package/build-module/query-pagination-previous/edit.js.map +1 -1
- package/build-module/quote/deprecated.js +162 -36
- package/build-module/quote/deprecated.js.map +1 -1
- package/build-module/quote/edit.js +77 -43
- package/build-module/quote/edit.js.map +1 -1
- package/build-module/quote/index.js +9 -39
- package/build-module/quote/index.js.map +1 -1
- package/build-module/quote/save.js +4 -8
- package/build-module/quote/save.js.map +1 -1
- package/build-module/quote/transforms.js +111 -158
- package/build-module/quote/transforms.js.map +1 -1
- package/build-module/search/edit.js +2 -2
- package/build-module/search/edit.js.map +1 -1
- package/build-module/site-logo/edit.js +5 -13
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/site-title/edit/level-toolbar.js +2 -1
- package/build-module/site-title/edit/level-toolbar.js.map +1 -1
- package/build-module/social-link/icons/index.js +1 -0
- package/build-module/social-link/icons/index.js.map +1 -1
- package/build-module/social-link/icons/whatsapp.js +15 -0
- package/build-module/social-link/icons/whatsapp.js.map +1 -0
- package/build-module/social-link/variations.js +8 -1
- package/build-module/social-link/variations.js.map +1 -1
- package/build-module/table/edit.js +2 -1
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table/save.js +3 -2
- package/build-module/table/save.js.map +1 -1
- package/build-module/template-part/edit/index.js +20 -11
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/selection-modal.js +33 -15
- package/build-module/template-part/edit/selection-modal.js.map +1 -1
- package/build-module/template-part/edit/utils/search.js +84 -0
- package/build-module/template-part/edit/utils/search.js.map +1 -0
- package/build-module/template-part/index.js +1 -1
- package/build-module/template-part/index.js.map +1 -1
- package/build-module/template-part/variations.js +0 -13
- package/build-module/template-part/variations.js.map +1 -1
- package/build-module/utils/clean-empty-object.js +5 -2
- package/build-module/utils/clean-empty-object.js.map +1 -1
- package/build-module/video/edit.js +2 -1
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/save.js +2 -1
- package/build-module/video/save.js.map +1 -1
- package/build-module/video/tracks-editor.js +9 -11
- package/build-module/video/tracks-editor.js.map +1 -1
- package/build-style/button/style-rtl.css +6 -1
- package/build-style/button/style.css +6 -1
- package/build-style/comment-template/style-rtl.css +12 -0
- package/build-style/comment-template/style.css +12 -0
- package/build-style/comments/editor-rtl.css +122 -0
- package/build-style/comments/editor.css +122 -0
- package/build-style/{post-comments → comments}/style-rtl.css +3 -1
- package/build-style/{post-comments → comments}/style.css +3 -1
- package/build-style/common-rtl.css +7 -0
- package/build-style/common.css +7 -0
- package/build-style/cover/style-rtl.css +2 -2
- package/build-style/cover/style.css +2 -2
- package/build-style/editor-elements-rtl.css +85 -0
- package/build-style/editor-elements.css +85 -0
- package/build-style/editor-rtl.css +154 -10
- package/build-style/editor.css +154 -10
- package/build-style/{post-comments/editor-rtl.css → elements-rtl.css} +5 -2
- package/build-style/{post-comments/editor.css → elements.css} +5 -2
- package/build-style/file/style-rtl.css +5 -8
- package/build-style/file/style.css +5 -8
- package/build-style/gallery/style-rtl.css +7 -2
- package/build-style/gallery/style.css +7 -2
- package/build-style/image/editor-rtl.css +4 -3
- package/build-style/image/editor.css +4 -3
- package/build-style/image/style-rtl.css +33 -3
- package/build-style/image/style.css +33 -3
- package/build-style/navigation/style-rtl.css +9 -1
- package/build-style/navigation/style.css +9 -1
- package/build-style/post-comments-form/editor-rtl.css +3 -0
- package/build-style/post-comments-form/editor.css +3 -0
- package/build-style/post-comments-form/style-rtl.css +0 -1
- package/build-style/post-comments-form/style.css +0 -1
- package/build-style/post-template/style-rtl.css +9 -18
- package/build-style/post-template/style.css +9 -18
- package/build-style/query/editor-rtl.css +1 -1
- package/build-style/query/editor.css +1 -1
- package/build-style/search/style-rtl.css +6 -8
- package/build-style/search/style.css +6 -8
- package/build-style/search/theme-rtl.css +5 -0
- package/build-style/search/theme.css +5 -0
- package/build-style/social-link/editor-rtl.css +1 -0
- package/build-style/social-link/editor.css +1 -0
- package/build-style/social-links/style-rtl.css +8 -0
- package/build-style/social-links/style.css +8 -0
- package/build-style/style-rtl.css +216 -154
- package/build-style/style.css +216 -154
- package/build-style/template-part/editor-rtl.css +14 -3
- package/build-style/template-part/editor.css +14 -3
- package/build-style/theme-rtl.css +5 -0
- package/build-style/theme.css +5 -0
- package/package.json +28 -28
- package/src/audio/edit.js +4 -0
- package/src/audio/save.js +12 -2
- package/src/avatar/hooks.js +6 -9
- package/src/button/block.json +1 -24
- package/src/button/edit.js +3 -2
- package/src/button/save.js +2 -2
- package/src/button/style.scss +13 -1
- package/src/buttons/edit.js +1 -5
- package/src/columns/edit.native.js +2 -2
- package/src/columns/variations.js +2 -2
- package/src/comment-author-name/block.json +0 -4
- package/src/comment-author-name/edit.js +3 -12
- package/src/comment-date/block.json +0 -4
- package/src/comment-date/edit.js +10 -14
- package/src/comment-date/index.php +0 -3
- package/src/comment-edit-link/block.json +0 -4
- package/src/comment-reply-link/block.json +0 -4
- package/src/comment-template/block.json +1 -1
- package/src/comment-template/style.scss +14 -0
- package/src/comments/block.json +7 -2
- package/src/comments/deprecated.js +53 -0
- package/src/comments/edit/comments-legacy.js +71 -0
- package/src/comments/edit/index.js +35 -0
- package/src/comments/edit/placeholder.js +124 -0
- package/src/comments/{edit.js → edit/template.js} +25 -32
- package/src/comments/editor.scss +9 -0
- package/src/comments/index.js +2 -0
- package/src/comments/index.php +219 -0
- package/src/comments/save.js +8 -7
- package/src/{post-comments → comments}/style.scss +14 -3
- package/src/comments-pagination/block.json +1 -1
- package/src/comments-title/block.json +1 -1
- package/src/comments-title/deprecated.js +0 -2
- package/src/common.scss +2 -0
- package/src/cover/block.json +1 -0
- package/src/cover/edit/block-controls.js +4 -20
- package/src/cover/edit/cover-placeholder.js +2 -0
- package/src/cover/edit/index.js +16 -0
- package/src/cover/index.php +21 -8
- package/src/cover/style.scss +2 -2
- package/src/cover/transforms.js +2 -2
- package/src/editor-elements.scss +10 -0
- package/src/editor.scss +2 -1
- package/src/elements.scss +6 -0
- package/src/embed/embed-placeholder.native.js +2 -3
- package/src/embed/embed-preview.js +8 -1
- package/src/embed/icons.js +25 -0
- package/src/embed/save.js +10 -2
- package/src/embed/test/__snapshots__/index.native.js.snap +1 -1
- package/src/embed/variations.js +10 -0
- package/src/file/edit.js +4 -2
- package/src/file/save.js +2 -2
- package/src/file/style.scss +5 -5
- package/src/freeform/editor.scss +0 -2
- package/src/gallery/edit.js +12 -23
- package/src/gallery/gallery.js +9 -2
- package/src/gallery/index.php +5 -1
- package/src/gallery/save.js +5 -1
- package/src/gallery/style.scss +10 -1
- package/src/gallery/test/__snapshots__/index.native.js.snap +2 -2
- package/src/gallery/test/helpers.native.js +11 -198
- package/src/gallery/test/index.native.js +19 -29
- package/src/gallery/transforms.js +28 -13
- package/src/gallery/use-get-media.js +11 -28
- package/src/gallery/use-get-media.native.js +44 -0
- package/src/gallery/v1/edit.js +3 -4
- package/src/gallery/v1/gallery-image.js +4 -0
- package/src/gallery/v1/gallery.js +8 -2
- package/src/gallery/v1/save.js +20 -3
- package/src/group/block.json +2 -0
- package/src/group/edit.js +1 -3
- package/src/group/variations.js +2 -2
- package/src/heading/heading-level-dropdown.js +1 -0
- package/src/heading/index.js +8 -2
- package/src/html/edit.js +10 -40
- package/src/html/preview.js +46 -0
- package/src/image/block.json +7 -1
- package/src/image/deprecated.js +86 -0
- package/src/image/edit.js +6 -1
- package/src/image/edit.native.js +19 -7
- package/src/image/editor.scss +9 -4
- package/src/image/image.js +28 -16
- package/src/image/save.js +20 -3
- package/src/image/style.scss +39 -3
- package/src/image/test/edit.native.js +51 -19
- package/src/index.js +0 -2
- package/src/index.native.js +2 -11
- package/src/latest-posts/edit.js +2 -6
- package/src/list/transforms.js +0 -47
- package/src/list/v2/transforms.js +23 -46
- package/src/list-item/edit.js +10 -12
- package/src/list-item/hooks/index.js +1 -1
- package/src/list-item/hooks/use-enter.js +9 -6
- package/src/list-item/hooks/use-merge.js +141 -0
- package/src/list-item/hooks/use-outdent-list-item.js +79 -54
- package/src/list-item/utils.js +27 -3
- package/src/media-text/deprecated.js +148 -1
- package/src/media-text/edit.js +2 -1
- package/src/media-text/save.js +18 -0
- package/src/more/edit.js +9 -11
- package/src/more/save.js +3 -6
- package/src/navigation/block.json +9 -0
- package/src/navigation/edit/index.js +1 -0
- package/src/navigation/style.scss +11 -2
- package/src/navigation/test/use-navigation-menu.js +16 -11
- package/src/navigation/use-navigation-menu.js +26 -83
- package/src/navigation/view.js +6 -1
- package/src/navigation-link/edit.js +4 -3
- package/src/navigation-link/hooks.js +0 -14
- package/src/navigation-link/index.js +1 -1
- package/src/navigation-link/test/__snapshots__/hooks.js.snap +0 -93
- package/src/navigation-link/test/hooks.js +0 -12
- package/src/navigation-submenu/edit.js +1 -0
- package/src/navigation-submenu/view.js +6 -1
- package/src/nextpage/edit.js +1 -3
- package/src/page-list/edit.js +12 -5
- package/src/paragraph/edit.js +8 -14
- package/src/post-comments-form/edit.js +3 -58
- package/src/post-comments-form/editor.scss +4 -0
- package/src/post-comments-form/form.js +81 -6
- package/src/post-comments-form/index.php +1 -1
- package/src/post-comments-form/style.scss +0 -1
- package/src/post-featured-image/index.php +4 -2
- package/src/post-template/index.php +23 -17
- package/src/post-template/style.scss +1 -7
- package/src/post-terms/edit.js +3 -2
- package/src/post-terms/index.js +1 -1
- package/src/post-title/block.json +1 -0
- package/src/query/edit/inspector-controls/index.js +1 -1
- package/src/query/editor.scss +1 -1
- package/src/query/index.js +1 -1
- package/src/query-no-results/edit.js +2 -5
- package/src/query-no-results/index.php +10 -8
- package/src/query-pagination-next/edit.js +1 -0
- package/src/query-pagination-previous/edit.js +1 -0
- package/src/quote/deprecated.js +213 -99
- package/src/quote/edit.js +77 -52
- package/src/quote/index.js +10 -33
- package/src/quote/save.js +5 -5
- package/src/quote/{v2/test → test}/migrate.js +2 -7
- package/src/quote/transforms.js +117 -147
- package/src/search/edit.js +2 -2
- package/src/search/index.php +12 -10
- package/src/search/style.scss +9 -8
- package/src/search/theme.scss +5 -0
- package/src/site-logo/edit.js +2 -11
- package/src/site-title/edit/level-toolbar.js +1 -0
- package/src/social-link/editor.scss +3 -0
- package/src/social-link/icons/index.js +1 -0
- package/src/social-link/icons/whatsapp.js +10 -0
- package/src/social-link/index.php +20 -0
- package/src/social-link/socials-with-bg.scss +5 -0
- package/src/social-link/socials-without-bg.scss +5 -0
- package/src/social-link/variations.js +7 -0
- package/src/style.scss +1 -1
- package/src/table/edit.js +2 -0
- package/src/table/save.js +6 -1
- package/src/template-part/edit/index.js +37 -24
- package/src/template-part/edit/selection-modal.js +68 -40
- package/src/template-part/edit/utils/search.js +76 -0
- package/src/template-part/editor.scss +21 -9
- package/src/template-part/index.js +1 -1
- package/src/template-part/index.php +56 -2
- package/src/template-part/variations.js +0 -11
- package/src/utils/clean-empty-object.js +8 -2
- package/src/video/edit.js +4 -0
- package/src/video/save.js +10 -2
- package/src/video/tracks-editor.js +1 -1
- package/build/comments/edit.js.map +0 -1
- package/build/gallery/use-short-code-transform.js +0 -64
- package/build/gallery/use-short-code-transform.js.map +0 -1
- package/build/list-item/hooks/use-backspace.js +0 -59
- package/build/list-item/hooks/use-backspace.js.map +0 -1
- package/build/navigation-link/fallback-variations.js +0 -75
- package/build/navigation-link/fallback-variations.js.map +0 -1
- package/build/post-comments/edit.js +0 -184
- package/build/post-comments/edit.js.map +0 -1
- package/build/post-comments/index.js +0 -72
- package/build/post-comments/index.js.map +0 -1
- package/build/quote/v2/deprecated.js +0 -133
- package/build/quote/v2/deprecated.js.map +0 -1
- package/build/quote/v2/edit.js +0 -139
- package/build/quote/v2/edit.js.map +0 -1
- package/build/quote/v2/index.js +0 -49
- package/build/quote/v2/index.js.map +0 -1
- package/build/quote/v2/save.js +0 -43
- package/build/quote/v2/save.js.map +0 -1
- package/build/quote/v2/transforms.js +0 -156
- package/build/quote/v2/transforms.js.map +0 -1
- package/build/template-part/fallback-variations.js +0 -59
- package/build/template-part/fallback-variations.js.map +0 -1
- package/build-module/comments/edit.js +0 -51
- package/build-module/comments/edit.js.map +0 -1
- package/build-module/gallery/use-short-code-transform.js +0 -54
- package/build-module/gallery/use-short-code-transform.js.map +0 -1
- package/build-module/list-item/hooks/use-backspace.js +0 -44
- package/build-module/list-item/hooks/use-backspace.js.map +0 -1
- package/build-module/navigation-link/fallback-variations.js +0 -65
- package/build-module/navigation-link/fallback-variations.js.map +0 -1
- package/build-module/post-comments/edit.js +0 -171
- package/build-module/post-comments/edit.js.map +0 -1
- package/build-module/post-comments/index.js +0 -59
- package/build-module/post-comments/index.js.map +0 -1
- package/build-module/quote/v2/deprecated.js +0 -116
- package/build-module/quote/v2/deprecated.js.map +0 -1
- package/build-module/quote/v2/edit.js +0 -122
- package/build-module/quote/v2/edit.js.map +0 -1
- package/build-module/quote/v2/index.js +0 -33
- package/build-module/quote/v2/index.js.map +0 -1
- package/build-module/quote/v2/save.js +0 -30
- package/build-module/quote/v2/save.js.map +0 -1
- package/build-module/quote/v2/transforms.js +0 -147
- package/build-module/quote/v2/transforms.js.map +0 -1
- package/build-module/template-part/fallback-variations.js +0 -47
- package/build-module/template-part/fallback-variations.js.map +0 -1
- package/src/gallery/use-short-code-transform.js +0 -55
- package/src/list-item/hooks/use-backspace.js +0 -51
- package/src/navigation-link/fallback-variations.js +0 -65
- package/src/post-comments/block.json +0 -45
- package/src/post-comments/edit.js +0 -247
- package/src/post-comments/editor.scss +0 -3
- package/src/post-comments/index.js +0 -18
- package/src/post-comments/index.php +0 -87
- package/src/quote/v2/deprecated.js +0 -107
- package/src/quote/v2/edit.js +0 -139
- package/src/quote/v2/index.js +0 -36
- package/src/quote/v2/save.js +0 -26
- package/src/quote/v2/transforms.js +0 -155
- package/src/template-part/fallback-variations.js +0 -51
|
@@ -16,6 +16,7 @@ import Clipboard from '@react-native-clipboard/clipboard';
|
|
|
16
16
|
*/
|
|
17
17
|
import { getBlockTypes, unregisterBlockType } from '@wordpress/blocks';
|
|
18
18
|
import {
|
|
19
|
+
requestMediaPicker,
|
|
19
20
|
setFeaturedImage,
|
|
20
21
|
sendMediaUpload,
|
|
21
22
|
subscribeMediaUpload,
|
|
@@ -49,6 +50,10 @@ jest.mock( 'lodash', () => {
|
|
|
49
50
|
return { ...actual, delay: ( cb ) => cb() };
|
|
50
51
|
} );
|
|
51
52
|
|
|
53
|
+
function mockGetMedia( media ) {
|
|
54
|
+
jest.spyOn( select( coreStore ), 'getMedia' ).mockReturnValue( media );
|
|
55
|
+
}
|
|
56
|
+
|
|
52
57
|
const apiFetchPromise = Promise.resolve( {} );
|
|
53
58
|
|
|
54
59
|
const clipboardPromise = Promise.resolve( '' );
|
|
@@ -79,7 +84,7 @@ describe( 'Image Block', () => {
|
|
|
79
84
|
<a href="https://cldup.com/cXyG__fTLN.jpg">
|
|
80
85
|
<img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/>
|
|
81
86
|
</a>
|
|
82
|
-
<figcaption>Mountain</figcaption></figure>
|
|
87
|
+
<figcaption class="wp-element-caption">Mountain</figcaption></figure>
|
|
83
88
|
<!-- /wp:image -->`;
|
|
84
89
|
const screen = await initializeEditor( { initialHtml } );
|
|
85
90
|
// We must await the image fetch via `getMedia`
|
|
@@ -95,7 +100,7 @@ describe( 'Image Block', () => {
|
|
|
95
100
|
fireEvent.press( screen.getByText( 'None' ) );
|
|
96
101
|
|
|
97
102
|
const expectedHtml = `<!-- wp:image {"id":1,"sizeSlug":"large","linkDestination":"none","className":"is-style-default"} -->
|
|
98
|
-
<figure class="wp-block-image size-large is-style-default"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/><figcaption>Mountain</figcaption></figure>
|
|
103
|
+
<figure class="wp-block-image size-large is-style-default"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/><figcaption class="wp-element-caption">Mountain</figcaption></figure>
|
|
99
104
|
<!-- /wp:image -->`;
|
|
100
105
|
expect( getEditorHtml() ).toBe( expectedHtml );
|
|
101
106
|
} );
|
|
@@ -105,7 +110,7 @@ describe( 'Image Block', () => {
|
|
|
105
110
|
<!-- wp:image {"id":1,"sizeSlug":"large","linkDestination":"none","className":"is-style-default"} -->
|
|
106
111
|
<figure class="wp-block-image size-large is-style-default">
|
|
107
112
|
<img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/>
|
|
108
|
-
<figcaption>Mountain</figcaption></figure>
|
|
113
|
+
<figcaption class="wp-element-caption">Mountain</figcaption></figure>
|
|
109
114
|
<!-- /wp:image -->`;
|
|
110
115
|
const screen = await initializeEditor( { initialHtml } );
|
|
111
116
|
// We must await the image fetch via `getMedia`
|
|
@@ -121,7 +126,7 @@ describe( 'Image Block', () => {
|
|
|
121
126
|
fireEvent.press( screen.getByText( 'Media File' ) );
|
|
122
127
|
|
|
123
128
|
const expectedHtml = `<!-- wp:image {"id":1,"sizeSlug":"large","linkDestination":"media","className":"is-style-default"} -->
|
|
124
|
-
<figure class="wp-block-image size-large is-style-default"><a href="https://cldup.com/cXyG__fTLN.jpg"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/></a><figcaption>Mountain</figcaption></figure>
|
|
129
|
+
<figure class="wp-block-image size-large is-style-default"><a href="https://cldup.com/cXyG__fTLN.jpg"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/></a><figcaption class="wp-element-caption">Mountain</figcaption></figure>
|
|
125
130
|
<!-- /wp:image -->`;
|
|
126
131
|
expect( getEditorHtml() ).toBe( expectedHtml );
|
|
127
132
|
} );
|
|
@@ -131,7 +136,7 @@ describe( 'Image Block', () => {
|
|
|
131
136
|
<!-- wp:image {"id":1,"sizeSlug":"large","linkDestination":"none","className":"is-style-default"} -->
|
|
132
137
|
<figure class="wp-block-image size-large is-style-default">
|
|
133
138
|
<img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/>
|
|
134
|
-
<figcaption>Mountain</figcaption></figure>
|
|
139
|
+
<figcaption class="wp-element-caption">Mountain</figcaption></figure>
|
|
135
140
|
<!-- /wp:image -->`;
|
|
136
141
|
const screen = await initializeEditor( { initialHtml } );
|
|
137
142
|
// We must await the image fetch via `getMedia`
|
|
@@ -154,7 +159,7 @@ describe( 'Image Block', () => {
|
|
|
154
159
|
fireEvent.press( screen.getByA11yLabel( 'Apply' ) );
|
|
155
160
|
|
|
156
161
|
const expectedHtml = `<!-- wp:image {"id":1,"sizeSlug":"large","linkDestination":"custom","className":"is-style-default"} -->
|
|
157
|
-
<figure class="wp-block-image size-large is-style-default"><a href="http://wordpress.org"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/></a><figcaption>Mountain</figcaption></figure>
|
|
162
|
+
<figure class="wp-block-image size-large is-style-default"><a href="http://wordpress.org"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/></a><figcaption class="wp-element-caption">Mountain</figcaption></figure>
|
|
158
163
|
<!-- /wp:image -->`;
|
|
159
164
|
expect( getEditorHtml() ).toBe( expectedHtml );
|
|
160
165
|
} );
|
|
@@ -164,7 +169,7 @@ describe( 'Image Block', () => {
|
|
|
164
169
|
<!-- wp:image {"id":1,"sizeSlug":"large","linkDestination":"none","className":"is-style-default"} -->
|
|
165
170
|
<figure class="wp-block-image size-large is-style-default">
|
|
166
171
|
<img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/>
|
|
167
|
-
<figcaption>Mountain</figcaption></figure>
|
|
172
|
+
<figcaption class="wp-element-caption">Mountain</figcaption></figure>
|
|
168
173
|
<!-- /wp:image -->`;
|
|
169
174
|
const screen = await initializeEditor( { initialHtml } );
|
|
170
175
|
// We must await the image fetch via `getMedia`
|
|
@@ -192,7 +197,7 @@ describe( 'Image Block', () => {
|
|
|
192
197
|
fireEvent.press( screen.getByText( 'Media File' ) );
|
|
193
198
|
|
|
194
199
|
const expectedHtml = `<!-- wp:image {"id":1,"sizeSlug":"large","linkDestination":"media","className":"is-style-default"} -->
|
|
195
|
-
<figure class="wp-block-image size-large is-style-default"><a href="https://cldup.com/cXyG__fTLN.jpg"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/></a><figcaption>Mountain</figcaption></figure>
|
|
200
|
+
<figure class="wp-block-image size-large is-style-default"><a href="https://cldup.com/cXyG__fTLN.jpg"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/></a><figcaption class="wp-element-caption">Mountain</figcaption></figure>
|
|
196
201
|
<!-- /wp:image -->`;
|
|
197
202
|
expect( getEditorHtml() ).toBe( expectedHtml );
|
|
198
203
|
} );
|
|
@@ -204,7 +209,7 @@ describe( 'Image Block', () => {
|
|
|
204
209
|
<a href="https://cldup.com/cXyG__fTLN.jpg">
|
|
205
210
|
<img src="https://cldup.com/cXyG__fTLN.jpg?w=683" alt="" class="wp-image-1"/>
|
|
206
211
|
</a>
|
|
207
|
-
<figcaption>Mountain</figcaption></figure>
|
|
212
|
+
<figcaption class="wp-element-caption">Mountain</figcaption></figure>
|
|
208
213
|
<!-- /wp:image -->`;
|
|
209
214
|
const screen = await initializeEditor( { initialHtml } );
|
|
210
215
|
// We must await the image fetch via `getMedia`
|
|
@@ -228,7 +233,7 @@ describe( 'Image Block', () => {
|
|
|
228
233
|
<a href="https://wordpress.org">
|
|
229
234
|
<img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/>
|
|
230
235
|
</a>
|
|
231
|
-
<figcaption>Mountain</figcaption></figure>
|
|
236
|
+
<figcaption class="wp-element-caption">Mountain</figcaption></figure>
|
|
232
237
|
<!-- /wp:image -->`;
|
|
233
238
|
const screen = await initializeEditor( { initialHtml } );
|
|
234
239
|
// We must await the image fetch via `getMedia`
|
|
@@ -246,7 +251,7 @@ describe( 'Image Block', () => {
|
|
|
246
251
|
fireEvent.press( linkTargetButton );
|
|
247
252
|
|
|
248
253
|
const expectedHtml = `<!-- wp:image {"id":1,"sizeSlug":"large","linkDestination":"custom","className":"is-style-default"} -->
|
|
249
|
-
<figure class="wp-block-image size-large is-style-default"><a href="https://wordpress.org" target="_blank" rel="noreferrer noopener"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/></a><figcaption>Mountain</figcaption></figure>
|
|
254
|
+
<figure class="wp-block-image size-large is-style-default"><a href="https://wordpress.org" target="_blank" rel="noreferrer noopener"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/></a><figcaption class="wp-element-caption">Mountain</figcaption></figure>
|
|
250
255
|
<!-- /wp:image -->`;
|
|
251
256
|
expect( getEditorHtml() ).toBe( expectedHtml );
|
|
252
257
|
} );
|
|
@@ -258,7 +263,7 @@ describe( 'Image Block', () => {
|
|
|
258
263
|
<a href="https://wordpress.org" target="_blank" rel="noreferrer noopener">
|
|
259
264
|
<img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/>
|
|
260
265
|
</a>
|
|
261
|
-
<figcaption>Mountain</figcaption>
|
|
266
|
+
<figcaption class="wp-element-caption">Mountain</figcaption>
|
|
262
267
|
</figure>
|
|
263
268
|
<!-- /wp:image -->`;
|
|
264
269
|
const screen = await initializeEditor( { initialHtml } );
|
|
@@ -277,7 +282,7 @@ describe( 'Image Block', () => {
|
|
|
277
282
|
fireEvent.press( linkTargetButton );
|
|
278
283
|
|
|
279
284
|
const expectedHtml = `<!-- wp:image {"id":1,"sizeSlug":"large","linkDestination":"custom","className":"is-style-default"} -->
|
|
280
|
-
<figure class="wp-block-image size-large is-style-default"><a href="https://wordpress.org"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/></a><figcaption>Mountain</figcaption></figure>
|
|
285
|
+
<figure class="wp-block-image size-large is-style-default"><a href="https://wordpress.org"><img src="https://cldup.com/cXyG__fTLN.jpg" alt="" class="wp-image-1"/></a><figcaption class="wp-element-caption">Mountain</figcaption></figure>
|
|
281
286
|
<!-- /wp:image -->`;
|
|
282
287
|
expect( getEditorHtml() ).toBe( expectedHtml );
|
|
283
288
|
} );
|
|
@@ -292,12 +297,6 @@ describe( 'Image Block', () => {
|
|
|
292
297
|
);
|
|
293
298
|
}
|
|
294
299
|
|
|
295
|
-
function mockGetMedia( media ) {
|
|
296
|
-
jest.spyOn( select( coreStore ), 'getMedia' ).mockReturnValueOnce(
|
|
297
|
-
media
|
|
298
|
-
);
|
|
299
|
-
}
|
|
300
|
-
|
|
301
300
|
it( 'does not prompt to replace featured image during a new image upload', () => {
|
|
302
301
|
// Arrange
|
|
303
302
|
const INITIAL_IMAGE = { id: 1, url: 'mock-url-1' };
|
|
@@ -406,4 +405,37 @@ describe( 'Image Block', () => {
|
|
|
406
405
|
);
|
|
407
406
|
} );
|
|
408
407
|
} );
|
|
408
|
+
|
|
409
|
+
it( 'sets src and alt attributes when selecting media', async () => {
|
|
410
|
+
const IMAGE = { id: 1, url: 'mock-image', alt: 'A beautiful mountain' };
|
|
411
|
+
requestMediaPicker.mockImplementationOnce(
|
|
412
|
+
( source, filter, multiple, callback ) => {
|
|
413
|
+
callback( {
|
|
414
|
+
id: IMAGE.id,
|
|
415
|
+
url: IMAGE.url,
|
|
416
|
+
alt: IMAGE.alt,
|
|
417
|
+
} );
|
|
418
|
+
}
|
|
419
|
+
);
|
|
420
|
+
mockGetMedia( {
|
|
421
|
+
id: IMAGE.id,
|
|
422
|
+
source_url: IMAGE.url,
|
|
423
|
+
} );
|
|
424
|
+
|
|
425
|
+
const initialHtml = `
|
|
426
|
+
<!-- wp:image -->
|
|
427
|
+
<figure class="wp-block-image">
|
|
428
|
+
<img alt="" />
|
|
429
|
+
</figure>
|
|
430
|
+
<!-- /wp:image -->`;
|
|
431
|
+
const screen = await initializeEditor( { initialHtml } );
|
|
432
|
+
|
|
433
|
+
fireEvent.press( screen.getByText( 'ADD IMAGE' ) );
|
|
434
|
+
fireEvent.press( screen.getByText( 'WordPress Media Library' ) );
|
|
435
|
+
|
|
436
|
+
const expectedHtml = `<!-- wp:image {"id":${ IMAGE.id },"sizeSlug":"large","linkDestination":"none"} -->
|
|
437
|
+
<figure class="wp-block-image size-large"><img src="${ IMAGE.url }" alt="${ IMAGE.alt }" class="wp-image-${ IMAGE.id }"/></figure>
|
|
438
|
+
<!-- /wp:image -->`;
|
|
439
|
+
expect( getEditorHtml() ).toBe( expectedHtml );
|
|
440
|
+
} );
|
|
409
441
|
} );
|
package/src/index.js
CHANGED
|
@@ -73,7 +73,6 @@ import * as postAuthor from './post-author';
|
|
|
73
73
|
import * as postAuthorName from './post-author-name';
|
|
74
74
|
import * as postAuthorBiography from './post-author-biography';
|
|
75
75
|
import * as postComment from './post-comment';
|
|
76
|
-
import * as postComments from './post-comments';
|
|
77
76
|
import * as postCommentsCount from './post-comments-count';
|
|
78
77
|
import * as postCommentsForm from './post-comments-form';
|
|
79
78
|
import * as postCommentsLink from './post-comments-link';
|
|
@@ -228,7 +227,6 @@ const getAllBlocks = () => [
|
|
|
228
227
|
commentsPaginationNext,
|
|
229
228
|
commentsPaginationNumbers,
|
|
230
229
|
commentsPaginationPrevious,
|
|
231
|
-
postComments,
|
|
232
230
|
postCommentsForm,
|
|
233
231
|
tableOfContents,
|
|
234
232
|
homeLink,
|
package/src/index.native.js
CHANGED
|
@@ -179,14 +179,6 @@ const devOnly = ( block ) => ( !! __DEV__ ? block : null );
|
|
|
179
179
|
const iOSOnly = ( block ) =>
|
|
180
180
|
Platform.OS === 'ios' ? block : devOnly( block );
|
|
181
181
|
|
|
182
|
-
// To be removed once Quote V2 is released on the web editor.
|
|
183
|
-
function quoteCheck( quoteBlock, blocksFlags ) {
|
|
184
|
-
if ( blocksFlags?.__experimentalEnableQuoteBlockV2 ) {
|
|
185
|
-
quoteBlock.settings = quoteBlock?.settingsV2;
|
|
186
|
-
}
|
|
187
|
-
return quoteBlock;
|
|
188
|
-
}
|
|
189
|
-
|
|
190
182
|
// Hide the Classic block and SocialLink block
|
|
191
183
|
addFilter(
|
|
192
184
|
'blocks.registerBlockType',
|
|
@@ -238,10 +230,9 @@ addFilter(
|
|
|
238
230
|
*
|
|
239
231
|
* registerCoreBlocks();
|
|
240
232
|
* ```
|
|
241
|
-
* @param {Object} [blocksFlags] Experimental flags
|
|
242
233
|
*
|
|
243
234
|
*/
|
|
244
|
-
export const registerCoreBlocks = (
|
|
235
|
+
export const registerCoreBlocks = () => {
|
|
245
236
|
// When adding new blocks to this list please also consider updating /src/block-support/supported-blocks.json in the Gutenberg-Mobile repo
|
|
246
237
|
[
|
|
247
238
|
paragraph,
|
|
@@ -254,7 +245,7 @@ export const registerCoreBlocks = ( blocksFlags ) => {
|
|
|
254
245
|
nextpage,
|
|
255
246
|
separator,
|
|
256
247
|
list,
|
|
257
|
-
|
|
248
|
+
quote,
|
|
258
249
|
mediaText,
|
|
259
250
|
preformatted,
|
|
260
251
|
gallery,
|
package/src/latest-posts/edit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { get, includes,
|
|
4
|
+
import { get, includes, pickBy } from 'lodash';
|
|
5
5
|
import classnames from 'classnames';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -432,11 +432,7 @@ export default function LatestPostsEdit( { attributes, setAttributes } ) {
|
|
|
432
432
|
</BlockControls>
|
|
433
433
|
<ul { ...blockProps }>
|
|
434
434
|
{ displayPosts.map( ( post, i ) => {
|
|
435
|
-
const titleTrimmed =
|
|
436
|
-
'title',
|
|
437
|
-
'rendered',
|
|
438
|
-
'trim',
|
|
439
|
-
] );
|
|
435
|
+
const titleTrimmed = post.title.rendered.trim();
|
|
440
436
|
let excerpt = post.excerpt.rendered;
|
|
441
437
|
const currentAuthor = authorList?.find(
|
|
442
438
|
( author ) => author.id === post.author
|
package/src/list/transforms.js
CHANGED
|
@@ -65,19 +65,6 @@ const transforms = {
|
|
|
65
65
|
} );
|
|
66
66
|
},
|
|
67
67
|
},
|
|
68
|
-
{
|
|
69
|
-
type: 'block',
|
|
70
|
-
blocks: [ 'core/quote', 'core/pullquote' ],
|
|
71
|
-
transform: ( { value, anchor } ) => {
|
|
72
|
-
return createBlock( 'core/list', {
|
|
73
|
-
values: toHTMLString( {
|
|
74
|
-
value: create( { html: value, multilineTag: 'p' } ),
|
|
75
|
-
multilineTag: 'li',
|
|
76
|
-
} ),
|
|
77
|
-
anchor,
|
|
78
|
-
} );
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
68
|
{
|
|
82
69
|
type: 'raw',
|
|
83
70
|
selector: 'ol,ul',
|
|
@@ -174,40 +161,6 @@ const transforms = {
|
|
|
174
161
|
} )
|
|
175
162
|
),
|
|
176
163
|
},
|
|
177
|
-
{
|
|
178
|
-
type: 'block',
|
|
179
|
-
blocks: [ 'core/quote' ],
|
|
180
|
-
transform: ( { values, anchor } ) => {
|
|
181
|
-
return createBlock( 'core/quote', {
|
|
182
|
-
value: toHTMLString( {
|
|
183
|
-
value: create( {
|
|
184
|
-
html: values,
|
|
185
|
-
multilineTag: 'li',
|
|
186
|
-
multilineWrapperTags: [ 'ul', 'ol' ],
|
|
187
|
-
} ),
|
|
188
|
-
multilineTag: 'p',
|
|
189
|
-
} ),
|
|
190
|
-
anchor,
|
|
191
|
-
} );
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
type: 'block',
|
|
196
|
-
blocks: [ 'core/pullquote' ],
|
|
197
|
-
transform: ( { values, anchor } ) => {
|
|
198
|
-
return createBlock( 'core/pullquote', {
|
|
199
|
-
value: toHTMLString( {
|
|
200
|
-
value: create( {
|
|
201
|
-
html: values,
|
|
202
|
-
multilineTag: 'li',
|
|
203
|
-
multilineWrapperTags: [ 'ul', 'ol' ],
|
|
204
|
-
} ),
|
|
205
|
-
multilineTag: 'p',
|
|
206
|
-
} ),
|
|
207
|
-
anchor,
|
|
208
|
-
} );
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
164
|
{
|
|
212
165
|
type: 'block',
|
|
213
166
|
blocks: [ 'core/table-of-contents' ],
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
/**
|
|
5
|
+
* External dependencies
|
|
6
|
+
*/
|
|
7
|
+
import { flatMap } from 'lodash';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* WordPress dependencies
|
|
11
|
+
*/
|
|
12
|
+
import { createBlock } from '@wordpress/blocks';
|
|
13
|
+
import { create, split, toHTMLString } from '@wordpress/rich-text';
|
|
11
14
|
|
|
12
15
|
/**
|
|
13
16
|
* Internal dependencies
|
|
@@ -35,6 +38,15 @@ function getListContentSchema( { phrasingContentSchema } ) {
|
|
|
35
38
|
return listContentSchema;
|
|
36
39
|
}
|
|
37
40
|
|
|
41
|
+
function getListContentFlat( blocks ) {
|
|
42
|
+
return flatMap( blocks, ( { name, attributes, innerBlocks = [] } ) => {
|
|
43
|
+
if ( name === 'core/list-item' ) {
|
|
44
|
+
return [ attributes.content, ...getListContentFlat( innerBlocks ) ];
|
|
45
|
+
}
|
|
46
|
+
return getListContentFlat( innerBlocks );
|
|
47
|
+
} );
|
|
48
|
+
}
|
|
49
|
+
|
|
38
50
|
const transforms = {
|
|
39
51
|
from: [
|
|
40
52
|
{
|
|
@@ -66,26 +78,6 @@ const transforms = {
|
|
|
66
78
|
);
|
|
67
79
|
},
|
|
68
80
|
},
|
|
69
|
-
{
|
|
70
|
-
type: 'block',
|
|
71
|
-
blocks: [ 'core/quote', 'core/pullquote' ],
|
|
72
|
-
transform: ( { value, anchor } ) => {
|
|
73
|
-
return createBlock(
|
|
74
|
-
'core/list',
|
|
75
|
-
{
|
|
76
|
-
anchor,
|
|
77
|
-
},
|
|
78
|
-
split(
|
|
79
|
-
create( { html: value, multilineTag: 'p' } ),
|
|
80
|
-
__UNSTABLE_LINE_SEPARATOR
|
|
81
|
-
).map( ( result ) => {
|
|
82
|
-
return createBlock( 'core/list-item', {
|
|
83
|
-
content: toHTMLString( { value: result } ),
|
|
84
|
-
} );
|
|
85
|
-
} )
|
|
86
|
-
);
|
|
87
|
-
},
|
|
88
|
-
},
|
|
89
81
|
...[ '*', '-' ].map( ( prefix ) => ( {
|
|
90
82
|
type: 'prefix',
|
|
91
83
|
prefix,
|
|
@@ -123,25 +115,10 @@ const transforms = {
|
|
|
123
115
|
type: 'block',
|
|
124
116
|
blocks: [ block ],
|
|
125
117
|
transform: ( _attributes, childBlocks ) => {
|
|
126
|
-
return childBlocks
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
content: attributes.content,
|
|
131
|
-
} )
|
|
132
|
-
);
|
|
133
|
-
},
|
|
134
|
-
} ) ),
|
|
135
|
-
...[ 'core/quote', 'core/pullquote' ].map( ( block ) => ( {
|
|
136
|
-
type: 'block',
|
|
137
|
-
blocks: [ block ],
|
|
138
|
-
transform: ( attributes, innerBlocks ) => {
|
|
139
|
-
return switchToBlockType(
|
|
140
|
-
switchToBlockType(
|
|
141
|
-
createBlock( 'core/list', attributes, innerBlocks ),
|
|
142
|
-
'core/paragraph'
|
|
143
|
-
),
|
|
144
|
-
block
|
|
118
|
+
return getListContentFlat( childBlocks ).map( ( content ) =>
|
|
119
|
+
createBlock( block, {
|
|
120
|
+
content,
|
|
121
|
+
} )
|
|
145
122
|
);
|
|
146
123
|
},
|
|
147
124
|
} ) ),
|
package/src/list-item/edit.js
CHANGED
|
@@ -22,12 +22,13 @@ import { useMergeRefs } from '@wordpress/compose';
|
|
|
22
22
|
*/
|
|
23
23
|
import {
|
|
24
24
|
useEnter,
|
|
25
|
-
useBackspace,
|
|
26
25
|
useSpace,
|
|
27
26
|
useIndentListItem,
|
|
28
27
|
useOutdentListItem,
|
|
29
28
|
useSplit,
|
|
29
|
+
useMerge,
|
|
30
30
|
} from './hooks';
|
|
31
|
+
import { convertToListItems } from './utils';
|
|
31
32
|
|
|
32
33
|
function IndentUI( { clientId } ) {
|
|
33
34
|
const [ canIndent, indentListItem ] = useIndentListItem( clientId );
|
|
@@ -40,14 +41,14 @@ function IndentUI( { clientId } ) {
|
|
|
40
41
|
title={ __( 'Outdent' ) }
|
|
41
42
|
describedBy={ __( 'Outdent list item' ) }
|
|
42
43
|
disabled={ ! canOutdent }
|
|
43
|
-
onClick={ outdentListItem }
|
|
44
|
+
onClick={ () => outdentListItem() }
|
|
44
45
|
/>
|
|
45
46
|
<ToolbarButton
|
|
46
47
|
icon={ isRTL() ? formatIndentRTL : formatIndent }
|
|
47
48
|
title={ __( 'Indent' ) }
|
|
48
49
|
describedBy={ __( 'Indent list item' ) }
|
|
49
50
|
isDisabled={ ! canIndent }
|
|
50
|
-
onClick={ indentListItem }
|
|
51
|
+
onClick={ () => indentListItem() }
|
|
51
52
|
/>
|
|
52
53
|
</>
|
|
53
54
|
);
|
|
@@ -56,7 +57,6 @@ function IndentUI( { clientId } ) {
|
|
|
56
57
|
export default function ListItemEdit( {
|
|
57
58
|
attributes,
|
|
58
59
|
setAttributes,
|
|
59
|
-
mergeBlocks,
|
|
60
60
|
onReplace,
|
|
61
61
|
clientId,
|
|
62
62
|
} ) {
|
|
@@ -66,18 +66,14 @@ export default function ListItemEdit( {
|
|
|
66
66
|
allowedBlocks: [ 'core/list' ],
|
|
67
67
|
} );
|
|
68
68
|
const useEnterRef = useEnter( { content, clientId } );
|
|
69
|
-
const useBackspaceRef = useBackspace( { clientId } );
|
|
70
69
|
const useSpaceRef = useSpace( clientId );
|
|
71
70
|
const onSplit = useSplit( clientId );
|
|
71
|
+
const onMerge = useMerge( clientId );
|
|
72
72
|
return (
|
|
73
73
|
<>
|
|
74
74
|
<li { ...innerBlocksProps }>
|
|
75
75
|
<RichText
|
|
76
|
-
ref={ useMergeRefs( [
|
|
77
|
-
useEnterRef,
|
|
78
|
-
useBackspaceRef,
|
|
79
|
-
useSpaceRef,
|
|
80
|
-
] ) }
|
|
76
|
+
ref={ useMergeRefs( [ useEnterRef, useSpaceRef ] ) }
|
|
81
77
|
identifier="content"
|
|
82
78
|
tagName="div"
|
|
83
79
|
onChange={ ( nextContent ) =>
|
|
@@ -87,8 +83,10 @@ export default function ListItemEdit( {
|
|
|
87
83
|
aria-label={ __( 'List text' ) }
|
|
88
84
|
placeholder={ placeholder || __( 'List' ) }
|
|
89
85
|
onSplit={ onSplit }
|
|
90
|
-
onMerge={
|
|
91
|
-
onReplace={
|
|
86
|
+
onMerge={ onMerge }
|
|
87
|
+
onReplace={ ( blocks, ...args ) => {
|
|
88
|
+
onReplace( convertToListItems( blocks ), ...args );
|
|
89
|
+
} }
|
|
92
90
|
/>
|
|
93
91
|
{ innerBlocksProps.children }
|
|
94
92
|
</li>
|
|
@@ -1,6 +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
4
|
export { default as useSpace } from './use-space';
|
|
6
5
|
export { default as useSplit } from './use-split';
|
|
6
|
+
export { default as useMerge } from './use-merge';
|
|
@@ -18,7 +18,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
|
18
18
|
import useOutdentListItem from './use-outdent-list-item';
|
|
19
19
|
|
|
20
20
|
export default function useEnter( props ) {
|
|
21
|
-
const { replaceBlocks } = useDispatch( blockEditorStore );
|
|
21
|
+
const { replaceBlocks, selectionChange } = useDispatch( blockEditorStore );
|
|
22
22
|
const { getBlock, getBlockRootClientId, getBlockIndex } =
|
|
23
23
|
useSelect( blockEditorStore );
|
|
24
24
|
const propsRef = useRef( props );
|
|
@@ -42,8 +42,9 @@ export default function useEnter( props ) {
|
|
|
42
42
|
return;
|
|
43
43
|
}
|
|
44
44
|
// Here we are in top level list so we need to split.
|
|
45
|
-
const
|
|
46
|
-
|
|
45
|
+
const topParentListBlock = getBlock(
|
|
46
|
+
getBlockRootClientId( clientId )
|
|
47
|
+
);
|
|
47
48
|
const blockIndex = getBlockIndex( clientId );
|
|
48
49
|
const head = cloneBlock( {
|
|
49
50
|
...topParentListBlock,
|
|
@@ -69,11 +70,13 @@ export default function useEnter( props ) {
|
|
|
69
70
|
]
|
|
70
71
|
: [];
|
|
71
72
|
replaceBlocks(
|
|
72
|
-
|
|
73
|
+
topParentListBlock.clientId,
|
|
73
74
|
[ head, middle, ...tail ],
|
|
74
|
-
1
|
|
75
|
-
0
|
|
75
|
+
1
|
|
76
76
|
);
|
|
77
|
+
// We manually change the selection here because we are replacing
|
|
78
|
+
// a different block than the selected one.
|
|
79
|
+
selectionChange( middle.clientId );
|
|
77
80
|
}
|
|
78
81
|
|
|
79
82
|
element.addEventListener( 'keydown', onKeyDown );
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRegistry, useDispatch, useSelect } from '@wordpress/data';
|
|
5
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
6
|
+
import { getDefaultBlockName, switchToBlockType } from '@wordpress/blocks';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
import useOutdentListItem from './use-outdent-list-item';
|
|
12
|
+
|
|
13
|
+
import { name as listItemName } from '../block.json';
|
|
14
|
+
|
|
15
|
+
export default function useMerge( clientId ) {
|
|
16
|
+
const registry = useRegistry();
|
|
17
|
+
const {
|
|
18
|
+
getPreviousBlockClientId,
|
|
19
|
+
getNextBlockClientId,
|
|
20
|
+
getBlockOrder,
|
|
21
|
+
getBlockRootClientId,
|
|
22
|
+
getBlockName,
|
|
23
|
+
getBlock,
|
|
24
|
+
} = useSelect( blockEditorStore );
|
|
25
|
+
const { mergeBlocks, moveBlocksToPosition, replaceBlock, selectBlock } =
|
|
26
|
+
useDispatch( blockEditorStore );
|
|
27
|
+
const [ , outdentListItem ] = useOutdentListItem( clientId );
|
|
28
|
+
|
|
29
|
+
function getTrailingId( id ) {
|
|
30
|
+
const order = getBlockOrder( id );
|
|
31
|
+
|
|
32
|
+
if ( ! order.length ) {
|
|
33
|
+
return id;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return getTrailingId( order[ order.length - 1 ] );
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getParentListItemId( id ) {
|
|
40
|
+
const listId = getBlockRootClientId( id );
|
|
41
|
+
const parentListItemId = getBlockRootClientId( listId );
|
|
42
|
+
if ( ! parentListItemId ) return;
|
|
43
|
+
if ( getBlockName( parentListItemId ) !== listItemName ) return;
|
|
44
|
+
return parentListItemId;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Return the next list item with respect to the given list item. If none,
|
|
49
|
+
* return the next list item of the parent list item if it exists.
|
|
50
|
+
*
|
|
51
|
+
* @param {string} id A list item client ID.
|
|
52
|
+
* @return {string?} The client ID of the next list item.
|
|
53
|
+
*/
|
|
54
|
+
function _getNextId( id ) {
|
|
55
|
+
const next = getNextBlockClientId( id );
|
|
56
|
+
if ( next ) return next;
|
|
57
|
+
const parentListItemId = getParentListItemId( id );
|
|
58
|
+
if ( ! parentListItemId ) return;
|
|
59
|
+
return _getNextId( parentListItemId );
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Given a client ID, return the client ID of the list item on the next
|
|
64
|
+
* line, regardless of indentation level.
|
|
65
|
+
*
|
|
66
|
+
* @param {string} id The client ID of the current list item.
|
|
67
|
+
* @return {string?} The client ID of the next list item.
|
|
68
|
+
*/
|
|
69
|
+
function getNextId( id ) {
|
|
70
|
+
const order = getBlockOrder( id );
|
|
71
|
+
|
|
72
|
+
// If the list item does not have a nested list, return the next list
|
|
73
|
+
// item.
|
|
74
|
+
if ( ! order.length ) {
|
|
75
|
+
return _getNextId( id );
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
// Get the first list item in the nested list.
|
|
79
|
+
return getBlockOrder( order[ 0 ] )[ 0 ];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function switchToDefaultBlockType( forward ) {
|
|
83
|
+
const rootClientId = getBlockRootClientId( clientId );
|
|
84
|
+
const replacement = switchToBlockType(
|
|
85
|
+
getBlock( rootClientId ),
|
|
86
|
+
getDefaultBlockName()
|
|
87
|
+
);
|
|
88
|
+
const indexToSelect = forward ? replacement.length - 1 : 0;
|
|
89
|
+
const initialPosition = forward ? -1 : 0;
|
|
90
|
+
registry.batch( () => {
|
|
91
|
+
replaceBlock( rootClientId, replacement );
|
|
92
|
+
selectBlock(
|
|
93
|
+
replacement[ indexToSelect ].clientId,
|
|
94
|
+
initialPosition
|
|
95
|
+
);
|
|
96
|
+
} );
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return ( forward ) => {
|
|
100
|
+
if ( forward ) {
|
|
101
|
+
const nextBlockClientId = getNextId( clientId );
|
|
102
|
+
|
|
103
|
+
if ( ! nextBlockClientId ) {
|
|
104
|
+
switchToDefaultBlockType( forward );
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
if ( getParentListItemId( nextBlockClientId ) ) {
|
|
109
|
+
outdentListItem( nextBlockClientId );
|
|
110
|
+
} else {
|
|
111
|
+
registry.batch( () => {
|
|
112
|
+
moveBlocksToPosition(
|
|
113
|
+
getBlockOrder( nextBlockClientId ),
|
|
114
|
+
nextBlockClientId,
|
|
115
|
+
getPreviousBlockClientId( nextBlockClientId )
|
|
116
|
+
);
|
|
117
|
+
mergeBlocks( clientId, nextBlockClientId );
|
|
118
|
+
} );
|
|
119
|
+
}
|
|
120
|
+
} else {
|
|
121
|
+
// Merging is only done from the top level. For lowel levels, the
|
|
122
|
+
// list item is outdented instead.
|
|
123
|
+
const previousBlockClientId = getPreviousBlockClientId( clientId );
|
|
124
|
+
if ( getParentListItemId( clientId ) ) {
|
|
125
|
+
outdentListItem( clientId );
|
|
126
|
+
} else if ( previousBlockClientId ) {
|
|
127
|
+
const trailingId = getTrailingId( previousBlockClientId );
|
|
128
|
+
registry.batch( () => {
|
|
129
|
+
moveBlocksToPosition(
|
|
130
|
+
getBlockOrder( clientId ),
|
|
131
|
+
clientId,
|
|
132
|
+
previousBlockClientId
|
|
133
|
+
);
|
|
134
|
+
mergeBlocks( trailingId, clientId );
|
|
135
|
+
} );
|
|
136
|
+
} else {
|
|
137
|
+
switchToDefaultBlockType( forward );
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
}
|