[ Index ]

PHP Cross Reference of WordPress

title

Body

[close]

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

   1  this["wp"] = this["wp"] || {}; this["wp"]["listReusableBlocks"] =
   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 = 472);
  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  /***/ 11:
 105  /***/ (function(module, exports) {
 106  
 107  (function() { module.exports = window["wp"]["compose"]; }());
 108  
 109  /***/ }),
 110  
 111  /***/ 16:
 112  /***/ (function(module, exports) {
 113  
 114  (function() { module.exports = window["regeneratorRuntime"]; }());
 115  
 116  /***/ }),
 117  
 118  /***/ 18:
 119  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 120  
 121  "use strict";
 122  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; });
 123  function _assertThisInitialized(self) {
 124    if (self === void 0) {
 125      throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
 126    }
 127  
 128    return self;
 129  }
 130  
 131  /***/ }),
 132  
 133  /***/ 2:
 134  /***/ (function(module, exports) {
 135  
 136  (function() { module.exports = window["lodash"]; }());
 137  
 138  /***/ }),
 139  
 140  /***/ 22:
 141  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 142  
 143  "use strict";
 144  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; });
 145  function _getPrototypeOf(o) {
 146    _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
 147      return o.__proto__ || Object.getPrototypeOf(o);
 148    };
 149    return _getPrototypeOf(o);
 150  }
 151  
 152  /***/ }),
 153  
 154  /***/ 25:
 155  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 156  
 157  "use strict";
 158  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; });
 159  function _classCallCheck(instance, Constructor) {
 160    if (!(instance instanceof Constructor)) {
 161      throw new TypeError("Cannot call a class as a function");
 162    }
 163  }
 164  
 165  /***/ }),
 166  
 167  /***/ 26:
 168  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 169  
 170  "use strict";
 171  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; });
 172  function _defineProperties(target, props) {
 173    for (var i = 0; i < props.length; i++) {
 174      var descriptor = props[i];
 175      descriptor.enumerable = descriptor.enumerable || false;
 176      descriptor.configurable = true;
 177      if ("value" in descriptor) descriptor.writable = true;
 178      Object.defineProperty(target, descriptor.key, descriptor);
 179    }
 180  }
 181  
 182  function _createClass(Constructor, protoProps, staticProps) {
 183    if (protoProps) _defineProperties(Constructor.prototype, protoProps);
 184    if (staticProps) _defineProperties(Constructor, staticProps);
 185    return Constructor;
 186  }
 187  
 188  /***/ }),
 189  
 190  /***/ 3:
 191  /***/ (function(module, exports) {
 192  
 193  (function() { module.exports = window["wp"]["components"]; }());
 194  
 195  /***/ }),
 196  
 197  /***/ 33:
 198  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 199  
 200  "use strict";
 201  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _inherits; });
 202  /* harmony import */ var _setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(55);
 203  
 204  function _inherits(subClass, superClass) {
 205    if (typeof superClass !== "function" && superClass !== null) {
 206      throw new TypeError("Super expression must either be null or a function");
 207    }
 208  
 209    subClass.prototype = Object.create(superClass && superClass.prototype, {
 210      constructor: {
 211        value: subClass,
 212        writable: true,
 213        configurable: true
 214      }
 215    });
 216    if (superClass) Object(_setPrototypeOf_js__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(subClass, superClass);
 217  }
 218  
 219  /***/ }),
 220  
 221  /***/ 34:
 222  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 223  
 224  "use strict";
 225  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; });
 226  /* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(59);
 227  /* harmony import */ var _babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0__);
 228  /* harmony import */ var _assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(18);
 229  
 230  
 231  function _possibleConstructorReturn(self, call) {
 232    if (call && (_babel_runtime_helpers_typeof__WEBPACK_IMPORTED_MODULE_0___default()(call) === "object" || typeof call === "function")) {
 233      return call;
 234    }
 235  
 236    return Object(_assertThisInitialized_js__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self);
 237  }
 238  
 239  /***/ }),
 240  
 241  /***/ 472:
 242  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 243  
 244  "use strict";
 245  // ESM COMPAT FLAG
 246  __webpack_require__.r(__webpack_exports__);
 247  
 248  // EXTERNAL MODULE: external ["wp","element"]
 249  var external_wp_element_ = __webpack_require__(0);
 250  
 251  // EXTERNAL MODULE: external ["wp","i18n"]
 252  var external_wp_i18n_ = __webpack_require__(1);
 253  
 254  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
 255  var asyncToGenerator = __webpack_require__(48);
 256  
 257  // EXTERNAL MODULE: external "regeneratorRuntime"
 258  var external_regeneratorRuntime_ = __webpack_require__(16);
 259  var external_regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(external_regeneratorRuntime_);
 260  
 261  // EXTERNAL MODULE: external "lodash"
 262  var external_lodash_ = __webpack_require__(2);
 263  
 264  // EXTERNAL MODULE: external ["wp","apiFetch"]
 265  var external_wp_apiFetch_ = __webpack_require__(50);
 266  var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_);
 267  
 268  // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/file.js
 269  /**
 270   * Downloads a file.
 271   *
 272   * @param {string} fileName    File Name.
 273   * @param {string} content     File Content.
 274   * @param {string} contentType File mime type.
 275   */
 276  function download(fileName, content, contentType) {
 277    var file = new window.Blob([content], {
 278      type: contentType
 279    }); // IE11 can't use the click to download technique
 280    // we use a specific IE11 technique instead.
 281  
 282    if (window.navigator.msSaveOrOpenBlob) {
 283      window.navigator.msSaveOrOpenBlob(file, fileName);
 284    } else {
 285      var a = document.createElement('a');
 286      a.href = URL.createObjectURL(file);
 287      a.download = fileName;
 288      a.style.display = 'none';
 289      document.body.appendChild(a);
 290      a.click();
 291      document.body.removeChild(a);
 292    }
 293  }
 294  /**
 295   * Reads the textual content of the given file.
 296   *
 297   * @param  {File} file        File.
 298   * @return {Promise<string>}  Content of the file.
 299   */
 300  
 301  function readTextFile(file) {
 302    var reader = new window.FileReader();
 303    return new Promise(function (resolve) {
 304      reader.onload = function () {
 305        resolve(reader.result);
 306      };
 307  
 308      reader.readAsText(file);
 309    });
 310  }
 311  
 312  // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/export.js
 313  
 314  
 315  
 316  /**
 317   * External dependencies
 318   */
 319  
 320  /**
 321   * WordPress dependencies
 322   */
 323  
 324  
 325  /**
 326   * Internal dependencies
 327   */
 328  
 329  
 330  /**
 331   * Export a reusable block as a JSON file.
 332   *
 333   * @param {number} id
 334   */
 335  
 336  function exportReusableBlock(_x) {
 337    return _exportReusableBlock.apply(this, arguments);
 338  }
 339  
 340  function _exportReusableBlock() {
 341    _exportReusableBlock = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee(id) {
 342      var postType, post, title, content, fileContent, fileName;
 343      return external_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
 344        while (1) {
 345          switch (_context.prev = _context.next) {
 346            case 0:
 347              _context.next = 2;
 348              return external_wp_apiFetch_default()({
 349                path: "/wp/v2/types/wp_block"
 350              });
 351  
 352            case 2:
 353              postType = _context.sent;
 354              _context.next = 5;
 355              return external_wp_apiFetch_default()({
 356                path: "/wp/v2/".concat(postType.rest_base, "/").concat(id, "?context=edit")
 357              });
 358  
 359            case 5:
 360              post = _context.sent;
 361              title = post.title.raw;
 362              content = post.content.raw;
 363              fileContent = JSON.stringify({
 364                __file: 'wp_block',
 365                title: title,
 366                content: content
 367              }, null, 2);
 368              fileName = Object(external_lodash_["kebabCase"])(title) + '.json';
 369              download(fileName, fileContent, 'application/json');
 370  
 371            case 11:
 372            case "end":
 373              return _context.stop();
 374          }
 375        }
 376      }, _callee);
 377    }));
 378    return _exportReusableBlock.apply(this, arguments);
 379  }
 380  
 381  /* harmony default export */ var utils_export = (exportReusableBlock);
 382  
 383  // EXTERNAL MODULE: external ["wp","components"]
 384  var external_wp_components_ = __webpack_require__(3);
 385  
 386  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
 387  var classCallCheck = __webpack_require__(25);
 388  
 389  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js
 390  var createClass = __webpack_require__(26);
 391  
 392  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
 393  var assertThisInitialized = __webpack_require__(18);
 394  
 395  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js
 396  var inherits = __webpack_require__(33);
 397  
 398  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
 399  var possibleConstructorReturn = __webpack_require__(34);
 400  
 401  // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
 402  var getPrototypeOf = __webpack_require__(22);
 403  
 404  // EXTERNAL MODULE: external ["wp","compose"]
 405  var external_wp_compose_ = __webpack_require__(11);
 406  
 407  // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/import.js
 408  
 409  
 410  
 411  /**
 412   * External dependencies
 413   */
 414  
 415  /**
 416   * WordPress dependencies
 417   */
 418  
 419  
 420  /**
 421   * Internal dependencies
 422   */
 423  
 424  
 425  /**
 426   * Import a reusable block from a JSON file.
 427   *
 428   * @param {File}     file File.
 429   * @return {Promise} Promise returning the imported reusable block.
 430   */
 431  
 432  function importReusableBlock(_x) {
 433    return _importReusableBlock.apply(this, arguments);
 434  }
 435  
 436  function _importReusableBlock() {
 437    _importReusableBlock = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_regeneratorRuntime_default.a.mark(function _callee(file) {
 438      var fileContent, parsedContent, postType, reusableBlock;
 439      return external_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
 440        while (1) {
 441          switch (_context.prev = _context.next) {
 442            case 0:
 443              _context.next = 2;
 444              return readTextFile(file);
 445  
 446            case 2:
 447              fileContent = _context.sent;
 448              _context.prev = 3;
 449              parsedContent = JSON.parse(fileContent);
 450              _context.next = 10;
 451              break;
 452  
 453            case 7:
 454              _context.prev = 7;
 455              _context.t0 = _context["catch"](3);
 456              throw new Error('Invalid JSON file');
 457  
 458            case 10:
 459              if (!(parsedContent.__file !== 'wp_block' || !parsedContent.title || !parsedContent.content || !Object(external_lodash_["isString"])(parsedContent.title) || !Object(external_lodash_["isString"])(parsedContent.content))) {
 460                _context.next = 12;
 461                break;
 462              }
 463  
 464              throw new Error('Invalid Reusable block JSON file');
 465  
 466            case 12:
 467              _context.next = 14;
 468              return external_wp_apiFetch_default()({
 469                path: "/wp/v2/types/wp_block"
 470              });
 471  
 472            case 14:
 473              postType = _context.sent;
 474              _context.next = 17;
 475              return external_wp_apiFetch_default()({
 476                path: "/wp/v2/".concat(postType.rest_base),
 477                data: {
 478                  title: parsedContent.title,
 479                  content: parsedContent.content,
 480                  status: 'publish'
 481                },
 482                method: 'POST'
 483              });
 484  
 485            case 17:
 486              reusableBlock = _context.sent;
 487              return _context.abrupt("return", reusableBlock);
 488  
 489            case 19:
 490            case "end":
 491              return _context.stop();
 492          }
 493        }
 494      }, _callee, null, [[3, 7]]);
 495    }));
 496    return _importReusableBlock.apply(this, arguments);
 497  }
 498  
 499  /* harmony default export */ var utils_import = (importReusableBlock);
 500  
 501  // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-form/index.js
 502  
 503  
 504  
 505  
 506  
 507  
 508  
 509  
 510  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = Object(getPrototypeOf["a" /* default */])(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = Object(getPrototypeOf["a" /* default */])(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return Object(possibleConstructorReturn["a" /* default */])(this, result); }; }
 511  
 512  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
 513  
 514  /**
 515   * WordPress dependencies
 516   */
 517  
 518  
 519  
 520  
 521  /**
 522   * Internal dependencies
 523   */
 524  
 525  
 526  
 527  var import_form_ImportForm = /*#__PURE__*/function (_Component) {
 528    Object(inherits["a" /* default */])(ImportForm, _Component);
 529  
 530    var _super = _createSuper(ImportForm);
 531  
 532    function ImportForm() {
 533      var _this;
 534  
 535      Object(classCallCheck["a" /* default */])(this, ImportForm);
 536  
 537      _this = _super.apply(this, arguments);
 538      _this.state = {
 539        isLoading: false,
 540        error: null,
 541        file: null
 542      };
 543      _this.isStillMounted = true;
 544      _this.onChangeFile = _this.onChangeFile.bind(Object(assertThisInitialized["a" /* default */])(_this));
 545      _this.onSubmit = _this.onSubmit.bind(Object(assertThisInitialized["a" /* default */])(_this));
 546      return _this;
 547    }
 548  
 549    Object(createClass["a" /* default */])(ImportForm, [{
 550      key: "componentWillUnmount",
 551      value: function componentWillUnmount() {
 552        this.isStillMounted = false;
 553      }
 554    }, {
 555      key: "onChangeFile",
 556      value: function onChangeFile(event) {
 557        this.setState({
 558          file: event.target.files[0],
 559          error: null
 560        });
 561      }
 562    }, {
 563      key: "onSubmit",
 564      value: function onSubmit(event) {
 565        var _this2 = this;
 566  
 567        event.preventDefault();
 568        var file = this.state.file;
 569        var onUpload = this.props.onUpload;
 570  
 571        if (!file) {
 572          return;
 573        }
 574  
 575        this.setState({
 576          isLoading: true
 577        });
 578        utils_import(file).then(function (reusableBlock) {
 579          if (!_this2.isStillMounted) {
 580            return;
 581          }
 582  
 583          _this2.setState({
 584            isLoading: false
 585          });
 586  
 587          onUpload(reusableBlock);
 588        }).catch(function (error) {
 589          if (!_this2.isStillMounted) {
 590            return;
 591          }
 592  
 593          var uiMessage;
 594  
 595          switch (error.message) {
 596            case 'Invalid JSON file':
 597              uiMessage = Object(external_wp_i18n_["__"])('Invalid JSON file');
 598              break;
 599  
 600            case 'Invalid Reusable block JSON file':
 601              uiMessage = Object(external_wp_i18n_["__"])('Invalid Reusable block JSON file');
 602              break;
 603  
 604            default:
 605              uiMessage = Object(external_wp_i18n_["__"])('Unknown error');
 606          }
 607  
 608          _this2.setState({
 609            isLoading: false,
 610            error: uiMessage
 611          });
 612        });
 613      }
 614    }, {
 615      key: "onDismissError",
 616      value: function onDismissError() {
 617        this.setState({
 618          error: null
 619        });
 620      }
 621    }, {
 622      key: "render",
 623      value: function render() {
 624        var _this3 = this;
 625  
 626        var instanceId = this.props.instanceId;
 627        var _this$state = this.state,
 628            file = _this$state.file,
 629            isLoading = _this$state.isLoading,
 630            error = _this$state.error;
 631        var inputId = 'list-reusable-blocks-import-form-' + instanceId;
 632        return Object(external_wp_element_["createElement"])("form", {
 633          className: "list-reusable-blocks-import-form",
 634          onSubmit: this.onSubmit
 635        }, error && Object(external_wp_element_["createElement"])(external_wp_components_["Notice"], {
 636          status: "error",
 637          onRemove: function onRemove() {
 638            return _this3.onDismissError();
 639          }
 640        }, error), Object(external_wp_element_["createElement"])("label", {
 641          htmlFor: inputId,
 642          className: "list-reusable-blocks-import-form__label"
 643        }, Object(external_wp_i18n_["__"])('File')), Object(external_wp_element_["createElement"])("input", {
 644          id: inputId,
 645          type: "file",
 646          onChange: this.onChangeFile
 647        }), Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
 648          type: "submit",
 649          isBusy: isLoading,
 650          disabled: !file || isLoading,
 651          isSecondary: true,
 652          className: "list-reusable-blocks-import-form__button"
 653        }, Object(external_wp_i18n_["_x"])('Import', 'button label')));
 654      }
 655    }]);
 656  
 657    return ImportForm;
 658  }(external_wp_element_["Component"]);
 659  
 660  /* harmony default export */ var import_form = (Object(external_wp_compose_["withInstanceId"])(import_form_ImportForm));
 661  
 662  // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-dropdown/index.js
 663  
 664  
 665  /**
 666   * External dependencies
 667   */
 668  
 669  /**
 670   * WordPress dependencies
 671   */
 672  
 673  
 674  
 675  /**
 676   * Internal dependencies
 677   */
 678  
 679  
 680  
 681  function ImportDropdown(_ref) {
 682    var onUpload = _ref.onUpload;
 683    return Object(external_wp_element_["createElement"])(external_wp_components_["Dropdown"], {
 684      position: "bottom right",
 685      contentClassName: "list-reusable-blocks-import-dropdown__content",
 686      renderToggle: function renderToggle(_ref2) {
 687        var isOpen = _ref2.isOpen,
 688            onToggle = _ref2.onToggle;
 689        return Object(external_wp_element_["createElement"])(external_wp_components_["Button"], {
 690          "aria-expanded": isOpen,
 691          onClick: onToggle,
 692          isPrimary: true
 693        }, Object(external_wp_i18n_["__"])('Import from JSON'));
 694      },
 695      renderContent: function renderContent(_ref3) {
 696        var onClose = _ref3.onClose;
 697        return Object(external_wp_element_["createElement"])(import_form, {
 698          onUpload: Object(external_lodash_["flow"])(onClose, onUpload)
 699        });
 700      }
 701    });
 702  }
 703  
 704  /* harmony default export */ var import_dropdown = (ImportDropdown);
 705  
 706  // CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/index.js
 707  
 708  
 709  /**
 710   * WordPress dependencies
 711   */
 712  
 713  
 714  /**
 715   * Internal dependencies
 716   */
 717  
 718  
 719   // Setup Export Links
 720  
 721  document.body.addEventListener('click', function (event) {
 722    if (!event.target.classList.contains('wp-list-reusable-blocks__export')) {
 723      return;
 724    }
 725  
 726    event.preventDefault();
 727    utils_export(event.target.dataset.id);
 728  }); // Setup Import Form
 729  
 730  document.addEventListener('DOMContentLoaded', function () {
 731    var button = document.querySelector('.page-title-action');
 732  
 733    if (!button) {
 734      return;
 735    }
 736  
 737    var showNotice = function showNotice() {
 738      var notice = document.createElement('div');
 739      notice.className = 'notice notice-success is-dismissible';
 740      notice.innerHTML = "<p>".concat(Object(external_wp_i18n_["__"])('Reusable block imported successfully!'), "</p>");
 741      var headerEnd = document.querySelector('.wp-header-end');
 742  
 743      if (!headerEnd) {
 744        return;
 745      }
 746  
 747      headerEnd.parentNode.insertBefore(notice, headerEnd);
 748    };
 749  
 750    var container = document.createElement('div');
 751    container.className = 'list-reusable-blocks__container';
 752    button.parentNode.insertBefore(container, button);
 753    Object(external_wp_element_["render"])(Object(external_wp_element_["createElement"])(import_dropdown, {
 754      onUpload: showNotice
 755    }), container);
 756  });
 757  
 758  
 759  /***/ }),
 760  
 761  /***/ 48:
 762  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 763  
 764  "use strict";
 765  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; });
 766  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
 767    try {
 768      var info = gen[key](arg);
 769      var value = info.value;
 770    } catch (error) {
 771      reject(error);
 772      return;
 773    }
 774  
 775    if (info.done) {
 776      resolve(value);
 777    } else {
 778      Promise.resolve(value).then(_next, _throw);
 779    }
 780  }
 781  
 782  function _asyncToGenerator(fn) {
 783    return function () {
 784      var self = this,
 785          args = arguments;
 786      return new Promise(function (resolve, reject) {
 787        var gen = fn.apply(self, args);
 788  
 789        function _next(value) {
 790          asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
 791        }
 792  
 793        function _throw(err) {
 794          asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
 795        }
 796  
 797        _next(undefined);
 798      });
 799    };
 800  }
 801  
 802  /***/ }),
 803  
 804  /***/ 50:
 805  /***/ (function(module, exports) {
 806  
 807  (function() { module.exports = window["wp"]["apiFetch"]; }());
 808  
 809  /***/ }),
 810  
 811  /***/ 55:
 812  /***/ (function(module, __webpack_exports__, __webpack_require__) {
 813  
 814  "use strict";
 815  /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _setPrototypeOf; });
 816  function _setPrototypeOf(o, p) {
 817    _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
 818      o.__proto__ = p;
 819      return o;
 820    };
 821  
 822    return _setPrototypeOf(o, p);
 823  }
 824  
 825  /***/ }),
 826  
 827  /***/ 59:
 828  /***/ (function(module, exports) {
 829  
 830  function _typeof(obj) {
 831    "@babel/helpers - typeof";
 832  
 833    if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
 834      module.exports = _typeof = function _typeof(obj) {
 835        return typeof obj;
 836      };
 837  
 838      module.exports["default"] = module.exports, module.exports.__esModule = true;
 839    } else {
 840      module.exports = _typeof = function _typeof(obj) {
 841        return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
 842      };
 843  
 844      module.exports["default"] = module.exports, module.exports.__esModule = true;
 845    }
 846  
 847    return _typeof(obj);
 848  }
 849  
 850  module.exports = _typeof;
 851  module.exports["default"] = module.exports, module.exports.__esModule = true;
 852  
 853  /***/ })
 854  
 855  /******/ });


Generated: Fri May 14 01:00:04 2021 Cross-referenced by PHPXref 0.7.1