@wordpress/block-directory 5.3.0 → 5.5.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 CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 5.5.0 (2024-08-07)
6
+
7
+ ## 5.4.0 (2024-07-24)
8
+
5
9
  ## 5.3.0 (2024-07-10)
6
10
 
7
11
  ## 5.2.0 (2024-06-26)
@@ -8,27 +8,24 @@ exports.default = InstalledBlocksPrePublishPanel;
8
8
  var _i18n = require("@wordpress/i18n");
9
9
  var _data = require("@wordpress/data");
10
10
  var _icons = require("@wordpress/icons");
11
+ var _editor = require("@wordpress/editor");
11
12
  var _compactList = _interopRequireDefault(require("../../components/compact-list"));
12
13
  var _store = require("../../store");
13
14
  var _jsxRuntime = require("react/jsx-runtime");
14
- var _window$wp$editor;
15
15
  /**
16
16
  * WordPress dependencies
17
17
  */
18
+
18
19
  /**
19
20
  * Internal dependencies
20
21
  */
21
- // We shouldn't import the editor package directly
22
- // because it would include the wp-editor in all pages loading the block-directory script.
23
- const {
24
- PluginPrePublishPanel
25
- } = (_window$wp$editor = window?.wp?.editor) !== null && _window$wp$editor !== void 0 ? _window$wp$editor : {};
22
+
26
23
  function InstalledBlocksPrePublishPanel() {
27
24
  const newBlockTypes = (0, _data.useSelect)(select => select(_store.store).getNewBlockTypes(), []);
28
25
  if (!newBlockTypes.length) {
29
26
  return null;
30
27
  }
31
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)(PluginPrePublishPanel, {
28
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_editor.PluginPrePublishPanel, {
32
29
  icon: _icons.blockDefault,
33
30
  title: (0, _i18n.sprintf)(
34
31
  // translators: %d: number of blocks (number).
@@ -1 +1 @@
1
- {"version":3,"names":["_i18n","require","_data","_icons","_compactList","_interopRequireDefault","_store","_jsxRuntime","_window$wp$editor","PluginPrePublishPanel","window","wp","editor","InstalledBlocksPrePublishPanel","newBlockTypes","useSelect","select","blockDirectoryStore","getNewBlockTypes","length","jsxs","icon","blockDefault","title","sprintf","_n","initialOpen","children","jsx","className","default","items"],"sources":["@wordpress/block-directory/src/plugins/installed-blocks-pre-publish-panel/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { blockDefault } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\n\n// We shouldn't import the editor package directly\n// because it would include the wp-editor in all pages loading the block-directory script.\nconst { PluginPrePublishPanel } = window?.wp?.editor ?? {};\n\nexport default function InstalledBlocksPrePublishPanel() {\n\tconst newBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getNewBlockTypes(),\n\t\t[]\n\t);\n\n\tif ( ! newBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PluginPrePublishPanel\n\t\t\ticon={ blockDefault }\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %d: number of blocks (number).\n\t\t\t\t_n(\n\t\t\t\t\t'Added: %d block',\n\t\t\t\t\t'Added: %d blocks',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t),\n\t\t\t\tnewBlockTypes.length\n\t\t\t) }\n\t\t\tinitialOpen\n\t\t>\n\t\t\t<p className=\"installed-blocks-pre-publish-panel__copy\">\n\t\t\t\t{ _n(\n\t\t\t\t\t'The following block has been added to your site.',\n\t\t\t\t\t'The following blocks have been added to your site.',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<CompactList items={ newBlockTypes } />\n\t\t</PluginPrePublishPanel>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AAKA,IAAAG,YAAA,GAAAC,sBAAA,CAAAJ,OAAA;AACA,IAAAK,MAAA,GAAAL,OAAA;AAA2D,IAAAM,WAAA,GAAAN,OAAA;AAAA,IAAAO,iBAAA;AAX3D;AACA;AACA;AAKA;AACA;AACA;AAIA;AACA;AACA,MAAM;EAAEC;AAAsB,CAAC,IAAAD,iBAAA,GAAGE,MAAM,EAAEC,EAAE,EAAEC,MAAM,cAAAJ,iBAAA,cAAAA,iBAAA,GAAI,CAAC,CAAC;AAE3C,SAASK,8BAA8BA,CAAA,EAAG;EACxD,MAAMC,aAAa,GAAG,IAAAC,eAAS,EAC5BC,MAAM,IAAMA,MAAM,CAAEC,YAAoB,CAAC,CAACC,gBAAgB,CAAC,CAAC,EAC9D,EACD,CAAC;EAED,IAAK,CAAEJ,aAAa,CAACK,MAAM,EAAG;IAC7B,OAAO,IAAI;EACZ;EAEA,oBACC,IAAAZ,WAAA,CAAAa,IAAA,EAACX,qBAAqB;IACrBY,IAAI,EAAGC,mBAAc;IACrBC,KAAK,EAAG,IAAAC,aAAO;IACd;IACA,IAAAC,QAAE,EACD,iBAAiB,EACjB,kBAAkB,EAClBX,aAAa,CAACK,MACf,CAAC,EACDL,aAAa,CAACK,MACf,CAAG;IACHO,WAAW;IAAAC,QAAA,gBAEX,IAAApB,WAAA,CAAAqB,GAAA;MAAGC,SAAS,EAAC,0CAA0C;MAAAF,QAAA,EACpD,IAAAF,QAAE,EACH,kDAAkD,EAClD,oDAAoD,EACpDX,aAAa,CAACK,MACf;IAAC,CACC,CAAC,eACJ,IAAAZ,WAAA,CAAAqB,GAAA,EAACxB,YAAA,CAAA0B,OAAW;MAACC,KAAK,EAAGjB;IAAe,CAAE,CAAC;EAAA,CACjB,CAAC;AAE1B","ignoreList":[]}
1
+ {"version":3,"names":["_i18n","require","_data","_icons","_editor","_compactList","_interopRequireDefault","_store","_jsxRuntime","InstalledBlocksPrePublishPanel","newBlockTypes","useSelect","select","blockDirectoryStore","getNewBlockTypes","length","jsxs","PluginPrePublishPanel","icon","blockDefault","title","sprintf","_n","initialOpen","children","jsx","className","default","items"],"sources":["@wordpress/block-directory/src/plugins/installed-blocks-pre-publish-panel/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { blockDefault } from '@wordpress/icons';\nimport { PluginPrePublishPanel } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstalledBlocksPrePublishPanel() {\n\tconst newBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getNewBlockTypes(),\n\t\t[]\n\t);\n\n\tif ( ! newBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PluginPrePublishPanel\n\t\t\ticon={ blockDefault }\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %d: number of blocks (number).\n\t\t\t\t_n(\n\t\t\t\t\t'Added: %d block',\n\t\t\t\t\t'Added: %d blocks',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t),\n\t\t\t\tnewBlockTypes.length\n\t\t\t) }\n\t\t\tinitialOpen\n\t\t>\n\t\t\t<p className=\"installed-blocks-pre-publish-panel__copy\">\n\t\t\t\t{ _n(\n\t\t\t\t\t'The following block has been added to your site.',\n\t\t\t\t\t'The following blocks have been added to your site.',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<CompactList items={ newBlockTypes } />\n\t\t</PluginPrePublishPanel>\n\t);\n}\n"],"mappings":";;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,KAAA,GAAAD,OAAA;AACA,IAAAE,MAAA,GAAAF,OAAA;AACA,IAAAG,OAAA,GAAAH,OAAA;AAKA,IAAAI,YAAA,GAAAC,sBAAA,CAAAL,OAAA;AACA,IAAAM,MAAA,GAAAN,OAAA;AAA2D,IAAAO,WAAA,GAAAP,OAAA;AAZ3D;AACA;AACA;;AAMA;AACA;AACA;;AAIe,SAASQ,8BAA8BA,CAAA,EAAG;EACxD,MAAMC,aAAa,GAAG,IAAAC,eAAS,EAC5BC,MAAM,IAAMA,MAAM,CAAEC,YAAoB,CAAC,CAACC,gBAAgB,CAAC,CAAC,EAC9D,EACD,CAAC;EAED,IAAK,CAAEJ,aAAa,CAACK,MAAM,EAAG;IAC7B,OAAO,IAAI;EACZ;EAEA,oBACC,IAAAP,WAAA,CAAAQ,IAAA,EAACZ,OAAA,CAAAa,qBAAqB;IACrBC,IAAI,EAAGC,mBAAc;IACrBC,KAAK,EAAG,IAAAC,aAAO;IACd;IACA,IAAAC,QAAE,EACD,iBAAiB,EACjB,kBAAkB,EAClBZ,aAAa,CAACK,MACf,CAAC,EACDL,aAAa,CAACK,MACf,CAAG;IACHQ,WAAW;IAAAC,QAAA,gBAEX,IAAAhB,WAAA,CAAAiB,GAAA;MAAGC,SAAS,EAAC,0CAA0C;MAAAF,QAAA,EACpD,IAAAF,QAAE,EACH,kDAAkD,EAClD,oDAAoD,EACpDZ,aAAa,CAACK,MACf;IAAC,CACC,CAAC,eACJ,IAAAP,WAAA,CAAAiB,GAAA,EAACpB,YAAA,CAAAsB,OAAW;MAACC,KAAK,EAAGlB;IAAe,CAAE,CAAC;EAAA,CACjB,CAAC;AAE1B","ignoreList":[]}
@@ -68,11 +68,11 @@ function getInstalledBlockTypes(state) {
68
68
  *
69
69
  * @return {Array} Block type items.
70
70
  */
71
- const getNewBlockTypes = exports.getNewBlockTypes = (0, _data.createRegistrySelector)(select => state => {
71
+ const getNewBlockTypes = exports.getNewBlockTypes = (0, _data.createRegistrySelector)(select => (0, _data.createSelector)(state => {
72
72
  const usedBlockTree = select(_blockEditor.store).getBlocks();
73
73
  const installedBlockTypes = getInstalledBlockTypes(state);
74
74
  return installedBlockTypes.filter(blockType => (0, _hasBlockType.default)(blockType, usedBlockTree));
75
- });
75
+ }, state => [getInstalledBlockTypes(state), select(_blockEditor.store).getBlocks()]));
76
76
 
77
77
  /**
78
78
  * Returns the block types that have been installed on the server but are not
@@ -82,11 +82,11 @@ const getNewBlockTypes = exports.getNewBlockTypes = (0, _data.createRegistrySele
82
82
  *
83
83
  * @return {Array} Block type items.
84
84
  */
85
- const getUnusedBlockTypes = exports.getUnusedBlockTypes = (0, _data.createRegistrySelector)(select => state => {
85
+ const getUnusedBlockTypes = exports.getUnusedBlockTypes = (0, _data.createRegistrySelector)(select => (0, _data.createSelector)(state => {
86
86
  const usedBlockTree = select(_blockEditor.store).getBlocks();
87
87
  const installedBlockTypes = getInstalledBlockTypes(state);
88
88
  return installedBlockTypes.filter(blockType => !(0, _hasBlockType.default)(blockType, usedBlockTree));
89
- });
89
+ }, state => [getInstalledBlockTypes(state), select(_blockEditor.store).getBlocks()]));
90
90
 
91
91
  /**
92
92
  * Returns true if a block plugin install is in progress.
@@ -1 +1 @@
1
- {"version":3,"names":["_data","require","_blockEditor","_hasBlockType","_interopRequireDefault","isRequestingDownloadableBlocks","state","filterValue","_state$downloadableBl","downloadableBlocks","isRequesting","getDownloadableBlocks","_state$downloadableBl2","results","getInstalledBlockTypes","blockManagement","installedBlockTypes","getNewBlockTypes","exports","createRegistrySelector","select","usedBlockTree","blockEditorStore","getBlocks","filter","blockType","hasBlockType","getUnusedBlockTypes","isInstalling","blockId","getErrorNotices","errorNotices","getErrorNoticeForBlock"],"sources":["@wordpress/block-directory/src/store/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport hasBlockType from './utils/has-block-type';\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? [];\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\treturn installedBlockTypes.filter( ( blockType ) =>\n\t\t\thasBlockType( blockType, usedBlockTree )\n\t\t);\n\t}\n);\n\n/**\n * Returns the block types that have been installed on the server but are not\n * used in the current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getUnusedBlockTypes = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\treturn installedBlockTypes.filter(\n\t\t\t( blockType ) => ! hasBlockType( blockType, usedBlockTree )\n\t\t);\n\t}\n);\n\n/**\n * Returns true if a block plugin install is in progress.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId Id of the block.\n *\n * @return {boolean} Whether this block is currently being installed.\n */\nexport function isInstalling( state, blockId ) {\n\treturn state.blockManagement.isInstalling[ blockId ] || false;\n}\n\n/**\n * Returns all block error notices.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Object with error notices.\n */\nexport function getErrorNotices( state ) {\n\treturn state.errorNotices;\n}\n\n/**\n * Returns the error notice for a given block.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {string|boolean} The error text, or false if no error.\n */\nexport function getErrorNoticeForBlock( state, blockId ) {\n\treturn state.errorNotices[ blockId ];\n}\n"],"mappings":";;;;;;;;;;;;;AAGA,IAAAA,KAAA,GAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAKA,IAAAE,aAAA,GAAAC,sBAAA,CAAAH,OAAA;AATA;AACA;AACA;;AAIA;AACA;AACA;;AAGA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASI,8BAA8BA,CAAEC,KAAK,EAAEC,WAAW,EAAG;EAAA,IAAAC,qBAAA;EACpE,QAAAA,qBAAA,GAAOF,KAAK,CAACG,kBAAkB,CAAEF,WAAW,CAAE,EAAEG,YAAY,cAAAF,qBAAA,cAAAA,qBAAA,GAAI,KAAK;AACtE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASG,qBAAqBA,CAAEL,KAAK,EAAEC,WAAW,EAAG;EAAA,IAAAK,sBAAA;EAC3D,QAAAA,sBAAA,GAAON,KAAK,CAACG,kBAAkB,CAAEF,WAAW,CAAE,EAAEM,OAAO,cAAAD,sBAAA,cAAAA,sBAAA,GAAI,EAAE;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASE,sBAAsBA,CAAER,KAAK,EAAG;EAC/C,OAAOA,KAAK,CAACS,eAAe,CAACC,mBAAmB;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMC,gBAAgB,GAAAC,OAAA,CAAAD,gBAAA,GAAG,IAAAE,4BAAsB,EACnDC,MAAM,IAAQd,KAAK,IAAM;EAC1B,MAAMe,aAAa,GAAGD,MAAM,CAAEE,kBAAiB,CAAC,CAACC,SAAS,CAAC,CAAC;EAC5D,MAAMP,mBAAmB,GAAGF,sBAAsB,CAAER,KAAM,CAAC;EAE3D,OAAOU,mBAAmB,CAACQ,MAAM,CAAIC,SAAS,IAC7C,IAAAC,qBAAY,EAAED,SAAS,EAAEJ,aAAc,CACxC,CAAC;AACF,CACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,MAAMM,mBAAmB,GAAAT,OAAA,CAAAS,mBAAA,GAAG,IAAAR,4BAAsB,EACtDC,MAAM,IAAQd,KAAK,IAAM;EAC1B,MAAMe,aAAa,GAAGD,MAAM,CAAEE,kBAAiB,CAAC,CAACC,SAAS,CAAC,CAAC;EAC5D,MAAMP,mBAAmB,GAAGF,sBAAsB,CAAER,KAAM,CAAC;EAE3D,OAAOU,mBAAmB,CAACQ,MAAM,CAC9BC,SAAS,IAAM,CAAE,IAAAC,qBAAY,EAAED,SAAS,EAAEJ,aAAc,CAC3D,CAAC;AACF,CACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASO,YAAYA,CAAEtB,KAAK,EAAEuB,OAAO,EAAG;EAC9C,OAAOvB,KAAK,CAACS,eAAe,CAACa,YAAY,CAAEC,OAAO,CAAE,IAAI,KAAK;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,eAAeA,CAAExB,KAAK,EAAG;EACxC,OAAOA,KAAK,CAACyB,YAAY;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACO,SAASC,sBAAsBA,CAAE1B,KAAK,EAAEuB,OAAO,EAAG;EACxD,OAAOvB,KAAK,CAACyB,YAAY,CAAEF,OAAO,CAAE;AACrC","ignoreList":[]}
1
+ {"version":3,"names":["_data","require","_blockEditor","_hasBlockType","_interopRequireDefault","isRequestingDownloadableBlocks","state","filterValue","_state$downloadableBl","downloadableBlocks","isRequesting","getDownloadableBlocks","_state$downloadableBl2","results","getInstalledBlockTypes","blockManagement","installedBlockTypes","getNewBlockTypes","exports","createRegistrySelector","select","createSelector","usedBlockTree","blockEditorStore","getBlocks","filter","blockType","hasBlockType","getUnusedBlockTypes","isInstalling","blockId","getErrorNotices","errorNotices","getErrorNoticeForBlock"],"sources":["@wordpress/block-directory/src/store/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport hasBlockType from './utils/has-block-type';\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? [];\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\t\treturn installedBlockTypes.filter( ( blockType ) =>\n\t\t\t\thasBlockType( blockType, usedBlockTree )\n\t\t\t);\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getBlocks(),\n\t\t]\n\t)\n);\n\n/**\n * Returns the block types that have been installed on the server but are not\n * used in the current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getUnusedBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\t\treturn installedBlockTypes.filter(\n\t\t\t\t( blockType ) => ! hasBlockType( blockType, usedBlockTree )\n\t\t\t);\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getBlocks(),\n\t\t]\n\t)\n);\n\n/**\n * Returns true if a block plugin install is in progress.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId Id of the block.\n *\n * @return {boolean} Whether this block is currently being installed.\n */\nexport function isInstalling( state, blockId ) {\n\treturn state.blockManagement.isInstalling[ blockId ] || false;\n}\n\n/**\n * Returns all block error notices.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Object with error notices.\n */\nexport function getErrorNotices( state ) {\n\treturn state.errorNotices;\n}\n\n/**\n * Returns the error notice for a given block.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {string|boolean} The error text, or false if no error.\n */\nexport function getErrorNoticeForBlock( state, blockId ) {\n\treturn state.errorNotices[ blockId ];\n}\n"],"mappings":"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","ignoreList":[]}
@@ -1,24 +1,18 @@
1
- var _window$wp$editor;
2
1
  /**
3
2
  * WordPress dependencies
4
3
  */
5
4
  import { _n, sprintf } from '@wordpress/i18n';
6
5
  import { useSelect } from '@wordpress/data';
7
6
  import { blockDefault } from '@wordpress/icons';
7
+ import { PluginPrePublishPanel } from '@wordpress/editor';
8
8
 
9
9
  /**
10
10
  * Internal dependencies
11
11
  */
12
12
  import CompactList from '../../components/compact-list';
13
13
  import { store as blockDirectoryStore } from '../../store';
14
-
15
- // We shouldn't import the editor package directly
16
- // because it would include the wp-editor in all pages loading the block-directory script.
17
14
  import { jsx as _jsx } from "react/jsx-runtime";
18
15
  import { jsxs as _jsxs } from "react/jsx-runtime";
19
- const {
20
- PluginPrePublishPanel
21
- } = (_window$wp$editor = window?.wp?.editor) !== null && _window$wp$editor !== void 0 ? _window$wp$editor : {};
22
16
  export default function InstalledBlocksPrePublishPanel() {
23
17
  const newBlockTypes = useSelect(select => select(blockDirectoryStore).getNewBlockTypes(), []);
24
18
  if (!newBlockTypes.length) {
@@ -1 +1 @@
1
- {"version":3,"names":["_n","sprintf","useSelect","blockDefault","CompactList","store","blockDirectoryStore","jsx","_jsx","jsxs","_jsxs","PluginPrePublishPanel","_window$wp$editor","window","wp","editor","InstalledBlocksPrePublishPanel","newBlockTypes","select","getNewBlockTypes","length","icon","title","initialOpen","children","className","items"],"sources":["@wordpress/block-directory/src/plugins/installed-blocks-pre-publish-panel/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { blockDefault } from '@wordpress/icons';\n\n/**\n * Internal dependencies\n */\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\n\n// We shouldn't import the editor package directly\n// because it would include the wp-editor in all pages loading the block-directory script.\nconst { PluginPrePublishPanel } = window?.wp?.editor ?? {};\n\nexport default function InstalledBlocksPrePublishPanel() {\n\tconst newBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getNewBlockTypes(),\n\t\t[]\n\t);\n\n\tif ( ! newBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PluginPrePublishPanel\n\t\t\ticon={ blockDefault }\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %d: number of blocks (number).\n\t\t\t\t_n(\n\t\t\t\t\t'Added: %d block',\n\t\t\t\t\t'Added: %d blocks',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t),\n\t\t\t\tnewBlockTypes.length\n\t\t\t) }\n\t\t\tinitialOpen\n\t\t>\n\t\t\t<p className=\"installed-blocks-pre-publish-panel__copy\">\n\t\t\t\t{ _n(\n\t\t\t\t\t'The following block has been added to your site.',\n\t\t\t\t\t'The following blocks have been added to your site.',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<CompactList items={ newBlockTypes } />\n\t\t</PluginPrePublishPanel>\n\t);\n}\n"],"mappings":";AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,YAAY,QAAQ,kBAAkB;;AAE/C;AACA;AACA;AACA,OAAOC,WAAW,MAAM,+BAA+B;AACvD,SAASC,KAAK,IAAIC,mBAAmB,QAAQ,aAAa;;AAE1D;AACA;AAAA,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AACA,MAAM;EAAEC;AAAsB,CAAC,IAAAC,iBAAA,GAAGC,MAAM,EAAEC,EAAE,EAAEC,MAAM,cAAAH,iBAAA,cAAAA,iBAAA,GAAI,CAAC,CAAC;AAE1D,eAAe,SAASI,8BAA8BA,CAAA,EAAG;EACxD,MAAMC,aAAa,GAAGf,SAAS,CAC5BgB,MAAM,IAAMA,MAAM,CAAEZ,mBAAoB,CAAC,CAACa,gBAAgB,CAAC,CAAC,EAC9D,EACD,CAAC;EAED,IAAK,CAAEF,aAAa,CAACG,MAAM,EAAG;IAC7B,OAAO,IAAI;EACZ;EAEA,oBACCV,KAAA,CAACC,qBAAqB;IACrBU,IAAI,EAAGlB,YAAc;IACrBmB,KAAK,EAAGrB,OAAO;IACd;IACAD,EAAE,CACD,iBAAiB,EACjB,kBAAkB,EAClBiB,aAAa,CAACG,MACf,CAAC,EACDH,aAAa,CAACG,MACf,CAAG;IACHG,WAAW;IAAAC,QAAA,gBAEXhB,IAAA;MAAGiB,SAAS,EAAC,0CAA0C;MAAAD,QAAA,EACpDxB,EAAE,CACH,kDAAkD,EAClD,oDAAoD,EACpDiB,aAAa,CAACG,MACf;IAAC,CACC,CAAC,eACJZ,IAAA,CAACJ,WAAW;MAACsB,KAAK,EAAGT;IAAe,CAAE,CAAC;EAAA,CACjB,CAAC;AAE1B","ignoreList":[]}
1
+ {"version":3,"names":["_n","sprintf","useSelect","blockDefault","PluginPrePublishPanel","CompactList","store","blockDirectoryStore","jsx","_jsx","jsxs","_jsxs","InstalledBlocksPrePublishPanel","newBlockTypes","select","getNewBlockTypes","length","icon","title","initialOpen","children","className","items"],"sources":["@wordpress/block-directory/src/plugins/installed-blocks-pre-publish-panel/index.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { _n, sprintf } from '@wordpress/i18n';\nimport { useSelect } from '@wordpress/data';\nimport { blockDefault } from '@wordpress/icons';\nimport { PluginPrePublishPanel } from '@wordpress/editor';\n\n/**\n * Internal dependencies\n */\nimport CompactList from '../../components/compact-list';\nimport { store as blockDirectoryStore } from '../../store';\n\nexport default function InstalledBlocksPrePublishPanel() {\n\tconst newBlockTypes = useSelect(\n\t\t( select ) => select( blockDirectoryStore ).getNewBlockTypes(),\n\t\t[]\n\t);\n\n\tif ( ! newBlockTypes.length ) {\n\t\treturn null;\n\t}\n\n\treturn (\n\t\t<PluginPrePublishPanel\n\t\t\ticon={ blockDefault }\n\t\t\ttitle={ sprintf(\n\t\t\t\t// translators: %d: number of blocks (number).\n\t\t\t\t_n(\n\t\t\t\t\t'Added: %d block',\n\t\t\t\t\t'Added: %d blocks',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t),\n\t\t\t\tnewBlockTypes.length\n\t\t\t) }\n\t\t\tinitialOpen\n\t\t>\n\t\t\t<p className=\"installed-blocks-pre-publish-panel__copy\">\n\t\t\t\t{ _n(\n\t\t\t\t\t'The following block has been added to your site.',\n\t\t\t\t\t'The following blocks have been added to your site.',\n\t\t\t\t\tnewBlockTypes.length\n\t\t\t\t) }\n\t\t\t</p>\n\t\t\t<CompactList items={ newBlockTypes } />\n\t\t</PluginPrePublishPanel>\n\t);\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,EAAE,EAAEC,OAAO,QAAQ,iBAAiB;AAC7C,SAASC,SAAS,QAAQ,iBAAiB;AAC3C,SAASC,YAAY,QAAQ,kBAAkB;AAC/C,SAASC,qBAAqB,QAAQ,mBAAmB;;AAEzD;AACA;AACA;AACA,OAAOC,WAAW,MAAM,+BAA+B;AACvD,SAASC,KAAK,IAAIC,mBAAmB,QAAQ,aAAa;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAAA,SAAAC,IAAA,IAAAC,KAAA;AAE3D,eAAe,SAASC,8BAA8BA,CAAA,EAAG;EACxD,MAAMC,aAAa,GAAGX,SAAS,CAC5BY,MAAM,IAAMA,MAAM,CAAEP,mBAAoB,CAAC,CAACQ,gBAAgB,CAAC,CAAC,EAC9D,EACD,CAAC;EAED,IAAK,CAAEF,aAAa,CAACG,MAAM,EAAG;IAC7B,OAAO,IAAI;EACZ;EAEA,oBACCL,KAAA,CAACP,qBAAqB;IACrBa,IAAI,EAAGd,YAAc;IACrBe,KAAK,EAAGjB,OAAO;IACd;IACAD,EAAE,CACD,iBAAiB,EACjB,kBAAkB,EAClBa,aAAa,CAACG,MACf,CAAC,EACDH,aAAa,CAACG,MACf,CAAG;IACHG,WAAW;IAAAC,QAAA,gBAEXX,IAAA;MAAGY,SAAS,EAAC,0CAA0C;MAAAD,QAAA,EACpDpB,EAAE,CACH,kDAAkD,EAClD,oDAAoD,EACpDa,aAAa,CAACG,MACf;IAAC,CACC,CAAC,eACJP,IAAA,CAACJ,WAAW;MAACiB,KAAK,EAAGT;IAAe,CAAE,CAAC;EAAA,CACjB,CAAC;AAE1B","ignoreList":[]}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { createRegistrySelector } from '@wordpress/data';
4
+ import { createSelector, createRegistrySelector } from '@wordpress/data';
5
5
  import { store as blockEditorStore } from '@wordpress/block-editor';
6
6
 
7
7
  /**
@@ -55,11 +55,11 @@ export function getInstalledBlockTypes(state) {
55
55
  *
56
56
  * @return {Array} Block type items.
57
57
  */
58
- export const getNewBlockTypes = createRegistrySelector(select => state => {
58
+ export const getNewBlockTypes = createRegistrySelector(select => createSelector(state => {
59
59
  const usedBlockTree = select(blockEditorStore).getBlocks();
60
60
  const installedBlockTypes = getInstalledBlockTypes(state);
61
61
  return installedBlockTypes.filter(blockType => hasBlockType(blockType, usedBlockTree));
62
- });
62
+ }, state => [getInstalledBlockTypes(state), select(blockEditorStore).getBlocks()]));
63
63
 
64
64
  /**
65
65
  * Returns the block types that have been installed on the server but are not
@@ -69,11 +69,11 @@ export const getNewBlockTypes = createRegistrySelector(select => state => {
69
69
  *
70
70
  * @return {Array} Block type items.
71
71
  */
72
- export const getUnusedBlockTypes = createRegistrySelector(select => state => {
72
+ export const getUnusedBlockTypes = createRegistrySelector(select => createSelector(state => {
73
73
  const usedBlockTree = select(blockEditorStore).getBlocks();
74
74
  const installedBlockTypes = getInstalledBlockTypes(state);
75
75
  return installedBlockTypes.filter(blockType => !hasBlockType(blockType, usedBlockTree));
76
- });
76
+ }, state => [getInstalledBlockTypes(state), select(blockEditorStore).getBlocks()]));
77
77
 
78
78
  /**
79
79
  * Returns true if a block plugin install is in progress.
@@ -1 +1 @@
1
- {"version":3,"names":["createRegistrySelector","store","blockEditorStore","hasBlockType","isRequestingDownloadableBlocks","state","filterValue","_state$downloadableBl","downloadableBlocks","isRequesting","getDownloadableBlocks","_state$downloadableBl2","results","getInstalledBlockTypes","blockManagement","installedBlockTypes","getNewBlockTypes","select","usedBlockTree","getBlocks","filter","blockType","getUnusedBlockTypes","isInstalling","blockId","getErrorNotices","errorNotices","getErrorNoticeForBlock"],"sources":["@wordpress/block-directory/src/store/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport hasBlockType from './utils/has-block-type';\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? [];\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\treturn installedBlockTypes.filter( ( blockType ) =>\n\t\t\thasBlockType( blockType, usedBlockTree )\n\t\t);\n\t}\n);\n\n/**\n * Returns the block types that have been installed on the server but are not\n * used in the current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getUnusedBlockTypes = createRegistrySelector(\n\t( select ) => ( state ) => {\n\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\treturn installedBlockTypes.filter(\n\t\t\t( blockType ) => ! hasBlockType( blockType, usedBlockTree )\n\t\t);\n\t}\n);\n\n/**\n * Returns true if a block plugin install is in progress.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId Id of the block.\n *\n * @return {boolean} Whether this block is currently being installed.\n */\nexport function isInstalling( state, blockId ) {\n\treturn state.blockManagement.isInstalling[ blockId ] || false;\n}\n\n/**\n * Returns all block error notices.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Object with error notices.\n */\nexport function getErrorNotices( state ) {\n\treturn state.errorNotices;\n}\n\n/**\n * Returns the error notice for a given block.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {string|boolean} The error text, or false if no error.\n */\nexport function getErrorNoticeForBlock( state, blockId ) {\n\treturn state.errorNotices[ blockId ];\n}\n"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,sBAAsB,QAAQ,iBAAiB;AACxD,SAASC,KAAK,IAAIC,gBAAgB,QAAQ,yBAAyB;;AAEnE;AACA;AACA;AACA,OAAOC,YAAY,MAAM,wBAAwB;;AAEjD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,8BAA8BA,CAAEC,KAAK,EAAEC,WAAW,EAAG;EAAA,IAAAC,qBAAA;EACpE,QAAAA,qBAAA,GAAOF,KAAK,CAACG,kBAAkB,CAAEF,WAAW,CAAE,EAAEG,YAAY,cAAAF,qBAAA,cAAAA,qBAAA,GAAI,KAAK;AACtE;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASG,qBAAqBA,CAAEL,KAAK,EAAEC,WAAW,EAAG;EAAA,IAAAK,sBAAA;EAC3D,QAAAA,sBAAA,GAAON,KAAK,CAACG,kBAAkB,CAAEF,WAAW,CAAE,EAAEM,OAAO,cAAAD,sBAAA,cAAAA,sBAAA,GAAI,EAAE;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,sBAAsBA,CAAER,KAAK,EAAG;EAC/C,OAAOA,KAAK,CAACS,eAAe,CAACC,mBAAmB;AACjD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,gBAAgB,GAAGhB,sBAAsB,CACnDiB,MAAM,IAAQZ,KAAK,IAAM;EAC1B,MAAMa,aAAa,GAAGD,MAAM,CAAEf,gBAAiB,CAAC,CAACiB,SAAS,CAAC,CAAC;EAC5D,MAAMJ,mBAAmB,GAAGF,sBAAsB,CAAER,KAAM,CAAC;EAE3D,OAAOU,mBAAmB,CAACK,MAAM,CAAIC,SAAS,IAC7ClB,YAAY,CAAEkB,SAAS,EAAEH,aAAc,CACxC,CAAC;AACF,CACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMI,mBAAmB,GAAGtB,sBAAsB,CACtDiB,MAAM,IAAQZ,KAAK,IAAM;EAC1B,MAAMa,aAAa,GAAGD,MAAM,CAAEf,gBAAiB,CAAC,CAACiB,SAAS,CAAC,CAAC;EAC5D,MAAMJ,mBAAmB,GAAGF,sBAAsB,CAAER,KAAM,CAAC;EAE3D,OAAOU,mBAAmB,CAACK,MAAM,CAC9BC,SAAS,IAAM,CAAElB,YAAY,CAAEkB,SAAS,EAAEH,aAAc,CAC3D,CAAC;AACF,CACD,CAAC;;AAED;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASK,YAAYA,CAAElB,KAAK,EAAEmB,OAAO,EAAG;EAC9C,OAAOnB,KAAK,CAACS,eAAe,CAACS,YAAY,CAAEC,OAAO,CAAE,IAAI,KAAK;AAC9D;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAAEpB,KAAK,EAAG;EACxC,OAAOA,KAAK,CAACqB,YAAY;AAC1B;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,sBAAsBA,CAAEtB,KAAK,EAAEmB,OAAO,EAAG;EACxD,OAAOnB,KAAK,CAACqB,YAAY,CAAEF,OAAO,CAAE;AACrC","ignoreList":[]}
1
+ {"version":3,"names":["createSelector","createRegistrySelector","store","blockEditorStore","hasBlockType","isRequestingDownloadableBlocks","state","filterValue","_state$downloadableBl","downloadableBlocks","isRequesting","getDownloadableBlocks","_state$downloadableBl2","results","getInstalledBlockTypes","blockManagement","installedBlockTypes","getNewBlockTypes","select","usedBlockTree","getBlocks","filter","blockType","getUnusedBlockTypes","isInstalling","blockId","getErrorNotices","errorNotices","getErrorNoticeForBlock"],"sources":["@wordpress/block-directory/src/store/selectors.js"],"sourcesContent":["/**\n * WordPress dependencies\n */\nimport { createSelector, createRegistrySelector } from '@wordpress/data';\nimport { store as blockEditorStore } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport hasBlockType from './utils/has-block-type';\n\n/**\n * Returns true if application is requesting for downloadable blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {boolean} Whether a request is in progress for the blocks list.\n */\nexport function isRequestingDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.isRequesting ?? false;\n}\n\n/**\n * Returns the available uninstalled blocks.\n *\n * @param {Object} state Global application state.\n * @param {string} filterValue Search string.\n *\n * @return {Array} Downloadable blocks.\n */\nexport function getDownloadableBlocks( state, filterValue ) {\n\treturn state.downloadableBlocks[ filterValue ]?.results ?? [];\n}\n\n/**\n * Returns the block types that have been installed on the server in this\n * session.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items\n */\nexport function getInstalledBlockTypes( state ) {\n\treturn state.blockManagement.installedBlockTypes;\n}\n\n/**\n * Returns block types that have been installed on the server and used in the\n * current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getNewBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\t\treturn installedBlockTypes.filter( ( blockType ) =>\n\t\t\t\thasBlockType( blockType, usedBlockTree )\n\t\t\t);\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getBlocks(),\n\t\t]\n\t)\n);\n\n/**\n * Returns the block types that have been installed on the server but are not\n * used in the current post.\n *\n * @param {Object} state Global application state.\n *\n * @return {Array} Block type items.\n */\nexport const getUnusedBlockTypes = createRegistrySelector( ( select ) =>\n\tcreateSelector(\n\t\t( state ) => {\n\t\t\tconst usedBlockTree = select( blockEditorStore ).getBlocks();\n\t\t\tconst installedBlockTypes = getInstalledBlockTypes( state );\n\n\t\t\treturn installedBlockTypes.filter(\n\t\t\t\t( blockType ) => ! hasBlockType( blockType, usedBlockTree )\n\t\t\t);\n\t\t},\n\t\t( state ) => [\n\t\t\tgetInstalledBlockTypes( state ),\n\t\t\tselect( blockEditorStore ).getBlocks(),\n\t\t]\n\t)\n);\n\n/**\n * Returns true if a block plugin install is in progress.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId Id of the block.\n *\n * @return {boolean} Whether this block is currently being installed.\n */\nexport function isInstalling( state, blockId ) {\n\treturn state.blockManagement.isInstalling[ blockId ] || false;\n}\n\n/**\n * Returns all block error notices.\n *\n * @param {Object} state Global application state.\n *\n * @return {Object} Object with error notices.\n */\nexport function getErrorNotices( state ) {\n\treturn state.errorNotices;\n}\n\n/**\n * Returns the error notice for a given block.\n *\n * @param {Object} state Global application state.\n * @param {string} blockId The ID of the block plugin. eg: my-block\n *\n * @return {string|boolean} The error text, or false if no error.\n */\nexport function getErrorNoticeForBlock( state, blockId ) {\n\treturn state.errorNotices[ blockId ];\n}\n"],"mappings":"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","ignoreList":[]}
@@ -33,6 +33,9 @@
33
33
  * Grid System.
34
34
  * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
35
35
  */
36
+ /**
37
+ * Radius scale.
38
+ */
36
39
  /**
37
40
  * Dimensions.
38
41
  */
@@ -158,6 +161,7 @@
158
161
  text-align: right;
159
162
  display: grid;
160
163
  grid-template-columns: auto 1fr;
164
+ position: relative;
161
165
  }
162
166
  .block-directory-downloadable-block-list-item:hover {
163
167
  box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
@@ -33,6 +33,9 @@
33
33
  * Grid System.
34
34
  * https://make.wordpress.org/design/2019/10/31/proposal-a-consistent-spacing-system-for-wordpress/
35
35
  */
36
+ /**
37
+ * Radius scale.
38
+ */
36
39
  /**
37
40
  * Dimensions.
38
41
  */
@@ -158,6 +161,7 @@
158
161
  text-align: left;
159
162
  display: grid;
160
163
  grid-template-columns: auto 1fr;
164
+ position: relative;
161
165
  }
162
166
  .block-directory-downloadable-block-list-item:hover {
163
167
  box-shadow: 0 0 0 var(--wp-admin-border-width-focus) var(--wp-admin-theme-color);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/block-directory",
3
- "version": "5.3.0",
3
+ "version": "5.5.0",
4
4
  "description": "Extend editor with block directory features to search, download and install blocks.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -27,25 +27,24 @@
27
27
  "react-native": "src/index",
28
28
  "dependencies": {
29
29
  "@babel/runtime": "^7.16.0",
30
- "@wordpress/a11y": "^4.3.0",
31
- "@wordpress/api-fetch": "^7.3.0",
32
- "@wordpress/block-editor": "^13.3.0",
33
- "@wordpress/blocks": "^13.3.0",
34
- "@wordpress/components": "^28.3.0",
35
- "@wordpress/compose": "^7.3.0",
36
- "@wordpress/core-data": "^7.3.0",
37
- "@wordpress/data": "^10.3.0",
38
- "@wordpress/edit-post": "^8.3.0",
39
- "@wordpress/editor": "^14.3.0",
40
- "@wordpress/element": "^6.3.0",
41
- "@wordpress/hooks": "^4.3.0",
42
- "@wordpress/html-entities": "^4.3.0",
43
- "@wordpress/i18n": "^5.3.0",
44
- "@wordpress/icons": "^10.3.0",
45
- "@wordpress/notices": "^5.3.0",
46
- "@wordpress/plugins": "^7.3.0",
47
- "@wordpress/private-apis": "^1.3.0",
48
- "@wordpress/url": "^4.3.0",
30
+ "@wordpress/a11y": "^4.5.0",
31
+ "@wordpress/api-fetch": "^7.5.0",
32
+ "@wordpress/block-editor": "^14.0.0",
33
+ "@wordpress/blocks": "^13.5.0",
34
+ "@wordpress/components": "^28.5.0",
35
+ "@wordpress/compose": "^7.5.0",
36
+ "@wordpress/core-data": "^7.5.0",
37
+ "@wordpress/data": "^10.5.0",
38
+ "@wordpress/editor": "^14.5.0",
39
+ "@wordpress/element": "^6.5.0",
40
+ "@wordpress/hooks": "^4.5.0",
41
+ "@wordpress/html-entities": "^4.5.0",
42
+ "@wordpress/i18n": "^5.5.0",
43
+ "@wordpress/icons": "^10.5.0",
44
+ "@wordpress/notices": "^5.5.0",
45
+ "@wordpress/plugins": "^7.5.0",
46
+ "@wordpress/private-apis": "^1.5.0",
47
+ "@wordpress/url": "^4.5.0",
49
48
  "change-case": "^4.1.2"
50
49
  },
51
50
  "peerDependencies": {
@@ -55,5 +54,5 @@
55
54
  "publishConfig": {
56
55
  "access": "public"
57
56
  },
58
- "gitHead": "122867d355ca4edc63d3a3bbd9411d3a2e1458df"
57
+ "gitHead": "c3101ab024e2bfc85d525c6d247e0d57cafc9fd9"
59
58
  }
@@ -6,6 +6,12 @@
6
6
  display: grid;
7
7
  grid-template-columns: auto 1fr;
8
8
 
9
+ // The item contains absolutely positioned items.
10
+ // Set `position: relative` on the parent to prevent overflow issues
11
+ // in scroll containers.
12
+ // See: https://github.com/WordPress/gutenberg/issues/63384
13
+ position: relative;
14
+
9
15
  &:hover {
10
16
  @include button-style__focus();
11
17
  }
@@ -4,6 +4,7 @@
4
4
  import { _n, sprintf } from '@wordpress/i18n';
5
5
  import { useSelect } from '@wordpress/data';
6
6
  import { blockDefault } from '@wordpress/icons';
7
+ import { PluginPrePublishPanel } from '@wordpress/editor';
7
8
 
8
9
  /**
9
10
  * Internal dependencies
@@ -11,10 +12,6 @@ import { blockDefault } from '@wordpress/icons';
11
12
  import CompactList from '../../components/compact-list';
12
13
  import { store as blockDirectoryStore } from '../../store';
13
14
 
14
- // We shouldn't import the editor package directly
15
- // because it would include the wp-editor in all pages loading the block-directory script.
16
- const { PluginPrePublishPanel } = window?.wp?.editor ?? {};
17
-
18
15
  export default function InstalledBlocksPrePublishPanel() {
19
16
  const newBlockTypes = useSelect(
20
17
  ( select ) => select( blockDirectoryStore ).getNewBlockTypes(),
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * WordPress dependencies
3
3
  */
4
- import { createRegistrySelector } from '@wordpress/data';
4
+ import { createSelector, createRegistrySelector } from '@wordpress/data';
5
5
  import { store as blockEditorStore } from '@wordpress/block-editor';
6
6
 
7
7
  /**
@@ -53,15 +53,21 @@ export function getInstalledBlockTypes( state ) {
53
53
  *
54
54
  * @return {Array} Block type items.
55
55
  */
56
- export const getNewBlockTypes = createRegistrySelector(
57
- ( select ) => ( state ) => {
58
- const usedBlockTree = select( blockEditorStore ).getBlocks();
59
- const installedBlockTypes = getInstalledBlockTypes( state );
56
+ export const getNewBlockTypes = createRegistrySelector( ( select ) =>
57
+ createSelector(
58
+ ( state ) => {
59
+ const usedBlockTree = select( blockEditorStore ).getBlocks();
60
+ const installedBlockTypes = getInstalledBlockTypes( state );
60
61
 
61
- return installedBlockTypes.filter( ( blockType ) =>
62
- hasBlockType( blockType, usedBlockTree )
63
- );
64
- }
62
+ return installedBlockTypes.filter( ( blockType ) =>
63
+ hasBlockType( blockType, usedBlockTree )
64
+ );
65
+ },
66
+ ( state ) => [
67
+ getInstalledBlockTypes( state ),
68
+ select( blockEditorStore ).getBlocks(),
69
+ ]
70
+ )
65
71
  );
66
72
 
67
73
  /**
@@ -72,15 +78,21 @@ export const getNewBlockTypes = createRegistrySelector(
72
78
  *
73
79
  * @return {Array} Block type items.
74
80
  */
75
- export const getUnusedBlockTypes = createRegistrySelector(
76
- ( select ) => ( state ) => {
77
- const usedBlockTree = select( blockEditorStore ).getBlocks();
78
- const installedBlockTypes = getInstalledBlockTypes( state );
81
+ export const getUnusedBlockTypes = createRegistrySelector( ( select ) =>
82
+ createSelector(
83
+ ( state ) => {
84
+ const usedBlockTree = select( blockEditorStore ).getBlocks();
85
+ const installedBlockTypes = getInstalledBlockTypes( state );
79
86
 
80
- return installedBlockTypes.filter(
81
- ( blockType ) => ! hasBlockType( blockType, usedBlockTree )
82
- );
83
- }
87
+ return installedBlockTypes.filter(
88
+ ( blockType ) => ! hasBlockType( blockType, usedBlockTree )
89
+ );
90
+ },
91
+ ( state ) => [
92
+ getInstalledBlockTypes( state ),
93
+ select( blockEditorStore ).getBlocks(),
94
+ ]
95
+ )
84
96
  );
85
97
 
86
98
  /**