@wordpress/reusable-blocks 4.16.0 → 4.17.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/components/index.js +0 -2
- package/build/components/index.js.map +1 -1
- package/build/components/reusable-blocks-menu-items/index.js +11 -15
- package/build/components/reusable-blocks-menu-items/index.js.map +1 -1
- package/build/components/reusable-blocks-menu-items/index.native.js +0 -2
- package/build/components/reusable-blocks-menu-items/index.native.js.map +1 -1
- package/build/components/reusable-blocks-menu-items/reusable-block-convert-button.js +21 -30
- package/build/components/reusable-blocks-menu-items/reusable-block-convert-button.js.map +1 -1
- package/build/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js +2 -16
- package/build/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js.map +1 -1
- package/build/index.js +0 -3
- package/build/index.js.map +1 -1
- package/build/index.native.js +0 -4
- package/build/index.native.js.map +1 -1
- package/build/lock-unlock.js +1 -2
- package/build/lock-unlock.js.map +1 -1
- package/build/store/actions.js +9 -21
- package/build/store/actions.js.map +1 -1
- package/build/store/index.js +2 -9
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js +3 -6
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js +0 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/reusable-blocks-menu-items/index.js +12 -11
- package/build-module/components/reusable-blocks-menu-items/index.js.map +1 -1
- package/build-module/components/reusable-blocks-menu-items/index.native.js.map +1 -1
- package/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js +24 -22
- package/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js.map +1 -1
- package/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js +4 -11
- package/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js.map +1 -1
- package/build-module/index.js.map +1 -1
- package/build-module/index.native.js.map +1 -1
- package/build-module/lock-unlock.js.map +1 -1
- package/build-module/store/actions.js +10 -12
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/index.js +2 -2
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js +2 -2
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/package.json +14 -13
- package/src/components/reusable-blocks-menu-items/index.js +16 -15
- package/src/components/reusable-blocks-menu-items/reusable-block-convert-button.js +64 -72
- package/src/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js +3 -6
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/reusable-blocks",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.17.0",
|
|
4
4
|
"description": "Reusable blocks utilities.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -28,17 +28,18 @@
|
|
|
28
28
|
"{src,build,build-module}/{index.js,store/index.js}"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@wordpress/
|
|
33
|
-
"@wordpress/
|
|
34
|
-
"@wordpress/
|
|
35
|
-
"@wordpress/data": "^
|
|
36
|
-
"@wordpress/
|
|
37
|
-
"@wordpress/
|
|
38
|
-
"@wordpress/
|
|
39
|
-
"@wordpress/
|
|
40
|
-
"@wordpress/
|
|
41
|
-
"@wordpress/
|
|
31
|
+
"@babel/runtime": "^7.16.0",
|
|
32
|
+
"@wordpress/block-editor": "^12.8.0",
|
|
33
|
+
"@wordpress/blocks": "^12.17.0",
|
|
34
|
+
"@wordpress/components": "^25.6.0",
|
|
35
|
+
"@wordpress/core-data": "^6.17.0",
|
|
36
|
+
"@wordpress/data": "^9.10.0",
|
|
37
|
+
"@wordpress/element": "^5.17.0",
|
|
38
|
+
"@wordpress/i18n": "^4.40.0",
|
|
39
|
+
"@wordpress/icons": "^9.31.0",
|
|
40
|
+
"@wordpress/notices": "^4.8.0",
|
|
41
|
+
"@wordpress/private-apis": "^0.22.0",
|
|
42
|
+
"@wordpress/url": "^3.41.0"
|
|
42
43
|
},
|
|
43
44
|
"peerDependencies": {
|
|
44
45
|
"react": "^18.0.0",
|
|
@@ -47,5 +48,5 @@
|
|
|
47
48
|
"publishConfig": {
|
|
48
49
|
"access": "public"
|
|
49
50
|
},
|
|
50
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "78a288d55b83a713b2f7d98d5a855c0771a2afc6"
|
|
51
52
|
}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
5
|
-
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
4
|
+
import { BlockSettingsMenuControls } from '@wordpress/block-editor';
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
7
|
* Internal dependencies
|
|
@@ -11,20 +10,22 @@ import ReusableBlockConvertButton from './reusable-block-convert-button';
|
|
|
11
10
|
import ReusableBlocksManageButton from './reusable-blocks-manage-button';
|
|
12
11
|
|
|
13
12
|
export default function ReusableBlocksMenuItems( { rootClientId } ) {
|
|
14
|
-
const clientIds = useSelect(
|
|
15
|
-
( select ) => select( blockEditorStore ).getSelectedBlockClientIds(),
|
|
16
|
-
[]
|
|
17
|
-
);
|
|
18
|
-
|
|
19
13
|
return (
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
<BlockSettingsMenuControls>
|
|
15
|
+
{ ( { onClose, selectedClientIds } ) => (
|
|
16
|
+
<>
|
|
17
|
+
<ReusableBlockConvertButton
|
|
18
|
+
clientIds={ selectedClientIds }
|
|
19
|
+
rootClientId={ rootClientId }
|
|
20
|
+
onClose={ onClose }
|
|
21
|
+
/>
|
|
22
|
+
{ selectedClientIds.length === 1 && (
|
|
23
|
+
<ReusableBlocksManageButton
|
|
24
|
+
clientId={ selectedClientIds[ 0 ] }
|
|
25
|
+
/>
|
|
26
|
+
) }
|
|
27
|
+
</>
|
|
27
28
|
) }
|
|
28
|
-
|
|
29
|
+
</BlockSettingsMenuControls>
|
|
29
30
|
);
|
|
30
31
|
}
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { hasBlockSupport, isReusableBlock } from '@wordpress/blocks';
|
|
5
5
|
import {
|
|
6
|
-
BlockSettingsMenuControls,
|
|
7
6
|
store as blockEditorStore,
|
|
8
7
|
privateApis as blockEditorPrivateApis,
|
|
9
8
|
} from '@wordpress/block-editor';
|
|
@@ -35,11 +34,13 @@ import { unlock } from '../../lock-unlock';
|
|
|
35
34
|
* @param {Object} props Component props.
|
|
36
35
|
* @param {string[]} props.clientIds Client ids of selected blocks.
|
|
37
36
|
* @param {string} props.rootClientId ID of the currently selected top-level block.
|
|
37
|
+
* @param {()=>void} props.onClose Callback to close the menu.
|
|
38
38
|
* @return {import('@wordpress/element').WPComponent} The menu control or null.
|
|
39
39
|
*/
|
|
40
40
|
export default function ReusableBlockConvertButton( {
|
|
41
41
|
clientIds,
|
|
42
42
|
rootClientId,
|
|
43
|
+
onClose,
|
|
43
44
|
} ) {
|
|
44
45
|
const { useReusableBlocksRenameHint, ReusableBlocksRenameHint } = unlock(
|
|
45
46
|
blockEditorPrivateApis
|
|
@@ -148,80 +149,71 @@ export default function ReusableBlockConvertButton( {
|
|
|
148
149
|
}
|
|
149
150
|
|
|
150
151
|
return (
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
152
|
+
<>
|
|
153
|
+
<MenuItem icon={ symbol } onClick={ () => setIsModalOpen( true ) }>
|
|
154
|
+
{ showRenameHint
|
|
155
|
+
? __( 'Create pattern/reusable block' )
|
|
156
|
+
: __( 'Create pattern' ) }
|
|
157
|
+
</MenuItem>
|
|
158
|
+
{ isModalOpen && (
|
|
159
|
+
<Modal
|
|
160
|
+
title={ __( 'Create pattern' ) }
|
|
161
|
+
onRequestClose={ () => {
|
|
162
|
+
setIsModalOpen( false );
|
|
163
|
+
setTitle( '' );
|
|
164
|
+
} }
|
|
165
|
+
overlayClassName="reusable-blocks-menu-items__convert-modal"
|
|
166
|
+
>
|
|
167
|
+
<form
|
|
168
|
+
onSubmit={ ( event ) => {
|
|
169
|
+
event.preventDefault();
|
|
170
|
+
onConvert( title );
|
|
171
|
+
setIsModalOpen( false );
|
|
172
|
+
setTitle( '' );
|
|
173
|
+
onClose();
|
|
174
|
+
} }
|
|
157
175
|
>
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
setTitle( '' );
|
|
168
|
-
} }
|
|
169
|
-
overlayClassName="reusable-blocks-menu-items__convert-modal"
|
|
170
|
-
>
|
|
171
|
-
<form
|
|
172
|
-
onSubmit={ ( event ) => {
|
|
173
|
-
event.preventDefault();
|
|
174
|
-
onConvert( title );
|
|
175
|
-
setIsModalOpen( false );
|
|
176
|
-
setTitle( '' );
|
|
177
|
-
onClose();
|
|
178
|
-
} }
|
|
179
|
-
>
|
|
180
|
-
<VStack spacing="5">
|
|
181
|
-
<ReusableBlocksRenameHint />
|
|
182
|
-
<TextControl
|
|
183
|
-
__nextHasNoMarginBottom
|
|
184
|
-
label={ __( 'Name' ) }
|
|
185
|
-
value={ title }
|
|
186
|
-
onChange={ setTitle }
|
|
187
|
-
placeholder={ __( 'My pattern' ) }
|
|
188
|
-
/>
|
|
176
|
+
<VStack spacing="5">
|
|
177
|
+
<ReusableBlocksRenameHint />
|
|
178
|
+
<TextControl
|
|
179
|
+
__nextHasNoMarginBottom
|
|
180
|
+
label={ __( 'Name' ) }
|
|
181
|
+
value={ title }
|
|
182
|
+
onChange={ setTitle }
|
|
183
|
+
placeholder={ __( 'My pattern' ) }
|
|
184
|
+
/>
|
|
189
185
|
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
{ __( 'Cancel' ) }
|
|
213
|
-
</Button>
|
|
186
|
+
<ToggleControl
|
|
187
|
+
label={ __( 'Synced' ) }
|
|
188
|
+
help={ __(
|
|
189
|
+
'Editing the pattern will update it anywhere it is used.'
|
|
190
|
+
) }
|
|
191
|
+
checked={ ! syncType }
|
|
192
|
+
onChange={ () => {
|
|
193
|
+
setSyncType(
|
|
194
|
+
! syncType ? 'unsynced' : undefined
|
|
195
|
+
);
|
|
196
|
+
} }
|
|
197
|
+
/>
|
|
198
|
+
<HStack justify="right">
|
|
199
|
+
<Button
|
|
200
|
+
variant="tertiary"
|
|
201
|
+
onClick={ () => {
|
|
202
|
+
setIsModalOpen( false );
|
|
203
|
+
setTitle( '' );
|
|
204
|
+
} }
|
|
205
|
+
>
|
|
206
|
+
{ __( 'Cancel' ) }
|
|
207
|
+
</Button>
|
|
214
208
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
) }
|
|
223
|
-
</>
|
|
209
|
+
<Button variant="primary" type="submit">
|
|
210
|
+
{ __( 'Create' ) }
|
|
211
|
+
</Button>
|
|
212
|
+
</HStack>
|
|
213
|
+
</VStack>
|
|
214
|
+
</form>
|
|
215
|
+
</Modal>
|
|
224
216
|
) }
|
|
225
|
-
|
|
217
|
+
</>
|
|
226
218
|
);
|
|
227
219
|
}
|
|
@@ -5,10 +5,7 @@ import { MenuItem } from '@wordpress/components';
|
|
|
5
5
|
import { __ } from '@wordpress/i18n';
|
|
6
6
|
import { isReusableBlock } from '@wordpress/blocks';
|
|
7
7
|
import { useSelect, useDispatch } from '@wordpress/data';
|
|
8
|
-
import {
|
|
9
|
-
BlockSettingsMenuControls,
|
|
10
|
-
store as blockEditorStore,
|
|
11
|
-
} from '@wordpress/block-editor';
|
|
8
|
+
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
12
9
|
import { addQueryArgs } from '@wordpress/url';
|
|
13
10
|
import { store as coreStore } from '@wordpress/core-data';
|
|
14
11
|
|
|
@@ -62,7 +59,7 @@ function ReusableBlocksManageButton( { clientId } ) {
|
|
|
62
59
|
}
|
|
63
60
|
|
|
64
61
|
return (
|
|
65
|
-
|
|
62
|
+
<>
|
|
66
63
|
<MenuItem href={ managePatternsUrl }>
|
|
67
64
|
{ __( 'Manage patterns' ) }
|
|
68
65
|
</MenuItem>
|
|
@@ -73,7 +70,7 @@ function ReusableBlocksManageButton( { clientId } ) {
|
|
|
73
70
|
: __( 'Detach pattern' ) }
|
|
74
71
|
</MenuItem>
|
|
75
72
|
) }
|
|
76
|
-
|
|
73
|
+
</>
|
|
77
74
|
);
|
|
78
75
|
}
|
|
79
76
|
|