@wordpress/patterns 1.16.0 → 1.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/api/index.js +1 -1
- package/build/api/index.js.map +1 -1
- package/build/components/allow-overrides-modal.js +114 -0
- package/build/components/allow-overrides-modal.js.map +1 -0
- package/build/components/category-selector.js.map +1 -1
- package/build/components/create-pattern-modal.js.map +1 -1
- package/build/components/duplicate-pattern-modal.js.map +1 -1
- package/build/components/index.js.map +1 -1
- package/build/components/overrides-panel.js.map +1 -1
- package/build/components/pattern-convert-button.js.map +1 -1
- package/build/components/pattern-overrides-controls.js +107 -0
- package/build/components/pattern-overrides-controls.js.map +1 -0
- package/build/components/patterns-manage-button.js.map +1 -1
- package/build/components/rename-pattern-category-modal.js.map +1 -1
- package/build/components/rename-pattern-modal.js.map +1 -1
- package/build/components/reset-overrides-control.js.map +1 -1
- package/build/constants.js +2 -1
- package/build/constants.js.map +1 -1
- package/build/index.js.map +1 -1
- package/build/index.native.js.map +1 -1
- package/build/lock-unlock.js.map +1 -1
- package/build/private-apis.js +3 -3
- package/build/private-apis.js.map +1 -1
- package/build/private-hooks.js.map +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/constants.js.map +1 -1
- package/build/store/index.js +1 -1
- package/build/store/index.js.map +1 -1
- package/build/store/reducer.js.map +1 -1
- package/build/store/selectors.js.map +1 -1
- package/build-module/api/index.js +1 -1
- package/build-module/api/index.js.map +1 -1
- package/build-module/components/allow-overrides-modal.js +106 -0
- package/build-module/components/allow-overrides-modal.js.map +1 -0
- package/build-module/components/category-selector.js.map +1 -1
- package/build-module/components/create-pattern-modal.js.map +1 -1
- package/build-module/components/duplicate-pattern-modal.js.map +1 -1
- package/build-module/components/index.js.map +1 -1
- package/build-module/components/overrides-panel.js.map +1 -1
- package/build-module/components/pattern-convert-button.js.map +1 -1
- package/build-module/components/pattern-overrides-controls.js +100 -0
- package/build-module/components/pattern-overrides-controls.js.map +1 -0
- package/build-module/components/patterns-manage-button.js.map +1 -1
- package/build-module/components/rename-pattern-category-modal.js.map +1 -1
- package/build-module/components/rename-pattern-modal.js.map +1 -1
- package/build-module/components/reset-overrides-control.js.map +1 -1
- package/build-module/constants.js +1 -0
- package/build-module/constants.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/private-apis.js +2 -2
- package/build-module/private-apis.js.map +1 -1
- package/build-module/private-hooks.js.map +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/constants.js.map +1 -1
- package/build-module/store/index.js.map +1 -1
- package/build-module/store/reducer.js.map +1 -1
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +6 -1
- package/build-style/style.css +6 -1
- package/package.json +16 -16
- package/src/api/index.js +1 -0
- package/src/components/allow-overrides-modal.js +149 -0
- package/src/components/pattern-overrides-controls.js +145 -0
- package/src/components/style.scss +6 -0
- package/src/constants.js +2 -0
- package/src/private-apis.js +2 -2
- package/build/components/use-set-pattern-bindings.js +0 -103
- package/build/components/use-set-pattern-bindings.js.map +0 -1
- package/build-module/components/use-set-pattern-bindings.js +0 -96
- package/build-module/components/use-set-pattern-bindings.js.map +0 -1
- package/src/components/use-set-pattern-bindings.js +0 -120
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/patterns",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Management of user pattern editing.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -31,20 +31,20 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "^7.16.0",
|
|
34
|
-
"@wordpress/a11y": "^3.
|
|
35
|
-
"@wordpress/block-editor": "^12.
|
|
36
|
-
"@wordpress/blocks": "^12.
|
|
37
|
-
"@wordpress/components": "^27.
|
|
38
|
-
"@wordpress/compose": "^6.
|
|
39
|
-
"@wordpress/core-data": "^6.
|
|
40
|
-
"@wordpress/data": "^9.
|
|
41
|
-
"@wordpress/element": "^5.
|
|
42
|
-
"@wordpress/html-entities": "^3.
|
|
43
|
-
"@wordpress/i18n": "^4.
|
|
44
|
-
"@wordpress/icons": "^9.
|
|
45
|
-
"@wordpress/notices": "^4.
|
|
46
|
-
"@wordpress/private-apis": "^0.
|
|
47
|
-
"@wordpress/url": "^3.
|
|
34
|
+
"@wordpress/a11y": "^3.56.0",
|
|
35
|
+
"@wordpress/block-editor": "^12.24.0",
|
|
36
|
+
"@wordpress/blocks": "^12.33.0",
|
|
37
|
+
"@wordpress/components": "^27.4.0",
|
|
38
|
+
"@wordpress/compose": "^6.33.0",
|
|
39
|
+
"@wordpress/core-data": "^6.33.0",
|
|
40
|
+
"@wordpress/data": "^9.26.0",
|
|
41
|
+
"@wordpress/element": "^5.33.0",
|
|
42
|
+
"@wordpress/html-entities": "^3.56.0",
|
|
43
|
+
"@wordpress/i18n": "^4.56.0",
|
|
44
|
+
"@wordpress/icons": "^9.47.0",
|
|
45
|
+
"@wordpress/notices": "^4.24.0",
|
|
46
|
+
"@wordpress/private-apis": "^0.38.0",
|
|
47
|
+
"@wordpress/url": "^3.57.0"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
50
|
"react": "^18.0.0",
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"publishConfig": {
|
|
54
54
|
"access": "public"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "280403b4c1cf6cc2c55a6c4d56f9ef91145e4191"
|
|
57
57
|
}
|
package/src/api/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export function isOverridableBlock( block ) {
|
|
|
15
15
|
Object.keys( PARTIAL_SYNCING_SUPPORTED_BLOCKS ).includes(
|
|
16
16
|
block.name
|
|
17
17
|
) &&
|
|
18
|
+
!! block.attributes.metadata?.name &&
|
|
18
19
|
!! block.attributes.metadata?.bindings &&
|
|
19
20
|
Object.values( block.attributes.metadata.bindings ).some(
|
|
20
21
|
( binding ) => binding.source === 'core/pattern-overrides'
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import {
|
|
5
|
+
__experimentalHStack as HStack,
|
|
6
|
+
__experimentalVStack as VStack,
|
|
7
|
+
Button,
|
|
8
|
+
__experimentalText as Text,
|
|
9
|
+
TextControl,
|
|
10
|
+
Modal,
|
|
11
|
+
} from '@wordpress/components';
|
|
12
|
+
import { __, sprintf } from '@wordpress/i18n';
|
|
13
|
+
import { useState, useId } from '@wordpress/element';
|
|
14
|
+
import { speak } from '@wordpress/a11y';
|
|
15
|
+
|
|
16
|
+
export function AllowOverridesModal( {
|
|
17
|
+
placeholder,
|
|
18
|
+
initialName = '',
|
|
19
|
+
onClose,
|
|
20
|
+
onSave,
|
|
21
|
+
} ) {
|
|
22
|
+
const [ editedBlockName, setEditedBlockName ] = useState( initialName );
|
|
23
|
+
const descriptionId = useId();
|
|
24
|
+
|
|
25
|
+
const isNameValid = !! editedBlockName.trim();
|
|
26
|
+
|
|
27
|
+
const handleSubmit = () => {
|
|
28
|
+
if ( editedBlockName !== initialName ) {
|
|
29
|
+
const message = sprintf(
|
|
30
|
+
/* translators: %s: new name/label for the block */
|
|
31
|
+
__( 'Block name changed to: "%s".' ),
|
|
32
|
+
editedBlockName
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
// Must be assertive to immediately announce change.
|
|
36
|
+
speak( message, 'assertive' );
|
|
37
|
+
}
|
|
38
|
+
onSave( editedBlockName );
|
|
39
|
+
|
|
40
|
+
// Immediate close avoids ability to hit save multiple times.
|
|
41
|
+
onClose();
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<Modal
|
|
46
|
+
title={ __( 'Enable overrides' ) }
|
|
47
|
+
onRequestClose={ onClose }
|
|
48
|
+
focusOnMount="firstContentElement"
|
|
49
|
+
aria={ { describedby: descriptionId } }
|
|
50
|
+
size="small"
|
|
51
|
+
>
|
|
52
|
+
<form
|
|
53
|
+
onSubmit={ ( event ) => {
|
|
54
|
+
event.preventDefault();
|
|
55
|
+
|
|
56
|
+
if ( ! isNameValid ) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
handleSubmit();
|
|
61
|
+
} }
|
|
62
|
+
>
|
|
63
|
+
<VStack spacing="6">
|
|
64
|
+
<Text id={ descriptionId }>
|
|
65
|
+
{ __(
|
|
66
|
+
'Overrides are changes you make to a block within a synced pattern instance. Use overrides to customize a synced pattern instance to suit its new context. Name this block to specify an override.'
|
|
67
|
+
) }
|
|
68
|
+
</Text>
|
|
69
|
+
<TextControl
|
|
70
|
+
__nextHasNoMarginBottom
|
|
71
|
+
__next40pxDefaultSize
|
|
72
|
+
value={ editedBlockName }
|
|
73
|
+
label={ __( 'Name' ) }
|
|
74
|
+
help={ __(
|
|
75
|
+
'For example, if you are creating a recipe pattern, you use "Recipe Title", "Recipe Description", etc.'
|
|
76
|
+
) }
|
|
77
|
+
placeholder={ placeholder }
|
|
78
|
+
onChange={ setEditedBlockName }
|
|
79
|
+
/>
|
|
80
|
+
<HStack justify="right">
|
|
81
|
+
<Button
|
|
82
|
+
__next40pxDefaultSize
|
|
83
|
+
variant="tertiary"
|
|
84
|
+
onClick={ onClose }
|
|
85
|
+
>
|
|
86
|
+
{ __( 'Cancel' ) }
|
|
87
|
+
</Button>
|
|
88
|
+
|
|
89
|
+
<Button
|
|
90
|
+
__next40pxDefaultSize
|
|
91
|
+
aria-disabled={ ! isNameValid }
|
|
92
|
+
variant="primary"
|
|
93
|
+
type="submit"
|
|
94
|
+
>
|
|
95
|
+
{ __( 'Enable' ) }
|
|
96
|
+
</Button>
|
|
97
|
+
</HStack>
|
|
98
|
+
</VStack>
|
|
99
|
+
</form>
|
|
100
|
+
</Modal>
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function DisallowOverridesModal( { onClose, onSave } ) {
|
|
105
|
+
const descriptionId = useId();
|
|
106
|
+
|
|
107
|
+
return (
|
|
108
|
+
<Modal
|
|
109
|
+
title={ __( 'Disable overrides' ) }
|
|
110
|
+
onRequestClose={ onClose }
|
|
111
|
+
aria={ { describedby: descriptionId } }
|
|
112
|
+
size="small"
|
|
113
|
+
>
|
|
114
|
+
<form
|
|
115
|
+
onSubmit={ ( event ) => {
|
|
116
|
+
event.preventDefault();
|
|
117
|
+
onSave();
|
|
118
|
+
onClose();
|
|
119
|
+
} }
|
|
120
|
+
>
|
|
121
|
+
<VStack spacing="6">
|
|
122
|
+
<Text id={ descriptionId }>
|
|
123
|
+
{ __(
|
|
124
|
+
'Are you sure you want to disable overrides? Disabling overrides will revert all applied overrides for this block throughout instances of this pattern.'
|
|
125
|
+
) }
|
|
126
|
+
</Text>
|
|
127
|
+
|
|
128
|
+
<HStack justify="right">
|
|
129
|
+
<Button
|
|
130
|
+
__next40pxDefaultSize
|
|
131
|
+
variant="tertiary"
|
|
132
|
+
onClick={ onClose }
|
|
133
|
+
>
|
|
134
|
+
{ __( 'Cancel' ) }
|
|
135
|
+
</Button>
|
|
136
|
+
|
|
137
|
+
<Button
|
|
138
|
+
__next40pxDefaultSize
|
|
139
|
+
variant="primary"
|
|
140
|
+
type="submit"
|
|
141
|
+
>
|
|
142
|
+
{ __( 'Disable' ) }
|
|
143
|
+
</Button>
|
|
144
|
+
</HStack>
|
|
145
|
+
</VStack>
|
|
146
|
+
</form>
|
|
147
|
+
</Modal>
|
|
148
|
+
);
|
|
149
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WordPress dependencies
|
|
3
|
+
*/
|
|
4
|
+
import { useState, useId } from '@wordpress/element';
|
|
5
|
+
import { InspectorControls } from '@wordpress/block-editor';
|
|
6
|
+
import { BaseControl, Button } from '@wordpress/components';
|
|
7
|
+
import { __ } from '@wordpress/i18n';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Internal dependencies
|
|
11
|
+
*/
|
|
12
|
+
import {
|
|
13
|
+
PARTIAL_SYNCING_SUPPORTED_BLOCKS,
|
|
14
|
+
PATTERN_OVERRIDES_BINDING_SOURCE,
|
|
15
|
+
} from '../constants';
|
|
16
|
+
import {
|
|
17
|
+
AllowOverridesModal,
|
|
18
|
+
DisallowOverridesModal,
|
|
19
|
+
} from './allow-overrides-modal';
|
|
20
|
+
|
|
21
|
+
function removeBindings( bindings, syncedAttributes ) {
|
|
22
|
+
let updatedBindings = {};
|
|
23
|
+
for ( const attributeName of syncedAttributes ) {
|
|
24
|
+
// Omit any bindings that's not the same source from the `updatedBindings` object.
|
|
25
|
+
if (
|
|
26
|
+
bindings?.[ attributeName ]?.source !==
|
|
27
|
+
PATTERN_OVERRIDES_BINDING_SOURCE &&
|
|
28
|
+
bindings?.[ attributeName ]?.source !== undefined
|
|
29
|
+
) {
|
|
30
|
+
updatedBindings[ attributeName ] = bindings[ attributeName ];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if ( ! Object.keys( updatedBindings ).length ) {
|
|
34
|
+
updatedBindings = undefined;
|
|
35
|
+
}
|
|
36
|
+
return updatedBindings;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function addBindings( bindings, syncedAttributes ) {
|
|
40
|
+
const updatedBindings = { ...bindings };
|
|
41
|
+
for ( const attributeName of syncedAttributes ) {
|
|
42
|
+
if ( ! bindings?.[ attributeName ] ) {
|
|
43
|
+
updatedBindings[ attributeName ] = {
|
|
44
|
+
source: PATTERN_OVERRIDES_BINDING_SOURCE,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return updatedBindings;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function PatternOverridesControls( { attributes, name, setAttributes } ) {
|
|
52
|
+
const controlId = useId();
|
|
53
|
+
const [ showAllowOverridesModal, setShowAllowOverridesModal ] =
|
|
54
|
+
useState( false );
|
|
55
|
+
const [ showDisallowOverridesModal, setShowDisallowOverridesModal ] =
|
|
56
|
+
useState( false );
|
|
57
|
+
|
|
58
|
+
const syncedAttributes = PARTIAL_SYNCING_SUPPORTED_BLOCKS[ name ];
|
|
59
|
+
const attributeSources = syncedAttributes.map(
|
|
60
|
+
( attributeName ) =>
|
|
61
|
+
attributes.metadata?.bindings?.[ attributeName ]?.source
|
|
62
|
+
);
|
|
63
|
+
const isConnectedToOtherSources = attributeSources.every(
|
|
64
|
+
( source ) => source && source !== 'core/pattern-overrides'
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
function updateBindings( isChecked, customName ) {
|
|
68
|
+
const prevBindings = attributes?.metadata?.bindings;
|
|
69
|
+
const updatedBindings = isChecked
|
|
70
|
+
? addBindings( prevBindings, syncedAttributes )
|
|
71
|
+
: removeBindings( prevBindings, syncedAttributes );
|
|
72
|
+
|
|
73
|
+
const updatedMetadata = {
|
|
74
|
+
...attributes.metadata,
|
|
75
|
+
bindings: updatedBindings,
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
if ( customName ) {
|
|
79
|
+
updatedMetadata.name = customName;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
setAttributes( {
|
|
83
|
+
metadata: updatedMetadata,
|
|
84
|
+
} );
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
// Avoid overwriting other (e.g. meta) bindings.
|
|
88
|
+
if ( isConnectedToOtherSources ) return null;
|
|
89
|
+
|
|
90
|
+
const hasName = !! attributes.metadata?.name;
|
|
91
|
+
const allowOverrides =
|
|
92
|
+
hasName &&
|
|
93
|
+
attributeSources.some(
|
|
94
|
+
( source ) => source === PATTERN_OVERRIDES_BINDING_SOURCE
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
return (
|
|
98
|
+
<>
|
|
99
|
+
<InspectorControls group="advanced">
|
|
100
|
+
<BaseControl
|
|
101
|
+
id={ controlId }
|
|
102
|
+
label={ __( 'Overrides' ) }
|
|
103
|
+
help={ __(
|
|
104
|
+
'Allow changes to this block throughout instances of this pattern.'
|
|
105
|
+
) }
|
|
106
|
+
>
|
|
107
|
+
<Button
|
|
108
|
+
__next40pxDefaultSize
|
|
109
|
+
className="pattern-overrides-control__allow-overrides-button"
|
|
110
|
+
variant="secondary"
|
|
111
|
+
onClick={ () => {
|
|
112
|
+
if ( allowOverrides ) {
|
|
113
|
+
setShowDisallowOverridesModal( true );
|
|
114
|
+
} else {
|
|
115
|
+
setShowAllowOverridesModal( true );
|
|
116
|
+
}
|
|
117
|
+
} }
|
|
118
|
+
>
|
|
119
|
+
{ allowOverrides
|
|
120
|
+
? __( 'Disable overrides' )
|
|
121
|
+
: __( 'Enable overrides' ) }
|
|
122
|
+
</Button>
|
|
123
|
+
</BaseControl>
|
|
124
|
+
</InspectorControls>
|
|
125
|
+
|
|
126
|
+
{ showAllowOverridesModal && (
|
|
127
|
+
<AllowOverridesModal
|
|
128
|
+
initialName={ attributes.metadata?.name }
|
|
129
|
+
onClose={ () => setShowAllowOverridesModal( false ) }
|
|
130
|
+
onSave={ ( newName ) => {
|
|
131
|
+
updateBindings( true, newName );
|
|
132
|
+
} }
|
|
133
|
+
/>
|
|
134
|
+
) }
|
|
135
|
+
{ showDisallowOverridesModal && (
|
|
136
|
+
<DisallowOverridesModal
|
|
137
|
+
onClose={ () => setShowDisallowOverridesModal( false ) }
|
|
138
|
+
onSave={ () => updateBindings( false ) }
|
|
139
|
+
/>
|
|
140
|
+
) }
|
|
141
|
+
</>
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export default PatternOverridesControls;
|
package/src/constants.js
CHANGED
package/src/private-apis.js
CHANGED
|
@@ -15,7 +15,7 @@ import { isOverridableBlock } from './api';
|
|
|
15
15
|
import RenamePatternModal from './components/rename-pattern-modal';
|
|
16
16
|
import PatternsMenuItems from './components';
|
|
17
17
|
import RenamePatternCategoryModal from './components/rename-pattern-category-modal';
|
|
18
|
-
import
|
|
18
|
+
import PatternOverridesControls from './components/pattern-overrides-controls';
|
|
19
19
|
import ResetOverridesControl from './components/reset-overrides-control';
|
|
20
20
|
import { useAddPatternCategory } from './private-hooks';
|
|
21
21
|
import {
|
|
@@ -38,7 +38,7 @@ lock( privateApis, {
|
|
|
38
38
|
RenamePatternModal,
|
|
39
39
|
PatternsMenuItems,
|
|
40
40
|
RenamePatternCategoryModal,
|
|
41
|
-
|
|
41
|
+
PatternOverridesControls,
|
|
42
42
|
ResetOverridesControl,
|
|
43
43
|
useAddPatternCategory,
|
|
44
44
|
PATTERN_TYPES,
|
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = useSetPatternBindings;
|
|
7
|
-
var _compose = require("@wordpress/compose");
|
|
8
|
-
var _blocks = require("@wordpress/blocks");
|
|
9
|
-
var _element = require("@wordpress/element");
|
|
10
|
-
var _data = require("@wordpress/data");
|
|
11
|
-
var _constants = require("../constants");
|
|
12
|
-
var _lockUnlock = require("../lock-unlock");
|
|
13
|
-
/**
|
|
14
|
-
* WordPress dependencies
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Internal dependencies
|
|
19
|
-
*/
|
|
20
|
-
|
|
21
|
-
function removeBindings(bindings, syncedAttributes) {
|
|
22
|
-
let updatedBindings = {};
|
|
23
|
-
for (const attributeName of syncedAttributes) {
|
|
24
|
-
// Omit any pattern override bindings from the `updatedBindings` object.
|
|
25
|
-
if (bindings?.[attributeName]?.source !== 'core/pattern-overrides' && bindings?.[attributeName]?.source !== undefined) {
|
|
26
|
-
updatedBindings[attributeName] = bindings[attributeName];
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
if (!Object.keys(updatedBindings).length) {
|
|
30
|
-
updatedBindings = undefined;
|
|
31
|
-
}
|
|
32
|
-
return updatedBindings;
|
|
33
|
-
}
|
|
34
|
-
function addBindings(bindings, syncedAttributes) {
|
|
35
|
-
const updatedBindings = {
|
|
36
|
-
...bindings
|
|
37
|
-
};
|
|
38
|
-
for (const attributeName of syncedAttributes) {
|
|
39
|
-
if (!bindings?.[attributeName]) {
|
|
40
|
-
updatedBindings[attributeName] = {
|
|
41
|
-
source: 'core/pattern-overrides'
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return updatedBindings;
|
|
46
|
-
}
|
|
47
|
-
function useSetPatternBindings({
|
|
48
|
-
name,
|
|
49
|
-
attributes,
|
|
50
|
-
setAttributes
|
|
51
|
-
}, currentPostType) {
|
|
52
|
-
var _attributes$metadata$, _usePrevious;
|
|
53
|
-
const hasPatternOverridesSource = (0, _data.useSelect)(select => {
|
|
54
|
-
const {
|
|
55
|
-
getBlockBindingsSource
|
|
56
|
-
} = (0, _lockUnlock.unlock)(select(_blocks.store));
|
|
57
|
-
|
|
58
|
-
// For editing link to the site editor if the theme and user permissions support it.
|
|
59
|
-
return !!getBlockBindingsSource('core/pattern-overrides');
|
|
60
|
-
}, []);
|
|
61
|
-
const metadataName = (_attributes$metadata$ = attributes?.metadata?.name) !== null && _attributes$metadata$ !== void 0 ? _attributes$metadata$ : '';
|
|
62
|
-
const prevMetadataName = (_usePrevious = (0, _compose.usePrevious)(metadataName)) !== null && _usePrevious !== void 0 ? _usePrevious : '';
|
|
63
|
-
const bindings = attributes?.metadata?.bindings;
|
|
64
|
-
(0, _element.useEffect)(() => {
|
|
65
|
-
// Bindings should only be created when editing a wp_block post type,
|
|
66
|
-
// and also when there's a change to the user-given name for the block.
|
|
67
|
-
// Also check that the pattern overrides source is registered.
|
|
68
|
-
if (!hasPatternOverridesSource || currentPostType !== 'wp_block' || metadataName === prevMetadataName) {
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
const syncedAttributes = _constants.PARTIAL_SYNCING_SUPPORTED_BLOCKS[name];
|
|
72
|
-
const attributeSources = syncedAttributes.map(attributeName => attributes.metadata?.bindings?.[attributeName]?.source);
|
|
73
|
-
const isConnectedToOtherSources = attributeSources.every(source => source && source !== 'core/pattern-overrides');
|
|
74
|
-
|
|
75
|
-
// Avoid overwriting other (e.g. meta) bindings.
|
|
76
|
-
if (isConnectedToOtherSources) {
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// The user-given name for the block was deleted, remove the bindings.
|
|
81
|
-
if (!metadataName?.length && prevMetadataName?.length) {
|
|
82
|
-
const updatedBindings = removeBindings(bindings, syncedAttributes);
|
|
83
|
-
setAttributes({
|
|
84
|
-
metadata: {
|
|
85
|
-
...attributes.metadata,
|
|
86
|
-
bindings: updatedBindings
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// The user-given name for the block was set, set the bindings.
|
|
92
|
-
if (!prevMetadataName?.length && metadataName.length) {
|
|
93
|
-
const updatedBindings = addBindings(bindings, syncedAttributes);
|
|
94
|
-
setAttributes({
|
|
95
|
-
metadata: {
|
|
96
|
-
...attributes.metadata,
|
|
97
|
-
bindings: updatedBindings
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
}, [hasPatternOverridesSource, bindings, prevMetadataName, metadataName, currentPostType, name, attributes.metadata, setAttributes]);
|
|
102
|
-
}
|
|
103
|
-
//# sourceMappingURL=use-set-pattern-bindings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_compose","require","_blocks","_element","_data","_constants","_lockUnlock","removeBindings","bindings","syncedAttributes","updatedBindings","attributeName","source","undefined","Object","keys","length","addBindings","useSetPatternBindings","name","attributes","setAttributes","currentPostType","_attributes$metadata$","_usePrevious","hasPatternOverridesSource","useSelect","select","getBlockBindingsSource","unlock","blocksStore","metadataName","metadata","prevMetadataName","usePrevious","useEffect","PARTIAL_SYNCING_SUPPORTED_BLOCKS","attributeSources","map","isConnectedToOtherSources","every"],"sources":["@wordpress/patterns/src/components/use-set-pattern-bindings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { PARTIAL_SYNCING_SUPPORTED_BLOCKS } from '../constants';\n\nimport { unlock } from '../lock-unlock';\n\nfunction removeBindings( bindings, syncedAttributes ) {\n\tlet updatedBindings = {};\n\tfor ( const attributeName of syncedAttributes ) {\n\t\t// Omit any pattern override bindings from the `updatedBindings` object.\n\t\tif (\n\t\t\tbindings?.[ attributeName ]?.source !== 'core/pattern-overrides' &&\n\t\t\tbindings?.[ attributeName ]?.source !== undefined\n\t\t) {\n\t\t\tupdatedBindings[ attributeName ] = bindings[ attributeName ];\n\t\t}\n\t}\n\tif ( ! Object.keys( updatedBindings ).length ) {\n\t\tupdatedBindings = undefined;\n\t}\n\treturn updatedBindings;\n}\n\nfunction addBindings( bindings, syncedAttributes ) {\n\tconst updatedBindings = { ...bindings };\n\tfor ( const attributeName of syncedAttributes ) {\n\t\tif ( ! bindings?.[ attributeName ] ) {\n\t\t\tupdatedBindings[ attributeName ] = {\n\t\t\t\tsource: 'core/pattern-overrides',\n\t\t\t};\n\t\t}\n\t}\n\treturn updatedBindings;\n}\n\nexport default function useSetPatternBindings(\n\t{ name, attributes, setAttributes },\n\tcurrentPostType\n) {\n\tconst hasPatternOverridesSource = useSelect( ( select ) => {\n\t\tconst { getBlockBindingsSource } = unlock( select( blocksStore ) );\n\n\t\t// For editing link to the site editor if the theme and user permissions support it.\n\t\treturn !! getBlockBindingsSource( 'core/pattern-overrides' );\n\t}, [] );\n\n\tconst metadataName = attributes?.metadata?.name ?? '';\n\tconst prevMetadataName = usePrevious( metadataName ) ?? '';\n\tconst bindings = attributes?.metadata?.bindings;\n\n\tuseEffect( () => {\n\t\t// Bindings should only be created when editing a wp_block post type,\n\t\t// and also when there's a change to the user-given name for the block.\n\t\t// Also check that the pattern overrides source is registered.\n\t\tif (\n\t\t\t! hasPatternOverridesSource ||\n\t\t\tcurrentPostType !== 'wp_block' ||\n\t\t\tmetadataName === prevMetadataName\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst syncedAttributes = PARTIAL_SYNCING_SUPPORTED_BLOCKS[ name ];\n\t\tconst attributeSources = syncedAttributes.map(\n\t\t\t( attributeName ) =>\n\t\t\t\tattributes.metadata?.bindings?.[ attributeName ]?.source\n\t\t);\n\t\tconst isConnectedToOtherSources = attributeSources.every(\n\t\t\t( source ) => source && source !== 'core/pattern-overrides'\n\t\t);\n\n\t\t// Avoid overwriting other (e.g. meta) bindings.\n\t\tif ( isConnectedToOtherSources ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// The user-given name for the block was deleted, remove the bindings.\n\t\tif ( ! metadataName?.length && prevMetadataName?.length ) {\n\t\t\tconst updatedBindings = removeBindings(\n\t\t\t\tbindings,\n\t\t\t\tsyncedAttributes\n\t\t\t);\n\t\t\tsetAttributes( {\n\t\t\t\tmetadata: {\n\t\t\t\t\t...attributes.metadata,\n\t\t\t\t\tbindings: updatedBindings,\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\t// The user-given name for the block was set, set the bindings.\n\t\tif ( ! prevMetadataName?.length && metadataName.length ) {\n\t\t\tconst updatedBindings = addBindings( bindings, syncedAttributes );\n\t\t\tsetAttributes( {\n\t\t\t\tmetadata: {\n\t\t\t\t\t...attributes.metadata,\n\t\t\t\t\tbindings: updatedBindings,\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}, [\n\t\thasPatternOverridesSource,\n\t\tbindings,\n\t\tprevMetadataName,\n\t\tmetadataName,\n\t\tcurrentPostType,\n\t\tname,\n\t\tattributes.metadata,\n\t\tsetAttributes,\n\t] );\n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AAE,CAAC;IACJ;;IAEA;IACA,IAAK,CAAEuB,gBAAgB,EAAEjB,MAAM,IAAIe,YAAY,CAACf,MAAM,EAAG;MACxD,MAAMN,eAAe,GAAGO,WAAW,CAAET,QAAQ,EAAEC,gBAAiB,CAAC;MACjEY,aAAa,CAAE;QACdW,QAAQ,EAAE;UACT,GAAGZ,UAAU,CAACY,QAAQ;UACtBxB,QAAQ,EAAEE;QACX;MACD,CAAE,CAAC;IACJ;EACD,CAAC,EAAE,CACFe,yBAAyB,EACzBjB,QAAQ,EACRyB,gBAAgB,EAChBF,YAAY,EACZT,eAAe,EACfH,IAAI,EACJC,UAAU,CAACY,QAAQ,EACnBX,aAAa,CACZ,CAAC;AACJ"}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WordPress dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { usePrevious } from '@wordpress/compose';
|
|
5
|
-
import { store as blocksStore } from '@wordpress/blocks';
|
|
6
|
-
import { useEffect } from '@wordpress/element';
|
|
7
|
-
import { useSelect } from '@wordpress/data';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Internal dependencies
|
|
11
|
-
*/
|
|
12
|
-
import { PARTIAL_SYNCING_SUPPORTED_BLOCKS } from '../constants';
|
|
13
|
-
import { unlock } from '../lock-unlock';
|
|
14
|
-
function removeBindings(bindings, syncedAttributes) {
|
|
15
|
-
let updatedBindings = {};
|
|
16
|
-
for (const attributeName of syncedAttributes) {
|
|
17
|
-
// Omit any pattern override bindings from the `updatedBindings` object.
|
|
18
|
-
if (bindings?.[attributeName]?.source !== 'core/pattern-overrides' && bindings?.[attributeName]?.source !== undefined) {
|
|
19
|
-
updatedBindings[attributeName] = bindings[attributeName];
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
if (!Object.keys(updatedBindings).length) {
|
|
23
|
-
updatedBindings = undefined;
|
|
24
|
-
}
|
|
25
|
-
return updatedBindings;
|
|
26
|
-
}
|
|
27
|
-
function addBindings(bindings, syncedAttributes) {
|
|
28
|
-
const updatedBindings = {
|
|
29
|
-
...bindings
|
|
30
|
-
};
|
|
31
|
-
for (const attributeName of syncedAttributes) {
|
|
32
|
-
if (!bindings?.[attributeName]) {
|
|
33
|
-
updatedBindings[attributeName] = {
|
|
34
|
-
source: 'core/pattern-overrides'
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
return updatedBindings;
|
|
39
|
-
}
|
|
40
|
-
export default function useSetPatternBindings({
|
|
41
|
-
name,
|
|
42
|
-
attributes,
|
|
43
|
-
setAttributes
|
|
44
|
-
}, currentPostType) {
|
|
45
|
-
var _attributes$metadata$, _usePrevious;
|
|
46
|
-
const hasPatternOverridesSource = useSelect(select => {
|
|
47
|
-
const {
|
|
48
|
-
getBlockBindingsSource
|
|
49
|
-
} = unlock(select(blocksStore));
|
|
50
|
-
|
|
51
|
-
// For editing link to the site editor if the theme and user permissions support it.
|
|
52
|
-
return !!getBlockBindingsSource('core/pattern-overrides');
|
|
53
|
-
}, []);
|
|
54
|
-
const metadataName = (_attributes$metadata$ = attributes?.metadata?.name) !== null && _attributes$metadata$ !== void 0 ? _attributes$metadata$ : '';
|
|
55
|
-
const prevMetadataName = (_usePrevious = usePrevious(metadataName)) !== null && _usePrevious !== void 0 ? _usePrevious : '';
|
|
56
|
-
const bindings = attributes?.metadata?.bindings;
|
|
57
|
-
useEffect(() => {
|
|
58
|
-
// Bindings should only be created when editing a wp_block post type,
|
|
59
|
-
// and also when there's a change to the user-given name for the block.
|
|
60
|
-
// Also check that the pattern overrides source is registered.
|
|
61
|
-
if (!hasPatternOverridesSource || currentPostType !== 'wp_block' || metadataName === prevMetadataName) {
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
const syncedAttributes = PARTIAL_SYNCING_SUPPORTED_BLOCKS[name];
|
|
65
|
-
const attributeSources = syncedAttributes.map(attributeName => attributes.metadata?.bindings?.[attributeName]?.source);
|
|
66
|
-
const isConnectedToOtherSources = attributeSources.every(source => source && source !== 'core/pattern-overrides');
|
|
67
|
-
|
|
68
|
-
// Avoid overwriting other (e.g. meta) bindings.
|
|
69
|
-
if (isConnectedToOtherSources) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
// The user-given name for the block was deleted, remove the bindings.
|
|
74
|
-
if (!metadataName?.length && prevMetadataName?.length) {
|
|
75
|
-
const updatedBindings = removeBindings(bindings, syncedAttributes);
|
|
76
|
-
setAttributes({
|
|
77
|
-
metadata: {
|
|
78
|
-
...attributes.metadata,
|
|
79
|
-
bindings: updatedBindings
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// The user-given name for the block was set, set the bindings.
|
|
85
|
-
if (!prevMetadataName?.length && metadataName.length) {
|
|
86
|
-
const updatedBindings = addBindings(bindings, syncedAttributes);
|
|
87
|
-
setAttributes({
|
|
88
|
-
metadata: {
|
|
89
|
-
...attributes.metadata,
|
|
90
|
-
bindings: updatedBindings
|
|
91
|
-
}
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
}, [hasPatternOverridesSource, bindings, prevMetadataName, metadataName, currentPostType, name, attributes.metadata, setAttributes]);
|
|
95
|
-
}
|
|
96
|
-
//# sourceMappingURL=use-set-pattern-bindings.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["usePrevious","store","blocksStore","useEffect","useSelect","PARTIAL_SYNCING_SUPPORTED_BLOCKS","unlock","removeBindings","bindings","syncedAttributes","updatedBindings","attributeName","source","undefined","Object","keys","length","addBindings","useSetPatternBindings","name","attributes","setAttributes","currentPostType","_attributes$metadata$","_usePrevious","hasPatternOverridesSource","select","getBlockBindingsSource","metadataName","metadata","prevMetadataName","attributeSources","map","isConnectedToOtherSources","every"],"sources":["@wordpress/patterns/src/components/use-set-pattern-bindings.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { usePrevious } from '@wordpress/compose';\nimport { store as blocksStore } from '@wordpress/blocks';\nimport { useEffect } from '@wordpress/element';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { PARTIAL_SYNCING_SUPPORTED_BLOCKS } from '../constants';\n\nimport { unlock } from '../lock-unlock';\n\nfunction removeBindings( bindings, syncedAttributes ) {\n\tlet updatedBindings = {};\n\tfor ( const attributeName of syncedAttributes ) {\n\t\t// Omit any pattern override bindings from the `updatedBindings` object.\n\t\tif (\n\t\t\tbindings?.[ attributeName ]?.source !== 'core/pattern-overrides' &&\n\t\t\tbindings?.[ attributeName ]?.source !== undefined\n\t\t) {\n\t\t\tupdatedBindings[ attributeName ] = bindings[ attributeName ];\n\t\t}\n\t}\n\tif ( ! Object.keys( updatedBindings ).length ) {\n\t\tupdatedBindings = undefined;\n\t}\n\treturn updatedBindings;\n}\n\nfunction addBindings( bindings, syncedAttributes ) {\n\tconst updatedBindings = { ...bindings };\n\tfor ( const attributeName of syncedAttributes ) {\n\t\tif ( ! bindings?.[ attributeName ] ) {\n\t\t\tupdatedBindings[ attributeName ] = {\n\t\t\t\tsource: 'core/pattern-overrides',\n\t\t\t};\n\t\t}\n\t}\n\treturn updatedBindings;\n}\n\nexport default function useSetPatternBindings(\n\t{ name, attributes, setAttributes },\n\tcurrentPostType\n) {\n\tconst hasPatternOverridesSource = useSelect( ( select ) => {\n\t\tconst { getBlockBindingsSource } = unlock( select( blocksStore ) );\n\n\t\t// For editing link to the site editor if the theme and user permissions support it.\n\t\treturn !! getBlockBindingsSource( 'core/pattern-overrides' );\n\t}, [] );\n\n\tconst metadataName = attributes?.metadata?.name ?? '';\n\tconst prevMetadataName = usePrevious( metadataName ) ?? '';\n\tconst bindings = attributes?.metadata?.bindings;\n\n\tuseEffect( () => {\n\t\t// Bindings should only be created when editing a wp_block post type,\n\t\t// and also when there's a change to the user-given name for the block.\n\t\t// Also check that the pattern overrides source is registered.\n\t\tif (\n\t\t\t! hasPatternOverridesSource ||\n\t\t\tcurrentPostType !== 'wp_block' ||\n\t\t\tmetadataName === prevMetadataName\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst syncedAttributes = PARTIAL_SYNCING_SUPPORTED_BLOCKS[ name ];\n\t\tconst attributeSources = syncedAttributes.map(\n\t\t\t( attributeName ) =>\n\t\t\t\tattributes.metadata?.bindings?.[ attributeName ]?.source\n\t\t);\n\t\tconst isConnectedToOtherSources = attributeSources.every(\n\t\t\t( source ) => source && source !== 'core/pattern-overrides'\n\t\t);\n\n\t\t// Avoid overwriting other (e.g. meta) bindings.\n\t\tif ( isConnectedToOtherSources ) {\n\t\t\treturn;\n\t\t}\n\n\t\t// The user-given name for the block was deleted, remove the bindings.\n\t\tif ( ! metadataName?.length && prevMetadataName?.length ) {\n\t\t\tconst updatedBindings = removeBindings(\n\t\t\t\tbindings,\n\t\t\t\tsyncedAttributes\n\t\t\t);\n\t\t\tsetAttributes( {\n\t\t\t\tmetadata: {\n\t\t\t\t\t...attributes.metadata,\n\t\t\t\t\tbindings: updatedBindings,\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\n\t\t// The user-given name for the block was set, set the bindings.\n\t\tif ( ! prevMetadataName?.length && metadataName.length ) {\n\t\t\tconst updatedBindings = addBindings( bindings, syncedAttributes );\n\t\t\tsetAttributes( {\n\t\t\t\tmetadata: {\n\t\t\t\t\t...attributes.metadata,\n\t\t\t\t\tbindings: updatedBindings,\n\t\t\t\t},\n\t\t\t} );\n\t\t}\n\t}, [\n\t\thasPatternOverridesSource,\n\t\tbindings,\n\t\tprevMetadataName,\n\t\tmetadataName,\n\t\tcurrentPostType,\n\t\tname,\n\t\tattributes.metadata,\n\t\tsetAttributes,\n\t] );\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAW,QAAQ,oBAAoB;AAChD,SAASC,KAAK,IAAIC,WAAW,QAAQ,mBAAmB;AACxD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;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