@wordpress/block-library 7.4.0 → 7.7.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 +10 -0
- package/README.md +3 -2
- package/babel-plugin.js +154 -0
- package/build/audio/edit.js +4 -16
- package/build/audio/edit.js.map +1 -1
- package/build/block/edit.js +10 -9
- package/build/block/edit.js.map +1 -1
- package/build/button/deprecated.js +175 -35
- package/build/button/deprecated.js.map +1 -1
- package/build/button/edit.js +1 -1
- package/build/button/edit.js.map +1 -1
- package/build/button/edit.native.js +7 -3
- package/build/button/edit.native.js.map +1 -1
- package/build/button/index.js +1 -0
- 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/categories/edit.js +1 -1
- package/build/categories/edit.js.map +1 -1
- package/build/categories/index.js +1 -1
- package/build/columns/index.js +3 -1
- package/build/columns/index.js.map +1 -1
- package/build/comment-author-avatar/index.js +1 -0
- package/build/comment-author-avatar/index.js.map +1 -1
- package/build/comment-template/edit.js +1 -3
- package/build/comment-template/edit.js.map +1 -1
- package/build/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
- package/{build-module/comments-query-loop → build/comments}/edit/comments-inspector-controls.js.map +1 -1
- package/build/{comments-query-loop → comments}/edit.js +3 -3
- package/build/comments/edit.js.map +1 -0
- package/build/{comments-query-loop → comments}/index.js +1 -1
- package/build/comments/index.js.map +1 -0
- package/build/{comments-query-loop → comments}/save.js +2 -2
- package/build/comments/save.js.map +1 -0
- package/build/comments-title/deprecated.js +110 -0
- package/build/comments-title/deprecated.js.map +1 -0
- package/build/comments-title/edit.js +35 -35
- package/build/comments-title/edit.js.map +1 -1
- package/build/comments-title/index.js +5 -8
- package/build/comments-title/index.js.map +1 -1
- package/build/cover/controls.native.js +2 -3
- package/build/cover/controls.native.js.map +1 -1
- package/build/cover/deprecated.js +212 -207
- package/build/cover/deprecated.js.map +1 -1
- package/build/cover/edit/block-controls.js +115 -0
- package/build/cover/edit/block-controls.js.map +1 -0
- package/build/cover/edit/cover-placeholder.js +49 -0
- package/build/cover/edit/cover-placeholder.js.map +1 -0
- package/build/cover/edit/index.js +343 -0
- package/build/cover/edit/index.js.map +1 -0
- package/build/cover/edit/inspector-controls.js +224 -0
- package/build/cover/edit/inspector-controls.js.map +1 -0
- package/build/cover/edit/resizable-cover.js +67 -0
- package/build/cover/edit/resizable-cover.js.map +1 -0
- package/build/cover/edit/use-cover-is-dark.js +81 -0
- package/build/cover/edit/use-cover-is-dark.js.map +1 -0
- package/build/cover/edit.native.js +36 -16
- package/build/cover/edit.native.js.map +1 -1
- package/build/cover/focal-point-settings-button.native.js.map +1 -1
- package/build/cover/save.js +18 -5
- package/build/cover/save.js.map +1 -1
- package/build/cover/shared.js +15 -9
- package/build/cover/shared.js.map +1 -1
- package/build/cover/transforms.js +77 -6
- package/build/cover/transforms.js.map +1 -1
- package/build/cover/use-cover-is-dark.native.js +60 -0
- package/build/cover/use-cover-is-dark.native.js.map +1 -0
- package/build/embed/embed-preview.js +1 -1
- package/build/embed/embed-preview.js.map +1 -1
- package/build/file/edit.js +1 -1
- package/build/file/edit.js.map +1 -1
- package/build/file/edit.native.js +0 -1
- package/build/file/edit.native.js.map +1 -1
- package/build/file/save.js +9 -1
- package/build/file/save.js.map +1 -1
- package/build/gallery/edit.js +2 -1
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.js +1 -1
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/gap-styles.js +14 -4
- package/build/gallery/gap-styles.js.map +1 -1
- package/build/gallery/index.js +1 -1
- package/build/gallery/shared.js +2 -2
- package/build/gallery/shared.js.map +1 -1
- package/build/gallery/use-get-media.js +2 -1
- package/build/gallery/use-get-media.js.map +1 -1
- package/build/gallery/use-short-code-transform.js +19 -18
- package/build/gallery/use-short-code-transform.js.map +1 -1
- package/build/gallery/v1/gallery.js +1 -1
- package/build/gallery/v1/gallery.js.map +1 -1
- package/build/group/index.js +1 -0
- package/build/group/index.js.map +1 -1
- package/build/heading/edit.js +6 -2
- package/build/heading/edit.js.map +1 -1
- package/build/heading/index.js +1 -0
- package/build/heading/index.js.map +1 -1
- package/build/heading/transforms.js +9 -4
- package/build/heading/transforms.js.map +1 -1
- package/build/image/edit.js +5 -56
- package/build/image/edit.js.map +1 -1
- package/build/image/edit.native.js +56 -4
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +4 -14
- package/build/image/image.js.map +1 -1
- package/build/index.js +48 -14
- package/build/index.js.map +1 -1
- package/build/is-block-metadata-experimental.js +18 -0
- package/build/is-block-metadata-experimental.js.map +1 -0
- package/build/latest-posts/edit.js +30 -4
- package/build/latest-posts/edit.js.map +1 -1
- package/build/latest-posts/edit.native.js +49 -0
- package/build/latest-posts/edit.native.js.map +1 -1
- package/build/list/transforms.js +6 -0
- package/build/list/transforms.js.map +1 -1
- package/build/list/v2/edit.js +2 -1
- package/build/list/v2/edit.js.map +1 -1
- package/build/list/v2/migrate.js +1 -0
- package/build/list/v2/migrate.js.map +1 -1
- package/build/list/v2/transforms.js +46 -9
- package/build/list/v2/transforms.js.map +1 -1
- package/build/list-item/edit.js +7 -9
- package/build/list-item/edit.js.map +1 -1
- package/build/list-item/hooks/index.js +24 -0
- package/build/list-item/hooks/index.js.map +1 -1
- package/build/list-item/hooks/use-backspace.js +59 -0
- package/build/list-item/hooks/use-backspace.js.map +1 -0
- package/build/list-item/hooks/use-enter.js +6 -9
- package/build/list-item/hooks/use-enter.js.map +1 -1
- package/build/list-item/hooks/use-indent-list-item.js +33 -39
- package/build/list-item/hooks/use-indent-list-item.js.map +1 -1
- package/build/list-item/hooks/use-space.js +54 -0
- package/build/list-item/hooks/use-space.js.map +1 -0
- package/build/list-item/hooks/use-split.js +44 -0
- package/build/list-item/hooks/use-split.js.map +1 -0
- package/build/list-item/index.js +1 -0
- package/build/list-item/index.js.map +1 -1
- package/build/list-item/utils.js +1 -1
- package/build/list-item/utils.js.map +1 -1
- package/build/media-text/edit.native.js +2 -1
- package/build/media-text/edit.native.js.map +1 -1
- package/build/media-text/media-container.native.js +2 -4
- package/build/media-text/media-container.native.js.map +1 -1
- package/build/media-text/transforms.js +137 -8
- package/build/media-text/transforms.js.map +1 -1
- package/build/navigation/edit/index.js +91 -109
- package/build/navigation/edit/index.js.map +1 -1
- package/build/navigation/edit/inner-blocks.js +6 -12
- package/build/navigation/edit/inner-blocks.js.map +1 -1
- package/build/navigation/index.js +0 -1
- package/build/navigation/index.js.map +1 -1
- package/build/navigation/use-navigation-entities.js +3 -3
- package/build/navigation/use-navigation-entities.js.map +1 -1
- package/build/navigation/view-modal.js +25 -0
- package/build/navigation/view-modal.js.map +1 -1
- package/build/navigation-link/edit.js +60 -35
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-link/fallback-variations.js +1 -1
- package/build/navigation-link/fallback-variations.js.map +1 -1
- package/build/navigation-link/hooks.js +1 -1
- package/build/navigation-link/hooks.js.map +1 -1
- package/build/navigation-submenu/edit.js +14 -14
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +1 -1
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/page-list/edit.js +1 -1
- package/build/page-list/edit.js.map +1 -1
- package/build/paragraph/edit.js +10 -0
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/use-enter.js +94 -0
- package/build/paragraph/use-enter.js.map +1 -0
- package/build/post-author/edit.js +1 -1
- package/build/post-author/edit.js.map +1 -1
- package/build/post-author-name/index.js +4 -0
- package/build/post-author-name/index.js.map +1 -1
- package/build/post-author-name/transforms.js +41 -0
- package/build/post-author-name/transforms.js.map +1 -0
- package/build/post-comment/index.js +2 -1
- package/build/post-comment/index.js.map +1 -1
- package/build/post-comments/edit.js +138 -35
- package/build/post-comments/edit.js.map +1 -1
- package/build/post-comments/index.js +3 -2
- package/build/post-comments/index.js.map +1 -1
- package/build/post-comments-count/index.js +1 -0
- package/build/post-comments-count/index.js.map +1 -1
- package/build/post-comments-form/edit.js +38 -4
- package/build/post-comments-form/edit.js.map +1 -1
- package/build/post-comments-form/form.js +58 -0
- package/build/post-comments-form/form.js.map +1 -0
- package/build/post-comments-form/index.js +1 -0
- package/build/post-comments-form/index.js.map +1 -1
- package/build/post-comments-link/index.js +1 -0
- package/build/post-comments-link/index.js.map +1 -1
- package/build/post-content/edit.js +1 -1
- package/build/post-content/edit.js.map +1 -1
- package/build/post-date/edit.js +13 -7
- package/build/post-date/edit.js.map +1 -1
- package/build/post-excerpt/edit.js +1 -1
- package/build/post-excerpt/edit.js.map +1 -1
- package/build/post-featured-image/edit.js +1 -1
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-template/edit.js +7 -2
- package/build/post-template/edit.js.map +1 -1
- package/build/post-terms/edit.js +35 -4
- package/build/post-terms/edit.js.map +1 -1
- package/build/post-terms/hooks.js +33 -0
- package/build/post-terms/hooks.js.map +1 -0
- package/build/post-terms/index.js +20 -5
- package/build/post-terms/index.js.map +1 -1
- package/build/post-title/index.js +1 -1
- package/build/post-title/index.js.map +1 -1
- package/build/pullquote/edit.js +1 -1
- package/build/pullquote/edit.js.map +1 -1
- package/build/pullquote/edit.native.js +1 -1
- package/build/pullquote/edit.native.js.map +1 -1
- package/build/query/edit/inspector-controls/index.js +26 -17
- package/build/query/edit/inspector-controls/index.js.map +1 -1
- package/build/query/edit/inspector-controls/parent-control.js +148 -0
- package/build/query/edit/inspector-controls/parent-control.js.map +1 -0
- package/build/query/edit/inspector-controls/sticky-control.js +41 -0
- package/build/query/edit/inspector-controls/sticky-control.js.map +1 -0
- package/build/query/index.js +2 -1
- package/build/query/index.js.map +1 -1
- package/build/query/utils.js +28 -2
- package/build/query/utils.js.map +1 -1
- package/build/query-no-results/edit.js +1 -1
- package/build/query-no-results/edit.js.map +1 -1
- package/build/query-title/index.js +1 -1
- package/build/query-title/index.js.map +1 -1
- package/build/query-title/variations.js +1 -1
- package/build/query-title/variations.js.map +1 -1
- package/build/quote/edit.js +3 -2
- package/build/quote/edit.js.map +1 -1
- package/build/quote/index.js +1 -0
- package/build/quote/index.js.map +1 -1
- package/build/quote/v2/edit.js +1 -1
- package/build/quote/v2/edit.js.map +1 -1
- package/build/search/edit.js +2 -1
- package/build/search/edit.js.map +1 -1
- package/build/search/index.js +4 -0
- package/build/search/index.js.map +1 -1
- package/build/separator/index.js +3 -0
- package/build/separator/index.js.map +1 -1
- package/build/shortcode/edit.native.js +16 -13
- package/build/shortcode/edit.native.js.map +1 -1
- package/build/site-logo/edit.js +1 -1
- package/build/site-logo/edit.js.map +1 -1
- package/build/social-links/edit.js +2 -2
- package/build/social-links/edit.js.map +1 -1
- package/build/table/edit.js +15 -2
- package/build/table/edit.js.map +1 -1
- package/build/table-of-contents/edit.js +145 -65
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/table-of-contents/index.js +13 -3
- package/build/table-of-contents/index.js.map +1 -1
- package/build/table-of-contents/list.js +16 -9
- package/build/table-of-contents/list.js.map +1 -1
- package/build/table-of-contents/save.js +40 -0
- package/build/table-of-contents/save.js.map +1 -0
- package/build/table-of-contents/utils.js +11 -77
- package/build/table-of-contents/utils.js.map +1 -1
- package/build/template-part/edit/index.js +7 -3
- package/build/template-part/edit/index.js.map +1 -1
- package/build/template-part/edit/inner-blocks.js +3 -8
- package/build/template-part/edit/inner-blocks.js.map +1 -1
- package/build/video/edit.js +4 -8
- package/build/video/edit.js.map +1 -1
- package/build-module/audio/edit.js +5 -17
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/block/edit.js +11 -10
- package/build-module/block/edit.js.map +1 -1
- package/build-module/button/deprecated.js +175 -35
- package/build-module/button/deprecated.js.map +1 -1
- package/build-module/button/edit.js +2 -2
- package/build-module/button/edit.js.map +1 -1
- package/build-module/button/edit.native.js +7 -3
- package/build-module/button/edit.native.js.map +1 -1
- package/build-module/button/index.js +1 -0
- 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/categories/edit.js +1 -1
- package/build-module/categories/edit.js.map +1 -1
- package/build-module/categories/index.js +1 -1
- package/build-module/columns/index.js +3 -1
- package/build-module/columns/index.js.map +1 -1
- package/build-module/comment-author-avatar/index.js +1 -0
- package/build-module/comment-author-avatar/index.js.map +1 -1
- package/build-module/comment-template/edit.js +1 -3
- package/build-module/comment-template/edit.js.map +1 -1
- package/build-module/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
- package/build-module/comments/edit/comments-inspector-controls.js.map +1 -0
- package/build-module/{comments-query-loop → comments}/edit.js +2 -2
- package/build-module/comments/edit.js.map +1 -0
- package/build-module/{comments-query-loop → comments}/index.js +1 -1
- package/build-module/comments/index.js.map +1 -0
- package/build-module/{comments-query-loop → comments}/save.js +1 -1
- package/build-module/comments/save.js.map +1 -0
- package/build-module/comments-title/deprecated.js +102 -0
- package/build-module/comments-title/deprecated.js.map +1 -0
- package/build-module/comments-title/edit.js +38 -38
- package/build-module/comments-title/edit.js.map +1 -1
- package/build-module/comments-title/index.js +4 -8
- package/build-module/comments-title/index.js.map +1 -1
- package/build-module/cover/controls.native.js +2 -3
- package/build-module/cover/controls.native.js.map +1 -1
- package/build-module/cover/deprecated.js +206 -198
- package/build-module/cover/deprecated.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +104 -0
- package/build-module/cover/edit/block-controls.js.map +1 -0
- package/build-module/cover/edit/cover-placeholder.js +38 -0
- package/build-module/cover/edit/cover-placeholder.js.map +1 -0
- package/build-module/cover/edit/index.js +317 -0
- package/build-module/cover/edit/index.js.map +1 -0
- package/build-module/cover/edit/inspector-controls.js +215 -0
- package/build-module/cover/edit/inspector-controls.js.map +1 -0
- package/build-module/cover/edit/resizable-cover.js +55 -0
- package/build-module/cover/edit/resizable-cover.js.map +1 -0
- package/build-module/cover/edit/use-cover-is-dark.js +70 -0
- package/build-module/cover/edit/use-cover-is-dark.js.map +1 -0
- package/build-module/cover/edit.native.js +35 -17
- package/build-module/cover/edit.native.js.map +1 -1
- package/build-module/cover/focal-point-settings-button.native.js.map +1 -1
- package/build-module/cover/save.js +19 -6
- package/build-module/cover/save.js.map +1 -1
- package/build-module/cover/shared.js +11 -5
- package/build-module/cover/shared.js.map +1 -1
- package/build-module/cover/transforms.js +74 -6
- package/build-module/cover/transforms.js.map +1 -1
- package/build-module/cover/use-cover-is-dark.native.js +51 -0
- package/build-module/cover/use-cover-is-dark.native.js.map +1 -0
- package/build-module/embed/embed-preview.js +2 -2
- package/build-module/embed/embed-preview.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/edit.native.js +0 -1
- package/build-module/file/edit.native.js.map +1 -1
- package/build-module/file/save.js +7 -2
- package/build-module/file/save.js.map +1 -1
- package/build-module/gallery/edit.js +2 -1
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.js +2 -2
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/gap-styles.js +14 -4
- package/build-module/gallery/gap-styles.js.map +1 -1
- package/build-module/gallery/index.js +1 -1
- package/build-module/gallery/shared.js +2 -2
- package/build-module/gallery/shared.js.map +1 -1
- package/build-module/gallery/use-get-media.js +2 -1
- package/build-module/gallery/use-get-media.js.map +1 -1
- package/build-module/gallery/use-short-code-transform.js +19 -18
- package/build-module/gallery/use-short-code-transform.js.map +1 -1
- package/build-module/gallery/v1/gallery.js +2 -2
- package/build-module/gallery/v1/gallery.js.map +1 -1
- package/build-module/group/index.js +1 -0
- package/build-module/group/index.js.map +1 -1
- package/build-module/heading/edit.js +6 -2
- package/build-module/heading/edit.js.map +1 -1
- package/build-module/heading/index.js +1 -0
- package/build-module/heading/index.js.map +1 -1
- package/build-module/heading/transforms.js +9 -4
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/image/edit.js +4 -52
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/edit.native.js +57 -6
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +6 -16
- package/build-module/image/image.js.map +1 -1
- package/build-module/index.js +43 -12
- package/build-module/index.js.map +1 -1
- package/build-module/is-block-metadata-experimental.js +16 -0
- package/build-module/is-block-metadata-experimental.js.map +1 -0
- package/build-module/latest-posts/edit.js +29 -5
- package/build-module/latest-posts/edit.js.map +1 -1
- package/build-module/latest-posts/edit.native.js +51 -2
- package/build-module/latest-posts/edit.native.js.map +1 -1
- package/build-module/list/transforms.js +6 -0
- package/build-module/list/transforms.js.map +1 -1
- package/build-module/list/v2/edit.js +2 -1
- package/build-module/list/v2/edit.js.map +1 -1
- package/build-module/list/v2/migrate.js +1 -3
- package/build-module/list/v2/migrate.js.map +1 -1
- package/build-module/list/v2/transforms.js +46 -9
- package/build-module/list/v2/transforms.js.map +1 -1
- package/build-module/list-item/edit.js +8 -9
- package/build-module/list-item/edit.js.map +1 -1
- package/build-module/list-item/hooks/index.js +3 -0
- package/build-module/list-item/hooks/index.js.map +1 -1
- package/build-module/list-item/hooks/use-backspace.js +44 -0
- package/build-module/list-item/hooks/use-backspace.js.map +1 -0
- package/build-module/list-item/hooks/use-enter.js +6 -9
- package/build-module/list-item/hooks/use-enter.js.map +1 -1
- package/build-module/list-item/hooks/use-indent-list-item.js +33 -38
- package/build-module/list-item/hooks/use-indent-list-item.js.map +1 -1
- package/build-module/list-item/hooks/use-space.js +40 -0
- package/build-module/list-item/hooks/use-space.js.map +1 -0
- package/build-module/list-item/hooks/use-split.js +33 -0
- package/build-module/list-item/hooks/use-split.js.map +1 -0
- package/build-module/list-item/index.js +1 -0
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/list-item/utils.js +1 -1
- package/build-module/list-item/utils.js.map +1 -1
- package/build-module/media-text/edit.native.js +2 -1
- package/build-module/media-text/edit.native.js.map +1 -1
- package/build-module/media-text/media-container.native.js +2 -4
- package/build-module/media-text/media-container.native.js.map +1 -1
- package/build-module/media-text/transforms.js +137 -8
- package/build-module/media-text/transforms.js.map +1 -1
- package/build-module/navigation/edit/index.js +93 -110
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/navigation/edit/inner-blocks.js +7 -13
- package/build-module/navigation/edit/inner-blocks.js.map +1 -1
- package/build-module/navigation/index.js +0 -1
- package/build-module/navigation/index.js.map +1 -1
- package/build-module/navigation/use-navigation-entities.js +1 -1
- package/build-module/navigation/use-navigation-entities.js.map +1 -1
- package/build-module/navigation/view-modal.js +24 -0
- package/build-module/navigation/view-modal.js.map +1 -1
- package/build-module/navigation-link/edit.js +60 -36
- package/build-module/navigation-link/edit.js.map +1 -1
- package/build-module/navigation-link/fallback-variations.js +1 -1
- package/build-module/navigation-link/fallback-variations.js.map +1 -1
- package/build-module/navigation-link/hooks.js +2 -2
- package/build-module/navigation-link/hooks.js.map +1 -1
- package/build-module/navigation-submenu/edit.js +14 -14
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +1 -1
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/page-list/edit.js +1 -1
- package/build-module/page-list/edit.js.map +1 -1
- package/build-module/paragraph/edit.js +9 -0
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/use-enter.js +81 -0
- package/build-module/paragraph/use-enter.js.map +1 -0
- package/build-module/post-author/edit.js +1 -1
- package/build-module/post-author/edit.js.map +1 -1
- package/build-module/post-author-name/index.js +3 -0
- package/build-module/post-author-name/index.js.map +1 -1
- package/build-module/post-author-name/transforms.js +32 -0
- package/build-module/post-author-name/transforms.js.map +1 -0
- package/build-module/post-comment/index.js +2 -1
- package/build-module/post-comment/index.js.map +1 -1
- package/build-module/post-comments/edit.js +139 -37
- package/build-module/post-comments/edit.js.map +1 -1
- package/build-module/post-comments/index.js +3 -2
- package/build-module/post-comments/index.js.map +1 -1
- package/build-module/post-comments-count/index.js +1 -0
- package/build-module/post-comments-count/index.js.map +1 -1
- package/build-module/post-comments-form/edit.js +38 -6
- package/build-module/post-comments-form/edit.js.map +1 -1
- package/build-module/post-comments-form/form.js +45 -0
- package/build-module/post-comments-form/form.js.map +1 -0
- package/build-module/post-comments-form/index.js +1 -0
- package/build-module/post-comments-form/index.js.map +1 -1
- package/build-module/post-comments-link/index.js +1 -0
- package/build-module/post-comments-link/index.js.map +1 -1
- package/build-module/post-content/edit.js +1 -1
- package/build-module/post-content/edit.js.map +1 -1
- package/build-module/post-date/edit.js +15 -9
- package/build-module/post-date/edit.js.map +1 -1
- package/build-module/post-excerpt/edit.js +1 -1
- package/build-module/post-excerpt/edit.js.map +1 -1
- package/build-module/post-featured-image/edit.js +1 -1
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-template/edit.js +7 -2
- package/build-module/post-template/edit.js.map +1 -1
- package/build-module/post-terms/edit.js +35 -6
- package/build-module/post-terms/edit.js.map +1 -1
- package/build-module/post-terms/hooks.js +25 -0
- package/build-module/post-terms/hooks.js.map +1 -0
- package/build-module/post-terms/index.js +18 -8
- package/build-module/post-terms/index.js.map +1 -1
- package/build-module/post-title/index.js +1 -1
- package/build-module/post-title/index.js.map +1 -1
- package/build-module/pullquote/edit.js +2 -2
- package/build-module/pullquote/edit.js.map +1 -1
- package/build-module/pullquote/edit.native.js +2 -2
- package/build-module/pullquote/edit.native.js.map +1 -1
- package/build-module/query/edit/inspector-controls/index.js +24 -17
- package/build-module/query/edit/inspector-controls/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/parent-control.js +135 -0
- package/build-module/query/edit/inspector-controls/parent-control.js.map +1 -0
- package/build-module/query/edit/inspector-controls/sticky-control.js +31 -0
- package/build-module/query/edit/inspector-controls/sticky-control.js.map +1 -0
- package/build-module/query/index.js +2 -1
- package/build-module/query/index.js.map +1 -1
- package/build-module/query/utils.js +21 -0
- package/build-module/query/utils.js.map +1 -1
- package/build-module/query-no-results/edit.js +1 -1
- package/build-module/query-no-results/edit.js.map +1 -1
- package/build-module/query-title/index.js +1 -1
- package/build-module/query-title/index.js.map +1 -1
- package/build-module/query-title/variations.js +2 -2
- package/build-module/query-title/variations.js.map +1 -1
- package/build-module/quote/edit.js +4 -3
- package/build-module/quote/edit.js.map +1 -1
- package/build-module/quote/index.js +1 -0
- package/build-module/quote/index.js.map +1 -1
- package/build-module/quote/v2/edit.js +2 -2
- package/build-module/quote/v2/edit.js.map +1 -1
- package/build-module/search/edit.js +3 -2
- package/build-module/search/edit.js.map +1 -1
- package/build-module/search/index.js +4 -0
- package/build-module/search/index.js.map +1 -1
- package/build-module/separator/index.js +3 -0
- package/build-module/separator/index.js.map +1 -1
- package/build-module/shortcode/edit.native.js +17 -13
- package/build-module/shortcode/edit.native.js.map +1 -1
- package/build-module/site-logo/edit.js +1 -1
- package/build-module/site-logo/edit.js.map +1 -1
- package/build-module/social-links/edit.js +2 -2
- package/build-module/social-links/edit.js.map +1 -1
- package/build-module/table/edit.js +17 -4
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table-of-contents/edit.js +144 -68
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/table-of-contents/index.js +12 -3
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-module/table-of-contents/list.js +18 -10
- package/build-module/table-of-contents/list.js.map +1 -1
- package/build-module/table-of-contents/save.js +28 -0
- package/build-module/table-of-contents/save.js.map +1 -0
- package/build-module/table-of-contents/utils.js +11 -73
- package/build-module/table-of-contents/utils.js.map +1 -1
- package/build-module/template-part/edit/index.js +8 -4
- package/build-module/template-part/edit/index.js.map +1 -1
- package/build-module/template-part/edit/inner-blocks.js +4 -9
- package/build-module/template-part/edit/inner-blocks.js.map +1 -1
- package/build-module/video/edit.js +5 -9
- package/build-module/video/edit.js.map +1 -1
- package/build-style/comment-content/style-rtl.css +81 -0
- package/build-style/comment-content/style.css +81 -0
- package/build-style/{comments-query-loop → comments}/editor-rtl.css +0 -0
- package/build-style/{comments-query-loop → comments}/editor.css +0 -0
- package/build-style/cover/style-rtl.css +32 -27
- package/build-style/cover/style.css +32 -27
- package/build-style/editor-rtl.css +16 -10
- package/build-style/editor.css +16 -10
- package/build-style/image/editor-rtl.css +1 -1
- package/build-style/image/editor.css +1 -1
- package/build-style/latest-posts/style-rtl.css +2 -0
- package/build-style/latest-posts/style.css +4 -0
- package/build-style/navigation/style-rtl.css +3 -0
- package/build-style/navigation/style.css +3 -0
- package/build-style/post-comments/editor-rtl.css +79 -0
- package/build-style/post-comments/editor.css +79 -0
- package/build-style/post-comments/style-rtl.css +27 -3
- package/build-style/post-comments/style.css +27 -3
- package/build-style/post-comments-form/editor-rtl.css +79 -0
- package/build-style/post-comments-form/editor.css +79 -0
- package/build-style/post-comments-form/style-rtl.css +1 -3
- package/build-style/post-comments-form/style.css +1 -3
- package/build-style/separator/editor-rtl.css +1 -0
- package/build-style/separator/editor.css +1 -0
- package/build-style/site-logo/style-rtl.css +4 -0
- package/build-style/site-logo/style.css +4 -0
- package/build-style/style-rtl.css +69 -33
- package/build-style/style.css +71 -33
- package/build-style/video/editor-rtl.css +2 -5
- package/build-style/video/editor.css +2 -5
- package/build-types/table-of-contents/list.d.ts +12 -0
- package/build-types/table-of-contents/list.d.ts.map +1 -0
- package/build-types/table-of-contents/utils.d.ts +24 -0
- package/build-types/table-of-contents/utils.d.ts.map +1 -0
- package/package.json +30 -29
- package/src/audio/edit.js +6 -9
- package/src/avatar/block.json +0 -1
- package/src/avatar/index.php +2 -2
- package/src/block/edit.js +39 -42
- package/src/block/test/edit.native.js +1 -1
- package/src/button/block.json +1 -0
- package/src/button/deprecated.js +145 -0
- package/src/button/edit.js +3 -1
- package/src/button/edit.native.js +6 -3
- package/src/button/save.js +3 -1
- package/src/buttons/test/__snapshots__/edit.native.js.snap +1 -1
- package/src/buttons/test/edit.native.js +1 -1
- package/src/categories/block.json +1 -1
- package/src/categories/edit.js +1 -1
- package/src/columns/block.json +3 -1
- package/src/comment-author-avatar/block.json +1 -0
- package/src/comment-author-name/index.php +7 -5
- package/src/comment-content/index.php +25 -3
- package/src/comment-content/style.scss +5 -0
- package/src/comment-edit-link/index.php +1 -4
- package/src/comment-reply-link/index.php +1 -4
- package/src/comment-template/edit.js +1 -5
- package/src/comment-template/index.php +4 -0
- package/src/{comments-query-loop → comments}/block.json +1 -1
- package/src/{comments-query-loop → comments}/edit/comments-inspector-controls.js +0 -0
- package/src/{comments-query-loop → comments}/edit.js +2 -1
- package/src/{comments-query-loop → comments}/editor.scss +0 -0
- package/src/{comments-query-loop → comments}/index.js +0 -0
- package/src/{comments-query-loop → comments}/save.js +1 -3
- package/src/comments-pagination/index.php +4 -0
- package/src/comments-title/block.json +0 -6
- package/src/comments-title/deprecated.js +34 -0
- package/src/comments-title/edit.js +44 -84
- package/src/comments-title/index.js +3 -1
- package/src/comments-title/index.php +51 -22
- package/src/cover/controls.native.js +1 -2
- package/src/cover/deprecated.js +230 -183
- package/src/cover/edit/block-controls.js +119 -0
- package/src/cover/edit/cover-placeholder.js +39 -0
- package/src/cover/edit/index.js +393 -0
- package/src/cover/edit/inspector-controls.js +286 -0
- package/src/cover/edit/resizable-cover.js +55 -0
- package/src/cover/edit/use-cover-is-dark.js +71 -0
- package/src/cover/edit.native.js +40 -14
- package/src/cover/editor.scss +1 -1
- package/src/cover/focal-point-settings-button.native.js +1 -1
- package/src/cover/index.php +20 -37
- package/src/cover/save.js +26 -13
- package/src/cover/shared.js +5 -3
- package/src/cover/style.native.scss +4 -0
- package/src/cover/style.scss +27 -26
- package/src/cover/test/__snapshots__/edit.native.js.snap +6 -6
- package/src/cover/test/block-controls.js +62 -0
- package/src/cover/test/transforms.js +301 -0
- package/src/cover/transforms.js +112 -7
- package/src/cover/use-cover-is-dark.native.js +51 -0
- package/src/editor.scss +3 -1
- package/src/embed/embed-preview.js +4 -2
- package/src/file/edit.js +5 -1
- package/src/file/edit.native.js +0 -1
- package/src/file/save.js +14 -2
- package/src/gallery/block.json +1 -1
- package/src/gallery/edit.js +2 -1
- package/src/gallery/gallery.js +2 -2
- package/src/gallery/gap-styles.js +21 -6
- package/src/gallery/index.php +23 -12
- package/src/gallery/shared.js +3 -2
- package/src/gallery/use-get-media.js +2 -1
- package/src/gallery/use-short-code-transform.js +19 -16
- package/src/gallery/v1/gallery.js +2 -2
- package/src/group/block.json +1 -0
- package/src/heading/block.json +1 -0
- package/src/heading/edit.js +5 -2
- package/src/heading/transforms.js +4 -3
- package/src/image/edit.js +0 -44
- package/src/image/edit.native.js +65 -4
- package/src/image/editor.scss +1 -1
- package/src/image/image.js +10 -13
- package/src/image/styles.native.scss +11 -0
- package/src/image/test/edit.native.js +7 -7
- package/src/index.js +53 -33
- package/src/is-block-metadata-experimental.js +19 -0
- package/src/latest-posts/edit.js +27 -2
- package/src/latest-posts/edit.native.js +56 -1
- package/src/latest-posts/index.php +12 -6
- package/src/latest-posts/style.scss +4 -0
- package/src/list/transforms.js +7 -0
- package/src/list/v2/edit.js +1 -0
- package/src/list/v2/migrate.js +1 -1
- package/src/list/v2/transforms.js +35 -0
- package/src/list-item/block.json +2 -1
- package/src/list-item/edit.js +17 -10
- package/src/list-item/hooks/index.js +3 -0
- package/src/list-item/hooks/use-backspace.js +52 -0
- package/src/list-item/hooks/use-enter.js +9 -16
- package/src/list-item/hooks/use-indent-list-item.js +50 -63
- package/src/list-item/hooks/use-space.js +48 -0
- package/src/list-item/hooks/use-split.js +33 -0
- package/src/list-item/utils.js +1 -1
- package/src/media-text/edit.native.js +3 -1
- package/src/media-text/media-container.native.js +2 -4
- package/src/media-text/transforms.js +154 -0
- package/src/navigation/block.json +0 -1
- package/src/navigation/edit/index.js +181 -205
- package/src/navigation/edit/inner-blocks.js +6 -15
- package/src/navigation/index.php +40 -0
- package/src/navigation/style.scss +3 -0
- package/src/navigation/use-navigation-entities.js +1 -1
- package/src/navigation/view-modal.js +32 -0
- package/src/navigation-link/edit.js +75 -48
- package/src/navigation-link/fallback-variations.js +1 -1
- package/src/navigation-link/hooks.js +2 -2
- package/src/navigation-link/test/__snapshots__/hooks.js.snap +4 -4
- package/src/navigation-link/test/edit.js +0 -20
- package/src/navigation-submenu/edit.js +13 -17
- package/src/page-list/convert-to-links-modal.js +1 -1
- package/src/page-list/edit.js +1 -4
- package/src/paragraph/edit.js +6 -0
- package/src/paragraph/use-enter.js +103 -0
- package/src/post-author/edit.js +24 -22
- package/src/post-author/index.php +4 -3
- package/src/post-author-name/block.json +1 -0
- package/src/post-author-name/index.js +2 -0
- package/src/post-author-name/index.php +1 -1
- package/src/post-author-name/transforms.js +25 -0
- package/src/post-comment/block.json +2 -1
- package/src/post-comments/block.json +3 -2
- package/src/post-comments/edit.js +206 -44
- package/src/post-comments/editor.scss +3 -0
- package/src/post-comments/index.php +3 -1
- package/src/post-comments/style.scss +30 -5
- package/src/post-comments-count/block.json +1 -0
- package/src/post-comments-form/block.json +1 -0
- package/src/post-comments-form/edit.js +52 -23
- package/src/post-comments-form/editor.scss +3 -0
- package/src/post-comments-form/form.js +50 -0
- package/src/post-comments-form/index.php +10 -3
- package/src/post-comments-form/style.scss +1 -4
- package/src/post-comments-link/block.json +1 -0
- package/src/post-content/edit.js +15 -1
- package/src/post-date/edit.js +4 -3
- package/src/post-excerpt/edit.js +14 -1
- package/src/post-featured-image/edit.js +1 -1
- package/src/post-template/edit.js +5 -0
- package/src/post-template/index.php +30 -0
- package/src/post-terms/block.json +8 -0
- package/src/post-terms/edit.js +47 -1
- package/src/post-terms/hooks.js +27 -0
- package/src/post-terms/index.js +14 -7
- package/src/post-terms/index.php +50 -2
- package/src/post-title/index.js +1 -1
- package/src/pullquote/edit.js +2 -2
- package/src/pullquote/edit.native.js +2 -2
- package/src/query/block.json +2 -1
- package/src/query/edit/inspector-controls/index.js +25 -11
- package/src/query/edit/inspector-controls/parent-control.js +133 -0
- package/src/query/edit/inspector-controls/sticky-control.js +25 -0
- package/src/query/utils.js +22 -0
- package/src/query-no-results/edit.js +1 -1
- package/src/query-pagination/index.php +0 -1
- package/src/query-title/index.js +1 -1
- package/src/query-title/variations.js +2 -2
- package/src/quote/block.json +1 -0
- package/src/quote/edit.js +5 -2
- package/src/quote/v2/edit.js +4 -2
- package/src/search/block.json +4 -0
- package/src/search/edit.js +4 -1
- package/src/search/index.php +29 -16
- package/src/separator/block.json +3 -0
- package/src/separator/editor.scss +1 -0
- package/src/shortcode/edit.native.js +29 -15
- package/src/shortcode/style.native.scss +11 -4
- package/src/shortcode/test/__snapshots__/edit.native.js.snap +9 -0
- package/src/shortcode/test/edit.native.js +58 -40
- package/src/site-logo/edit.js +1 -1
- package/src/site-logo/style.scss +6 -0
- package/src/social-links/edit.js +11 -10
- package/src/table/edit.js +19 -4
- package/src/table-of-contents/block.json +9 -2
- package/src/table-of-contents/edit.js +170 -77
- package/src/table-of-contents/index.js +2 -0
- package/src/table-of-contents/list.tsx +46 -0
- package/src/table-of-contents/save.js +25 -0
- package/src/table-of-contents/utils.ts +71 -0
- package/src/tag-cloud/block.json +1 -1
- package/src/template-part/edit/index.js +25 -15
- package/src/template-part/edit/inner-blocks.js +2 -10
- package/src/video/edit.js +7 -6
- package/src/video/editor.scss +3 -6
- package/test/babel-plugin.js +67 -0
- package/tsconfig.json +11 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/build/comments-query-loop/edit/comments-inspector-controls.js.map +0 -1
- package/build/comments-query-loop/edit.js.map +0 -1
- package/build/comments-query-loop/index.js.map +0 -1
- package/build/comments-query-loop/save.js.map +0 -1
- package/build/cover/edit.js +0 -665
- package/build/cover/edit.js.map +0 -1
- package/build/navigation-area/edit.js +0 -110
- package/build/navigation-area/edit.js.map +0 -1
- package/build/navigation-area/index.js +0 -62
- package/build/navigation-area/index.js.map +0 -1
- package/build/navigation-area/inner-blocks.js +0 -34
- package/build/navigation-area/inner-blocks.js.map +0 -1
- package/build/navigation-area/save.js +0 -18
- package/build/navigation-area/save.js.map +0 -1
- package/build/post-terms/variations.js +0 -37
- package/build/post-terms/variations.js.map +0 -1
- package/build-module/comments-query-loop/edit.js.map +0 -1
- package/build-module/comments-query-loop/index.js.map +0 -1
- package/build-module/comments-query-loop/save.js.map +0 -1
- package/build-module/cover/edit.js +0 -642
- package/build-module/cover/edit.js.map +0 -1
- package/build-module/navigation-area/edit.js +0 -94
- package/build-module/navigation-area/edit.js.map +0 -1
- package/build-module/navigation-area/index.js +0 -48
- package/build-module/navigation-area/index.js.map +0 -1
- package/build-module/navigation-area/inner-blocks.js +0 -26
- package/build-module/navigation-area/inner-blocks.js.map +0 -1
- package/build-module/navigation-area/save.js +0 -10
- package/build-module/navigation-area/save.js.map +0 -1
- package/build-module/post-terms/variations.js +0 -27
- package/build-module/post-terms/variations.js.map +0 -1
- package/src/cover/edit.js +0 -822
- package/src/navigation-area/block.json +0 -23
- package/src/navigation-area/edit.js +0 -111
- package/src/navigation-area/index.js +0 -26
- package/src/navigation-area/index.php +0 -22
- package/src/navigation-area/inner-blocks.js +0 -24
- package/src/navigation-area/save.js +0 -8
- package/src/post-terms/variations.js +0 -28
- package/src/table-of-contents/index.php +0 -346
- package/src/table-of-contents/list.js +0 -28
- package/src/table-of-contents/utils.js +0 -126
|
@@ -3,6 +3,35 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { createBlock, switchToBlockType } from '@wordpress/blocks';
|
|
5
5
|
import { __UNSTABLE_LINE_SEPARATOR, create, split, toHTMLString } from '@wordpress/rich-text';
|
|
6
|
+
/**
|
|
7
|
+
* Internal dependencies
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { createListBlockFromDOMElement } from './migrate';
|
|
11
|
+
|
|
12
|
+
function getListContentSchema(_ref) {
|
|
13
|
+
let {
|
|
14
|
+
phrasingContentSchema
|
|
15
|
+
} = _ref;
|
|
16
|
+
const listContentSchema = { ...phrasingContentSchema,
|
|
17
|
+
ul: {},
|
|
18
|
+
ol: {
|
|
19
|
+
attributes: ['type', 'start', 'reversed']
|
|
20
|
+
}
|
|
21
|
+
}; // Recursion is needed.
|
|
22
|
+
// Possible: ul > li > ul.
|
|
23
|
+
// Impossible: ul > ul.
|
|
24
|
+
|
|
25
|
+
['ul', 'ol'].forEach(tag => {
|
|
26
|
+
listContentSchema[tag].children = {
|
|
27
|
+
li: {
|
|
28
|
+
children: listContentSchema
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
return listContentSchema;
|
|
33
|
+
}
|
|
34
|
+
|
|
6
35
|
const transforms = {
|
|
7
36
|
from: [{
|
|
8
37
|
type: 'block',
|
|
@@ -12,10 +41,10 @@ const transforms = {
|
|
|
12
41
|
let childBlocks = [];
|
|
13
42
|
|
|
14
43
|
if (blockAttributes.length > 1) {
|
|
15
|
-
childBlocks = blockAttributes.map(
|
|
44
|
+
childBlocks = blockAttributes.map(_ref2 => {
|
|
16
45
|
let {
|
|
17
46
|
content
|
|
18
|
-
} =
|
|
47
|
+
} = _ref2;
|
|
19
48
|
return createBlock('core/list-item', {
|
|
20
49
|
content
|
|
21
50
|
});
|
|
@@ -40,11 +69,11 @@ const transforms = {
|
|
|
40
69
|
}, {
|
|
41
70
|
type: 'block',
|
|
42
71
|
blocks: ['core/quote', 'core/pullquote'],
|
|
43
|
-
transform:
|
|
72
|
+
transform: _ref3 => {
|
|
44
73
|
let {
|
|
45
74
|
value,
|
|
46
75
|
anchor
|
|
47
|
-
} =
|
|
76
|
+
} = _ref3;
|
|
48
77
|
return createBlock('core/list', {
|
|
49
78
|
anchor
|
|
50
79
|
}, split(create({
|
|
@@ -80,20 +109,28 @@ const transforms = {
|
|
|
80
109
|
})]);
|
|
81
110
|
}
|
|
82
111
|
|
|
83
|
-
}))
|
|
112
|
+
})), {
|
|
113
|
+
type: 'raw',
|
|
114
|
+
selector: 'ol,ul',
|
|
115
|
+
schema: args => ({
|
|
116
|
+
ol: getListContentSchema(args).ol,
|
|
117
|
+
ul: getListContentSchema(args).ul
|
|
118
|
+
}),
|
|
119
|
+
transform: createListBlockFromDOMElement
|
|
120
|
+
}],
|
|
84
121
|
to: [...['core/paragraph', 'core/heading'].map(block => ({
|
|
85
122
|
type: 'block',
|
|
86
123
|
blocks: [block],
|
|
87
124
|
transform: (_attributes, childBlocks) => {
|
|
88
|
-
return childBlocks.filter(
|
|
125
|
+
return childBlocks.filter(_ref4 => {
|
|
89
126
|
let {
|
|
90
127
|
name
|
|
91
|
-
} =
|
|
128
|
+
} = _ref4;
|
|
92
129
|
return name === 'core/list-item';
|
|
93
|
-
}).map(
|
|
130
|
+
}).map(_ref5 => {
|
|
94
131
|
let {
|
|
95
132
|
attributes
|
|
96
|
-
} =
|
|
133
|
+
} = _ref5;
|
|
97
134
|
return createBlock(block, {
|
|
98
135
|
content: attributes.content
|
|
99
136
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/list/v2/transforms.js"],"names":["createBlock","switchToBlockType","__UNSTABLE_LINE_SEPARATOR","create","split","toHTMLString","transforms","from","type","isMultiBlock","blocks","transform","blockAttributes","childBlocks","length","map","content","value","html","result","anchor","multilineTag","prefix","ordered","to","block","_attributes","filter","name","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/list/v2/transforms.js"],"names":["createBlock","switchToBlockType","__UNSTABLE_LINE_SEPARATOR","create","split","toHTMLString","createListBlockFromDOMElement","getListContentSchema","phrasingContentSchema","listContentSchema","ul","ol","attributes","forEach","tag","children","li","transforms","from","type","isMultiBlock","blocks","transform","blockAttributes","childBlocks","length","map","content","value","html","result","anchor","multilineTag","prefix","ordered","selector","schema","args","to","block","_attributes","filter","name","innerBlocks"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,iBAAtB,QAA+C,mBAA/C;AACA,SACCC,yBADD,EAECC,MAFD,EAGCC,KAHD,EAICC,YAJD,QAKO,sBALP;AAOA;AACA;AACA;;AACA,SAASC,6BAAT,QAA8C,WAA9C;;AAEA,SAASC,oBAAT,OAA2D;AAAA,MAA5B;AAAEC,IAAAA;AAAF,GAA4B;AAC1D,QAAMC,iBAAiB,GAAG,EACzB,GAAGD,qBADsB;AAEzBE,IAAAA,EAAE,EAAE,EAFqB;AAGzBC,IAAAA,EAAE,EAAE;AAAEC,MAAAA,UAAU,EAAE,CAAE,MAAF,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KAAe;AACzDpB,IAAAA,IAAI,EAAE,OADmD;AAEzDE,IAAAA,MAAM,EAAE,CAAEkB,KAAF,CAFiD;AAGzDjB,IAAAA,SAAS,EAAE,CAAEV,UAAF,EAAc+B,WAAd,KAA+B;AACzC,aAAO1C,iBAAiB,CACvBA,iBAAiB,CAChBD,WAAW,CAAE,WAAF,EAAeY,UAAf,EAA2B+B,WAA3B,CADK,EAEhB,gBAFgB,CADM,EAKvBJ,KALuB,CAAxB;AAOA;AAXwD,GAAf,CAAxC,CAdA;AAnFc,CAAnB;AAiHA,eAAetB,UAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createBlock, switchToBlockType } from '@wordpress/blocks';\nimport {\n\t__UNSTABLE_LINE_SEPARATOR,\n\tcreate,\n\tsplit,\n\ttoHTMLString,\n} from '@wordpress/rich-text';\n\n/**\n * Internal dependencies\n */\nimport { createListBlockFromDOMElement } from './migrate';\n\nfunction getListContentSchema( { phrasingContentSchema } ) {\n\tconst listContentSchema = {\n\t\t...phrasingContentSchema,\n\t\tul: {},\n\t\tol: { attributes: [ 'type', 'start', 'reversed' ] },\n\t};\n\n\t// Recursion is needed.\n\t// Possible: ul > li > ul.\n\t// Impossible: ul > ul.\n\t[ 'ul', 'ol' ].forEach( ( tag ) => {\n\t\tlistContentSchema[ tag ].children = {\n\t\t\tli: {\n\t\t\t\tchildren: listContentSchema,\n\t\t\t},\n\t\t};\n\t} );\n\n\treturn listContentSchema;\n}\n\nconst transforms = {\n\tfrom: [\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tisMultiBlock: true,\n\t\t\tblocks: [ 'core/paragraph', 'core/heading' ],\n\t\t\ttransform: ( blockAttributes ) => {\n\t\t\t\tlet childBlocks = [];\n\t\t\t\tif ( blockAttributes.length > 1 ) {\n\t\t\t\t\tchildBlocks = blockAttributes.map( ( { content } ) => {\n\t\t\t\t\t\treturn createBlock( 'core/list-item', { content } );\n\t\t\t\t\t} );\n\t\t\t\t} else if ( blockAttributes.length === 1 ) {\n\t\t\t\t\tconst value = create( {\n\t\t\t\t\t\thtml: blockAttributes[ 0 ].content,\n\t\t\t\t\t} );\n\t\t\t\t\tchildBlocks = split( value, '\\n' ).map( ( result ) => {\n\t\t\t\t\t\treturn createBlock( 'core/list-item', {\n\t\t\t\t\t\t\tcontent: toHTMLString( { value: result } ),\n\t\t\t\t\t\t} );\n\t\t\t\t\t} );\n\t\t\t\t}\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/list',\n\t\t\t\t\t{\n\t\t\t\t\t\tanchor: blockAttributes.anchor,\n\t\t\t\t\t},\n\t\t\t\t\tchildBlocks\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\t{\n\t\t\ttype: 'block',\n\t\t\tblocks: [ 'core/quote', 'core/pullquote' ],\n\t\t\ttransform: ( { value, anchor } ) => {\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/list',\n\t\t\t\t\t{\n\t\t\t\t\t\tanchor,\n\t\t\t\t\t},\n\t\t\t\t\tsplit(\n\t\t\t\t\t\tcreate( { html: value, multilineTag: 'p' } ),\n\t\t\t\t\t\t__UNSTABLE_LINE_SEPARATOR\n\t\t\t\t\t).map( ( result ) => {\n\t\t\t\t\t\treturn createBlock( 'core/list-item', {\n\t\t\t\t\t\t\tcontent: toHTMLString( { value: result } ),\n\t\t\t\t\t\t} );\n\t\t\t\t\t} )\n\t\t\t\t);\n\t\t\t},\n\t\t},\n\t\t...[ '*', '-' ].map( ( prefix ) => ( {\n\t\t\ttype: 'prefix',\n\t\t\tprefix,\n\t\t\ttransform( content ) {\n\t\t\t\treturn createBlock( 'core/list', {}, [\n\t\t\t\t\tcreateBlock( 'core/list-item', { content } ),\n\t\t\t\t] );\n\t\t\t},\n\t\t} ) ),\n\t\t...[ '1.', '1)' ].map( ( prefix ) => ( {\n\t\t\ttype: 'prefix',\n\t\t\tprefix,\n\t\t\ttransform( content ) {\n\t\t\t\treturn createBlock(\n\t\t\t\t\t'core/list',\n\t\t\t\t\t{\n\t\t\t\t\t\tordered: true,\n\t\t\t\t\t},\n\t\t\t\t\t[ createBlock( 'core/list-item', { content } ) ]\n\t\t\t\t);\n\t\t\t},\n\t\t} ) ),\n\t\t{\n\t\t\ttype: 'raw',\n\t\t\tselector: 'ol,ul',\n\t\t\tschema: ( args ) => ( {\n\t\t\t\tol: getListContentSchema( args ).ol,\n\t\t\t\tul: getListContentSchema( args ).ul,\n\t\t\t} ),\n\t\t\ttransform: createListBlockFromDOMElement,\n\t\t},\n\t],\n\tto: [\n\t\t...[ 'core/paragraph', 'core/heading' ].map( ( block ) => ( {\n\t\t\ttype: 'block',\n\t\t\tblocks: [ block ],\n\t\t\ttransform: ( _attributes, childBlocks ) => {\n\t\t\t\treturn childBlocks\n\t\t\t\t\t.filter( ( { name } ) => name === 'core/list-item' )\n\t\t\t\t\t.map( ( { attributes } ) =>\n\t\t\t\t\t\tcreateBlock( block, {\n\t\t\t\t\t\t\tcontent: attributes.content,\n\t\t\t\t\t\t} )\n\t\t\t\t\t);\n\t\t\t},\n\t\t} ) ),\n\t\t...[ 'core/quote', 'core/pullquote' ].map( ( block ) => ( {\n\t\t\ttype: 'block',\n\t\t\tblocks: [ block ],\n\t\t\ttransform: ( attributes, innerBlocks ) => {\n\t\t\t\treturn switchToBlockType(\n\t\t\t\t\tswitchToBlockType(\n\t\t\t\t\t\tcreateBlock( 'core/list', attributes, innerBlocks ),\n\t\t\t\t\t\t'core/paragraph'\n\t\t\t\t\t),\n\t\t\t\t\tblock\n\t\t\t\t);\n\t\t\t},\n\t\t} ) ),\n\t],\n};\n\nexport default transforms;\n"]}
|
|
@@ -5,7 +5,6 @@ import { createElement, Fragment } from "@wordpress/element";
|
|
|
5
5
|
*/
|
|
6
6
|
import { RichText, useBlockProps, useInnerBlocksProps, BlockControls } from '@wordpress/block-editor';
|
|
7
7
|
import { isRTL, __ } from '@wordpress/i18n';
|
|
8
|
-
import { createBlock } from '@wordpress/blocks';
|
|
9
8
|
import { ToolbarButton } from '@wordpress/components';
|
|
10
9
|
import { formatOutdent, formatOutdentRTL, formatIndentRTL, formatIndent } from '@wordpress/icons';
|
|
11
10
|
import { useMergeRefs } from '@wordpress/compose';
|
|
@@ -13,7 +12,7 @@ import { useMergeRefs } from '@wordpress/compose';
|
|
|
13
12
|
* Internal dependencies
|
|
14
13
|
*/
|
|
15
14
|
|
|
16
|
-
import { useEnter, useIndentListItem, useOutdentListItem } from './hooks';
|
|
15
|
+
import { useEnter, useBackspace, useSpace, useIndentListItem, useOutdentListItem, useSplit } from './hooks';
|
|
17
16
|
|
|
18
17
|
function IndentUI(_ref) {
|
|
19
18
|
let {
|
|
@@ -38,7 +37,6 @@ function IndentUI(_ref) {
|
|
|
38
37
|
|
|
39
38
|
export default function ListItemEdit(_ref2) {
|
|
40
39
|
let {
|
|
41
|
-
name,
|
|
42
40
|
attributes,
|
|
43
41
|
setAttributes,
|
|
44
42
|
mergeBlocks,
|
|
@@ -57,8 +55,13 @@ export default function ListItemEdit(_ref2) {
|
|
|
57
55
|
content,
|
|
58
56
|
clientId
|
|
59
57
|
});
|
|
58
|
+
const useBackspaceRef = useBackspace({
|
|
59
|
+
clientId
|
|
60
|
+
});
|
|
61
|
+
const useSpaceRef = useSpace(clientId);
|
|
62
|
+
const onSplit = useSplit(clientId);
|
|
60
63
|
return createElement(Fragment, null, createElement("li", innerBlocksProps, createElement(RichText, {
|
|
61
|
-
ref: useMergeRefs([useEnterRef]),
|
|
64
|
+
ref: useMergeRefs([useEnterRef, useBackspaceRef, useSpaceRef]),
|
|
62
65
|
identifier: "content",
|
|
63
66
|
tagName: "div",
|
|
64
67
|
onChange: nextContent => setAttributes({
|
|
@@ -67,11 +70,7 @@ export default function ListItemEdit(_ref2) {
|
|
|
67
70
|
value: content,
|
|
68
71
|
"aria-label": __('List text'),
|
|
69
72
|
placeholder: placeholder || __('List'),
|
|
70
|
-
onSplit:
|
|
71
|
-
return createBlock(name, { ...attributes,
|
|
72
|
-
content: value
|
|
73
|
-
});
|
|
74
|
-
},
|
|
73
|
+
onSplit: onSplit,
|
|
75
74
|
onMerge: mergeBlocks,
|
|
76
75
|
onReplace: onReplace
|
|
77
76
|
}), innerBlocksProps.children), createElement(BlockControls, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/list-item/edit.js"],"names":["RichText","useBlockProps","useInnerBlocksProps","BlockControls","isRTL","__","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/list-item/edit.js"],"names":["RichText","useBlockProps","useInnerBlocksProps","BlockControls","isRTL","__","ToolbarButton","formatOutdent","formatOutdentRTL","formatIndentRTL","formatIndent","useMergeRefs","useEnter","useBackspace","useSpace","useIndentListItem","useOutdentListItem","useSplit","IndentUI","clientId","canIndent","indentListItem","canOutdent","outdentListItem","ListItemEdit","attributes","setAttributes","mergeBlocks","onReplace","placeholder","content","blockProps","innerBlocksProps","allowedBlocks","useEnterRef","useBackspaceRef","useSpaceRef","onSplit","nextContent","children"],"mappings":";;AAAA;AACA;AACA;AACA,SACCA,QADD,EAECC,aAFD,EAGCC,mBAHD,EAICC,aAJD,QAKO,yBALP;AAMA,SAASC,KAAT,EAAgBC,EAAhB,QAA0B,iBAA1B;AACA,SAASC,aAAT,QAA8B,uBAA9B;AACA,SACCC,aADD,EAECC,gBAFD,EAGCC,eAHD,EAICC,YAJD,QAKO,kBALP;AAMA,SAASC,YAAT,QAA6B,oBAA7B;AAEA;AACA;AACA;;AACA,SACCC,QADD,EAECC,YAFD,EAGCC,QAHD,EAICC,iBAJD,EAKCC,kBALD,EAMCC,QAND,QAOO,SAPP;;AASA,SAASC,QAAT,OAAkC;AAAA,MAAf;AAAEC,IAAAA;AAAF,GAAe;AACjC,QAAM,CAAEC,SAAF,EAAaC,cAAb,IAAgCN,iBAAiB,CAAEI,QAAF,CAAvD;AACA,QAAM,CAAEG,UAAF,EAAcC,eAAd,IAAkCP,kBAAkB,CAAEG,QAAF,CAA1D;AAEA,SACC,8BACC,cAAC,aAAD;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,YAAY,CAAE,CACnBuB,WADmB,EAEnBC,eAFmB,EAGnBC,WAHmB,CAAF,CADnB;AAMC,IAAA,UAAU,EAAC,SANZ;AAOC,IAAA,OAAO,EAAC,KAPT;AAQC,IAAA,QAAQ,EAAKE,WAAF,IACVZ,aAAa,CAAE;AAAEI,MAAAA,OAAO,EAAEQ;AAAX,KAAF,CATf;AAWC,IAAA,KAAK,EAAGR,OAXT;AAYC,kBAAazB,EAAE,CAAE,WAAF,CAZhB;AAaC,IAAA,WAAW,EAAGwB,WAAW,IAAIxB,EAAE,CAAE,MAAF,CAbhC;AAcC,IAAA,OAAO,EAAGgC,OAdX;AAeC,IAAA,OAAO,EAAGV,WAfX;AAgBC,IAAA,SAAS,EAAGC;AAhBb,IADD,EAmBGI,gBAAgB,CAACO,QAnBpB,CADD,EAsBC,cAAC,aAAD;AAAe,IAAA,KAAK,EAAC;AAArB,KACC,cAAC,QAAD;AAAU,IAAA,QAAQ,EAAGpB;AAArB,IADD,CAtBD,CADD;AA4BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tRichText,\n\tuseBlockProps,\n\tuseInnerBlocksProps,\n\tBlockControls,\n} from '@wordpress/block-editor';\nimport { isRTL, __ } from '@wordpress/i18n';\nimport { ToolbarButton } from '@wordpress/components';\nimport {\n\tformatOutdent,\n\tformatOutdentRTL,\n\tformatIndentRTL,\n\tformatIndent,\n} from '@wordpress/icons';\nimport { useMergeRefs } from '@wordpress/compose';\n\n/**\n * Internal dependencies\n */\nimport {\n\tuseEnter,\n\tuseBackspace,\n\tuseSpace,\n\tuseIndentListItem,\n\tuseOutdentListItem,\n\tuseSplit,\n} from './hooks';\n\nfunction IndentUI( { clientId } ) {\n\tconst [ canIndent, indentListItem ] = useIndentListItem( clientId );\n\tconst [ canOutdent, outdentListItem ] = useOutdentListItem( clientId );\n\n\treturn (\n\t\t<>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatOutdentRTL : formatOutdent }\n\t\t\t\ttitle={ __( 'Outdent' ) }\n\t\t\t\tdescribedBy={ __( 'Outdent list item' ) }\n\t\t\t\tdisabled={ ! canOutdent }\n\t\t\t\tonClick={ outdentListItem }\n\t\t\t/>\n\t\t\t<ToolbarButton\n\t\t\t\ticon={ isRTL() ? formatIndentRTL : formatIndent }\n\t\t\t\ttitle={ __( 'Indent' ) }\n\t\t\t\tdescribedBy={ __( 'Indent list item' ) }\n\t\t\t\tisDisabled={ ! canIndent }\n\t\t\t\tonClick={ indentListItem }\n\t\t\t/>\n\t\t</>\n\t);\n}\n\nexport default function ListItemEdit( {\n\tattributes,\n\tsetAttributes,\n\tmergeBlocks,\n\tonReplace,\n\tclientId,\n} ) {\n\tconst { placeholder, content } = attributes;\n\tconst blockProps = useBlockProps();\n\tconst innerBlocksProps = useInnerBlocksProps( blockProps, {\n\t\tallowedBlocks: [ 'core/list' ],\n\t} );\n\tconst useEnterRef = useEnter( { content, clientId } );\n\tconst useBackspaceRef = useBackspace( { clientId } );\n\tconst useSpaceRef = useSpace( clientId );\n\tconst onSplit = useSplit( clientId );\n\treturn (\n\t\t<>\n\t\t\t<li { ...innerBlocksProps }>\n\t\t\t\t<RichText\n\t\t\t\t\tref={ useMergeRefs( [\n\t\t\t\t\t\tuseEnterRef,\n\t\t\t\t\t\tuseBackspaceRef,\n\t\t\t\t\t\tuseSpaceRef,\n\t\t\t\t\t] ) }\n\t\t\t\t\tidentifier=\"content\"\n\t\t\t\t\ttagName=\"div\"\n\t\t\t\t\tonChange={ ( nextContent ) =>\n\t\t\t\t\t\tsetAttributes( { content: nextContent } )\n\t\t\t\t\t}\n\t\t\t\t\tvalue={ content }\n\t\t\t\t\taria-label={ __( 'List text' ) }\n\t\t\t\t\tplaceholder={ placeholder || __( 'List' ) }\n\t\t\t\t\tonSplit={ onSplit }\n\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\tonReplace={ onReplace }\n\t\t\t\t/>\n\t\t\t\t{ innerBlocksProps.children }\n\t\t\t</li>\n\t\t\t<BlockControls group=\"block\">\n\t\t\t\t<IndentUI clientId={ clientId } />\n\t\t\t</BlockControls>\n\t\t</>\n\t);\n}\n"]}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { default as useOutdentListItem } from './use-outdent-list-item';
|
|
2
2
|
export { default as useIndentListItem } from './use-indent-list-item';
|
|
3
3
|
export { default as useEnter } from './use-enter';
|
|
4
|
+
export { default as useBackspace } from './use-backspace';
|
|
5
|
+
export { default as useSpace } from './use-space';
|
|
6
|
+
export { default as useSplit } from './use-split';
|
|
4
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/index.js"],"names":["default","useOutdentListItem","useIndentListItem","useEnter"],"mappings":"AAAA,SAASA,OAAO,IAAIC,kBAApB,QAA8C,yBAA9C;AACA,SAASD,OAAO,IAAIE,iBAApB,QAA6C,wBAA7C;AACA,SAASF,OAAO,IAAIG,QAApB,QAAoC,aAApC","sourcesContent":["export { default as useOutdentListItem } from './use-outdent-list-item';\nexport { default as useIndentListItem } from './use-indent-list-item';\nexport { default as useEnter } from './use-enter';\n"]}
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/index.js"],"names":["default","useOutdentListItem","useIndentListItem","useEnter","useBackspace","useSpace","useSplit"],"mappings":"AAAA,SAASA,OAAO,IAAIC,kBAApB,QAA8C,yBAA9C;AACA,SAASD,OAAO,IAAIE,iBAApB,QAA6C,wBAA7C;AACA,SAASF,OAAO,IAAIG,QAApB,QAAoC,aAApC;AACA,SAASH,OAAO,IAAII,YAApB,QAAwC,iBAAxC;AACA,SAASJ,OAAO,IAAIK,QAApB,QAAoC,aAApC;AACA,SAASL,OAAO,IAAIM,QAApB,QAAoC,aAApC","sourcesContent":["export { default as useOutdentListItem } from './use-outdent-list-item';\nexport { default as useIndentListItem } from './use-indent-list-item';\nexport { default as useEnter } from './use-enter';\nexport { default as useBackspace } from './use-backspace';\nexport { default as useSpace } from './use-space';\nexport { default as useSplit } from './use-split';\n"]}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRef } from '@wordpress/element';
|
|
5
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
6
|
+
import { BACKSPACE } from '@wordpress/keycodes';
|
|
7
|
+
import { useSelect } from '@wordpress/data';
|
|
8
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import useOutdentListItem from './use-outdent-list-item';
|
|
14
|
+
export default function useBackspace(props) {
|
|
15
|
+
const {
|
|
16
|
+
getSelectionStart,
|
|
17
|
+
getSelectionEnd
|
|
18
|
+
} = useSelect(blockEditorStore);
|
|
19
|
+
const propsRef = useRef(props);
|
|
20
|
+
propsRef.current = props;
|
|
21
|
+
const [canOutdent, outdentListItem] = useOutdentListItem(propsRef.current.clientId);
|
|
22
|
+
return useRefEffect(element => {
|
|
23
|
+
function onKeyDown(event) {
|
|
24
|
+
if (event.defaultPrevented || event.keyCode !== BACKSPACE) {
|
|
25
|
+
return;
|
|
26
|
+
} // Handle only if we have a collapsed selection at the
|
|
27
|
+
// start of a list item and we can outdent.
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
if (!canOutdent || [getSelectionStart().offset, getSelectionEnd().offset].some(offset => offset !== 0)) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
event.preventDefault();
|
|
35
|
+
outdentListItem();
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
element.addEventListener('keydown', onKeyDown);
|
|
39
|
+
return () => {
|
|
40
|
+
element.removeEventListener('keydown', onKeyDown);
|
|
41
|
+
};
|
|
42
|
+
}, [canOutdent]);
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=use-backspace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/use-backspace.js"],"names":["useRef","useRefEffect","BACKSPACE","useSelect","store","blockEditorStore","useOutdentListItem","useBackspace","props","getSelectionStart","getSelectionEnd","propsRef","current","canOutdent","outdentListItem","clientId","element","onKeyDown","event","defaultPrevented","keyCode","offset","some","preventDefault","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,MAAT,QAAuB,oBAAvB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,SAAT,QAA0B,qBAA1B;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AAEA,eAAe,SAASC,YAAT,CAAuBC,KAAvB,EAA+B;AAC7C,QAAM;AAAEC,IAAAA,iBAAF;AAAqBC,IAAAA;AAArB,MAAyCP,SAAS,CACvDE,gBADuD,CAAxD;AAGA,QAAMM,QAAQ,GAAGX,MAAM,CAAEQ,KAAF,CAAvB;AACAG,EAAAA,QAAQ,CAACC,OAAT,GAAmBJ,KAAnB;AACA,QAAM,CAAEK,UAAF,EAAcC,eAAd,IAAkCR,kBAAkB,CACzDK,QAAQ,CAACC,OAAT,CAAiBG,QADwC,CAA1D;AAGA,SAAOd,YAAY,CAChBe,OAAF,IAAe;AACd,aAASC,SAAT,CAAoBC,KAApB,EAA4B;AAC3B,UAAKA,KAAK,CAACC,gBAAN,IAA0BD,KAAK,CAACE,OAAN,KAAkBlB,SAAjD,EAA6D;AAC5D;AACA,OAH0B,CAI3B;AACA;;;AACA,UACC,CAAEW,UAAF,IACA,CACCJ,iBAAiB,GAAGY,MADrB,EAECX,eAAe,GAAGW,MAFnB,EAGEC,IAHF,CAGUD,MAAF,IAAcA,MAAM,KAAK,CAHjC,CAFD,EAME;AACD;AACA;;AACDH,MAAAA,KAAK,CAACK,cAAN;AACAT,MAAAA,eAAe;AACf;;AAEDE,IAAAA,OAAO,CAACQ,gBAAR,CAA0B,SAA1B,EAAqCP,SAArC;AACA,WAAO,MAAM;AACZD,MAAAA,OAAO,CAACS,mBAAR,CAA6B,SAA7B,EAAwCR,SAAxC;AACA,KAFD;AAGA,GAzBiB,EA0BlB,CAAEJ,UAAF,CA1BkB,CAAnB;AA4BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { BACKSPACE } from '@wordpress/keycodes';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport useOutdentListItem from './use-outdent-list-item';\n\nexport default function useBackspace( props ) {\n\tconst { getSelectionStart, getSelectionEnd } = useSelect(\n\t\tblockEditorStore\n\t);\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\tconst [ canOutdent, outdentListItem ] = useOutdentListItem(\n\t\tpropsRef.current.clientId\n\t);\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\tif ( event.defaultPrevented || event.keyCode !== BACKSPACE ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Handle only if we have a collapsed selection at the\n\t\t\t\t// start of a list item and we can outdent.\n\t\t\t\tif (\n\t\t\t\t\t! canOutdent ||\n\t\t\t\t\t[\n\t\t\t\t\t\tgetSelectionStart().offset,\n\t\t\t\t\t\tgetSelectionEnd().offset,\n\t\t\t\t\t].some( ( offset ) => offset !== 0 )\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tevent.preventDefault();\n\t\t\t\toutdentListItem();\n\t\t\t}\n\n\t\t\telement.addEventListener( 'keydown', onKeyDown );\n\t\t\treturn () => {\n\t\t\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t\t\t};\n\t\t},\n\t\t[ canOutdent ]\n\t);\n}\n"]}
|
|
@@ -11,7 +11,7 @@ import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
|
11
11
|
* Internal dependencies
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import
|
|
14
|
+
import useOutdentListItem from './use-outdent-list-item';
|
|
15
15
|
export default function useEnter(props) {
|
|
16
16
|
const {
|
|
17
17
|
replaceBlocks
|
|
@@ -19,12 +19,11 @@ export default function useEnter(props) {
|
|
|
19
19
|
const {
|
|
20
20
|
getBlock,
|
|
21
21
|
getBlockRootClientId,
|
|
22
|
-
getBlockParents,
|
|
23
22
|
getBlockIndex
|
|
24
23
|
} = useSelect(blockEditorStore);
|
|
25
24
|
const propsRef = useRef(props);
|
|
26
25
|
propsRef.current = props;
|
|
27
|
-
const [
|
|
26
|
+
const [canOutdent, outdentListItem] = useOutdentListItem(propsRef.current.clientId);
|
|
28
27
|
return useRefEffect(element => {
|
|
29
28
|
function onKeyDown(event) {
|
|
30
29
|
var _topParentListBlock$i;
|
|
@@ -44,16 +43,14 @@ export default function useEnter(props) {
|
|
|
44
43
|
|
|
45
44
|
event.preventDefault();
|
|
46
45
|
|
|
47
|
-
if (
|
|
48
|
-
|
|
46
|
+
if (canOutdent) {
|
|
47
|
+
outdentListItem();
|
|
49
48
|
return;
|
|
50
49
|
} // Here we are in top level list so we need to split.
|
|
51
50
|
|
|
52
51
|
|
|
53
52
|
const blockRootClientId = getBlockRootClientId(clientId);
|
|
54
|
-
const
|
|
55
|
-
const topParentListBlockClientId = blockParents[0];
|
|
56
|
-
const topParentListBlock = getBlock(topParentListBlockClientId);
|
|
53
|
+
const topParentListBlock = getBlock(blockRootClientId);
|
|
57
54
|
const blockIndex = getBlockIndex(clientId);
|
|
58
55
|
const head = cloneBlock({ ...topParentListBlock,
|
|
59
56
|
innerBlocks: topParentListBlock.innerBlocks.slice(0, blockIndex)
|
|
@@ -72,6 +69,6 @@ export default function useEnter(props) {
|
|
|
72
69
|
return () => {
|
|
73
70
|
element.removeEventListener('keydown', onKeyDown);
|
|
74
71
|
};
|
|
75
|
-
}, [
|
|
72
|
+
}, [canOutdent]);
|
|
76
73
|
}
|
|
77
74
|
//# sourceMappingURL=use-enter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/use-enter.js"],"names":["createBlock","getDefaultBlockName","cloneBlock","useRef","useRefEffect","ENTER","useSelect","useDispatch","store","blockEditorStore","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/use-enter.js"],"names":["createBlock","getDefaultBlockName","cloneBlock","useRef","useRefEffect","ENTER","useSelect","useDispatch","store","blockEditorStore","useOutdentListItem","useEnter","props","replaceBlocks","getBlock","getBlockRootClientId","getBlockIndex","propsRef","current","canOutdent","outdentListItem","clientId","element","onKeyDown","event","defaultPrevented","keyCode","content","length","preventDefault","blockRootClientId","topParentListBlock","blockIndex","head","innerBlocks","slice","middle","after","tail","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,WADD,EAECC,mBAFD,EAGCC,UAHD,QAIO,mBAJP;AAKA,SAASC,MAAT,QAAuB,oBAAvB;AACA,SAASC,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAT,QAAsB,qBAAtB;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AAEA;AACA;AACA;;AACA,OAAOC,kBAAP,MAA+B,yBAA/B;AAEA,eAAe,SAASC,QAAT,CAAmBC,KAAnB,EAA2B;AACzC,QAAM;AAAEC,IAAAA;AAAF,MAAoBN,WAAW,CAAEE,gBAAF,CAArC;AACA,QAAM;AAAEK,IAAAA,QAAF;AAAYC,IAAAA,oBAAZ;AAAkCC,IAAAA;AAAlC,MAAoDV,SAAS,CAClEG,gBADkE,CAAnE;AAGA,QAAMQ,QAAQ,GAAGd,MAAM,CAAES,KAAF,CAAvB;AACAK,EAAAA,QAA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,CAACT,MAAN,GACV,CACA1B,UAAU,CAAE,EACX,GAAG6B,kBADQ;AAEXG,QAAAA,WAAW,EAAEG;AAFF,OAAF,CADV,CADU,GAOV,EAPH;AAQAxB,MAAAA,aAAa,CACZiB,iBADY,EAEZ,CAAEG,IAAF,EAAQG,MAAR,EAAgB,GAAGE,IAAnB,CAFY,EAGZ,CAHY,EAIZ,CAJY,CAAb;AAMA;;AAEDhB,IAAAA,OAAO,CAACiB,gBAAR,CAA0B,SAA1B,EAAqChB,SAArC;AACA,WAAO,MAAM;AACZD,MAAAA,OAAO,CAACkB,mBAAR,CAA6B,SAA7B,EAAwCjB,SAAxC;AACA,KAFD;AAGA,GAtDiB,EAuDlB,CAAEJ,UAAF,CAvDkB,CAAnB;AAyDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tcreateBlock,\n\tgetDefaultBlockName,\n\tcloneBlock,\n} from '@wordpress/blocks';\nimport { useRef } from '@wordpress/element';\nimport { useRefEffect } from '@wordpress/compose';\nimport { ENTER } from '@wordpress/keycodes';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport useOutdentListItem from './use-outdent-list-item';\n\nexport default function useEnter( props ) {\n\tconst { replaceBlocks } = useDispatch( blockEditorStore );\n\tconst { getBlock, getBlockRootClientId, getBlockIndex } = useSelect(\n\t\tblockEditorStore\n\t);\n\tconst propsRef = useRef( props );\n\tpropsRef.current = props;\n\tconst [ canOutdent, outdentListItem ] = useOutdentListItem(\n\t\tpropsRef.current.clientId\n\t);\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\tif ( event.defaultPrevented || event.keyCode !== ENTER ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst { content, clientId } = propsRef.current;\n\t\t\t\tif ( content.length ) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tevent.preventDefault();\n\t\t\t\tif ( canOutdent ) {\n\t\t\t\t\toutdentListItem();\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\t// Here we are in top level list so we need to split.\n\t\t\t\tconst blockRootClientId = getBlockRootClientId( clientId );\n\t\t\t\tconst topParentListBlock = getBlock( blockRootClientId );\n\t\t\t\tconst blockIndex = getBlockIndex( clientId );\n\t\t\t\tconst head = cloneBlock( {\n\t\t\t\t\t...topParentListBlock,\n\t\t\t\t\tinnerBlocks: topParentListBlock.innerBlocks.slice(\n\t\t\t\t\t\t0,\n\t\t\t\t\t\tblockIndex\n\t\t\t\t\t),\n\t\t\t\t} );\n\t\t\t\tconst middle = createBlock( getDefaultBlockName() );\n\t\t\t\t// Last list item might contain a `list` block innerBlock\n\t\t\t\t// In that case append remaining innerBlocks blocks.\n\t\t\t\tconst after = [\n\t\t\t\t\t...( topParentListBlock.innerBlocks[ blockIndex ]\n\t\t\t\t\t\t.innerBlocks[ 0 ]?.innerBlocks || [] ),\n\t\t\t\t\t...topParentListBlock.innerBlocks.slice( blockIndex + 1 ),\n\t\t\t\t];\n\t\t\t\tconst tail = after.length\n\t\t\t\t\t? [\n\t\t\t\t\t\t\tcloneBlock( {\n\t\t\t\t\t\t\t\t...topParentListBlock,\n\t\t\t\t\t\t\t\tinnerBlocks: after,\n\t\t\t\t\t\t\t} ),\n\t\t\t\t\t ]\n\t\t\t\t\t: [];\n\t\t\t\treplaceBlocks(\n\t\t\t\t\tblockRootClientId,\n\t\t\t\t\t[ head, middle, ...tail ],\n\t\t\t\t\t1,\n\t\t\t\t\t0\n\t\t\t\t);\n\t\t\t}\n\n\t\t\telement.addEventListener( 'keydown', onKeyDown );\n\t\t\treturn () => {\n\t\t\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t\t\t};\n\t\t},\n\t\t[ canOutdent ]\n\t);\n}\n"]}
|
|
@@ -1,62 +1,57 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { first } from 'lodash';
|
|
5
1
|
/**
|
|
6
2
|
* WordPress dependencies
|
|
7
3
|
*/
|
|
8
|
-
|
|
9
4
|
import { useCallback } from '@wordpress/element';
|
|
10
5
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
11
6
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
12
|
-
|
|
13
|
-
* Internal dependencies
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import { createListItem } from '../utils';
|
|
7
|
+
import { createBlock, cloneBlock } from '@wordpress/blocks';
|
|
17
8
|
export default function useIndentListItem(clientId) {
|
|
18
|
-
const
|
|
19
|
-
canIndent
|
|
20
|
-
} = useSelect(innerSelect => {
|
|
21
|
-
const {
|
|
22
|
-
getBlockIndex
|
|
23
|
-
} = innerSelect(blockEditorStore);
|
|
24
|
-
return {
|
|
25
|
-
canIndent: getBlockIndex(clientId) > 0
|
|
26
|
-
};
|
|
27
|
-
}, [clientId]);
|
|
9
|
+
const canIndent = useSelect(select => select(blockEditorStore).getBlockIndex(clientId) > 0, [clientId]);
|
|
28
10
|
const {
|
|
29
11
|
replaceBlocks,
|
|
30
|
-
selectionChange
|
|
12
|
+
selectionChange,
|
|
13
|
+
multiSelect
|
|
31
14
|
} = useDispatch(blockEditorStore);
|
|
32
15
|
const {
|
|
33
|
-
getBlockRootClientId,
|
|
34
16
|
getBlock,
|
|
35
|
-
|
|
17
|
+
getPreviousBlockClientId,
|
|
36
18
|
getSelectionStart,
|
|
37
19
|
getSelectionEnd,
|
|
38
|
-
|
|
20
|
+
hasMultiSelection,
|
|
21
|
+
getMultiSelectedBlockClientIds
|
|
39
22
|
} = useSelect(blockEditorStore);
|
|
40
23
|
return [canIndent, useCallback(() => {
|
|
41
|
-
var
|
|
24
|
+
var _newListItem$innerBlo;
|
|
25
|
+
|
|
26
|
+
const _hasMultiSelection = hasMultiSelection();
|
|
27
|
+
|
|
28
|
+
const clientIds = _hasMultiSelection ? getMultiSelectedBlockClientIds() : [clientId];
|
|
29
|
+
const clonedBlocks = clientIds.map(_clientId => cloneBlock(getBlock(_clientId)));
|
|
30
|
+
const previousSiblingId = getPreviousBlockClientId(clientId);
|
|
31
|
+
const newListItem = cloneBlock(getBlock(previousSiblingId)); // If the sibling has no innerBlocks, create a new `list` block.
|
|
32
|
+
|
|
33
|
+
if (!((_newListItem$innerBlo = newListItem.innerBlocks) !== null && _newListItem$innerBlo !== void 0 && _newListItem$innerBlo.length)) {
|
|
34
|
+
newListItem.innerBlocks = [createBlock('core/list')];
|
|
35
|
+
} // A list item usually has one `list`, but it's possible to have
|
|
36
|
+
// more. So we need to preserve the previous `list` blocks and
|
|
37
|
+
// merge the new blocks to the last `list`.
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
newListItem.innerBlocks[newListItem.innerBlocks.length - 1].innerBlocks.push(...clonedBlocks); // We get the selection start/end here, because when
|
|
41
|
+
// we replace blocks, the selection is updated too.
|
|
42
42
|
|
|
43
43
|
const selectionStart = getSelectionStart();
|
|
44
|
-
const selectionEnd = getSelectionEnd();
|
|
45
|
-
const parentId = getBlockRootClientId(clientId);
|
|
46
|
-
const previousSiblingId = getBlockOrder(parentId)[getBlockIndex(clientId) - 1];
|
|
47
|
-
const previousSibling = getBlock(previousSiblingId);
|
|
48
|
-
const previousSiblingChildren = ((_first = first(previousSibling.innerBlocks)) === null || _first === void 0 ? void 0 : _first.innerBlocks) || [];
|
|
49
|
-
const previousSiblingListAttributes = ((_first2 = first(previousSibling.innerBlocks)) === null || _first2 === void 0 ? void 0 : _first2.attributes) || {};
|
|
50
|
-
const block = getBlock(clientId);
|
|
51
|
-
const childListAttributes = (_first3 = first(block.innerBlocks)) === null || _first3 === void 0 ? void 0 : _first3.attributes;
|
|
52
|
-
const childItemBlocks = ((_first4 = first(block.innerBlocks)) === null || _first4 === void 0 ? void 0 : _first4.innerBlocks) || [];
|
|
53
|
-
const newBlock = createListItem(block.attributes, childListAttributes, childItemBlocks); // Replace the previous sibling of the block being indented and the indented block,
|
|
44
|
+
const selectionEnd = getSelectionEnd(); // Replace the previous sibling of the block being indented and the indented blocks,
|
|
54
45
|
// with a new block whose attributes are equal to the ones of the previous sibling and
|
|
55
|
-
// whose descendants are the children of the previous sibling, followed by the indented
|
|
46
|
+
// whose descendants are the children of the previous sibling, followed by the indented blocks.
|
|
56
47
|
|
|
57
|
-
replaceBlocks([previousSiblingId,
|
|
48
|
+
replaceBlocks([previousSiblingId, ...clientIds], [newListItem]);
|
|
58
49
|
|
|
59
|
-
|
|
50
|
+
if (!_hasMultiSelection) {
|
|
51
|
+
selectionChange(clonedBlocks[0].clientId, selectionEnd.attributeKey, selectionEnd.clientId === selectionStart.clientId ? selectionStart.offset : selectionEnd.offset, selectionEnd.offset);
|
|
52
|
+
} else {
|
|
53
|
+
multiSelect(clonedBlocks[0].clientId, clonedBlocks[clonedBlocks.length - 1].clientId);
|
|
54
|
+
}
|
|
60
55
|
}, [clientId])];
|
|
61
56
|
}
|
|
62
57
|
//# sourceMappingURL=use-indent-list-item.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/use-indent-list-item.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/use-indent-list-item.js"],"names":["useCallback","useSelect","useDispatch","store","blockEditorStore","createBlock","cloneBlock","useIndentListItem","clientId","canIndent","select","getBlockIndex","replaceBlocks","selectionChange","multiSelect","getBlock","getPreviousBlockClientId","getSelectionStart","getSelectionEnd","hasMultiSelection","getMultiSelectedBlockClientIds","_hasMultiSelection","clientIds","clonedBlocks","map","_clientId","previousSiblingId","newListItem","innerBlocks","length","push","selectionStart","selectionEnd","attributeKey","offset"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,QAA4B,oBAA5B;AACA,SAASC,SAAT,EAAoBC,WAApB,QAAuC,iBAAvC;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,WAAT,EAAsBC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EAEED,WAFF,CAEcE,IAFd,CAEoB,GAAGP,YAFvB,EAjBkB,CAqBlB;AACA;;AACA,UAAMQ,cAAc,GAAGd,iBAAiB,EAAxC;AACA,UAAMe,YAAY,GAAGd,eAAe,EAApC,CAxBkB,CAyBlB;AACA;AACA;;AACAN,IAAAA,aAAa,CACZ,CAAEc,iBAAF,EAAqB,GAAGJ,SAAxB,CADY,EAEZ,CAAEK,WAAF,CAFY,CAAb;;AAIA,QAAK,CAAEN,kBAAP,EAA4B;AAC3BR,MAAAA,eAAe,CACdU,YAAY,CAAE,CAAF,CAAZ,CAAkBf,QADJ,EAEdwB,YAAY,CAACC,YAFC,EAGdD,YAAY,CAACxB,QAAb,KAA0BuB,cAAc,CAACvB,QAAzC,GACGuB,cAAc,CAACG,MADlB,GAEGF,YAAY,CAACE,MALF,EAMdF,YAAY,CAACE,MANC,CAAf;AAQA,KATD,MASO;AACNpB,MAAAA,WAAW,CACVS,YAAY,CAAE,CAAF,CAAZ,CAAkBf,QADR,EAEVe,YAAY,CAAEA,YAAY,CAACM,MAAb,GAAsB,CAAxB,CAAZ,CAAwCrB,QAF9B,CAAX;AAIA;AACD,GA/CU,EA+CR,CAAEA,QAAF,CA/CQ,CAFL,CAAP;AAmDA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback } from '@wordpress/element';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { createBlock, cloneBlock } from '@wordpress/blocks';\n\nexport default function useIndentListItem( clientId ) {\n\tconst canIndent = useSelect(\n\t\t( select ) => select( blockEditorStore ).getBlockIndex( clientId ) > 0,\n\t\t[ clientId ]\n\t);\n\tconst { replaceBlocks, selectionChange, multiSelect } = useDispatch(\n\t\tblockEditorStore\n\t);\n\tconst {\n\t\tgetBlock,\n\t\tgetPreviousBlockClientId,\n\t\tgetSelectionStart,\n\t\tgetSelectionEnd,\n\t\thasMultiSelection,\n\t\tgetMultiSelectedBlockClientIds,\n\t} = useSelect( blockEditorStore );\n\treturn [\n\t\tcanIndent,\n\t\tuseCallback( () => {\n\t\t\tconst _hasMultiSelection = hasMultiSelection();\n\t\t\tconst clientIds = _hasMultiSelection\n\t\t\t\t? getMultiSelectedBlockClientIds()\n\t\t\t\t: [ clientId ];\n\t\t\tconst clonedBlocks = clientIds.map( ( _clientId ) =>\n\t\t\t\tcloneBlock( getBlock( _clientId ) )\n\t\t\t);\n\t\t\tconst previousSiblingId = getPreviousBlockClientId( clientId );\n\t\t\tconst newListItem = cloneBlock( getBlock( previousSiblingId ) );\n\t\t\t// If the sibling has no innerBlocks, create a new `list` block.\n\t\t\tif ( ! newListItem.innerBlocks?.length ) {\n\t\t\t\tnewListItem.innerBlocks = [ createBlock( 'core/list' ) ];\n\t\t\t}\n\t\t\t// A list item usually has one `list`, but it's possible to have\n\t\t\t// more. So we need to preserve the previous `list` blocks and\n\t\t\t// merge the new blocks to the last `list`.\n\t\t\tnewListItem.innerBlocks[\n\t\t\t\tnewListItem.innerBlocks.length - 1\n\t\t\t].innerBlocks.push( ...clonedBlocks );\n\n\t\t\t// We get the selection start/end here, because when\n\t\t\t// we replace blocks, the selection is updated too.\n\t\t\tconst selectionStart = getSelectionStart();\n\t\t\tconst selectionEnd = getSelectionEnd();\n\t\t\t// Replace the previous sibling of the block being indented and the indented blocks,\n\t\t\t// with a new block whose attributes are equal to the ones of the previous sibling and\n\t\t\t// whose descendants are the children of the previous sibling, followed by the indented blocks.\n\t\t\treplaceBlocks(\n\t\t\t\t[ previousSiblingId, ...clientIds ],\n\t\t\t\t[ newListItem ]\n\t\t\t);\n\t\t\tif ( ! _hasMultiSelection ) {\n\t\t\t\tselectionChange(\n\t\t\t\t\tclonedBlocks[ 0 ].clientId,\n\t\t\t\t\tselectionEnd.attributeKey,\n\t\t\t\t\tselectionEnd.clientId === selectionStart.clientId\n\t\t\t\t\t\t? selectionStart.offset\n\t\t\t\t\t\t: selectionEnd.offset,\n\t\t\t\t\tselectionEnd.offset\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tmultiSelect(\n\t\t\t\t\tclonedBlocks[ 0 ].clientId,\n\t\t\t\t\tclonedBlocks[ clonedBlocks.length - 1 ].clientId\n\t\t\t\t);\n\t\t\t}\n\t\t}, [ clientId ] ),\n\t];\n}\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useRefEffect } from '@wordpress/compose';
|
|
5
|
+
import { SPACE } from '@wordpress/keycodes';
|
|
6
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
|
+
import { useSelect } from '@wordpress/data';
|
|
8
|
+
/**
|
|
9
|
+
* Internal dependencies
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import useIndentListItem from './use-indent-list-item';
|
|
13
|
+
export default function useSpace(clientId) {
|
|
14
|
+
const {
|
|
15
|
+
getSelectionStart,
|
|
16
|
+
getSelectionEnd
|
|
17
|
+
} = useSelect(blockEditorStore);
|
|
18
|
+
const [canIndent, indentListItem] = useIndentListItem(clientId);
|
|
19
|
+
return useRefEffect(element => {
|
|
20
|
+
function onKeyDown(event) {
|
|
21
|
+
if (event.defaultPrevented || event.keyCode !== SPACE || !canIndent) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
const selectionStart = getSelectionStart();
|
|
26
|
+
const selectionEnd = getSelectionEnd();
|
|
27
|
+
|
|
28
|
+
if (selectionStart.offset === 0 && selectionEnd.offset === 0) {
|
|
29
|
+
event.preventDefault();
|
|
30
|
+
indentListItem();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
element.addEventListener('keydown', onKeyDown);
|
|
35
|
+
return () => {
|
|
36
|
+
element.removeEventListener('keydown', onKeyDown);
|
|
37
|
+
};
|
|
38
|
+
}, [canIndent, indentListItem]);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=use-space.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/use-space.js"],"names":["useRefEffect","SPACE","store","blockEditorStore","useSelect","useIndentListItem","useSpace","clientId","getSelectionStart","getSelectionEnd","canIndent","indentListItem","element","onKeyDown","event","defaultPrevented","keyCode","selectionStart","selectionEnd","offset","preventDefault","addEventListener","removeEventListener"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,YAAT,QAA6B,oBAA7B;AACA,SAASC,KAAT,QAAsB,qBAAtB;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,SAAT,QAA0B,iBAA1B;AAEA;AACA;AACA;;AACA,OAAOC,iBAAP,MAA8B,wBAA9B;AAEA,eAAe,SAASC,QAAT,CAAmBC,QAAnB,EAA8B;AAC5C,QAAM;AAAEC,IAAAA,iBAAF;AAAqBC,IAAAA;AAArB,MAAyCL,SAAS,CACvDD,gBADuD,CAAxD;AAGA,QAAM,CAAEO,SAAF,EAAaC,cAAb,IAAgCN,iBAAiB,CAAEE,QAAF,CAAvD;AAEA,SAAOP,YAAY,CAChBY,OAAF,IAAe;AACd,aAASC,SAAT,CAAoBC,KAApB,EAA4B;AAC3B,UACCA,KAAK,CAACC,gBAAN,IACAD,KAAK,CAACE,OAAN,KAAkBf,KADlB,IAEA,CAAES,SAHH,EAIE;AACD;AACA;;AACD,YAAMO,cAAc,GAAGT,iBAAiB,EAAxC;AACA,YAAMU,YAAY,GAAGT,eAAe,EAApC;;AACA,UACCQ,cAAc,CAACE,MAAf,KAA0B,CAA1B,IACAD,YAAY,CAACC,MAAb,KAAwB,CAFzB,EAGE;AACDL,QAAAA,KAAK,CAACM,cAAN;AACAT,QAAAA,cAAc;AACd;AACD;;AAEDC,IAAAA,OAAO,CAACS,gBAAR,CAA0B,SAA1B,EAAqCR,SAArC;AACA,WAAO,MAAM;AACZD,MAAAA,OAAO,CAACU,mBAAR,CAA6B,SAA7B,EAAwCT,SAAxC;AACA,KAFD;AAGA,GAzBiB,EA0BlB,CAAEH,SAAF,EAAaC,cAAb,CA1BkB,CAAnB;AA4BA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useRefEffect } from '@wordpress/compose';\nimport { SPACE } from '@wordpress/keycodes';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport useIndentListItem from './use-indent-list-item';\n\nexport default function useSpace( clientId ) {\n\tconst { getSelectionStart, getSelectionEnd } = useSelect(\n\t\tblockEditorStore\n\t);\n\tconst [ canIndent, indentListItem ] = useIndentListItem( clientId );\n\n\treturn useRefEffect(\n\t\t( element ) => {\n\t\t\tfunction onKeyDown( event ) {\n\t\t\t\tif (\n\t\t\t\t\tevent.defaultPrevented ||\n\t\t\t\t\tevent.keyCode !== SPACE ||\n\t\t\t\t\t! canIndent\n\t\t\t\t) {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst selectionStart = getSelectionStart();\n\t\t\t\tconst selectionEnd = getSelectionEnd();\n\t\t\t\tif (\n\t\t\t\t\tselectionStart.offset === 0 &&\n\t\t\t\t\tselectionEnd.offset === 0\n\t\t\t\t) {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tindentListItem();\n\t\t\t\t}\n\t\t\t}\n\n\t\t\telement.addEventListener( 'keydown', onKeyDown );\n\t\t\treturn () => {\n\t\t\t\telement.removeEventListener( 'keydown', onKeyDown );\n\t\t\t};\n\t\t},\n\t\t[ canIndent, indentListItem ]\n\t);\n}\n"]}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useCallback, useRef } from '@wordpress/element';
|
|
5
|
+
import { useSelect } from '@wordpress/data';
|
|
6
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
7
|
+
import { cloneBlock, createBlock } from '@wordpress/blocks';
|
|
8
|
+
export default function useSplit(clientId) {
|
|
9
|
+
// We can not rely on the isAfterOriginal parameter of the callback,
|
|
10
|
+
// because if the value after the split is empty isAfterOriginal is false
|
|
11
|
+
// while the value is in fact after the original. So to avoid that issue we use
|
|
12
|
+
// a flag where the first execution of the callback is false (it is the before value)
|
|
13
|
+
// and the second execution is true, it is the after value.
|
|
14
|
+
const isAfter = useRef(false);
|
|
15
|
+
const {
|
|
16
|
+
getBlock
|
|
17
|
+
} = useSelect(blockEditorStore);
|
|
18
|
+
return useCallback(value => {
|
|
19
|
+
const block = getBlock(clientId);
|
|
20
|
+
|
|
21
|
+
if (isAfter.current) {
|
|
22
|
+
return cloneBlock(block, {
|
|
23
|
+
content: value
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
isAfter.current = true;
|
|
28
|
+
return createBlock(block.name, { ...block.attributes,
|
|
29
|
+
content: value
|
|
30
|
+
});
|
|
31
|
+
}, [clientId, getBlock]);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=use-split.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-library/src/list-item/hooks/use-split.js"],"names":["useCallback","useRef","useSelect","store","blockEditorStore","cloneBlock","createBlock","useSplit","clientId","isAfter","getBlock","value","block","current","content","name","attributes"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,MAAtB,QAAoC,oBAApC;AACA,SAASC,SAAT,QAA0B,iBAA1B;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SAASC,UAAT,EAAqBC,WAArB,QAAwC,mBAAxC;AAEA,eAAe,SAASC,QAAT,CAAmBC,QAAnB,EAA8B;AAC5C;AACA;AACA;AACA;AACA;AACA,QAAMC,OAAO,GAAGR,MAAM,CAAE,KAAF,CAAtB;AACA,QAAM;AAAES,IAAAA;AAAF,MAAeR,SAAS,CAAEE,gBAAF,CAA9B;AACA,SAAOJ,WAAW,CACfW,KAAF,IAAa;AACZ,UAAMC,KAAK,GAAGF,QAAQ,CAAEF,QAAF,CAAtB;;AACA,QAAKC,OAAO,CAACI,OAAb,EAAuB;AACtB,aAAOR,UAAU,CAAEO,KAAF,EAAS;AACzBE,QAAAA,OAAO,EAAEH;AADgB,OAAT,CAAjB;AAGA;;AACDF,IAAAA,OAAO,CAACI,OAAR,GAAkB,IAAlB;AACA,WAAOP,WAAW,CAAEM,KAAK,CAACG,IAAR,EAAc,EAC/B,GAAGH,KAAK,CAACI,UADsB;AAE/BF,MAAAA,OAAO,EAAEH;AAFsB,KAAd,CAAlB;AAIA,GAbgB,EAcjB,CAAEH,QAAF,EAAYE,QAAZ,CAdiB,CAAlB;AAgBA","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useCallback, useRef } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { cloneBlock, createBlock } from '@wordpress/blocks';\n\nexport default function useSplit( clientId ) {\n\t// We can not rely on the isAfterOriginal parameter of the callback,\n\t// because if the value after the split is empty isAfterOriginal is false\n\t// while the value is in fact after the original. So to avoid that issue we use\n\t// a flag where the first execution of the callback is false (it is the before value)\n\t// and the second execution is true, it is the after value.\n\tconst isAfter = useRef( false );\n\tconst { getBlock } = useSelect( blockEditorStore );\n\treturn useCallback(\n\t\t( value ) => {\n\t\t\tconst block = getBlock( clientId );\n\t\t\tif ( isAfter.current ) {\n\t\t\t\treturn cloneBlock( block, {\n\t\t\t\t\tcontent: value,\n\t\t\t\t} );\n\t\t\t}\n\t\t\tisAfter.current = true;\n\t\t\treturn createBlock( block.name, {\n\t\t\t\t...block.attributes,\n\t\t\t\tcontent: value,\n\t\t\t} );\n\t\t},\n\t\t[ clientId, getBlock ]\n\t);\n}\n"]}
|