@wordpress/editor 14.8.5 → 14.8.7

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.
Files changed (33) hide show
  1. package/build/bindings/api.js +2 -5
  2. package/build/bindings/api.js.map +1 -1
  3. package/build/bindings/pattern-overrides.js +7 -6
  4. package/build/bindings/pattern-overrides.js.map +1 -1
  5. package/build/bindings/post-meta.js +16 -16
  6. package/build/bindings/post-meta.js.map +1 -1
  7. package/build/components/header/index.js +3 -1
  8. package/build/components/header/index.js.map +1 -1
  9. package/build/hooks/pattern-overrides.js +1 -4
  10. package/build/hooks/pattern-overrides.js.map +1 -1
  11. package/build-module/bindings/api.js +1 -4
  12. package/build-module/bindings/api.js.map +1 -1
  13. package/build-module/bindings/pattern-overrides.js +7 -6
  14. package/build-module/bindings/pattern-overrides.js.map +1 -1
  15. package/build-module/bindings/post-meta.js +16 -16
  16. package/build-module/bindings/post-meta.js.map +1 -1
  17. package/build-module/components/header/index.js +3 -1
  18. package/build-module/components/header/index.js.map +1 -1
  19. package/build-module/hooks/pattern-overrides.js +1 -4
  20. package/build-module/hooks/pattern-overrides.js.map +1 -1
  21. package/build-types/bindings/api.d.ts.map +1 -1
  22. package/build-types/bindings/pattern-overrides.d.ts +5 -4
  23. package/build-types/bindings/pattern-overrides.d.ts.map +1 -1
  24. package/build-types/bindings/post-meta.d.ts +8 -8
  25. package/build-types/bindings/post-meta.d.ts.map +1 -1
  26. package/build-types/components/header/index.d.ts.map +1 -1
  27. package/package.json +15 -15
  28. package/src/bindings/api.js +1 -2
  29. package/src/bindings/pattern-overrides.js +27 -30
  30. package/src/bindings/post-meta.js +28 -30
  31. package/src/components/header/index.js +6 -1
  32. package/src/hooks/pattern-overrides.js +1 -2
  33. package/tsconfig.tsbuildinfo +1 -1
