@wordpress/block-directory 5.5.0 → 5.7.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 +4 -3
- package/build/components/downloadable-block-list-item/index.js.map +1 -1
- package/build/components/downloadable-blocks-list/index.js +1 -5
- package/build/components/downloadable-blocks-list/index.js.map +1 -1
- package/build/plugins/get-install-missing/index.js +4 -1
- package/build/plugins/get-install-missing/index.js.map +1 -1
- package/build/plugins/get-install-missing/install-button.js +4 -1
- package/build/plugins/get-install-missing/install-button.js.map +1 -1
- package/build-module/components/downloadable-block-list-item/index.js +4 -3
- package/build-module/components/downloadable-block-list-item/index.js.map +1 -1
- package/build-module/components/downloadable-blocks-list/index.js +1 -5
- package/build-module/components/downloadable-blocks-list/index.js.map +1 -1
- package/build-module/plugins/get-install-missing/index.js +4 -1
- package/build-module/plugins/get-install-missing/index.js.map +1 -1
- package/build-module/plugins/get-install-missing/install-button.js +4 -1
- package/build-module/plugins/get-install-missing/install-button.js.map +1 -1
- package/build-style/style-rtl.css +2 -2
- package/build-style/style.css +2 -2
- package/package.json +20 -20
- package/src/components/downloadable-block-icon/style.scss +1 -1
- package/src/components/downloadable-block-list-item/index.js +3 -2
- package/src/components/downloadable-blocks-list/index.js +1 -5
- package/src/plugins/get-install-missing/index.js +7 -1
- package/src/plugins/get-install-missing/install-button.js +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -62,7 +62,6 @@ function getDownloadableBlockLabel({
|
|
|
62
62
|
(0, _i18n._n)('Install %1$s. %2$s stars with %3$s review.', 'Install %1$s. %2$s stars with %3$s reviews.', ratingCount), (0, _htmlEntities.decodeEntities)(title), stars, ratingCount);
|
|
63
63
|
}
|
|
64
64
|
function DownloadableBlockListItem({
|
|
65
|
-
composite,
|
|
66
65
|
item,
|
|
67
66
|
onClick
|
|
68
67
|
}) {
|
|
@@ -99,7 +98,10 @@ function DownloadableBlockListItem({
|
|
|
99
98
|
statusText = (0, _i18n.__)('Installing…');
|
|
100
99
|
}
|
|
101
100
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(CompositeItem, {
|
|
102
|
-
render: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
101
|
+
render: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
102
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
103
|
+
, {
|
|
104
|
+
__next40pxDefaultSize: false,
|
|
103
105
|
accessibleWhenDisabled: true,
|
|
104
106
|
type: "button",
|
|
105
107
|
role: "option",
|
|
@@ -117,7 +119,6 @@ function DownloadableBlockListItem({
|
|
|
117
119
|
showTooltip: true,
|
|
118
120
|
tooltipPosition: "top center"
|
|
119
121
|
}),
|
|
120
|
-
store: composite,
|
|
121
122
|
disabled: isInstalling || !isInstallable,
|
|
122
123
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
123
124
|
className: "block-directory-downloadable-block-list-item__icon",
|
|
@@ -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","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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IAAAuB,QAAE,EAAE,2BAA4B,CAAC,EACjC,IAAAtB,4BAAc,EAAEV,KAAM,CAAC,EACvBgB,MACD,CAAC,EACD;UACCqC,IAAI,eACH,IAAA3D,WAAA,CAAAyC,GAAA;YAAMK,SAAS,EAAC;UAAsD,CAAE;QAE1E,CACD;MAAC,CACI,CAAC,EACLrC,SAAS,gBACV,IAAAT,WAAA,CAAAyC,GAAA,EAAC5C,wBAAA,CAAA2D,OAAuB;QAACI,KAAK,EAAGxC;MAAM,CAAE,CAAC,gBAE1C,IAAApB,WAAA,CAAAuC,IAAA,EAAAvC,WAAA,CAAA6D,QAAA;QAAAN,QAAA,gBACC,IAAAvD,WAAA,CAAAyC,GAAA;UAAMK,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
|
+
{"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","item","onClick","author","description","icon","getBlockType","name","isInstallable","useSelect","select","getErrorNoticeForBlock","isBlockInstalling","blockDirectoryStore","notice","id","hasFatal","isFatal","statusText","__","jsxs","render","jsx","Button","__next40pxDefaultSize","accessibleWhenDisabled","type","role","className","isBusy","event","preventDefault","label","showTooltip","tooltipPosition","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( { 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// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t__next40pxDefaultSize={ false }\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\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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
24
|
const {
|
|
25
|
-
CompositeV2: Composite
|
|
26
|
-
useCompositeStoreV2: useCompositeStore
|
|
25
|
+
CompositeV2: Composite
|
|
27
26
|
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
28
27
|
const noop = () => {};
|
|
29
28
|
function DownloadableBlocksList({
|
|
@@ -31,7 +30,6 @@ function DownloadableBlocksList({
|
|
|
31
30
|
onHover = noop,
|
|
32
31
|
onSelect
|
|
33
32
|
}) {
|
|
34
|
-
const composite = useCompositeStore();
|
|
35
33
|
const {
|
|
36
34
|
installBlockType
|
|
37
35
|
} = (0, _data.useDispatch)(_store.store);
|
|
@@ -39,13 +37,11 @@ function DownloadableBlocksList({
|
|
|
39
37
|
return null;
|
|
40
38
|
}
|
|
41
39
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Composite, {
|
|
42
|
-
store: composite,
|
|
43
40
|
role: "listbox",
|
|
44
41
|
className: "block-directory-downloadable-blocks-list",
|
|
45
42
|
"aria-label": (0, _i18n.__)('Blocks available for install'),
|
|
46
43
|
children: items.map(item => {
|
|
47
44
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_downloadableBlockListItem.default, {
|
|
48
|
-
composite: composite,
|
|
49
45
|
onClick: () => {
|
|
50
46
|
// Check if the block is registered (`getBlockType`
|
|
51
47
|
// will return an object). If so, insert the block.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_blocks","_data","_downloadableBlockListItem","_interopRequireDefault","_store","_lockUnlock","_jsxRuntime","CompositeV2","Composite","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_blocks","_data","_downloadableBlockListItem","_interopRequireDefault","_store","_lockUnlock","_jsxRuntime","CompositeV2","Composite","unlock","componentsPrivateApis","noop","DownloadableBlocksList","items","onHover","onSelect","installBlockType","useDispatch","blockDirectoryStore","length","jsx","role","className","__","children","map","item","default","onClick","getBlockType","name","then","success","id","_default","exports"],"sources":["@wordpress/block-directory/src/components/downloadable-blocks-list/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlockListItem from '../downloadable-block-list-item';\nimport { store as blockDirectoryStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { CompositeV2: Composite } = unlock( componentsPrivateApis );\nconst noop = () => {};\n\nfunction DownloadableBlocksList( { items, onHover = noop, onSelect } ) {\n\tconst { installBlockType } = useDispatch( blockDirectoryStore );\n\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Composite\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-directory-downloadable-blocks-list\"\n\t\t\taria-label={ __( 'Blocks available for install' ) }\n\t\t>\n\t\t\t{ items.map( ( item ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DownloadableBlockListItem\n\t\t\t\t\t\tkey={ item.id }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Check if the block is registered (`getBlockType`\n\t\t\t\t\t\t\t// will return an object). If so, insert the block.\n\t\t\t\t\t\t\t// This prevents installing existing plugins.\n\t\t\t\t\t\t\tif ( getBlockType( item.name ) ) {\n\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tinstallBlockType( item ).then( ( success ) => {\n\t\t\t\t\t\t\t\t\tif ( success ) {\n\t\t\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Composite>\n\t);\n}\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A,OAAO,EAAG;gBACdjB,QAAQ,CAAEW,IAAK,CAAC;cACjB;YACD,CAAE,CAAC;UACJ;UACAZ,OAAO,CAAE,IAAK,CAAC;QAChB,CAAG;QACHA,OAAO,EAAGA,OAAS;QACnBY,IAAI,EAAGA;MAAM,GAjBPA,IAAI,CAACO,EAkBX,CAAC;IAEJ,CAAE;EAAC,CACO,CAAC;AAEd;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAEcf,sBAAsB","ignoreList":[]}
|
|
@@ -91,7 +91,10 @@ const ModifiedWarning = ({
|
|
|
91
91
|
if (hasContent && hasHTMLBlock) {
|
|
92
92
|
messageHTML = (0, _i18n.sprintf)( /* translators: %s: block name */
|
|
93
93
|
(0, _i18n.__)('Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'), originalBlock.title || originalName);
|
|
94
|
-
actions.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
94
|
+
actions.push( /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
95
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
96
|
+
, {
|
|
97
|
+
__next40pxDefaultSize: false,
|
|
95
98
|
onClick: convertToHTML,
|
|
96
99
|
variant: "tertiary",
|
|
97
100
|
children: (0, _i18n.__)('Keep as HTML')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_blocks","_element","_data","_coreData","_blockEditor","_installButton","_interopRequireDefault","_store","_jsxRuntime","getInstallMissing","OriginalComponent","props","originalName","attributes","block","hasPermission","useSelect","select","getDownloadableBlocks","blockDirectoryStore","blocks","filter","name","coreStore","canUser","length","jsx","ModifiedWarning","originalBlock","originalUndelimitedContent","clientId","replaceBlock","useDispatch","blockEditorStore","convertToHTML","createBlock","content","hasContent","hasHTMLBlock","canInsertBlockType","getBlockRootClientId","messageHTML","sprintf","__","title","actions","default","push","Button","onClick","variant","children","jsxs","useBlockProps","Warning","RawHTML","_default","exports"],"sources":["@wordpress/block-directory/src/plugins/get-install-missing/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock } from '@wordpress/blocks';\nimport { RawHTML } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport InstallButton from './install-button';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst getInstallMissing = ( OriginalComponent ) => ( props ) => {\n\tconst { originalName } = props.attributes;\n\t// Disable reason: This is a valid component, but it's mistaken for a callback.\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst { block, hasPermission } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getDownloadableBlocks } = select( blockDirectoryStore );\n\t\t\tconst blocks = getDownloadableBlocks(\n\t\t\t\t'block:' + originalName\n\t\t\t).filter( ( { name } ) => originalName === name );\n\t\t\treturn {\n\t\t\t\thasPermission: select( coreStore ).canUser(\n\t\t\t\t\t'read',\n\t\t\t\t\t'block-directory/search'\n\t\t\t\t),\n\t\t\t\tblock: blocks.length && blocks[ 0 ],\n\t\t\t};\n\t\t},\n\t\t[ originalName ]\n\t);\n\n\t// The user can't install blocks, or the block isn't available for download.\n\tif ( ! hasPermission || ! block ) {\n\t\treturn <OriginalComponent { ...props } />;\n\t}\n\n\treturn <ModifiedWarning { ...props } originalBlock={ block } />;\n};\n\nconst ModifiedWarning = ( { originalBlock, ...props } ) => {\n\tconst { originalName, originalUndelimitedContent, clientId } =\n\t\tprops.attributes;\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\tconst convertToHTML = () => {\n\t\treplaceBlock(\n\t\t\tprops.clientId,\n\t\t\tcreateBlock( 'core/html', {\n\t\t\t\tcontent: originalUndelimitedContent,\n\t\t\t} )\n\t\t);\n\t};\n\n\tconst hasContent = !! originalUndelimitedContent;\n\tconst hasHTMLBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn canInsertBlockType(\n\t\t\t\t'core/html',\n\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tlet messageHTML = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__(\n\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'\n\t\t),\n\t\toriginalBlock.title || originalName\n\t);\n\tconst actions = [\n\t\t<InstallButton\n\t\t\tkey=\"install\"\n\t\t\tblock={ originalBlock }\n\t\t\tattributes={ props.attributes }\n\t\t\tclientId={ props.clientId }\n\t\t/>,\n\t];\n\n\tif ( hasContent && hasHTMLBlock ) {\n\t\tmessageHTML = sprintf(\n\t\t\t/* translators: %s: block name */\n\t\t\t__(\n\t\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'\n\t\t\t),\n\t\t\toriginalBlock.title || originalName\n\t\t);\n\t\tactions.push(\n\t\t\t<Button
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_blocks","_element","_data","_coreData","_blockEditor","_installButton","_interopRequireDefault","_store","_jsxRuntime","getInstallMissing","OriginalComponent","props","originalName","attributes","block","hasPermission","useSelect","select","getDownloadableBlocks","blockDirectoryStore","blocks","filter","name","coreStore","canUser","length","jsx","ModifiedWarning","originalBlock","originalUndelimitedContent","clientId","replaceBlock","useDispatch","blockEditorStore","convertToHTML","createBlock","content","hasContent","hasHTMLBlock","canInsertBlockType","getBlockRootClientId","messageHTML","sprintf","__","title","actions","default","push","Button","__next40pxDefaultSize","onClick","variant","children","jsxs","useBlockProps","Warning","RawHTML","_default","exports"],"sources":["@wordpress/block-directory/src/plugins/get-install-missing/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock } from '@wordpress/blocks';\nimport { RawHTML } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport InstallButton from './install-button';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst getInstallMissing = ( OriginalComponent ) => ( props ) => {\n\tconst { originalName } = props.attributes;\n\t// Disable reason: This is a valid component, but it's mistaken for a callback.\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst { block, hasPermission } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getDownloadableBlocks } = select( blockDirectoryStore );\n\t\t\tconst blocks = getDownloadableBlocks(\n\t\t\t\t'block:' + originalName\n\t\t\t).filter( ( { name } ) => originalName === name );\n\t\t\treturn {\n\t\t\t\thasPermission: select( coreStore ).canUser(\n\t\t\t\t\t'read',\n\t\t\t\t\t'block-directory/search'\n\t\t\t\t),\n\t\t\t\tblock: blocks.length && blocks[ 0 ],\n\t\t\t};\n\t\t},\n\t\t[ originalName ]\n\t);\n\n\t// The user can't install blocks, or the block isn't available for download.\n\tif ( ! hasPermission || ! block ) {\n\t\treturn <OriginalComponent { ...props } />;\n\t}\n\n\treturn <ModifiedWarning { ...props } originalBlock={ block } />;\n};\n\nconst ModifiedWarning = ( { originalBlock, ...props } ) => {\n\tconst { originalName, originalUndelimitedContent, clientId } =\n\t\tprops.attributes;\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\tconst convertToHTML = () => {\n\t\treplaceBlock(\n\t\t\tprops.clientId,\n\t\t\tcreateBlock( 'core/html', {\n\t\t\t\tcontent: originalUndelimitedContent,\n\t\t\t} )\n\t\t);\n\t};\n\n\tconst hasContent = !! originalUndelimitedContent;\n\tconst hasHTMLBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn canInsertBlockType(\n\t\t\t\t'core/html',\n\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tlet messageHTML = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__(\n\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'\n\t\t),\n\t\toriginalBlock.title || originalName\n\t);\n\tconst actions = [\n\t\t<InstallButton\n\t\t\tkey=\"install\"\n\t\t\tblock={ originalBlock }\n\t\t\tattributes={ props.attributes }\n\t\t\tclientId={ props.clientId }\n\t\t/>,\n\t];\n\n\tif ( hasContent && hasHTMLBlock ) {\n\t\tmessageHTML = sprintf(\n\t\t\t/* translators: %s: block name */\n\t\t\t__(\n\t\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'\n\t\t\t),\n\t\t\toriginalBlock.title || originalName\n\t\t);\n\t\tactions.push(\n\t\t\t<Button\n\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\tkey=\"convert\"\n\t\t\t\tonClick={ convertToHTML }\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t>\n\t\t\t\t{ __( 'Keep as HTML' ) }\n\t\t\t</Button>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div { ...useBlockProps() }>\n\t\t\t<Warning actions={ actions }>{ messageHTML }</Warning>\n\t\t\t<RawHTML>{ originalUndelimitedContent }</RawHTML>\n\t\t</div>\n\t);\n};\n\nexport default getInstallMissing;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,KAAA,GAAAJ,OAAA;AACA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AGhB,aAAe;MACzBiB,OAAO,EAAC,UAAU;MAAAC,QAAA,EAEhB,IAAAT,QAAE,EAAE,cAAe;IAAC,GAJlB,SAKG,CACT,CAAC;EACF;EAEA,oBACC,IAAAnC,WAAA,CAAA6C,IAAA;IAAA,GAAU,IAAAC,0BAAa,EAAC,CAAC;IAAAF,QAAA,gBACxB,IAAA5C,WAAA,CAAAkB,GAAA,EAACtB,YAAA,CAAAmD,OAAO;MAACV,OAAO,EAAGA,OAAS;MAAAO,QAAA,EAAGX;IAAW,CAAW,CAAC,eACtD,IAAAjC,WAAA,CAAAkB,GAAA,EAACzB,QAAA,CAAAuD,OAAO;MAAAJ,QAAA,EAAGvB;IAA0B,CAAW,CAAC;EAAA,CAC7C,CAAC;AAER,CAAC;AAAC,IAAA4B,QAAA,GAAAC,OAAA,CAAAZ,OAAA,GAEarC,iBAAiB","ignoreList":[]}
|
|
@@ -31,7 +31,10 @@ function InstallButton({
|
|
|
31
31
|
const {
|
|
32
32
|
replaceBlock
|
|
33
33
|
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
34
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
34
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
35
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
36
|
+
, {
|
|
37
|
+
__next40pxDefaultSize: false,
|
|
35
38
|
onClick: () => installBlockType(block).then(success => {
|
|
36
39
|
if (success) {
|
|
37
40
|
const blockType = (0, _blocks.getBlockType)(block.name);
|
|
@@ -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","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;AACA;AACA;;AAGe,SAASO,aAAaA,CAAE;EAAEC,UAAU;EAAEC,KAAK;EAAEC;AAAS,CAAC,EAAG;EACxE,MAAMC,iBAAiB,GAAG,IAAAC,eAAS,EAChCC,MAAM,IAAMA,MAAM,CAAEC,YAAoB,CAAC,CAACC,YAAY,CAAEN,KAAK,CAACO,EAAG,CAAC,EACpE,CAAEP,KAAK,CAACO,EAAE,CACX,CAAC;EACD,MAAM;IAAEC;EAAiB,CAAC,GAAG,IAAAC,iBAAW,EAAEJ,YAAoB,CAAC;EAC/D,MAAM;IAAEK;EAAa,CAAC,GAAG,IAAAD,iBAAW,EAAEE,kBAAiB,CAAC;EAExD,oBACC,IAAAd,WAAA,CAAAe,GAAA,EAACpB,WAAA,CAAAqB,
|
|
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","__next40pxDefaultSize","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\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t__next40pxDefaultSize={ false }\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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AAS;IAAAC,QAAA,EAEf,IAAAC,aAAO,GACR;IACA,IAAAC,QAAE,EAAE,YAAa,CAAC,EAClBhC,KAAK,CAACiC,KACP;EAAC,CACM,CAAC;AAEX","ignoreList":[]}
|
|
@@ -56,7 +56,6 @@ function getDownloadableBlockLabel({
|
|
|
56
56
|
_n('Install %1$s. %2$s stars with %3$s review.', 'Install %1$s. %2$s stars with %3$s reviews.', ratingCount), decodeEntities(title), stars, ratingCount);
|
|
57
57
|
}
|
|
58
58
|
function DownloadableBlockListItem({
|
|
59
|
-
composite,
|
|
60
59
|
item,
|
|
61
60
|
onClick
|
|
62
61
|
}) {
|
|
@@ -93,7 +92,10 @@ function DownloadableBlockListItem({
|
|
|
93
92
|
statusText = __('Installing…');
|
|
94
93
|
}
|
|
95
94
|
return /*#__PURE__*/_jsxs(CompositeItem, {
|
|
96
|
-
render: /*#__PURE__*/_jsx(Button
|
|
95
|
+
render: /*#__PURE__*/_jsx(Button
|
|
96
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
97
|
+
, {
|
|
98
|
+
__next40pxDefaultSize: false,
|
|
97
99
|
accessibleWhenDisabled: true,
|
|
98
100
|
type: "button",
|
|
99
101
|
role: "option",
|
|
@@ -111,7 +113,6 @@ function DownloadableBlockListItem({
|
|
|
111
113
|
showTooltip: true,
|
|
112
114
|
tooltipPosition: "top center"
|
|
113
115
|
}),
|
|
114
|
-
store: composite,
|
|
115
116
|
disabled: isInstalling || !isInstallable,
|
|
116
117
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
117
118
|
className: "block-directory-downloadable-block-list-item__icon",
|
|
@@ -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","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\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A;QAAMsC,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
|
+
{"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","item","onClick","author","description","icon","name","isInstallable","select","getErrorNoticeForBlock","isBlockInstalling","notice","id","hasFatal","isFatal","statusText","render","__next40pxDefaultSize","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( { 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// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t\t__next40pxDefaultSize={ false }\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\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 Download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,EAAC;UAAsD,CAAE;QAE1E,CACD;MAAC,CACI,CAAC,EACL3B,SAAS,gBACVX,IAAA,CAACL,uBAAuB;QAACqD,KAAK,EAAG9B;MAAM,CAAE,CAAC,gBAE1ChB,KAAA,CAAAE,SAAA;QAAA0C,QAAA,gBACC9C,IAAA;UAAMsC,SAAS,EAAC,oDAAoD;UAAAQ,QAAA,EACjE,CAAC,CAAEd,UAAU,GACZA,UAAU,GACV1C,cAAc,CAAE+B,WAAY;QAAC,CAC3B,CAAC,EACLG,aAAa,IACd,EAAIZ,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":[]}
|
|
@@ -14,8 +14,7 @@ import { store as blockDirectoryStore } from '../../store';
|
|
|
14
14
|
import { unlock } from '../../lock-unlock';
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
16
|
const {
|
|
17
|
-
CompositeV2: Composite
|
|
18
|
-
useCompositeStoreV2: useCompositeStore
|
|
17
|
+
CompositeV2: Composite
|
|
19
18
|
} = unlock(componentsPrivateApis);
|
|
20
19
|
const noop = () => {};
|
|
21
20
|
function DownloadableBlocksList({
|
|
@@ -23,7 +22,6 @@ function DownloadableBlocksList({
|
|
|
23
22
|
onHover = noop,
|
|
24
23
|
onSelect
|
|
25
24
|
}) {
|
|
26
|
-
const composite = useCompositeStore();
|
|
27
25
|
const {
|
|
28
26
|
installBlockType
|
|
29
27
|
} = useDispatch(blockDirectoryStore);
|
|
@@ -31,13 +29,11 @@ function DownloadableBlocksList({
|
|
|
31
29
|
return null;
|
|
32
30
|
}
|
|
33
31
|
return /*#__PURE__*/_jsx(Composite, {
|
|
34
|
-
store: composite,
|
|
35
32
|
role: "listbox",
|
|
36
33
|
className: "block-directory-downloadable-blocks-list",
|
|
37
34
|
"aria-label": __('Blocks available for install'),
|
|
38
35
|
children: items.map(item => {
|
|
39
36
|
return /*#__PURE__*/_jsx(DownloadableBlockListItem, {
|
|
40
|
-
composite: composite,
|
|
41
37
|
onClick: () => {
|
|
42
38
|
// Check if the block is registered (`getBlockType`
|
|
43
39
|
// will return an object). If so, insert the block.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","privateApis","componentsPrivateApis","getBlockType","useDispatch","DownloadableBlockListItem","store","blockDirectoryStore","unlock","jsx","_jsx","CompositeV2","Composite","
|
|
1
|
+
{"version":3,"names":["__","privateApis","componentsPrivateApis","getBlockType","useDispatch","DownloadableBlockListItem","store","blockDirectoryStore","unlock","jsx","_jsx","CompositeV2","Composite","noop","DownloadableBlocksList","items","onHover","onSelect","installBlockType","length","role","className","children","map","item","onClick","name","then","success","id"],"sources":["@wordpress/block-directory/src/components/downloadable-blocks-list/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { privateApis as componentsPrivateApis } from '@wordpress/components';\nimport { getBlockType } from '@wordpress/blocks';\nimport { useDispatch } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlockListItem from '../downloadable-block-list-item';\nimport { store as blockDirectoryStore } from '../../store';\nimport { unlock } from '../../lock-unlock';\n\nconst { CompositeV2: Composite } = unlock( componentsPrivateApis );\nconst noop = () => {};\n\nfunction DownloadableBlocksList( { items, onHover = noop, onSelect } ) {\n\tconst { installBlockType } = useDispatch( blockDirectoryStore );\n\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<Composite\n\t\t\trole=\"listbox\"\n\t\t\tclassName=\"block-directory-downloadable-blocks-list\"\n\t\t\taria-label={ __( 'Blocks available for install' ) }\n\t\t>\n\t\t\t{ items.map( ( item ) => {\n\t\t\t\treturn (\n\t\t\t\t\t<DownloadableBlockListItem\n\t\t\t\t\t\tkey={ item.id }\n\t\t\t\t\t\tonClick={ () => {\n\t\t\t\t\t\t\t// Check if the block is registered (`getBlockType`\n\t\t\t\t\t\t\t// will return an object). If so, insert the block.\n\t\t\t\t\t\t\t// This prevents installing existing plugins.\n\t\t\t\t\t\t\tif ( getBlockType( item.name ) ) {\n\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\tinstallBlockType( item ).then( ( success ) => {\n\t\t\t\t\t\t\t\t\tif ( success ) {\n\t\t\t\t\t\t\t\t\t\tonSelect( item );\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t} );\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tonHover( null );\n\t\t\t\t\t\t} }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\titem={ item }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} ) }\n\t\t</Composite>\n\t);\n}\n\nexport default DownloadableBlocksList;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,WAAW,IAAIC,qBAAqB,QAAQ,uBAAuB;AAC5E,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,yBAAyB,MAAM,iCAAiC;AACvE,SAASC,KAAK,IAAIC,mBAAmB,QAAQ,aAAa;AAC1D,SAASC,MAAM,QAAQ,mBAAmB;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3C,MAAM;EAAEC,WAAW,EAAEC;AAAU,CAAC,GAAGJ,MAAM,CAAEN,qBAAsB,CAAC;AAClE,MAAMW,IAAI,GAAGA,CAAA,KAAM,CAAC,CAAC;AAErB,SAASC,sBAAsBA,CAAE;EAAEC,KAAK;EAAEC,OAAO,GAAGH,IAAI;EAAEI;AAAS,CAAC,EAAG;EACtE,MAAM;IAAEC;EAAiB,CAAC,GAAGd,WAAW,CAAEG,mBAAoB,CAAC;EAE/D,IAAK,CAAEQ,KAAK,CAACI,MAAM,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,oBACCT,IAAA,CAACE,SAAS;IACTQ,IAAI,EAAC,SAAS;IACdC,SAAS,EAAC,0CAA0C;IACpD,cAAarB,EAAE,CAAE,8BAA+B,CAAG;IAAAsB,QAAA,EAEjDP,KAAK,CAACQ,GAAG,CAAIC,IAAI,IAAM;MACxB,oBACCd,IAAA,CAACL,yBAAyB;QAEzBoB,OAAO,EAAGA,CAAA,KAAM;UACf;UACA;UACA;UACA,IAAKtB,YAAY,CAAEqB,IAAI,CAACE,IAAK,CAAC,EAAG;YAChCT,QAAQ,CAAEO,IAAK,CAAC;UACjB,CAAC,MAAM;YACNN,gBAAgB,CAAEM,IAAK,CAAC,CAACG,IAAI,CAAIC,OAAO,IAAM;cAC7C,IAAKA,OAAO,EAAG;gBACdX,QAAQ,CAAEO,IAAK,CAAC;cACjB;YACD,CAAE,CAAC;UACJ;UACAR,OAAO,CAAE,IAAK,CAAC;QAChB,CAAG;QACHA,OAAO,EAAGA,OAAS;QACnBQ,IAAI,EAAGA;MAAM,GAjBPA,IAAI,CAACK,EAkBX,CAAC;IAEJ,CAAE;EAAC,CACO,CAAC;AAEd;AAEA,eAAef,sBAAsB","ignoreList":[]}
|
|
@@ -84,7 +84,10 @@ const ModifiedWarning = ({
|
|
|
84
84
|
if (hasContent && hasHTMLBlock) {
|
|
85
85
|
messageHTML = sprintf( /* translators: %s: block name */
|
|
86
86
|
__('Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'), originalBlock.title || originalName);
|
|
87
|
-
actions.push( /*#__PURE__*/_jsx(Button
|
|
87
|
+
actions.push( /*#__PURE__*/_jsx(Button
|
|
88
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
89
|
+
, {
|
|
90
|
+
__next40pxDefaultSize: false,
|
|
88
91
|
onClick: convertToHTML,
|
|
89
92
|
variant: "tertiary",
|
|
90
93
|
children: __('Keep as HTML')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","sprintf","Button","createBlock","RawHTML","useDispatch","useSelect","store","coreStore","Warning","useBlockProps","blockEditorStore","InstallButton","blockDirectoryStore","jsx","_jsx","jsxs","_jsxs","getInstallMissing","OriginalComponent","props","originalName","attributes","block","hasPermission","select","getDownloadableBlocks","blocks","filter","name","canUser","length","ModifiedWarning","originalBlock","originalUndelimitedContent","clientId","replaceBlock","convertToHTML","content","hasContent","hasHTMLBlock","canInsertBlockType","getBlockRootClientId","messageHTML","title","actions","push","onClick","variant","children"],"sources":["@wordpress/block-directory/src/plugins/get-install-missing/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock } from '@wordpress/blocks';\nimport { RawHTML } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport InstallButton from './install-button';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst getInstallMissing = ( OriginalComponent ) => ( props ) => {\n\tconst { originalName } = props.attributes;\n\t// Disable reason: This is a valid component, but it's mistaken for a callback.\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst { block, hasPermission } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getDownloadableBlocks } = select( blockDirectoryStore );\n\t\t\tconst blocks = getDownloadableBlocks(\n\t\t\t\t'block:' + originalName\n\t\t\t).filter( ( { name } ) => originalName === name );\n\t\t\treturn {\n\t\t\t\thasPermission: select( coreStore ).canUser(\n\t\t\t\t\t'read',\n\t\t\t\t\t'block-directory/search'\n\t\t\t\t),\n\t\t\t\tblock: blocks.length && blocks[ 0 ],\n\t\t\t};\n\t\t},\n\t\t[ originalName ]\n\t);\n\n\t// The user can't install blocks, or the block isn't available for download.\n\tif ( ! hasPermission || ! block ) {\n\t\treturn <OriginalComponent { ...props } />;\n\t}\n\n\treturn <ModifiedWarning { ...props } originalBlock={ block } />;\n};\n\nconst ModifiedWarning = ( { originalBlock, ...props } ) => {\n\tconst { originalName, originalUndelimitedContent, clientId } =\n\t\tprops.attributes;\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\tconst convertToHTML = () => {\n\t\treplaceBlock(\n\t\t\tprops.clientId,\n\t\t\tcreateBlock( 'core/html', {\n\t\t\t\tcontent: originalUndelimitedContent,\n\t\t\t} )\n\t\t);\n\t};\n\n\tconst hasContent = !! originalUndelimitedContent;\n\tconst hasHTMLBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn canInsertBlockType(\n\t\t\t\t'core/html',\n\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tlet messageHTML = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__(\n\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'\n\t\t),\n\t\toriginalBlock.title || originalName\n\t);\n\tconst actions = [\n\t\t<InstallButton\n\t\t\tkey=\"install\"\n\t\t\tblock={ originalBlock }\n\t\t\tattributes={ props.attributes }\n\t\t\tclientId={ props.clientId }\n\t\t/>,\n\t];\n\n\tif ( hasContent && hasHTMLBlock ) {\n\t\tmessageHTML = sprintf(\n\t\t\t/* translators: %s: block name */\n\t\t\t__(\n\t\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'\n\t\t\t),\n\t\t\toriginalBlock.title || originalName\n\t\t);\n\t\tactions.push(\n\t\t\t<Button
|
|
1
|
+
{"version":3,"names":["__","sprintf","Button","createBlock","RawHTML","useDispatch","useSelect","store","coreStore","Warning","useBlockProps","blockEditorStore","InstallButton","blockDirectoryStore","jsx","_jsx","jsxs","_jsxs","getInstallMissing","OriginalComponent","props","originalName","attributes","block","hasPermission","select","getDownloadableBlocks","blocks","filter","name","canUser","length","ModifiedWarning","originalBlock","originalUndelimitedContent","clientId","replaceBlock","convertToHTML","content","hasContent","hasHTMLBlock","canInsertBlockType","getBlockRootClientId","messageHTML","title","actions","push","__next40pxDefaultSize","onClick","variant","children"],"sources":["@wordpress/block-directory/src/plugins/get-install-missing/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Button } from '@wordpress/components';\nimport { createBlock } from '@wordpress/blocks';\nimport { RawHTML } from '@wordpress/element';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { store as coreStore } from '@wordpress/core-data';\nimport {\n\tWarning,\n\tuseBlockProps,\n\tstore as blockEditorStore,\n} from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport InstallButton from './install-button';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst getInstallMissing = ( OriginalComponent ) => ( props ) => {\n\tconst { originalName } = props.attributes;\n\t// Disable reason: This is a valid component, but it's mistaken for a callback.\n\t// eslint-disable-next-line react-hooks/rules-of-hooks\n\tconst { block, hasPermission } = useSelect(\n\t\t( select ) => {\n\t\t\tconst { getDownloadableBlocks } = select( blockDirectoryStore );\n\t\t\tconst blocks = getDownloadableBlocks(\n\t\t\t\t'block:' + originalName\n\t\t\t).filter( ( { name } ) => originalName === name );\n\t\t\treturn {\n\t\t\t\thasPermission: select( coreStore ).canUser(\n\t\t\t\t\t'read',\n\t\t\t\t\t'block-directory/search'\n\t\t\t\t),\n\t\t\t\tblock: blocks.length && blocks[ 0 ],\n\t\t\t};\n\t\t},\n\t\t[ originalName ]\n\t);\n\n\t// The user can't install blocks, or the block isn't available for download.\n\tif ( ! hasPermission || ! block ) {\n\t\treturn <OriginalComponent { ...props } />;\n\t}\n\n\treturn <ModifiedWarning { ...props } originalBlock={ block } />;\n};\n\nconst ModifiedWarning = ( { originalBlock, ...props } ) => {\n\tconst { originalName, originalUndelimitedContent, clientId } =\n\t\tprops.attributes;\n\tconst { replaceBlock } = useDispatch( blockEditorStore );\n\tconst convertToHTML = () => {\n\t\treplaceBlock(\n\t\t\tprops.clientId,\n\t\t\tcreateBlock( 'core/html', {\n\t\t\t\tcontent: originalUndelimitedContent,\n\t\t\t} )\n\t\t);\n\t};\n\n\tconst hasContent = !! originalUndelimitedContent;\n\tconst hasHTMLBlock = useSelect(\n\t\t( select ) => {\n\t\t\tconst { canInsertBlockType, getBlockRootClientId } =\n\t\t\t\tselect( blockEditorStore );\n\n\t\t\treturn canInsertBlockType(\n\t\t\t\t'core/html',\n\t\t\t\tgetBlockRootClientId( clientId )\n\t\t\t);\n\t\t},\n\t\t[ clientId ]\n\t);\n\n\tlet messageHTML = sprintf(\n\t\t/* translators: %s: block name */\n\t\t__(\n\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'\n\t\t),\n\t\toriginalBlock.title || originalName\n\t);\n\tconst actions = [\n\t\t<InstallButton\n\t\t\tkey=\"install\"\n\t\t\tblock={ originalBlock }\n\t\t\tattributes={ props.attributes }\n\t\t\tclientId={ props.clientId }\n\t\t/>,\n\t];\n\n\tif ( hasContent && hasHTMLBlock ) {\n\t\tmessageHTML = sprintf(\n\t\t\t/* translators: %s: block name */\n\t\t\t__(\n\t\t\t\t'Your site doesn’t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely.'\n\t\t\t),\n\t\t\toriginalBlock.title || originalName\n\t\t);\n\t\tactions.push(\n\t\t\t<Button\n\t\t\t\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t\t__next40pxDefaultSize={ false }\n\t\t\t\tkey=\"convert\"\n\t\t\t\tonClick={ convertToHTML }\n\t\t\t\tvariant=\"tertiary\"\n\t\t\t>\n\t\t\t\t{ __( 'Keep as HTML' ) }\n\t\t\t</Button>\n\t\t);\n\t}\n\n\treturn (\n\t\t<div { ...useBlockProps() }>\n\t\t\t<Warning actions={ actions }>{ messageHTML }</Warning>\n\t\t\t<RawHTML>{ originalUndelimitedContent }</RawHTML>\n\t\t</div>\n\t);\n};\n\nexport default getInstallMissing;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,WAAW,QAAQ,mBAAmB;AAC/C,SAASC,OAAO,QAAQ,oBAAoB;AAC5C,SAASC,WAAW,EAAEC,SAAS,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SACCC,OAAO,EACPC,aAAa,EACbH,KAAK,IAAII,gBAAgB,QACnB,yBAAyB;;AAEhC;AACA;AACA;AACA,OAAOC,aAAa,MAAM,kBAAkB;AAC5C,SAASL,KAAK,IAAIM,mBAAmB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAE3D,MAAMC,iBAAiB,GAAKC,iBAAiB,IAAQC,KAAK,IAAM;EAC/D,MAAM;IAAEC;EAAa,CAAC,GAAGD,KAAK,CAACE,UAAU;EACzC;EACA;EACA,MAAM;IAAEC,KAAK;IAAEC;EAAc,CAAC,GAAGlB,SAAS,CACvCmB,MAAM,IAAM;IACb,MAAM;MAAEC;IAAsB,CAAC,GAAGD,MAAM,CAAEZ,mBAAoB,CAAC;IAC/D,MAAMc,MAAM,GAAGD,qBAAqB,CACnC,QAAQ,GAAGL,YACZ,CAAC,CAACO,MAAM,CAAE,CAAE;MAAEC;IAAK,CAAC,KAAMR,YAAY,KAAKQ,IAAK,CAAC;IACjD,OAAO;MACNL,aAAa,EAAEC,MAAM,CAAEjB,SAAU,CAAC,CAACsB,OAAO,CACzC,MAAM,EACN,wBACD,CAAC;MACDP,KAAK,EAAEI,MAAM,CAACI,MAAM,IAAIJ,MAAM,CAAE,CAAC;IAClC,CAAC;EACF,CAAC,EACD,CAAE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AIJ,CAAC,CACF;EAED,IAAKI,UAAU,IAAIC,YAAY,EAAG;IACjCG,WAAW,GAAG1C,OAAO,EACpB;IACAD,EAAE,CACD,iJACD,CAAC,EACDiC,aAAa,CAACW,KAAK,IAAIvB,YACxB,CAAC;IACDwB,OAAO,CAACC,IAAI,eACX/B,IAAA,CAACb;IACA;IAAA;MACA6C,qBAAqB,EAAG,KAAO;MAE/BC,OAAO,EAAGX,aAAe;MACzBY,OAAO,EAAC,UAAU;MAAAC,QAAA,EAEhBlD,EAAE,CAAE,cAAe;IAAC,GAJlB,SAKG,CACT,CAAC;EACF;EAEA,oBACCiB,KAAA;IAAA,GAAUP,aAAa,CAAC,CAAC;IAAAwC,QAAA,gBACxBnC,IAAA,CAACN,OAAO;MAACoC,OAAO,EAAGA,OAAS;MAAAK,QAAA,EAAGP;IAAW,CAAW,CAAC,eACtD5B,IAAA,CAACX,OAAO;MAAA8C,QAAA,EAAGhB;IAA0B,CAAW,CAAC;EAAA,CAC7C,CAAC;AAER,CAAC;AAED,eAAehB,iBAAiB","ignoreList":[]}
|
|
@@ -24,7 +24,10 @@ export default function InstallButton({
|
|
|
24
24
|
const {
|
|
25
25
|
replaceBlock
|
|
26
26
|
} = useDispatch(blockEditorStore);
|
|
27
|
-
return /*#__PURE__*/_jsx(Button
|
|
27
|
+
return /*#__PURE__*/_jsx(Button
|
|
28
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
29
|
+
, {
|
|
30
|
+
__next40pxDefaultSize: false,
|
|
28
31
|
onClick: () => installBlockType(block).then(success => {
|
|
29
32
|
if (success) {
|
|
30
33
|
const blockType = getBlockType(block.name);
|
|
@@ -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","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;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,MAAM,QAAQ,uBAAuB;AAC9C,SAASC,WAAW,EAAEC,YAAY,EAAEC,KAAK,QAAQ,mBAAmB;AACpE,SAASC,SAAS,EAAEC,WAAW,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;;AAEnE;AACA;AACA;AACA,SAASD,KAAK,IAAIE,mBAAmB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3D,eAAe,SAASC,aAAaA,CAAE;EAAEC,UAAU;EAAEC,KAAK;EAAEC;AAAS,CAAC,EAAG;EACxE,MAAMC,iBAAiB,GAAGX,SAAS,CAChCY,MAAM,IAAMA,MAAM,CAAER,mBAAoB,CAAC,CAACS,YAAY,CAAEJ,KAAK,CAACK,EAAG,CAAC,EACpE,CAAEL,KAAK,CAACK,EAAE,CACX,CAAC;EACD,MAAM;IAAEC;EAAiB,CAAC,GAAGd,WAAW,CAAEG,mBAAoB,CAAC;EAC/D,MAAM;IAAEY;EAAa,CAAC,GAAGf,WAAW,CAAEE,gBAAiB,CAAC;EAExD,oBACCG,IAAA,CAACV,
|
|
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","__next40pxDefaultSize","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\t// TODO: Switch to `true` (40px size) if possible\n\t\t\t__next40pxDefaultSize={ false }\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;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,MAAM,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AGjB,iBAAmB;IAC5BkB,OAAO,EAAC,SAAS;IAAAC,QAAA,EAEfnC,OAAO,EACR;IACAD,EAAE,CAAE,YAAa,CAAC,EAClBe,KAAK,CAACsB,KACP;EAAC,CACM,CAAC;AAEX","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.7.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,24 +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": "^14.
|
|
33
|
-
"@wordpress/blocks": "^13.
|
|
34
|
-
"@wordpress/components": "^28.
|
|
35
|
-
"@wordpress/compose": "^7.
|
|
36
|
-
"@wordpress/core-data": "^7.
|
|
37
|
-
"@wordpress/data": "^10.
|
|
38
|
-
"@wordpress/editor": "^14.
|
|
39
|
-
"@wordpress/element": "^6.
|
|
40
|
-
"@wordpress/hooks": "^4.
|
|
41
|
-
"@wordpress/html-entities": "^4.
|
|
42
|
-
"@wordpress/i18n": "^5.
|
|
43
|
-
"@wordpress/icons": "^10.
|
|
44
|
-
"@wordpress/notices": "^5.
|
|
45
|
-
"@wordpress/plugins": "^7.
|
|
46
|
-
"@wordpress/private-apis": "^1.
|
|
47
|
-
"@wordpress/url": "^4.
|
|
30
|
+
"@wordpress/a11y": "^4.7.0",
|
|
31
|
+
"@wordpress/api-fetch": "^7.7.0",
|
|
32
|
+
"@wordpress/block-editor": "^14.2.0",
|
|
33
|
+
"@wordpress/blocks": "^13.7.0",
|
|
34
|
+
"@wordpress/components": "^28.7.0",
|
|
35
|
+
"@wordpress/compose": "^7.7.0",
|
|
36
|
+
"@wordpress/core-data": "^7.7.0",
|
|
37
|
+
"@wordpress/data": "^10.7.0",
|
|
38
|
+
"@wordpress/editor": "^14.7.0",
|
|
39
|
+
"@wordpress/element": "^6.7.0",
|
|
40
|
+
"@wordpress/hooks": "^4.7.0",
|
|
41
|
+
"@wordpress/html-entities": "^4.7.0",
|
|
42
|
+
"@wordpress/i18n": "^5.7.0",
|
|
43
|
+
"@wordpress/icons": "^10.7.0",
|
|
44
|
+
"@wordpress/notices": "^5.7.0",
|
|
45
|
+
"@wordpress/plugins": "^7.7.0",
|
|
46
|
+
"@wordpress/private-apis": "^1.7.0",
|
|
47
|
+
"@wordpress/url": "^4.7.0",
|
|
48
48
|
"change-case": "^4.1.2"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "c90d920de07c53dff82c5914635b56fafa503b7f"
|
|
58
58
|
}
|
|
@@ -65,7 +65,7 @@ function getDownloadableBlockLabel(
|
|
|
65
65
|
);
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
function DownloadableBlockListItem( {
|
|
68
|
+
function DownloadableBlockListItem( { item, onClick } ) {
|
|
69
69
|
const { author, description, icon, rating, title } = item;
|
|
70
70
|
// getBlockType returns a block object if this block exists, or null if not.
|
|
71
71
|
const isInstalled = !! getBlockType( item.name );
|
|
@@ -96,6 +96,8 @@ function DownloadableBlockListItem( { composite, item, onClick } ) {
|
|
|
96
96
|
<CompositeItem
|
|
97
97
|
render={
|
|
98
98
|
<Button
|
|
99
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
100
|
+
__next40pxDefaultSize={ false }
|
|
99
101
|
accessibleWhenDisabled
|
|
100
102
|
type="button"
|
|
101
103
|
role="option"
|
|
@@ -114,7 +116,6 @@ function DownloadableBlockListItem( { composite, item, onClick } ) {
|
|
|
114
116
|
tooltipPosition="top center"
|
|
115
117
|
/>
|
|
116
118
|
}
|
|
117
|
-
store={ composite }
|
|
118
119
|
disabled={ isInstalling || ! isInstallable }
|
|
119
120
|
>
|
|
120
121
|
<div className="block-directory-downloadable-block-list-item__icon">
|
|
@@ -13,12 +13,10 @@ import DownloadableBlockListItem from '../downloadable-block-list-item';
|
|
|
13
13
|
import { store as blockDirectoryStore } from '../../store';
|
|
14
14
|
import { unlock } from '../../lock-unlock';
|
|
15
15
|
|
|
16
|
-
const { CompositeV2: Composite
|
|
17
|
-
unlock( componentsPrivateApis );
|
|
16
|
+
const { CompositeV2: Composite } = unlock( componentsPrivateApis );
|
|
18
17
|
const noop = () => {};
|
|
19
18
|
|
|
20
19
|
function DownloadableBlocksList( { items, onHover = noop, onSelect } ) {
|
|
21
|
-
const composite = useCompositeStore();
|
|
22
20
|
const { installBlockType } = useDispatch( blockDirectoryStore );
|
|
23
21
|
|
|
24
22
|
if ( ! items.length ) {
|
|
@@ -27,7 +25,6 @@ function DownloadableBlocksList( { items, onHover = noop, onSelect } ) {
|
|
|
27
25
|
|
|
28
26
|
return (
|
|
29
27
|
<Composite
|
|
30
|
-
store={ composite }
|
|
31
28
|
role="listbox"
|
|
32
29
|
className="block-directory-downloadable-blocks-list"
|
|
33
30
|
aria-label={ __( 'Blocks available for install' ) }
|
|
@@ -36,7 +33,6 @@ function DownloadableBlocksList( { items, onHover = noop, onSelect } ) {
|
|
|
36
33
|
return (
|
|
37
34
|
<DownloadableBlockListItem
|
|
38
35
|
key={ item.id }
|
|
39
|
-
composite={ composite }
|
|
40
36
|
onClick={ () => {
|
|
41
37
|
// Check if the block is registered (`getBlockType`
|
|
42
38
|
// will return an object). If so, insert the block.
|
|
@@ -100,7 +100,13 @@ const ModifiedWarning = ( { originalBlock, ...props } ) => {
|
|
|
100
100
|
originalBlock.title || originalName
|
|
101
101
|
);
|
|
102
102
|
actions.push(
|
|
103
|
-
<Button
|
|
103
|
+
<Button
|
|
104
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
105
|
+
__next40pxDefaultSize={ false }
|
|
106
|
+
key="convert"
|
|
107
|
+
onClick={ convertToHTML }
|
|
108
|
+
variant="tertiary"
|
|
109
|
+
>
|
|
104
110
|
{ __( 'Keep as HTML' ) }
|
|
105
111
|
</Button>
|
|
106
112
|
);
|
|
@@ -22,6 +22,8 @@ export default function InstallButton( { attributes, block, clientId } ) {
|
|
|
22
22
|
|
|
23
23
|
return (
|
|
24
24
|
<Button
|
|
25
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
26
|
+
__next40pxDefaultSize={ false }
|
|
25
27
|
onClick={ () =>
|
|
26
28
|
installBlockType( block ).then( ( success ) => {
|
|
27
29
|
if ( success ) {
|