@wordpress/block-library 8.24.0 → 8.25.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/audio/edit.js +7 -52
- package/build/audio/edit.js.map +1 -1
- package/build/audio/edit.native.js +1 -1
- package/build/audio/edit.native.js.map +1 -1
- package/build/audio/index.js +2 -2
- package/build/block/edit.js +102 -11
- package/build/block/edit.js.map +1 -1
- package/build/block/index.js +3 -2
- package/build/block/index.js.map +1 -1
- package/build/block/v1/edit.js +116 -0
- package/build/block/v1/edit.js.map +1 -0
- package/build/block/{edit.native.js → v1/edit.native.js} +2 -2
- package/build/block/v1/edit.native.js.map +1 -0
- package/build/button/index.js +2 -2
- package/build/button/save.js +1 -1
- package/build/button/save.js.map +1 -1
- package/build/code/edit.native.js +13 -14
- package/build/code/edit.native.js.map +1 -1
- package/build/code/index.js +2 -2
- package/build/code/save.js +6 -2
- package/build/code/save.js.map +1 -1
- package/build/details/index.js +2 -2
- package/build/embed/deprecated.js +2 -2
- package/build/embed/embed-preview.native.js +1 -1
- package/build/embed/embed-preview.native.js.map +1 -1
- package/build/embed/icons.js +1 -1
- package/build/embed/icons.js.map +1 -1
- package/build/embed/index.js +2 -2
- package/build/embed/transforms.js +2 -2
- package/build/embed/util.js +2 -2
- package/build/file/edit.js +1 -1
- package/build/file/edit.js.map +1 -1
- package/build/file/edit.native.js +1 -1
- package/build/file/edit.native.js.map +1 -1
- package/build/file/index.js +4 -4
- package/build/file/save.js +4 -1
- package/build/file/save.js.map +1 -1
- package/build/form-input/deprecated.js +147 -0
- package/build/form-input/deprecated.js.map +1 -0
- package/build/form-input/edit.js +1 -1
- package/build/form-input/edit.js.map +1 -1
- package/build/form-input/index.js +4 -2
- package/build/form-input/index.js.map +1 -1
- package/build/form-input/save.js +7 -9
- package/build/form-input/save.js.map +1 -1
- package/build/gallery/edit.js +2 -41
- package/build/gallery/edit.js.map +1 -1
- package/build/gallery/gallery.js +18 -24
- package/build/gallery/gallery.js.map +1 -1
- package/build/gallery/gallery.native.js +1 -1
- package/build/gallery/gallery.native.js.map +1 -1
- package/build/gallery/index.js +4 -4
- package/build/gallery/v1/gallery.native.js +1 -1
- package/build/gallery/v1/gallery.native.js.map +1 -1
- package/build/group/edit.js +6 -1
- package/build/group/edit.js.map +1 -1
- package/build/heading/index.js +3 -6
- package/build/heading/index.js.map +1 -1
- package/build/image/edit.native.js +1 -1
- package/build/image/edit.native.js.map +1 -1
- package/build/image/image.js +14 -51
- package/build/image/image.js.map +1 -1
- package/build/image/index.js +2 -2
- package/build/image/save.js +3 -1
- package/build/image/save.js.map +1 -1
- package/build/list-item/index.js +10 -3
- package/build/list-item/index.js.map +1 -1
- package/build/navigation/edit/index.js +1 -1
- package/build/navigation/edit/index.js.map +1 -1
- package/build/page-list/convert-to-links-modal.js +2 -2
- package/build/page-list/convert-to-links-modal.js.map +1 -1
- package/build/paragraph/edit.js +54 -32
- package/build/paragraph/edit.js.map +1 -1
- package/build/paragraph/index.js +2 -3
- package/build/paragraph/index.js.map +1 -1
- package/build/paragraph/transforms.js +2 -3
- package/build/paragraph/transforms.js.map +1 -1
- package/build/post-title/index.js +1 -3
- package/build/post-title/index.js.map +1 -1
- package/build/preformatted/index.js +2 -3
- package/build/preformatted/index.js.map +1 -1
- package/build/pullquote/index.js +5 -7
- package/build/pullquote/index.js.map +1 -1
- package/build/query/edit/inspector-controls/taxonomy-controls.js +2 -0
- package/build/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build/query-title/index.js +1 -3
- package/build/query-title/index.js.map +1 -1
- package/build/quote/index.js +3 -5
- package/build/quote/index.js.map +1 -1
- package/build/quote/transforms.js +7 -6
- package/build/quote/transforms.js.map +1 -1
- package/build/site-title/index.js +1 -5
- package/build/site-title/index.js.map +1 -1
- package/build/social-link/icons/gravatar.js +22 -0
- package/build/social-link/icons/gravatar.js.map +1 -0
- package/build/social-link/icons/index.js +11 -0
- package/build/social-link/icons/index.js.map +1 -1
- package/build/social-link/variations.js +7 -0
- package/build/social-link/variations.js.map +1 -1
- package/build/table/edit.js +3 -1
- package/build/table/edit.js.map +1 -1
- package/build/table/index.js +9 -10
- package/build/table/index.js.map +1 -1
- package/build/table-of-contents/edit.js +2 -2
- package/build/table-of-contents/edit.js.map +1 -1
- package/build/table-of-contents/index.js +5 -2
- package/build/table-of-contents/index.js.map +1 -1
- package/build/utils/caption.js +90 -0
- package/build/utils/caption.js.map +1 -0
- package/build/utils/remove-anchor-tag.js +2 -1
- package/build/utils/remove-anchor-tag.js.map +1 -1
- package/build/verse/index.js +3 -5
- package/build/verse/index.js.map +1 -1
- package/build/video/deprecated.js +2 -2
- package/build/video/edit.js +8 -52
- package/build/video/edit.js.map +1 -1
- package/build/video/edit.native.js +1 -1
- package/build/video/edit.native.js.map +1 -1
- package/build/video/index.js +2 -2
- package/build-module/audio/edit.js +11 -56
- package/build-module/audio/edit.js.map +1 -1
- package/build-module/audio/edit.native.js +2 -2
- package/build-module/audio/edit.native.js.map +1 -1
- package/build-module/audio/index.js +2 -2
- package/build-module/block/edit.js +104 -13
- package/build-module/block/edit.js.map +1 -1
- package/build-module/block/index.js +3 -2
- package/build-module/block/index.js.map +1 -1
- package/build-module/block/v1/edit.js +108 -0
- package/build-module/block/v1/edit.js.map +1 -0
- package/build-module/block/{edit.native.js → v1/edit.native.js} +2 -2
- package/build-module/block/v1/edit.native.js.map +1 -0
- package/build-module/button/index.js +2 -2
- package/build-module/button/save.js +1 -1
- package/build-module/button/save.js.map +1 -1
- package/build-module/code/edit.native.js +14 -16
- package/build-module/code/edit.native.js.map +1 -1
- package/build-module/code/index.js +2 -2
- package/build-module/code/save.js +6 -2
- package/build-module/code/save.js.map +1 -1
- package/build-module/details/index.js +2 -2
- package/build-module/embed/deprecated.js +2 -2
- package/build-module/embed/embed-preview.native.js +2 -2
- package/build-module/embed/embed-preview.native.js.map +1 -1
- package/build-module/embed/icons.js +1 -1
- package/build-module/embed/icons.js.map +1 -1
- package/build-module/embed/index.js +2 -2
- package/build-module/embed/transforms.js +2 -2
- package/build-module/embed/util.js +2 -2
- package/build-module/file/edit.js +1 -1
- package/build-module/file/edit.js.map +1 -1
- package/build-module/file/edit.native.js +1 -1
- package/build-module/file/edit.native.js.map +1 -1
- package/build-module/file/index.js +4 -4
- package/build-module/file/save.js +4 -1
- package/build-module/file/save.js.map +1 -1
- package/build-module/form-input/deprecated.js +138 -0
- package/build-module/form-input/deprecated.js.map +1 -0
- package/build-module/form-input/edit.js +1 -1
- package/build-module/form-input/edit.js.map +1 -1
- package/build-module/form-input/index.js +4 -2
- package/build-module/form-input/index.js.map +1 -1
- package/build-module/form-input/save.js +8 -10
- package/build-module/form-input/save.js.map +1 -1
- package/build-module/gallery/edit.js +5 -44
- package/build-module/gallery/edit.js.map +1 -1
- package/build-module/gallery/gallery.js +17 -21
- package/build-module/gallery/gallery.js.map +1 -1
- package/build-module/gallery/gallery.native.js +2 -2
- package/build-module/gallery/gallery.native.js.map +1 -1
- package/build-module/gallery/index.js +4 -4
- package/build-module/gallery/v1/gallery.native.js +2 -2
- package/build-module/gallery/v1/gallery.native.js.map +1 -1
- package/build-module/group/edit.js +6 -1
- package/build-module/group/edit.js.map +1 -1
- package/build-module/heading/index.js +3 -6
- package/build-module/heading/index.js.map +1 -1
- package/build-module/image/edit.native.js +2 -2
- package/build-module/image/edit.native.js.map +1 -1
- package/build-module/image/image.js +19 -56
- package/build-module/image/image.js.map +1 -1
- package/build-module/image/index.js +2 -2
- package/build-module/image/save.js +3 -1
- package/build-module/image/save.js.map +1 -1
- package/build-module/list-item/index.js +10 -3
- package/build-module/list-item/index.js.map +1 -1
- package/build-module/navigation/edit/index.js +2 -2
- package/build-module/navigation/edit/index.js.map +1 -1
- package/build-module/page-list/convert-to-links-modal.js +2 -2
- package/build-module/page-list/convert-to-links-modal.js.map +1 -1
- package/build-module/paragraph/edit.js +54 -32
- package/build-module/paragraph/edit.js.map +1 -1
- package/build-module/paragraph/index.js +2 -3
- package/build-module/paragraph/index.js.map +1 -1
- package/build-module/paragraph/transforms.js +2 -3
- package/build-module/paragraph/transforms.js.map +1 -1
- package/build-module/post-title/index.js +1 -3
- package/build-module/post-title/index.js.map +1 -1
- package/build-module/preformatted/index.js +2 -3
- package/build-module/preformatted/index.js.map +1 -1
- package/build-module/pullquote/index.js +5 -7
- package/build-module/pullquote/index.js.map +1 -1
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js +2 -0
- package/build-module/query/edit/inspector-controls/taxonomy-controls.js.map +1 -1
- package/build-module/query-title/index.js +1 -3
- package/build-module/query-title/index.js.map +1 -1
- package/build-module/quote/index.js +3 -5
- package/build-module/quote/index.js.map +1 -1
- package/build-module/quote/transforms.js +7 -6
- package/build-module/quote/transforms.js.map +1 -1
- package/build-module/site-title/index.js +1 -5
- package/build-module/site-title/index.js.map +1 -1
- package/build-module/social-link/icons/gravatar.js +14 -0
- package/build-module/social-link/icons/gravatar.js.map +1 -0
- 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/variations.js +8 -1
- package/build-module/social-link/variations.js.map +1 -1
- package/build-module/table/edit.js +3 -1
- package/build-module/table/edit.js.map +1 -1
- package/build-module/table/index.js +9 -10
- package/build-module/table/index.js.map +1 -1
- package/build-module/table-of-contents/edit.js +1 -1
- package/build-module/table-of-contents/edit.js.map +1 -1
- package/build-module/table-of-contents/index.js +5 -1
- package/build-module/table-of-contents/index.js.map +1 -1
- package/build-module/utils/caption.js +82 -0
- package/build-module/utils/caption.js.map +1 -0
- package/build-module/utils/remove-anchor-tag.js +2 -1
- package/build-module/utils/remove-anchor-tag.js.map +1 -1
- package/build-module/verse/index.js +3 -5
- package/build-module/verse/index.js.map +1 -1
- package/build-module/video/deprecated.js +2 -2
- package/build-module/video/edit.js +13 -57
- package/build-module/video/edit.js.map +1 -1
- package/build-module/video/edit.native.js +2 -2
- package/build-module/video/edit.native.js.map +1 -1
- package/build-module/video/index.js +2 -2
- package/build-style/editor-rtl.css +1 -11
- package/build-style/editor.css +1 -11
- package/build-style/social-links/style-rtl.css +14 -2
- package/build-style/social-links/style.css +14 -2
- package/build-style/style-rtl.css +14 -2
- package/build-style/style.css +14 -2
- package/build-style/table/editor-rtl.css +1 -11
- package/build-style/table/editor.css +1 -11
- package/package.json +32 -32
- package/src/audio/block.json +2 -2
- package/src/audio/edit.js +11 -74
- package/src/audio/edit.native.js +2 -1
- package/src/block/edit.js +143 -16
- package/src/block/index.js +3 -2
- package/src/block/index.php +48 -0
- package/src/block/v1/edit.js +163 -0
- package/src/block/{edit.native.js → v1/edit.native.js} +2 -2
- package/src/button/block.json +2 -2
- package/src/button/save.js +1 -1
- package/src/code/block.json +2 -2
- package/src/code/edit.native.js +11 -13
- package/src/code/save.js +4 -1
- package/src/code/test/edit.native.js +2 -2
- package/src/cover/test/edit.native.js +7 -1
- package/src/details/block.json +2 -2
- package/src/embed/block.json +2 -2
- package/src/embed/embed-preview.native.js +2 -1
- package/src/embed/icons.js +1 -1
- package/src/file/block.json +4 -4
- package/src/file/edit.js +1 -1
- package/src/file/edit.native.js +1 -1
- package/src/file/save.js +5 -1
- package/src/form-input/block.json +2 -2
- package/src/form-input/deprecated.js +142 -0
- package/src/form-input/edit.js +1 -1
- package/src/form-input/index.js +2 -0
- package/src/form-input/save.js +27 -24
- package/src/gallery/block.json +4 -4
- package/src/gallery/edit.js +4 -59
- package/src/gallery/gallery.js +19 -36
- package/src/gallery/gallery.native.js +6 -2
- package/src/gallery/v1/gallery.native.js +2 -1
- package/src/group/edit.js +4 -1
- package/src/heading/block.json +3 -6
- package/src/image/block.json +2 -2
- package/src/image/edit.native.js +2 -3
- package/src/image/image.js +24 -93
- package/src/image/save.js +3 -1
- package/src/list-item/block.json +10 -3
- package/src/navigation/edit/index.js +7 -2
- package/src/navigation/index.php +1 -1
- package/src/navigation-link/test/__snapshots__/hooks.js.snap +6 -3
- package/src/page-list/convert-to-links-modal.js +2 -2
- package/src/paragraph/block.json +2 -3
- package/src/paragraph/edit.js +53 -40
- package/src/post-title/block.json +1 -3
- package/src/preformatted/block.json +2 -3
- package/src/pullquote/block.json +5 -7
- package/src/query/edit/inspector-controls/taxonomy-controls.js +2 -0
- package/src/query-title/block.json +1 -3
- package/src/quote/block.json +3 -5
- package/src/quote/transforms.js +12 -11
- package/src/site-title/block.json +1 -5
- package/src/social-link/icons/gravatar.js +10 -0
- package/src/social-link/icons/index.js +1 -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 +4 -0
- package/src/social-link/variations.js +7 -0
- package/src/social-links/style.scss +14 -8
- package/src/table/block.json +9 -10
- package/src/table/edit.js +3 -1
- package/src/table/editor.scss +1 -14
- package/src/table-of-contents/edit.js +1 -1
- package/src/table-of-contents/index.js +5 -1
- package/src/utils/caption.js +108 -0
- package/src/utils/remove-anchor-tag.js +2 -1
- package/src/verse/block.json +3 -5
- package/src/video/block.json +2 -2
- package/src/video/edit.js +12 -74
- package/src/video/edit.native.js +2 -1
- package/build/block/edit.native.js.map +0 -1
- package/build/table-of-contents/icon.js +0 -22
- package/build/table-of-contents/icon.js.map +0 -1
- package/build-module/block/edit.native.js.map +0 -1
- package/build-module/table-of-contents/icon.js +0 -15
- package/build-module/table-of-contents/icon.js.map +0 -1
- package/src/table-of-contents/icon.js +0 -18
package/src/paragraph/edit.js
CHANGED
|
@@ -49,6 +49,48 @@ function hasDropCapDisabled( align ) {
|
|
|
49
49
|
return align === ( isRTL() ? 'left' : 'right' ) || align === 'center';
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
function DropCapControl( { clientId, attributes, setAttributes } ) {
|
|
53
|
+
// Please do no add a useSelect call to the paragraph block unconditionaly.
|
|
54
|
+
// Every useSelect added to a (frequestly used) block will degrade the load
|
|
55
|
+
// and type bit. By moving it within InspectorControls, the subscription is
|
|
56
|
+
// now only added for the selected block(s).
|
|
57
|
+
const [ isDropCapFeatureEnabled ] = useSettings( 'typography.dropCap' );
|
|
58
|
+
|
|
59
|
+
if ( ! isDropCapFeatureEnabled ) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const { align, dropCap } = attributes;
|
|
64
|
+
|
|
65
|
+
let helpText;
|
|
66
|
+
if ( hasDropCapDisabled( align ) ) {
|
|
67
|
+
helpText = __( 'Not available for aligned text.' );
|
|
68
|
+
} else if ( dropCap ) {
|
|
69
|
+
helpText = __( 'Showing large initial letter.' );
|
|
70
|
+
} else {
|
|
71
|
+
helpText = __( 'Toggle to show a large initial letter.' );
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return (
|
|
75
|
+
<ToolsPanelItem
|
|
76
|
+
hasValue={ () => !! dropCap }
|
|
77
|
+
label={ __( 'Drop cap' ) }
|
|
78
|
+
onDeselect={ () => setAttributes( { dropCap: undefined } ) }
|
|
79
|
+
resetAllFilter={ () => ( { dropCap: undefined } ) }
|
|
80
|
+
panelId={ clientId }
|
|
81
|
+
>
|
|
82
|
+
<ToggleControl
|
|
83
|
+
__nextHasNoMarginBottom
|
|
84
|
+
label={ __( 'Drop cap' ) }
|
|
85
|
+
checked={ !! dropCap }
|
|
86
|
+
onChange={ () => setAttributes( { dropCap: ! dropCap } ) }
|
|
87
|
+
help={ helpText }
|
|
88
|
+
disabled={ hasDropCapDisabled( align ) ? true : false }
|
|
89
|
+
/>
|
|
90
|
+
</ToolsPanelItem>
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
|
|
52
94
|
function ParagraphBlock( {
|
|
53
95
|
attributes,
|
|
54
96
|
mergeBlocks,
|
|
@@ -58,7 +100,6 @@ function ParagraphBlock( {
|
|
|
58
100
|
clientId,
|
|
59
101
|
} ) {
|
|
60
102
|
const { align, content, direction, dropCap, placeholder } = attributes;
|
|
61
|
-
const [ isDropCapFeatureEnabled ] = useSettings( 'typography.dropCap' );
|
|
62
103
|
const blockProps = useBlockProps( {
|
|
63
104
|
ref: useOnEnter( { clientId, content } ),
|
|
64
105
|
className: classnames( {
|
|
@@ -68,15 +109,6 @@ function ParagraphBlock( {
|
|
|
68
109
|
style: { direction },
|
|
69
110
|
} );
|
|
70
111
|
|
|
71
|
-
let helpText;
|
|
72
|
-
if ( hasDropCapDisabled( align ) ) {
|
|
73
|
-
helpText = __( 'Not available for aligned text.' );
|
|
74
|
-
} else if ( dropCap ) {
|
|
75
|
-
helpText = __( 'Showing large initial letter.' );
|
|
76
|
-
} else {
|
|
77
|
-
helpText = __( 'Toggle to show a large initial letter.' );
|
|
78
|
-
}
|
|
79
|
-
|
|
80
112
|
return (
|
|
81
113
|
<>
|
|
82
114
|
<BlockControls group="block">
|
|
@@ -98,32 +130,13 @@ function ParagraphBlock( {
|
|
|
98
130
|
}
|
|
99
131
|
/>
|
|
100
132
|
</BlockControls>
|
|
101
|
-
|
|
102
|
-
<
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
resetAllFilter={ () => ( { dropCap: undefined } ) }
|
|
110
|
-
panelId={ clientId }
|
|
111
|
-
>
|
|
112
|
-
<ToggleControl
|
|
113
|
-
__nextHasNoMarginBottom
|
|
114
|
-
label={ __( 'Drop cap' ) }
|
|
115
|
-
checked={ !! dropCap }
|
|
116
|
-
onChange={ () =>
|
|
117
|
-
setAttributes( { dropCap: ! dropCap } )
|
|
118
|
-
}
|
|
119
|
-
help={ helpText }
|
|
120
|
-
disabled={
|
|
121
|
-
hasDropCapDisabled( align ) ? true : false
|
|
122
|
-
}
|
|
123
|
-
/>
|
|
124
|
-
</ToolsPanelItem>
|
|
125
|
-
</InspectorControls>
|
|
126
|
-
) }
|
|
133
|
+
<InspectorControls group="typography">
|
|
134
|
+
<DropCapControl
|
|
135
|
+
clientId={ clientId }
|
|
136
|
+
attributes={ attributes }
|
|
137
|
+
setAttributes={ setAttributes }
|
|
138
|
+
/>
|
|
139
|
+
</InspectorControls>
|
|
127
140
|
<RichText
|
|
128
141
|
identifier="content"
|
|
129
142
|
tagName="p"
|
|
@@ -154,13 +167,13 @@ function ParagraphBlock( {
|
|
|
154
167
|
onReplace={ onReplace }
|
|
155
168
|
onRemove={ onRemove }
|
|
156
169
|
aria-label={
|
|
157
|
-
content
|
|
158
|
-
? __(
|
|
159
|
-
: __(
|
|
170
|
+
RichText.isEmpty( content )
|
|
171
|
+
? __(
|
|
160
172
|
'Empty block; start writing or type forward slash to choose a block'
|
|
161
173
|
)
|
|
174
|
+
: __( 'Block: Paragraph' )
|
|
162
175
|
}
|
|
163
|
-
data-empty={ content
|
|
176
|
+
data-empty={ RichText.isEmpty( content ) }
|
|
164
177
|
placeholder={ placeholder || __( 'Type / to choose a block' ) }
|
|
165
178
|
data-custom-placeholder={ placeholder ? true : undefined }
|
|
166
179
|
__unstableEmbedURLOnPaste
|
|
@@ -8,10 +8,9 @@
|
|
|
8
8
|
"textdomain": "default",
|
|
9
9
|
"attributes": {
|
|
10
10
|
"content": {
|
|
11
|
-
"type": "
|
|
12
|
-
"source": "
|
|
11
|
+
"type": "rich-text",
|
|
12
|
+
"source": "rich-text",
|
|
13
13
|
"selector": "pre",
|
|
14
|
-
"default": "",
|
|
15
14
|
"__unstablePreserveWhiteSpace": true,
|
|
16
15
|
"__experimentalRole": "content"
|
|
17
16
|
}
|
package/src/pullquote/block.json
CHANGED
|
@@ -8,16 +8,15 @@
|
|
|
8
8
|
"textdomain": "default",
|
|
9
9
|
"attributes": {
|
|
10
10
|
"value": {
|
|
11
|
-
"type": "
|
|
12
|
-
"source": "
|
|
11
|
+
"type": "rich-text",
|
|
12
|
+
"source": "rich-text",
|
|
13
13
|
"selector": "p",
|
|
14
14
|
"__experimentalRole": "content"
|
|
15
15
|
},
|
|
16
16
|
"citation": {
|
|
17
|
-
"type": "
|
|
18
|
-
"source": "
|
|
17
|
+
"type": "rich-text",
|
|
18
|
+
"source": "rich-text",
|
|
19
19
|
"selector": "cite",
|
|
20
|
-
"default": "",
|
|
21
20
|
"__experimentalRole": "content"
|
|
22
21
|
},
|
|
23
22
|
"textAlign": {
|
|
@@ -46,8 +45,7 @@
|
|
|
46
45
|
"__experimentalTextDecoration": true,
|
|
47
46
|
"__experimentalLetterSpacing": true,
|
|
48
47
|
"__experimentalDefaultControls": {
|
|
49
|
-
"fontSize": true
|
|
50
|
-
"fontAppearance": true
|
|
48
|
+
"fontSize": true
|
|
51
49
|
}
|
|
52
50
|
},
|
|
53
51
|
"__experimentalBorder": {
|
|
@@ -6,6 +6,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
6
6
|
import { store as coreStore } from '@wordpress/core-data';
|
|
7
7
|
import { useState, useEffect } from '@wordpress/element';
|
|
8
8
|
import { useDebounce } from '@wordpress/compose';
|
|
9
|
+
import { decodeEntities } from '@wordpress/html-entities';
|
|
9
10
|
|
|
10
11
|
/**
|
|
11
12
|
* Internal dependencies
|
|
@@ -177,6 +178,7 @@ function TaxonomyItem( { taxonomy, termIds, onChange } ) {
|
|
|
177
178
|
value={ value }
|
|
178
179
|
onInputChange={ debouncedSearch }
|
|
179
180
|
suggestions={ suggestions }
|
|
181
|
+
displayTransform={ decodeEntities }
|
|
180
182
|
onChange={ onTermsChange }
|
|
181
183
|
__experimentalShowHowTo={ false }
|
|
182
184
|
/>
|
package/src/quote/block.json
CHANGED
|
@@ -17,10 +17,9 @@
|
|
|
17
17
|
"__experimentalRole": "content"
|
|
18
18
|
},
|
|
19
19
|
"citation": {
|
|
20
|
-
"type": "
|
|
21
|
-
"source": "
|
|
20
|
+
"type": "rich-text",
|
|
21
|
+
"source": "rich-text",
|
|
22
22
|
"selector": "cite",
|
|
23
|
-
"default": "",
|
|
24
23
|
"__experimentalRole": "content"
|
|
25
24
|
},
|
|
26
25
|
"align": {
|
|
@@ -42,8 +41,7 @@
|
|
|
42
41
|
"__experimentalTextDecoration": true,
|
|
43
42
|
"__experimentalLetterSpacing": true,
|
|
44
43
|
"__experimentalDefaultControls": {
|
|
45
|
-
"fontSize": true
|
|
46
|
-
"fontAppearance": true
|
|
44
|
+
"fontSize": true
|
|
47
45
|
}
|
|
48
46
|
},
|
|
49
47
|
"color": {
|
package/src/quote/transforms.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
+
import { RichText } from '@wordpress/block-editor';
|
|
4
5
|
import { createBlock } from '@wordpress/blocks';
|
|
5
6
|
|
|
6
7
|
const transforms = {
|
|
@@ -113,14 +114,14 @@ const transforms = {
|
|
|
113
114
|
type: 'block',
|
|
114
115
|
blocks: [ 'core/paragraph' ],
|
|
115
116
|
transform: ( { citation }, innerBlocks ) =>
|
|
116
|
-
citation
|
|
117
|
-
?
|
|
117
|
+
RichText.isEmpty( citation )
|
|
118
|
+
? innerBlocks
|
|
119
|
+
: [
|
|
118
120
|
...innerBlocks,
|
|
119
121
|
createBlock( 'core/paragraph', {
|
|
120
122
|
content: citation,
|
|
121
123
|
} ),
|
|
122
|
-
]
|
|
123
|
-
: innerBlocks,
|
|
124
|
+
],
|
|
124
125
|
},
|
|
125
126
|
{
|
|
126
127
|
type: 'block',
|
|
@@ -129,26 +130,26 @@ const transforms = {
|
|
|
129
130
|
createBlock(
|
|
130
131
|
'core/group',
|
|
131
132
|
{ anchor },
|
|
132
|
-
citation
|
|
133
|
-
?
|
|
133
|
+
RichText.isEmpty( citation )
|
|
134
|
+
? innerBlocks
|
|
135
|
+
: [
|
|
134
136
|
...innerBlocks,
|
|
135
137
|
createBlock( 'core/paragraph', {
|
|
136
138
|
content: citation,
|
|
137
139
|
} ),
|
|
138
140
|
]
|
|
139
|
-
: innerBlocks
|
|
140
141
|
),
|
|
141
142
|
},
|
|
142
143
|
],
|
|
143
144
|
ungroup: ( { citation }, innerBlocks ) =>
|
|
144
|
-
citation
|
|
145
|
-
?
|
|
145
|
+
RichText.isEmpty( citation )
|
|
146
|
+
? innerBlocks
|
|
147
|
+
: [
|
|
146
148
|
...innerBlocks,
|
|
147
149
|
createBlock( 'core/paragraph', {
|
|
148
150
|
content: citation,
|
|
149
151
|
} ),
|
|
150
|
-
]
|
|
151
|
-
: innerBlocks,
|
|
152
|
+
],
|
|
152
153
|
};
|
|
153
154
|
|
|
154
155
|
export default transforms;
|
|
@@ -56,11 +56,7 @@
|
|
|
56
56
|
"__experimentalFontWeight": true,
|
|
57
57
|
"__experimentalLetterSpacing": true,
|
|
58
58
|
"__experimentalDefaultControls": {
|
|
59
|
-
"fontSize": true
|
|
60
|
-
"lineHeight": true,
|
|
61
|
-
"fontAppearance": true,
|
|
62
|
-
"letterSpacing": true,
|
|
63
|
-
"textTransform": true
|
|
59
|
+
"fontSize": true
|
|
64
60
|
}
|
|
65
61
|
}
|
|
66
62
|
},
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { Path, SVG } from '@wordpress/primitives';
|
|
5
|
+
|
|
6
|
+
export const GravatarIcon = () => (
|
|
7
|
+
<SVG width="24" height="24" viewBox="0 0 24 24" version="1.1">
|
|
8
|
+
<Path d="M10.8001 4.69937V10.6494C10.8001 11.1001 10.9791 11.5323 11.2978 11.851C11.6165 12.1697 12.0487 12.3487 12.4994 12.3487C12.9501 12.3487 13.3824 12.1697 13.7011 11.851C14.0198 11.5323 14.1988 11.1001 14.1988 10.6494V6.69089C15.2418 7.05861 16.1371 7.75537 16.7496 8.67617C17.3622 9.59698 17.6589 10.6919 17.595 11.796C17.5311 12.9001 17.1101 13.9535 16.3954 14.7975C15.6807 15.6415 14.711 16.2303 13.6325 16.4753C12.5541 16.7202 11.4252 16.608 10.4161 16.1555C9.40691 15.703 8.57217 14.9348 8.03763 13.9667C7.50308 12.9985 7.29769 11.8828 7.45242 10.7877C7.60714 9.69266 8.11359 8.67755 8.89545 7.89537C9.20904 7.57521 9.38364 7.14426 9.38132 6.69611C9.37899 6.24797 9.19994 5.81884 8.88305 5.50195C8.56616 5.18506 8.13704 5.00601 7.68889 5.00369C7.24075 5.00137 6.80979 5.17597 6.48964 5.48956C5.09907 6.8801 4.23369 8.7098 4.04094 10.6669C3.84819 12.624 4.34 14.5873 5.43257 16.2224C6.52515 17.8575 8.15088 19.0632 10.0328 19.634C11.9146 20.2049 13.9362 20.1055 15.753 19.3529C17.5699 18.6003 19.0695 17.241 19.9965 15.5066C20.9234 13.7722 21.2203 11.7701 20.8366 9.84133C20.4528 7.91259 19.4122 6.17658 17.892 4.92911C16.3717 3.68163 14.466 2.99987 12.4994 3C12.0487 3 11.6165 3.17904 11.2978 3.49773C10.9791 3.81643 10.8001 4.24867 10.8001 4.69937Z" />
|
|
9
|
+
</SVG>
|
|
10
|
+
);
|
|
@@ -194,6 +194,10 @@ function block_core_social_link_services( $service = '', $field = '' ) {
|
|
|
194
194
|
'name' => 'GitHub',
|
|
195
195
|
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"></path></svg>',
|
|
196
196
|
),
|
|
197
|
+
'gravatar' => array(
|
|
198
|
+
'name' => 'Gravatar',
|
|
199
|
+
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M10.8001 4.69937V10.6494C10.8001 11.1001 10.9791 11.5323 11.2978 11.851C11.6165 12.1697 12.0487 12.3487 12.4994 12.3487C12.9501 12.3487 13.3824 12.1697 13.7011 11.851C14.0198 11.5323 14.1988 11.1001 14.1988 10.6494V6.69089C15.2418 7.05861 16.1371 7.75537 16.7496 8.67617C17.3622 9.59698 17.6589 10.6919 17.595 11.796C17.5311 12.9001 17.1101 13.9535 16.3954 14.7975C15.6807 15.6415 14.711 16.2303 13.6325 16.4753C12.5541 16.7202 11.4252 16.608 10.4161 16.1555C9.40691 15.703 8.57217 14.9348 8.03763 13.9667C7.50308 12.9985 7.29769 11.8828 7.45242 10.7877C7.60714 9.69266 8.11359 8.67755 8.89545 7.89537C9.20904 7.57521 9.38364 7.14426 9.38132 6.69611C9.37899 6.24797 9.19994 5.81884 8.88305 5.50195C8.56616 5.18506 8.13704 5.00601 7.68889 5.00369C7.24075 5.00137 6.80979 5.17597 6.48964 5.48956C5.09907 6.8801 4.23369 8.7098 4.04094 10.6669C3.84819 12.624 4.34 14.5873 5.43257 16.2224C6.52515 17.8575 8.15088 19.0632 10.0328 19.634C11.9146 20.2049 13.9362 20.1055 15.753 19.3529C17.5699 18.6003 19.0695 17.241 19.9965 15.5066C20.9234 13.7722 21.2203 11.7701 20.8366 9.84133C20.4528 7.91259 19.4122 6.17658 17.892 4.92911C16.3717 3.68163 14.466 2.99987 12.4994 3C12.0487 3 11.6165 3.17904 11.2978 3.49773C10.9791 3.81643 10.8001 4.24867 10.8001 4.69937Z" /></svg>',
|
|
200
|
+
),
|
|
197
201
|
'instagram' => array(
|
|
198
202
|
'name' => 'Instagram',
|
|
199
203
|
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,4.622c2.403,0,2.688,0.009,3.637,0.052c0.877,0.04,1.354,0.187,1.671,0.31c0.42,0.163,0.72,0.358,1.035,0.673 c0.315,0.315,0.51,0.615,0.673,1.035c0.123,0.317,0.27,0.794,0.31,1.671c0.043,0.949,0.052,1.234,0.052,3.637 s-0.009,2.688-0.052,3.637c-0.04,0.877-0.187,1.354-0.31,1.671c-0.163,0.42-0.358,0.72-0.673,1.035 c-0.315,0.315-0.615,0.51-1.035,0.673c-0.317,0.123-0.794,0.27-1.671,0.31c-0.949,0.043-1.233,0.052-3.637,0.052 s-2.688-0.009-3.637-0.052c-0.877-0.04-1.354-0.187-1.671-0.31c-0.42-0.163-0.72-0.358-1.035-0.673 c-0.315-0.315-0.51-0.615-0.673-1.035c-0.123-0.317-0.27-0.794-0.31-1.671C4.631,14.688,4.622,14.403,4.622,12 s0.009-2.688,0.052-3.637c0.04-0.877,0.187-1.354,0.31-1.671c0.163-0.42,0.358-0.72,0.673-1.035 c0.315-0.315,0.615-0.51,1.035-0.673c0.317-0.123,0.794-0.27,1.671-0.31C9.312,4.631,9.597,4.622,12,4.622 M12,3 C9.556,3,9.249,3.01,8.289,3.054C7.331,3.098,6.677,3.25,6.105,3.472C5.513,3.702,5.011,4.01,4.511,4.511 c-0.5,0.5-0.808,1.002-1.038,1.594C3.25,6.677,3.098,7.331,3.054,8.289C3.01,9.249,3,9.556,3,12c0,2.444,0.01,2.751,0.054,3.711 c0.044,0.958,0.196,1.612,0.418,2.185c0.23,0.592,0.538,1.094,1.038,1.594c0.5,0.5,1.002,0.808,1.594,1.038 c0.572,0.222,1.227,0.375,2.185,0.418C9.249,20.99,9.556,21,12,21s2.751-0.01,3.711-0.054c0.958-0.044,1.612-0.196,2.185-0.418 c0.592-0.23,1.094-0.538,1.594-1.038c0.5-0.5,0.808-1.002,1.038-1.594c0.222-0.572,0.375-1.227,0.418-2.185 C20.99,14.751,21,14.444,21,12s-0.01-2.751-0.054-3.711c-0.044-0.958-0.196-1.612-0.418-2.185c-0.23-0.592-0.538-1.094-1.038-1.594 c-0.5-0.5-1.002-0.808-1.594-1.038c-0.572-0.222-1.227-0.375-2.185-0.418C14.751,3.01,14.444,3,12,3L12,3z M12,7.378 c-2.552,0-4.622,2.069-4.622,4.622S9.448,16.622,12,16.622s4.622-2.069,4.622-4.622S14.552,7.378,12,7.378z M12,15 c-1.657,0-3-1.343-3-3s1.343-3,3-3s3,1.343,3,3S13.657,15,12,15z M16.804,6.116c-0.596,0-1.08,0.484-1.08,1.08 s0.484,1.08,1.08,1.08c0.596,0,1.08-0.484,1.08-1.08S17.401,6.116,16.804,6.116z"></path></svg>',
|
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
GoodreadsIcon,
|
|
20
20
|
GoogleIcon,
|
|
21
21
|
GitHubIcon,
|
|
22
|
+
GravatarIcon,
|
|
22
23
|
InstagramIcon,
|
|
23
24
|
LastfmIcon,
|
|
24
25
|
LinkedInIcon,
|
|
@@ -160,6 +161,12 @@ const variations = [
|
|
|
160
161
|
title: 'GitHub',
|
|
161
162
|
icon: GitHubIcon,
|
|
162
163
|
},
|
|
164
|
+
{
|
|
165
|
+
name: 'gravatar',
|
|
166
|
+
attributes: { service: 'gravatar' },
|
|
167
|
+
title: 'Gravatar',
|
|
168
|
+
icon: GravatarIcon,
|
|
169
|
+
},
|
|
163
170
|
{
|
|
164
171
|
name: 'instagram',
|
|
165
172
|
attributes: { service: 'instagram' },
|
|
@@ -95,14 +95,20 @@
|
|
|
95
95
|
}
|
|
96
96
|
|
|
97
97
|
// This needs specificity because themes usually override it with things like .widget-area a.
|
|
98
|
-
.wp-block-social-links .wp-block-social-link
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
98
|
+
.wp-block-social-links .wp-block-social-link.wp-social-link {
|
|
99
|
+
display: inline-block;
|
|
100
|
+
margin: 0;
|
|
101
|
+
padding: 0;
|
|
102
|
+
|
|
103
|
+
.wp-block-social-link-anchor {
|
|
104
|
+
&,
|
|
105
|
+
&:hover,
|
|
106
|
+
&:active,
|
|
107
|
+
&:visited,
|
|
108
|
+
svg {
|
|
109
|
+
color: currentColor;
|
|
110
|
+
fill: currentColor;
|
|
111
|
+
}
|
|
106
112
|
}
|
|
107
113
|
}
|
|
108
114
|
|
package/src/table/block.json
CHANGED
|
@@ -12,10 +12,9 @@
|
|
|
12
12
|
"default": false
|
|
13
13
|
},
|
|
14
14
|
"caption": {
|
|
15
|
-
"type": "
|
|
16
|
-
"source": "
|
|
17
|
-
"selector": "figcaption"
|
|
18
|
-
"default": ""
|
|
15
|
+
"type": "rich-text",
|
|
16
|
+
"source": "rich-text",
|
|
17
|
+
"selector": "figcaption"
|
|
19
18
|
},
|
|
20
19
|
"head": {
|
|
21
20
|
"type": "array",
|
|
@@ -30,8 +29,8 @@
|
|
|
30
29
|
"selector": "td,th",
|
|
31
30
|
"query": {
|
|
32
31
|
"content": {
|
|
33
|
-
"type": "
|
|
34
|
-
"source": "
|
|
32
|
+
"type": "rich-text",
|
|
33
|
+
"source": "rich-text"
|
|
35
34
|
},
|
|
36
35
|
"tag": {
|
|
37
36
|
"type": "string",
|
|
@@ -75,8 +74,8 @@
|
|
|
75
74
|
"selector": "td,th",
|
|
76
75
|
"query": {
|
|
77
76
|
"content": {
|
|
78
|
-
"type": "
|
|
79
|
-
"source": "
|
|
77
|
+
"type": "rich-text",
|
|
78
|
+
"source": "rich-text"
|
|
80
79
|
},
|
|
81
80
|
"tag": {
|
|
82
81
|
"type": "string",
|
|
@@ -120,8 +119,8 @@
|
|
|
120
119
|
"selector": "td,th",
|
|
121
120
|
"query": {
|
|
122
121
|
"content": {
|
|
123
|
-
"type": "
|
|
124
|
-
"source": "
|
|
122
|
+
"type": "rich-text",
|
|
123
|
+
"source": "rich-text"
|
|
125
124
|
},
|
|
126
125
|
"tag": {
|
|
127
126
|
"type": "string",
|
package/src/table/edit.js
CHANGED
|
@@ -555,6 +555,7 @@ function TableEdit( {
|
|
|
555
555
|
>
|
|
556
556
|
<TextControl
|
|
557
557
|
__nextHasNoMarginBottom
|
|
558
|
+
__next40pxDefaultSize
|
|
558
559
|
type="number"
|
|
559
560
|
label={ __( 'Column count' ) }
|
|
560
561
|
value={ initialColumnCount }
|
|
@@ -564,6 +565,7 @@ function TableEdit( {
|
|
|
564
565
|
/>
|
|
565
566
|
<TextControl
|
|
566
567
|
__nextHasNoMarginBottom
|
|
568
|
+
__next40pxDefaultSize
|
|
567
569
|
type="number"
|
|
568
570
|
label={ __( 'Row count' ) }
|
|
569
571
|
value={ initialRowCount }
|
|
@@ -572,7 +574,7 @@ function TableEdit( {
|
|
|
572
574
|
className="blocks-table__placeholder-input"
|
|
573
575
|
/>
|
|
574
576
|
<Button
|
|
575
|
-
|
|
577
|
+
__next40pxDefaultSize
|
|
576
578
|
variant="primary"
|
|
577
579
|
type="submit"
|
|
578
580
|
>
|
package/src/table/editor.scss
CHANGED
|
@@ -58,27 +58,14 @@
|
|
|
58
58
|
display: flex;
|
|
59
59
|
flex-direction: column;
|
|
60
60
|
align-items: flex-start;
|
|
61
|
-
|
|
62
|
-
> * {
|
|
63
|
-
margin-bottom: $grid-unit-10;
|
|
64
|
-
}
|
|
61
|
+
gap: $grid-unit-10;
|
|
65
62
|
|
|
66
63
|
@include break-medium() {
|
|
67
64
|
flex-direction: row;
|
|
68
65
|
align-items: flex-end;
|
|
69
|
-
|
|
70
|
-
> * {
|
|
71
|
-
margin-bottom: 0;
|
|
72
|
-
}
|
|
73
66
|
}
|
|
74
67
|
}
|
|
75
68
|
|
|
76
69
|
.blocks-table__placeholder-input {
|
|
77
70
|
width: $grid-unit-10 * 14;
|
|
78
|
-
margin-right: $grid-unit-10;
|
|
79
|
-
margin-bottom: 0;
|
|
80
|
-
|
|
81
|
-
input {
|
|
82
|
-
height: $button-size;
|
|
83
|
-
}
|
|
84
71
|
}
|
|
@@ -21,11 +21,11 @@ import { renderToString } from '@wordpress/element';
|
|
|
21
21
|
import { __ } from '@wordpress/i18n';
|
|
22
22
|
import { useInstanceId } from '@wordpress/compose';
|
|
23
23
|
import { store as noticeStore } from '@wordpress/notices';
|
|
24
|
+
import { tableOfContents as icon } from '@wordpress/icons';
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
27
|
* Internal dependencies
|
|
27
28
|
*/
|
|
28
|
-
import icon from './icon';
|
|
29
29
|
import TableOfContentsList from './list';
|
|
30
30
|
import { linearToNestedHeadingList } from './utils';
|
|
31
31
|
import { useObserveHeadings } from './hooks';
|
|
@@ -1,10 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { tableOfContents as icon } from '@wordpress/icons';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* Internal dependencies
|
|
3
8
|
*/
|
|
4
9
|
import initBlock from '../utils/init-block';
|
|
5
10
|
import metadata from './block.json';
|
|
6
11
|
import edit from './edit';
|
|
7
|
-
import icon from './icon';
|
|
8
12
|
import save from './save';
|
|
9
13
|
|
|
10
14
|
const { name } = metadata;
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External dependencies
|
|
3
|
+
*/
|
|
4
|
+
import classnames from 'classnames';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* WordPress dependencies
|
|
8
|
+
*/
|
|
9
|
+
import { useState, useEffect, useCallback } from '@wordpress/element';
|
|
10
|
+
import { usePrevious } from '@wordpress/compose';
|
|
11
|
+
import { __ } from '@wordpress/i18n';
|
|
12
|
+
import {
|
|
13
|
+
RichText,
|
|
14
|
+
BlockControls,
|
|
15
|
+
__experimentalGetElementClassName,
|
|
16
|
+
} from '@wordpress/block-editor';
|
|
17
|
+
import { ToolbarButton } from '@wordpress/components';
|
|
18
|
+
import { caption as captionIcon } from '@wordpress/icons';
|
|
19
|
+
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
|
|
20
|
+
|
|
21
|
+
export function Caption( {
|
|
22
|
+
key = 'caption',
|
|
23
|
+
attributes,
|
|
24
|
+
setAttributes,
|
|
25
|
+
isSelected,
|
|
26
|
+
insertBlocksAfter,
|
|
27
|
+
placeholder = __( 'Add caption' ),
|
|
28
|
+
label = __( 'Caption text' ),
|
|
29
|
+
showToolbarButton = true,
|
|
30
|
+
className,
|
|
31
|
+
} ) {
|
|
32
|
+
const caption = attributes[ key ];
|
|
33
|
+
const prevCaption = usePrevious( caption );
|
|
34
|
+
const isCaptionEmpty = RichText.isEmpty( caption );
|
|
35
|
+
const isPrevCaptionEmpty = RichText.isEmpty( prevCaption );
|
|
36
|
+
const [ showCaption, setShowCaption ] = useState( ! isCaptionEmpty );
|
|
37
|
+
|
|
38
|
+
// We need to show the caption when changes come from
|
|
39
|
+
// history navigation(undo/redo).
|
|
40
|
+
useEffect( () => {
|
|
41
|
+
if ( ! isCaptionEmpty && isPrevCaptionEmpty ) {
|
|
42
|
+
setShowCaption( true );
|
|
43
|
+
}
|
|
44
|
+
}, [ isCaptionEmpty, isPrevCaptionEmpty ] );
|
|
45
|
+
|
|
46
|
+
useEffect( () => {
|
|
47
|
+
if ( ! isSelected && isCaptionEmpty ) {
|
|
48
|
+
setShowCaption( false );
|
|
49
|
+
}
|
|
50
|
+
}, [ isSelected, isCaptionEmpty ] );
|
|
51
|
+
|
|
52
|
+
// Focus the caption when we click to add one.
|
|
53
|
+
const ref = useCallback(
|
|
54
|
+
( node ) => {
|
|
55
|
+
if ( node && isCaptionEmpty ) {
|
|
56
|
+
node.focus();
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
[ isCaptionEmpty ]
|
|
60
|
+
);
|
|
61
|
+
return (
|
|
62
|
+
<>
|
|
63
|
+
{ showToolbarButton && (
|
|
64
|
+
<BlockControls group="block">
|
|
65
|
+
<ToolbarButton
|
|
66
|
+
onClick={ () => {
|
|
67
|
+
setShowCaption( ! showCaption );
|
|
68
|
+
if ( showCaption && caption ) {
|
|
69
|
+
setAttributes( { caption: undefined } );
|
|
70
|
+
}
|
|
71
|
+
} }
|
|
72
|
+
icon={ captionIcon }
|
|
73
|
+
isPressed={ showCaption }
|
|
74
|
+
label={
|
|
75
|
+
showCaption
|
|
76
|
+
? __( 'Remove caption' )
|
|
77
|
+
: __( 'Add caption' )
|
|
78
|
+
}
|
|
79
|
+
/>
|
|
80
|
+
</BlockControls>
|
|
81
|
+
) }
|
|
82
|
+
{ showCaption &&
|
|
83
|
+
( ! RichText.isEmpty( caption ) || isSelected ) && (
|
|
84
|
+
<RichText
|
|
85
|
+
identifier={ key }
|
|
86
|
+
tagName="figcaption"
|
|
87
|
+
className={ classnames(
|
|
88
|
+
className,
|
|
89
|
+
__experimentalGetElementClassName( 'caption' )
|
|
90
|
+
) }
|
|
91
|
+
ref={ ref }
|
|
92
|
+
aria-label={ label }
|
|
93
|
+
placeholder={ placeholder }
|
|
94
|
+
value={ caption }
|
|
95
|
+
onChange={ ( value ) =>
|
|
96
|
+
setAttributes( { caption: value } )
|
|
97
|
+
}
|
|
98
|
+
inlineToolbar
|
|
99
|
+
__unstableOnSplitAtEnd={ () =>
|
|
100
|
+
insertBlocksAfter(
|
|
101
|
+
createBlock( getDefaultBlockName() )
|
|
102
|
+
)
|
|
103
|
+
}
|
|
104
|
+
/>
|
|
105
|
+
) }
|
|
106
|
+
</>
|
|
107
|
+
);
|
|
108
|
+
}
|