@wordpress/reusable-blocks 3.1.2 → 3.2.0-next.e230fbab09.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -77,11 +77,11 @@ const __experimentalDeleteReusableBlock = id => async _ref3 => {
77
77
  let {
78
78
  registry
79
79
  } = _ref3;
80
- const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', id); // Don't allow a reusable block with a temporary ID to be deleted
80
+ const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', id); // Don't allow a reusable block with a temporary ID to be deleted.
81
81
 
82
82
  if (!reusableBlock) {
83
83
  return;
84
- } // Remove any other blocks that reference this reusable block
84
+ } // Remove any other blocks that reference this reusable block.
85
85
 
86
86
 
87
87
  const allBlocks = registry.select(_blockEditor.store).getBlocks();
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/reusable-blocks/src/store/actions.js"],"names":["__experimentalConvertBlockToStatic","clientId","registry","oldBlock","select","blockEditorStore","getBlock","reusableBlock","getEditedEntityRecord","attributes","ref","newBlocks","content","dispatch","replaceBlocks","__experimentalConvertBlocksToReusable","clientIds","title","getBlocksByClientId","status","updatedRecord","saveEntityRecord","newBlock","id","__experimentalSetEditingReusableBlock","__experimentalDeleteReusableBlock","allBlocks","getBlocks","associatedBlocks","filter","block","associatedBlockClientIds","map","length","removeBlocks","deleteEntityRecord","isEditing","type"],"mappings":";;;;;;;;AAGA;;AAKA;;AACA;;AAMA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACO,MAAMA,kCAAkC,GAAKC,QAAF,IAAgB,QAE3D;AAAA,MAF6D;AACnEC,IAAAA;AADmE,GAE7D;AACN,QAAMC,QAAQ,GAAGD,QAAQ,CAACE,MAAT,CAAiBC,kBAAjB,EAAoCC,QAApC,CAA8CL,QAA9C,CAAjB;AACA,QAAMM,aAAa,GAAGL,QAAQ,CAC5BE,MADoB,CACZ,MAD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AiC,GAAKF,EAAF,IAAU,eAEpD;AAAA,MAF4D;AAClErB,IAAAA;AADkE,GAE5D;AACN,QAAMK,aAAa,GAAGL,QAAQ,CAC5BE,MADoB,CACZ,MADY,EAEpBI,qBAFoB,CAEG,UAFH,EAEe,UAFf,EAE2Be,EAF3B,CAAtB,CADM,CAKN;;AACA,MAAK,CAAEhB,aAAP,EAAuB;AACtB;AACA,GARK,CAUN;;;AACA,QAAMmB,SAAS,GAAGxB,QAAQ,CAACE,MAAT,CAAiBC,kBAAjB,EAAoCsB,SAApC,EAAlB;AACA,QAAMC,gBAAgB,GAAGF,SAAS,CAACG,MAAV,CACtBC,KAAF,IAAa,6BAAiBA,KAAjB,KAA4BA,KAAK,CAACrB,UAAN,CAAiBC,GAAjB,KAAyBa,EAD1C,CAAzB;AAGA,QAAMQ,wBAAwB,GAAGH,gBAAgB,CAACI,GAAjB,CAC9BF,KAAF,IAAaA,KAAK,CAAC7B,QADa,CAAjC,CAfM,CAmBN;;AACA,MAAK8B,wBAAwB,CAACE,MAA9B,EAAuC;AACtC/B,IAAAA,QAAQ,CACNW,QADF,CACYR,kBADZ,EAEE6B,YAFF,CAEgBH,wBAFhB;AAGA;;AAED,QAAM7B,QAAQ,CACZW,QADI,CACM,MADN,EAEJsB,kBAFI,CAEgB,UAFhB,EAE4B,UAF5B,EAEwCZ,EAFxC,CAAN;AAGA,CA/BM;AAiCP;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,SAASC,qCAAT,CAAgDvB,QAAhD,EAA0DmC,SAA1D,EAAsE;AAC5E,SAAO;AACNC,IAAAA,IAAI,EAAE,4BADA;AAENpC,IAAAA,QAFM;AAGNmC,IAAAA;AAHM,GAAP;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport { isFunction } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tcreateBlock,\n\tisReusableBlock,\n\tparse,\n\tserialize,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Returns a generator converting a reusable block into a static block.\n *\n * @param {string} clientId The client ID of the block to attach.\n */\nexport const __experimentalConvertBlockToStatic = ( clientId ) => ( {\n\tregistry,\n} ) => {\n\tconst oldBlock = registry.select( blockEditorStore ).getBlock( clientId );\n\tconst reusableBlock = registry\n\t\t.select( 'core' )\n\t\t.getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_block',\n\t\t\toldBlock.attributes.ref\n\t\t);\n\n\tconst newBlocks = parse(\n\t\tisFunction( reusableBlock.content )\n\t\t\t? reusableBlock.content( reusableBlock )\n\t\t\t: reusableBlock.content\n\t);\n\tregistry\n\t\t.dispatch( blockEditorStore )\n\t\t.replaceBlocks( oldBlock.clientId, newBlocks );\n};\n\n/**\n * Returns a generator converting one or more static blocks into a reusable block.\n *\n * @param {string[]} clientIds The client IDs of the block to detach.\n * @param {string} title Reusable block title.\n */\nexport const __experimentalConvertBlocksToReusable = (\n\tclientIds,\n\ttitle\n) => async ( { registry, dispatch } ) => {\n\tconst reusableBlock = {\n\t\ttitle: title || __( 'Untitled Reusable block' ),\n\t\tcontent: serialize(\n\t\t\tregistry.select( blockEditorStore ).getBlocksByClientId( clientIds )\n\t\t),\n\t\tstatus: 'publish',\n\t};\n\n\tconst updatedRecord = await registry\n\t\t.dispatch( 'core' )\n\t\t.saveEntityRecord( 'postType', 'wp_block', reusableBlock );\n\n\tconst newBlock = createBlock( 'core/block', {\n\t\tref: updatedRecord.id,\n\t} );\n\tregistry.dispatch( blockEditorStore ).replaceBlocks( clientIds, newBlock );\n\tdispatch.__experimentalSetEditingReusableBlock( newBlock.clientId, true );\n};\n\n/**\n * Returns a generator deleting a reusable block.\n *\n * @param {string} id The ID of the reusable block to delete.\n */\nexport const __experimentalDeleteReusableBlock = ( id ) => async ( {\n\tregistry,\n} ) => {\n\tconst reusableBlock = registry\n\t\t.select( 'core' )\n\t\t.getEditedEntityRecord( 'postType', 'wp_block', id );\n\n\t// Don't allow a reusable block with a temporary ID to be deleted\n\tif ( ! reusableBlock ) {\n\t\treturn;\n\t}\n\n\t// Remove any other blocks that reference this reusable block\n\tconst allBlocks = registry.select( blockEditorStore ).getBlocks();\n\tconst associatedBlocks = allBlocks.filter(\n\t\t( block ) => isReusableBlock( block ) && block.attributes.ref === id\n\t);\n\tconst associatedBlockClientIds = associatedBlocks.map(\n\t\t( block ) => block.clientId\n\t);\n\n\t// Remove the parsed block.\n\tif ( associatedBlockClientIds.length ) {\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.removeBlocks( associatedBlockClientIds );\n\t}\n\n\tawait registry\n\t\t.dispatch( 'core' )\n\t\t.deleteEntityRecord( 'postType', 'wp_block', id );\n};\n\n/**\n * Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action.\n *\n * @param {string} clientId The clientID of the reusable block to target.\n * @param {boolean} isEditing Whether the block should be in editing state.\n * @return {Object} Action descriptor.\n */\nexport function __experimentalSetEditingReusableBlock( clientId, isEditing ) {\n\treturn {\n\t\ttype: 'SET_EDITING_REUSABLE_BLOCK',\n\t\tclientId,\n\t\tisEditing,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/reusable-blocks/src/store/actions.js"],"names":["__experimentalConvertBlockToStatic","clientId","registry","oldBlock","select","blockEditorStore","getBlock","reusableBlock","getEditedEntityRecord","attributes","ref","newBlocks","content","dispatch","replaceBlocks","__experimentalConvertBlocksToReusable","clientIds","title","getBlocksByClientId","status","updatedRecord","saveEntityRecord","newBlock","id","__experimentalSetEditingReusableBlock","__experimentalDeleteReusableBlock","allBlocks","getBlocks","associatedBlocks","filter","block","associatedBlockClientIds","map","length","removeBlocks","deleteEntityRecord","isEditing","type"],"mappings":";;;;;;;;AAGA;;AAKA;;AACA;;AAMA;;AAfA;AACA;AACA;;AAGA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACO,MAAMA,kCAAkC,GAAKC,QAAF,IAAgB,QAE3D;AAAA,MAF6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GAAP;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport { isFunction } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tcreateBlock,\n\tisReusableBlock,\n\tparse,\n\tserialize,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Returns a generator converting a reusable block into a static block.\n *\n * @param {string} clientId The client ID of the block to attach.\n */\nexport const __experimentalConvertBlockToStatic = ( clientId ) => ( {\n\tregistry,\n} ) => {\n\tconst oldBlock = registry.select( blockEditorStore ).getBlock( clientId );\n\tconst reusableBlock = registry\n\t\t.select( 'core' )\n\t\t.getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_block',\n\t\t\toldBlock.attributes.ref\n\t\t);\n\n\tconst newBlocks = parse(\n\t\tisFunction( reusableBlock.content )\n\t\t\t? reusableBlock.content( reusableBlock )\n\t\t\t: reusableBlock.content\n\t);\n\tregistry\n\t\t.dispatch( blockEditorStore )\n\t\t.replaceBlocks( oldBlock.clientId, newBlocks );\n};\n\n/**\n * Returns a generator converting one or more static blocks into a reusable block.\n *\n * @param {string[]} clientIds The client IDs of the block to detach.\n * @param {string} title Reusable block title.\n */\nexport const __experimentalConvertBlocksToReusable = (\n\tclientIds,\n\ttitle\n) => async ( { registry, dispatch } ) => {\n\tconst reusableBlock = {\n\t\ttitle: title || __( 'Untitled Reusable block' ),\n\t\tcontent: serialize(\n\t\t\tregistry.select( blockEditorStore ).getBlocksByClientId( clientIds )\n\t\t),\n\t\tstatus: 'publish',\n\t};\n\n\tconst updatedRecord = await registry\n\t\t.dispatch( 'core' )\n\t\t.saveEntityRecord( 'postType', 'wp_block', reusableBlock );\n\n\tconst newBlock = createBlock( 'core/block', {\n\t\tref: updatedRecord.id,\n\t} );\n\tregistry.dispatch( blockEditorStore ).replaceBlocks( clientIds, newBlock );\n\tdispatch.__experimentalSetEditingReusableBlock( newBlock.clientId, true );\n};\n\n/**\n * Returns a generator deleting a reusable block.\n *\n * @param {string} id The ID of the reusable block to delete.\n */\nexport const __experimentalDeleteReusableBlock = ( id ) => async ( {\n\tregistry,\n} ) => {\n\tconst reusableBlock = registry\n\t\t.select( 'core' )\n\t\t.getEditedEntityRecord( 'postType', 'wp_block', id );\n\n\t// Don't allow a reusable block with a temporary ID to be deleted.\n\tif ( ! reusableBlock ) {\n\t\treturn;\n\t}\n\n\t// Remove any other blocks that reference this reusable block.\n\tconst allBlocks = registry.select( blockEditorStore ).getBlocks();\n\tconst associatedBlocks = allBlocks.filter(\n\t\t( block ) => isReusableBlock( block ) && block.attributes.ref === id\n\t);\n\tconst associatedBlockClientIds = associatedBlocks.map(\n\t\t( block ) => block.clientId\n\t);\n\n\t// Remove the parsed block.\n\tif ( associatedBlockClientIds.length ) {\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.removeBlocks( associatedBlockClientIds );\n\t}\n\n\tawait registry\n\t\t.dispatch( 'core' )\n\t\t.deleteEntityRecord( 'postType', 'wp_block', id );\n};\n\n/**\n * Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action.\n *\n * @param {string} clientId The clientID of the reusable block to target.\n * @param {boolean} isEditing Whether the block should be in editing state.\n * @return {Object} Action descriptor.\n */\nexport function __experimentalSetEditingReusableBlock( clientId, isEditing ) {\n\treturn {\n\t\ttype: 'SET_EDITING_REUSABLE_BLOCK',\n\t\tclientId,\n\t\tisEditing,\n\t};\n}\n"]}
@@ -38,8 +38,7 @@ const STORE_NAME = 'core/reusable-blocks';
38
38
  const store = (0, _data.createReduxStore)(STORE_NAME, {
39
39
  actions,
40
40
  reducer: _reducer.default,
41
- selectors,
42
- __experimentalUseThunks: true
41
+ selectors
43
42
  });
44
43
  exports.store = store;
45
44
  (0, _data.register)(store);
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/reusable-blocks/src/store/index.js"],"names":["STORE_NAME","store","actions","reducer","selectors","__experimentalUseThunks"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;;;;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKA,MAAMA,UAAU,GAAG,sBAAnB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,KAAK,GAAG,4BAAkBD,UAAlB,EAA8B;AAClDE,EAAAA,OADkD;AAElDC,EAAAA,OAAO,EAAPA,gBAFkD;AAGlDC,EAAAA,SAHkD;AAIlDC,EAAAA,uBAAuB,EAAE;AAJyB,CAA9B,CAAd;;AAOP,oBAAUJ,KAAV","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport * as actions from './actions';\nimport reducer from './reducer';\nimport * as selectors from './selectors';\n\nconst STORE_NAME = 'core/reusable-blocks';\n\n/**\n * Store definition for the reusable blocks namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\tactions,\n\treducer,\n\tselectors,\n\t__experimentalUseThunks: true,\n} );\n\nregister( store );\n"]}
1
+ {"version":3,"sources":["@wordpress/reusable-blocks/src/store/index.js"],"names":["STORE_NAME","store","actions","reducer","selectors"],"mappings":";;;;;;;;;AAGA;;AAKA;;AACA;;AACA;;;;;;AAVA;AACA;AACA;;AAGA;AACA;AACA;AAKA,MAAMA,UAAU,GAAG,sBAAnB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACO,MAAMC,KAAK,GAAG,4BAAkBD,UAAlB,EAA8B;AAClDE,EAAAA,OADkD;AAElDC,EAAAA,OAAO,EAAPA,gBAFkD;AAGlDC,EAAAA;AAHkD,CAA9B,CAAd;;AAMP,oBAAUH,KAAV","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport * as actions from './actions';\nimport reducer from './reducer';\nimport * as selectors from './selectors';\n\nconst STORE_NAME = 'core/reusable-blocks';\n\n/**\n * Store definition for the reusable blocks namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\tactions,\n\treducer,\n\tselectors,\n} );\n\nregister( store );\n"]}
@@ -59,11 +59,11 @@ export const __experimentalDeleteReusableBlock = id => async _ref3 => {
59
59
  let {
60
60
  registry
61
61
  } = _ref3;
62
- const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', id); // Don't allow a reusable block with a temporary ID to be deleted
62
+ const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', id); // Don't allow a reusable block with a temporary ID to be deleted.
63
63
 
64
64
  if (!reusableBlock) {
65
65
  return;
66
- } // Remove any other blocks that reference this reusable block
66
+ } // Remove any other blocks that reference this reusable block.
67
67
 
