2018-12-13 23:41:57 -05:00
|
|
|
this["wp"] = this["wp"] || {}; this["wp"]["listReusableBlocks"] =
|
|
|
|
/******/ (function(modules) { // webpackBootstrap
|
|
|
|
/******/ // The module cache
|
|
|
|
/******/ var installedModules = {};
|
|
|
|
/******/
|
|
|
|
/******/ // The require function
|
|
|
|
/******/ function __webpack_require__(moduleId) {
|
|
|
|
/******/
|
|
|
|
/******/ // Check if module is in cache
|
|
|
|
/******/ if(installedModules[moduleId]) {
|
|
|
|
/******/ return installedModules[moduleId].exports;
|
|
|
|
/******/ }
|
|
|
|
/******/ // Create a new module (and put it into the cache)
|
|
|
|
/******/ var module = installedModules[moduleId] = {
|
|
|
|
/******/ i: moduleId,
|
|
|
|
/******/ l: false,
|
|
|
|
/******/ exports: {}
|
|
|
|
/******/ };
|
|
|
|
/******/
|
|
|
|
/******/ // Execute the module function
|
|
|
|
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
|
|
|
/******/
|
|
|
|
/******/ // Flag the module as loaded
|
|
|
|
/******/ module.l = true;
|
|
|
|
/******/
|
|
|
|
/******/ // Return the exports of the module
|
|
|
|
/******/ return module.exports;
|
|
|
|
/******/ }
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/ // expose the modules object (__webpack_modules__)
|
|
|
|
/******/ __webpack_require__.m = modules;
|
|
|
|
/******/
|
|
|
|
/******/ // expose the module cache
|
|
|
|
/******/ __webpack_require__.c = installedModules;
|
|
|
|
/******/
|
|
|
|
/******/ // define getter function for harmony exports
|
|
|
|
/******/ __webpack_require__.d = function(exports, name, getter) {
|
|
|
|
/******/ if(!__webpack_require__.o(exports, name)) {
|
|
|
|
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
|
|
|
|
/******/ }
|
|
|
|
/******/ };
|
|
|
|
/******/
|
|
|
|
/******/ // define __esModule on exports
|
|
|
|
/******/ __webpack_require__.r = function(exports) {
|
|
|
|
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
|
|
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
|
/******/ }
|
|
|
|
/******/ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
|
/******/ };
|
|
|
|
/******/
|
|
|
|
/******/ // create a fake namespace object
|
|
|
|
/******/ // mode & 1: value is a module id, require it
|
|
|
|
/******/ // mode & 2: merge all properties of value into the ns
|
|
|
|
/******/ // mode & 4: return value when already ns object
|
|
|
|
/******/ // mode & 8|1: behave like require
|
|
|
|
/******/ __webpack_require__.t = function(value, mode) {
|
|
|
|
/******/ if(mode & 1) value = __webpack_require__(value);
|
|
|
|
/******/ if(mode & 8) return value;
|
|
|
|
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
|
|
|
|
/******/ var ns = Object.create(null);
|
|
|
|
/******/ __webpack_require__.r(ns);
|
|
|
|
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
|
|
|
|
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
|
|
|
|
/******/ return ns;
|
|
|
|
/******/ };
|
|
|
|
/******/
|
|
|
|
/******/ // getDefaultExport function for compatibility with non-harmony modules
|
|
|
|
/******/ __webpack_require__.n = function(module) {
|
|
|
|
/******/ var getter = module && module.__esModule ?
|
|
|
|
/******/ function getDefault() { return module['default']; } :
|
|
|
|
/******/ function getModuleExports() { return module; };
|
|
|
|
/******/ __webpack_require__.d(getter, 'a', getter);
|
|
|
|
/******/ return getter;
|
|
|
|
/******/ };
|
|
|
|
/******/
|
|
|
|
/******/ // Object.prototype.hasOwnProperty.call
|
|
|
|
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
|
|
|
/******/
|
|
|
|
/******/ // __webpack_public_path__
|
|
|
|
/******/ __webpack_require__.p = "";
|
|
|
|
/******/
|
|
|
|
/******/
|
|
|
|
/******/ // Load entry module and return exports
|
2020-12-01 07:19:43 -05:00
|
|
|
/******/ return __webpack_require__(__webpack_require__.s = 481);
|
2018-12-13 23:41:57 -05:00
|
|
|
/******/ })
|
|
|
|
/************************************************************************/
|
|
|
|
/******/ ({
|
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
/***/ 0:
|
|
|
|
/***/ (function(module, exports) {
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
(function() { module.exports = this["wp"]["element"]; }());
|
2018-12-13 23:41:57 -05:00
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
/***/ 1:
|
|
|
|
/***/ (function(module, exports) {
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
(function() { module.exports = this["wp"]["i18n"]; }());
|
2018-12-13 23:41:57 -05:00
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-10-13 09:10:30 -04:00
|
|
|
/***/ 10:
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
(function() { module.exports = this["wp"]["compose"]; }());
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-10-20 09:36:16 -04:00
|
|
|
/***/ 16:
|
2020-06-26 09:33:47 -04:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; });
|
|
|
|
function _assertThisInitialized(self) {
|
|
|
|
if (self === void 0) {
|
|
|
|
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
|
|
}
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-10-20 09:36:16 -04:00
|
|
|
/***/ 19:
|
2019-09-19 11:19:18 -04:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
2020-06-26 09:33:47 -04:00
|
|
|
"use strict";
|
|
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; });
|
|
|
|
function _getPrototypeOf(o) {
|
|
|
|
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
|
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
|
|
};
|
|
|
|
return _getPrototypeOf(o);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-10-13 09:10:30 -04:00
|
|
|
/***/ 2:
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
(function() { module.exports = this["lodash"]; }());
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 20:
|
2020-10-20 09:36:16 -04:00
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
(function() { module.exports = this["regeneratorRuntime"]; }());
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 21:
|
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; });
|
|
|
|
function _classCallCheck(instance, Constructor) {
|
|
|
|
if (!(instance instanceof Constructor)) {
|
|
|
|
throw new TypeError("Cannot call a class as a function");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 22:
|
2020-06-26 09:33:47 -04:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
2019-09-19 11:19:18 -04:00
|
|
|
"use strict";
|
|
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; });
|
|
|
|
function _defineProperties(target, props) {
|
|
|
|
for (var i = 0; i < props.length; i++) {
|
|
|
|
var descriptor = props[i];
|
|
|
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
|
|
descriptor.configurable = true;
|
|
|
|
if ("value" in descriptor) descriptor.writable = true;
|
|
|
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
|
|
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
|
|
|
|
if (staticProps) _defineProperties(Constructor, staticProps);
|
|
|
|
return Constructor;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-10-20 09:36:16 -04:00
|
|
|
/***/ 23:
|
2018-12-13 23:41:57 -05:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
2018-12-17 22:14:52 -05:00
|
|
|
|
2020-06-29 07:50:29 -04:00
|
|
|
// EXPORTS
|
|
|
|
__webpack_require__.d(__webpack_exports__, "a", function() { return /* binding */ _inherits; });
|
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js
|
|
|
|
function _setPrototypeOf(o, p) {
|
|
|
|
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) {
|
|
|
|
o.__proto__ = p;
|
|
|
|
return o;
|
|
|
|
};
|
|
|
|
|
|
|
|
return _setPrototypeOf(o, p);
|
|
|
|
}
|
|
|
|
// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js
|
2018-12-13 23:41:57 -05:00
|
|
|
|
|
|
|
function _inherits(subClass, superClass) {
|
|
|
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
|
|
throw new TypeError("Super expression must either be null or a function");
|
|
|
|
}
|
|
|
|
|
|
|
|
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
|
|
constructor: {
|
|
|
|
value: subClass,
|
|
|
|
writable: true,
|
|
|
|
configurable: true
|
|
|
|
}
|
|
|
|
});
|
2018-12-17 22:14:52 -05:00
|
|
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
2018-12-13 23:41:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-10-20 09:36:16 -04:00
|
|
|
/***/ 24:
|
2020-06-26 09:33:47 -04:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2020-06-26 09:33:47 -04:00
|
|
|
"use strict";
|
|
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; });
|
|
|
|
/* harmony import */ var _helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(40);
|
2020-10-20 09:36:16 -04:00
|
|
|
/* harmony import */ var _assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(16);
|
2020-06-26 09:33:47 -04:00
|
|
|
|
|
|
|
|
|
|
|
function _possibleConstructorReturn(self, call) {
|
|
|
|
if (call && (Object(_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(call) === "object" || typeof call === "function")) {
|
|
|
|
return call;
|
|
|
|
}
|
|
|
|
|
|
|
|
return Object(_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self);
|
|
|
|
}
|
2018-12-13 23:41:57 -05:00
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2019-03-21 08:48:00 -04:00
|
|
|
/***/ 3:
|
2019-09-19 11:19:18 -04:00
|
|
|
/***/ (function(module, exports) {
|
2019-03-21 08:48:00 -04:00
|
|
|
|
2019-09-19 11:19:18 -04:00
|
|
|
(function() { module.exports = this["wp"]["components"]; }());
|
2019-03-21 08:48:00 -04:00
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-06-26 09:33:47 -04:00
|
|
|
/***/ 40:
|
2018-12-13 23:41:57 -05:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
2018-12-17 22:14:52 -05:00
|
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; });
|
2018-12-13 23:41:57 -05:00
|
|
|
function _typeof(obj) {
|
2020-02-06 16:03:31 -05:00
|
|
|
"@babel/helpers - typeof";
|
|
|
|
|
2020-01-08 06:57:23 -05:00
|
|
|
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
2018-12-13 23:41:57 -05:00
|
|
|
_typeof = function _typeof(obj) {
|
2020-01-08 06:57:23 -05:00
|
|
|
return typeof obj;
|
2018-12-13 23:41:57 -05:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
_typeof = function _typeof(obj) {
|
2020-01-08 06:57:23 -05:00
|
|
|
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
2018-12-13 23:41:57 -05:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return _typeof(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-06-26 09:33:47 -04:00
|
|
|
/***/ 45:
|
2020-10-13 09:10:30 -04:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; });
|
|
|
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
|
|
|
|
try {
|
|
|
|
var info = gen[key](arg);
|
|
|
|
var value = info.value;
|
|
|
|
} catch (error) {
|
|
|
|
reject(error);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info.done) {
|
|
|
|
resolve(value);
|
|
|
|
} else {
|
|
|
|
Promise.resolve(value).then(_next, _throw);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function _asyncToGenerator(fn) {
|
|
|
|
return function () {
|
|
|
|
var self = this,
|
|
|
|
args = arguments;
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
var gen = fn.apply(self, args);
|
|
|
|
|
|
|
|
function _next(value) {
|
|
|
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
|
|
}
|
|
|
|
|
|
|
|
function _throw(err) {
|
|
|
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
|
|
}
|
|
|
|
|
|
|
|
_next(undefined);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-10-20 09:36:16 -04:00
|
|
|
/***/ 47:
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
(function() { module.exports = this["wp"]["apiFetch"]; }());
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-12-01 07:19:43 -05:00
|
|
|
/***/ 481:
|
2018-12-13 23:41:57 -05:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
2020-06-29 07:50:29 -04:00
|
|
|
// ESM COMPAT FLAG
|
2018-12-13 23:41:57 -05:00
|
|
|
__webpack_require__.r(__webpack_exports__);
|
2018-12-17 22:14:52 -05:00
|
|
|
|
|
|
|
// EXTERNAL MODULE: external {"this":["wp","element"]}
|
|
|
|
var external_this_wp_element_ = __webpack_require__(0);
|
|
|
|
|
|
|
|
// EXTERNAL MODULE: external {"this":["wp","i18n"]}
|
|
|
|
var external_this_wp_i18n_ = __webpack_require__(1);
|
|
|
|
|
2020-01-03 08:17:24 -05:00
|
|
|
// EXTERNAL MODULE: external {"this":"regeneratorRuntime"}
|
2020-10-20 09:36:16 -04:00
|
|
|
var external_this_regeneratorRuntime_ = __webpack_require__(20);
|
2020-01-03 08:17:24 -05:00
|
|
|
var external_this_regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(external_this_regeneratorRuntime_);
|
2019-03-21 08:48:00 -04:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
|
2020-10-20 09:36:16 -04:00
|
|
|
var asyncToGenerator = __webpack_require__(45);
|
2018-12-17 22:14:52 -05:00
|
|
|
|
2020-01-03 08:17:24 -05:00
|
|
|
// EXTERNAL MODULE: external {"this":"lodash"}
|
|
|
|
var external_this_lodash_ = __webpack_require__(2);
|
2018-12-17 22:14:52 -05:00
|
|
|
|
|
|
|
// EXTERNAL MODULE: external {"this":["wp","apiFetch"]}
|
2020-10-20 09:36:16 -04:00
|
|
|
var external_this_wp_apiFetch_ = __webpack_require__(47);
|
2018-12-17 22:14:52 -05:00
|
|
|
var external_this_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_apiFetch_);
|
|
|
|
|
|
|
|
// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/file.js
|
|
|
|
/**
|
|
|
|
* Downloads a file.
|
|
|
|
*
|
|
|
|
* @param {string} fileName File Name.
|
|
|
|
* @param {string} content File Content.
|
|
|
|
* @param {string} contentType File mime type.
|
|
|
|
*/
|
|
|
|
function download(fileName, content, contentType) {
|
|
|
|
var file = new window.Blob([content], {
|
|
|
|
type: contentType
|
|
|
|
}); // IE11 can't use the click to download technique
|
|
|
|
// we use a specific IE11 technique instead.
|
|
|
|
|
|
|
|
if (window.navigator.msSaveOrOpenBlob) {
|
|
|
|
window.navigator.msSaveOrOpenBlob(file, fileName);
|
|
|
|
} else {
|
|
|
|
var a = document.createElement('a');
|
|
|
|
a.href = URL.createObjectURL(file);
|
|
|
|
a.download = fileName;
|
|
|
|
a.style.display = 'none';
|
|
|
|
document.body.appendChild(a);
|
|
|
|
a.click();
|
|
|
|
document.body.removeChild(a);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Reads the textual content of the given file.
|
|
|
|
*
|
|
|
|
* @param {File} file File.
|
|
|
|
* @return {Promise<string>} Content of the file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
function readTextFile(file) {
|
|
|
|
var reader = new window.FileReader();
|
|
|
|
return new Promise(function (resolve) {
|
|
|
|
reader.onload = function () {
|
|
|
|
resolve(reader.result);
|
|
|
|
};
|
|
|
|
|
|
|
|
reader.readAsText(file);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/export.js
|
2018-12-13 23:41:57 -05:00
|
|
|
|
|
|
|
|
2019-03-21 08:48:00 -04:00
|
|
|
|
2018-12-13 23:41:57 -05:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
/**
|
|
|
|
* Export a reusable block as a JSON file.
|
|
|
|
*
|
|
|
|
* @param {number} id
|
|
|
|
*/
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
function exportReusableBlock(_x) {
|
|
|
|
return _exportReusableBlock.apply(this, arguments);
|
2018-12-13 23:41:57 -05:00
|
|
|
}
|
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
function _exportReusableBlock() {
|
2020-06-26 09:33:47 -04:00
|
|
|
_exportReusableBlock = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(function _callee(id) {
|
2018-12-17 22:14:52 -05:00
|
|
|
var postType, post, title, content, fileContent, fileName;
|
2020-01-03 08:17:24 -05:00
|
|
|
return external_this_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
|
2018-12-17 22:14:52 -05:00
|
|
|
while (1) {
|
|
|
|
switch (_context.prev = _context.next) {
|
|
|
|
case 0:
|
|
|
|
_context.next = 2;
|
|
|
|
return external_this_wp_apiFetch_default()({
|
|
|
|
path: "/wp/v2/types/wp_block"
|
|
|
|
});
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
case 2:
|
|
|
|
postType = _context.sent;
|
|
|
|
_context.next = 5;
|
|
|
|
return external_this_wp_apiFetch_default()({
|
|
|
|
path: "/wp/v2/".concat(postType.rest_base, "/").concat(id, "?context=edit")
|
|
|
|
});
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
case 5:
|
|
|
|
post = _context.sent;
|
|
|
|
title = post.title.raw;
|
|
|
|
content = post.content.raw;
|
|
|
|
fileContent = JSON.stringify({
|
|
|
|
__file: 'wp_block',
|
|
|
|
title: title,
|
|
|
|
content: content
|
|
|
|
}, null, 2);
|
2020-01-03 08:17:24 -05:00
|
|
|
fileName = Object(external_this_lodash_["kebabCase"])(title) + '.json';
|
2018-12-17 22:14:52 -05:00
|
|
|
download(fileName, fileContent, 'application/json');
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
case 11:
|
|
|
|
case "end":
|
|
|
|
return _context.stop();
|
|
|
|
}
|
|
|
|
}
|
2019-09-19 11:19:18 -04:00
|
|
|
}, _callee);
|
2018-12-17 22:14:52 -05:00
|
|
|
}));
|
|
|
|
return _exportReusableBlock.apply(this, arguments);
|
|
|
|
}
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
/* harmony default export */ var utils_export = (exportReusableBlock);
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
// EXTERNAL MODULE: external {"this":["wp","components"]}
|
2019-09-19 11:19:18 -04:00
|
|
|
var external_this_wp_components_ = __webpack_require__(3);
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
|
2020-10-13 09:10:30 -04:00
|
|
|
var classCallCheck = __webpack_require__(21);
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js
|
2020-10-20 09:36:16 -04:00
|
|
|
var createClass = __webpack_require__(22);
|
2020-06-26 09:33:47 -04:00
|
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
|
2020-10-20 09:36:16 -04:00
|
|
|
var assertThisInitialized = __webpack_require__(16);
|
2020-10-13 09:10:30 -04:00
|
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js + 1 modules
|
2020-10-20 09:36:16 -04:00
|
|
|
var inherits = __webpack_require__(23);
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
|
2020-10-20 09:36:16 -04:00
|
|
|
var possibleConstructorReturn = __webpack_require__(24);
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
|
2020-10-20 09:36:16 -04:00
|
|
|
var getPrototypeOf = __webpack_require__(19);
|
2018-12-17 22:14:52 -05:00
|
|
|
|
|
|
|
// EXTERNAL MODULE: external {"this":["wp","compose"]}
|
2020-10-13 09:10:30 -04:00
|
|
|
var external_this_wp_compose_ = __webpack_require__(10);
|
2018-12-17 22:14:52 -05:00
|
|
|
|
|
|
|
// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/import.js
|
2018-12-13 23:41:57 -05:00
|
|
|
|
|
|
|
|
2019-03-21 08:48:00 -04:00
|
|
|
|
2018-12-13 23:41:57 -05:00
|
|
|
/**
|
2018-12-17 22:14:52 -05:00
|
|
|
* External dependencies
|
2018-12-13 23:41:57 -05:00
|
|
|
*/
|
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
2018-12-13 23:41:57 -05:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
/**
|
|
|
|
* Import a reusable block from a JSON file.
|
|
|
|
*
|
|
|
|
* @param {File} file File.
|
|
|
|
* @return {Promise} Promise returning the imported reusable block.
|
|
|
|
*/
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
function importReusableBlock(_x) {
|
|
|
|
return _importReusableBlock.apply(this, arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
function _importReusableBlock() {
|
2020-06-26 09:33:47 -04:00
|
|
|
_importReusableBlock = Object(asyncToGenerator["a" /* default */])( /*#__PURE__*/external_this_regeneratorRuntime_default.a.mark(function _callee(file) {
|
2018-12-17 22:14:52 -05:00
|
|
|
var fileContent, parsedContent, postType, reusableBlock;
|
2020-01-03 08:17:24 -05:00
|
|
|
return external_this_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
|
2018-12-17 22:14:52 -05:00
|
|
|
while (1) {
|
|
|
|
switch (_context.prev = _context.next) {
|
|
|
|
case 0:
|
|
|
|
_context.next = 2;
|
|
|
|
return readTextFile(file);
|
|
|
|
|
|
|
|
case 2:
|
|
|
|
fileContent = _context.sent;
|
|
|
|
_context.prev = 3;
|
|
|
|
parsedContent = JSON.parse(fileContent);
|
|
|
|
_context.next = 10;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 7:
|
|
|
|
_context.prev = 7;
|
|
|
|
_context.t0 = _context["catch"](3);
|
|
|
|
throw new Error('Invalid JSON file');
|
|
|
|
|
|
|
|
case 10:
|
2020-01-03 08:17:24 -05:00
|
|
|
if (!(parsedContent.__file !== 'wp_block' || !parsedContent.title || !parsedContent.content || !Object(external_this_lodash_["isString"])(parsedContent.title) || !Object(external_this_lodash_["isString"])(parsedContent.content))) {
|
2018-12-17 22:14:52 -05:00
|
|
|
_context.next = 12;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new Error('Invalid Reusable Block JSON file');
|
|
|
|
|
|
|
|
case 12:
|
|
|
|
_context.next = 14;
|
|
|
|
return external_this_wp_apiFetch_default()({
|
|
|
|
path: "/wp/v2/types/wp_block"
|
|
|
|
});
|
|
|
|
|
|
|
|
case 14:
|
|
|
|
postType = _context.sent;
|
|
|
|
_context.next = 17;
|
|
|
|
return external_this_wp_apiFetch_default()({
|
|
|
|
path: "/wp/v2/".concat(postType.rest_base),
|
|
|
|
data: {
|
|
|
|
title: parsedContent.title,
|
|
|
|
content: parsedContent.content,
|
|
|
|
status: 'publish'
|
|
|
|
},
|
|
|
|
method: 'POST'
|
|
|
|
});
|
|
|
|
|
|
|
|
case 17:
|
|
|
|
reusableBlock = _context.sent;
|
|
|
|
return _context.abrupt("return", reusableBlock);
|
|
|
|
|
|
|
|
case 19:
|
|
|
|
case "end":
|
|
|
|
return _context.stop();
|
|
|
|
}
|
|
|
|
}
|
2019-09-19 11:19:18 -04:00
|
|
|
}, _callee, null, [[3, 7]]);
|
2018-12-17 22:14:52 -05:00
|
|
|
}));
|
|
|
|
return _importReusableBlock.apply(this, arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* harmony default export */ var utils_import = (importReusableBlock);
|
|
|
|
|
|
|
|
// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-form/index.js
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-10-13 09:10:30 -04:00
|
|
|
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); }; }
|
2020-06-26 09:33:47 -04:00
|
|
|
|
|
|
|
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
|
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-06-26 09:33:47 -04:00
|
|
|
var import_form_ImportForm = /*#__PURE__*/function (_Component) {
|
2018-12-17 22:14:52 -05:00
|
|
|
Object(inherits["a" /* default */])(ImportForm, _Component);
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2020-06-26 09:33:47 -04:00
|
|
|
var _super = _createSuper(ImportForm);
|
|
|
|
|
2018-12-13 23:41:57 -05:00
|
|
|
function ImportForm() {
|
|
|
|
var _this;
|
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
Object(classCallCheck["a" /* default */])(this, ImportForm);
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2020-06-26 09:33:47 -04:00
|
|
|
_this = _super.apply(this, arguments);
|
2018-12-13 23:41:57 -05:00
|
|
|
_this.state = {
|
|
|
|
isLoading: false,
|
|
|
|
error: null,
|
|
|
|
file: null
|
|
|
|
};
|
|
|
|
_this.isStillMounted = true;
|
2019-09-19 11:19:18 -04:00
|
|
|
_this.onChangeFile = _this.onChangeFile.bind(Object(assertThisInitialized["a" /* default */])(_this));
|
|
|
|
_this.onSubmit = _this.onSubmit.bind(Object(assertThisInitialized["a" /* default */])(_this));
|
2018-12-13 23:41:57 -05:00
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
Object(createClass["a" /* default */])(ImportForm, [{
|
2018-12-13 23:41:57 -05:00
|
|
|
key: "componentWillUnmount",
|
|
|
|
value: function componentWillUnmount() {
|
|
|
|
this.isStillMounted = false;
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
key: "onChangeFile",
|
|
|
|
value: function onChangeFile(event) {
|
|
|
|
this.setState({
|
|
|
|
file: event.target.files[0]
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
key: "onSubmit",
|
|
|
|
value: function onSubmit(event) {
|
|
|
|
var _this2 = this;
|
|
|
|
|
|
|
|
event.preventDefault();
|
|
|
|
var file = this.state.file;
|
|
|
|
var onUpload = this.props.onUpload;
|
|
|
|
|
|
|
|
if (!file) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.setState({
|
|
|
|
isLoading: true
|
|
|
|
});
|
2018-12-17 22:14:52 -05:00
|
|
|
utils_import(file).then(function (reusableBlock) {
|
2018-12-13 23:41:57 -05:00
|
|
|
if (!_this2.isStillMounted) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_this2.setState({
|
|
|
|
isLoading: false
|
|
|
|
});
|
|
|
|
|
|
|
|
onUpload(reusableBlock);
|
|
|
|
}).catch(function (error) {
|
|
|
|
if (!_this2.isStillMounted) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var uiMessage;
|
|
|
|
|
|
|
|
switch (error.message) {
|
|
|
|
case 'Invalid JSON file':
|
2018-12-17 22:14:52 -05:00
|
|
|
uiMessage = Object(external_this_wp_i18n_["__"])('Invalid JSON file');
|
2018-12-13 23:41:57 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Invalid Reusable Block JSON file':
|
2018-12-17 22:14:52 -05:00
|
|
|
uiMessage = Object(external_this_wp_i18n_["__"])('Invalid Reusable Block JSON file');
|
2018-12-13 23:41:57 -05:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-12-17 22:14:52 -05:00
|
|
|
uiMessage = Object(external_this_wp_i18n_["__"])('Unknown error');
|
2018-12-13 23:41:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
_this2.setState({
|
|
|
|
isLoading: false,
|
|
|
|
error: uiMessage
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, {
|
|
|
|
key: "render",
|
|
|
|
value: function render() {
|
|
|
|
var instanceId = this.props.instanceId;
|
|
|
|
var _this$state = this.state,
|
|
|
|
file = _this$state.file,
|
|
|
|
isLoading = _this$state.isLoading,
|
|
|
|
error = _this$state.error;
|
|
|
|
var inputId = 'list-reusable-blocks-import-form-' + instanceId;
|
2018-12-17 22:14:52 -05:00
|
|
|
return Object(external_this_wp_element_["createElement"])("form", {
|
2018-12-13 23:41:57 -05:00
|
|
|
className: "list-reusable-blocks-import-form",
|
|
|
|
onSubmit: this.onSubmit
|
2018-12-17 22:14:52 -05:00
|
|
|
}, error && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Notice"], {
|
2018-12-13 23:41:57 -05:00
|
|
|
status: "error"
|
2018-12-17 22:14:52 -05:00
|
|
|
}, error), Object(external_this_wp_element_["createElement"])("label", {
|
2018-12-13 23:41:57 -05:00
|
|
|
htmlFor: inputId,
|
|
|
|
className: "list-reusable-blocks-import-form__label"
|
2018-12-17 22:14:52 -05:00
|
|
|
}, Object(external_this_wp_i18n_["__"])('File')), Object(external_this_wp_element_["createElement"])("input", {
|
2018-12-13 23:41:57 -05:00
|
|
|
id: inputId,
|
|
|
|
type: "file",
|
|
|
|
onChange: this.onChangeFile
|
2018-12-17 22:14:52 -05:00
|
|
|
}), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], {
|
2018-12-13 23:41:57 -05:00
|
|
|
type: "submit",
|
|
|
|
isBusy: isLoading,
|
|
|
|
disabled: !file || isLoading,
|
2020-01-22 17:06:21 -05:00
|
|
|
isSecondary: true,
|
2018-12-13 23:41:57 -05:00
|
|
|
className: "list-reusable-blocks-import-form__button"
|
2018-12-17 22:14:52 -05:00
|
|
|
}, Object(external_this_wp_i18n_["_x"])('Import', 'button label')));
|
2018-12-13 23:41:57 -05:00
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return ImportForm;
|
2018-12-17 22:14:52 -05:00
|
|
|
}(external_this_wp_element_["Component"]);
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
/* harmony default export */ var import_form = (Object(external_this_wp_compose_["withInstanceId"])(import_form_ImportForm));
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-dropdown/index.js
|
2018-12-13 23:41:57 -05:00
|
|
|
|
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
2018-12-13 23:41:57 -05:00
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function ImportDropdown(_ref) {
|
|
|
|
var onUpload = _ref.onUpload;
|
|
|
|
return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Dropdown"], {
|
|
|
|
position: "bottom right",
|
|
|
|
contentClassName: "list-reusable-blocks-import-dropdown__content",
|
|
|
|
renderToggle: function renderToggle(_ref2) {
|
|
|
|
var isOpen = _ref2.isOpen,
|
|
|
|
onToggle = _ref2.onToggle;
|
|
|
|
return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], {
|
|
|
|
"aria-expanded": isOpen,
|
|
|
|
onClick: onToggle,
|
|
|
|
isPrimary: true
|
|
|
|
}, Object(external_this_wp_i18n_["__"])('Import from JSON'));
|
|
|
|
},
|
|
|
|
renderContent: function renderContent(_ref3) {
|
|
|
|
var onClose = _ref3.onClose;
|
|
|
|
return Object(external_this_wp_element_["createElement"])(import_form, {
|
2020-01-03 08:17:24 -05:00
|
|
|
onUpload: Object(external_this_lodash_["flow"])(onClose, onUpload)
|
2018-12-17 22:14:52 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/* harmony default export */ var import_dropdown = (ImportDropdown);
|
|
|
|
|
|
|
|
// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/index.js
|
2018-12-13 23:41:57 -05:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
// Setup Export Links
|
|
|
|
|
|
|
|
document.body.addEventListener('click', function (event) {
|
|
|
|
if (!event.target.classList.contains('wp-list-reusable-blocks__export')) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
event.preventDefault();
|
2018-12-17 22:14:52 -05:00
|
|
|
utils_export(event.target.dataset.id);
|
2018-12-13 23:41:57 -05:00
|
|
|
}); // Setup Import Form
|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function () {
|
|
|
|
var button = document.querySelector('.page-title-action');
|
|
|
|
|
|
|
|
if (!button) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
var showNotice = function showNotice() {
|
|
|
|
var notice = document.createElement('div');
|
|
|
|
notice.className = 'notice notice-success is-dismissible';
|
2018-12-17 22:14:52 -05:00
|
|
|
notice.innerHTML = "<p>".concat(Object(external_this_wp_i18n_["__"])('Reusable block imported successfully!'), "</p>");
|
2018-12-13 23:41:57 -05:00
|
|
|
var headerEnd = document.querySelector('.wp-header-end');
|
|
|
|
|
|
|
|
if (!headerEnd) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
headerEnd.parentNode.insertBefore(notice, headerEnd);
|
|
|
|
};
|
|
|
|
|
|
|
|
var container = document.createElement('div');
|
|
|
|
container.className = 'list-reusable-blocks__container';
|
|
|
|
button.parentNode.insertBefore(container, button);
|
2018-12-17 22:14:52 -05:00
|
|
|
Object(external_this_wp_element_["render"])(Object(external_this_wp_element_["createElement"])(import_dropdown, {
|
2018-12-13 23:41:57 -05:00
|
|
|
onUpload: showNotice
|
|
|
|
}), container);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
/***/ })
|
|
|
|
|
2018-12-17 22:14:52 -05:00
|
|
|
/******/ });
|