@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.
@@ -1 +1 @@
1
- {"version":3,"names":["store","coreDataStore","editorStore","unlock","getPostMetaFields","registry","context","getEditedEntityRecord","select","getRegisteredPostMeta","entityMetaValues","postType","postId","meta","registeredFields","metaFields","Object","entries","forEach","key","props","charAt","_entityMetaValues$key","label","title","value","default","undefined","keys","length","name","getValues","bindings","newValues","attributeName","source","_ref","fieldKey","args","fieldValue","fieldLabel","setValues","newMeta","values","newValue","dispatch","editEntityRecord","canUserEditValue","query","queryId","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} registry The registry context exposed through `useRegistry`.\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( registry, context ) {\n\tconst { getEditedEntityRecord } = registry.select( coreDataStore );\n\tconst { getRegisteredPostMeta } = unlock(\n\t\tregistry.select( coreDataStore )\n\t);\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( { registry, context, bindings } ) {\n\t\tconst metaFields = getPostMetaFields( registry, 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( { registry, 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\t\tregistry\n\t\t\t.dispatch( coreDataStore )\n\t\t\t.editEntityRecord( 'postType', context?.postType, context?.postId, {\n\t\t\t\tmeta: newMeta,\n\t\t\t} );\n\t},\n\tcanUserEditValue( { registry, 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 ||\n\t\t\tregistry.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( registry, 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 = registry\n\t\t\t.select( editorStore )\n\t\t\t.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 = registry\n\t\t\t.select( coreDataStore )\n\t\t\t.canUser( 'update', {\n\t\t\t\tkind: 'postType',\n\t\t\t\tname: context?.postType,\n\t\t\t\tid: context?.postId,\n\t\t\t} );\n\t\tif ( ! canUserEdit ) {\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t},\n\tgetFieldsList( { registry, context } ) {\n\t\treturn getPostMetaFields( registry, context );\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,aAAa,QAAQ,sBAAsB;;AAE7D;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,UAAU;AAC/C,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,iBAAiBA,CAAEC,QAAQ,EAAEC,OAAO,EAAG;EAC/C,MAAM;IAAEC;EAAsB,CAAC,GAAGF,QAAQ,CAACG,MAAM,CAAEP,aAAc,CAAC;EAClE,MAAM;IAAEQ;EAAsB,CAAC,GAAGN,MAAM,CACvCE,QAAQ,CAACG,MAAM,CAAEP,aAAc,CAChC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ACgD,kBAAkB,CAAC,CAAC;;IAEpD;IACA,IAAKvC,QAAQ,KAAK,aAAa,EAAG;MACjC,OAAO,KAAK;IACb;IAEA,MAAM4B,UAAU,GAAGnC,iBAAiB,CAAEC,QAAQ,EAAEC,OAAQ,CAAC,GAAIgC,IAAI,CAACnB,GAAG,CAAE,EACpEM,KAAK;IACR;IACA,IAAKc,UAAU,KAAKZ,SAAS,EAAG;MAC/B,OAAO,KAAK;IACb;IACA;IACA,MAAMwB,sBAAsB,GAAG9C,QAAQ,CACrCG,MAAM,CAAEN,WAAY,CAAC,CACrBkD,iBAAiB,CAAC,CAAC,CAACC,kBAAkB;IACxC,IAAKF,sBAAsB,EAAG;MAC7B,OAAO,KAAK;IACb;;IAEA;IACA,MAAMG,WAAW,GAAGjD,QAAQ,CAC1BG,MAAM,CAAEP,aAAc,CAAC,CACvBsD,OAAO,CAAE,QAAQ,EAAE;MACnBC,IAAI,EAAE,UAAU;MAChB1B,IAAI,EAAExB,OAAO,EAAEK,QAAQ;MACvB8C,EAAE,EAAEnD,OAAO,EAAEM;IACd,CAAE,CAAC;IACJ,IAAK,CAAE0C,WAAW,EAAG;MACpB,OAAO,KAAK;IACb;IAEA,OAAO,IAAI;EACZ,CAAC;EACDI,aAAaA,CAAE;IAAErD,QAAQ;IAAEC;EAAQ,CAAC,EAAG;IACtC,OAAOF,iBAAiB,CAAEC,QAAQ,EAAEC,OAAQ,CAAC;EAC9C;AACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["store","coreDataStore","editorStore","unlock","getPostMetaFields","select","context","getEditedEntityRecord","getRegisteredPostMeta","entityMetaValues","postType","postId","meta","registeredFields","metaFields","Object","entries","forEach","key","props","charAt","_entityMetaValues$key","label","title","value","default","undefined","keys","length","name","getValues","bindings","newValues","attributeName","source","_ref","fieldKey","args","fieldValue","fieldLabel","setValues","dispatch","newMeta","values","newValue","editEntityRecord","canUserEditValue","query","queryId","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":"AAAA;AACA;AACA;AACA,SAASA,KAAK,IAAIC,aAAa,QAAQ,sBAAsB;;AAE7D;AACA;AACA;AACA,SAASD,KAAK,IAAIE,WAAW,QAAQ,UAAU;AAC/C,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,SAASC,iBAAiBA,CAAEC,MAAM,EAAEC,OAAO,EAAG;EAC7C,MAAM;IAAEC;EAAsB,CAAC,GAAGF,MAAM,CAAEJ,aAAc,CAAC;EACzD,MAAM;IAAEO;EAAsB,CAAC,GAAGL,MAAM,CAAEE,MAAM,CAAEJ,aAAc,CAAE,CAAC;EAEnE,IAAIQ,gBAAgB;EACpB;EACA,IAAKH,OAAO,EAAEI,QAAQ,IAAIJ,OAAO,EAAEK,MAAM,EAAG;IAC3CF,gBAAgB,GAAGF,qBAAqB,CACvC,UAAU,EACVD,OAAO,EAAEI,QAAQ,EACjBJ,OAAO,EAAEK,MACV,CAAC,CAACC,IAAI;EACP;EAEA,MAAMC,gBAAgB,GAAGL,qBAAqB,CAAEF,OAAO,EAAEI,QAAS,CAAC;EACnE,MAAMI,UAAU,GAAG,CAAC,CAAC;EACrBC,MAAM,CAACC,OAAO,CAAEH,gBAAgB,IAAI,CAAC,CAAE,CAAC,CAACI,OAAO,CAAE,CAAE,CAAEC,GAAG,EAAEC,KAAK,CAAE,KAAM;IACvE;IACA,IAAKD,GAAG,KAAK,WAAW,IAAIA,GAAG,CAACE,MAAM,CAAE,CAAE,CAAC,KAAK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EAAEvB,OAAO,EAAEI,QAAQ;MACvB8C,EAAE,EAAElD,OAAO,EAAEK;IACd,CAAE,CAAC;IACH,IAAK,CAAE0C,WAAW,EAAG;MACpB,OAAO,KAAK;IACb;IAEA,OAAO,IAAI;EACZ,CAAC;EACDI,aAAaA,CAAE;IAAEpD,MAAM;IAAEC;EAAQ,CAAC,EAAG;IACpC,OAAOF,iBAAiB,CAAEC,MAAM,EAAEC,OAAQ,CAAC;EAC5C;AACD,CAAC","ignoreList":[]}
@@ -6,7 +6,7 @@ import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
6
6
  import { createHigherOrderComponent } from '@wordpress/compose';
7
7
  import { useBlockEditingMode } from '@wordpress/block-editor';
8
8
  import { useSelect } from '@wordpress/data';
9
- import { store as blocksStore } from '@wordpress/blocks';
9
+ import { getBlockBindingsSource } from '@wordpress/blocks';
10
10
 
11
11
  /**
12
12
  * Internal dependencies
@@ -55,9 +55,6 @@ function ControlsWithStoreSubscription(props) {
55
55
  hasPatternOverridesSource,
56
56
  isEditingSyncedPattern
57
57
  } = useSelect(select => {
58
- const {
59
- getBlockBindingsSource
60
- } = unlock(select(blocksStore));
61
58
  const {
62
59
  getCurrentPostType,
63
60
  getEditedPostAttribute
@@ -1 +1 @@
1
- {"version":3,"names":["addFilter","privateApis","patternsPrivateApis","createHigherOrderComponent","useBlockEditingMode","useSelect","store","blocksStore","editorStore","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PatternOverridesControls","ResetOverridesControl","PatternOverridesBlockControls","PATTERN_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","PATTERN_SYNC_TYPES","withPatternOverrideControls","BlockEdit","props","isSupportedBlock","name","children","isSelected","ControlsWithStoreSubscription","blockEditingMode","hasPatternOverridesSource","isEditingSyncedPattern","select","getBlockBindingsSource","getCurrentPostType","getEditedPostAttribute","user","wp_pattern_sync_status","unsynced","bindings","attributes","metadata","hasPatternBindings","Object","values","some","binding","source","shouldShowPatternOverridesControls","shouldShowResetOverridesControl"],"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 { store as blocksStore } 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 { getBlockBindingsSource } = unlock( select( blocksStore ) );\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":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,WAAW,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CAAC;AAEL;AAEAxB,SAAS,CACR,kBAAkB,EAClB,4CAA4C,EAC5CsB,2BACD,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["addFilter","privateApis","patternsPrivateApis","createHigherOrderComponent","useBlockEditingMode","useSelect","getBlockBindingsSource","store","editorStore","unlock","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","PatternOverridesControls","ResetOverridesControl","PatternOverridesBlockControls","PATTERN_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","PATTERN_SYNC_TYPES","withPatternOverrideControls","BlockEdit","props","isSupportedBlock","name","children","isSelected","ControlsWithStoreSubscription","blockEditingMode","hasPatternOverridesSource","isEditingSyncedPattern","select","getCurrentPostType","getEditedPostAttribute","user","wp_pattern_sync_status","unsynced","bindings","attributes","metadata","hasPatternBindings","Object","values","some","binding","source","shouldShowPatternOverridesControls","shouldShowResetOverridesControl"],"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":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,kBAAkB;AAC5C,SAASC,WAAW,IAAIC,mBAAmB,QAAQ,qBAAqB;AACxE,SAASC,0BAA0B,QAAQ,oBAAoB;AAC/D,SAASC,mBAAmB,QAAQ,yBAAyB;AAC7D,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,sBAAsB,QAAQ,mBAAmB;;AAE1D;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,UAAU;AAC/C,SAASC,MAAM,QAAQ,gBAAgB;;AAEvC;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAEA,MAAM;EACLC,wBAAwB;EACxBC,qBAAqB;EACrBC,6BAA6B;EAC7BC,aAAa;EACbC,gCAAgC;EAChCC;AACD,CAAC,GAAGZ,MAAM,CAAEP,mBAAoB,CAAC;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMoB,2BAA2B,GAAGnB,0BAA0B,CAC3DoB,SAAS,IAAQC,KAAK,IAAM;EAC7B,MAAMC,gBAAgB,GACrB,CAAC,CAAEL,gCAAgC,CAAEI,KAAK,CAACE,IAAI,CAAE;EAElD,oBACCX,KA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EjB,sBAAsB,IACxB,CAAC,CAAER,KAAK,CAACgB,UAAU,CAACC,QAAQ,EAAEf,IAAI,IAClCI,gBAAgB,KAAK,UAAU,IAC/BY,kBAAkB;EAEnB,IAAK,CAAEX,yBAAyB,EAAG;IAClC,OAAO,IAAI;EACZ;EAEA,oBACChB,KAAA,CAAAF,SAAA;IAAAc,QAAA,GACGqB,kCAAkC,iBACnCrC,IAAA,CAACK,wBAAwB;MAAA,GAAMQ;IAAK,CAAI,CACxC,EACCyB,+BAA+B,iBAChCtC,IAAA,CAACM,qBAAqB;MAAA,GAAMO;IAAK,CAAI,CACrC;EAAA,CACA,CAAC;AAEL;AAEAxB,SAAS,CACR,kBAAkB,EAClB,4CAA4C,EAC5CsB,2BACD,CAAC","ignoreList":[]}
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/bindings/api.js"],"names":[],"mappings":"AAgBA;;;;;;;;;GASG;AACH,yDAIC;AAED;;;;;;;;;;;GAWG;AACH,iEATW,MAAM,QAqBhB"}
1
+ {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/bindings/api.js"],"names":[],"mappings":"AAgBA;;;;;;;;;GASG;AACH,yDAGC;AAED;;;;;;;;;;;GAWG;AACH,iEATW,MAAM,QAqBhB"}
@@ -1,13 +1,14 @@
1
1
  declare namespace _default {
2
2
  let name: string;
3
- function getValues({ registry, clientId, context, bindings }: {
4
- registry: any;
3
+ function getValues({ select, clientId, context, bindings }: {
4
+ select: any;
5
5
  clientId: any;
6
6
  context: any;
7
7
  bindings: any;
8
8
  }): {};
9
- function setValues({ registry, clientId, bindings }: {
10
- registry: any;
9
+ function setValues({ select, dispatch, clientId, bindings }: {
10
+ select: any;
11
+ dispatch: any;
11
12
  clientId: any;
12
13
  bindings: any;
13
14
  }): void;
@@ -1 +1 @@
1
- {"version":3,"file":"pattern-overrides.d.ts","sourceRoot":"","sources":["../../src/bindings/pattern-overrides.js"],"names":[],"mappings":";;IASC;;;;;WAwBC;IACD;;;;aAkEC;IACiB,qCAAU"}
1
+ {"version":3,"file":"pattern-overrides.d.ts","sourceRoot":"","sources":["../../src/bindings/pattern-overrides.js"],"names":[],"mappings":";;IASC;;;;;WAwBC;IACD;;;;;aA+DC;IACiB,qCAAU"}
@@ -1,22 +1,22 @@
1
1
  declare namespace _default {
2
2
  let name: string;
3
- function getValues({ registry, context, bindings }: {
4
- registry: any;
3
+ function getValues({ select, context, bindings }: {
4
+ select: any;
5
5
  context: any;
6
6
  bindings: any;
7
7
  }): {};
8
- function setValues({ registry, context, bindings }: {
9
- registry: any;
8
+ function setValues({ dispatch, context, bindings }: {
9
+ dispatch: any;
10
10
  context: any;
11
11
  bindings: any;
12
12
  }): void;
13
- function canUserEditValue({ registry, context, args }: {
14
- registry: any;
13
+ function canUserEditValue({ select, context, args }: {
14
+ select: any;
15
15
  context: any;
16
16
  args: any;
17
17
  }): boolean;
18
- function getFieldsList({ registry, context }: {
19
- registry: any;
18
+ function getFieldsList({ select, context }: {
19
+ select: any;
20
20
  context: any;
21
21
  }): Object;
22
22
  }
@@ -1 +1 @@
1
- {"version":3,"file":"post-meta.d.ts","sourceRoot":"","sources":["../../src/bindings/post-meta.js"],"names":[],"mappings":";;IA6EC;;;;WAYC;IACD;;;;aAUC;IACD;;;;gBA0CC;IACD;;;eAEC"}
1
+ {"version":3,"file":"post-meta.d.ts","sourceRoot":"","sources":["../../src/bindings/post-meta.js"],"names":[],"mappings":";;IA2EC;;;;WAYC;IACD;;;;aAcC;IACD;;;;gBAsCC;IACD;;;eAEC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "14.8.5",
3
+ "version": "14.8.6",
4
4
  "description": "Enhanced block editor for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -35,35 +35,35 @@
35
35
  "@wordpress/a11y": "^4.8.2",
36
36
  "@wordpress/api-fetch": "^7.8.2",
37
37
  "@wordpress/blob": "^4.8.1",
38
- "@wordpress/block-editor": "^14.3.3",
39
- "@wordpress/blocks": "^13.8.3",
40
- "@wordpress/commands": "^1.8.3",
41
- "@wordpress/components": "^28.8.3",
38
+ "@wordpress/block-editor": "^14.3.4",
39
+ "@wordpress/blocks": "^13.8.4",
40
+ "@wordpress/commands": "^1.8.4",
41
+ "@wordpress/components": "^28.8.4",
42
42
  "@wordpress/compose": "^7.8.3",
43
- "@wordpress/core-data": "^7.8.3",
43
+ "@wordpress/core-data": "^7.8.4",
44
44
  "@wordpress/data": "^10.8.3",
45
- "@wordpress/dataviews": "^4.4.3",
45
+ "@wordpress/dataviews": "^4.4.4",
46
46
  "@wordpress/date": "^5.8.2",
47
47
  "@wordpress/deprecated": "^4.8.2",
48
48
  "@wordpress/dom": "^4.8.2",
49
49
  "@wordpress/element": "^6.8.1",
50
- "@wordpress/fields": "^0.0.4",
50
+ "@wordpress/fields": "^0.0.5",
51
51
  "@wordpress/hooks": "^4.8.2",
52
52
  "@wordpress/html-entities": "^4.8.1",
53
53
  "@wordpress/i18n": "^5.8.2",
54
54
  "@wordpress/icons": "^10.8.2",
55
- "@wordpress/interface": "^6.8.3",
55
+ "@wordpress/interface": "^6.8.4",
56
56
  "@wordpress/keyboard-shortcuts": "^5.8.3",
57
57
  "@wordpress/keycodes": "^4.8.2",
58
58
  "@wordpress/media-utils": "^5.8.2",
59
59
  "@wordpress/notices": "^5.8.3",
60
- "@wordpress/patterns": "^2.8.3",
61
- "@wordpress/plugins": "^7.8.3",
62
- "@wordpress/preferences": "^4.8.3",
60
+ "@wordpress/patterns": "^2.8.4",
61
+ "@wordpress/plugins": "^7.8.4",
62
+ "@wordpress/preferences": "^4.8.4",
63
63
  "@wordpress/private-apis": "^1.8.1",
64
- "@wordpress/reusable-blocks": "^5.8.3",
64
+ "@wordpress/reusable-blocks": "^5.8.4",
65
65
  "@wordpress/rich-text": "^7.8.3",
66
- "@wordpress/server-side-render": "^5.8.3",
66
+ "@wordpress/server-side-render": "^5.8.4",
67
67
  "@wordpress/url": "^4.8.1",
68
68
  "@wordpress/warning": "^3.8.1",
69
69
  "@wordpress/wordcount": "^4.8.1",
@@ -86,5 +86,5 @@
86
86
  "publishConfig": {
87
87
  "access": "public"
88
88
  },
89
- "gitHead": "6187079697e13c3292eb098d6338523a6676c6e8"
89
+ "gitHead": "07c75154341d1e5a1b8aaa1c226029b6666a52a9"
90
90
  }
@@ -2,8 +2,8 @@
2
2
  * WordPress dependencies
3
3
  */
4
4
  import {
5
- privateApis as blocksPrivateApis,
6
5
  store as blocksStore,
6
+ registerBlockBindingsSource,
7
7
  } from '@wordpress/blocks';
8
8
  import { dispatch } from '@wordpress/data';
9
9
 
@@ -25,7 +25,6 @@ import { unlock } from '../lock-unlock';
25
25
  * ```
26
26
  */
27
27
  export function registerCoreBlockBindingsSources() {
28
- const { registerBlockBindingsSource } = unlock( blocksPrivateApis );
29
28
  registerBlockBindingsSource( patternOverrides );
30
29
  registerBlockBindingsSource( postMeta );
31
30
  }
@@ -7,9 +7,9 @@ const CONTENT = 'content';
7
7
 
8
8
  export default {
9
9
  name: 'core/pattern-overrides',
10
- getValues( { registry, clientId, context, bindings } ) {
10
+ getValues( { select, clientId, context, bindings } ) {
11
11
  const patternOverridesContent = context[ 'pattern/overrides' ];
12
- const { getBlockAttributes } = registry.select( blockEditorStore );
12
+ const { getBlockAttributes } = select( blockEditorStore );
13
13
  const currentBlockAttributes = getBlockAttributes( clientId );
14
14
 
15
15
  const overridesValues = {};
@@ -32,9 +32,9 @@ export default {
32
32
  }
33
33
  return overridesValues;
34
34
  },
35
- setValues( { registry, clientId, bindings } ) {
35
+ setValues( { select, dispatch, clientId, bindings } ) {
36
36
  const { getBlockAttributes, getBlockParentsByBlockName, getBlocks } =
37
- registry.select( blockEditorStore );
37
+ select( blockEditorStore );
38
38
  const currentBlockAttributes = getBlockAttributes( clientId );
39
39
  const blockName = currentBlockAttributes?.metadata?.name;
40
40
  if ( ! blockName ) {
@@ -61,12 +61,10 @@ export default {
61
61
  const syncBlocksWithSameName = ( blocks ) => {
62
62
  for ( const block of blocks ) {
63
63
  if ( block.attributes?.metadata?.name === blockName ) {
64
- registry
65
- .dispatch( blockEditorStore )
66
- .updateBlockAttributes(
67
- block.clientId,
68
- attributes
69
- );
64
+ dispatch( blockEditorStore ).updateBlockAttributes(
65
+ block.clientId,
66
+ attributes
67
+ );
70
68
  }
71
69
  syncBlocksWithSameName( block.innerBlocks );
72
70
  }
@@ -77,27 +75,26 @@ export default {
77
75
  }
78
76
  const currentBindingValue =
79
77
  getBlockAttributes( patternClientId )?.[ CONTENT ];
80
- registry
81
- .dispatch( blockEditorStore )
82
- .updateBlockAttributes( patternClientId, {
83
- [ CONTENT ]: {
84
- ...currentBindingValue,
85
- [ blockName ]: {
86
- ...currentBindingValue?.[ blockName ],
87
- ...Object.entries( attributes ).reduce(
88
- ( acc, [ key, value ] ) => {
89
- // TODO: We need a way to represent `undefined` in the serialized overrides.
90
- // Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871
91
- // We use an empty string to represent undefined for now until
92
- // we support a richer format for overrides and the block bindings API.
93
- acc[ key ] = value === undefined ? '' : value;
94
- return acc;
95
- },
96
- {}
97
- ),
98
- },
78
+
79
+ dispatch( blockEditorStore ).updateBlockAttributes( patternClientId, {
80
+ [ CONTENT ]: {
81
+ ...currentBindingValue,
82
+ [ blockName ]: {
83
+ ...currentBindingValue?.[ blockName ],
84
+ ...Object.entries( attributes ).reduce(
85
+ ( acc, [ key, value ] ) => {
86
+ // TODO: We need a way to represent `undefined` in the serialized overrides.
87
+ // Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871
88
+ // We use an empty string to represent undefined for now until
89
+ // we support a richer format for overrides and the block bindings API.
90
+ acc[ key ] = value === undefined ? '' : value;
91
+ return acc;
92
+ },
93
+ {}
94
+ ),
99
95
  },
100
- } );
96
+ },
97
+ } );
101
98
  },
102
99
  canUserEditValue: () => true,
103
100
  };
@@ -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} registry The registry context exposed through `useRegistry`.
19
- * @param {Object} context The context provided.
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,11 +34,9 @@ import { unlock } from '../lock-unlock';
34
34
  * }
35
35
  * ```
36
36
  */
37
- function getPostMetaFields( registry, context ) {
38
- const { getEditedEntityRecord } = registry.select( coreDataStore );
39
- const { getRegisteredPostMeta } = unlock(
40
- registry.select( coreDataStore )
41
- );
37
+ function getPostMetaFields( select, context ) {
38
+ const { getEditedEntityRecord } = select( coreDataStore );
39
+ const { getRegisteredPostMeta } = unlock( select( coreDataStore ) );
42
40
 
43
41
  let entityMetaValues;
44
42
  // Try to get the current entity meta values.
@@ -75,8 +73,8 @@ function getPostMetaFields( registry, context ) {
75
73
 
76
74
  export default {
77
75
  name: 'core/post-meta',
78
- getValues( { registry, context, bindings } ) {
79
- const metaFields = getPostMetaFields( registry, context );
76
+ getValues( { select, context, bindings } ) {
77
+ const metaFields = getPostMetaFields( select, context );
80
78
 
81
79
  const newValues = {};
82
80
  for ( const [ attributeName, source ] of Object.entries( bindings ) ) {
@@ -88,61 +86,61 @@ export default {
88
86
  }
89
87
  return newValues;
90
88
  },
91
- setValues( { registry, context, bindings } ) {
89
+ setValues( { dispatch, context, bindings } ) {
92
90
  const newMeta = {};
93
91
  Object.values( bindings ).forEach( ( { args, newValue } ) => {
94
92
  newMeta[ args.key ] = newValue;
95
93
  } );
96
- registry
97
- .dispatch( coreDataStore )
98
- .editEntityRecord( 'postType', context?.postType, context?.postId, {
94
+
95
+ dispatch( coreDataStore ).editEntityRecord(
96
+ 'postType',
97
+ context?.postType,
98
+ context?.postId,
99
+ {
99
100
  meta: newMeta,
100
- } );
101
+ }
102
+ );
101
103
  },
102
- canUserEditValue( { registry, context, args } ) {
104
+ canUserEditValue( { select, context, args } ) {
103
105
  // Lock editing in query loop.
104
106
  if ( context?.query || context?.queryId ) {
105
107
  return false;
106
108
  }
107
109
 
108
110
  const postType =
109
- context?.postType ||
110
- registry.select( editorStore ).getCurrentPostType();
111
+ context?.postType || select( editorStore ).getCurrentPostType();
111
112
 
112
113
  // Check that editing is happening in the post editor and not a template.
113
114
  if ( postType === 'wp_template' ) {
114
115
  return false;
115
116
  }
116
117
 
117
- const fieldValue = getPostMetaFields( registry, context )?.[ args.key ]
118
+ const fieldValue = getPostMetaFields( select, context )?.[ args.key ]
118
119
  ?.value;
119
120
  // Empty string or `false` could be a valid value, so we need to check if the field value is undefined.
120
121
  if ( fieldValue === undefined ) {
121
122
  return false;
122
123
  }
123
124
  // Check that custom fields metabox is not enabled.
124
- const areCustomFieldsEnabled = registry
125
- .select( editorStore )
126
- .getEditorSettings().enableCustomFields;
125
+ const areCustomFieldsEnabled =
126
+ select( editorStore ).getEditorSettings().enableCustomFields;
127
127
  if ( areCustomFieldsEnabled ) {
128
128
  return false;
129
129
  }
130
130
 
131
131
  // Check that the user has the capability to edit post meta.
132
- const canUserEdit = registry
133
- .select( coreDataStore )
134
- .canUser( 'update', {
135
- kind: 'postType',
136
- name: context?.postType,
137
- id: context?.postId,
138
- } );
132
+ const canUserEdit = select( coreDataStore ).canUser( 'update', {
133
+ kind: 'postType',
134
+ name: context?.postType,
135
+ id: context?.postId,
136
+ } );
139
137
  if ( ! canUserEdit ) {
140
138
  return false;
141
139
  }
142
140
 
143
141
  return true;
144
142
  },
145
- getFieldsList( { registry, context } ) {
146
- return getPostMetaFields( registry, context );
143
+ getFieldsList( { select, context } ) {
144
+ return getPostMetaFields( select, context );
147
145
  },
148
146
  };
@@ -6,7 +6,7 @@ import { privateApis as patternsPrivateApis } from '@wordpress/patterns';
6
6
  import { createHigherOrderComponent } from '@wordpress/compose';
7
7
  import { useBlockEditingMode } from '@wordpress/block-editor';
8
8
  import { useSelect } from '@wordpress/data';
9
- import { store as blocksStore } from '@wordpress/blocks';
9
+ import { getBlockBindingsSource } from '@wordpress/blocks';
10
10
 
11
11
  /**
12
12
  * Internal dependencies
@@ -58,7 +58,6 @@ function ControlsWithStoreSubscription( props ) {
58
58
  const blockEditingMode = useBlockEditingMode();
59
59
  const { hasPatternOverridesSource, isEditingSyncedPattern } = useSelect(
60
60
  ( select ) => {
61
- const { getBlockBindingsSource } = unlock( select( blocksStore ) );
62
61
  const { getCurrentPostType, getEditedPostAttribute } =
63
62
  select( editorStore );
64
63