@@ -30,11 +30,8 @@ var _lockUnlock = require("../lock-unlock");
30
30
  * ```
31
31
  */
32
32
  function registerCoreBlockBindingsSources() {
33
- const {
34
- registerBlockBindingsSource
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","unlock","blocksPrivateApis","patternOverrides","postMeta","bootstrapBlockBindingsSourcesFromServer","sources","addBootstrappedBlockBindingsSource","dispatch","blocksStore","name","args","Object","entries"],"sources":["@wordpress/editor/src/bindings/api.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blocksPrivateApis,\n\tstore as blocksStore,\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\tconst { registerBlockBindingsSource } = unlock( blocksPrivateApis );\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,MAAM;IAAEC;EAA4B,CAAC,GAAG,IAAAC,kBAAM,EAAEC,mBAAkB,CAAC;EACnEF,2BAA2B,CAAEG,yBAAiB,CAAC;EAC/CH,2BAA2B,CAAEI,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,IAAAN,kBAAM,EACpD,IAAAO,cAAQ,EAAEC,aAAY,CACvB,CAAC;IACD,KAAM,MAAM,CAAEC,IAAI,EAAEC,IAAI,CAAE,IAAIC,MAAM,CAACC,OAAO,CAAEP,OAAQ,CAAC,EAAG;MACzDC,kCAAkC,CAAE;QACnCG,IAAI;QACJ,GAAGC;MACJ,CAAE,CAAC;IACJ;EACD;AACD","ignoreList":[]}
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
- registry,
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
- } = registry.select(_blockEditor.store);
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
- registry,
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
- } = registry.select(_blockEditor.store);
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
- registry.dispatch(_blockEditor.store).updateBlockAttributes(block.clientId, attributes);
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
- registry.dispatch(_blockEditor.store).updateBlockAttributes(patternClientId, {
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","registry","clientId","context","bindings","patternOverridesContent","getBlockAttributes","select","blockEditorStore","currentBlockAttributes","overridesValues","attributeName","Object","keys","overridableValue","metadata","undefined","setValues","getBlockParentsByBlockName","getBlocks","blockName","patternClientId","attributes","entries","reduce","attrs","key","newValue","syncBlocksWithSameName","blocks","block","dispatch","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( { registry, clientId, context, bindings } ) {\n\t\tconst patternOverridesContent = context[ 'pattern/overrides' ];\n\t\tconst { getBlockAttributes } = registry.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( { registry, clientId, bindings } ) {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName, getBlocks } =\n\t\t\tregistry.select( 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\tregistry\n\t\t\t\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t\t\t\t.updateBlockAttributes(\n\t\t\t\t\t\t\t\tblock.clientId,\n\t\t\t\t\t\t\t\tattributes\n\t\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\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.updateBlockAttributes( patternClientId, {\n\t\t\t\t[ CONTENT ]: {\n\t\t\t\t\t...currentBindingValue,\n\t\t\t\t\t[ blockName ]: {\n\t\t\t\t\t\t...currentBindingValue?.[ blockName ],\n\t\t\t\t\t\t...Object.entries( attributes ).reduce(\n\t\t\t\t\t\t\t( acc, [ key, value ] ) => {\n\t\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\t// Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871\n\t\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\t// we support a richer format for overrides and the block bindings API.\n\t\t\t\t\t\t\t\tacc[ key ] = value === undefined ? '' : value;\n\t\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t\t},\n\t\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},\n\tcanUserEditValue: () => true,\n};\n"],"mappings":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,MAAMC,OAAO,GAAG,SAAS;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEX;EACdC,IAAI,EAAE,wBAAwB;EAC9BC,SAASA,CAAE;IAAEC,QAAQ;IAAEC,QAAQ;IAAEC,OAAO;IAAEC;EAAS,CAAC,EAAG;IACtD,MAAMC,uBAAuB,GAAGF,OAAO,CAAE,mBAAmB,CAAE;IAC9D,MAAM;MAAEG;IAAmB,CAAC,GAAGL,QAAQ,CAACM,MAAM,CAAEC,kBAAiB,CAAC;IAClE,MAAMC,sBAAsB,GAAGH,kBAAkB,CAAEJ,QAAS,CAAC;IAE7D,MAAMQ,eAAe,GAAG,CAAC,CAAC;IAC1B,KAAM,MAAMC,aAAa,IAAIC,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ID,MAAM,EAAG;UAC7B,IAAKC,KAAK,CAACR,UAAU,EAAEP,QAAQ,EAAEhB,IAAI,KAAKqB,SAAS,EAAG;YACrDnB,QAAQ,CACN8B,QAAQ,CAAEvB,kBAAiB,CAAC,CAC5BwB,qBAAqB,CACrBF,KAAK,CAAC5B,QAAQ,EACdoB,UACD,CAAC;UACH;UACAM,sBAAsB,CAAEE,KAAK,CAACG,WAAY,CAAC;QAC5C;MACD,CAAC;MAEDL,sBAAsB,CAAET,SAAS,CAAC,CAAE,CAAC;MACrC;IACD;IACA,MAAMe,mBAAmB,GACxB5B,kBAAkB,CAAEe,eAAgB,CAAC,GAAI1B,OAAO,CAAE;IACnDM,QAAQ,CACN8B,QAAQ,CAAEvB,kBAAiB,CAAC,CAC5BwB,qBAAqB,CAAEX,eAAe,EAAE;MACxC,CAAE1B,OAAO,GAAI;QACZ,GAAGuC,mBAAmB;QACtB,CAAEd,SAAS,GAAI;UACd,GAAGc,mBAAmB,GAAId,SAAS,CAAE;UACrC,GAAGR,MAAM,CAACW,OAAO,CAAED,UAAW,CAAC,CAACE,MAAM,CACrC,CAAEW,GAAG,EAAE,CAAET,GAAG,EAAEU,KAAK,CAAE,KAAM;YAC1B;YACA;YACA;YACA;YACAD,GAAG,CAAET,GAAG,CAAE,GAAGU,KAAK,KAAKpB,SAAS,GAAG,EAAE,GAAGoB,KAAK;YAC7C,OAAOD,GAAG;UACX,CAAC,EACD,CAAC,CACF;QACD;MACD;IACD,CAAE,CAAC;EACL,CAAC;EACDE,gBAAgB,EAAEA,CAAA,KAAM;AACzB,CAAC","ignoreList":[]}
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{}\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":";;;;;;AAGA,IAAAA,YAAA,GAAAC,OAAA;AAHA;AACA;AACA;;AAGA,MAAMC,OAAO,GAAG,SAAS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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} registry The registry context exposed through `useRegistry`.
25
- * @param {Object} context The context provided.
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(registry, context) {
43
+ function getPostMetaFields(select, context) {
44
44
  const {
45
45
  getEditedEntityRecord
46
- } = registry.select(_coreData.store);
46
+ } = select(_coreData.store);
47
47
  const {
48
48
  getRegisteredPostMeta
49
- } = (0, _lockUnlock.unlock)(registry.select(_coreData.store));
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
- registry,
78
+ select,
79
79
  context,
80
80
  bindings
81
81
  }) {
82
- const metaFields = getPostMetaFields(registry, context);
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
- registry,
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
- registry.dispatch(_coreData.store).editEntityRecord('postType', context?.postType, context?.postId, {
108
+ dispatch(_coreData.store).editEntityRecord('postType', context?.postType, context?.postId, {
109
109
  meta: newMeta
110
110
  });
111
111
  },
112
112
  canUserEditValue({
113
- registry,
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 || registry.select(_store.store).getCurrentPostType();
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(registry, context)?.[args.key]?.value;
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 = registry.select(_store.store).getEditorSettings().enableCustomFields;
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 = registry.select(_coreData.store).canUser('update', {
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
- registry,
150
+ select,
151
151
  context
152
152
  }) {
153
- return getPostMetaFields(registry, context);
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","registry","context","getEditedEntityRecord","select","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","newMeta","values","newValue","dispatch","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} 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":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;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,SAASG,iBAAiBA,CAAEC,QAAQ,EAAEC,OAAO,EAAG;EAC/C,MAAM;IAAEC;EAAsB,CAAC,GAAGF,QAAQ,CAACG,MAAM,CAAEC,eAAc,CAAC;EAClE,MAAM;IAAEC;EAAsB,CAAC,GAAG,IAAAC,kBAAM,EACvCN,QAAQ,CAACG,MAAM,CAAEC,eAAc,CAChC,CAAC;EAED,IAAIG,gBAAgB;EACpB;EACA,IAAKN,OAAO,EAAEO,QAAQ,IAAIP,OAAO,EAAEQ,MAAM,EAAG;IAC3CF,gBAAgB,GAAGL,qBAAqB,CACvC,UAAU,EACVD,OAAO,EAAEO,QAAQ,EACjBP,OAAO,EAAEQ,MACV,CAAC,CAACC,IAAI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AAIoC,IAAI,CAACrB,GAAG,CAAE,EACpEM,KAAK;IACR;IACA,IAAKgB,UAAU,KAAKd,SAAS,EAAG;MAC/B,OAAO,KAAK;IACb;IACA;IACA,MAAM2B,sBAAsB,GAAGnD,QAAQ,CACrCG,MAAM,CAAE8C,YAAY,CAAC,CACrBG,iBAAiB,CAAC,CAAC,CAACC,kBAAkB;IACxC,IAAKF,sBAAsB,EAAG;MAC7B,OAAO,KAAK;IACb;;IAEA;IACA,MAAMG,WAAW,GAAGtD,QAAQ,CAC1BG,MAAM,CAAEC,eAAc,CAAC,CACvBmD,OAAO,CAAE,QAAQ,EAAE;MACnBC,IAAI,EAAE,UAAU;MAChB3B,IAAI,EAAE5B,OAAO,EAAEO,QAAQ;MACvBiD,EAAE,EAAExD,OAAO,EAAEQ;IACd,CAAE,CAAC;IACJ,IAAK,CAAE6C,WAAW,EAAG;MACpB,OAAO,KAAK;IACb;IAEA,OAAO,IAAI;EACZ,CAAC;EACDI,aAAaA,CAAE;IAAE1D,QAAQ;IAAEC;EAAQ,CAAC,EAAG;IACtC,OAAOF,iBAAiB,CAAEC,QAAQ,EAAEC,OAAQ,CAAC;EAC9C;AACD,CAAC","ignoreList":[]}
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;AAKA,IAAAC,MAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;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,SAASG,iBAAiBA,CAAEC,MAAM,EAAEC,OAAO,EAAG;EAC7C,MAAM;IAAEC;EAAsB,CAAC,GAAGF,MAAM,CAAEG,eAAc,CAAC;EACzD,MAAM;IAAEC;EAAsB,CAAC,GAAG,IAAAC,kBAAM,EAAEL,MAAM,CAAEG,eAAc,CAAE,CAAC;EAEnE,IAAIG,gBAAgB;EACpB;EACA,IAAKL,OAAO,EAAEM,QAAQ,IAAIN,OAAO,EAAEO,MAAM,EAAG;IAC3CF,gBAAgB,GAAGJ,qBAAqB,CACvC,UAAU,EACVD,OAAO,EAAEM,QAAQ,EACjBN,OAAO,EAAEO,MACV,CAAC,CAACC,IAAI;EACP;EAEA,MAAMC,gBAAgB,GAAGN,qBAAqB,CAAEH,OAAO,EAAEM,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,GAAG,EAAG;MAAA,IAAAC,qBAAA;MACrDP,UAAU,CAAEI,GAAG,CAAE,GAAG;QACnBI,KAAK,EAAEH,KAAK,CAACI,KAAK,IAAIL,GAAG;QACzBM,KAAK,EACJ;QAAA,CAAAH,qBAAA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,KAAK;IACb;IAEA,OAAO,IAAI;EACZ,CAAC;EACDI,aAAaA,CAAE;IAAEzD,MAAM;IAAEC;EAAQ,CAAC,EAAG;IACpC,OAAOF,iBAAiB,CAAEC,MAAM,EAAEC,OAAQ,CAAC;EAC5C;AACD,CAAC","ignoreList":[]}
@@ -85,6 +85,7 @@ function Header({
85
85
  isPublishSidebarOpened,
86
86
  showIconLabels,
87
87
  hasFixedToolbar,
88
+ hasBlockSelection,
88
89
  isNestedEntity
89
90
  } = (0, _data.useSelect)(select => {
90
91
  const {
@@ -103,12 +104,13 @@ function Header({
103
104
  isPublishSidebarOpened: _isPublishSidebarOpened(),
104
105
  showIconLabels: getPreference('core', 'showIconLabels'),
105
106
  hasFixedToolbar: getPreference('core', 'fixedToolbar'),
107
+ hasBlockSelection: !!select(_blockEditor.store).getBlockSelectionStart(),
106
108
  isNestedEntity: !!getEditorSettings().onNavigateToPreviousEntityRecord,
107
109
  isZoomedOutView: __unstableGetEditorMode() === 'zoom-out'
108
110
  };
109
111
  }, []);
110
112
  const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = (0, _element.useState)(true);
111
- const hasCenter = isBlockToolsCollapsed && !isTooNarrowForDocumentBar;
113
+ const hasCenter = (!hasBlockSelection || isBlockToolsCollapsed) && !isTooNarrowForDocumentBar;
112
114
  const hasBackButton = (0, _backButton.useHasBackButton)();
113
115
 
114
116
  // The edit-post-header classname is only kept for backward compatibilty
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_compose","_components","_preferences","_element","_interface","_blockEditor","_backButton","_interopRequireWildcard","_collapsibleBlockToolbar","_interopRequireDefault","_documentBar","_documentTools","_moreMenu","_postPreviewButton","_postPublishButtonOrToggle","_postSavedState","_postViewLink","_previewDropdown","_zoomOutToggle","_store","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","toolbarVariations","distractionFreeDisabled","y","distractionFreeHover","distractionFreeHidden","visible","hidden","backButtonVariations","x","Header","customSaveButton","forceIsDirty","forceDisableBlockTools","setEntitiesSavedStatesCallback","title","isEditorIframed","isWideViewport","useViewportMatch","isLargeViewport","isTooNarrowForDocumentBar","useMediaQuery","isTextEditor","isPublishSidebarOpened","showIconLabels","hasFixedToolbar","isNestedEntity","useSelect","select","getPreference","preferencesStore","getEditorMode","getEditorSettings","_isPublishSidebarOpened","editorStore","__unstableGetEditorMode","blockEditorStore","onNavigateToPreviousEntityRecord","isZoomedOutView","isBlockToolsCollapsed","setIsBlockToolsCollapsed","useState","hasCenter","hasBackButton","useHasBackButton","jsxs","className","children","jsx","__unstableMotion","div","variants","transition","type","Slot","disableBlockTools","isCollapsed","onToggle","forceIsAutosaveable","disabled","PinnedItems","scope","_default","exports"],"sources":["@wordpress/editor/src/components/header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMediaQuery, useViewportMatch } from '@wordpress/compose';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useState } from '@wordpress/element';\nimport { PinnedItems } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport BackButton, { useHasBackButton } from './back-button';\nimport CollapsibleBlockToolbar from '../collapsible-block-toolbar';\nimport DocumentBar from '../document-bar';\nimport DocumentTools from '../document-tools';\nimport MoreMenu from '../more-menu';\nimport PostPreviewButton from '../post-preview-button';\nimport PostPublishButtonOrToggle from '../post-publish-button/post-publish-button-or-toggle';\nimport PostSavedState from '../post-saved-state';\nimport PostViewLink from '../post-view-link';\nimport PreviewDropdown from '../preview-dropdown';\nimport ZoomOutToggle from '../zoom-out-toggle';\nimport { store as editorStore } from '../../store';\n\nconst toolbarVariations = {\n\tdistractionFreeDisabled: { y: '-50px' },\n\tdistractionFreeHover: { y: 0 },\n\tdistractionFreeHidden: { y: '-50px' },\n\tvisible: { y: 0 },\n\thidden: { y: 0 },\n};\n\nconst backButtonVariations = {\n\tdistractionFreeDisabled: { x: '-100%' },\n\tdistractionFreeHover: { x: 0 },\n\tdistractionFreeHidden: { x: '-100%' },\n\tvisible: { x: 0 },\n\thidden: { x: 0 },\n};\n\nfunction Header( {\n\tcustomSaveButton,\n\tforceIsDirty,\n\tforceDisableBlockTools,\n\tsetEntitiesSavedStatesCallback,\n\ttitle,\n\tisEditorIframed,\n} ) {\n\tconst isWideViewport = useViewportMatch( 'large' );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isTooNarrowForDocumentBar = useMediaQuery( '(max-width: 403px)' );\n\tconst {\n\t\tisTextEditor,\n\t\tisPublishSidebarOpened,\n\t\tshowIconLabels,\n\t\thasFixedToolbar,\n\t\tisNestedEntity,\n\t} = useSelect( ( select ) => {\n\t\tconst { get: getPreference } = select( preferencesStore );\n\t\tconst {\n\t\t\tgetEditorMode,\n\t\t\tgetEditorSettings,\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened,\n\t\t} = select( editorStore );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tisTextEditor: getEditorMode() === 'text',\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened(),\n\t\t\tshowIconLabels: getPreference( 'core', 'showIconLabels' ),\n\t\t\thasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),\n\t\t\tisNestedEntity:\n\t\t\t\t!! getEditorSettings().onNavigateToPreviousEntityRecord,\n\t\t\tisZoomedOutView: __unstableGetEditorMode() === 'zoom-out',\n\t\t};\n\t}, [] );\n\n\tconst [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =\n\t\tuseState( true );\n\n\tconst hasCenter = isBlockToolsCollapsed && ! isTooNarrowForDocumentBar;\n\tconst hasBackButton = useHasBackButton();\n\n\t// The edit-post-header classname is only kept for backward compatibilty\n\t// as some plugins might be relying on its presence.\n\treturn (\n\t\t<div className=\"editor-header edit-post-header\">\n\t\t\t{ hasBackButton && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__back-button\"\n\t\t\t\t\tvariants={ backButtonVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<BackButton.Slot />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\tclassName=\"editor-header__toolbar\"\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t>\n\t\t\t\t<DocumentTools\n\t\t\t\t\tdisableBlockTools={ forceDisableBlockTools || isTextEditor }\n\t\t\t\t/>\n\t\t\t\t{ hasFixedToolbar && isLargeViewport && (\n\t\t\t\t\t<CollapsibleBlockToolbar\n\t\t\t\t\t\tisCollapsed={ isBlockToolsCollapsed }\n\t\t\t\t\t\tonToggle={ setIsBlockToolsCollapsed }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t\t{ hasCenter && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__center\"\n\t\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<DocumentBar title={ title } />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\tclassName=\"editor-header__settings\"\n\t\t\t>\n\t\t\t\t{ ! customSaveButton && ! isPublishSidebarOpened && (\n\t\t\t\t\t// This button isn't completely hidden by the publish sidebar.\n\t\t\t\t\t// We can't hide the whole toolbar when the publish sidebar is open because\n\t\t\t\t\t// we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.\n\t\t\t\t\t// We track that DOM node to return focus to the PostPublishButtonOrToggle\n\t\t\t\t\t// when the publish sidebar has been closed.\n\t\t\t\t\t<PostSavedState forceIsDirty={ forceIsDirty } />\n\t\t\t\t) }\n\t\t\t\t<PreviewDropdown\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t\tdisabled={ isNestedEntity }\n\t\t\t\t/>\n\t\t\t\t<PostPreviewButton\n\t\t\t\t\tclassName=\"editor-header__post-preview-button\"\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t/>\n\t\t\t\t<PostViewLink />\n\n\t\t\t\t{ isEditorIframed && isWideViewport && <ZoomOutToggle /> }\n\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<PinnedItems.Slot scope=\"core\" />\n\t\t\t\t) }\n\n\t\t\t\t{ ! customSaveButton && (\n\t\t\t\t\t<PostPublishButtonOrToggle\n\t\t\t\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ customSaveButton }\n\t\t\t\t<MoreMenu />\n\t\t\t</motion.div>\n\t\t</div>\n\t);\n}\n\nexport default Header;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAKA,IAAAO,WAAA,GAAAC,uBAAA,CAAAR,OAAA;AACA,IAAAS,wBAAA,GAAAC,sBAAA,CAAAV,OAAA;AACA,IAAAW,YAAA,GAAAD,sBAAA,CAAAV,OAAA;AACA,IAAAY,cAAA,GAAAF,sBAAA,CAAAV,OAAA;AACA,IAAAa,SAAA,GAAAH,sBAAA,CAAAV,OAAA;AACA,IAAAc,kBAAA,GAA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A,CAAAoE,GAAA,EAACvE,gBAAA,CAAAU,OAAe;QACfuE,mBAAmB,EAAG9C,YAAc;QACpC+C,QAAQ,EAAGjC;MAAgB,CAC3B,CAAC,eACF,IAAA9C,WAAA,CAAAoE,GAAA,EAAC3E,kBAAA,CAAAc,OAAiB;QACjB2D,SAAS,EAAC,oCAAoC;QAC9CY,mBAAmB,EAAG9C;MAAc,CACpC,CAAC,eACF,IAAAhC,WAAA,CAAAoE,GAAA,EAACxE,aAAA,CAAAW,OAAY,IAAE,CAAC,EAEd6B,eAAe,IAAIC,cAAc,iBAAI,IAAArC,WAAA,CAAAoE,GAAA,EAACtE,cAAA,CAAAS,OAAa,IAAE,CAAC,EAEtD,CAAE8B,cAAc,IAAI,CAAEO,cAAc,kBACrC,IAAA5C,WAAA,CAAAoE,GAAA,EAACpF,UAAA,CAAAgG,WAAW,CAACN,IAAI;QAACO,KAAK,EAAC;MAAM,CAAE,CAChC,EAEC,CAAElD,gBAAgB,iBACnB,IAAA/B,WAAA,CAAAoE,GAAA,EAAC1E,0BAAA,CAAAa,OAAyB;QACzByB,YAAY,EAAGA,YAAc;QAC7BE,8BAA8B,EAC7BA;MACA,CACD,CACD,EAECH,gBAAgB,eAClB,IAAA/B,WAAA,CAAAoE,GAAA,EAAC5E,SAAA,CAAAe,OAAQ,IAAE,CAAC;IAAA,CACD,CAAC;EAAA,CACT,CAAC;AAER;AAAC,IAAA2E,QAAA,GAAAC,OAAA,CAAA5E,OAAA,GAEcuB,MAAM","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_compose","_components","_preferences","_element","_interface","_blockEditor","_backButton","_interopRequireWildcard","_collapsibleBlockToolbar","_interopRequireDefault","_documentBar","_documentTools","_moreMenu","_postPreviewButton","_postPublishButtonOrToggle","_postSavedState","_postViewLink","_previewDropdown","_zoomOutToggle","_store","_jsxRuntime","_getRequireWildcardCache","e","WeakMap","r","t","__esModule","default","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","toolbarVariations","distractionFreeDisabled","y","distractionFreeHover","distractionFreeHidden","visible","hidden","backButtonVariations","x","Header","customSaveButton","forceIsDirty","forceDisableBlockTools","setEntitiesSavedStatesCallback","title","isEditorIframed","isWideViewport","useViewportMatch","isLargeViewport","isTooNarrowForDocumentBar","useMediaQuery","isTextEditor","isPublishSidebarOpened","showIconLabels","hasFixedToolbar","hasBlockSelection","isNestedEntity","useSelect","select","getPreference","preferencesStore","getEditorMode","getEditorSettings","_isPublishSidebarOpened","editorStore","__unstableGetEditorMode","blockEditorStore","getBlockSelectionStart","onNavigateToPreviousEntityRecord","isZoomedOutView","isBlockToolsCollapsed","setIsBlockToolsCollapsed","useState","hasCenter","hasBackButton","useHasBackButton","jsxs","className","children","jsx","__unstableMotion","div","variants","transition","type","Slot","disableBlockTools","isCollapsed","onToggle","forceIsAutosaveable","disabled","PinnedItems","scope","_default","exports"],"sources":["@wordpress/editor/src/components/header/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useSelect } from '@wordpress/data';\nimport { useMediaQuery, useViewportMatch } from '@wordpress/compose';\nimport { __unstableMotion as motion } from '@wordpress/components';\nimport { store as preferencesStore } from '@wordpress/preferences';\nimport { useState } from '@wordpress/element';\nimport { PinnedItems } from '@wordpress/interface';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport BackButton, { useHasBackButton } from './back-button';\nimport CollapsibleBlockToolbar from '../collapsible-block-toolbar';\nimport DocumentBar from '../document-bar';\nimport DocumentTools from '../document-tools';\nimport MoreMenu from '../more-menu';\nimport PostPreviewButton from '../post-preview-button';\nimport PostPublishButtonOrToggle from '../post-publish-button/post-publish-button-or-toggle';\nimport PostSavedState from '../post-saved-state';\nimport PostViewLink from '../post-view-link';\nimport PreviewDropdown from '../preview-dropdown';\nimport ZoomOutToggle from '../zoom-out-toggle';\nimport { store as editorStore } from '../../store';\n\nconst toolbarVariations = {\n\tdistractionFreeDisabled: { y: '-50px' },\n\tdistractionFreeHover: { y: 0 },\n\tdistractionFreeHidden: { y: '-50px' },\n\tvisible: { y: 0 },\n\thidden: { y: 0 },\n};\n\nconst backButtonVariations = {\n\tdistractionFreeDisabled: { x: '-100%' },\n\tdistractionFreeHover: { x: 0 },\n\tdistractionFreeHidden: { x: '-100%' },\n\tvisible: { x: 0 },\n\thidden: { x: 0 },\n};\n\nfunction Header( {\n\tcustomSaveButton,\n\tforceIsDirty,\n\tforceDisableBlockTools,\n\tsetEntitiesSavedStatesCallback,\n\ttitle,\n\tisEditorIframed,\n} ) {\n\tconst isWideViewport = useViewportMatch( 'large' );\n\tconst isLargeViewport = useViewportMatch( 'medium' );\n\tconst isTooNarrowForDocumentBar = useMediaQuery( '(max-width: 403px)' );\n\tconst {\n\t\tisTextEditor,\n\t\tisPublishSidebarOpened,\n\t\tshowIconLabels,\n\t\thasFixedToolbar,\n\t\thasBlockSelection,\n\t\tisNestedEntity,\n\t} = useSelect( ( select ) => {\n\t\tconst { get: getPreference } = select( preferencesStore );\n\t\tconst {\n\t\t\tgetEditorMode,\n\t\t\tgetEditorSettings,\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened,\n\t\t} = select( editorStore );\n\t\tconst { __unstableGetEditorMode } = select( blockEditorStore );\n\n\t\treturn {\n\t\t\tisTextEditor: getEditorMode() === 'text',\n\t\t\tisPublishSidebarOpened: _isPublishSidebarOpened(),\n\t\t\tshowIconLabels: getPreference( 'core', 'showIconLabels' ),\n\t\t\thasFixedToolbar: getPreference( 'core', 'fixedToolbar' ),\n\t\t\thasBlockSelection:\n\t\t\t\t!! select( blockEditorStore ).getBlockSelectionStart(),\n\t\t\tisNestedEntity:\n\t\t\t\t!! getEditorSettings().onNavigateToPreviousEntityRecord,\n\t\t\tisZoomedOutView: __unstableGetEditorMode() === 'zoom-out',\n\t\t};\n\t}, [] );\n\n\tconst [ isBlockToolsCollapsed, setIsBlockToolsCollapsed ] =\n\t\tuseState( true );\n\n\tconst hasCenter =\n\t\t( ! hasBlockSelection || isBlockToolsCollapsed ) &&\n\t\t! isTooNarrowForDocumentBar;\n\tconst hasBackButton = useHasBackButton();\n\n\t// The edit-post-header classname is only kept for backward compatibilty\n\t// as some plugins might be relying on its presence.\n\treturn (\n\t\t<div className=\"editor-header edit-post-header\">\n\t\t\t{ hasBackButton && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__back-button\"\n\t\t\t\t\tvariants={ backButtonVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<BackButton.Slot />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\tclassName=\"editor-header__toolbar\"\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t>\n\t\t\t\t<DocumentTools\n\t\t\t\t\tdisableBlockTools={ forceDisableBlockTools || isTextEditor }\n\t\t\t\t/>\n\t\t\t\t{ hasFixedToolbar && isLargeViewport && (\n\t\t\t\t\t<CollapsibleBlockToolbar\n\t\t\t\t\t\tisCollapsed={ isBlockToolsCollapsed }\n\t\t\t\t\t\tonToggle={ setIsBlockToolsCollapsed }\n\t\t\t\t\t/>\n\t\t\t\t) }\n\t\t\t</motion.div>\n\t\t\t{ hasCenter && (\n\t\t\t\t<motion.div\n\t\t\t\t\tclassName=\"editor-header__center\"\n\t\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\t>\n\t\t\t\t\t<DocumentBar title={ title } />\n\t\t\t\t</motion.div>\n\t\t\t) }\n\t\t\t<motion.div\n\t\t\t\tvariants={ toolbarVariations }\n\t\t\t\ttransition={ { type: 'tween' } }\n\t\t\t\tclassName=\"editor-header__settings\"\n\t\t\t>\n\t\t\t\t{ ! customSaveButton && ! isPublishSidebarOpened && (\n\t\t\t\t\t// This button isn't completely hidden by the publish sidebar.\n\t\t\t\t\t// We can't hide the whole toolbar when the publish sidebar is open because\n\t\t\t\t\t// we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.\n\t\t\t\t\t// We track that DOM node to return focus to the PostPublishButtonOrToggle\n\t\t\t\t\t// when the publish sidebar has been closed.\n\t\t\t\t\t<PostSavedState forceIsDirty={ forceIsDirty } />\n\t\t\t\t) }\n\t\t\t\t<PreviewDropdown\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t\tdisabled={ isNestedEntity }\n\t\t\t\t/>\n\t\t\t\t<PostPreviewButton\n\t\t\t\t\tclassName=\"editor-header__post-preview-button\"\n\t\t\t\t\tforceIsAutosaveable={ forceIsDirty }\n\t\t\t\t/>\n\t\t\t\t<PostViewLink />\n\n\t\t\t\t{ isEditorIframed && isWideViewport && <ZoomOutToggle /> }\n\n\t\t\t\t{ ( isWideViewport || ! showIconLabels ) && (\n\t\t\t\t\t<PinnedItems.Slot scope=\"core\" />\n\t\t\t\t) }\n\n\t\t\t\t{ ! customSaveButton && (\n\t\t\t\t\t<PostPublishButtonOrToggle\n\t\t\t\t\t\tforceIsDirty={ forceIsDirty }\n\t\t\t\t\t\tsetEntitiesSavedStatesCallback={\n\t\t\t\t\t\t\tsetEntitiesSavedStatesCallback\n\t\t\t\t\t\t}\n\t\t\t\t\t/>\n\t\t\t\t) }\n\n\t\t\t\t{ customSaveButton }\n\t\t\t\t<MoreMenu />\n\t\t\t</motion.div>\n\t\t</div>\n\t);\n}\n\nexport default Header;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AACA,IAAAG,YAAA,GAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,UAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AAKA,IAAAO,WAAA,GAAAC,uBAAA,CAAAR,OAAA;AACA,IAAAS,wBAAA,GAAAC,sBAAA,CAA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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","getBlockBindingsSource","blocksStore","getCurrentPostType","getEditedPostAttribute","editorStore","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 { 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":";;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,GAA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BACD,CAAC","ignoreList":[]}
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,M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CAAEZ,KAAK,CAACuB,UAAU,CAACC,QAAQ,EAAEtB,IAAI,IAClCO,gBAAgB,KAAK,UAAU,IAC/BgB,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 { privateApis as blocksPrivateApis, store as blocksStore } from '@wordpress/blocks';
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":["privateApis","blocksPrivateApis","store","blocksStore","dispatch","patternOverrides","postMeta","unlock","registerCoreBlockBindingsSources","registerBlockBindingsSource","bootstrapBlockBindingsSourcesFromServer","sources","addBootstrappedBlockBindingsSource","name","args","Object","entries"],"sources":["@wordpress/editor/src/bindings/api.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tprivateApis as blocksPrivateApis,\n\tstore as blocksStore,\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\tconst { registerBlockBindingsSource } = unlock( blocksPrivateApis );\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,WAAW,IAAIC,iBAAiB,EAChCC,KAAK,IAAIC,WAAW,QACd,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;EAClD,MAAM;IAAEC;EAA4B,CAAC,GAAGF,MAAM,CAAEN,iBAAkB,CAAC;EACnEQ,2BAA2B,CAAEJ,gBAAiB,CAAC;EAC/CI,2BAA2B,CAAEH,QAAS,CAAC;AACxC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASI,uCAAuCA,CAAEC,OAAO,EAAG;EAClE,IAAKA,OAAO,EAAG;IACd,MAAM;MAAEC;IAAmC,CAAC,GAAGL,MAAM,CACpDH,QAAQ,CAAED,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":[]}
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
- registry,
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
- } = registry.select(blockEditorStore);
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
- registry,
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
- } = registry.select(blockEditorStore);
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
- registry.dispatch(blockEditorStore).updateBlockAttributes(block.clientId, attributes);
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
- registry.dispatch(blockEditorStore).updateBlockAttributes(patternClientId, {
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","registry","clientId","context","bindings","patternOverridesContent","getBlockAttributes","select","currentBlockAttributes","overridesValues","attributeName","Object","keys","overridableValue","metadata","undefined","setValues","getBlockParentsByBlockName","getBlocks","blockName","patternClientId","attributes","entries","reduce","attrs","key","newValue","syncBlocksWithSameName","blocks","block","dispatch","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( { registry, clientId, context, bindings } ) {\n\t\tconst patternOverridesContent = context[ 'pattern/overrides' ];\n\t\tconst { getBlockAttributes } = registry.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( { registry, clientId, bindings } ) {\n\t\tconst { getBlockAttributes, getBlockParentsByBlockName, getBlocks } =\n\t\t\tregistry.select( 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\tregistry\n\t\t\t\t\t\t\t.dispatch( blockEditorStore )\n\t\t\t\t\t\t\t.updateBlockAttributes(\n\t\t\t\t\t\t\t\tblock.clientId,\n\t\t\t\t\t\t\t\tattributes\n\t\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\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.updateBlockAttributes( patternClientId, {\n\t\t\t\t[ CONTENT ]: {\n\t\t\t\t\t...currentBindingValue,\n\t\t\t\t\t[ blockName ]: {\n\t\t\t\t\t\t...currentBindingValue?.[ blockName ],\n\t\t\t\t\t\t...Object.entries( attributes ).reduce(\n\t\t\t\t\t\t\t( acc, [ key, value ] ) => {\n\t\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\t// Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871\n\t\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\t// we support a richer format for overrides and the block bindings API.\n\t\t\t\t\t\t\t\tacc[ key ] = value === undefined ? '' : value;\n\t\t\t\t\t\t\t\treturn acc;\n\t\t\t\t\t\t\t},\n\t\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},\n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AG,EAAEU,KAAK,CAAE,KAAM;YAC1B;YACA;YACA;YACA;YACAD,GAAG,CAAET,GAAG,CAAE,GAAGU,KAAK,KAAKpB,SAAS,GAAG,EAAE,GAAGoB,KAAK;YAC7C,OAAOD,GAAG;UACX,CAAC,EACD,CAAC,CACF;QACD;MACD;IACD,CAAE,CAAC;EACL,CAAC;EACDE,gBAAgB,EAAEA,CAAA,KAAM;AACzB,CAAC","ignoreList":[]}
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,CAAEP,QAAS,CAAC,EAAG;MACtD,MAAMQ,gBAAgB,GACrBP,uBAAuB,GACtBE,sBAAsB,EAAEM,QAAQ,EAAEd,IAAI,CACtC,GAAIU,aAAa,CAAE;;MAErB;MACA;MACA,IAAKG,gBAAgB,KAAKE,SAAS,EAAG;QACrCN,eAAe,CAAEC,aAAa,CAAE,GAC/BF,sBAAsB,CAAEE,aAAa,CAAE;QACxC;MACD,CAAC,MAAM;QACND,eAAe,CAAEC,aAAa,CAAE,GAC/BG,gBAAgB,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