@wordpress/block-directory 5.2.0 → 5.4.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/downloadable-block-list-item/index.js +1 -1
- package/build/components/downloadable-block-list-item/index.js.map +1 -1
- package/build/plugins/get-install-missing/install-button.js +1 -1
- package/build/plugins/get-install-missing/install-button.js.map +1 -1
- package/build/plugins/installed-blocks-pre-publish-panel/index.js +4 -7
- package/build/plugins/installed-blocks-pre-publish-panel/index.js.map +1 -1
- package/build/store/selectors.js +4 -4
- package/build/store/selectors.js.map +1 -1
- package/build-module/components/downloadable-block-list-item/index.js +1 -1
- package/build-module/components/downloadable-block-list-item/index.js.map +1 -1
- package/build-module/plugins/get-install-missing/install-button.js +1 -1
- package/build-module/plugins/get-install-missing/install-button.js.map +1 -1
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.js +1 -7
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.js.map +1 -1
- package/build-module/store/selectors.js +5 -5
- package/build-module/store/selectors.js.map +1 -1
- package/build-style/style-rtl.css +1 -0
- package/build-style/style.css +1 -0
- package/package.json +20 -21
- package/src/components/downloadable-block-list-item/index.js +1 -1
- package/src/components/downloadable-block-list-item/style.scss +6 -0
- package/src/plugins/get-install-missing/install-button.js +1 -1
- package/src/plugins/installed-blocks-pre-publish-panel/index.js +1 -4
- package/src/store/selectors.js +29 -17
package/CHANGELOG.md
CHANGED
|
@@ -100,7 +100,7 @@ function DownloadableBlockListItem({
|
|
|
100
100
|
}
|
|
101
101
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(CompositeItem, {
|
|
102
102
|
render: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
103
|
-
|
|
103
|
+
accessibleWhenDisabled: true,
|
|
104
104
|
type: "button",
|
|
105
105
|
role: "option",
|
|
106
106
|
className: "block-directory-downloadable-block-list-item",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_element","_htmlEntities","_blocks","_data","_blockRatings","_interopRequireDefault","_downloadableBlockIcon","_downloadableBlockNotice","_store","_lockUnlock","_jsxRuntime","CompositeItemV2","CompositeItem","unlock","componentsPrivateApis","getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","sprintf","decodeEntities","_n","DownloadableBlockListItem","composite","item","onClick","author","description","icon","getBlockType","name","isInstallable","useSelect","select","getErrorNoticeForBlock","isBlockInstalling","blockDirectoryStore","notice","id","hasFatal","isFatal","statusText","__","jsxs","render","jsx","Button","__experimentalIsFocusable","type","role","className","isBusy","event","preventDefault","label","showTooltip","tooltipPosition","store","disabled","children","default","Spinner","createInterpolateElement","span","block","Fragment","VisuallyHidden","_default","exports"],"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tSpinner,\n\tVisuallyHidden,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockRatings from '../block-ratings';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\nimport DownloadableBlockNotice from '../downloadable-block-notice';\nimport { store as blockDirectoryStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { CompositeItemV2: CompositeItem } = unlock( componentsPrivateApis );\n\n// Return the appropriate block item label, given the block data and status.\nfunction getDownloadableBlockLabel(\n\t{ title, rating, ratingCount },\n\t{ hasNotice, isInstalled, isInstalling }\n) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tif ( ! isInstalled && hasNotice ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Retry installing %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalled ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Add %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalling ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Installing %s.', decodeEntities( title ) );\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Install %s.', decodeEntities( title ) );\n\t}\n\n\treturn sprintf(\n\t\t/* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */\n\t\t_n(\n\t\t\t'Install %1$s. %2$s stars with %3$s review.',\n\t\t\t'Install %1$s. %2$s stars with %3$s reviews.',\n\t\t\tratingCount\n\t\t),\n\t\tdecodeEntities( title ),\n\t\tstars,\n\t\tratingCount\n\t);\n}\n\nfunction DownloadableBlockListItem( { composite, item, onClick } ) {\n\tconst { author, description, icon, rating, title } = item;\n\t// getBlockType returns a block object if this block exists, or null if not.\n\tconst isInstalled = !! getBlockType( item.name );\n\n\tconst { hasNotice, isInstalling, isInstallable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getErrorNoticeForBlock, isInstalling: isBlockInstalling } =\n\t\t\t\tselect( blockDirectoryStore );\n\t\t\tconst notice = getErrorNoticeForBlock( item.id );\n\t\t\tconst hasFatal = notice && notice.isFatal;\n\t\t\treturn {\n\t\t\t\thasNotice: !! notice,\n\t\t\t\tisInstalling: isBlockInstalling( item.id ),\n\t\t\t\tisInstallable: ! hasFatal,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\n\tlet statusText = '';\n\tif ( isInstalled ) {\n\t\tstatusText = __( 'Installed!' );\n\t} else if ( isInstalling ) {\n\t\tstatusText = __( 'Installing…' );\n\t}\n\n\treturn (\n\t\t<CompositeItem\n\t\t\trender={\n\t\t\t\t<Button\n\t\t\t\t\t__experimentalIsFocusable\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\tclassName=\"block-directory-downloadable-block-list-item\"\n\t\t\t\t\tisBusy={ isInstalling }\n\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tonClick();\n\t\t\t\t\t} }\n\t\t\t\t\tlabel={ getDownloadableBlockLabel( item, {\n\t\t\t\t\t\thasNotice,\n\t\t\t\t\t\tisInstalled,\n\t\t\t\t\t\tisInstalling,\n\t\t\t\t\t} ) }\n\t\t\t\t\tshowTooltip\n\t\t\t\t\ttooltipPosition=\"top center\"\n\t\t\t\t/>\n\t\t\t}\n\t\t\tstore={ composite }\n\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t>\n\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</span>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %1$s: block title, %2$s: author name. */\n\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__author\" />\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</CompositeItem>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,aAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,sBAAA,GAAAD,sBAAA,CAAAP,OAAA;AACA,IAAAS,wBAAA,GAAAF,sBAAA,CAAAP,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,WAAA,GAAAX,OAAA;AAA2C,IAAAY,WAAA,GAAAZ,OAAA;AAtB3C;AACA;AACA;;AAaA;AACA;AACA;;AAOA,MAAM;EAAEa,eAAe,EAAEC;AAAc,CAAC,GAAG,IAAAC,kBAAM,EAAEC,uBAAsB,CAAC;;AAE1E;AACA,SAASC,yBAAyBA,CACjC;EAAEC,KAAK;EAAEC,MAAM;EAAEC;AAAY,CAAC,EAC9B;EAAEC,SAAS;EAAEC,WAAW;EAAEC;AAAa,CAAC,EACvC;EACD,MAAMC,KAAK,GAAGC,IAAI,CA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D,WAAA,CAAAyE,cAAc;UAAAP,QAAA,EACZ,IAAAjB,QAAE,EAAE,eAAgB;QAAC,CACR,CAChB;MAAA,CACD,CACF;IAAA,CACI,CAAC;EAAA,CACO,CAAC;AAElB;AAAC,IAAAyB,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAEctC,yBAAyB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_element","_htmlEntities","_blocks","_data","_blockRatings","_interopRequireDefault","_downloadableBlockIcon","_downloadableBlockNotice","_store","_lockUnlock","_jsxRuntime","CompositeItemV2","CompositeItem","unlock","componentsPrivateApis","getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","sprintf","decodeEntities","_n","DownloadableBlockListItem","composite","item","onClick","author","description","icon","getBlockType","name","isInstallable","useSelect","select","getErrorNoticeForBlock","isBlockInstalling","blockDirectoryStore","notice","id","hasFatal","isFatal","statusText","__","jsxs","render","jsx","Button","accessibleWhenDisabled","type","role","className","isBusy","event","preventDefault","label","showTooltip","tooltipPosition","store","disabled","children","default","Spinner","createInterpolateElement","span","block","Fragment","VisuallyHidden","_default","exports"],"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tSpinner,\n\tVisuallyHidden,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockRatings from '../block-ratings';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\nimport DownloadableBlockNotice from '../downloadable-block-notice';\nimport { store as blockDirectoryStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { CompositeItemV2: CompositeItem } = unlock( componentsPrivateApis );\n\n// Return the appropriate block item label, given the block data and status.\nfunction getDownloadableBlockLabel(\n\t{ title, rating, ratingCount },\n\t{ hasNotice, isInstalled, isInstalling }\n) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tif ( ! isInstalled && hasNotice ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Retry installing %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalled ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Add %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalling ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Installing %s.', decodeEntities( title ) );\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Install %s.', decodeEntities( title ) );\n\t}\n\n\treturn sprintf(\n\t\t/* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */\n\t\t_n(\n\t\t\t'Install %1$s. %2$s stars with %3$s review.',\n\t\t\t'Install %1$s. %2$s stars with %3$s reviews.',\n\t\t\tratingCount\n\t\t),\n\t\tdecodeEntities( title ),\n\t\tstars,\n\t\tratingCount\n\t);\n}\n\nfunction DownloadableBlockListItem( { composite, item, onClick } ) {\n\tconst { author, description, icon, rating, title } = item;\n\t// getBlockType returns a block object if this block exists, or null if not.\n\tconst isInstalled = !! getBlockType( item.name );\n\n\tconst { hasNotice, isInstalling, isInstallable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getErrorNoticeForBlock, isInstalling: isBlockInstalling } =\n\t\t\t\tselect( blockDirectoryStore );\n\t\t\tconst notice = getErrorNoticeForBlock( item.id );\n\t\t\tconst hasFatal = notice && notice.isFatal;\n\t\t\treturn {\n\t\t\t\thasNotice: !! notice,\n\t\t\t\tisInstalling: isBlockInstalling( item.id ),\n\t\t\t\tisInstallable: ! hasFatal,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\n\tlet statusText = '';\n\tif ( isInstalled ) {\n\t\tstatusText = __( 'Installed!' );\n\t} else if ( isInstalling ) {\n\t\tstatusText = __( 'Installing…' );\n\t}\n\n\treturn (\n\t\t<CompositeItem\n\t\t\trender={\n\t\t\t\t<Button\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\tclassName=\"block-directory-downloadable-block-list-item\"\n\t\t\t\t\tisBusy={ isInstalling }\n\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tonClick();\n\t\t\t\t\t} }\n\t\t\t\t\tlabel={ getDownloadableBlockLabel( item, {\n\t\t\t\t\t\thasNotice,\n\t\t\t\t\t\tisInstalled,\n\t\t\t\t\t\tisInstalling,\n\t\t\t\t\t} ) }\n\t\t\t\t\tshowTooltip\n\t\t\t\t\ttooltipPosition=\"top center\"\n\t\t\t\t/>\n\t\t\t}\n\t\t\tstore={ composite }\n\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t>\n\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</span>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %1$s: block title, %2$s: author name. */\n\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__author\" />\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t</span>\n\t\t</CompositeItem>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AAMA,IAAAE,QAAA,GAAAF,OAAA;AACA,IAAAG,aAAA,GAAAH,OAAA;AACA,IAAAI,OAAA,GAAAJ,OAAA;AACA,IAAAK,KAAA,GAAAL,OAAA;AAKA,IAAAM,aAAA,GAAAC,sBAAA,CAAAP,OAAA;AACA,IAAAQ,sBAAA,GAAAD,sBAAA,CAAAP,OAAA;AACA,IAAAS,wBAAA,GAAAF,sBAAA,CAAAP,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AACA,IAAAW,WAAA,GAAAX,OAAA;AAA2C,IAAAY,WAAA,GAAAZ,OAAA;AAtB3C;AACA;AACA;;AAaA;AACA;AACA;;AAOA,MAAM;EAAEa,eAAe,EAAEC;AAAc,CAAC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MK,SAAS,EAAC,oDAAoD;UAAAS,QAAA,EACjE,CAAC,CAAElB,UAAU,GACZA,UAAU,GACV,IAAArB,4BAAc,EAAEO,WAAY;QAAC,CAC3B,CAAC,EACLI,aAAa,IACd,EAAIjB,WAAW,IAAIC,YAAY,CAAE,iBAChC,IAAAX,WAAA,CAAAyC,GAAA,EAACpD,WAAA,CAAAyE,cAAc;UAAAP,QAAA,EACZ,IAAAjB,QAAE,EAAE,eAAgB;QAAC,CACR,CAChB;MAAA,CACD,CACF;IAAA,CACI,CAAC;EAAA,CACO,CAAC;AAElB;AAAC,IAAAyB,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAEctC,yBAAyB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_blocks","_data","_blockEditor","_store","_jsxRuntime","InstallButton","attributes","block","clientId","isInstallingBlock","useSelect","select","blockDirectoryStore","isInstalling","id","installBlockType","useDispatch","replaceBlock","blockEditorStore","jsx","Button","onClick","then","success","blockType","getBlockType","name","originalBlock","parse","originalContent","createBlock","innerBlocks","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_blocks","_data","_blockEditor","_store","_jsxRuntime","InstallButton","attributes","block","clientId","isInstallingBlock","useSelect","select","blockDirectoryStore","isInstalling","id","installBlockType","useDispatch","replaceBlock","blockEditorStore","jsx","Button","onClick","then","success","blockType","getBlockType","name","originalBlock","parse","originalContent","createBlock","innerBlocks","accessibleWhenDisabled","disabled","isBusy","variant","children","sprintf","__","title"],"sources":["@wordpress/block-directory/src/plugins/get-install-missing/install-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock, getBlockType, parse } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstallButton( { attributes, block, clientId } ) {\n\tconst isInstallingBlock = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).isInstalling( block.id ),\n\t\t[ block.id ]\n\t);\n\tconst { installBlockType } = useDispatch( blockDirectoryStore );\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<Button\n\t\t\tonClick={ () =>\n\t\t\t\tinstallBlockType( block ).then( ( success ) => {\n\t\t\t\t\tif ( success ) {\n\t\t\t\t\t\tconst blockType = getBlockType( block.name );\n\t\t\t\t\t\tconst [ originalBlock ] = parse(\n\t\t\t\t\t\t\tattributes.originalContent\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( originalBlock && blockType ) {\n\t\t\t\t\t\t\treplaceBlock(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\tblockType.name,\n\t\t\t\t\t\t\t\t\toriginalBlock.attributes,\n\t\t\t\t\t\t\t\t\toriginalBlock.innerBlocks\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} )\n\t\t\t}\n\t\t\taccessibleWhenDisabled\n\t\t\tdisabled={ isInstallingBlock }\n\t\t\tisBusy={ isInstallingBlock }\n\t\t\tvariant=\"primary\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %s: block name */\n\t\t\t\t__( 'Install %s' ),\n\t\t\t\tblock.title\n\t\t\t) }\n\t\t</Button>\n\t);\n}\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AACA,IAAAI,YAAA,GAAAJ,OAAA;AAKA,IAAAK,MAAA,GAAAL,OAAA;AAA2D,IAAAM,WAAA,GAAAN,OAAA;AAZ3D;AACA;AACA;;AAOA;AAC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
|
|
|
8
8
|
var _i18n = require("@wordpress/i18n");
|
|
9
9
|
var _data = require("@wordpress/data");
|
|
10
10
|
var _icons = require("@wordpress/icons");
|
|
11
|
+
var _editor = require("@wordpress/editor");
|
|
11
12
|
var _compactList = _interopRequireDefault(require("../../components/compact-list"));
|
|
12
13
|
var _store = require("../../store");
|
|
13
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
|
-
var _window$wp$editor;
|
|
15
15
|
/**
|
|
16
16
|
* WordPress dependencies
|
|
17
17
|
*/
|
|
18
|
+
|
|
18
19
|
/**
|
|
19
20
|
* Internal dependencies
|
|
20
21
|
*/
|
|
21
|
-
|
|
22
|
-
// because it would include the wp-editor in all pages loading the block-directory script.
|
|
23
|
-
const {
|
|
24
|
-
PluginPrePublishPanel
|
|
25
|
-
} = (_window$wp$editor = window?.wp?.editor) !== null && _window$wp$editor !== void 0 ? _window$wp$editor : {};
|
|
22
|
+
|
|
26
23
|
function InstalledBlocksPrePublishPanel() {
|
|
27
24
|
const newBlockTypes = (0, _data.useSelect)(select => select(_store.store).getNewBlockTypes(), []);
|
|
28
25
|
if (!newBlockTypes.length) {
|
|
29
26
|
return null;
|
|
30
27
|
}
|
|
31
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(PluginPrePublishPanel, {
|
|
28
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_editor.PluginPrePublishPanel, {
|
|
32
29
|
icon: _icons.blockDefault,
|
|
33
30
|
title: (0, _i18n.sprintf)(
|
|
34
31
|
// translators: %d: number of blocks (number).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_data","_icons","_compactList","_interopRequireDefault","_store","_jsxRuntime","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_data","_icons","_editor","_compactList","_interopRequireDefault","_store","_jsxRuntime","InstalledBlocksPrePublishPanel","newBlockTypes","useSelect","select","blockDirectoryStore","getNewBlockTypes","length","jsxs","PluginPrePublishPanel","icon","blockDefault","title","sprintf","_n","initialOpen","children","jsx","className","default","items"],"sources":["@wordpress/block-directory/src/plugins/installed-blocks-pre-publish-panel/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { blockDefault } from '@wordpress/icons';\nimport { PluginPrePublishPanel } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstalledBlocksPrePublishPanel() {\n\tconst newBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getNewBlockTypes(),\n\t\t[]\n\t);\n\n\tif ( ! newBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PluginPrePublishPanel\n\t\t\ticon={ blockDefault }\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %d: number of blocks (number).\n\t\t\t\t_n(\n\t\t\t\t\t'Added: %d block',\n\t\t\t\t\t'Added: %d blocks',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t),\n\t\t\t\tnewBlockTypes.length\n\t\t\t) }\n\t\t\tinitialOpen\n\t\t>\n\t\t\t<p className=\"installed-blocks-pre-publish-panel__copy\">\n\t\t\t\t{ _n(\n\t\t\t\t\t'The following block has been added to your site.',\n\t\t\t\t\t'The following blocks have been added to your site.',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<CompactList items={ newBlockTypes } />\n\t\t</PluginPrePublishPanel>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAKA,IAAAI,YAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAA2D,IAAAO,WAAA,GAAAP,OAAA;AAZ3D;AACA;AACA;;AAMA;AACA;AACA;;AAIe,SAASQ,8BAA8BA,CAAA,EAAG;EACxD,MAAMC,aAAa,GAAG,IAAAC,eAAS,EAC5BC,MAAM,IAAMA,MAAM,CAAEC,YAAoB,CAAC,CAACC,gBAAgB,CAAC,CAAC,EAC9D,EACD,CAAC;EAED,IAAK,CAAEJ,aAAa,CAACK,MAAM,EAAG;IAC7B,OAAO,IAAI;EACZ;EAEA,oBACC,IAAAP,WAAA,CAAAQ,IAAA,EAACZ,OAAA,CAAAa,qBAAqB;IACrBC,IAAI,EAAGC,mBAAc;IACrBC,KAAK,EAAG,IAAAC,aAAO;IACd;IACA,IAAAC,QAAE,EACD,iBAAiB,EACjB,kBAAkB,EAClBZ,aAAa,CAACK,MACf,CAAC,EACDL,aAAa,CAACK,MACf,CAAG;IACHQ,WAAW;IAAAC,QAAA,gBAEX,IAAAhB,WAAA,CAAAiB,GAAA;MAAGC,SAAS,EAAC,0CAA0C;MAAAF,QAAA,EACpD,IAAAF,QAAE,EACH,kDAAkD,EAClD,oDAAoD,EACpDZ,aAAa,CAACK,MACf;IAAC,CACC,CAAC,eACJ,IAAAP,WAAA,CAAAiB,GAAA,EAACpB,YAAA,CAAAsB,OAAW;MAACC,KAAK,EAAGlB;IAAe,CAAE,CAAC;EAAA,CACjB,CAAC;AAE1B","ignoreList":[]}
|
package/build/store/selectors.js
CHANGED
|
@@ -68,11 +68,11 @@ function getInstalledBlockTypes(state) {
|
|
|
68
68
|
*
|
|
69
69
|
* @return {Array} Block type items.
|
|
70
70
|
*/
|
|
71
|
-
const getNewBlockTypes = exports.getNewBlockTypes = (0, _data.createRegistrySelector)(select => state => {
|
|
71
|
+
const getNewBlockTypes = exports.getNewBlockTypes = (0, _data.createRegistrySelector)(select => (0, _data.createSelector)(state => {
|
|
72
72
|
const usedBlockTree = select(_blockEditor.store).getBlocks();
|
|
73
73
|
const installedBlockTypes = getInstalledBlockTypes(state);
|
|
74
74
|
return installedBlockTypes.filter(blockType => (0, _hasBlockType.default)(blockType, usedBlockTree));
|
|
75
|
-
});
|
|
75
|
+
}, state => [getInstalledBlockTypes(state), select(_blockEditor.store).getBlocks()]));
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
78
|
* Returns the block types that have been installed on the server but are not
|
|
@@ -82,11 +82,11 @@ const getNewBlockTypes = exports.getNewBlockTypes = (0, _data.createRegistrySele
|
|
|
82
82
|
*
|
|
83
83
|
* @return {Array} Block type items.
|
|
84
84
|
*/
|
|
85
|
-
const getUnusedBlockTypes = exports.getUnusedBlockTypes = (0, _data.createRegistrySelector)(select => state => {
|
|
85
|
+
const getUnusedBlockTypes = exports.getUnusedBlockTypes = (0, _data.createRegistrySelector)(select => (0, _data.createSelector)(state => {
|
|
86
86
|
const usedBlockTree = select(_blockEditor.store).getBlocks();
|
|
87
87
|
const installedBlockTypes = getInstalledBlockTypes(state);
|
|
88
88
|
return installedBlockTypes.filter(blockType => !(0, _hasBlockType.default)(blockType, usedBlockTree));
|
|
89
|
-
});
|
|
89
|
+
}, state => [getInstalledBlockTypes(state), select(_blockEditor.store).getBlocks()]));
|
|
90
90
|
|
|
91
91
|
/**
|
|
92
92
|
* Returns true if a block plugin install is in progress.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_data","require","_blockEditor","_hasBlockType","_interopRequireDefault","isRequestingDownloadableBlocks","state","filterValue","_state$downloadableBl","downloadableBlocks","isRequesting","getDownloadableBlocks","_state$downloadableBl2","results","getInstalledBlockTypes","blockManagement","installedBlockTypes","getNewBlockTypes","exports","createRegistrySelector","select","usedBlockTree","blockEditorStore","getBlocks","filter","blockType","hasBlockType","getUnusedBlockTypes","isInstalling","blockId","getErrorNotices","errorNotices","getErrorNoticeForBlock"],"sources":["@wordpress/block-directory/src/store/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport hasBlockType from './utils/has-block-type';\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? [];\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector(
|
|
1
|
+
{"version":3,"names":["_data","require","_blockEditor","_hasBlockType","_interopRequireDefault","isRequestingDownloadableBlocks","state","filterValue","_state$downloadableBl","downloadableBlocks","isRequesting","getDownloadableBlocks","_state$downloadableBl2","results","getInstalledBlockTypes","blockManagement","installedBlockTypes","getNewBlockTypes","exports","createRegistrySelector","select","createSelector","usedBlockTree","blockEditorStore","getBlocks","filter","blockType","hasBlockType","getUnusedBlockTypes","isInstalling","blockId","getErrorNotices","errorNotices","getErrorNoticeForBlock"],"sources":["@wordpress/block-directory/src/store/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport hasBlockType from './utils/has-block-type';\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? [];\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\t\treturn installedBlockTypes.filter( ( blockType ) =>\n\t\t\t\thasBlockType( blockType, usedBlockTree )\n\t\t\t);\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getBlocks(),\n\t\t]\n\t)\n);\n\n/**\n * Returns the block types that have been installed on the server but are not\n * used in the current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getUnusedBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\t\treturn installedBlockTypes.filter(\n\t\t\t\t( blockType ) => ! hasBlockType( blockType, usedBlockTree )\n\t\t\t);\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getBlocks(),\n\t\t]\n\t)\n);\n\n/**\n * Returns true if a block plugin install is in progress.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId Id of the block.\n *\n * @return {boolean} Whether this block is currently being installed.\n */\nexport function isInstalling( state, blockId ) {\n\treturn state.blockManagement.isInstalling[ blockId ] || false;\n}\n\n/**\n * Returns all block error notices.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Object with error notices.\n */\nexport function getErrorNotices( state ) {\n\treturn state.errorNotices;\n}\n\n/**\n * Returns the error notice for a given block.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {string|boolean} The error text, or false if no error.\n */\nexport function getErrorNoticeForBlock( state, blockId ) {\n\treturn state.errorNotices[ blockId ];\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAKA,IAAAE,aAAA,GAAAC,sBAAA,CAAAH,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,8BAA8BA,CAAEC,KAAK,EAAEC,WAAW,EAAG;EAAA,IAAAC,qBAAA;EACpE,QAAAA,qBAAA,GAAOF,KAAK,CAACG,kBAAkB,CAAEF,WAAW,CAAE,EAAEG,YAAY,cAAAF,qBAAA,cAAAA,qBAAA,GAAI,KAAK;AACtE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,qBAAqBA,CAAEL,KAAK,EAAEC,WAAW,EAAG;EAAA,IAAAK,sBAAA;EAC3D,QAAAA,sBAAA,GAAON,KAAK,CAACG,kBAAkB,CAAEF,WAAW,CAAE,EAAEM,OAAO,cAAAD,sBAAA,cAAAA,sBAAA,GAAI,EAAE;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,sBAAsBA,CAAER,KAAK,EAAG;EAC/C,OAAOA,KAAK,CAACS,eAAe,CAACC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CAACS,eAAe,CAACc,YAAY,CAAEC,OAAO,CAAE,IAAI,KAAK;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAAEzB,KAAK,EAAG;EACxC,OAAOA,KAAK,CAAC0B,YAAY;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,sBAAsBA,CAAE3B,KAAK,EAAEwB,OAAO,EAAG;EACxD,OAAOxB,KAAK,CAAC0B,YAAY,CAAEF,OAAO,CAAE;AACrC","ignoreList":[]}
|
|
@@ -94,7 +94,7 @@ function DownloadableBlockListItem({
|
|
|
94
94
|
}
|
|
95
95
|
return /*#__PURE__*/_jsxs(CompositeItem, {
|
|
96
96
|
render: /*#__PURE__*/_jsx(Button, {
|
|
97
|
-
|
|
97
|
+
accessibleWhenDisabled: true,
|
|
98
98
|
type: "button",
|
|
99
99
|
role: "option",
|
|
100
100
|
className: "block-directory-downloadable-block-list-item",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","_n","sprintf","Button","Spinner","VisuallyHidden","privateApis","componentsPrivateApis","createInterpolateElement","decodeEntities","getBlockType","useSelect","BlockRatings","DownloadableBlockIcon","DownloadableBlockNotice","store","blockDirectoryStore","unlock","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","CompositeItemV2","CompositeItem","getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","DownloadableBlockListItem","composite","item","onClick","author","description","icon","name","isInstallable","select","getErrorNoticeForBlock","isBlockInstalling","notice","id","hasFatal","isFatal","statusText","render","
|
|
1
|
+
{"version":3,"names":["__","_n","sprintf","Button","Spinner","VisuallyHidden","privateApis","componentsPrivateApis","createInterpolateElement","decodeEntities","getBlockType","useSelect","BlockRatings","DownloadableBlockIcon","DownloadableBlockNotice","store","blockDirectoryStore","unlock","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","CompositeItemV2","CompositeItem","getDownloadableBlockLabel","title","rating","ratingCount","hasNotice","isInstalled","isInstalling","stars","Math","round","DownloadableBlockListItem","composite","item","onClick","author","description","icon","name","isInstallable","select","getErrorNoticeForBlock","isBlockInstalling","notice","id","hasFatal","isFatal","statusText","render","accessibleWhenDisabled","type","role","className","isBusy","event","preventDefault","label","showTooltip","tooltipPosition","disabled","children","span","block"],"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tButton,\n\tSpinner,\n\tVisuallyHidden,\n\tprivateApis as componentsPrivateApis,\n} from '@wordpress/components';\nimport { createInterpolateElement } from '@wordpress/element';\nimport { decodeEntities } from '@wordpress/html-entities';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport BlockRatings from '../block-ratings';\nimport DownloadableBlockIcon from '../downloadable-block-icon';\nimport DownloadableBlockNotice from '../downloadable-block-notice';\nimport { store as blockDirectoryStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { CompositeItemV2: CompositeItem } = unlock( componentsPrivateApis );\n\n// Return the appropriate block item label, given the block data and status.\nfunction getDownloadableBlockLabel(\n\t{ title, rating, ratingCount },\n\t{ hasNotice, isInstalled, isInstalling }\n) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tif ( ! isInstalled && hasNotice ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Retry installing %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalled ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Add %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalling ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Installing %s.', decodeEntities( title ) );\n\t}\n\n\t// No ratings yet, just use the title.\n\tif ( ratingCount < 1 ) {\n\t\t/* translators: %1$s: block title */\n\t\treturn sprintf( 'Install %s.', decodeEntities( title ) );\n\t}\n\n\treturn sprintf(\n\t\t/* translators: %1$s: block title, %2$s: average rating, %3$s: total ratings count. */\n\t\t_n(\n\t\t\t'Install %1$s. %2$s stars with %3$s review.',\n\t\t\t'Install %1$s. %2$s stars with %3$s reviews.',\n\t\t\tratingCount\n\t\t),\n\t\tdecodeEntities( title ),\n\t\tstars,\n\t\tratingCount\n\t);\n}\n\nfunction DownloadableBlockListItem( { composite, item, onClick } ) {\n\tconst { author, description, icon, rating, title } = item;\n\t// getBlockType returns a block object if this block exists, or null if not.\n\tconst isInstalled = !! getBlockType( item.name );\n\n\tconst { hasNotice, isInstalling, isInstallable } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getErrorNoticeForBlock, isInstalling: isBlockInstalling } =\n\t\t\t\tselect( blockDirectoryStore );\n\t\t\tconst notice = getErrorNoticeForBlock( item.id );\n\t\t\tconst hasFatal = notice && notice.isFatal;\n\t\t\treturn {\n\t\t\t\thasNotice: !! notice,\n\t\t\t\tisInstalling: isBlockInstalling( item.id ),\n\t\t\t\tisInstallable: ! hasFatal,\n\t\t\t};\n\t\t},\n\t\t[ item ]\n\t);\n\n\tlet statusText = '';\n\tif ( isInstalled ) {\n\t\tstatusText = __( 'Installed!' );\n\t} else if ( isInstalling ) {\n\t\tstatusText = __( 'Installing…' );\n\t}\n\n\treturn (\n\t\t<CompositeItem\n\t\t\trender={\n\t\t\t\t<Button\n\t\t\t\t\taccessibleWhenDisabled\n\t\t\t\t\ttype=\"button\"\n\t\t\t\t\trole=\"option\"\n\t\t\t\t\tclassName=\"block-directory-downloadable-block-list-item\"\n\t\t\t\t\tisBusy={ isInstalling }\n\t\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\t\tonClick();\n\t\t\t\t\t} }\n\t\t\t\t\tlabel={ getDownloadableBlockLabel( item, {\n\t\t\t\t\t\thasNotice,\n\t\t\t\t\t\tisInstalled,\n\t\t\t\t\t\tisInstalling,\n\t\t\t\t\t} ) }\n\t\t\t\t\tshowTooltip\n\t\t\t\t\ttooltipPosition=\"top center\"\n\t\t\t\t/>\n\t\t\t}\n\t\t\tstore={ composite }\n\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t>\n\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t</span>\n\t\t\t\t) : (\n\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t) }\n\t\t\t</div>\n\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t/* translators: %1$s: block title, %2$s: author name. */\n\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tspan: (\n\t\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__author\" />\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t}\n\t\t\t\t\t) }\n\t\t\t\t</span>\n\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t) : (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t</span>\n\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\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AMsC,SAAS,EAAC,qDAAqD;QAAAQ,QAAA,EAClEzD,wBAAwB,CACzBN,OAAO,EACN;QACAF,EAAE,CAAE,2BAA4B,CAAC,EACjCS,cAAc,CAAEkB,KAAM,CAAC,EACvBa,MACD,CAAC,EACD;UACC0B,IAAI,eACH/C,IAAA;YAAMsC,SAAS,EAAC;UAAsD,CAAE;QAE1E,CACD;MAAC,CACI,CAAC,EACL3B,SAAS,gBACVX,IAAA,CAACL,uBAAuB;QAACqD,KAAK,EAAG7B;MAAM,CAAE,CAAC,gBAE1CjB,KAAA,CAAAE,SAAA;QAAA0C,QAAA,gBACC9C,IAAA;UAAMsC,SAAS,EAAC,oDAAoD;UAAAQ,QAAA,EACjE,CAAC,CAAEb,UAAU,GACZA,UAAU,GACV3C,cAAc,CAAEgC,WAAY;QAAC,CAC3B,CAAC,EACLG,aAAa,IACd,EAAIb,WAAW,IAAIC,YAAY,CAAE,iBAChCb,IAAA,CAACd,cAAc;UAAA4D,QAAA,EACZjE,EAAE,CAAE,eAAgB;QAAC,CACR,CAChB;MAAA,CACD,CACF;IAAA,CACI,CAAC;EAAA,CACO,CAAC;AAElB;AAEA,eAAeoC,yBAAyB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","sprintf","Button","createBlock","getBlockType","parse","useSelect","useDispatch","store","blockEditorStore","blockDirectoryStore","jsx","_jsx","InstallButton","attributes","block","clientId","isInstallingBlock","select","isInstalling","id","installBlockType","replaceBlock","onClick","then","success","blockType","name","originalBlock","originalContent","innerBlocks","
|
|
1
|
+
{"version":3,"names":["__","sprintf","Button","createBlock","getBlockType","parse","useSelect","useDispatch","store","blockEditorStore","blockDirectoryStore","jsx","_jsx","InstallButton","attributes","block","clientId","isInstallingBlock","select","isInstalling","id","installBlockType","replaceBlock","onClick","then","success","blockType","name","originalBlock","originalContent","innerBlocks","accessibleWhenDisabled","disabled","isBusy","variant","children","title"],"sources":["@wordpress/block-directory/src/plugins/get-install-missing/install-button.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock, getBlockType, parse } from '@wordpress/blocks';\nimport { useSelect, useDispatch } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstallButton( { attributes, block, clientId } ) {\n\tconst isInstallingBlock = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).isInstalling( block.id ),\n\t\t[ block.id ]\n\t);\n\tconst { installBlockType } = useDispatch( blockDirectoryStore );\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\n\treturn (\n\t\t<Button\n\t\t\tonClick={ () =>\n\t\t\t\tinstallBlockType( block ).then( ( success ) => {\n\t\t\t\t\tif ( success ) {\n\t\t\t\t\t\tconst blockType = getBlockType( block.name );\n\t\t\t\t\t\tconst [ originalBlock ] = parse(\n\t\t\t\t\t\t\tattributes.originalContent\n\t\t\t\t\t\t);\n\t\t\t\t\t\tif ( originalBlock && blockType ) {\n\t\t\t\t\t\t\treplaceBlock(\n\t\t\t\t\t\t\t\tclientId,\n\t\t\t\t\t\t\t\tcreateBlock(\n\t\t\t\t\t\t\t\t\tblockType.name,\n\t\t\t\t\t\t\t\t\toriginalBlock.attributes,\n\t\t\t\t\t\t\t\t\toriginalBlock.innerBlocks\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t} )\n\t\t\t}\n\t\t\taccessibleWhenDisabled\n\t\t\tdisabled={ isInstallingBlock }\n\t\t\tisBusy={ isInstallingBlock }\n\t\t\tvariant=\"primary\"\n\t\t>\n\t\t\t{ sprintf(\n\t\t\t\t/* translators: %s: block name */\n\t\t\t\t__( 'Install %s' ),\n\t\t\t\tblock.title\n\t\t\t) }\n\t\t</Button>\n\t);\n}\n"],"mappings":"AAAA;AACA;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,EAAGf,iBAAmB;IAC9BgB,MAAM,EAAGhB,iBAAmB;IAC5BiB,OAAO,EAAC,SAAS;IAAAC,QAAA,EAEflC,OAAO,EACR;IACAD,EAAE,CAAE,YAAa,CAAC,EAClBe,KAAK,CAACqB,KACP;EAAC,CACM,CAAC;AAEX","ignoreList":[]}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
var _window$wp$editor;
|
|
2
1
|
/**
|
|
3
2
|
* WordPress dependencies
|
|
4
3
|
*/
|
|
5
4
|
import { _n, sprintf } from '@wordpress/i18n';
|
|
6
5
|
import { useSelect } from '@wordpress/data';
|
|
7
6
|
import { blockDefault } from '@wordpress/icons';
|
|
7
|
+
import { PluginPrePublishPanel } from '@wordpress/editor';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* Internal dependencies
|
|
11
11
|
*/
|
|
12
12
|
import CompactList from '../../components/compact-list';
|
|
13
13
|
import { store as blockDirectoryStore } from '../../store';
|
|
14
|
-
|
|
15
|
-
// We shouldn't import the editor package directly
|
|
16
|
-
// because it would include the wp-editor in all pages loading the block-directory script.
|
|
17
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
-
const {
|
|
20
|
-
PluginPrePublishPanel
|
|
21
|
-
} = (_window$wp$editor = window?.wp?.editor) !== null && _window$wp$editor !== void 0 ? _window$wp$editor : {};
|
|
22
16
|
export default function InstalledBlocksPrePublishPanel() {
|
|
23
17
|
const newBlockTypes = useSelect(select => select(blockDirectoryStore).getNewBlockTypes(), []);
|
|
24
18
|
if (!newBlockTypes.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_n","sprintf","useSelect","blockDefault","CompactList","store","blockDirectoryStore","jsx","_jsx","jsxs","_jsxs","
|
|
1
|
+
{"version":3,"names":["_n","sprintf","useSelect","blockDefault","PluginPrePublishPanel","CompactList","store","blockDirectoryStore","jsx","_jsx","jsxs","_jsxs","InstalledBlocksPrePublishPanel","newBlockTypes","select","getNewBlockTypes","length","icon","title","initialOpen","children","className","items"],"sources":["@wordpress/block-directory/src/plugins/installed-blocks-pre-publish-panel/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { blockDefault } from '@wordpress/icons';\nimport { PluginPrePublishPanel } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstalledBlocksPrePublishPanel() {\n\tconst newBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getNewBlockTypes(),\n\t\t[]\n\t);\n\n\tif ( ! newBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PluginPrePublishPanel\n\t\t\ticon={ blockDefault }\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %d: number of blocks (number).\n\t\t\t\t_n(\n\t\t\t\t\t'Added: %d block',\n\t\t\t\t\t'Added: %d blocks',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t),\n\t\t\t\tnewBlockTypes.length\n\t\t\t) }\n\t\t\tinitialOpen\n\t\t>\n\t\t\t<p className=\"installed-blocks-pre-publish-panel__copy\">\n\t\t\t\t{ _n(\n\t\t\t\t\t'The following block has been added to your site.',\n\t\t\t\t\t'The following blocks have been added to your site.',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<CompactList items={ newBlockTypes } />\n\t\t</PluginPrePublishPanel>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,qBAAqB,QAAQ,mBAAmB;;AAEzD;AACA;AACA;AACA,OAAOC,WAAW,MAAM,+BAA+B;AACvD,SAASC,KAAK,IAAIC,mBAAmB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAE3D,eAAe,SAASC,8BAA8BA,CAAA,EAAG;EACxD,MAAMC,aAAa,GAAGX,SAAS,CAC5BY,MAAM,IAAMA,MAAM,CAAEP,mBAAoB,CAAC,CAACQ,gBAAgB,CAAC,CAAC,EAC9D,EACD,CAAC;EAED,IAAK,CAAEF,aAAa,CAACG,MAAM,EAAG;IAC7B,OAAO,IAAI;EACZ;EAEA,oBACCL,KAAA,CAACP,qBAAqB;IACrBa,IAAI,EAAGd,YAAc;IACrBe,KAAK,EAAGjB,OAAO;IACd;IACAD,EAAE,CACD,iBAAiB,EACjB,kBAAkB,EAClBa,aAAa,CAACG,MACf,CAAC,EACDH,aAAa,CAACG,MACf,CAAG;IACHG,WAAW;IAAAC,QAAA,gBAEXX,IAAA;MAAGY,SAAS,EAAC,0CAA0C;MAAAD,QAAA,EACpDpB,EAAE,CACH,kDAAkD,EAClD,oDAAoD,EACpDa,aAAa,CAACG,MACf;IAAC,CACC,CAAC,eACJP,IAAA,CAACJ,WAAW;MAACiB,KAAK,EAAGT;IAAe,CAAE,CAAC;EAAA,CACjB,CAAC;AAE1B","ignoreList":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { createRegistrySelector } from '@wordpress/data';
|
|
4
|
+
import { createSelector, createRegistrySelector } from '@wordpress/data';
|
|
5
5
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -55,11 +55,11 @@ export function getInstalledBlockTypes(state) {
|
|
|
55
55
|
*
|
|
56
56
|
* @return {Array} Block type items.
|
|
57
57
|
*/
|
|
58
|
-
export const getNewBlockTypes = createRegistrySelector(select => state => {
|
|
58
|
+
export const getNewBlockTypes = createRegistrySelector(select => createSelector(state => {
|
|
59
59
|
const usedBlockTree = select(blockEditorStore).getBlocks();
|
|
60
60
|
const installedBlockTypes = getInstalledBlockTypes(state);
|
|
61
61
|
return installedBlockTypes.filter(blockType => hasBlockType(blockType, usedBlockTree));
|
|
62
|
-
});
|
|
62
|
+
}, state => [getInstalledBlockTypes(state), select(blockEditorStore).getBlocks()]));
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
65
|
* Returns the block types that have been installed on the server but are not
|
|
@@ -69,11 +69,11 @@ export const getNewBlockTypes = createRegistrySelector(select => state => {
|
|
|
69
69
|
*
|
|
70
70
|
* @return {Array} Block type items.
|
|
71
71
|
*/
|
|
72
|
-
export const getUnusedBlockTypes = createRegistrySelector(select => state => {
|
|
72
|
+
export const getUnusedBlockTypes = createRegistrySelector(select => createSelector(state => {
|
|
73
73
|
const usedBlockTree = select(blockEditorStore).getBlocks();
|
|
74
74
|
const installedBlockTypes = getInstalledBlockTypes(state);
|
|
75
75
|
return installedBlockTypes.filter(blockType => !hasBlockType(blockType, usedBlockTree));
|
|
76
|
-
});
|
|
76
|
+
}, state => [getInstalledBlockTypes(state), select(blockEditorStore).getBlocks()]));
|
|
77
77
|
|
|
78
78
|
/**
|
|
79
79
|
* Returns true if a block plugin install is in progress.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["createRegistrySelector","store","blockEditorStore","hasBlockType","isRequestingDownloadableBlocks","state","filterValue","_state$downloadableBl","downloadableBlocks","isRequesting","getDownloadableBlocks","_state$downloadableBl2","results","getInstalledBlockTypes","blockManagement","installedBlockTypes","getNewBlockTypes","select","usedBlockTree","getBlocks","filter","blockType","getUnusedBlockTypes","isInstalling","blockId","getErrorNotices","errorNotices","getErrorNoticeForBlock"],"sources":["@wordpress/block-directory/src/store/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport hasBlockType from './utils/has-block-type';\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? [];\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector(
|
|
1
|
+
{"version":3,"names":["createSelector","createRegistrySelector","store","blockEditorStore","hasBlockType","isRequestingDownloadableBlocks","state","filterValue","_state$downloadableBl","downloadableBlocks","isRequesting","getDownloadableBlocks","_state$downloadableBl2","results","getInstalledBlockTypes","blockManagement","installedBlockTypes","getNewBlockTypes","select","usedBlockTree","getBlocks","filter","blockType","getUnusedBlockTypes","isInstalling","blockId","getErrorNotices","errorNotices","getErrorNoticeForBlock"],"sources":["@wordpress/block-directory/src/store/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport hasBlockType from './utils/has-block-type';\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? [];\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\t\treturn installedBlockTypes.filter( ( blockType ) =>\n\t\t\t\thasBlockType( blockType, usedBlockTree )\n\t\t\t);\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getBlocks(),\n\t\t]\n\t)\n);\n\n/**\n * Returns the block types that have been installed on the server but are not\n * used in the current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getUnusedBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\t\treturn installedBlockTypes.filter(\n\t\t\t\t( blockType ) => ! hasBlockType( blockType, usedBlockTree )\n\t\t\t);\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getBlocks(),\n\t\t]\n\t)\n);\n\n/**\n * Returns true if a block plugin install is in progress.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId Id of the block.\n *\n * @return {boolean} Whether this block is currently being installed.\n */\nexport function isInstalling( state, blockId ) {\n\treturn state.blockManagement.isInstalling[ blockId ] || false;\n}\n\n/**\n * Returns all block error notices.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Object with error notices.\n */\nexport function getErrorNotices( state ) {\n\treturn state.errorNotices;\n}\n\n/**\n * Returns the error notice for a given block.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {string|boolean} The error text, or false if no error.\n */\nexport function getErrorNoticeForBlock( state, blockId ) {\n\treturn state.errorNotices[ blockId ];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAc,EAAEC,sBAAsB,QAAQ,iBAAiB;AACxE,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;;AAEnE;AACA;AACA;AACA,OAAOC,YAAY,MAAM,wBAAwB;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,8BAA8BA,CAAEC,KAAK,EAAEC,WAAW,EAAG;EAAA,IAAAC,qBAAA;EACpE,QAAAA,qBAAA,GAAOF,KAAK,CAACG,kBAAkB,CAAEF,WAAW,CAAE,EAAEG,YAAY,cAAAF,qBAAA,cAAAA,qBAAA,GAAI,KAAK;AACtE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,qBAAqBA,CAAEL,KAAK,EAAEC,WAAW,EAAG;EAAA,IAAAK,sBAAA;EAC3D,QAAAA,sBAAA,GAAON,KAAK,CAACG,kBAAkB,CAAEF,WAAW,CAAE,EAAEM,OAAO,cAAAD,sBAAA,cAAAA,sBAAA,GAAI,EAAE;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,sBAAsBA,CAAER,KAAK,EAAG;EAC/C,OAAOA,KAAK,CAACS,eAAe,CAACC,mBAAmB;AAC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AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAAEpB,KAAK,EAAG;EACxC,OAAOA,KAAK,CAACqB,YAAY;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CAAEtB,KAAK,EAAEmB,OAAO,EAAG;EACxD,OAAOnB,KAAK,CAACqB,YAAY,CAAEF,OAAO,CAAE;AACrC","ignoreList":[]}
|
package/build-style/style.css
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-directory",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.4.0",
|
|
4
4
|
"description": "Extend editor with block directory features to search, download and install blocks.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -27,25 +27,24 @@
|
|
|
27
27
|
"react-native": "src/index",
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@babel/runtime": "^7.16.0",
|
|
30
|
-
"@wordpress/a11y": "^4.
|
|
31
|
-
"@wordpress/api-fetch": "^7.
|
|
32
|
-
"@wordpress/block-editor": "^13.
|
|
33
|
-
"@wordpress/blocks": "^13.
|
|
34
|
-
"@wordpress/components": "^28.
|
|
35
|
-
"@wordpress/compose": "^7.
|
|
36
|
-
"@wordpress/core-data": "^7.
|
|
37
|
-
"@wordpress/data": "^10.
|
|
38
|
-
"@wordpress/
|
|
39
|
-
"@wordpress/
|
|
40
|
-
"@wordpress/
|
|
41
|
-
"@wordpress/
|
|
42
|
-
"@wordpress/
|
|
43
|
-
"@wordpress/
|
|
44
|
-
"@wordpress/
|
|
45
|
-
"@wordpress/
|
|
46
|
-
"@wordpress/
|
|
47
|
-
"@wordpress/
|
|
48
|
-
"@wordpress/url": "^4.2.0",
|
|
30
|
+
"@wordpress/a11y": "^4.4.0",
|
|
31
|
+
"@wordpress/api-fetch": "^7.4.0",
|
|
32
|
+
"@wordpress/block-editor": "^13.4.0",
|
|
33
|
+
"@wordpress/blocks": "^13.4.0",
|
|
34
|
+
"@wordpress/components": "^28.4.0",
|
|
35
|
+
"@wordpress/compose": "^7.4.0",
|
|
36
|
+
"@wordpress/core-data": "^7.4.0",
|
|
37
|
+
"@wordpress/data": "^10.4.0",
|
|
38
|
+
"@wordpress/editor": "^14.4.0",
|
|
39
|
+
"@wordpress/element": "^6.4.0",
|
|
40
|
+
"@wordpress/hooks": "^4.4.0",
|
|
41
|
+
"@wordpress/html-entities": "^4.4.0",
|
|
42
|
+
"@wordpress/i18n": "^5.4.0",
|
|
43
|
+
"@wordpress/icons": "^10.4.0",
|
|
44
|
+
"@wordpress/notices": "^5.4.0",
|
|
45
|
+
"@wordpress/plugins": "^7.4.0",
|
|
46
|
+
"@wordpress/private-apis": "^1.4.0",
|
|
47
|
+
"@wordpress/url": "^4.4.0",
|
|
49
48
|
"change-case": "^4.1.2"
|
|
50
49
|
},
|
|
51
50
|
"peerDependencies": {
|
|
@@ -55,5 +54,5 @@
|
|
|
55
54
|
"publishConfig": {
|
|
56
55
|
"access": "public"
|
|
57
56
|
},
|
|
58
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "363edb39b8dda8727f652e42cbb8497732693ed2"
|
|
59
58
|
}
|
|
@@ -96,7 +96,7 @@ function DownloadableBlockListItem( { composite, item, onClick } ) {
|
|
|
96
96
|
<CompositeItem
|
|
97
97
|
render={
|
|
98
98
|
<Button
|
|
99
|
-
|
|
99
|
+
accessibleWhenDisabled
|
|
100
100
|
type="button"
|
|
101
101
|
role="option"
|
|
102
102
|
className="block-directory-downloadable-block-list-item"
|
|
@@ -6,6 +6,12 @@
|
|
|
6
6
|
display: grid;
|
|
7
7
|
grid-template-columns: auto 1fr;
|
|
8
8
|
|
|
9
|
+
// The item contains absolutely positioned items.
|
|
10
|
+
// Set `position: relative` on the parent to prevent overflow issues
|
|
11
|
+
// in scroll containers.
|
|
12
|
+
// See: https://github.com/WordPress/gutenberg/issues/63384
|
|
13
|
+
position: relative;
|
|
14
|
+
|
|
9
15
|
&:hover {
|
|
10
16
|
@include button-style__focus();
|
|
11
17
|
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import { _n, sprintf } from '@wordpress/i18n';
|
|
5
5
|
import { useSelect } from '@wordpress/data';
|
|
6
6
|
import { blockDefault } from '@wordpress/icons';
|
|
7
|
+
import { PluginPrePublishPanel } from '@wordpress/editor';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Internal dependencies
|
|
@@ -11,10 +12,6 @@ import { blockDefault } from '@wordpress/icons';
|
|
|
11
12
|
import CompactList from '../../components/compact-list';
|
|
12
13
|
import { store as blockDirectoryStore } from '../../store';
|
|
13
14
|
|
|
14
|
-
// We shouldn't import the editor package directly
|
|
15
|
-
// because it would include the wp-editor in all pages loading the block-directory script.
|
|
16
|
-
const { PluginPrePublishPanel } = window?.wp?.editor ?? {};
|
|
17
|
-
|
|
18
15
|
export default function InstalledBlocksPrePublishPanel() {
|
|
19
16
|
const newBlockTypes = useSelect(
|
|
20
17
|
( select ) => select( blockDirectoryStore ).getNewBlockTypes(),
|
package/src/store/selectors.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
|
-
import { createRegistrySelector } from '@wordpress/data';
|
|
4
|
+
import { createSelector, createRegistrySelector } from '@wordpress/data';
|
|
5
5
|
import { store as blockEditorStore } from '@wordpress/block-editor';
|
|
6
6
|
|
|
7
7
|
/**
|
|
@@ -53,15 +53,21 @@ export function getInstalledBlockTypes( state ) {
|
|
|
53
53
|
*
|
|
54
54
|
* @return {Array} Block type items.
|
|
55
55
|
*/
|
|
56
|
-
export const getNewBlockTypes = createRegistrySelector(
|
|
57
|
-
(
|
|
58
|
-
|
|
59
|
-
|
|
56
|
+
export const getNewBlockTypes = createRegistrySelector( ( select ) =>
|
|
57
|
+
createSelector(
|
|
58
|
+
( state ) => {
|
|
59
|
+
const usedBlockTree = select( blockEditorStore ).getBlocks();
|
|
60
|
+
const installedBlockTypes = getInstalledBlockTypes( state );
|
|
60
61
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
return installedBlockTypes.filter( ( blockType ) =>
|
|
63
|
+
hasBlockType( blockType, usedBlockTree )
|
|
64
|
+
);
|
|
65
|
+
},
|
|
66
|
+
( state ) => [
|
|
67
|
+
getInstalledBlockTypes( state ),
|
|
68
|
+
select( blockEditorStore ).getBlocks(),
|
|
69
|
+
]
|
|
70
|
+
)
|
|
65
71
|
);
|
|
66
72
|
|
|
67
73
|
/**
|
|
@@ -72,15 +78,21 @@ export const getNewBlockTypes = createRegistrySelector(
|
|
|
72
78
|
*
|
|
73
79
|
* @return {Array} Block type items.
|
|
74
80
|
*/
|
|
75
|
-
export const getUnusedBlockTypes = createRegistrySelector(
|
|
76
|
-
(
|
|
77
|
-
|
|
78
|
-
|
|
81
|
+
export const getUnusedBlockTypes = createRegistrySelector( ( select ) =>
|
|
82
|
+
createSelector(
|
|
83
|
+
( state ) => {
|
|
84
|
+
const usedBlockTree = select( blockEditorStore ).getBlocks();
|
|
85
|
+
const installedBlockTypes = getInstalledBlockTypes( state );
|
|
79
86
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
87
|
+
return installedBlockTypes.filter(
|
|
88
|
+
( blockType ) => ! hasBlockType( blockType, usedBlockTree )
|
|
89
|
+
);
|
|
90
|
+
},
|
|
91
|
+
( state ) => [
|
|
92
|
+
getInstalledBlockTypes( state ),
|
|
93
|
+
select( blockEditorStore ).getBlocks(),
|
|
94
|
+
]
|
|
95
|
+
)
|
|
84
96
|
);
|
|
85
97
|
|
|
86
98
|
/**
|