68
68
 
69
69
  const allBlocks = registry.select(blockEditorStore).getBlocks();
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/reusable-blocks/src/store/actions.js"],"names":["isFunction","store","blockEditorStore","createBlock","isReusableBlock","parse","serialize","__","__experimentalConvertBlockToStatic","clientId","registry","oldBlock","select","getBlock","reusableBlock","getEditedEntityRecord","attributes","ref","newBlocks","content","dispatch","replaceBlocks","__experimentalConvertBlocksToReusable","clientIds","title","getBlocksByClientId","status","updatedRecord","saveEntityRecord","newBlock","id","__experimentalSetEditingReusableBlock","__experimentalDeleteReusableBlock","allBlocks","getBlocks","associatedBlocks","filter","block","associatedBlockClientIds","map","length","removeBlocks","deleteEntityRecord","isEditing","type"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,QAA3B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SACCC,WADD,EAECC,eAFD,EAGCC,KAHD,EAICC,SAJD,QAKO,mBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;AACA;AACA;;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,qCAAT,CAAgDtB,QAAhD,EAA0DkC,SAA1D,EAAsE;AAC5E,SAAO;AACNC,IAAAA,IAAI,EAAE,4BADA;AAENnC,IAAAA,QAFM;AAGNkC,IAAAA;AAHM,GAAP;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport { isFunction } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tcreateBlock,\n\tisReusableBlock,\n\tparse,\n\tserialize,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Returns a generator converting a reusable block into a static block.\n *\n * @param {string} clientId The client ID of the block to attach.\n */\nexport const __experimentalConvertBlockToStatic = ( clientId ) => ( {\n\tregistry,\n} ) => {\n\tconst oldBlock = registry.select( blockEditorStore ).getBlock( clientId );\n\tconst reusableBlock = registry\n\t\t.select( 'core' )\n\t\t.getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_block',\n\t\t\toldBlock.attributes.ref\n\t\t);\n\n\tconst newBlocks = parse(\n\t\tisFunction( reusableBlock.content )\n\t\t\t? reusableBlock.content( reusableBlock )\n\t\t\t: reusableBlock.content\n\t);\n\tregistry\n\t\t.dispatch( blockEditorStore )\n\t\t.replaceBlocks( oldBlock.clientId, newBlocks );\n};\n\n/**\n * Returns a generator converting one or more static blocks into a reusable block.\n *\n * @param {string[]} clientIds The client IDs of the block to detach.\n * @param {string} title Reusable block title.\n */\nexport const __experimentalConvertBlocksToReusable = (\n\tclientIds,\n\ttitle\n) => async ( { registry, dispatch } ) => {\n\tconst reusableBlock = {\n\t\ttitle: title || __( 'Untitled Reusable block' ),\n\t\tcontent: serialize(\n\t\t\tregistry.select( blockEditorStore ).getBlocksByClientId( clientIds )\n\t\t),\n\t\tstatus: 'publish',\n\t};\n\n\tconst updatedRecord = await registry\n\t\t.dispatch( 'core' )\n\t\t.saveEntityRecord( 'postType', 'wp_block', reusableBlock );\n\n\tconst newBlock = createBlock( 'core/block', {\n\t\tref: updatedRecord.id,\n\t} );\n\tregistry.dispatch( blockEditorStore ).replaceBlocks( clientIds, newBlock );\n\tdispatch.__experimentalSetEditingReusableBlock( newBlock.clientId, true );\n};\n\n/**\n * Returns a generator deleting a reusable block.\n *\n * @param {string} id The ID of the reusable block to delete.\n */\nexport const __experimentalDeleteReusableBlock = ( id ) => async ( {\n\tregistry,\n} ) => {\n\tconst reusableBlock = registry\n\t\t.select( 'core' )\n\t\t.getEditedEntityRecord( 'postType', 'wp_block', id );\n\n\t// Don't allow a reusable block with a temporary ID to be deleted\n\tif ( ! reusableBlock ) {\n\t\treturn;\n\t}\n\n\t// Remove any other blocks that reference this reusable block\n\tconst allBlocks = registry.select( blockEditorStore ).getBlocks();\n\tconst associatedBlocks = allBlocks.filter(\n\t\t( block ) => isReusableBlock( block ) && block.attributes.ref === id\n\t);\n\tconst associatedBlockClientIds = associatedBlocks.map(\n\t\t( block ) => block.clientId\n\t);\n\n\t// Remove the parsed block.\n\tif ( associatedBlockClientIds.length ) {\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.removeBlocks( associatedBlockClientIds );\n\t}\n\n\tawait registry\n\t\t.dispatch( 'core' )\n\t\t.deleteEntityRecord( 'postType', 'wp_block', id );\n};\n\n/**\n * Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action.\n *\n * @param {string} clientId The clientID of the reusable block to target.\n * @param {boolean} isEditing Whether the block should be in editing state.\n * @return {Object} Action descriptor.\n */\nexport function __experimentalSetEditingReusableBlock( clientId, isEditing ) {\n\treturn {\n\t\ttype: 'SET_EDITING_REUSABLE_BLOCK',\n\t\tclientId,\n\t\tisEditing,\n\t};\n}\n"]}
1
+ {"version":3,"sources":["@wordpress/reusable-blocks/src/store/actions.js"],"names":["isFunction","store","blockEditorStore","createBlock","isReusableBlock","parse","serialize","__","__experimentalConvertBlockToStatic","clientId","registry","oldBlock","select","getBlock","reusableBlock","getEditedEntityRecord","attributes","ref","newBlocks","content","dispatch","replaceBlocks","__experimentalConvertBlocksToReusable","clientIds","title","getBlocksByClientId","status","updatedRecord","saveEntityRecord","newBlock","id","__experimentalSetEditingReusableBlock","__experimentalDeleteReusableBlock","allBlocks","getBlocks","associatedBlocks","filter","block","associatedBlockClientIds","map","length","removeBlocks","deleteEntityRecord","isEditing","type"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,UAAT,QAA2B,QAA3B;AAEA;AACA;AACA;;AACA,SAASC,KAAK,IAAIC,gBAAlB,QAA0C,yBAA1C;AACA,SACCC,WADD,EAECC,eAFD,EAGCC,KAHD,EAICC,SAJD,QAKO,mBALP;AAMA,SAASC,EAAT,QAAmB,iBAAnB;AAEA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,kCAAkC,GAAKC,QAAF,IAAgB,QAE3D;AAAA,MAF6D;AACnEC,IAAAA;AADmE,GAE7D;AACN,QAAMC,QAAQ,GAAGD,QAAQ,CAACE,MAAT,CAAiBV,gBAAjB,EAAoCW,QAApC,CAA8CJ,QAA9C,CAAjB;AACA,QAAMK,aAAa,GAAGJ,QAAQ,CAC5BE,MADoB,CACZ,MADY,EAEpBG,qBAFoB,CAGpB,UAHoB,EAIpB,UAJoB,EAKpBJ,QAAQ,CAACK,UAAT,CAAoBC,GALA,CAAtB;AAQA,QAAMC,SAAS,GAAGb,KAAK,CACtBL,UAAU,CAAEc,aAAa,CAACK,OAAhB,CAAV,GACGL,aAAa,CAACK,OAAd,CAAuBL,aAAvB,CADH,GAEGA,aAAa,CAACK,OAHK,CAAvB;AAKAT,EAAAA,QAAQ,CACNU,QADF,CACYlB,gBADZ,EAEEmB,aAFF,CAEiBV,QAAQ,CAACF,QAF1B,EAEoCS,SAFpC;AAGA,CApBM;AAsBP;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMI,qCAAqC,GAAG,CACpDC,SADoD,EAEpDC,KAFoD,KAGhD,eAAoC;AAAA,MAA5B;AAAEd,IAAAA,QAAF;AAAYU,IAAAA;AAAZ,GAA4B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AAyBa,EAD1C,CAAzB;AAGA,QAAMQ,wBAAwB,GAAGH,gBAAgB,CAACI,GAAjB,CAC9BF,KAAF,IAAaA,KAAK,CAAC5B,QADa,CAAjC,CAfM,CAmBN;;AACA,MAAK6B,wBAAwB,CAACE,MAA9B,EAAuC;AACtC9B,IAAAA,QAAQ,CACNU,QADF,CACYlB,gBADZ,EAEEuC,YAFF,CAEgBH,wBAFhB;AAGA;;AAED,QAAM5B,QAAQ,CACZU,QADI,CACM,MADN,EAEJsB,kBAFI,CAEgB,UAFhB,EAE4B,UAF5B,EAEwCZ,EAFxC,CAAN;AAGA,CA/BM;AAiCP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,SAASC,qCAAT,CAAgDtB,QAAhD,EAA0DkC,SAA1D,EAAsE;AAC5E,SAAO;AACNC,IAAAA,IAAI,EAAE,4BADA;AAENnC,IAAAA,QAFM;AAGNkC,IAAAA;AAHM,GAAP;AAKA","sourcesContent":["/**\n * External dependencies\n */\nimport { isFunction } from 'lodash';\n\n/**\n * WordPress dependencies\n */\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport {\n\tcreateBlock,\n\tisReusableBlock,\n\tparse,\n\tserialize,\n} from '@wordpress/blocks';\nimport { __ } from '@wordpress/i18n';\n\n/**\n * Returns a generator converting a reusable block into a static block.\n *\n * @param {string} clientId The client ID of the block to attach.\n */\nexport const __experimentalConvertBlockToStatic = ( clientId ) => ( {\n\tregistry,\n} ) => {\n\tconst oldBlock = registry.select( blockEditorStore ).getBlock( clientId );\n\tconst reusableBlock = registry\n\t\t.select( 'core' )\n\t\t.getEditedEntityRecord(\n\t\t\t'postType',\n\t\t\t'wp_block',\n\t\t\toldBlock.attributes.ref\n\t\t);\n\n\tconst newBlocks = parse(\n\t\tisFunction( reusableBlock.content )\n\t\t\t? reusableBlock.content( reusableBlock )\n\t\t\t: reusableBlock.content\n\t);\n\tregistry\n\t\t.dispatch( blockEditorStore )\n\t\t.replaceBlocks( oldBlock.clientId, newBlocks );\n};\n\n/**\n * Returns a generator converting one or more static blocks into a reusable block.\n *\n * @param {string[]} clientIds The client IDs of the block to detach.\n * @param {string} title Reusable block title.\n */\nexport const __experimentalConvertBlocksToReusable = (\n\tclientIds,\n\ttitle\n) => async ( { registry, dispatch } ) => {\n\tconst reusableBlock = {\n\t\ttitle: title || __( 'Untitled Reusable block' ),\n\t\tcontent: serialize(\n\t\t\tregistry.select( blockEditorStore ).getBlocksByClientId( clientIds )\n\t\t),\n\t\tstatus: 'publish',\n\t};\n\n\tconst updatedRecord = await registry\n\t\t.dispatch( 'core' )\n\t\t.saveEntityRecord( 'postType', 'wp_block', reusableBlock );\n\n\tconst newBlock = createBlock( 'core/block', {\n\t\tref: updatedRecord.id,\n\t} );\n\tregistry.dispatch( blockEditorStore ).replaceBlocks( clientIds, newBlock );\n\tdispatch.__experimentalSetEditingReusableBlock( newBlock.clientId, true );\n};\n\n/**\n * Returns a generator deleting a reusable block.\n *\n * @param {string} id The ID of the reusable block to delete.\n */\nexport const __experimentalDeleteReusableBlock = ( id ) => async ( {\n\tregistry,\n} ) => {\n\tconst reusableBlock = registry\n\t\t.select( 'core' )\n\t\t.getEditedEntityRecord( 'postType', 'wp_block', id );\n\n\t// Don't allow a reusable block with a temporary ID to be deleted.\n\tif ( ! reusableBlock ) {\n\t\treturn;\n\t}\n\n\t// Remove any other blocks that reference this reusable block.\n\tconst allBlocks = registry.select( blockEditorStore ).getBlocks();\n\tconst associatedBlocks = allBlocks.filter(\n\t\t( block ) => isReusableBlock( block ) && block.attributes.ref === id\n\t);\n\tconst associatedBlockClientIds = associatedBlocks.map(\n\t\t( block ) => block.clientId\n\t);\n\n\t// Remove the parsed block.\n\tif ( associatedBlockClientIds.length ) {\n\t\tregistry\n\t\t\t.dispatch( blockEditorStore )\n\t\t\t.removeBlocks( associatedBlockClientIds );\n\t}\n\n\tawait registry\n\t\t.dispatch( 'core' )\n\t\t.deleteEntityRecord( 'postType', 'wp_block', id );\n};\n\n/**\n * Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action.\n *\n * @param {string} clientId The clientID of the reusable block to target.\n * @param {boolean} isEditing Whether the block should be in editing state.\n * @return {Object} Action descriptor.\n */\nexport function __experimentalSetEditingReusableBlock( clientId, isEditing ) {\n\treturn {\n\t\ttype: 'SET_EDITING_REUSABLE_BLOCK',\n\t\tclientId,\n\t\tisEditing,\n\t};\n}\n"]}
@@ -21,8 +21,7 @@ const STORE_NAME = 'core/reusable-blocks';
21
21
  export const store = createReduxStore(STORE_NAME, {
22
22
  actions,
23
23
  reducer,
24
- selectors,
25
- __experimentalUseThunks: true
24
+ selectors
26
25
  });
27
26
  register(store);
28
27
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/reusable-blocks/src/store/index.js"],"names":["createReduxStore","register","actions","reducer","selectors","STORE_NAME","store","__experimentalUseThunks"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,QAA3B,QAA2C,iBAA3C;AAEA;AACA;AACA;;AACA,OAAO,KAAKC,OAAZ,MAAyB,WAAzB;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAO,KAAKC,SAAZ,MAA2B,aAA3B;AAEA,MAAMC,UAAU,GAAG,sBAAnB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,KAAK,GAAGN,gBAAgB,CAAEK,UAAF,EAAc;AAClDH,EAAAA,OADkD;AAElDC,EAAAA,OAFkD;AAGlDC,EAAAA,SAHkD;AAIlDG,EAAAA,uBAAuB,EAAE;AAJyB,CAAd,CAA9B;AAOPN,QAAQ,CAAEK,KAAF,CAAR","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport * as actions from './actions';\nimport reducer from './reducer';\nimport * as selectors from './selectors';\n\nconst STORE_NAME = 'core/reusable-blocks';\n\n/**\n * Store definition for the reusable blocks namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\tactions,\n\treducer,\n\tselectors,\n\t__experimentalUseThunks: true,\n} );\n\nregister( store );\n"]}
1
+ {"version":3,"sources":["@wordpress/reusable-blocks/src/store/index.js"],"names":["createReduxStore","register","actions","reducer","selectors","STORE_NAME","store"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,gBAAT,EAA2BC,QAA3B,QAA2C,iBAA3C;AAEA;AACA;AACA;;AACA,OAAO,KAAKC,OAAZ,MAAyB,WAAzB;AACA,OAAOC,OAAP,MAAoB,WAApB;AACA,OAAO,KAAKC,SAAZ,MAA2B,aAA3B;AAEA,MAAMC,UAAU,GAAG,sBAAnB;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,KAAK,GAAGN,gBAAgB,CAAEK,UAAF,EAAc;AAClDH,EAAAA,OADkD;AAElDC,EAAAA,OAFkD;AAGlDC,EAAAA;AAHkD,CAAd,CAA9B;AAMPH,QAAQ,CAAEK,KAAF,CAAR","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createReduxStore, register } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport * as actions from './actions';\nimport reducer from './reducer';\nimport * as selectors from './selectors';\n\nconst STORE_NAME = 'core/reusable-blocks';\n\n/**\n * Store definition for the reusable blocks namespace.\n *\n * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore\n *\n * @type {Object}\n */\nexport const store = createReduxStore( STORE_NAME, {\n\tactions,\n\treducer,\n\tselectors,\n} );\n\nregister( store );\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/reusable-blocks",
3
- "version": "3.1.2",
3
+ "version": "3.2.0-next.e230fbab09.0",
4
4
  "description": "Reusable blocks utilities.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -28,20 +28,24 @@
28
28
  "{src,build,build-module}/{index.js,store/index.js}"
29
29
  ],
30
30
  "dependencies": {
31
- "@wordpress/block-editor": "^8.1.2",
32
- "@wordpress/blocks": "^11.2.1",
33
- "@wordpress/components": "^19.4.1",
34
- "@wordpress/core-data": "^4.1.1",
35
- "@wordpress/data": "^6.2.1",
36
- "@wordpress/element": "^4.1.1",
37
- "@wordpress/i18n": "^4.3.1",
38
- "@wordpress/icons": "^7.0.0",
39
- "@wordpress/notices": "^3.3.1",
40
- "@wordpress/url": "^3.4.1",
31
+ "@wordpress/block-editor": "^8.3.0-next.e230fbab09.0",
32
+ "@wordpress/blocks": "^11.3.0-next.e230fbab09.0",
33
+ "@wordpress/components": "^19.7.0-next.e230fbab09.0",
34
+ "@wordpress/core-data": "^4.2.0-next.e230fbab09.0",
35
+ "@wordpress/data": "^6.4.0-next.e230fbab09.0",
36
+ "@wordpress/element": "^4.3.0-next.e230fbab09.0",
37
+ "@wordpress/i18n": "^4.4.0-next.e230fbab09.0",
38
+ "@wordpress/icons": "^7.1.0-next.e230fbab09.0",
39
+ "@wordpress/notices": "^3.4.0-next.e230fbab09.0",
40
+ "@wordpress/url": "^3.5.0-next.e230fbab09.0",
41
41
  "lodash": "^4.17.21"
42
42
  },
43
+ "peerDependencies": {
44
+ "react": "^17.0.0",
45
+ "react-dom": "^17.0.0"
46
+ },
43
47
  "publishConfig": {
44
48
  "access": "public"
45
49
  },
46
- "gitHead": "0f838547f37472e46e6d5a9d2e84b6c61f4bd3f0"
50
+ "gitHead": "308df03e6a96ded732f9c4e32471b1b4f8dea54a"
47
51
  }
