@wordpress/block-directory 3.15.2 → 3.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -0
- package/build/plugins/get-install-missing/index.js +9 -2
- package/build/plugins/get-install-missing/index.js.map +1 -1
- package/build/plugins/inserter-menu-downloadable-blocks-panel/index.js +3 -7
- package/build/plugins/inserter-menu-downloadable-blocks-panel/index.js.map +1 -1
- package/build-module/plugins/get-install-missing/index.js +10 -3
- package/build-module/plugins/get-install-missing/index.js.map +1 -1
- package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.js +1 -5
- package/build-module/plugins/inserter-menu-downloadable-blocks-panel/index.js.map +1 -1
- package/package.json +20 -20
- package/src/plugins/get-install-missing/index.js +15 -3
- package/src/plugins/inserter-menu-downloadable-blocks-panel/index.js +1 -5
package/CHANGELOG.md
CHANGED
|
@@ -75,7 +75,8 @@ const ModifiedWarning = _ref2 => {
|
|
|
75
75
|
} = _ref2;
|
|
76
76
|
const {
|
|
77
77
|
originalName,
|
|
78
|
-
originalUndelimitedContent
|
|
78
|
+
originalUndelimitedContent,
|
|
79
|
+
clientId
|
|
79
80
|
} = props.attributes;
|
|
80
81
|
const {
|
|
81
82
|
replaceBlock
|
|
@@ -88,7 +89,13 @@ const ModifiedWarning = _ref2 => {
|
|
|
88
89
|
};
|
|
89
90
|
|
|
90
91
|
const hasContent = !!originalUndelimitedContent;
|
|
91
|
-
const hasHTMLBlock = (0,
|
|
92
|
+
const hasHTMLBlock = (0, _data.useSelect)(select => {
|
|
93
|
+
const {
|
|
94
|
+
canInsertBlockType,
|
|
95
|
+
getBlockRootClientId
|
|
96
|
+
} = select(_blockEditor.store);
|
|
97
|
+
return canInsertBlockType('core/html', getBlockRootClientId(clientId));
|
|
98
|
+
}, [clientId]);
|
|
92
99
|
let messageHTML = (0, _i18n.sprintf)(
|
|
93
100
|
/* translators: %s: block name */
|
|
94
101
|
(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);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-directory/src/plugins/get-install-missing/index.js"],"names":["getInstallMissing","OriginalComponent","props","originalName","attributes","block","hasPermission","select","getDownloadableBlocks","blockDirectoryStore","blocks","filter","name","coreStore","canUser","length","ModifiedWarning","originalBlock","originalUndelimitedContent","replaceBlock","blockEditorStore","convertToHTML","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-directory/src/plugins/get-install-missing/index.js"],"names":["getInstallMissing","OriginalComponent","props","originalName","attributes","block","hasPermission","select","getDownloadableBlocks","blockDirectoryStore","blocks","filter","name","coreStore","canUser","length","ModifiedWarning","originalBlock","originalUndelimitedContent","clientId","replaceBlock","blockEditorStore","convertToHTML","content","hasContent","hasHTMLBlock","canInsertBlockType","getBlockRootClientId","messageHTML","title","actions","push"],"mappings":";;;;;;;;;AAMA;;;;AAHA;;AACA;;AACA;;AAEA;;AACA;;AACA;;AASA;;AACA;;AAnBA;AACA;AACA;;AAaA;AACA;AACA;AAIA,MAAMA,iBAAiB,GAAKC,iBAAF,IAA2BC,KAAF,IAAa;AAC/D,QAAM;AAAEC,IAAAA;AAAF,MAAmBD,KAAK,CAACE,UAA/B,CAD+D,CAE/D;AACA;;AACA,QAAM;AAAEC,IAAAA,KAAF;AAASC,IAAAA;AAAT,MAA2B,qBAC9BC,MAAF,IAAc;AACb,UAAM;AAAEC,MAAAA;AAAF,QAA4BD,MAAM,CAAEE,YAAF,CAAxC;AACA,UAAMC,MAAM,GAAGF,qBAAqB,CACnC,WAAWL,YADwB,CAArB,CAEbQ,MAFa,CAEL;AAAA,UAAE;AAAEC,QAAAA;AAAF,OAAF;AAAA,aAAgBT,YAAY,KAAKS,IAAjC;AAAA,KAFK,CAAf;AAGA,WAAO;AACNN,MAAAA,aAAa,EAAEC,MAAM,CAAEM,eAAF,CAAN,CAAoBC,OAApB,CACd,MADc,EAEd,w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BAAC,sBAAD;AACC,IAAA,GAAG,EAAC,SADL;AAEC,IAAA,KAAK,EAAGb,aAFT;AAGC,IAAA,UAAU,EAAGf,KAAK,CAACE,UAHpB;AAIC,IAAA,QAAQ,EAAGF,KAAK,CAACiB;AAJlB,IADe,CAAhB;;AASA,MAAKK,UAAU,IAAIC,YAAnB,EAAkC;AACjCG,IAAAA,WAAW,GAAG;AACb;AACA,kBACC,iJADD,CAFa,EAKbX,aAAa,CAACY,KAAd,IAAuB1B,YALV,CAAd;AAOA2B,IAAAA,OAAO,CAACC,IAAR,CACC,4BAAC,kBAAD;AAAQ,MAAA,GAAG,EAAC,SAAZ;AAAsB,MAAA,OAAO,EAAGT,aAAhC;AAAgD,MAAA,OAAO,EAAC;AAAxD,OACG,cAAI,cAAJ,CADH,CADD;AAKA;;AAED,SACC,mCAAU,iCAAV,EACC,4BAAC,oBAAD;AAAS,IAAA,OAAO,EAAGQ;AAAnB,KAA+BF,WAA/B,CADD,EAEC,4BAAC,gBAAD,QAAWV,0BAAX,CAFD,CADD;AAMA,CAhED;;eAkEelB,iB","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 key=\"convert\" onClick={ convertToHTML } variant=\"link\">\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"]}
|
|
@@ -9,15 +9,11 @@ exports.default = void 0;
|
|
|
9
9
|
|
|
10
10
|
var _element = require("@wordpress/element");
|
|
11
11
|
|
|
12
|
-
var _lodash = require("lodash");
|
|
13
|
-
|
|
14
12
|
var _blockEditor = require("@wordpress/block-editor");
|
|
15
13
|
|
|
16
|
-
var
|
|
14
|
+
var _compose = require("@wordpress/compose");
|
|
17
15
|
|
|
18
|
-
|
|
19
|
-
* External dependencies
|
|
20
|
-
*/
|
|
16
|
+
var _downloadableBlocksPanel = _interopRequireDefault(require("../../components/downloadable-blocks-panel"));
|
|
21
17
|
|
|
22
18
|
/**
|
|
23
19
|
* WordPress dependencies
|
|
@@ -28,7 +24,7 @@ var _downloadableBlocksPanel = _interopRequireDefault(require("../../components/
|
|
|
28
24
|
*/
|
|
29
25
|
function InserterMenuDownloadableBlocksPanel() {
|
|
30
26
|
const [debouncedFilterValue, setFilterValue] = (0, _element.useState)('');
|
|
31
|
-
const debouncedSetFilterValue = (0,
|
|
27
|
+
const debouncedSetFilterValue = (0, _compose.debounce)(setFilterValue, 400);
|
|
32
28
|
return (0, _element.createElement)(_blockEditor.__unstableInserterMenuExtension, null, _ref => {
|
|
33
29
|
let {
|
|
34
30
|
onSelect,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-directory/src/plugins/inserter-menu-downloadable-blocks-panel/index.js"],"names":["InserterMenuDownloadableBlocksPanel","debouncedFilterValue","setFilterValue","debouncedSetFilterValue","onSelect","onHover","filterValue","hasItems","rootClientId"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-directory/src/plugins/inserter-menu-downloadable-blocks-panel/index.js"],"names":["InserterMenuDownloadableBlocksPanel","debouncedFilterValue","setFilterValue","debouncedSetFilterValue","onSelect","onHover","filterValue","hasItems","rootClientId"],"mappings":";;;;;;;;;AAKA;;AAFA;;AACA;;AAMA;;AAVA;AACA;AACA;;AAKA;AACA;AACA;AAGA,SAASA,mCAAT,GAA+C;AAC9C,QAAM,CAAEC,oBAAF,EAAwBC,cAAxB,IAA2C,uBAAU,EAAV,CAAjD;AACA,QAAMC,uBAAuB,GAAG,uBAAUD,cAAV,EAA0B,GAA1B,CAAhC;AAEA,SACC,4BAAC,4CAAD,QACG,QAMK;AAAA,QANH;AACHE,MAAAA,QADG;AAEHC,MAAAA,OAFG;AAGHC,MAAAA,WAHG;AAIHC,MAAAA,QAJG;AAKHC,MAAAA;AALG,KAMG;;AACN,QAAKP,oBAAoB,KAAKK,WAA9B,EAA4C;AAC3CH,MAAAA,uBAAuB,CAAEG,WAAF,CAAvB;AACA;;AAED,QAAK,CAAEL,oBAAP,EAA8B;AAC7B,aAAO,IAAP;AACA;;AAED,WACC,4BAAC,gCAAD;AACC,MAAA,QAAQ,EAAGG,QADZ;AAEC,MAAA,OAAO,EAAGC,OAFX;AAGC,MAAA,YAAY,EAAGG,YAHhB;AAIC,MAAA,WAAW,EAAGP,oBAJf;AAKC,MAAA,cAAc,EAAGM,QALlB;AAMC,MAAA,QAAQ,EAAGD,WAAW,KAAKL;AAN5B,MADD;AAUA,GA1BF,CADD;AA8BA;;eAEcD,mC","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableInserterMenuExtension } from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\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{ ( {\n\t\t\t\tonSelect,\n\t\t\t\tonHover,\n\t\t\t\tfilterValue,\n\t\t\t\thasItems,\n\t\t\t\trootClientId,\n\t\t\t} ) => {\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\trootClientId={ rootClientId }\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"]}
|
|
@@ -6,7 +6,7 @@ import { createElement } from "@wordpress/element";
|
|
|
6
6
|
*/
|
|
7
7
|
import { __, sprintf } from '@wordpress/i18n';
|
|
8
8
|
import { Button } from '@wordpress/components';
|
|
9
|
-
import { createBlock
|
|
9
|
+
import { createBlock } from '@wordpress/blocks';
|
|
10
10
|
import { RawHTML } from '@wordpress/element';
|
|
11
11
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
12
12
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -59,7 +59,8 @@ const ModifiedWarning = _ref2 => {
|
|
|
59
59
|
} = _ref2;
|
|
60
60
|
const {
|
|
61
61
|
originalName,
|
|
62
|
-
originalUndelimitedContent
|
|
62
|
+
originalUndelimitedContent,
|
|
63
|
+
clientId
|
|
63
64
|
} = props.attributes;
|
|
64
65
|
const {
|
|
65
66
|
replaceBlock
|
|
@@ -72,7 +73,13 @@ const ModifiedWarning = _ref2 => {
|
|
|
72
73
|
};
|
|
73
74
|
|
|
74
75
|
const hasContent = !!originalUndelimitedContent;
|
|
75
|
-
const hasHTMLBlock =
|
|
76
|
+
const hasHTMLBlock = useSelect(select => {
|
|
77
|
+
const {
|
|
78
|
+
canInsertBlockType,
|
|
79
|
+
getBlockRootClientId
|
|
80
|
+
} = select(blockEditorStore);
|
|
81
|
+
return canInsertBlockType('core/html', getBlockRootClientId(clientId));
|
|
82
|
+
}, [clientId]);
|
|
76
83
|
let messageHTML = sprintf(
|
|
77
84
|
/* translators: %s: block name */
|
|
78
85
|
__('Your site doesn’t include support for the %s block. You can try installing the block or remove it entirely.'), originalBlock.title || originalName);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-directory/src/plugins/get-install-missing/index.js"],"names":["__","sprintf","Button","createBlock","
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-directory/src/plugins/get-install-missing/index.js"],"names":["__","sprintf","Button","createBlock","RawHTML","useDispatch","useSelect","store","coreStore","Warning","useBlockProps","blockEditorStore","InstallButton","blockDirectoryStore","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"],"mappings":";;;AAAA;AACA;AACA;AACA,SAASA,EAAT,EAAaC,OAAb,QAA4B,iBAA5B;AACA,SAASC,MAAT,QAAuB,uBAAvB;AACA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SAASC,OAAT,QAAwB,oBAAxB;AACA,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CACC,cAAC,MAAD;AAAQ,MAAA,GAAG,EAAC,SAAZ;AAAsB,MAAA,OAAO,EAAGT,aAAhC;AAAgD,MAAA,OAAO,EAAC;AAAxD,OACGjC,EAAE,CAAE,cAAF,CADL,CADD;AAKA;;AAED,SACC,qBAAUU,aAAa,EAAvB,EACC,cAAC,OAAD;AAAS,IAAA,OAAO,EAAG+B;AAAnB,KAA+BF,WAA/B,CADD,EAEC,cAAC,OAAD,QAAWT,0BAAX,CAFD,CADD;AAMA,CAhED;;AAkEA,eAAehB,iBAAf","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 key=\"convert\" onClick={ convertToHTML } variant=\"link\">\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"]}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import { createElement } from "@wordpress/element";
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* External dependencies
|
|
5
|
-
*/
|
|
6
|
-
import { debounce } from 'lodash';
|
|
7
3
|
/**
|
|
8
4
|
* WordPress dependencies
|
|
9
5
|
*/
|
|
10
|
-
|
|
11
6
|
import { __unstableInserterMenuExtension } from '@wordpress/block-editor';
|
|
7
|
+
import { debounce } from '@wordpress/compose';
|
|
12
8
|
import { useState } from '@wordpress/element';
|
|
13
9
|
/**
|
|
14
10
|
* Internal dependencies
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["@wordpress/block-directory/src/plugins/inserter-menu-downloadable-blocks-panel/index.js"],"names":["
|
|
1
|
+
{"version":3,"sources":["@wordpress/block-directory/src/plugins/inserter-menu-downloadable-blocks-panel/index.js"],"names":["__unstableInserterMenuExtension","debounce","useState","DownloadableBlocksPanel","InserterMenuDownloadableBlocksPanel","debouncedFilterValue","setFilterValue","debouncedSetFilterValue","onSelect","onHover","filterValue","hasItems","rootClientId"],"mappings":";;AAAA;AACA;AACA;AACA,SAASA,+BAAT,QAAgD,yBAAhD;AACA,SAASC,QAAT,QAAyB,oBAAzB;AACA,SAASC,QAAT,QAAyB,oBAAzB;AAEA;AACA;AACA;;AACA,OAAOC,uBAAP,MAAoC,4CAApC;;AAEA,SAASC,mCAAT,GAA+C;AAC9C,QAAM,CAAEC,oBAAF,EAAwBC,cAAxB,IAA2CJ,QAAQ,CAAE,EAAF,CAAzD;AACA,QAAMK,uBAAuB,GAAGN,QAAQ,CAAEK,cAAF,EAAkB,GAAlB,CAAxC;AAEA,SACC,cAAC,+BAAD,QACG,QAMK;AAAA,QANH;AACHE,MAAAA,QADG;AAEHC,MAAAA,OAFG;AAGHC,MAAAA,WAHG;AAIHC,MAAAA,QAJG;AAKHC,MAAAA;AALG,KAMG;;AACN,QAAKP,oBAAoB,KAAKK,WAA9B,EAA4C;AAC3CH,MAAAA,uBAAuB,CAAEG,WAAF,CAAvB;AACA;;AAED,QAAK,CAAEL,oBAAP,EAA8B;AAC7B,aAAO,IAAP;AACA;;AAED,WACC,cAAC,uBAAD;AACC,MAAA,QAAQ,EAAGG,QADZ;AAEC,MAAA,OAAO,EAAGC,OAFX;AAGC,MAAA,YAAY,EAAGG,YAHhB;AAIC,MAAA,WAAW,EAAGP,oBAJf;AAKC,MAAA,cAAc,EAAGM,QALlB;AAMC,MAAA,QAAQ,EAAGD,WAAW,KAAKL;AAN5B,MADD;AAUA,GA1BF,CADD;AA8BA;;AAED,eAAeD,mCAAf","sourcesContent":["/**\n * WordPress dependencies\n */\nimport { __unstableInserterMenuExtension } from '@wordpress/block-editor';\nimport { debounce } from '@wordpress/compose';\nimport { useState } from '@wordpress/element';\n\n/**\n * Internal dependencies\n */\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{ ( {\n\t\t\t\tonSelect,\n\t\t\t\tonHover,\n\t\t\t\tfilterValue,\n\t\t\t\thasItems,\n\t\t\t\trootClientId,\n\t\t\t} ) => {\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\trootClientId={ rootClientId }\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/block-directory",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.16.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,24 +26,24 @@
|
|
|
26
26
|
"react-native": "src/index",
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@babel/runtime": "^7.16.0",
|
|
29
|
-
"@wordpress/a11y": "^3.
|
|
30
|
-
"@wordpress/api-fetch": "^6.
|
|
31
|
-
"@wordpress/block-editor": "^10.0
|
|
32
|
-
"@wordpress/blocks": "^11.
|
|
33
|
-
"@wordpress/components": "^21.0
|
|
34
|
-
"@wordpress/compose": "^5.
|
|
35
|
-
"@wordpress/core-data": "^5.0
|
|
36
|
-
"@wordpress/data": "^7.
|
|
37
|
-
"@wordpress/edit-post": "^6.
|
|
38
|
-
"@wordpress/editor": "^12.
|
|
39
|
-
"@wordpress/element": "^4.
|
|
40
|
-
"@wordpress/hooks": "^3.
|
|
41
|
-
"@wordpress/html-entities": "^3.
|
|
42
|
-
"@wordpress/i18n": "^4.
|
|
43
|
-
"@wordpress/icons": "^9.
|
|
44
|
-
"@wordpress/notices": "^3.
|
|
45
|
-
"@wordpress/plugins": "^4.
|
|
46
|
-
"@wordpress/url": "^3.
|
|
29
|
+
"@wordpress/a11y": "^3.18.0",
|
|
30
|
+
"@wordpress/api-fetch": "^6.15.0",
|
|
31
|
+
"@wordpress/block-editor": "^10.1.0",
|
|
32
|
+
"@wordpress/blocks": "^11.17.0",
|
|
33
|
+
"@wordpress/components": "^21.1.0",
|
|
34
|
+
"@wordpress/compose": "^5.16.0",
|
|
35
|
+
"@wordpress/core-data": "^5.1.0",
|
|
36
|
+
"@wordpress/data": "^7.2.0",
|
|
37
|
+
"@wordpress/edit-post": "^6.15.0",
|
|
38
|
+
"@wordpress/editor": "^12.17.0",
|
|
39
|
+
"@wordpress/element": "^4.16.0",
|
|
40
|
+
"@wordpress/hooks": "^3.18.0",
|
|
41
|
+
"@wordpress/html-entities": "^3.18.0",
|
|
42
|
+
"@wordpress/i18n": "^4.18.0",
|
|
43
|
+
"@wordpress/icons": "^9.9.0",
|
|
44
|
+
"@wordpress/notices": "^3.18.0",
|
|
45
|
+
"@wordpress/plugins": "^4.16.0",
|
|
46
|
+
"@wordpress/url": "^3.19.0",
|
|
47
47
|
"change-case": "^4.1.2",
|
|
48
48
|
"lodash": "^4.17.21"
|
|
49
49
|
},
|
|
@@ -54,5 +54,5 @@
|
|
|
54
54
|
"publishConfig": {
|
|
55
55
|
"access": "public"
|
|
56
56
|
},
|
|
57
|
-
"gitHead": "
|
|
57
|
+
"gitHead": "23e136283fa1d3b8d9d8b33869f871ad5eb77726"
|
|
58
58
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { __, sprintf } from '@wordpress/i18n';
|
|
5
5
|
import { Button } from '@wordpress/components';
|
|
6
|
-
import { createBlock
|
|
6
|
+
import { createBlock } from '@wordpress/blocks';
|
|
7
7
|
import { RawHTML } from '@wordpress/element';
|
|
8
8
|
import { useDispatch, useSelect } from '@wordpress/data';
|
|
9
9
|
import { store as coreStore } from '@wordpress/core-data';
|
|
@@ -49,7 +49,8 @@ const getInstallMissing = ( OriginalComponent ) => ( props ) => {
|
|
|
49
49
|
};
|
|
50
50
|
|
|
51
51
|
const ModifiedWarning = ( { originalBlock, ...props } ) => {
|
|
52
|
-
const { originalName, originalUndelimitedContent } =
|
|
52
|
+
const { originalName, originalUndelimitedContent, clientId } =
|
|
53
|
+
props.attributes;
|
|
53
54
|
const { replaceBlock } = useDispatch( blockEditorStore );
|
|
54
55
|
const convertToHTML = () => {
|
|
55
56
|
replaceBlock(
|
|
@@ -61,7 +62,18 @@ const ModifiedWarning = ( { originalBlock, ...props } ) => {
|
|
|
61
62
|
};
|
|
62
63
|
|
|
63
64
|
const hasContent = !! originalUndelimitedContent;
|
|
64
|
-
const hasHTMLBlock =
|
|
65
|
+
const hasHTMLBlock = useSelect(
|
|
66
|
+
( select ) => {
|
|
67
|
+
const { canInsertBlockType, getBlockRootClientId } =
|
|
68
|
+
select( blockEditorStore );
|
|
69
|
+
|
|
70
|
+
return canInsertBlockType(
|
|
71
|
+
'core/html',
|
|
72
|
+
getBlockRootClientId( clientId )
|
|
73
|
+
);
|
|
74
|
+
},
|
|
75
|
+
[ clientId ]
|
|
76
|
+
);
|
|
65
77
|
|
|
66
78
|
let messageHTML = sprintf(
|
|
67
79
|
/* translators: %s: block name */
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* External dependencies
|
|
3
|
-
*/
|
|
4
|
-
import { debounce } from 'lodash';
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
* WordPress dependencies
|
|
8
3
|
*/
|
|
9
4
|
import { __unstableInserterMenuExtension } from '@wordpress/block-editor';
|
|
5
|
+
import { debounce } from '@wordpress/compose';
|
|
10
6
|
import { useState } from '@wordpress/element';
|
|
11
7
|
|
|
12
8
|
/**
|