@wordpress/reusable-blocks 5.24.0 → 5.26.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.
- package/CHANGELOG.md +4 -0
- package/build/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js +1 -3
- package/build/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js.map +1 -1
- package/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js +1 -3
- package/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js.map +1 -1
- package/package.json +13 -13
- package/src/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js +1 -3
package/CHANGELOG.md
CHANGED
|
@@ -31,8 +31,7 @@ function ReusableBlocksManageButton({
|
|
|
31
31
|
} = (0, _data.useSelect)(select => {
|
|
32
32
|
const {
|
|
33
33
|
getBlock,
|
|
34
|
-
canRemoveBlock
|
|
35
|
-
getBlockCount
|
|
34
|
+
canRemoveBlock
|
|
36
35
|
} = select(_blockEditor.store);
|
|
37
36
|
const {
|
|
38
37
|
canUser
|
|
@@ -45,7 +44,6 @@ function ReusableBlocksManageButton({
|
|
|
45
44
|
name: 'wp_block',
|
|
46
45
|
id: reusableBlock.attributes.ref
|
|
47
46
|
}),
|
|
48
|
-
innerBlockCount: getBlockCount(clientId),
|
|
49
47
|
// The site editor and templates both check whether the user
|
|
50
48
|
// has edit_theme_options capabilities. We can leverage that here
|
|
51
49
|
// and omit the manage patterns link if the user can't access it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_components","require","_i18n","_blocks","_data","_blockEditor","_url","_coreData","_store","_jsxRuntime","ReusableBlocksManageButton","clientId","canRemove","isVisible","managePatternsUrl","useSelect","select","getBlock","canRemoveBlock","
|
|
1
|
+
{"version":3,"names":["_components","require","_i18n","_blocks","_data","_blockEditor","_url","_coreData","_store","_jsxRuntime","ReusableBlocksManageButton","clientId","canRemove","isVisible","managePatternsUrl","useSelect","select","getBlock","canRemoveBlock","blockEditorStore","canUser","coreStore","reusableBlock","isReusableBlock","kind","name","id","attributes","ref","addQueryArgs","p","post_type","__experimentalConvertBlockToStatic","convertBlockToStatic","useDispatch","reusableBlocksStore","jsxs","Fragment","children","jsx","MenuItem","href","__","onClick","_default","exports","default"],"sources":["@wordpress/reusable-blocks/src/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { isReusableBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as reusableBlocksStore } from '../../store';\n\nfunction ReusableBlocksManageButton( { clientId } ) {\n\tconst { canRemove, isVisible, managePatternsUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, canRemoveBlock } = select( blockEditorStore );\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst reusableBlock = getBlock( clientId );\n\n\t\t\treturn {\n\t\t\t\tcanRemove: canRemoveBlock( clientId ),\n\t\t\t\tisVisible:\n\t\t\t\t\t!! reusableBlock &&\n\t\t\t\t\tisReusableBlock( reusableBlock ) &&\n\t\t\t\t\t!! canUser( 'update', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\t\tid: reusableBlock.attributes.ref,\n\t\t\t\t\t} ),\n\t\t\t\t// The site editor and templates both check whether the user\n\t\t\t\t// has edit_theme_options capabilities. We can leverage that here\n\t\t\t\t// and omit the manage patterns link if the user can't access it.\n\t\t\t\tmanagePatternsUrl: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t\t} )\n\t\t\t\t\t? addQueryArgs( 'site-editor.php', {\n\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t } )\n\t\t\t\t\t: addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t } ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { __experimentalConvertBlockToStatic: convertBlockToStatic } =\n\t\tuseDispatch( reusableBlocksStore );\n\n\tif ( ! isVisible ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem href={ managePatternsUrl }>\n\t\t\t\t{ __( 'Manage patterns' ) }\n\t\t\t</MenuItem>\n\t\t\t{ canRemove && (\n\t\t\t\t<MenuItem onClick={ () => convertBlockToStatic( clientId ) }>\n\t\t\t\t\t{ __( 'Detach' ) }\n\t\t\t\t</MenuItem>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default ReusableBlocksManageButton;\n"],"mappings":";;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AACA,IAAAM,SAAA,GAAAN,OAAA;AAKA,IAAAO,MAAA,GAAAP,OAAA;AAA2D,IAAAQ,WAAA,GAAAR,OAAA;AAd3D;AACA;AACA;;AASA;AACA;AACA;;AAGA,SAASS,0BAA0BA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACnD,MAAM;IAAEC,SAAS;IAAEC,SAAS;IAAEC;EAAkB,CAAC,GAAG,IAAAC,eAAS,EAC1DC,MAAM,IAAM;IACb,MAAM;MAAEC,QAAQ;MAAEC;IAAe,CAAC,GAAGF,MAAM,CAAEG,kBAAiB,CAAC;IAC/D,MAAM;MAAEC;IAAQ,CAAC,GAAGJ,MAAM,CAAEK,eAAU,CAAC;IACvC,MAAMC,aAAa,GAAGL,QAAQ,CAAEN,QAAS,CAAC;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AAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcpC,0BAA0B","ignoreList":[]}
|
|
@@ -24,8 +24,7 @@ function ReusableBlocksManageButton({
|
|
|
24
24
|
} = useSelect(select => {
|
|
25
25
|
const {
|
|
26
26
|
getBlock,
|
|
27
|
-
canRemoveBlock
|
|
28
|
-
getBlockCount
|
|
27
|
+
canRemoveBlock
|
|
29
28
|
} = select(blockEditorStore);
|
|
30
29
|
const {
|
|
31
30
|
canUser
|
|
@@ -38,7 +37,6 @@ function ReusableBlocksManageButton({
|
|
|
38
37
|
name: 'wp_block',
|
|
39
38
|
id: reusableBlock.attributes.ref
|
|
40
39
|
}),
|
|
41
|
-
innerBlockCount: getBlockCount(clientId),
|
|
42
40
|
// The site editor and templates both check whether the user
|
|
43
41
|
// has edit_theme_options capabilities. We can leverage that here
|
|
44
42
|
// and omit the manage patterns link if the user can't access it.
|
package/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["MenuItem","__","isReusableBlock","useSelect","useDispatch","store","blockEditorStore","addQueryArgs","coreStore","reusableBlocksStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ReusableBlocksManageButton","clientId","canRemove","isVisible","managePatternsUrl","select","getBlock","canRemoveBlock","
|
|
1
|
+
{"version":3,"names":["MenuItem","__","isReusableBlock","useSelect","useDispatch","store","blockEditorStore","addQueryArgs","coreStore","reusableBlocksStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","ReusableBlocksManageButton","clientId","canRemove","isVisible","managePatternsUrl","select","getBlock","canRemoveBlock","canUser","reusableBlock","kind","name","id","attributes","ref","p","post_type","__experimentalConvertBlockToStatic","convertBlockToStatic","children","href","onClick"],"sources":["@wordpress/reusable-blocks/src/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { MenuItem } from '@wordpress/components';\nimport { __ } from '@wordpress/i18n';\nimport { isReusableBlock } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\nimport { addQueryArgs } from '@wordpress/url';\nimport { store as coreStore } from '@wordpress/core-data';\n\n/**\n * Internal dependencies\n */\nimport { store as reusableBlocksStore } from '../../store';\n\nfunction ReusableBlocksManageButton( { clientId } ) {\n\tconst { canRemove, isVisible, managePatternsUrl } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getBlock, canRemoveBlock } = select( blockEditorStore );\n\t\t\tconst { canUser } = select( coreStore );\n\t\t\tconst reusableBlock = getBlock( clientId );\n\n\t\t\treturn {\n\t\t\t\tcanRemove: canRemoveBlock( clientId ),\n\t\t\t\tisVisible:\n\t\t\t\t\t!! reusableBlock &&\n\t\t\t\t\tisReusableBlock( reusableBlock ) &&\n\t\t\t\t\t!! canUser( 'update', {\n\t\t\t\t\t\tkind: 'postType',\n\t\t\t\t\t\tname: 'wp_block',\n\t\t\t\t\t\tid: reusableBlock.attributes.ref,\n\t\t\t\t\t} ),\n\t\t\t\t// The site editor and templates both check whether the user\n\t\t\t\t// has edit_theme_options capabilities. We can leverage that here\n\t\t\t\t// and omit the manage patterns link if the user can't access it.\n\t\t\t\tmanagePatternsUrl: canUser( 'create', {\n\t\t\t\t\tkind: 'postType',\n\t\t\t\t\tname: 'wp_template',\n\t\t\t\t} )\n\t\t\t\t\t? addQueryArgs( 'site-editor.php', {\n\t\t\t\t\t\t\tp: '/pattern',\n\t\t\t\t\t } )\n\t\t\t\t\t: addQueryArgs( 'edit.php', {\n\t\t\t\t\t\t\tpost_type: 'wp_block',\n\t\t\t\t\t } ),\n\t\t\t};\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tconst { __experimentalConvertBlockToStatic: convertBlockToStatic } =\n\t\tuseDispatch( reusableBlocksStore );\n\n\tif ( ! isVisible ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<>\n\t\t\t<MenuItem href={ managePatternsUrl }>\n\t\t\t\t{ __( 'Manage patterns' ) }\n\t\t\t</MenuItem>\n\t\t\t{ canRemove && (\n\t\t\t\t<MenuItem onClick={ () => convertBlockToStatic( clientId ) }>\n\t\t\t\t\t{ __( 'Detach' ) }\n\t\t\t\t</MenuItem>\n\t\t\t) }\n\t\t</>\n\t);\n}\n\nexport default ReusableBlocksManageButton;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,QAAQ,QAAQ,uBAAuB;AAChD,SAASC,EAAE,QAAQ,iBAAiB;AACpC,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;AACnE,SAASC,YAAY,QAAQ,gBAAgB;AAC7C,SAASF,KAAK,IAAIG,SAAS,QAAQ,sBAAsB;;AAEzD;AACA;AACA;AACA,SAASH,KAAK,IAAII,mBAAmB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAE3D,SAASC,0BAA0BA,CAAE;EAAEC;AAAS,CAAC,EAAG;EACnD,MAAM;IAAEC,SAAS;IAAEC,SAAS;IAAEC;EAAkB,CAAC,GAAGjB,SAAS,CAC1DkB,MAAM,IAAM;IACb,MAAM;MAAEC,QAAQ;MAAEC;IAAe,CAAC,GAAGF,MAAM,CAAEf,gBAAiB,CAAC;IAC/D,MAAM;MAAEkB;IAAQ,CAAC,GAAGH,MAAM,CAAEb,SAAU,CAAC;IACvC,MAAMiB,aAAa,GAAGH,QAAQ,CAAEL,QAAS,CAAC;IAE1C,OAAO;MACNC,SAAS,EAAEK,cAAc,CAAEN,QAAS,CAAC;MACrCE,SAAS,EACR,CAAC,CAAEM,aAAa,IAChBvB,eAAe,CAAEuB,aAAc,CAAC,IAChC,CAAC,CAAED,OAAO,CAAE,QAAQ,EAAE;QACrBE,IAAI,EAAE,UAAU;QAChBC,IAAI,EAAE,UAAU;QAChBC,EAAE,EAAEH,aAAa,CAACI,UAAU,CAACC;MAC9B,CAAE,CAAC;MACJ;MACA;MACA;MACAV,iBAAiB,EAAEI,OAAO,CAAE,QAAQ,EAAE;QACrCE,IAAI,EAAE,UAAU;QAChBC,IAAI,EAAE;MACP,CAAE,CAAC,GACApB,YAAY,CAAE,iBAAiB,EAAE;QACjCwB,CAAC,EAAE;MACH,CAAE,CAAC,GACHxB,YAAY,CAAE,UAAU,EAAE;QAC1ByB,SAAS,EAAE;MACX,CAAE;IACN,CAAC;EACF,CAAC,EACD,CAAEf,QAAQ,CACX,CAAC;EAED,MAAM;IAAEgB,kCAAkC,EAAEC;EAAqB,CAAC,GACjE9B,WAAW,CAAEK,mBAAoB,CAAC;EAEnC,IAAK,CAAEU,SAAS,EAAG;IAClB,OAAO,IAAI;EACZ;EAEA,oBACCJ,KAAA,CAAAF,SAAA;IAAAsB,QAAA,gBACCxB,IAAA,CAACX,QAAQ;MAACoC,IAAI,EAAGhB,iBAAmB;MAAAe,QAAA,EACjClC,EAAE,CAAE,iBAAkB;IAAC,CAChB,CAAC,EACTiB,SAAS,iBACVP,IAAA,CAACX,QAAQ;MAACqC,OAAO,EAAGA,CAAA,KAAMH,oBAAoB,CAAEjB,QAAS,CAAG;MAAAkB,QAAA,EACzDlC,EAAE,CAAE,QAAS;IAAC,CACP,CACV;EAAA,CACA,CAAC;AAEL;AAEA,eAAee,0BAA0B","ignoreList":[]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/reusable-blocks",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.26.0",
|
|
4
4
|
"description": "Reusable blocks utilities.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@babel/runtime": "7.25.7",
|
|
34
|
-
"@wordpress/block-editor": "^14.
|
|
35
|
-
"@wordpress/blocks": "^14.
|
|
36
|
-
"@wordpress/components": "^29.
|
|
37
|
-
"@wordpress/core-data": "^7.
|
|
38
|
-
"@wordpress/data": "^10.
|
|
39
|
-
"@wordpress/element": "^6.
|
|
40
|
-
"@wordpress/i18n": "^5.
|
|
41
|
-
"@wordpress/icons": "^10.
|
|
42
|
-
"@wordpress/notices": "^5.
|
|
43
|
-
"@wordpress/private-apis": "^1.
|
|
44
|
-
"@wordpress/url": "^4.
|
|
34
|
+
"@wordpress/block-editor": "^14.21.0",
|
|
35
|
+
"@wordpress/blocks": "^14.15.0",
|
|
36
|
+
"@wordpress/components": "^29.12.0",
|
|
37
|
+
"@wordpress/core-data": "^7.26.0",
|
|
38
|
+
"@wordpress/data": "^10.26.0",
|
|
39
|
+
"@wordpress/element": "^6.26.0",
|
|
40
|
+
"@wordpress/i18n": "^5.26.0",
|
|
41
|
+
"@wordpress/icons": "^10.26.0",
|
|
42
|
+
"@wordpress/notices": "^5.26.0",
|
|
43
|
+
"@wordpress/private-apis": "^1.26.0",
|
|
44
|
+
"@wordpress/url": "^4.26.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": "^18.0.0",
|
|
@@ -50,5 +50,5 @@
|
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "35e26942820d8237771af0c58e45b4303f0497f1"
|
|
54
54
|
}
|
|
@@ -17,8 +17,7 @@ import { store as reusableBlocksStore } from '../../store';
|
|
|
17
17
|
function ReusableBlocksManageButton( { clientId } ) {
|
|
18
18
|
const { canRemove, isVisible, managePatternsUrl } = useSelect(
|
|
19
19
|
( select ) => {
|
|
20
|
-
const { getBlock, canRemoveBlock
|
|
21
|
-
select( blockEditorStore );
|
|
20
|
+
const { getBlock, canRemoveBlock } = select( blockEditorStore );
|
|
22
21
|
const { canUser } = select( coreStore );
|
|
23
22
|
const reusableBlock = getBlock( clientId );
|
|
24
23
|
|
|
@@ -32,7 +31,6 @@ function ReusableBlocksManageButton( { clientId } ) {
|
|
|
32
31
|
name: 'wp_block',
|
|
33
32
|
id: reusableBlock.attributes.ref,
|
|
34
33
|
} ),
|
|
35
|
-
innerBlockCount: getBlockCount( clientId ),
|
|
36
34
|
// The site editor and templates both check whether the user
|
|
37
35
|
// has edit_theme_options capabilities. We can leverage that here
|
|
38
36
|
// and omit the manage patterns link if the user can't access it.
|