@@ -83,12 +83,12 @@ export const __experimentalDeleteReusableBlock = ( id ) => async ( {
83
83
  .select( 'core' )
84
84
  .getEditedEntityRecord( 'postType', 'wp_block', id );
85
85
 
86
- // Don't allow a reusable block with a temporary ID to be deleted
86
+ // Don't allow a reusable block with a temporary ID to be deleted.
87
87
  if ( ! reusableBlock ) {
88
88
  return;
89
89
  }
90
90
 
91
- // Remove any other blocks that reference this reusable block
91
+ // Remove any other blocks that reference this reusable block.
92
92
  const allBlocks = registry.select( blockEditorStore ).getBlocks();
93
93
  const associatedBlocks = allBlocks.filter(
94
94
  ( block ) => isReusableBlock( block ) && block.attributes.ref === id
@@ -23,7 +23,6 @@ export const store = createReduxStore( STORE_NAME, {
23
23
  actions,
24
24
  reducer,
25
25
  selectors,
26
- __experimentalUseThunks: true,
27
26
  } );
28
27
 
29
28
  register( store );
@@ -24,7 +24,7 @@ jest.mock( '@wordpress/api-fetch', () => ( {
24
24
  } ) );
25
25
 
26
26
  function createRegistryWithStores() {
27
- // create a registry and register stores
27
+ // Create a registry and register stores.
28
28
  const registry = createRegistry();
29
29
 
30
30
  registry.register( coreStore );
@@ -102,7 +102,7 @@ describe( 'Actions', () => {
102
102
  } );
103
103
 
104
104
  const registry = createRegistryWithStores();
105
- // mock the api-fetch
105
+ // Mock the api-fetch.
106
106
  apiFetch.mockImplementation( async ( args ) => {
107
107
  const { path, data } = args;
108
108
  switch ( path ) {
@@ -124,7 +124,7 @@ describe( 'Actions', () => {
124
124
  staticBlock.clientId,
125
125
  ] );
126
126
 
127
- // check that blocks were converted to reusable
127
+ // Check that blocks were converted to reusable.
128
128
  const updatedBlocks = registry
129
129
  .select( blockEditorStore )
130
130
  .getBlocks();
@@ -133,7 +133,7 @@ describe( 'Actions', () => {
133
133
 
134
134
  expect( updatedBlocks ).toHaveLength( 1 );
135
135
 
136
- // Delete random clientId before matching with snapshot
136
+ // Delete random clientId before matching with snapshot.
137
137
  delete updatedBlocks[ 0 ].clientId;
138
138
  expect( updatedBlocks ).toMatchSnapshot();
139
139
 
@@ -158,7 +158,7 @@ describe( 'Actions', () => {
158
158
  };
159
159
 
160
160
  const registry = createRegistryWithStores();
161
- // mock the api-fetch
161
+ // Mock the api-fetch.
162
162
  apiFetch.mockImplementation( async ( args ) => {
163
163
  const { path, data } = args;
164
164
  switch ( path ) {
@@ -182,14 +182,14 @@ describe( 'Actions', () => {
182
182
  associatedBlock.clientId,
183
183
  ] );
184
184
 
185
- // check that blocks were converted to reusable
185
+ // Check that blocks were converted to reusable.
186
186
  const updatedBlocks = registry
187
187
  .select( blockEditorStore )
188
188
  .getBlocks();
189
189
 
190
190
  expect( updatedBlocks ).toHaveLength( 1 );
191
191
 
192
- // Delete random clientIds before matching with snapshot
192
+ // Delete random clientIds before matching with snapshot.
193
193
  delete updatedBlocks[ 0 ].clientId;
194
194
  delete updatedBlocks[ 0 ].innerBlocks[ 0 ].clientId;
195
195
  delete updatedBlocks[ 0 ].innerBlocks[ 1 ].clientId;
@@ -219,7 +219,7 @@ describe( 'Actions', () => {
219
219
  ];
220
220
 
221
221
  const registry = createRegistryWithStores();
222
- // mock the api-fetch
222
+ // Mock the api-fetch.
223
223
  apiFetch.mockImplementation( async ( args ) => {
224
224
  const { path, data, method } = args;
225
225
  if (
@@ -246,7 +246,7 @@ describe( 'Actions', () => {
246
246
  .dispatch( blockEditorStore )
247
247
  .insertBlocks( availableBlocks );
248
248
 
249
- // confirm that reusable block is stored
249
+ // Confirm that reusable block is stored.
250
250
  const reusableBlockBefore = registry
251
251
  .select( coreStore )
252
252
  .getEntityRecord( 'postType', 'wp_block', reusableBlock.id );
@@ -257,13 +257,13 @@ describe( 'Actions', () => {
257
257
  .dispatch( reusableBlocksStore )
258
258
  .__experimentalDeleteReusableBlock( reusableBlock.id );
259
259
 
260
- // check if reusable block was deleted
260
+ // Check if reusable block was deleted.
261
261
  const reusableBlockAfter = registry
262
262
  .select( coreStore )
263
263
  .getEntityRecord( 'postType', 'wp_block', reusableBlock.id );
264
264
  expect( reusableBlockAfter ).toBeFalsy();
265
265
 
266
- // check if block instances were removed from the editor
266
+ // Check if block instances were removed from the editor.
267
267
  const blocksAfter = registry.select( blockEditorStore ).getBlocks();
268
268
  expect( blocksAfter ).toHaveLength( 3 );
269
269
  } );