@wordpress/block-directory 5.57.0 → 6.1.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/build/components/auto-block-uninstaller/index.cjs +26 -47
- package/build/components/auto-block-uninstaller/index.cjs.map +1 -7
- package/build/components/block-ratings/index.cjs +28 -34
- package/build/components/block-ratings/index.cjs.map +1 -7
- package/build/components/block-ratings/stars.cjs +35 -71
- package/build/components/block-ratings/stars.cjs.map +1 -7
- package/build/components/compact-list/index.cjs +45 -43
- package/build/components/compact-list/index.cjs.map +1 -7
- package/build/components/downloadable-block-icon/index.cjs +20 -29
- package/build/components/downloadable-block-icon/index.cjs.map +1 -7
- package/build/components/downloadable-block-list-item/index.cjs +95 -161
- package/build/components/downloadable-block-list-item/index.cjs.map +1 -7
- package/build/components/downloadable-block-notice/index.cjs +23 -46
- package/build/components/downloadable-block-notice/index.cjs.map +1 -7
- package/build/components/downloadable-blocks-list/index.cjs +50 -70
- package/build/components/downloadable-blocks-list/index.cjs.map +1 -7
- package/build/components/downloadable-blocks-panel/index.cjs +79 -119
- package/build/components/downloadable-blocks-panel/index.cjs.map +1 -7
- package/build/components/downloadable-blocks-panel/inserter-panel.cjs +37 -61
- package/build/components/downloadable-blocks-panel/inserter-panel.cjs.map +1 -7
- package/build/components/downloadable-blocks-panel/no-results.cjs +27 -39
- package/build/components/downloadable-blocks-panel/no-results.cjs.map +1 -7
- package/build/index.cjs +11 -29
- package/build/plugins/get-install-missing/index.cjs +80 -122
- package/build/plugins/get-install-missing/index.cjs.map +1 -7
- package/build/plugins/get-install-missing/install-button.cjs +33 -70
- package/build/plugins/get-install-missing/install-button.cjs.map +1 -7
- package/build/plugins/index.cjs +45 -45
- package/build/plugins/index.cjs.map +1 -7
- package/build/plugins/inserter-menu-downloadable-blocks-panel/index.cjs +40 -52
- package/build/plugins/inserter-menu-downloadable-blocks-panel/index.cjs.map +1 -7
- package/build/plugins/installed-blocks-pre-publish-panel/index.cjs +38 -62
- package/build/plugins/installed-blocks-pre-publish-panel/index.cjs.map +1 -7
- package/build/store/actions.cjs +233 -205
- package/build/store/actions.cjs.map +1 -7
- package/build/store/index.cjs +56 -45
- package/build/store/index.cjs.map +1 -7
- package/build/store/load-assets.cjs +62 -63
- package/build/store/load-assets.cjs.map +1 -7
- package/build/store/reducer.cjs +90 -101
- package/build/store/reducer.cjs.map +1 -7
- package/build/store/resolvers.cjs +34 -54
- package/build/store/resolvers.cjs.map +1 -7
- package/build/store/selectors.cjs +111 -107
- package/build/store/selectors.cjs.map +1 -7
- package/build/store/utils/get-plugin-url.cjs +19 -32
- package/build/store/utils/get-plugin-url.cjs.map +1 -7
- package/build-module/components/auto-block-uninstaller/index.mjs +19 -25
- package/build-module/components/auto-block-uninstaller/index.mjs.map +1 -7
- package/build-module/components/block-ratings/index.mjs +8 -8
- package/build-module/components/block-ratings/index.mjs.map +1 -7
- package/build-module/components/block-ratings/stars.mjs +28 -49
- package/build-module/components/block-ratings/stars.mjs.map +1 -7
- package/build-module/components/compact-list/index.mjs +24 -19
- package/build-module/components/compact-list/index.mjs.map +1 -7
- package/build-module/components/downloadable-block-icon/index.mjs +14 -8
- package/build-module/components/downloadable-block-icon/index.mjs.map +1 -7
- package/build-module/components/downloadable-block-list-item/index.mjs +64 -130
- package/build-module/components/downloadable-block-list-item/index.mjs.map +1 -7
- package/build-module/components/downloadable-block-notice/index.mjs +15 -20
- package/build-module/components/downloadable-block-notice/index.mjs.map +1 -7
- package/build-module/components/downloadable-blocks-list/index.mjs +26 -43
- package/build-module/components/downloadable-blocks-list/index.mjs.map +1 -7
- package/build-module/components/downloadable-blocks-panel/index.mjs +51 -90
- package/build-module/components/downloadable-blocks-panel/index.mjs.map +1 -7
- package/build-module/components/downloadable-blocks-panel/inserter-panel.mjs +29 -38
- package/build-module/components/downloadable-blocks-panel/inserter-panel.mjs.map +1 -7
- package/build-module/components/downloadable-blocks-panel/no-results.mjs +21 -18
- package/build-module/components/downloadable-blocks-panel/no-results.mjs.map +1 -7
- package/build-module/index.mjs +1 -6
- package/build-module/plugins/get-install-missing/index.mjs +55 -98
- package/build-module/plugins/get-install-missing/index.mjs.map +1 -7
- package/build-module/plugins/get-install-missing/install-button.mjs +25 -47
- package/build-module/plugins/get-install-missing/install-button.mjs.map +1 -7
- package/build-module/plugins/index.mjs +16 -23
- package/build-module/plugins/index.mjs.map +1 -7
- package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs +17 -26
- package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.mjs.map +1 -7
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs +15 -36
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.mjs.map +1 -7
- package/build-module/store/actions.mjs +201 -170
- package/build-module/store/actions.mjs.map +1 -7
- package/build-module/store/index.mjs +28 -13
- package/build-module/store/index.mjs.map +1 -7
- package/build-module/store/load-assets.mjs +42 -36
- package/build-module/store/load-assets.mjs.map +1 -7
- package/build-module/store/reducer.mjs +81 -74
- package/build-module/store/reducer.mjs.map +1 -7
- package/build-module/store/resolvers.mjs +13 -26
- package/build-module/store/resolvers.mjs.map +1 -7
- package/build-module/store/selectors.mjs +99 -76
- package/build-module/store/selectors.mjs.map +1 -7
- package/build-module/store/utils/get-plugin-url.mjs +14 -12
- package/build-module/store/utils/get-plugin-url.mjs.map +1 -7
- package/build-style/style-rtl.css +6 -12
- package/build-style/style.css +6 -12
- package/package.json +25 -27
- package/src/components/downloadable-block-list-item/index.jsx +2 -2
- package/src/components/downloadable-block-list-item/style.scss +6 -6
- package/src/components/downloadable-blocks-panel/index.jsx +2 -2
- package/src/components/downloadable-blocks-panel/no-results.jsx +15 -8
- package/CHANGELOG.md +0 -295
- package/build/index.cjs.map +0 -7
- package/build/lock-unlock.cjs +0 -36
- package/build/lock-unlock.cjs.map +0 -7
- package/build-module/index.mjs.map +0 -7
- package/build-module/lock-unlock.mjs +0 -11
- package/build-module/lock-unlock.mjs.map +0 -7
- package/src/lock-unlock.js +0 -7
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/plugins/get-install-missing/install-button.jsx"],
|
|
4
|
-
"sourcesContent": ["import { __, 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';\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"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,IAAI,eAAe;AAC5B,SAAS,cAAc;AACvB,SAAS,aAAa,cAAc,aAAa;AACjD,SAAS,WAAW,mBAAmB;AACvC,SAAS,SAAS,wBAAwB;AAC1C,SAAS,SAAS,2BAA2B;AAW3C;AATa,SAAR,cAAgC,EAAE,YAAY,OAAO,SAAS,GAAI;AACxE,QAAM,oBAAoB;AAAA,IACzB,CAAE,WAAY,OAAQ,mBAAoB,EAAE,aAAc,MAAM,EAAG;AAAA,IACnE,CAAE,MAAM,EAAG;AAAA,EACZ;AACA,QAAM,EAAE,iBAAiB,IAAI,YAAa,mBAAoB;AAC9D,QAAM,EAAE,aAAa,IAAI,YAAa,gBAAiB;AAEvD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,uBAAqB;AAAA,MACrB,SAAU,MACT,iBAAkB,KAAM,EAAE,KAAM,CAAE,YAAa;AAC9C,YAAK,SAAU;AACd,gBAAM,YAAY,aAAc,MAAM,IAAK;AAC3C,gBAAM,CAAE,aAAc,IAAI;AAAA,YACzB,WAAW;AAAA,UACZ;AACA,cAAK,iBAAiB,WAAY;AACjC;AAAA,cACC;AAAA,cACA;AAAA,gBACC,UAAU;AAAA,gBACV,cAAc;AAAA,gBACd,cAAc;AAAA,cACf;AAAA,YACD;AAAA,UACD;AAAA,QACD;AAAA,MACD,CAAE;AAAA,MAEH,wBAAsB;AAAA,MACtB,UAAW;AAAA,MACX,QAAS;AAAA,MACT,SAAQ;AAAA,MAEN;AAAA;AAAA,QAED,GAAI,YAAa;AAAA,QACjB,MAAM;AAAA,MACP;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"install-button.mjs","names":["blockDirectoryStore","blockEditorStore"],"sources":["../../../src/plugins/get-install-missing/install-button.jsx"],"sourcesContent":["import { __, 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';\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":";;;;;;;;AAOA,SAAwB,cAAe,EAAE,YAAY,OAAO,YAAa;CACxE,MAAM,oBAAoB,WACvB,WAAY,OAAQA,OAAoB,CAAC,CAAC,aAAc,MAAM,EAAG,GACnE,CAAE,MAAM,EAAG,CACZ;CACA,MAAM,EAAE,qBAAqB,YAAaA,OAAoB;CAC9D,MAAM,EAAE,iBAAiB,YAAaC,KAAiB;CAEvD,OACC,oBAAC,QAAD;EACC,uBAAA;EACA,eACC,iBAAkB,KAAM,CAAC,CAAC,MAAQ,YAAa;GAC9C,IAAK,SAAU;IACd,MAAM,YAAY,aAAc,MAAM,IAAK;IAC3C,MAAM,CAAE,iBAAkB,MACzB,WAAW,eACZ;IACA,IAAK,iBAAiB,WACrB,aACC,UACA,YACC,UAAU,MACV,cAAc,YACd,cAAc,WACf,CACD;GAEF;EACD,CAAE;EAEH,wBAAA;EACA,UAAW;EACX,QAAS;EACT,SAAQ;EAEN,UAAA,QAED,GAAI,YAAa,GACjB,MAAM,KACP;CACO,CAAA;AAEV"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
// packages/block-directory/src/plugins/index.jsx
|
|
2
1
|
import { registerPlugin } from "@wordpress/plugins";
|
|
3
2
|
import { addFilter } from "@wordpress/hooks";
|
|
4
3
|
import AutoBlockUninstaller from "../components/auto-block-uninstaller/index.mjs";
|
|
@@ -6,27 +5,21 @@ import InserterMenuDownloadableBlocksPanel from "./inserter-menu-downloadable-bl
|
|
|
6
5
|
import InstalledBlocksPrePublishPanel from "./installed-blocks-pre-publish-panel/index.mjs";
|
|
7
6
|
import getInstallMissing from "./get-install-missing/index.mjs";
|
|
8
7
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
8
|
+
// packages/block-directory/src/plugins/index.jsx
|
|
9
9
|
registerPlugin("block-directory", {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
10
|
+
icon: void 0,
|
|
11
|
+
render() {
|
|
12
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
13
|
+
/* @__PURE__ */ jsx(AutoBlockUninstaller, {}),
|
|
14
|
+
/* @__PURE__ */ jsx(InserterMenuDownloadableBlocksPanel, {}),
|
|
15
|
+
/* @__PURE__ */ jsx(InstalledBlocksPrePublishPanel, {})
|
|
16
|
+
] });
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
addFilter("blocks.registerBlockType", "block-directory/fallback", (settings, name) => {
|
|
20
|
+
if (name !== "core/missing") return settings;
|
|
21
|
+
settings.edit = getInstallMissing(settings.edit);
|
|
22
|
+
return settings;
|
|
20
23
|
});
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"block-directory/fallback",
|
|
24
|
-
(settings, name) => {
|
|
25
|
-
if (name !== "core/missing") {
|
|
26
|
-
return settings;
|
|
27
|
-
}
|
|
28
|
-
settings.edit = getInstallMissing(settings.edit);
|
|
29
|
-
return settings;
|
|
30
|
-
}
|
|
31
|
-
);
|
|
32
|
-
//# sourceMappingURL=index.mjs.map
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../src/plugins/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\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\t// The icon is explicitly set to undefined to prevent PluginPrePublishPanel\n\t// from rendering the fallback icon pluginIcon.\n\ticon: undefined,\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"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,sBAAsB;AAC/B,SAAS,iBAAiB;AAC1B,OAAO,0BAA0B;AACjC,OAAO,yCAAyC;AAChD,OAAO,oCAAoC;AAC3C,OAAO,uBAAuB;AAQ3B,mBACC,KADD;AANH,eAAgB,mBAAmB;AAAA;AAAA;AAAA,EAGlC,MAAM;AAAA,EACN,SAAS;AACR,WACC,iCACC;AAAA,0BAAC,wBAAqB;AAAA,MACtB,oBAAC,uCAAoC;AAAA,MACrC,oBAAC,kCAA+B;AAAA,OACjC;AAAA,EAEF;AACD,CAAE;AAEF;AAAA,EACC;AAAA,EACA;AAAA,EACA,CAAE,UAAU,SAAU;AACrB,QAAK,SAAS,gBAAiB;AAC9B,aAAO;AAAA,IACR;AACA,aAAS,OAAO,kBAAmB,SAAS,IAAK;AAEjD,WAAO;AAAA,EACR;AACD;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/plugins/index.jsx"],"sourcesContent":["import { registerPlugin } from '@wordpress/plugins';\nimport { addFilter } from '@wordpress/hooks';\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\t// The icon is explicitly set to undefined to prevent PluginPrePublishPanel\n\t// from rendering the fallback icon pluginIcon.\n\ticon: undefined,\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":";;;;;;;;AAOA,eAAgB,mBAAmB;CAGlC,MAAM,KAAA;CACN,SAAS;EACR,OACC,qBAAA,UAAA,EAAA,UAAA;GACC,oBAAC,sBAAD,CAAuB,CAAA;GACvB,oBAAC,qCAAD,CAAsC,CAAA;GACtC,oBAAC,gCAAD,CAAiC,CAAA;EAChC,EAAA,CAAA;CAEJ;AACD,CAAE;AAEF,UACC,4BACA,6BACE,UAAU,SAAU;CACrB,IAAK,SAAS,gBACb,OAAO;CAER,SAAS,OAAO,kBAAmB,SAAS,IAAK;CAEjD,OAAO;AACR,CACD"}
|
|
@@ -1,33 +1,24 @@
|
|
|
1
|
-
// packages/block-directory/src/plugins/inserter-menu-downloadable-blocks-panel/index.jsx
|
|
2
1
|
import { __unstableInserterMenuExtension } from "@wordpress/block-editor";
|
|
3
2
|
import { debounce } from "@wordpress/compose";
|
|
4
3
|
import { useState } from "@wordpress/element";
|
|
5
4
|
import DownloadableBlocksPanel from "../../components/downloadable-blocks-panel/index.mjs";
|
|
6
5
|
import { jsx } from "react/jsx-runtime";
|
|
6
|
+
// packages/block-directory/src/plugins/inserter-menu-downloadable-blocks-panel/index.jsx
|
|
7
7
|
function InserterMenuDownloadableBlocksPanel() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
onHover,
|
|
22
|
-
filterValue: debouncedFilterValue,
|
|
23
|
-
hasLocalBlocks: hasItems,
|
|
24
|
-
isTyping: filterValue !== debouncedFilterValue
|
|
25
|
-
}
|
|
26
|
-
);
|
|
27
|
-
} });
|
|
8
|
+
const [debouncedFilterValue, setFilterValue] = useState("");
|
|
9
|
+
const debouncedSetFilterValue = debounce(setFilterValue, 400);
|
|
10
|
+
return /* @__PURE__ */ jsx(__unstableInserterMenuExtension, { children: ({ onSelect, onHover, filterValue, hasItems }) => {
|
|
11
|
+
if (debouncedFilterValue !== filterValue) debouncedSetFilterValue(filterValue);
|
|
12
|
+
if (!debouncedFilterValue) return null;
|
|
13
|
+
return /* @__PURE__ */ jsx(DownloadableBlocksPanel, {
|
|
14
|
+
onSelect,
|
|
15
|
+
onHover,
|
|
16
|
+
filterValue: debouncedFilterValue,
|
|
17
|
+
hasLocalBlocks: hasItems,
|
|
18
|
+
isTyping: filterValue !== debouncedFilterValue
|
|
19
|
+
});
|
|
20
|
+
} });
|
|
28
21
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
};
|
|
33
|
-
//# sourceMappingURL=index.mjs.map
|
|
22
|
+
export { InserterMenuDownloadableBlocksPanel as default };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/plugins/inserter-menu-downloadable-blocks-panel/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { __unstableInserterMenuExtension } from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport DownloadableBlocksPanel from '../../components/downloadable-blocks-panel';\n\nfunction InserterMenuDownloadableBlocksPanel() {\n\tconst [ debouncedFilterValue, setFilterValue ] = useState( '' );\n\tconst debouncedSetFilterValue = debounce( setFilterValue, 400 );\n\n\treturn (\n\t\t<__unstableInserterMenuExtension>\n\t\t\t{ ( { onSelect, onHover, filterValue, hasItems } ) => {\n\t\t\t\tif ( debouncedFilterValue !== filterValue ) {\n\t\t\t\t\tdebouncedSetFilterValue( filterValue );\n\t\t\t\t}\n\n\t\t\t\tif ( ! debouncedFilterValue ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<DownloadableBlocksPanel\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tfilterValue={ debouncedFilterValue }\n\t\t\t\t\t\thasLocalBlocks={ hasItems }\n\t\t\t\t\t\tisTyping={ filterValue !== debouncedFilterValue }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} }\n\t\t</__unstableInserterMenuExtension>\n\t);\n}\n\nexport default InserterMenuDownloadableBlocksPanel;\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,uCAAuC;AAChD,SAAS,gBAAgB;AACzB,SAAS,gBAAgB;AACzB,OAAO,6BAA6B;AAkB/B;AAhBL,SAAS,sCAAsC;AAC9C,QAAM,CAAE,sBAAsB,cAAe,IAAI,SAAU,EAAG;AAC9D,QAAM,0BAA0B,SAAU,gBAAgB,GAAI;AAE9D,SACC,oBAAC,mCACE,WAAE,EAAE,UAAU,SAAS,aAAa,SAAS,MAAO;AACrD,QAAK,yBAAyB,aAAc;AAC3C,8BAAyB,WAAY;AAAA,IACtC;AAEA,QAAK,CAAE,sBAAuB;AAC7B,aAAO;AAAA,IACR;AAEA,WACC;AAAA,MAAC;AAAA;AAAA,QACA;AAAA,QACA;AAAA,QACA,aAAc;AAAA,QACd,gBAAiB;AAAA,QACjB,UAAW,gBAAgB;AAAA;AAAA,IAC5B;AAAA,EAEF,GACD;AAEF;AAEA,IAAO,kDAAQ;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/plugins/inserter-menu-downloadable-blocks-panel/index.jsx"],"sourcesContent":["import { __unstableInserterMenuExtension } from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\nimport DownloadableBlocksPanel from '../../components/downloadable-blocks-panel';\n\nfunction InserterMenuDownloadableBlocksPanel() {\n\tconst [ debouncedFilterValue, setFilterValue ] = useState( '' );\n\tconst debouncedSetFilterValue = debounce( setFilterValue, 400 );\n\n\treturn (\n\t\t<__unstableInserterMenuExtension>\n\t\t\t{ ( { onSelect, onHover, filterValue, hasItems } ) => {\n\t\t\t\tif ( debouncedFilterValue !== filterValue ) {\n\t\t\t\t\tdebouncedSetFilterValue( filterValue );\n\t\t\t\t}\n\n\t\t\t\tif ( ! debouncedFilterValue ) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\n\t\t\t\treturn (\n\t\t\t\t\t<DownloadableBlocksPanel\n\t\t\t\t\t\tonSelect={ onSelect }\n\t\t\t\t\t\tonHover={ onHover }\n\t\t\t\t\t\tfilterValue={ debouncedFilterValue }\n\t\t\t\t\t\thasLocalBlocks={ hasItems }\n\t\t\t\t\t\tisTyping={ filterValue !== debouncedFilterValue }\n\t\t\t\t\t/>\n\t\t\t\t);\n\t\t\t} }\n\t\t</__unstableInserterMenuExtension>\n\t);\n}\n\nexport default InserterMenuDownloadableBlocksPanel;\n"],"mappings":";;;;;;AAKA,SAAS,sCAAsC;CAC9C,MAAM,CAAE,sBAAsB,kBAAmB,SAAU,EAAG;CAC9D,MAAM,0BAA0B,SAAU,gBAAgB,GAAI;CAE9D,OACC,oBAAC,iCAAD,EAAA,WACK,EAAE,UAAU,SAAS,aAAa,eAAgB;EACrD,IAAK,yBAAyB,aAC7B,wBAAyB,WAAY;EAGtC,IAAK,CAAE,sBACN,OAAO;EAGR,OACC,oBAAC,yBAAD;GACY;GACD;GACV,aAAc;GACd,gBAAiB;GACjB,UAAW,gBAAgB;EAC3B,CAAA;CAEH,EACgC,CAAA;AAEnC"}
|
|
@@ -1,43 +1,22 @@
|
|
|
1
|
-
// packages/block-directory/src/plugins/installed-blocks-pre-publish-panel/index.jsx
|
|
2
1
|
import { _n, sprintf } from "@wordpress/i18n";
|
|
3
2
|
import { useSelect } from "@wordpress/data";
|
|
4
3
|
import { PluginPrePublishPanel } from "@wordpress/editor";
|
|
5
4
|
import CompactList from "../../components/compact-list/index.mjs";
|
|
6
|
-
import { store
|
|
5
|
+
import { store } from "../../store/index.mjs";
|
|
7
6
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
7
|
+
// packages/block-directory/src/plugins/installed-blocks-pre-publish-panel/index.jsx
|
|
8
8
|
function InstalledBlocksPrePublishPanel() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
title: sprintf(
|
|
20
|
-
// translators: %d: number of blocks (number).
|
|
21
|
-
_n(
|
|
22
|
-
"Added: %d block",
|
|
23
|
-
"Added: %d blocks",
|
|
24
|
-
newBlockTypes.length
|
|
25
|
-
),
|
|
26
|
-
newBlockTypes.length
|
|
27
|
-
),
|
|
28
|
-
initialOpen: true,
|
|
29
|
-
children: [
|
|
30
|
-
/* @__PURE__ */ jsx("p", { className: "installed-blocks-pre-publish-panel__copy", children: _n(
|
|
31
|
-
"The following block has been added to your site.",
|
|
32
|
-
"The following blocks have been added to your site.",
|
|
33
|
-
newBlockTypes.length
|
|
34
|
-
) }),
|
|
35
|
-
/* @__PURE__ */ jsx(CompactList, { items: newBlockTypes })
|
|
36
|
-
]
|
|
37
|
-
}
|
|
38
|
-
);
|
|
9
|
+
const newBlockTypes = useSelect((select) => select(store).getNewBlockTypes(), []);
|
|
10
|
+
if (!newBlockTypes.length) return null;
|
|
11
|
+
return /* @__PURE__ */ jsxs(PluginPrePublishPanel, {
|
|
12
|
+
title: sprintf(_n("Added: %d block", "Added: %d blocks", newBlockTypes.length), newBlockTypes.length),
|
|
13
|
+
initialOpen: true,
|
|
14
|
+
children: [/* @__PURE__ */ jsx("p", {
|
|
15
|
+
className: "installed-blocks-pre-publish-panel__copy",
|
|
16
|
+
children: _n("The following block has been added to your site.", "The following blocks have been added to your site.", newBlockTypes.length)
|
|
17
|
+
}), /* @__PURE__ */ jsx(CompactList, { items: newBlockTypes })]
|
|
18
|
+
});
|
|
39
19
|
}
|
|
40
|
-
export {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
//# sourceMappingURL=index.mjs.map
|
|
20
|
+
export { InstalledBlocksPrePublishPanel as default };
|
|
21
|
+
|
|
22
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../../../src/plugins/installed-blocks-pre-publish-panel/index.jsx"],
|
|
4
|
-
"sourcesContent": ["import { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PluginPrePublishPanel } from '@wordpress/editor';\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\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"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,IAAI,eAAe;AAC5B,SAAS,iBAAiB;AAC1B,SAAS,6BAA6B;AACtC,OAAO,iBAAiB;AACxB,SAAS,SAAS,2BAA2B;AAa3C,SAYC,KAZD;AAXa,SAAR,iCAAkD;AACxD,QAAM,gBAAgB;AAAA,IACrB,CAAE,WAAY,OAAQ,mBAAoB,EAAE,iBAAiB;AAAA,IAC7D,CAAC;AAAA,EACF;AAEA,MAAK,CAAE,cAAc,QAAS;AAC7B,WAAO;AAAA,EACR;AAEA,SACC;AAAA,IAAC;AAAA;AAAA,MACA,OAAQ;AAAA;AAAA,QAEP;AAAA,UACC;AAAA,UACA;AAAA,UACA,cAAc;AAAA,QACf;AAAA,QACA,cAAc;AAAA,MACf;AAAA,MACA,aAAW;AAAA,MAEX;AAAA,4BAAC,OAAE,WAAU,4CACV;AAAA,UACD;AAAA,UACA;AAAA,UACA,cAAc;AAAA,QACf,GACD;AAAA,QACA,oBAAC,eAAY,OAAQ,eAAgB;AAAA;AAAA;AAAA,EACtC;AAEF;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["blockDirectoryStore"],"sources":["../../../src/plugins/installed-blocks-pre-publish-panel/index.jsx"],"sourcesContent":["import { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { PluginPrePublishPanel } from '@wordpress/editor';\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\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":";;;;;;;AAMA,SAAwB,iCAAiC;CACxD,MAAM,gBAAgB,WACnB,WAAY,OAAQA,KAAoB,CAAC,CAAC,iBAAiB,GAC7D,CAAC,CACF;CAEA,IAAK,CAAE,cAAc,QACpB,OAAO;CAGR,OACC,qBAAC,uBAAD;EACC,OAAQ,QAEP,GACC,mBACA,oBACA,cAAc,MACf,GACA,cAAc,MACf;EACA,aAAA;EAVD,UAAA,CAYC,oBAAC,KAAD;GAAG,WAAU;GACV,UAAA,GACD,oDACA,sDACA,cAAc,MACf;EACE,CAAA,GACH,oBAAC,aAAD,EAAa,OAAQ,cAAiB,CAAA,CAChB;;AAEzB"}
|
|
@@ -1,191 +1,222 @@
|
|
|
1
|
-
|
|
2
|
-
import {
|
|
3
|
-
store as blocksStore,
|
|
4
|
-
unstable__bootstrapServerSideBlockDefinitions
|
|
5
|
-
} from "@wordpress/blocks";
|
|
1
|
+
import { store, unstable__bootstrapServerSideBlockDefinitions } from "@wordpress/blocks";
|
|
6
2
|
import { __, sprintf } from "@wordpress/i18n";
|
|
7
3
|
import apiFetch from "@wordpress/api-fetch";
|
|
8
|
-
import { store as
|
|
4
|
+
import { store as store$1 } from "@wordpress/notices";
|
|
9
5
|
import { addQueryArgs } from "@wordpress/url";
|
|
10
6
|
import { loadAssets } from "./load-assets.mjs";
|
|
11
7
|
import getPluginUrl from "./utils/get-plugin-url.mjs";
|
|
8
|
+
// packages/block-directory/src/store/actions.js
|
|
9
|
+
/**
|
|
10
|
+
* Returns an action object used in signalling that the downloadable blocks
|
|
11
|
+
* have been requested and are loading.
|
|
12
|
+
*
|
|
13
|
+
* @param {string} filterValue Search string.
|
|
14
|
+
*
|
|
15
|
+
* @return {Object} Action object.
|
|
16
|
+
*/
|
|
12
17
|
function fetchDownloadableBlocks(filterValue) {
|
|
13
|
-
|
|
18
|
+
return {
|
|
19
|
+
type: "FETCH_DOWNLOADABLE_BLOCKS",
|
|
20
|
+
filterValue
|
|
21
|
+
};
|
|
14
22
|
}
|
|
23
|
+
/**
|
|
24
|
+
* Returns an action object used in signalling that the downloadable blocks
|
|
25
|
+
* have been updated.
|
|
26
|
+
*
|
|
27
|
+
* @param {Array} downloadableBlocks Downloadable blocks.
|
|
28
|
+
* @param {string} filterValue Search string.
|
|
29
|
+
*
|
|
30
|
+
* @return {Object} Action object.
|
|
31
|
+
*/
|
|
15
32
|
function receiveDownloadableBlocks(downloadableBlocks, filterValue) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
33
|
+
return {
|
|
34
|
+
type: "RECEIVE_DOWNLOADABLE_BLOCKS",
|
|
35
|
+
downloadableBlocks,
|
|
36
|
+
filterValue
|
|
37
|
+
};
|
|
21
38
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
const fatalAPIErrors = {
|
|
108
|
-
folder_exists: __(
|
|
109
|
-
"This block is already installed. Try reloading the page."
|
|
110
|
-
),
|
|
111
|
-
unable_to_connect_to_filesystem: __(
|
|
112
|
-
"Error installing block. You can reload the page and try again."
|
|
113
|
-
)
|
|
114
|
-
};
|
|
115
|
-
if (fatalAPIErrors[error.code]) {
|
|
116
|
-
isFatal = true;
|
|
117
|
-
message = fatalAPIErrors[error.code];
|
|
118
|
-
}
|
|
119
|
-
dispatch.setErrorNotice(id, message, isFatal);
|
|
120
|
-
registry.dispatch(noticesStore).createErrorNotice(message, {
|
|
121
|
-
speak: true,
|
|
122
|
-
isDismissible: true
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
dispatch.setIsInstalling(id, false);
|
|
126
|
-
return success;
|
|
39
|
+
/**
|
|
40
|
+
* Action triggered to install a block plugin.
|
|
41
|
+
*
|
|
42
|
+
* @param {Object} block The block item returned by search.
|
|
43
|
+
*
|
|
44
|
+
* @return {boolean} Whether the block was successfully installed & loaded.
|
|
45
|
+
*/
|
|
46
|
+
const installBlockType = (block) => async ({ registry, dispatch }) => {
|
|
47
|
+
const { id, name } = block;
|
|
48
|
+
let success = false;
|
|
49
|
+
dispatch.clearErrorNotice(id);
|
|
50
|
+
try {
|
|
51
|
+
dispatch.setIsInstalling(id, true);
|
|
52
|
+
const url = getPluginUrl(block);
|
|
53
|
+
let links = {};
|
|
54
|
+
if (url) await apiFetch({
|
|
55
|
+
method: "PUT",
|
|
56
|
+
url,
|
|
57
|
+
data: { status: "active" }
|
|
58
|
+
});
|
|
59
|
+
else links = (await apiFetch({
|
|
60
|
+
method: "POST",
|
|
61
|
+
path: "wp/v2/plugins",
|
|
62
|
+
data: {
|
|
63
|
+
slug: id,
|
|
64
|
+
status: "active"
|
|
65
|
+
}
|
|
66
|
+
}))._links;
|
|
67
|
+
dispatch.addInstalledBlockType({
|
|
68
|
+
...block,
|
|
69
|
+
links: {
|
|
70
|
+
...block.links,
|
|
71
|
+
...links
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const metadataFields = [
|
|
75
|
+
"api_version",
|
|
76
|
+
"title",
|
|
77
|
+
"category",
|
|
78
|
+
"parent",
|
|
79
|
+
"ancestor",
|
|
80
|
+
"icon",
|
|
81
|
+
"description",
|
|
82
|
+
"keywords",
|
|
83
|
+
"attributes",
|
|
84
|
+
"provides_context",
|
|
85
|
+
"uses_context",
|
|
86
|
+
"selectors",
|
|
87
|
+
"supports",
|
|
88
|
+
"styles",
|
|
89
|
+
"example",
|
|
90
|
+
"variations",
|
|
91
|
+
"allowed_blocks",
|
|
92
|
+
"block_hooks"
|
|
93
|
+
];
|
|
94
|
+
await apiFetch({ path: addQueryArgs(`/wp/v2/block-types/${name}`, { _fields: metadataFields }) }).catch(() => {}).then((response) => {
|
|
95
|
+
if (!response) return;
|
|
96
|
+
unstable__bootstrapServerSideBlockDefinitions({ [name]: Object.fromEntries(Object.entries(response).filter(([key]) => metadataFields.includes(key))) });
|
|
97
|
+
});
|
|
98
|
+
await loadAssets();
|
|
99
|
+
if (!registry.select(store).getBlockTypes().some((i) => i.name === name)) throw new Error(__("Error registering block. Try reloading the page."));
|
|
100
|
+
registry.dispatch(store$1).createInfoNotice(sprintf(__("Block %s installed and added."), block.title), {
|
|
101
|
+
speak: true,
|
|
102
|
+
type: "snackbar"
|
|
103
|
+
});
|
|
104
|
+
success = true;
|
|
105
|
+
} catch (error) {
|
|
106
|
+
let message = error.message || __("An error occurred.");
|
|
107
|
+
let isFatal = error instanceof Error;
|
|
108
|
+
const fatalAPIErrors = {
|
|
109
|
+
folder_exists: __("This block is already installed. Try reloading the page."),
|
|
110
|
+
unable_to_connect_to_filesystem: __("Error installing block. You can reload the page and try again.")
|
|
111
|
+
};
|
|
112
|
+
if (fatalAPIErrors[error.code]) {
|
|
113
|
+
isFatal = true;
|
|
114
|
+
message = fatalAPIErrors[error.code];
|
|
115
|
+
}
|
|
116
|
+
dispatch.setErrorNotice(id, message, isFatal);
|
|
117
|
+
registry.dispatch(store$1).createErrorNotice(message, {
|
|
118
|
+
speak: true,
|
|
119
|
+
isDismissible: true
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
dispatch.setIsInstalling(id, false);
|
|
123
|
+
return success;
|
|
127
124
|
};
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Action triggered to uninstall a block plugin.
|
|
127
|
+
*
|
|
128
|
+
* @param {Object} block The blockType object.
|
|
129
|
+
*/
|
|
130
|
+
const uninstallBlockType = (block) => async ({ registry, dispatch }) => {
|
|
131
|
+
try {
|
|
132
|
+
const url = getPluginUrl(block);
|
|
133
|
+
await apiFetch({
|
|
134
|
+
method: "PUT",
|
|
135
|
+
url,
|
|
136
|
+
data: { status: "inactive" }
|
|
137
|
+
});
|
|
138
|
+
await apiFetch({
|
|
139
|
+
method: "DELETE",
|
|
140
|
+
url
|
|
141
|
+
});
|
|
142
|
+
dispatch.removeInstalledBlockType(block);
|
|
143
|
+
} catch (error) {
|
|
144
|
+
registry.dispatch(store$1).createErrorNotice(error.message || __("An error occurred."));
|
|
145
|
+
}
|
|
146
146
|
};
|
|
147
|
+
/**
|
|
148
|
+
* Returns an action object used to add a block type to the "newly installed"
|
|
149
|
+
* tracking list.
|
|
150
|
+
*
|
|
151
|
+
* @param {Object} item The block item with the block id and name.
|
|
152
|
+
*
|
|
153
|
+
* @return {Object} Action object.
|
|
154
|
+
*/
|
|
147
155
|
function addInstalledBlockType(item) {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
156
|
+
return {
|
|
157
|
+
type: "ADD_INSTALLED_BLOCK_TYPE",
|
|
158
|
+
item
|
|
159
|
+
};
|
|
152
160
|
}
|
|
161
|
+
/**
|
|
162
|
+
* Returns an action object used to remove a block type from the "newly installed"
|
|
163
|
+
* tracking list.
|
|
164
|
+
*
|
|
165
|
+
* @param {string} item The block item with the block id and name.
|
|
166
|
+
*
|
|
167
|
+
* @return {Object} Action object.
|
|
168
|
+
*/
|
|
153
169
|
function removeInstalledBlockType(item) {
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
170
|
+
return {
|
|
171
|
+
type: "REMOVE_INSTALLED_BLOCK_TYPE",
|
|
172
|
+
item
|
|
173
|
+
};
|
|
158
174
|
}
|
|
175
|
+
/**
|
|
176
|
+
* Returns an action object used to indicate install in progress.
|
|
177
|
+
*
|
|
178
|
+
* @param {string} blockId
|
|
179
|
+
* @param {boolean} isInstalling
|
|
180
|
+
*
|
|
181
|
+
* @return {Object} Action object.
|
|
182
|
+
*/
|
|
159
183
|
function setIsInstalling(blockId, isInstalling) {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
184
|
+
return {
|
|
185
|
+
type: "SET_INSTALLING_BLOCK",
|
|
186
|
+
blockId,
|
|
187
|
+
isInstalling
|
|
188
|
+
};
|
|
165
189
|
}
|
|
190
|
+
/**
|
|
191
|
+
* Sets an error notice to be displayed to the user for a given block.
|
|
192
|
+
*
|
|
193
|
+
* @param {string} blockId The ID of the block plugin. eg: my-block
|
|
194
|
+
* @param {string} message The message shown in the notice.
|
|
195
|
+
* @param {boolean} isFatal Whether the user can recover from the error.
|
|
196
|
+
*
|
|
197
|
+
* @return {Object} Action object.
|
|
198
|
+
*/
|
|
166
199
|
function setErrorNotice(blockId, message, isFatal = false) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
200
|
+
return {
|
|
201
|
+
type: "SET_ERROR_NOTICE",
|
|
202
|
+
blockId,
|
|
203
|
+
message,
|
|
204
|
+
isFatal
|
|
205
|
+
};
|
|
173
206
|
}
|
|
207
|
+
/**
|
|
208
|
+
* Sets the error notice to empty for specific block.
|
|
209
|
+
*
|
|
210
|
+
* @param {string} blockId The ID of the block plugin. eg: my-block
|
|
211
|
+
*
|
|
212
|
+
* @return {Object} Action object.
|
|
213
|
+
*/
|
|
174
214
|
function clearErrorNotice(blockId) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
215
|
+
return {
|
|
216
|
+
type: "CLEAR_ERROR_NOTICE",
|
|
217
|
+
blockId
|
|
218
|
+
};
|
|
179
219
|
}
|
|
180
|
-
export {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
fetchDownloadableBlocks,
|
|
184
|
-
installBlockType,
|
|
185
|
-
receiveDownloadableBlocks,
|
|
186
|
-
removeInstalledBlockType,
|
|
187
|
-
setErrorNotice,
|
|
188
|
-
setIsInstalling,
|
|
189
|
-
uninstallBlockType
|
|
190
|
-
};
|
|
191
|
-
//# sourceMappingURL=actions.mjs.map
|
|
220
|
+
export { addInstalledBlockType, clearErrorNotice, fetchDownloadableBlocks, installBlockType, receiveDownloadableBlocks, removeInstalledBlockType, setErrorNotice, setIsInstalling, uninstallBlockType };
|
|
221
|
+
|
|
222
|
+
//# sourceMappingURL=actions.mjs.map
|