2018-12-14 05:41:57 +01: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-02-10 23:33:27 +01:00
|
|
|
/******/ return __webpack_require__(__webpack_require__.s = 437);
|
2018-12-14 05:41:57 +01:00
|
|
|
/******/ })
|
|
|
|
/************************************************************************/
|
|
|
|
/******/ ({
|
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
/***/ 0:
|
|
|
|
/***/ (function(module, exports) {
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
(function() { module.exports = this["wp"]["element"]; }());
|
2018-12-14 05:41:57 +01:00
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
/***/ 1:
|
|
|
|
/***/ (function(module, exports) {
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
(function() { module.exports = this["wp"]["i18n"]; }());
|
2018-12-14 05:41:57 +01:00
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-02-10 23:33:27 +01:00
|
|
|
/***/ 13:
|
2019-09-19 17:19:18 +02:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
"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-02-10 23:33:27 +01:00
|
|
|
/***/ 14:
|
2018-12-14 05:41:57 +01:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
2018-12-18 04:14:52 +01:00
|
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; });
|
2018-12-14 05:41:57 +01:00
|
|
|
function _classCallCheck(instance, Constructor) {
|
|
|
|
if (!(instance instanceof Constructor)) {
|
|
|
|
throw new TypeError("Cannot call a class as a function");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-02-10 23:33:27 +01:00
|
|
|
/***/ 15:
|
2018-12-14 05:41:57 +01:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
2018-12-18 04:14:52 +01:00
|
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; });
|
2020-03-03 00:21:15 +01:00
|
|
|
/* harmony import */ var _helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(34);
|
2020-01-22 23:06:21 +01:00
|
|
|
/* harmony import */ var _assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(7);
|
2018-12-18 04:14:52 +01:00
|
|
|
|
|
|
|
|
|
|
|
function _possibleConstructorReturn(self, call) {
|
|
|
|
if (call && (Object(_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(call) === "object" || typeof call === "function")) {
|
|
|
|
return call;
|
2018-12-14 05:41:57 +01:00
|
|
|
}
|
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
return Object(_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self);
|
2018-12-14 05:41:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-02-10 23:33:27 +01:00
|
|
|
/***/ 16:
|
2018-12-14 05:41:57 +01:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
2018-12-18 04:14:52 +01:00
|
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; });
|
2018-12-14 05:41:57 +01:00
|
|
|
function _getPrototypeOf(o) {
|
|
|
|
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) {
|
|
|
|
return o.__proto__ || Object.getPrototypeOf(o);
|
|
|
|
};
|
|
|
|
return _getPrototypeOf(o);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-02-10 23:33:27 +01:00
|
|
|
/***/ 17:
|
2018-12-14 05:41:57 +01:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
2018-12-18 04:14:52 +01: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
|
|
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _inherits; });
|
2018-12-14 05:41:57 +01: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-18 04:14:52 +01:00
|
|
|
if (superClass) _setPrototypeOf(subClass, superClass);
|
2018-12-14 05:41:57 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
/***/ 2:
|
|
|
|
/***/ (function(module, exports) {
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
(function() { module.exports = this["lodash"]; }());
|
2018-12-14 05:41:57 +01:00
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-01-08 12:57:23 +01:00
|
|
|
/***/ 23:
|
2020-01-03 14:17:24 +01:00
|
|
|
/***/ (function(module, exports) {
|
2019-03-21 13:48:00 +01:00
|
|
|
|
2020-01-03 14:17:24 +01:00
|
|
|
(function() { module.exports = this["regeneratorRuntime"]; }());
|
2019-03-21 13:48:00 +01:00
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 3:
|
2019-09-19 17:19:18 +02:00
|
|
|
/***/ (function(module, exports) {
|
2019-03-21 13:48:00 +01:00
|
|
|
|
2019-09-19 17:19:18 +02:00
|
|
|
(function() { module.exports = this["wp"]["components"]; }());
|
2019-03-21 13:48:00 +01:00
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-03-03 00:21:15 +01:00
|
|
|
/***/ 34:
|
2018-12-14 05:41:57 +01:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
2018-12-18 04:14:52 +01:00
|
|
|
/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; });
|
2018-12-14 05:41:57 +01:00
|
|
|
function _typeof(obj) {
|
2020-02-06 22:03:31 +01:00
|
|
|
"@babel/helpers - typeof";
|
|
|
|
|
2020-01-08 12:57:23 +01:00
|
|
|
if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
|
2018-12-14 05:41:57 +01:00
|
|
|
_typeof = function _typeof(obj) {
|
2020-01-08 12:57:23 +01:00
|
|
|
return typeof obj;
|
2018-12-14 05:41:57 +01:00
|
|
|
};
|
|
|
|
} else {
|
|
|
|
_typeof = function _typeof(obj) {
|
2020-01-08 12:57:23 +01:00
|
|
|
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
2018-12-14 05:41:57 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return _typeof(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-02-06 22:03:31 +01:00
|
|
|
/***/ 40:
|
2018-12-18 04:14:52 +01:00
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
(function() { module.exports = this["wp"]["apiFetch"]; }());
|
|
|
|
|
|
|
|
/***/ }),
|
|
|
|
|
2020-02-10 23:33:27 +01:00
|
|
|
/***/ 437:
|
2018-12-14 05:41:57 +01:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
__webpack_require__.r(__webpack_exports__);
|
2018-12-18 04:14:52 +01: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 14:17:24 +01:00
|
|
|
// EXTERNAL MODULE: external {"this":"regeneratorRuntime"}
|
2020-01-08 12:57:23 +01:00
|
|
|
var external_this_regeneratorRuntime_ = __webpack_require__(23);
|
2020-01-03 14:17:24 +01:00
|
|
|
var external_this_regeneratorRuntime_default = /*#__PURE__*/__webpack_require__.n(external_this_regeneratorRuntime_);
|
2019-03-21 13:48:00 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js
|
2020-02-06 22:03:31 +01:00
|
|
|
var asyncToGenerator = __webpack_require__(47);
|
2018-12-18 04:14:52 +01:00
|
|
|
|
2020-01-03 14:17:24 +01:00
|
|
|
// EXTERNAL MODULE: external {"this":"lodash"}
|
|
|
|
var external_this_lodash_ = __webpack_require__(2);
|
2018-12-18 04:14:52 +01:00
|
|
|
|
|
|
|
// EXTERNAL MODULE: external {"this":["wp","apiFetch"]}
|
2020-02-06 22:03:31 +01:00
|
|
|
var external_this_wp_apiFetch_ = __webpack_require__(40);
|
2018-12-18 04:14:52 +01: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-14 05:41:57 +01:00
|
|
|
|
|
|
|
|
2019-03-21 13:48:00 +01:00
|
|
|
|
2018-12-14 05:41:57 +01:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
/**
|
|
|
|
* Export a reusable block as a JSON file.
|
|
|
|
*
|
|
|
|
* @param {number} id
|
|
|
|
*/
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
function exportReusableBlock(_x) {
|
|
|
|
return _exportReusableBlock.apply(this, arguments);
|
2018-12-14 05:41:57 +01:00
|
|
|
}
|
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
function _exportReusableBlock() {
|
|
|
|
_exportReusableBlock = Object(asyncToGenerator["a" /* default */])(
|
|
|
|
/*#__PURE__*/
|
2020-01-03 14:17:24 +01:00
|
|
|
external_this_regeneratorRuntime_default.a.mark(function _callee(id) {
|
2018-12-18 04:14:52 +01:00
|
|
|
var postType, post, title, content, fileContent, fileName;
|
2020-01-03 14:17:24 +01:00
|
|
|
return external_this_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
|
2018-12-18 04:14:52 +01: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-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01: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-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01: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 14:17:24 +01:00
|
|
|
fileName = Object(external_this_lodash_["kebabCase"])(title) + '.json';
|
2018-12-18 04:14:52 +01:00
|
|
|
download(fileName, fileContent, 'application/json');
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
case 11:
|
|
|
|
case "end":
|
|
|
|
return _context.stop();
|
|
|
|
}
|
|
|
|
}
|
2019-09-19 17:19:18 +02:00
|
|
|
}, _callee);
|
2018-12-18 04:14:52 +01:00
|
|
|
}));
|
|
|
|
return _exportReusableBlock.apply(this, arguments);
|
|
|
|
}
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
/* harmony default export */ var utils_export = (exportReusableBlock);
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
// EXTERNAL MODULE: external {"this":["wp","components"]}
|
2019-09-19 17:19:18 +02:00
|
|
|
var external_this_wp_components_ = __webpack_require__(3);
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js
|
2020-02-10 23:33:27 +01:00
|
|
|
var classCallCheck = __webpack_require__(14);
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js
|
2020-02-10 23:33:27 +01:00
|
|
|
var createClass = __webpack_require__(13);
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js
|
2020-02-10 23:33:27 +01:00
|
|
|
var possibleConstructorReturn = __webpack_require__(15);
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js
|
2020-02-10 23:33:27 +01:00
|
|
|
var getPrototypeOf = __webpack_require__(16);
|
2018-12-18 04:14:52 +01:00
|
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js
|
2020-01-22 23:06:21 +01:00
|
|
|
var assertThisInitialized = __webpack_require__(7);
|
2019-09-19 17:19:18 +02:00
|
|
|
|
|
|
|
// EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js + 1 modules
|
2020-02-10 23:33:27 +01:00
|
|
|
var inherits = __webpack_require__(17);
|
2018-12-18 04:14:52 +01:00
|
|
|
|
|
|
|
// EXTERNAL MODULE: external {"this":["wp","compose"]}
|
2019-09-19 17:19:18 +02:00
|
|
|
var external_this_wp_compose_ = __webpack_require__(8);
|
2018-12-18 04:14:52 +01:00
|
|
|
|
|
|
|
// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/utils/import.js
|
2018-12-14 05:41:57 +01:00
|
|
|
|
|
|
|
|
2019-03-21 13:48:00 +01:00
|
|
|
|
2018-12-14 05:41:57 +01:00
|
|
|
/**
|
2018-12-18 04:14:52 +01:00
|
|
|
* External dependencies
|
2018-12-14 05:41:57 +01:00
|
|
|
*/
|
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
2018-12-14 05:41:57 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
/**
|
|
|
|
* Import a reusable block from a JSON file.
|
|
|
|
*
|
|
|
|
* @param {File} file File.
|
|
|
|
* @return {Promise} Promise returning the imported reusable block.
|
|
|
|
*/
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
function importReusableBlock(_x) {
|
|
|
|
return _importReusableBlock.apply(this, arguments);
|
|
|
|
}
|
|
|
|
|
|
|
|
function _importReusableBlock() {
|
|
|
|
_importReusableBlock = Object(asyncToGenerator["a" /* default */])(
|
|
|
|
/*#__PURE__*/
|
2020-01-03 14:17:24 +01:00
|
|
|
external_this_regeneratorRuntime_default.a.mark(function _callee(file) {
|
2018-12-18 04:14:52 +01:00
|
|
|
var fileContent, parsedContent, postType, reusableBlock;
|
2020-01-03 14:17:24 +01:00
|
|
|
return external_this_regeneratorRuntime_default.a.wrap(function _callee$(_context) {
|
2018-12-18 04:14:52 +01: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 14:17:24 +01: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-18 04:14:52 +01: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 17:19:18 +02:00
|
|
|
}, _callee, null, [[3, 7]]);
|
2018-12-18 04:14:52 +01: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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var import_form_ImportForm =
|
|
|
|
/*#__PURE__*/
|
2018-12-14 05:41:57 +01:00
|
|
|
function (_Component) {
|
2018-12-18 04:14:52 +01:00
|
|
|
Object(inherits["a" /* default */])(ImportForm, _Component);
|
2018-12-14 05:41:57 +01:00
|
|
|
|
|
|
|
function ImportForm() {
|
|
|
|
var _this;
|
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
Object(classCallCheck["a" /* default */])(this, ImportForm);
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
_this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(ImportForm).apply(this, arguments));
|
2018-12-14 05:41:57 +01:00
|
|
|
_this.state = {
|
|
|
|
isLoading: false,
|
|
|
|
error: null,
|
|
|
|
file: null
|
|
|
|
};
|
|
|
|
_this.isStillMounted = true;
|
2019-09-19 17:19:18 +02:00
|
|
|
_this.onChangeFile = _this.onChangeFile.bind(Object(assertThisInitialized["a" /* default */])(_this));
|
|
|
|
_this.onSubmit = _this.onSubmit.bind(Object(assertThisInitialized["a" /* default */])(_this));
|
2018-12-14 05:41:57 +01:00
|
|
|
return _this;
|
|
|
|
}
|
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
Object(createClass["a" /* default */])(ImportForm, [{
|
2018-12-14 05:41:57 +01: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-18 04:14:52 +01:00
|
|
|
utils_import(file).then(function (reusableBlock) {
|
2018-12-14 05:41:57 +01: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-18 04:14:52 +01:00
|
|
|
uiMessage = Object(external_this_wp_i18n_["__"])('Invalid JSON file');
|
2018-12-14 05:41:57 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case 'Invalid Reusable Block JSON file':
|
2018-12-18 04:14:52 +01:00
|
|
|
uiMessage = Object(external_this_wp_i18n_["__"])('Invalid Reusable Block JSON file');
|
2018-12-14 05:41:57 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2018-12-18 04:14:52 +01:00
|
|
|
uiMessage = Object(external_this_wp_i18n_["__"])('Unknown error');
|
2018-12-14 05:41:57 +01: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-18 04:14:52 +01:00
|
|
|
return Object(external_this_wp_element_["createElement"])("form", {
|
2018-12-14 05:41:57 +01:00
|
|
|
className: "list-reusable-blocks-import-form",
|
|
|
|
onSubmit: this.onSubmit
|
2018-12-18 04:14:52 +01:00
|
|
|
}, error && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Notice"], {
|
2018-12-14 05:41:57 +01:00
|
|
|
status: "error"
|
2018-12-18 04:14:52 +01:00
|
|
|
}, error), Object(external_this_wp_element_["createElement"])("label", {
|
2018-12-14 05:41:57 +01:00
|
|
|
htmlFor: inputId,
|
|
|
|
className: "list-reusable-blocks-import-form__label"
|
2018-12-18 04:14:52 +01:00
|
|
|
}, Object(external_this_wp_i18n_["__"])('File')), Object(external_this_wp_element_["createElement"])("input", {
|
2018-12-14 05:41:57 +01:00
|
|
|
id: inputId,
|
|
|
|
type: "file",
|
|
|
|
onChange: this.onChangeFile
|
2018-12-18 04:14:52 +01:00
|
|
|
}), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], {
|
2018-12-14 05:41:57 +01:00
|
|
|
type: "submit",
|
|
|
|
isBusy: isLoading,
|
|
|
|
disabled: !file || isLoading,
|
2020-01-22 23:06:21 +01:00
|
|
|
isSecondary: true,
|
2018-12-14 05:41:57 +01:00
|
|
|
className: "list-reusable-blocks-import-form__button"
|
2018-12-18 04:14:52 +01:00
|
|
|
}, Object(external_this_wp_i18n_["_x"])('Import', 'button label')));
|
2018-12-14 05:41:57 +01:00
|
|
|
}
|
|
|
|
}]);
|
|
|
|
|
|
|
|
return ImportForm;
|
2018-12-18 04:14:52 +01:00
|
|
|
}(external_this_wp_element_["Component"]);
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
/* harmony default export */ var import_form = (Object(external_this_wp_compose_["withInstanceId"])(import_form_ImportForm));
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/components/import-dropdown/index.js
|
2018-12-14 05:41:57 +01:00
|
|
|
|
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* WordPress dependencies
|
|
|
|
*/
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01: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 14:17:24 +01:00
|
|
|
onUpload: Object(external_this_lodash_["flow"])(onClose, onUpload)
|
2018-12-18 04:14:52 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
/* harmony default export */ var import_dropdown = (ImportDropdown);
|
|
|
|
|
|
|
|
// CONCATENATED MODULE: ./node_modules/@wordpress/list-reusable-blocks/build-module/index.js
|
2018-12-14 05:41:57 +01: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-18 04:14:52 +01:00
|
|
|
utils_export(event.target.dataset.id);
|
2018-12-14 05:41:57 +01: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-18 04:14:52 +01:00
|
|
|
notice.innerHTML = "<p>".concat(Object(external_this_wp_i18n_["__"])('Reusable block imported successfully!'), "</p>");
|
2018-12-14 05:41:57 +01: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-18 04:14:52 +01:00
|
|
|
Object(external_this_wp_element_["render"])(Object(external_this_wp_element_["createElement"])(import_dropdown, {
|
2018-12-14 05:41:57 +01:00
|
|
|
onUpload: showNotice
|
|
|
|
}), container);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
2019-03-07 10:09:59 +01:00
|
|
|
/***/ }),
|
|
|
|
|
2020-02-06 22:03:31 +01:00
|
|
|
/***/ 47:
|
2018-12-14 05:41:57 +01:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
|
|
|
|
|
|
|
"use strict";
|
2018-12-18 04:14:52 +01:00
|
|
|
/* 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;
|
|
|
|
}
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
if (info.done) {
|
|
|
|
resolve(value);
|
2018-12-14 05:41:57 +01:00
|
|
|
} else {
|
2018-12-18 04:14:52 +01:00
|
|
|
Promise.resolve(value).then(_next, _throw);
|
2018-12-14 05:41:57 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
function _asyncToGenerator(fn) {
|
|
|
|
return function () {
|
|
|
|
var self = this,
|
|
|
|
args = arguments;
|
|
|
|
return new Promise(function (resolve, reject) {
|
|
|
|
var gen = fn.apply(self, args);
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
function _next(value) {
|
|
|
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
2018-12-14 05:41:57 +01:00
|
|
|
}
|
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
function _throw(err) {
|
|
|
|
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
|
|
}
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
_next(undefined);
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2019-03-21 13:48:00 +01:00
|
|
|
/***/ }),
|
|
|
|
|
2020-01-22 23:06:21 +01:00
|
|
|
/***/ 7:
|
2018-12-18 04:14:52 +01:00
|
|
|
/***/ (function(module, __webpack_exports__, __webpack_require__) {
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
"use strict";
|
2019-09-19 17:19:18 +02:00
|
|
|
/* 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");
|
2018-12-18 04:14:52 +01:00
|
|
|
}
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2019-09-19 17:19:18 +02:00
|
|
|
return self;
|
2018-12-18 04:14:52 +01:00
|
|
|
}
|
2018-12-14 05:41:57 +01:00
|
|
|
|
2019-09-19 17:19:18 +02:00
|
|
|
/***/ }),
|
|
|
|
|
|
|
|
/***/ 8:
|
|
|
|
/***/ (function(module, exports) {
|
|
|
|
|
|
|
|
(function() { module.exports = this["wp"]["compose"]; }());
|
|
|
|
|
2018-12-14 05:41:57 +01:00
|
|
|
/***/ })
|
|
|
|
|
2018-12-18 04:14:52 +01:00
|
|
|
/******/ });
|