暂无描述

reusable-blocks.js 22KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674
  1. this["wp"] = this["wp"] || {}; this["wp"]["reusableBlocks"] =
  2. /******/ (function(modules) { // webpackBootstrap
  3. /******/ // The module cache
  4. /******/ var installedModules = {};
  5. /******/
  6. /******/ // The require function
  7. /******/ function __webpack_require__(moduleId) {
  8. /******/
  9. /******/ // Check if module is in cache
  10. /******/ if(installedModules[moduleId]) {
  11. /******/ return installedModules[moduleId].exports;
  12. /******/ }
  13. /******/ // Create a new module (and put it into the cache)
  14. /******/ var module = installedModules[moduleId] = {
  15. /******/ i: moduleId,
  16. /******/ l: false,
  17. /******/ exports: {}
  18. /******/ };
  19. /******/
  20. /******/ // Execute the module function
  21. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  22. /******/
  23. /******/ // Flag the module as loaded
  24. /******/ module.l = true;
  25. /******/
  26. /******/ // Return the exports of the module
  27. /******/ return module.exports;
  28. /******/ }
  29. /******/
  30. /******/
  31. /******/ // expose the modules object (__webpack_modules__)
  32. /******/ __webpack_require__.m = modules;
  33. /******/
  34. /******/ // expose the module cache
  35. /******/ __webpack_require__.c = installedModules;
  36. /******/
  37. /******/ // define getter function for harmony exports
  38. /******/ __webpack_require__.d = function(exports, name, getter) {
  39. /******/ if(!__webpack_require__.o(exports, name)) {
  40. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  41. /******/ }
  42. /******/ };
  43. /******/
  44. /******/ // define __esModule on exports
  45. /******/ __webpack_require__.r = function(exports) {
  46. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  47. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  48. /******/ }
  49. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  50. /******/ };
  51. /******/
  52. /******/ // create a fake namespace object
  53. /******/ // mode & 1: value is a module id, require it
  54. /******/ // mode & 2: merge all properties of value into the ns
  55. /******/ // mode & 4: return value when already ns object
  56. /******/ // mode & 8|1: behave like require
  57. /******/ __webpack_require__.t = function(value, mode) {
  58. /******/ if(mode & 1) value = __webpack_require__(value);
  59. /******/ if(mode & 8) return value;
  60. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  61. /******/ var ns = Object.create(null);
  62. /******/ __webpack_require__.r(ns);
  63. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  64. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  65. /******/ return ns;
  66. /******/ };
  67. /******/
  68. /******/ // getDefaultExport function for compatibility with non-harmony modules
  69. /******/ __webpack_require__.n = function(module) {
  70. /******/ var getter = module && module.__esModule ?
  71. /******/ function getDefault() { return module['default']; } :
  72. /******/ function getModuleExports() { return module; };
  73. /******/ __webpack_require__.d(getter, 'a', getter);
  74. /******/ return getter;
  75. /******/ };
  76. /******/
  77. /******/ // Object.prototype.hasOwnProperty.call
  78. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  79. /******/
  80. /******/ // __webpack_public_path__
  81. /******/ __webpack_require__.p = "";
  82. /******/
  83. /******/
  84. /******/ // Load entry module and return exports
  85. /******/ return __webpack_require__(__webpack_require__.s = "iqm2");
  86. /******/ })
  87. /************************************************************************/
  88. /******/ ({
  89. /***/ "1ZqX":
  90. /***/ (function(module, exports) {
  91. (function() { module.exports = window["wp"]["data"]; }());
  92. /***/ }),
  93. /***/ "GRId":
  94. /***/ (function(module, exports) {
  95. (function() { module.exports = window["wp"]["element"]; }());
  96. /***/ }),
  97. /***/ "HSyU":
  98. /***/ (function(module, exports) {
  99. (function() { module.exports = window["wp"]["blocks"]; }());
  100. /***/ }),
  101. /***/ "Mmq9":
  102. /***/ (function(module, exports) {
  103. (function() { module.exports = window["wp"]["url"]; }());
  104. /***/ }),
  105. /***/ "Tqx9":
  106. /***/ (function(module, exports) {
  107. (function() { module.exports = window["wp"]["primitives"]; }());
  108. /***/ }),
  109. /***/ "YLtl":
  110. /***/ (function(module, exports) {
  111. (function() { module.exports = window["lodash"]; }());
  112. /***/ }),
  113. /***/ "axFQ":
  114. /***/ (function(module, exports) {
  115. (function() { module.exports = window["wp"]["blockEditor"]; }());
  116. /***/ }),
  117. /***/ "iqm2":
  118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119. "use strict";
  120. // ESM COMPAT FLAG
  121. __webpack_require__.r(__webpack_exports__);
  122. // EXPORTS
  123. __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; });
  124. __webpack_require__.d(__webpack_exports__, "ReusableBlocksMenuItems", function() { return /* reexport */ reusable_blocks_menu_items; });
  125. // NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js
  126. var actions_namespaceObject = {};
  127. __webpack_require__.r(actions_namespaceObject);
  128. __webpack_require__.d(actions_namespaceObject, "__experimentalConvertBlockToStatic", function() { return __experimentalConvertBlockToStatic; });
  129. __webpack_require__.d(actions_namespaceObject, "__experimentalConvertBlocksToReusable", function() { return __experimentalConvertBlocksToReusable; });
  130. __webpack_require__.d(actions_namespaceObject, "__experimentalDeleteReusableBlock", function() { return __experimentalDeleteReusableBlock; });
  131. __webpack_require__.d(actions_namespaceObject, "__experimentalSetEditingReusableBlock", function() { return __experimentalSetEditingReusableBlock; });
  132. // NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js
  133. var selectors_namespaceObject = {};
  134. __webpack_require__.r(selectors_namespaceObject);
  135. __webpack_require__.d(selectors_namespaceObject, "__experimentalIsEditingReusableBlock", function() { return __experimentalIsEditingReusableBlock; });
  136. // EXTERNAL MODULE: external ["wp","blockEditor"]
  137. var external_wp_blockEditor_ = __webpack_require__("axFQ");
  138. // EXTERNAL MODULE: external ["wp","coreData"]
  139. var external_wp_coreData_ = __webpack_require__("jZUy");
  140. // EXTERNAL MODULE: external ["wp","data"]
  141. var external_wp_data_ = __webpack_require__("1ZqX");
  142. // EXTERNAL MODULE: external "lodash"
  143. var external_lodash_ = __webpack_require__("YLtl");
  144. // EXTERNAL MODULE: external ["wp","blocks"]
  145. var external_wp_blocks_ = __webpack_require__("HSyU");
  146. // EXTERNAL MODULE: external ["wp","i18n"]
  147. var external_wp_i18n_ = __webpack_require__("l3Sj");
  148. // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/controls.js
  149. /**
  150. * External dependencies
  151. */
  152. /**
  153. * WordPress dependencies
  154. */
  155. /**
  156. * Internal dependencies
  157. */
  158. /**
  159. * Convert a reusable block to a static block effect handler
  160. *
  161. * @param {string} clientId Block ID.
  162. * @return {Object} control descriptor.
  163. */
  164. function convertBlockToStatic(clientId) {
  165. return {
  166. type: 'CONVERT_BLOCK_TO_STATIC',
  167. clientId
  168. };
  169. }
  170. /**
  171. * Convert a static block to a reusable block effect handler
  172. *
  173. * @param {Array} clientIds Block IDs.
  174. * @param {string} title Reusable block title.
  175. * @return {Object} control descriptor.
  176. */
  177. function controls_convertBlocksToReusable(clientIds, title) {
  178. return {
  179. type: 'CONVERT_BLOCKS_TO_REUSABLE',
  180. clientIds,
  181. title
  182. };
  183. }
  184. /**
  185. * Deletes a reusable block.
  186. *
  187. * @param {string} id Reusable block ID.
  188. * @return {Object} control descriptor.
  189. */
  190. function deleteReusableBlock(id) {
  191. return {
  192. type: 'DELETE_REUSABLE_BLOCK',
  193. id
  194. };
  195. }
  196. const controls = {
  197. CONVERT_BLOCK_TO_STATIC: Object(external_wp_data_["createRegistryControl"])(registry => ({
  198. clientId
  199. }) => {
  200. const oldBlock = registry.select(external_wp_blockEditor_["store"]).getBlock(clientId);
  201. const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', oldBlock.attributes.ref);
  202. const newBlocks = Object(external_wp_blocks_["parse"])(Object(external_lodash_["isFunction"])(reusableBlock.content) ? reusableBlock.content(reusableBlock) : reusableBlock.content);
  203. registry.dispatch(external_wp_blockEditor_["store"]).replaceBlocks(oldBlock.clientId, newBlocks);
  204. }),
  205. CONVERT_BLOCKS_TO_REUSABLE: Object(external_wp_data_["createRegistryControl"])(registry => async function ({
  206. clientIds,
  207. title
  208. }) {
  209. const reusableBlock = {
  210. title: title || Object(external_wp_i18n_["__"])('Untitled Reusable block'),
  211. content: Object(external_wp_blocks_["serialize"])(registry.select(external_wp_blockEditor_["store"]).getBlocksByClientId(clientIds)),
  212. status: 'publish'
  213. };
  214. const updatedRecord = await registry.dispatch('core').saveEntityRecord('postType', 'wp_block', reusableBlock);
  215. const newBlock = Object(external_wp_blocks_["createBlock"])('core/block', {
  216. ref: updatedRecord.id
  217. });
  218. registry.dispatch(external_wp_blockEditor_["store"]).replaceBlocks(clientIds, newBlock);
  219. registry.dispatch(store).__experimentalSetEditingReusableBlock(newBlock.clientId, true);
  220. }),
  221. DELETE_REUSABLE_BLOCK: Object(external_wp_data_["createRegistryControl"])(registry => async function ({
  222. id
  223. }) {
  224. const reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', id); // Don't allow a reusable block with a temporary ID to be deleted
  225. if (!reusableBlock) {
  226. return;
  227. } // Remove any other blocks that reference this reusable block
  228. const allBlocks = registry.select(external_wp_blockEditor_["store"]).getBlocks();
  229. const associatedBlocks = allBlocks.filter(block => Object(external_wp_blocks_["isReusableBlock"])(block) && block.attributes.ref === id);
  230. const associatedBlockClientIds = associatedBlocks.map(block => block.clientId); // Remove the parsed block.
  231. if (associatedBlockClientIds.length) {
  232. registry.dispatch(external_wp_blockEditor_["store"]).removeBlocks(associatedBlockClientIds);
  233. }
  234. await registry.dispatch('core').deleteEntityRecord('postType', 'wp_block', id);
  235. })
  236. };
  237. /* harmony default export */ var store_controls = (controls);
  238. // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js
  239. /**
  240. * Internal dependencies
  241. */
  242. /**
  243. * Returns a generator converting a reusable block into a static block.
  244. *
  245. * @param {string} clientId The client ID of the block to attach.
  246. */
  247. function* __experimentalConvertBlockToStatic(clientId) {
  248. yield convertBlockToStatic(clientId);
  249. }
  250. /**
  251. * Returns a generator converting one or more static blocks into a reusable block.
  252. *
  253. * @param {string[]} clientIds The client IDs of the block to detach.
  254. * @param {string} title Reusable block title.
  255. */
  256. function* __experimentalConvertBlocksToReusable(clientIds, title) {
  257. yield controls_convertBlocksToReusable(clientIds, title);
  258. }
  259. /**
  260. * Returns a generator deleting a reusable block.
  261. *
  262. * @param {string} id The ID of the reusable block to delete.
  263. */
  264. function* __experimentalDeleteReusableBlock(id) {
  265. yield deleteReusableBlock(id);
  266. }
  267. /**
  268. * Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action.
  269. *
  270. * @param {string} clientId The clientID of the reusable block to target.
  271. * @param {boolean} isEditing Whether the block should be in editing state.
  272. * @return {Object} Action descriptor.
  273. */
  274. function __experimentalSetEditingReusableBlock(clientId, isEditing) {
  275. return {
  276. type: 'SET_EDITING_REUSABLE_BLOCK',
  277. clientId,
  278. isEditing
  279. };
  280. }
  281. // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/reducer.js
  282. /**
  283. * WordPress dependencies
  284. */
  285. function isEditingReusableBlock(state = {}, action) {
  286. if ((action === null || action === void 0 ? void 0 : action.type) === 'SET_EDITING_REUSABLE_BLOCK') {
  287. return { ...state,
  288. [action.clientId]: action.isEditing
  289. };
  290. }
  291. return state;
  292. }
  293. /* harmony default export */ var reducer = (Object(external_wp_data_["combineReducers"])({
  294. isEditingReusableBlock
  295. }));
  296. // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js
  297. /**
  298. * Returns true if reusable block is in the editing state.
  299. *
  300. * @param {Object} state Global application state.
  301. * @param {number} clientId the clientID of the block.
  302. * @return {boolean} Whether the reusable block is in the editing state.
  303. */
  304. function __experimentalIsEditingReusableBlock(state, clientId) {
  305. return state.isEditingReusableBlock[clientId];
  306. }
  307. // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/index.js
  308. /**
  309. * WordPress dependencies
  310. */
  311. /**
  312. * Internal dependencies
  313. */
  314. const STORE_NAME = 'core/reusable-blocks';
  315. /**
  316. * Store definition for the reusable blocks namespace.
  317. *
  318. * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
  319. *
  320. * @type {Object}
  321. */
  322. const store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, {
  323. actions: actions_namespaceObject,
  324. controls: store_controls,
  325. reducer: reducer,
  326. selectors: selectors_namespaceObject
  327. });
  328. Object(external_wp_data_["register"])(store);
  329. // EXTERNAL MODULE: external ["wp","element"]
  330. var external_wp_element_ = __webpack_require__("GRId");
  331. // EXTERNAL MODULE: external ["wp","components"]
  332. var external_wp_components_ = __webpack_require__("tI+e");
  333. // EXTERNAL MODULE: external ["wp","primitives"]
  334. var external_wp_primitives_ = __webpack_require__("Tqx9");
  335. // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/reusable-block.js
  336. /**
  337. * WordPress dependencies
  338. */
  339. const reusable_block_reusableBlock = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
  340. xmlns: "http://www.w3.org/2000/svg",
  341. viewBox: "0 0 24 24"
  342. }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
  343. d: "M7 7.2h8.2L13.5 9l1.1 1.1 3.6-3.6-3.5-4-1.1 1 1.9 2.3H7c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.2-.5zm13.8 4V11h-1.5v.3c0 1.1 0 3.5-1 4.5-.3.3-.7.5-1.3.5H8.8l1.7-1.7-1.1-1.1L5.9 17l3.5 4 1.1-1-1.9-2.3H17c.9 0 1.7-.3 2.3-.9 1.5-1.4 1.5-4.2 1.5-5.6z"
  344. }));
  345. /* harmony default export */ var reusable_block = (reusable_block_reusableBlock);
  346. // EXTERNAL MODULE: external ["wp","notices"]
  347. var external_wp_notices_ = __webpack_require__("onLe");
  348. // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js
  349. /**
  350. * WordPress dependencies
  351. */
  352. /**
  353. * Internal dependencies
  354. */
  355. /**
  356. * Menu control to convert block(s) to reusable block.
  357. *
  358. * @param {Object} props Component props.
  359. * @param {string[]} props.clientIds Client ids of selected blocks.
  360. * @param {string} props.rootClientId ID of the currently selected top-level block.
  361. * @return {import('@wordpress/element').WPComponent} The menu control or null.
  362. */
  363. function ReusableBlockConvertButton({
  364. clientIds,
  365. rootClientId
  366. }) {
  367. const [isModalOpen, setIsModalOpen] = Object(external_wp_element_["useState"])(false);
  368. const [title, setTitle] = Object(external_wp_element_["useState"])('');
  369. const canConvert = Object(external_wp_data_["useSelect"])(select => {
  370. var _getBlocksByClientId;
  371. const {
  372. canUser
  373. } = select('core');
  374. const {
  375. getBlocksByClientId,
  376. canInsertBlockType
  377. } = select('core/block-editor');
  378. const blocks = (_getBlocksByClientId = getBlocksByClientId(clientIds)) !== null && _getBlocksByClientId !== void 0 ? _getBlocksByClientId : [];
  379. const isReusable = blocks.length === 1 && blocks[0] && Object(external_wp_blocks_["isReusableBlock"])(blocks[0]) && !!select('core').getEntityRecord('postType', 'wp_block', blocks[0].attributes.ref);
  380. const _canConvert = // Hide when this is already a reusable block.
  381. !isReusable && // Hide when reusable blocks are disabled.
  382. canInsertBlockType('core/block', rootClientId) && blocks.every(block => // Guard against the case where a regular block has *just* been converted.
  383. !!block && // Hide on invalid blocks.
  384. block.isValid && // Hide when block doesn't support being made reusable.
  385. Object(external_wp_blocks_["hasBlockSupport"])(block.name, 'reusable', true)) && // Hide when current doesn't have permission to do that.
  386. !!canUser('create', 'blocks');
  387. return _canConvert;
  388. }, [clientIds]);
  389. const {
  390. __experimentalConvertBlocksToReusable: convertBlocksToReusable
  391. } = Object(external_wp_data_["useDispatch"])(store);
  392. const {
  393. createSuccessNotice,
  394. createErrorNotice
  395. } = Object(external_wp_data_["useDispatch"])(external_wp_notices_["store"]);
  396. const onConvert = Object(external_wp_element_["useCallback"])(async function (reusableBlockTitle) {
  397. try {
  398. await convertBlocksToReusable(clientIds, reusableBlockTitle);
  399. createSuccessNotice(Object(external_wp_i18n_["__"])('Reusable block created.'), {
  400. type: 'snackbar'
  401. });
  402. } catch (error) {
  403. createErrorNotice(error.message, {
  404. type: 'snackbar'
  405. });
  406. }
  407. }, [clientIds]);
  408. if (!canConvert) {
  409. return null;
  410. }
  411. return Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockSettingsMenuControls"], null, ({
  412. onClose
  413. }) => Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  414. icon: reusable_block,
  415. onClick: () => {
  416. setIsModalOpen(true);
  417. }
  418. }, Object(external_wp_i18n_["__"])('Add to Reusable blocks')), isModalOpen && Object(external_wp_element_["createElement"])(external_wp_components_["Modal"], {
  419. title: Object(external_wp_i18n_["__"])('Create Reusable block'),
  420. closeLabel: Object(external_wp_i18n_["__"])('Close'),
  421. onRequestClose: () => {
  422. setIsModalOpen(false);
  423. setTitle('');
  424. },
  425. overlayClassName: "reusable-blocks-menu-items__convert-modal"
  426. }, Object(external_wp_element_["createElement"])("form", {
  427. onSubmit: event => {
  428. event.preventDefault();
  429. onConvert(title);
  430. setIsModalOpen(false);
  431. setTitle('');
  432. onClose();
  433. }
  434. }, Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
  435. label: Object(external_wp_i18n_["__"])('Name'),
  436. value: title,
  437. onChange: setTitle
  438. }), Object(external_wp_element_["createElement"])(external_wp_components_["Flex"], {
  439. className: "reusable-blocks-menu-items__convert-modal-actions",
  440. justify: "flex-end"
  441. }, Object(external_wp_element_["createElement"])(external_wp_components_["FlexItem"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  442. isSecondary: true,
  443. onClick: () => {
  444. setIsModalOpen(false);
  445. setTitle('');
  446. }
  447. }, Object(external_wp_i18n_["__"])('Cancel'))), Object(external_wp_element_["createElement"])(external_wp_components_["FlexItem"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
  448. isPrimary: true,
  449. type: "submit"
  450. }, Object(external_wp_i18n_["__"])('Save'))))))));
  451. }
  452. // EXTERNAL MODULE: external ["wp","url"]
  453. var external_wp_url_ = __webpack_require__("Mmq9");
  454. // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js
  455. /**
  456. * WordPress dependencies
  457. */
  458. function ReusableBlocksManageButton({
  459. clientId
  460. }) {
  461. const {
  462. isVisible
  463. } = Object(external_wp_data_["useSelect"])(select => {
  464. const {
  465. getBlock
  466. } = select(external_wp_blockEditor_["store"]);
  467. const {
  468. canUser
  469. } = select('core');
  470. const reusableBlock = getBlock(clientId);
  471. return {
  472. isVisible: !!reusableBlock && Object(external_wp_blocks_["isReusableBlock"])(reusableBlock) && !!canUser('update', 'blocks', reusableBlock.attributes.ref)
  473. };
  474. }, [clientId]);
  475. if (!isVisible) {
  476. return null;
  477. }
  478. return Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockSettingsMenuControls"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
  479. href: Object(external_wp_url_["addQueryArgs"])('edit.php', {
  480. post_type: 'wp_block'
  481. })
  482. }, Object(external_wp_i18n_["__"])('Manage Reusable blocks')));
  483. }
  484. /* harmony default export */ var reusable_blocks_manage_button = (ReusableBlocksManageButton);
  485. // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.js
  486. /**
  487. * WordPress dependencies
  488. */
  489. /**
  490. * Internal dependencies
  491. */
  492. function ReusableBlocksMenuItems({
  493. clientIds,
  494. rootClientId
  495. }) {
  496. return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(ReusableBlockConvertButton, {
  497. clientIds: clientIds,
  498. rootClientId: rootClientId
  499. }), clientIds.length === 1 && Object(external_wp_element_["createElement"])(reusable_blocks_manage_button, {
  500. clientId: clientIds[0]
  501. }));
  502. }
  503. /* harmony default export */ var reusable_blocks_menu_items = (Object(external_wp_data_["withSelect"])(select => {
  504. const {
  505. getSelectedBlockClientIds
  506. } = select(external_wp_blockEditor_["store"]);
  507. return {
  508. clientIds: getSelectedBlockClientIds()
  509. };
  510. })(ReusableBlocksMenuItems));
  511. // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/index.js
  512. // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/index.js
  513. /**
  514. * WordPress dependencies
  515. */
  516. /***/ }),
  517. /***/ "jZUy":
  518. /***/ (function(module, exports) {
  519. (function() { module.exports = window["wp"]["coreData"]; }());
  520. /***/ }),
  521. /***/ "l3Sj":
  522. /***/ (function(module, exports) {
  523. (function() { module.exports = window["wp"]["i18n"]; }());
  524. /***/ }),
  525. /***/ "onLe":
  526. /***/ (function(module, exports) {
  527. (function() { module.exports = window["wp"]["notices"]; }());
  528. /***/ }),
  529. /***/ "tI+e":
  530. /***/ (function(module, exports) {
  531. (function() { module.exports = window["wp"]["components"]; }());
  532. /***/ })
  533. /******/ });