@wordpress/block-directory 5.6.0 → 5.7.1-next.5368f64a9.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 +2 -0
- package/build/components/downloadable-block-list-item/index.js +5 -9
- package/build/components/downloadable-block-list-item/index.js.map +1 -1
- package/build/components/downloadable-blocks-list/index.js +1 -9
- 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 +8 -11
- package/build-module/components/downloadable-block-list-item/index.js.map +1 -1
- package/build-module/components/downloadable-blocks-list/index.js +1 -9
- 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/package.json +20 -20
- package/src/components/downloadable-block-list-item/index.js +6 -8
- package/src/components/downloadable-blocks-list/index.js +1 -7
- 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
|
@@ -15,7 +15,6 @@ var _blockRatings = _interopRequireDefault(require("../block-ratings"));
|
|
|
15
15
|
var _downloadableBlockIcon = _interopRequireDefault(require("../downloadable-block-icon"));
|
|
16
16
|
var _downloadableBlockNotice = _interopRequireDefault(require("../downloadable-block-notice"));
|
|
17
17
|
var _store = require("../../store");
|
|
18
|
-
var _lockUnlock = require("../../lock-unlock");
|
|
19
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
19
|
/**
|
|
21
20
|
* WordPress dependencies
|
|
@@ -25,10 +24,6 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
25
24
|
* Internal dependencies
|
|
26
25
|
*/
|
|
27
26
|
|
|
28
|
-
const {
|
|
29
|
-
CompositeItemV2: CompositeItem
|
|
30
|
-
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
31
|
-
|
|
32
27
|
// Return the appropriate block item label, given the block data and status.
|
|
33
28
|
function getDownloadableBlockLabel({
|
|
34
29
|
title,
|
|
@@ -62,7 +57,6 @@ function getDownloadableBlockLabel({
|
|
|
62
57
|
(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
58
|
}
|
|
64
59
|
function DownloadableBlockListItem({
|
|
65
|
-
composite,
|
|
66
60
|
item,
|
|
67
61
|
onClick
|
|
68
62
|
}) {
|
|
@@ -98,8 +92,11 @@ function DownloadableBlockListItem({
|
|
|
98
92
|
} else if (isInstalling) {
|
|
99
93
|
statusText = (0, _i18n.__)('Installing…');
|
|
100
94
|
}
|
|
101
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(
|
|
102
|
-
render: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
95
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_components.Composite.Item, {
|
|
96
|
+
render: /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button
|
|
97
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
98
|
+
, {
|
|
99
|
+
__next40pxDefaultSize: false,
|
|
103
100
|
accessibleWhenDisabled: true,
|
|
104
101
|
type: "button",
|
|
105
102
|
role: "option",
|
|
@@ -117,7 +114,6 @@ function DownloadableBlockListItem({
|
|
|
117
114
|
showTooltip: true,
|
|
118
115
|
tooltipPosition: "top center"
|
|
119
116
|
}),
|
|
120
|
-
store: composite,
|
|
121
117
|
disabled: isInstalling || !isInstallable,
|
|
122
118
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
123
119
|
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,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;A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AAY,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","_jsxRuntime","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","Composite","Item","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\tComposite,\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';\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<Composite.Item\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</Composite.Item>\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;AAA2D,IAAAW,WAAA,GAAAX,OAAA;AArB3D;AACA;AACA;;AAaA;AACA;AACA;;AAMA;AACA,SAASY,yBAAyBA,CACjC;EAAEC,KAAK;EAAEC,MAAM;EAAEC;AAAY,CAAC,EAC9B;EAAE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EACLI,aAAa,IACd,EAAIhB,WAAW,IAAIC,YAAY,CAAE,iBAChC,IAAAP,WAAA,CAAAsC,GAAA,EAAChD,WAAA,CAAAqE,cAAc;UAAAP,QAAA,EACZ,IAAAnB,QAAE,EAAE,eAAgB;QAAC,CACR,CAChB;MAAA,CACD,CACF;IAAA,CACI,CAAC;EAAA,CACQ,CAAC;AAEnB;AAAC,IAAA2B,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAEcvC,yBAAyB","ignoreList":[]}
|
|
@@ -11,7 +11,6 @@ var _blocks = require("@wordpress/blocks");
|
|
|
11
11
|
var _data = require("@wordpress/data");
|
|
12
12
|
var _downloadableBlockListItem = _interopRequireDefault(require("../downloadable-block-list-item"));
|
|
13
13
|
var _store = require("../../store");
|
|
14
|
-
var _lockUnlock = require("../../lock-unlock");
|
|
15
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
15
|
/**
|
|
17
16
|
* WordPress dependencies
|
|
@@ -21,31 +20,24 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
21
20
|
* Internal dependencies
|
|
22
21
|
*/
|
|
23
22
|
|
|
24
|
-
const {
|
|
25
|
-
CompositeV2: Composite,
|
|
26
|
-
useCompositeStoreV2: useCompositeStore
|
|
27
|
-
} = (0, _lockUnlock.unlock)(_components.privateApis);
|
|
28
23
|
const noop = () => {};
|
|
29
24
|
function DownloadableBlocksList({
|
|
30
25
|
items,
|
|
31
26
|
onHover = noop,
|
|
32
27
|
onSelect
|
|
33
28
|
}) {
|
|
34
|
-
const composite = useCompositeStore();
|
|
35
29
|
const {
|
|
36
30
|
installBlockType
|
|
37
31
|
} = (0, _data.useDispatch)(_store.store);
|
|
38
32
|
if (!items.length) {
|
|
39
33
|
return null;
|
|
40
34
|
}
|
|
41
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(Composite, {
|
|
42
|
-
store: composite,
|
|
35
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Composite, {
|
|
43
36
|
role: "listbox",
|
|
44
37
|
className: "block-directory-downloadable-blocks-list",
|
|
45
38
|
"aria-label": (0, _i18n.__)('Blocks available for install'),
|
|
46
39
|
children: items.map(item => {
|
|
47
40
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_downloadableBlockListItem.default, {
|
|
48
|
-
composite: composite,
|
|
49
41
|
onClick: () => {
|
|
50
42
|
// Check if the block is registered (`getBlockType`
|
|
51
43
|
// will return an object). If so, insert the block.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_components","_blocks","_data","_downloadableBlockListItem","_interopRequireDefault","_store","
|
|
1
|
+
{"version":3,"names":["_i18n","require","_components","_blocks","_data","_downloadableBlockListItem","_interopRequireDefault","_store","_jsxRuntime","noop","DownloadableBlocksList","items","onHover","onSelect","installBlockType","useDispatch","blockDirectoryStore","length","jsx","Composite","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 { Composite } 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';\n\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":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,WAAA,GAAAD,OAAA;AACA,IAAAE,OAAA,GAAAF,OAAA;AACA,IAAAG,KAAA,GAAAH,OAAA;AAKA,IAAAI,0BAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAA2D,IAAAO,WAAA,GAAAP,OAAA;AAZ3D;AACA;AACA;;AAMA;AACA;AACA;;AAIA,MAAMQ,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,GAAG,IAAAC,iBAAW,EAAEC,YAAoB,CAAC;EAE/D,IAAK,CAAEL,KAAK,CAACM,MAAM,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,oBACC,IAAAT,WAAA,CAAAU,GAAA,EAAChB,WAAA,CAAAiB,SAAS;IACTC,IAAI,EAAC,SAAS;IACdC,SAAS,EAAC,0CAA0C;IACpD,cAAa,IAAAC,QAAE,EAAE,8BAA+B,CAAG;IAAAC,QAAA,EAEjDZ,KAAK,CAACa,GAAG,CAAIC,IAAI,IAAM;MACxB,oBACC,IAAAjB,WAAA,CAAAU,GAAA,EAACb,0BAAA,CAAAqB,OAAyB;QAEzBC,OAAO,EAAGA,CAAA,KAAM;UACf;UACA;UACA;UACA,IAAK,IAAAC,oBAAY,EAAEH,IAAI,CAACI,IAAK,CAAC,EAAG;YAChChB,QAAQ,CAAEY,IAAK,CAAC;UACjB,CAAC,MAAM;YACNX,gBAAgB,CAAEW,IAAK,CAAC,CAACK,IAAI,CAAIC,OAAO,IAAM;cAC7C,IAAKA,OAAO,EAAG;gBACdlB,QAAQ,CAAEY,IAAK,CAAC;cACjB;YACD,CAAE,CAAC;UACJ;UACAb,OAAO,CAAE,IAAK,CAAC;QAChB,CAAG;QACHA,OAAO,EAAGA,OAAS;QACnBa,IAAI,EAAGA;MAAM,GAjBPA,IAAI,CAACO,EAkBX,CAAC;IAEJ,CAAE;EAAC,CACO,CAAC;AAEd;AAAC,IAAAC,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAEchB,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,IAAAK,SAAA,GAAAL,OAAA;AACA,IAAAM,YAAA,GAAAN,OAAA;AASA,IAAAO,cAAA,GAAAC,sBAAA,CAAAR,OAAA;AACA,IAAAS,MAAA,GAAAT,OAAA;AAA2D,IAAAU,WAAA,GAAAV,OAAA;AAnB3D;AACA;AACA;;AAaA;AACA;AACA;;AAIA,MAAMW,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,GAAG,IAAAC,eAAS,EACvCC,MAAM,IAAM;IACb,MAAM;MAAEC;IAAsB,CAAC,GAAGD,MAAM,CAAEE,YAAoB,CAAC;IAC/D,MAAMC,MAAM,GAAGF,qBAAqB,CACnC,QAAQ,GAAGN,YACZ,CAAC,CAACS,MAAM,CAAE,CAAE;MAAEC;IAAK,CAAC,KAAMV,YAAY,KAAKU,IAAK,CAAC;IACjD,OAAO;MACNP,aAAa,EAAEE,MAAM,CAAEM,eAAU,CAAC,CAACC,OAAO,CACzC,MAAM,EACN,wBACD,CAAC;MACDV,KAAK,EAAEM,MAAM,CAACK,MAAM,IAAIL,MAAM,CAAE,CAAC;IAClC,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,CAAAyC,OAAa;IAEbhC,KAAK,EAAGc,aAAe;IACvBf,UAAU,EAAGF,KAAK,CAACE,UAAY;IAC/BiB,QAAQ,EAAGnB,KAAK,CAACmB;EAAU,GAHvB,SAIJ,CAAC,CACF;EAED,IAAKO,UAAU,IAAIC,YAAY,EAAG;IACjCG,WAAW,GAAG,IAAAC,aAAO,GACpB;IACA,IAAAC,QAAE,EACD,iJACD,CAAC,EACDf,aAAa,CAACgB,KAAK,IAAIhC,YACxB,CAAC;IACDiC,OAAO,CAACE,IAAI,eACX,IAAAvC,WAAA,CAAAkB,GAAA,EAAC3B,WAAA,CAAAiD;IACA;IAAA;MACAC,qBAAqB,EAAG,KAAO;MAE/BC,OAAO,EAAGhB,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,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;EACA;EAAA;IACAC,qBAAqB,EAAG,KAAO;IAC/BC,OAAO,EAAGA,CAAA,KACTP,gBAAgB,CAAER,KAAM,CAAC,CAACgB,IAAI,CAAIC,OAAO,IAAM;MAC9C,IAAKA,OAAO,EAAG;QACd,MAAMC,SAAS,GAAG,IAAAC,oBAAY,EAAEnB,KAAK,CAACoB,IAAK,CAAC;QAC5C,MAAM,CAAEC,aAAa,CAAE,GAAG,IAAAC,aAAK,EAC9BvB,UAAU,CAACwB,eACZ,CAAC;QACD,IAAKF,aAAa,IAAIH,SAAS,EAAG;UACjCR,YAAY,CACXT,QAAQ,EACR,IAAAuB,mBAAW,EACVN,SAAS,CAACE,IAAI,EACdC,aAAa,CAACtB,UAAU,EACxBsB,aAAa,CAACI,WACf,CACD,CAAC;QACF;MACD;IACD,CAAE,CACF;IACDC,sBAAsB;IACtBC,QAAQ,EAAGzB,iBAAmB;IAC9B0B,MAAM,EAAG1B,iBAAmB;IAC5B2B,OAAO,EAAC,SAAS;IAAAC,QAAA,EAEf,IAAAC,aAAO,GACR;IACA,IAAAC,QAAE,EAAE,YAAa,CAAC,EAClBhC,KAAK,CAACiC,KACP;EAAC,CACM,CAAC;AAEX","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
5
|
-
import { Button, Spinner, VisuallyHidden,
|
|
5
|
+
import { Button, Spinner, VisuallyHidden, Composite } from '@wordpress/components';
|
|
6
6
|
import { createInterpolateElement } from '@wordpress/element';
|
|
7
7
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
8
8
|
import { getBlockType } from '@wordpress/blocks';
|
|
@@ -15,15 +15,11 @@ import BlockRatings from '../block-ratings';
|
|
|
15
15
|
import DownloadableBlockIcon from '../downloadable-block-icon';
|
|
16
16
|
import DownloadableBlockNotice from '../downloadable-block-notice';
|
|
17
17
|
import { store as blockDirectoryStore } from '../../store';
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
// Return the appropriate block item label, given the block data and status.
|
|
19
20
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
20
21
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
21
22
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
22
|
-
const {
|
|
23
|
-
CompositeItemV2: CompositeItem
|
|
24
|
-
} = unlock(componentsPrivateApis);
|
|
25
|
-
|
|
26
|
-
// Return the appropriate block item label, given the block data and status.
|
|
27
23
|
function getDownloadableBlockLabel({
|
|
28
24
|
title,
|
|
29
25
|
rating,
|
|
@@ -56,7 +52,6 @@ function getDownloadableBlockLabel({
|
|
|
56
52
|
_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
53
|
}
|
|
58
54
|
function DownloadableBlockListItem({
|
|
59
|
-
composite,
|
|
60
55
|
item,
|
|
61
56
|
onClick
|
|
62
57
|
}) {
|
|
@@ -92,8 +87,11 @@ function DownloadableBlockListItem({
|
|
|
92
87
|
} else if (isInstalling) {
|
|
93
88
|
statusText = __('Installing…');
|
|
94
89
|
}
|
|
95
|
-
return /*#__PURE__*/_jsxs(
|
|
96
|
-
render: /*#__PURE__*/_jsx(Button
|
|
90
|
+
return /*#__PURE__*/_jsxs(Composite.Item, {
|
|
91
|
+
render: /*#__PURE__*/_jsx(Button
|
|
92
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
93
|
+
, {
|
|
94
|
+
__next40pxDefaultSize: false,
|
|
97
95
|
accessibleWhenDisabled: true,
|
|
98
96
|
type: "button",
|
|
99
97
|
role: "option",
|
|
@@ -111,7 +109,6 @@ function DownloadableBlockListItem({
|
|
|
111
109
|
showTooltip: true,
|
|
112
110
|
tooltipPosition: "top center"
|
|
113
111
|
}),
|
|
114
|
-
store: composite,
|
|
115
112
|
disabled: isInstalling || !isInstallable,
|
|
116
113
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
117
114
|
className: "block-directory-downloadable-block-list-item__icon",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","_n","sprintf","Button","Spinner","VisuallyHidden","
|
|
1
|
+
{"version":3,"names":["__","_n","sprintf","Button","Spinner","VisuallyHidden","Composite","createInterpolateElement","decodeEntities","getBlockType","useSelect","BlockRatings","DownloadableBlockIcon","DownloadableBlockNotice","store","blockDirectoryStore","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","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","Item","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\tComposite,\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';\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<Composite.Item\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</Composite.Item>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SACCC,MAAM,EACNC,OAAO,EACPC,cAAc,EACdC,SAAS,QACH,uBAAuB;AAC9B,SAASC,wBAAwB,QAAQ,oBAAoB;AAC7D,SAASC,cAAc,QAAQ,0BAA0B;AACzD,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,OAAOC,YAAY,MAAM,kBAAkB;AAC3C,OAAOC,qBAAqB,MAAM,4BAA4B;AAC9D,OAAOC,uBAAuB,MAAM,8BAA8B;AAClE,SAASC,KAAK,IAAIC,mBAAmB,QAAQ,aAAa;;AAE1D;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAAA,SAAAC,QAAA,IAAAC,SAAA;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,CAACC,KAAK,CAAEP,MAAM,GAAG,GAAI,CAAC,GAAG,GAAG;EAE9C,IAAK,CAAEG,WAAW,IAAID,SAAS,EAAG;IACjC;IACA,OAAOxB,OAAO,CAAE,sBAAsB,EAAEM,cAAc,CA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qC,SAAS,EAAC,qDAAqD;QAAAQ,QAAA,EAClEvD,wBAAwB,CACzBL,OAAO,EACN;QACAF,EAAE,CAAE,2BAA4B,CAAC,EACjCQ,cAAc,CAAEe,KAAM,CAAC,EACvBY,MACD,CAAC,EACD;UACC4B,IAAI,eACH9C,IAAA;YAAMqC,SAAS,EAAC;UAAsD,CAAE;QAE1E,CACD;MAAC,CACI,CAAC,EACL5B,SAAS,gBACVT,IAAA,CAACJ,uBAAuB;QAACmD,KAAK,EAAG/B;MAAM,CAAE,CAAC,gBAE1Cd,KAAA,CAAAE,SAAA;QAAAyC,QAAA,gBACC7C,IAAA;UAAMqC,SAAS,EAAC,oDAAoD;UAAAQ,QAAA,EACjE,CAAC,CAAEf,UAAU,GACZA,UAAU,GACVvC,cAAc,CAAE4B,WAAY;QAAC,CAC3B,CAAC,EACLG,aAAa,IACd,EAAIZ,WAAW,IAAIC,YAAY,CAAE,iBAChCX,IAAA,CAACZ,cAAc;UAAAyD,QAAA,EACZ9D,EAAE,CAAE,eAAgB;QAAC,CACR,CAChB;MAAA,CACD,CACF;IAAA,CACI,CAAC;EAAA,CACQ,CAAC;AAEnB;AAEA,eAAegC,yBAAyB","ignoreList":[]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import { Composite } from '@wordpress/components';
|
|
6
6
|
import { getBlockType } from '@wordpress/blocks';
|
|
7
7
|
import { useDispatch } from '@wordpress/data';
|
|
8
8
|
|
|
@@ -11,19 +11,13 @@ import { useDispatch } from '@wordpress/data';
|
|
|
11
11
|
*/
|
|
12
12
|
import DownloadableBlockListItem from '../downloadable-block-list-item';
|
|
13
13
|
import { store as blockDirectoryStore } from '../../store';
|
|
14
|
-
import { unlock } from '../../lock-unlock';
|
|
15
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
|
-
const {
|
|
17
|
-
CompositeV2: Composite,
|
|
18
|
-
useCompositeStoreV2: useCompositeStore
|
|
19
|
-
} = unlock(componentsPrivateApis);
|
|
20
15
|
const noop = () => {};
|
|
21
16
|
function DownloadableBlocksList({
|
|
22
17
|
items,
|
|
23
18
|
onHover = noop,
|
|
24
19
|
onSelect
|
|
25
20
|
}) {
|
|
26
|
-
const composite = useCompositeStore();
|
|
27
21
|
const {
|
|
28
22
|
installBlockType
|
|
29
23
|
} = useDispatch(blockDirectoryStore);
|
|
@@ -31,13 +25,11 @@ function DownloadableBlocksList({
|
|
|
31
25
|
return null;
|
|
32
26
|
}
|
|
33
27
|
return /*#__PURE__*/_jsx(Composite, {
|
|
34
|
-
store: composite,
|
|
35
28
|
role: "listbox",
|
|
36
29
|
className: "block-directory-downloadable-blocks-list",
|
|
37
30
|
"aria-label": __('Blocks available for install'),
|
|
38
31
|
children: items.map(item => {
|
|
39
32
|
return /*#__PURE__*/_jsx(DownloadableBlockListItem, {
|
|
40
|
-
composite: composite,
|
|
41
33
|
onClick: () => {
|
|
42
34
|
// Check if the block is registered (`getBlockType`
|
|
43
35
|
// will return an object). If so, insert the block.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","
|
|
1
|
+
{"version":3,"names":["__","Composite","getBlockType","useDispatch","DownloadableBlockListItem","store","blockDirectoryStore","jsx","_jsx","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 { Composite } 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';\n\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,SAAS,QAAQ,uBAAuB;AACjD,SAASC,YAAY,QAAQ,mBAAmB;AAChD,SAASC,WAAW,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,yBAAyB,MAAM,iCAAiC;AACvE,SAASC,KAAK,IAAIC,mBAAmB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAE3D,MAAMC,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,GAAGX,WAAW,CAAEG,mBAAoB,CAAC;EAE/D,IAAK,CAAEK,KAAK,CAACI,MAAM,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,oBACCP,IAAA,CAACP,SAAS;IACTe,IAAI,EAAC,SAAS;IACdC,SAAS,EAAC,0CAA0C;IACpD,cAAajB,EAAE,CAAE,8BAA+B,CAAG;IAAAkB,QAAA,EAEjDP,KAAK,CAACQ,GAAG,CAAIC,IAAI,IAAM;MACxB,oBACCZ,IAAA,CAACJ,yBAAyB;QAEzBiB,OAAO,EAAGA,CAAA,KAAM;UACf;UACA;UACA;UACA,IAAKnB,YAAY,CAAEkB,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,CAA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B,OAAO,GAAG,cACf9B,IAAA,CAACH,aAAa;IAEbW,KAAK,EAAGU,aAAe;IACvBX,UAAU,EAAGF,KAAK,CAACE,UAAY;IAC/Ba,QAAQ,EAAGf,KAAK,CAACe;EAAU,GAHvB,SAIJ,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__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,IAAI,EACdC,aAAa,CAACf,UAAU,EACxBe,aAAa,CAACE,WACf,CACD,CAAC;QACF;MACD;IACD,CAAE,CACF;IACDC,sBAAsB;IACtBC,QAAQ,EAAGhB,iBAAmB;IAC9BiB,MAAM,EAAGjB,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-directory",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.7.1-next.5368f64a9.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.1.0",
|
|
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.1-next.5368f64a9.0",
|
|
31
|
+
"@wordpress/api-fetch": "^7.7.1-next.5368f64a9.0",
|
|
32
|
+
"@wordpress/block-editor": "^14.2.1-next.5368f64a9.0",
|
|
33
|
+
"@wordpress/blocks": "^13.7.1-next.5368f64a9.0",
|
|
34
|
+
"@wordpress/components": "^28.8.1-next.5368f64a9.0",
|
|
35
|
+
"@wordpress/compose": "^7.8.1-next.5368f64a9.0",
|
|
36
|
+
"@wordpress/core-data": "^7.7.1-next.5368f64a9.0",
|
|
37
|
+
"@wordpress/data": "^10.7.1-next.5368f64a9.0",
|
|
38
|
+
"@wordpress/editor": "^14.7.1-next.5368f64a9.0",
|
|
39
|
+
"@wordpress/element": "^6.7.1-next.5368f64a9.0",
|
|
40
|
+
"@wordpress/hooks": "^4.7.1-next.5368f64a9.0",
|
|
41
|
+
"@wordpress/html-entities": "^4.7.1-next.5368f64a9.0",
|
|
42
|
+
"@wordpress/i18n": "^5.7.1-next.5368f64a9.0",
|
|
43
|
+
"@wordpress/icons": "^10.7.1-next.5368f64a9.0",
|
|
44
|
+
"@wordpress/notices": "^5.7.1-next.5368f64a9.0",
|
|
45
|
+
"@wordpress/plugins": "^7.7.1-next.5368f64a9.0",
|
|
46
|
+
"@wordpress/private-apis": "^1.7.1-next.5368f64a9.0",
|
|
47
|
+
"@wordpress/url": "^4.7.1-next.5368f64a9.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": "24934a1f5251bbee15045d1fd953d9c5650317cd"
|
|
58
58
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
Button,
|
|
7
7
|
Spinner,
|
|
8
8
|
VisuallyHidden,
|
|
9
|
-
|
|
9
|
+
Composite,
|
|
10
10
|
} from '@wordpress/components';
|
|
11
11
|
import { createInterpolateElement } from '@wordpress/element';
|
|
12
12
|
import { decodeEntities } from '@wordpress/html-entities';
|
|
@@ -20,9 +20,6 @@ import BlockRatings from '../block-ratings';
|
|
|
20
20
|
import DownloadableBlockIcon from '../downloadable-block-icon';
|
|
21
21
|
import DownloadableBlockNotice from '../downloadable-block-notice';
|
|
22
22
|
import { store as blockDirectoryStore } from '../../store';
|
|
23
|
-
import { unlock } from '../../lock-unlock';
|
|
24
|
-
|
|
25
|
-
const { CompositeItemV2: CompositeItem } = unlock( componentsPrivateApis );
|
|
26
23
|
|
|
27
24
|
// Return the appropriate block item label, given the block data and status.
|
|
28
25
|
function getDownloadableBlockLabel(
|
|
@@ -65,7 +62,7 @@ function getDownloadableBlockLabel(
|
|
|
65
62
|
);
|
|
66
63
|
}
|
|
67
64
|
|
|
68
|
-
function DownloadableBlockListItem( {
|
|
65
|
+
function DownloadableBlockListItem( { item, onClick } ) {
|
|
69
66
|
const { author, description, icon, rating, title } = item;
|
|
70
67
|
// getBlockType returns a block object if this block exists, or null if not.
|
|
71
68
|
const isInstalled = !! getBlockType( item.name );
|
|
@@ -93,9 +90,11 @@ function DownloadableBlockListItem( { composite, item, onClick } ) {
|
|
|
93
90
|
}
|
|
94
91
|
|
|
95
92
|
return (
|
|
96
|
-
<
|
|
93
|
+
<Composite.Item
|
|
97
94
|
render={
|
|
98
95
|
<Button
|
|
96
|
+
// TODO: Switch to `true` (40px size) if possible
|
|
97
|
+
__next40pxDefaultSize={ false }
|
|
99
98
|
accessibleWhenDisabled
|
|
100
99
|
type="button"
|
|
101
100
|
role="option"
|
|
@@ -114,7 +113,6 @@ function DownloadableBlockListItem( { composite, item, onClick } ) {
|
|
|
114
113
|
tooltipPosition="top center"
|
|
115
114
|
/>
|
|
116
115
|
}
|
|
117
|
-
store={ composite }
|
|
118
116
|
disabled={ isInstalling || ! isInstallable }
|
|
119
117
|
>
|
|
120
118
|
<div className="block-directory-downloadable-block-list-item__icon">
|
|
@@ -161,7 +159,7 @@ function DownloadableBlockListItem( { composite, item, onClick } ) {
|
|
|
161
159
|
</>
|
|
162
160
|
) }
|
|
163
161
|
</span>
|
|
164
|
-
</
|
|
162
|
+
</Composite.Item>
|
|
165
163
|
);
|
|
166
164
|
}
|
|
167
165
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* WordPress dependencies
|
|
3
3
|
*/
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
|
-
import {
|
|
5
|
+
import { Composite } from '@wordpress/components';
|
|
6
6
|
import { getBlockType } from '@wordpress/blocks';
|
|
7
7
|
import { useDispatch } from '@wordpress/data';
|
|
8
8
|
|
|
@@ -11,14 +11,10 @@ import { useDispatch } from '@wordpress/data';
|
|
|
11
11
|
*/
|
|
12
12
|
import DownloadableBlockListItem from '../downloadable-block-list-item';
|
|
13
13
|
import { store as blockDirectoryStore } from '../../store';
|
|
14
|
-
import { unlock } from '../../lock-unlock';
|
|
15
14
|
|
|
16
|
-
const { CompositeV2: Composite, useCompositeStoreV2: useCompositeStore } =
|
|
17
|
-
unlock( componentsPrivateApis );
|
|
18
15
|
const noop = () => {};
|
|
19
16
|
|
|
20
17
|
function DownloadableBlocksList( { items, onHover = noop, onSelect } ) {
|
|
21
|
-
const composite = useCompositeStore();
|
|
22
18
|
const { installBlockType } = useDispatch( blockDirectoryStore );
|
|
23
19
|
|
|
24
20
|
if ( ! items.length ) {
|
|
@@ -27,7 +23,6 @@ function DownloadableBlocksList( { items, onHover = noop, onSelect } ) {
|
|
|
27
23
|
|
|
28
24
|
return (
|
|
29
25
|
<Composite
|
|
30
|
-
store={ composite }
|
|
31
26
|
role="listbox"
|
|
32
27
|
className="block-directory-downloadable-blocks-list"
|
|
33
28
|
aria-label={ __( 'Blocks available for install' ) }
|
|
@@ -36,7 +31,6 @@ function DownloadableBlocksList( { items, onHover = noop, onSelect } ) {
|
|
|
36
31
|
return (
|
|
37
32
|
<DownloadableBlockListItem
|
|
38
33
|
key={ item.id }
|
|
39
|
-
composite={ composite }
|
|
40
34
|
onClick={ () => {
|
|
41
35
|
// Check if the block is registered (`getBlockType`
|
|
42
36
|
// 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 ) {
|