@wordpress/editor 14.8.5 → 14.8.6
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/bindings/api.js +2 -5
- package/build/bindings/api.js.map +1 -1
- package/build/bindings/pattern-overrides.js +7 -6
- package/build/bindings/pattern-overrides.js.map +1 -1
- package/build/bindings/post-meta.js +16 -16
- package/build/bindings/post-meta.js.map +1 -1
- package/build/hooks/pattern-overrides.js +1 -4
- package/build/hooks/pattern-overrides.js.map +1 -1
- package/build-module/bindings/api.js +1 -4
- package/build-module/bindings/api.js.map +1 -1
- package/build-module/bindings/pattern-overrides.js +7 -6
- package/build-module/bindings/pattern-overrides.js.map +1 -1
- package/build-module/bindings/post-meta.js +16 -16
- package/build-module/bindings/post-meta.js.map +1 -1
- package/build-module/hooks/pattern-overrides.js +1 -4
- package/build-module/hooks/pattern-overrides.js.map +1 -1
- package/build-types/bindings/api.d.ts.map +1 -1
- package/build-types/bindings/pattern-overrides.d.ts +5 -4
- package/build-types/bindings/pattern-overrides.d.ts.map +1 -1
- package/build-types/bindings/post-meta.d.ts +8 -8
- package/build-types/bindings/post-meta.d.ts.map +1 -1
- package/package.json +15 -15
- package/src/bindings/api.js +1 -2
- package/src/bindings/pattern-overrides.js +27 -30
- package/src/bindings/post-meta.js +28 -30
- package/src/hooks/pattern-overrides.js +1 -2
- package/tsconfig.tsbuildinfo +1 -1
package/build/bindings/api.js
CHANGED
|
@@ -30,11 +30,8 @@ var _lockUnlock = require("../lock-unlock");
|
|
|
30
30
|
* ```
|
|
31
31
|
*/
|
|
32
32
|
function registerCoreBlockBindingsSources() {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
} = (0, _lockUnlock.unlock)(_blocks.privateApis);
|
|
36
|
-
registerBlockBindingsSource(_patternOverrides.default);
|
|
37
|
-
registerBlockBindingsSource(_postMeta.default);
|
|
33
|
+
(0, _blocks.registerBlockBindingsSource)(_patternOverrides.default);
|
|
34
|
+
(0, _blocks.registerBlockBindingsSource)(_postMeta.default);
|
|
38
35
|
}
|
|
39
36
|
|
|
40
37
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blocks","require","_data","_patternOverrides","_interopRequireDefault","_postMeta","_lockUnlock","registerCoreBlockBindingsSources","registerBlockBindingsSource","
|
|
1
|
+
{"version":3,"names":["_blocks","require","_data","_patternOverrides","_interopRequireDefault","_postMeta","_lockUnlock","registerCoreBlockBindingsSources","registerBlockBindingsSource","patternOverrides","postMeta","bootstrapBlockBindingsSourcesFromServer","sources","addBootstrappedBlockBindingsSource","unlock","dispatch","blocksStore","name","args","Object","entries"],"sources":["@wordpress/editor/src/bindings/api.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blocksStore,\n\tregisterBlockBindingsSource,\n} from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport patternOverrides from './pattern-overrides';\nimport postMeta from './post-meta';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Function to register core block bindings sources provided by the editor.\n *\n * @example\n * ```js\n * import { registerCoreBlockBindingsSources } from '@wordpress/editor';\n *\n * registerCoreBlockBindingsSources();\n * ```\n */\nexport function registerCoreBlockBindingsSources() {\n\tregisterBlockBindingsSource( patternOverrides );\n\tregisterBlockBindingsSource( postMeta );\n}\n\n/**\n * Function to bootstrap core block bindings sources defined in the server.\n *\n * @param {Object} sources Object containing the sources to bootstrap.\n *\n * @example\n * ```js\n * import { bootstrapBlockBindingsSourcesFromServer } from '@wordpress/editor';\n *\n * bootstrapBlockBindingsSourcesFromServer( sources );\n * ```\n */\nexport function bootstrapBlockBindingsSourcesFromServer( sources ) {\n\tif ( sources ) {\n\t\tconst { addBootstrappedBlockBindingsSource } = unlock(\n\t\t\tdispatch( blocksStore )\n\t\t);\n\t\tfor ( const [ name, args ] of Object.entries( sources ) ) {\n\t\t\taddBootstrappedBlockBindingsSource( {\n\t\t\t\tname,\n\t\t\t\t...args,\n\t\t\t} );\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AAKA,IAAAE,iBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,SAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,WAAA,GAAAL,OAAA;AAdA;AACA;AACA;;AAOA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASM,gCAAgCA,CAAA,EAAG;EAClD,IAAAC,mCAA2B,EAAEC,yBAAiB,CAAC;EAC/C,IAAAD,mCAA2B,EAAEE,iBAAS,CAAC;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,uCAAuCA,CAAEC,OAAO,EAAG;EAClE,IAAKA,OAAO,EAAG;IACd,MAAM;MAAEC;IAAmC,CAAC,GAAG,IAAAC,kBAAM,EACpD,IAAAC,cAAQ,EAAEC,aAAY,CACvB,CAAC;IACD,KAAM,MAAM,CAAEC,IAAI,EAAEC,IAAI,CAAE,IAAIC,MAAM,CAACC,OAAO,CAAER,OAAQ,CAAC,EAAG;MACzDC,kCAAkC,CAAE;QACnCI,IAAI;QACJ,GAAGC;MACJ,CAAE,CAAC;IACJ;EACD;AACD","ignoreList":[]}
|
|
@@ -13,7 +13,7 @@ const CONTENT = 'content';
|
|
|
13
13
|
var _default = exports.default = {
|
|
14
14
|
name: 'core/pattern-overrides',
|
|
15
15
|
getValues({
|
|
16
|
-
|
|
16
|
+
select,
|
|
17
17
|
clientId,
|
|
18
18
|
context,
|
|
19
19
|
bindings
|
|
@@ -21,7 +21,7 @@ var _default = exports.default = {
|
|
|
21
21
|
const patternOverridesContent = context['pattern/overrides'];
|
|
22
22
|
const {
|
|
23
23
|
getBlockAttributes
|
|
24
|
-
} =
|
|
24
|
+
} = select(_blockEditor.store);
|
|
25
25
|
const currentBlockAttributes = getBlockAttributes(clientId);
|
|
26
26
|
const overridesValues = {};
|
|
27
27
|
for (const attributeName of Object.keys(bindings)) {
|
|
@@ -39,7 +39,8 @@ var _default = exports.default = {
|
|
|
39
39
|
return overridesValues;
|
|
40
40
|
},
|
|
41
41
|
setValues({
|
|
42
|
-
|
|
42
|
+
select,
|
|
43
|
+
dispatch,
|
|
43
44
|
clientId,
|
|
44
45
|
bindings
|
|
45
46
|
}) {
|
|
@@ -47,7 +48,7 @@ var _default = exports.default = {
|
|
|
47
48
|
getBlockAttributes,
|
|
48
49
|
getBlockParentsByBlockName,
|
|
49
50
|
getBlocks
|
|
50
|
-
} =
|
|
51
|
+
} = select(_blockEditor.store);
|
|
51
52
|
const currentBlockAttributes = getBlockAttributes(clientId);
|
|
52
53
|
const blockName = currentBlockAttributes?.metadata?.name;
|
|
53
54
|
if (!blockName) {
|
|
@@ -68,7 +69,7 @@ var _default = exports.default = {
|
|
|
68
69
|
const syncBlocksWithSameName = blocks => {
|
|
69
70
|
for (const block of blocks) {
|
|
70
71
|
if (block.attributes?.metadata?.name === blockName) {
|
|
71
|
-
|
|
72
|
+
dispatch(_blockEditor.store).updateBlockAttributes(block.clientId, attributes);
|
|
72
73
|
}
|
|
73
74
|
syncBlocksWithSameName(block.innerBlocks);
|
|
74
75
|
}
|
|
@@ -77,7 +78,7 @@ var _default = exports.default = {
|
|
|
77
78
|
return;
|
|
78
79
|
}
|
|
79
80
|
const currentBindingValue = getBlockAttributes(patternClientId)?.[CONTENT];
|
|
80
|
-
|
|
81
|
+
dispatch(_blockEditor.store).updateBlockAttributes(patternClientId, {
|
|
81
82
|
[CONTENT]: {
|
|
82
83
|
...currentBindingValue,
|
|
83
84
|
[blockName]: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blockEditor","require","CONTENT","_default","exports","default","name","getValues","
|
|
1
|
+
{"version":3,"names":["_blockEditor","require","CONTENT","_default","exports","default","name","getValues","select","clientId","context","bindings","patternOverridesContent","getBlockAttributes","blockEditorStore","currentBlockAttributes","overridesValues","attributeName","Object","keys","overridableValue","metadata","undefined","setValues","dispatch","getBlockParentsByBlockName","getBlocks","blockName","patternClientId","attributes","entries","reduce","attrs","key","newValue","syncBlocksWithSameName","blocks","block","updateBlockAttributes","innerBlocks","currentBindingValue","acc","value","canUserEditValue"],"sources":["@wordpress/editor/src/bindings/pattern-overrides.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nconst CONTENT = 'content';\n\nexport default {\n\tname: 'core/pattern-overrides',\n\tgetValues( { select, clientId, context, bindings } ) {\n\t\tconst patternOverridesContent = context[ 'pattern/overrides' ];\n\t\tconst { getBlockAttributes } = select( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\n\t\tconst overridesValues = {};\n\t\tfor ( const attributeName of Object.keys( bindings ) ) {\n\t\t\tconst overridableValue =\n\t\t\t\tpatternOverridesContent?.[\n\t\t\t\t\tcurrentBlockAttributes?.metadata?.name\n\t\t\t\t]?.[ attributeName ];\n\n\t\t\t// If it has not been overriden, return the original value.\n\t\t\t// Check undefined because empty string is a valid value.\n\t\t\tif ( overridableValue === undefined ) {\n\t\t\t\toverridesValues[ attributeName ] =\n\t\t\t\t\tcurrentBlockAttributes[ attributeName ];\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\toverridesValues[ attributeName ] =\n\t\t\t\t\toverridableValue === '' ? undefined : overridableValue;\n\t\t\t}\n\t\t}\n\t\treturn overridesValues;\n\t},\n\tsetValues( { select, dispatch, clientId, bindings } ) {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName, getBlocks } =\n\t\t\tselect( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\t\tconst blockName = currentBlockAttributes?.metadata?.name;\n\t\tif ( ! blockName ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\tclientId,\n\t\t\t'core/block',\n\t\t\ttrue\n\t\t);\n\n\t\t// Extract the updated attributes from the source bindings.\n\t\tconst attributes = Object.entries( bindings ).reduce(\n\t\t\t( attrs, [ key, { newValue } ] ) => {\n\t\t\t\tattrs[ key ] = newValue;\n\t\t\t\treturn attrs;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\t// If there is no pattern client ID, sync blocks with the same name and same attributes.\n\t\tif ( ! patternClientId ) {\n\t\t\tconst syncBlocksWithSameName = ( blocks ) => {\n\t\t\t\tfor ( const block of blocks ) {\n\t\t\t\t\tif ( block.attributes?.metadata?.name === blockName ) {\n\t\t\t\t\t\tdispatch( blockEditorStore ).updateBlockAttributes(\n\t\t\t\t\t\t\tblock.clientId,\n\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tsyncBlocksWithSameName( block.innerBlocks );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tsyncBlocksWithSameName( getBlocks() );\n\t\t\treturn;\n\t\t}\n\t\tconst currentBindingValue =\n\t\t\tgetBlockAttributes( patternClientId )?.[ CONTENT ];\n\n\t\tdispatch( blockEditorStore ).updateBlockAttributes( patternClientId, {\n\t\t\t[ CONTENT ]: {\n\t\t\t\t...currentBindingValue,\n\t\t\t\t[ blockName ]: {\n\t\t\t\t\t...currentBindingValue?.[ blockName ],\n\t\t\t\t\t...Object.entries( attributes ).reduce(\n\t\t\t\t\t\t( acc, [ key, value ] ) => {\n\t\t\t\t\t\t\t// TODO: We need a way to represent `undefined` in the serialized overrides.\n\t\t\t\t\t\t\t// Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871\n\t\t\t\t\t\t\t// We use an empty string to represent undefined for now until\n\t\t\t\t\t\t\t// we support a richer format for overrides and the block bindings API.\n\t\t\t\t\t\t\tacc[ key ] = value === undefined ? '' : value;\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t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CAACE,MAAM,CACrC,CAAEU,GAAG,EAAE,CAAER,GAAG,EAAES,KAAK,CAAE,KAAM;YAC1B;YACA;YACA;YACA;YACAD,GAAG,CAAER,GAAG,CAAE,GAAGS,KAAK,KAAKpB,SAAS,GAAG,EAAE,GAAGoB,KAAK;YAC7C,OAAOD,GAAG;UACX,CAAC,EACD,CAAC,CACF;QACD;MACD;IACD,CAAE,CAAC;EACJ,CAAC;EACDE,gBAAgB,EAAEA,CAAA,KAAM;AACzB,CAAC","ignoreList":[]}
|
|
@@ -21,8 +21,8 @@ var _lockUnlock = require("../lock-unlock");
|
|
|
21
21
|
* If the value is not available based on context, like in templates,
|
|
22
22
|
* it falls back to the default value, label, or key.
|
|
23
23
|
*
|
|
24
|
-
* @param {Object}
|
|
25
|
-
* @param {Object} context
|
|
24
|
+
* @param {Object} select The select function from the data store.
|
|
25
|
+
* @param {Object} context The context provided.
|
|
26
26
|
* @return {Object} List of post meta fields with their value and label.
|
|
27
27
|
*
|
|
28
28
|
* @example
|
|
@@ -40,13 +40,13 @@ var _lockUnlock = require("../lock-unlock");
|
|
|
40
40
|
* }
|
|
41
41
|
* ```
|
|
42
42
|
*/
|
|
43
|
-
function getPostMetaFields(
|
|
43
|
+
function getPostMetaFields(select, context) {
|
|
44
44
|
const {
|
|
45
45
|
getEditedEntityRecord
|
|
46
|
-
} =
|
|
46
|
+
} = select(_coreData.store);
|
|
47
47
|
const {
|
|
48
48
|
getRegisteredPostMeta
|
|
49
|
-
} = (0, _lockUnlock.unlock)(
|
|
49
|
+
} = (0, _lockUnlock.unlock)(select(_coreData.store));
|
|
50
50
|
let entityMetaValues;
|
|
51
51
|
// Try to get the current entity meta values.
|
|
52
52
|
if (context?.postType && context?.postId) {
|
|
@@ -75,11 +75,11 @@ function getPostMetaFields(registry, context) {
|
|
|
75
75
|
var _default = exports.default = {
|
|
76
76
|
name: 'core/post-meta',
|
|
77
77
|
getValues({
|
|
78
|
-
|
|
78
|
+
select,
|
|
79
79
|
context,
|
|
80
80
|
bindings
|
|
81
81
|
}) {
|
|
82
|
-
const metaFields = getPostMetaFields(
|
|
82
|
+
const metaFields = getPostMetaFields(select, context);
|
|
83
83
|
const newValues = {};
|
|
84
84
|
for (const [attributeName, source] of Object.entries(bindings)) {
|
|
85
85
|
var _ref;
|
|
@@ -94,7 +94,7 @@ var _default = exports.default = {
|
|
|
94
94
|
return newValues;
|
|
95
95
|
},
|
|
96
96
|
setValues({
|
|
97
|
-
|
|
97
|
+
dispatch,
|
|
98
98
|
context,
|
|
99
99
|
bindings
|
|
100
100
|
}) {
|
|
@@ -105,12 +105,12 @@ var _default = exports.default = {
|
|
|
105
105
|
}) => {
|
|
106
106
|
newMeta[args.key] = newValue;
|
|
107
107
|
});
|
|
108
|
-
|
|
108
|
+
dispatch(_coreData.store).editEntityRecord('postType', context?.postType, context?.postId, {
|
|
109
109
|
meta: newMeta
|
|
110
110
|
});
|
|
111
111
|
},
|
|
112
112
|
canUserEditValue({
|
|
113
|
-
|
|
113
|
+
select,
|
|
114
114
|
context,
|
|
115
115
|
args
|
|
116
116
|
}) {
|
|
@@ -118,25 +118,25 @@ var _default = exports.default = {
|
|
|
118
118
|
if (context?.query || context?.queryId) {
|
|
119
119
|
return false;
|
|
120
120
|
}
|
|
121
|
-
const postType = context?.postType ||
|
|
121
|
+
const postType = context?.postType || select(_store.store).getCurrentPostType();
|
|
122
122
|
|
|
123
123
|
// Check that editing is happening in the post editor and not a template.
|
|
124
124
|
if (postType === 'wp_template') {
|
|
125
125
|
return false;
|
|
126
126
|
}
|
|
127
|
-
const fieldValue = getPostMetaFields(
|
|
127
|
+
const fieldValue = getPostMetaFields(select, context)?.[args.key]?.value;
|
|
128
128
|
// Empty string or `false` could be a valid value, so we need to check if the field value is undefined.
|
|
129
129
|
if (fieldValue === undefined) {
|
|
130
130
|
return false;
|
|
131
131
|
}
|
|
132
132
|
// Check that custom fields metabox is not enabled.
|
|
133
|
-
const areCustomFieldsEnabled =
|
|
133
|
+
const areCustomFieldsEnabled = select(_store.store).getEditorSettings().enableCustomFields;
|
|
134
134
|
if (areCustomFieldsEnabled) {
|
|
135
135
|
return false;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
138
|
// Check that the user has the capability to edit post meta.
|
|
139
|
-
const canUserEdit =
|
|
139
|
+
const canUserEdit = select(_coreData.store).canUser('update', {
|
|
140
140
|
kind: 'postType',
|
|
141
141
|
name: context?.postType,
|
|
142
142
|
id: context?.postId
|
|
@@ -147,10 +147,10 @@ var _default = exports.default = {
|
|
|
147
147
|
return true;
|
|
148
148
|
},
|
|
149
149
|
getFieldsList({
|
|
150
|
-
|
|
150
|
+
select,
|
|
151
151
|
context
|
|
152
152
|
}) {
|
|
153
|
-
return getPostMetaFields(
|
|
153
|
+
return getPostMetaFields(select, context);
|
|
154
154
|
}
|
|
155
155
|
};
|
|
156
156
|
//# sourceMappingURL=post-meta.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_coreData","require","_store","_lockUnlock","getPostMetaFields","
|
|
1
|
+
{"version":3,"names":["_coreData","require","_store","_lockUnlock","getPostMetaFields","select","context","getEditedEntityRecord","coreDataStore","getRegisteredPostMeta","unlock","entityMetaValues","postType","postId","meta","registeredFields","metaFields","Object","entries","forEach","key","props","charAt","_entityMetaValues$key","label","title","value","default","undefined","keys","length","_default","exports","name","getValues","bindings","newValues","attributeName","source","_ref","fieldKey","args","fieldValue","fieldLabel","setValues","dispatch","newMeta","values","newValue","editEntityRecord","canUserEditValue","query","queryId","editorStore","getCurrentPostType","areCustomFieldsEnabled","getEditorSettings","enableCustomFields","canUserEdit","canUser","kind","id","getFieldsList"],"sources":["@wordpress/editor/src/bindings/post-meta.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as coreDataStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Gets a list of post meta fields with their values and labels\n * to be consumed in the needed callbacks.\n * If the value is not available based on context, like in templates,\n * it falls back to the default value, label, or key.\n *\n * @param {Object} select The select function from the data store.\n * @param {Object} context The context provided.\n * @return {Object} List of post meta fields with their value and label.\n *\n * @example\n * ```js\n * {\n * field_1_key: {\n * label: 'Field 1 Label',\n * value: 'Field 1 Value',\n * },\n * field_2_key: {\n * label: 'Field 2 Label',\n * value: 'Field 2 Value',\n * },\n * ...\n * }\n * ```\n */\nfunction getPostMetaFields( select, context ) {\n\tconst { getEditedEntityRecord } = select( coreDataStore );\n\tconst { getRegisteredPostMeta } = unlock( select( coreDataStore ) );\n\n\tlet entityMetaValues;\n\t// Try to get the current entity meta values.\n\tif ( context?.postType && context?.postId ) {\n\t\tentityMetaValues = getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\tcontext?.postType,\n\t\t\tcontext?.postId\n\t\t).meta;\n\t}\n\n\tconst registeredFields = getRegisteredPostMeta( context?.postType );\n\tconst metaFields = {};\n\tObject.entries( registeredFields || {} ).forEach( ( [ key, props ] ) => {\n\t\t// Don't include footnotes or private fields.\n\t\tif ( key !== 'footnotes' && key.charAt( 0 ) !== '_' ) {\n\t\t\tmetaFields[ key ] = {\n\t\t\t\tlabel: props.title || key,\n\t\t\t\tvalue:\n\t\t\t\t\t// When using the entity value, an empty string IS a valid value.\n\t\t\t\t\tentityMetaValues?.[ key ] ??\n\t\t\t\t\t// When using the default, an empty string IS NOT a valid value.\n\t\t\t\t\t( props.default || undefined ),\n\t\t\t};\n\t\t}\n\t} );\n\n\tif ( ! Object.keys( metaFields || {} ).length ) {\n\t\treturn null;\n\t}\n\n\treturn metaFields;\n}\n\nexport default {\n\tname: 'core/post-meta',\n\tgetValues( { select, context, bindings } ) {\n\t\tconst metaFields = getPostMetaFields( select, context );\n\n\t\tconst newValues = {};\n\t\tfor ( const [ attributeName, source ] of Object.entries( bindings ) ) {\n\t\t\t// Use the value, the field label, or the field key.\n\t\t\tconst fieldKey = source.args.key;\n\t\t\tconst { value: fieldValue, label: fieldLabel } =\n\t\t\t\tmetaFields?.[ fieldKey ] || {};\n\t\t\tnewValues[ attributeName ] = fieldValue ?? fieldLabel ?? fieldKey;\n\t\t}\n\t\treturn newValues;\n\t},\n\tsetValues( { dispatch, context, bindings } ) {\n\t\tconst newMeta = {};\n\t\tObject.values( bindings ).forEach( ( { args, newValue } ) => {\n\t\t\tnewMeta[ args.key ] = newValue;\n\t\t} );\n\n\t\tdispatch( coreDataStore ).editEntityRecord(\n\t\t\t'postType',\n\t\t\tcontext?.postType,\n\t\t\tcontext?.postId,\n\t\t\t{\n\t\t\t\tmeta: newMeta,\n\t\t\t}\n\t\t);\n\t},\n\tcanUserEditValue( { select, context, args } ) {\n\t\t// Lock editing in query loop.\n\t\tif ( context?.query || context?.queryId ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst postType =\n\t\t\tcontext?.postType || select( editorStore ).getCurrentPostType();\n\n\t\t// Check that editing is happening in the post editor and not a template.\n\t\tif ( postType === 'wp_template' ) {\n\t\t\treturn false;\n\t\t}\n\n\t\tconst fieldValue = getPostMetaFields( select, context )?.[ args.key ]\n\t\t\t?.value;\n\t\t// Empty string or `false` could be a valid value, so we need to check if the field value is undefined.\n\t\tif ( fieldValue === undefined ) {\n\t\t\treturn false;\n\t\t}\n\t\t// Check that custom fields metabox is not enabled.\n\t\tconst areCustomFieldsEnabled =\n\t\t\tselect( editorStore ).getEditorSettings().enableCustomFields;\n\t\tif ( areCustomFieldsEnabled ) {\n\t\t\treturn false;\n\t\t}\n\n\t\t// Check that the user has the capability to edit post meta.\n\t\tconst canUserEdit = select( coreDataStore ).canUser( 'update', {\n\t\t\tkind: 'postType',\n\t\t\tname: context?.postType,\n\t\t\tid: context?.postId,\n\t\t} );\n\t\tif ( ! canUserEdit ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t},\n\tgetFieldsList( { select, context } ) {\n\t\treturn getPostMetaFields( select, context );\n\t},\n};\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;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OAAOF,iBAAiB,CAAEC,MAAM,EAAEC,OAAQ,CAAC;EAC5C;AACD,CAAC","ignoreList":[]}
|
|
@@ -54,16 +54,13 @@ function ControlsWithStoreSubscription(props) {
|
|
|
54
54
|
hasPatternOverridesSource,
|
|
55
55
|
isEditingSyncedPattern
|
|
56
56
|
} = (0, _data.useSelect)(select => {
|
|
57
|
-
const {
|
|
58
|
-
getBlockBindingsSource
|
|
59
|
-
} = (0, _lockUnlock.unlock)(select(_blocks.store));
|
|
60
57
|
const {
|
|
61
58
|
getCurrentPostType,
|
|
62
59
|
getEditedPostAttribute
|
|
63
60
|
} = select(_store.store);
|
|
64
61
|
return {
|
|
65
62
|
// For editing link to the site editor if the theme and user permissions support it.
|
|
66
|
-
hasPatternOverridesSource: !!getBlockBindingsSource('core/pattern-overrides'),
|
|
63
|
+
hasPatternOverridesSource: !!(0, _blocks.getBlockBindingsSource)('core/pattern-overrides'),
|
|
67
64
|
isEditingSyncedPattern: getCurrentPostType() === PATTERN_TYPES.user && getEditedPostAttribute('meta')?.wp_pattern_sync_status !== PATTERN_SYNC_TYPES.unsynced && getEditedPostAttribute('wp_pattern_sync_status') !== PATTERN_SYNC_TYPES.unsynced
|
|
68
65
|
};
|
|
69
66
|
}, []);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_hooks","require","_patterns","_compose","_blockEditor","_data","_blocks","_store","_lockUnlock","_jsxRuntime","PatternOverridesControls","ResetOverridesControl","PatternOverridesBlockControls","PATTERN_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","PATTERN_SYNC_TYPES","unlock","patternsPrivateApis","withPatternOverrideControls","createHigherOrderComponent","BlockEdit","props","isSupportedBlock","name","jsxs","Fragment","children","jsx","isSelected","ControlsWithStoreSubscription","blockEditingMode","useBlockEditingMode","hasPatternOverridesSource","isEditingSyncedPattern","useSelect","select","
|
|
1
|
+
{"version":3,"names":["_hooks","require","_patterns","_compose","_blockEditor","_data","_blocks","_store","_lockUnlock","_jsxRuntime","PatternOverridesControls","ResetOverridesControl","PatternOverridesBlockControls","PATTERN_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","PATTERN_SYNC_TYPES","unlock","patternsPrivateApis","withPatternOverrideControls","createHigherOrderComponent","BlockEdit","props","isSupportedBlock","name","jsxs","Fragment","children","jsx","isSelected","ControlsWithStoreSubscription","blockEditingMode","useBlockEditingMode","hasPatternOverridesSource","isEditingSyncedPattern","useSelect","select","getCurrentPostType","getEditedPostAttribute","editorStore","getBlockBindingsSource","user","wp_pattern_sync_status","unsynced","bindings","attributes","metadata","hasPatternBindings","Object","values","some","binding","source","shouldShowPatternOverridesControls","shouldShowResetOverridesControl","addFilter"],"sources":["@wordpress/editor/src/hooks/pattern-overrides.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { addFilter } from '@wordpress/hooks';\nimport { privateApis as patternsPrivateApis } from '@wordpress/patterns';\nimport { createHigherOrderComponent } from '@wordpress/compose';\nimport { useBlockEditingMode } from '@wordpress/block-editor';\nimport { useSelect } from '@wordpress/data';\nimport { getBlockBindingsSource } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\n/** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */\n\nconst {\n\tPatternOverridesControls,\n\tResetOverridesControl,\n\tPatternOverridesBlockControls,\n\tPATTERN_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\n\tPATTERN_SYNC_TYPES,\n} = unlock( patternsPrivateApis );\n\n/**\n * Override the default edit UI to include a new block inspector control for\n * assigning a partial syncing controls to supported blocks in the pattern editor.\n * Currently, only the `core/paragraph` block is supported.\n *\n * @param {Component} BlockEdit Original component.\n *\n * @return {Component} Wrapped component.\n */\nconst withPatternOverrideControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst isSupportedBlock =\n\t\t\t!! PARTIAL_SYNCING_SUPPORTED_BLOCKS[ props.name ];\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit key=\"edit\" { ...props } />\n\t\t\t\t{ props.isSelected && isSupportedBlock && (\n\t\t\t\t\t<ControlsWithStoreSubscription { ...props } />\n\t\t\t\t) }\n\t\t\t\t{ isSupportedBlock && <PatternOverridesBlockControls /> }\n\t\t\t</>\n\t\t);\n\t},\n\t'withPatternOverrideControls'\n);\n\n// Split into a separate component to avoid a store subscription\n// on every block.\nfunction ControlsWithStoreSubscription( props ) {\n\tconst blockEditingMode = useBlockEditingMode();\n\tconst { hasPatternOverridesSource, isEditingSyncedPattern } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getCurrentPostType, getEditedPostAttribute } =\n\t\t\t\tselect( editorStore );\n\n\t\t\treturn {\n\t\t\t\t// For editing link to the site editor if the theme and user permissions support it.\n\t\t\t\thasPatternOverridesSource: !! getBlockBindingsSource(\n\t\t\t\t\t'core/pattern-overrides'\n\t\t\t\t),\n\t\t\t\tisEditingSyncedPattern:\n\t\t\t\t\tgetCurrentPostType() === PATTERN_TYPES.user &&\n\t\t\t\t\tgetEditedPostAttribute( 'meta' )?.wp_pattern_sync_status !==\n\t\t\t\t\t\tPATTERN_SYNC_TYPES.unsynced &&\n\t\t\t\t\tgetEditedPostAttribute( 'wp_pattern_sync_status' ) !==\n\t\t\t\t\t\tPATTERN_SYNC_TYPES.unsynced,\n\t\t\t};\n\t\t},\n\t\t[]\n\t);\n\n\tconst bindings = props.attributes.metadata?.bindings;\n\tconst hasPatternBindings =\n\t\t!! bindings &&\n\t\tObject.values( bindings ).some(\n\t\t\t( binding ) => binding.source === 'core/pattern-overrides'\n\t\t);\n\n\tconst shouldShowPatternOverridesControls =\n\t\tisEditingSyncedPattern && blockEditingMode === 'default';\n\tconst shouldShowResetOverridesControl =\n\t\t! isEditingSyncedPattern &&\n\t\t!! props.attributes.metadata?.name &&\n\t\tblockEditingMode !== 'disabled' &&\n\t\thasPatternBindings;\n\n\tif ( ! hasPatternOverridesSource ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t{ shouldShowPatternOverridesControls && (\n\t\t\t\t<PatternOverridesControls { ...props } />\n\t\t\t) }\n\t\t\t{ shouldShowResetOverridesControl && (\n\t\t\t\t<ResetOverridesControl { ...props } />\n\t\t\t) }\n\t\t</>\n\t);\n}\n\naddFilter(\n\t'editor.BlockEdit',\n\t'core/editor/with-pattern-override-controls',\n\twithPatternOverrideControls\n);\n"],"mappings":";;AAGA,IAAAA,MAAA,GAAAC,OAAA;AACA,IAAAC,SAAA,GAAAD,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AAKA,IAAAM,MAAA,GAAAN,OAAA;AACA,IAAAO,WAAA,GAAAP,OAAA;AAAwC,IAAAQ,WAAA,GAAAR,OAAA;AAdxC;AACA;AACA;;AAQA;AACA;AACA;;AAIA,6EAEA,MAAM;EACLS,wBAAwB;EACxBC,qBAAqB;EACrBC,6BAA6B;EAC7BC,aAAa;EACbC,gCAAgC;EAChCC;AACD,CAAC,GAAG,IAAAC,kBAAM,EAAEC,qBAAoB,CAAC;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,2BAA2B,GAAG,IAAAC,mCAA0B,EAC3DC,SAAS,IAAQC,KAAK,IAAM;EAC7B,MAAMC,gBAAgB,GACrB,CAAC,CAAER,gCAAgC,CAAEO,KAAK,CAACE,IAAI,CAAE;EAElD,oBACC,IAAAd,WAAA,CAAAe,IAAA,EAAAf,WAAA,CAAAgB,QAAA;IAAAC,QAAA,gBACC,IAAAjB,WAAA,CAAAkB,GAAA,EAACP,SAAS;MAAA,GAAiBC;IAAK,GAAjB,MAAqB,CAAC,EACnCA,KAAK,CAACO,UAAU,IAAIN,gBAAgB,iBACrC,IAAAb,WAAA,CAAAkB,GAAA,EAAC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,kBAAkB;EAEnB,IAAK,CAAEd,yBAAyB,EAAG;IAClC,OAAO,IAAI;EACZ;EAEA,oBACC,IAAAvB,WAAA,CAAAe,IAAA,EAAAf,WAAA,CAAAgB,QAAA;IAAAC,QAAA,GACG0B,kCAAkC,iBACnC,IAAA3C,WAAA,CAAAkB,GAAA,EAACjB,wBAAwB;MAAA,GAAMW;IAAK,CAAI,CACxC,EACCgC,+BAA+B,iBAChC,IAAA5C,WAAA,CAAAkB,GAAA,EAAChB,qBAAqB;MAAA,GAAMU;IAAK,CAAI,CACrC;EAAA,CACA,CAAC;AAEL;AAEA,IAAAiC,gBAAS,EACR,kBAAkB,EAClB,4CAA4C,EAC5CpC,2BACD,CAAC","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import {
|
|
4
|
+
import { store as blocksStore, registerBlockBindingsSource } from '@wordpress/blocks';
|
|
5
5
|
import { dispatch } from '@wordpress/data';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -22,9 +22,6 @@ import { unlock } from '../lock-unlock';
|
|
|
22
22
|
* ```
|
|
23
23
|
*/
|
|
24
24
|
export function registerCoreBlockBindingsSources() {
|
|
25
|
-
const {
|
|
26
|
-
registerBlockBindingsSource
|
|
27
|
-
} = unlock(blocksPrivateApis);
|
|
28
25
|
registerBlockBindingsSource(patternOverrides);
|
|
29
26
|
registerBlockBindingsSource(postMeta);
|
|
30
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["store","blocksStore","registerBlockBindingsSource","dispatch","patternOverrides","postMeta","unlock","registerCoreBlockBindingsSources","bootstrapBlockBindingsSourcesFromServer","sources","addBootstrappedBlockBindingsSource","name","args","Object","entries"],"sources":["@wordpress/editor/src/bindings/api.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blocksStore,\n\tregisterBlockBindingsSource,\n} from '@wordpress/blocks';\nimport { dispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport patternOverrides from './pattern-overrides';\nimport postMeta from './post-meta';\nimport { unlock } from '../lock-unlock';\n\n/**\n * Function to register core block bindings sources provided by the editor.\n *\n * @example\n * ```js\n * import { registerCoreBlockBindingsSources } from '@wordpress/editor';\n *\n * registerCoreBlockBindingsSources();\n * ```\n */\nexport function registerCoreBlockBindingsSources() {\n\tregisterBlockBindingsSource( patternOverrides );\n\tregisterBlockBindingsSource( postMeta );\n}\n\n/**\n * Function to bootstrap core block bindings sources defined in the server.\n *\n * @param {Object} sources Object containing the sources to bootstrap.\n *\n * @example\n * ```js\n * import { bootstrapBlockBindingsSourcesFromServer } from '@wordpress/editor';\n *\n * bootstrapBlockBindingsSourcesFromServer( sources );\n * ```\n */\nexport function bootstrapBlockBindingsSourcesFromServer( sources ) {\n\tif ( sources ) {\n\t\tconst { addBootstrappedBlockBindingsSource } = unlock(\n\t\t\tdispatch( blocksStore )\n\t\t);\n\t\tfor ( const [ name, args ] of Object.entries( sources ) ) {\n\t\t\taddBootstrappedBlockBindingsSource( {\n\t\t\t\tname,\n\t\t\t\t...args,\n\t\t\t} );\n\t\t}\n\t}\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,KAAK,IAAIC,WAAW,EACpBC,2BAA2B,QACrB,mBAAmB;AAC1B,SAASC,QAAQ,QAAQ,iBAAiB;;AAE1C;AACA;AACA;AACA,OAAOC,gBAAgB,MAAM,qBAAqB;AAClD,OAAOC,QAAQ,MAAM,aAAa;AAClC,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,gCAAgCA,CAAA,EAAG;EAClDL,2BAA2B,CAAEE,gBAAiB,CAAC;EAC/CF,2BAA2B,CAAEG,QAAS,CAAC;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,uCAAuCA,CAAEC,OAAO,EAAG;EAClE,IAAKA,OAAO,EAAG;IACd,MAAM;MAAEC;IAAmC,CAAC,GAAGJ,MAAM,CACpDH,QAAQ,CAAEF,WAAY,CACvB,CAAC;IACD,KAAM,MAAM,CAAEU,IAAI,EAAEC,IAAI,CAAE,IAAIC,MAAM,CAACC,OAAO,CAAEL,OAAQ,CAAC,EAAG;MACzDC,kCAAkC,CAAE;QACnCC,IAAI;QACJ,GAAGC;MACJ,CAAE,CAAC;IACJ;EACD;AACD","ignoreList":[]}
|
|
@@ -6,7 +6,7 @@ const CONTENT = 'content';
|
|
|
6
6
|
export default {
|
|
7
7
|
name: 'core/pattern-overrides',
|
|
8
8
|
getValues({
|
|
9
|
-
|
|
9
|
+
select,
|
|
10
10
|
clientId,
|
|
11
11
|
context,
|
|
12
12
|
bindings
|
|
@@ -14,7 +14,7 @@ export default {
|
|
|
14
14
|
const patternOverridesContent = context['pattern/overrides'];
|
|
15
15
|
const {
|
|
16
16
|
getBlockAttributes
|
|
17
|
-
} =
|
|
17
|
+
} = select(blockEditorStore);
|
|
18
18
|
const currentBlockAttributes = getBlockAttributes(clientId);
|
|
19
19
|
const overridesValues = {};
|
|
20
20
|
for (const attributeName of Object.keys(bindings)) {
|
|
@@ -32,7 +32,8 @@ export default {
|
|
|
32
32
|
return overridesValues;
|
|
33
33
|
},
|
|
34
34
|
setValues({
|
|
35
|
-
|
|
35
|
+
select,
|
|
36
|
+
dispatch,
|
|
36
37
|
clientId,
|
|
37
38
|
bindings
|
|
38
39
|
}) {
|
|
@@ -40,7 +41,7 @@ export default {
|
|
|
40
41
|
getBlockAttributes,
|
|
41
42
|
getBlockParentsByBlockName,
|
|
42
43
|
getBlocks
|
|
43
|
-
} =
|
|
44
|
+
} = select(blockEditorStore);
|
|
44
45
|
const currentBlockAttributes = getBlockAttributes(clientId);
|
|
45
46
|
const blockName = currentBlockAttributes?.metadata?.name;
|
|
46
47
|
if (!blockName) {
|
|
@@ -61,7 +62,7 @@ export default {
|
|
|
61
62
|
const syncBlocksWithSameName = blocks => {
|
|
62
63
|
for (const block of blocks) {
|
|
63
64
|
if (block.attributes?.metadata?.name === blockName) {
|
|
64
|
-
|
|
65
|
+
dispatch(blockEditorStore).updateBlockAttributes(block.clientId, attributes);
|
|
65
66
|
}
|
|
66
67
|
syncBlocksWithSameName(block.innerBlocks);
|
|
67
68
|
}
|
|
@@ -70,7 +71,7 @@ export default {
|
|
|
70
71
|
return;
|
|
71
72
|
}
|
|
72
73
|
const currentBindingValue = getBlockAttributes(patternClientId)?.[CONTENT];
|
|
73
|
-
|
|
74
|
+
dispatch(blockEditorStore).updateBlockAttributes(patternClientId, {
|
|
74
75
|
[CONTENT]: {
|
|
75
76
|
...currentBindingValue,
|
|
76
77
|
[blockName]: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","blockEditorStore","CONTENT","name","getValues","
|
|
1
|
+
{"version":3,"names":["store","blockEditorStore","CONTENT","name","getValues","select","clientId","context","bindings","patternOverridesContent","getBlockAttributes","currentBlockAttributes","overridesValues","attributeName","Object","keys","overridableValue","metadata","undefined","setValues","dispatch","getBlockParentsByBlockName","getBlocks","blockName","patternClientId","attributes","entries","reduce","attrs","key","newValue","syncBlocksWithSameName","blocks","block","updateBlockAttributes","innerBlocks","currentBindingValue","acc","value","canUserEditValue"],"sources":["@wordpress/editor/src/bindings/pattern-overrides.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\nconst CONTENT = 'content';\n\nexport default {\n\tname: 'core/pattern-overrides',\n\tgetValues( { select, clientId, context, bindings } ) {\n\t\tconst patternOverridesContent = context[ 'pattern/overrides' ];\n\t\tconst { getBlockAttributes } = select( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\n\t\tconst overridesValues = {};\n\t\tfor ( const attributeName of Object.keys( bindings ) ) {\n\t\t\tconst overridableValue =\n\t\t\t\tpatternOverridesContent?.[\n\t\t\t\t\tcurrentBlockAttributes?.metadata?.name\n\t\t\t\t]?.[ attributeName ];\n\n\t\t\t// If it has not been overriden, return the original value.\n\t\t\t// Check undefined because empty string is a valid value.\n\t\t\tif ( overridableValue === undefined ) {\n\t\t\t\toverridesValues[ attributeName ] =\n\t\t\t\t\tcurrentBlockAttributes[ attributeName ];\n\t\t\t\tcontinue;\n\t\t\t} else {\n\t\t\t\toverridesValues[ attributeName ] =\n\t\t\t\t\toverridableValue === '' ? undefined : overridableValue;\n\t\t\t}\n\t\t}\n\t\treturn overridesValues;\n\t},\n\tsetValues( { select, dispatch, clientId, bindings } ) {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName, getBlocks } =\n\t\t\tselect( blockEditorStore );\n\t\tconst currentBlockAttributes = getBlockAttributes( clientId );\n\t\tconst blockName = currentBlockAttributes?.metadata?.name;\n\t\tif ( ! blockName ) {\n\t\t\treturn;\n\t\t}\n\n\t\tconst [ patternClientId ] = getBlockParentsByBlockName(\n\t\t\tclientId,\n\t\t\t'core/block',\n\t\t\ttrue\n\t\t);\n\n\t\t// Extract the updated attributes from the source bindings.\n\t\tconst attributes = Object.entries( bindings ).reduce(\n\t\t\t( attrs, [ key, { newValue } ] ) => {\n\t\t\t\tattrs[ key ] = newValue;\n\t\t\t\treturn attrs;\n\t\t\t},\n\t\t\t{}\n\t\t);\n\n\t\t// If there is no pattern client ID, sync blocks with the same name and same attributes.\n\t\tif ( ! patternClientId ) {\n\t\t\tconst syncBlocksWithSameName = ( blocks ) => {\n\t\t\t\tfor ( const block of blocks ) {\n\t\t\t\t\tif ( block.attributes?.metadata?.name === blockName ) {\n\t\t\t\t\t\tdispatch( blockEditorStore ).updateBlockAttributes(\n\t\t\t\t\t\t\tblock.clientId,\n\t\t\t\t\t\t\tattributes\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tsyncBlocksWithSameName( block.innerBlocks );\n\t\t\t\t}\n\t\t\t};\n\n\t\t\tsyncBlocksWithSameName( getBlocks() );\n\t\t\treturn;\n\t\t}\n\t\tconst currentBindingValue =\n\t\t\tgetBlockAttributes( patternClientId )?.[ CONTENT ];\n\n\t\tdispatch( blockEditorStore ).updateBlockAttributes( patternClientId, {\n\t\t\t[ CONTENT ]: {\n\t\t\t\t...currentBindingValue,\n\t\t\t\t[ blockName ]: {\n\t\t\t\t\t...currentBindingValue?.[ blockName ],\n\t\t\t\t\t...Object.entries( attributes ).reduce(\n\t\t\t\t\t\t( acc, [ key, value ] ) => {\n\t\t\t\t\t\t\t// TODO: We need a way to represent `undefined` in the serialized overrides.\n\t\t\t\t\t\t\t// Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871\n\t\t\t\t\t\t\t// We use an empty string to represent undefined for now until\n\t\t\t\t\t\t\t// we support a richer format for overrides and the block bindings API.\n\t\t\t\t\t\t\tacc[ key ] = value === undefined ? '' : value;\n\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t},\n\t\t\t\t\t\t{}\n\t\t\t\t\t),\n\t\t\t\t},\n\t\t\t},\n\t\t} );\n\t},\n\tcanUserEditValue: () => true,\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AAEnE,MAAMC,OAAO,GAAG,SAAS;AAEzB,eAAe;EACdC,IAAI,EAAE,wBAAwB;EAC9BC,SAASA,CAAE;IAAEC,MAAM;IAAEC,QAAQ;IAAEC,OAAO;IAAEC;EAAS,CAAC,EAAG;IACpD,MAAMC,uBAAuB,GAAGF,OAAO,CAAE,mBAAmB,CAAE;IAC9D,MAAM;MAAEG;IAAmB,CAAC,GAAGL,MAAM,CAAEJ,gBAAiB,CAAC;IACzD,MAAMU,sBAAsB,GAAGD,kBAAkB,CAAEJ,QAAS,CAAC;IAE7D,MAAMM,eAAe,GAAG,CAAC,CAAC;IAC1B,KAAM,MAAMC,aAAa,IAAIC,MAAM,CAACC,IAAI,CA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,IAAKC,KAAK,CAACR,UAAU,EAAER,QAAQ,EAAEd,IAAI,KAAKoB,SAAS,EAAG;YACrDH,QAAQ,CAAEnB,gBAAiB,CAAC,CAACiC,qBAAqB,CACjDD,KAAK,CAAC3B,QAAQ,EACdmB,UACD,CAAC;UACF;UACAM,sBAAsB,CAAEE,KAAK,CAACE,WAAY,CAAC;QAC5C;MACD,CAAC;MAEDJ,sBAAsB,CAAET,SAAS,CAAC,CAAE,CAAC;MACrC;IACD;IACA,MAAMc,mBAAmB,GACxB1B,kBAAkB,CAAEc,eAAgB,CAAC,GAAItB,OAAO,CAAE;IAEnDkB,QAAQ,CAAEnB,gBAAiB,CAAC,CAACiC,qBAAqB,CAAEV,eAAe,EAAE;MACpE,CAAEtB,OAAO,GAAI;QACZ,GAAGkC,mBAAmB;QACtB,CAAEb,SAAS,GAAI;UACd,GAAGa,mBAAmB,GAAIb,SAAS,CAAE;UACrC,GAAGT,MAAM,CAACY,OAAO,CAAED,UAAW,CAAC,CAACE,MAAM,CACrC,CAAEU,GAAG,EAAE,CAAER,GAAG,EAAES,KAAK,CAAE,KAAM;YAC1B;YACA;YACA;YACA;YACAD,GAAG,CAAER,GAAG,CAAE,GAAGS,KAAK,KAAKpB,SAAS,GAAG,EAAE,GAAGoB,KAAK;YAC7C,OAAOD,GAAG;UACX,CAAC,EACD,CAAC,CACF;QACD;MACD;IACD,CAAE,CAAC;EACJ,CAAC;EACDE,gBAAgB,EAAEA,CAAA,KAAM;AACzB,CAAC","ignoreList":[]}
|
|
@@ -15,8 +15,8 @@ import { unlock } from '../lock-unlock';
|
|
|
15
15
|
* If the value is not available based on context, like in templates,
|
|
16
16
|
* it falls back to the default value, label, or key.
|
|
17
17
|
*
|
|
18
|
-
* @param {Object}
|
|
19
|
-
* @param {Object} context
|
|
18
|
+
* @param {Object} select The select function from the data store.
|
|
19
|
+
* @param {Object} context The context provided.
|
|
20
20
|
* @return {Object} List of post meta fields with their value and label.
|
|
21
21
|
*
|
|
22
22
|
* @example
|
|
@@ -34,13 +34,13 @@ import { unlock } from '../lock-unlock';
|
|
|
34
34
|
* }
|
|
35
35
|
* ```
|
|
36
36
|
*/
|
|
37
|
-
function getPostMetaFields(
|
|
37
|
+
function getPostMetaFields(select, context) {
|
|
38
38
|
const {
|
|
39
39
|
getEditedEntityRecord
|
|
40
|
-
} =
|
|
40
|
+
} = select(coreDataStore);
|
|
41
41
|
const {
|
|
42
42
|
getRegisteredPostMeta
|
|
43
|
-
} = unlock(
|
|
43
|
+
} = unlock(select(coreDataStore));
|
|
44
44
|
let entityMetaValues;
|
|
45
45
|
// Try to get the current entity meta values.
|
|
46
46
|
if (context?.postType && context?.postId) {
|
|
@@ -69,11 +69,11 @@ function getPostMetaFields(registry, context) {
|
|
|
69
69
|
export default {
|
|
70
70
|
name: 'core/post-meta',
|
|
71
71
|
getValues({
|
|
72
|
-
|
|
72
|
+
select,
|
|
73
73
|
context,
|
|
74
74
|
bindings
|
|
75
75
|
}) {
|
|
76
|
-
const metaFields = getPostMetaFields(
|
|
76
|
+
const metaFields = getPostMetaFields(select, context);
|
|
77
77
|
const newValues = {};
|
|
78
78
|
for (const [attributeName, source] of Object.entries(bindings)) {
|
|
79
79
|
var _ref;
|
|
@@ -88,7 +88,7 @@ export default {
|
|
|
88
88
|
return newValues;
|
|
89
89
|
},
|
|
90
90
|
setValues({
|
|
91
|
-
|
|
91
|
+
dispatch,
|
|
92
92
|
context,
|
|
93
93
|
bindings
|
|
94
94
|
}) {
|
|
@@ -99,12 +99,12 @@ export default {
|
|
|
99
99
|
}) => {
|
|
100
100
|
newMeta[args.key] = newValue;
|
|
101
101
|
});
|
|
102
|
-
|
|
102
|
+
dispatch(coreDataStore).editEntityRecord('postType', context?.postType, context?.postId, {
|
|
103
103
|
meta: newMeta
|
|
104
104
|
});
|
|
105
105
|
},
|
|
106
106
|
canUserEditValue({
|
|
107
|
-
|
|
107
|
+
select,
|
|
108
108
|
context,
|
|
109
109
|
args
|
|
110
110
|
}) {
|
|
@@ -112,25 +112,25 @@ export default {
|
|
|
112
112
|
if (context?.query || context?.queryId) {
|
|
113
113
|
return false;
|
|
114
114
|
}
|
|
115
|
-
const postType = context?.postType ||
|
|
115
|
+
const postType = context?.postType || select(editorStore).getCurrentPostType();
|
|
116
116
|
|
|
117
117
|
// Check that editing is happening in the post editor and not a template.
|
|
118
118
|
if (postType === 'wp_template') {
|
|
119
119
|
return false;
|
|
120
120
|
}
|
|
121
|
-
const fieldValue = getPostMetaFields(
|
|
121
|
+
const fieldValue = getPostMetaFields(select, context)?.[args.key]?.value;
|
|
122
122
|
// Empty string or `false` could be a valid value, so we need to check if the field value is undefined.
|
|
123
123
|
if (fieldValue === undefined) {
|
|
124
124
|
return false;
|
|
125
125
|
}
|
|
126
126
|
// Check that custom fields metabox is not enabled.
|
|
127
|
-
const areCustomFieldsEnabled =
|
|
127
|
+
const areCustomFieldsEnabled = select(editorStore).getEditorSettings().enableCustomFields;
|
|
128
128
|
if (areCustomFieldsEnabled) {
|
|
129
129
|
return false;
|
|
130
130
|
}
|
|
131
131
|
|
|
132
132
|
// Check that the user has the capability to edit post meta.
|
|
133
|
-
const canUserEdit =
|
|
133
|
+
const canUserEdit = select(coreDataStore).canUser('update', {
|
|
134
134
|
kind: 'postType',
|
|
135
135
|
name: context?.postType,
|
|
136
136
|
id: context?.postId
|
|
@@ -141,10 +141,10 @@ export default {
|
|
|
141
141
|
return true;
|
|
142
142
|
},
|
|
143
143
|
getFieldsList({
|
|
144
|
-
|
|
144
|
+
select,
|
|
145
145
|
context
|
|
146
146
|
}) {
|
|
147
|
-
return getPostMetaFields(
|
|
147
|
+
return getPostMetaFields(select, context);
|
|
148
148
|
}
|
|
149
149
|
};
|
|
150
150
|
//# sourceMappingURL=post-meta.js.map
|