[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

/wp-includes/js/dist/ -> reusable-blocks.js (source)

   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 = 468);
  86  /******/ })
  87  /************************************************************************/
  88  /******/ ({
  89  
  90  /***/ 0:
  91  /***/ (function(module, exports) {
  92  
  93  (function() { module.exports = window["wp"]["element"]; }());
  94  
  95  /***/ }),
  96  
  97  /***/ 1:
  98  /***/ (function(module, exports) {
  99  
 100  (function() { module.exports = window["wp"]["i18n"]; }());
 101  
 102  /***/ }),
 103  
 104  /***/ 16:
 105  /***/ (function(module, exports) {
 106  
 107  (function() { module.exports = window["regeneratorRuntime"]; }());
 108  
 109  /***/ }),
 110  
 111  /***/ 3:
 112  /***/ (function(module, exports) {
 113  
 114  (function() { module.exports = window["wp"]["components"]; }());
 115  
 116  /***/ }),
 117  
 118  /***/ 32:
 119  /***/ (function(module, exports) {
 120  
 121  (function() { module.exports = window["wp"]["url"]; }());
 122  
 123  /***/ }),
 124  
 125  /***/ 4:
 126  /***/ (function(module, exports) {
 127  
 128  (function() { module.exports = window["wp"]["data"]; }());
 129  
 130  /***/ }),
 131  
 132  /***/ 468:
 133  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 134  
 135  "use strict";
 136  // ESM COMPAT FLAG
 137  __webpack_require__.r(__webpack_exports__);
 138  
 139  // EXPORTS
 140  __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; });
 141  __webpack_require__.d(__webpack_exports__, "ReusableBlocksMenuItems", function() { return /* reexport */ reusable_blocks_menu_items; });
 142  
 143  // NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js
 144  var actions_namespaceObject = {};
 145  __webpack_require__.r(actions_namespaceObject);
 146  __webpack_require__.d(actions_namespaceObject, "__experimentalConvertBlockToStatic", function() { return __experimentalConvertBlockToStatic; });
 147  __webpack_require__.d(actions_namespaceObject, "__experimentalConvertBlocksToReusable", function() { return __experimentalConvertBlocksToReusable; });
 148  __webpack_require__.d(actions_namespaceObject, "__experimentalDeleteReusableBlock", function() { return __experimentalDeleteReusableBlock; });
 149  __webpack_require__.d(actions_namespaceObject, "__experimentalSetEditingReusableBlock", function() { return __experimentalSetEditingReusableBlock; });
 150  
 151  // NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js
 152  var selectors_namespaceObject = {};
 153  __webpack_require__.r(selectors_namespaceObject);
 154  __webpack_require__.d(selectors_namespaceObject, "__experimentalIsEditingReusableBlock", function() { return __experimentalIsEditingReusableBlock; });
 155  
 156  // EXTERNAL MODULE: external ["wp","blockEditor"]
 157  var external_wp_blockEditor_ = __webpack_require__(6);
 158  
 159  // EXTERNAL MODULE: external ["wp","coreData"]
 160  var external_wp_coreData_ = __webpack_require__(57);
 161  
 162  // EXTERNAL MODULE: external ["wp","data"]
 163  var external_wp_data_ = __webpack_require__(4);
 164  
 165  // EXTERNAL MODULE: external "regeneratorRuntime"
 166  var external_regeneratorRuntime_ = __webpack_require__(16);
 167  var external_regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(external_regeneratorRuntime_);
 168  
 169  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
 170  var asyncToGenerator = __webpack_require__(47);
 171  
 172  // EXTERNAL MODULE: external ["wp","blocks"]
 173  var external_wp_blocks_ = __webpack_require__(9);
 174  
 175  // EXTERNAL MODULE: external ["wp","i18n"]
 176  var external_wp_i18n_ = __webpack_require__(1);
 177  
 178  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/controls.js
 179  
 180  
 181  
 182  /**
 183   * WordPress dependencies
 184   */
 185  
 186  
 187  
 188  /**
 189   * Internal dependencies
 190   */
 191  
 192  
 193  /**
 194   * Convert a reusable block to a static block effect handler
 195   *
 196   * @param {string}  clientId Block ID.
 197   * @return {Object} control descriptor.
 198   */
 199  
 200  function convertBlockToStatic(clientId) {
 201    return {
 202      type: 'CONVERT_BLOCK_TO_STATIC',
 203      clientId: clientId
 204    };
 205  }
 206  /**
 207   * Convert a static block to a reusable block effect handler
 208   *
 209   * @param {Array}  clientIds Block IDs.
 210   * @return {Object} control descriptor.
 211   */
 212  
 213  function controls_convertBlocksToReusable(clientIds) {
 214    return {
 215      type: 'CONVERT_BLOCKS_TO_REUSABLE',
 216      clientIds: clientIds
 217    };
 218  }
 219  /**
 220   * Deletes a reusable block.
 221   *
 222   * @param {string} id Reusable block ID.
 223   * @return {Object} control descriptor.
 224   */
 225  
 226  function deleteReusableBlock(id) {
 227    return {
 228      type: 'DELETE_REUSABLE_BLOCK',
 229      id: id
 230    };
 231  }
 232  var controls = {
 233    CONVERT_BLOCK_TO_STATIC: Object(external_wp_data_["createRegistryControl"])(function (registry) {
 234      return function (_ref) {
 235        var clientId = _ref.clientId;
 236        var oldBlock = registry.select('core/block-editor').getBlock(clientId);
 237        var reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', oldBlock.attributes.ref);
 238        var newBlocks = Object(external_wp_blocks_["parse"])(reusableBlock.content);
 239        registry.dispatch('core/block-editor').replaceBlocks(oldBlock.clientId, newBlocks);
 240      };
 241    }),
 242    CONVERT_BLOCKS_TO_REUSABLE: Object(external_wp_data_["createRegistryControl"])(function (registry) {
 243      return /*#__PURE__*/function () {
 244        var _ref3 = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee(_ref2) {
 245          var clientIds, reusableBlock, updatedRecord, newBlock;
 246          return external_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
 247            while (1) {
 248              switch (_context.prev = _context.next) {
 249                case 0:
 250                  clientIds = _ref2.clientIds;
 251                  reusableBlock = {
 252                    title: Object(external_wp_i18n_["__"])('Untitled Reusable Block'),
 253                    content: Object(external_wp_blocks_["serialize"])(registry.select('core/block-editor').getBlocksByClientId(clientIds)),
 254                    status: 'publish'
 255                  };
 256                  _context.next = 4;
 257                  return registry.dispatch('core').saveEntityRecord('postType', 'wp_block', reusableBlock);
 258  
 259                case 4:
 260                  updatedRecord = _context.sent;
 261                  newBlock = Object(external_wp_blocks_["createBlock"])('core/block', {
 262                    ref: updatedRecord.id
 263                  });
 264                  registry.dispatch('core/block-editor').replaceBlocks(clientIds, newBlock);
 265  
 266                  registry.dispatch(store).__experimentalSetEditingReusableBlock(newBlock.clientId, true);
 267  
 268                case 8:
 269                case "end":
 270                  return _context.stop();
 271              }
 272            }
 273          }, _callee);
 274        }));
 275  
 276        return function (_x) {
 277          return _ref3.apply(this, arguments);
 278        };
 279      }();
 280    }),
 281    DELETE_REUSABLE_BLOCK: Object(external_wp_data_["createRegistryControl"])(function (registry) {
 282      return /*#__PURE__*/function () {
 283        var _ref5 = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee2(_ref4) {
 284          var id, reusableBlock, allBlocks, associatedBlocks, associatedBlockClientIds;
 285          return external_regeneratorRuntime_default.a.wrap(function _callee2$(_context2) {
 286            while (1) {
 287              switch (_context2.prev = _context2.next) {
 288                case 0:
 289                  id = _ref4.id;
 290                  reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', id); // Don't allow a reusable block with a temporary ID to be deleted
 291  
 292                  if (reusableBlock) {
 293                    _context2.next = 4;
 294                    break;
 295                  }
 296  
 297                  return _context2.abrupt("return");
 298  
 299                case 4:
 300                  // Remove any other blocks that reference this reusable block
 301                  allBlocks = registry.select('core/block-editor').getBlocks();
 302                  associatedBlocks = allBlocks.filter(function (block) {
 303                    return Object(external_wp_blocks_["isReusableBlock"])(block) && block.attributes.ref === id;
 304                  });
 305                  associatedBlockClientIds = associatedBlocks.map(function (block) {
 306                    return block.clientId;
 307                  }); // Remove the parsed block.
 308  
 309                  if (associatedBlockClientIds.length) {
 310                    registry.dispatch('core/block-editor').removeBlocks(associatedBlockClientIds);
 311                  }
 312  
 313                  _context2.next = 10;
 314                  return registry.dispatch('core').deleteEntityRecord('postType', 'wp_block', id);
 315  
 316                case 10:
 317                case "end":
 318                  return _context2.stop();
 319              }
 320            }
 321          }, _callee2);
 322        }));
 323  
 324        return function (_x2) {
 325          return _ref5.apply(this, arguments);
 326        };
 327      }();
 328    })
 329  };
 330  /* harmony default export */ var store_controls = (controls);
 331  
 332  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js
 333  
 334  
 335  var _marked = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(__experimentalConvertBlockToStatic),
 336      _marked2 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(__experimentalConvertBlocksToReusable),
 337      _marked3 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(__experimentalDeleteReusableBlock);
 338  
 339  /**
 340   * Internal dependencies
 341   */
 342  
 343  /**
 344   * Returns a generator converting a reusable block into a static block.
 345   *
 346   * @param {string} clientId The client ID of the block to attach.
 347   */
 348  
 349  function __experimentalConvertBlockToStatic(clientId) {
 350    return external_regeneratorRuntime_default.a.wrap(function __experimentalConvertBlockToStatic$(_context) {
 351      while (1) {
 352        switch (_context.prev = _context.next) {
 353          case 0:
 354            _context.next = 2;
 355            return convertBlockToStatic(clientId);
 356  
 357          case 2:
 358          case "end":
 359            return _context.stop();
 360        }
 361      }
 362    }, _marked);
 363  }
 364  /**
 365   * Returns a generator converting one or more static blocks into a reusable block.
 366   *
 367   * @param {string[]} clientIds The client IDs of the block to detach.
 368   */
 369  
 370  function __experimentalConvertBlocksToReusable(clientIds) {
 371    return external_regeneratorRuntime_default.a.wrap(function __experimentalConvertBlocksToReusable$(_context2) {
 372      while (1) {
 373        switch (_context2.prev = _context2.next) {
 374          case 0:
 375            _context2.next = 2;
 376            return controls_convertBlocksToReusable(clientIds);
 377  
 378          case 2:
 379          case "end":
 380            return _context2.stop();
 381        }
 382      }
 383    }, _marked2);
 384  }
 385  /**
 386   * Returns a generator deleting a reusable block.
 387   *
 388   * @param {string} id The ID of the reusable block to delete.
 389   */
 390  
 391  function __experimentalDeleteReusableBlock(id) {
 392    return external_regeneratorRuntime_default.a.wrap(function __experimentalDeleteReusableBlock$(_context3) {
 393      while (1) {
 394        switch (_context3.prev = _context3.next) {
 395          case 0:
 396            _context3.next = 2;
 397            return deleteReusableBlock(id);
 398  
 399          case 2:
 400          case "end":
 401            return _context3.stop();
 402        }
 403      }
 404    }, _marked3);
 405  }
 406  /**
 407   * Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action.
 408   *
 409   * @param {string} clientId The clientID of the reusable block to target.
 410   * @param {boolean} isEditing Whether the block should be in editing state.
 411   * @return {Object} Action descriptor.
 412   */
 413  
 414  function __experimentalSetEditingReusableBlock(clientId, isEditing) {
 415    return {
 416      type: 'SET_EDITING_REUSABLE_BLOCK',
 417      clientId: clientId,
 418      isEditing: isEditing
 419    };
 420  }
 421  
 422  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
 423  var defineProperty = __webpack_require__(5);
 424  
 425  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/reducer.js
 426  
 427  
 428  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
 429  
 430  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { Object(defineProperty["a" /* default */])(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
 431  
 432  /**
 433   * WordPress dependencies
 434   */
 435  
 436  function isEditingReusableBlock() {
 437    var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
 438    var action = arguments.length > 1 ? arguments[1] : undefined;
 439  
 440    if ((action === null || action === void 0 ? void 0 : action.type) === 'SET_EDITING_REUSABLE_BLOCK') {
 441      return _objectSpread(_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, action.clientId, action.isEditing));
 442    }
 443  
 444    return state;
 445  }
 446  /* harmony default export */ var reducer = (Object(external_wp_data_["combineReducers"])({
 447    isEditingReusableBlock: isEditingReusableBlock
 448  }));
 449  
 450  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js
 451  /**
 452   * Returns true if reusable block is in the editing state.
 453   *
 454   * @param {Object} state Global application state.
 455   * @param {number} clientId the clientID of the block.
 456   * @return {boolean} Whether the reusable block is in the editing state.
 457   */
 458  function __experimentalIsEditingReusableBlock(state, clientId) {
 459    return state.isEditingReusableBlock[clientId];
 460  }
 461  
 462  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/index.js
 463  /**
 464   * WordPress dependencies
 465   */
 466  
 467  /**
 468   * Internal dependencies
 469   */
 470  
 471  
 472  
 473  
 474  
 475  var STORE_NAME = 'core/reusable-blocks';
 476  /**
 477   * Store definition for the reusable blocks namespace.
 478   *
 479   * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
 480   *
 481   * @type {Object}
 482   */
 483  
 484  var store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, {
 485    actions: actions_namespaceObject,
 486    controls: store_controls,
 487    reducer: reducer,
 488    selectors: selectors_namespaceObject
 489  });
 490  Object(external_wp_data_["register"])(store);
 491  
 492  // EXTERNAL MODULE: external ["wp","element"]
 493  var external_wp_element_ = __webpack_require__(0);
 494  
 495  // EXTERNAL MODULE: external ["wp","components"]
 496  var external_wp_components_ = __webpack_require__(3);
 497  
 498  // EXTERNAL MODULE: external ["wp","primitives"]
 499  var external_wp_primitives_ = __webpack_require__(7);
 500  
 501  // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/reusable-block.js
 502  
 503  
 504  /**
 505   * WordPress dependencies
 506   */
 507  
 508  var reusable_block_reusableBlock = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
 509    xmlns: "http://www.w3.org/2000/svg",
 510    viewBox: "0 0 24 24"
 511  }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
 512    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"
 513  }));
 514  /* harmony default export */ var reusable_block = (reusable_block_reusableBlock);
 515  
 516  // EXTERNAL MODULE: external ["wp","notices"]
 517  var external_wp_notices_ = __webpack_require__(51);
 518  
 519  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js
 520  
 521  
 522  
 523  
 524  /**
 525   * WordPress dependencies
 526   */
 527  
 528  
 529  
 530  
 531  
 532  
 533  
 534  
 535  /**
 536   * Internal dependencies
 537   */
 538  
 539  
 540  /**
 541   * Menu control to convert block(s) to reusable block.
 542   *
 543   * @param {Object}   props              Component props.
 544   * @param {string[]} props.clientIds    Client ids of selected blocks.
 545   * @param {string}   props.rootClientId ID of the currently selected top-level block.
 546   * @return {import('@wordpress/element').WPComponent} The menu control or null.
 547   */
 548  
 549  function ReusableBlockConvertButton(_ref) {
 550    var clientIds = _ref.clientIds,
 551        rootClientId = _ref.rootClientId;
 552    var canConvert = Object(external_wp_data_["useSelect"])(function (select) {
 553      var _getBlocksByClientId;
 554  
 555      var _select = select('core'),
 556          canUser = _select.canUser;
 557  
 558      var _select2 = select('core/block-editor'),
 559          getBlocksByClientId = _select2.getBlocksByClientId,
 560          canInsertBlockType = _select2.canInsertBlockType;
 561  
 562      var blocks = (_getBlocksByClientId = getBlocksByClientId(clientIds)) !== null && _getBlocksByClientId !== void 0 ? _getBlocksByClientId : [];
 563      var isReusable = blocks.length === 1 && blocks[0] && Object(external_wp_blocks_["isReusableBlock"])(blocks[0]) && !!select('core').getEntityRecord('postType', 'wp_block', blocks[0].attributes.ref);
 564  
 565      var _canConvert = // Hide when this is already a reusable block.
 566      !isReusable && // Hide when reusable blocks are disabled.
 567      canInsertBlockType('core/block', rootClientId) && blocks.every(function (block) {
 568        return (// Guard against the case where a regular block has *just* been converted.
 569          !!block && // Hide on invalid blocks.
 570          block.isValid && // Hide when block doesn't support being made reusable.
 571          Object(external_wp_blocks_["hasBlockSupport"])(block.name, 'reusable', true)
 572        );
 573      }) && // Hide when current doesn't have permission to do that.
 574      !!canUser('create', 'blocks');
 575  
 576      return _canConvert;
 577    }, [clientIds]);
 578  
 579    var _useDispatch = Object(external_wp_data_["useDispatch"])(store),
 580        convertBlocksToReusable = _useDispatch.__experimentalConvertBlocksToReusable;
 581  
 582    var _useDispatch2 = Object(external_wp_data_["useDispatch"])(external_wp_notices_["store"]),
 583        createSuccessNotice = _useDispatch2.createSuccessNotice,
 584        createErrorNotice = _useDispatch2.createErrorNotice;
 585  
 586    var onConvert = Object(external_wp_element_["useCallback"])( /*#__PURE__*/Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee() {
 587      return external_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
 588        while (1) {
 589          switch (_context.prev = _context.next) {
 590            case 0:
 591              _context.prev = 0;
 592              _context.next = 3;
 593              return convertBlocksToReusable(clientIds);
 594  
 595            case 3:
 596              createSuccessNotice(Object(external_wp_i18n_["__"])('Block created.'), {
 597                type: 'snackbar'
 598              });
 599              _context.next = 9;
 600              break;
 601  
 602            case 6:
 603              _context.prev = 6;
 604              _context.t0 = _context["catch"](0);
 605              createErrorNotice(_context.t0.message, {
 606                type: 'snackbar'
 607              });
 608  
 609            case 9:
 610            case "end":
 611              return _context.stop();
 612          }
 613        }
 614      }, _callee, null, [[0, 6]]);
 615    })), [clientIds]);
 616  
 617    if (!canConvert) {
 618      return null;
 619    }
 620  
 621    return Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockSettingsMenuControls"], null, function (_ref3) {
 622      var onClose = _ref3.onClose;
 623      return Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
 624        icon: reusable_block,
 625        onClick: function onClick() {
 626          onConvert();
 627          onClose();
 628        }
 629      }, Object(external_wp_i18n_["__"])('Add to Reusable blocks'));
 630    });
 631  }
 632  
 633  // EXTERNAL MODULE: external ["wp","url"]
 634  var external_wp_url_ = __webpack_require__(32);
 635  
 636  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js
 637  
 638  
 639  /**
 640   * WordPress dependencies
 641   */
 642  
 643  
 644  
 645  
 646  
 647  
 648  
 649  function ReusableBlocksManageButton(_ref) {
 650    var clientId = _ref.clientId;
 651  
 652    var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
 653      var _select = select('core/block-editor'),
 654          getBlock = _select.getBlock;
 655  
 656      var _select2 = select('core'),
 657          canUser = _select2.canUser;
 658  
 659      var reusableBlock = getBlock(clientId);
 660      return {
 661        isVisible: !!reusableBlock && Object(external_wp_blocks_["isReusableBlock"])(reusableBlock) && !!canUser('update', 'blocks', reusableBlock.attributes.ref)
 662      };
 663    }, [clientId]),
 664        isVisible = _useSelect.isVisible;
 665  
 666    if (!isVisible) {
 667      return null;
 668    }
 669  
 670    return Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockSettingsMenuControls"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
 671      href: Object(external_wp_url_["addQueryArgs"])('edit.php', {
 672        post_type: 'wp_block'
 673      })
 674    }, Object(external_wp_i18n_["__"])('Manage Reusable blocks')));
 675  }
 676  
 677  /* harmony default export */ var reusable_blocks_manage_button = (ReusableBlocksManageButton);
 678  
 679  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.js
 680  
 681  
 682  /**
 683   * WordPress dependencies
 684   */
 685  
 686  /**
 687   * Internal dependencies
 688   */
 689  
 690  
 691  
 692  
 693  function ReusableBlocksMenuItems(_ref) {
 694    var clientIds = _ref.clientIds,
 695        rootClientId = _ref.rootClientId;
 696    return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(ReusableBlockConvertButton, {
 697      clientIds: clientIds,
 698      rootClientId: rootClientId
 699    }), clientIds.length === 1 && Object(external_wp_element_["createElement"])(reusable_blocks_manage_button, {
 700      clientId: clientIds[0]
 701    }));
 702  }
 703  
 704  /* harmony default export */ var reusable_blocks_menu_items = (Object(external_wp_data_["withSelect"])(function (select) {
 705    var _select = select('core/block-editor'),
 706        getSelectedBlockClientIds = _select.getSelectedBlockClientIds;
 707  
 708    return {
 709      clientIds: getSelectedBlockClientIds()
 710    };
 711  })(ReusableBlocksMenuItems));
 712  
 713  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/index.js
 714  
 715  
 716  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/index.js
 717  /**
 718   * WordPress dependencies
 719   */
 720  
 721  
 722  
 723  
 724  
 725  
 726  /***/ }),
 727  
 728  /***/ 47:
 729  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 730  
 731  "use strict";
 732  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; });
 733  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
 734    try {
 735      var info = gen[key](arg);
 736      var value = info.value;
 737    } catch (error) {
 738      reject(error);
 739      return;
 740    }
 741  
 742    if (info.done) {
 743      resolve(value);
 744    } else {
 745      Promise.resolve(value).then(_next, _throw);
 746    }
 747  }
 748  
 749  function _asyncToGenerator(fn) {
 750    return function () {
 751      var self = this,
 752          args = arguments;
 753      return new Promise(function (resolve, reject) {
 754        var gen = fn.apply(self, args);
 755  
 756        function _next(value) {
 757          asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
 758        }
 759  
 760        function _throw(err) {
 761          asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
 762        }
 763  
 764        _next(undefined);
 765      });
 766    };
 767  }
 768  
 769  /***/ }),
 770  
 771  /***/ 5:
 772  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 773  
 774  "use strict";
 775  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
 776  function _defineProperty(obj, key, value) {
 777    if (key in obj) {
 778      Object.defineProperty(obj, key, {
 779        value: value,
 780        enumerable: true,
 781        configurable: true,
 782        writable: true
 783      });
 784    } else {
 785      obj[key] = value;
 786    }
 787  
 788    return obj;
 789  }
 790  
 791  /***/ }),
 792  
 793  /***/ 51:
 794  /***/ (function(module, exports) {
 795  
 796  (function() { module.exports = window["wp"]["notices"]; }());
 797  
 798  /***/ }),
 799  
 800  /***/ 57:
 801  /***/ (function(module, exports) {
 802  
 803  (function() { module.exports = window["wp"]["coreData"]; }());
 804  
 805  /***/ }),
 806  
 807  /***/ 6:
 808  /***/ (function(module, exports) {
 809  
 810  (function() { module.exports = window["wp"]["blockEditor"]; }());
 811  
 812  /***/ }),
 813  
 814  /***/ 7:
 815  /***/ (function(module, exports) {
 816  
 817  (function() { module.exports = window["wp"]["primitives"]; }());
 818  
 819  /***/ }),
 820  
 821  /***/ 9:
 822  /***/ (function(module, exports) {
 823  
 824  (function() { module.exports = window["wp"]["blocks"]; }());
 825  
 826  /***/ })
 827  
 828  /******/ });


Generated: Sat Feb 27 01:00:04 2021 Cross-referenced by PHPXref 0.7.1