@wordpress/editor 13.28.4 → 13.28.5

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.
@@ -43,7 +43,8 @@ var _default = exports.default = {
43
43
  };
44
44
  return {
45
45
  placeholder: metaKey,
46
- useValue: [metaValue, updateMetaValue]
46
+ value: metaValue,
47
+ updateValue: updateMetaValue
47
48
  };
48
49
  }
49
50
  };
@@ -1 +1 @@
1
- {"version":3,"names":["_coreData","require","_data","_i18n","_store","_default","exports","default","name","label","_x","useSource","props","sourceAttributes","getCurrentPostType","useSelect","editorStore","context","key","metaKey","postType","meta","setMeta","useEntityProp","postId","placeholder","metaValue","updateMetaValue","newValue","useValue"],"sources":["@wordpress/editor/src/bindings/post-meta.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityProp } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { _x } from '@wordpress/i18n';\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\n\nexport default {\n\tname: 'core/post-meta',\n\tlabel: _x( 'Post Meta', 'block bindings source' ),\n\tuseSource( props, sourceAttributes ) {\n\t\tconst { getCurrentPostType } = useSelect( editorStore );\n\t\tconst { context } = props;\n\t\tconst { key: metaKey } = sourceAttributes;\n\t\tconst postType = context.postType\n\t\t\t? context.postType\n\t\t\t: getCurrentPostType();\n\t\tconst [ meta, setMeta ] = useEntityProp(\n\t\t\t'postType',\n\t\t\tcontext.postType,\n\t\t\t'meta',\n\t\t\tcontext.postId\n\t\t);\n\n\t\tif ( postType === 'wp_template' ) {\n\t\t\treturn { placeholder: metaKey };\n\t\t}\n\t\tconst metaValue = meta[ metaKey ];\n\t\tconst updateMetaValue = ( newValue ) => {\n\t\t\tsetMeta( { ...meta, [ metaKey ]: newValue } );\n\t\t};\n\t\treturn {\n\t\t\tplaceholder: metaKey,\n\t\t\tuseValue: [ metaValue, updateMetaValue ],\n\t\t};\n\t},\n};\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAIA,IAAAG,MAAA,GAAAH,OAAA;AATA;AACA;AACA;AAIA;AACA;AACA;AAFA,IAAAI,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAKe;EACdC,IAAI,EAAE,gBAAgB;EACtBC,KAAK,EAAE,IAAAC,QAAE,EAAE,WAAW,EAAE,uBAAwB,CAAC;EACjDC,SAASA,CAAEC,KAAK,EAAEC,gBAAgB,EAAG;IACpC,MAAM;MAAEC;IAAmB,CAAC,GAAG,IAAAC,eAAS,EAAEC,YAAY,CAAC;IACvD,MAAM;MAAEC;IAAQ,CAAC,GAAGL,KAAK;IACzB,MAAM;MAAEM,GAAG,EAAEC;IAAQ,CAAC,GAAGN,gBAAgB;IACzC,MAAMO,QAAQ,GAAGH,OAAO,CAACG,QAAQ,GAC9BH,OAAO,CAACG,QAAQ,GAChBN,kBAAkB,CAAC,CAAC;IACvB,MAAM,CAAEO,IAAI,EAAEC,OAAO,CAAE,GAAG,IAAAC,uBAAa,EACtC,UAAU,EACVN,OAAO,CAACG,QAAQ,EAChB,MAAM,EACNH,OAAO,CAACO,MACT,CAAC;IAED,IAAKJ,QAAQ,KAAK,aAAa,EAAG;MACjC,OAAO;QAAEK,WAAW,EAAEN;MAAQ,CAAC;IAChC;IACA,MAAMO,SAAS,GAAGL,IAAI,CAAEF,OAAO,CAAE;IACjC,MAAMQ,eAAe,GAAKC,QAAQ,IAAM;MACvCN,OAAO,CAAE;QAAE,GAAGD,IAAI;QAAE,CAAEF,OAAO,GAAIS;MAAS,CAAE,CAAC;IAC9C,CAAC;IACD,OAAO;MACNH,WAAW,EAAEN,OAAO;MACpBU,QAAQ,EAAE,CAAEH,SAAS,EAAEC,eAAe;IACvC,CAAC;EACF;AACD,CAAC"}
1
+ {"version":3,"names":["_coreData","require","_data","_i18n","_store","_default","exports","default","name","label","_x","useSource","props","sourceAttributes","getCurrentPostType","useSelect","editorStore","context","key","metaKey","postType","meta","setMeta","useEntityProp","postId","placeholder","metaValue","updateMetaValue","newValue","value","updateValue"],"sources":["@wordpress/editor/src/bindings/post-meta.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityProp } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { _x } from '@wordpress/i18n';\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\n\nexport default {\n\tname: 'core/post-meta',\n\tlabel: _x( 'Post Meta', 'block bindings source' ),\n\tuseSource( props, sourceAttributes ) {\n\t\tconst { getCurrentPostType } = useSelect( editorStore );\n\t\tconst { context } = props;\n\t\tconst { key: metaKey } = sourceAttributes;\n\t\tconst postType = context.postType\n\t\t\t? context.postType\n\t\t\t: getCurrentPostType();\n\n\t\tconst [ meta, setMeta ] = useEntityProp(\n\t\t\t'postType',\n\t\t\tcontext.postType,\n\t\t\t'meta',\n\t\t\tcontext.postId\n\t\t);\n\n\t\tif ( postType === 'wp_template' ) {\n\t\t\treturn { placeholder: metaKey };\n\t\t}\n\t\tconst metaValue = meta[ metaKey ];\n\t\tconst updateMetaValue = ( newValue ) => {\n\t\t\tsetMeta( { ...meta, [ metaKey ]: newValue } );\n\t\t};\n\n\t\treturn {\n\t\t\tplaceholder: metaKey,\n\t\t\tvalue: metaValue,\n\t\t\tupdateValue: updateMetaValue,\n\t\t};\n\t},\n};\n"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAIA,IAAAG,MAAA,GAAAH,OAAA;AATA;AACA;AACA;AAIA;AACA;AACA;AAFA,IAAAI,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAKe;EACdC,IAAI,EAAE,gBAAgB;EACtBC,KAAK,EAAE,IAAAC,QAAE,EAAE,WAAW,EAAE,uBAAwB,CAAC;EACjDC,SAASA,CAAEC,KAAK,EAAEC,gBAAgB,EAAG;IACpC,MAAM;MAAEC;IAAmB,CAAC,GAAG,IAAAC,eAAS,EAAEC,YAAY,CAAC;IACvD,MAAM;MAAEC;IAAQ,CAAC,GAAGL,KAAK;IACzB,MAAM;MAAEM,GAAG,EAAEC;IAAQ,CAAC,GAAGN,gBAAgB;IACzC,MAAMO,QAAQ,GAAGH,OAAO,CAACG,QAAQ,GAC9BH,OAAO,CAACG,QAAQ,GAChBN,kBAAkB,CAAC,CAAC;IAEvB,MAAM,CAAEO,IAAI,EAAEC,OAAO,CAAE,GAAG,IAAAC,uBAAa,EACtC,UAAU,EACVN,OAAO,CAACG,QAAQ,EAChB,MAAM,EACNH,OAAO,CAACO,MACT,CAAC;IAED,IAAKJ,QAAQ,KAAK,aAAa,EAAG;MACjC,OAAO;QAAEK,WAAW,EAAEN;MAAQ,CAAC;IAChC;IACA,MAAMO,SAAS,GAAGL,IAAI,CAAEF,OAAO,CAAE;IACjC,MAAMQ,eAAe,GAAKC,QAAQ,IAAM;MACvCN,OAAO,CAAE;QAAE,GAAGD,IAAI;QAAE,CAAEF,OAAO,GAAIS;MAAS,CAAE,CAAC;IAC9C,CAAC;IAED,OAAO;MACNH,WAAW,EAAEN,OAAO;MACpBU,KAAK,EAAEH,SAAS;MAChBI,WAAW,EAAEH;IACd,CAAC;EACF;AACD,CAAC"}
@@ -2,5 +2,5 @@
2
2
 
3
3
  require("./custom-sources-backwards-compatibility");
4
4
  require("./default-autocompleters");
5
- require("./pattern-partial-syncing");
5
+ require("./pattern-overrides");
6
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["require"],"sources":["@wordpress/editor/src/hooks/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport './custom-sources-backwards-compatibility';\nimport './default-autocompleters';\nimport './pattern-partial-syncing';\n"],"mappings":";;AAGAA,OAAA;AACAA,OAAA;AACAA,OAAA"}
1
+ {"version":3,"names":["require"],"sources":["@wordpress/editor/src/hooks/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport './custom-sources-backwards-compatibility';\nimport './default-autocompleters';\nimport './pattern-overrides';\n"],"mappings":";;AAGAA,OAAA;AACAA,OAAA;AACAA,OAAA"}
@@ -17,7 +17,7 @@ var _lockUnlock = require("../lock-unlock");
17
17
  */
18
18
 
19
19
  const {
20
- PartialSyncingControls,
20
+ useSetPatternBindings,
21
21
  ResetOverridesControl,
22
22
  PATTERN_TYPES,
23
23
  PARTIAL_SYNCING_SUPPORTED_BLOCKS
@@ -32,14 +32,21 @@ const {
32
32
  *
33
33
  * @return {Component} Wrapped component.
34
34
  */
35
- const withPartialSyncingControls = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
35
+ const withPatternOverrideControls = (0, _compose.createHigherOrderComponent)(BlockEdit => props => {
36
36
  const isSupportedBlock = Object.keys(PARTIAL_SYNCING_SUPPORTED_BLOCKS).includes(props.name);
37
37
  return (0, _react.createElement)(_react.Fragment, null, (0, _react.createElement)(BlockEdit, {
38
38
  ...props
39
+ }), isSupportedBlock && (0, _react.createElement)(BindingUpdater, {
40
+ ...props
39
41
  }), props.isSelected && isSupportedBlock && (0, _react.createElement)(ControlsWithStoreSubscription, {
40
42
  ...props
41
43
  }));
42
44
  });
45
+ function BindingUpdater(props) {
46
+ const postType = (0, _data.useSelect)(select => select(_store.store).getCurrentPostType(), []);
47
+ useSetPatternBindings(props, postType);
48
+ return null;
49
+ }
43
50
 
44
51
  // Split into a separate component to avoid a store subscription
45
52
  // on every block.
@@ -48,13 +55,10 @@ function ControlsWithStoreSubscription(props) {
48
55
  const isEditingPattern = (0, _data.useSelect)(select => select(_store.store).getCurrentPostType() === PATTERN_TYPES.user, []);
49
56
  const bindings = props.attributes.metadata?.bindings;
50
57
  const hasPatternBindings = !!bindings && Object.values(bindings).some(binding => binding.source === 'core/pattern-overrides');
51
- const shouldShowPartialSyncingControls = isEditingPattern && blockEditingMode === 'default';
52
- const shouldShowResetOverridesControl = !isEditingPattern && !!props.attributes.metadata?.id && blockEditingMode !== 'disabled' && hasPatternBindings;
53
- return (0, _react.createElement)(_react.Fragment, null, shouldShowPartialSyncingControls && (0, _react.createElement)(PartialSyncingControls, {
54
- ...props
55
- }), shouldShowResetOverridesControl && (0, _react.createElement)(ResetOverridesControl, {
58
+ const shouldShowResetOverridesControl = !isEditingPattern && !!props.attributes.metadata?.name && blockEditingMode !== 'disabled' && hasPatternBindings;
59
+ return (0, _react.createElement)(_react.Fragment, null, shouldShowResetOverridesControl && (0, _react.createElement)(ResetOverridesControl, {
56
60
  ...props
57
61
  }));
58
62
  }
59
- (0, _hooks.addFilter)('editor.BlockEdit', 'core/editor/with-partial-syncing-controls', withPartialSyncingControls);
60
- //# sourceMappingURL=pattern-partial-syncing.js.map
63
+ (0, _hooks.addFilter)('editor.BlockEdit', 'core/editor/with-pattern-override-controls', withPatternOverrideControls);
64
+ //# sourceMappingURL=pattern-overrides.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_hooks","require","_patterns","_compose","_blockEditor","_data","_store","_lockUnlock","useSetPatternBindings","ResetOverridesControl","PATTERN_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","unlock","patternsPrivateApis","withPatternOverrideControls","createHigherOrderComponent","BlockEdit","props","isSupportedBlock","Object","keys","includes","name","_react","createElement","Fragment","BindingUpdater","isSelected","ControlsWithStoreSubscription","postType","useSelect","select","editorStore","getCurrentPostType","blockEditingMode","useBlockEditingMode","isEditingPattern","user","bindings","attributes","metadata","hasPatternBindings","values","some","binding","source","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';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst {\n\tuseSetPatternBindings,\n\tResetOverridesControl,\n\tPATTERN_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\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 = Object.keys(\n\t\t\tPARTIAL_SYNCING_SUPPORTED_BLOCKS\n\t\t).includes( props.name );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ isSupportedBlock && <BindingUpdater { ...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</>\n\t\t);\n\t}\n);\n\nfunction BindingUpdater( props ) {\n\tconst postType = useSelect(\n\t\t( select ) => select( editorStore ).getCurrentPostType(),\n\t\t[]\n\t);\n\tuseSetPatternBindings( props, postType );\n\treturn null;\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 isEditingPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getCurrentPostType() === PATTERN_TYPES.user,\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 shouldShowResetOverridesControl =\n\t\t! isEditingPattern &&\n\t\t!! props.attributes.metadata?.name &&\n\t\tblockEditingMode !== 'disabled' &&\n\t\thasPatternBindings;\n\n\treturn (\n\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;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAM;EACLO,qBAAqB;EACrBC,qBAAqB;EACrBC,aAAa;EACbC;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,GAAGC,MAAM,CAACC,IAAI,CACnCT,gCACD,CAAC,CAACU,QAAQ,CAAEJ,KAAK,CAACK,IAAK,CAAC;EAExB,OACC,IAAAC,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAE,QAAA,QACC,IAAAF,MAAA,CAAAC,aAAA,EAACR,SAAS;IAAA,GAAMC;EAAK,CAAI,CAAC,EACxBC,gBAAgB,IAAI,IAAAK,MAAA,CAAAC,aAAA,EAACE,cAAc;IAAA,GAAMT;EAAK,CAAI,CAAC,EACnDA,KAAK,CAACU,UAAU,IAAIT,gBAAgB,IACrC,IAAAK,MAAA,CAAAC,aAAA,EAACI,6BAA6B;IAAA,GAAMX;EAAK,CAAI,CAE7C,CAAC;AAEL,CACD,CAAC;AAED,SAASS,cAAcA,CAAET,KAAK,EAAG;EAChC,MAAMY,QAAQ,GAAG,IAAAC,eAAS,EACvBC,MAAM,IAAMA,MAAM,CAAEC,YAAY,CAAC,CAACC,kBAAkB,CAAC,CAAC,EACxD,EACD,CAAC;EACDzB,qBAAqB,CAAES,KAAK,EAAEY,QAAS,CAAC;EACxC,OAAO,IAAI;AACZ;;AAEA;AACA;AACA,SAASD,6BAA6BA,CAAEX,KAAK,EAAG;EAC/C,MAAMiB,gBAAgB,GAAG,IAAAC,gCAAmB,EAAC,CAAC;EAC9C,MAAMC,gBAAgB,GAAG,IAAAN,eAAS,EAC/BC,MAAM,IACPA,MAAM,CAAEC,YAAY,CAAC,CAACC,kBAAkB,CAAC,CAAC,KAAKvB,aAAa,CAAC2B,IAAI,EAClE,EACD,CAAC;EAED,MAAMC,QAAQ,GAAGrB,KAAK,CAACsB,UAAU,CAACC,QAAQ,EAAEF,QAAQ;EACpD,MAAMG,kBAAkB,GACvB,CAAC,CAAEH,QAAQ,IACXnB,MAAM,CAACuB,MAAM,CAAEJ,QAAS,CAAC,CAACK,IAAI,CAC3BC,OAAO,IAAMA,OAAO,CAACC,MAAM,KAAK,wBACnC,CAAC;EAEF,MAAMC,+BAA+B,GACpC,CAAEV,gBAAgB,IAClB,CAAC,CAAEnB,KAAK,CAACsB,UAAU,CAACC,QAAQ,EAAElB,IAAI,IAClCY,gBAAgB,KAAK,UAAU,IAC/BO,kBAAkB;EAEnB,OACC,IAAAlB,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAE,QAAA,QACGqB,+BAA+B,IAChC,IAAAvB,MAAA,CAAAC,aAAA,EAACf,qBAAqB;IAAA,GAAMQ;EAAK,CAAI,CAErC,CAAC;AAEL;AAEA,IAAA8B,gBAAS,EACR,kBAAkB,EAClB,4CAA4C,EAC5CjC,2BACD,CAAC"}
@@ -37,7 +37,8 @@ export default {
37
37
  };
38
38
  return {
39
39
  placeholder: metaKey,
40
- useValue: [metaValue, updateMetaValue]
40
+ value: metaValue,
41
+ updateValue: updateMetaValue
41
42
  };
42
43
  }
43
44
  };
@@ -1 +1 @@
1
- {"version":3,"names":["useEntityProp","useSelect","_x","store","editorStore","name","label","useSource","props","sourceAttributes","getCurrentPostType","context","key","metaKey","postType","meta","setMeta","postId","placeholder","metaValue","updateMetaValue","newValue","useValue"],"sources":["@wordpress/editor/src/bindings/post-meta.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityProp } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { _x } from '@wordpress/i18n';\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\n\nexport default {\n\tname: 'core/post-meta',\n\tlabel: _x( 'Post Meta', 'block bindings source' ),\n\tuseSource( props, sourceAttributes ) {\n\t\tconst { getCurrentPostType } = useSelect( editorStore );\n\t\tconst { context } = props;\n\t\tconst { key: metaKey } = sourceAttributes;\n\t\tconst postType = context.postType\n\t\t\t? context.postType\n\t\t\t: getCurrentPostType();\n\t\tconst [ meta, setMeta ] = useEntityProp(\n\t\t\t'postType',\n\t\t\tcontext.postType,\n\t\t\t'meta',\n\t\t\tcontext.postId\n\t\t);\n\n\t\tif ( postType === 'wp_template' ) {\n\t\t\treturn { placeholder: metaKey };\n\t\t}\n\t\tconst metaValue = meta[ metaKey ];\n\t\tconst updateMetaValue = ( newValue ) => {\n\t\t\tsetMeta( { ...meta, [ metaKey ]: newValue } );\n\t\t};\n\t\treturn {\n\t\t\tplaceholder: metaKey,\n\t\t\tuseValue: [ metaValue, updateMetaValue ],\n\t\t};\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,sBAAsB;AACpD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,EAAE,QAAQ,iBAAiB;AACpC;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,UAAU;AAE/C,eAAe;EACdC,IAAI,EAAE,gBAAgB;EACtBC,KAAK,EAAEJ,EAAE,CAAE,WAAW,EAAE,uBAAwB,CAAC;EACjDK,SAASA,CAAEC,KAAK,EAAEC,gBAAgB,EAAG;IACpC,MAAM;MAAEC;IAAmB,CAAC,GAAGT,SAAS,CAAEG,WAAY,CAAC;IACvD,MAAM;MAAEO;IAAQ,CAAC,GAAGH,KAAK;IACzB,MAAM;MAAEI,GAAG,EAAEC;IAAQ,CAAC,GAAGJ,gBAAgB;IACzC,MAAMK,QAAQ,GAAGH,OAAO,CAACG,QAAQ,GAC9BH,OAAO,CAACG,QAAQ,GAChBJ,kBAAkB,CAAC,CAAC;IACvB,MAAM,CAAEK,IAAI,EAAEC,OAAO,CAAE,GAAGhB,aAAa,CACtC,UAAU,EACVW,OAAO,CAACG,QAAQ,EAChB,MAAM,EACNH,OAAO,CAACM,MACT,CAAC;IAED,IAAKH,QAAQ,KAAK,aAAa,EAAG;MACjC,OAAO;QAAEI,WAAW,EAAEL;MAAQ,CAAC;IAChC;IACA,MAAMM,SAAS,GAAGJ,IAAI,CAAEF,OAAO,CAAE;IACjC,MAAMO,eAAe,GAAKC,QAAQ,IAAM;MACvCL,OAAO,CAAE;QAAE,GAAGD,IAAI;QAAE,CAAEF,OAAO,GAAIQ;MAAS,CAAE,CAAC;IAC9C,CAAC;IACD,OAAO;MACNH,WAAW,EAAEL,OAAO;MACpBS,QAAQ,EAAE,CAAEH,SAAS,EAAEC,eAAe;IACvC,CAAC;EACF;AACD,CAAC"}
1
+ {"version":3,"names":["useEntityProp","useSelect","_x","store","editorStore","name","label","useSource","props","sourceAttributes","getCurrentPostType","context","key","metaKey","postType","meta","setMeta","postId","placeholder","metaValue","updateMetaValue","newValue","value","updateValue"],"sources":["@wordpress/editor/src/bindings/post-meta.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { useEntityProp } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { _x } from '@wordpress/i18n';\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\n\nexport default {\n\tname: 'core/post-meta',\n\tlabel: _x( 'Post Meta', 'block bindings source' ),\n\tuseSource( props, sourceAttributes ) {\n\t\tconst { getCurrentPostType } = useSelect( editorStore );\n\t\tconst { context } = props;\n\t\tconst { key: metaKey } = sourceAttributes;\n\t\tconst postType = context.postType\n\t\t\t? context.postType\n\t\t\t: getCurrentPostType();\n\n\t\tconst [ meta, setMeta ] = useEntityProp(\n\t\t\t'postType',\n\t\t\tcontext.postType,\n\t\t\t'meta',\n\t\t\tcontext.postId\n\t\t);\n\n\t\tif ( postType === 'wp_template' ) {\n\t\t\treturn { placeholder: metaKey };\n\t\t}\n\t\tconst metaValue = meta[ metaKey ];\n\t\tconst updateMetaValue = ( newValue ) => {\n\t\t\tsetMeta( { ...meta, [ metaKey ]: newValue } );\n\t\t};\n\n\t\treturn {\n\t\t\tplaceholder: metaKey,\n\t\t\tvalue: metaValue,\n\t\t\tupdateValue: updateMetaValue,\n\t\t};\n\t},\n};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,aAAa,QAAQ,sBAAsB;AACpD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,EAAE,QAAQ,iBAAiB;AACpC;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,UAAU;AAE/C,eAAe;EACdC,IAAI,EAAE,gBAAgB;EACtBC,KAAK,EAAEJ,EAAE,CAAE,WAAW,EAAE,uBAAwB,CAAC;EACjDK,SAASA,CAAEC,KAAK,EAAEC,gBAAgB,EAAG;IACpC,MAAM;MAAEC;IAAmB,CAAC,GAAGT,SAAS,CAAEG,WAAY,CAAC;IACvD,MAAM;MAAEO;IAAQ,CAAC,GAAGH,KAAK;IACzB,MAAM;MAAEI,GAAG,EAAEC;IAAQ,CAAC,GAAGJ,gBAAgB;IACzC,MAAMK,QAAQ,GAAGH,OAAO,CAACG,QAAQ,GAC9BH,OAAO,CAACG,QAAQ,GAChBJ,kBAAkB,CAAC,CAAC;IAEvB,MAAM,CAAEK,IAAI,EAAEC,OAAO,CAAE,GAAGhB,aAAa,CACtC,UAAU,EACVW,OAAO,CAACG,QAAQ,EAChB,MAAM,EACNH,OAAO,CAACM,MACT,CAAC;IAED,IAAKH,QAAQ,KAAK,aAAa,EAAG;MACjC,OAAO;QAAEI,WAAW,EAAEL;MAAQ,CAAC;IAChC;IACA,MAAMM,SAAS,GAAGJ,IAAI,CAAEF,OAAO,CAAE;IACjC,MAAMO,eAAe,GAAKC,QAAQ,IAAM;MACvCL,OAAO,CAAE;QAAE,GAAGD,IAAI;QAAE,CAAEF,OAAO,GAAIQ;MAAS,CAAE,CAAC;IAC9C,CAAC;IAED,OAAO;MACNH,WAAW,EAAEL,OAAO;MACpBS,KAAK,EAAEH,SAAS;MAChBI,WAAW,EAAEH;IACd,CAAC;EACF;AACD,CAAC"}
@@ -3,5 +3,5 @@
3
3
  */
4
4
  import './custom-sources-backwards-compatibility';
5
5
  import './default-autocompleters';
6
- import './pattern-partial-syncing';
6
+ import './pattern-overrides';
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"names":[],"sources":["@wordpress/editor/src/hooks/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport './custom-sources-backwards-compatibility';\nimport './default-autocompleters';\nimport './pattern-partial-syncing';\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,0CAA0C;AACjD,OAAO,0BAA0B;AACjC,OAAO,2BAA2B"}
1
+ {"version":3,"names":[],"sources":["@wordpress/editor/src/hooks/index.js"],"sourcesContent":["/**\n * Internal dependencies\n */\nimport './custom-sources-backwards-compatibility';\nimport './default-autocompleters';\nimport './pattern-overrides';\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,0CAA0C;AACjD,OAAO,0BAA0B;AACjC,OAAO,qBAAqB"}
@@ -14,7 +14,7 @@ import { useSelect } from '@wordpress/data';
14
14
  import { store as editorStore } from '../store';
15
15
  import { unlock } from '../lock-unlock';
16
16
  const {
17
- PartialSyncingControls,
17
+ useSetPatternBindings,
18
18
  ResetOverridesControl,
19
19
  PATTERN_TYPES,
20
20
  PARTIAL_SYNCING_SUPPORTED_BLOCKS
@@ -29,14 +29,21 @@ const {
29
29
  *
30
30
  * @return {Component} Wrapped component.
31
31
  */
32
- const withPartialSyncingControls = createHigherOrderComponent(BlockEdit => props => {
32
+ const withPatternOverrideControls = createHigherOrderComponent(BlockEdit => props => {
33
33
  const isSupportedBlock = Object.keys(PARTIAL_SYNCING_SUPPORTED_BLOCKS).includes(props.name);
34
34
  return createElement(Fragment, null, createElement(BlockEdit, {
35
35
  ...props
36
+ }), isSupportedBlock && createElement(BindingUpdater, {
37
+ ...props
36
38
  }), props.isSelected && isSupportedBlock && createElement(ControlsWithStoreSubscription, {
37
39
  ...props
38
40
  }));
39
41
  });
42
+ function BindingUpdater(props) {
43
+ const postType = useSelect(select => select(editorStore).getCurrentPostType(), []);
44
+ useSetPatternBindings(props, postType);
45
+ return null;
46
+ }
40
47
 
41
48
  // Split into a separate component to avoid a store subscription
42
49
  // on every block.
@@ -45,13 +52,10 @@ function ControlsWithStoreSubscription(props) {
45
52
  const isEditingPattern = useSelect(select => select(editorStore).getCurrentPostType() === PATTERN_TYPES.user, []);
46
53
  const bindings = props.attributes.metadata?.bindings;
47
54
  const hasPatternBindings = !!bindings && Object.values(bindings).some(binding => binding.source === 'core/pattern-overrides');
48
- const shouldShowPartialSyncingControls = isEditingPattern && blockEditingMode === 'default';
49
- const shouldShowResetOverridesControl = !isEditingPattern && !!props.attributes.metadata?.id && blockEditingMode !== 'disabled' && hasPatternBindings;
50
- return createElement(Fragment, null, shouldShowPartialSyncingControls && createElement(PartialSyncingControls, {
51
- ...props
52
- }), shouldShowResetOverridesControl && createElement(ResetOverridesControl, {
55
+ const shouldShowResetOverridesControl = !isEditingPattern && !!props.attributes.metadata?.name && blockEditingMode !== 'disabled' && hasPatternBindings;
56
+ return createElement(Fragment, null, shouldShowResetOverridesControl && createElement(ResetOverridesControl, {
53
57
  ...props
54
58
  }));
55
59
  }
56
- addFilter('editor.BlockEdit', 'core/editor/with-partial-syncing-controls', withPartialSyncingControls);
57
- //# sourceMappingURL=pattern-partial-syncing.js.map
60
+ addFilter('editor.BlockEdit', 'core/editor/with-pattern-override-controls', withPatternOverrideControls);
61
+ //# sourceMappingURL=pattern-overrides.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["addFilter","privateApis","patternsPrivateApis","createHigherOrderComponent","useBlockEditingMode","useSelect","store","editorStore","unlock","useSetPatternBindings","ResetOverridesControl","PATTERN_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","withPatternOverrideControls","BlockEdit","props","isSupportedBlock","Object","keys","includes","name","createElement","Fragment","BindingUpdater","isSelected","ControlsWithStoreSubscription","postType","select","getCurrentPostType","blockEditingMode","isEditingPattern","user","bindings","attributes","metadata","hasPatternBindings","values","some","binding","source","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';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst {\n\tuseSetPatternBindings,\n\tResetOverridesControl,\n\tPATTERN_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\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 = Object.keys(\n\t\t\tPARTIAL_SYNCING_SUPPORTED_BLOCKS\n\t\t).includes( props.name );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...props } />\n\t\t\t\t{ isSupportedBlock && <BindingUpdater { ...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</>\n\t\t);\n\t}\n);\n\nfunction BindingUpdater( props ) {\n\tconst postType = useSelect(\n\t\t( select ) => select( editorStore ).getCurrentPostType(),\n\t\t[]\n\t);\n\tuseSetPatternBindings( props, postType );\n\treturn null;\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 isEditingPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getCurrentPostType() === PATTERN_TYPES.user,\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 shouldShowResetOverridesControl =\n\t\t! isEditingPattern &&\n\t\t!! props.attributes.metadata?.name &&\n\t\tblockEditingMode !== 'disabled' &&\n\t\thasPatternBindings;\n\n\treturn (\n\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;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,UAAU;AAC/C,SAASC,MAAM,QAAQ,gBAAgB;AAEvC,MAAM;EACLC,qBAAqB;EACrBC,qBAAqB;EACrBC,aAAa;EACbC;AACD,CAAC,GAAGJ,MAAM,CAAEN,mBAAoB,CAAC;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMW,2BAA2B,GAAGV,0BAA0B,CAC3DW,SAAS,IAAQC,KAAK,IAAM;EAC7B,MAAMC,gBAAgB,GAAGC,MAAM,CAACC,IAAI,CACnCN,gCACD,CAAC,CAACO,QAAQ,CAAEJ,KAAK,CAACK,IAAK,CAAC;EAExB,OACCC,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACP,SAAS;IAAA,GAAMC;EAAK,CAAI,CAAC,EACxBC,gBAAgB,IAAIK,aAAA,CAACE,cAAc;IAAA,GAAMR;EAAK,CAAI,CAAC,EACnDA,KAAK,CAACS,UAAU,IAAIR,gBAAgB,IACrCK,aAAA,CAACI,6BAA6B;IAAA,GAAMV;EAAK,CAAI,CAE7C,CAAC;AAEL,CACD,CAAC;AAED,SAASQ,cAAcA,CAAER,KAAK,EAAG;EAChC,MAAMW,QAAQ,GAAGrB,SAAS,CACvBsB,MAAM,IAAMA,MAAM,CAAEpB,WAAY,CAAC,CAACqB,kBAAkB,CAAC,CAAC,EACxD,EACD,CAAC;EACDnB,qBAAqB,CAAEM,KAAK,EAAEW,QAAS,CAAC;EACxC,OAAO,IAAI;AACZ;;AAEA;AACA;AACA,SAASD,6BAA6BA,CAAEV,KAAK,EAAG;EAC/C,MAAMc,gBAAgB,GAAGzB,mBAAmB,CAAC,CAAC;EAC9C,MAAM0B,gBAAgB,GAAGzB,SAAS,CAC/BsB,MAAM,IACPA,MAAM,CAAEpB,WAAY,CAAC,CAACqB,kBAAkB,CAAC,CAAC,KAAKjB,aAAa,CAACoB,IAAI,EAClE,EACD,CAAC;EAED,MAAMC,QAAQ,GAAGjB,KAAK,CAACkB,UAAU,CAACC,QAAQ,EAAEF,QAAQ;EACpD,MAAMG,kBAAkB,GACvB,CAAC,CAAEH,QAAQ,IACXf,MAAM,CAACmB,MAAM,CAAEJ,QAAS,CAAC,CAACK,IAAI,CAC3BC,OAAO,IAAMA,OAAO,CAACC,MAAM,KAAK,wBACnC,CAAC;EAEF,MAAMC,+BAA+B,GACpC,CAAEV,gBAAgB,IAClB,CAAC,CAAEf,KAAK,CAACkB,UAAU,CAACC,QAAQ,EAAEd,IAAI,IAClCS,gBAAgB,KAAK,UAAU,IAC/BM,kBAAkB;EAEnB,OACCd,aAAA,CAAAC,QAAA,QACGkB,+BAA+B,IAChCnB,aAAA,CAACX,qBAAqB;IAAA,GAAMK;EAAK,CAAI,CAErC,CAAC;AAEL;AAEAf,SAAS,CACR,kBAAkB,EAClB,4CAA4C,EAC5Ca,2BACD,CAAC"}
@@ -97,6 +97,7 @@
97
97
  --wp-admin-border-width-focus: 2px;
98
98
  --wp-block-synced-color: #7a00df;
99
99
  --wp-block-synced-color--rgb: 122, 0, 223;
100
+ --wp-bound-block-color: #9747ff;
100
101
  }
101
102
  @media (min-resolution: 192dpi) {
102
103
  :root {
@@ -97,6 +97,7 @@
97
97
  --wp-admin-border-width-focus: 2px;
98
98
  --wp-block-synced-color: #7a00df;
99
99
  --wp-block-synced-color--rgb: 122, 0, 223;
100
+ --wp-bound-block-color: #9747ff;
100
101
  }
101
102
  @media (min-resolution: 192dpi) {
102
103
  :root {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/editor",
3
- "version": "13.28.4",
3
+ "version": "13.28.5",
4
4
  "description": "Enhanced block editor for WordPress posts.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -34,12 +34,12 @@
34
34
  "@wordpress/a11y": "^3.51.1",
35
35
  "@wordpress/api-fetch": "^6.48.1",
36
36
  "@wordpress/blob": "^3.51.1",
37
- "@wordpress/block-editor": "^12.19.4",
38
- "@wordpress/blocks": "^12.28.4",
39
- "@wordpress/commands": "^0.22.3",
40
- "@wordpress/components": "^26.0.3",
37
+ "@wordpress/block-editor": "^12.19.5",
38
+ "@wordpress/blocks": "^12.28.5",
39
+ "@wordpress/commands": "^0.22.4",
40
+ "@wordpress/components": "^26.0.4",
41
41
  "@wordpress/compose": "^6.28.1",
42
- "@wordpress/core-data": "^6.28.4",
42
+ "@wordpress/core-data": "^6.28.5",
43
43
  "@wordpress/data": "^9.21.1",
44
44
  "@wordpress/date": "^4.51.1",
45
45
  "@wordpress/deprecated": "^3.51.1",
@@ -48,17 +48,17 @@
48
48
  "@wordpress/hooks": "^3.51.1",
49
49
  "@wordpress/html-entities": "^3.51.1",
50
50
  "@wordpress/i18n": "^4.51.1",
51
- "@wordpress/icons": "^9.42.2",
51
+ "@wordpress/icons": "^9.42.3",
52
52
  "@wordpress/keyboard-shortcuts": "^4.28.1",
53
53
  "@wordpress/keycodes": "^3.51.1",
54
54
  "@wordpress/media-utils": "^4.42.1",
55
55
  "@wordpress/notices": "^4.19.1",
56
- "@wordpress/patterns": "^1.12.4",
57
- "@wordpress/preferences": "^3.28.3",
56
+ "@wordpress/patterns": "^1.12.5",
57
+ "@wordpress/preferences": "^3.28.4",
58
58
  "@wordpress/private-apis": "^0.33.1",
59
- "@wordpress/reusable-blocks": "^4.28.4",
60
- "@wordpress/rich-text": "^6.28.2",
61
- "@wordpress/server-side-render": "^4.28.4",
59
+ "@wordpress/reusable-blocks": "^4.28.5",
60
+ "@wordpress/rich-text": "^6.28.3",
61
+ "@wordpress/server-side-render": "^4.28.5",
62
62
  "@wordpress/url": "^3.52.1",
63
63
  "@wordpress/wordcount": "^3.51.1",
64
64
  "classnames": "^2.3.1",
@@ -75,5 +75,5 @@
75
75
  "publishConfig": {
76
76
  "access": "public"
77
77
  },
78
- "gitHead": "864c1c553cb284def3bd5c907998da45f5c143ea"
78
+ "gitHead": "4927ea437069f9aed12f696df294a79bd8e12fd5"
79
79
  }
@@ -19,6 +19,7 @@ export default {
19
19
  const postType = context.postType
20
20
  ? context.postType
21
21
  : getCurrentPostType();
22
+
22
23
  const [ meta, setMeta ] = useEntityProp(
23
24
  'postType',
24
25
  context.postType,
@@ -33,9 +34,11 @@ export default {
33
34
  const updateMetaValue = ( newValue ) => {
34
35
  setMeta( { ...meta, [ metaKey ]: newValue } );
35
36
  };
37
+
36
38
  return {
37
39
  placeholder: metaKey,
38
- useValue: [ metaValue, updateMetaValue ],
40
+ value: metaValue,
41
+ updateValue: updateMetaValue,
39
42
  };
40
43
  },
41
44
  };
@@ -3,4 +3,4 @@
3
3
  */
4
4
  import './custom-sources-backwards-compatibility';
5
5
  import './default-autocompleters';
6
- import './pattern-partial-syncing';
6
+ import './pattern-overrides';
@@ -14,7 +14,7 @@ import { store as editorStore } from '../store';
14
14
  import { unlock } from '../lock-unlock';
15
15
 
16
16
  const {
17
- PartialSyncingControls,
17
+ useSetPatternBindings,
18
18
  ResetOverridesControl,
19
19
  PATTERN_TYPES,
20
20
  PARTIAL_SYNCING_SUPPORTED_BLOCKS,
@@ -29,7 +29,7 @@ const {
29
29
  *
30
30
  * @return {Component} Wrapped component.
31
31
  */
32
- const withPartialSyncingControls = createHigherOrderComponent(
32
+ const withPatternOverrideControls = createHigherOrderComponent(
33
33
  ( BlockEdit ) => ( props ) => {
34
34
  const isSupportedBlock = Object.keys(
35
35
  PARTIAL_SYNCING_SUPPORTED_BLOCKS
@@ -38,6 +38,7 @@ const withPartialSyncingControls = createHigherOrderComponent(
38
38
  return (
39
39
  <>
40
40
  <BlockEdit { ...props } />
41
+ { isSupportedBlock && <BindingUpdater { ...props } /> }
41
42
  { props.isSelected && isSupportedBlock && (
42
43
  <ControlsWithStoreSubscription { ...props } />
43
44
  ) }
@@ -46,6 +47,15 @@ const withPartialSyncingControls = createHigherOrderComponent(
46
47
  }
47
48
  );
48
49
 
50
+ function BindingUpdater( props ) {
51
+ const postType = useSelect(
52
+ ( select ) => select( editorStore ).getCurrentPostType(),
53
+ []
54
+ );
55
+ useSetPatternBindings( props, postType );
56
+ return null;
57
+ }
58
+
49
59
  // Split into a separate component to avoid a store subscription
50
60
  // on every block.
51
61
  function ControlsWithStoreSubscription( props ) {
@@ -55,6 +65,7 @@ function ControlsWithStoreSubscription( props ) {
55
65
  select( editorStore ).getCurrentPostType() === PATTERN_TYPES.user,
56
66
  []
57
67
  );
68
+
58
69
  const bindings = props.attributes.metadata?.bindings;
59
70
  const hasPatternBindings =
60
71
  !! bindings &&
@@ -62,19 +73,14 @@ function ControlsWithStoreSubscription( props ) {
62
73
  ( binding ) => binding.source === 'core/pattern-overrides'
63
74
  );
64
75
 
65
- const shouldShowPartialSyncingControls =
66
- isEditingPattern && blockEditingMode === 'default';
67
76
  const shouldShowResetOverridesControl =
68
77
  ! isEditingPattern &&
69
- !! props.attributes.metadata?.id &&
78
+ !! props.attributes.metadata?.name &&
70
79
  blockEditingMode !== 'disabled' &&
71
80
  hasPatternBindings;
72
81
 
73
82
  return (
74
83
  <>
75
- { shouldShowPartialSyncingControls && (
76
- <PartialSyncingControls { ...props } />
77
- ) }
78
84
  { shouldShowResetOverridesControl && (
79
85
  <ResetOverridesControl { ...props } />
80
86
  ) }
@@ -84,6 +90,6 @@ function ControlsWithStoreSubscription( props ) {
84
90
 
85
91
  addFilter(
86
92
  'editor.BlockEdit',
87
- 'core/editor/with-partial-syncing-controls',
88
- withPartialSyncingControls
93
+ 'core/editor/with-pattern-override-controls',
94
+ withPatternOverrideControls
89
95
  );
@@ -1 +0,0 @@
1
- {"version":3,"names":["_hooks","require","_patterns","_compose","_blockEditor","_data","_store","_lockUnlock","PartialSyncingControls","ResetOverridesControl","PATTERN_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","unlock","patternsPrivateApis","withPartialSyncingControls","createHigherOrderComponent","BlockEdit","props","isSupportedBlock","Object","keys","includes","name","_react","createElement","Fragment","isSelected","ControlsWithStoreSubscription","blockEditingMode","useBlockEditingMode","isEditingPattern","useSelect","select","editorStore","getCurrentPostType","user","bindings","attributes","metadata","hasPatternBindings","values","some","binding","source","shouldShowPartialSyncingControls","shouldShowResetOverridesControl","id","addFilter"],"sources":["@wordpress/editor/src/hooks/pattern-partial-syncing.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';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst {\n\tPartialSyncingControls,\n\tResetOverridesControl,\n\tPATTERN_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\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 withPartialSyncingControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst isSupportedBlock = Object.keys(\n\t\t\tPARTIAL_SYNCING_SUPPORTED_BLOCKS\n\t\t).includes( props.name );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...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</>\n\t\t);\n\t}\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 isEditingPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getCurrentPostType() === PATTERN_TYPES.user,\n\t\t[]\n\t);\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 shouldShowPartialSyncingControls =\n\t\tisEditingPattern && blockEditingMode === 'default';\n\tconst shouldShowResetOverridesControl =\n\t\t! isEditingPattern &&\n\t\t!! props.attributes.metadata?.id &&\n\t\tblockEditingMode !== 'disabled' &&\n\t\thasPatternBindings;\n\n\treturn (\n\t\t<>\n\t\t\t{ shouldShowPartialSyncingControls && (\n\t\t\t\t<PartialSyncingControls { ...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-partial-syncing-controls',\n\twithPartialSyncingControls\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;AAKA,IAAAK,MAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AAbA;AACA;AACA;;AAOA;AACA;AACA;;AAIA,MAAM;EACLO,sBAAsB;EACtBC,qBAAqB;EACrBC,aAAa;EACbC;AACD,CAAC,GAAG,IAAAC,kBAAM,EAAEC,qBAAoB,CAAC;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,0BAA0B,GAAG,IAAAC,mCAA0B,EAC1DC,SAAS,IAAQC,KAAK,IAAM;EAC7B,MAAMC,gBAAgB,GAAGC,MAAM,CAACC,IAAI,CACnCT,gCACD,CAAC,CAACU,QAAQ,CAAEJ,KAAK,CAACK,IAAK,CAAC;EAExB,OACC,IAAAC,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAE,QAAA,QACC,IAAAF,MAAA,CAAAC,aAAA,EAACR,SAAS;IAAA,GAAMC;EAAK,CAAI,CAAC,EACxBA,KAAK,CAACS,UAAU,IAAIR,gBAAgB,IACrC,IAAAK,MAAA,CAAAC,aAAA,EAACG,6BAA6B;IAAA,GAAMV;EAAK,CAAI,CAE7C,CAAC;AAEL,CACD,CAAC;;AAED;AACA;AACA,SAASU,6BAA6BA,CAAEV,KAAK,EAAG;EAC/C,MAAMW,gBAAgB,GAAG,IAAAC,gCAAmB,EAAC,CAAC;EAC9C,MAAMC,gBAAgB,GAAG,IAAAC,eAAS,EAC/BC,MAAM,IACPA,MAAM,CAAEC,YAAY,CAAC,CAACC,kBAAkB,CAAC,CAAC,KAAKxB,aAAa,CAACyB,IAAI,EAClE,EACD,CAAC;EACD,MAAMC,QAAQ,GAAGnB,KAAK,CAACoB,UAAU,CAACC,QAAQ,EAAEF,QAAQ;EACpD,MAAMG,kBAAkB,GACvB,CAAC,CAAEH,QAAQ,IACXjB,MAAM,CAACqB,MAAM,CAAEJ,QAAS,CAAC,CAACK,IAAI,CAC3BC,OAAO,IAAMA,OAAO,CAACC,MAAM,KAAK,wBACnC,CAAC;EAEF,MAAMC,gCAAgC,GACrCd,gBAAgB,IAAIF,gBAAgB,KAAK,SAAS;EACnD,MAAMiB,+BAA+B,GACpC,CAAEf,gBAAgB,IAClB,CAAC,CAAEb,KAAK,CAACoB,UAAU,CAACC,QAAQ,EAAEQ,EAAE,IAChClB,gBAAgB,KAAK,UAAU,IAC/BW,kBAAkB;EAEnB,OACC,IAAAhB,MAAA,CAAAC,aAAA,EAAAD,MAAA,CAAAE,QAAA,QACGmB,gCAAgC,IACjC,IAAArB,MAAA,CAAAC,aAAA,EAAChB,sBAAsB;IAAA,GAAMS;EAAK,CAAI,CACtC,EACC4B,+BAA+B,IAChC,IAAAtB,MAAA,CAAAC,aAAA,EAACf,qBAAqB;IAAA,GAAMQ;EAAK,CAAI,CAErC,CAAC;AAEL;AAEA,IAAA8B,gBAAS,EACR,kBAAkB,EAClB,2CAA2C,EAC3CjC,0BACD,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"names":["addFilter","privateApis","patternsPrivateApis","createHigherOrderComponent","useBlockEditingMode","useSelect","store","editorStore","unlock","PartialSyncingControls","ResetOverridesControl","PATTERN_TYPES","PARTIAL_SYNCING_SUPPORTED_BLOCKS","withPartialSyncingControls","BlockEdit","props","isSupportedBlock","Object","keys","includes","name","createElement","Fragment","isSelected","ControlsWithStoreSubscription","blockEditingMode","isEditingPattern","select","getCurrentPostType","user","bindings","attributes","metadata","hasPatternBindings","values","some","binding","source","shouldShowPartialSyncingControls","shouldShowResetOverridesControl","id"],"sources":["@wordpress/editor/src/hooks/pattern-partial-syncing.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';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../store';\nimport { unlock } from '../lock-unlock';\n\nconst {\n\tPartialSyncingControls,\n\tResetOverridesControl,\n\tPATTERN_TYPES,\n\tPARTIAL_SYNCING_SUPPORTED_BLOCKS,\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 withPartialSyncingControls = createHigherOrderComponent(\n\t( BlockEdit ) => ( props ) => {\n\t\tconst isSupportedBlock = Object.keys(\n\t\t\tPARTIAL_SYNCING_SUPPORTED_BLOCKS\n\t\t).includes( props.name );\n\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<BlockEdit { ...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</>\n\t\t);\n\t}\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 isEditingPattern = useSelect(\n\t\t( select ) =>\n\t\t\tselect( editorStore ).getCurrentPostType() === PATTERN_TYPES.user,\n\t\t[]\n\t);\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 shouldShowPartialSyncingControls =\n\t\tisEditingPattern && blockEditingMode === 'default';\n\tconst shouldShowResetOverridesControl =\n\t\t! isEditingPattern &&\n\t\t!! props.attributes.metadata?.id &&\n\t\tblockEditingMode !== 'disabled' &&\n\t\thasPatternBindings;\n\n\treturn (\n\t\t<>\n\t\t\t{ shouldShowPartialSyncingControls && (\n\t\t\t\t<PartialSyncingControls { ...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-partial-syncing-controls',\n\twithPartialSyncingControls\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;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,WAAW,QAAQ,UAAU;AAC/C,SAASC,MAAM,QAAQ,gBAAgB;AAEvC,MAAM;EACLC,sBAAsB;EACtBC,qBAAqB;EACrBC,aAAa;EACbC;AACD,CAAC,GAAGJ,MAAM,CAAEN,mBAAoB,CAAC;;AAEjC;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMW,0BAA0B,GAAGV,0BAA0B,CAC1DW,SAAS,IAAQC,KAAK,IAAM;EAC7B,MAAMC,gBAAgB,GAAGC,MAAM,CAACC,IAAI,CACnCN,gCACD,CAAC,CAACO,QAAQ,CAAEJ,KAAK,CAACK,IAAK,CAAC;EAExB,OACCC,aAAA,CAAAC,QAAA,QACCD,aAAA,CAACP,SAAS;IAAA,GAAMC;EAAK,CAAI,CAAC,EACxBA,KAAK,CAACQ,UAAU,IAAIP,gBAAgB,IACrCK,aAAA,CAACG,6BAA6B;IAAA,GAAMT;EAAK,CAAI,CAE7C,CAAC;AAEL,CACD,CAAC;;AAED;AACA;AACA,SAASS,6BAA6BA,CAAET,KAAK,EAAG;EAC/C,MAAMU,gBAAgB,GAAGrB,mBAAmB,CAAC,CAAC;EAC9C,MAAMsB,gBAAgB,GAAGrB,SAAS,CAC/BsB,MAAM,IACPA,MAAM,CAAEpB,WAAY,CAAC,CAACqB,kBAAkB,CAAC,CAAC,KAAKjB,aAAa,CAACkB,IAAI,EAClE,EACD,CAAC;EACD,MAAMC,QAAQ,GAAGf,KAAK,CAACgB,UAAU,CAACC,QAAQ,EAAEF,QAAQ;EACpD,MAAMG,kBAAkB,GACvB,CAAC,CAAEH,QAAQ,IACXb,MAAM,CAACiB,MAAM,CAAEJ,QAAS,CAAC,CAACK,IAAI,CAC3BC,OAAO,IAAMA,OAAO,CAACC,MAAM,KAAK,wBACnC,CAAC;EAEF,MAAMC,gCAAgC,GACrCZ,gBAAgB,IAAID,gBAAgB,KAAK,SAAS;EACnD,MAAMc,+BAA+B,GACpC,CAAEb,gBAAgB,IAClB,CAAC,CAAEX,KAAK,CAACgB,UAAU,CAACC,QAAQ,EAAEQ,EAAE,IAChCf,gBAAgB,KAAK,UAAU,IAC/BQ,kBAAkB;EAEnB,OACCZ,aAAA,CAAAC,QAAA,QACGgB,gCAAgC,IACjCjB,aAAA,CAACZ,sBAAsB;IAAA,GAAMM;EAAK,CAAI,CACtC,EACCwB,+BAA+B,IAChClB,aAAA,CAACX,qBAAqB;IAAA,GAAMK;EAAK,CAAI,CAErC,CAAC;AAEL;AAEAf,SAAS,CACR,kBAAkB,EAClB,2CAA2C,EAC3Ca,0BACD,CAAC"}