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