@wordpress/block-library 8.28.3 → 8.28.4
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/build/button/edit.js +1 -1
- package/build/button/edit.js.map +1 -1
- package/build/buttons/transforms.js +16 -2
- package/build/buttons/transforms.js.map +1 -1
- package/build/code/transforms.js +17 -6
- package/build/code/transforms.js.map +1 -1
- package/build/cover/edit/block-controls.js +14 -3
- package/build/cover/edit/block-controls.js.map +1 -1
- package/build/cover/edit/inspector-controls.js +1 -1
- package/build/cover/edit/inspector-controls.js.map +1 -1
- package/build/heading/transforms.js +17 -4
- package/build/heading/transforms.js.map +1 -1
- package/build/image/edit.js +2 -1
- package/build/image/edit.js.map +1 -1
- package/build/image/image.js +11 -3
- package/build/image/image.js.map +1 -1
- package/build/post-featured-image/edit.js +8 -11
- package/build/post-featured-image/edit.js.map +1 -1
- package/build/post-title/edit.js +2 -2
- package/build/post-title/edit.js.map +1 -1
- package/build/utils/caption.js +15 -5
- package/build/utils/caption.js.map +1 -1
- package/build/utils/get-transformed-metadata.js +57 -0
- package/build/utils/get-transformed-metadata.js.map +1 -0
- package/build-module/button/edit.js +2 -2
- package/build-module/button/edit.js.map +1 -1
- package/build-module/buttons/transforms.js +16 -2
- package/build-module/buttons/transforms.js.map +1 -1
- package/build-module/code/transforms.js +17 -6
- package/build-module/code/transforms.js.map +1 -1
- package/build-module/cover/edit/block-controls.js +15 -4
- package/build-module/cover/edit/block-controls.js.map +1 -1
- package/build-module/cover/edit/inspector-controls.js +1 -1
- package/build-module/cover/edit/inspector-controls.js.map +1 -1
- package/build-module/heading/transforms.js +17 -4
- package/build-module/heading/transforms.js.map +1 -1
- package/build-module/image/edit.js +2 -1
- package/build-module/image/edit.js.map +1 -1
- package/build-module/image/image.js +12 -4
- package/build-module/image/image.js.map +1 -1
- package/build-module/post-featured-image/edit.js +9 -12
- package/build-module/post-featured-image/edit.js.map +1 -1
- package/build-module/post-title/edit.js +2 -2
- package/build-module/post-title/edit.js.map +1 -1
- package/build-module/utils/caption.js +13 -3
- package/build-module/utils/caption.js.map +1 -1
- package/build-module/utils/get-transformed-metadata.js +51 -0
- package/build-module/utils/get-transformed-metadata.js.map +1 -0
- package/build-style/cover/style-rtl.css +2 -1
- package/build-style/cover/style.css +2 -1
- package/build-style/search/style-rtl.css +2 -0
- package/build-style/search/style.css +2 -0
- package/build-style/style-rtl.css +4 -1
- package/build-style/style.css +4 -1
- package/package.json +12 -12
- package/src/button/edit.js +2 -1
- package/src/buttons/transforms.js +14 -4
- package/src/code/transforms.js +20 -5
- package/src/cover/edit/block-controls.js +16 -2
- package/src/cover/edit/inspector-controls.js +5 -1
- package/src/cover/style.scss +3 -2
- package/src/footnotes/index.php +1 -1
- package/src/heading/transforms.js +27 -8
- package/src/image/edit.js +2 -1
- package/src/image/image.js +12 -4
- package/src/navigation/index.php +7 -3
- package/src/post-featured-image/edit.js +9 -11
- package/src/post-title/edit.js +49 -43
- package/src/search/style.scss +2 -0
- package/src/utils/caption.js +10 -1
- package/src/utils/get-transformed-metadata.js +65 -0
package/src/post-title/edit.js
CHANGED
|
@@ -115,53 +115,59 @@ export default function PostTitleEdit( {
|
|
|
115
115
|
return (
|
|
116
116
|
<>
|
|
117
117
|
{ blockEditingMode === 'default' && (
|
|
118
|
-
|
|
119
|
-
<
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
<ToggleControl
|
|
136
|
-
__nextHasNoMarginBottom
|
|
137
|
-
label={ __( 'Make title a link' ) }
|
|
138
|
-
onChange={ () => setAttributes( { isLink: ! isLink } ) }
|
|
139
|
-
checked={ isLink }
|
|
140
|
-
/>
|
|
141
|
-
{ isLink && (
|
|
142
|
-
<>
|
|
118
|
+
<>
|
|
119
|
+
<BlockControls group="block">
|
|
120
|
+
<HeadingLevelDropdown
|
|
121
|
+
value={ level }
|
|
122
|
+
onChange={ ( newLevel ) =>
|
|
123
|
+
setAttributes( { level: newLevel } )
|
|
124
|
+
}
|
|
125
|
+
/>
|
|
126
|
+
<AlignmentControl
|
|
127
|
+
value={ textAlign }
|
|
128
|
+
onChange={ ( nextAlign ) => {
|
|
129
|
+
setAttributes( { textAlign: nextAlign } );
|
|
130
|
+
} }
|
|
131
|
+
/>
|
|
132
|
+
</BlockControls>
|
|
133
|
+
<InspectorControls>
|
|
134
|
+
<PanelBody title={ __( 'Settings' ) }>
|
|
143
135
|
<ToggleControl
|
|
144
136
|
__nextHasNoMarginBottom
|
|
145
|
-
label={ __( '
|
|
146
|
-
onChange={ (
|
|
147
|
-
setAttributes( {
|
|
148
|
-
linkTarget: value ? '_blank' : '_self',
|
|
149
|
-
} )
|
|
137
|
+
label={ __( 'Make title a link' ) }
|
|
138
|
+
onChange={ () =>
|
|
139
|
+
setAttributes( { isLink: ! isLink } )
|
|
150
140
|
}
|
|
151
|
-
checked={
|
|
141
|
+
checked={ isLink }
|
|
152
142
|
/>
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
143
|
+
{ isLink && (
|
|
144
|
+
<>
|
|
145
|
+
<ToggleControl
|
|
146
|
+
__nextHasNoMarginBottom
|
|
147
|
+
label={ __( 'Open in new tab' ) }
|
|
148
|
+
onChange={ ( value ) =>
|
|
149
|
+
setAttributes( {
|
|
150
|
+
linkTarget: value
|
|
151
|
+
? '_blank'
|
|
152
|
+
: '_self',
|
|
153
|
+
} )
|
|
154
|
+
}
|
|
155
|
+
checked={ linkTarget === '_blank' }
|
|
156
|
+
/>
|
|
157
|
+
<TextControl
|
|
158
|
+
__nextHasNoMarginBottom
|
|
159
|
+
label={ __( 'Link rel' ) }
|
|
160
|
+
value={ rel }
|
|
161
|
+
onChange={ ( newRel ) =>
|
|
162
|
+
setAttributes( { rel: newRel } )
|
|
163
|
+
}
|
|
164
|
+
/>
|
|
165
|
+
</>
|
|
166
|
+
) }
|
|
167
|
+
</PanelBody>
|
|
168
|
+
</InspectorControls>
|
|
169
|
+
</>
|
|
170
|
+
) }
|
|
165
171
|
{ titleElement }
|
|
166
172
|
</>
|
|
167
173
|
);
|
package/src/search/style.scss
CHANGED
package/src/utils/caption.js
CHANGED
|
@@ -10,14 +10,21 @@ import { useState, useEffect, useCallback } from '@wordpress/element';
|
|
|
10
10
|
import { usePrevious } from '@wordpress/compose';
|
|
11
11
|
import { __ } from '@wordpress/i18n';
|
|
12
12
|
import {
|
|
13
|
-
RichText,
|
|
14
13
|
BlockControls,
|
|
15
14
|
__experimentalGetElementClassName,
|
|
15
|
+
privateApis as blockEditorPrivateApis,
|
|
16
16
|
} from '@wordpress/block-editor';
|
|
17
17
|
import { ToolbarButton } from '@wordpress/components';
|
|
18
18
|
import { caption as captionIcon } from '@wordpress/icons';
|
|
19
19
|
import { createBlock, getDefaultBlockName } from '@wordpress/blocks';
|
|
20
20
|
|
|
21
|
+
/**
|
|
22
|
+
* Internal dependencies
|
|
23
|
+
*/
|
|
24
|
+
import { unlock } from '../lock-unlock';
|
|
25
|
+
|
|
26
|
+
const { PrivateRichText: RichText } = unlock( blockEditorPrivateApis );
|
|
27
|
+
|
|
21
28
|
export function Caption( {
|
|
22
29
|
key = 'caption',
|
|
23
30
|
attributes,
|
|
@@ -28,6 +35,7 @@ export function Caption( {
|
|
|
28
35
|
label = __( 'Caption text' ),
|
|
29
36
|
showToolbarButton = true,
|
|
30
37
|
className,
|
|
38
|
+
disableEditing,
|
|
31
39
|
} ) {
|
|
32
40
|
const caption = attributes[ key ];
|
|
33
41
|
const prevCaption = usePrevious( caption );
|
|
@@ -101,6 +109,7 @@ export function Caption( {
|
|
|
101
109
|
createBlock( getDefaultBlockName() )
|
|
102
110
|
)
|
|
103
111
|
}
|
|
112
|
+
disableEditing={ disableEditing }
|
|
104
113
|
/>
|
|
105
114
|
) }
|
|
106
115
|
</>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { getBlockType } from '@wordpress/blocks';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Transform the metadata attribute with only the values and bindings specified by each transform.
|
|
8
|
+
* Returns `undefined` if the input metadata is falsy.
|
|
9
|
+
*
|
|
10
|
+
* @param {Object} metadata Original metadata attribute from the block that is being transformed.
|
|
11
|
+
* @param {Object} newBlockName Name of the final block after the transformation.
|
|
12
|
+
* @param {Function} bindingsCallback Optional callback to transform the `bindings` property object.
|
|
13
|
+
* @return {Object|undefined} New metadata object only with the relevant properties.
|
|
14
|
+
*/
|
|
15
|
+
export function getTransformedMetadata(
|
|
16
|
+
metadata,
|
|
17
|
+
newBlockName,
|
|
18
|
+
bindingsCallback
|
|
19
|
+
) {
|
|
20
|
+
if ( ! metadata ) {
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
const { supports } = getBlockType( newBlockName );
|
|
24
|
+
// Fixed until an opt-in mechanism is implemented.
|
|
25
|
+
const BLOCK_BINDINGS_SUPPORTED_BLOCKS = [
|
|
26
|
+
'core/paragraph',
|
|
27
|
+
'core/heading',
|
|
28
|
+
'core/image',
|
|
29
|
+
'core/button',
|
|
30
|
+
];
|
|
31
|
+
// The metadata properties that should be preserved after the transform.
|
|
32
|
+
const transformSupportedProps = [];
|
|
33
|
+
// If it support bindings, and there is a transform bindings callback, add the `id` and `bindings` properties.
|
|
34
|
+
if (
|
|
35
|
+
BLOCK_BINDINGS_SUPPORTED_BLOCKS.includes( newBlockName ) &&
|
|
36
|
+
bindingsCallback
|
|
37
|
+
) {
|
|
38
|
+
transformSupportedProps.push( 'id', 'bindings' );
|
|
39
|
+
}
|
|
40
|
+
// If it support block naming (true by default), add the `name` property.
|
|
41
|
+
if ( supports.renaming !== false ) {
|
|
42
|
+
transformSupportedProps.push( 'name' );
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Return early if no supported properties.
|
|
46
|
+
if ( ! transformSupportedProps.length ) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
const newMetadata = Object.entries( metadata ).reduce(
|
|
51
|
+
( obj, [ prop, value ] ) => {
|
|
52
|
+
// If prop is not supported, don't add it to the new metadata object.
|
|
53
|
+
if ( ! transformSupportedProps.includes( prop ) ) {
|
|
54
|
+
return obj;
|
|
55
|
+
}
|
|
56
|
+
obj[ prop ] =
|
|
57
|
+
prop === 'bindings' ? bindingsCallback( value ) : value;
|
|
58
|
+
return obj;
|
|
59
|
+
},
|
|
60
|
+
{}
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
// Return undefined if object is empty.
|
|
64
|
+
return Object.keys( newMetadata ).length ? newMetadata : undefined;
|
|
65
|
+
}
|