[ 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 = 463);
  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  /***/ 12:
 105  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 106  
 107  "use strict";
 108  
 109  // EXPORTS
 110  __webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _slicedToArray; });
 111  
 112  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js
 113  var arrayWithHoles = __webpack_require__(38);
 114  
 115  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js
 116  function _iterableToArrayLimit(arr, i) {
 117    var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]);
 118  
 119    if (_i == null) return;
 120    var _arr = [];
 121    var _n = true;
 122    var _d = false;
 123  
 124    var _s, _e;
 125  
 126    try {
 127      for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) {
 128        _arr.push(_s.value);
 129  
 130        if (i && _arr.length === i) break;
 131      }
 132    } catch (err) {
 133      _d = true;
 134      _e = err;
 135    } finally {
 136      try {
 137        if (!_n && _i["return"] != null) _i["return"]();
 138      } finally {
 139        if (_d) throw _e;
 140      }
 141    }
 142  
 143    return _arr;
 144  }
 145  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/unsupportedIterableToArray.js
 146  var unsupportedIterableToArray = __webpack_require__(28);
 147  
 148  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js
 149  var nonIterableRest = __webpack_require__(39);
 150  
 151  // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js
 152  
 153  
 154  
 155  
 156  function _slicedToArray(arr, i) {
 157    return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(unsupportedIterableToArray["a" /* default */])(arr, i) || Object(nonIterableRest["a" /* default */])();
 158  }
 159  
 160  /***/ }),
 161  
 162  /***/ 16:
 163  /***/ (function(module, exports) {
 164  
 165  (function() { module.exports = window["regeneratorRuntime"]; }());
 166  
 167  /***/ }),
 168  
 169  /***/ 2:
 170  /***/ (function(module, exports) {
 171  
 172  (function() { module.exports = window["lodash"]; }());
 173  
 174  /***/ }),
 175  
 176  /***/ 24:
 177  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 178  
 179  "use strict";
 180  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayLikeToArray; });
 181  function _arrayLikeToArray(arr, len) {
 182    if (len == null || len > arr.length) len = arr.length;
 183  
 184    for (var i = 0, arr2 = new Array(len); i < len; i++) {
 185      arr2[i] = arr[i];
 186    }
 187  
 188    return arr2;
 189  }
 190  
 191  /***/ }),
 192  
 193  /***/ 28:
 194  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 195  
 196  "use strict";
 197  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _unsupportedIterableToArray; });
 198  /* harmony import */ var _arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(24);
 199  
 200  function _unsupportedIterableToArray(o, minLen) {
 201    if (!o) return;
 202    if (typeof o === "string") return Object(_arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 203    var n = Object.prototype.toString.call(o).slice(8, -1);
 204    if (n === "Object" && o.constructor) n = o.constructor.name;
 205    if (n === "Map" || n === "Set") return Array.from(o);
 206    if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return Object(_arrayLikeToArray_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(o, minLen);
 207  }
 208  
 209  /***/ }),
 210  
 211  /***/ 29:
 212  /***/ (function(module, exports) {
 213  
 214  (function() { module.exports = window["wp"]["url"]; }());
 215  
 216  /***/ }),
 217  
 218  /***/ 3:
 219  /***/ (function(module, exports) {
 220  
 221  (function() { module.exports = window["wp"]["components"]; }());
 222  
 223  /***/ }),
 224  
 225  /***/ 37:
 226  /***/ (function(module, exports) {
 227  
 228  (function() { module.exports = window["wp"]["coreData"]; }());
 229  
 230  /***/ }),
 231  
 232  /***/ 38:
 233  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 234  
 235  "use strict";
 236  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; });
 237  function _arrayWithHoles(arr) {
 238    if (Array.isArray(arr)) return arr;
 239  }
 240  
 241  /***/ }),
 242  
 243  /***/ 39:
 244  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 245  
 246  "use strict";
 247  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; });
 248  function _nonIterableRest() {
 249    throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
 250  }
 251  
 252  /***/ }),
 253  
 254  /***/ 4:
 255  /***/ (function(module, exports) {
 256  
 257  (function() { module.exports = window["wp"]["data"]; }());
 258  
 259  /***/ }),
 260  
 261  /***/ 463:
 262  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 263  
 264  "use strict";
 265  // ESM COMPAT FLAG
 266  __webpack_require__.r(__webpack_exports__);
 267  
 268  // EXPORTS
 269  __webpack_require__.d(__webpack_exports__, "store", function() { return /* reexport */ store; });
 270  __webpack_require__.d(__webpack_exports__, "ReusableBlocksMenuItems", function() { return /* reexport */ reusable_blocks_menu_items; });
 271  
 272  // NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js
 273  var actions_namespaceObject = {};
 274  __webpack_require__.r(actions_namespaceObject);
 275  __webpack_require__.d(actions_namespaceObject, "__experimentalConvertBlockToStatic", function() { return __experimentalConvertBlockToStatic; });
 276  __webpack_require__.d(actions_namespaceObject, "__experimentalConvertBlocksToReusable", function() { return __experimentalConvertBlocksToReusable; });
 277  __webpack_require__.d(actions_namespaceObject, "__experimentalDeleteReusableBlock", function() { return __experimentalDeleteReusableBlock; });
 278  __webpack_require__.d(actions_namespaceObject, "__experimentalSetEditingReusableBlock", function() { return __experimentalSetEditingReusableBlock; });
 279  
 280  // NAMESPACE OBJECT: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js
 281  var selectors_namespaceObject = {};
 282  __webpack_require__.r(selectors_namespaceObject);
 283  __webpack_require__.d(selectors_namespaceObject, "__experimentalIsEditingReusableBlock", function() { return __experimentalIsEditingReusableBlock; });
 284  
 285  // EXTERNAL MODULE: external ["wp","blockEditor"]
 286  var external_wp_blockEditor_ = __webpack_require__(6);
 287  
 288  // EXTERNAL MODULE: external ["wp","coreData"]
 289  var external_wp_coreData_ = __webpack_require__(37);
 290  
 291  // EXTERNAL MODULE: external ["wp","data"]
 292  var external_wp_data_ = __webpack_require__(4);
 293  
 294  // EXTERNAL MODULE: external "regeneratorRuntime"
 295  var external_regeneratorRuntime_ = __webpack_require__(16);
 296  var external_regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(external_regeneratorRuntime_);
 297  
 298  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
 299  var asyncToGenerator = __webpack_require__(48);
 300  
 301  // EXTERNAL MODULE: external "lodash"
 302  var external_lodash_ = __webpack_require__(2);
 303  
 304  // EXTERNAL MODULE: external ["wp","blocks"]
 305  var external_wp_blocks_ = __webpack_require__(9);
 306  
 307  // EXTERNAL MODULE: external ["wp","i18n"]
 308  var external_wp_i18n_ = __webpack_require__(1);
 309  
 310  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/controls.js
 311  
 312  
 313  
 314  /**
 315   * External dependencies
 316   */
 317  
 318  /**
 319   * WordPress dependencies
 320   */
 321  
 322  
 323  
 324  
 325  /**
 326   * Internal dependencies
 327   */
 328  
 329  
 330  /**
 331   * Convert a reusable block to a static block effect handler
 332   *
 333   * @param {string}  clientId Block ID.
 334   * @return {Object} control descriptor.
 335   */
 336  
 337  function convertBlockToStatic(clientId) {
 338    return {
 339      type: 'CONVERT_BLOCK_TO_STATIC',
 340      clientId: clientId
 341    };
 342  }
 343  /**
 344   * Convert a static block to a reusable block effect handler
 345   *
 346   * @param {Array} clientIds Block IDs.
 347   * @param {string} title    Reusable block title.
 348   * @return {Object} control descriptor.
 349   */
 350  
 351  function controls_convertBlocksToReusable(clientIds, title) {
 352    return {
 353      type: 'CONVERT_BLOCKS_TO_REUSABLE',
 354      clientIds: clientIds,
 355      title: title
 356    };
 357  }
 358  /**
 359   * Deletes a reusable block.
 360   *
 361   * @param {string} id Reusable block ID.
 362   * @return {Object} control descriptor.
 363   */
 364  
 365  function deleteReusableBlock(id) {
 366    return {
 367      type: 'DELETE_REUSABLE_BLOCK',
 368      id: id
 369    };
 370  }
 371  var controls = {
 372    CONVERT_BLOCK_TO_STATIC: Object(external_wp_data_["createRegistryControl"])(function (registry) {
 373      return function (_ref) {
 374        var clientId = _ref.clientId;
 375        var oldBlock = registry.select('core/block-editor').getBlock(clientId);
 376        var reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', oldBlock.attributes.ref);
 377        var newBlocks = Object(external_wp_blocks_["parse"])(Object(external_lodash_["isFunction"])(reusableBlock.content) ? reusableBlock.content(reusableBlock) : reusableBlock.content);
 378        registry.dispatch('core/block-editor').replaceBlocks(oldBlock.clientId, newBlocks);
 379      };
 380    }),
 381    CONVERT_BLOCKS_TO_REUSABLE: Object(external_wp_data_["createRegistryControl"])(function (registry) {
 382      return /*#__PURE__*/function () {
 383        var _ref3 = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee(_ref2) {
 384          var clientIds, title, reusableBlock, updatedRecord, newBlock;
 385          return external_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
 386            while (1) {
 387              switch (_context.prev = _context.next) {
 388                case 0:
 389                  clientIds = _ref2.clientIds, title = _ref2.title;
 390                  reusableBlock = {
 391                    title: title || Object(external_wp_i18n_["__"])('Untitled Reusable block'),
 392                    content: Object(external_wp_blocks_["serialize"])(registry.select('core/block-editor').getBlocksByClientId(clientIds)),
 393                    status: 'publish'
 394                  };
 395                  _context.next = 4;
 396                  return registry.dispatch('core').saveEntityRecord('postType', 'wp_block', reusableBlock);
 397  
 398                case 4:
 399                  updatedRecord = _context.sent;
 400                  newBlock = Object(external_wp_blocks_["createBlock"])('core/block', {
 401                    ref: updatedRecord.id
 402                  });
 403                  registry.dispatch('core/block-editor').replaceBlocks(clientIds, newBlock);
 404  
 405                  registry.dispatch(store).__experimentalSetEditingReusableBlock(newBlock.clientId, true);
 406  
 407                case 8:
 408                case "end":
 409                  return _context.stop();
 410              }
 411            }
 412          }, _callee);
 413        }));
 414  
 415        return function (_x) {
 416          return _ref3.apply(this, arguments);
 417        };
 418      }();
 419    }),
 420    DELETE_REUSABLE_BLOCK: Object(external_wp_data_["createRegistryControl"])(function (registry) {
 421      return /*#__PURE__*/function () {
 422        var _ref5 = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee2(_ref4) {
 423          var id, reusableBlock, allBlocks, associatedBlocks, associatedBlockClientIds;
 424          return external_regeneratorRuntime_default.a.wrap(function _callee2$(_context2) {
 425            while (1) {
 426              switch (_context2.prev = _context2.next) {
 427                case 0:
 428                  id = _ref4.id;
 429                  reusableBlock = registry.select('core').getEditedEntityRecord('postType', 'wp_block', id); // Don't allow a reusable block with a temporary ID to be deleted
 430  
 431                  if (reusableBlock) {
 432                    _context2.next = 4;
 433                    break;
 434                  }
 435  
 436                  return _context2.abrupt("return");
 437  
 438                case 4:
 439                  // Remove any other blocks that reference this reusable block
 440                  allBlocks = registry.select('core/block-editor').getBlocks();
 441                  associatedBlocks = allBlocks.filter(function (block) {
 442                    return Object(external_wp_blocks_["isReusableBlock"])(block) && block.attributes.ref === id;
 443                  });
 444                  associatedBlockClientIds = associatedBlocks.map(function (block) {
 445                    return block.clientId;
 446                  }); // Remove the parsed block.
 447  
 448                  if (associatedBlockClientIds.length) {
 449                    registry.dispatch('core/block-editor').removeBlocks(associatedBlockClientIds);
 450                  }
 451  
 452                  _context2.next = 10;
 453                  return registry.dispatch('core').deleteEntityRecord('postType', 'wp_block', id);
 454  
 455                case 10:
 456                case "end":
 457                  return _context2.stop();
 458              }
 459            }
 460          }, _callee2);
 461        }));
 462  
 463        return function (_x2) {
 464          return _ref5.apply(this, arguments);
 465        };
 466      }();
 467    })
 468  };
 469  /* harmony default export */ var store_controls = (controls);
 470  
 471  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/actions.js
 472  
 473  
 474  var _marked = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(__experimentalConvertBlockToStatic),
 475      _marked2 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(__experimentalConvertBlocksToReusable),
 476      _marked3 = /*#__PURE__*/external_regeneratorRuntime_default.a.mark(__experimentalDeleteReusableBlock);
 477  
 478  /**
 479   * Internal dependencies
 480   */
 481  
 482  /**
 483   * Returns a generator converting a reusable block into a static block.
 484   *
 485   * @param {string} clientId The client ID of the block to attach.
 486   */
 487  
 488  function __experimentalConvertBlockToStatic(clientId) {
 489    return external_regeneratorRuntime_default.a.wrap(function __experimentalConvertBlockToStatic$(_context) {
 490      while (1) {
 491        switch (_context.prev = _context.next) {
 492          case 0:
 493            _context.next = 2;
 494            return convertBlockToStatic(clientId);
 495  
 496          case 2:
 497          case "end":
 498            return _context.stop();
 499        }
 500      }
 501    }, _marked);
 502  }
 503  /**
 504   * Returns a generator converting one or more static blocks into a reusable block.
 505   *
 506   * @param {string[]} clientIds The client IDs of the block to detach.
 507   * @param {string}   title     Reusable block title.
 508   */
 509  
 510  function __experimentalConvertBlocksToReusable(clientIds, title) {
 511    return external_regeneratorRuntime_default.a.wrap(function __experimentalConvertBlocksToReusable$(_context2) {
 512      while (1) {
 513        switch (_context2.prev = _context2.next) {
 514          case 0:
 515            _context2.next = 2;
 516            return controls_convertBlocksToReusable(clientIds, title);
 517  
 518          case 2:
 519          case "end":
 520            return _context2.stop();
 521        }
 522      }
 523    }, _marked2);
 524  }
 525  /**
 526   * Returns a generator deleting a reusable block.
 527   *
 528   * @param {string} id The ID of the reusable block to delete.
 529   */
 530  
 531  function __experimentalDeleteReusableBlock(id) {
 532    return external_regeneratorRuntime_default.a.wrap(function __experimentalDeleteReusableBlock$(_context3) {
 533      while (1) {
 534        switch (_context3.prev = _context3.next) {
 535          case 0:
 536            _context3.next = 2;
 537            return deleteReusableBlock(id);
 538  
 539          case 2:
 540          case "end":
 541            return _context3.stop();
 542        }
 543      }
 544    }, _marked3);
 545  }
 546  /**
 547   * Returns an action descriptor for SET_EDITING_REUSABLE_BLOCK action.
 548   *
 549   * @param {string} clientId The clientID of the reusable block to target.
 550   * @param {boolean} isEditing Whether the block should be in editing state.
 551   * @return {Object} Action descriptor.
 552   */
 553  
 554  function __experimentalSetEditingReusableBlock(clientId, isEditing) {
 555    return {
 556      type: 'SET_EDITING_REUSABLE_BLOCK',
 557      clientId: clientId,
 558      isEditing: isEditing
 559    };
 560  }
 561  
 562  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js
 563  var defineProperty = __webpack_require__(5);
 564  
 565  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/reducer.js
 566  
 567  
 568  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; }
 569  
 570  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; }
 571  
 572  /**
 573   * WordPress dependencies
 574   */
 575  
 576  function isEditingReusableBlock() {
 577    var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
 578    var action = arguments.length > 1 ? arguments[1] : undefined;
 579  
 580    if ((action === null || action === void 0 ? void 0 : action.type) === 'SET_EDITING_REUSABLE_BLOCK') {
 581      return _objectSpread(_objectSpread({}, state), {}, Object(defineProperty["a" /* default */])({}, action.clientId, action.isEditing));
 582    }
 583  
 584    return state;
 585  }
 586  /* harmony default export */ var reducer = (Object(external_wp_data_["combineReducers"])({
 587    isEditingReusableBlock: isEditingReusableBlock
 588  }));
 589  
 590  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/selectors.js
 591  /**
 592   * Returns true if reusable block is in the editing state.
 593   *
 594   * @param {Object} state Global application state.
 595   * @param {number} clientId the clientID of the block.
 596   * @return {boolean} Whether the reusable block is in the editing state.
 597   */
 598  function __experimentalIsEditingReusableBlock(state, clientId) {
 599    return state.isEditingReusableBlock[clientId];
 600  }
 601  
 602  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/store/index.js
 603  /**
 604   * WordPress dependencies
 605   */
 606  
 607  /**
 608   * Internal dependencies
 609   */
 610  
 611  
 612  
 613  
 614  
 615  var STORE_NAME = 'core/reusable-blocks';
 616  /**
 617   * Store definition for the reusable blocks namespace.
 618   *
 619   * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
 620   *
 621   * @type {Object}
 622   */
 623  
 624  var store = Object(external_wp_data_["createReduxStore"])(STORE_NAME, {
 625    actions: actions_namespaceObject,
 626    controls: store_controls,
 627    reducer: reducer,
 628    selectors: selectors_namespaceObject
 629  });
 630  Object(external_wp_data_["register"])(store);
 631  
 632  // EXTERNAL MODULE: external ["wp","element"]
 633  var external_wp_element_ = __webpack_require__(0);
 634  
 635  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules
 636  var slicedToArray = __webpack_require__(12);
 637  
 638  // EXTERNAL MODULE: external ["wp","components"]
 639  var external_wp_components_ = __webpack_require__(3);
 640  
 641  // EXTERNAL MODULE: external ["wp","primitives"]
 642  var external_wp_primitives_ = __webpack_require__(7);
 643  
 644  // CONCATENATED MODULE: ./node_modules/@wordpress/icons/build-module/library/reusable-block.js
 645  
 646  
 647  /**
 648   * WordPress dependencies
 649   */
 650  
 651  var reusable_block_reusableBlock = Object(external_wp_element_["createElement"])(external_wp_primitives_["SVG"], {
 652    xmlns: "http://www.w3.org/2000/svg",
 653    viewBox: "0 0 24 24"
 654  }, Object(external_wp_element_["createElement"])(external_wp_primitives_["Path"], {
 655    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"
 656  }));
 657  /* harmony default export */ var reusable_block = (reusable_block_reusableBlock);
 658  
 659  // EXTERNAL MODULE: external ["wp","notices"]
 660  var external_wp_notices_ = __webpack_require__(51);
 661  
 662  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-block-convert-button.js
 663  
 664  
 665  
 666  
 667  
 668  /**
 669   * WordPress dependencies
 670   */
 671  
 672  
 673  
 674  
 675  
 676  
 677  
 678  
 679  /**
 680   * Internal dependencies
 681   */
 682  
 683  
 684  /**
 685   * Menu control to convert block(s) to reusable block.
 686   *
 687   * @param {Object}   props              Component props.
 688   * @param {string[]} props.clientIds    Client ids of selected blocks.
 689   * @param {string}   props.rootClientId ID of the currently selected top-level block.
 690   * @return {import('@wordpress/element').WPComponent} The menu control or null.
 691   */
 692  
 693  function ReusableBlockConvertButton(_ref) {
 694    var clientIds = _ref.clientIds,
 695        rootClientId = _ref.rootClientId;
 696  
 697    var _useState = Object(external_wp_element_["useState"])(false),
 698        _useState2 = Object(slicedToArray["a" /* default */])(_useState, 2),
 699        isModalOpen = _useState2[0],
 700        setIsModalOpen = _useState2[1];
 701  
 702    var _useState3 = Object(external_wp_element_["useState"])(''),
 703        _useState4 = Object(slicedToArray["a" /* default */])(_useState3, 2),
 704        title = _useState4[0],
 705        setTitle = _useState4[1];
 706  
 707    var canConvert = Object(external_wp_data_["useSelect"])(function (select) {
 708      var _getBlocksByClientId;
 709  
 710      var _select = select('core'),
 711          canUser = _select.canUser;
 712  
 713      var _select2 = select('core/block-editor'),
 714          getBlocksByClientId = _select2.getBlocksByClientId,
 715          canInsertBlockType = _select2.canInsertBlockType;
 716  
 717      var blocks = (_getBlocksByClientId = getBlocksByClientId(clientIds)) !== null && _getBlocksByClientId !== void 0 ? _getBlocksByClientId : [];
 718      var isReusable = blocks.length === 1 && blocks[0] && Object(external_wp_blocks_["isReusableBlock"])(blocks[0]) && !!select('core').getEntityRecord('postType', 'wp_block', blocks[0].attributes.ref);
 719  
 720      var _canConvert = // Hide when this is already a reusable block.
 721      !isReusable && // Hide when reusable blocks are disabled.
 722      canInsertBlockType('core/block', rootClientId) && blocks.every(function (block) {
 723        return (// Guard against the case where a regular block has *just* been converted.
 724          !!block && // Hide on invalid blocks.
 725          block.isValid && // Hide when block doesn't support being made reusable.
 726          Object(external_wp_blocks_["hasBlockSupport"])(block.name, 'reusable', true)
 727        );
 728      }) && // Hide when current doesn't have permission to do that.
 729      !!canUser('create', 'blocks');
 730  
 731      return _canConvert;
 732    }, [clientIds]);
 733  
 734    var _useDispatch = Object(external_wp_data_["useDispatch"])(store),
 735        convertBlocksToReusable = _useDispatch.__experimentalConvertBlocksToReusable;
 736  
 737    var _useDispatch2 = Object(external_wp_data_["useDispatch"])(external_wp_notices_["store"]),
 738        createSuccessNotice = _useDispatch2.createSuccessNotice,
 739        createErrorNotice = _useDispatch2.createErrorNotice;
 740  
 741    var onConvert = Object(external_wp_element_["useCallback"])( /*#__PURE__*/function () {
 742      var _ref2 = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee(reusableBlockTitle) {
 743        return external_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
 744          while (1) {
 745            switch (_context.prev = _context.next) {
 746              case 0:
 747                _context.prev = 0;
 748                _context.next = 3;
 749                return convertBlocksToReusable(clientIds, reusableBlockTitle);
 750  
 751              case 3:
 752                createSuccessNotice(Object(external_wp_i18n_["__"])('Reusable block created.'), {
 753                  type: 'snackbar'
 754                });
 755                _context.next = 9;
 756                break;
 757  
 758              case 6:
 759                _context.prev = 6;
 760                _context.t0 = _context["catch"](0);
 761                createErrorNotice(_context.t0.message, {
 762                  type: 'snackbar'
 763                });
 764  
 765              case 9:
 766              case "end":
 767                return _context.stop();
 768            }
 769          }
 770        }, _callee, null, [[0, 6]]);
 771      }));
 772  
 773      return function (_x) {
 774        return _ref2.apply(this, arguments);
 775      };
 776    }(), [clientIds]);
 777  
 778    if (!canConvert) {
 779      return null;
 780    }
 781  
 782    return Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockSettingsMenuControls"], null, function (_ref3) {
 783      var onClose = _ref3.onClose;
 784      return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
 785        icon: reusable_block,
 786        onClick: function onClick() {
 787          setIsModalOpen(true);
 788        }
 789      }, Object(external_wp_i18n_["__"])('Add to Reusable blocks')), isModalOpen && Object(external_wp_element_["createElement"])(external_wp_components_["Modal"], {
 790        title: Object(external_wp_i18n_["__"])('Create Reusable block'),
 791        closeLabel: Object(external_wp_i18n_["__"])('Close'),
 792        onRequestClose: function onRequestClose() {
 793          setIsModalOpen(false);
 794          setTitle('');
 795        },
 796        overlayClassName: "reusable-blocks-menu-items__convert-modal"
 797      }, Object(external_wp_element_["createElement"])("form", {
 798        onSubmit: function onSubmit(event) {
 799          event.preventDefault();
 800          onConvert(title);
 801          setIsModalOpen(false);
 802          setTitle('');
 803          onClose();
 804        }
 805      }, Object(external_wp_element_["createElement"])(external_wp_components_["TextControl"], {
 806        label: Object(external_wp_i18n_["__"])('Name'),
 807        value: title,
 808        onChange: setTitle
 809      }), Object(external_wp_element_["createElement"])(external_wp_components_["Flex"], {
 810        className: "reusable-blocks-menu-items__convert-modal-actions",
 811        justify: "flex-end"
 812      }, Object(external_wp_element_["createElement"])(external_wp_components_["FlexItem"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
 813        isSecondary: true,
 814        onClick: function onClick() {
 815          setIsModalOpen(false);
 816          setTitle('');
 817        }
 818      }, Object(external_wp_i18n_["__"])('Cancel'))), Object(external_wp_element_["createElement"])(external_wp_components_["FlexItem"], null, Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
 819        isPrimary: true,
 820        type: "submit"
 821      }, Object(external_wp_i18n_["__"])('Save')))))));
 822    });
 823  }
 824  
 825  // EXTERNAL MODULE: external ["wp","url"]
 826  var external_wp_url_ = __webpack_require__(29);
 827  
 828  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/reusable-blocks-manage-button.js
 829  
 830  
 831  /**
 832   * WordPress dependencies
 833   */
 834  
 835  
 836  
 837  
 838  
 839  
 840  
 841  function ReusableBlocksManageButton(_ref) {
 842    var clientId = _ref.clientId;
 843  
 844    var _useSelect = Object(external_wp_data_["useSelect"])(function (select) {
 845      var _select = select('core/block-editor'),
 846          getBlock = _select.getBlock;
 847  
 848      var _select2 = select('core'),
 849          canUser = _select2.canUser;
 850  
 851      var reusableBlock = getBlock(clientId);
 852      return {
 853        isVisible: !!reusableBlock && Object(external_wp_blocks_["isReusableBlock"])(reusableBlock) && !!canUser('update', 'blocks', reusableBlock.attributes.ref)
 854      };
 855    }, [clientId]),
 856        isVisible = _useSelect.isVisible;
 857  
 858    if (!isVisible) {
 859      return null;
 860    }
 861  
 862    return Object(external_wp_element_["createElement"])(external_wp_blockEditor_["BlockSettingsMenuControls"], null, Object(external_wp_element_["createElement"])(external_wp_components_["MenuItem"], {
 863      href: Object(external_wp_url_["addQueryArgs"])('edit.php', {
 864        post_type: 'wp_block'
 865      })
 866    }, Object(external_wp_i18n_["__"])('Manage Reusable blocks')));
 867  }
 868  
 869  /* harmony default export */ var reusable_blocks_manage_button = (ReusableBlocksManageButton);
 870  
 871  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/reusable-blocks-menu-items/index.js
 872  
 873  
 874  /**
 875   * WordPress dependencies
 876   */
 877  
 878  /**
 879   * Internal dependencies
 880   */
 881  
 882  
 883  
 884  
 885  function ReusableBlocksMenuItems(_ref) {
 886    var clientIds = _ref.clientIds,
 887        rootClientId = _ref.rootClientId;
 888    return Object(external_wp_element_["createElement"])(external_wp_element_["Fragment"], null, Object(external_wp_element_["createElement"])(ReusableBlockConvertButton, {
 889      clientIds: clientIds,
 890      rootClientId: rootClientId
 891    }), clientIds.length === 1 && Object(external_wp_element_["createElement"])(reusable_blocks_manage_button, {
 892      clientId: clientIds[0]
 893    }));
 894  }
 895  
 896  /* harmony default export */ var reusable_blocks_menu_items = (Object(external_wp_data_["withSelect"])(function (select) {
 897    var _select = select('core/block-editor'),
 898        getSelectedBlockClientIds = _select.getSelectedBlockClientIds;
 899  
 900    return {
 901      clientIds: getSelectedBlockClientIds()
 902    };
 903  })(ReusableBlocksMenuItems));
 904  
 905  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/components/index.js
 906  
 907  
 908  // CONCATENATED MODULE: ./node_modules/@wordpress/reusable-blocks/build-module/index.js
 909  /**
 910   * WordPress dependencies
 911   */
 912  
 913  
 914  
 915  
 916  
 917  
 918  /***/ }),
 919  
 920  /***/ 48:
 921  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 922  
 923  "use strict";
 924  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; });
 925  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
 926    try {
 927      var info = gen[key](arg);
 928      var value = info.value;
 929    } catch (error) {
 930      reject(error);
 931      return;
 932    }
 933  
 934    if (info.done) {
 935      resolve(value);
 936    } else {
 937      Promise.resolve(value).then(_next, _throw);
 938    }
 939  }
 940  
 941  function _asyncToGenerator(fn) {
 942    return function () {
 943      var self = this,
 944          args = arguments;
 945      return new Promise(function (resolve, reject) {
 946        var gen = fn.apply(self, args);
 947  
 948        function _next(value) {
 949          asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
 950        }
 951  
 952        function _throw(err) {
 953          asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
 954        }
 955  
 956        _next(undefined);
 957      });
 958    };
 959  }
 960  
 961  /***/ }),
 962  
 963  /***/ 5:
 964  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 965  
 966  "use strict";
 967  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; });
 968  function _defineProperty(obj, key, value) {
 969    if (key in obj) {
 970      Object.defineProperty(obj, key, {
 971        value: value,
 972        enumerable: true,
 973        configurable: true,
 974        writable: true
 975      });
 976    } else {
 977      obj[key] = value;
 978    }
 979  
 980    return obj;
 981  }
 982  
 983  /***/ }),
 984  
 985  /***/ 51:
 986  /***/ (function(module, exports) {
 987  
 988  (function() { module.exports = window["wp"]["notices"]; }());
 989  
 990  /***/ }),
 991  
 992  /***/ 6:
 993  /***/ (function(module, exports) {
 994  
 995  (function() { module.exports = window["wp"]["blockEditor"]; }());
 996  
 997  /***/ }),
 998  
 999  /***/ 7:
1000  /***/ (function(module, exports) {
1001  
1002  (function() { module.exports = window["wp"]["primitives"]; }());
1003  
1004  /***/ }),
1005  
1006  /***/ 9:
1007  /***/ (function(module, exports) {
1008  
1009  (function() { module.exports = window["wp"]["blocks"]; }());
1010  
1011  /***/ })
1012  
1013  /******/ });


Generated: Sat May 15 01:00:05 2021 Cross-referenced by PHPXref 0.7.1