@wordpress/block-library 7.10.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 +2 -0
- package/build/button/edit.js +2 -1
- package/build/button/edit.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/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 -38
- 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 +6 -1
- 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/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/gallery/edit.js +2 -2
- package/build/gallery/edit.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/group/index.js +1 -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/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 +18 -8
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +27 -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 +8 -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/list/transforms.js +4 -63
- package/build/list/transforms.js.map +1 -1
- package/build/list/v2/transforms.js +0 -27
- 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-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 +86 -50
- 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/save.js +1 -7
- package/build/more/save.js.map +1 -1
- package/build/navigation-link/edit.js +5 -4
- package/build/navigation-link/edit.js.map +1 -1
- package/build/navigation-submenu/edit.js +2 -1
- package/build/navigation-submenu/edit.js.map +1 -1
- package/build/page-list/edit.js +8 -1
- 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 -45
- 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/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/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/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-module/button/edit.js +2 -1
- package/build-module/button/edit.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/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 +6 -1
- 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/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/gallery/edit.js +2 -2
- package/build-module/gallery/edit.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/group/index.js +1 -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/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 +18 -8
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +29 -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 +9 -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/list/transforms.js +4 -63
- package/build-module/list/transforms.js.map +1 -1
- package/build-module/list/v2/transforms.js +2 -29
- 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-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 +82 -46
- 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/save.js +1 -6
- package/build-module/more/save.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-submenu/edit.js +2 -1
- package/build-module/navigation-submenu/edit.js.map +1 -1
- package/build-module/page-list/edit.js +8 -1
- 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 -42
- 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/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/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/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-style/button/style-rtl.css +1 -1
- package/build-style/button/style.css +1 -1
- 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 +1 -0
- package/build-style/{post-comments → comments}/style.css +1 -0
- 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/{post-comments/editor.css → editor-elements-rtl.css} +8 -2
- package/build-style/{post-comments/editor-rtl.css → editor-elements.css} +8 -2
- package/build-style/editor-rtl.css +151 -10
- package/build-style/editor.css +151 -10
- 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/post-comments-form/style-rtl.css +0 -1
- package/build-style/post-comments-form/style.css +0 -1
- 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 +170 -127
- package/build-style/style.css +170 -127
- package/build-style/template-part/editor-rtl.css +14 -3
- package/build-style/template-part/editor.css +14 -3
- package/package.json +28 -28
- package/src/button/edit.js +1 -0
- package/src/button/style.scss +3 -1
- package/src/buttons/edit.js +1 -5
- package/src/columns/edit.native.js +2 -2
- package/src/comments/block.json +6 -1
- 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} +1 -28
- package/src/comments/editor.scss +9 -0
- package/src/comments/index.php +219 -0
- package/src/comments/save.js +8 -7
- package/src/{post-comments → comments}/style.scss +7 -0
- package/src/common.scss +2 -0
- 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/embed/embed-placeholder.native.js +2 -3
- package/src/gallery/edit.js +4 -2
- package/src/gallery/style.scss +10 -1
- package/src/gallery/use-get-media.native.js +44 -0
- package/src/group/block.json +1 -0
- package/src/group/variations.js +2 -2
- 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 +18 -7
- package/src/image/editor.scss +9 -4
- package/src/image/image.js +26 -16
- package/src/image/save.js +10 -1
- package/src/image/style.scss +39 -3
- package/src/index.js +0 -2
- package/src/index.native.js +2 -11
- package/src/list/transforms.js +0 -47
- package/src/list/v2/transforms.js +2 -40
- package/src/list-item/edit.js +10 -12
- package/src/list-item/hooks/index.js +1 -1
- package/src/list-item/hooks/use-merge.js +141 -0
- package/src/list-item/hooks/use-outdent-list-item.js +72 -74
- 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/save.js +3 -6
- package/src/navigation-link/edit.js +4 -3
- package/src/navigation-submenu/edit.js +1 -0
- package/src/page-list/edit.js +9 -0
- package/src/paragraph/edit.js +8 -14
- package/src/post-comments-form/edit.js +2 -71
- package/src/post-comments-form/form.js +80 -5
- package/src/post-comments-form/index.php +1 -1
- package/src/post-comments-form/style.scss +0 -1
- package/src/post-terms/edit.js +3 -2
- package/src/query-no-results/edit.js +2 -5
- 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/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 +4 -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 -2
- 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.php +56 -2
- package/build/comments/edit.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/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-module/comments/edit.js +0 -59
- package/build-module/comments/edit.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/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/src/list-item/hooks/use-backspace.js +0 -51
- 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
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
<?php
|
|
2
|
-
/**
|
|
3
|
-
* Server-side rendering of the `core/post-comments` block.
|
|
4
|
-
*
|
|
5
|
-
* @package WordPress
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Renders the `core/post-comments` block on the server.
|
|
10
|
-
*
|
|
11
|
-
* @param array $attributes Block attributes.
|
|
12
|
-
* @param string $content Block default content.
|
|
13
|
-
* @param WP_Block $block Block instance.
|
|
14
|
-
* @return string Returns the filtered post comments for the current post wrapped inside "p" tags.
|
|
15
|
-
*/
|
|
16
|
-
function render_block_core_post_comments( $attributes, $content, $block ) {
|
|
17
|
-
global $post;
|
|
18
|
-
|
|
19
|
-
$post_id = $block->context['postId'];
|
|
20
|
-
if ( ! isset( $post_id ) ) {
|
|
21
|
-
return '';
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
$comment_args = array(
|
|
25
|
-
'post_id' => $post_id,
|
|
26
|
-
'count' => true,
|
|
27
|
-
);
|
|
28
|
-
// Return early if there are no comments and comments are closed.
|
|
29
|
-
if ( ! comments_open( $post_id ) && get_comments( $comment_args ) === 0 ) {
|
|
30
|
-
return '';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
$post_before = $post;
|
|
34
|
-
$post = get_post( $post_id );
|
|
35
|
-
setup_postdata( $post );
|
|
36
|
-
|
|
37
|
-
ob_start();
|
|
38
|
-
// There's a deprecation warning generated by WP Core.
|
|
39
|
-
// Ideally this deprecation is removed from Core.
|
|
40
|
-
// In the meantime, this removes it from the output.
|
|
41
|
-
add_filter( 'deprecated_file_trigger_error', '__return_false' );
|
|
42
|
-
comments_template();
|
|
43
|
-
remove_filter( 'deprecated_file_trigger_error', '__return_false' );
|
|
44
|
-
$post = $post_before;
|
|
45
|
-
|
|
46
|
-
$classes = '';
|
|
47
|
-
if ( isset( $attributes['textAlign'] ) ) {
|
|
48
|
-
$classes .= 'has-text-align-' . $attributes['textAlign'];
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );
|
|
52
|
-
$output = ob_get_clean();
|
|
53
|
-
|
|
54
|
-
wp_enqueue_script( 'comment-reply' );
|
|
55
|
-
|
|
56
|
-
return sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $output );
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Registers the `core/post-comments` block on the server.
|
|
61
|
-
*/
|
|
62
|
-
function register_block_core_post_comments() {
|
|
63
|
-
register_block_type_from_metadata(
|
|
64
|
-
__DIR__ . '/post-comments',
|
|
65
|
-
array(
|
|
66
|
-
'render_callback' => 'render_block_core_post_comments',
|
|
67
|
-
)
|
|
68
|
-
);
|
|
69
|
-
}
|
|
70
|
-
add_action( 'init', 'register_block_core_post_comments' );
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Use the button block classes for the form-submit button.
|
|
74
|
-
*
|
|
75
|
-
* @param array $fields The default comment form arguments.
|
|
76
|
-
*
|
|
77
|
-
* @return array Returns the modified fields.
|
|
78
|
-
*/
|
|
79
|
-
function post_comments_block_form_defaults( $fields ) {
|
|
80
|
-
if ( wp_is_block_theme() ) {
|
|
81
|
-
$fields['submit_button'] = '<input name="%1$s" type="submit" id="%2$s" class="%3$s wp-block-button__link ' . WP_Theme_JSON_Gutenberg::get_element_class_name( 'button' ) . '" value="%4$s" />';
|
|
82
|
-
$fields['submit_field'] = '<p class="form-submit wp-block-button">%1$s %2$s</p>';
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
return $fields;
|
|
86
|
-
}
|
|
87
|
-
add_filter( 'comment_form_defaults', 'post_comments_block_form_defaults' );
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classnames from 'classnames';
|
|
5
|
-
import { omit } from 'lodash';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* WordPress dependencies
|
|
9
|
-
*/
|
|
10
|
-
import { createBlock, parseWithAttributeSchema } from '@wordpress/blocks';
|
|
11
|
-
import { RichText, useBlockProps } from '@wordpress/block-editor';
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* Internal dependencies
|
|
15
|
-
*/
|
|
16
|
-
import deprecationsForV1Block from '../deprecated';
|
|
17
|
-
|
|
18
|
-
export const migrateToQuoteV2 = ( attributes ) => {
|
|
19
|
-
const { value } = attributes;
|
|
20
|
-
|
|
21
|
-
return [
|
|
22
|
-
{
|
|
23
|
-
...omit( attributes, [ 'value' ] ),
|
|
24
|
-
},
|
|
25
|
-
value
|
|
26
|
-
? parseWithAttributeSchema( value, {
|
|
27
|
-
type: 'array',
|
|
28
|
-
source: 'query',
|
|
29
|
-
selector: 'p',
|
|
30
|
-
query: {
|
|
31
|
-
content: {
|
|
32
|
-
type: 'string',
|
|
33
|
-
source: 'html',
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
} ).map( ( { content } ) =>
|
|
37
|
-
createBlock( 'core/paragraph', { content } )
|
|
38
|
-
)
|
|
39
|
-
: createBlock( 'core/paragraph' ),
|
|
40
|
-
];
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const v3 = {
|
|
44
|
-
attributes: {
|
|
45
|
-
value: {
|
|
46
|
-
type: 'string',
|
|
47
|
-
source: 'html',
|
|
48
|
-
selector: 'blockquote',
|
|
49
|
-
multiline: 'p',
|
|
50
|
-
default: '',
|
|
51
|
-
__experimentalRole: 'content',
|
|
52
|
-
},
|
|
53
|
-
citation: {
|
|
54
|
-
type: 'string',
|
|
55
|
-
source: 'html',
|
|
56
|
-
selector: 'cite',
|
|
57
|
-
default: '',
|
|
58
|
-
__experimentalRole: 'content',
|
|
59
|
-
},
|
|
60
|
-
align: {
|
|
61
|
-
type: 'string',
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
supports: {
|
|
65
|
-
anchor: true,
|
|
66
|
-
__experimentalSlashInserter: true,
|
|
67
|
-
typography: {
|
|
68
|
-
fontSize: true,
|
|
69
|
-
lineHeight: true,
|
|
70
|
-
__experimentalFontStyle: true,
|
|
71
|
-
__experimentalFontWeight: true,
|
|
72
|
-
__experimentalLetterSpacing: true,
|
|
73
|
-
__experimentalTextTransform: true,
|
|
74
|
-
__experimentalDefaultControls: {
|
|
75
|
-
fontSize: true,
|
|
76
|
-
fontAppearance: true,
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
save( { attributes } ) {
|
|
81
|
-
const { align, value, citation } = attributes;
|
|
82
|
-
|
|
83
|
-
const className = classnames( {
|
|
84
|
-
[ `has-text-align-${ align }` ]: align,
|
|
85
|
-
} );
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<blockquote { ...useBlockProps.save( { className } ) }>
|
|
89
|
-
<RichText.Content multiline value={ value } />
|
|
90
|
-
{ ! RichText.isEmpty( citation ) && (
|
|
91
|
-
<RichText.Content tagName="cite" value={ citation } />
|
|
92
|
-
) }
|
|
93
|
-
</blockquote>
|
|
94
|
-
);
|
|
95
|
-
},
|
|
96
|
-
migrate: migrateToQuoteV2,
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* New deprecations need to be placed first
|
|
101
|
-
* for them to have higher priority.
|
|
102
|
-
*
|
|
103
|
-
* Old deprecations may need to be updated as well.
|
|
104
|
-
*
|
|
105
|
-
* See block-deprecation.md
|
|
106
|
-
*/
|
|
107
|
-
export default [ v3, ...deprecationsForV1Block ];
|
package/src/quote/v2/edit.js
DELETED
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classNames from 'classnames';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { __ } from '@wordpress/i18n';
|
|
10
|
-
import {
|
|
11
|
-
AlignmentControl,
|
|
12
|
-
BlockControls,
|
|
13
|
-
RichText,
|
|
14
|
-
useBlockProps,
|
|
15
|
-
useInnerBlocksProps,
|
|
16
|
-
store as blockEditorStore,
|
|
17
|
-
} from '@wordpress/block-editor';
|
|
18
|
-
import { BlockQuotation } from '@wordpress/components';
|
|
19
|
-
import { useDispatch, useSelect, useRegistry } from '@wordpress/data';
|
|
20
|
-
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
|
|
21
|
-
import { Platform, useEffect } from '@wordpress/element';
|
|
22
|
-
import deprecated from '@wordpress/deprecated';
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Internal dependencies
|
|
26
|
-
*/
|
|
27
|
-
import { migrateToQuoteV2 } from './deprecated';
|
|
28
|
-
|
|
29
|
-
const isWebPlatform = Platform.OS === 'web';
|
|
30
|
-
const TEMPLATE = [ [ 'core/paragraph', {} ] ];
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* At the moment, deprecations don't handle create blocks from attributes
|
|
34
|
-
* (like when using CPT templates). For this reason, this hook is necessary
|
|
35
|
-
* to avoid breaking templates using the old quote block format.
|
|
36
|
-
*
|
|
37
|
-
* @param {Object} attributes Block attributes.
|
|
38
|
-
* @param {string} clientId Block client ID.
|
|
39
|
-
*/
|
|
40
|
-
const useMigrateOnLoad = ( attributes, clientId ) => {
|
|
41
|
-
const registry = useRegistry();
|
|
42
|
-
const { updateBlockAttributes, replaceInnerBlocks } =
|
|
43
|
-
useDispatch( blockEditorStore );
|
|
44
|
-
useEffect( () => {
|
|
45
|
-
// As soon as the block is loaded, migrate it to the new version.
|
|
46
|
-
|
|
47
|
-
if ( ! attributes.value ) {
|
|
48
|
-
// No need to migrate if it doesn't have the value attribute.
|
|
49
|
-
return;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const [ newAttributes, newInnerBlocks ] =
|
|
53
|
-
migrateToQuoteV2( attributes );
|
|
54
|
-
|
|
55
|
-
deprecated( 'Value attribute on the quote block', {
|
|
56
|
-
since: '6.0',
|
|
57
|
-
version: '6.5',
|
|
58
|
-
alternative: 'inner blocks',
|
|
59
|
-
} );
|
|
60
|
-
|
|
61
|
-
registry.batch( () => {
|
|
62
|
-
updateBlockAttributes( clientId, newAttributes );
|
|
63
|
-
replaceInnerBlocks( clientId, newInnerBlocks );
|
|
64
|
-
} );
|
|
65
|
-
}, [ attributes.value ] );
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export default function QuoteEdit( {
|
|
69
|
-
attributes,
|
|
70
|
-
setAttributes,
|
|
71
|
-
isSelected,
|
|
72
|
-
insertBlocksAfter,
|
|
73
|
-
clientId,
|
|
74
|
-
className,
|
|
75
|
-
style,
|
|
76
|
-
} ) {
|
|
77
|
-
const { citation, align } = attributes;
|
|
78
|
-
|
|
79
|
-
useMigrateOnLoad( attributes, clientId );
|
|
80
|
-
|
|
81
|
-
const isAncestorOfSelectedBlock = useSelect( ( select ) =>
|
|
82
|
-
select( blockEditorStore ).hasSelectedInnerBlock( clientId )
|
|
83
|
-
);
|
|
84
|
-
const hasSelection = isSelected || isAncestorOfSelectedBlock;
|
|
85
|
-
|
|
86
|
-
const blockProps = useBlockProps( {
|
|
87
|
-
className: classNames( className, {
|
|
88
|
-
[ `has-text-align-${ align }` ]: align,
|
|
89
|
-
} ),
|
|
90
|
-
...( ! isWebPlatform && { style } ),
|
|
91
|
-
} );
|
|
92
|
-
const innerBlocksProps = useInnerBlocksProps( blockProps, {
|
|
93
|
-
template: TEMPLATE,
|
|
94
|
-
templateInsertUpdatesSelection: true,
|
|
95
|
-
} );
|
|
96
|
-
|
|
97
|
-
return (
|
|
98
|
-
<>
|
|
99
|
-
<BlockControls group="block">
|
|
100
|
-
<AlignmentControl
|
|
101
|
-
value={ align }
|
|
102
|
-
onChange={ ( nextAlign ) => {
|
|
103
|
-
setAttributes( { align: nextAlign } );
|
|
104
|
-
} }
|
|
105
|
-
/>
|
|
106
|
-
</BlockControls>
|
|
107
|
-
<BlockQuotation { ...innerBlocksProps }>
|
|
108
|
-
{ innerBlocksProps.children }
|
|
109
|
-
{ ( ! RichText.isEmpty( citation ) || hasSelection ) && (
|
|
110
|
-
<RichText
|
|
111
|
-
identifier="citation"
|
|
112
|
-
tagName={ isWebPlatform ? 'cite' : undefined }
|
|
113
|
-
style={ { display: 'block' } }
|
|
114
|
-
value={ citation }
|
|
115
|
-
onChange={ ( nextCitation ) => {
|
|
116
|
-
setAttributes( {
|
|
117
|
-
citation: nextCitation,
|
|
118
|
-
} );
|
|
119
|
-
} }
|
|
120
|
-
__unstableMobileNoFocusOnMount
|
|
121
|
-
aria-label={ __( 'Quote citation' ) }
|
|
122
|
-
placeholder={
|
|
123
|
-
// translators: placeholder text used for the
|
|
124
|
-
// citation
|
|
125
|
-
__( 'Add citation' )
|
|
126
|
-
}
|
|
127
|
-
className="wp-block-quote__citation"
|
|
128
|
-
__unstableOnSplitAtEnd={ () =>
|
|
129
|
-
insertBlocksAfter(
|
|
130
|
-
createBlock( getDefaultBlockName() )
|
|
131
|
-
)
|
|
132
|
-
}
|
|
133
|
-
{ ...( ! isWebPlatform ? { textAlign: align } : {} ) }
|
|
134
|
-
/>
|
|
135
|
-
) }
|
|
136
|
-
</BlockQuotation>
|
|
137
|
-
</>
|
|
138
|
-
);
|
|
139
|
-
}
|
package/src/quote/v2/index.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import { quote as icon } from '@wordpress/icons';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Internal dependencies
|
|
9
|
-
*/
|
|
10
|
-
import edit from './edit';
|
|
11
|
-
import save from './save';
|
|
12
|
-
import transforms from './transforms';
|
|
13
|
-
import deprecated from './deprecated';
|
|
14
|
-
|
|
15
|
-
const settings = {
|
|
16
|
-
icon,
|
|
17
|
-
example: {
|
|
18
|
-
attributes: {
|
|
19
|
-
citation: 'Julio Cortázar',
|
|
20
|
-
},
|
|
21
|
-
innerBlocks: [
|
|
22
|
-
{
|
|
23
|
-
name: 'core/paragraph',
|
|
24
|
-
attributes: {
|
|
25
|
-
content: __( 'In quoting others, we cite ourselves.' ),
|
|
26
|
-
},
|
|
27
|
-
},
|
|
28
|
-
],
|
|
29
|
-
},
|
|
30
|
-
transforms,
|
|
31
|
-
edit,
|
|
32
|
-
save,
|
|
33
|
-
deprecated,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default settings;
|
package/src/quote/v2/save.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import classNames from 'classnames';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* WordPress dependencies
|
|
8
|
-
*/
|
|
9
|
-
import { InnerBlocks, RichText, useBlockProps } from '@wordpress/block-editor';
|
|
10
|
-
|
|
11
|
-
export default function save( { attributes } ) {
|
|
12
|
-
const { align, citation } = attributes;
|
|
13
|
-
const blockProps = useBlockProps.save( {
|
|
14
|
-
className: classNames( {
|
|
15
|
-
[ `has-text-align-${ align }` ]: align,
|
|
16
|
-
} ),
|
|
17
|
-
} );
|
|
18
|
-
return (
|
|
19
|
-
<blockquote { ...blockProps }>
|
|
20
|
-
<InnerBlocks.Content />
|
|
21
|
-
{ ! RichText.isEmpty( citation ) && (
|
|
22
|
-
<RichText.Content tagName="cite" value={ citation } />
|
|
23
|
-
) }
|
|
24
|
-
</blockquote>
|
|
25
|
-
);
|
|
26
|
-
}
|
|
@@ -1,155 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import {
|
|
5
|
-
createBlock,
|
|
6
|
-
parseWithAttributeSchema,
|
|
7
|
-
rawHandler,
|
|
8
|
-
serialize,
|
|
9
|
-
} from '@wordpress/blocks';
|
|
10
|
-
|
|
11
|
-
const transforms = {
|
|
12
|
-
from: [
|
|
13
|
-
{
|
|
14
|
-
type: 'block',
|
|
15
|
-
blocks: [ 'core/pullquote' ],
|
|
16
|
-
transform: ( { value, citation, anchor, fontSize, style } ) => {
|
|
17
|
-
return createBlock(
|
|
18
|
-
'core/quote',
|
|
19
|
-
{
|
|
20
|
-
citation,
|
|
21
|
-
anchor,
|
|
22
|
-
fontSize,
|
|
23
|
-
style,
|
|
24
|
-
},
|
|
25
|
-
parseWithAttributeSchema( value, {
|
|
26
|
-
type: 'array',
|
|
27
|
-
source: 'query',
|
|
28
|
-
selector: 'p',
|
|
29
|
-
query: {
|
|
30
|
-
content: {
|
|
31
|
-
type: 'string',
|
|
32
|
-
source: 'html',
|
|
33
|
-
},
|
|
34
|
-
},
|
|
35
|
-
} ).map( ( { content } ) =>
|
|
36
|
-
createBlock( 'core/paragraph', { content } )
|
|
37
|
-
)
|
|
38
|
-
);
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
type: 'block',
|
|
43
|
-
blocks: [ 'core/group' ],
|
|
44
|
-
transform: ( { anchor }, innerBlocks ) =>
|
|
45
|
-
createBlock( 'core/quote', { anchor }, innerBlocks ),
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
type: 'prefix',
|
|
49
|
-
prefix: '>',
|
|
50
|
-
transform: ( content ) =>
|
|
51
|
-
createBlock( 'core/quote', {}, [
|
|
52
|
-
createBlock( 'core/paragraph', { content } ),
|
|
53
|
-
] ),
|
|
54
|
-
},
|
|
55
|
-
{
|
|
56
|
-
type: 'raw',
|
|
57
|
-
schema: () => ( {
|
|
58
|
-
blockquote: {
|
|
59
|
-
children: '*',
|
|
60
|
-
},
|
|
61
|
-
} ),
|
|
62
|
-
selector: 'blockquote',
|
|
63
|
-
transform: ( node ) => {
|
|
64
|
-
return createBlock(
|
|
65
|
-
'core/quote',
|
|
66
|
-
// Don't try to parse any `cite` out of this content.
|
|
67
|
-
// * There may be more than one cite.
|
|
68
|
-
// * There may be more attribution text than just the cite.
|
|
69
|
-
// * If the cite is nested in the quoted text, it's wrong to
|
|
70
|
-
// remove it.
|
|
71
|
-
{},
|
|
72
|
-
rawHandler( {
|
|
73
|
-
HTML: node.innerHTML,
|
|
74
|
-
mode: 'BLOCKS',
|
|
75
|
-
} )
|
|
76
|
-
);
|
|
77
|
-
},
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
type: 'block',
|
|
81
|
-
isMultiBlock: true,
|
|
82
|
-
blocks: [ '*' ],
|
|
83
|
-
isMatch: ( {}, blocks ) => {
|
|
84
|
-
return ! blocks.some( ( { name } ) => name === 'core/quote' );
|
|
85
|
-
},
|
|
86
|
-
__experimentalConvert: ( blocks ) =>
|
|
87
|
-
createBlock(
|
|
88
|
-
'core/quote',
|
|
89
|
-
{},
|
|
90
|
-
blocks.map( ( block ) =>
|
|
91
|
-
createBlock(
|
|
92
|
-
block.name,
|
|
93
|
-
block.attributes,
|
|
94
|
-
block.innerBlocks
|
|
95
|
-
)
|
|
96
|
-
)
|
|
97
|
-
),
|
|
98
|
-
},
|
|
99
|
-
],
|
|
100
|
-
to: [
|
|
101
|
-
{
|
|
102
|
-
type: 'block',
|
|
103
|
-
blocks: [ 'core/pullquote' ],
|
|
104
|
-
isMatch: ( {}, block ) => {
|
|
105
|
-
return block.innerBlocks.every(
|
|
106
|
-
( { name } ) => name === 'core/paragraph'
|
|
107
|
-
);
|
|
108
|
-
},
|
|
109
|
-
transform: (
|
|
110
|
-
{ citation, anchor, fontSize, style },
|
|
111
|
-
innerBlocks
|
|
112
|
-
) => {
|
|
113
|
-
return createBlock( 'core/pullquote', {
|
|
114
|
-
value: serialize( innerBlocks ),
|
|
115
|
-
citation,
|
|
116
|
-
anchor,
|
|
117
|
-
fontSize,
|
|
118
|
-
style,
|
|
119
|
-
} );
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
{
|
|
123
|
-
type: 'block',
|
|
124
|
-
blocks: [ 'core/group' ],
|
|
125
|
-
transform: ( { citation, anchor }, innerBlocks ) =>
|
|
126
|
-
createBlock(
|
|
127
|
-
'core/group',
|
|
128
|
-
{ anchor },
|
|
129
|
-
citation
|
|
130
|
-
? [
|
|
131
|
-
...innerBlocks,
|
|
132
|
-
createBlock( 'core/paragraph', {
|
|
133
|
-
content: citation,
|
|
134
|
-
} ),
|
|
135
|
-
]
|
|
136
|
-
: innerBlocks
|
|
137
|
-
),
|
|
138
|
-
},
|
|
139
|
-
{
|
|
140
|
-
type: 'block',
|
|
141
|
-
blocks: [ '*' ],
|
|
142
|
-
transform: ( { citation }, innerBlocks ) =>
|
|
143
|
-
citation
|
|
144
|
-
? [
|
|
145
|
-
...innerBlocks,
|
|
146
|
-
createBlock( 'core/paragraph', {
|
|
147
|
-
content: citation,
|
|
148
|
-
} ),
|
|
149
|
-
]
|
|
150
|
-
: innerBlocks,
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
export default transforms;
|