@wordpress/block-directory 5.9.0 → 5.11.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/block-ratings/stars.js +1 -1
- package/build/components/block-ratings/stars.js.map +1 -1
- package/build/components/compact-list/index.js +1 -1
- package/build/components/compact-list/index.js.map +1 -1
- package/build/components/downloadable-block-list-item/index.js +6 -6
- package/build/components/downloadable-block-list-item/index.js.map +1 -1
- package/build/components/downloadable-blocks-panel/inserter-panel.js +1 -1
- package/build/components/downloadable-blocks-panel/inserter-panel.js.map +1 -1
- package/build/plugins/get-install-missing/index.js +3 -3
- package/build/plugins/get-install-missing/index.js.map +1 -1
- package/build/plugins/get-install-missing/install-button.js +1 -1
- package/build/plugins/get-install-missing/install-button.js.map +1 -1
- package/build/store/actions.js.map +1 -1
- package/build/store/resolvers.js.map +1 -1
- package/build-module/components/block-ratings/stars.js +2 -3
- package/build-module/components/block-ratings/stars.js.map +1 -1
- package/build-module/components/compact-list/index.js +2 -3
- package/build-module/components/compact-list/index.js.map +1 -1
- package/build-module/components/downloadable-block-list-item/index.js +7 -9
- package/build-module/components/downloadable-block-list-item/index.js.map +1 -1
- package/build-module/components/downloadable-block-notice/index.js +1 -2
- package/build-module/components/downloadable-block-notice/index.js.map +1 -1
- package/build-module/components/downloadable-blocks-panel/index.js +1 -3
- package/build-module/components/downloadable-blocks-panel/index.js.map +1 -1
- package/build-module/components/downloadable-blocks-panel/inserter-panel.js +2 -4
- package/build-module/components/downloadable-blocks-panel/inserter-panel.js.map +1 -1
- package/build-module/components/downloadable-blocks-panel/no-results.js +1 -3
- package/build-module/components/downloadable-blocks-panel/no-results.js.map +1 -1
- package/build-module/plugins/get-install-missing/index.js +4 -5
- package/build-module/plugins/get-install-missing/index.js.map +1 -1
- package/build-module/plugins/get-install-missing/install-button.js +1 -1
- package/build-module/plugins/get-install-missing/install-button.js.map +1 -1
- package/build-module/plugins/index.js +1 -3
- package/build-module/plugins/index.js.map +1 -1
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.js +1 -2
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.js.map +1 -1
- package/build-module/store/actions.js.map +1 -1
- package/build-module/store/resolvers.js.map +1 -1
- package/build-style/style-rtl.css +1 -10
- package/build-style/style.css +1 -10
- package/package.json +22 -21
- package/src/components/downloadable-block-list-item/index.js +6 -6
- package/src/components/downloadable-block-list-item/style.scss +1 -11
package/CHANGELOG.md
CHANGED
|
@@ -19,7 +19,7 @@ function Stars({
|
|
|
19
19
|
const halfStarCount = Math.ceil(rating - fullStarCount);
|
|
20
20
|
const emptyStarCount = 5 - (fullStarCount + halfStarCount);
|
|
21
21
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
|
|
22
|
-
"aria-label": (0, _i18n.sprintf)(
|
|
22
|
+
"aria-label": (0, _i18n.sprintf)(/* translators: %s: number of stars. */
|
|
23
23
|
(0, _i18n.__)('%s out of 5 stars'), stars),
|
|
24
24
|
children: [Array.from({
|
|
25
25
|
length: fullStarCount
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_icons","_jsxRuntime","Stars","rating","stars","Math","round","fullStarCount","floor","halfStarCount","ceil","emptyStarCount","jsxs","sprintf","__","children","Array","from","length","map","_","i","jsx","Icon","className","icon","starFilled","size","starHalf","starEmpty","_default","exports","default"],"sources":["@wordpress/block-directory/src/components/block-ratings/stars.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Icon, starEmpty, starFilled, starHalf } from '@wordpress/icons';\n\nfunction Stars( { rating } ) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tconst fullStarCount = Math.floor( rating );\n\tconst halfStarCount = Math.ceil( rating - fullStarCount );\n\tconst emptyStarCount = 5 - ( fullStarCount + halfStarCount );\n\n\treturn (\n\t\t<span\n\t\t\taria-label={ sprintf(\n\t\t\t\t/* translators: %s: number of stars. */\n\t\t\t\t__( '%s out of 5 stars' ),\n\t\t\t\tstars\n\t\t\t) }\n\t\t>\n\t\t\t{ Array.from( { length: fullStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `full_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-full\"\n\t\t\t\t\ticon={ starFilled }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: halfStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `half_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-half-full\"\n\t\t\t\t\ticon={ starHalf }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: emptyStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `empty_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-empty\"\n\t\t\t\t\ticon={ starEmpty }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</span>\n\t);\n}\n\nexport default Stars;\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAyE,IAAAE,WAAA,GAAAF,OAAA;AAJzE;AACA;AACA;;AAIA,SAASG,KAAKA,CAAE;EAAEC;AAAO,CAAC,EAAG;EAC5B,MAAMC,KAAK,GAAGC,IAAI,CAACC,KAAK,CAAEH,MAAM,GAAG,GAAI,CAAC,GAAG,GAAG;EAE9C,MAAMI,aAAa,GAAGF,IAAI,CAACG,KAAK,CAAEL,MAAO,CAAC;EAC1C,MAAMM,aAAa,GAAGJ,IAAI,CAACK,IAAI,CAAEP,MAAM,GAAGI,aAAc,CAAC;EACzD,MAAMI,cAAc,GAAG,CAAC,IAAKJ,aAAa,GAAGE,aAAa,CAAE;EAE5D,oBACC,IAAAR,WAAA,CAAAW,IAAA;IACC,cAAa,IAAAC,aAAO,
|
|
1
|
+
{"version":3,"names":["_i18n","require","_icons","_jsxRuntime","Stars","rating","stars","Math","round","fullStarCount","floor","halfStarCount","ceil","emptyStarCount","jsxs","sprintf","__","children","Array","from","length","map","_","i","jsx","Icon","className","icon","starFilled","size","starHalf","starEmpty","_default","exports","default"],"sources":["@wordpress/block-directory/src/components/block-ratings/stars.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Icon, starEmpty, starFilled, starHalf } from '@wordpress/icons';\n\nfunction Stars( { rating } ) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tconst fullStarCount = Math.floor( rating );\n\tconst halfStarCount = Math.ceil( rating - fullStarCount );\n\tconst emptyStarCount = 5 - ( fullStarCount + halfStarCount );\n\n\treturn (\n\t\t<span\n\t\t\taria-label={ sprintf(\n\t\t\t\t/* translators: %s: number of stars. */\n\t\t\t\t__( '%s out of 5 stars' ),\n\t\t\t\tstars\n\t\t\t) }\n\t\t>\n\t\t\t{ Array.from( { length: fullStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `full_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-full\"\n\t\t\t\t\ticon={ starFilled }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: halfStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `half_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-half-full\"\n\t\t\t\t\ticon={ starHalf }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: emptyStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `empty_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-empty\"\n\t\t\t\t\ticon={ starEmpty }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</span>\n\t);\n}\n\nexport default Stars;\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,MAAA,GAAAD,OAAA;AAAyE,IAAAE,WAAA,GAAAF,OAAA;AAJzE;AACA;AACA;;AAIA,SAASG,KAAKA,CAAE;EAAEC;AAAO,CAAC,EAAG;EAC5B,MAAMC,KAAK,GAAGC,IAAI,CAACC,KAAK,CAAEH,MAAM,GAAG,GAAI,CAAC,GAAG,GAAG;EAE9C,MAAMI,aAAa,GAAGF,IAAI,CAACG,KAAK,CAAEL,MAAO,CAAC;EAC1C,MAAMM,aAAa,GAAGJ,IAAI,CAACK,IAAI,CAAEP,MAAM,GAAGI,aAAc,CAAC;EACzD,MAAMI,cAAc,GAAG,CAAC,IAAKJ,aAAa,GAAGE,aAAa,CAAE;EAE5D,oBACC,IAAAR,WAAA,CAAAW,IAAA;IACC,cAAa,IAAAC,aAAO,EACnB;IACA,IAAAC,QAAE,EAAE,mBAAoB,CAAC,EACzBV,KACD,CAAG;IAAAW,QAAA,GAEDC,KAAK,CAACC,IAAI,CAAE;MAAEC,MAAM,EAAEX;IAAc,CAAE,CAAC,CAACY,GAAG,CAAE,CAAEC,CAAC,EAAEC,CAAC,kBACpD,IAAApB,WAAA,CAAAqB,GAAA,EAACtB,MAAA,CAAAuB,IAAI;MAEJC,SAAS,EAAC,0CAA0C;MACpDC,IAAI,EAAGC,iBAAY;MACnBC,IAAI,EAAG;IAAI,GAHL,cAAeN,CAAC,EAItB,CACA,CAAC,EACDL,KAAK,CAACC,IAAI,CAAE;MAAEC,MAAM,EAAET;IAAc,CAAE,CAAC,CAACU,GAAG,CAAE,CAAEC,CAAC,EAAEC,CAAC,kBACpD,IAAApB,WAAA,CAAAqB,GAAA,EAACtB,MAAA,CAAAuB,IAAI;MAEJC,SAAS,EAAC,+CAA+C;MACzDC,IAAI,EAAGG,eAAU;MACjBD,IAAI,EAAG;IAAI,GAHL,cAAeN,CAAC,EAItB,CACA,CAAC,EACDL,KAAK,CAACC,IAAI,CAAE;MAAEC,MAAM,EAAEP;IAAe,CAAE,CAAC,CAACQ,GAAG,CAAE,CAAEC,CAAC,EAAEC,CAAC,kBACrD,IAAApB,WAAA,CAAAqB,GAAA,EAACtB,MAAA,CAAAuB,IAAI;MAEJC,SAAS,EAAC,2CAA2C;MACrDC,IAAI,EAAGI,gBAAW;MAClBF,IAAI,EAAG;IAAI,GAHL,eAAgBN,CAAC,EAIvB,CACA,CAAC;EAAA,CACE,CAAC;AAET;AAAC,IAAAS,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEc9B,KAAK","ignoreList":[]}
|
|
@@ -41,7 +41,7 @@ function CompactList({
|
|
|
41
41
|
children: title
|
|
42
42
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
43
43
|
className: "block-directory-compact-list__item-author",
|
|
44
|
-
children: (0, _i18n.sprintf)(
|
|
44
|
+
children: (0, _i18n.sprintf)(/* translators: %s: Name of the block author. */
|
|
45
45
|
(0, _i18n.__)('By %s'), author)
|
|
46
46
|
})]
|
|
47
47
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_downloadableBlockIcon","_interopRequireDefault","_jsxRuntime","CompactList","items","length","jsx","className","children","map","icon","id","title","author","jsxs","default","sprintf","__"],"sources":["@wordpress/block-directory/src/components/compact-list/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlockIcon from '../downloadable-block-icon';\n\nexport default function CompactList( { items } ) {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ul className=\"block-directory-compact-list\">\n\t\t\t{ items.map( ( { icon, id, title, author } ) => (\n\t\t\t\t<li key={ id } className=\"block-directory-compact-list__item\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\n\t\t\t\t\t<div className=\"block-directory-compact-list__item-details\">\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-title\">\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-author\">\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: Name of the block author. */\n\t\t\t\t\t\t\t\t__( 'By %s' ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,sBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA+D,IAAAG,WAAA,GAAAH,OAAA;AAR/D;AACA;AACA;;AAGA;AACA;AACA;;AAGe,SAASI,WAAWA,CAAE;EAAEC;AAAM,CAAC,EAAG;EAChD,IAAK,CAAEA,KAAK,CAACC,MAAM,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,oBACC,IAAAH,WAAA,CAAAI,GAAA;IAAIC,SAAS,EAAC,8BAA8B;IAAAC,QAAA,EACzCJ,KAAK,CAACK,GAAG,CAAE,CAAE;MAAEC,IAAI;MAAEC,EAAE;MAAEC,KAAK;MAAEC;IAAO,CAAC,kBACzC,IAAAX,WAAA,CAAAY,IAAA;MAAeP,SAAS,EAAC,oCAAoC;MAAAC,QAAA,gBAC5D,IAAAN,WAAA,CAAAI,GAAA,EAACN,sBAAA,CAAAe,OAAqB;QAACL,IAAI,EAAGA,IAAM;QAACE,KAAK,EAAGA;MAAO,CAAE,CAAC,eAEvD,IAAAV,WAAA,CAAAY,IAAA;QAAKP,SAAS,EAAC,4CAA4C;QAAAC,QAAA,gBAC1D,IAAAN,WAAA,CAAAI,GAAA;UAAKC,SAAS,EAAC,0CAA0C;UAAAC,QAAA,EACtDI;QAAK,CACH,CAAC,eACN,IAAAV,WAAA,CAAAI,GAAA;UAAKC,SAAS,EAAC,2CAA2C;UAAAC,QAAA,EACvD,IAAAQ,aAAO,
|
|
1
|
+
{"version":3,"names":["_i18n","require","_downloadableBlockIcon","_interopRequireDefault","_jsxRuntime","CompactList","items","length","jsx","className","children","map","icon","id","title","author","jsxs","default","sprintf","__"],"sources":["@wordpress/block-directory/src/components/compact-list/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlockIcon from '../downloadable-block-icon';\n\nexport default function CompactList( { items } ) {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ul className=\"block-directory-compact-list\">\n\t\t\t{ items.map( ( { icon, id, title, author } ) => (\n\t\t\t\t<li key={ id } className=\"block-directory-compact-list__item\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\n\t\t\t\t\t<div className=\"block-directory-compact-list__item-details\">\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-title\">\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-author\">\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: Name of the block author. */\n\t\t\t\t\t\t\t\t__( 'By %s' ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AAKA,IAAAC,sBAAA,GAAAC,sBAAA,CAAAF,OAAA;AAA+D,IAAAG,WAAA,GAAAH,OAAA;AAR/D;AACA;AACA;;AAGA;AACA;AACA;;AAGe,SAASI,WAAWA,CAAE;EAAEC;AAAM,CAAC,EAAG;EAChD,IAAK,CAAEA,KAAK,CAACC,MAAM,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,oBACC,IAAAH,WAAA,CAAAI,GAAA;IAAIC,SAAS,EAAC,8BAA8B;IAAAC,QAAA,EACzCJ,KAAK,CAACK,GAAG,CAAE,CAAE;MAAEC,IAAI;MAAEC,EAAE;MAAEC,KAAK;MAAEC;IAAO,CAAC,kBACzC,IAAAX,WAAA,CAAAY,IAAA;MAAeP,SAAS,EAAC,oCAAoC;MAAAC,QAAA,gBAC5D,IAAAN,WAAA,CAAAI,GAAA,EAACN,sBAAA,CAAAe,OAAqB;QAACL,IAAI,EAAGA,IAAM;QAACE,KAAK,EAAGA;MAAO,CAAE,CAAC,eAEvD,IAAAV,WAAA,CAAAY,IAAA;QAAKP,SAAS,EAAC,4CAA4C;QAAAC,QAAA,gBAC1D,IAAAN,WAAA,CAAAI,GAAA;UAAKC,SAAS,EAAC,0CAA0C;UAAAC,QAAA,EACtDI;QAAK,CACH,CAAC,eACN,IAAAV,WAAA,CAAAI,GAAA;UAAKC,SAAS,EAAC,2CAA2C;UAAAC,QAAA,EACvD,IAAAQ,aAAO,EACR;UACA,IAAAC,QAAE,EAAE,OAAQ,CAAC,EACbJ,MACD;QAAC,CACG,CAAC;MAAA,CACF,CAAC;IAAA,GAdGF,EAeN,CACH;EAAC,CACA,CAAC;AAEP","ignoreList":[]}
|
|
@@ -41,24 +41,24 @@ function getDownloadableBlockLabel({
|
|
|
41
41
|
}) {
|
|
42
42
|
const stars = Math.round(rating / 0.5) * 0.5;
|
|
43
43
|
if (!isInstalled && hasNotice) {
|
|
44
|
-
/* translators: %
|
|
44
|
+
/* translators: %s: block title */
|
|
45
45
|
return (0, _i18n.sprintf)('Retry installing %s.', (0, _htmlEntities.decodeEntities)(title));
|
|
46
46
|
}
|
|
47
47
|
if (isInstalled) {
|
|
48
|
-
/* translators: %
|
|
48
|
+
/* translators: %s: block title */
|
|
49
49
|
return (0, _i18n.sprintf)('Add %s.', (0, _htmlEntities.decodeEntities)(title));
|
|
50
50
|
}
|
|
51
51
|
if (isInstalling) {
|
|
52
|
-
/* translators: %
|
|
52
|
+
/* translators: %s: block title */
|
|
53
53
|
return (0, _i18n.sprintf)('Installing %s.', (0, _htmlEntities.decodeEntities)(title));
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
// No ratings yet, just use the title.
|
|
57
57
|
if (ratingCount < 1) {
|
|
58
|
-
/* translators: %
|
|
58
|
+
/* translators: %s: block title */
|
|
59
59
|
return (0, _i18n.sprintf)('Install %s.', (0, _htmlEntities.decodeEntities)(title));
|
|
60
60
|
}
|
|
61
|
-
return (0, _i18n.sprintf)(
|
|
61
|
+
return (0, _i18n.sprintf)(/* translators: 1: block title, 2: average rating, 3: total ratings count. */
|
|
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({
|
|
@@ -131,7 +131,7 @@ function DownloadableBlockListItem({
|
|
|
131
131
|
className: "block-directory-downloadable-block-list-item__details",
|
|
132
132
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
133
133
|
className: "block-directory-downloadable-block-list-item__title",
|
|
134
|
-
children: (0, _element.createInterpolateElement)((0, _i18n.sprintf)(
|
|
134
|
+
children: (0, _element.createInterpolateElement)((0, _i18n.sprintf)(/* translators: 1: block title. 2: author name. */
|
|
135
135
|
(0, _i18n.__)('%1$s <span>by %2$s</span>'), (0, _htmlEntities.decodeEntities)(title), author), {
|
|
136
136
|
span: /*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
|
|
137
137
|
className: "block-directory-downloadable-block-list-item__author"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_components","_element","_htmlEntities","_blocks","_data","_blockRatings","_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","__","itemLabel","jsx","Tooltip","placement","text","children","jsxs","Composite","Item","className","clsx","accessibleWhenDisabled","disabled","event","preventDefault","type","role","default","Spinner","createInterpolateElement","span","block","Fragment","VisuallyHidden","_default","exports"],"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tTooltip,\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\tconst itemLabel = getDownloadableBlockLabel( item, {\n\t\thasNotice,\n\t\tisInstalled,\n\t\tisInstalling,\n\t} );\n\n\treturn (\n\t\t<Tooltip placement=\"top\" text={ itemLabel }>\n\t\t\t<Composite.Item\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-directory-downloadable-block-list-item',\n\t\t\t\t\tisInstalling && 'is-installing'\n\t\t\t\t) }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tonClick();\n\t\t\t\t} }\n\t\t\t\taria-label={ itemLabel }\n\t\t\t\ttype=\"button\"\n\t\t\t\trole=\"option\"\n\t\t\t>\n\t\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: %1$s: block title, %2$s: author name. */\n\t\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: (\n\t\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\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\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</Composite.Item>\n\t\t</Tooltip>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAKA,IAAAO,aAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,sBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,wBAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AAA2D,IAAAW,WAAA,GAAAX,OAAA;AA1B3D;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;;AAMA;AACA,SAASY,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,OAA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AAC,CACR,CAChB;QAAA,CACD,CACF;MAAA,CACI,CAAC;IAAA,CACQ;EAAC,CACT,CAAC;AAEZ;AAAC,IAAAyB,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAEcrC,yBAAyB","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_clsx","_interopRequireDefault","require","_i18n","_components","_element","_htmlEntities","_blocks","_data","_blockRatings","_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","__","itemLabel","jsx","Tooltip","placement","text","children","jsxs","Composite","Item","className","clsx","accessibleWhenDisabled","disabled","event","preventDefault","type","role","default","Spinner","createInterpolateElement","span","block","Fragment","VisuallyHidden","_default","exports"],"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tTooltip,\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: %s: block title */\n\t\treturn sprintf( 'Retry installing %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalled ) {\n\t\t/* translators: %s: block title */\n\t\treturn sprintf( 'Add %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalling ) {\n\t\t/* translators: %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: %s: block title */\n\t\treturn sprintf( 'Install %s.', decodeEntities( title ) );\n\t}\n\n\treturn sprintf(\n\t\t/* translators: 1: block title, 2: average rating, 3: 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\tconst itemLabel = getDownloadableBlockLabel( item, {\n\t\thasNotice,\n\t\tisInstalled,\n\t\tisInstalling,\n\t} );\n\n\treturn (\n\t\t<Tooltip placement=\"top\" text={ itemLabel }>\n\t\t\t<Composite.Item\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-directory-downloadable-block-list-item',\n\t\t\t\t\tisInstalling && 'is-installing'\n\t\t\t\t) }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tonClick();\n\t\t\t\t} }\n\t\t\t\taria-label={ itemLabel }\n\t\t\t\ttype=\"button\"\n\t\t\t\trole=\"option\"\n\t\t\t>\n\t\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: 1: block title. 2: author name. */\n\t\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: (\n\t\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\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\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</Composite.Item>\n\t\t</Tooltip>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,sBAAA,CAAAC,OAAA;AAKA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,WAAA,GAAAF,OAAA;AAMA,IAAAG,QAAA,GAAAH,OAAA;AACA,IAAAI,aAAA,GAAAJ,OAAA;AACA,IAAAK,OAAA,GAAAL,OAAA;AACA,IAAAM,KAAA,GAAAN,OAAA;AAKA,IAAAO,aAAA,GAAAR,sBAAA,CAAAC,OAAA;AACA,IAAAQ,sBAAA,GAAAT,sBAAA,CAAAC,OAAA;AACA,IAAAS,wBAAA,GAAAV,sBAAA,CAAAC,OAAA;AACA,IAAAU,MAAA,GAAAV,OAAA;AAA2D,IAAAW,WAAA,GAAAX,OAAA;AA1B3D;AACA;AACA;;AAGA;AACA;AACA;;AAaA;AACA;AACA;;AAMA;AACA,SAASY,yBAAyBA,CACjC;EAAEC,KAAK;EAAEC,MAAM;EAAEC;AAAY,CAAC,EAC9B;EAAEC,SAAS;EAAEC,WAAW;EAAEC;AAAa,CAAC,EACvC;EACD,M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B,WAAW,IAAIC,YAAY,CAAE,iBAChC,IAAAP,WAAA,CAAAmC,GAAA,EAAC5C,WAAA,CAAAkE,cAAc;YAAAlB,QAAA,EACZ,IAAAN,QAAE,EAAE,eAAgB;UAAC,CACR,CAChB;QAAA,CACD,CACF;MAAA,CACI,CAAC;IAAA,CACQ;EAAC,CACT,CAAC;AAEZ;AAAC,IAAAyB,QAAA,GAAAC,OAAA,CAAAR,OAAA,GAEcrC,yBAAyB","ignoreList":[]}
|
|
@@ -19,7 +19,7 @@ function DownloadableBlocksInserterPanel({
|
|
|
19
19
|
}) {
|
|
20
20
|
const count = downloadableItems.length;
|
|
21
21
|
(0, _element.useEffect)(() => {
|
|
22
|
-
(0, _a11y.speak)((0, _i18n.sprintf)(
|
|
22
|
+
(0, _a11y.speak)((0, _i18n.sprintf)(/* translators: %d: number of available blocks. */
|
|
23
23
|
(0, _i18n._n)('%d additional block is available to install.', '%d additional blocks are available to install.', count), count));
|
|
24
24
|
}, [count]);
|
|
25
25
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_i18n","require","_element","_a11y","_jsxRuntime","DownloadableBlocksInserterPanel","children","downloadableItems","hasLocalBlocks","count","length","useEffect","speak","sprintf","_n","jsxs","Fragment","jsx","className","__","_default","exports","default"],"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/inserter-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\nfunction DownloadableBlocksInserterPanel( {\n\tchildren,\n\tdownloadableItems,\n\thasLocalBlocks,\n} ) {\n\tconst count = downloadableItems.length;\n\tuseEffect( () => {\n\t\tspeak(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of available blocks. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d additional block is available to install.',\n\t\t\t\t\t'%d additional blocks are available to install.',\n\t\t\t\t\tcount\n\t\t\t\t),\n\t\t\t\tcount\n\t\t\t)\n\t\t);\n\t}, [ count ] );\n\n\treturn (\n\t\t<>\n\t\t\t{ ! hasLocalBlocks && (\n\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__no-local\">\n\t\t\t\t\t{ __( 'No results available from your installed blocks.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\n\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\n\t\t\t<div className=\"block-directory-downloadable-blocks-panel\">\n\t\t\t\t<div className=\"block-directory-downloadable-blocks-panel__header\">\n\t\t\t\t\t<h2 className=\"block-directory-downloadable-blocks-panel__title\">\n\t\t\t\t\t\t{ __( 'Available to install' ) }\n\t\t\t\t\t</h2>\n\t\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__description\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Select a block to install and add it to your post.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default DownloadableBlocksInserterPanel;\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,OAAA;AAAwC,IAAAG,WAAA,GAAAH,OAAA;AALxC;AACA;AACA;;AAKA,SAASI,+BAA+BA,CAAE;EACzCC,QAAQ;EACRC,iBAAiB;EACjBC;AACD,CAAC,EAAG;EACH,MAAMC,KAAK,GAAGF,iBAAiB,CAACG,MAAM;EACtC,IAAAC,kBAAS,EAAE,MAAM;IAChB,IAAAC,WAAK,EACJ,IAAAC,aAAO,
|
|
1
|
+
{"version":3,"names":["_i18n","require","_element","_a11y","_jsxRuntime","DownloadableBlocksInserterPanel","children","downloadableItems","hasLocalBlocks","count","length","useEffect","speak","sprintf","_n","jsxs","Fragment","jsx","className","__","_default","exports","default"],"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/inserter-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\nfunction DownloadableBlocksInserterPanel( {\n\tchildren,\n\tdownloadableItems,\n\thasLocalBlocks,\n} ) {\n\tconst count = downloadableItems.length;\n\tuseEffect( () => {\n\t\tspeak(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of available blocks. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d additional block is available to install.',\n\t\t\t\t\t'%d additional blocks are available to install.',\n\t\t\t\t\tcount\n\t\t\t\t),\n\t\t\t\tcount\n\t\t\t)\n\t\t);\n\t}, [ count ] );\n\n\treturn (\n\t\t<>\n\t\t\t{ ! hasLocalBlocks && (\n\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__no-local\">\n\t\t\t\t\t{ __( 'No results available from your installed blocks.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\n\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\n\t\t\t<div className=\"block-directory-downloadable-blocks-panel\">\n\t\t\t\t<div className=\"block-directory-downloadable-blocks-panel__header\">\n\t\t\t\t\t<h2 className=\"block-directory-downloadable-blocks-panel__title\">\n\t\t\t\t\t\t{ __( 'Available to install' ) }\n\t\t\t\t\t</h2>\n\t\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__description\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Select a block to install and add it to your post.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default DownloadableBlocksInserterPanel;\n"],"mappings":";;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,QAAA,GAAAD,OAAA;AACA,IAAAE,KAAA,GAAAF,O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@@ -81,7 +81,7 @@ const ModifiedWarning = ({
|
|
|
81
81
|
} = select(_blockEditor.store);
|
|
82
82
|
return canInsertBlockType('core/html', getBlockRootClientId(clientId));
|
|
83
83
|
}, [clientId]);
|
|
84
|
-
let messageHTML = (0, _i18n.sprintf)(
|
|
84
|
+
let messageHTML = (0, _i18n.sprintf)(/* translators: %s: block name */
|
|
85
85
|
(0, _i18n.__)('Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'), originalBlock.title || originalName);
|
|
86
86
|
const actions = [/*#__PURE__*/(0, _jsxRuntime.jsx)(_installButton.default, {
|
|
87
87
|
block: originalBlock,
|
|
@@ -89,9 +89,9 @@ const ModifiedWarning = ({
|
|
|
89
89
|
clientId: props.clientId
|
|
90
90
|
}, "install")];
|
|
91
91
|
if (hasContent && hasHTMLBlock) {
|
|
92
|
-
messageHTML = (0, _i18n.sprintf)(
|
|
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(
|
|
94
|
+
actions.push(/*#__PURE__*/(0, _jsxRuntime.jsx)(_components.Button, {
|
|
95
95
|
__next40pxDefaultSize: true,
|
|
96
96
|
onClick: convertToHTML,
|
|
97
97
|
variant: "tertiary",
|
|
@@ -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","__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__next40pxDefaultSize\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,G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AAE,GAAGjB;AAAM,CAAC,KAAM;EAC1D,MAAM;IAAEC,YAAY;IAAEiB,0BAA0B;IAAEC;EAAS,CAAC,GAC3DnB,KAAK,CAACE,UAAU;EACjB,MAAM;IAAEkB;EAAa,CAAC,GAAG,IAAAC,iBAAW,EAAEC,kBAAiB,CAAC;EACxD,MAAMC,aAAa,GAAGA,CAAA,KAAM;IAC3BH,YAAY,CACXpB,KAAK,CAACmB,QAAQ,EACd,IAAAK,mBAAW,EAAE,WAAW,EAAE;MACzBC,OAAO,EAAEP;IACV,CAAE,CACH,CAAC;EACF,CAAC;EAED,MAAMQ,UAAU,GAAG,CAAC,CAAER,0BAA0B;EAChD,MAAMS,YAAY,GAAG,IAAAtB,eAAS,EAC3BC,MAAM,IAAM;IACb,MAAM;MAAEsB,kBAAkB;MAAEC;IAAqB,CAAC,GACjDvB,MAAM,CAAEgB,kBAAiB,CAAC;IAE3B,OAAOM,kBAAkB,CACxB,WAAW,EACXC,oBAAoB,CAAEV,QAAS,CAChC,CAAC;EACF,CAAC,EACD,CAAEA,QAAQ,CACX,CAAC;EAED,IAAIW,WAAW,GAAG,IAAAC,aAAO,
|
|
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__next40pxDefaultSize\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,sBA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T,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":[]}
|
|
@@ -46,7 +46,7 @@ function InstallButton({
|
|
|
46
46
|
disabled: isInstallingBlock,
|
|
47
47
|
isBusy: isInstallingBlock,
|
|
48
48
|
variant: "primary",
|
|
49
|
-
children: (0, _i18n.sprintf)(
|
|
49
|
+
children: (0, _i18n.sprintf)(/* translators: %s: block name */
|
|
50
50
|
(0, _i18n.__)('Install %s'), block.title)
|
|
51
51
|
});
|
|
52
52
|
}
|
|
@@ -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","__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__next40pxDefaultSize\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,IAA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Editor","_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__next40pxDefaultSize\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,MAAM;IACNC,qBAAqB;IACrBC,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,EACR;IACA,IAAAC,QAAE,EAAE,YAAa,CAAC,EAClBhC,KAAK,CAACiC,KACP;EAAC,CACM,CAAC;AAEX","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_blocks","require","_i18n","_apiFetch","_interopRequireDefault","_notices","_url","_loadAssets","_getPluginUrl","fetchDownloadableBlocks","filterValue","type","receiveDownloadableBlocks","downloadableBlocks","installBlockType","block","registry","dispatch","id","name","success","clearErrorNotice","setIsInstalling","url","getPluginUrl","links","apiFetch","method","data","status","response","path","slug","_links","addInstalledBlockType","metadataFields","addQueryArgs","_fields","catch","then","unstable__bootstrapServerSideBlockDefinitions","Object","fromEntries","entries","filter","key","includes","loadAssets","registeredBlocks","select","blocksStore","getBlockTypes","some","i","Error","__","noticesStore","createInfoNotice","sprintf","title","speak","error","message","isFatal","fatalAPIErrors","folder_exists","unable_to_connect_to_filesystem","code","setErrorNotice","createErrorNotice","isDismissible","exports","uninstallBlockType","removeInstalledBlockType","item","blockId","isInstalling"],"sources":["@wordpress/block-directory/src/store/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blocksStore,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n} from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { loadAssets } from './load-assets';\nimport getPluginUrl from './utils/get-plugin-url';\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been requested and are loading.\n *\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function fetchDownloadableBlocks( filterValue ) {\n\treturn { type: 'FETCH_DOWNLOADABLE_BLOCKS', filterValue };\n}\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been updated.\n *\n * @param {Array} downloadableBlocks Downloadable blocks.\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function receiveDownloadableBlocks( downloadableBlocks, filterValue ) {\n\treturn {\n\t\ttype: 'RECEIVE_DOWNLOADABLE_BLOCKS',\n\t\tdownloadableBlocks,\n\t\tfilterValue,\n\t};\n}\n\n/**\n * Action triggered to install a block plugin.\n *\n * @param {Object} block The block item returned by search.\n *\n * @return {boolean} Whether the block was successfully installed & loaded.\n */\nexport const installBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\tconst { id, name } = block;\n\t\tlet success = false;\n\t\tdispatch.clearErrorNotice( id );\n\t\ttry {\n\t\t\tdispatch.setIsInstalling( id, true );\n\n\t\t\t// If we have a wp:plugin link, the plugin is installed but inactive.\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tlet links = {};\n\t\t\tif ( url ) {\n\t\t\t\tawait apiFetch( {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\turl,\n\t\t\t\t\tdata: { status: 'active' },\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst response = await apiFetch( {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tpath: 'wp/v2/plugins',\n\t\t\t\t\tdata: { slug: id, status: 'active' },\n\t\t\t\t} );\n\t\t\t\t// Add the `self` link for newly-installed blocks.\n\t\t\t\tlinks = response._links;\n\t\t\t}\n\n\t\t\tdispatch.addInstalledBlockType( {\n\t\t\t\t...block,\n\t\t\t\tlinks: { ...block.links, ...links },\n\t\t\t} );\n\n\t\t\t// Ensures that the block metadata is propagated to the editor when registered on the server.\n\t\t\tconst metadataFields = [\n\t\t\t\t'api_version',\n\t\t\t\t'title',\n\t\t\t\t'category',\n\t\t\t\t'parent',\n\t\t\t\t'icon',\n\t\t\t\t'description',\n\t\t\t\t'keywords',\n\t\t\t\t'attributes',\n\t\t\t\t'provides_context',\n\t\t\t\t'uses_context',\n\t\t\t\t'supports',\n\t\t\t\t'styles',\n\t\t\t\t'example',\n\t\t\t\t'variations',\n\t\t\t];\n\t\t\tawait apiFetch( {\n\t\t\t\tpath: addQueryArgs( `/wp/v2/block-types/${ name }`, {\n\t\t\t\t\t_fields: metadataFields,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t// Ignore when the block is not registered on the server.\n\t\t\t\t.catch( () => {} )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( ! response ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tunstable__bootstrapServerSideBlockDefinitions( {\n\t\t\t\t\t\t[ name ]: Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( response ).filter( ( [ key ] ) =>\n\t\t\t\t\t\t\t\tmetadataFields.includes( key )\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\n\t\t\tawait loadAssets();\n\t\t\tconst registeredBlocks = registry\n\t\t\t\t.select( blocksStore )\n\t\t\t\t.getBlockTypes();\n\t\t\tif ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t__( 'Error registering block. Try reloading the page.' )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tregistry.dispatch( noticesStore ).createInfoNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s is the block title.\n\t\t\t\t\t__( 'Block %s installed and added.' ),\n\t\t\t\t\tblock.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\tspeak: true,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t\tsuccess = true;\n\t\t} catch ( error ) {\n\t\t\tlet message = error.message || __( 'An error occurred.' );\n\n\t\t\t// Errors we throw are fatal.\n\t\t\tlet isFatal = error instanceof Error;\n\n\t\t\t// Specific API errors that are fatal.\n\t\t\tconst fatalAPIErrors = {\n\t\t\t\tfolder_exists: __(\n\t\t\t\t\t'This block is already installed. Try reloading the page.'\n\t\t\t\t),\n\t\t\t\tunable_to_connect_to_filesystem: __(\n\t\t\t\t\t'Error installing block. You can reload the page and try again.'\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tif ( fatalAPIErrors[ error.code ] ) {\n\t\t\t\tisFatal = true;\n\t\t\t\tmessage = fatalAPIErrors[ error.code ];\n\t\t\t}\n\n\t\t\tdispatch.setErrorNotice( id, message, isFatal );\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice( message, {\n\t\t\t\tspeak: true,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}\n\t\tdispatch.setIsInstalling( id, false );\n\t\treturn success;\n\t};\n\n/**\n * Action triggered to uninstall a block plugin.\n *\n * @param {Object} block The blockType object.\n */\nexport const uninstallBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\ttry {\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'PUT',\n\t\t\t\turl,\n\t\t\t\tdata: { status: 'inactive' },\n\t\t\t} );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl,\n\t\t\t} );\n\t\t\tdispatch.removeInstalledBlockType( block );\n\t\t} catch ( error ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\terror.message || __( 'An error occurred.' )\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Returns an action object used to add a block type to the \"newly installed\"\n * tracking list.\n *\n * @param {Object} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function addInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'ADD_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to remove a block type from the \"newly installed\"\n * tracking list.\n *\n * @param {string} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function removeInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'REMOVE_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to indicate install in progress.\n *\n * @param {string} blockId\n * @param {boolean} isInstalling\n *\n * @return {Object} Action object.\n */\nexport function setIsInstalling( blockId, isInstalling ) {\n\treturn {\n\t\ttype: 'SET_INSTALLING_BLOCK',\n\t\tblockId,\n\t\tisInstalling,\n\t};\n}\n\n/**\n * Sets an error notice to be displayed to the user for a given block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n * @param {string} message The message shown in the notice.\n * @param {boolean} isFatal Whether the user can recover from the error.\n *\n * @return {Object} Action object.\n */\nexport function setErrorNotice( blockId, message, isFatal = false ) {\n\treturn {\n\t\ttype: 'SET_ERROR_NOTICE',\n\t\tblockId,\n\t\tmessage,\n\t\tisFatal,\n\t};\n}\n\n/**\n * Sets the error notice to empty for specific block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {Object} Action object.\n */\nexport function clearErrorNotice( blockId ) {\n\treturn {\n\t\ttype: 'CLEAR_ERROR_NOTICE',\n\t\tblockId,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,G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A;AACA;AACA;AACA;AACA;AACA;AACO,SAAS1C,gBAAgBA,CAAEsD,OAAO,EAAG;EAC3C,OAAO;IACNhE,IAAI,EAAE,oBAAoB;IAC1BgE;EACD,CAAC;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["_blocks","require","_i18n","_apiFetch","_interopRequireDefault","_notices","_url","_loadAssets","_getPluginUrl","fetchDownloadableBlocks","filterValue","type","receiveDownloadableBlocks","downloadableBlocks","installBlockType","block","registry","dispatch","id","name","success","clearErrorNotice","setIsInstalling","url","getPluginUrl","links","apiFetch","method","data","status","response","path","slug","_links","addInstalledBlockType","metadataFields","addQueryArgs","_fields","catch","then","unstable__bootstrapServerSideBlockDefinitions","Object","fromEntries","entries","filter","key","includes","loadAssets","registeredBlocks","select","blocksStore","getBlockTypes","some","i","Error","__","noticesStore","createInfoNotice","sprintf","title","speak","error","message","isFatal","fatalAPIErrors","folder_exists","unable_to_connect_to_filesystem","code","setErrorNotice","createErrorNotice","isDismissible","exports","uninstallBlockType","removeInstalledBlockType","item","blockId","isInstalling"],"sources":["@wordpress/block-directory/src/store/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blocksStore,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n} from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { loadAssets } from './load-assets';\nimport getPluginUrl from './utils/get-plugin-url';\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been requested and are loading.\n *\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function fetchDownloadableBlocks( filterValue ) {\n\treturn { type: 'FETCH_DOWNLOADABLE_BLOCKS', filterValue };\n}\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been updated.\n *\n * @param {Array} downloadableBlocks Downloadable blocks.\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function receiveDownloadableBlocks( downloadableBlocks, filterValue ) {\n\treturn {\n\t\ttype: 'RECEIVE_DOWNLOADABLE_BLOCKS',\n\t\tdownloadableBlocks,\n\t\tfilterValue,\n\t};\n}\n\n/**\n * Action triggered to install a block plugin.\n *\n * @param {Object} block The block item returned by search.\n *\n * @return {boolean} Whether the block was successfully installed & loaded.\n */\nexport const installBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\tconst { id, name } = block;\n\t\tlet success = false;\n\t\tdispatch.clearErrorNotice( id );\n\t\ttry {\n\t\t\tdispatch.setIsInstalling( id, true );\n\n\t\t\t// If we have a wp:plugin link, the plugin is installed but inactive.\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tlet links = {};\n\t\t\tif ( url ) {\n\t\t\t\tawait apiFetch( {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\turl,\n\t\t\t\t\tdata: { status: 'active' },\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst response = await apiFetch( {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tpath: 'wp/v2/plugins',\n\t\t\t\t\tdata: { slug: id, status: 'active' },\n\t\t\t\t} );\n\t\t\t\t// Add the `self` link for newly-installed blocks.\n\t\t\t\tlinks = response._links;\n\t\t\t}\n\n\t\t\tdispatch.addInstalledBlockType( {\n\t\t\t\t...block,\n\t\t\t\tlinks: { ...block.links, ...links },\n\t\t\t} );\n\n\t\t\t// Ensures that the block metadata is propagated to the editor when registered on the server.\n\t\t\tconst metadataFields = [\n\t\t\t\t'api_version',\n\t\t\t\t'title',\n\t\t\t\t'category',\n\t\t\t\t'parent',\n\t\t\t\t'icon',\n\t\t\t\t'description',\n\t\t\t\t'keywords',\n\t\t\t\t'attributes',\n\t\t\t\t'provides_context',\n\t\t\t\t'uses_context',\n\t\t\t\t'supports',\n\t\t\t\t'styles',\n\t\t\t\t'example',\n\t\t\t\t'variations',\n\t\t\t];\n\t\t\tawait apiFetch( {\n\t\t\t\tpath: addQueryArgs( `/wp/v2/block-types/${ name }`, {\n\t\t\t\t\t_fields: metadataFields,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t// Ignore when the block is not registered on the server.\n\t\t\t\t.catch( () => {} )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( ! response ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tunstable__bootstrapServerSideBlockDefinitions( {\n\t\t\t\t\t\t[ name ]: Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( response ).filter( ( [ key ] ) =>\n\t\t\t\t\t\t\t\tmetadataFields.includes( key )\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\n\t\t\tawait loadAssets();\n\t\t\tconst registeredBlocks = registry\n\t\t\t\t.select( blocksStore )\n\t\t\t\t.getBlockTypes();\n\t\t\tif ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t__( 'Error registering block. Try reloading the page.' )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tregistry.dispatch( noticesStore ).createInfoNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s is the block title.\n\t\t\t\t\t__( 'Block %s installed and added.' ),\n\t\t\t\t\tblock.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\tspeak: true,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t\tsuccess = true;\n\t\t} catch ( error ) {\n\t\t\tlet message = error.message || __( 'An error occurred.' );\n\n\t\t\t// Errors we throw are fatal.\n\t\t\tlet isFatal = error instanceof Error;\n\n\t\t\t// Specific API errors that are fatal.\n\t\t\tconst fatalAPIErrors = {\n\t\t\t\tfolder_exists: __(\n\t\t\t\t\t'This block is already installed. Try reloading the page.'\n\t\t\t\t),\n\t\t\t\tunable_to_connect_to_filesystem: __(\n\t\t\t\t\t'Error installing block. You can reload the page and try again.'\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tif ( fatalAPIErrors[ error.code ] ) {\n\t\t\t\tisFatal = true;\n\t\t\t\tmessage = fatalAPIErrors[ error.code ];\n\t\t\t}\n\n\t\t\tdispatch.setErrorNotice( id, message, isFatal );\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice( message, {\n\t\t\t\tspeak: true,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}\n\t\tdispatch.setIsInstalling( id, false );\n\t\treturn success;\n\t};\n\n/**\n * Action triggered to uninstall a block plugin.\n *\n * @param {Object} block The blockType object.\n */\nexport const uninstallBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\ttry {\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'PUT',\n\t\t\t\turl,\n\t\t\t\tdata: { status: 'inactive' },\n\t\t\t} );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl,\n\t\t\t} );\n\t\t\tdispatch.removeInstalledBlockType( block );\n\t\t} catch ( error ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\terror.message || __( 'An error occurred.' )\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Returns an action object used to add a block type to the \"newly installed\"\n * tracking list.\n *\n * @param {Object} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function addInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'ADD_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to remove a block type from the \"newly installed\"\n * tracking list.\n *\n * @param {string} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function removeInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'REMOVE_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to indicate install in progress.\n *\n * @param {string} blockId\n * @param {boolean} isInstalling\n *\n * @return {Object} Action object.\n */\nexport function setIsInstalling( blockId, isInstalling ) {\n\treturn {\n\t\ttype: 'SET_INSTALLING_BLOCK',\n\t\tblockId,\n\t\tisInstalling,\n\t};\n}\n\n/**\n * Sets an error notice to be displayed to the user for a given block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n * @param {string} message The message shown in the notice.\n * @param {boolean} isFatal Whether the user can recover from the error.\n *\n * @return {Object} Action object.\n */\nexport function setErrorNotice( blockId, message, isFatal = false ) {\n\treturn {\n\t\ttype: 'SET_ERROR_NOTICE',\n\t\tblockId,\n\t\tmessage,\n\t\tisFatal,\n\t};\n}\n\n/**\n * Sets the error notice to empty for specific block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {Object} Action object.\n */\nexport function clearErrorNotice( blockId ) {\n\treturn {\n\t\ttype: 'CLEAR_ERROR_NOTICE',\n\t\tblockId,\n\t};\n}\n"],"mappings":";;;;;;;;;;;;;;;AAGA,IAAAA,OAAA,GAAAC,OAAA;AAIA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,SAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,QAAA,GAAAJ,OAAA;AACA,IAAAK,IAAA,GAAAL,OAAA;AAKA,IAAAM,WAAA,GAAAN,OAAA;AACA,IAAAO,aAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAhBA;AACA;AACA;;AAUA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASQ,uBAAuBA,CAAEC,WAAW,EAAG;EACtD,OAAO;IAAEC,IAAI,EAAE,2BAA2B;IAAED;EAAY,CAAC;AAC1D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,yBAAyBA,CAAEC,kBAAkB,EAAEH,WAAW,EAAG;EAC5E,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,CAAEuC,cAAa,CAAC,CACxBa,iBAAiB,CACjBR,KAAK,CAACC,OAAO,IAAI,IAAAP,QAAE,EAAE,oBAAqB,CAC3C,CAAC;EACH;AACD,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAgB,OAAA,CAAAC,kBAAA,GAAAA,kBAAA;AAQO,SAAStC,qBAAqBA,CAAEwC,IAAI,EAAG;EAC7C,OAAO;IACN/D,IAAI,EAAE,0BAA0B;IAChC+D;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASD,wBAAwBA,CAAEC,IAAI,EAAG;EAChD,OAAO;IACN/D,IAAI,EAAE,6BAA6B;IACnC+D;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASpD,eAAeA,CAAEqD,OAAO,EAAEC,YAAY,EAAG;EACxD,OAAO;IACNjE,IAAI,EAAE,sBAAsB;IAC5BgE,OAAO;IACPC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASR,cAAcA,CAAEO,OAAO,EAAEb,OAAO,EAAEC,OAAO,GAAG,KAAK,EAAG;EACnE,OAAO;IACNpD,IAAI,EAAE,kBAAkB;IACxBgE,OAAO;IACPb,OAAO;IACPC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAAS1C,gBAAgBA,CAAEsD,OAAO,EAAG;EAC3C,OAAO;IACNhE,IAAI,EAAE,oBAAoB;IAC1BgE;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_changeCase","require","_apiFetch","_interopRequireDefault","_actions","getDownloadableBlocks","filterValue","dispatch","fetchDownloadableBlocks","results","apiFetch","path","blocks","map","result","Object","fromEntries","entries","key","value","camelCase","receiveDownloadableBlocks","exports"],"sources":["@wordpress/block-directory/src/store/resolvers.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks =\n\t( filterValue ) =>\n\tasync ( { dispatch } ) => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\t\tconst results = await apiFetch( {\n\t\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t\t} );\n\t\t\tconst blocks = results.map( ( result ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( result ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t\t} catch {}\n\t};\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGO,MAAMI,qBAAqB,GAC/BC,WAAW,IACb,OAAQ;EAAEC;AAAS,CAAC,KAAM;EACzB,IAAK,CAAED,WAAW,EAAG;IACpB;EACD;EAEA,IAAI;IACHC,QAAQ,CAAE,IAAAC,gCAAuB,EAAEF,WAAY,CAAE,CAAC;IAClD,MAAMG,OAAO,GAAG,MAAM,IAAAC,iBAAQ,EAAE;MAC/BC,IAAI,
|
|
1
|
+
{"version":3,"names":["_changeCase","require","_apiFetch","_interopRequireDefault","_actions","getDownloadableBlocks","filterValue","dispatch","fetchDownloadableBlocks","results","apiFetch","path","blocks","map","result","Object","fromEntries","entries","key","value","camelCase","receiveDownloadableBlocks","exports"],"sources":["@wordpress/block-directory/src/store/resolvers.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks =\n\t( filterValue ) =>\n\tasync ( { dispatch } ) => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\t\tconst results = await apiFetch( {\n\t\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t\t} );\n\t\t\tconst blocks = results.map( ( result ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( result ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t\t} catch {}\n\t};\n"],"mappings":";;;;;;;AAGA,IAAAA,WAAA,GAAAC,OAAA;AAKA,IAAAC,SAAA,GAAAC,sBAAA,CAAAF,OAAA;AAKA,IAAAG,QAAA,GAAAH,OAAA;AAbA;AACA;AACA;;AAGA;AACA;AACA;;AAGA;AACA;AACA;;AAGO,MAAMI,qBAAqB,GAC/BC,WAAW,IACb,OAAQ;EAAEC;AAAS,CAAC,KAAM;EACzB,IAAK,CAAED,WAAW,EAAG;IACpB;EACD;EAEA,IAAI;IACHC,QAAQ,CAAE,IAAAC,gCAAuB,EAAEF,WAAY,CAAE,CAAC;IAClD,MAAMG,OAAO,GAAG,MAAM,IAAAC,iBAAQ,EAAE;MAC/BC,IAAI,EAAE,qCAAsCL,WAAW;IACxD,CAAE,CAAC;IACH,MAAMM,MAAM,GAAGH,OAAO,CAACI,GAAG,CAAIC,MAAM,IACnCC,MAAM,CAACC,WAAW,CACjBD,MAAM,CAACE,OAAO,CAAEH,MAAO,CAAC,CAACD,GAAG,CAAE,CAAE,CAAEK,GAAG,EAAEC,KAAK,CAAE,KAAM,CACnD,IAAAC,qBAAS,EAAEF,GAAI,CAAC,EAChBC,KAAK,CACJ,CACH,CACD,CAAC;IAEDZ,QAAQ,CAAE,IAAAc,kCAAyB,EAAET,MAAM,EAAEN,WAAY,CAAE,CAAC;EAC7D,CAAC,CAAC,MAAM,CAAC;AACV,CAAC;AAACgB,OAAA,CAAAjB,qBAAA,GAAAA,qBAAA","ignoreList":[]}
|
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __, sprintf } from '@wordpress/i18n';
|
|
5
5
|
import { Icon, starEmpty, starFilled, starHalf } from '@wordpress/icons';
|
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
7
|
function Stars({
|
|
9
8
|
rating
|
|
10
9
|
}) {
|
|
@@ -13,7 +12,7 @@ function Stars({
|
|
|
13
12
|
const halfStarCount = Math.ceil(rating - fullStarCount);
|
|
14
13
|
const emptyStarCount = 5 - (fullStarCount + halfStarCount);
|
|
15
14
|
return /*#__PURE__*/_jsxs("span", {
|
|
16
|
-
"aria-label": sprintf(
|
|
15
|
+
"aria-label": sprintf(/* translators: %s: number of stars. */
|
|
17
16
|
__('%s out of 5 stars'), stars),
|
|
18
17
|
children: [Array.from({
|
|
19
18
|
length: fullStarCount
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","sprintf","Icon","starEmpty","starFilled","starHalf","jsx","_jsx","jsxs","_jsxs","Stars","rating","stars","Math","round","fullStarCount","floor","halfStarCount","ceil","emptyStarCount","children","Array","from","length","map","_","i","className","icon","size"],"sources":["@wordpress/block-directory/src/components/block-ratings/stars.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Icon, starEmpty, starFilled, starHalf } from '@wordpress/icons';\n\nfunction Stars( { rating } ) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tconst fullStarCount = Math.floor( rating );\n\tconst halfStarCount = Math.ceil( rating - fullStarCount );\n\tconst emptyStarCount = 5 - ( fullStarCount + halfStarCount );\n\n\treturn (\n\t\t<span\n\t\t\taria-label={ sprintf(\n\t\t\t\t/* translators: %s: number of stars. */\n\t\t\t\t__( '%s out of 5 stars' ),\n\t\t\t\tstars\n\t\t\t) }\n\t\t>\n\t\t\t{ Array.from( { length: fullStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `full_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-full\"\n\t\t\t\t\ticon={ starFilled }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: halfStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `half_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-half-full\"\n\t\t\t\t\ticon={ starHalf }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: emptyStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `empty_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-empty\"\n\t\t\t\t\ticon={ starEmpty }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t</span>\n\t);\n}\n\nexport default Stars;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,IAAI,EAAEC,SAAS,EAAEC,UAAU,EAAEC,QAAQ,QAAQ,kBAAkB;AAAC,SAAAC,GAAA,IAAAC,IAAA
|
|
1
|
+
{"version":3,"names":["__","sprintf","Icon","starEmpty","starFilled","starHalf","jsx","_jsx","jsxs","_jsxs","Stars","rating","stars","Math","round","fullStarCount","floor","halfStarCount","ceil","emptyStarCount","children","Array","from","length","map","_","i","className","icon","size"],"sources":["@wordpress/block-directory/src/components/block-ratings/stars.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\nimport { Icon, starEmpty, starFilled, starHalf } from '@wordpress/icons';\n\nfunction Stars( { rating } ) {\n\tconst stars = Math.round( rating / 0.5 ) * 0.5;\n\n\tconst fullStarCount = Math.floor( rating );\n\tconst halfStarCount = Math.ceil( rating - fullStarCount );\n\tconst emptyStarCount = 5 - ( fullStarCount + halfStarCount );\n\n\treturn (\n\t\t<span\n\t\t\taria-label={ sprintf(\n\t\t\t\t/* translators: %s: number of stars. */\n\t\t\t\t__( '%s out of 5 stars' ),\n\t\t\t\tstars\n\t\t\t) }\n\t\t>\n\t\t\t{ Array.from( { length: fullStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `full_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-full\"\n\t\t\t\t\ticon={ starFilled }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: halfStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `half_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-half-full\"\n\t\t\t\t\ticon={ starHalf }\n\t\t\t\t\tsize={ 16 }\n\t\t\t\t/>\n\t\t\t) ) }\n\t\t\t{ Array.from( { length: emptyStarCount } ).map( ( _, i ) => (\n\t\t\t\t<Icon\n\t\t\t\t\tkey={ `empty_stars_${ i }` }\n\t\t\t\t\tclassName=\"block-directory-block-ratings__star-empty\"\n\t\t\t\t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,IAAI,EAAG;IAAI,GAHL,cAAeH,CAAC,EAItB,CACA,CAAC,EACDL,KAAK,CAACC,IAAI,CAAE;MAAEC,MAAM,EAAEJ;IAAe,CAAE,CAAC,CAACK,GAAG,CAAE,CAAEC,CAAC,EAAEC,CAAC,kBACrDnB,IAAA,CAACL,IAAI;MAEJyB,SAAS,EAAC,2CAA2C;MACrDC,IAAI,EAAGzB,SAAW;MAClB0B,IAAI,EAAG;IAAI,GAHL,eAAgBH,CAAC,EAIvB,CACA,CAAC;EAAA,CACE,CAAC;AAET;AAEA,eAAehB,KAAK","ignoreList":[]}
|
|
@@ -7,8 +7,7 @@ import { __, sprintf } from '@wordpress/i18n';
|
|
|
7
7
|
* Internal dependencies
|
|
8
8
|
*/
|
|
9
9
|
import DownloadableBlockIcon from '../downloadable-block-icon';
|
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
11
|
export default function CompactList({
|
|
13
12
|
items
|
|
14
13
|
}) {
|
|
@@ -34,7 +33,7 @@ export default function CompactList({
|
|
|
34
33
|
children: title
|
|
35
34
|
}), /*#__PURE__*/_jsx("div", {
|
|
36
35
|
className: "block-directory-compact-list__item-author",
|
|
37
|
-
children: sprintf(
|
|
36
|
+
children: sprintf(/* translators: %s: Name of the block author. */
|
|
38
37
|
__('By %s'), author)
|
|
39
38
|
})]
|
|
40
39
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","sprintf","DownloadableBlockIcon","jsx","_jsx","jsxs","_jsxs","CompactList","items","length","className","children","map","icon","id","title","author"],"sources":["@wordpress/block-directory/src/components/compact-list/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlockIcon from '../downloadable-block-icon';\n\nexport default function CompactList( { items } ) {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ul className=\"block-directory-compact-list\">\n\t\t\t{ items.map( ( { icon, id, title, author } ) => (\n\t\t\t\t<li key={ id } className=\"block-directory-compact-list__item\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\n\t\t\t\t\t<div className=\"block-directory-compact-list__item-details\">\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-title\">\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-author\">\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: Name of the block author. */\n\t\t\t\t\t\t\t\t__( 'By %s' ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,4BAA4B;AAAC,SAAAC,GAAA,IAAAC,IAAA
|
|
1
|
+
{"version":3,"names":["__","sprintf","DownloadableBlockIcon","jsx","_jsx","jsxs","_jsxs","CompactList","items","length","className","children","map","icon","id","title","author"],"sources":["@wordpress/block-directory/src/components/compact-list/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, sprintf } from '@wordpress/i18n';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlockIcon from '../downloadable-block-icon';\n\nexport default function CompactList( { items } ) {\n\tif ( ! items.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<ul className=\"block-directory-compact-list\">\n\t\t\t{ items.map( ( { icon, id, title, author } ) => (\n\t\t\t\t<li key={ id } className=\"block-directory-compact-list__item\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\n\t\t\t\t\t<div className=\"block-directory-compact-list__item-details\">\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-title\">\n\t\t\t\t\t\t\t{ title }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t\t<div className=\"block-directory-compact-list__item-author\">\n\t\t\t\t\t\t\t{ sprintf(\n\t\t\t\t\t\t\t\t/* translators: %s: Name of the block author. */\n\t\t\t\t\t\t\t\t__( 'By %s' ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</div>\n\t\t\t\t\t</div>\n\t\t\t\t</li>\n\t\t\t) ) }\n\t\t</ul>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;;AAE7C;AACA;AACA;AACA,OAAOC,qBAAqB,MAAM,4BAA4B;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE/D,eAAe,SAASC,WAAWA,CAAE;EAAEC;AAAM,CAAC,EAAG;EAChD,IAAK,CAAEA,KAAK,CAACC,MAAM,EAAG;IACrB,OAAO,IAAI;EACZ;EAEA,oBACCL,IAAA;IAAIM,SAAS,EAAC,8BAA8B;IAAAC,QAAA,EACzCH,KAAK,CAACI,GAAG,CAAE,CAAE;MAAEC,IAAI;MAAEC,EAAE;MAAEC,KAAK;MAAEC;IAAO,CAAC,kBACzCV,KAAA;MAAeI,SAAS,EAAC,oCAAoC;MAAAC,QAAA,gBAC5DP,IAAA,CAACF,qBAAqB;QAACW,IAAI,EAAGA,IAAM;QAACE,KAAK,EAAGA;MAAO,CAAE,CAAC,eAEvDT,KAAA;QAAKI,SAAS,EAAC,4CAA4C;QAAAC,QAAA,gBAC1DP,IAAA;UAAKM,SAAS,EAAC,0CAA0C;UAAAC,QAAA,EACtDI;QAAK,CACH,CAAC,eACNX,IAAA;UAAKM,SAAS,EAAC,2CAA2C;UAAAC,QAAA,EACvDV,OAAO,CACR;UACAD,EAAE,CAAE,OAAQ,CAAC,EACbgB,MACD;QAAC,CACG,CAAC;MAAA,CACF,CAAC;IAAA,GAdGF,EAeN,CACH;EAAC,CACA,CAAC;AAEP","ignoreList":[]}
|
|
@@ -22,9 +22,7 @@ import DownloadableBlockNotice from '../downloadable-block-notice';
|
|
|
22
22
|
import { store as blockDirectoryStore } from '../../store';
|
|
23
23
|
|
|
24
24
|
// Return the appropriate block item label, given the block data and status.
|
|
25
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
26
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
25
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
28
26
|
function getDownloadableBlockLabel({
|
|
29
27
|
title,
|
|
30
28
|
rating,
|
|
@@ -36,24 +34,24 @@ function getDownloadableBlockLabel({
|
|
|
36
34
|
}) {
|
|
37
35
|
const stars = Math.round(rating / 0.5) * 0.5;
|
|
38
36
|
if (!isInstalled && hasNotice) {
|
|
39
|
-
/* translators: %
|
|
37
|
+
/* translators: %s: block title */
|
|
40
38
|
return sprintf('Retry installing %s.', decodeEntities(title));
|
|
41
39
|
}
|
|
42
40
|
if (isInstalled) {
|
|
43
|
-
/* translators: %
|
|
41
|
+
/* translators: %s: block title */
|
|
44
42
|
return sprintf('Add %s.', decodeEntities(title));
|
|
45
43
|
}
|
|
46
44
|
if (isInstalling) {
|
|
47
|
-
/* translators: %
|
|
45
|
+
/* translators: %s: block title */
|
|
48
46
|
return sprintf('Installing %s.', decodeEntities(title));
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
// No ratings yet, just use the title.
|
|
52
50
|
if (ratingCount < 1) {
|
|
53
|
-
/* translators: %
|
|
51
|
+
/* translators: %s: block title */
|
|
54
52
|
return sprintf('Install %s.', decodeEntities(title));
|
|
55
53
|
}
|
|
56
|
-
return sprintf(
|
|
54
|
+
return sprintf(/* translators: 1: block title, 2: average rating, 3: total ratings count. */
|
|
57
55
|
_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);
|
|
58
56
|
}
|
|
59
57
|
function DownloadableBlockListItem({
|
|
@@ -126,7 +124,7 @@ function DownloadableBlockListItem({
|
|
|
126
124
|
className: "block-directory-downloadable-block-list-item__details",
|
|
127
125
|
children: [/*#__PURE__*/_jsx("span", {
|
|
128
126
|
className: "block-directory-downloadable-block-list-item__title",
|
|
129
|
-
children: createInterpolateElement(sprintf(
|
|
127
|
+
children: createInterpolateElement(sprintf(/* translators: 1: block title. 2: author name. */
|
|
130
128
|
__('%1$s <span>by %2$s</span>'), decodeEntities(title), author), {
|
|
131
129
|
span: /*#__PURE__*/_jsx("span", {
|
|
132
130
|
className: "block-directory-downloadable-block-list-item__author"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["clsx","__","_n","sprintf","Tooltip","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","itemLabel","placement","text","children","Item","className","accessibleWhenDisabled","disabled","event","preventDefault","type","role","span","block"],"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tTooltip,\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
|
+
{"version":3,"names":["clsx","__","_n","sprintf","Tooltip","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","itemLabel","placement","text","children","Item","className","accessibleWhenDisabled","disabled","event","preventDefault","type","role","span","block"],"sources":["@wordpress/block-directory/src/components/downloadable-block-list-item/index.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport clsx from 'clsx';\n\n/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport {\n\tTooltip,\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: %s: block title */\n\t\treturn sprintf( 'Retry installing %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalled ) {\n\t\t/* translators: %s: block title */\n\t\treturn sprintf( 'Add %s.', decodeEntities( title ) );\n\t}\n\n\tif ( isInstalling ) {\n\t\t/* translators: %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: %s: block title */\n\t\treturn sprintf( 'Install %s.', decodeEntities( title ) );\n\t}\n\n\treturn sprintf(\n\t\t/* translators: 1: block title, 2: average rating, 3: 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\tconst itemLabel = getDownloadableBlockLabel( item, {\n\t\thasNotice,\n\t\tisInstalled,\n\t\tisInstalling,\n\t} );\n\n\treturn (\n\t\t<Tooltip placement=\"top\" text={ itemLabel }>\n\t\t\t<Composite.Item\n\t\t\t\tclassName={ clsx(\n\t\t\t\t\t'block-directory-downloadable-block-list-item',\n\t\t\t\t\tisInstalling && 'is-installing'\n\t\t\t\t) }\n\t\t\t\taccessibleWhenDisabled\n\t\t\t\tdisabled={ isInstalling || ! isInstallable }\n\t\t\t\tonClick={ ( event ) => {\n\t\t\t\t\tevent.preventDefault();\n\t\t\t\t\tonClick();\n\t\t\t\t} }\n\t\t\t\taria-label={ itemLabel }\n\t\t\t\ttype=\"button\"\n\t\t\t\trole=\"option\"\n\t\t\t>\n\t\t\t\t<div className=\"block-directory-downloadable-block-list-item__icon\">\n\t\t\t\t\t<DownloadableBlockIcon icon={ icon } title={ title } />\n\t\t\t\t\t{ isInstalling ? (\n\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__spinner\">\n\t\t\t\t\t\t\t<Spinner />\n\t\t\t\t\t\t</span>\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<BlockRatings rating={ rating } />\n\t\t\t\t\t) }\n\t\t\t\t</div>\n\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__details\">\n\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__title\">\n\t\t\t\t\t\t{ createInterpolateElement(\n\t\t\t\t\t\t\tsprintf(\n\t\t\t\t\t\t\t\t/* translators: 1: block title. 2: author name. */\n\t\t\t\t\t\t\t\t__( '%1$s <span>by %2$s</span>' ),\n\t\t\t\t\t\t\t\tdecodeEntities( title ),\n\t\t\t\t\t\t\t\tauthor\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tspan: (\n\t\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\t),\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t) }\n\t\t\t\t\t</span>\n\t\t\t\t\t{ hasNotice ? (\n\t\t\t\t\t\t<DownloadableBlockNotice block={ item } />\n\t\t\t\t\t) : (\n\t\t\t\t\t\t<>\n\t\t\t\t\t\t\t<span className=\"block-directory-downloadable-block-list-item__desc\">\n\t\t\t\t\t\t\t\t{ !! statusText\n\t\t\t\t\t\t\t\t\t? statusText\n\t\t\t\t\t\t\t\t\t: decodeEntities( description ) }\n\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t{ isInstallable &&\n\t\t\t\t\t\t\t\t! ( isInstalled || isInstalling ) && (\n\t\t\t\t\t\t\t\t\t<VisuallyHidden>\n\t\t\t\t\t\t\t\t\t\t{ __( 'Install block' ) }\n\t\t\t\t\t\t\t\t\t</VisuallyHidden>\n\t\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</Composite.Item>\n\t\t</Tooltip>\n\t);\n}\n\nexport default DownloadableBlockListItem;\n"],"mappings":"AAAA;AACA;AACA;AACA,OAAOA,IAAI,MAAM,MAAM;;AAEvB;AACA;AACA;AACA,SAASC,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SACCC,OAAO,EACPC,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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8,8 +8,7 @@ import { useSelect } from '@wordpress/data';
|
|
|
8
8
|
* Internal dependencies
|
|
9
9
|
*/
|
|
10
10
|
import { store as blockDirectoryStore } from '../../store';
|
|
11
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
13
12
|
export const DownloadableBlockNotice = ({
|
|
14
13
|
block
|
|
15
14
|
}) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","useSelect","store","blockDirectoryStore","jsxs","_jsxs","jsx","_jsx","DownloadableBlockNotice","block","errorNotice","select","getErrorNoticeForBlock","id","className","children","message","isFatal"],"sources":["@wordpress/block-directory/src/components/downloadable-block-notice/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockDirectoryStore } from '../../store';\n\nexport const DownloadableBlockNotice = ( { block } ) => {\n\tconst errorNotice = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockDirectoryStore ).getErrorNoticeForBlock( block.id ),\n\t\t[ block ]\n\t);\n\n\tif ( ! errorNotice ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-directory-downloadable-block-notice\">\n\t\t\t<div className=\"block-directory-downloadable-block-notice__content\">\n\t\t\t\t{ errorNotice.message }\n\t\t\t\t{ errorNotice.isFatal\n\t\t\t\t\t? ' ' + __( 'Try reloading the page.' )\n\t\t\t\t\t: null }\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default DownloadableBlockNotice;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,mBAAmB,QAAQ,aAAa;AAAC,SAAAC,IAAA,IAAAC,KAAA
|
|
1
|
+
{"version":3,"names":["__","useSelect","store","blockDirectoryStore","jsxs","_jsxs","jsx","_jsx","DownloadableBlockNotice","block","errorNotice","select","getErrorNoticeForBlock","id","className","children","message","isFatal"],"sources":["@wordpress/block-directory/src/components/downloadable-block-notice/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\n\n/**\n * Internal dependencies\n */\nimport { store as blockDirectoryStore } from '../../store';\n\nexport const DownloadableBlockNotice = ( { block } ) => {\n\tconst errorNotice = useSelect(\n\t\t( select ) =>\n\t\t\tselect( blockDirectoryStore ).getErrorNoticeForBlock( block.id ),\n\t\t[ block ]\n\t);\n\n\tif ( ! errorNotice ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<div className=\"block-directory-downloadable-block-notice\">\n\t\t\t<div className=\"block-directory-downloadable-block-notice__content\">\n\t\t\t\t{ errorNotice.message }\n\t\t\t\t{ errorNotice.isFatal\n\t\t\t\t\t? ' ' + __( 'Try reloading the page.' )\n\t\t\t\t\t: null }\n\t\t\t</div>\n\t\t</div>\n\t);\n};\n\nexport default DownloadableBlockNotice;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,SAAS,QAAQ,iBAAiB;;AAE3C;AACA;AACA;AACA,SAASC,KAAK,IAAIC,mBAAmB,QAAQ,aAAa;AAAC,SAAAC,IAAA,IAAAC,KAAA,EAAAC,GAAA,IAAAC,IAAA;AAE3D,OAAO,MAAMC,uBAAuB,GAAGA,CAAE;EAAEC;AAAM,CAAC,KAAM;EACvD,MAAMC,WAAW,GAAGT,SAAS,CAC1BU,MAAM,IACPA,MAAM,CAAER,mBAAoB,CAAC,CAACS,sBAAsB,CAAEH,KAAK,CAACI,EAAG,CAAC,EACjE,CAAEJ,KAAK,CACR,CAAC;EAED,IAAK,CAAEC,WAAW,EAAG;IACpB,OAAO,IAAI;EACZ;EAEA,oBACCH,IAAA;IAAKO,SAAS,EAAC,2CAA2C;IAAAC,QAAA,eACzDV,KAAA;MAAKS,SAAS,EAAC,oDAAoD;MAAAC,QAAA,GAChEL,WAAW,CAACM,OAAO,EACnBN,WAAW,CAACO,OAAO,GAClB,GAAG,GAAGjB,EAAE,CAAE,yBAA0B,CAAC,GACrC,IAAI;IAAA,CACH;EAAC,CACF,CAAC;AAER,CAAC;AAED,eAAeQ,uBAAuB","ignoreList":[]}
|
|
@@ -14,9 +14,7 @@ import DownloadableBlocksList from '../downloadable-blocks-list';
|
|
|
14
14
|
import DownloadableBlocksInserterPanel from './inserter-panel';
|
|
15
15
|
import DownloadableBlocksNoResults from './no-results';
|
|
16
16
|
import { store as blockDirectoryStore } from '../../store';
|
|
17
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
20
18
|
const EMPTY_ARRAY = [];
|
|
21
19
|
const useDownloadableBlocks = filterValue => useSelect(select => {
|
|
22
20
|
const {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","Spinner","store","coreStore","useSelect","getBlockType","DownloadableBlocksList","DownloadableBlocksInserterPanel","DownloadableBlocksNoResults","blockDirectoryStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","EMPTY_ARRAY","useDownloadableBlocks","filterValue","select","getDownloadableBlocks","isRequestingDownloadableBlocks","getInstalledBlockTypes","hasPermission","canUser","downloadableBlocks","installedBlockTypes","installableBlocks","filter","name","isJustInstalled","some","blockType","isPreviouslyInstalled","length","isLoading","DownloadableBlocksPanel","onSelect","onHover","hasLocalBlocks","isTyping","undefined","children","className","downloadableItems","items"],"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlocksList from '../downloadable-blocks-list';\nimport DownloadableBlocksInserterPanel from './inserter-panel';\nimport DownloadableBlocksNoResults from './no-results';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst EMPTY_ARRAY = [];\n\nconst useDownloadableBlocks = ( filterValue ) =>\n\tuseSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetDownloadableBlocks,\n\t\t\t\tisRequestingDownloadableBlocks,\n\t\t\t\tgetInstalledBlockTypes,\n\t\t\t} = select( blockDirectoryStore );\n\n\t\t\tconst hasPermission = select( coreStore ).canUser(\n\t\t\t\t'read',\n\t\t\t\t'block-directory/search'\n\t\t\t);\n\n\t\t\tlet downloadableBlocks = EMPTY_ARRAY;\n\t\t\tif ( hasPermission ) {\n\t\t\t\tdownloadableBlocks = getDownloadableBlocks( filterValue );\n\n\t\t\t\t// Filter out blocks that are already installed.\n\t\t\t\tconst installedBlockTypes = getInstalledBlockTypes();\n\t\t\t\tconst installableBlocks = downloadableBlocks.filter(\n\t\t\t\t\t( { name } ) => {\n\t\t\t\t\t\t// Check if the block has just been installed, in which case it\n\t\t\t\t\t\t// should still show in the list to avoid suddenly disappearing.\n\t\t\t\t\t\t// `installedBlockTypes` only returns blocks stored in state\n\t\t\t\t\t\t// immediately after installation, not all installed blocks.\n\t\t\t\t\t\tconst isJustInstalled = installedBlockTypes.some(\n\t\t\t\t\t\t\t( blockType ) => blockType.name === name\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst isPreviouslyInstalled = getBlockType( name );\n\t\t\t\t\t\treturn isJustInstalled || ! isPreviouslyInstalled;\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\t// Keep identity of the `downloadableBlocks` array if nothing was filtered out\n\t\t\t\tif ( installableBlocks.length !== downloadableBlocks.length ) {\n\t\t\t\t\tdownloadableBlocks = installableBlocks;\n\t\t\t\t}\n\n\t\t\t\t// Return identical empty array when there are no blocks\n\t\t\t\tif ( downloadableBlocks.length === 0 ) {\n\t\t\t\t\tdownloadableBlocks = EMPTY_ARRAY;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\thasPermission,\n\t\t\t\tdownloadableBlocks,\n\t\t\t\tisLoading: isRequestingDownloadableBlocks( filterValue ),\n\t\t\t};\n\t\t},\n\t\t[ filterValue ]\n\t);\n\nexport default function DownloadableBlocksPanel( {\n\tonSelect,\n\tonHover,\n\thasLocalBlocks,\n\tisTyping,\n\tfilterValue,\n} ) {\n\tconst { hasPermission, downloadableBlocks, isLoading } =\n\t\tuseDownloadableBlocks( filterValue );\n\n\tif ( hasPermission === undefined || isLoading || isTyping ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ hasPermission && ! hasLocalBlocks && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__no-local\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'No results available from your installed blocks.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<div className=\"block-directory-downloadable-blocks-panel has-blocks-loading\">\n\t\t\t\t\t<Spinner />\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tif ( false === hasPermission ) {\n\t\tif ( ! hasLocalBlocks ) {\n\t\t\treturn <DownloadableBlocksNoResults />;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tif ( downloadableBlocks.length === 0 ) {\n\t\treturn hasLocalBlocks ? null : <DownloadableBlocksNoResults />;\n\t}\n\n\treturn (\n\t\t<DownloadableBlocksInserterPanel\n\t\t\tdownloadableItems={ downloadableBlocks }\n\t\t\thasLocalBlocks={ hasLocalBlocks }\n\t\t>\n\t\t\t<DownloadableBlocksList\n\t\t\t\titems={ downloadableBlocks }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tonHover={ onHover }\n\t\t\t/>\n\t\t</DownloadableBlocksInserterPanel>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,OAAO,QAAQ,uBAAuB;AAC/C,SAASC,KAAK,IAAIC,SAAS,QAAQ,sBAAsB;AACzD,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,YAAY,QAAQ,mBAAmB;;AAEhD;AACA;AACA;AACA,OAAOC,sBAAsB,MAAM,6BAA6B;AAChE,OAAOC,+BAA+B,MAAM,kBAAkB;AAC9D,OAAOC,2BAA2B,MAAM,cAAc;AACtD,SAASN,KAAK,IAAIO,mBAAmB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA
|
|
1
|
+
{"version":3,"names":["__","Spinner","store","coreStore","useSelect","getBlockType","DownloadableBlocksList","DownloadableBlocksInserterPanel","DownloadableBlocksNoResults","blockDirectoryStore","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","EMPTY_ARRAY","useDownloadableBlocks","filterValue","select","getDownloadableBlocks","isRequestingDownloadableBlocks","getInstalledBlockTypes","hasPermission","canUser","downloadableBlocks","installedBlockTypes","installableBlocks","filter","name","isJustInstalled","some","blockType","isPreviouslyInstalled","length","isLoading","DownloadableBlocksPanel","onSelect","onHover","hasLocalBlocks","isTyping","undefined","children","className","downloadableItems","items"],"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Spinner } from '@wordpress/components';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useSelect } from '@wordpress/data';\nimport { getBlockType } from '@wordpress/blocks';\n\n/**\n * Internal dependencies\n */\nimport DownloadableBlocksList from '../downloadable-blocks-list';\nimport DownloadableBlocksInserterPanel from './inserter-panel';\nimport DownloadableBlocksNoResults from './no-results';\nimport { store as blockDirectoryStore } from '../../store';\n\nconst EMPTY_ARRAY = [];\n\nconst useDownloadableBlocks = ( filterValue ) =>\n\tuseSelect(\n\t\t( select ) => {\n\t\t\tconst {\n\t\t\t\tgetDownloadableBlocks,\n\t\t\t\tisRequestingDownloadableBlocks,\n\t\t\t\tgetInstalledBlockTypes,\n\t\t\t} = select( blockDirectoryStore );\n\n\t\t\tconst hasPermission = select( coreStore ).canUser(\n\t\t\t\t'read',\n\t\t\t\t'block-directory/search'\n\t\t\t);\n\n\t\t\tlet downloadableBlocks = EMPTY_ARRAY;\n\t\t\tif ( hasPermission ) {\n\t\t\t\tdownloadableBlocks = getDownloadableBlocks( filterValue );\n\n\t\t\t\t// Filter out blocks that are already installed.\n\t\t\t\tconst installedBlockTypes = getInstalledBlockTypes();\n\t\t\t\tconst installableBlocks = downloadableBlocks.filter(\n\t\t\t\t\t( { name } ) => {\n\t\t\t\t\t\t// Check if the block has just been installed, in which case it\n\t\t\t\t\t\t// should still show in the list to avoid suddenly disappearing.\n\t\t\t\t\t\t// `installedBlockTypes` only returns blocks stored in state\n\t\t\t\t\t\t// immediately after installation, not all installed blocks.\n\t\t\t\t\t\tconst isJustInstalled = installedBlockTypes.some(\n\t\t\t\t\t\t\t( blockType ) => blockType.name === name\n\t\t\t\t\t\t);\n\t\t\t\t\t\tconst isPreviouslyInstalled = getBlockType( name );\n\t\t\t\t\t\treturn isJustInstalled || ! isPreviouslyInstalled;\n\t\t\t\t\t}\n\t\t\t\t);\n\n\t\t\t\t// Keep identity of the `downloadableBlocks` array if nothing was filtered out\n\t\t\t\tif ( installableBlocks.length !== downloadableBlocks.length ) {\n\t\t\t\t\tdownloadableBlocks = installableBlocks;\n\t\t\t\t}\n\n\t\t\t\t// Return identical empty array when there are no blocks\n\t\t\t\tif ( downloadableBlocks.length === 0 ) {\n\t\t\t\t\tdownloadableBlocks = EMPTY_ARRAY;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\thasPermission,\n\t\t\t\tdownloadableBlocks,\n\t\t\t\tisLoading: isRequestingDownloadableBlocks( filterValue ),\n\t\t\t};\n\t\t},\n\t\t[ filterValue ]\n\t);\n\nexport default function DownloadableBlocksPanel( {\n\tonSelect,\n\tonHover,\n\thasLocalBlocks,\n\tisTyping,\n\tfilterValue,\n} ) {\n\tconst { hasPermission, downloadableBlocks, isLoading } =\n\t\tuseDownloadableBlocks( filterValue );\n\n\tif ( hasPermission === undefined || isLoading || isTyping ) {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t{ hasPermission && ! hasLocalBlocks && (\n\t\t\t\t\t<>\n\t\t\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__no-local\">\n\t\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t\t'No results available from your installed blocks.'\n\t\t\t\t\t\t\t) }\n\t\t\t\t\t\t</p>\n\t\t\t\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\t\t\t\t\t</>\n\t\t\t\t) }\n\t\t\t\t<div className=\"block-directory-downloadable-blocks-panel has-blocks-loading\">\n\t\t\t\t\t<Spinner />\n\t\t\t\t</div>\n\t\t\t</>\n\t\t);\n\t}\n\n\tif ( false === hasPermission ) {\n\t\tif ( ! hasLocalBlocks ) {\n\t\t\treturn <DownloadableBlocksNoResults />;\n\t\t}\n\n\t\treturn null;\n\t}\n\n\tif ( downloadableBlocks.length === 0 ) {\n\t\treturn hasLocalBlocks ? null : <DownloadableBlocksNoResults />;\n\t}\n\n\treturn (\n\t\t<DownloadableBlocksInserterPanel\n\t\t\tdownloadableItems={ downloadableBlocks }\n\t\t\thasLocalBlocks={ hasLocalBlocks }\n\t\t>\n\t\t\t<DownloadableBlocksList\n\t\t\t\titems={ downloadableBlocks }\n\t\t\t\tonSelect={ onSelect }\n\t\t\t\tonHover={ onHover }\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C;IAEA,OAAO,IAAI;EACZ;EAEA,IAAKiB,kBAAkB,CAACS,MAAM,KAAK,CAAC,EAAG;IACtC,OAAOK,cAAc,GAAG,IAAI,gBAAG5B,IAAA,CAACH,2BAA2B,IAAE,CAAC;EAC/D;EAEA,oBACCG,IAAA,CAACJ,+BAA+B;IAC/BqC,iBAAiB,EAAGnB,kBAAoB;IACxCc,cAAc,EAAGA,cAAgB;IAAAG,QAAA,eAEjC/B,IAAA,CAACL,sBAAsB;MACtBuC,KAAK,EAAGpB,kBAAoB;MAC5BY,QAAQ,EAAGA,QAAU;MACrBC,OAAO,EAAGA;IAAS,CACnB;EAAC,CAC8B,CAAC;AAEpC","ignoreList":[]}
|
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
import { __, _n, sprintf } from '@wordpress/i18n';
|
|
5
5
|
import { useEffect } from '@wordpress/element';
|
|
6
6
|
import { speak } from '@wordpress/a11y';
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
8
|
function DownloadableBlocksInserterPanel({
|
|
11
9
|
children,
|
|
12
10
|
downloadableItems,
|
|
@@ -14,7 +12,7 @@ function DownloadableBlocksInserterPanel({
|
|
|
14
12
|
}) {
|
|
15
13
|
const count = downloadableItems.length;
|
|
16
14
|
useEffect(() => {
|
|
17
|
-
speak(sprintf(
|
|
15
|
+
speak(sprintf(/* translators: %d: number of available blocks. */
|
|
18
16
|
_n('%d additional block is available to install.', '%d additional blocks are available to install.', count), count));
|
|
19
17
|
}, [count]);
|
|
20
18
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","_n","sprintf","useEffect","speak","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","DownloadableBlocksInserterPanel","children","downloadableItems","hasLocalBlocks","count","length","className"],"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/inserter-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\nfunction DownloadableBlocksInserterPanel( {\n\tchildren,\n\tdownloadableItems,\n\thasLocalBlocks,\n} ) {\n\tconst count = downloadableItems.length;\n\tuseEffect( () => {\n\t\tspeak(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of available blocks. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d additional block is available to install.',\n\t\t\t\t\t'%d additional blocks are available to install.',\n\t\t\t\t\tcount\n\t\t\t\t),\n\t\t\t\tcount\n\t\t\t)\n\t\t);\n\t}, [ count ] );\n\n\treturn (\n\t\t<>\n\t\t\t{ ! hasLocalBlocks && (\n\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__no-local\">\n\t\t\t\t\t{ __( 'No results available from your installed blocks.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\n\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\n\t\t\t<div className=\"block-directory-downloadable-blocks-panel\">\n\t\t\t\t<div className=\"block-directory-downloadable-blocks-panel__header\">\n\t\t\t\t\t<h2 className=\"block-directory-downloadable-blocks-panel__title\">\n\t\t\t\t\t\t{ __( 'Available to install' ) }\n\t\t\t\t\t</h2>\n\t\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__description\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Select a block to install and add it to your post.'\n\t\t\t\t\t\t) }\n\t\t\t\t\t</p>\n\t\t\t\t</div>\n\t\t\t\t{ children }\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default DownloadableBlocksInserterPanel;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AACjD,SAASC,SAAS,QAAQ,oBAAoB;AAC9C,SAASC,KAAK,QAAQ,iBAAiB;AAAC,SAAAC,GAAA,IAAAC,IAAA
|
|
1
|
+
{"version":3,"names":["__","_n","sprintf","useEffect","speak","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","DownloadableBlocksInserterPanel","children","downloadableItems","hasLocalBlocks","count","length","className"],"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/inserter-panel.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __, _n, sprintf } from '@wordpress/i18n';\nimport { useEffect } from '@wordpress/element';\nimport { speak } from '@wordpress/a11y';\n\nfunction DownloadableBlocksInserterPanel( {\n\tchildren,\n\tdownloadableItems,\n\thasLocalBlocks,\n} ) {\n\tconst count = downloadableItems.length;\n\tuseEffect( () => {\n\t\tspeak(\n\t\t\tsprintf(\n\t\t\t\t/* translators: %d: number of available blocks. */\n\t\t\t\t_n(\n\t\t\t\t\t'%d additional block is available to install.',\n\t\t\t\t\t'%d additional blocks are available to install.',\n\t\t\t\t\tcount\n\t\t\t\t),\n\t\t\t\tcount\n\t\t\t)\n\t\t);\n\t}, [ count ] );\n\n\treturn (\n\t\t<>\n\t\t\t{ ! hasLocalBlocks && (\n\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__no-local\">\n\t\t\t\t\t{ __( 'No results available from your installed blocks.' ) }\n\t\t\t\t</p>\n\t\t\t) }\n\n\t\t\t<div className=\"block-editor-inserter__quick-inserter-separator\" />\n\n\t\t\t<div className=\"block-directory-downloadable-blocks-panel\">\n\t\t\t\t<div className=\"block-directory-downloadable-blocks-panel__header\">\n\t\t\t\t\t<h2 className=\"block-directory-downloadable-blocks-panel__title\">\n\t\t\t\t\t\t{ __( 'Available to install' ) }\n\t\t\t\t\t</h2>\n\t\t\t\t\t<p className=\"block-directory-downloadable-blocks-panel__description\">\n\t\t\t\t\t\t{ __(\n\t\t\t\t\t\t\t'Select a block to install and add it to your post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Q;IAAA,CACN,CAAC;EAAA,CACL,CAAC;AAEL;AAEA,eAAeD,+BAA+B","ignoreList":[]}
|
|
@@ -4,9 +4,7 @@
|
|
|
4
4
|
import { __ } from '@wordpress/i18n';
|
|
5
5
|
import { Icon, blockDefault } from '@wordpress/icons';
|
|
6
6
|
import { Tip, ExternalLink } from '@wordpress/components';
|
|
7
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
7
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
10
8
|
function DownloadableBlocksNoResults() {
|
|
11
9
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
12
10
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["__","Icon","blockDefault","Tip","ExternalLink","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","DownloadableBlocksNoResults","children","className","icon","href"],"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/no-results.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon, blockDefault } from '@wordpress/icons';\nimport { Tip, ExternalLink } from '@wordpress/components';\n\nfunction DownloadableBlocksNoResults() {\n\treturn (\n\t\t<>\n\t\t\t<div className=\"block-editor-inserter__no-results\">\n\t\t\t\t<Icon\n\t\t\t\t\tclassName=\"block-editor-inserter__no-results-icon\"\n\t\t\t\t\ticon={ blockDefault }\n\t\t\t\t/>\n\t\t\t\t<p>{ __( 'No results found.' ) }</p>\n\t\t\t</div>\n\t\t\t<div className=\"block-editor-inserter__tips\">\n\t\t\t\t<Tip>\n\t\t\t\t\t{ __( 'Interested in creating your own block?' ) }\n\t\t\t\t\t<br />\n\t\t\t\t\t<ExternalLink href=\"https://developer.wordpress.org/block-editor/\">\n\t\t\t\t\t\t{ __( 'Get started here' ) }.\n\t\t\t\t\t</ExternalLink>\n\t\t\t\t</Tip>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default DownloadableBlocksNoResults;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,EAAEC,YAAY,QAAQ,kBAAkB;AACrD,SAASC,GAAG,EAAEC,YAAY,QAAQ,uBAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA
|
|
1
|
+
{"version":3,"names":["__","Icon","blockDefault","Tip","ExternalLink","jsx","_jsx","jsxs","_jsxs","Fragment","_Fragment","DownloadableBlocksNoResults","children","className","icon","href"],"sources":["@wordpress/block-directory/src/components/downloadable-blocks-panel/no-results.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Icon, blockDefault } from '@wordpress/icons';\nimport { Tip, ExternalLink } from '@wordpress/components';\n\nfunction DownloadableBlocksNoResults() {\n\treturn (\n\t\t<>\n\t\t\t<div className=\"block-editor-inserter__no-results\">\n\t\t\t\t<Icon\n\t\t\t\t\tclassName=\"block-editor-inserter__no-results-icon\"\n\t\t\t\t\ticon={ blockDefault }\n\t\t\t\t/>\n\t\t\t\t<p>{ __( 'No results found.' ) }</p>\n\t\t\t</div>\n\t\t\t<div className=\"block-editor-inserter__tips\">\n\t\t\t\t<Tip>\n\t\t\t\t\t{ __( 'Interested in creating your own block?' ) }\n\t\t\t\t\t<br />\n\t\t\t\t\t<ExternalLink href=\"https://developer.wordpress.org/block-editor/\">\n\t\t\t\t\t\t{ __( 'Get started here' ) }.\n\t\t\t\t\t</ExternalLink>\n\t\t\t\t</Tip>\n\t\t\t</div>\n\t\t</>\n\t);\n}\n\nexport default DownloadableBlocksNoResults;\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,QAAQ,iBAAiB;AACpC,SAASC,IAAI,EAAEC,YAAY,QAAQ,kBAAkB;AACrD,SAASC,GAAG,EAAEC,YAAY,QAAQ,uBAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA,EAAAC,QAAA,IAAAC,SAAA;AAE1D,SAASC,2BAA2BA,CAAA,EAAG;EACtC,oBACCH,KAAA,CAAAE,SAAA;IAAAE,QAAA,gBACCJ,KAAA;MAAKK,SAAS,EAAC,mCAAmC;MAAAD,QAAA,gBACjDN,IAAA,CAACL,IAAI;QACJY,SAAS,EAAC,wCAAwC;QAClDC,IAAI,EAAGZ;MAAc,CACrB,CAAC,eACFI,IAAA;QAAAM,QAAA,EAAKZ,EAAE,CAAE,mBAAoB;MAAC,CAAK,CAAC;IAAA,CAChC,CAAC,eACNM,IAAA;MAAKO,SAAS,EAAC,6BAA6B;MAAAD,QAAA,eAC3CJ,KAAA,CAACL,GAAG;QAAAS,QAAA,GACDZ,EAAE,CAAE,wCAAyC,CAAC,eAChDM,IAAA,SAAK,CAAC,eACNE,KAAA,CAACJ,YAAY;UAACW,IAAI,EAAC,+CAA+C;UAAAH,QAAA,GAC/DZ,EAAE,CAAE,kBAAmB,CAAC,EAAE,GAC7B;QAAA,CAAc,CAAC;MAAA,CACX;IAAC,CACF,CAAC;EAAA,CACL,CAAC;AAEL;AAEA,eAAeW,2BAA2B","ignoreList":[]}
|
|
@@ -14,8 +14,7 @@ import { Warning, useBlockProps, store as blockEditorStore } from '@wordpress/bl
|
|
|
14
14
|
*/
|
|
15
15
|
import InstallButton from './install-button';
|
|
16
16
|
import { store as blockDirectoryStore } from '../../store';
|
|
17
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
18
|
const getInstallMissing = OriginalComponent => props => {
|
|
20
19
|
const {
|
|
21
20
|
originalName
|
|
@@ -74,7 +73,7 @@ const ModifiedWarning = ({
|
|
|
74
73
|
} = select(blockEditorStore);
|
|
75
74
|
return canInsertBlockType('core/html', getBlockRootClientId(clientId));
|
|
76
75
|
}, [clientId]);
|
|
77
|
-
let messageHTML = sprintf(
|
|
76
|
+
let messageHTML = sprintf(/* translators: %s: block name */
|
|
78
77
|
__('Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'), originalBlock.title || originalName);
|
|
79
78
|
const actions = [/*#__PURE__*/_jsx(InstallButton, {
|
|
80
79
|
block: originalBlock,
|
|
@@ -82,9 +81,9 @@ const ModifiedWarning = ({
|
|
|
82
81
|
clientId: props.clientId
|
|
83
82
|
}, "install")];
|
|
84
83
|
if (hasContent && hasHTMLBlock) {
|
|
85
|
-
messageHTML = sprintf(
|
|
84
|
+
messageHTML = sprintf(/* translators: %s: block name */
|
|
86
85
|
__('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(
|
|
86
|
+
actions.push(/*#__PURE__*/_jsx(Button, {
|
|
88
87
|
__next40pxDefaultSize: true,
|
|
89
88
|
onClick: convertToHTML,
|
|
90
89
|
variant: "tertiary",
|
|
@@ -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","__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__next40pxDefaultSize\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
|
|
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__next40pxDefaultSize\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,EAAAC,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,YA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D,CAAC,EACDiC,aAAa,CAACW,KAAK,IAAIvB,YACxB,CAAC;EACD,MAAMwB,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,CACpB;IACAD,EAAE,CACD,iJACD,CAAC,EACDiC,aAAa,CAACW,KAAK,IAAIvB,YACxB,CAAC;IACDwB,OAAO,CAACC,IAAI,cACX/B,IAAA,CAACb,MAAM;MACN6C,qBAAqB;MAErBC,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":[]}
|
|
@@ -39,7 +39,7 @@ export default function InstallButton({
|
|
|
39
39
|
disabled: isInstallingBlock,
|
|
40
40
|
isBusy: isInstallingBlock,
|
|
41
41
|
variant: "primary",
|
|
42
|
-
children: sprintf(
|
|
42
|
+
children: sprintf(/* translators: %s: block name */
|
|
43
43
|
__('Install %s'), block.title)
|
|
44
44
|
});
|
|
45
45
|
}
|
|
@@ -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","__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__next40pxDefaultSize\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,MAAM;IACNqB,qBAAqB;IACrBC,OAAO,EAAGA,CAAA,KACTH,gBAAgB,CAAEN,KAAM,CAAC,CAACU,IAAI,CAAIC,OAAO,IAAM;MAC9C,IAAKA,OAAO,EAAG;QACd,MAAMC,SAAS,GAAGvB,YAAY,CAAEW,KAAK,CAACa,IAAK,CAAC;QAC5C,MAAM,CAAEC,aAAa,CAAE,GAAGxB,KAAK,CAC9BS,UAAU,CAACgB,eACZ,CAAC;QACD,IAAKD,aAAa,IAAIF,SAAS,EAAG;UACjCL,YAAY,CACXN,QAAQ,EACRb,WAAW,CACVwB,SAAS,CAACC,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,
|
|
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__next40pxDefaultSize\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,MAAM;IACNqB,qBAAqB;IACrBC,OAAO,EAAGA,CAAA,KACTH,gBAAgB,CAAEN,KAAM,CAAC,CAACU,IAAI,CAAIC,OAAO,IAAM;MAC9C,IAAKA,OAAO,EAAG;QACd,MAAMC,SAAS,GAAGvB,YAAY,CAAEW,KAAK,CAACa,IAAK,CAAC;QAC5C,MAAM,CAAEC,aAAa,CAAE,GAAGxB,KAAK,CAC9BS,UAAU,CAACgB,eACZ,CAAC;QACD,IAAKD,aAAa,IAAIF,SAAS,EAAG;UACjCL,YAAY,CACXN,QAAQ,EACRb,WAAW,CACVwB,SAAS,CAACC,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,CACR;IACAD,EAAE,CAAE,YAAa,CAAC,EAClBe,KAAK,CAACsB,KACP;EAAC,CACM,CAAC;AAEX","ignoreList":[]}
|
|
@@ -11,9 +11,7 @@ import AutoBlockUninstaller from '../components/auto-block-uninstaller';
|
|
|
11
11
|
import InserterMenuDownloadableBlocksPanel from './inserter-menu-downloadable-blocks-panel';
|
|
12
12
|
import InstalledBlocksPrePublishPanel from './installed-blocks-pre-publish-panel';
|
|
13
13
|
import getInstallMissing from './get-install-missing';
|
|
14
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
16
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
15
|
registerPlugin('block-directory', {
|
|
18
16
|
render() {
|
|
19
17
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["registerPlugin","addFilter","AutoBlockUninstaller","InserterMenuDownloadableBlocksPanel","InstalledBlocksPrePublishPanel","getInstallMissing","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","render","children","settings","name","edit"],"sources":["@wordpress/block-directory/src/plugins/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport AutoBlockUninstaller from '../components/auto-block-uninstaller';\nimport InserterMenuDownloadableBlocksPanel from './inserter-menu-downloadable-blocks-panel';\nimport InstalledBlocksPrePublishPanel from './installed-blocks-pre-publish-panel';\nimport getInstallMissing from './get-install-missing';\n\nregisterPlugin( 'block-directory', {\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<AutoBlockUninstaller />\n\t\t\t\t<InserterMenuDownloadableBlocksPanel />\n\t\t\t\t<InstalledBlocksPrePublishPanel />\n\t\t\t</>\n\t\t);\n\t},\n} );\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-directory/fallback',\n\t( settings, name ) => {\n\t\tif ( name !== 'core/missing' ) {\n\t\t\treturn settings;\n\t\t}\n\t\tsettings.edit = getInstallMissing( settings.edit );\n\n\t\treturn settings;\n\t}\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAc,QAAQ,oBAAoB;AACnD,SAASC,SAAS,QAAQ,kBAAkB;;AAE5C;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,sCAAsC;AACvE,OAAOC,mCAAmC,MAAM,2CAA2C;AAC3F,OAAOC,8BAA8B,MAAM,sCAAsC;AACjF,OAAOC,iBAAiB,MAAM,uBAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA
|
|
1
|
+
{"version":3,"names":["registerPlugin","addFilter","AutoBlockUninstaller","InserterMenuDownloadableBlocksPanel","InstalledBlocksPrePublishPanel","getInstallMissing","jsx","_jsx","Fragment","_Fragment","jsxs","_jsxs","render","children","settings","name","edit"],"sources":["@wordpress/block-directory/src/plugins/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\n\n/**\n * Internal dependencies\n */\nimport AutoBlockUninstaller from '../components/auto-block-uninstaller';\nimport InserterMenuDownloadableBlocksPanel from './inserter-menu-downloadable-blocks-panel';\nimport InstalledBlocksPrePublishPanel from './installed-blocks-pre-publish-panel';\nimport getInstallMissing from './get-install-missing';\n\nregisterPlugin( 'block-directory', {\n\trender() {\n\t\treturn (\n\t\t\t<>\n\t\t\t\t<AutoBlockUninstaller />\n\t\t\t\t<InserterMenuDownloadableBlocksPanel />\n\t\t\t\t<InstalledBlocksPrePublishPanel />\n\t\t\t</>\n\t\t);\n\t},\n} );\n\naddFilter(\n\t'blocks.registerBlockType',\n\t'block-directory/fallback',\n\t( settings, name ) => {\n\t\tif ( name !== 'core/missing' ) {\n\t\t\treturn settings;\n\t\t}\n\t\tsettings.edit = getInstallMissing( settings.edit );\n\n\t\treturn settings;\n\t}\n);\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,cAAc,QAAQ,oBAAoB;AACnD,SAASC,SAAS,QAAQ,kBAAkB;;AAE5C;AACA;AACA;AACA,OAAOC,oBAAoB,MAAM,sCAAsC;AACvE,OAAOC,mCAAmC,MAAM,2CAA2C;AAC3F,OAAOC,8BAA8B,MAAM,sCAAsC;AACjF,OAAOC,iBAAiB,MAAM,uBAAuB;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,QAAA,IAAAC,SAAA,EAAAC,IAAA,IAAAC,KAAA;AAEtDX,cAAc,CAAE,iBAAiB,EAAE;EAClCY,MAAMA,CAAA,EAAG;IACR,oBACCD,KAAA,CAAAF,SAAA;MAAAI,QAAA,gBACCN,IAAA,CAACL,oBAAoB,IAAE,CAAC,eACxBK,IAAA,CAACJ,mCAAmC,IAAE,CAAC,eACvCI,IAAA,CAACH,8BAA8B,IAAE,CAAC;IAAA,CACjC,CAAC;EAEL;AACD,CAAE,CAAC;AAEHH,SAAS,CACR,0BAA0B,EAC1B,0BAA0B,EAC1B,CAAEa,QAAQ,EAAEC,IAAI,KAAM;EACrB,IAAKA,IAAI,KAAK,cAAc,EAAG;IAC9B,OAAOD,QAAQ;EAChB;EACAA,QAAQ,CAACE,IAAI,GAAGX,iBAAiB,CAAES,QAAQ,CAACE,IAAK,CAAC;EAElD,OAAOF,QAAQ;AAChB,CACD,CAAC","ignoreList":[]}
|
|
@@ -11,8 +11,7 @@ import { PluginPrePublishPanel } from '@wordpress/editor';
|
|
|
11
11
|
*/
|
|
12
12
|
import CompactList from '../../components/compact-list';
|
|
13
13
|
import { store as blockDirectoryStore } from '../../store';
|
|
14
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
14
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
15
|
export default function InstalledBlocksPrePublishPanel() {
|
|
17
16
|
const newBlockTypes = useSelect(select => select(blockDirectoryStore).getNewBlockTypes(), []);
|
|
18
17
|
if (!newBlockTypes.length) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_n","sprintf","useSelect","blockDefault","PluginPrePublishPanel","CompactList","store","blockDirectoryStore","jsx","_jsx","jsxs","_jsxs","InstalledBlocksPrePublishPanel","newBlockTypes","select","getNewBlockTypes","length","icon","title","initialOpen","children","className","items"],"sources":["@wordpress/block-directory/src/plugins/installed-blocks-pre-publish-panel/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { blockDefault } from '@wordpress/icons';\nimport { PluginPrePublishPanel } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstalledBlocksPrePublishPanel() {\n\tconst newBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getNewBlockTypes(),\n\t\t[]\n\t);\n\n\tif ( ! newBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PluginPrePublishPanel\n\t\t\ticon={ blockDefault }\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %d: number of blocks (number).\n\t\t\t\t_n(\n\t\t\t\t\t'Added: %d block',\n\t\t\t\t\t'Added: %d blocks',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t),\n\t\t\t\tnewBlockTypes.length\n\t\t\t) }\n\t\t\tinitialOpen\n\t\t>\n\t\t\t<p className=\"installed-blocks-pre-publish-panel__copy\">\n\t\t\t\t{ _n(\n\t\t\t\t\t'The following block has been added to your site.',\n\t\t\t\t\t'The following blocks have been added to your site.',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<CompactList items={ newBlockTypes } />\n\t\t</PluginPrePublishPanel>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,qBAAqB,QAAQ,mBAAmB;;AAEzD;AACA;AACA;AACA,OAAOC,WAAW,MAAM,+BAA+B;AACvD,SAASC,KAAK,IAAIC,mBAAmB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA
|
|
1
|
+
{"version":3,"names":["_n","sprintf","useSelect","blockDefault","PluginPrePublishPanel","CompactList","store","blockDirectoryStore","jsx","_jsx","jsxs","_jsxs","InstalledBlocksPrePublishPanel","newBlockTypes","select","getNewBlockTypes","length","icon","title","initialOpen","children","className","items"],"sources":["@wordpress/block-directory/src/plugins/installed-blocks-pre-publish-panel/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { blockDefault } from '@wordpress/icons';\nimport { PluginPrePublishPanel } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstalledBlocksPrePublishPanel() {\n\tconst newBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getNewBlockTypes(),\n\t\t[]\n\t);\n\n\tif ( ! newBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PluginPrePublishPanel\n\t\t\ticon={ blockDefault }\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %d: number of blocks (number).\n\t\t\t\t_n(\n\t\t\t\t\t'Added: %d block',\n\t\t\t\t\t'Added: %d blocks',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t),\n\t\t\t\tnewBlockTypes.length\n\t\t\t) }\n\t\t\tinitialOpen\n\t\t>\n\t\t\t<p className=\"installed-blocks-pre-publish-panel__copy\">\n\t\t\t\t{ _n(\n\t\t\t\t\t'The following block has been added to your site.',\n\t\t\t\t\t'The following blocks have been added to your site.',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<CompactList items={ newBlockTypes } />\n\t\t</PluginPrePublishPanel>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,qBAAqB,QAAQ,mBAAmB;;AAEzD;AACA;AACA;AACA,OAAOC,WAAW,MAAM,+BAA+B;AACvD,SAASC,KAAK,IAAIC,mBAAmB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA,EAAAC,IAAA,IAAAC,KAAA;AAE3D,eAAe,SAASC,8BAA8BA,CAAA,EAAG;EACxD,MAAMC,aAAa,GAAGX,SAAS,CAC5BY,MAAM,IAAMA,MAAM,CAAEP,mBAAoB,CAAC,CAACQ,gBAAgB,CAAC,CAAC,EAC9D,EACD,CAAC;EAED,IAAK,CAAEF,aAAa,CAACG,MAAM,EAAG;IAC7B,OAAO,IAAI;EACZ;EAEA,oBACCL,KAAA,CAACP,qBAAqB;IACrBa,IAAI,EAAGd,YAAc;IACrBe,KAAK,EAAGjB,OAAO;IACd;IACAD,EAAE,CACD,iBAAiB,EACjB,kBAAkB,EAClBa,aAAa,CAACG,MACf,CAAC,EACDH,aAAa,CAACG,MACf,CAAG;IACHG,WAAW;IAAAC,QAAA,gBAEXX,IAAA;MAAGY,SAAS,EAAC,0CAA0C;MAAAD,QAAA,EACpDpB,EAAE,CACH,kDAAkD,EAClD,oDAAoD,EACpDa,aAAa,CAACG,MACf;IAAC,CACC,CAAC,eACJP,IAAA,CAACJ,WAAW;MAACiB,KAAK,EAAGT;IAAe,CAAE,CAAC;EAAA,CACjB,CAAC;AAE1B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["store","blocksStore","unstable__bootstrapServerSideBlockDefinitions","__","sprintf","apiFetch","noticesStore","addQueryArgs","loadAssets","getPluginUrl","fetchDownloadableBlocks","filterValue","type","receiveDownloadableBlocks","downloadableBlocks","installBlockType","block","registry","dispatch","id","name","success","clearErrorNotice","setIsInstalling","url","links","method","data","status","response","path","slug","_links","addInstalledBlockType","metadataFields","_fields","catch","then","Object","fromEntries","entries","filter","key","includes","registeredBlocks","select","getBlockTypes","some","i","Error","createInfoNotice","title","speak","error","message","isFatal","fatalAPIErrors","folder_exists","unable_to_connect_to_filesystem","code","setErrorNotice","createErrorNotice","isDismissible","uninstallBlockType","removeInstalledBlockType","item","blockId","isInstalling"],"sources":["@wordpress/block-directory/src/store/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blocksStore,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n} from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { loadAssets } from './load-assets';\nimport getPluginUrl from './utils/get-plugin-url';\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been requested and are loading.\n *\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function fetchDownloadableBlocks( filterValue ) {\n\treturn { type: 'FETCH_DOWNLOADABLE_BLOCKS', filterValue };\n}\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been updated.\n *\n * @param {Array} downloadableBlocks Downloadable blocks.\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function receiveDownloadableBlocks( downloadableBlocks, filterValue ) {\n\treturn {\n\t\ttype: 'RECEIVE_DOWNLOADABLE_BLOCKS',\n\t\tdownloadableBlocks,\n\t\tfilterValue,\n\t};\n}\n\n/**\n * Action triggered to install a block plugin.\n *\n * @param {Object} block The block item returned by search.\n *\n * @return {boolean} Whether the block was successfully installed & loaded.\n */\nexport const installBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\tconst { id, name } = block;\n\t\tlet success = false;\n\t\tdispatch.clearErrorNotice( id );\n\t\ttry {\n\t\t\tdispatch.setIsInstalling( id, true );\n\n\t\t\t// If we have a wp:plugin link, the plugin is installed but inactive.\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tlet links = {};\n\t\t\tif ( url ) {\n\t\t\t\tawait apiFetch( {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\turl,\n\t\t\t\t\tdata: { status: 'active' },\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst response = await apiFetch( {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tpath: 'wp/v2/plugins',\n\t\t\t\t\tdata: { slug: id, status: 'active' },\n\t\t\t\t} );\n\t\t\t\t// Add the `self` link for newly-installed blocks.\n\t\t\t\tlinks = response._links;\n\t\t\t}\n\n\t\t\tdispatch.addInstalledBlockType( {\n\t\t\t\t...block,\n\t\t\t\tlinks: { ...block.links, ...links },\n\t\t\t} );\n\n\t\t\t// Ensures that the block metadata is propagated to the editor when registered on the server.\n\t\t\tconst metadataFields = [\n\t\t\t\t'api_version',\n\t\t\t\t'title',\n\t\t\t\t'category',\n\t\t\t\t'parent',\n\t\t\t\t'icon',\n\t\t\t\t'description',\n\t\t\t\t'keywords',\n\t\t\t\t'attributes',\n\t\t\t\t'provides_context',\n\t\t\t\t'uses_context',\n\t\t\t\t'supports',\n\t\t\t\t'styles',\n\t\t\t\t'example',\n\t\t\t\t'variations',\n\t\t\t];\n\t\t\tawait apiFetch( {\n\t\t\t\tpath: addQueryArgs( `/wp/v2/block-types/${ name }`, {\n\t\t\t\t\t_fields: metadataFields,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t// Ignore when the block is not registered on the server.\n\t\t\t\t.catch( () => {} )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( ! response ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tunstable__bootstrapServerSideBlockDefinitions( {\n\t\t\t\t\t\t[ name ]: Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( response ).filter( ( [ key ] ) =>\n\t\t\t\t\t\t\t\tmetadataFields.includes( key )\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\n\t\t\tawait loadAssets();\n\t\t\tconst registeredBlocks = registry\n\t\t\t\t.select( blocksStore )\n\t\t\t\t.getBlockTypes();\n\t\t\tif ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t__( 'Error registering block. Try reloading the page.' )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tregistry.dispatch( noticesStore ).createInfoNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s is the block title.\n\t\t\t\t\t__( 'Block %s installed and added.' ),\n\t\t\t\t\tblock.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\tspeak: true,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t\tsuccess = true;\n\t\t} catch ( error ) {\n\t\t\tlet message = error.message || __( 'An error occurred.' );\n\n\t\t\t// Errors we throw are fatal.\n\t\t\tlet isFatal = error instanceof Error;\n\n\t\t\t// Specific API errors that are fatal.\n\t\t\tconst fatalAPIErrors = {\n\t\t\t\tfolder_exists: __(\n\t\t\t\t\t'This block is already installed. Try reloading the page.'\n\t\t\t\t),\n\t\t\t\tunable_to_connect_to_filesystem: __(\n\t\t\t\t\t'Error installing block. You can reload the page and try again.'\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tif ( fatalAPIErrors[ error.code ] ) {\n\t\t\t\tisFatal = true;\n\t\t\t\tmessage = fatalAPIErrors[ error.code ];\n\t\t\t}\n\n\t\t\tdispatch.setErrorNotice( id, message, isFatal );\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice( message, {\n\t\t\t\tspeak: true,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}\n\t\tdispatch.setIsInstalling( id, false );\n\t\treturn success;\n\t};\n\n/**\n * Action triggered to uninstall a block plugin.\n *\n * @param {Object} block The blockType object.\n */\nexport const uninstallBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\ttry {\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'PUT',\n\t\t\t\turl,\n\t\t\t\tdata: { status: 'inactive' },\n\t\t\t} );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl,\n\t\t\t} );\n\t\t\tdispatch.removeInstalledBlockType( block );\n\t\t} catch ( error ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\terror.message || __( 'An error occurred.' )\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Returns an action object used to add a block type to the \"newly installed\"\n * tracking list.\n *\n * @param {Object} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function addInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'ADD_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to remove a block type from the \"newly installed\"\n * tracking list.\n *\n * @param {string} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function removeInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'REMOVE_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to indicate install in progress.\n *\n * @param {string} blockId\n * @param {boolean} isInstalling\n *\n * @return {Object} Action object.\n */\nexport function setIsInstalling( blockId, isInstalling ) {\n\treturn {\n\t\ttype: 'SET_INSTALLING_BLOCK',\n\t\tblockId,\n\t\tisInstalling,\n\t};\n}\n\n/**\n * Sets an error notice to be displayed to the user for a given block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n * @param {string} message The message shown in the notice.\n * @param {boolean} isFatal Whether the user can recover from the error.\n *\n * @return {Object} Action object.\n */\nexport function setErrorNotice( blockId, message, isFatal = false ) {\n\treturn {\n\t\ttype: 'SET_ERROR_NOTICE',\n\t\tblockId,\n\t\tmessage,\n\t\tisFatal,\n\t};\n}\n\n/**\n * Sets the error notice to empty for specific block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {Object} Action object.\n */\nexport function clearErrorNotice( blockId ) {\n\treturn {\n\t\ttype: 'CLEAR_ERROR_NOTICE',\n\t\tblockId,\n\t};\n}\n"],"mappings":"A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IACN3C,IAAI,EAAE,kBAAkB;IACxBsD,OAAO;IACPZ,OAAO;IACPC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASjC,gBAAgBA,CAAE4C,OAAO,EAAG;EAC3C,OAAO;IACNtD,IAAI,EAAE,oBAAoB;IAC1BsD;EACD,CAAC;AACF","ignoreList":[]}
|
|
1
|
+
{"version":3,"names":["store","blocksStore","unstable__bootstrapServerSideBlockDefinitions","__","sprintf","apiFetch","noticesStore","addQueryArgs","loadAssets","getPluginUrl","fetchDownloadableBlocks","filterValue","type","receiveDownloadableBlocks","downloadableBlocks","installBlockType","block","registry","dispatch","id","name","success","clearErrorNotice","setIsInstalling","url","links","method","data","status","response","path","slug","_links","addInstalledBlockType","metadataFields","_fields","catch","then","Object","fromEntries","entries","filter","key","includes","registeredBlocks","select","getBlockTypes","some","i","Error","createInfoNotice","title","speak","error","message","isFatal","fatalAPIErrors","folder_exists","unable_to_connect_to_filesystem","code","setErrorNotice","createErrorNotice","isDismissible","uninstallBlockType","removeInstalledBlockType","item","blockId","isInstalling"],"sources":["@wordpress/block-directory/src/store/actions.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport {\n\tstore as blocksStore,\n\tunstable__bootstrapServerSideBlockDefinitions, // eslint-disable-line camelcase\n} from '@wordpress/blocks';\nimport { __, sprintf } from '@wordpress/i18n';\nimport apiFetch from '@wordpress/api-fetch';\nimport { store as noticesStore } from '@wordpress/notices';\nimport { addQueryArgs } from '@wordpress/url';\n\n/**\n * Internal dependencies\n */\nimport { loadAssets } from './load-assets';\nimport getPluginUrl from './utils/get-plugin-url';\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been requested and are loading.\n *\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function fetchDownloadableBlocks( filterValue ) {\n\treturn { type: 'FETCH_DOWNLOADABLE_BLOCKS', filterValue };\n}\n\n/**\n * Returns an action object used in signalling that the downloadable blocks\n * have been updated.\n *\n * @param {Array} downloadableBlocks Downloadable blocks.\n * @param {string} filterValue Search string.\n *\n * @return {Object} Action object.\n */\nexport function receiveDownloadableBlocks( downloadableBlocks, filterValue ) {\n\treturn {\n\t\ttype: 'RECEIVE_DOWNLOADABLE_BLOCKS',\n\t\tdownloadableBlocks,\n\t\tfilterValue,\n\t};\n}\n\n/**\n * Action triggered to install a block plugin.\n *\n * @param {Object} block The block item returned by search.\n *\n * @return {boolean} Whether the block was successfully installed & loaded.\n */\nexport const installBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\tconst { id, name } = block;\n\t\tlet success = false;\n\t\tdispatch.clearErrorNotice( id );\n\t\ttry {\n\t\t\tdispatch.setIsInstalling( id, true );\n\n\t\t\t// If we have a wp:plugin link, the plugin is installed but inactive.\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tlet links = {};\n\t\t\tif ( url ) {\n\t\t\t\tawait apiFetch( {\n\t\t\t\t\tmethod: 'PUT',\n\t\t\t\t\turl,\n\t\t\t\t\tdata: { status: 'active' },\n\t\t\t\t} );\n\t\t\t} else {\n\t\t\t\tconst response = await apiFetch( {\n\t\t\t\t\tmethod: 'POST',\n\t\t\t\t\tpath: 'wp/v2/plugins',\n\t\t\t\t\tdata: { slug: id, status: 'active' },\n\t\t\t\t} );\n\t\t\t\t// Add the `self` link for newly-installed blocks.\n\t\t\t\tlinks = response._links;\n\t\t\t}\n\n\t\t\tdispatch.addInstalledBlockType( {\n\t\t\t\t...block,\n\t\t\t\tlinks: { ...block.links, ...links },\n\t\t\t} );\n\n\t\t\t// Ensures that the block metadata is propagated to the editor when registered on the server.\n\t\t\tconst metadataFields = [\n\t\t\t\t'api_version',\n\t\t\t\t'title',\n\t\t\t\t'category',\n\t\t\t\t'parent',\n\t\t\t\t'icon',\n\t\t\t\t'description',\n\t\t\t\t'keywords',\n\t\t\t\t'attributes',\n\t\t\t\t'provides_context',\n\t\t\t\t'uses_context',\n\t\t\t\t'supports',\n\t\t\t\t'styles',\n\t\t\t\t'example',\n\t\t\t\t'variations',\n\t\t\t];\n\t\t\tawait apiFetch( {\n\t\t\t\tpath: addQueryArgs( `/wp/v2/block-types/${ name }`, {\n\t\t\t\t\t_fields: metadataFields,\n\t\t\t\t} ),\n\t\t\t} )\n\t\t\t\t// Ignore when the block is not registered on the server.\n\t\t\t\t.catch( () => {} )\n\t\t\t\t.then( ( response ) => {\n\t\t\t\t\tif ( ! response ) {\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\t\t\t\t\tunstable__bootstrapServerSideBlockDefinitions( {\n\t\t\t\t\t\t[ name ]: Object.fromEntries(\n\t\t\t\t\t\t\tObject.entries( response ).filter( ( [ key ] ) =>\n\t\t\t\t\t\t\t\tmetadataFields.includes( key )\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\n\t\t\tawait loadAssets();\n\t\t\tconst registeredBlocks = registry\n\t\t\t\t.select( blocksStore )\n\t\t\t\t.getBlockTypes();\n\t\t\tif ( ! registeredBlocks.some( ( i ) => i.name === name ) ) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t__( 'Error registering block. Try reloading the page.' )\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tregistry.dispatch( noticesStore ).createInfoNotice(\n\t\t\t\tsprintf(\n\t\t\t\t\t// translators: %s is the block title.\n\t\t\t\t\t__( 'Block %s installed and added.' ),\n\t\t\t\t\tblock.title\n\t\t\t\t),\n\t\t\t\t{\n\t\t\t\t\tspeak: true,\n\t\t\t\t\ttype: 'snackbar',\n\t\t\t\t}\n\t\t\t);\n\t\t\tsuccess = true;\n\t\t} catch ( error ) {\n\t\t\tlet message = error.message || __( 'An error occurred.' );\n\n\t\t\t// Errors we throw are fatal.\n\t\t\tlet isFatal = error instanceof Error;\n\n\t\t\t// Specific API errors that are fatal.\n\t\t\tconst fatalAPIErrors = {\n\t\t\t\tfolder_exists: __(\n\t\t\t\t\t'This block is already installed. Try reloading the page.'\n\t\t\t\t),\n\t\t\t\tunable_to_connect_to_filesystem: __(\n\t\t\t\t\t'Error installing block. You can reload the page and try again.'\n\t\t\t\t),\n\t\t\t};\n\n\t\t\tif ( fatalAPIErrors[ error.code ] ) {\n\t\t\t\tisFatal = true;\n\t\t\t\tmessage = fatalAPIErrors[ error.code ];\n\t\t\t}\n\n\t\t\tdispatch.setErrorNotice( id, message, isFatal );\n\t\t\tregistry.dispatch( noticesStore ).createErrorNotice( message, {\n\t\t\t\tspeak: true,\n\t\t\t\tisDismissible: true,\n\t\t\t} );\n\t\t}\n\t\tdispatch.setIsInstalling( id, false );\n\t\treturn success;\n\t};\n\n/**\n * Action triggered to uninstall a block plugin.\n *\n * @param {Object} block The blockType object.\n */\nexport const uninstallBlockType =\n\t( block ) =>\n\tasync ( { registry, dispatch } ) => {\n\t\ttry {\n\t\t\tconst url = getPluginUrl( block );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'PUT',\n\t\t\t\turl,\n\t\t\t\tdata: { status: 'inactive' },\n\t\t\t} );\n\t\t\tawait apiFetch( {\n\t\t\t\tmethod: 'DELETE',\n\t\t\t\turl,\n\t\t\t} );\n\t\t\tdispatch.removeInstalledBlockType( block );\n\t\t} catch ( error ) {\n\t\t\tregistry\n\t\t\t\t.dispatch( noticesStore )\n\t\t\t\t.createErrorNotice(\n\t\t\t\t\terror.message || __( 'An error occurred.' )\n\t\t\t\t);\n\t\t}\n\t};\n\n/**\n * Returns an action object used to add a block type to the \"newly installed\"\n * tracking list.\n *\n * @param {Object} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function addInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'ADD_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to remove a block type from the \"newly installed\"\n * tracking list.\n *\n * @param {string} item The block item with the block id and name.\n *\n * @return {Object} Action object.\n */\nexport function removeInstalledBlockType( item ) {\n\treturn {\n\t\ttype: 'REMOVE_INSTALLED_BLOCK_TYPE',\n\t\titem,\n\t};\n}\n\n/**\n * Returns an action object used to indicate install in progress.\n *\n * @param {string} blockId\n * @param {boolean} isInstalling\n *\n * @return {Object} Action object.\n */\nexport function setIsInstalling( blockId, isInstalling ) {\n\treturn {\n\t\ttype: 'SET_INSTALLING_BLOCK',\n\t\tblockId,\n\t\tisInstalling,\n\t};\n}\n\n/**\n * Sets an error notice to be displayed to the user for a given block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n * @param {string} message The message shown in the notice.\n * @param {boolean} isFatal Whether the user can recover from the error.\n *\n * @return {Object} Action object.\n */\nexport function setErrorNotice( blockId, message, isFatal = false ) {\n\treturn {\n\t\ttype: 'SET_ERROR_NOTICE',\n\t\tblockId,\n\t\tmessage,\n\t\tisFatal,\n\t};\n}\n\n/**\n * Sets the error notice to empty for specific block.\n *\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {Object} Action object.\n */\nexport function clearErrorNotice( blockId ) {\n\treturn {\n\t\ttype: 'CLEAR_ERROR_NOTICE',\n\t\tblockId,\n\t};\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SACCA,KAAK,IAAIC,WAAW,EACpBC,6CAA6C,CAAE;AAAA,OACzC,mBAAmB;AAC1B,SAASC,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,OAAOC,QAAQ,MAAM,sBAAsB;AAC3C,SAASL,KAAK,IAAIM,YAAY,QAAQ,oBAAoB;AAC1D,SAASC,YAAY,QAAQ,gBAAgB;;AAE7C;AACA;AACA;AACA,SAASC,UAAU,QAAQ,eAAe;AAC1C,OAAOC,YAAY,MAAM,wBAAwB;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CAAEC,WAAW,EAAG;EACtD,OAAO;IAAEC,IAAI,EAAE,2BAA2B;IAAED;EAAY,CAAC;AAC1D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;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R,KAAK,CAACC,OAAO,IAAInD,EAAE,CAAE,oBAAqB,CAC3C,CAAC;EACH;AACD,CAAC;;AAEF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS8B,qBAAqBA,CAAEgC,IAAI,EAAG;EAC7C,OAAO;IACNrD,IAAI,EAAE,0BAA0B;IAChCqD;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASD,wBAAwBA,CAAEC,IAAI,EAAG;EAChD,OAAO;IACNrD,IAAI,EAAE,6BAA6B;IACnCqD;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAAS1C,eAAeA,CAAE2C,OAAO,EAAEC,YAAY,EAAG;EACxD,OAAO;IACNvD,IAAI,EAAE,sBAAsB;IAC5BsD,OAAO;IACPC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASP,cAAcA,CAAEM,OAAO,EAAEZ,OAAO,EAAEC,OAAO,GAAG,KAAK,EAAG;EACnE,OAAO;IACN3C,IAAI,EAAE,kBAAkB;IACxBsD,OAAO;IACPZ,OAAO;IACPC;EACD,CAAC;AACF;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASjC,gBAAgBA,CAAE4C,OAAO,EAAG;EAC3C,OAAO;IACNtD,IAAI,EAAE,oBAAoB;IAC1BsD;EACD,CAAC;AACF","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["camelCase","apiFetch","fetchDownloadableBlocks","receiveDownloadableBlocks","getDownloadableBlocks","filterValue","dispatch","results","path","blocks","map","result","Object","fromEntries","entries","key","value"],"sources":["@wordpress/block-directory/src/store/resolvers.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks =\n\t( filterValue ) =>\n\tasync ( { dispatch } ) => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\t\tconst results = await apiFetch( {\n\t\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t\t} );\n\t\t\tconst blocks = results.map( ( result ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( result ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t\t} catch {}\n\t};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,aAAa;;AAEvC;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,sBAAsB;;AAE3C;AACA;AACA;AACA,SAASC,uBAAuB,EAAEC,yBAAyB,QAAQ,WAAW;AAE9E,OAAO,MAAMC,qBAAqB,GAC/BC,WAAW,IACb,OAAQ;EAAEC;AAAS,CAAC,KAAM;EACzB,IAAK,CAAED,WAAW,EAAG;IACpB;EACD;EAEA,IAAI;IACHC,QAAQ,CAAEJ,uBAAuB,CAAEG,WAAY,CAAE,CAAC;IAClD,MAAME,OAAO,GAAG,MAAMN,QAAQ,CAAE;MAC/BO,IAAI,
|
|
1
|
+
{"version":3,"names":["camelCase","apiFetch","fetchDownloadableBlocks","receiveDownloadableBlocks","getDownloadableBlocks","filterValue","dispatch","results","path","blocks","map","result","Object","fromEntries","entries","key","value"],"sources":["@wordpress/block-directory/src/store/resolvers.js"],"sourcesContent":["/**\n * External dependencies\n */\nimport { camelCase } from 'change-case';\n\n/**\n * WordPress dependencies\n */\nimport apiFetch from '@wordpress/api-fetch';\n\n/**\n * Internal dependencies\n */\nimport { fetchDownloadableBlocks, receiveDownloadableBlocks } from './actions';\n\nexport const getDownloadableBlocks =\n\t( filterValue ) =>\n\tasync ( { dispatch } ) => {\n\t\tif ( ! filterValue ) {\n\t\t\treturn;\n\t\t}\n\n\t\ttry {\n\t\t\tdispatch( fetchDownloadableBlocks( filterValue ) );\n\t\t\tconst results = await apiFetch( {\n\t\t\t\tpath: `wp/v2/block-directory/search?term=${ filterValue }`,\n\t\t\t} );\n\t\t\tconst blocks = results.map( ( result ) =>\n\t\t\t\tObject.fromEntries(\n\t\t\t\t\tObject.entries( result ).map( ( [ key, value ] ) => [\n\t\t\t\t\t\tcamelCase( key ),\n\t\t\t\t\t\tvalue,\n\t\t\t\t\t] )\n\t\t\t\t)\n\t\t\t);\n\n\t\t\tdispatch( receiveDownloadableBlocks( blocks, filterValue ) );\n\t\t} catch {}\n\t};\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,SAAS,QAAQ,aAAa;;AAEvC;AACA;AACA;AACA,OAAOC,QAAQ,MAAM,sBAAsB;;AAE3C;AACA;AACA;AACA,SAASC,uBAAuB,EAAEC,yBAAyB,QAAQ,WAAW;AAE9E,OAAO,MAAMC,qBAAqB,GAC/BC,WAAW,IACb,OAAQ;EAAEC;AAAS,CAAC,KAAM;EACzB,IAAK,CAAED,WAAW,EAAG;IACpB;EACD;EAEA,IAAI;IACHC,QAAQ,CAAEJ,uBAAuB,CAAEG,WAAY,CAAE,CAAC;IAClD,MAAME,OAAO,GAAG,MAAMN,QAAQ,CAAE;MAC/BO,IAAI,EAAE,qCAAsCH,WAAW;IACxD,CAAE,CAAC;IACH,MAAMI,MAAM,GAAGF,OAAO,CAACG,GAAG,CAAIC,MAAM,IACnCC,MAAM,CAACC,WAAW,CACjBD,MAAM,CAACE,OAAO,CAAEH,MAAO,CAAC,CAACD,GAAG,CAAE,CAAE,CAAEK,GAAG,EAAEC,KAAK,CAAE,KAAM,CACnDhB,SAAS,CAAEe,GAAI,CAAC,EAChBC,KAAK,CACJ,CACH,CACD,CAAC;IAEDV,QAAQ,CAAEH,yBAAyB,CAAEM,MAAM,EAAEJ,WAAY,CAAE,CAAC;EAC7D,CAAC,CAAC,MAAM,CAAC;AACV,CAAC","ignoreList":[]}
|
|
@@ -192,16 +192,7 @@
|
|
|
192
192
|
outline: 2px solid transparent;
|
|
193
193
|
}
|
|
194
194
|
.block-directory-downloadable-block-list-item.is-installing .block-directory-downloadable-block-list-item__author {
|
|
195
|
-
|
|
196
|
-
clip: rect(1px, 1px, 1px, 1px);
|
|
197
|
-
clip-path: inset(50%);
|
|
198
|
-
height: 1px;
|
|
199
|
-
margin: -1px;
|
|
200
|
-
overflow: hidden;
|
|
201
|
-
padding: 0;
|
|
202
|
-
position: absolute;
|
|
203
|
-
width: 1px;
|
|
204
|
-
word-wrap: normal !important;
|
|
195
|
+
display: none;
|
|
205
196
|
}
|
|
206
197
|
|
|
207
198
|
.block-directory-downloadable-block-list-item__icon {
|
package/build-style/style.css
CHANGED
|
@@ -192,16 +192,7 @@
|
|
|
192
192
|
outline: 2px solid transparent;
|
|
193
193
|
}
|
|
194
194
|
.block-directory-downloadable-block-list-item.is-installing .block-directory-downloadable-block-list-item__author {
|
|
195
|
-
|
|
196
|
-
clip: rect(1px, 1px, 1px, 1px);
|
|
197
|
-
clip-path: inset(50%);
|
|
198
|
-
height: 1px;
|
|
199
|
-
margin: -1px;
|
|
200
|
-
overflow: hidden;
|
|
201
|
-
padding: 0;
|
|
202
|
-
position: absolute;
|
|
203
|
-
width: 1px;
|
|
204
|
-
word-wrap: normal !important;
|
|
195
|
+
display: none;
|
|
205
196
|
}
|
|
206
197
|
|
|
207
198
|
.block-directory-downloadable-block-list-item__icon {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-directory",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.11.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",
|
|
@@ -26,25 +26,25 @@
|
|
|
26
26
|
"module": "build-module/index.js",
|
|
27
27
|
"react-native": "src/index",
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@babel/runtime": "
|
|
30
|
-
"@wordpress/a11y": "
|
|
31
|
-
"@wordpress/api-fetch": "
|
|
32
|
-
"@wordpress/block-editor": "
|
|
33
|
-
"@wordpress/blocks": "
|
|
34
|
-
"@wordpress/components": "
|
|
35
|
-
"@wordpress/compose": "
|
|
36
|
-
"@wordpress/core-data": "
|
|
37
|
-
"@wordpress/data": "
|
|
38
|
-
"@wordpress/editor": "
|
|
39
|
-
"@wordpress/element": "
|
|
40
|
-
"@wordpress/hooks": "
|
|
41
|
-
"@wordpress/html-entities": "
|
|
42
|
-
"@wordpress/i18n": "
|
|
43
|
-
"@wordpress/icons": "
|
|
44
|
-
"@wordpress/notices": "
|
|
45
|
-
"@wordpress/plugins": "
|
|
46
|
-
"@wordpress/private-apis": "
|
|
47
|
-
"@wordpress/url": "
|
|
29
|
+
"@babel/runtime": "7.25.7",
|
|
30
|
+
"@wordpress/a11y": "*",
|
|
31
|
+
"@wordpress/api-fetch": "*",
|
|
32
|
+
"@wordpress/block-editor": "*",
|
|
33
|
+
"@wordpress/blocks": "*",
|
|
34
|
+
"@wordpress/components": "*",
|
|
35
|
+
"@wordpress/compose": "*",
|
|
36
|
+
"@wordpress/core-data": "*",
|
|
37
|
+
"@wordpress/data": "*",
|
|
38
|
+
"@wordpress/editor": "*",
|
|
39
|
+
"@wordpress/element": "*",
|
|
40
|
+
"@wordpress/hooks": "*",
|
|
41
|
+
"@wordpress/html-entities": "*",
|
|
42
|
+
"@wordpress/i18n": "*",
|
|
43
|
+
"@wordpress/icons": "*",
|
|
44
|
+
"@wordpress/notices": "*",
|
|
45
|
+
"@wordpress/plugins": "*",
|
|
46
|
+
"@wordpress/private-apis": "*",
|
|
47
|
+
"@wordpress/url": "*",
|
|
48
48
|
"change-case": "^4.1.2",
|
|
49
49
|
"clsx": "^2.1.1"
|
|
50
50
|
},
|
|
@@ -55,5 +55,6 @@
|
|
|
55
55
|
"publishConfig": {
|
|
56
56
|
"access": "public"
|
|
57
57
|
},
|
|
58
|
-
"
|
|
58
|
+
"wpScript": true,
|
|
59
|
+
"gitHead": "dcf4613b33b0eda14e203ac30f700ed0db70347f"
|
|
59
60
|
}
|
|
@@ -34,28 +34,28 @@ function getDownloadableBlockLabel(
|
|
|
34
34
|
const stars = Math.round( rating / 0.5 ) * 0.5;
|
|
35
35
|
|
|
36
36
|
if ( ! isInstalled && hasNotice ) {
|
|
37
|
-
/* translators: %
|
|
37
|
+
/* translators: %s: block title */
|
|
38
38
|
return sprintf( 'Retry installing %s.', decodeEntities( title ) );
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
if ( isInstalled ) {
|
|
42
|
-
/* translators: %
|
|
42
|
+
/* translators: %s: block title */
|
|
43
43
|
return sprintf( 'Add %s.', decodeEntities( title ) );
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
if ( isInstalling ) {
|
|
47
|
-
/* translators: %
|
|
47
|
+
/* translators: %s: block title */
|
|
48
48
|
return sprintf( 'Installing %s.', decodeEntities( title ) );
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
// No ratings yet, just use the title.
|
|
52
52
|
if ( ratingCount < 1 ) {
|
|
53
|
-
/* translators: %
|
|
53
|
+
/* translators: %s: block title */
|
|
54
54
|
return sprintf( 'Install %s.', decodeEntities( title ) );
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
return sprintf(
|
|
58
|
-
/* translators:
|
|
58
|
+
/* translators: 1: block title, 2: average rating, 3: total ratings count. */
|
|
59
59
|
_n(
|
|
60
60
|
'Install %1$s. %2$s stars with %3$s review.',
|
|
61
61
|
'Install %1$s. %2$s stars with %3$s reviews.',
|
|
@@ -131,7 +131,7 @@ function DownloadableBlockListItem( { item, onClick } ) {
|
|
|
131
131
|
<span className="block-directory-downloadable-block-list-item__title">
|
|
132
132
|
{ createInterpolateElement(
|
|
133
133
|
sprintf(
|
|
134
|
-
/* translators:
|
|
134
|
+
/* translators: 1: block title. 2: author name. */
|
|
135
135
|
__( '%1$s <span>by %2$s</span>' ),
|
|
136
136
|
decodeEntities( title ),
|
|
137
137
|
author
|
|
@@ -38,17 +38,7 @@
|
|
|
38
38
|
|
|
39
39
|
&.is-installing {
|
|
40
40
|
.block-directory-downloadable-block-list-item__author {
|
|
41
|
-
|
|
42
|
-
clip: rect(1px, 1px, 1px, 1px);
|
|
43
|
-
-webkit-clip-path: inset(50%);
|
|
44
|
-
clip-path: inset(50%);
|
|
45
|
-
height: 1px;
|
|
46
|
-
margin: -1px;
|
|
47
|
-
overflow: hidden;
|
|
48
|
-
padding: 0;
|
|
49
|
-
position: absolute;
|
|
50
|
-
width: 1px;
|
|
51
|
-
word-wrap: normal !important;
|
|
41
|
+
display: none;
|
|
52
42
|
}
|
|
53
43
|
}
|
|
54
44
|
}
|