@wordpress/block-directory 5.32.0 → 5.32.1-next.b8c8708f3.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.js +37 -31
- package/build/components/auto-block-uninstaller/index.js.map +7 -1
- package/build/components/block-ratings/index.js +40 -22
- package/build/components/block-ratings/index.js.map +7 -1
- package/build/components/block-ratings/stars.js +66 -40
- package/build/components/block-ratings/stars.js.map +7 -1
- package/build/components/compact-list/index.js +47 -46
- package/build/components/compact-list/index.js.map +7 -1
- package/build/components/downloadable-block-icon/index.js +28 -26
- package/build/components/downloadable-block-icon/index.js.map +7 -1
- package/build/components/downloadable-block-list-item/index.js +113 -127
- package/build/components/downloadable-block-list-item/index.js.map +7 -1
- package/build/components/downloadable-block-notice/index.js +41 -31
- package/build/components/downloadable-block-notice/index.js.map +7 -1
- package/build/components/downloadable-blocks-list/index.js +72 -56
- package/build/components/downloadable-blocks-list/index.js.map +7 -1
- package/build/components/downloadable-blocks-panel/index.js +108 -95
- package/build/components/downloadable-blocks-panel/index.js.map +7 -1
- package/build/components/downloadable-blocks-panel/inserter-panel.js +52 -38
- package/build/components/downloadable-blocks-panel/inserter-panel.js.map +7 -1
- package/build/components/downloadable-blocks-panel/no-results.js +37 -30
- package/build/components/downloadable-blocks-panel/no-results.js.map +7 -1
- package/build/index.js +27 -12
- package/build/index.js.map +7 -1
- package/build/lock-unlock.js +31 -15
- package/build/lock-unlock.js.map +7 -1
- package/build/plugins/get-install-missing/index.js +123 -102
- package/build/plugins/get-install-missing/index.js.map +7 -1
- package/build/plugins/get-install-missing/install-button.js +68 -50
- package/build/plugins/get-install-missing/install-button.js.map +7 -1
- package/build/plugins/index.js +46 -29
- package/build/plugins/index.js.map +7 -1
- package/build/plugins/inserter-menu-downloadable-blocks-panel/index.js +55 -42
- package/build/plugins/inserter-menu-downloadable-blocks-panel/index.js.map +7 -1
- package/build/plugins/installed-blocks-pre-publish-panel/index.js +65 -34
- package/build/plugins/installed-blocks-pre-publish-panel/index.js.map +7 -1
- package/build/store/actions.js +142 -188
- package/build/store/actions.js.map +7 -1
- package/build/store/index.js +48 -46
- package/build/store/index.js.map +7 -1
- package/build/store/load-assets.js +48 -55
- package/build/store/load-assets.js.map +7 -1
- package/build/store/reducer.js +48 -54
- package/build/store/reducer.js.map +7 -1
- package/build/store/resolvers.js +52 -31
- package/build/store/resolvers.js.map +7 -1
- package/build/store/selectors.js +100 -127
- package/build/store/selectors.js.map +7 -1
- package/build/store/utils/get-plugin-url.js +23 -14
- package/build/store/utils/get-plugin-url.js.map +7 -1
- package/build-module/components/auto-block-uninstaller/index.js +18 -24
- package/build-module/components/auto-block-uninstaller/index.js.map +7 -1
- package/build-module/components/block-ratings/index.js +9 -15
- package/build-module/components/block-ratings/index.js.map +7 -1
- package/build-module/components/block-ratings/stars.js +48 -34
- package/build-module/components/block-ratings/stars.js.map +7 -1
- package/build-module/components/compact-list/index.js +19 -39
- package/build-module/components/compact-list/index.js.map +7 -1
- package/build-module/components/downloadable-block-icon/index.js +10 -20
- package/build-module/components/downloadable-block-icon/index.js.map +7 -1
- package/build-module/components/downloadable-block-list-item/index.js +89 -120
- package/build-module/components/downloadable-block-list-item/index.js.map +7 -1
- package/build-module/components/downloadable-block-notice/index.js +19 -24
- package/build-module/components/downloadable-block-notice/index.js.map +7 -1
- package/build-module/components/downloadable-blocks-list/index.js +44 -49
- package/build-module/components/downloadable-blocks-list/index.js.map +7 -1
- package/build-module/components/downloadable-blocks-panel/index.js +81 -89
- package/build-module/components/downloadable-blocks-panel/index.js.map +7 -1
- package/build-module/components/downloadable-blocks-panel/inserter-panel.js +33 -31
- package/build-module/components/downloadable-blocks-panel/inserter-panel.js.map +7 -1
- package/build-module/components/downloadable-blocks-panel/no-results.js +19 -24
- package/build-module/components/downloadable-blocks-panel/no-results.js.map +7 -1
- package/build-module/index.js +6 -6
- package/build-module/index.js.map +7 -1
- package/build-module/lock-unlock.js +8 -7
- package/build-module/lock-unlock.js.map +7 -1
- package/build-module/plugins/get-install-missing/index.js +99 -95
- package/build-module/plugins/get-install-missing/index.js.map +7 -1
- package/build-module/plugins/get-install-missing/install-button.js +50 -44
- package/build-module/plugins/get-install-missing/install-button.js.map +7 -1
- package/build-module/plugins/index.js +24 -25
- package/build-module/plugins/index.js.map +7 -1
- package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.js +26 -34
- package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.js.map +7 -1
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.js +38 -28
- package/build-module/plugins/installed-blocks-pre-publish-panel/index.js.map +7 -1
- package/build-module/store/actions.js +100 -168
- package/build-module/store/actions.js.map +7 -1
- package/build-module/store/index.js +13 -36
- package/build-module/store/index.js.map +7 -1
- package/build-module/store/load-assets.js +15 -47
- package/build-module/store/load-assets.js.map +7 -1
- package/build-module/store/reducer.js +27 -49
- package/build-module/store/reducer.js.map +7 -1
- package/build-module/store/resolvers.js +16 -19
- package/build-module/store/resolvers.js.map +7 -1
- package/build-module/store/selectors.js +77 -121
- package/build-module/store/selectors.js.map +7 -1
- package/build-module/store/utils/get-plugin-url.js +6 -10
- package/build-module/store/utils/get-plugin-url.js.map +7 -1
- package/build-style/style-rtl.css +9 -142
- package/build-style/style.css +9 -142
- package/package.json +28 -21
- package/src/components/block-ratings/style.scss +2 -0
- package/src/components/compact-list/style.scss +3 -0
- package/src/components/downloadable-block-icon/style.scss +3 -0
- package/src/components/downloadable-block-list-item/style.scss +4 -0
- package/src/components/downloadable-block-notice/style.scss +3 -0
- package/src/components/downloadable-blocks-panel/style.scss +3 -1
- package/src/style.scss +8 -7
|
@@ -1,112 +1,133 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var get_install_missing_exports = {};
|
|
29
|
+
__export(get_install_missing_exports, {
|
|
30
|
+
default: () => get_install_missing_default
|
|
6
31
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var
|
|
17
|
-
var
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
const {
|
|
37
|
-
getDownloadableBlocks
|
|
38
|
-
} = select(_store.store);
|
|
39
|
-
const blocks = getDownloadableBlocks('block:' + originalName).filter(({
|
|
40
|
-
name
|
|
41
|
-
}) => originalName === name);
|
|
42
|
-
return {
|
|
43
|
-
hasPermission: select(_coreData.store).canUser('read', 'block-directory/search'),
|
|
44
|
-
block: blocks.length && blocks[0]
|
|
45
|
-
};
|
|
46
|
-
}, [originalName]);
|
|
47
|
-
|
|
48
|
-
// The user can't install blocks, or the block isn't available for download.
|
|
32
|
+
module.exports = __toCommonJS(get_install_missing_exports);
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_i18n = require("@wordpress/i18n");
|
|
35
|
+
var import_components = require("@wordpress/components");
|
|
36
|
+
var import_blocks = require("@wordpress/blocks");
|
|
37
|
+
var import_element = require("@wordpress/element");
|
|
38
|
+
var import_data = require("@wordpress/data");
|
|
39
|
+
var import_core_data = require("@wordpress/core-data");
|
|
40
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
41
|
+
var import_install_button = __toESM(require("./install-button"));
|
|
42
|
+
var import_store = require("../../store");
|
|
43
|
+
const getInstallMissing = (OriginalComponent) => (props) => {
|
|
44
|
+
const { originalName } = props.attributes;
|
|
45
|
+
const { block, hasPermission } = (0, import_data.useSelect)(
|
|
46
|
+
(select) => {
|
|
47
|
+
const { getDownloadableBlocks } = select(import_store.store);
|
|
48
|
+
const blocks = getDownloadableBlocks(
|
|
49
|
+
"block:" + originalName
|
|
50
|
+
).filter(({ name }) => originalName === name);
|
|
51
|
+
return {
|
|
52
|
+
hasPermission: select(import_core_data.store).canUser(
|
|
53
|
+
"read",
|
|
54
|
+
"block-directory/search"
|
|
55
|
+
),
|
|
56
|
+
block: blocks.length && blocks[0]
|
|
57
|
+
};
|
|
58
|
+
},
|
|
59
|
+
[originalName]
|
|
60
|
+
);
|
|
49
61
|
if (!hasPermission || !block) {
|
|
50
|
-
return
|
|
51
|
-
...props
|
|
52
|
-
});
|
|
62
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(OriginalComponent, { ...props });
|
|
53
63
|
}
|
|
54
|
-
return
|
|
55
|
-
...props,
|
|
56
|
-
originalBlock: block
|
|
57
|
-
});
|
|
64
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ModifiedWarning, { ...props, originalBlock: block });
|
|
58
65
|
};
|
|
59
|
-
const ModifiedWarning = ({
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}) => {
|
|
63
|
-
const {
|
|
64
|
-
originalName,
|
|
65
|
-
originalUndelimitedContent,
|
|
66
|
-
clientId
|
|
67
|
-
} = props.attributes;
|
|
68
|
-
const {
|
|
69
|
-
replaceBlock
|
|
70
|
-
} = (0, _data.useDispatch)(_blockEditor.store);
|
|
66
|
+
const ModifiedWarning = ({ originalBlock, ...props }) => {
|
|
67
|
+
const { originalName, originalUndelimitedContent, clientId } = props.attributes;
|
|
68
|
+
const { replaceBlock } = (0, import_data.useDispatch)(import_block_editor.store);
|
|
71
69
|
const convertToHTML = () => {
|
|
72
|
-
replaceBlock(
|
|
73
|
-
|
|
74
|
-
|
|
70
|
+
replaceBlock(
|
|
71
|
+
props.clientId,
|
|
72
|
+
(0, import_blocks.createBlock)("core/html", {
|
|
73
|
+
content: originalUndelimitedContent
|
|
74
|
+
})
|
|
75
|
+
);
|
|
75
76
|
};
|
|
76
77
|
const hasContent = !!originalUndelimitedContent;
|
|
77
|
-
const hasHTMLBlock = (0,
|
|
78
|
-
|
|
79
|
-
canInsertBlockType,
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
78
|
+
const hasHTMLBlock = (0, import_data.useSelect)(
|
|
79
|
+
(select) => {
|
|
80
|
+
const { canInsertBlockType, getBlockRootClientId } = select(import_block_editor.store);
|
|
81
|
+
return canInsertBlockType(
|
|
82
|
+
"core/html",
|
|
83
|
+
getBlockRootClientId(clientId)
|
|
84
|
+
);
|
|
85
|
+
},
|
|
86
|
+
[clientId]
|
|
87
|
+
);
|
|
88
|
+
let messageHTML = (0, import_i18n.sprintf)(
|
|
89
|
+
/* translators: %s: block name */
|
|
90
|
+
(0, import_i18n.__)(
|
|
91
|
+
"Your site doesn\u2019t include support for the %s block. You can try installing the block or remove it entirely."
|
|
92
|
+
),
|
|
93
|
+
originalBlock.title || originalName
|
|
94
|
+
);
|
|
95
|
+
const actions = [
|
|
96
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
97
|
+
import_install_button.default,
|
|
98
|
+
{
|
|
99
|
+
block: originalBlock,
|
|
100
|
+
attributes: props.attributes,
|
|
101
|
+
clientId: props.clientId
|
|
102
|
+
},
|
|
103
|
+
"install"
|
|
104
|
+
)
|
|
105
|
+
];
|
|
91
106
|
if (hasContent && hasHTMLBlock) {
|
|
92
|
-
messageHTML = (0,
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
107
|
+
messageHTML = (0, import_i18n.sprintf)(
|
|
108
|
+
/* translators: %s: block name */
|
|
109
|
+
(0, import_i18n.__)(
|
|
110
|
+
"Your site doesn\u2019t include support for the %s block. You can try installing the block, convert it to a Custom HTML block, or remove it entirely."
|
|
111
|
+
),
|
|
112
|
+
originalBlock.title || originalName
|
|
113
|
+
);
|
|
114
|
+
actions.push(
|
|
115
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
116
|
+
import_components.Button,
|
|
117
|
+
{
|
|
118
|
+
__next40pxDefaultSize: true,
|
|
119
|
+
onClick: convertToHTML,
|
|
120
|
+
variant: "tertiary",
|
|
121
|
+
children: (0, import_i18n.__)("Keep as HTML")
|
|
122
|
+
},
|
|
123
|
+
"convert"
|
|
124
|
+
)
|
|
125
|
+
);
|
|
100
126
|
}
|
|
101
|
-
return
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
children: messageHTML
|
|
106
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_element.RawHTML, {
|
|
107
|
-
children: originalUndelimitedContent
|
|
108
|
-
})]
|
|
109
|
-
});
|
|
127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { ...(0, import_block_editor.useBlockProps)(), children: [
|
|
128
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.Warning, { actions, children: messageHTML }),
|
|
129
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_element.RawHTML, { children: originalUndelimitedContent })
|
|
130
|
+
] });
|
|
110
131
|
};
|
|
111
|
-
var
|
|
112
|
-
//# sourceMappingURL=index.js.map
|
|
132
|
+
var get_install_missing_default = getInstallMissing;
|
|
133
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/get-install-missing/index.js"],
|
|
4
|
+
"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\u2019t 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\u2019t 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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AA4CS;AAzCT,kBAA4B;AAC5B,wBAAuB;AACvB,oBAA4B;AAC5B,qBAAwB;AACxB,kBAAuC;AACvC,uBAAmC;AACnC,0BAIO;AAKP,4BAA0B;AAC1B,mBAA6C;AAE7C,MAAM,oBAAoB,CAAE,sBAAuB,CAAE,UAAW;AAC/D,QAAM,EAAE,aAAa,IAAI,MAAM;AAG/B,QAAM,EAAE,OAAO,cAAc,QAAI;AAAA,IAChC,CAAE,WAAY;AACb,YAAM,EAAE,sBAAsB,IAAI,OAAQ,aAAAA,KAAoB;AAC9D,YAAM,SAAS;AAAA,QACd,WAAW;AAAA,MACZ,EAAE,OAAQ,CAAE,EAAE,KAAK,MAAO,iBAAiB,IAAK;AAChD,aAAO;AAAA,QACN,eAAe,OAAQ,iBAAAC,KAAU,EAAE;AAAA,UAClC;AAAA,UACA;AAAA,QACD;AAAA,QACA,OAAO,OAAO,UAAU,OAAQ,CAAE;AAAA,MACnC;AAAA,IACD;AAAA,IACA,CAAE,YAAa;AAAA,EAChB;AAGA,MAAK,CAAE,iBAAiB,CAAE,OAAQ;AACjC,WAAO,4CAAC,qBAAoB,GAAG,OAAQ;AAAA,EACxC;AAEA,SAAO,4CAAC,mBAAkB,GAAG,OAAQ,eAAgB,OAAQ;AAC9D;AAEA,MAAM,kBAAkB,CAAE,EAAE,eAAe,GAAG,MAAM,MAAO;AAC1D,QAAM,EAAE,cAAc,4BAA4B,SAAS,IAC1D,MAAM;AACP,QAAM,EAAE,aAAa,QAAI,yBAAa,oBAAAC,KAAiB;AACvD,QAAM,gBAAgB,MAAM;AAC3B;AAAA,MACC,MAAM;AAAA,UACN,2BAAa,aAAa;AAAA,QACzB,SAAS;AAAA,MACV,CAAE;AAAA,IACH;AAAA,EACD;AAEA,QAAM,aAAa,CAAC,CAAE;AACtB,QAAM,mBAAe;AAAA,IACpB,CAAE,WAAY;AACb,YAAM,EAAE,oBAAoB,qBAAqB,IAChD,OAAQ,oBAAAA,KAAiB;AAE1B,aAAO;AAAA,QACN;AAAA,QACA,qBAAsB,QAAS;AAAA,MAChC;AAAA,IACD;AAAA,IACA,CAAE,QAAS;AAAA,EACZ;AAEA,MAAI,kBAAc;AAAA;AAAA,QAEjB;AAAA,MACC;AAAA,IACD;AAAA,IACA,cAAc,SAAS;AAAA,EACxB;AACA,QAAM,UAAU;AAAA,IACf;AAAA,MAAC,sBAAAC;AAAA,MAAA;AAAA,QAEA,OAAQ;AAAA,QACR,YAAa,MAAM;AAAA,QACnB,UAAW,MAAM;AAAA;AAAA,MAHb;AAAA,IAIL;AAAA,EACD;AAEA,MAAK,cAAc,cAAe;AACjC,sBAAc;AAAA;AAAA,UAEb;AAAA,QACC;AAAA,MACD;AAAA,MACA,cAAc,SAAS;AAAA,IACxB;AACA,YAAQ;AAAA,MACP;AAAA,QAAC;AAAA;AAAA,UACA,uBAAqB;AAAA,UAErB,SAAU;AAAA,UACV,SAAQ;AAAA,UAEN,8BAAI,cAAe;AAAA;AAAA,QAJjB;AAAA,MAKL;AAAA,IACD;AAAA,EACD;AAEA,SACC,6CAAC,SAAM,OAAG,mCAAc,GACvB;AAAA,gDAAC,+BAAQ,SAAsB,uBAAa;AAAA,IAC5C,4CAAC,0BAAU,sCAA4B;AAAA,KACxC;AAEF;AAEA,IAAO,8BAAQ;",
|
|
6
|
+
"names": ["blockDirectoryStore", "coreStore", "blockEditorStore", "InstallButton"]
|
|
7
|
+
}
|
|
@@ -1,53 +1,71 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.
|
|
4
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var install_button_exports = {};
|
|
19
|
+
__export(install_button_exports, {
|
|
20
|
+
default: () => InstallButton
|
|
5
21
|
});
|
|
6
|
-
exports
|
|
7
|
-
var
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
replaceBlock(clientId, (0, _blocks.createBlock)(blockType.name, originalBlock.attributes, originalBlock.innerBlocks));
|
|
22
|
+
module.exports = __toCommonJS(install_button_exports);
|
|
23
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
24
|
+
var import_i18n = require("@wordpress/i18n");
|
|
25
|
+
var import_components = require("@wordpress/components");
|
|
26
|
+
var import_blocks = require("@wordpress/blocks");
|
|
27
|
+
var import_data = require("@wordpress/data");
|
|
28
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
29
|
+
var import_store = require("../../store");
|
|
30
|
+
function InstallButton({ attributes, block, clientId }) {
|
|
31
|
+
const isInstallingBlock = (0, import_data.useSelect)(
|
|
32
|
+
(select) => select(import_store.store).isInstalling(block.id),
|
|
33
|
+
[block.id]
|
|
34
|
+
);
|
|
35
|
+
const { installBlockType } = (0, import_data.useDispatch)(import_store.store);
|
|
36
|
+
const { replaceBlock } = (0, import_data.useDispatch)(import_block_editor.store);
|
|
37
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
38
|
+
import_components.Button,
|
|
39
|
+
{
|
|
40
|
+
__next40pxDefaultSize: true,
|
|
41
|
+
onClick: () => installBlockType(block).then((success) => {
|
|
42
|
+
if (success) {
|
|
43
|
+
const blockType = (0, import_blocks.getBlockType)(block.name);
|
|
44
|
+
const [originalBlock] = (0, import_blocks.parse)(
|
|
45
|
+
attributes.originalContent
|
|
46
|
+
);
|
|
47
|
+
if (originalBlock && blockType) {
|
|
48
|
+
replaceBlock(
|
|
49
|
+
clientId,
|
|
50
|
+
(0, import_blocks.createBlock)(
|
|
51
|
+
blockType.name,
|
|
52
|
+
originalBlock.attributes,
|
|
53
|
+
originalBlock.innerBlocks
|
|
54
|
+
)
|
|
55
|
+
);
|
|
56
|
+
}
|
|
42
57
|
}
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
58
|
+
}),
|
|
59
|
+
accessibleWhenDisabled: true,
|
|
60
|
+
disabled: isInstallingBlock,
|
|
61
|
+
isBusy: isInstallingBlock,
|
|
62
|
+
variant: "primary",
|
|
63
|
+
children: (0, import_i18n.sprintf)(
|
|
64
|
+
/* translators: %s: block name */
|
|
65
|
+
(0, import_i18n.__)("Install %s"),
|
|
66
|
+
block.title
|
|
67
|
+
)
|
|
68
|
+
}
|
|
69
|
+
);
|
|
52
70
|
}
|
|
53
|
-
//# sourceMappingURL=install-button.js.map
|
|
71
|
+
//# sourceMappingURL=install-button.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../src/plugins/get-install-missing/install-button.js"],
|
|
4
|
+
"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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAuBE;AApBF,kBAA4B;AAC5B,wBAAuB;AACvB,oBAAiD;AACjD,kBAAuC;AACvC,0BAA0C;AAK1C,mBAA6C;AAE9B,SAAR,cAAgC,EAAE,YAAY,OAAO,SAAS,GAAI;AACxE,QAAM,wBAAoB;AAAA,IACzB,CAAE,WAAY,OAAQ,aAAAA,KAAoB,EAAE,aAAc,MAAM,EAAG;AAAA,IACnE,CAAE,MAAM,EAAG;AAAA,EACZ;AACA,QAAM,EAAE,iBAAiB,QAAI,yBAAa,aAAAA,KAAoB;AAC9D,QAAM,EAAE,aAAa,QAAI,yBAAa,oBAAAC,KAAiB;AAEvD,SACC;AAAA,IAAC;AAAA;AAAA,MACA,uBAAqB;AAAA,MACrB,SAAU,MACT,iBAAkB,KAAM,EAAE,KAAM,CAAE,YAAa;AAC9C,YAAK,SAAU;AACd,gBAAM,gBAAY,4BAAc,MAAM,IAAK;AAC3C,gBAAM,CAAE,aAAc,QAAI;AAAA,YACzB,WAAW;AAAA,UACZ;AACA,cAAK,iBAAiB,WAAY;AACjC;AAAA,cACC;AAAA,kBACA;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,YAED,gBAAI,YAAa;AAAA,QACjB,MAAM;AAAA,MACP;AAAA;AAAA,EACD;AAEF;",
|
|
6
|
+
"names": ["blockDirectoryStore", "blockEditorStore"]
|
|
7
|
+
}
|
package/build/plugins/index.js
CHANGED
|
@@ -1,36 +1,53 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __copyProps = (to, from, except, desc) => {
|
|
8
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
9
|
+
for (let key of __getOwnPropNames(from))
|
|
10
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
11
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
12
|
+
}
|
|
13
|
+
return to;
|
|
14
|
+
};
|
|
15
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
16
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
17
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
18
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
19
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
20
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
21
|
+
mod
|
|
22
|
+
));
|
|
23
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
24
|
+
var import_plugins = require("@wordpress/plugins");
|
|
25
|
+
var import_hooks = require("@wordpress/hooks");
|
|
26
|
+
var import_auto_block_uninstaller = __toESM(require("../components/auto-block-uninstaller"));
|
|
27
|
+
var import_inserter_menu_downloadable_blocks_panel = __toESM(require("./inserter-menu-downloadable-blocks-panel"));
|
|
28
|
+
var import_installed_blocks_pre_publish_panel = __toESM(require("./installed-blocks-pre-publish-panel"));
|
|
29
|
+
var import_get_install_missing = __toESM(require("./get-install-missing"));
|
|
30
|
+
(0, import_plugins.registerPlugin)("block-directory", {
|
|
20
31
|
// The icon is explicitly set to undefined to prevent PluginPrePublishPanel
|
|
21
32
|
// from rendering the fallback icon pluginIcon.
|
|
22
|
-
icon:
|
|
33
|
+
icon: void 0,
|
|
23
34
|
render() {
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
35
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
36
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_auto_block_uninstaller.default, {}),
|
|
37
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_inserter_menu_downloadable_blocks_panel.default, {}),
|
|
38
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_installed_blocks_pre_publish_panel.default, {})
|
|
39
|
+
] });
|
|
27
40
|
}
|
|
28
41
|
});
|
|
29
|
-
(0,
|
|
30
|
-
|
|
42
|
+
(0, import_hooks.addFilter)(
|
|
43
|
+
"blocks.registerBlockType",
|
|
44
|
+
"block-directory/fallback",
|
|
45
|
+
(settings, name) => {
|
|
46
|
+
if (name !== "core/missing") {
|
|
47
|
+
return settings;
|
|
48
|
+
}
|
|
49
|
+
settings.edit = (0, import_get_install_missing.default)(settings.edit);
|
|
31
50
|
return settings;
|
|
32
51
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
//# sourceMappingURL=index.js.map
|
|
52
|
+
);
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/plugins/index.js"],
|
|
4
|
+
"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\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": ";;;;;;;;;;;;;;;;;;;;;;AAoBG;AAjBH,qBAA+B;AAC/B,mBAA0B;AAK1B,oCAAiC;AACjC,qDAAgD;AAChD,gDAA2C;AAC3C,iCAA8B;AAAA,IAE9B,+BAAgB,mBAAmB;AAAA;AAAA;AAAA,EAGlC,MAAM;AAAA,EACN,SAAS;AACR,WACC,4EACC;AAAA,kDAAC,8BAAAA,SAAA,EAAqB;AAAA,MACtB,4CAAC,+CAAAC,SAAA,EAAoC;AAAA,MACrC,4CAAC,0CAAAC,SAAA,EAA+B;AAAA,OACjC;AAAA,EAEF;AACD,CAAE;AAAA,IAEF;AAAA,EACC;AAAA,EACA;AAAA,EACA,CAAE,UAAU,SAAU;AACrB,QAAK,SAAS,gBAAiB;AAC9B,aAAO;AAAA,IACR;AACA,aAAS,WAAO,2BAAAC,SAAmB,SAAS,IAAK;AAEjD,WAAO;AAAA,EACR;AACD;",
|
|
6
|
+
"names": ["AutoBlockUninstaller", "InserterMenuDownloadableBlocksPanel", "InstalledBlocksPrePublishPanel", "getInstallMissing"]
|
|
7
|
+
}
|
|
@@ -1,48 +1,61 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
Object.
|
|
5
|
-
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var inserter_menu_downloadable_blocks_panel_exports = {};
|
|
29
|
+
__export(inserter_menu_downloadable_blocks_panel_exports, {
|
|
30
|
+
default: () => inserter_menu_downloadable_blocks_panel_default
|
|
6
31
|
});
|
|
7
|
-
exports
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
/**
|
|
14
|
-
* WordPress dependencies
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Internal dependencies
|
|
19
|
-
*/
|
|
20
|
-
|
|
32
|
+
module.exports = __toCommonJS(inserter_menu_downloadable_blocks_panel_exports);
|
|
33
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
34
|
+
var import_block_editor = require("@wordpress/block-editor");
|
|
35
|
+
var import_compose = require("@wordpress/compose");
|
|
36
|
+
var import_element = require("@wordpress/element");
|
|
37
|
+
var import_downloadable_blocks_panel = __toESM(require("../../components/downloadable-blocks-panel"));
|
|
21
38
|
function InserterMenuDownloadableBlocksPanel() {
|
|
22
|
-
const [debouncedFilterValue, setFilterValue] = (0,
|
|
23
|
-
const debouncedSetFilterValue = (0,
|
|
24
|
-
return
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_downloadableBlocksPanel.default, {
|
|
38
|
-
onSelect: onSelect,
|
|
39
|
-
onHover: onHover,
|
|
39
|
+
const [debouncedFilterValue, setFilterValue] = (0, import_element.useState)("");
|
|
40
|
+
const debouncedSetFilterValue = (0, import_compose.debounce)(setFilterValue, 400);
|
|
41
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_block_editor.__unstableInserterMenuExtension, { children: ({ onSelect, onHover, filterValue, hasItems }) => {
|
|
42
|
+
if (debouncedFilterValue !== filterValue) {
|
|
43
|
+
debouncedSetFilterValue(filterValue);
|
|
44
|
+
}
|
|
45
|
+
if (!debouncedFilterValue) {
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
49
|
+
import_downloadable_blocks_panel.default,
|
|
50
|
+
{
|
|
51
|
+
onSelect,
|
|
52
|
+
onHover,
|
|
40
53
|
filterValue: debouncedFilterValue,
|
|
41
54
|
hasLocalBlocks: hasItems,
|
|
42
55
|
isTyping: filterValue !== debouncedFilterValue
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
});
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
} });
|
|
46
59
|
}
|
|
47
|
-
var
|
|
48
|
-
//# sourceMappingURL=index.js.map
|
|
60
|
+
var inserter_menu_downloadable_blocks_panel_default = InserterMenuDownloadableBlocksPanel;
|
|
61
|
+
//# sourceMappingURL=index.js.map
|