|
1 this["wp"] = this["wp"] || {}; this["wp"]["editor"] = |
|
2 /******/ (function(modules) { // webpackBootstrap |
|
3 /******/ // The module cache |
|
4 /******/ var installedModules = {}; |
|
5 /******/ |
|
6 /******/ // The require function |
|
7 /******/ function __webpack_require__(moduleId) { |
|
8 /******/ |
|
9 /******/ // Check if module is in cache |
|
10 /******/ if(installedModules[moduleId]) { |
|
11 /******/ return installedModules[moduleId].exports; |
|
12 /******/ } |
|
13 /******/ // Create a new module (and put it into the cache) |
|
14 /******/ var module = installedModules[moduleId] = { |
|
15 /******/ i: moduleId, |
|
16 /******/ l: false, |
|
17 /******/ exports: {} |
|
18 /******/ }; |
|
19 /******/ |
|
20 /******/ // Execute the module function |
|
21 /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); |
|
22 /******/ |
|
23 /******/ // Flag the module as loaded |
|
24 /******/ module.l = true; |
|
25 /******/ |
|
26 /******/ // Return the exports of the module |
|
27 /******/ return module.exports; |
|
28 /******/ } |
|
29 /******/ |
|
30 /******/ |
|
31 /******/ // expose the modules object (__webpack_modules__) |
|
32 /******/ __webpack_require__.m = modules; |
|
33 /******/ |
|
34 /******/ // expose the module cache |
|
35 /******/ __webpack_require__.c = installedModules; |
|
36 /******/ |
|
37 /******/ // define getter function for harmony exports |
|
38 /******/ __webpack_require__.d = function(exports, name, getter) { |
|
39 /******/ if(!__webpack_require__.o(exports, name)) { |
|
40 /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); |
|
41 /******/ } |
|
42 /******/ }; |
|
43 /******/ |
|
44 /******/ // define __esModule on exports |
|
45 /******/ __webpack_require__.r = function(exports) { |
|
46 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { |
|
47 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); |
|
48 /******/ } |
|
49 /******/ Object.defineProperty(exports, '__esModule', { value: true }); |
|
50 /******/ }; |
|
51 /******/ |
|
52 /******/ // create a fake namespace object |
|
53 /******/ // mode & 1: value is a module id, require it |
|
54 /******/ // mode & 2: merge all properties of value into the ns |
|
55 /******/ // mode & 4: return value when already ns object |
|
56 /******/ // mode & 8|1: behave like require |
|
57 /******/ __webpack_require__.t = function(value, mode) { |
|
58 /******/ if(mode & 1) value = __webpack_require__(value); |
|
59 /******/ if(mode & 8) return value; |
|
60 /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; |
|
61 /******/ var ns = Object.create(null); |
|
62 /******/ __webpack_require__.r(ns); |
|
63 /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); |
|
64 /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); |
|
65 /******/ return ns; |
|
66 /******/ }; |
|
67 /******/ |
|
68 /******/ // getDefaultExport function for compatibility with non-harmony modules |
|
69 /******/ __webpack_require__.n = function(module) { |
|
70 /******/ var getter = module && module.__esModule ? |
|
71 /******/ function getDefault() { return module['default']; } : |
|
72 /******/ function getModuleExports() { return module; }; |
|
73 /******/ __webpack_require__.d(getter, 'a', getter); |
|
74 /******/ return getter; |
|
75 /******/ }; |
|
76 /******/ |
|
77 /******/ // Object.prototype.hasOwnProperty.call |
|
78 /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; |
|
79 /******/ |
|
80 /******/ // __webpack_public_path__ |
|
81 /******/ __webpack_require__.p = ""; |
|
82 /******/ |
|
83 /******/ |
|
84 /******/ // Load entry module and return exports |
|
85 /******/ return __webpack_require__(__webpack_require__.s = 358); |
|
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 |
|
104 /***/ 10: |
|
105 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
106 |
|
107 "use strict"; |
|
108 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _classCallCheck; }); |
|
109 function _classCallCheck(instance, Constructor) { |
|
110 if (!(instance instanceof Constructor)) { |
|
111 throw new TypeError("Cannot call a class as a function"); |
|
112 } |
|
113 } |
|
114 |
|
115 /***/ }), |
|
116 |
|
117 /***/ 109: |
|
118 /***/ (function(module, exports) { |
|
119 |
|
120 if (typeof Object.create === 'function') { |
|
121 // implementation from standard node.js 'util' module |
|
122 module.exports = function inherits(ctor, superCtor) { |
|
123 ctor.super_ = superCtor |
|
124 ctor.prototype = Object.create(superCtor.prototype, { |
|
125 constructor: { |
|
126 value: ctor, |
|
127 enumerable: false, |
|
128 writable: true, |
|
129 configurable: true |
|
130 } |
|
131 }); |
|
132 }; |
|
133 } else { |
|
134 // old school shim for old browsers |
|
135 module.exports = function inherits(ctor, superCtor) { |
|
136 ctor.super_ = superCtor |
|
137 var TempCtor = function () {} |
|
138 TempCtor.prototype = superCtor.prototype |
|
139 ctor.prototype = new TempCtor() |
|
140 ctor.prototype.constructor = ctor |
|
141 } |
|
142 } |
|
143 |
|
144 |
|
145 /***/ }), |
|
146 |
|
147 /***/ 11: |
|
148 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
149 |
|
150 "use strict"; |
|
151 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _possibleConstructorReturn; }); |
|
152 /* harmony import */ var _helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(32); |
|
153 /* harmony import */ var _assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(3); |
|
154 |
|
155 |
|
156 function _possibleConstructorReturn(self, call) { |
|
157 if (call && (Object(_helpers_esm_typeof__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(call) === "object" || typeof call === "function")) { |
|
158 return call; |
|
159 } |
|
160 |
|
161 return Object(_assertThisInitialized__WEBPACK_IMPORTED_MODULE_1__[/* default */ "a"])(self); |
|
162 } |
|
163 |
|
164 /***/ }), |
|
165 |
|
166 /***/ 111: |
|
167 /***/ (function(module, exports, __webpack_require__) { |
|
168 |
|
169 "use strict"; |
|
170 |
|
171 var __extends = (this && this.__extends) || (function () { |
|
172 var extendStatics = Object.setPrototypeOf || |
|
173 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || |
|
174 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; |
|
175 return function (d, b) { |
|
176 extendStatics(d, b); |
|
177 function __() { this.constructor = d; } |
|
178 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); |
|
179 }; |
|
180 })(); |
|
181 var __assign = (this && this.__assign) || Object.assign || function(t) { |
|
182 for (var s, i = 1, n = arguments.length; i < n; i++) { |
|
183 s = arguments[i]; |
|
184 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) |
|
185 t[p] = s[p]; |
|
186 } |
|
187 return t; |
|
188 }; |
|
189 var __rest = (this && this.__rest) || function (s, e) { |
|
190 var t = {}; |
|
191 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) |
|
192 t[p] = s[p]; |
|
193 if (s != null && typeof Object.getOwnPropertySymbols === "function") |
|
194 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) |
|
195 t[p[i]] = s[p[i]]; |
|
196 return t; |
|
197 }; |
|
198 exports.__esModule = true; |
|
199 var React = __webpack_require__(27); |
|
200 var PropTypes = __webpack_require__(31); |
|
201 var autosize = __webpack_require__(112); |
|
202 var _getLineHeight = __webpack_require__(113); |
|
203 var getLineHeight = _getLineHeight; |
|
204 var UPDATE = 'autosize:update'; |
|
205 var DESTROY = 'autosize:destroy'; |
|
206 var RESIZED = 'autosize:resized'; |
|
207 /** |
|
208 * A light replacement for built-in textarea component |
|
209 * which automaticaly adjusts its height to match the content |
|
210 */ |
|
211 var TextareaAutosize = /** @class */ (function (_super) { |
|
212 __extends(TextareaAutosize, _super); |
|
213 function TextareaAutosize() { |
|
214 var _this = _super !== null && _super.apply(this, arguments) || this; |
|
215 _this.state = { |
|
216 lineHeight: null |
|
217 }; |
|
218 _this.dispatchEvent = function (EVENT_TYPE) { |
|
219 var event = document.createEvent('Event'); |
|
220 event.initEvent(EVENT_TYPE, true, false); |
|
221 _this.textarea.dispatchEvent(event); |
|
222 }; |
|
223 _this.updateLineHeight = function () { |
|
224 _this.setState({ |
|
225 lineHeight: getLineHeight(_this.textarea) |
|
226 }); |
|
227 }; |
|
228 _this.onChange = function (e) { |
|
229 var onChange = _this.props.onChange; |
|
230 _this.currentValue = e.currentTarget.value; |
|
231 onChange && onChange(e); |
|
232 }; |
|
233 _this.saveDOMNodeRef = function (ref) { |
|
234 var innerRef = _this.props.innerRef; |
|
235 if (innerRef) { |
|
236 innerRef(ref); |
|
237 } |
|
238 _this.textarea = ref; |
|
239 }; |
|
240 _this.getLocals = function () { |
|
241 var _a = _this, _b = _a.props, onResize = _b.onResize, maxRows = _b.maxRows, onChange = _b.onChange, style = _b.style, innerRef = _b.innerRef, props = __rest(_b, ["onResize", "maxRows", "onChange", "style", "innerRef"]), lineHeight = _a.state.lineHeight, saveDOMNodeRef = _a.saveDOMNodeRef; |
|
242 var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null; |
|
243 return __assign({}, props, { saveDOMNodeRef: saveDOMNodeRef, style: maxHeight ? __assign({}, style, { maxHeight: maxHeight }) : style, onChange: _this.onChange }); |
|
244 }; |
|
245 return _this; |
|
246 } |
|
247 TextareaAutosize.prototype.componentDidMount = function () { |
|
248 var _this = this; |
|
249 var _a = this.props, onResize = _a.onResize, maxRows = _a.maxRows; |
|
250 if (typeof maxRows === 'number') { |
|
251 this.updateLineHeight(); |
|
252 } |
|
253 /* |
|
254 the defer is needed to: |
|
255 - force "autosize" to activate the scrollbar when this.props.maxRows is passed |
|
256 - support StyledComponents (see #71) |
|
257 */ |
|
258 setTimeout(function () { return autosize(_this.textarea); }); |
|
259 if (onResize) { |
|
260 this.textarea.addEventListener(RESIZED, onResize); |
|
261 } |
|
262 }; |
|
263 TextareaAutosize.prototype.componentWillUnmount = function () { |
|
264 var onResize = this.props.onResize; |
|
265 if (onResize) { |
|
266 this.textarea.removeEventListener(RESIZED, onResize); |
|
267 } |
|
268 this.dispatchEvent(DESTROY); |
|
269 }; |
|
270 TextareaAutosize.prototype.render = function () { |
|
271 var _a = this.getLocals(), children = _a.children, saveDOMNodeRef = _a.saveDOMNodeRef, locals = __rest(_a, ["children", "saveDOMNodeRef"]); |
|
272 return (React.createElement("textarea", __assign({}, locals, { ref: saveDOMNodeRef }), children)); |
|
273 }; |
|
274 TextareaAutosize.prototype.componentDidUpdate = function (prevProps) { |
|
275 if (this.props.value !== this.currentValue || this.props.rows !== prevProps.rows) { |
|
276 this.dispatchEvent(UPDATE); |
|
277 } |
|
278 }; |
|
279 TextareaAutosize.defaultProps = { |
|
280 rows: 1 |
|
281 }; |
|
282 TextareaAutosize.propTypes = { |
|
283 rows: PropTypes.number, |
|
284 maxRows: PropTypes.number, |
|
285 onResize: PropTypes.func, |
|
286 innerRef: PropTypes.func |
|
287 }; |
|
288 return TextareaAutosize; |
|
289 }(React.Component)); |
|
290 exports["default"] = TextareaAutosize; |
|
291 |
|
292 |
|
293 /***/ }), |
|
294 |
|
295 /***/ 112: |
|
296 /***/ (function(module, exports, __webpack_require__) { |
|
297 |
|
298 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! |
|
299 autosize 4.0.2 |
|
300 license: MIT |
|
301 http://www.jacklmoore.com/autosize |
|
302 */ |
|
303 (function (global, factory) { |
|
304 if (true) { |
|
305 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory), |
|
306 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ? |
|
307 (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__), |
|
308 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
|
309 } else { var mod; } |
|
310 })(this, function (module, exports) { |
|
311 'use strict'; |
|
312 |
|
313 var map = typeof Map === "function" ? new Map() : function () { |
|
314 var keys = []; |
|
315 var values = []; |
|
316 |
|
317 return { |
|
318 has: function has(key) { |
|
319 return keys.indexOf(key) > -1; |
|
320 }, |
|
321 get: function get(key) { |
|
322 return values[keys.indexOf(key)]; |
|
323 }, |
|
324 set: function set(key, value) { |
|
325 if (keys.indexOf(key) === -1) { |
|
326 keys.push(key); |
|
327 values.push(value); |
|
328 } |
|
329 }, |
|
330 delete: function _delete(key) { |
|
331 var index = keys.indexOf(key); |
|
332 if (index > -1) { |
|
333 keys.splice(index, 1); |
|
334 values.splice(index, 1); |
|
335 } |
|
336 } |
|
337 }; |
|
338 }(); |
|
339 |
|
340 var createEvent = function createEvent(name) { |
|
341 return new Event(name, { bubbles: true }); |
|
342 }; |
|
343 try { |
|
344 new Event('test'); |
|
345 } catch (e) { |
|
346 // IE does not support `new Event()` |
|
347 createEvent = function createEvent(name) { |
|
348 var evt = document.createEvent('Event'); |
|
349 evt.initEvent(name, true, false); |
|
350 return evt; |
|
351 }; |
|
352 } |
|
353 |
|
354 function assign(ta) { |
|
355 if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has(ta)) return; |
|
356 |
|
357 var heightOffset = null; |
|
358 var clientWidth = null; |
|
359 var cachedHeight = null; |
|
360 |
|
361 function init() { |
|
362 var style = window.getComputedStyle(ta, null); |
|
363 |
|
364 if (style.resize === 'vertical') { |
|
365 ta.style.resize = 'none'; |
|
366 } else if (style.resize === 'both') { |
|
367 ta.style.resize = 'horizontal'; |
|
368 } |
|
369 |
|
370 if (style.boxSizing === 'content-box') { |
|
371 heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom)); |
|
372 } else { |
|
373 heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth); |
|
374 } |
|
375 // Fix when a textarea is not on document body and heightOffset is Not a Number |
|
376 if (isNaN(heightOffset)) { |
|
377 heightOffset = 0; |
|
378 } |
|
379 |
|
380 update(); |
|
381 } |
|
382 |
|
383 function changeOverflow(value) { |
|
384 { |
|
385 // Chrome/Safari-specific fix: |
|
386 // When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space |
|
387 // made available by removing the scrollbar. The following forces the necessary text reflow. |
|
388 var width = ta.style.width; |
|
389 ta.style.width = '0px'; |
|
390 // Force reflow: |
|
391 /* jshint ignore:start */ |
|
392 ta.offsetWidth; |
|
393 /* jshint ignore:end */ |
|
394 ta.style.width = width; |
|
395 } |
|
396 |
|
397 ta.style.overflowY = value; |
|
398 } |
|
399 |
|
400 function getParentOverflows(el) { |
|
401 var arr = []; |
|
402 |
|
403 while (el && el.parentNode && el.parentNode instanceof Element) { |
|
404 if (el.parentNode.scrollTop) { |
|
405 arr.push({ |
|
406 node: el.parentNode, |
|
407 scrollTop: el.parentNode.scrollTop |
|
408 }); |
|
409 } |
|
410 el = el.parentNode; |
|
411 } |
|
412 |
|
413 return arr; |
|
414 } |
|
415 |
|
416 function resize() { |
|
417 if (ta.scrollHeight === 0) { |
|
418 // If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM. |
|
419 return; |
|
420 } |
|
421 |
|
422 var overflows = getParentOverflows(ta); |
|
423 var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240) |
|
424 |
|
425 ta.style.height = ''; |
|
426 ta.style.height = ta.scrollHeight + heightOffset + 'px'; |
|
427 |
|
428 // used to check if an update is actually necessary on window.resize |
|
429 clientWidth = ta.clientWidth; |
|
430 |
|
431 // prevents scroll-position jumping |
|
432 overflows.forEach(function (el) { |
|
433 el.node.scrollTop = el.scrollTop; |
|
434 }); |
|
435 |
|
436 if (docTop) { |
|
437 document.documentElement.scrollTop = docTop; |
|
438 } |
|
439 } |
|
440 |
|
441 function update() { |
|
442 resize(); |
|
443 |
|
444 var styleHeight = Math.round(parseFloat(ta.style.height)); |
|
445 var computed = window.getComputedStyle(ta, null); |
|
446 |
|
447 // Using offsetHeight as a replacement for computed.height in IE, because IE does not account use of border-box |
|
448 var actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(computed.height)) : ta.offsetHeight; |
|
449 |
|
450 // The actual height not matching the style height (set via the resize method) indicates that |
|
451 // the max-height has been exceeded, in which case the overflow should be allowed. |
|
452 if (actualHeight < styleHeight) { |
|
453 if (computed.overflowY === 'hidden') { |
|
454 changeOverflow('scroll'); |
|
455 resize(); |
|
456 actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight; |
|
457 } |
|
458 } else { |
|
459 // Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands. |
|
460 if (computed.overflowY !== 'hidden') { |
|
461 changeOverflow('hidden'); |
|
462 resize(); |
|
463 actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight; |
|
464 } |
|
465 } |
|
466 |
|
467 if (cachedHeight !== actualHeight) { |
|
468 cachedHeight = actualHeight; |
|
469 var evt = createEvent('autosize:resized'); |
|
470 try { |
|
471 ta.dispatchEvent(evt); |
|
472 } catch (err) { |
|
473 // Firefox will throw an error on dispatchEvent for a detached element |
|
474 // https://bugzilla.mozilla.org/show_bug.cgi?id=889376 |
|
475 } |
|
476 } |
|
477 } |
|
478 |
|
479 var pageResize = function pageResize() { |
|
480 if (ta.clientWidth !== clientWidth) { |
|
481 update(); |
|
482 } |
|
483 }; |
|
484 |
|
485 var destroy = function (style) { |
|
486 window.removeEventListener('resize', pageResize, false); |
|
487 ta.removeEventListener('input', update, false); |
|
488 ta.removeEventListener('keyup', update, false); |
|
489 ta.removeEventListener('autosize:destroy', destroy, false); |
|
490 ta.removeEventListener('autosize:update', update, false); |
|
491 |
|
492 Object.keys(style).forEach(function (key) { |
|
493 ta.style[key] = style[key]; |
|
494 }); |
|
495 |
|
496 map.delete(ta); |
|
497 }.bind(ta, { |
|
498 height: ta.style.height, |
|
499 resize: ta.style.resize, |
|
500 overflowY: ta.style.overflowY, |
|
501 overflowX: ta.style.overflowX, |
|
502 wordWrap: ta.style.wordWrap |
|
503 }); |
|
504 |
|
505 ta.addEventListener('autosize:destroy', destroy, false); |
|
506 |
|
507 // IE9 does not fire onpropertychange or oninput for deletions, |
|
508 // so binding to onkeyup to catch most of those events. |
|
509 // There is no way that I know of to detect something like 'cut' in IE9. |
|
510 if ('onpropertychange' in ta && 'oninput' in ta) { |
|
511 ta.addEventListener('keyup', update, false); |
|
512 } |
|
513 |
|
514 window.addEventListener('resize', pageResize, false); |
|
515 ta.addEventListener('input', update, false); |
|
516 ta.addEventListener('autosize:update', update, false); |
|
517 ta.style.overflowX = 'hidden'; |
|
518 ta.style.wordWrap = 'break-word'; |
|
519 |
|
520 map.set(ta, { |
|
521 destroy: destroy, |
|
522 update: update |
|
523 }); |
|
524 |
|
525 init(); |
|
526 } |
|
527 |
|
528 function destroy(ta) { |
|
529 var methods = map.get(ta); |
|
530 if (methods) { |
|
531 methods.destroy(); |
|
532 } |
|
533 } |
|
534 |
|
535 function update(ta) { |
|
536 var methods = map.get(ta); |
|
537 if (methods) { |
|
538 methods.update(); |
|
539 } |
|
540 } |
|
541 |
|
542 var autosize = null; |
|
543 |
|
544 // Do nothing in Node.js environment and IE8 (or lower) |
|
545 if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') { |
|
546 autosize = function autosize(el) { |
|
547 return el; |
|
548 }; |
|
549 autosize.destroy = function (el) { |
|
550 return el; |
|
551 }; |
|
552 autosize.update = function (el) { |
|
553 return el; |
|
554 }; |
|
555 } else { |
|
556 autosize = function autosize(el, options) { |
|
557 if (el) { |
|
558 Array.prototype.forEach.call(el.length ? el : [el], function (x) { |
|
559 return assign(x, options); |
|
560 }); |
|
561 } |
|
562 return el; |
|
563 }; |
|
564 autosize.destroy = function (el) { |
|
565 if (el) { |
|
566 Array.prototype.forEach.call(el.length ? el : [el], destroy); |
|
567 } |
|
568 return el; |
|
569 }; |
|
570 autosize.update = function (el) { |
|
571 if (el) { |
|
572 Array.prototype.forEach.call(el.length ? el : [el], update); |
|
573 } |
|
574 return el; |
|
575 }; |
|
576 } |
|
577 |
|
578 exports.default = autosize; |
|
579 module.exports = exports['default']; |
|
580 }); |
|
581 |
|
582 /***/ }), |
|
583 |
|
584 /***/ 113: |
|
585 /***/ (function(module, exports, __webpack_require__) { |
|
586 |
|
587 // Load in dependencies |
|
588 var computedStyle = __webpack_require__(114); |
|
589 |
|
590 /** |
|
591 * Calculate the `line-height` of a given node |
|
592 * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM. |
|
593 * @returns {Number} `line-height` of the element in pixels |
|
594 */ |
|
595 function lineHeight(node) { |
|
596 // Grab the line-height via style |
|
597 var lnHeightStr = computedStyle(node, 'line-height'); |
|
598 var lnHeight = parseFloat(lnHeightStr, 10); |
|
599 |
|
600 // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em') |
|
601 if (lnHeightStr === lnHeight + '') { |
|
602 // Save the old lineHeight style and update the em unit to the element |
|
603 var _lnHeightStyle = node.style.lineHeight; |
|
604 node.style.lineHeight = lnHeightStr + 'em'; |
|
605 |
|
606 // Calculate the em based height |
|
607 lnHeightStr = computedStyle(node, 'line-height'); |
|
608 lnHeight = parseFloat(lnHeightStr, 10); |
|
609 |
|
610 // Revert the lineHeight style |
|
611 if (_lnHeightStyle) { |
|
612 node.style.lineHeight = _lnHeightStyle; |
|
613 } else { |
|
614 delete node.style.lineHeight; |
|
615 } |
|
616 } |
|
617 |
|
618 // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt) |
|
619 // DEV: `em` units are converted to `pt` in IE6 |
|
620 // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length |
|
621 if (lnHeightStr.indexOf('pt') !== -1) { |
|
622 lnHeight *= 4; |
|
623 lnHeight /= 3; |
|
624 // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm) |
|
625 } else if (lnHeightStr.indexOf('mm') !== -1) { |
|
626 lnHeight *= 96; |
|
627 lnHeight /= 25.4; |
|
628 // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm) |
|
629 } else if (lnHeightStr.indexOf('cm') !== -1) { |
|
630 lnHeight *= 96; |
|
631 lnHeight /= 2.54; |
|
632 // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in) |
|
633 } else if (lnHeightStr.indexOf('in') !== -1) { |
|
634 lnHeight *= 96; |
|
635 // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc) |
|
636 } else if (lnHeightStr.indexOf('pc') !== -1) { |
|
637 lnHeight *= 16; |
|
638 } |
|
639 |
|
640 // Continue our computation |
|
641 lnHeight = Math.round(lnHeight); |
|
642 |
|
643 // If the line-height is "normal", calculate by font-size |
|
644 if (lnHeightStr === 'normal') { |
|
645 // Create a temporary node |
|
646 var nodeName = node.nodeName; |
|
647 var _node = document.createElement(nodeName); |
|
648 _node.innerHTML = ' '; |
|
649 |
|
650 // If we have a text area, reset it to only 1 row |
|
651 // https://github.com/twolfson/line-height/issues/4 |
|
652 if (nodeName.toUpperCase() === 'TEXTAREA') { |
|
653 _node.setAttribute('rows', '1'); |
|
654 } |
|
655 |
|
656 // Set the font-size of the element |
|
657 var fontSizeStr = computedStyle(node, 'font-size'); |
|
658 _node.style.fontSize = fontSizeStr; |
|
659 |
|
660 // Remove default padding/border which can affect offset height |
|
661 // https://github.com/twolfson/line-height/issues/4 |
|
662 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight |
|
663 _node.style.padding = '0px'; |
|
664 _node.style.border = '0px'; |
|
665 |
|
666 // Append it to the body |
|
667 var body = document.body; |
|
668 body.appendChild(_node); |
|
669 |
|
670 // Assume the line height of the element is the height |
|
671 var height = _node.offsetHeight; |
|
672 lnHeight = height; |
|
673 |
|
674 // Remove our child from the DOM |
|
675 body.removeChild(_node); |
|
676 } |
|
677 |
|
678 // Return the calculated height |
|
679 return lnHeight; |
|
680 } |
|
681 |
|
682 // Export lineHeight |
|
683 module.exports = lineHeight; |
|
684 |
|
685 |
|
686 /***/ }), |
|
687 |
|
688 /***/ 114: |
|
689 /***/ (function(module, exports) { |
|
690 |
|
691 // This code has been refactored for 140 bytes |
|
692 // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js |
|
693 var computedStyle = function (el, prop, getComputedStyle) { |
|
694 getComputedStyle = window.getComputedStyle; |
|
695 |
|
696 // In one fell swoop |
|
697 return ( |
|
698 // If we have getComputedStyle |
|
699 getComputedStyle ? |
|
700 // Query it |
|
701 // TODO: From CSS-Query notes, we might need (node, null) for FF |
|
702 getComputedStyle(el) : |
|
703 |
|
704 // Otherwise, we are in IE and use currentStyle |
|
705 el.currentStyle |
|
706 )[ |
|
707 // Switch to camelCase for CSSOM |
|
708 // DEV: Grabbed from jQuery |
|
709 // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194 |
|
710 // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597 |
|
711 prop.replace(/-(\w)/gi, function (word, letter) { |
|
712 return letter.toUpperCase(); |
|
713 }) |
|
714 ]; |
|
715 }; |
|
716 |
|
717 module.exports = computedStyle; |
|
718 |
|
719 |
|
720 /***/ }), |
|
721 |
|
722 /***/ 117: |
|
723 /***/ (function(module, exports, __webpack_require__) { |
|
724 |
|
725 /* WEBPACK VAR INJECTION */(function(module, global) {var __WEBPACK_AMD_DEFINE_RESULT__;/*! https://mths.be/punycode v1.4.1 by @mathias */ |
|
726 ;(function(root) { |
|
727 |
|
728 /** Detect free variables */ |
|
729 var freeExports = true && exports && |
|
730 !exports.nodeType && exports; |
|
731 var freeModule = true && module && |
|
732 !module.nodeType && module; |
|
733 var freeGlobal = typeof global == 'object' && global; |
|
734 if ( |
|
735 freeGlobal.global === freeGlobal || |
|
736 freeGlobal.window === freeGlobal || |
|
737 freeGlobal.self === freeGlobal |
|
738 ) { |
|
739 root = freeGlobal; |
|
740 } |
|
741 |
|
742 /** |
|
743 * The `punycode` object. |
|
744 * @name punycode |
|
745 * @type Object |
|
746 */ |
|
747 var punycode, |
|
748 |
|
749 /** Highest positive signed 32-bit float value */ |
|
750 maxInt = 2147483647, // aka. 0x7FFFFFFF or 2^31-1 |
|
751 |
|
752 /** Bootstring parameters */ |
|
753 base = 36, |
|
754 tMin = 1, |
|
755 tMax = 26, |
|
756 skew = 38, |
|
757 damp = 700, |
|
758 initialBias = 72, |
|
759 initialN = 128, // 0x80 |
|
760 delimiter = '-', // '\x2D' |
|
761 |
|
762 /** Regular expressions */ |
|
763 regexPunycode = /^xn--/, |
|
764 regexNonASCII = /[^\x20-\x7E]/, // unprintable ASCII chars + non-ASCII chars |
|
765 regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, // RFC 3490 separators |
|
766 |
|
767 /** Error messages */ |
|
768 errors = { |
|
769 'overflow': 'Overflow: input needs wider integers to process', |
|
770 'not-basic': 'Illegal input >= 0x80 (not a basic code point)', |
|
771 'invalid-input': 'Invalid input' |
|
772 }, |
|
773 |
|
774 /** Convenience shortcuts */ |
|
775 baseMinusTMin = base - tMin, |
|
776 floor = Math.floor, |
|
777 stringFromCharCode = String.fromCharCode, |
|
778 |
|
779 /** Temporary variable */ |
|
780 key; |
|
781 |
|
782 /*--------------------------------------------------------------------------*/ |
|
783 |
|
784 /** |
|
785 * A generic error utility function. |
|
786 * @private |
|
787 * @param {String} type The error type. |
|
788 * @returns {Error} Throws a `RangeError` with the applicable error message. |
|
789 */ |
|
790 function error(type) { |
|
791 throw new RangeError(errors[type]); |
|
792 } |
|
793 |
|
794 /** |
|
795 * A generic `Array#map` utility function. |
|
796 * @private |
|
797 * @param {Array} array The array to iterate over. |
|
798 * @param {Function} callback The function that gets called for every array |
|
799 * item. |
|
800 * @returns {Array} A new array of values returned by the callback function. |
|
801 */ |
|
802 function map(array, fn) { |
|
803 var length = array.length; |
|
804 var result = []; |
|
805 while (length--) { |
|
806 result[length] = fn(array[length]); |
|
807 } |
|
808 return result; |
|
809 } |
|
810 |
|
811 /** |
|
812 * A simple `Array#map`-like wrapper to work with domain name strings or email |
|
813 * addresses. |
|
814 * @private |
|
815 * @param {String} domain The domain name or email address. |
|
816 * @param {Function} callback The function that gets called for every |
|
817 * character. |
|
818 * @returns {Array} A new string of characters returned by the callback |
|
819 * function. |
|
820 */ |
|
821 function mapDomain(string, fn) { |
|
822 var parts = string.split('@'); |
|
823 var result = ''; |
|
824 if (parts.length > 1) { |
|
825 // In email addresses, only the domain name should be punycoded. Leave |
|
826 // the local part (i.e. everything up to `@`) intact. |
|
827 result = parts[0] + '@'; |
|
828 string = parts[1]; |
|
829 } |
|
830 // Avoid `split(regex)` for IE8 compatibility. See #17. |
|
831 string = string.replace(regexSeparators, '\x2E'); |
|
832 var labels = string.split('.'); |
|
833 var encoded = map(labels, fn).join('.'); |
|
834 return result + encoded; |
|
835 } |
|
836 |
|
837 /** |
|
838 * Creates an array containing the numeric code points of each Unicode |
|
839 * character in the string. While JavaScript uses UCS-2 internally, |
|
840 * this function will convert a pair of surrogate halves (each of which |
|
841 * UCS-2 exposes as separate characters) into a single code point, |
|
842 * matching UTF-16. |
|
843 * @see `punycode.ucs2.encode` |
|
844 * @see <https://mathiasbynens.be/notes/javascript-encoding> |
|
845 * @memberOf punycode.ucs2 |
|
846 * @name decode |
|
847 * @param {String} string The Unicode input string (UCS-2). |
|
848 * @returns {Array} The new array of code points. |
|
849 */ |
|
850 function ucs2decode(string) { |
|
851 var output = [], |
|
852 counter = 0, |
|
853 length = string.length, |
|
854 value, |
|
855 extra; |
|
856 while (counter < length) { |
|
857 value = string.charCodeAt(counter++); |
|
858 if (value >= 0xD800 && value <= 0xDBFF && counter < length) { |
|
859 // high surrogate, and there is a next character |
|
860 extra = string.charCodeAt(counter++); |
|
861 if ((extra & 0xFC00) == 0xDC00) { // low surrogate |
|
862 output.push(((value & 0x3FF) << 10) + (extra & 0x3FF) + 0x10000); |
|
863 } else { |
|
864 // unmatched surrogate; only append this code unit, in case the next |
|
865 // code unit is the high surrogate of a surrogate pair |
|
866 output.push(value); |
|
867 counter--; |
|
868 } |
|
869 } else { |
|
870 output.push(value); |
|
871 } |
|
872 } |
|
873 return output; |
|
874 } |
|
875 |
|
876 /** |
|
877 * Creates a string based on an array of numeric code points. |
|
878 * @see `punycode.ucs2.decode` |
|
879 * @memberOf punycode.ucs2 |
|
880 * @name encode |
|
881 * @param {Array} codePoints The array of numeric code points. |
|
882 * @returns {String} The new Unicode string (UCS-2). |
|
883 */ |
|
884 function ucs2encode(array) { |
|
885 return map(array, function(value) { |
|
886 var output = ''; |
|
887 if (value > 0xFFFF) { |
|
888 value -= 0x10000; |
|
889 output += stringFromCharCode(value >>> 10 & 0x3FF | 0xD800); |
|
890 value = 0xDC00 | value & 0x3FF; |
|
891 } |
|
892 output += stringFromCharCode(value); |
|
893 return output; |
|
894 }).join(''); |
|
895 } |
|
896 |
|
897 /** |
|
898 * Converts a basic code point into a digit/integer. |
|
899 * @see `digitToBasic()` |
|
900 * @private |
|
901 * @param {Number} codePoint The basic numeric code point value. |
|
902 * @returns {Number} The numeric value of a basic code point (for use in |
|
903 * representing integers) in the range `0` to `base - 1`, or `base` if |
|
904 * the code point does not represent a value. |
|
905 */ |
|
906 function basicToDigit(codePoint) { |
|
907 if (codePoint - 48 < 10) { |
|
908 return codePoint - 22; |
|
909 } |
|
910 if (codePoint - 65 < 26) { |
|
911 return codePoint - 65; |
|
912 } |
|
913 if (codePoint - 97 < 26) { |
|
914 return codePoint - 97; |
|
915 } |
|
916 return base; |
|
917 } |
|
918 |
|
919 /** |
|
920 * Converts a digit/integer into a basic code point. |
|
921 * @see `basicToDigit()` |
|
922 * @private |
|
923 * @param {Number} digit The numeric value of a basic code point. |
|
924 * @returns {Number} The basic code point whose value (when used for |
|
925 * representing integers) is `digit`, which needs to be in the range |
|
926 * `0` to `base - 1`. If `flag` is non-zero, the uppercase form is |
|
927 * used; else, the lowercase form is used. The behavior is undefined |
|
928 * if `flag` is non-zero and `digit` has no uppercase form. |
|
929 */ |
|
930 function digitToBasic(digit, flag) { |
|
931 // 0..25 map to ASCII a..z or A..Z |
|
932 // 26..35 map to ASCII 0..9 |
|
933 return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5); |
|
934 } |
|
935 |
|
936 /** |
|
937 * Bias adaptation function as per section 3.4 of RFC 3492. |
|
938 * https://tools.ietf.org/html/rfc3492#section-3.4 |
|
939 * @private |
|
940 */ |
|
941 function adapt(delta, numPoints, firstTime) { |
|
942 var k = 0; |
|
943 delta = firstTime ? floor(delta / damp) : delta >> 1; |
|
944 delta += floor(delta / numPoints); |
|
945 for (/* no initialization */; delta > baseMinusTMin * tMax >> 1; k += base) { |
|
946 delta = floor(delta / baseMinusTMin); |
|
947 } |
|
948 return floor(k + (baseMinusTMin + 1) * delta / (delta + skew)); |
|
949 } |
|
950 |
|
951 /** |
|
952 * Converts a Punycode string of ASCII-only symbols to a string of Unicode |
|
953 * symbols. |
|
954 * @memberOf punycode |
|
955 * @param {String} input The Punycode string of ASCII-only symbols. |
|
956 * @returns {String} The resulting string of Unicode symbols. |
|
957 */ |
|
958 function decode(input) { |
|
959 // Don't use UCS-2 |
|
960 var output = [], |
|
961 inputLength = input.length, |
|
962 out, |
|
963 i = 0, |
|
964 n = initialN, |
|
965 bias = initialBias, |
|
966 basic, |
|
967 j, |
|
968 index, |
|
969 oldi, |
|
970 w, |
|
971 k, |
|
972 digit, |
|
973 t, |
|
974 /** Cached calculation results */ |
|
975 baseMinusT; |
|
976 |
|
977 // Handle the basic code points: let `basic` be the number of input code |
|
978 // points before the last delimiter, or `0` if there is none, then copy |
|
979 // the first basic code points to the output. |
|
980 |
|
981 basic = input.lastIndexOf(delimiter); |
|
982 if (basic < 0) { |
|
983 basic = 0; |
|
984 } |
|
985 |
|
986 for (j = 0; j < basic; ++j) { |
|
987 // if it's not a basic code point |
|
988 if (input.charCodeAt(j) >= 0x80) { |
|
989 error('not-basic'); |
|
990 } |
|
991 output.push(input.charCodeAt(j)); |
|
992 } |
|
993 |
|
994 // Main decoding loop: start just after the last delimiter if any basic code |
|
995 // points were copied; start at the beginning otherwise. |
|
996 |
|
997 for (index = basic > 0 ? basic + 1 : 0; index < inputLength; /* no final expression */) { |
|
998 |
|
999 // `index` is the index of the next character to be consumed. |
|
1000 // Decode a generalized variable-length integer into `delta`, |
|
1001 // which gets added to `i`. The overflow checking is easier |
|
1002 // if we increase `i` as we go, then subtract off its starting |
|
1003 // value at the end to obtain `delta`. |
|
1004 for (oldi = i, w = 1, k = base; /* no condition */; k += base) { |
|
1005 |
|
1006 if (index >= inputLength) { |
|
1007 error('invalid-input'); |
|
1008 } |
|
1009 |
|
1010 digit = basicToDigit(input.charCodeAt(index++)); |
|
1011 |
|
1012 if (digit >= base || digit > floor((maxInt - i) / w)) { |
|
1013 error('overflow'); |
|
1014 } |
|
1015 |
|
1016 i += digit * w; |
|
1017 t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); |
|
1018 |
|
1019 if (digit < t) { |
|
1020 break; |
|
1021 } |
|
1022 |
|
1023 baseMinusT = base - t; |
|
1024 if (w > floor(maxInt / baseMinusT)) { |
|
1025 error('overflow'); |
|
1026 } |
|
1027 |
|
1028 w *= baseMinusT; |
|
1029 |
|
1030 } |
|
1031 |
|
1032 out = output.length + 1; |
|
1033 bias = adapt(i - oldi, out, oldi == 0); |
|
1034 |
|
1035 // `i` was supposed to wrap around from `out` to `0`, |
|
1036 // incrementing `n` each time, so we'll fix that now: |
|
1037 if (floor(i / out) > maxInt - n) { |
|
1038 error('overflow'); |
|
1039 } |
|
1040 |
|
1041 n += floor(i / out); |
|
1042 i %= out; |
|
1043 |
|
1044 // Insert `n` at position `i` of the output |
|
1045 output.splice(i++, 0, n); |
|
1046 |
|
1047 } |
|
1048 |
|
1049 return ucs2encode(output); |
|
1050 } |
|
1051 |
|
1052 /** |
|
1053 * Converts a string of Unicode symbols (e.g. a domain name label) to a |
|
1054 * Punycode string of ASCII-only symbols. |
|
1055 * @memberOf punycode |
|
1056 * @param {String} input The string of Unicode symbols. |
|
1057 * @returns {String} The resulting Punycode string of ASCII-only symbols. |
|
1058 */ |
|
1059 function encode(input) { |
|
1060 var n, |
|
1061 delta, |
|
1062 handledCPCount, |
|
1063 basicLength, |
|
1064 bias, |
|
1065 j, |
|
1066 m, |
|
1067 q, |
|
1068 k, |
|
1069 t, |
|
1070 currentValue, |
|
1071 output = [], |
|
1072 /** `inputLength` will hold the number of code points in `input`. */ |
|
1073 inputLength, |
|
1074 /** Cached calculation results */ |
|
1075 handledCPCountPlusOne, |
|
1076 baseMinusT, |
|
1077 qMinusT; |
|
1078 |
|
1079 // Convert the input in UCS-2 to Unicode |
|
1080 input = ucs2decode(input); |
|
1081 |
|
1082 // Cache the length |
|
1083 inputLength = input.length; |
|
1084 |
|
1085 // Initialize the state |
|
1086 n = initialN; |
|
1087 delta = 0; |
|
1088 bias = initialBias; |
|
1089 |
|
1090 // Handle the basic code points |
|
1091 for (j = 0; j < inputLength; ++j) { |
|
1092 currentValue = input[j]; |
|
1093 if (currentValue < 0x80) { |
|
1094 output.push(stringFromCharCode(currentValue)); |
|
1095 } |
|
1096 } |
|
1097 |
|
1098 handledCPCount = basicLength = output.length; |
|
1099 |
|
1100 // `handledCPCount` is the number of code points that have been handled; |
|
1101 // `basicLength` is the number of basic code points. |
|
1102 |
|
1103 // Finish the basic string - if it is not empty - with a delimiter |
|
1104 if (basicLength) { |
|
1105 output.push(delimiter); |
|
1106 } |
|
1107 |
|
1108 // Main encoding loop: |
|
1109 while (handledCPCount < inputLength) { |
|
1110 |
|
1111 // All non-basic code points < n have been handled already. Find the next |
|
1112 // larger one: |
|
1113 for (m = maxInt, j = 0; j < inputLength; ++j) { |
|
1114 currentValue = input[j]; |
|
1115 if (currentValue >= n && currentValue < m) { |
|
1116 m = currentValue; |
|
1117 } |
|
1118 } |
|
1119 |
|
1120 // Increase `delta` enough to advance the decoder's <n,i> state to <m,0>, |
|
1121 // but guard against overflow |
|
1122 handledCPCountPlusOne = handledCPCount + 1; |
|
1123 if (m - n > floor((maxInt - delta) / handledCPCountPlusOne)) { |
|
1124 error('overflow'); |
|
1125 } |
|
1126 |
|
1127 delta += (m - n) * handledCPCountPlusOne; |
|
1128 n = m; |
|
1129 |
|
1130 for (j = 0; j < inputLength; ++j) { |
|
1131 currentValue = input[j]; |
|
1132 |
|
1133 if (currentValue < n && ++delta > maxInt) { |
|
1134 error('overflow'); |
|
1135 } |
|
1136 |
|
1137 if (currentValue == n) { |
|
1138 // Represent delta as a generalized variable-length integer |
|
1139 for (q = delta, k = base; /* no condition */; k += base) { |
|
1140 t = k <= bias ? tMin : (k >= bias + tMax ? tMax : k - bias); |
|
1141 if (q < t) { |
|
1142 break; |
|
1143 } |
|
1144 qMinusT = q - t; |
|
1145 baseMinusT = base - t; |
|
1146 output.push( |
|
1147 stringFromCharCode(digitToBasic(t + qMinusT % baseMinusT, 0)) |
|
1148 ); |
|
1149 q = floor(qMinusT / baseMinusT); |
|
1150 } |
|
1151 |
|
1152 output.push(stringFromCharCode(digitToBasic(q, 0))); |
|
1153 bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength); |
|
1154 delta = 0; |
|
1155 ++handledCPCount; |
|
1156 } |
|
1157 } |
|
1158 |
|
1159 ++delta; |
|
1160 ++n; |
|
1161 |
|
1162 } |
|
1163 return output.join(''); |
|
1164 } |
|
1165 |
|
1166 /** |
|
1167 * Converts a Punycode string representing a domain name or an email address |
|
1168 * to Unicode. Only the Punycoded parts of the input will be converted, i.e. |
|
1169 * it doesn't matter if you call it on a string that has already been |
|
1170 * converted to Unicode. |
|
1171 * @memberOf punycode |
|
1172 * @param {String} input The Punycoded domain name or email address to |
|
1173 * convert to Unicode. |
|
1174 * @returns {String} The Unicode representation of the given Punycode |
|
1175 * string. |
|
1176 */ |
|
1177 function toUnicode(input) { |
|
1178 return mapDomain(input, function(string) { |
|
1179 return regexPunycode.test(string) |
|
1180 ? decode(string.slice(4).toLowerCase()) |
|
1181 : string; |
|
1182 }); |
|
1183 } |
|
1184 |
|
1185 /** |
|
1186 * Converts a Unicode string representing a domain name or an email address to |
|
1187 * Punycode. Only the non-ASCII parts of the domain name will be converted, |
|
1188 * i.e. it doesn't matter if you call it with a domain that's already in |
|
1189 * ASCII. |
|
1190 * @memberOf punycode |
|
1191 * @param {String} input The domain name or email address to convert, as a |
|
1192 * Unicode string. |
|
1193 * @returns {String} The Punycode representation of the given domain name or |
|
1194 * email address. |
|
1195 */ |
|
1196 function toASCII(input) { |
|
1197 return mapDomain(input, function(string) { |
|
1198 return regexNonASCII.test(string) |
|
1199 ? 'xn--' + encode(string) |
|
1200 : string; |
|
1201 }); |
|
1202 } |
|
1203 |
|
1204 /*--------------------------------------------------------------------------*/ |
|
1205 |
|
1206 /** Define the public API */ |
|
1207 punycode = { |
|
1208 /** |
|
1209 * A string representing the current Punycode.js version number. |
|
1210 * @memberOf punycode |
|
1211 * @type String |
|
1212 */ |
|
1213 'version': '1.4.1', |
|
1214 /** |
|
1215 * An object of methods to convert from JavaScript's internal character |
|
1216 * representation (UCS-2) to Unicode code points, and back. |
|
1217 * @see <https://mathiasbynens.be/notes/javascript-encoding> |
|
1218 * @memberOf punycode |
|
1219 * @type Object |
|
1220 */ |
|
1221 'ucs2': { |
|
1222 'decode': ucs2decode, |
|
1223 'encode': ucs2encode |
|
1224 }, |
|
1225 'decode': decode, |
|
1226 'encode': encode, |
|
1227 'toASCII': toASCII, |
|
1228 'toUnicode': toUnicode |
|
1229 }; |
|
1230 |
|
1231 /** Expose `punycode` */ |
|
1232 // Some AMD build optimizers, like r.js, check for specific condition patterns |
|
1233 // like the following: |
|
1234 if ( |
|
1235 true |
|
1236 ) { |
|
1237 !(__WEBPACK_AMD_DEFINE_RESULT__ = (function() { |
|
1238 return punycode; |
|
1239 }).call(exports, __webpack_require__, exports, module), |
|
1240 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
|
1241 } else {} |
|
1242 |
|
1243 }(this)); |
|
1244 |
|
1245 /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(118)(module), __webpack_require__(59))) |
|
1246 |
|
1247 /***/ }), |
|
1248 |
|
1249 /***/ 118: |
|
1250 /***/ (function(module, exports) { |
|
1251 |
|
1252 module.exports = function(module) { |
|
1253 if (!module.webpackPolyfill) { |
|
1254 module.deprecate = function() {}; |
|
1255 module.paths = []; |
|
1256 // module.parent = undefined by default |
|
1257 if (!module.children) module.children = []; |
|
1258 Object.defineProperty(module, "loaded", { |
|
1259 enumerable: true, |
|
1260 get: function() { |
|
1261 return module.l; |
|
1262 } |
|
1263 }); |
|
1264 Object.defineProperty(module, "id", { |
|
1265 enumerable: true, |
|
1266 get: function() { |
|
1267 return module.i; |
|
1268 } |
|
1269 }); |
|
1270 module.webpackPolyfill = 1; |
|
1271 } |
|
1272 return module; |
|
1273 }; |
|
1274 |
|
1275 |
|
1276 /***/ }), |
|
1277 |
|
1278 /***/ 119: |
|
1279 /***/ (function(module, exports, __webpack_require__) { |
|
1280 |
|
1281 "use strict"; |
|
1282 |
|
1283 |
|
1284 module.exports = { |
|
1285 isString: function(arg) { |
|
1286 return typeof(arg) === 'string'; |
|
1287 }, |
|
1288 isObject: function(arg) { |
|
1289 return typeof(arg) === 'object' && arg !== null; |
|
1290 }, |
|
1291 isNull: function(arg) { |
|
1292 return arg === null; |
|
1293 }, |
|
1294 isNullOrUndefined: function(arg) { |
|
1295 return arg == null; |
|
1296 } |
|
1297 }; |
|
1298 |
|
1299 |
|
1300 /***/ }), |
|
1301 |
|
1302 /***/ 12: |
|
1303 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1304 |
|
1305 "use strict"; |
|
1306 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _getPrototypeOf; }); |
|
1307 function _getPrototypeOf(o) { |
|
1308 _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { |
|
1309 return o.__proto__ || Object.getPrototypeOf(o); |
|
1310 }; |
|
1311 return _getPrototypeOf(o); |
|
1312 } |
|
1313 |
|
1314 /***/ }), |
|
1315 |
|
1316 /***/ 120: |
|
1317 /***/ (function(module, exports, __webpack_require__) { |
|
1318 |
|
1319 "use strict"; |
|
1320 |
|
1321 |
|
1322 exports.decode = exports.parse = __webpack_require__(121); |
|
1323 exports.encode = exports.stringify = __webpack_require__(122); |
|
1324 |
|
1325 |
|
1326 /***/ }), |
|
1327 |
|
1328 /***/ 121: |
|
1329 /***/ (function(module, exports, __webpack_require__) { |
|
1330 |
|
1331 "use strict"; |
|
1332 // Copyright Joyent, Inc. and other Node contributors. |
|
1333 // |
|
1334 // Permission is hereby granted, free of charge, to any person obtaining a |
|
1335 // copy of this software and associated documentation files (the |
|
1336 // "Software"), to deal in the Software without restriction, including |
|
1337 // without limitation the rights to use, copy, modify, merge, publish, |
|
1338 // distribute, sublicense, and/or sell copies of the Software, and to permit |
|
1339 // persons to whom the Software is furnished to do so, subject to the |
|
1340 // following conditions: |
|
1341 // |
|
1342 // The above copyright notice and this permission notice shall be included |
|
1343 // in all copies or substantial portions of the Software. |
|
1344 // |
|
1345 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|
1346 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
1347 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
|
1348 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
|
1349 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
|
1350 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
|
1351 // USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
1352 |
|
1353 |
|
1354 |
|
1355 // If obj.hasOwnProperty has been overridden, then calling |
|
1356 // obj.hasOwnProperty(prop) will break. |
|
1357 // See: https://github.com/joyent/node/issues/1707 |
|
1358 function hasOwnProperty(obj, prop) { |
|
1359 return Object.prototype.hasOwnProperty.call(obj, prop); |
|
1360 } |
|
1361 |
|
1362 module.exports = function(qs, sep, eq, options) { |
|
1363 sep = sep || '&'; |
|
1364 eq = eq || '='; |
|
1365 var obj = {}; |
|
1366 |
|
1367 if (typeof qs !== 'string' || qs.length === 0) { |
|
1368 return obj; |
|
1369 } |
|
1370 |
|
1371 var regexp = /\+/g; |
|
1372 qs = qs.split(sep); |
|
1373 |
|
1374 var maxKeys = 1000; |
|
1375 if (options && typeof options.maxKeys === 'number') { |
|
1376 maxKeys = options.maxKeys; |
|
1377 } |
|
1378 |
|
1379 var len = qs.length; |
|
1380 // maxKeys <= 0 means that we should not limit keys count |
|
1381 if (maxKeys > 0 && len > maxKeys) { |
|
1382 len = maxKeys; |
|
1383 } |
|
1384 |
|
1385 for (var i = 0; i < len; ++i) { |
|
1386 var x = qs[i].replace(regexp, '%20'), |
|
1387 idx = x.indexOf(eq), |
|
1388 kstr, vstr, k, v; |
|
1389 |
|
1390 if (idx >= 0) { |
|
1391 kstr = x.substr(0, idx); |
|
1392 vstr = x.substr(idx + 1); |
|
1393 } else { |
|
1394 kstr = x; |
|
1395 vstr = ''; |
|
1396 } |
|
1397 |
|
1398 k = decodeURIComponent(kstr); |
|
1399 v = decodeURIComponent(vstr); |
|
1400 |
|
1401 if (!hasOwnProperty(obj, k)) { |
|
1402 obj[k] = v; |
|
1403 } else if (isArray(obj[k])) { |
|
1404 obj[k].push(v); |
|
1405 } else { |
|
1406 obj[k] = [obj[k], v]; |
|
1407 } |
|
1408 } |
|
1409 |
|
1410 return obj; |
|
1411 }; |
|
1412 |
|
1413 var isArray = Array.isArray || function (xs) { |
|
1414 return Object.prototype.toString.call(xs) === '[object Array]'; |
|
1415 }; |
|
1416 |
|
1417 |
|
1418 /***/ }), |
|
1419 |
|
1420 /***/ 122: |
|
1421 /***/ (function(module, exports, __webpack_require__) { |
|
1422 |
|
1423 "use strict"; |
|
1424 // Copyright Joyent, Inc. and other Node contributors. |
|
1425 // |
|
1426 // Permission is hereby granted, free of charge, to any person obtaining a |
|
1427 // copy of this software and associated documentation files (the |
|
1428 // "Software"), to deal in the Software without restriction, including |
|
1429 // without limitation the rights to use, copy, modify, merge, publish, |
|
1430 // distribute, sublicense, and/or sell copies of the Software, and to permit |
|
1431 // persons to whom the Software is furnished to do so, subject to the |
|
1432 // following conditions: |
|
1433 // |
|
1434 // The above copyright notice and this permission notice shall be included |
|
1435 // in all copies or substantial portions of the Software. |
|
1436 // |
|
1437 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|
1438 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
1439 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
|
1440 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
|
1441 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
|
1442 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
|
1443 // USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
1444 |
|
1445 |
|
1446 |
|
1447 var stringifyPrimitive = function(v) { |
|
1448 switch (typeof v) { |
|
1449 case 'string': |
|
1450 return v; |
|
1451 |
|
1452 case 'boolean': |
|
1453 return v ? 'true' : 'false'; |
|
1454 |
|
1455 case 'number': |
|
1456 return isFinite(v) ? v : ''; |
|
1457 |
|
1458 default: |
|
1459 return ''; |
|
1460 } |
|
1461 }; |
|
1462 |
|
1463 module.exports = function(obj, sep, eq, name) { |
|
1464 sep = sep || '&'; |
|
1465 eq = eq || '='; |
|
1466 if (obj === null) { |
|
1467 obj = undefined; |
|
1468 } |
|
1469 |
|
1470 if (typeof obj === 'object') { |
|
1471 return map(objectKeys(obj), function(k) { |
|
1472 var ks = encodeURIComponent(stringifyPrimitive(k)) + eq; |
|
1473 if (isArray(obj[k])) { |
|
1474 return map(obj[k], function(v) { |
|
1475 return ks + encodeURIComponent(stringifyPrimitive(v)); |
|
1476 }).join(sep); |
|
1477 } else { |
|
1478 return ks + encodeURIComponent(stringifyPrimitive(obj[k])); |
|
1479 } |
|
1480 }).join(sep); |
|
1481 |
|
1482 } |
|
1483 |
|
1484 if (!name) return ''; |
|
1485 return encodeURIComponent(stringifyPrimitive(name)) + eq + |
|
1486 encodeURIComponent(stringifyPrimitive(obj)); |
|
1487 }; |
|
1488 |
|
1489 var isArray = Array.isArray || function (xs) { |
|
1490 return Object.prototype.toString.call(xs) === '[object Array]'; |
|
1491 }; |
|
1492 |
|
1493 function map (xs, f) { |
|
1494 if (xs.map) return xs.map(f); |
|
1495 var res = []; |
|
1496 for (var i = 0; i < xs.length; i++) { |
|
1497 res.push(f(xs[i], i)); |
|
1498 } |
|
1499 return res; |
|
1500 } |
|
1501 |
|
1502 var objectKeys = Object.keys || function (obj) { |
|
1503 var res = []; |
|
1504 for (var key in obj) { |
|
1505 if (Object.prototype.hasOwnProperty.call(obj, key)) res.push(key); |
|
1506 } |
|
1507 return res; |
|
1508 }; |
|
1509 |
|
1510 |
|
1511 /***/ }), |
|
1512 |
|
1513 /***/ 13: |
|
1514 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1515 |
|
1516 "use strict"; |
|
1517 |
|
1518 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js |
|
1519 function _setPrototypeOf(o, p) { |
|
1520 _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { |
|
1521 o.__proto__ = p; |
|
1522 return o; |
|
1523 }; |
|
1524 |
|
1525 return _setPrototypeOf(o, p); |
|
1526 } |
|
1527 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js |
|
1528 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _inherits; }); |
|
1529 |
|
1530 function _inherits(subClass, superClass) { |
|
1531 if (typeof superClass !== "function" && superClass !== null) { |
|
1532 throw new TypeError("Super expression must either be null or a function"); |
|
1533 } |
|
1534 |
|
1535 subClass.prototype = Object.create(superClass && superClass.prototype, { |
|
1536 constructor: { |
|
1537 value: subClass, |
|
1538 writable: true, |
|
1539 configurable: true |
|
1540 } |
|
1541 }); |
|
1542 if (superClass) _setPrototypeOf(subClass, superClass); |
|
1543 } |
|
1544 |
|
1545 /***/ }), |
|
1546 |
|
1547 /***/ 133: |
|
1548 /***/ (function(module, exports) { |
|
1549 |
|
1550 (function() { module.exports = this["wp"]["notices"]; }()); |
|
1551 |
|
1552 /***/ }), |
|
1553 |
|
1554 /***/ 14: |
|
1555 /***/ (function(module, exports) { |
|
1556 |
|
1557 (function() { module.exports = this["wp"]["blocks"]; }()); |
|
1558 |
|
1559 /***/ }), |
|
1560 |
|
1561 /***/ 15: |
|
1562 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1563 |
|
1564 "use strict"; |
|
1565 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _defineProperty; }); |
|
1566 function _defineProperty(obj, key, value) { |
|
1567 if (key in obj) { |
|
1568 Object.defineProperty(obj, key, { |
|
1569 value: value, |
|
1570 enumerable: true, |
|
1571 configurable: true, |
|
1572 writable: true |
|
1573 }); |
|
1574 } else { |
|
1575 obj[key] = value; |
|
1576 } |
|
1577 |
|
1578 return obj; |
|
1579 } |
|
1580 |
|
1581 /***/ }), |
|
1582 |
|
1583 /***/ 16: |
|
1584 /***/ (function(module, exports, __webpack_require__) { |
|
1585 |
|
1586 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! |
|
1587 Copyright (c) 2017 Jed Watson. |
|
1588 Licensed under the MIT License (MIT), see |
|
1589 http://jedwatson.github.io/classnames |
|
1590 */ |
|
1591 /* global define */ |
|
1592 |
|
1593 (function () { |
|
1594 'use strict'; |
|
1595 |
|
1596 var hasOwn = {}.hasOwnProperty; |
|
1597 |
|
1598 function classNames () { |
|
1599 var classes = []; |
|
1600 |
|
1601 for (var i = 0; i < arguments.length; i++) { |
|
1602 var arg = arguments[i]; |
|
1603 if (!arg) continue; |
|
1604 |
|
1605 var argType = typeof arg; |
|
1606 |
|
1607 if (argType === 'string' || argType === 'number') { |
|
1608 classes.push(arg); |
|
1609 } else if (Array.isArray(arg) && arg.length) { |
|
1610 var inner = classNames.apply(null, arg); |
|
1611 if (inner) { |
|
1612 classes.push(inner); |
|
1613 } |
|
1614 } else if (argType === 'object') { |
|
1615 for (var key in arg) { |
|
1616 if (hasOwn.call(arg, key) && arg[key]) { |
|
1617 classes.push(key); |
|
1618 } |
|
1619 } |
|
1620 } |
|
1621 } |
|
1622 |
|
1623 return classes.join(' '); |
|
1624 } |
|
1625 |
|
1626 if ( true && module.exports) { |
|
1627 classNames.default = classNames; |
|
1628 module.exports = classNames; |
|
1629 } else if (true) { |
|
1630 // register as 'classnames', consistent with npm package name |
|
1631 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () { |
|
1632 return classNames; |
|
1633 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__), |
|
1634 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)); |
|
1635 } else {} |
|
1636 }()); |
|
1637 |
|
1638 |
|
1639 /***/ }), |
|
1640 |
|
1641 /***/ 17: |
|
1642 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1643 |
|
1644 "use strict"; |
|
1645 |
|
1646 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithoutHoles.js |
|
1647 function _arrayWithoutHoles(arr) { |
|
1648 if (Array.isArray(arr)) { |
|
1649 for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { |
|
1650 arr2[i] = arr[i]; |
|
1651 } |
|
1652 |
|
1653 return arr2; |
|
1654 } |
|
1655 } |
|
1656 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArray.js |
|
1657 var iterableToArray = __webpack_require__(34); |
|
1658 |
|
1659 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableSpread.js |
|
1660 function _nonIterableSpread() { |
|
1661 throw new TypeError("Invalid attempt to spread non-iterable instance"); |
|
1662 } |
|
1663 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js |
|
1664 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _toConsumableArray; }); |
|
1665 |
|
1666 |
|
1667 |
|
1668 function _toConsumableArray(arr) { |
|
1669 return _arrayWithoutHoles(arr) || Object(iterableToArray["a" /* default */])(arr) || _nonIterableSpread(); |
|
1670 } |
|
1671 |
|
1672 /***/ }), |
|
1673 |
|
1674 /***/ 18: |
|
1675 /***/ (function(module, exports) { |
|
1676 |
|
1677 (function() { module.exports = this["wp"]["keycodes"]; }()); |
|
1678 |
|
1679 /***/ }), |
|
1680 |
|
1681 /***/ 19: |
|
1682 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1683 |
|
1684 "use strict"; |
|
1685 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _extends; }); |
|
1686 function _extends() { |
|
1687 _extends = Object.assign || function (target) { |
|
1688 for (var i = 1; i < arguments.length; i++) { |
|
1689 var source = arguments[i]; |
|
1690 |
|
1691 for (var key in source) { |
|
1692 if (Object.prototype.hasOwnProperty.call(source, key)) { |
|
1693 target[key] = source[key]; |
|
1694 } |
|
1695 } |
|
1696 } |
|
1697 |
|
1698 return target; |
|
1699 }; |
|
1700 |
|
1701 return _extends.apply(this, arguments); |
|
1702 } |
|
1703 |
|
1704 /***/ }), |
|
1705 |
|
1706 /***/ 2: |
|
1707 /***/ (function(module, exports) { |
|
1708 |
|
1709 (function() { module.exports = this["lodash"]; }()); |
|
1710 |
|
1711 /***/ }), |
|
1712 |
|
1713 /***/ 20: |
|
1714 /***/ (function(module, exports) { |
|
1715 |
|
1716 (function() { module.exports = this["wp"]["richText"]; }()); |
|
1717 |
|
1718 /***/ }), |
|
1719 |
|
1720 /***/ 21: |
|
1721 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
1722 |
|
1723 "use strict"; |
|
1724 |
|
1725 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutPropertiesLoose.js |
|
1726 function _objectWithoutPropertiesLoose(source, excluded) { |
|
1727 if (source == null) return {}; |
|
1728 var target = {}; |
|
1729 var sourceKeys = Object.keys(source); |
|
1730 var key, i; |
|
1731 |
|
1732 for (i = 0; i < sourceKeys.length; i++) { |
|
1733 key = sourceKeys[i]; |
|
1734 if (excluded.indexOf(key) >= 0) continue; |
|
1735 target[key] = source[key]; |
|
1736 } |
|
1737 |
|
1738 return target; |
|
1739 } |
|
1740 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js |
|
1741 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectWithoutProperties; }); |
|
1742 |
|
1743 function _objectWithoutProperties(source, excluded) { |
|
1744 if (source == null) return {}; |
|
1745 var target = _objectWithoutPropertiesLoose(source, excluded); |
|
1746 var key, i; |
|
1747 |
|
1748 if (Object.getOwnPropertySymbols) { |
|
1749 var sourceSymbolKeys = Object.getOwnPropertySymbols(source); |
|
1750 |
|
1751 for (i = 0; i < sourceSymbolKeys.length; i++) { |
|
1752 key = sourceSymbolKeys[i]; |
|
1753 if (excluded.indexOf(key) >= 0) continue; |
|
1754 if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; |
|
1755 target[key] = source[key]; |
|
1756 } |
|
1757 } |
|
1758 |
|
1759 return target; |
|
1760 } |
|
1761 |
|
1762 /***/ }), |
|
1763 |
|
1764 /***/ 227: |
|
1765 /***/ (function(module, exports) { |
|
1766 |
|
1767 var traverse = module.exports = function (obj) { |
|
1768 return new Traverse(obj); |
|
1769 }; |
|
1770 |
|
1771 function Traverse (obj) { |
|
1772 this.value = obj; |
|
1773 } |
|
1774 |
|
1775 Traverse.prototype.get = function (ps) { |
|
1776 var node = this.value; |
|
1777 for (var i = 0; i < ps.length; i ++) { |
|
1778 var key = ps[i]; |
|
1779 if (!node || !hasOwnProperty.call(node, key)) { |
|
1780 node = undefined; |
|
1781 break; |
|
1782 } |
|
1783 node = node[key]; |
|
1784 } |
|
1785 return node; |
|
1786 }; |
|
1787 |
|
1788 Traverse.prototype.has = function (ps) { |
|
1789 var node = this.value; |
|
1790 for (var i = 0; i < ps.length; i ++) { |
|
1791 var key = ps[i]; |
|
1792 if (!node || !hasOwnProperty.call(node, key)) { |
|
1793 return false; |
|
1794 } |
|
1795 node = node[key]; |
|
1796 } |
|
1797 return true; |
|
1798 }; |
|
1799 |
|
1800 Traverse.prototype.set = function (ps, value) { |
|
1801 var node = this.value; |
|
1802 for (var i = 0; i < ps.length - 1; i ++) { |
|
1803 var key = ps[i]; |
|
1804 if (!hasOwnProperty.call(node, key)) node[key] = {}; |
|
1805 node = node[key]; |
|
1806 } |
|
1807 node[ps[i]] = value; |
|
1808 return value; |
|
1809 }; |
|
1810 |
|
1811 Traverse.prototype.map = function (cb) { |
|
1812 return walk(this.value, cb, true); |
|
1813 }; |
|
1814 |
|
1815 Traverse.prototype.forEach = function (cb) { |
|
1816 this.value = walk(this.value, cb, false); |
|
1817 return this.value; |
|
1818 }; |
|
1819 |
|
1820 Traverse.prototype.reduce = function (cb, init) { |
|
1821 var skip = arguments.length === 1; |
|
1822 var acc = skip ? this.value : init; |
|
1823 this.forEach(function (x) { |
|
1824 if (!this.isRoot || !skip) { |
|
1825 acc = cb.call(this, acc, x); |
|
1826 } |
|
1827 }); |
|
1828 return acc; |
|
1829 }; |
|
1830 |
|
1831 Traverse.prototype.paths = function () { |
|
1832 var acc = []; |
|
1833 this.forEach(function (x) { |
|
1834 acc.push(this.path); |
|
1835 }); |
|
1836 return acc; |
|
1837 }; |
|
1838 |
|
1839 Traverse.prototype.nodes = function () { |
|
1840 var acc = []; |
|
1841 this.forEach(function (x) { |
|
1842 acc.push(this.node); |
|
1843 }); |
|
1844 return acc; |
|
1845 }; |
|
1846 |
|
1847 Traverse.prototype.clone = function () { |
|
1848 var parents = [], nodes = []; |
|
1849 |
|
1850 return (function clone (src) { |
|
1851 for (var i = 0; i < parents.length; i++) { |
|
1852 if (parents[i] === src) { |
|
1853 return nodes[i]; |
|
1854 } |
|
1855 } |
|
1856 |
|
1857 if (typeof src === 'object' && src !== null) { |
|
1858 var dst = copy(src); |
|
1859 |
|
1860 parents.push(src); |
|
1861 nodes.push(dst); |
|
1862 |
|
1863 forEach(objectKeys(src), function (key) { |
|
1864 dst[key] = clone(src[key]); |
|
1865 }); |
|
1866 |
|
1867 parents.pop(); |
|
1868 nodes.pop(); |
|
1869 return dst; |
|
1870 } |
|
1871 else { |
|
1872 return src; |
|
1873 } |
|
1874 })(this.value); |
|
1875 }; |
|
1876 |
|
1877 function walk (root, cb, immutable) { |
|
1878 var path = []; |
|
1879 var parents = []; |
|
1880 var alive = true; |
|
1881 |
|
1882 return (function walker (node_) { |
|
1883 var node = immutable ? copy(node_) : node_; |
|
1884 var modifiers = {}; |
|
1885 |
|
1886 var keepGoing = true; |
|
1887 |
|
1888 var state = { |
|
1889 node : node, |
|
1890 node_ : node_, |
|
1891 path : [].concat(path), |
|
1892 parent : parents[parents.length - 1], |
|
1893 parents : parents, |
|
1894 key : path.slice(-1)[0], |
|
1895 isRoot : path.length === 0, |
|
1896 level : path.length, |
|
1897 circular : null, |
|
1898 update : function (x, stopHere) { |
|
1899 if (!state.isRoot) { |
|
1900 state.parent.node[state.key] = x; |
|
1901 } |
|
1902 state.node = x; |
|
1903 if (stopHere) keepGoing = false; |
|
1904 }, |
|
1905 'delete' : function (stopHere) { |
|
1906 delete state.parent.node[state.key]; |
|
1907 if (stopHere) keepGoing = false; |
|
1908 }, |
|
1909 remove : function (stopHere) { |
|
1910 if (isArray(state.parent.node)) { |
|
1911 state.parent.node.splice(state.key, 1); |
|
1912 } |
|
1913 else { |
|
1914 delete state.parent.node[state.key]; |
|
1915 } |
|
1916 if (stopHere) keepGoing = false; |
|
1917 }, |
|
1918 keys : null, |
|
1919 before : function (f) { modifiers.before = f }, |
|
1920 after : function (f) { modifiers.after = f }, |
|
1921 pre : function (f) { modifiers.pre = f }, |
|
1922 post : function (f) { modifiers.post = f }, |
|
1923 stop : function () { alive = false }, |
|
1924 block : function () { keepGoing = false } |
|
1925 }; |
|
1926 |
|
1927 if (!alive) return state; |
|
1928 |
|
1929 function updateState() { |
|
1930 if (typeof state.node === 'object' && state.node !== null) { |
|
1931 if (!state.keys || state.node_ !== state.node) { |
|
1932 state.keys = objectKeys(state.node) |
|
1933 } |
|
1934 |
|
1935 state.isLeaf = state.keys.length == 0; |
|
1936 |
|
1937 for (var i = 0; i < parents.length; i++) { |
|
1938 if (parents[i].node_ === node_) { |
|
1939 state.circular = parents[i]; |
|
1940 break; |
|
1941 } |
|
1942 } |
|
1943 } |
|
1944 else { |
|
1945 state.isLeaf = true; |
|
1946 state.keys = null; |
|
1947 } |
|
1948 |
|
1949 state.notLeaf = !state.isLeaf; |
|
1950 state.notRoot = !state.isRoot; |
|
1951 } |
|
1952 |
|
1953 updateState(); |
|
1954 |
|
1955 // use return values to update if defined |
|
1956 var ret = cb.call(state, state.node); |
|
1957 if (ret !== undefined && state.update) state.update(ret); |
|
1958 |
|
1959 if (modifiers.before) modifiers.before.call(state, state.node); |
|
1960 |
|
1961 if (!keepGoing) return state; |
|
1962 |
|
1963 if (typeof state.node == 'object' |
|
1964 && state.node !== null && !state.circular) { |
|
1965 parents.push(state); |
|
1966 |
|
1967 updateState(); |
|
1968 |
|
1969 forEach(state.keys, function (key, i) { |
|
1970 path.push(key); |
|
1971 |
|
1972 if (modifiers.pre) modifiers.pre.call(state, state.node[key], key); |
|
1973 |
|
1974 var child = walker(state.node[key]); |
|
1975 if (immutable && hasOwnProperty.call(state.node, key)) { |
|
1976 state.node[key] = child.node; |
|
1977 } |
|
1978 |
|
1979 child.isLast = i == state.keys.length - 1; |
|
1980 child.isFirst = i == 0; |
|
1981 |
|
1982 if (modifiers.post) modifiers.post.call(state, child); |
|
1983 |
|
1984 path.pop(); |
|
1985 }); |
|
1986 parents.pop(); |
|
1987 } |
|
1988 |
|
1989 if (modifiers.after) modifiers.after.call(state, state.node); |
|
1990 |
|
1991 return state; |
|
1992 })(root).node; |
|
1993 } |
|
1994 |
|
1995 function copy (src) { |
|
1996 if (typeof src === 'object' && src !== null) { |
|
1997 var dst; |
|
1998 |
|
1999 if (isArray(src)) { |
|
2000 dst = []; |
|
2001 } |
|
2002 else if (isDate(src)) { |
|
2003 dst = new Date(src.getTime ? src.getTime() : src); |
|
2004 } |
|
2005 else if (isRegExp(src)) { |
|
2006 dst = new RegExp(src); |
|
2007 } |
|
2008 else if (isError(src)) { |
|
2009 dst = { message: src.message }; |
|
2010 } |
|
2011 else if (isBoolean(src)) { |
|
2012 dst = new Boolean(src); |
|
2013 } |
|
2014 else if (isNumber(src)) { |
|
2015 dst = new Number(src); |
|
2016 } |
|
2017 else if (isString(src)) { |
|
2018 dst = new String(src); |
|
2019 } |
|
2020 else if (Object.create && Object.getPrototypeOf) { |
|
2021 dst = Object.create(Object.getPrototypeOf(src)); |
|
2022 } |
|
2023 else if (src.constructor === Object) { |
|
2024 dst = {}; |
|
2025 } |
|
2026 else { |
|
2027 var proto = |
|
2028 (src.constructor && src.constructor.prototype) |
|
2029 || src.__proto__ |
|
2030 || {} |
|
2031 ; |
|
2032 var T = function () {}; |
|
2033 T.prototype = proto; |
|
2034 dst = new T; |
|
2035 } |
|
2036 |
|
2037 forEach(objectKeys(src), function (key) { |
|
2038 dst[key] = src[key]; |
|
2039 }); |
|
2040 return dst; |
|
2041 } |
|
2042 else return src; |
|
2043 } |
|
2044 |
|
2045 var objectKeys = Object.keys || function keys (obj) { |
|
2046 var res = []; |
|
2047 for (var key in obj) res.push(key) |
|
2048 return res; |
|
2049 }; |
|
2050 |
|
2051 function toS (obj) { return Object.prototype.toString.call(obj) } |
|
2052 function isDate (obj) { return toS(obj) === '[object Date]' } |
|
2053 function isRegExp (obj) { return toS(obj) === '[object RegExp]' } |
|
2054 function isError (obj) { return toS(obj) === '[object Error]' } |
|
2055 function isBoolean (obj) { return toS(obj) === '[object Boolean]' } |
|
2056 function isNumber (obj) { return toS(obj) === '[object Number]' } |
|
2057 function isString (obj) { return toS(obj) === '[object String]' } |
|
2058 |
|
2059 var isArray = Array.isArray || function isArray (xs) { |
|
2060 return Object.prototype.toString.call(xs) === '[object Array]'; |
|
2061 }; |
|
2062 |
|
2063 var forEach = function (xs, fn) { |
|
2064 if (xs.forEach) return xs.forEach(fn) |
|
2065 else for (var i = 0; i < xs.length; i++) { |
|
2066 fn(xs[i], i, xs); |
|
2067 } |
|
2068 }; |
|
2069 |
|
2070 forEach(objectKeys(Traverse.prototype), function (key) { |
|
2071 traverse[key] = function (obj) { |
|
2072 var args = [].slice.call(arguments, 1); |
|
2073 var t = new Traverse(obj); |
|
2074 return t[key].apply(t, args); |
|
2075 }; |
|
2076 }); |
|
2077 |
|
2078 var hasOwnProperty = Object.hasOwnProperty || function (obj, key) { |
|
2079 return key in obj; |
|
2080 }; |
|
2081 |
|
2082 |
|
2083 /***/ }), |
|
2084 |
|
2085 /***/ 23: |
|
2086 /***/ (function(module, exports, __webpack_require__) { |
|
2087 |
|
2088 module.exports = __webpack_require__(54); |
|
2089 |
|
2090 |
|
2091 /***/ }), |
|
2092 |
|
2093 /***/ 25: |
|
2094 /***/ (function(module, exports) { |
|
2095 |
|
2096 (function() { module.exports = this["wp"]["url"]; }()); |
|
2097 |
|
2098 /***/ }), |
|
2099 |
|
2100 /***/ 26: |
|
2101 /***/ (function(module, exports) { |
|
2102 |
|
2103 (function() { module.exports = this["wp"]["hooks"]; }()); |
|
2104 |
|
2105 /***/ }), |
|
2106 |
|
2107 /***/ 27: |
|
2108 /***/ (function(module, exports) { |
|
2109 |
|
2110 (function() { module.exports = this["React"]; }()); |
|
2111 |
|
2112 /***/ }), |
|
2113 |
|
2114 /***/ 28: |
|
2115 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
2116 |
|
2117 "use strict"; |
|
2118 |
|
2119 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/arrayWithHoles.js |
|
2120 var arrayWithHoles = __webpack_require__(37); |
|
2121 |
|
2122 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/iterableToArrayLimit.js |
|
2123 function _iterableToArrayLimit(arr, i) { |
|
2124 var _arr = []; |
|
2125 var _n = true; |
|
2126 var _d = false; |
|
2127 var _e = undefined; |
|
2128 |
|
2129 try { |
|
2130 for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { |
|
2131 _arr.push(_s.value); |
|
2132 |
|
2133 if (i && _arr.length === i) break; |
|
2134 } |
|
2135 } catch (err) { |
|
2136 _d = true; |
|
2137 _e = err; |
|
2138 } finally { |
|
2139 try { |
|
2140 if (!_n && _i["return"] != null) _i["return"](); |
|
2141 } finally { |
|
2142 if (_d) throw _e; |
|
2143 } |
|
2144 } |
|
2145 |
|
2146 return _arr; |
|
2147 } |
|
2148 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/nonIterableRest.js |
|
2149 var nonIterableRest = __webpack_require__(38); |
|
2150 |
|
2151 // CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js |
|
2152 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _slicedToArray; }); |
|
2153 |
|
2154 |
|
2155 |
|
2156 function _slicedToArray(arr, i) { |
|
2157 return Object(arrayWithHoles["a" /* default */])(arr) || _iterableToArrayLimit(arr, i) || Object(nonIterableRest["a" /* default */])(); |
|
2158 } |
|
2159 |
|
2160 /***/ }), |
|
2161 |
|
2162 /***/ 3: |
|
2163 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
2164 |
|
2165 "use strict"; |
|
2166 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _assertThisInitialized; }); |
|
2167 function _assertThisInitialized(self) { |
|
2168 if (self === void 0) { |
|
2169 throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); |
|
2170 } |
|
2171 |
|
2172 return self; |
|
2173 } |
|
2174 |
|
2175 /***/ }), |
|
2176 |
|
2177 /***/ 30: |
|
2178 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
2179 |
|
2180 "use strict"; |
|
2181 |
|
2182 |
|
2183 var LEAF_KEY, hasWeakMap; |
|
2184 |
|
2185 /** |
|
2186 * Arbitrary value used as key for referencing cache object in WeakMap tree. |
|
2187 * |
|
2188 * @type {Object} |
|
2189 */ |
|
2190 LEAF_KEY = {}; |
|
2191 |
|
2192 /** |
|
2193 * Whether environment supports WeakMap. |
|
2194 * |
|
2195 * @type {boolean} |
|
2196 */ |
|
2197 hasWeakMap = typeof WeakMap !== 'undefined'; |
|
2198 |
|
2199 /** |
|
2200 * Returns the first argument as the sole entry in an array. |
|
2201 * |
|
2202 * @param {*} value Value to return. |
|
2203 * |
|
2204 * @return {Array} Value returned as entry in array. |
|
2205 */ |
|
2206 function arrayOf( value ) { |
|
2207 return [ value ]; |
|
2208 } |
|
2209 |
|
2210 /** |
|
2211 * Returns true if the value passed is object-like, or false otherwise. A value |
|
2212 * is object-like if it can support property assignment, e.g. object or array. |
|
2213 * |
|
2214 * @param {*} value Value to test. |
|
2215 * |
|
2216 * @return {boolean} Whether value is object-like. |
|
2217 */ |
|
2218 function isObjectLike( value ) { |
|
2219 return !! value && 'object' === typeof value; |
|
2220 } |
|
2221 |
|
2222 /** |
|
2223 * Creates and returns a new cache object. |
|
2224 * |
|
2225 * @return {Object} Cache object. |
|
2226 */ |
|
2227 function createCache() { |
|
2228 var cache = { |
|
2229 clear: function() { |
|
2230 cache.head = null; |
|
2231 }, |
|
2232 }; |
|
2233 |
|
2234 return cache; |
|
2235 } |
|
2236 |
|
2237 /** |
|
2238 * Returns true if entries within the two arrays are strictly equal by |
|
2239 * reference from a starting index. |
|
2240 * |
|
2241 * @param {Array} a First array. |
|
2242 * @param {Array} b Second array. |
|
2243 * @param {number} fromIndex Index from which to start comparison. |
|
2244 * |
|
2245 * @return {boolean} Whether arrays are shallowly equal. |
|
2246 */ |
|
2247 function isShallowEqual( a, b, fromIndex ) { |
|
2248 var i; |
|
2249 |
|
2250 if ( a.length !== b.length ) { |
|
2251 return false; |
|
2252 } |
|
2253 |
|
2254 for ( i = fromIndex; i < a.length; i++ ) { |
|
2255 if ( a[ i ] !== b[ i ] ) { |
|
2256 return false; |
|
2257 } |
|
2258 } |
|
2259 |
|
2260 return true; |
|
2261 } |
|
2262 |
|
2263 /** |
|
2264 * Returns a memoized selector function. The getDependants function argument is |
|
2265 * called before the memoized selector and is expected to return an immutable |
|
2266 * reference or array of references on which the selector depends for computing |
|
2267 * its own return value. The memoize cache is preserved only as long as those |
|
2268 * dependant references remain the same. If getDependants returns a different |
|
2269 * reference(s), the cache is cleared and the selector value regenerated. |
|
2270 * |
|
2271 * @param {Function} selector Selector function. |
|
2272 * @param {Function} getDependants Dependant getter returning an immutable |
|
2273 * reference or array of reference used in |
|
2274 * cache bust consideration. |
|
2275 * |
|
2276 * @return {Function} Memoized selector. |
|
2277 */ |
|
2278 /* harmony default export */ __webpack_exports__["a"] = (function( selector, getDependants ) { |
|
2279 var rootCache, getCache; |
|
2280 |
|
2281 // Use object source as dependant if getter not provided |
|
2282 if ( ! getDependants ) { |
|
2283 getDependants = arrayOf; |
|
2284 } |
|
2285 |
|
2286 /** |
|
2287 * Returns the root cache. If WeakMap is supported, this is assigned to the |
|
2288 * root WeakMap cache set, otherwise it is a shared instance of the default |
|
2289 * cache object. |
|
2290 * |
|
2291 * @return {(WeakMap|Object)} Root cache object. |
|
2292 */ |
|
2293 function getRootCache() { |
|
2294 return rootCache; |
|
2295 } |
|
2296 |
|
2297 /** |
|
2298 * Returns the cache for a given dependants array. When possible, a WeakMap |
|
2299 * will be used to create a unique cache for each set of dependants. This |
|
2300 * is feasible due to the nature of WeakMap in allowing garbage collection |
|
2301 * to occur on entries where the key object is no longer referenced. Since |
|
2302 * WeakMap requires the key to be an object, this is only possible when the |
|
2303 * dependant is object-like. The root cache is created as a hierarchy where |
|
2304 * each top-level key is the first entry in a dependants set, the value a |
|
2305 * WeakMap where each key is the next dependant, and so on. This continues |
|
2306 * so long as the dependants are object-like. If no dependants are object- |
|
2307 * like, then the cache is shared across all invocations. |
|
2308 * |
|
2309 * @see isObjectLike |
|
2310 * |
|
2311 * @param {Array} dependants Selector dependants. |
|
2312 * |
|
2313 * @return {Object} Cache object. |
|
2314 */ |
|
2315 function getWeakMapCache( dependants ) { |
|
2316 var caches = rootCache, |
|
2317 isUniqueByDependants = true, |
|
2318 i, dependant, map, cache; |
|
2319 |
|
2320 for ( i = 0; i < dependants.length; i++ ) { |
|
2321 dependant = dependants[ i ]; |
|
2322 |
|
2323 // Can only compose WeakMap from object-like key. |
|
2324 if ( ! isObjectLike( dependant ) ) { |
|
2325 isUniqueByDependants = false; |
|
2326 break; |
|
2327 } |
|
2328 |
|
2329 // Does current segment of cache already have a WeakMap? |
|
2330 if ( caches.has( dependant ) ) { |
|
2331 // Traverse into nested WeakMap. |
|
2332 caches = caches.get( dependant ); |
|
2333 } else { |
|
2334 // Create, set, and traverse into a new one. |
|
2335 map = new WeakMap(); |
|
2336 caches.set( dependant, map ); |
|
2337 caches = map; |
|
2338 } |
|
2339 } |
|
2340 |
|
2341 // We use an arbitrary (but consistent) object as key for the last item |
|
2342 // in the WeakMap to serve as our running cache. |
|
2343 if ( ! caches.has( LEAF_KEY ) ) { |
|
2344 cache = createCache(); |
|
2345 cache.isUniqueByDependants = isUniqueByDependants; |
|
2346 caches.set( LEAF_KEY, cache ); |
|
2347 } |
|
2348 |
|
2349 return caches.get( LEAF_KEY ); |
|
2350 } |
|
2351 |
|
2352 // Assign cache handler by availability of WeakMap |
|
2353 getCache = hasWeakMap ? getWeakMapCache : getRootCache; |
|
2354 |
|
2355 /** |
|
2356 * Resets root memoization cache. |
|
2357 */ |
|
2358 function clear() { |
|
2359 rootCache = hasWeakMap ? new WeakMap() : createCache(); |
|
2360 } |
|
2361 |
|
2362 // eslint-disable-next-line jsdoc/check-param-names |
|
2363 /** |
|
2364 * The augmented selector call, considering first whether dependants have |
|
2365 * changed before passing it to underlying memoize function. |
|
2366 * |
|
2367 * @param {Object} source Source object for derivation. |
|
2368 * @param {...*} extraArgs Additional arguments to pass to selector. |
|
2369 * |
|
2370 * @return {*} Selector result. |
|
2371 */ |
|
2372 function callSelector( /* source, ...extraArgs */ ) { |
|
2373 var len = arguments.length, |
|
2374 cache, node, i, args, dependants; |
|
2375 |
|
2376 // Create copy of arguments (avoid leaking deoptimization). |
|
2377 args = new Array( len ); |
|
2378 for ( i = 0; i < len; i++ ) { |
|
2379 args[ i ] = arguments[ i ]; |
|
2380 } |
|
2381 |
|
2382 dependants = getDependants.apply( null, args ); |
|
2383 cache = getCache( dependants ); |
|
2384 |
|
2385 // If not guaranteed uniqueness by dependants (primitive type or lack |
|
2386 // of WeakMap support), shallow compare against last dependants and, if |
|
2387 // references have changed, destroy cache to recalculate result. |
|
2388 if ( ! cache.isUniqueByDependants ) { |
|
2389 if ( cache.lastDependants && ! isShallowEqual( dependants, cache.lastDependants, 0 ) ) { |
|
2390 cache.clear(); |
|
2391 } |
|
2392 |
|
2393 cache.lastDependants = dependants; |
|
2394 } |
|
2395 |
|
2396 node = cache.head; |
|
2397 while ( node ) { |
|
2398 // Check whether node arguments match arguments |
|
2399 if ( ! isShallowEqual( node.args, args, 1 ) ) { |
|
2400 node = node.next; |
|
2401 continue; |
|
2402 } |
|
2403 |
|
2404 // At this point we can assume we've found a match |
|
2405 |
|
2406 // Surface matched node to head if not already |
|
2407 if ( node !== cache.head ) { |
|
2408 // Adjust siblings to point to each other. |
|
2409 node.prev.next = node.next; |
|
2410 if ( node.next ) { |
|
2411 node.next.prev = node.prev; |
|
2412 } |
|
2413 |
|
2414 node.next = cache.head; |
|
2415 node.prev = null; |
|
2416 cache.head.prev = node; |
|
2417 cache.head = node; |
|
2418 } |
|
2419 |
|
2420 // Return immediately |
|
2421 return node.val; |
|
2422 } |
|
2423 |
|
2424 // No cached value found. Continue to insertion phase: |
|
2425 |
|
2426 node = { |
|
2427 // Generate the result from original function |
|
2428 val: selector.apply( null, args ), |
|
2429 }; |
|
2430 |
|
2431 // Avoid including the source object in the cache. |
|
2432 args[ 0 ] = null; |
|
2433 node.args = args; |
|
2434 |
|
2435 // Don't need to check whether node is already head, since it would |
|
2436 // have been returned above already if it was |
|
2437 |
|
2438 // Shift existing head down list |
|
2439 if ( cache.head ) { |
|
2440 cache.head.prev = node; |
|
2441 node.next = cache.head; |
|
2442 } |
|
2443 |
|
2444 cache.head = node; |
|
2445 |
|
2446 return node.val; |
|
2447 } |
|
2448 |
|
2449 callSelector.getDependants = getDependants; |
|
2450 callSelector.clear = clear; |
|
2451 clear(); |
|
2452 |
|
2453 return callSelector; |
|
2454 }); |
|
2455 |
|
2456 |
|
2457 /***/ }), |
|
2458 |
|
2459 /***/ 31: |
|
2460 /***/ (function(module, exports, __webpack_require__) { |
|
2461 |
|
2462 /** |
|
2463 * Copyright (c) 2013-present, Facebook, Inc. |
|
2464 * |
|
2465 * This source code is licensed under the MIT license found in the |
|
2466 * LICENSE file in the root directory of this source tree. |
|
2467 */ |
|
2468 |
|
2469 if (false) { var throwOnDirectAccess, isValidElement, REACT_ELEMENT_TYPE; } else { |
|
2470 // By explicitly using `prop-types` you are opting into new production behavior. |
|
2471 // http://fb.me/prop-types-in-prod |
|
2472 module.exports = __webpack_require__(89)(); |
|
2473 } |
|
2474 |
|
2475 |
|
2476 /***/ }), |
|
2477 |
|
2478 /***/ 32: |
|
2479 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
2480 |
|
2481 "use strict"; |
|
2482 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _typeof; }); |
|
2483 function _typeof2(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof2 = function _typeof2(obj) { return typeof obj; }; } else { _typeof2 = function _typeof2(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof2(obj); } |
|
2484 |
|
2485 function _typeof(obj) { |
|
2486 if (typeof Symbol === "function" && _typeof2(Symbol.iterator) === "symbol") { |
|
2487 _typeof = function _typeof(obj) { |
|
2488 return _typeof2(obj); |
|
2489 }; |
|
2490 } else { |
|
2491 _typeof = function _typeof(obj) { |
|
2492 return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : _typeof2(obj); |
|
2493 }; |
|
2494 } |
|
2495 |
|
2496 return _typeof(obj); |
|
2497 } |
|
2498 |
|
2499 /***/ }), |
|
2500 |
|
2501 /***/ 33: |
|
2502 /***/ (function(module, exports) { |
|
2503 |
|
2504 (function() { module.exports = this["wp"]["apiFetch"]; }()); |
|
2505 |
|
2506 /***/ }), |
|
2507 |
|
2508 /***/ 34: |
|
2509 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
2510 |
|
2511 "use strict"; |
|
2512 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _iterableToArray; }); |
|
2513 function _iterableToArray(iter) { |
|
2514 if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === "[object Arguments]") return Array.from(iter); |
|
2515 } |
|
2516 |
|
2517 /***/ }), |
|
2518 |
|
2519 /***/ 341: |
|
2520 /***/ (function(module, exports, __webpack_require__) { |
|
2521 |
|
2522 "use strict"; |
|
2523 |
|
2524 |
|
2525 var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; |
|
2526 |
|
2527 function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } |
|
2528 |
|
2529 var BEGIN = 'BEGIN'; |
|
2530 var COMMIT = 'COMMIT'; |
|
2531 var REVERT = 'REVERT'; |
|
2532 // Array({transactionID: string or null, beforeState: {object}, action: {object}} |
|
2533 var INITIAL_OPTIMIST = []; |
|
2534 |
|
2535 module.exports = optimist; |
|
2536 module.exports.BEGIN = BEGIN; |
|
2537 module.exports.COMMIT = COMMIT; |
|
2538 module.exports.REVERT = REVERT; |
|
2539 function optimist(fn) { |
|
2540 function beginReducer(state, action) { |
|
2541 var _separateState = separateState(state); |
|
2542 |
|
2543 var optimist = _separateState.optimist; |
|
2544 var innerState = _separateState.innerState; |
|
2545 |
|
2546 optimist = optimist.concat([{ beforeState: innerState, action: action }]); |
|
2547 innerState = fn(innerState, action); |
|
2548 validateState(innerState, action); |
|
2549 return _extends({ optimist: optimist }, innerState); |
|
2550 } |
|
2551 function commitReducer(state, action) { |
|
2552 var _separateState2 = separateState(state); |
|
2553 |
|
2554 var optimist = _separateState2.optimist; |
|
2555 var innerState = _separateState2.innerState; |
|
2556 |
|
2557 var newOptimist = [], |
|
2558 started = false, |
|
2559 committed = false; |
|
2560 optimist.forEach(function (entry) { |
|
2561 if (started) { |
|
2562 if (entry.beforeState && matchesTransaction(entry.action, action.optimist.id)) { |
|
2563 committed = true; |
|
2564 newOptimist.push({ action: entry.action }); |
|
2565 } else { |
|
2566 newOptimist.push(entry); |
|
2567 } |
|
2568 } else if (entry.beforeState && !matchesTransaction(entry.action, action.optimist.id)) { |
|
2569 started = true; |
|
2570 newOptimist.push(entry); |
|
2571 } else if (entry.beforeState && matchesTransaction(entry.action, action.optimist.id)) { |
|
2572 committed = true; |
|
2573 } |
|
2574 }); |
|
2575 if (!committed) { |
|
2576 console.error('Cannot commit transaction with id "' + action.optimist.id + '" because it does not exist'); |
|
2577 } |
|
2578 optimist = newOptimist; |
|
2579 return baseReducer(optimist, innerState, action); |
|
2580 } |
|
2581 function revertReducer(state, action) { |
|
2582 var _separateState3 = separateState(state); |
|
2583 |
|
2584 var optimist = _separateState3.optimist; |
|
2585 var innerState = _separateState3.innerState; |
|
2586 |
|
2587 var newOptimist = [], |
|
2588 started = false, |
|
2589 gotInitialState = false, |
|
2590 currentState = innerState; |
|
2591 optimist.forEach(function (entry) { |
|
2592 if (entry.beforeState && matchesTransaction(entry.action, action.optimist.id)) { |
|
2593 currentState = entry.beforeState; |
|
2594 gotInitialState = true; |
|
2595 } |
|
2596 if (!matchesTransaction(entry.action, action.optimist.id)) { |
|
2597 if (entry.beforeState) { |
|
2598 started = true; |
|
2599 } |
|
2600 if (started) { |
|
2601 if (gotInitialState && entry.beforeState) { |
|
2602 newOptimist.push({ |
|
2603 beforeState: currentState, |
|
2604 action: entry.action |
|
2605 }); |
|
2606 } else { |
|
2607 newOptimist.push(entry); |
|
2608 } |
|
2609 } |
|
2610 if (gotInitialState) { |
|
2611 currentState = fn(currentState, entry.action); |
|
2612 validateState(innerState, action); |
|
2613 } |
|
2614 } |
|
2615 }); |
|
2616 if (!gotInitialState) { |
|
2617 console.error('Cannot revert transaction with id "' + action.optimist.id + '" because it does not exist'); |
|
2618 } |
|
2619 optimist = newOptimist; |
|
2620 return baseReducer(optimist, currentState, action); |
|
2621 } |
|
2622 function baseReducer(optimist, innerState, action) { |
|
2623 if (optimist.length) { |
|
2624 optimist = optimist.concat([{ action: action }]); |
|
2625 } |
|
2626 innerState = fn(innerState, action); |
|
2627 validateState(innerState, action); |
|
2628 return _extends({ optimist: optimist }, innerState); |
|
2629 } |
|
2630 return function (state, action) { |
|
2631 if (action.optimist) { |
|
2632 switch (action.optimist.type) { |
|
2633 case BEGIN: |
|
2634 return beginReducer(state, action); |
|
2635 case COMMIT: |
|
2636 return commitReducer(state, action); |
|
2637 case REVERT: |
|
2638 return revertReducer(state, action); |
|
2639 } |
|
2640 } |
|
2641 |
|
2642 var _separateState4 = separateState(state); |
|
2643 |
|
2644 var optimist = _separateState4.optimist; |
|
2645 var innerState = _separateState4.innerState; |
|
2646 |
|
2647 if (state && !optimist.length) { |
|
2648 var nextState = fn(innerState, action); |
|
2649 if (nextState === innerState) { |
|
2650 return state; |
|
2651 } |
|
2652 validateState(nextState, action); |
|
2653 return _extends({ optimist: optimist }, nextState); |
|
2654 } |
|
2655 return baseReducer(optimist, innerState, action); |
|
2656 }; |
|
2657 } |
|
2658 |
|
2659 function matchesTransaction(action, id) { |
|
2660 return action.optimist && action.optimist.id === id; |
|
2661 } |
|
2662 |
|
2663 function validateState(newState, action) { |
|
2664 if (!newState || typeof newState !== 'object' || Array.isArray(newState)) { |
|
2665 throw new TypeError('Error while handling "' + action.type + '": Optimist requires that state is always a plain object.'); |
|
2666 } |
|
2667 } |
|
2668 |
|
2669 function separateState(state) { |
|
2670 if (!state) { |
|
2671 return { optimist: INITIAL_OPTIMIST, innerState: state }; |
|
2672 } else { |
|
2673 var _state$optimist = state.optimist; |
|
2674 |
|
2675 var _optimist = _state$optimist === undefined ? INITIAL_OPTIMIST : _state$optimist; |
|
2676 |
|
2677 var innerState = _objectWithoutProperties(state, ['optimist']); |
|
2678 |
|
2679 return { optimist: _optimist, innerState: innerState }; |
|
2680 } |
|
2681 } |
|
2682 |
|
2683 /***/ }), |
|
2684 |
|
2685 /***/ 35: |
|
2686 /***/ (function(module, exports) { |
|
2687 |
|
2688 (function() { module.exports = this["wp"]["blob"]; }()); |
|
2689 |
|
2690 /***/ }), |
|
2691 |
|
2692 /***/ 358: |
|
2693 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
2694 |
|
2695 "use strict"; |
|
2696 __webpack_require__.r(__webpack_exports__); |
|
2697 var actions_namespaceObject = {}; |
|
2698 __webpack_require__.r(actions_namespaceObject); |
|
2699 __webpack_require__.d(actions_namespaceObject, "setupEditor", function() { return setupEditor; }); |
|
2700 __webpack_require__.d(actions_namespaceObject, "resetPost", function() { return resetPost; }); |
|
2701 __webpack_require__.d(actions_namespaceObject, "resetAutosave", function() { return resetAutosave; }); |
|
2702 __webpack_require__.d(actions_namespaceObject, "__experimentalRequestPostUpdateStart", function() { return __experimentalRequestPostUpdateStart; }); |
|
2703 __webpack_require__.d(actions_namespaceObject, "__experimentalRequestPostUpdateSuccess", function() { return __experimentalRequestPostUpdateSuccess; }); |
|
2704 __webpack_require__.d(actions_namespaceObject, "__experimentalRequestPostUpdateFailure", function() { return __experimentalRequestPostUpdateFailure; }); |
|
2705 __webpack_require__.d(actions_namespaceObject, "updatePost", function() { return updatePost; }); |
|
2706 __webpack_require__.d(actions_namespaceObject, "setupEditorState", function() { return setupEditorState; }); |
|
2707 __webpack_require__.d(actions_namespaceObject, "editPost", function() { return actions_editPost; }); |
|
2708 __webpack_require__.d(actions_namespaceObject, "__experimentalOptimisticUpdatePost", function() { return __experimentalOptimisticUpdatePost; }); |
|
2709 __webpack_require__.d(actions_namespaceObject, "savePost", function() { return savePost; }); |
|
2710 __webpack_require__.d(actions_namespaceObject, "refreshPost", function() { return refreshPost; }); |
|
2711 __webpack_require__.d(actions_namespaceObject, "trashPost", function() { return trashPost; }); |
|
2712 __webpack_require__.d(actions_namespaceObject, "autosave", function() { return actions_autosave; }); |
|
2713 __webpack_require__.d(actions_namespaceObject, "redo", function() { return actions_redo; }); |
|
2714 __webpack_require__.d(actions_namespaceObject, "undo", function() { return actions_undo; }); |
|
2715 __webpack_require__.d(actions_namespaceObject, "createUndoLevel", function() { return createUndoLevel; }); |
|
2716 __webpack_require__.d(actions_namespaceObject, "updatePostLock", function() { return updatePostLock; }); |
|
2717 __webpack_require__.d(actions_namespaceObject, "__experimentalFetchReusableBlocks", function() { return __experimentalFetchReusableBlocks; }); |
|
2718 __webpack_require__.d(actions_namespaceObject, "__experimentalReceiveReusableBlocks", function() { return __experimentalReceiveReusableBlocks; }); |
|
2719 __webpack_require__.d(actions_namespaceObject, "__experimentalSaveReusableBlock", function() { return __experimentalSaveReusableBlock; }); |
|
2720 __webpack_require__.d(actions_namespaceObject, "__experimentalDeleteReusableBlock", function() { return __experimentalDeleteReusableBlock; }); |
|
2721 __webpack_require__.d(actions_namespaceObject, "__experimentalUpdateReusableBlockTitle", function() { return __experimentalUpdateReusableBlockTitle; }); |
|
2722 __webpack_require__.d(actions_namespaceObject, "__experimentalConvertBlockToStatic", function() { return __experimentalConvertBlockToStatic; }); |
|
2723 __webpack_require__.d(actions_namespaceObject, "__experimentalConvertBlockToReusable", function() { return __experimentalConvertBlockToReusable; }); |
|
2724 __webpack_require__.d(actions_namespaceObject, "enablePublishSidebar", function() { return enablePublishSidebar; }); |
|
2725 __webpack_require__.d(actions_namespaceObject, "disablePublishSidebar", function() { return disablePublishSidebar; }); |
|
2726 __webpack_require__.d(actions_namespaceObject, "lockPostSaving", function() { return lockPostSaving; }); |
|
2727 __webpack_require__.d(actions_namespaceObject, "unlockPostSaving", function() { return unlockPostSaving; }); |
|
2728 __webpack_require__.d(actions_namespaceObject, "resetEditorBlocks", function() { return actions_resetEditorBlocks; }); |
|
2729 __webpack_require__.d(actions_namespaceObject, "updateEditorSettings", function() { return updateEditorSettings; }); |
|
2730 __webpack_require__.d(actions_namespaceObject, "resetBlocks", function() { return resetBlocks; }); |
|
2731 __webpack_require__.d(actions_namespaceObject, "receiveBlocks", function() { return receiveBlocks; }); |
|
2732 __webpack_require__.d(actions_namespaceObject, "updateBlock", function() { return updateBlock; }); |
|
2733 __webpack_require__.d(actions_namespaceObject, "updateBlockAttributes", function() { return updateBlockAttributes; }); |
|
2734 __webpack_require__.d(actions_namespaceObject, "selectBlock", function() { return selectBlock; }); |
|
2735 __webpack_require__.d(actions_namespaceObject, "startMultiSelect", function() { return startMultiSelect; }); |
|
2736 __webpack_require__.d(actions_namespaceObject, "stopMultiSelect", function() { return stopMultiSelect; }); |
|
2737 __webpack_require__.d(actions_namespaceObject, "multiSelect", function() { return multiSelect; }); |
|
2738 __webpack_require__.d(actions_namespaceObject, "clearSelectedBlock", function() { return clearSelectedBlock; }); |
|
2739 __webpack_require__.d(actions_namespaceObject, "toggleSelection", function() { return toggleSelection; }); |
|
2740 __webpack_require__.d(actions_namespaceObject, "replaceBlocks", function() { return replaceBlocks; }); |
|
2741 __webpack_require__.d(actions_namespaceObject, "replaceBlock", function() { return replaceBlock; }); |
|
2742 __webpack_require__.d(actions_namespaceObject, "moveBlocksDown", function() { return moveBlocksDown; }); |
|
2743 __webpack_require__.d(actions_namespaceObject, "moveBlocksUp", function() { return moveBlocksUp; }); |
|
2744 __webpack_require__.d(actions_namespaceObject, "moveBlockToPosition", function() { return moveBlockToPosition; }); |
|
2745 __webpack_require__.d(actions_namespaceObject, "insertBlock", function() { return insertBlock; }); |
|
2746 __webpack_require__.d(actions_namespaceObject, "insertBlocks", function() { return insertBlocks; }); |
|
2747 __webpack_require__.d(actions_namespaceObject, "showInsertionPoint", function() { return showInsertionPoint; }); |
|
2748 __webpack_require__.d(actions_namespaceObject, "hideInsertionPoint", function() { return hideInsertionPoint; }); |
|
2749 __webpack_require__.d(actions_namespaceObject, "setTemplateValidity", function() { return setTemplateValidity; }); |
|
2750 __webpack_require__.d(actions_namespaceObject, "synchronizeTemplate", function() { return synchronizeTemplate; }); |
|
2751 __webpack_require__.d(actions_namespaceObject, "mergeBlocks", function() { return mergeBlocks; }); |
|
2752 __webpack_require__.d(actions_namespaceObject, "removeBlocks", function() { return removeBlocks; }); |
|
2753 __webpack_require__.d(actions_namespaceObject, "removeBlock", function() { return removeBlock; }); |
|
2754 __webpack_require__.d(actions_namespaceObject, "toggleBlockMode", function() { return toggleBlockMode; }); |
|
2755 __webpack_require__.d(actions_namespaceObject, "startTyping", function() { return startTyping; }); |
|
2756 __webpack_require__.d(actions_namespaceObject, "stopTyping", function() { return stopTyping; }); |
|
2757 __webpack_require__.d(actions_namespaceObject, "enterFormattedText", function() { return enterFormattedText; }); |
|
2758 __webpack_require__.d(actions_namespaceObject, "exitFormattedText", function() { return exitFormattedText; }); |
|
2759 __webpack_require__.d(actions_namespaceObject, "insertDefaultBlock", function() { return insertDefaultBlock; }); |
|
2760 __webpack_require__.d(actions_namespaceObject, "updateBlockListSettings", function() { return updateBlockListSettings; }); |
|
2761 var selectors_namespaceObject = {}; |
|
2762 __webpack_require__.r(selectors_namespaceObject); |
|
2763 __webpack_require__.d(selectors_namespaceObject, "hasEditorUndo", function() { return hasEditorUndo; }); |
|
2764 __webpack_require__.d(selectors_namespaceObject, "hasEditorRedo", function() { return hasEditorRedo; }); |
|
2765 __webpack_require__.d(selectors_namespaceObject, "isEditedPostNew", function() { return selectors_isEditedPostNew; }); |
|
2766 __webpack_require__.d(selectors_namespaceObject, "hasChangedContent", function() { return hasChangedContent; }); |
|
2767 __webpack_require__.d(selectors_namespaceObject, "isEditedPostDirty", function() { return selectors_isEditedPostDirty; }); |
|
2768 __webpack_require__.d(selectors_namespaceObject, "isCleanNewPost", function() { return selectors_isCleanNewPost; }); |
|
2769 __webpack_require__.d(selectors_namespaceObject, "getCurrentPost", function() { return selectors_getCurrentPost; }); |
|
2770 __webpack_require__.d(selectors_namespaceObject, "getCurrentPostType", function() { return selectors_getCurrentPostType; }); |
|
2771 __webpack_require__.d(selectors_namespaceObject, "getCurrentPostId", function() { return selectors_getCurrentPostId; }); |
|
2772 __webpack_require__.d(selectors_namespaceObject, "getCurrentPostRevisionsCount", function() { return getCurrentPostRevisionsCount; }); |
|
2773 __webpack_require__.d(selectors_namespaceObject, "getCurrentPostLastRevisionId", function() { return getCurrentPostLastRevisionId; }); |
|
2774 __webpack_require__.d(selectors_namespaceObject, "getPostEdits", function() { return getPostEdits; }); |
|
2775 __webpack_require__.d(selectors_namespaceObject, "getReferenceByDistinctEdits", function() { return getReferenceByDistinctEdits; }); |
|
2776 __webpack_require__.d(selectors_namespaceObject, "getCurrentPostAttribute", function() { return selectors_getCurrentPostAttribute; }); |
|
2777 __webpack_require__.d(selectors_namespaceObject, "getEditedPostAttribute", function() { return selectors_getEditedPostAttribute; }); |
|
2778 __webpack_require__.d(selectors_namespaceObject, "getAutosaveAttribute", function() { return getAutosaveAttribute; }); |
|
2779 __webpack_require__.d(selectors_namespaceObject, "getEditedPostVisibility", function() { return selectors_getEditedPostVisibility; }); |
|
2780 __webpack_require__.d(selectors_namespaceObject, "isCurrentPostPending", function() { return isCurrentPostPending; }); |
|
2781 __webpack_require__.d(selectors_namespaceObject, "isCurrentPostPublished", function() { return selectors_isCurrentPostPublished; }); |
|
2782 __webpack_require__.d(selectors_namespaceObject, "isCurrentPostScheduled", function() { return selectors_isCurrentPostScheduled; }); |
|
2783 __webpack_require__.d(selectors_namespaceObject, "isEditedPostPublishable", function() { return selectors_isEditedPostPublishable; }); |
|
2784 __webpack_require__.d(selectors_namespaceObject, "isEditedPostSaveable", function() { return selectors_isEditedPostSaveable; }); |
|
2785 __webpack_require__.d(selectors_namespaceObject, "isEditedPostEmpty", function() { return isEditedPostEmpty; }); |
|
2786 __webpack_require__.d(selectors_namespaceObject, "isEditedPostAutosaveable", function() { return selectors_isEditedPostAutosaveable; }); |
|
2787 __webpack_require__.d(selectors_namespaceObject, "getAutosave", function() { return getAutosave; }); |
|
2788 __webpack_require__.d(selectors_namespaceObject, "hasAutosave", function() { return hasAutosave; }); |
|
2789 __webpack_require__.d(selectors_namespaceObject, "isEditedPostBeingScheduled", function() { return selectors_isEditedPostBeingScheduled; }); |
|
2790 __webpack_require__.d(selectors_namespaceObject, "isEditedPostDateFloating", function() { return isEditedPostDateFloating; }); |
|
2791 __webpack_require__.d(selectors_namespaceObject, "isSavingPost", function() { return selectors_isSavingPost; }); |
|
2792 __webpack_require__.d(selectors_namespaceObject, "didPostSaveRequestSucceed", function() { return didPostSaveRequestSucceed; }); |
|
2793 __webpack_require__.d(selectors_namespaceObject, "didPostSaveRequestFail", function() { return didPostSaveRequestFail; }); |
|
2794 __webpack_require__.d(selectors_namespaceObject, "isAutosavingPost", function() { return selectors_isAutosavingPost; }); |
|
2795 __webpack_require__.d(selectors_namespaceObject, "isPreviewingPost", function() { return isPreviewingPost; }); |
|
2796 __webpack_require__.d(selectors_namespaceObject, "getEditedPostPreviewLink", function() { return selectors_getEditedPostPreviewLink; }); |
|
2797 __webpack_require__.d(selectors_namespaceObject, "getSuggestedPostFormat", function() { return selectors_getSuggestedPostFormat; }); |
|
2798 __webpack_require__.d(selectors_namespaceObject, "getBlocksForSerialization", function() { return getBlocksForSerialization; }); |
|
2799 __webpack_require__.d(selectors_namespaceObject, "getEditedPostContent", function() { return getEditedPostContent; }); |
|
2800 __webpack_require__.d(selectors_namespaceObject, "__experimentalGetReusableBlock", function() { return __experimentalGetReusableBlock; }); |
|
2801 __webpack_require__.d(selectors_namespaceObject, "__experimentalIsSavingReusableBlock", function() { return __experimentalIsSavingReusableBlock; }); |
|
2802 __webpack_require__.d(selectors_namespaceObject, "__experimentalIsFetchingReusableBlock", function() { return __experimentalIsFetchingReusableBlock; }); |
|
2803 __webpack_require__.d(selectors_namespaceObject, "__experimentalGetReusableBlocks", function() { return __experimentalGetReusableBlocks; }); |
|
2804 __webpack_require__.d(selectors_namespaceObject, "getStateBeforeOptimisticTransaction", function() { return getStateBeforeOptimisticTransaction; }); |
|
2805 __webpack_require__.d(selectors_namespaceObject, "isPublishingPost", function() { return selectors_isPublishingPost; }); |
|
2806 __webpack_require__.d(selectors_namespaceObject, "isPermalinkEditable", function() { return selectors_isPermalinkEditable; }); |
|
2807 __webpack_require__.d(selectors_namespaceObject, "getPermalink", function() { return getPermalink; }); |
|
2808 __webpack_require__.d(selectors_namespaceObject, "getPermalinkParts", function() { return selectors_getPermalinkParts; }); |
|
2809 __webpack_require__.d(selectors_namespaceObject, "inSomeHistory", function() { return inSomeHistory; }); |
|
2810 __webpack_require__.d(selectors_namespaceObject, "isPostLocked", function() { return isPostLocked; }); |
|
2811 __webpack_require__.d(selectors_namespaceObject, "isPostSavingLocked", function() { return selectors_isPostSavingLocked; }); |
|
2812 __webpack_require__.d(selectors_namespaceObject, "isPostLockTakeover", function() { return isPostLockTakeover; }); |
|
2813 __webpack_require__.d(selectors_namespaceObject, "getPostLockUser", function() { return getPostLockUser; }); |
|
2814 __webpack_require__.d(selectors_namespaceObject, "getActivePostLock", function() { return getActivePostLock; }); |
|
2815 __webpack_require__.d(selectors_namespaceObject, "canUserUseUnfilteredHTML", function() { return canUserUseUnfilteredHTML; }); |
|
2816 __webpack_require__.d(selectors_namespaceObject, "isPublishSidebarEnabled", function() { return selectors_isPublishSidebarEnabled; }); |
|
2817 __webpack_require__.d(selectors_namespaceObject, "getEditorBlocks", function() { return getEditorBlocks; }); |
|
2818 __webpack_require__.d(selectors_namespaceObject, "__unstableIsEditorReady", function() { return __unstableIsEditorReady; }); |
|
2819 __webpack_require__.d(selectors_namespaceObject, "getEditorSettings", function() { return selectors_getEditorSettings; }); |
|
2820 __webpack_require__.d(selectors_namespaceObject, "getBlockDependantsCacheBust", function() { return getBlockDependantsCacheBust; }); |
|
2821 __webpack_require__.d(selectors_namespaceObject, "getBlockName", function() { return selectors_getBlockName; }); |
|
2822 __webpack_require__.d(selectors_namespaceObject, "isBlockValid", function() { return isBlockValid; }); |
|
2823 __webpack_require__.d(selectors_namespaceObject, "getBlockAttributes", function() { return getBlockAttributes; }); |
|
2824 __webpack_require__.d(selectors_namespaceObject, "getBlock", function() { return getBlock; }); |
|
2825 __webpack_require__.d(selectors_namespaceObject, "getBlocks", function() { return selectors_getBlocks; }); |
|
2826 __webpack_require__.d(selectors_namespaceObject, "__unstableGetBlockWithoutInnerBlocks", function() { return __unstableGetBlockWithoutInnerBlocks; }); |
|
2827 __webpack_require__.d(selectors_namespaceObject, "getClientIdsOfDescendants", function() { return getClientIdsOfDescendants; }); |
|
2828 __webpack_require__.d(selectors_namespaceObject, "getClientIdsWithDescendants", function() { return getClientIdsWithDescendants; }); |
|
2829 __webpack_require__.d(selectors_namespaceObject, "getGlobalBlockCount", function() { return getGlobalBlockCount; }); |
|
2830 __webpack_require__.d(selectors_namespaceObject, "getBlocksByClientId", function() { return getBlocksByClientId; }); |
|
2831 __webpack_require__.d(selectors_namespaceObject, "getBlockCount", function() { return getBlockCount; }); |
|
2832 __webpack_require__.d(selectors_namespaceObject, "getBlockSelectionStart", function() { return getBlockSelectionStart; }); |
|
2833 __webpack_require__.d(selectors_namespaceObject, "getBlockSelectionEnd", function() { return getBlockSelectionEnd; }); |
|
2834 __webpack_require__.d(selectors_namespaceObject, "getSelectedBlockCount", function() { return getSelectedBlockCount; }); |
|
2835 __webpack_require__.d(selectors_namespaceObject, "hasSelectedBlock", function() { return hasSelectedBlock; }); |
|
2836 __webpack_require__.d(selectors_namespaceObject, "getSelectedBlockClientId", function() { return selectors_getSelectedBlockClientId; }); |
|
2837 __webpack_require__.d(selectors_namespaceObject, "getSelectedBlock", function() { return getSelectedBlock; }); |
|
2838 __webpack_require__.d(selectors_namespaceObject, "getBlockRootClientId", function() { return getBlockRootClientId; }); |
|
2839 __webpack_require__.d(selectors_namespaceObject, "getBlockHierarchyRootClientId", function() { return getBlockHierarchyRootClientId; }); |
|
2840 __webpack_require__.d(selectors_namespaceObject, "getAdjacentBlockClientId", function() { return getAdjacentBlockClientId; }); |
|
2841 __webpack_require__.d(selectors_namespaceObject, "getPreviousBlockClientId", function() { return getPreviousBlockClientId; }); |
|
2842 __webpack_require__.d(selectors_namespaceObject, "getNextBlockClientId", function() { return getNextBlockClientId; }); |
|
2843 __webpack_require__.d(selectors_namespaceObject, "getSelectedBlocksInitialCaretPosition", function() { return getSelectedBlocksInitialCaretPosition; }); |
|
2844 __webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlockClientIds", function() { return getMultiSelectedBlockClientIds; }); |
|
2845 __webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlocks", function() { return getMultiSelectedBlocks; }); |
|
2846 __webpack_require__.d(selectors_namespaceObject, "getFirstMultiSelectedBlockClientId", function() { return getFirstMultiSelectedBlockClientId; }); |
|
2847 __webpack_require__.d(selectors_namespaceObject, "getLastMultiSelectedBlockClientId", function() { return getLastMultiSelectedBlockClientId; }); |
|
2848 __webpack_require__.d(selectors_namespaceObject, "isFirstMultiSelectedBlock", function() { return isFirstMultiSelectedBlock; }); |
|
2849 __webpack_require__.d(selectors_namespaceObject, "isBlockMultiSelected", function() { return isBlockMultiSelected; }); |
|
2850 __webpack_require__.d(selectors_namespaceObject, "isAncestorMultiSelected", function() { return isAncestorMultiSelected; }); |
|
2851 __webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlocksStartClientId", function() { return getMultiSelectedBlocksStartClientId; }); |
|
2852 __webpack_require__.d(selectors_namespaceObject, "getMultiSelectedBlocksEndClientId", function() { return getMultiSelectedBlocksEndClientId; }); |
|
2853 __webpack_require__.d(selectors_namespaceObject, "getBlockOrder", function() { return getBlockOrder; }); |
|
2854 __webpack_require__.d(selectors_namespaceObject, "getBlockIndex", function() { return getBlockIndex; }); |
|
2855 __webpack_require__.d(selectors_namespaceObject, "isBlockSelected", function() { return isBlockSelected; }); |
|
2856 __webpack_require__.d(selectors_namespaceObject, "hasSelectedInnerBlock", function() { return hasSelectedInnerBlock; }); |
|
2857 __webpack_require__.d(selectors_namespaceObject, "isBlockWithinSelection", function() { return isBlockWithinSelection; }); |
|
2858 __webpack_require__.d(selectors_namespaceObject, "hasMultiSelection", function() { return hasMultiSelection; }); |
|
2859 __webpack_require__.d(selectors_namespaceObject, "isMultiSelecting", function() { return isMultiSelecting; }); |
|
2860 __webpack_require__.d(selectors_namespaceObject, "isSelectionEnabled", function() { return isSelectionEnabled; }); |
|
2861 __webpack_require__.d(selectors_namespaceObject, "getBlockMode", function() { return getBlockMode; }); |
|
2862 __webpack_require__.d(selectors_namespaceObject, "isTyping", function() { return selectors_isTyping; }); |
|
2863 __webpack_require__.d(selectors_namespaceObject, "isCaretWithinFormattedText", function() { return selectors_isCaretWithinFormattedText; }); |
|
2864 __webpack_require__.d(selectors_namespaceObject, "getBlockInsertionPoint", function() { return getBlockInsertionPoint; }); |
|
2865 __webpack_require__.d(selectors_namespaceObject, "isBlockInsertionPointVisible", function() { return isBlockInsertionPointVisible; }); |
|
2866 __webpack_require__.d(selectors_namespaceObject, "isValidTemplate", function() { return isValidTemplate; }); |
|
2867 __webpack_require__.d(selectors_namespaceObject, "getTemplate", function() { return getTemplate; }); |
|
2868 __webpack_require__.d(selectors_namespaceObject, "getTemplateLock", function() { return getTemplateLock; }); |
|
2869 __webpack_require__.d(selectors_namespaceObject, "canInsertBlockType", function() { return canInsertBlockType; }); |
|
2870 __webpack_require__.d(selectors_namespaceObject, "getInserterItems", function() { return selectors_getInserterItems; }); |
|
2871 __webpack_require__.d(selectors_namespaceObject, "hasInserterItems", function() { return hasInserterItems; }); |
|
2872 __webpack_require__.d(selectors_namespaceObject, "getBlockListSettings", function() { return getBlockListSettings; }); |
|
2873 |
|
2874 // EXTERNAL MODULE: external {"this":["wp","blockEditor"]} |
|
2875 var external_this_wp_blockEditor_ = __webpack_require__(8); |
|
2876 |
|
2877 // EXTERNAL MODULE: external {"this":["wp","blocks"]} |
|
2878 var external_this_wp_blocks_ = __webpack_require__(14); |
|
2879 |
|
2880 // EXTERNAL MODULE: external {"this":["wp","coreData"]} |
|
2881 var external_this_wp_coreData_ = __webpack_require__(72); |
|
2882 |
|
2883 // EXTERNAL MODULE: external {"this":["wp","notices"]} |
|
2884 var external_this_wp_notices_ = __webpack_require__(133); |
|
2885 |
|
2886 // EXTERNAL MODULE: external {"this":["wp","nux"]} |
|
2887 var external_this_wp_nux_ = __webpack_require__(60); |
|
2888 |
|
2889 // EXTERNAL MODULE: external {"this":["wp","richText"]} |
|
2890 var external_this_wp_richText_ = __webpack_require__(20); |
|
2891 |
|
2892 // EXTERNAL MODULE: external {"this":["wp","viewport"]} |
|
2893 var external_this_wp_viewport_ = __webpack_require__(40); |
|
2894 |
|
2895 // EXTERNAL MODULE: external {"this":["wp","data"]} |
|
2896 var external_this_wp_data_ = __webpack_require__(5); |
|
2897 |
|
2898 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/slicedToArray.js + 1 modules |
|
2899 var slicedToArray = __webpack_require__(28); |
|
2900 |
|
2901 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/defineProperty.js |
|
2902 var defineProperty = __webpack_require__(15); |
|
2903 |
|
2904 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectSpread.js |
|
2905 var objectSpread = __webpack_require__(7); |
|
2906 |
|
2907 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/typeof.js |
|
2908 var esm_typeof = __webpack_require__(32); |
|
2909 |
|
2910 // EXTERNAL MODULE: ./node_modules/redux-optimist/index.js |
|
2911 var redux_optimist = __webpack_require__(62); |
|
2912 var redux_optimist_default = /*#__PURE__*/__webpack_require__.n(redux_optimist); |
|
2913 |
|
2914 // EXTERNAL MODULE: external "lodash" |
|
2915 var external_lodash_ = __webpack_require__(2); |
|
2916 |
|
2917 // EXTERNAL MODULE: external {"this":["wp","url"]} |
|
2918 var external_this_wp_url_ = __webpack_require__(25); |
|
2919 |
|
2920 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/defaults.js |
|
2921 |
|
2922 |
|
2923 /** |
|
2924 * WordPress dependencies |
|
2925 */ |
|
2926 |
|
2927 var PREFERENCES_DEFAULTS = { |
|
2928 isPublishSidebarEnabled: true |
|
2929 }; |
|
2930 /** |
|
2931 * Default initial edits state. |
|
2932 * |
|
2933 * @type {Object} |
|
2934 */ |
|
2935 |
|
2936 var INITIAL_EDITS_DEFAULTS = {}; |
|
2937 /** |
|
2938 * The default post editor settings |
|
2939 * |
|
2940 * allowedBlockTypes boolean|Array Allowed block types |
|
2941 * richEditingEnabled boolean Whether rich editing is enabled or not |
|
2942 * enableCustomFields boolean Whether the WordPress custom fields are enabled or not |
|
2943 * autosaveInterval number Autosave Interval |
|
2944 * availableTemplates array? The available post templates |
|
2945 * disablePostFormats boolean Whether or not the post formats are disabled |
|
2946 * allowedMimeTypes array? List of allowed mime types and file extensions |
|
2947 * maxUploadFileSize number Maximum upload file size |
|
2948 */ |
|
2949 |
|
2950 var EDITOR_SETTINGS_DEFAULTS = Object(objectSpread["a" /* default */])({}, external_this_wp_blockEditor_["SETTINGS_DEFAULTS"], { |
|
2951 richEditingEnabled: true, |
|
2952 enableCustomFields: false |
|
2953 }); |
|
2954 |
|
2955 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/constants.js |
|
2956 /** |
|
2957 * Set of post properties for which edits should assume a merging behavior, |
|
2958 * assuming an object value. |
|
2959 * |
|
2960 * @type {Set} |
|
2961 */ |
|
2962 var EDIT_MERGE_PROPERTIES = new Set(['meta']); |
|
2963 /** |
|
2964 * Constant for the store module (or reducer) key. |
|
2965 * @type {string} |
|
2966 */ |
|
2967 |
|
2968 var STORE_KEY = 'core/editor'; |
|
2969 var POST_UPDATE_TRANSACTION_ID = 'post-update'; |
|
2970 var SAVE_POST_NOTICE_ID = 'SAVE_POST_NOTICE_ID'; |
|
2971 var TRASH_POST_NOTICE_ID = 'TRASH_POST_NOTICE_ID'; |
|
2972 var PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/; |
|
2973 var ONE_MINUTE_IN_MS = 60 * 1000; |
|
2974 |
|
2975 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/with-change-detection/index.js |
|
2976 |
|
2977 |
|
2978 /** |
|
2979 * External dependencies |
|
2980 */ |
|
2981 |
|
2982 /** |
|
2983 * Higher-order reducer creator for tracking changes to state over time. The |
|
2984 * returned reducer will include a `isDirty` property on the object reflecting |
|
2985 * whether the original reference of the reducer has changed. |
|
2986 * |
|
2987 * @param {?Object} options Optional options. |
|
2988 * @param {?Array} options.ignoreTypes Action types upon which to skip check. |
|
2989 * @param {?Array} options.resetTypes Action types upon which to reset dirty. |
|
2990 * |
|
2991 * @return {Function} Higher-order reducer. |
|
2992 */ |
|
2993 |
|
2994 var with_change_detection_withChangeDetection = function withChangeDetection() { |
|
2995 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
2996 return function (reducer) { |
|
2997 return function (state, action) { |
|
2998 var nextState = reducer(state, action); // Reset at: |
|
2999 // - Initial state |
|
3000 // - Reset types |
|
3001 |
|
3002 var isReset = state === undefined || Object(external_lodash_["includes"])(options.resetTypes, action.type); |
|
3003 var isChanging = state !== nextState; // If not intending to update dirty flag, return early and avoid clone. |
|
3004 |
|
3005 if (!isChanging && !isReset) { |
|
3006 return state; |
|
3007 } // Avoid mutating state, unless it's already changing by original |
|
3008 // reducer and not initial. |
|
3009 |
|
3010 |
|
3011 if (!isChanging || state === undefined) { |
|
3012 nextState = Object(objectSpread["a" /* default */])({}, nextState); |
|
3013 } |
|
3014 |
|
3015 var isIgnored = Object(external_lodash_["includes"])(options.ignoreTypes, action.type); |
|
3016 |
|
3017 if (isIgnored) { |
|
3018 // Preserve the original value if ignored. |
|
3019 nextState.isDirty = state.isDirty; |
|
3020 } else { |
|
3021 nextState.isDirty = !isReset && isChanging; |
|
3022 } |
|
3023 |
|
3024 return nextState; |
|
3025 }; |
|
3026 }; |
|
3027 }; |
|
3028 |
|
3029 /* harmony default export */ var with_change_detection = (with_change_detection_withChangeDetection); |
|
3030 |
|
3031 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/toConsumableArray.js + 2 modules |
|
3032 var toConsumableArray = __webpack_require__(17); |
|
3033 |
|
3034 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/with-history/index.js |
|
3035 |
|
3036 |
|
3037 |
|
3038 /** |
|
3039 * External dependencies |
|
3040 */ |
|
3041 |
|
3042 /** |
|
3043 * Default options for withHistory reducer enhancer. Refer to withHistory |
|
3044 * documentation for options explanation. |
|
3045 * |
|
3046 * @see withHistory |
|
3047 * |
|
3048 * @type {Object} |
|
3049 */ |
|
3050 |
|
3051 var DEFAULT_OPTIONS = { |
|
3052 resetTypes: [], |
|
3053 ignoreTypes: [], |
|
3054 shouldOverwriteState: function shouldOverwriteState() { |
|
3055 return false; |
|
3056 } |
|
3057 }; |
|
3058 /** |
|
3059 * Higher-order reducer creator which transforms the result of the original |
|
3060 * reducer into an object tracking its own history (past, present, future). |
|
3061 * |
|
3062 * @param {?Object} options Optional options. |
|
3063 * @param {?Array} options.resetTypes Action types upon which to |
|
3064 * clear past. |
|
3065 * @param {?Array} options.ignoreTypes Action types upon which to |
|
3066 * avoid history tracking. |
|
3067 * @param {?Function} options.shouldOverwriteState Function receiving last and |
|
3068 * current actions, returning |
|
3069 * boolean indicating whether |
|
3070 * present should be merged, |
|
3071 * rather than add undo level. |
|
3072 * |
|
3073 * @return {Function} Higher-order reducer. |
|
3074 */ |
|
3075 |
|
3076 var with_history_withHistory = function withHistory() { |
|
3077 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
3078 return function (reducer) { |
|
3079 options = Object(objectSpread["a" /* default */])({}, DEFAULT_OPTIONS, options); // `ignoreTypes` is simply a convenience for `shouldOverwriteState` |
|
3080 |
|
3081 options.shouldOverwriteState = Object(external_lodash_["overSome"])([options.shouldOverwriteState, function (action) { |
|
3082 return Object(external_lodash_["includes"])(options.ignoreTypes, action.type); |
|
3083 }]); |
|
3084 var initialState = { |
|
3085 past: [], |
|
3086 present: reducer(undefined, {}), |
|
3087 future: [], |
|
3088 lastAction: null, |
|
3089 shouldCreateUndoLevel: false |
|
3090 }; |
|
3091 var _options = options, |
|
3092 _options$resetTypes = _options.resetTypes, |
|
3093 resetTypes = _options$resetTypes === void 0 ? [] : _options$resetTypes, |
|
3094 _options$shouldOverwr = _options.shouldOverwriteState, |
|
3095 shouldOverwriteState = _options$shouldOverwr === void 0 ? function () { |
|
3096 return false; |
|
3097 } : _options$shouldOverwr; |
|
3098 return function () { |
|
3099 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : initialState; |
|
3100 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3101 var past = state.past, |
|
3102 present = state.present, |
|
3103 future = state.future, |
|
3104 lastAction = state.lastAction, |
|
3105 shouldCreateUndoLevel = state.shouldCreateUndoLevel; |
|
3106 var previousAction = lastAction; |
|
3107 |
|
3108 switch (action.type) { |
|
3109 case 'UNDO': |
|
3110 // Can't undo if no past. |
|
3111 if (!past.length) { |
|
3112 return state; |
|
3113 } |
|
3114 |
|
3115 return { |
|
3116 past: Object(external_lodash_["dropRight"])(past), |
|
3117 present: Object(external_lodash_["last"])(past), |
|
3118 future: [present].concat(Object(toConsumableArray["a" /* default */])(future)), |
|
3119 lastAction: null, |
|
3120 shouldCreateUndoLevel: false |
|
3121 }; |
|
3122 |
|
3123 case 'REDO': |
|
3124 // Can't redo if no future. |
|
3125 if (!future.length) { |
|
3126 return state; |
|
3127 } |
|
3128 |
|
3129 return { |
|
3130 past: [].concat(Object(toConsumableArray["a" /* default */])(past), [present]), |
|
3131 present: Object(external_lodash_["first"])(future), |
|
3132 future: Object(external_lodash_["drop"])(future), |
|
3133 lastAction: null, |
|
3134 shouldCreateUndoLevel: false |
|
3135 }; |
|
3136 |
|
3137 case 'CREATE_UNDO_LEVEL': |
|
3138 return Object(objectSpread["a" /* default */])({}, state, { |
|
3139 lastAction: null, |
|
3140 shouldCreateUndoLevel: true |
|
3141 }); |
|
3142 } |
|
3143 |
|
3144 var nextPresent = reducer(present, action); |
|
3145 |
|
3146 if (Object(external_lodash_["includes"])(resetTypes, action.type)) { |
|
3147 return { |
|
3148 past: [], |
|
3149 present: nextPresent, |
|
3150 future: [], |
|
3151 lastAction: null, |
|
3152 shouldCreateUndoLevel: false |
|
3153 }; |
|
3154 } |
|
3155 |
|
3156 if (present === nextPresent) { |
|
3157 return state; |
|
3158 } |
|
3159 |
|
3160 var nextPast = past; // The `lastAction` property is used to compare actions in the |
|
3161 // `shouldOverwriteState` option. If an action should be ignored, do not |
|
3162 // submit that action as the last action, otherwise the ability to |
|
3163 // compare subsequent actions will break. |
|
3164 |
|
3165 var lastActionToSubmit = previousAction; |
|
3166 |
|
3167 if (shouldCreateUndoLevel || !past.length || !shouldOverwriteState(action, previousAction)) { |
|
3168 nextPast = [].concat(Object(toConsumableArray["a" /* default */])(past), [present]); |
|
3169 lastActionToSubmit = action; |
|
3170 } |
|
3171 |
|
3172 return { |
|
3173 past: nextPast, |
|
3174 present: nextPresent, |
|
3175 future: [], |
|
3176 shouldCreateUndoLevel: false, |
|
3177 lastAction: lastActionToSubmit |
|
3178 }; |
|
3179 }; |
|
3180 }; |
|
3181 }; |
|
3182 |
|
3183 /* harmony default export */ var with_history = (with_history_withHistory); |
|
3184 |
|
3185 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/reducer.js |
|
3186 |
|
3187 |
|
3188 |
|
3189 |
|
3190 |
|
3191 /** |
|
3192 * External dependencies |
|
3193 */ |
|
3194 |
|
3195 |
|
3196 /** |
|
3197 * WordPress dependencies |
|
3198 */ |
|
3199 |
|
3200 |
|
3201 |
|
3202 /** |
|
3203 * Internal dependencies |
|
3204 */ |
|
3205 |
|
3206 |
|
3207 |
|
3208 |
|
3209 |
|
3210 /** |
|
3211 * Returns a post attribute value, flattening nested rendered content using its |
|
3212 * raw value in place of its original object form. |
|
3213 * |
|
3214 * @param {*} value Original value. |
|
3215 * |
|
3216 * @return {*} Raw value. |
|
3217 */ |
|
3218 |
|
3219 function getPostRawValue(value) { |
|
3220 if (value && 'object' === Object(esm_typeof["a" /* default */])(value) && 'raw' in value) { |
|
3221 return value.raw; |
|
3222 } |
|
3223 |
|
3224 return value; |
|
3225 } |
|
3226 /** |
|
3227 * Returns an object against which it is safe to perform mutating operations, |
|
3228 * given the original object and its current working copy. |
|
3229 * |
|
3230 * @param {Object} original Original object. |
|
3231 * @param {Object} working Working object. |
|
3232 * |
|
3233 * @return {Object} Mutation-safe object. |
|
3234 */ |
|
3235 |
|
3236 function getMutateSafeObject(original, working) { |
|
3237 if (original === working) { |
|
3238 return Object(objectSpread["a" /* default */])({}, original); |
|
3239 } |
|
3240 |
|
3241 return working; |
|
3242 } |
|
3243 /** |
|
3244 * Returns true if the two object arguments have the same keys, or false |
|
3245 * otherwise. |
|
3246 * |
|
3247 * @param {Object} a First object. |
|
3248 * @param {Object} b Second object. |
|
3249 * |
|
3250 * @return {boolean} Whether the two objects have the same keys. |
|
3251 */ |
|
3252 |
|
3253 |
|
3254 function hasSameKeys(a, b) { |
|
3255 return Object(external_lodash_["isEqual"])(Object(external_lodash_["keys"])(a), Object(external_lodash_["keys"])(b)); |
|
3256 } |
|
3257 /** |
|
3258 * Returns true if, given the currently dispatching action and the previously |
|
3259 * dispatched action, the two actions are editing the same post property, or |
|
3260 * false otherwise. |
|
3261 * |
|
3262 * @param {Object} action Currently dispatching action. |
|
3263 * @param {Object} previousAction Previously dispatched action. |
|
3264 * |
|
3265 * @return {boolean} Whether actions are updating the same post property. |
|
3266 */ |
|
3267 |
|
3268 function isUpdatingSamePostProperty(action, previousAction) { |
|
3269 return action.type === 'EDIT_POST' && hasSameKeys(action.edits, previousAction.edits); |
|
3270 } |
|
3271 /** |
|
3272 * Returns true if, given the currently dispatching action and the previously |
|
3273 * dispatched action, the two actions are modifying the same property such that |
|
3274 * undo history should be batched. |
|
3275 * |
|
3276 * @param {Object} action Currently dispatching action. |
|
3277 * @param {Object} previousAction Previously dispatched action. |
|
3278 * |
|
3279 * @return {boolean} Whether to overwrite present state. |
|
3280 */ |
|
3281 |
|
3282 function reducer_shouldOverwriteState(action, previousAction) { |
|
3283 if (action.type === 'RESET_EDITOR_BLOCKS') { |
|
3284 return !action.shouldCreateUndoLevel; |
|
3285 } |
|
3286 |
|
3287 if (!previousAction || action.type !== previousAction.type) { |
|
3288 return false; |
|
3289 } |
|
3290 |
|
3291 return isUpdatingSamePostProperty(action, previousAction); |
|
3292 } |
|
3293 /** |
|
3294 * Undoable reducer returning the editor post state, including blocks parsed |
|
3295 * from current HTML markup. |
|
3296 * |
|
3297 * Handles the following state keys: |
|
3298 * - edits: an object describing changes to be made to the current post, in |
|
3299 * the format accepted by the WP REST API |
|
3300 * - blocks: post content blocks |
|
3301 * |
|
3302 * @param {Object} state Current state. |
|
3303 * @param {Object} action Dispatched action. |
|
3304 * |
|
3305 * @returns {Object} Updated state. |
|
3306 */ |
|
3307 |
|
3308 var editor = Object(external_lodash_["flow"])([external_this_wp_data_["combineReducers"], with_history({ |
|
3309 resetTypes: ['SETUP_EDITOR_STATE'], |
|
3310 ignoreTypes: ['RESET_POST', 'UPDATE_POST'], |
|
3311 shouldOverwriteState: reducer_shouldOverwriteState |
|
3312 })])({ |
|
3313 // Track whether changes exist, resetting at each post save. Relies on |
|
3314 // editor initialization firing post reset as an effect. |
|
3315 blocks: with_change_detection({ |
|
3316 resetTypes: ['SETUP_EDITOR_STATE', 'REQUEST_POST_UPDATE_START'] |
|
3317 })(function () { |
|
3318 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { |
|
3319 value: [] |
|
3320 }; |
|
3321 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3322 |
|
3323 switch (action.type) { |
|
3324 case 'RESET_EDITOR_BLOCKS': |
|
3325 if (action.blocks === state.value) { |
|
3326 return state; |
|
3327 } |
|
3328 |
|
3329 return { |
|
3330 value: action.blocks |
|
3331 }; |
|
3332 } |
|
3333 |
|
3334 return state; |
|
3335 }), |
|
3336 edits: function edits() { |
|
3337 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
3338 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3339 |
|
3340 switch (action.type) { |
|
3341 case 'EDIT_POST': |
|
3342 return Object(external_lodash_["reduce"])(action.edits, function (result, value, key) { |
|
3343 // Only assign into result if not already same value |
|
3344 if (value !== state[key]) { |
|
3345 result = getMutateSafeObject(state, result); |
|
3346 |
|
3347 if (EDIT_MERGE_PROPERTIES.has(key)) { |
|
3348 // Merge properties should assign to current value. |
|
3349 result[key] = Object(objectSpread["a" /* default */])({}, result[key], value); |
|
3350 } else { |
|
3351 // Otherwise override. |
|
3352 result[key] = value; |
|
3353 } |
|
3354 } |
|
3355 |
|
3356 return result; |
|
3357 }, state); |
|
3358 |
|
3359 case 'UPDATE_POST': |
|
3360 case 'RESET_POST': |
|
3361 var getCanonicalValue = action.type === 'UPDATE_POST' ? function (key) { |
|
3362 return action.edits[key]; |
|
3363 } : function (key) { |
|
3364 return getPostRawValue(action.post[key]); |
|
3365 }; |
|
3366 return Object(external_lodash_["reduce"])(state, function (result, value, key) { |
|
3367 if (!Object(external_lodash_["isEqual"])(value, getCanonicalValue(key))) { |
|
3368 return result; |
|
3369 } |
|
3370 |
|
3371 result = getMutateSafeObject(state, result); |
|
3372 delete result[key]; |
|
3373 return result; |
|
3374 }, state); |
|
3375 |
|
3376 case 'RESET_EDITOR_BLOCKS': |
|
3377 if ('content' in state) { |
|
3378 return Object(external_lodash_["omit"])(state, 'content'); |
|
3379 } |
|
3380 |
|
3381 return state; |
|
3382 } |
|
3383 |
|
3384 return state; |
|
3385 } |
|
3386 }); |
|
3387 /** |
|
3388 * Reducer returning the initial edits state. With matching shape to that of |
|
3389 * `editor.edits`, the initial edits are those applied programmatically, are |
|
3390 * not considered in prompting the user for unsaved changes, and are included |
|
3391 * in (and reset by) the next save payload. |
|
3392 * |
|
3393 * @param {Object} state Current state. |
|
3394 * @param {Object} action Action object. |
|
3395 * |
|
3396 * @return {Object} Next state. |
|
3397 */ |
|
3398 |
|
3399 function initialEdits() { |
|
3400 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : INITIAL_EDITS_DEFAULTS; |
|
3401 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3402 |
|
3403 switch (action.type) { |
|
3404 case 'SETUP_EDITOR': |
|
3405 if (!action.edits) { |
|
3406 break; |
|
3407 } |
|
3408 |
|
3409 return action.edits; |
|
3410 |
|
3411 case 'SETUP_EDITOR_STATE': |
|
3412 if ('content' in state) { |
|
3413 return Object(external_lodash_["omit"])(state, 'content'); |
|
3414 } |
|
3415 |
|
3416 return state; |
|
3417 |
|
3418 case 'UPDATE_POST': |
|
3419 return Object(external_lodash_["reduce"])(action.edits, function (result, value, key) { |
|
3420 if (!result.hasOwnProperty(key)) { |
|
3421 return result; |
|
3422 } |
|
3423 |
|
3424 result = getMutateSafeObject(state, result); |
|
3425 delete result[key]; |
|
3426 return result; |
|
3427 }, state); |
|
3428 |
|
3429 case 'RESET_POST': |
|
3430 return INITIAL_EDITS_DEFAULTS; |
|
3431 } |
|
3432 |
|
3433 return state; |
|
3434 } |
|
3435 /** |
|
3436 * Reducer returning the last-known state of the current post, in the format |
|
3437 * returned by the WP REST API. |
|
3438 * |
|
3439 * @param {Object} state Current state. |
|
3440 * @param {Object} action Dispatched action. |
|
3441 * |
|
3442 * @return {Object} Updated state. |
|
3443 */ |
|
3444 |
|
3445 function currentPost() { |
|
3446 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
3447 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3448 |
|
3449 switch (action.type) { |
|
3450 case 'SETUP_EDITOR_STATE': |
|
3451 case 'RESET_POST': |
|
3452 case 'UPDATE_POST': |
|
3453 var post; |
|
3454 |
|
3455 if (action.post) { |
|
3456 post = action.post; |
|
3457 } else if (action.edits) { |
|
3458 post = Object(objectSpread["a" /* default */])({}, state, action.edits); |
|
3459 } else { |
|
3460 return state; |
|
3461 } |
|
3462 |
|
3463 return Object(external_lodash_["mapValues"])(post, getPostRawValue); |
|
3464 } |
|
3465 |
|
3466 return state; |
|
3467 } |
|
3468 /** |
|
3469 * Reducer returning typing state. |
|
3470 * |
|
3471 * @param {boolean} state Current state. |
|
3472 * @param {Object} action Dispatched action. |
|
3473 * |
|
3474 * @return {boolean} Updated state. |
|
3475 */ |
|
3476 |
|
3477 function isTyping() { |
|
3478 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
|
3479 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3480 |
|
3481 switch (action.type) { |
|
3482 case 'START_TYPING': |
|
3483 return true; |
|
3484 |
|
3485 case 'STOP_TYPING': |
|
3486 return false; |
|
3487 } |
|
3488 |
|
3489 return state; |
|
3490 } |
|
3491 /** |
|
3492 * Reducer returning whether the caret is within formatted text. |
|
3493 * |
|
3494 * @param {boolean} state Current state. |
|
3495 * @param {Object} action Dispatched action. |
|
3496 * |
|
3497 * @return {boolean} Updated state. |
|
3498 */ |
|
3499 |
|
3500 function isCaretWithinFormattedText() { |
|
3501 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
|
3502 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3503 |
|
3504 switch (action.type) { |
|
3505 case 'ENTER_FORMATTED_TEXT': |
|
3506 return true; |
|
3507 |
|
3508 case 'EXIT_FORMATTED_TEXT': |
|
3509 return false; |
|
3510 } |
|
3511 |
|
3512 return state; |
|
3513 } |
|
3514 /** |
|
3515 * Reducer returning the block selection's state. |
|
3516 * |
|
3517 * @param {Object} state Current state. |
|
3518 * @param {Object} action Dispatched action. |
|
3519 * |
|
3520 * @return {Object} Updated state. |
|
3521 */ |
|
3522 |
|
3523 function blockSelection() { |
|
3524 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { |
|
3525 start: null, |
|
3526 end: null, |
|
3527 isMultiSelecting: false, |
|
3528 isEnabled: true, |
|
3529 initialPosition: null |
|
3530 }; |
|
3531 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3532 |
|
3533 switch (action.type) { |
|
3534 case 'CLEAR_SELECTED_BLOCK': |
|
3535 if (state.start === null && state.end === null && !state.isMultiSelecting) { |
|
3536 return state; |
|
3537 } |
|
3538 |
|
3539 return Object(objectSpread["a" /* default */])({}, state, { |
|
3540 start: null, |
|
3541 end: null, |
|
3542 isMultiSelecting: false, |
|
3543 initialPosition: null |
|
3544 }); |
|
3545 |
|
3546 case 'START_MULTI_SELECT': |
|
3547 if (state.isMultiSelecting) { |
|
3548 return state; |
|
3549 } |
|
3550 |
|
3551 return Object(objectSpread["a" /* default */])({}, state, { |
|
3552 isMultiSelecting: true, |
|
3553 initialPosition: null |
|
3554 }); |
|
3555 |
|
3556 case 'STOP_MULTI_SELECT': |
|
3557 if (!state.isMultiSelecting) { |
|
3558 return state; |
|
3559 } |
|
3560 |
|
3561 return Object(objectSpread["a" /* default */])({}, state, { |
|
3562 isMultiSelecting: false, |
|
3563 initialPosition: null |
|
3564 }); |
|
3565 |
|
3566 case 'MULTI_SELECT': |
|
3567 return Object(objectSpread["a" /* default */])({}, state, { |
|
3568 start: action.start, |
|
3569 end: action.end, |
|
3570 initialPosition: null |
|
3571 }); |
|
3572 |
|
3573 case 'SELECT_BLOCK': |
|
3574 if (action.clientId === state.start && action.clientId === state.end) { |
|
3575 return state; |
|
3576 } |
|
3577 |
|
3578 return Object(objectSpread["a" /* default */])({}, state, { |
|
3579 start: action.clientId, |
|
3580 end: action.clientId, |
|
3581 initialPosition: action.initialPosition |
|
3582 }); |
|
3583 |
|
3584 case 'INSERT_BLOCKS': |
|
3585 { |
|
3586 if (action.updateSelection) { |
|
3587 return Object(objectSpread["a" /* default */])({}, state, { |
|
3588 start: action.blocks[0].clientId, |
|
3589 end: action.blocks[0].clientId, |
|
3590 initialPosition: null, |
|
3591 isMultiSelecting: false |
|
3592 }); |
|
3593 } |
|
3594 |
|
3595 return state; |
|
3596 } |
|
3597 |
|
3598 case 'REMOVE_BLOCKS': |
|
3599 if (!action.clientIds || !action.clientIds.length || action.clientIds.indexOf(state.start) === -1) { |
|
3600 return state; |
|
3601 } |
|
3602 |
|
3603 return Object(objectSpread["a" /* default */])({}, state, { |
|
3604 start: null, |
|
3605 end: null, |
|
3606 initialPosition: null, |
|
3607 isMultiSelecting: false |
|
3608 }); |
|
3609 |
|
3610 case 'REPLACE_BLOCKS': |
|
3611 if (action.clientIds.indexOf(state.start) === -1) { |
|
3612 return state; |
|
3613 } // If there are replacement blocks, assign last block as the next |
|
3614 // selected block, otherwise set to null. |
|
3615 |
|
3616 |
|
3617 var lastBlock = Object(external_lodash_["last"])(action.blocks); |
|
3618 var nextSelectedBlockClientId = lastBlock ? lastBlock.clientId : null; |
|
3619 |
|
3620 if (nextSelectedBlockClientId === state.start && nextSelectedBlockClientId === state.end) { |
|
3621 return state; |
|
3622 } |
|
3623 |
|
3624 return Object(objectSpread["a" /* default */])({}, state, { |
|
3625 start: nextSelectedBlockClientId, |
|
3626 end: nextSelectedBlockClientId, |
|
3627 initialPosition: null, |
|
3628 isMultiSelecting: false |
|
3629 }); |
|
3630 |
|
3631 case 'TOGGLE_SELECTION': |
|
3632 return Object(objectSpread["a" /* default */])({}, state, { |
|
3633 isEnabled: action.isSelectionEnabled |
|
3634 }); |
|
3635 } |
|
3636 |
|
3637 return state; |
|
3638 } |
|
3639 function blocksMode() { |
|
3640 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
3641 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3642 |
|
3643 if (action.type === 'TOGGLE_BLOCK_MODE') { |
|
3644 var clientId = action.clientId; |
|
3645 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, clientId, state[clientId] && state[clientId] === 'html' ? 'visual' : 'html')); |
|
3646 } |
|
3647 |
|
3648 return state; |
|
3649 } |
|
3650 /** |
|
3651 * Reducer returning the block insertion point visibility, either null if there |
|
3652 * is not an explicit insertion point assigned, or an object of its `index` and |
|
3653 * `rootClientId`. |
|
3654 * |
|
3655 * @param {Object} state Current state. |
|
3656 * @param {Object} action Dispatched action. |
|
3657 * |
|
3658 * @return {Object} Updated state. |
|
3659 */ |
|
3660 |
|
3661 function insertionPoint() { |
|
3662 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; |
|
3663 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3664 |
|
3665 switch (action.type) { |
|
3666 case 'SHOW_INSERTION_POINT': |
|
3667 var rootClientId = action.rootClientId, |
|
3668 index = action.index; |
|
3669 return { |
|
3670 rootClientId: rootClientId, |
|
3671 index: index |
|
3672 }; |
|
3673 |
|
3674 case 'HIDE_INSERTION_POINT': |
|
3675 return null; |
|
3676 } |
|
3677 |
|
3678 return state; |
|
3679 } |
|
3680 /** |
|
3681 * Reducer returning whether the post blocks match the defined template or not. |
|
3682 * |
|
3683 * @param {Object} state Current state. |
|
3684 * @param {Object} action Dispatched action. |
|
3685 * |
|
3686 * @return {boolean} Updated state. |
|
3687 */ |
|
3688 |
|
3689 function reducer_template() { |
|
3690 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { |
|
3691 isValid: true |
|
3692 }; |
|
3693 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3694 |
|
3695 switch (action.type) { |
|
3696 case 'SET_TEMPLATE_VALIDITY': |
|
3697 return Object(objectSpread["a" /* default */])({}, state, { |
|
3698 isValid: action.isValid |
|
3699 }); |
|
3700 } |
|
3701 |
|
3702 return state; |
|
3703 } |
|
3704 /** |
|
3705 * Reducer returning the user preferences. |
|
3706 * |
|
3707 * @param {Object} state Current state. |
|
3708 * @param {Object} action Dispatched action. |
|
3709 * |
|
3710 * @return {string} Updated state. |
|
3711 */ |
|
3712 |
|
3713 function preferences() { |
|
3714 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : PREFERENCES_DEFAULTS; |
|
3715 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3716 |
|
3717 switch (action.type) { |
|
3718 case 'ENABLE_PUBLISH_SIDEBAR': |
|
3719 return Object(objectSpread["a" /* default */])({}, state, { |
|
3720 isPublishSidebarEnabled: true |
|
3721 }); |
|
3722 |
|
3723 case 'DISABLE_PUBLISH_SIDEBAR': |
|
3724 return Object(objectSpread["a" /* default */])({}, state, { |
|
3725 isPublishSidebarEnabled: false |
|
3726 }); |
|
3727 } |
|
3728 |
|
3729 return state; |
|
3730 } |
|
3731 /** |
|
3732 * Reducer returning current network request state (whether a request to |
|
3733 * the WP REST API is in progress, successful, or failed). |
|
3734 * |
|
3735 * @param {Object} state Current state. |
|
3736 * @param {Object} action Dispatched action. |
|
3737 * |
|
3738 * @return {Object} Updated state. |
|
3739 */ |
|
3740 |
|
3741 function saving() { |
|
3742 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
3743 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3744 |
|
3745 switch (action.type) { |
|
3746 case 'REQUEST_POST_UPDATE_START': |
|
3747 return { |
|
3748 requesting: true, |
|
3749 successful: false, |
|
3750 error: null, |
|
3751 options: action.options || {} |
|
3752 }; |
|
3753 |
|
3754 case 'REQUEST_POST_UPDATE_SUCCESS': |
|
3755 return { |
|
3756 requesting: false, |
|
3757 successful: true, |
|
3758 error: null, |
|
3759 options: action.options || {} |
|
3760 }; |
|
3761 |
|
3762 case 'REQUEST_POST_UPDATE_FAILURE': |
|
3763 return { |
|
3764 requesting: false, |
|
3765 successful: false, |
|
3766 error: action.error, |
|
3767 options: action.options || {} |
|
3768 }; |
|
3769 } |
|
3770 |
|
3771 return state; |
|
3772 } |
|
3773 /** |
|
3774 * Post Lock State. |
|
3775 * |
|
3776 * @typedef {Object} PostLockState |
|
3777 * |
|
3778 * @property {boolean} isLocked Whether the post is locked. |
|
3779 * @property {?boolean} isTakeover Whether the post editing has been taken over. |
|
3780 * @property {?boolean} activePostLock Active post lock value. |
|
3781 * @property {?Object} user User that took over the post. |
|
3782 */ |
|
3783 |
|
3784 /** |
|
3785 * Reducer returning the post lock status. |
|
3786 * |
|
3787 * @param {PostLockState} state Current state. |
|
3788 * @param {Object} action Dispatched action. |
|
3789 * |
|
3790 * @return {PostLockState} Updated state. |
|
3791 */ |
|
3792 |
|
3793 function postLock() { |
|
3794 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : { |
|
3795 isLocked: false |
|
3796 }; |
|
3797 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3798 |
|
3799 switch (action.type) { |
|
3800 case 'UPDATE_POST_LOCK': |
|
3801 return action.lock; |
|
3802 } |
|
3803 |
|
3804 return state; |
|
3805 } |
|
3806 /** |
|
3807 * Post saving lock. |
|
3808 * |
|
3809 * When post saving is locked, the post cannot be published or updated. |
|
3810 * |
|
3811 * @param {PostSavingLockState} state Current state. |
|
3812 * @param {Object} action Dispatched action. |
|
3813 * |
|
3814 * @return {PostLockState} Updated state. |
|
3815 */ |
|
3816 |
|
3817 function postSavingLock() { |
|
3818 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
3819 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3820 |
|
3821 switch (action.type) { |
|
3822 case 'LOCK_POST_SAVING': |
|
3823 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, action.lockName, true)); |
|
3824 |
|
3825 case 'UNLOCK_POST_SAVING': |
|
3826 return Object(external_lodash_["omit"])(state, action.lockName); |
|
3827 } |
|
3828 |
|
3829 return state; |
|
3830 } |
|
3831 var reducer_reusableBlocks = Object(external_this_wp_data_["combineReducers"])({ |
|
3832 data: function data() { |
|
3833 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
3834 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3835 |
|
3836 switch (action.type) { |
|
3837 case 'RECEIVE_REUSABLE_BLOCKS': |
|
3838 { |
|
3839 return Object(external_lodash_["reduce"])(action.results, function (nextState, result) { |
|
3840 var _result$reusableBlock = result.reusableBlock, |
|
3841 id = _result$reusableBlock.id, |
|
3842 title = _result$reusableBlock.title; |
|
3843 var clientId = result.parsedBlock.clientId; |
|
3844 var value = { |
|
3845 clientId: clientId, |
|
3846 title: title |
|
3847 }; |
|
3848 |
|
3849 if (!Object(external_lodash_["isEqual"])(nextState[id], value)) { |
|
3850 nextState = getMutateSafeObject(state, nextState); |
|
3851 nextState[id] = value; |
|
3852 } |
|
3853 |
|
3854 return nextState; |
|
3855 }, state); |
|
3856 } |
|
3857 |
|
3858 case 'UPDATE_REUSABLE_BLOCK_TITLE': |
|
3859 { |
|
3860 var id = action.id, |
|
3861 title = action.title; |
|
3862 |
|
3863 if (!state[id] || state[id].title === title) { |
|
3864 return state; |
|
3865 } |
|
3866 |
|
3867 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, id, Object(objectSpread["a" /* default */])({}, state[id], { |
|
3868 title: title |
|
3869 }))); |
|
3870 } |
|
3871 |
|
3872 case 'SAVE_REUSABLE_BLOCK_SUCCESS': |
|
3873 { |
|
3874 var _id = action.id, |
|
3875 updatedId = action.updatedId; // If a temporary reusable block is saved, we swap the temporary id with the final one |
|
3876 |
|
3877 if (_id === updatedId) { |
|
3878 return state; |
|
3879 } |
|
3880 |
|
3881 var value = state[_id]; |
|
3882 return Object(objectSpread["a" /* default */])({}, Object(external_lodash_["omit"])(state, _id), Object(defineProperty["a" /* default */])({}, updatedId, value)); |
|
3883 } |
|
3884 |
|
3885 case 'REMOVE_REUSABLE_BLOCK': |
|
3886 { |
|
3887 var _id2 = action.id; |
|
3888 return Object(external_lodash_["omit"])(state, _id2); |
|
3889 } |
|
3890 } |
|
3891 |
|
3892 return state; |
|
3893 }, |
|
3894 isFetching: function isFetching() { |
|
3895 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
3896 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3897 |
|
3898 switch (action.type) { |
|
3899 case 'FETCH_REUSABLE_BLOCKS': |
|
3900 { |
|
3901 var id = action.id; |
|
3902 |
|
3903 if (!id) { |
|
3904 return state; |
|
3905 } |
|
3906 |
|
3907 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, id, true)); |
|
3908 } |
|
3909 |
|
3910 case 'FETCH_REUSABLE_BLOCKS_SUCCESS': |
|
3911 case 'FETCH_REUSABLE_BLOCKS_FAILURE': |
|
3912 { |
|
3913 var _id3 = action.id; |
|
3914 return Object(external_lodash_["omit"])(state, _id3); |
|
3915 } |
|
3916 } |
|
3917 |
|
3918 return state; |
|
3919 }, |
|
3920 isSaving: function isSaving() { |
|
3921 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
3922 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3923 |
|
3924 switch (action.type) { |
|
3925 case 'SAVE_REUSABLE_BLOCK': |
|
3926 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, action.id, true)); |
|
3927 |
|
3928 case 'SAVE_REUSABLE_BLOCK_SUCCESS': |
|
3929 case 'SAVE_REUSABLE_BLOCK_FAILURE': |
|
3930 { |
|
3931 var id = action.id; |
|
3932 return Object(external_lodash_["omit"])(state, id); |
|
3933 } |
|
3934 } |
|
3935 |
|
3936 return state; |
|
3937 } |
|
3938 }); |
|
3939 /** |
|
3940 * Reducer returning an object where each key is a block client ID, its value |
|
3941 * representing the settings for its nested blocks. |
|
3942 * |
|
3943 * @param {Object} state Current state. |
|
3944 * @param {Object} action Dispatched action. |
|
3945 * |
|
3946 * @return {Object} Updated state. |
|
3947 */ |
|
3948 |
|
3949 var reducer_blockListSettings = function blockListSettings() { |
|
3950 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
3951 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3952 |
|
3953 switch (action.type) { |
|
3954 // Even if the replaced blocks have the same client ID, our logic |
|
3955 // should correct the state. |
|
3956 case 'REPLACE_BLOCKS': |
|
3957 case 'REMOVE_BLOCKS': |
|
3958 { |
|
3959 return Object(external_lodash_["omit"])(state, action.clientIds); |
|
3960 } |
|
3961 |
|
3962 case 'UPDATE_BLOCK_LIST_SETTINGS': |
|
3963 { |
|
3964 var clientId = action.clientId; |
|
3965 |
|
3966 if (!action.settings) { |
|
3967 if (state.hasOwnProperty(clientId)) { |
|
3968 return Object(external_lodash_["omit"])(state, clientId); |
|
3969 } |
|
3970 |
|
3971 return state; |
|
3972 } |
|
3973 |
|
3974 if (Object(external_lodash_["isEqual"])(state[clientId], action.settings)) { |
|
3975 return state; |
|
3976 } |
|
3977 |
|
3978 return Object(objectSpread["a" /* default */])({}, state, Object(defineProperty["a" /* default */])({}, clientId, action.settings)); |
|
3979 } |
|
3980 } |
|
3981 |
|
3982 return state; |
|
3983 }; |
|
3984 /** |
|
3985 * Reducer returning the most recent autosave. |
|
3986 * |
|
3987 * @param {Object} state The autosave object. |
|
3988 * @param {Object} action Dispatched action. |
|
3989 * |
|
3990 * @return {Object} Updated state. |
|
3991 */ |
|
3992 |
|
3993 function autosave() { |
|
3994 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; |
|
3995 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
3996 |
|
3997 switch (action.type) { |
|
3998 case 'RESET_AUTOSAVE': |
|
3999 var post = action.post; |
|
4000 |
|
4001 var _map = ['title', 'excerpt', 'content'].map(function (field) { |
|
4002 return getPostRawValue(post[field]); |
|
4003 }), |
|
4004 _map2 = Object(slicedToArray["a" /* default */])(_map, 3), |
|
4005 title = _map2[0], |
|
4006 excerpt = _map2[1], |
|
4007 content = _map2[2]; |
|
4008 |
|
4009 return { |
|
4010 title: title, |
|
4011 excerpt: excerpt, |
|
4012 content: content |
|
4013 }; |
|
4014 } |
|
4015 |
|
4016 return state; |
|
4017 } |
|
4018 /** |
|
4019 * Reducer returning the post preview link. |
|
4020 * |
|
4021 * @param {string?} state The preview link |
|
4022 * @param {Object} action Dispatched action. |
|
4023 * |
|
4024 * @return {string?} Updated state. |
|
4025 */ |
|
4026 |
|
4027 function reducer_previewLink() { |
|
4028 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null; |
|
4029 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
4030 |
|
4031 switch (action.type) { |
|
4032 case 'REQUEST_POST_UPDATE_SUCCESS': |
|
4033 if (action.post.preview_link) { |
|
4034 return action.post.preview_link; |
|
4035 } else if (action.post.link) { |
|
4036 return Object(external_this_wp_url_["addQueryArgs"])(action.post.link, { |
|
4037 preview: true |
|
4038 }); |
|
4039 } |
|
4040 |
|
4041 return state; |
|
4042 |
|
4043 case 'REQUEST_POST_UPDATE_START': |
|
4044 // Invalidate known preview link when autosave starts. |
|
4045 if (state && action.options.isPreview) { |
|
4046 return null; |
|
4047 } |
|
4048 |
|
4049 break; |
|
4050 } |
|
4051 |
|
4052 return state; |
|
4053 } |
|
4054 /** |
|
4055 * Reducer returning whether the editor is ready to be rendered. |
|
4056 * The editor is considered ready to be rendered once |
|
4057 * the post object is loaded properly and the initial blocks parsed. |
|
4058 * |
|
4059 * @param {boolean} state |
|
4060 * @param {Object} action |
|
4061 * |
|
4062 * @return {boolean} Updated state. |
|
4063 */ |
|
4064 |
|
4065 function reducer_isReady() { |
|
4066 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; |
|
4067 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
4068 |
|
4069 switch (action.type) { |
|
4070 case 'SETUP_EDITOR_STATE': |
|
4071 return true; |
|
4072 } |
|
4073 |
|
4074 return state; |
|
4075 } |
|
4076 /** |
|
4077 * Reducer returning the post editor setting. |
|
4078 * |
|
4079 * @param {Object} state Current state. |
|
4080 * @param {Object} action Dispatched action. |
|
4081 * |
|
4082 * @return {Object} Updated state. |
|
4083 */ |
|
4084 |
|
4085 function reducer_editorSettings() { |
|
4086 var state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : EDITOR_SETTINGS_DEFAULTS; |
|
4087 var action = arguments.length > 1 ? arguments[1] : undefined; |
|
4088 |
|
4089 switch (action.type) { |
|
4090 case 'UPDATE_EDITOR_SETTINGS': |
|
4091 return Object(objectSpread["a" /* default */])({}, state, action.settings); |
|
4092 } |
|
4093 |
|
4094 return state; |
|
4095 } |
|
4096 /* harmony default export */ var store_reducer = (redux_optimist_default()(Object(external_this_wp_data_["combineReducers"])({ |
|
4097 editor: editor, |
|
4098 initialEdits: initialEdits, |
|
4099 currentPost: currentPost, |
|
4100 preferences: preferences, |
|
4101 saving: saving, |
|
4102 postLock: postLock, |
|
4103 reusableBlocks: reducer_reusableBlocks, |
|
4104 template: reducer_template, |
|
4105 autosave: autosave, |
|
4106 previewLink: reducer_previewLink, |
|
4107 postSavingLock: postSavingLock, |
|
4108 isReady: reducer_isReady, |
|
4109 editorSettings: reducer_editorSettings |
|
4110 }))); |
|
4111 |
|
4112 // EXTERNAL MODULE: ./node_modules/refx/refx.js |
|
4113 var refx = __webpack_require__(70); |
|
4114 var refx_default = /*#__PURE__*/__webpack_require__.n(refx); |
|
4115 |
|
4116 // EXTERNAL MODULE: ./node_modules/redux-multi/lib/index.js |
|
4117 var lib = __webpack_require__(97); |
|
4118 var lib_default = /*#__PURE__*/__webpack_require__.n(lib); |
|
4119 |
|
4120 // EXTERNAL MODULE: ./node_modules/@babel/runtime/regenerator/index.js |
|
4121 var regenerator = __webpack_require__(23); |
|
4122 var regenerator_default = /*#__PURE__*/__webpack_require__.n(regenerator); |
|
4123 |
|
4124 // EXTERNAL MODULE: external {"this":["wp","apiFetch"]} |
|
4125 var external_this_wp_apiFetch_ = __webpack_require__(33); |
|
4126 var external_this_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_apiFetch_); |
|
4127 |
|
4128 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/controls.js |
|
4129 |
|
4130 |
|
4131 /** |
|
4132 * WordPress dependencies |
|
4133 */ |
|
4134 |
|
4135 |
|
4136 /** |
|
4137 * Dispatches a control action for triggering an api fetch call. |
|
4138 * |
|
4139 * @param {Object} request Arguments for the fetch request. |
|
4140 * |
|
4141 * @return {Object} control descriptor. |
|
4142 */ |
|
4143 |
|
4144 function apiFetch(request) { |
|
4145 return { |
|
4146 type: 'API_FETCH', |
|
4147 request: request |
|
4148 }; |
|
4149 } |
|
4150 /** |
|
4151 * Dispatches a control action for triggering a registry select. |
|
4152 * |
|
4153 * @param {string} storeKey |
|
4154 * @param {string} selectorName |
|
4155 * @param {Array} args Arguments for the select. |
|
4156 * |
|
4157 * @return {Object} control descriptor. |
|
4158 */ |
|
4159 |
|
4160 function controls_select(storeKey, selectorName) { |
|
4161 for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { |
|
4162 args[_key - 2] = arguments[_key]; |
|
4163 } |
|
4164 |
|
4165 return { |
|
4166 type: 'SELECT', |
|
4167 storeKey: storeKey, |
|
4168 selectorName: selectorName, |
|
4169 args: args |
|
4170 }; |
|
4171 } |
|
4172 /** |
|
4173 * Dispatches a control action for triggering a registry select that has a |
|
4174 * resolver. |
|
4175 * |
|
4176 * @param {string} storeKey |
|
4177 * @param {string} selectorName |
|
4178 * @param {Array} args Arguments for the select. |
|
4179 * |
|
4180 * @return {Object} control descriptor. |
|
4181 */ |
|
4182 |
|
4183 function resolveSelect(storeKey, selectorName) { |
|
4184 for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) { |
|
4185 args[_key2 - 2] = arguments[_key2]; |
|
4186 } |
|
4187 |
|
4188 return { |
|
4189 type: 'RESOLVE_SELECT', |
|
4190 storeKey: storeKey, |
|
4191 selectorName: selectorName, |
|
4192 args: args |
|
4193 }; |
|
4194 } |
|
4195 /** |
|
4196 * Dispatches a control action for triggering a registry dispatch. |
|
4197 * |
|
4198 * @param {string} storeKey |
|
4199 * @param {string} actionName |
|
4200 * @param {Array} args Arguments for the dispatch action. |
|
4201 * |
|
4202 * @return {Object} control descriptor. |
|
4203 */ |
|
4204 |
|
4205 function controls_dispatch(storeKey, actionName) { |
|
4206 for (var _len3 = arguments.length, args = new Array(_len3 > 2 ? _len3 - 2 : 0), _key3 = 2; _key3 < _len3; _key3++) { |
|
4207 args[_key3 - 2] = arguments[_key3]; |
|
4208 } |
|
4209 |
|
4210 return { |
|
4211 type: 'DISPATCH', |
|
4212 storeKey: storeKey, |
|
4213 actionName: actionName, |
|
4214 args: args |
|
4215 }; |
|
4216 } |
|
4217 /* harmony default export */ var controls = ({ |
|
4218 API_FETCH: function API_FETCH(_ref) { |
|
4219 var request = _ref.request; |
|
4220 return external_this_wp_apiFetch_default()(request); |
|
4221 }, |
|
4222 SELECT: Object(external_this_wp_data_["createRegistryControl"])(function (registry) { |
|
4223 return function (_ref2) { |
|
4224 var _registry$select; |
|
4225 |
|
4226 var storeKey = _ref2.storeKey, |
|
4227 selectorName = _ref2.selectorName, |
|
4228 args = _ref2.args; |
|
4229 return (_registry$select = registry.select(storeKey))[selectorName].apply(_registry$select, Object(toConsumableArray["a" /* default */])(args)); |
|
4230 }; |
|
4231 }), |
|
4232 DISPATCH: Object(external_this_wp_data_["createRegistryControl"])(function (registry) { |
|
4233 return function (_ref3) { |
|
4234 var _registry$dispatch; |
|
4235 |
|
4236 var storeKey = _ref3.storeKey, |
|
4237 actionName = _ref3.actionName, |
|
4238 args = _ref3.args; |
|
4239 return (_registry$dispatch = registry.dispatch(storeKey))[actionName].apply(_registry$dispatch, Object(toConsumableArray["a" /* default */])(args)); |
|
4240 }; |
|
4241 }), |
|
4242 RESOLVE_SELECT: Object(external_this_wp_data_["createRegistryControl"])(function (registry) { |
|
4243 return function (_ref4) { |
|
4244 var storeKey = _ref4.storeKey, |
|
4245 selectorName = _ref4.selectorName, |
|
4246 args = _ref4.args; |
|
4247 return new Promise(function (resolve) { |
|
4248 var hasFinished = function hasFinished() { |
|
4249 return registry.select('core/data').hasFinishedResolution(storeKey, selectorName, args); |
|
4250 }; |
|
4251 |
|
4252 var getResult = function getResult() { |
|
4253 return registry.select(storeKey)[selectorName].apply(null, args); |
|
4254 }; // trigger the selector (to trigger the resolver) |
|
4255 |
|
4256 |
|
4257 var result = getResult(); |
|
4258 |
|
4259 if (hasFinished()) { |
|
4260 return resolve(result); |
|
4261 } |
|
4262 |
|
4263 var unsubscribe = registry.subscribe(function () { |
|
4264 if (hasFinished()) { |
|
4265 unsubscribe(); |
|
4266 resolve(getResult()); |
|
4267 } |
|
4268 }); |
|
4269 }); |
|
4270 }; |
|
4271 }) |
|
4272 }); |
|
4273 |
|
4274 // EXTERNAL MODULE: external {"this":["wp","i18n"]} |
|
4275 var external_this_wp_i18n_ = __webpack_require__(1); |
|
4276 |
|
4277 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/utils/notice-builder.js |
|
4278 /** |
|
4279 * WordPress dependencies |
|
4280 */ |
|
4281 |
|
4282 /** |
|
4283 * Internal dependencies |
|
4284 */ |
|
4285 |
|
4286 |
|
4287 /** |
|
4288 * External dependencies |
|
4289 */ |
|
4290 |
|
4291 |
|
4292 /** |
|
4293 * Builds the arguments for a success notification dispatch. |
|
4294 * |
|
4295 * @param {Object} data Incoming data to build the arguments from. |
|
4296 * |
|
4297 * @return {Array} Arguments for dispatch. An empty array signals no |
|
4298 * notification should be sent. |
|
4299 */ |
|
4300 |
|
4301 function getNotificationArgumentsForSaveSuccess(data) { |
|
4302 var previousPost = data.previousPost, |
|
4303 post = data.post, |
|
4304 postType = data.postType; // Autosaves are neither shown a notice nor redirected. |
|
4305 |
|
4306 if (Object(external_lodash_["get"])(data.options, ['isAutosave'])) { |
|
4307 return []; |
|
4308 } |
|
4309 |
|
4310 var publishStatus = ['publish', 'private', 'future']; |
|
4311 var isPublished = Object(external_lodash_["includes"])(publishStatus, previousPost.status); |
|
4312 var willPublish = Object(external_lodash_["includes"])(publishStatus, post.status); |
|
4313 var noticeMessage; |
|
4314 var shouldShowLink = Object(external_lodash_["get"])(postType, ['viewable'], false); |
|
4315 |
|
4316 if (!isPublished && !willPublish) { |
|
4317 // If saving a non-published post, don't show notice. |
|
4318 noticeMessage = null; |
|
4319 } else if (isPublished && !willPublish) { |
|
4320 // If undoing publish status, show specific notice |
|
4321 noticeMessage = postType.labels.item_reverted_to_draft; |
|
4322 shouldShowLink = false; |
|
4323 } else if (!isPublished && willPublish) { |
|
4324 // If publishing or scheduling a post, show the corresponding |
|
4325 // publish message |
|
4326 noticeMessage = { |
|
4327 publish: postType.labels.item_published, |
|
4328 private: postType.labels.item_published_privately, |
|
4329 future: postType.labels.item_scheduled |
|
4330 }[post.status]; |
|
4331 } else { |
|
4332 // Generic fallback notice |
|
4333 noticeMessage = postType.labels.item_updated; |
|
4334 } |
|
4335 |
|
4336 if (noticeMessage) { |
|
4337 var actions = []; |
|
4338 |
|
4339 if (shouldShowLink) { |
|
4340 actions.push({ |
|
4341 label: postType.labels.view_item, |
|
4342 url: post.link |
|
4343 }); |
|
4344 } |
|
4345 |
|
4346 return [noticeMessage, { |
|
4347 id: SAVE_POST_NOTICE_ID, |
|
4348 actions: actions |
|
4349 }]; |
|
4350 } |
|
4351 |
|
4352 return []; |
|
4353 } |
|
4354 /** |
|
4355 * Builds the fail notification arguments for dispatch. |
|
4356 * |
|
4357 * @param {Object} data Incoming data to build the arguments with. |
|
4358 * |
|
4359 * @return {Array} Arguments for dispatch. An empty array signals no |
|
4360 * notification should be sent. |
|
4361 */ |
|
4362 |
|
4363 function getNotificationArgumentsForSaveFail(data) { |
|
4364 var post = data.post, |
|
4365 edits = data.edits, |
|
4366 error = data.error; |
|
4367 |
|
4368 if (error && 'rest_autosave_no_changes' === error.code) { |
|
4369 // Autosave requested a new autosave, but there were no changes. This shouldn't |
|
4370 // result in an error notice for the user. |
|
4371 return []; |
|
4372 } |
|
4373 |
|
4374 var publishStatus = ['publish', 'private', 'future']; |
|
4375 var isPublished = publishStatus.indexOf(post.status) !== -1; // If the post was being published, we show the corresponding publish error message |
|
4376 // Unless we publish an "updating failed" message |
|
4377 |
|
4378 var messages = { |
|
4379 publish: Object(external_this_wp_i18n_["__"])('Publishing failed'), |
|
4380 private: Object(external_this_wp_i18n_["__"])('Publishing failed'), |
|
4381 future: Object(external_this_wp_i18n_["__"])('Scheduling failed') |
|
4382 }; |
|
4383 var noticeMessage = !isPublished && publishStatus.indexOf(edits.status) !== -1 ? messages[edits.status] : Object(external_this_wp_i18n_["__"])('Updating failed'); |
|
4384 return [noticeMessage, { |
|
4385 id: SAVE_POST_NOTICE_ID |
|
4386 }]; |
|
4387 } |
|
4388 /** |
|
4389 * Builds the trash fail notification arguments for dispatch. |
|
4390 * |
|
4391 * @param {Object} data |
|
4392 * |
|
4393 * @return {Array} Arguments for dispatch. |
|
4394 */ |
|
4395 |
|
4396 function getNotificationArgumentsForTrashFail(data) { |
|
4397 return [data.error.message && data.error.code !== 'unknown_error' ? data.error.message : Object(external_this_wp_i18n_["__"])('Trashing failed'), { |
|
4398 id: TRASH_POST_NOTICE_ID |
|
4399 }]; |
|
4400 } |
|
4401 |
|
4402 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/actions.js |
|
4403 |
|
4404 |
|
4405 |
|
4406 |
|
4407 var _marked = |
|
4408 /*#__PURE__*/ |
|
4409 regenerator_default.a.mark(savePost), |
|
4410 _marked2 = |
|
4411 /*#__PURE__*/ |
|
4412 regenerator_default.a.mark(refreshPost), |
|
4413 _marked3 = |
|
4414 /*#__PURE__*/ |
|
4415 regenerator_default.a.mark(trashPost), |
|
4416 _marked4 = |
|
4417 /*#__PURE__*/ |
|
4418 regenerator_default.a.mark(actions_autosave); |
|
4419 |
|
4420 /** |
|
4421 * External dependencies |
|
4422 */ |
|
4423 |
|
4424 |
|
4425 /** |
|
4426 * Internal dependencies |
|
4427 */ |
|
4428 |
|
4429 |
|
4430 |
|
4431 |
|
4432 /** |
|
4433 * Returns an action object used in signalling that editor has initialized with |
|
4434 * the specified post object and editor settings. |
|
4435 * |
|
4436 * @param {Object} post Post object. |
|
4437 * @param {Object} edits Initial edited attributes object. |
|
4438 * @param {Array?} template Block Template. |
|
4439 * |
|
4440 * @return {Object} Action object. |
|
4441 */ |
|
4442 |
|
4443 function setupEditor(post, edits, template) { |
|
4444 return { |
|
4445 type: 'SETUP_EDITOR', |
|
4446 post: post, |
|
4447 edits: edits, |
|
4448 template: template |
|
4449 }; |
|
4450 } |
|
4451 /** |
|
4452 * Returns an action object used in signalling that the latest version of the |
|
4453 * post has been received, either by initialization or save. |
|
4454 * |
|
4455 * @param {Object} post Post object. |
|
4456 * |
|
4457 * @return {Object} Action object. |
|
4458 */ |
|
4459 |
|
4460 function resetPost(post) { |
|
4461 return { |
|
4462 type: 'RESET_POST', |
|
4463 post: post |
|
4464 }; |
|
4465 } |
|
4466 /** |
|
4467 * Returns an action object used in signalling that the latest autosave of the |
|
4468 * post has been received, by initialization or autosave. |
|
4469 * |
|
4470 * @param {Object} post Autosave post object. |
|
4471 * |
|
4472 * @return {Object} Action object. |
|
4473 */ |
|
4474 |
|
4475 function resetAutosave(post) { |
|
4476 return { |
|
4477 type: 'RESET_AUTOSAVE', |
|
4478 post: post |
|
4479 }; |
|
4480 } |
|
4481 /** |
|
4482 * Optimistic action for dispatching that a post update request has started. |
|
4483 * |
|
4484 * @param {Object} options |
|
4485 * |
|
4486 * @return {Object} An action object |
|
4487 */ |
|
4488 |
|
4489 function __experimentalRequestPostUpdateStart() { |
|
4490 var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
4491 return { |
|
4492 type: 'REQUEST_POST_UPDATE_START', |
|
4493 optimist: { |
|
4494 type: redux_optimist["BEGIN"], |
|
4495 id: POST_UPDATE_TRANSACTION_ID |
|
4496 }, |
|
4497 options: options |
|
4498 }; |
|
4499 } |
|
4500 /** |
|
4501 * Optimistic action for indicating that the request post update has completed |
|
4502 * successfully. |
|
4503 * |
|
4504 * @param {Object} data The data for the action. |
|
4505 * @param {Object} data.previousPost The previous post prior to update. |
|
4506 * @param {Object} data.post The new post after update |
|
4507 * @param {boolean} data.isRevision Whether the post is a revision or not. |
|
4508 * @param {Object} data.options Options passed through from the original |
|
4509 * action dispatch. |
|
4510 * @param {Object} data.postType The post type object. |
|
4511 * |
|
4512 * @return {Object} Action object. |
|
4513 */ |
|
4514 |
|
4515 function __experimentalRequestPostUpdateSuccess(_ref) { |
|
4516 var previousPost = _ref.previousPost, |
|
4517 post = _ref.post, |
|
4518 isRevision = _ref.isRevision, |
|
4519 options = _ref.options, |
|
4520 postType = _ref.postType; |
|
4521 return { |
|
4522 type: 'REQUEST_POST_UPDATE_SUCCESS', |
|
4523 previousPost: previousPost, |
|
4524 post: post, |
|
4525 optimist: { |
|
4526 // Note: REVERT is not a failure case here. Rather, it |
|
4527 // is simply reversing the assumption that the updates |
|
4528 // were applied to the post proper, such that the post |
|
4529 // treated as having unsaved changes. |
|
4530 type: isRevision ? redux_optimist["REVERT"] : redux_optimist["COMMIT"], |
|
4531 id: POST_UPDATE_TRANSACTION_ID |
|
4532 }, |
|
4533 options: options, |
|
4534 postType: postType |
|
4535 }; |
|
4536 } |
|
4537 /** |
|
4538 * Optimistic action for indicating that the request post update has completed |
|
4539 * with a failure. |
|
4540 * |
|
4541 * @param {Object} data The data for the action |
|
4542 * @param {Object} data.post The post that failed updating. |
|
4543 * @param {Object} data.edits The fields that were being updated. |
|
4544 * @param {*} data.error The error from the failed call. |
|
4545 * @param {Object} data.options Options passed through from the original |
|
4546 * action dispatch. |
|
4547 * @return {Object} An action object |
|
4548 */ |
|
4549 |
|
4550 function __experimentalRequestPostUpdateFailure(_ref2) { |
|
4551 var post = _ref2.post, |
|
4552 edits = _ref2.edits, |
|
4553 error = _ref2.error, |
|
4554 options = _ref2.options; |
|
4555 return { |
|
4556 type: 'REQUEST_POST_UPDATE_FAILURE', |
|
4557 optimist: { |
|
4558 type: redux_optimist["REVERT"], |
|
4559 id: POST_UPDATE_TRANSACTION_ID |
|
4560 }, |
|
4561 post: post, |
|
4562 edits: edits, |
|
4563 error: error, |
|
4564 options: options |
|
4565 }; |
|
4566 } |
|
4567 /** |
|
4568 * Returns an action object used in signalling that a patch of updates for the |
|
4569 * latest version of the post have been received. |
|
4570 * |
|
4571 * @param {Object} edits Updated post fields. |
|
4572 * |
|
4573 * @return {Object} Action object. |
|
4574 */ |
|
4575 |
|
4576 function updatePost(edits) { |
|
4577 return { |
|
4578 type: 'UPDATE_POST', |
|
4579 edits: edits |
|
4580 }; |
|
4581 } |
|
4582 /** |
|
4583 * Returns an action object used to setup the editor state when first opening |
|
4584 * an editor. |
|
4585 * |
|
4586 * @param {Object} post Post object. |
|
4587 * |
|
4588 * @return {Object} Action object. |
|
4589 */ |
|
4590 |
|
4591 function setupEditorState(post) { |
|
4592 return { |
|
4593 type: 'SETUP_EDITOR_STATE', |
|
4594 post: post |
|
4595 }; |
|
4596 } |
|
4597 /** |
|
4598 * Returns an action object used in signalling that attributes of the post have |
|
4599 * been edited. |
|
4600 * |
|
4601 * @param {Object} edits Post attributes to edit. |
|
4602 * |
|
4603 * @return {Object} Action object. |
|
4604 */ |
|
4605 |
|
4606 function actions_editPost(edits) { |
|
4607 return { |
|
4608 type: 'EDIT_POST', |
|
4609 edits: edits |
|
4610 }; |
|
4611 } |
|
4612 /** |
|
4613 * Returns action object produced by the updatePost creator augmented by |
|
4614 * an optimist option that signals optimistically applying updates. |
|
4615 * |
|
4616 * @param {Object} edits Updated post fields. |
|
4617 * |
|
4618 * @return {Object} Action object. |
|
4619 */ |
|
4620 |
|
4621 function __experimentalOptimisticUpdatePost(edits) { |
|
4622 return Object(objectSpread["a" /* default */])({}, updatePost(edits), { |
|
4623 optimist: { |
|
4624 id: POST_UPDATE_TRANSACTION_ID |
|
4625 } |
|
4626 }); |
|
4627 } |
|
4628 /** |
|
4629 * Action generator for saving the current post in the editor. |
|
4630 * |
|
4631 * @param {Object} options |
|
4632 */ |
|
4633 |
|
4634 function savePost() { |
|
4635 var options, |
|
4636 isEditedPostSaveable, |
|
4637 edits, |
|
4638 isAutosave, |
|
4639 isEditedPostNew, |
|
4640 post, |
|
4641 editedPostContent, |
|
4642 toSend, |
|
4643 currentPostType, |
|
4644 postType, |
|
4645 path, |
|
4646 method, |
|
4647 autoSavePost, |
|
4648 newPost, |
|
4649 resetAction, |
|
4650 notifySuccessArgs, |
|
4651 notifyFailArgs, |
|
4652 _args = arguments; |
|
4653 return regenerator_default.a.wrap(function savePost$(_context) { |
|
4654 while (1) { |
|
4655 switch (_context.prev = _context.next) { |
|
4656 case 0: |
|
4657 options = _args.length > 0 && _args[0] !== undefined ? _args[0] : {}; |
|
4658 _context.next = 3; |
|
4659 return controls_select(STORE_KEY, 'isEditedPostSaveable'); |
|
4660 |
|
4661 case 3: |
|
4662 isEditedPostSaveable = _context.sent; |
|
4663 |
|
4664 if (isEditedPostSaveable) { |
|
4665 _context.next = 6; |
|
4666 break; |
|
4667 } |
|
4668 |
|
4669 return _context.abrupt("return"); |
|
4670 |
|
4671 case 6: |
|
4672 _context.next = 8; |
|
4673 return controls_select(STORE_KEY, 'getPostEdits'); |
|
4674 |
|
4675 case 8: |
|
4676 edits = _context.sent; |
|
4677 isAutosave = !!options.isAutosave; |
|
4678 |
|
4679 if (isAutosave) { |
|
4680 edits = Object(external_lodash_["pick"])(edits, ['title', 'content', 'excerpt']); |
|
4681 } |
|
4682 |
|
4683 _context.next = 13; |
|
4684 return controls_select(STORE_KEY, 'isEditedPostNew'); |
|
4685 |
|
4686 case 13: |
|
4687 isEditedPostNew = _context.sent; |
|
4688 |
|
4689 // New posts (with auto-draft status) must be explicitly assigned draft |
|
4690 // status if there is not already a status assigned in edits (publish). |
|
4691 // Otherwise, they are wrongly left as auto-draft. Status is not always |
|
4692 // respected for autosaves, so it cannot simply be included in the pick |
|
4693 // above. This behavior relies on an assumption that an auto-draft post |
|
4694 // would never be saved by anyone other than the owner of the post, per |
|
4695 // logic within autosaves REST controller to save status field only for |
|
4696 // draft/auto-draft by current user. |
|
4697 // |
|
4698 // See: https://core.trac.wordpress.org/ticket/43316#comment:88 |
|
4699 // See: https://core.trac.wordpress.org/ticket/43316#comment:89 |
|
4700 if (isEditedPostNew) { |
|
4701 edits = Object(objectSpread["a" /* default */])({ |
|
4702 status: 'draft' |
|
4703 }, edits); |
|
4704 } |
|
4705 |
|
4706 _context.next = 17; |
|
4707 return controls_select(STORE_KEY, 'getCurrentPost'); |
|
4708 |
|
4709 case 17: |
|
4710 post = _context.sent; |
|
4711 _context.next = 20; |
|
4712 return controls_select(STORE_KEY, 'getEditedPostContent'); |
|
4713 |
|
4714 case 20: |
|
4715 editedPostContent = _context.sent; |
|
4716 toSend = Object(objectSpread["a" /* default */])({}, edits, { |
|
4717 content: editedPostContent, |
|
4718 id: post.id |
|
4719 }); |
|
4720 _context.next = 24; |
|
4721 return controls_select(STORE_KEY, 'getCurrentPostType'); |
|
4722 |
|
4723 case 24: |
|
4724 currentPostType = _context.sent; |
|
4725 _context.next = 27; |
|
4726 return resolveSelect('core', 'getPostType', currentPostType); |
|
4727 |
|
4728 case 27: |
|
4729 postType = _context.sent; |
|
4730 _context.next = 30; |
|
4731 return controls_dispatch(STORE_KEY, '__experimentalRequestPostUpdateStart', options); |
|
4732 |
|
4733 case 30: |
|
4734 _context.next = 32; |
|
4735 return controls_dispatch(STORE_KEY, '__experimentalOptimisticUpdatePost', toSend); |
|
4736 |
|
4737 case 32: |
|
4738 path = "/wp/v2/".concat(postType.rest_base, "/").concat(post.id); |
|
4739 method = 'PUT'; |
|
4740 |
|
4741 if (!isAutosave) { |
|
4742 _context.next = 43; |
|
4743 break; |
|
4744 } |
|
4745 |
|
4746 _context.next = 37; |
|
4747 return controls_select(STORE_KEY, 'getAutosave'); |
|
4748 |
|
4749 case 37: |
|
4750 autoSavePost = _context.sent; |
|
4751 // Ensure autosaves contain all expected fields, using autosave or |
|
4752 // post values as fallback if not otherwise included in edits. |
|
4753 toSend = Object(objectSpread["a" /* default */])({}, Object(external_lodash_["pick"])(post, ['title', 'content', 'excerpt']), autoSavePost, toSend); |
|
4754 path += '/autosaves'; |
|
4755 method = 'POST'; |
|
4756 _context.next = 47; |
|
4757 break; |
|
4758 |
|
4759 case 43: |
|
4760 _context.next = 45; |
|
4761 return controls_dispatch('core/notices', 'removeNotice', SAVE_POST_NOTICE_ID); |
|
4762 |
|
4763 case 45: |
|
4764 _context.next = 47; |
|
4765 return controls_dispatch('core/notices', 'removeNotice', 'autosave-exists'); |
|
4766 |
|
4767 case 47: |
|
4768 _context.prev = 47; |
|
4769 _context.next = 50; |
|
4770 return apiFetch({ |
|
4771 path: path, |
|
4772 method: method, |
|
4773 data: toSend |
|
4774 }); |
|
4775 |
|
4776 case 50: |
|
4777 newPost = _context.sent; |
|
4778 resetAction = isAutosave ? 'resetAutosave' : 'resetPost'; |
|
4779 _context.next = 54; |
|
4780 return controls_dispatch(STORE_KEY, resetAction, newPost); |
|
4781 |
|
4782 case 54: |
|
4783 _context.next = 56; |
|
4784 return controls_dispatch(STORE_KEY, '__experimentalRequestPostUpdateSuccess', { |
|
4785 previousPost: post, |
|
4786 post: newPost, |
|
4787 options: options, |
|
4788 postType: postType, |
|
4789 // An autosave may be processed by the server as a regular save |
|
4790 // when its update is requested by the author and the post was |
|
4791 // draft or auto-draft. |
|
4792 isRevision: newPost.id !== post.id |
|
4793 }); |
|
4794 |
|
4795 case 56: |
|
4796 notifySuccessArgs = getNotificationArgumentsForSaveSuccess({ |
|
4797 previousPost: post, |
|
4798 post: newPost, |
|
4799 postType: postType, |
|
4800 options: options |
|
4801 }); |
|
4802 |
|
4803 if (!(notifySuccessArgs.length > 0)) { |
|
4804 _context.next = 60; |
|
4805 break; |
|
4806 } |
|
4807 |
|
4808 _context.next = 60; |
|
4809 return controls_dispatch.apply(void 0, ['core/notices', 'createSuccessNotice'].concat(Object(toConsumableArray["a" /* default */])(notifySuccessArgs))); |
|
4810 |
|
4811 case 60: |
|
4812 _context.next = 70; |
|
4813 break; |
|
4814 |
|
4815 case 62: |
|
4816 _context.prev = 62; |
|
4817 _context.t0 = _context["catch"](47); |
|
4818 _context.next = 66; |
|
4819 return controls_dispatch(STORE_KEY, '__experimentalRequestPostUpdateFailure', { |
|
4820 post: post, |
|
4821 edits: edits, |
|
4822 error: _context.t0, |
|
4823 options: options |
|
4824 }); |
|
4825 |
|
4826 case 66: |
|
4827 notifyFailArgs = getNotificationArgumentsForSaveFail({ |
|
4828 post: post, |
|
4829 edits: edits, |
|
4830 error: _context.t0 |
|
4831 }); |
|
4832 |
|
4833 if (!(notifyFailArgs.length > 0)) { |
|
4834 _context.next = 70; |
|
4835 break; |
|
4836 } |
|
4837 |
|
4838 _context.next = 70; |
|
4839 return controls_dispatch.apply(void 0, ['core/notices', 'createErrorNotice'].concat(Object(toConsumableArray["a" /* default */])(notifyFailArgs))); |
|
4840 |
|
4841 case 70: |
|
4842 case "end": |
|
4843 return _context.stop(); |
|
4844 } |
|
4845 } |
|
4846 }, _marked, this, [[47, 62]]); |
|
4847 } |
|
4848 /** |
|
4849 * Action generator for handling refreshing the current post. |
|
4850 */ |
|
4851 |
|
4852 function refreshPost() { |
|
4853 var post, postTypeSlug, postType, newPost; |
|
4854 return regenerator_default.a.wrap(function refreshPost$(_context2) { |
|
4855 while (1) { |
|
4856 switch (_context2.prev = _context2.next) { |
|
4857 case 0: |
|
4858 _context2.next = 2; |
|
4859 return controls_select(STORE_KEY, 'getCurrentPost'); |
|
4860 |
|
4861 case 2: |
|
4862 post = _context2.sent; |
|
4863 _context2.next = 5; |
|
4864 return controls_select(STORE_KEY, 'getCurrentPostType'); |
|
4865 |
|
4866 case 5: |
|
4867 postTypeSlug = _context2.sent; |
|
4868 _context2.next = 8; |
|
4869 return resolveSelect('core', 'getPostType', postTypeSlug); |
|
4870 |
|
4871 case 8: |
|
4872 postType = _context2.sent; |
|
4873 _context2.next = 11; |
|
4874 return apiFetch({ |
|
4875 // Timestamp arg allows caller to bypass browser caching, which is |
|
4876 // expected for this specific function. |
|
4877 path: "/wp/v2/".concat(postType.rest_base, "/").concat(post.id) + "?context=edit&_timestamp=".concat(Date.now()) |
|
4878 }); |
|
4879 |
|
4880 case 11: |
|
4881 newPost = _context2.sent; |
|
4882 _context2.next = 14; |
|
4883 return controls_dispatch(STORE_KEY, 'resetPost', newPost); |
|
4884 |
|
4885 case 14: |
|
4886 case "end": |
|
4887 return _context2.stop(); |
|
4888 } |
|
4889 } |
|
4890 }, _marked2, this); |
|
4891 } |
|
4892 /** |
|
4893 * Action generator for trashing the current post in the editor. |
|
4894 */ |
|
4895 |
|
4896 function trashPost() { |
|
4897 var postTypeSlug, postType, post; |
|
4898 return regenerator_default.a.wrap(function trashPost$(_context3) { |
|
4899 while (1) { |
|
4900 switch (_context3.prev = _context3.next) { |
|
4901 case 0: |
|
4902 _context3.next = 2; |
|
4903 return controls_select(STORE_KEY, 'getCurrentPostType'); |
|
4904 |
|
4905 case 2: |
|
4906 postTypeSlug = _context3.sent; |
|
4907 _context3.next = 5; |
|
4908 return resolveSelect('core', 'getPostType', postTypeSlug); |
|
4909 |
|
4910 case 5: |
|
4911 postType = _context3.sent; |
|
4912 _context3.next = 8; |
|
4913 return controls_dispatch('core/notices', 'removeNotice', TRASH_POST_NOTICE_ID); |
|
4914 |
|
4915 case 8: |
|
4916 _context3.prev = 8; |
|
4917 _context3.next = 11; |
|
4918 return controls_select(STORE_KEY, 'getCurrentPost'); |
|
4919 |
|
4920 case 11: |
|
4921 post = _context3.sent; |
|
4922 _context3.next = 14; |
|
4923 return apiFetch({ |
|
4924 path: "/wp/v2/".concat(postType.rest_base, "/").concat(post.id), |
|
4925 method: 'DELETE' |
|
4926 }); |
|
4927 |
|
4928 case 14: |
|
4929 _context3.next = 16; |
|
4930 return controls_dispatch(STORE_KEY, 'resetPost', Object(objectSpread["a" /* default */])({}, post, { |
|
4931 status: 'trash' |
|
4932 })); |
|
4933 |
|
4934 case 16: |
|
4935 _context3.next = 22; |
|
4936 break; |
|
4937 |
|
4938 case 18: |
|
4939 _context3.prev = 18; |
|
4940 _context3.t0 = _context3["catch"](8); |
|
4941 _context3.next = 22; |
|
4942 return controls_dispatch.apply(void 0, ['core/notices', 'createErrorNotice'].concat(Object(toConsumableArray["a" /* default */])(getNotificationArgumentsForTrashFail({ |
|
4943 error: _context3.t0 |
|
4944 })))); |
|
4945 |
|
4946 case 22: |
|
4947 case "end": |
|
4948 return _context3.stop(); |
|
4949 } |
|
4950 } |
|
4951 }, _marked3, this, [[8, 18]]); |
|
4952 } |
|
4953 /** |
|
4954 * Action generator used in signalling that the post should autosave. |
|
4955 * |
|
4956 * @param {Object?} options Extra flags to identify the autosave. |
|
4957 */ |
|
4958 |
|
4959 function actions_autosave(options) { |
|
4960 return regenerator_default.a.wrap(function autosave$(_context4) { |
|
4961 while (1) { |
|
4962 switch (_context4.prev = _context4.next) { |
|
4963 case 0: |
|
4964 _context4.next = 2; |
|
4965 return controls_dispatch(STORE_KEY, 'savePost', Object(objectSpread["a" /* default */])({ |
|
4966 isAutosave: true |
|
4967 }, options)); |
|
4968 |
|
4969 case 2: |
|
4970 case "end": |
|
4971 return _context4.stop(); |
|
4972 } |
|
4973 } |
|
4974 }, _marked4, this); |
|
4975 } |
|
4976 /** |
|
4977 * Returns an action object used in signalling that undo history should |
|
4978 * restore last popped state. |
|
4979 * |
|
4980 * @return {Object} Action object. |
|
4981 */ |
|
4982 |
|
4983 function actions_redo() { |
|
4984 return { |
|
4985 type: 'REDO' |
|
4986 }; |
|
4987 } |
|
4988 /** |
|
4989 * Returns an action object used in signalling that undo history should pop. |
|
4990 * |
|
4991 * @return {Object} Action object. |
|
4992 */ |
|
4993 |
|
4994 function actions_undo() { |
|
4995 return { |
|
4996 type: 'UNDO' |
|
4997 }; |
|
4998 } |
|
4999 /** |
|
5000 * Returns an action object used in signalling that undo history record should |
|
5001 * be created. |
|
5002 * |
|
5003 * @return {Object} Action object. |
|
5004 */ |
|
5005 |
|
5006 function createUndoLevel() { |
|
5007 return { |
|
5008 type: 'CREATE_UNDO_LEVEL' |
|
5009 }; |
|
5010 } |
|
5011 /** |
|
5012 * Returns an action object used to lock the editor. |
|
5013 * |
|
5014 * @param {Object} lock Details about the post lock status, user, and nonce. |
|
5015 * |
|
5016 * @return {Object} Action object. |
|
5017 */ |
|
5018 |
|
5019 function updatePostLock(lock) { |
|
5020 return { |
|
5021 type: 'UPDATE_POST_LOCK', |
|
5022 lock: lock |
|
5023 }; |
|
5024 } |
|
5025 /** |
|
5026 * Returns an action object used to fetch a single reusable block or all |
|
5027 * reusable blocks from the REST API into the store. |
|
5028 * |
|
5029 * @param {?string} id If given, only a single reusable block with this ID will |
|
5030 * be fetched. |
|
5031 * |
|
5032 * @return {Object} Action object. |
|
5033 */ |
|
5034 |
|
5035 function __experimentalFetchReusableBlocks(id) { |
|
5036 return { |
|
5037 type: 'FETCH_REUSABLE_BLOCKS', |
|
5038 id: id |
|
5039 }; |
|
5040 } |
|
5041 /** |
|
5042 * Returns an action object used in signalling that reusable blocks have been |
|
5043 * received. `results` is an array of objects containing: |
|
5044 * - `reusableBlock` - Details about how the reusable block is persisted. |
|
5045 * - `parsedBlock` - The original block. |
|
5046 * |
|
5047 * @param {Object[]} results Reusable blocks received. |
|
5048 * |
|
5049 * @return {Object} Action object. |
|
5050 */ |
|
5051 |
|
5052 function __experimentalReceiveReusableBlocks(results) { |
|
5053 return { |
|
5054 type: 'RECEIVE_REUSABLE_BLOCKS', |
|
5055 results: results |
|
5056 }; |
|
5057 } |
|
5058 /** |
|
5059 * Returns an action object used to save a reusable block that's in the store to |
|
5060 * the REST API. |
|
5061 * |
|
5062 * @param {Object} id The ID of the reusable block to save. |
|
5063 * |
|
5064 * @return {Object} Action object. |
|
5065 */ |
|
5066 |
|
5067 function __experimentalSaveReusableBlock(id) { |
|
5068 return { |
|
5069 type: 'SAVE_REUSABLE_BLOCK', |
|
5070 id: id |
|
5071 }; |
|
5072 } |
|
5073 /** |
|
5074 * Returns an action object used to delete a reusable block via the REST API. |
|
5075 * |
|
5076 * @param {number} id The ID of the reusable block to delete. |
|
5077 * |
|
5078 * @return {Object} Action object. |
|
5079 */ |
|
5080 |
|
5081 function __experimentalDeleteReusableBlock(id) { |
|
5082 return { |
|
5083 type: 'DELETE_REUSABLE_BLOCK', |
|
5084 id: id |
|
5085 }; |
|
5086 } |
|
5087 /** |
|
5088 * Returns an action object used in signalling that a reusable block's title is |
|
5089 * to be updated. |
|
5090 * |
|
5091 * @param {number} id The ID of the reusable block to update. |
|
5092 * @param {string} title The new title. |
|
5093 * |
|
5094 * @return {Object} Action object. |
|
5095 */ |
|
5096 |
|
5097 function __experimentalUpdateReusableBlockTitle(id, title) { |
|
5098 return { |
|
5099 type: 'UPDATE_REUSABLE_BLOCK_TITLE', |
|
5100 id: id, |
|
5101 title: title |
|
5102 }; |
|
5103 } |
|
5104 /** |
|
5105 * Returns an action object used to convert a reusable block into a static |
|
5106 * block. |
|
5107 * |
|
5108 * @param {string} clientId The client ID of the block to attach. |
|
5109 * |
|
5110 * @return {Object} Action object. |
|
5111 */ |
|
5112 |
|
5113 function __experimentalConvertBlockToStatic(clientId) { |
|
5114 return { |
|
5115 type: 'CONVERT_BLOCK_TO_STATIC', |
|
5116 clientId: clientId |
|
5117 }; |
|
5118 } |
|
5119 /** |
|
5120 * Returns an action object used to convert a static block into a reusable |
|
5121 * block. |
|
5122 * |
|
5123 * @param {string} clientIds The client IDs of the block to detach. |
|
5124 * |
|
5125 * @return {Object} Action object. |
|
5126 */ |
|
5127 |
|
5128 function __experimentalConvertBlockToReusable(clientIds) { |
|
5129 return { |
|
5130 type: 'CONVERT_BLOCK_TO_REUSABLE', |
|
5131 clientIds: Object(external_lodash_["castArray"])(clientIds) |
|
5132 }; |
|
5133 } |
|
5134 /** |
|
5135 * Returns an action object used in signalling that the user has enabled the |
|
5136 * publish sidebar. |
|
5137 * |
|
5138 * @return {Object} Action object |
|
5139 */ |
|
5140 |
|
5141 function enablePublishSidebar() { |
|
5142 return { |
|
5143 type: 'ENABLE_PUBLISH_SIDEBAR' |
|
5144 }; |
|
5145 } |
|
5146 /** |
|
5147 * Returns an action object used in signalling that the user has disabled the |
|
5148 * publish sidebar. |
|
5149 * |
|
5150 * @return {Object} Action object |
|
5151 */ |
|
5152 |
|
5153 function disablePublishSidebar() { |
|
5154 return { |
|
5155 type: 'DISABLE_PUBLISH_SIDEBAR' |
|
5156 }; |
|
5157 } |
|
5158 /** |
|
5159 * Returns an action object used to signal that post saving is locked. |
|
5160 * |
|
5161 * @param {string} lockName The lock name. |
|
5162 * |
|
5163 * @return {Object} Action object |
|
5164 */ |
|
5165 |
|
5166 function lockPostSaving(lockName) { |
|
5167 return { |
|
5168 type: 'LOCK_POST_SAVING', |
|
5169 lockName: lockName |
|
5170 }; |
|
5171 } |
|
5172 /** |
|
5173 * Returns an action object used to signal that post saving is unlocked. |
|
5174 * |
|
5175 * @param {string} lockName The lock name. |
|
5176 * |
|
5177 * @return {Object} Action object |
|
5178 */ |
|
5179 |
|
5180 function unlockPostSaving(lockName) { |
|
5181 return { |
|
5182 type: 'UNLOCK_POST_SAVING', |
|
5183 lockName: lockName |
|
5184 }; |
|
5185 } |
|
5186 /** |
|
5187 * Returns an action object used to signal that the blocks have been updated. |
|
5188 * |
|
5189 * @param {Array} blocks Block Array. |
|
5190 * @param {?Object} options Optional options. |
|
5191 * |
|
5192 * @return {Object} Action object |
|
5193 */ |
|
5194 |
|
5195 function actions_resetEditorBlocks(blocks) { |
|
5196 var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; |
|
5197 return { |
|
5198 type: 'RESET_EDITOR_BLOCKS', |
|
5199 blocks: blocks, |
|
5200 shouldCreateUndoLevel: options.__unstableShouldCreateUndoLevel !== false |
|
5201 }; |
|
5202 } |
|
5203 /* |
|
5204 * Returns an action object used in signalling that the post editor settings have been updated. |
|
5205 * |
|
5206 * @param {Object} settings Updated settings |
|
5207 * |
|
5208 * @return {Object} Action object |
|
5209 */ |
|
5210 |
|
5211 function updateEditorSettings(settings) { |
|
5212 return { |
|
5213 type: 'UPDATE_EDITOR_SETTINGS', |
|
5214 settings: settings |
|
5215 }; |
|
5216 } |
|
5217 /** |
|
5218 * Backward compatibility |
|
5219 */ |
|
5220 |
|
5221 var actions_getBlockEditorAction = function getBlockEditorAction(name) { |
|
5222 return ( |
|
5223 /*#__PURE__*/ |
|
5224 regenerator_default.a.mark(function _callee() { |
|
5225 var _len, |
|
5226 args, |
|
5227 _key, |
|
5228 _args5 = arguments; |
|
5229 |
|
5230 return regenerator_default.a.wrap(function _callee$(_context5) { |
|
5231 while (1) { |
|
5232 switch (_context5.prev = _context5.next) { |
|
5233 case 0: |
|
5234 for (_len = _args5.length, args = new Array(_len), _key = 0; _key < _len; _key++) { |
|
5235 args[_key] = _args5[_key]; |
|
5236 } |
|
5237 |
|
5238 _context5.next = 3; |
|
5239 return controls_dispatch.apply(void 0, ['core/block-editor', name].concat(args)); |
|
5240 |
|
5241 case 3: |
|
5242 case "end": |
|
5243 return _context5.stop(); |
|
5244 } |
|
5245 } |
|
5246 }, _callee, this); |
|
5247 }) |
|
5248 ); |
|
5249 }; |
|
5250 |
|
5251 var resetBlocks = actions_getBlockEditorAction('resetBlocks'); |
|
5252 var receiveBlocks = actions_getBlockEditorAction('receiveBlocks'); |
|
5253 var updateBlock = actions_getBlockEditorAction('updateBlock'); |
|
5254 var updateBlockAttributes = actions_getBlockEditorAction('updateBlockAttributes'); |
|
5255 var selectBlock = actions_getBlockEditorAction('selectBlock'); |
|
5256 var startMultiSelect = actions_getBlockEditorAction('startMultiSelect'); |
|
5257 var stopMultiSelect = actions_getBlockEditorAction('stopMultiSelect'); |
|
5258 var multiSelect = actions_getBlockEditorAction('multiSelect'); |
|
5259 var clearSelectedBlock = actions_getBlockEditorAction('clearSelectedBlock'); |
|
5260 var toggleSelection = actions_getBlockEditorAction('toggleSelection'); |
|
5261 var replaceBlocks = actions_getBlockEditorAction('replaceBlocks'); |
|
5262 var replaceBlock = actions_getBlockEditorAction('replaceBlock'); |
|
5263 var moveBlocksDown = actions_getBlockEditorAction('moveBlocksDown'); |
|
5264 var moveBlocksUp = actions_getBlockEditorAction('moveBlocksUp'); |
|
5265 var moveBlockToPosition = actions_getBlockEditorAction('moveBlockToPosition'); |
|
5266 var insertBlock = actions_getBlockEditorAction('insertBlock'); |
|
5267 var insertBlocks = actions_getBlockEditorAction('insertBlocks'); |
|
5268 var showInsertionPoint = actions_getBlockEditorAction('showInsertionPoint'); |
|
5269 var hideInsertionPoint = actions_getBlockEditorAction('hideInsertionPoint'); |
|
5270 var setTemplateValidity = actions_getBlockEditorAction('setTemplateValidity'); |
|
5271 var synchronizeTemplate = actions_getBlockEditorAction('synchronizeTemplate'); |
|
5272 var mergeBlocks = actions_getBlockEditorAction('mergeBlocks'); |
|
5273 var removeBlocks = actions_getBlockEditorAction('removeBlocks'); |
|
5274 var removeBlock = actions_getBlockEditorAction('removeBlock'); |
|
5275 var toggleBlockMode = actions_getBlockEditorAction('toggleBlockMode'); |
|
5276 var startTyping = actions_getBlockEditorAction('startTyping'); |
|
5277 var stopTyping = actions_getBlockEditorAction('stopTyping'); |
|
5278 var enterFormattedText = actions_getBlockEditorAction('enterFormattedText'); |
|
5279 var exitFormattedText = actions_getBlockEditorAction('exitFormattedText'); |
|
5280 var insertDefaultBlock = actions_getBlockEditorAction('insertDefaultBlock'); |
|
5281 var updateBlockListSettings = actions_getBlockEditorAction('updateBlockListSettings'); |
|
5282 |
|
5283 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js |
|
5284 var asyncToGenerator = __webpack_require__(44); |
|
5285 |
|
5286 // EXTERNAL MODULE: ./node_modules/rememo/es/rememo.js |
|
5287 var rememo = __webpack_require__(30); |
|
5288 |
|
5289 // EXTERNAL MODULE: external {"this":["wp","date"]} |
|
5290 var external_this_wp_date_ = __webpack_require__(50); |
|
5291 |
|
5292 // EXTERNAL MODULE: external {"this":["wp","autop"]} |
|
5293 var external_this_wp_autop_ = __webpack_require__(66); |
|
5294 |
|
5295 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/selectors.js |
|
5296 |
|
5297 |
|
5298 |
|
5299 /** |
|
5300 * External dependencies |
|
5301 */ |
|
5302 |
|
5303 |
|
5304 /** |
|
5305 * WordPress dependencies |
|
5306 */ |
|
5307 |
|
5308 |
|
5309 |
|
5310 |
|
5311 |
|
5312 |
|
5313 /** |
|
5314 * Internal dependencies |
|
5315 */ |
|
5316 |
|
5317 |
|
5318 |
|
5319 /** |
|
5320 * Shared reference to an empty object for cases where it is important to avoid |
|
5321 * returning a new object reference on every invocation, as in a connected or |
|
5322 * other pure component which performs `shouldComponentUpdate` check on props. |
|
5323 * This should be used as a last resort, since the normalized data should be |
|
5324 * maintained by the reducer result in state. |
|
5325 */ |
|
5326 |
|
5327 var EMPTY_OBJECT = {}; |
|
5328 /** |
|
5329 * Returns true if any past editor history snapshots exist, or false otherwise. |
|
5330 * |
|
5331 * @param {Object} state Global application state. |
|
5332 * |
|
5333 * @return {boolean} Whether undo history exists. |
|
5334 */ |
|
5335 |
|
5336 function hasEditorUndo(state) { |
|
5337 return state.editor.past.length > 0; |
|
5338 } |
|
5339 /** |
|
5340 * Returns true if any future editor history snapshots exist, or false |
|
5341 * otherwise. |
|
5342 * |
|
5343 * @param {Object} state Global application state. |
|
5344 * |
|
5345 * @return {boolean} Whether redo history exists. |
|
5346 */ |
|
5347 |
|
5348 function hasEditorRedo(state) { |
|
5349 return state.editor.future.length > 0; |
|
5350 } |
|
5351 /** |
|
5352 * Returns true if the currently edited post is yet to be saved, or false if |
|
5353 * the post has been saved. |
|
5354 * |
|
5355 * @param {Object} state Global application state. |
|
5356 * |
|
5357 * @return {boolean} Whether the post is new. |
|
5358 */ |
|
5359 |
|
5360 function selectors_isEditedPostNew(state) { |
|
5361 return selectors_getCurrentPost(state).status === 'auto-draft'; |
|
5362 } |
|
5363 /** |
|
5364 * Returns true if content includes unsaved changes, or false otherwise. |
|
5365 * |
|
5366 * @param {Object} state Editor state. |
|
5367 * |
|
5368 * @return {boolean} Whether content includes unsaved changes. |
|
5369 */ |
|
5370 |
|
5371 function hasChangedContent(state) { |
|
5372 return state.editor.present.blocks.isDirty || // `edits` is intended to contain only values which are different from |
|
5373 // the saved post, so the mere presence of a property is an indicator |
|
5374 // that the value is different than what is known to be saved. While |
|
5375 // content in Visual mode is represented by the blocks state, in Text |
|
5376 // mode it is tracked by `edits.content`. |
|
5377 'content' in state.editor.present.edits; |
|
5378 } |
|
5379 /** |
|
5380 * Returns true if there are unsaved values for the current edit session, or |
|
5381 * false if the editing state matches the saved or new post. |
|
5382 * |
|
5383 * @param {Object} state Global application state. |
|
5384 * |
|
5385 * @return {boolean} Whether unsaved values exist. |
|
5386 */ |
|
5387 |
|
5388 function selectors_isEditedPostDirty(state) { |
|
5389 if (hasChangedContent(state)) { |
|
5390 return true; |
|
5391 } // Edits should contain only fields which differ from the saved post (reset |
|
5392 // at initial load and save complete). Thus, a non-empty edits state can be |
|
5393 // inferred to contain unsaved values. |
|
5394 |
|
5395 |
|
5396 if (Object.keys(state.editor.present.edits).length > 0) { |
|
5397 return true; |
|
5398 } // Edits and change detection are reset at the start of a save, but a post |
|
5399 // is still considered dirty until the point at which the save completes. |
|
5400 // Because the save is performed optimistically, the prior states are held |
|
5401 // until committed. These can be referenced to determine whether there's a |
|
5402 // chance that state may be reverted into one considered dirty. |
|
5403 |
|
5404 |
|
5405 return inSomeHistory(state, selectors_isEditedPostDirty); |
|
5406 } |
|
5407 /** |
|
5408 * Returns true if there are no unsaved values for the current edit session and |
|
5409 * if the currently edited post is new (has never been saved before). |
|
5410 * |
|
5411 * @param {Object} state Global application state. |
|
5412 * |
|
5413 * @return {boolean} Whether new post and unsaved values exist. |
|
5414 */ |
|
5415 |
|
5416 function selectors_isCleanNewPost(state) { |
|
5417 return !selectors_isEditedPostDirty(state) && selectors_isEditedPostNew(state); |
|
5418 } |
|
5419 /** |
|
5420 * Returns the post currently being edited in its last known saved state, not |
|
5421 * including unsaved edits. Returns an object containing relevant default post |
|
5422 * values if the post has not yet been saved. |
|
5423 * |
|
5424 * @param {Object} state Global application state. |
|
5425 * |
|
5426 * @return {Object} Post object. |
|
5427 */ |
|
5428 |
|
5429 function selectors_getCurrentPost(state) { |
|
5430 return state.currentPost; |
|
5431 } |
|
5432 /** |
|
5433 * Returns the post type of the post currently being edited. |
|
5434 * |
|
5435 * @param {Object} state Global application state. |
|
5436 * |
|
5437 * @return {string} Post type. |
|
5438 */ |
|
5439 |
|
5440 function selectors_getCurrentPostType(state) { |
|
5441 return state.currentPost.type; |
|
5442 } |
|
5443 /** |
|
5444 * Returns the ID of the post currently being edited, or null if the post has |
|
5445 * not yet been saved. |
|
5446 * |
|
5447 * @param {Object} state Global application state. |
|
5448 * |
|
5449 * @return {?number} ID of current post. |
|
5450 */ |
|
5451 |
|
5452 function selectors_getCurrentPostId(state) { |
|
5453 return selectors_getCurrentPost(state).id || null; |
|
5454 } |
|
5455 /** |
|
5456 * Returns the number of revisions of the post currently being edited. |
|
5457 * |
|
5458 * @param {Object} state Global application state. |
|
5459 * |
|
5460 * @return {number} Number of revisions. |
|
5461 */ |
|
5462 |
|
5463 function getCurrentPostRevisionsCount(state) { |
|
5464 return Object(external_lodash_["get"])(selectors_getCurrentPost(state), ['_links', 'version-history', 0, 'count'], 0); |
|
5465 } |
|
5466 /** |
|
5467 * Returns the last revision ID of the post currently being edited, |
|
5468 * or null if the post has no revisions. |
|
5469 * |
|
5470 * @param {Object} state Global application state. |
|
5471 * |
|
5472 * @return {?number} ID of the last revision. |
|
5473 */ |
|
5474 |
|
5475 function getCurrentPostLastRevisionId(state) { |
|
5476 return Object(external_lodash_["get"])(selectors_getCurrentPost(state), ['_links', 'predecessor-version', 0, 'id'], null); |
|
5477 } |
|
5478 /** |
|
5479 * Returns any post values which have been changed in the editor but not yet |
|
5480 * been saved. |
|
5481 * |
|
5482 * @param {Object} state Global application state. |
|
5483 * |
|
5484 * @return {Object} Object of key value pairs comprising unsaved edits. |
|
5485 */ |
|
5486 |
|
5487 var getPostEdits = Object(rememo["a" /* default */])(function (state) { |
|
5488 return Object(objectSpread["a" /* default */])({}, state.initialEdits, state.editor.present.edits); |
|
5489 }, function (state) { |
|
5490 return [state.editor.present.edits, state.initialEdits]; |
|
5491 }); |
|
5492 /** |
|
5493 * Returns a new reference when edited values have changed. This is useful in |
|
5494 * inferring where an edit has been made between states by comparison of the |
|
5495 * return values using strict equality. |
|
5496 * |
|
5497 * @example |
|
5498 * |
|
5499 * ``` |
|
5500 * const hasEditOccurred = ( |
|
5501 * getReferenceByDistinctEdits( beforeState ) !== |
|
5502 * getReferenceByDistinctEdits( afterState ) |
|
5503 * ); |
|
5504 * ``` |
|
5505 * |
|
5506 * @param {Object} state Editor state. |
|
5507 * |
|
5508 * @return {*} A value whose reference will change only when an edit occurs. |
|
5509 */ |
|
5510 |
|
5511 var getReferenceByDistinctEdits = Object(rememo["a" /* default */])(function () { |
|
5512 return []; |
|
5513 }, function (state) { |
|
5514 return [state.editor]; |
|
5515 }); |
|
5516 /** |
|
5517 * Returns an attribute value of the saved post. |
|
5518 * |
|
5519 * @param {Object} state Global application state. |
|
5520 * @param {string} attributeName Post attribute name. |
|
5521 * |
|
5522 * @return {*} Post attribute value. |
|
5523 */ |
|
5524 |
|
5525 function selectors_getCurrentPostAttribute(state, attributeName) { |
|
5526 var post = selectors_getCurrentPost(state); |
|
5527 |
|
5528 if (post.hasOwnProperty(attributeName)) { |
|
5529 return post[attributeName]; |
|
5530 } |
|
5531 } |
|
5532 /** |
|
5533 * Returns a single attribute of the post being edited, preferring the unsaved |
|
5534 * edit if one exists, but merging with the attribute value for the last known |
|
5535 * saved state of the post (this is needed for some nested attributes like meta). |
|
5536 * |
|
5537 * @param {Object} state Global application state. |
|
5538 * @param {string} attributeName Post attribute name. |
|
5539 * |
|
5540 * @return {*} Post attribute value. |
|
5541 */ |
|
5542 |
|
5543 var getNestedEditedPostProperty = Object(rememo["a" /* default */])(function (state, attributeName) { |
|
5544 var edits = getPostEdits(state); |
|
5545 |
|
5546 if (!edits.hasOwnProperty(attributeName)) { |
|
5547 return selectors_getCurrentPostAttribute(state, attributeName); |
|
5548 } |
|
5549 |
|
5550 return Object(objectSpread["a" /* default */])({}, selectors_getCurrentPostAttribute(state, attributeName), edits[attributeName]); |
|
5551 }, function (state, attributeName) { |
|
5552 return [Object(external_lodash_["get"])(state.editor.present.edits, [attributeName], EMPTY_OBJECT), Object(external_lodash_["get"])(state.currentPost, [attributeName], EMPTY_OBJECT)]; |
|
5553 }); |
|
5554 /** |
|
5555 * Returns a single attribute of the post being edited, preferring the unsaved |
|
5556 * edit if one exists, but falling back to the attribute for the last known |
|
5557 * saved state of the post. |
|
5558 * |
|
5559 * @param {Object} state Global application state. |
|
5560 * @param {string} attributeName Post attribute name. |
|
5561 * |
|
5562 * @return {*} Post attribute value. |
|
5563 */ |
|
5564 |
|
5565 function selectors_getEditedPostAttribute(state, attributeName) { |
|
5566 // Special cases |
|
5567 switch (attributeName) { |
|
5568 case 'content': |
|
5569 return getEditedPostContent(state); |
|
5570 } // Fall back to saved post value if not edited. |
|
5571 |
|
5572 |
|
5573 var edits = getPostEdits(state); |
|
5574 |
|
5575 if (!edits.hasOwnProperty(attributeName)) { |
|
5576 return selectors_getCurrentPostAttribute(state, attributeName); |
|
5577 } // Merge properties are objects which contain only the patch edit in state, |
|
5578 // and thus must be merged with the current post attribute. |
|
5579 |
|
5580 |
|
5581 if (EDIT_MERGE_PROPERTIES.has(attributeName)) { |
|
5582 return getNestedEditedPostProperty(state, attributeName); |
|
5583 } |
|
5584 |
|
5585 return edits[attributeName]; |
|
5586 } |
|
5587 /** |
|
5588 * Returns an attribute value of the current autosave revision for a post, or |
|
5589 * null if there is no autosave for the post. |
|
5590 * |
|
5591 * @param {Object} state Global application state. |
|
5592 * @param {string} attributeName Autosave attribute name. |
|
5593 * |
|
5594 * @return {*} Autosave attribute value. |
|
5595 */ |
|
5596 |
|
5597 function getAutosaveAttribute(state, attributeName) { |
|
5598 if (!hasAutosave(state)) { |
|
5599 return null; |
|
5600 } |
|
5601 |
|
5602 var autosave = getAutosave(state); |
|
5603 |
|
5604 if (autosave.hasOwnProperty(attributeName)) { |
|
5605 return autosave[attributeName]; |
|
5606 } |
|
5607 } |
|
5608 /** |
|
5609 * Returns the current visibility of the post being edited, preferring the |
|
5610 * unsaved value if different than the saved post. The return value is one of |
|
5611 * "private", "password", or "public". |
|
5612 * |
|
5613 * @param {Object} state Global application state. |
|
5614 * |
|
5615 * @return {string} Post visibility. |
|
5616 */ |
|
5617 |
|
5618 function selectors_getEditedPostVisibility(state) { |
|
5619 var status = selectors_getEditedPostAttribute(state, 'status'); |
|
5620 |
|
5621 if (status === 'private') { |
|
5622 return 'private'; |
|
5623 } |
|
5624 |
|
5625 var password = selectors_getEditedPostAttribute(state, 'password'); |
|
5626 |
|
5627 if (password) { |
|
5628 return 'password'; |
|
5629 } |
|
5630 |
|
5631 return 'public'; |
|
5632 } |
|
5633 /** |
|
5634 * Returns true if post is pending review. |
|
5635 * |
|
5636 * @param {Object} state Global application state. |
|
5637 * |
|
5638 * @return {boolean} Whether current post is pending review. |
|
5639 */ |
|
5640 |
|
5641 function isCurrentPostPending(state) { |
|
5642 return selectors_getCurrentPost(state).status === 'pending'; |
|
5643 } |
|
5644 /** |
|
5645 * Return true if the current post has already been published. |
|
5646 * |
|
5647 * @param {Object} state Global application state. |
|
5648 * |
|
5649 * @return {boolean} Whether the post has been published. |
|
5650 */ |
|
5651 |
|
5652 function selectors_isCurrentPostPublished(state) { |
|
5653 var post = selectors_getCurrentPost(state); |
|
5654 return ['publish', 'private'].indexOf(post.status) !== -1 || post.status === 'future' && !Object(external_this_wp_date_["isInTheFuture"])(new Date(Number(Object(external_this_wp_date_["getDate"])(post.date)) - ONE_MINUTE_IN_MS)); |
|
5655 } |
|
5656 /** |
|
5657 * Returns true if post is already scheduled. |
|
5658 * |
|
5659 * @param {Object} state Global application state. |
|
5660 * |
|
5661 * @return {boolean} Whether current post is scheduled to be posted. |
|
5662 */ |
|
5663 |
|
5664 function selectors_isCurrentPostScheduled(state) { |
|
5665 return selectors_getCurrentPost(state).status === 'future' && !selectors_isCurrentPostPublished(state); |
|
5666 } |
|
5667 /** |
|
5668 * Return true if the post being edited can be published. |
|
5669 * |
|
5670 * @param {Object} state Global application state. |
|
5671 * |
|
5672 * @return {boolean} Whether the post can been published. |
|
5673 */ |
|
5674 |
|
5675 function selectors_isEditedPostPublishable(state) { |
|
5676 var post = selectors_getCurrentPost(state); // TODO: Post being publishable should be superset of condition of post |
|
5677 // being saveable. Currently this restriction is imposed at UI. |
|
5678 // |
|
5679 // See: <PostPublishButton /> (`isButtonEnabled` assigned by `isSaveable`) |
|
5680 |
|
5681 return selectors_isEditedPostDirty(state) || ['publish', 'private', 'future'].indexOf(post.status) === -1; |
|
5682 } |
|
5683 /** |
|
5684 * Returns true if the post can be saved, or false otherwise. A post must |
|
5685 * contain a title, an excerpt, or non-empty content to be valid for save. |
|
5686 * |
|
5687 * @param {Object} state Global application state. |
|
5688 * |
|
5689 * @return {boolean} Whether the post can be saved. |
|
5690 */ |
|
5691 |
|
5692 function selectors_isEditedPostSaveable(state) { |
|
5693 if (selectors_isSavingPost(state)) { |
|
5694 return false; |
|
5695 } // TODO: Post should not be saveable if not dirty. Cannot be added here at |
|
5696 // this time since posts where meta boxes are present can be saved even if |
|
5697 // the post is not dirty. Currently this restriction is imposed at UI, but |
|
5698 // should be moved here. |
|
5699 // |
|
5700 // See: `isEditedPostPublishable` (includes `isEditedPostDirty` condition) |
|
5701 // See: <PostSavedState /> (`forceIsDirty` prop) |
|
5702 // See: <PostPublishButton /> (`forceIsDirty` prop) |
|
5703 // See: https://github.com/WordPress/gutenberg/pull/4184 |
|
5704 |
|
5705 |
|
5706 return !!selectors_getEditedPostAttribute(state, 'title') || !!selectors_getEditedPostAttribute(state, 'excerpt') || !isEditedPostEmpty(state); |
|
5707 } |
|
5708 /** |
|
5709 * Returns true if the edited post has content. A post has content if it has at |
|
5710 * least one saveable block or otherwise has a non-empty content property |
|
5711 * assigned. |
|
5712 * |
|
5713 * @param {Object} state Global application state. |
|
5714 * |
|
5715 * @return {boolean} Whether post has content. |
|
5716 */ |
|
5717 |
|
5718 function isEditedPostEmpty(state) { |
|
5719 // While the condition of truthy content string is sufficient to determine |
|
5720 // emptiness, testing saveable blocks length is a trivial operation. Since |
|
5721 // this function can be called frequently, optimize for the fast case as a |
|
5722 // condition of the mere existence of blocks. Note that the value of edited |
|
5723 // content takes precedent over block content, and must fall through to the |
|
5724 // default logic. |
|
5725 var blocks = state.editor.present.blocks.value; |
|
5726 |
|
5727 if (blocks.length && !('content' in getPostEdits(state))) { |
|
5728 // Pierce the abstraction of the serializer in knowing that blocks are |
|
5729 // joined with with newlines such that even if every individual block |
|
5730 // produces an empty save result, the serialized content is non-empty. |
|
5731 if (blocks.length > 1) { |
|
5732 return false; |
|
5733 } // There are two conditions under which the optimization cannot be |
|
5734 // assumed, and a fallthrough to getEditedPostContent must occur: |
|
5735 // |
|
5736 // 1. getBlocksForSerialization has special treatment in omitting a |
|
5737 // single unmodified default block. |
|
5738 // 2. Comment delimiters are omitted for a freeform or unregistered |
|
5739 // block in its serialization. The freeform block specifically may |
|
5740 // produce an empty string in its saved output. |
|
5741 // |
|
5742 // For all other content, the single block is assumed to make a post |
|
5743 // non-empty, if only by virtue of its own comment delimiters. |
|
5744 |
|
5745 |
|
5746 var blockName = blocks[0].name; |
|
5747 |
|
5748 if (blockName !== Object(external_this_wp_blocks_["getDefaultBlockName"])() && blockName !== Object(external_this_wp_blocks_["getFreeformContentHandlerName"])()) { |
|
5749 return false; |
|
5750 } |
|
5751 } |
|
5752 |
|
5753 return !getEditedPostContent(state); |
|
5754 } |
|
5755 /** |
|
5756 * Returns true if the post can be autosaved, or false otherwise. |
|
5757 * |
|
5758 * @param {Object} state Global application state. |
|
5759 * |
|
5760 * @return {boolean} Whether the post can be autosaved. |
|
5761 */ |
|
5762 |
|
5763 function selectors_isEditedPostAutosaveable(state) { |
|
5764 // A post must contain a title, an excerpt, or non-empty content to be valid for autosaving. |
|
5765 if (!selectors_isEditedPostSaveable(state)) { |
|
5766 return false; |
|
5767 } // If we don't already have an autosave, the post is autosaveable. |
|
5768 |
|
5769 |
|
5770 if (!hasAutosave(state)) { |
|
5771 return true; |
|
5772 } // To avoid an expensive content serialization, use the content dirtiness |
|
5773 // flag in place of content field comparison against the known autosave. |
|
5774 // This is not strictly accurate, and relies on a tolerance toward autosave |
|
5775 // request failures for unnecessary saves. |
|
5776 |
|
5777 |
|
5778 if (hasChangedContent(state)) { |
|
5779 return true; |
|
5780 } // If the title, excerpt or content has changed, the post is autosaveable. |
|
5781 |
|
5782 |
|
5783 var autosave = getAutosave(state); |
|
5784 return ['title', 'excerpt'].some(function (field) { |
|
5785 return autosave[field] !== selectors_getEditedPostAttribute(state, field); |
|
5786 }); |
|
5787 } |
|
5788 /** |
|
5789 * Returns the current autosave, or null if one is not set (i.e. if the post |
|
5790 * has yet to be autosaved, or has been saved or published since the last |
|
5791 * autosave). |
|
5792 * |
|
5793 * @param {Object} state Editor state. |
|
5794 * |
|
5795 * @return {?Object} Current autosave, if exists. |
|
5796 */ |
|
5797 |
|
5798 function getAutosave(state) { |
|
5799 return state.autosave; |
|
5800 } |
|
5801 /** |
|
5802 * Returns the true if there is an existing autosave, otherwise false. |
|
5803 * |
|
5804 * @param {Object} state Global application state. |
|
5805 * |
|
5806 * @return {boolean} Whether there is an existing autosave. |
|
5807 */ |
|
5808 |
|
5809 function hasAutosave(state) { |
|
5810 return !!getAutosave(state); |
|
5811 } |
|
5812 /** |
|
5813 * Return true if the post being edited is being scheduled. Preferring the |
|
5814 * unsaved status values. |
|
5815 * |
|
5816 * @param {Object} state Global application state. |
|
5817 * |
|
5818 * @return {boolean} Whether the post has been published. |
|
5819 */ |
|
5820 |
|
5821 function selectors_isEditedPostBeingScheduled(state) { |
|
5822 var date = selectors_getEditedPostAttribute(state, 'date'); // Offset the date by one minute (network latency) |
|
5823 |
|
5824 var checkedDate = new Date(Number(Object(external_this_wp_date_["getDate"])(date)) - ONE_MINUTE_IN_MS); |
|
5825 return Object(external_this_wp_date_["isInTheFuture"])(checkedDate); |
|
5826 } |
|
5827 /** |
|
5828 * Returns whether the current post should be considered to have a "floating" |
|
5829 * date (i.e. that it would publish "Immediately" rather than at a set time). |
|
5830 * |
|
5831 * Unlike in the PHP backend, the REST API returns a full date string for posts |
|
5832 * where the 0000-00-00T00:00:00 placeholder is present in the database. To |
|
5833 * infer that a post is set to publish "Immediately" we check whether the date |
|
5834 * and modified date are the same. |
|
5835 * |
|
5836 * @param {Object} state Editor state. |
|
5837 * |
|
5838 * @return {boolean} Whether the edited post has a floating date value. |
|
5839 */ |
|
5840 |
|
5841 function isEditedPostDateFloating(state) { |
|
5842 var date = selectors_getEditedPostAttribute(state, 'date'); |
|
5843 var modified = selectors_getEditedPostAttribute(state, 'modified'); |
|
5844 var status = selectors_getEditedPostAttribute(state, 'status'); |
|
5845 |
|
5846 if (status === 'draft' || status === 'auto-draft' || status === 'pending') { |
|
5847 return date === modified; |
|
5848 } |
|
5849 |
|
5850 return false; |
|
5851 } |
|
5852 /** |
|
5853 * Returns true if the post is currently being saved, or false otherwise. |
|
5854 * |
|
5855 * @param {Object} state Global application state. |
|
5856 * |
|
5857 * @return {boolean} Whether post is being saved. |
|
5858 */ |
|
5859 |
|
5860 function selectors_isSavingPost(state) { |
|
5861 return state.saving.requesting; |
|
5862 } |
|
5863 /** |
|
5864 * Returns true if a previous post save was attempted successfully, or false |
|
5865 * otherwise. |
|
5866 * |
|
5867 * @param {Object} state Global application state. |
|
5868 * |
|
5869 * @return {boolean} Whether the post was saved successfully. |
|
5870 */ |
|
5871 |
|
5872 function didPostSaveRequestSucceed(state) { |
|
5873 return state.saving.successful; |
|
5874 } |
|
5875 /** |
|
5876 * Returns true if a previous post save was attempted but failed, or false |
|
5877 * otherwise. |
|
5878 * |
|
5879 * @param {Object} state Global application state. |
|
5880 * |
|
5881 * @return {boolean} Whether the post save failed. |
|
5882 */ |
|
5883 |
|
5884 function didPostSaveRequestFail(state) { |
|
5885 return !!state.saving.error; |
|
5886 } |
|
5887 /** |
|
5888 * Returns true if the post is autosaving, or false otherwise. |
|
5889 * |
|
5890 * @param {Object} state Global application state. |
|
5891 * |
|
5892 * @return {boolean} Whether the post is autosaving. |
|
5893 */ |
|
5894 |
|
5895 function selectors_isAutosavingPost(state) { |
|
5896 return selectors_isSavingPost(state) && !!state.saving.options.isAutosave; |
|
5897 } |
|
5898 /** |
|
5899 * Returns true if the post is being previewed, or false otherwise. |
|
5900 * |
|
5901 * @param {Object} state Global application state. |
|
5902 * |
|
5903 * @return {boolean} Whether the post is being previewed. |
|
5904 */ |
|
5905 |
|
5906 function isPreviewingPost(state) { |
|
5907 return selectors_isSavingPost(state) && !!state.saving.options.isPreview; |
|
5908 } |
|
5909 /** |
|
5910 * Returns the post preview link |
|
5911 * |
|
5912 * @param {Object} state Global application state. |
|
5913 * |
|
5914 * @return {string?} Preview Link. |
|
5915 */ |
|
5916 |
|
5917 function selectors_getEditedPostPreviewLink(state) { |
|
5918 var featuredImageId = selectors_getEditedPostAttribute(state, 'featured_media'); |
|
5919 var previewLink = state.previewLink; |
|
5920 |
|
5921 if (previewLink && featuredImageId) { |
|
5922 return Object(external_this_wp_url_["addQueryArgs"])(previewLink, { |
|
5923 _thumbnail_id: featuredImageId |
|
5924 }); |
|
5925 } |
|
5926 |
|
5927 return previewLink; |
|
5928 } |
|
5929 /** |
|
5930 * Returns a suggested post format for the current post, inferred only if there |
|
5931 * is a single block within the post and it is of a type known to match a |
|
5932 * default post format. Returns null if the format cannot be determined. |
|
5933 * |
|
5934 * @param {Object} state Global application state. |
|
5935 * |
|
5936 * @return {?string} Suggested post format. |
|
5937 */ |
|
5938 |
|
5939 function selectors_getSuggestedPostFormat(state) { |
|
5940 var blocks = state.editor.present.blocks.value; |
|
5941 var name; // If there is only one block in the content of the post grab its name |
|
5942 // so we can derive a suitable post format from it. |
|
5943 |
|
5944 if (blocks.length === 1) { |
|
5945 name = blocks[0].name; |
|
5946 } // If there are two blocks in the content and the last one is a text blocks |
|
5947 // grab the name of the first one to also suggest a post format from it. |
|
5948 |
|
5949 |
|
5950 if (blocks.length === 2) { |
|
5951 if (blocks[1].name === 'core/paragraph') { |
|
5952 name = blocks[0].name; |
|
5953 } |
|
5954 } // We only convert to default post formats in core. |
|
5955 |
|
5956 |
|
5957 switch (name) { |
|
5958 case 'core/image': |
|
5959 return 'image'; |
|
5960 |
|
5961 case 'core/quote': |
|
5962 case 'core/pullquote': |
|
5963 return 'quote'; |
|
5964 |
|
5965 case 'core/gallery': |
|
5966 return 'gallery'; |
|
5967 |
|
5968 case 'core/video': |
|
5969 case 'core-embed/youtube': |
|
5970 case 'core-embed/vimeo': |
|
5971 return 'video'; |
|
5972 |
|
5973 case 'core/audio': |
|
5974 case 'core-embed/spotify': |
|
5975 case 'core-embed/soundcloud': |
|
5976 return 'audio'; |
|
5977 } |
|
5978 |
|
5979 return null; |
|
5980 } |
|
5981 /** |
|
5982 * Returns a set of blocks which are to be used in consideration of the post's |
|
5983 * generated save content. |
|
5984 * |
|
5985 * @param {Object} state Editor state. |
|
5986 * |
|
5987 * @return {WPBlock[]} Filtered set of blocks for save. |
|
5988 */ |
|
5989 |
|
5990 function getBlocksForSerialization(state) { |
|
5991 var blocks = state.editor.present.blocks.value; // WARNING: Any changes to the logic of this function should be verified |
|
5992 // against the implementation of isEditedPostEmpty, which bypasses this |
|
5993 // function for performance' sake, in an assumption of this current logic |
|
5994 // being irrelevant to the optimized condition of emptiness. |
|
5995 // A single unmodified default block is assumed to be equivalent to an |
|
5996 // empty post. |
|
5997 |
|
5998 var isSingleUnmodifiedDefaultBlock = blocks.length === 1 && Object(external_this_wp_blocks_["isUnmodifiedDefaultBlock"])(blocks[0]); |
|
5999 |
|
6000 if (isSingleUnmodifiedDefaultBlock) { |
|
6001 return []; |
|
6002 } |
|
6003 |
|
6004 return blocks; |
|
6005 } |
|
6006 /** |
|
6007 * Returns the content of the post being edited, preferring raw string edit |
|
6008 * before falling back to serialization of block state. |
|
6009 * |
|
6010 * @param {Object} state Global application state. |
|
6011 * |
|
6012 * @return {string} Post content. |
|
6013 */ |
|
6014 |
|
6015 var getEditedPostContent = Object(rememo["a" /* default */])(function (state) { |
|
6016 var edits = getPostEdits(state); |
|
6017 |
|
6018 if ('content' in edits) { |
|
6019 return edits.content; |
|
6020 } |
|
6021 |
|
6022 var blocks = getBlocksForSerialization(state); |
|
6023 var content = Object(external_this_wp_blocks_["serialize"])(blocks); // For compatibility purposes, treat a post consisting of a single |
|
6024 // freeform block as legacy content and downgrade to a pre-block-editor |
|
6025 // removep'd content format. |
|
6026 |
|
6027 var isSingleFreeformBlock = blocks.length === 1 && blocks[0].name === Object(external_this_wp_blocks_["getFreeformContentHandlerName"])(); |
|
6028 |
|
6029 if (isSingleFreeformBlock) { |
|
6030 return Object(external_this_wp_autop_["removep"])(content); |
|
6031 } |
|
6032 |
|
6033 return content; |
|
6034 }, function (state) { |
|
6035 return [state.editor.present.blocks.value, state.editor.present.edits.content, state.initialEdits.content]; |
|
6036 }); |
|
6037 /** |
|
6038 * Returns the reusable block with the given ID. |
|
6039 * |
|
6040 * @param {Object} state Global application state. |
|
6041 * @param {number|string} ref The reusable block's ID. |
|
6042 * |
|
6043 * @return {Object} The reusable block, or null if none exists. |
|
6044 */ |
|
6045 |
|
6046 var __experimentalGetReusableBlock = Object(rememo["a" /* default */])(function (state, ref) { |
|
6047 var block = state.reusableBlocks.data[ref]; |
|
6048 |
|
6049 if (!block) { |
|
6050 return null; |
|
6051 } |
|
6052 |
|
6053 var isTemporary = isNaN(parseInt(ref)); |
|
6054 return Object(objectSpread["a" /* default */])({}, block, { |
|
6055 id: isTemporary ? ref : +ref, |
|
6056 isTemporary: isTemporary |
|
6057 }); |
|
6058 }, function (state, ref) { |
|
6059 return [state.reusableBlocks.data[ref]]; |
|
6060 }); |
|
6061 /** |
|
6062 * Returns whether or not the reusable block with the given ID is being saved. |
|
6063 * |
|
6064 * @param {Object} state Global application state. |
|
6065 * @param {string} ref The reusable block's ID. |
|
6066 * |
|
6067 * @return {boolean} Whether or not the reusable block is being saved. |
|
6068 */ |
|
6069 |
|
6070 function __experimentalIsSavingReusableBlock(state, ref) { |
|
6071 return state.reusableBlocks.isSaving[ref] || false; |
|
6072 } |
|
6073 /** |
|
6074 * Returns true if the reusable block with the given ID is being fetched, or |
|
6075 * false otherwise. |
|
6076 * |
|
6077 * @param {Object} state Global application state. |
|
6078 * @param {string} ref The reusable block's ID. |
|
6079 * |
|
6080 * @return {boolean} Whether the reusable block is being fetched. |
|
6081 */ |
|
6082 |
|
6083 function __experimentalIsFetchingReusableBlock(state, ref) { |
|
6084 return !!state.reusableBlocks.isFetching[ref]; |
|
6085 } |
|
6086 /** |
|
6087 * Returns an array of all reusable blocks. |
|
6088 * |
|
6089 * @param {Object} state Global application state. |
|
6090 * |
|
6091 * @return {Array} An array of all reusable blocks. |
|
6092 */ |
|
6093 |
|
6094 var __experimentalGetReusableBlocks = Object(rememo["a" /* default */])(function (state) { |
|
6095 return Object(external_lodash_["map"])(state.reusableBlocks.data, function (value, ref) { |
|
6096 return __experimentalGetReusableBlock(state, ref); |
|
6097 }); |
|
6098 }, function (state) { |
|
6099 return [state.reusableBlocks.data]; |
|
6100 }); |
|
6101 /** |
|
6102 * Returns state object prior to a specified optimist transaction ID, or `null` |
|
6103 * if the transaction corresponding to the given ID cannot be found. |
|
6104 * |
|
6105 * @param {Object} state Current global application state. |
|
6106 * @param {Object} transactionId Optimist transaction ID. |
|
6107 * |
|
6108 * @return {Object} Global application state prior to transaction. |
|
6109 */ |
|
6110 |
|
6111 function getStateBeforeOptimisticTransaction(state, transactionId) { |
|
6112 var transaction = Object(external_lodash_["find"])(state.optimist, function (entry) { |
|
6113 return entry.beforeState && Object(external_lodash_["get"])(entry.action, ['optimist', 'id']) === transactionId; |
|
6114 }); |
|
6115 return transaction ? transaction.beforeState : null; |
|
6116 } |
|
6117 /** |
|
6118 * Returns true if the post is being published, or false otherwise. |
|
6119 * |
|
6120 * @param {Object} state Global application state. |
|
6121 * |
|
6122 * @return {boolean} Whether post is being published. |
|
6123 */ |
|
6124 |
|
6125 function selectors_isPublishingPost(state) { |
|
6126 if (!selectors_isSavingPost(state)) { |
|
6127 return false; |
|
6128 } // Saving is optimistic, so assume that current post would be marked as |
|
6129 // published if publishing |
|
6130 |
|
6131 |
|
6132 if (!selectors_isCurrentPostPublished(state)) { |
|
6133 return false; |
|
6134 } // Use post update transaction ID to retrieve the state prior to the |
|
6135 // optimistic transaction |
|
6136 |
|
6137 |
|
6138 var stateBeforeRequest = getStateBeforeOptimisticTransaction(state, POST_UPDATE_TRANSACTION_ID); // Consider as publishing when current post prior to request was not |
|
6139 // considered published |
|
6140 |
|
6141 return !!stateBeforeRequest && !selectors_isCurrentPostPublished(stateBeforeRequest); |
|
6142 } |
|
6143 /** |
|
6144 * Returns whether the permalink is editable or not. |
|
6145 * |
|
6146 * @param {Object} state Editor state. |
|
6147 * |
|
6148 * @return {boolean} Whether or not the permalink is editable. |
|
6149 */ |
|
6150 |
|
6151 function selectors_isPermalinkEditable(state) { |
|
6152 var permalinkTemplate = selectors_getEditedPostAttribute(state, 'permalink_template'); |
|
6153 return PERMALINK_POSTNAME_REGEX.test(permalinkTemplate); |
|
6154 } |
|
6155 /** |
|
6156 * Returns the permalink for the post. |
|
6157 * |
|
6158 * @param {Object} state Editor state. |
|
6159 * |
|
6160 * @return {?string} The permalink, or null if the post is not viewable. |
|
6161 */ |
|
6162 |
|
6163 function getPermalink(state) { |
|
6164 var permalinkParts = selectors_getPermalinkParts(state); |
|
6165 |
|
6166 if (!permalinkParts) { |
|
6167 return null; |
|
6168 } |
|
6169 |
|
6170 var prefix = permalinkParts.prefix, |
|
6171 postName = permalinkParts.postName, |
|
6172 suffix = permalinkParts.suffix; |
|
6173 |
|
6174 if (selectors_isPermalinkEditable(state)) { |
|
6175 return prefix + postName + suffix; |
|
6176 } |
|
6177 |
|
6178 return prefix; |
|
6179 } |
|
6180 /** |
|
6181 * Returns the permalink for a post, split into it's three parts: the prefix, |
|
6182 * the postName, and the suffix. |
|
6183 * |
|
6184 * @param {Object} state Editor state. |
|
6185 * |
|
6186 * @return {Object} An object containing the prefix, postName, and suffix for |
|
6187 * the permalink, or null if the post is not viewable. |
|
6188 */ |
|
6189 |
|
6190 function selectors_getPermalinkParts(state) { |
|
6191 var permalinkTemplate = selectors_getEditedPostAttribute(state, 'permalink_template'); |
|
6192 |
|
6193 if (!permalinkTemplate) { |
|
6194 return null; |
|
6195 } |
|
6196 |
|
6197 var postName = selectors_getEditedPostAttribute(state, 'slug') || selectors_getEditedPostAttribute(state, 'generated_slug'); |
|
6198 |
|
6199 var _permalinkTemplate$sp = permalinkTemplate.split(PERMALINK_POSTNAME_REGEX), |
|
6200 _permalinkTemplate$sp2 = Object(slicedToArray["a" /* default */])(_permalinkTemplate$sp, 2), |
|
6201 prefix = _permalinkTemplate$sp2[0], |
|
6202 suffix = _permalinkTemplate$sp2[1]; |
|
6203 |
|
6204 return { |
|
6205 prefix: prefix, |
|
6206 postName: postName, |
|
6207 suffix: suffix |
|
6208 }; |
|
6209 } |
|
6210 /** |
|
6211 * Returns true if an optimistic transaction is pending commit, for which the |
|
6212 * before state satisfies the given predicate function. |
|
6213 * |
|
6214 * @param {Object} state Editor state. |
|
6215 * @param {Function} predicate Function given state, returning true if match. |
|
6216 * |
|
6217 * @return {boolean} Whether predicate matches for some history. |
|
6218 */ |
|
6219 |
|
6220 function inSomeHistory(state, predicate) { |
|
6221 var optimist = state.optimist; // In recursion, optimist state won't exist. Assume exhausted options. |
|
6222 |
|
6223 if (!optimist) { |
|
6224 return false; |
|
6225 } |
|
6226 |
|
6227 return optimist.some(function (_ref) { |
|
6228 var beforeState = _ref.beforeState; |
|
6229 return beforeState && predicate(beforeState); |
|
6230 }); |
|
6231 } |
|
6232 /** |
|
6233 * Returns whether the post is locked. |
|
6234 * |
|
6235 * @param {Object} state Global application state. |
|
6236 * |
|
6237 * @return {boolean} Is locked. |
|
6238 */ |
|
6239 |
|
6240 function isPostLocked(state) { |
|
6241 return state.postLock.isLocked; |
|
6242 } |
|
6243 /** |
|
6244 * Returns whether post saving is locked. |
|
6245 * |
|
6246 * @param {Object} state Global application state. |
|
6247 * |
|
6248 * @return {boolean} Is locked. |
|
6249 */ |
|
6250 |
|
6251 function selectors_isPostSavingLocked(state) { |
|
6252 return Object.keys(state.postSavingLock).length > 0; |
|
6253 } |
|
6254 /** |
|
6255 * Returns whether the edition of the post has been taken over. |
|
6256 * |
|
6257 * @param {Object} state Global application state. |
|
6258 * |
|
6259 * @return {boolean} Is post lock takeover. |
|
6260 */ |
|
6261 |
|
6262 function isPostLockTakeover(state) { |
|
6263 return state.postLock.isTakeover; |
|
6264 } |
|
6265 /** |
|
6266 * Returns details about the post lock user. |
|
6267 * |
|
6268 * @param {Object} state Global application state. |
|
6269 * |
|
6270 * @return {Object} A user object. |
|
6271 */ |
|
6272 |
|
6273 function getPostLockUser(state) { |
|
6274 return state.postLock.user; |
|
6275 } |
|
6276 /** |
|
6277 * Returns the active post lock. |
|
6278 * |
|
6279 * @param {Object} state Global application state. |
|
6280 * |
|
6281 * @return {Object} The lock object. |
|
6282 */ |
|
6283 |
|
6284 function getActivePostLock(state) { |
|
6285 return state.postLock.activePostLock; |
|
6286 } |
|
6287 /** |
|
6288 * Returns whether or not the user has the unfiltered_html capability. |
|
6289 * |
|
6290 * @param {Object} state Editor state. |
|
6291 * |
|
6292 * @return {boolean} Whether the user can or can't post unfiltered HTML. |
|
6293 */ |
|
6294 |
|
6295 function canUserUseUnfilteredHTML(state) { |
|
6296 return Object(external_lodash_["has"])(selectors_getCurrentPost(state), ['_links', 'wp:action-unfiltered-html']); |
|
6297 } |
|
6298 /** |
|
6299 * Returns whether the pre-publish panel should be shown |
|
6300 * or skipped when the user clicks the "publish" button. |
|
6301 * |
|
6302 * @param {Object} state Global application state. |
|
6303 * |
|
6304 * @return {boolean} Whether the pre-publish panel should be shown or not. |
|
6305 */ |
|
6306 |
|
6307 function selectors_isPublishSidebarEnabled(state) { |
|
6308 if (state.preferences.hasOwnProperty('isPublishSidebarEnabled')) { |
|
6309 return state.preferences.isPublishSidebarEnabled; |
|
6310 } |
|
6311 |
|
6312 return PREFERENCES_DEFAULTS.isPublishSidebarEnabled; |
|
6313 } |
|
6314 /** |
|
6315 * Return the current block list. |
|
6316 * |
|
6317 * @param {Object} state |
|
6318 * @return {Array} Block list. |
|
6319 */ |
|
6320 |
|
6321 function getEditorBlocks(state) { |
|
6322 return state.editor.present.blocks.value; |
|
6323 } |
|
6324 /** |
|
6325 * Is the editor ready |
|
6326 * |
|
6327 * @param {Object} state |
|
6328 * @return {boolean} is Ready. |
|
6329 */ |
|
6330 |
|
6331 function __unstableIsEditorReady(state) { |
|
6332 return state.isReady; |
|
6333 } |
|
6334 /** |
|
6335 * Returns the post editor settings. |
|
6336 * |
|
6337 * @param {Object} state Editor state. |
|
6338 * |
|
6339 * @return {Object} The editor settings object. |
|
6340 */ |
|
6341 |
|
6342 function selectors_getEditorSettings(state) { |
|
6343 return state.editorSettings; |
|
6344 } |
|
6345 /* |
|
6346 * Backward compatibility |
|
6347 */ |
|
6348 |
|
6349 function getBlockEditorSelector(name) { |
|
6350 return Object(external_this_wp_data_["createRegistrySelector"])(function (select) { |
|
6351 return function (state) { |
|
6352 var _select; |
|
6353 |
|
6354 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { |
|
6355 args[_key - 1] = arguments[_key]; |
|
6356 } |
|
6357 |
|
6358 return (_select = select('core/block-editor'))[name].apply(_select, args); |
|
6359 }; |
|
6360 }); |
|
6361 } |
|
6362 |
|
6363 var getBlockDependantsCacheBust = getBlockEditorSelector('getBlockDependantsCacheBust'); |
|
6364 var selectors_getBlockName = getBlockEditorSelector('getBlockName'); |
|
6365 var isBlockValid = getBlockEditorSelector('isBlockValid'); |
|
6366 var getBlockAttributes = getBlockEditorSelector('getBlockAttributes'); |
|
6367 var getBlock = getBlockEditorSelector('getBlock'); |
|
6368 var selectors_getBlocks = getBlockEditorSelector('getBlocks'); |
|
6369 var __unstableGetBlockWithoutInnerBlocks = getBlockEditorSelector('__unstableGetBlockWithoutInnerBlocks'); |
|
6370 var getClientIdsOfDescendants = getBlockEditorSelector('getClientIdsOfDescendants'); |
|
6371 var getClientIdsWithDescendants = getBlockEditorSelector('getClientIdsWithDescendants'); |
|
6372 var getGlobalBlockCount = getBlockEditorSelector('getGlobalBlockCount'); |
|
6373 var getBlocksByClientId = getBlockEditorSelector('getBlocksByClientId'); |
|
6374 var getBlockCount = getBlockEditorSelector('getBlockCount'); |
|
6375 var getBlockSelectionStart = getBlockEditorSelector('getBlockSelectionStart'); |
|
6376 var getBlockSelectionEnd = getBlockEditorSelector('getBlockSelectionEnd'); |
|
6377 var getSelectedBlockCount = getBlockEditorSelector('getSelectedBlockCount'); |
|
6378 var hasSelectedBlock = getBlockEditorSelector('hasSelectedBlock'); |
|
6379 var selectors_getSelectedBlockClientId = getBlockEditorSelector('getSelectedBlockClientId'); |
|
6380 var getSelectedBlock = getBlockEditorSelector('getSelectedBlock'); |
|
6381 var getBlockRootClientId = getBlockEditorSelector('getBlockRootClientId'); |
|
6382 var getBlockHierarchyRootClientId = getBlockEditorSelector('getBlockHierarchyRootClientId'); |
|
6383 var getAdjacentBlockClientId = getBlockEditorSelector('getAdjacentBlockClientId'); |
|
6384 var getPreviousBlockClientId = getBlockEditorSelector('getPreviousBlockClientId'); |
|
6385 var getNextBlockClientId = getBlockEditorSelector('getNextBlockClientId'); |
|
6386 var getSelectedBlocksInitialCaretPosition = getBlockEditorSelector('getSelectedBlocksInitialCaretPosition'); |
|
6387 var getMultiSelectedBlockClientIds = getBlockEditorSelector('getMultiSelectedBlockClientIds'); |
|
6388 var getMultiSelectedBlocks = getBlockEditorSelector('getMultiSelectedBlocks'); |
|
6389 var getFirstMultiSelectedBlockClientId = getBlockEditorSelector('getFirstMultiSelectedBlockClientId'); |
|
6390 var getLastMultiSelectedBlockClientId = getBlockEditorSelector('getLastMultiSelectedBlockClientId'); |
|
6391 var isFirstMultiSelectedBlock = getBlockEditorSelector('isFirstMultiSelectedBlock'); |
|
6392 var isBlockMultiSelected = getBlockEditorSelector('isBlockMultiSelected'); |
|
6393 var isAncestorMultiSelected = getBlockEditorSelector('isAncestorMultiSelected'); |
|
6394 var getMultiSelectedBlocksStartClientId = getBlockEditorSelector('getMultiSelectedBlocksStartClientId'); |
|
6395 var getMultiSelectedBlocksEndClientId = getBlockEditorSelector('getMultiSelectedBlocksEndClientId'); |
|
6396 var getBlockOrder = getBlockEditorSelector('getBlockOrder'); |
|
6397 var getBlockIndex = getBlockEditorSelector('getBlockIndex'); |
|
6398 var isBlockSelected = getBlockEditorSelector('isBlockSelected'); |
|
6399 var hasSelectedInnerBlock = getBlockEditorSelector('hasSelectedInnerBlock'); |
|
6400 var isBlockWithinSelection = getBlockEditorSelector('isBlockWithinSelection'); |
|
6401 var hasMultiSelection = getBlockEditorSelector('hasMultiSelection'); |
|
6402 var isMultiSelecting = getBlockEditorSelector('isMultiSelecting'); |
|
6403 var isSelectionEnabled = getBlockEditorSelector('isSelectionEnabled'); |
|
6404 var getBlockMode = getBlockEditorSelector('getBlockMode'); |
|
6405 var selectors_isTyping = getBlockEditorSelector('isTyping'); |
|
6406 var selectors_isCaretWithinFormattedText = getBlockEditorSelector('isCaretWithinFormattedText'); |
|
6407 var getBlockInsertionPoint = getBlockEditorSelector('getBlockInsertionPoint'); |
|
6408 var isBlockInsertionPointVisible = getBlockEditorSelector('isBlockInsertionPointVisible'); |
|
6409 var isValidTemplate = getBlockEditorSelector('isValidTemplate'); |
|
6410 var getTemplate = getBlockEditorSelector('getTemplate'); |
|
6411 var getTemplateLock = getBlockEditorSelector('getTemplateLock'); |
|
6412 var canInsertBlockType = getBlockEditorSelector('canInsertBlockType'); |
|
6413 var selectors_getInserterItems = getBlockEditorSelector('getInserterItems'); |
|
6414 var hasInserterItems = getBlockEditorSelector('hasInserterItems'); |
|
6415 var getBlockListSettings = getBlockEditorSelector('getBlockListSettings'); |
|
6416 |
|
6417 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/effects/reusable-blocks.js |
|
6418 |
|
6419 |
|
6420 |
|
6421 |
|
6422 /** |
|
6423 * External dependencies |
|
6424 */ |
|
6425 |
|
6426 |
|
6427 /** |
|
6428 * WordPress dependencies |
|
6429 */ |
|
6430 |
|
6431 |
|
6432 |
|
6433 // TODO: Ideally this would be the only dispatch in scope. This requires either |
|
6434 // refactoring editor actions to yielded controls, or replacing direct dispatch |
|
6435 // on the editor store with action creators (e.g. `REMOVE_REUSABLE_BLOCK`). |
|
6436 |
|
6437 |
|
6438 /** |
|
6439 * Internal dependencies |
|
6440 */ |
|
6441 |
|
6442 |
|
6443 |
|
6444 |
|
6445 /** |
|
6446 * Module Constants |
|
6447 */ |
|
6448 |
|
6449 var REUSABLE_BLOCK_NOTICE_ID = 'REUSABLE_BLOCK_NOTICE_ID'; |
|
6450 /** |
|
6451 * Fetch Reusable Blocks Effect Handler. |
|
6452 * |
|
6453 * @param {Object} action action object. |
|
6454 * @param {Object} store Redux Store. |
|
6455 */ |
|
6456 |
|
6457 var fetchReusableBlocks = |
|
6458 /*#__PURE__*/ |
|
6459 function () { |
|
6460 var _ref = Object(asyncToGenerator["a" /* default */])( |
|
6461 /*#__PURE__*/ |
|
6462 regenerator_default.a.mark(function _callee(action, store) { |
|
6463 var id, dispatch, postType, posts, results; |
|
6464 return regenerator_default.a.wrap(function _callee$(_context) { |
|
6465 while (1) { |
|
6466 switch (_context.prev = _context.next) { |
|
6467 case 0: |
|
6468 id = action.id; |
|
6469 dispatch = store.dispatch; // TODO: these are potentially undefined, this fix is in place |
|
6470 // until there is a filter to not use reusable blocks if undefined |
|
6471 |
|
6472 _context.next = 4; |
|
6473 return external_this_wp_apiFetch_default()({ |
|
6474 path: '/wp/v2/types/wp_block' |
|
6475 }); |
|
6476 |
|
6477 case 4: |
|
6478 postType = _context.sent; |
|
6479 |
|
6480 if (postType) { |
|
6481 _context.next = 7; |
|
6482 break; |
|
6483 } |
|
6484 |
|
6485 return _context.abrupt("return"); |
|
6486 |
|
6487 case 7: |
|
6488 _context.prev = 7; |
|
6489 |
|
6490 if (!id) { |
|
6491 _context.next = 15; |
|
6492 break; |
|
6493 } |
|
6494 |
|
6495 _context.next = 11; |
|
6496 return external_this_wp_apiFetch_default()({ |
|
6497 path: "/wp/v2/".concat(postType.rest_base, "/").concat(id) |
|
6498 }); |
|
6499 |
|
6500 case 11: |
|
6501 _context.t0 = _context.sent; |
|
6502 posts = [_context.t0]; |
|
6503 _context.next = 18; |
|
6504 break; |
|
6505 |
|
6506 case 15: |
|
6507 _context.next = 17; |
|
6508 return external_this_wp_apiFetch_default()({ |
|
6509 path: "/wp/v2/".concat(postType.rest_base, "?per_page=-1") |
|
6510 }); |
|
6511 |
|
6512 case 17: |
|
6513 posts = _context.sent; |
|
6514 |
|
6515 case 18: |
|
6516 results = Object(external_lodash_["compact"])(Object(external_lodash_["map"])(posts, function (post) { |
|
6517 if (post.status !== 'publish' || post.content.protected) { |
|
6518 return null; |
|
6519 } |
|
6520 |
|
6521 var parsedBlocks = Object(external_this_wp_blocks_["parse"])(post.content.raw); |
|
6522 return { |
|
6523 reusableBlock: { |
|
6524 id: post.id, |
|
6525 title: getPostRawValue(post.title) |
|
6526 }, |
|
6527 parsedBlock: parsedBlocks.length === 1 ? parsedBlocks[0] : Object(external_this_wp_blocks_["createBlock"])('core/template', {}, parsedBlocks) |
|
6528 }; |
|
6529 })); |
|
6530 |
|
6531 if (results.length) { |
|
6532 dispatch(__experimentalReceiveReusableBlocks(results)); |
|
6533 } |
|
6534 |
|
6535 dispatch({ |
|
6536 type: 'FETCH_REUSABLE_BLOCKS_SUCCESS', |
|
6537 id: id |
|
6538 }); |
|
6539 _context.next = 26; |
|
6540 break; |
|
6541 |
|
6542 case 23: |
|
6543 _context.prev = 23; |
|
6544 _context.t1 = _context["catch"](7); |
|
6545 dispatch({ |
|
6546 type: 'FETCH_REUSABLE_BLOCKS_FAILURE', |
|
6547 id: id, |
|
6548 error: _context.t1 |
|
6549 }); |
|
6550 |
|
6551 case 26: |
|
6552 case "end": |
|
6553 return _context.stop(); |
|
6554 } |
|
6555 } |
|
6556 }, _callee, this, [[7, 23]]); |
|
6557 })); |
|
6558 |
|
6559 return function fetchReusableBlocks(_x, _x2) { |
|
6560 return _ref.apply(this, arguments); |
|
6561 }; |
|
6562 }(); |
|
6563 /** |
|
6564 * Save Reusable Blocks Effect Handler. |
|
6565 * |
|
6566 * @param {Object} action action object. |
|
6567 * @param {Object} store Redux Store. |
|
6568 */ |
|
6569 |
|
6570 var saveReusableBlocks = |
|
6571 /*#__PURE__*/ |
|
6572 function () { |
|
6573 var _ref2 = Object(asyncToGenerator["a" /* default */])( |
|
6574 /*#__PURE__*/ |
|
6575 regenerator_default.a.mark(function _callee2(action, store) { |
|
6576 var postType, id, dispatch, state, _getReusableBlock, clientId, title, isTemporary, reusableBlock, content, data, path, method, updatedReusableBlock, message; |
|
6577 |
|
6578 return regenerator_default.a.wrap(function _callee2$(_context2) { |
|
6579 while (1) { |
|
6580 switch (_context2.prev = _context2.next) { |
|
6581 case 0: |
|
6582 _context2.next = 2; |
|
6583 return external_this_wp_apiFetch_default()({ |
|
6584 path: '/wp/v2/types/wp_block' |
|
6585 }); |
|
6586 |
|
6587 case 2: |
|
6588 postType = _context2.sent; |
|
6589 |
|
6590 if (postType) { |
|
6591 _context2.next = 5; |
|
6592 break; |
|
6593 } |
|
6594 |
|
6595 return _context2.abrupt("return"); |
|
6596 |
|
6597 case 5: |
|
6598 id = action.id; |
|
6599 dispatch = store.dispatch; |
|
6600 state = store.getState(); |
|
6601 _getReusableBlock = __experimentalGetReusableBlock(state, id), clientId = _getReusableBlock.clientId, title = _getReusableBlock.title, isTemporary = _getReusableBlock.isTemporary; |
|
6602 reusableBlock = Object(external_this_wp_data_["select"])('core/block-editor').getBlock(clientId); |
|
6603 content = Object(external_this_wp_blocks_["serialize"])(reusableBlock.name === 'core/template' ? reusableBlock.innerBlocks : reusableBlock); |
|
6604 data = isTemporary ? { |
|
6605 title: title, |
|
6606 content: content, |
|
6607 status: 'publish' |
|
6608 } : { |
|
6609 id: id, |
|
6610 title: title, |
|
6611 content: content, |
|
6612 status: 'publish' |
|
6613 }; |
|
6614 path = isTemporary ? "/wp/v2/".concat(postType.rest_base) : "/wp/v2/".concat(postType.rest_base, "/").concat(id); |
|
6615 method = isTemporary ? 'POST' : 'PUT'; |
|
6616 _context2.prev = 14; |
|
6617 _context2.next = 17; |
|
6618 return external_this_wp_apiFetch_default()({ |
|
6619 path: path, |
|
6620 data: data, |
|
6621 method: method |
|
6622 }); |
|
6623 |
|
6624 case 17: |
|
6625 updatedReusableBlock = _context2.sent; |
|
6626 dispatch({ |
|
6627 type: 'SAVE_REUSABLE_BLOCK_SUCCESS', |
|
6628 updatedId: updatedReusableBlock.id, |
|
6629 id: id |
|
6630 }); |
|
6631 message = isTemporary ? Object(external_this_wp_i18n_["__"])('Block created.') : Object(external_this_wp_i18n_["__"])('Block updated.'); |
|
6632 Object(external_this_wp_data_["dispatch"])('core/notices').createSuccessNotice(message, { |
|
6633 id: REUSABLE_BLOCK_NOTICE_ID |
|
6634 }); |
|
6635 |
|
6636 Object(external_this_wp_data_["dispatch"])('core/block-editor').__unstableSaveReusableBlock(id, updatedReusableBlock.id); |
|
6637 |
|
6638 _context2.next = 28; |
|
6639 break; |
|
6640 |
|
6641 case 24: |
|
6642 _context2.prev = 24; |
|
6643 _context2.t0 = _context2["catch"](14); |
|
6644 dispatch({ |
|
6645 type: 'SAVE_REUSABLE_BLOCK_FAILURE', |
|
6646 id: id |
|
6647 }); |
|
6648 Object(external_this_wp_data_["dispatch"])('core/notices').createErrorNotice(_context2.t0.message, { |
|
6649 id: REUSABLE_BLOCK_NOTICE_ID |
|
6650 }); |
|
6651 |
|
6652 case 28: |
|
6653 case "end": |
|
6654 return _context2.stop(); |
|
6655 } |
|
6656 } |
|
6657 }, _callee2, this, [[14, 24]]); |
|
6658 })); |
|
6659 |
|
6660 return function saveReusableBlocks(_x3, _x4) { |
|
6661 return _ref2.apply(this, arguments); |
|
6662 }; |
|
6663 }(); |
|
6664 /** |
|
6665 * Delete Reusable Blocks Effect Handler. |
|
6666 * |
|
6667 * @param {Object} action action object. |
|
6668 * @param {Object} store Redux Store. |
|
6669 */ |
|
6670 |
|
6671 var deleteReusableBlocks = |
|
6672 /*#__PURE__*/ |
|
6673 function () { |
|
6674 var _ref3 = Object(asyncToGenerator["a" /* default */])( |
|
6675 /*#__PURE__*/ |
|
6676 regenerator_default.a.mark(function _callee3(action, store) { |
|
6677 var postType, id, getState, dispatch, reusableBlock, allBlocks, associatedBlocks, associatedBlockClientIds, transactionId, message; |
|
6678 return regenerator_default.a.wrap(function _callee3$(_context3) { |
|
6679 while (1) { |
|
6680 switch (_context3.prev = _context3.next) { |
|
6681 case 0: |
|
6682 _context3.next = 2; |
|
6683 return external_this_wp_apiFetch_default()({ |
|
6684 path: '/wp/v2/types/wp_block' |
|
6685 }); |
|
6686 |
|
6687 case 2: |
|
6688 postType = _context3.sent; |
|
6689 |
|
6690 if (postType) { |
|
6691 _context3.next = 5; |
|
6692 break; |
|
6693 } |
|
6694 |
|
6695 return _context3.abrupt("return"); |
|
6696 |
|
6697 case 5: |
|
6698 id = action.id; |
|
6699 getState = store.getState, dispatch = store.dispatch; // Don't allow a reusable block with a temporary ID to be deleted |
|
6700 |
|
6701 reusableBlock = __experimentalGetReusableBlock(getState(), id); |
|
6702 |
|
6703 if (!(!reusableBlock || reusableBlock.isTemporary)) { |
|
6704 _context3.next = 10; |
|
6705 break; |
|
6706 } |
|
6707 |
|
6708 return _context3.abrupt("return"); |
|
6709 |
|
6710 case 10: |
|
6711 // Remove any other blocks that reference this reusable block |
|
6712 allBlocks = Object(external_this_wp_data_["select"])('core/block-editor').getBlocks(); |
|
6713 associatedBlocks = allBlocks.filter(function (block) { |
|
6714 return Object(external_this_wp_blocks_["isReusableBlock"])(block) && block.attributes.ref === id; |
|
6715 }); |
|
6716 associatedBlockClientIds = associatedBlocks.map(function (block) { |
|
6717 return block.clientId; |
|
6718 }); |
|
6719 transactionId = Object(external_lodash_["uniqueId"])(); |
|
6720 dispatch({ |
|
6721 type: 'REMOVE_REUSABLE_BLOCK', |
|
6722 id: id, |
|
6723 optimist: { |
|
6724 type: redux_optimist["BEGIN"], |
|
6725 id: transactionId |
|
6726 } |
|
6727 }); // Remove the parsed block. |
|
6728 |
|
6729 Object(external_this_wp_data_["dispatch"])('core/block-editor').removeBlocks([].concat(Object(toConsumableArray["a" /* default */])(associatedBlockClientIds), [reusableBlock.clientId])); |
|
6730 _context3.prev = 16; |
|
6731 _context3.next = 19; |
|
6732 return external_this_wp_apiFetch_default()({ |
|
6733 path: "/wp/v2/".concat(postType.rest_base, "/").concat(id), |
|
6734 method: 'DELETE' |
|
6735 }); |
|
6736 |
|
6737 case 19: |
|
6738 dispatch({ |
|
6739 type: 'DELETE_REUSABLE_BLOCK_SUCCESS', |
|
6740 id: id, |
|
6741 optimist: { |
|
6742 type: redux_optimist["COMMIT"], |
|
6743 id: transactionId |
|
6744 } |
|
6745 }); |
|
6746 message = Object(external_this_wp_i18n_["__"])('Block deleted.'); |
|
6747 Object(external_this_wp_data_["dispatch"])('core/notices').createSuccessNotice(message, { |
|
6748 id: REUSABLE_BLOCK_NOTICE_ID |
|
6749 }); |
|
6750 _context3.next = 28; |
|
6751 break; |
|
6752 |
|
6753 case 24: |
|
6754 _context3.prev = 24; |
|
6755 _context3.t0 = _context3["catch"](16); |
|
6756 dispatch({ |
|
6757 type: 'DELETE_REUSABLE_BLOCK_FAILURE', |
|
6758 id: id, |
|
6759 optimist: { |
|
6760 type: redux_optimist["REVERT"], |
|
6761 id: transactionId |
|
6762 } |
|
6763 }); |
|
6764 Object(external_this_wp_data_["dispatch"])('core/notices').createErrorNotice(_context3.t0.message, { |
|
6765 id: REUSABLE_BLOCK_NOTICE_ID |
|
6766 }); |
|
6767 |
|
6768 case 28: |
|
6769 case "end": |
|
6770 return _context3.stop(); |
|
6771 } |
|
6772 } |
|
6773 }, _callee3, this, [[16, 24]]); |
|
6774 })); |
|
6775 |
|
6776 return function deleteReusableBlocks(_x5, _x6) { |
|
6777 return _ref3.apply(this, arguments); |
|
6778 }; |
|
6779 }(); |
|
6780 /** |
|
6781 * Receive Reusable Blocks Effect Handler. |
|
6782 * |
|
6783 * @param {Object} action action object. |
|
6784 */ |
|
6785 |
|
6786 var reusable_blocks_receiveReusableBlocks = function receiveReusableBlocks(action) { |
|
6787 Object(external_this_wp_data_["dispatch"])('core/block-editor').receiveBlocks(Object(external_lodash_["map"])(action.results, 'parsedBlock')); |
|
6788 }; |
|
6789 /** |
|
6790 * Convert a reusable block to a static block effect handler |
|
6791 * |
|
6792 * @param {Object} action action object. |
|
6793 * @param {Object} store Redux Store. |
|
6794 */ |
|
6795 |
|
6796 var reusable_blocks_convertBlockToStatic = function convertBlockToStatic(action, store) { |
|
6797 var state = store.getState(); |
|
6798 var oldBlock = Object(external_this_wp_data_["select"])('core/block-editor').getBlock(action.clientId); |
|
6799 var reusableBlock = __experimentalGetReusableBlock(state, oldBlock.attributes.ref); |
|
6800 var referencedBlock = Object(external_this_wp_data_["select"])('core/block-editor').getBlock(reusableBlock.clientId); |
|
6801 var newBlocks; |
|
6802 |
|
6803 if (referencedBlock.name === 'core/template') { |
|
6804 newBlocks = referencedBlock.innerBlocks.map(function (innerBlock) { |
|
6805 return Object(external_this_wp_blocks_["cloneBlock"])(innerBlock); |
|
6806 }); |
|
6807 } else { |
|
6808 newBlocks = [Object(external_this_wp_blocks_["cloneBlock"])(referencedBlock)]; |
|
6809 } |
|
6810 |
|
6811 Object(external_this_wp_data_["dispatch"])('core/block-editor').replaceBlocks(oldBlock.clientId, newBlocks); |
|
6812 }; |
|
6813 /** |
|
6814 * Convert a static block to a reusable block effect handler |
|
6815 * |
|
6816 * @param {Object} action action object. |
|
6817 * @param {Object} store Redux Store. |
|
6818 */ |
|
6819 |
|
6820 var reusable_blocks_convertBlockToReusable = function convertBlockToReusable(action, store) { |
|
6821 var dispatch = store.dispatch; |
|
6822 var parsedBlock; |
|
6823 |
|
6824 if (action.clientIds.length === 1) { |
|
6825 parsedBlock = Object(external_this_wp_data_["select"])('core/block-editor').getBlock(action.clientIds[0]); |
|
6826 } else { |
|
6827 parsedBlock = Object(external_this_wp_blocks_["createBlock"])('core/template', {}, Object(external_this_wp_data_["select"])('core/block-editor').getBlocksByClientId(action.clientIds)); // This shouldn't be necessary but at the moment |
|
6828 // we expect the content of the shared blocks to live in the blocks state. |
|
6829 |
|
6830 Object(external_this_wp_data_["dispatch"])('core/block-editor').receiveBlocks([parsedBlock]); |
|
6831 } |
|
6832 |
|
6833 var reusableBlock = { |
|
6834 id: Object(external_lodash_["uniqueId"])('reusable'), |
|
6835 clientId: parsedBlock.clientId, |
|
6836 title: Object(external_this_wp_i18n_["__"])('Untitled Reusable Block') |
|
6837 }; |
|
6838 dispatch(__experimentalReceiveReusableBlocks([{ |
|
6839 reusableBlock: reusableBlock, |
|
6840 parsedBlock: parsedBlock |
|
6841 }])); |
|
6842 dispatch(__experimentalSaveReusableBlock(reusableBlock.id)); |
|
6843 Object(external_this_wp_data_["dispatch"])('core/block-editor').replaceBlocks(action.clientIds, Object(external_this_wp_blocks_["createBlock"])('core/block', { |
|
6844 ref: reusableBlock.id |
|
6845 })); // Re-add the original block to the store, since replaceBlock() will have removed it |
|
6846 |
|
6847 Object(external_this_wp_data_["dispatch"])('core/block-editor').receiveBlocks([parsedBlock]); |
|
6848 }; |
|
6849 |
|
6850 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/effects.js |
|
6851 /** |
|
6852 * External dependencies |
|
6853 */ |
|
6854 |
|
6855 /** |
|
6856 * WordPress dependencies |
|
6857 */ |
|
6858 |
|
6859 |
|
6860 /** |
|
6861 * Internal dependencies |
|
6862 */ |
|
6863 |
|
6864 |
|
6865 |
|
6866 /* harmony default export */ var effects = ({ |
|
6867 SETUP_EDITOR: function SETUP_EDITOR(action) { |
|
6868 var post = action.post, |
|
6869 edits = action.edits, |
|
6870 template = action.template; // In order to ensure maximum of a single parse during setup, edits are |
|
6871 // included as part of editor setup action. Assume edited content as |
|
6872 // canonical if provided, falling back to post. |
|
6873 |
|
6874 var content; |
|
6875 |
|
6876 if (Object(external_lodash_["has"])(edits, ['content'])) { |
|
6877 content = edits.content; |
|
6878 } else { |
|
6879 content = post.content.raw; |
|
6880 } |
|
6881 |
|
6882 var blocks = Object(external_this_wp_blocks_["parse"])(content); // Apply a template for new posts only, if exists. |
|
6883 |
|
6884 var isNewPost = post.status === 'auto-draft'; |
|
6885 |
|
6886 if (isNewPost && template) { |
|
6887 blocks = Object(external_this_wp_blocks_["synchronizeBlocksWithTemplate"])(blocks, template); |
|
6888 } |
|
6889 |
|
6890 return [actions_resetEditorBlocks(blocks), setupEditorState(post)]; |
|
6891 }, |
|
6892 FETCH_REUSABLE_BLOCKS: function FETCH_REUSABLE_BLOCKS(action, store) { |
|
6893 fetchReusableBlocks(action, store); |
|
6894 }, |
|
6895 SAVE_REUSABLE_BLOCK: function SAVE_REUSABLE_BLOCK(action, store) { |
|
6896 saveReusableBlocks(action, store); |
|
6897 }, |
|
6898 DELETE_REUSABLE_BLOCK: function DELETE_REUSABLE_BLOCK(action, store) { |
|
6899 deleteReusableBlocks(action, store); |
|
6900 }, |
|
6901 RECEIVE_REUSABLE_BLOCKS: reusable_blocks_receiveReusableBlocks, |
|
6902 CONVERT_BLOCK_TO_STATIC: reusable_blocks_convertBlockToStatic, |
|
6903 CONVERT_BLOCK_TO_REUSABLE: reusable_blocks_convertBlockToReusable |
|
6904 }); |
|
6905 |
|
6906 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/middlewares.js |
|
6907 |
|
6908 |
|
6909 /** |
|
6910 * External dependencies |
|
6911 */ |
|
6912 |
|
6913 |
|
6914 |
|
6915 /** |
|
6916 * Internal dependencies |
|
6917 */ |
|
6918 |
|
6919 |
|
6920 /** |
|
6921 * Applies the custom middlewares used specifically in the editor module. |
|
6922 * |
|
6923 * @param {Object} store Store Object. |
|
6924 * |
|
6925 * @return {Object} Update Store Object. |
|
6926 */ |
|
6927 |
|
6928 function applyMiddlewares(store) { |
|
6929 var middlewares = [refx_default()(effects), lib_default.a]; |
|
6930 |
|
6931 var enhancedDispatch = function enhancedDispatch() { |
|
6932 throw new Error('Dispatching while constructing your middleware is not allowed. ' + 'Other middleware would not be applied to this dispatch.'); |
|
6933 }; |
|
6934 |
|
6935 var chain = []; |
|
6936 var middlewareAPI = { |
|
6937 getState: store.getState, |
|
6938 dispatch: function dispatch() { |
|
6939 return enhancedDispatch.apply(void 0, arguments); |
|
6940 } |
|
6941 }; |
|
6942 chain = middlewares.map(function (middleware) { |
|
6943 return middleware(middlewareAPI); |
|
6944 }); |
|
6945 enhancedDispatch = external_lodash_["flowRight"].apply(void 0, Object(toConsumableArray["a" /* default */])(chain))(store.dispatch); |
|
6946 store.dispatch = enhancedDispatch; |
|
6947 return store; |
|
6948 } |
|
6949 |
|
6950 /* harmony default export */ var store_middlewares = (applyMiddlewares); |
|
6951 |
|
6952 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/store/index.js |
|
6953 /** |
|
6954 * WordPress dependencies |
|
6955 */ |
|
6956 |
|
6957 /** |
|
6958 * Internal dependencies |
|
6959 */ |
|
6960 |
|
6961 |
|
6962 |
|
6963 |
|
6964 |
|
6965 |
|
6966 |
|
6967 var store_store = Object(external_this_wp_data_["registerStore"])(STORE_KEY, { |
|
6968 reducer: store_reducer, |
|
6969 selectors: selectors_namespaceObject, |
|
6970 actions: actions_namespaceObject, |
|
6971 controls: controls, |
|
6972 persist: ['preferences'] |
|
6973 }); |
|
6974 store_middlewares(store_store); |
|
6975 /* harmony default export */ var build_module_store = (store_store); |
|
6976 |
|
6977 // EXTERNAL MODULE: external {"this":["wp","hooks"]} |
|
6978 var external_this_wp_hooks_ = __webpack_require__(26); |
|
6979 |
|
6980 // EXTERNAL MODULE: external {"this":["wp","element"]} |
|
6981 var external_this_wp_element_ = __webpack_require__(0); |
|
6982 |
|
6983 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autocompleters/block.js |
|
6984 |
|
6985 |
|
6986 |
|
6987 /** |
|
6988 * WordPress dependencies |
|
6989 */ |
|
6990 |
|
6991 |
|
6992 |
|
6993 /** |
|
6994 * Returns the client ID of the parent where a newly inserted block would be |
|
6995 * placed. |
|
6996 * |
|
6997 * @return {string} Client ID of the parent where a newly inserted block would |
|
6998 * be placed. |
|
6999 */ |
|
7000 |
|
7001 function defaultGetBlockInsertionParentClientId() { |
|
7002 return Object(external_this_wp_data_["select"])('core/block-editor').getBlockInsertionPoint().rootClientId; |
|
7003 } |
|
7004 /** |
|
7005 * Returns the inserter items for the specified parent block. |
|
7006 * |
|
7007 * @param {string} rootClientId Client ID of the block for which to retrieve |
|
7008 * inserter items. |
|
7009 * |
|
7010 * @return {Array<Editor.InserterItem>} The inserter items for the specified |
|
7011 * parent. |
|
7012 */ |
|
7013 |
|
7014 |
|
7015 function defaultGetInserterItems(rootClientId) { |
|
7016 return Object(external_this_wp_data_["select"])('core/block-editor').getInserterItems(rootClientId); |
|
7017 } |
|
7018 /** |
|
7019 * Returns the name of the currently selected block. |
|
7020 * |
|
7021 * @return {string?} The name of the currently selected block or `null` if no |
|
7022 * block is selected. |
|
7023 */ |
|
7024 |
|
7025 |
|
7026 function defaultGetSelectedBlockName() { |
|
7027 var _select = Object(external_this_wp_data_["select"])('core/block-editor'), |
|
7028 getSelectedBlockClientId = _select.getSelectedBlockClientId, |
|
7029 getBlockName = _select.getBlockName; |
|
7030 |
|
7031 var selectedBlockClientId = getSelectedBlockClientId(); |
|
7032 return selectedBlockClientId ? getBlockName(selectedBlockClientId) : null; |
|
7033 } |
|
7034 /** |
|
7035 * Creates a blocks repeater for replacing the current block with a selected block type. |
|
7036 * |
|
7037 * @return {Completer} A blocks completer. |
|
7038 */ |
|
7039 |
|
7040 |
|
7041 function createBlockCompleter() { |
|
7042 var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}, |
|
7043 _ref$getBlockInsertio = _ref.getBlockInsertionParentClientId, |
|
7044 getBlockInsertionParentClientId = _ref$getBlockInsertio === void 0 ? defaultGetBlockInsertionParentClientId : _ref$getBlockInsertio, |
|
7045 _ref$getInserterItems = _ref.getInserterItems, |
|
7046 getInserterItems = _ref$getInserterItems === void 0 ? defaultGetInserterItems : _ref$getInserterItems, |
|
7047 _ref$getSelectedBlock = _ref.getSelectedBlockName, |
|
7048 getSelectedBlockName = _ref$getSelectedBlock === void 0 ? defaultGetSelectedBlockName : _ref$getSelectedBlock; |
|
7049 |
|
7050 return { |
|
7051 name: 'blocks', |
|
7052 className: 'editor-autocompleters__block', |
|
7053 triggerPrefix: '/', |
|
7054 options: function options() { |
|
7055 var selectedBlockName = getSelectedBlockName(); |
|
7056 return getInserterItems(getBlockInsertionParentClientId()).filter( // Avoid offering to replace the current block with a block of the same type. |
|
7057 function (inserterItem) { |
|
7058 return selectedBlockName !== inserterItem.name; |
|
7059 }); |
|
7060 }, |
|
7061 getOptionKeywords: function getOptionKeywords(inserterItem) { |
|
7062 var title = inserterItem.title, |
|
7063 _inserterItem$keyword = inserterItem.keywords, |
|
7064 keywords = _inserterItem$keyword === void 0 ? [] : _inserterItem$keyword, |
|
7065 category = inserterItem.category; |
|
7066 return [category].concat(Object(toConsumableArray["a" /* default */])(keywords), [title]); |
|
7067 }, |
|
7068 getOptionLabel: function getOptionLabel(inserterItem) { |
|
7069 var icon = inserterItem.icon, |
|
7070 title = inserterItem.title; |
|
7071 return [Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["BlockIcon"], { |
|
7072 key: "icon", |
|
7073 icon: icon, |
|
7074 showColors: true |
|
7075 }), title]; |
|
7076 }, |
|
7077 allowContext: function allowContext(before, after) { |
|
7078 return !(/\S/.test(before) || /\S/.test(after)); |
|
7079 }, |
|
7080 getOptionCompletion: function getOptionCompletion(inserterItem) { |
|
7081 var name = inserterItem.name, |
|
7082 initialAttributes = inserterItem.initialAttributes; |
|
7083 return { |
|
7084 action: 'replace', |
|
7085 value: Object(external_this_wp_blocks_["createBlock"])(name, initialAttributes) |
|
7086 }; |
|
7087 }, |
|
7088 isOptionDisabled: function isOptionDisabled(inserterItem) { |
|
7089 return inserterItem.isDisabled; |
|
7090 } |
|
7091 }; |
|
7092 } |
|
7093 /** |
|
7094 * Creates a blocks repeater for replacing the current block with a selected block type. |
|
7095 * |
|
7096 * @return {Completer} A blocks completer. |
|
7097 */ |
|
7098 |
|
7099 /* harmony default export */ var autocompleters_block = (createBlockCompleter()); |
|
7100 |
|
7101 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autocompleters/user.js |
|
7102 |
|
7103 |
|
7104 /** |
|
7105 * WordPress dependencies |
|
7106 */ |
|
7107 |
|
7108 /** |
|
7109 * A user mentions completer. |
|
7110 * |
|
7111 * @type {Completer} |
|
7112 */ |
|
7113 |
|
7114 /* harmony default export */ var autocompleters_user = ({ |
|
7115 name: 'users', |
|
7116 className: 'editor-autocompleters__user', |
|
7117 triggerPrefix: '@', |
|
7118 options: function options(search) { |
|
7119 var payload = ''; |
|
7120 |
|
7121 if (search) { |
|
7122 payload = '?search=' + encodeURIComponent(search); |
|
7123 } |
|
7124 |
|
7125 return external_this_wp_apiFetch_default()({ |
|
7126 path: '/wp/v2/users' + payload |
|
7127 }); |
|
7128 }, |
|
7129 isDebounced: true, |
|
7130 getOptionKeywords: function getOptionKeywords(user) { |
|
7131 return [user.slug, user.name]; |
|
7132 }, |
|
7133 getOptionLabel: function getOptionLabel(user) { |
|
7134 return [Object(external_this_wp_element_["createElement"])("img", { |
|
7135 key: "avatar", |
|
7136 className: "editor-autocompleters__user-avatar", |
|
7137 alt: "", |
|
7138 src: user.avatar_urls[24] |
|
7139 }), Object(external_this_wp_element_["createElement"])("span", { |
|
7140 key: "name", |
|
7141 className: "editor-autocompleters__user-name" |
|
7142 }, user.name), Object(external_this_wp_element_["createElement"])("span", { |
|
7143 key: "slug", |
|
7144 className: "editor-autocompleters__user-slug" |
|
7145 }, user.slug)]; |
|
7146 }, |
|
7147 getOptionCompletion: function getOptionCompletion(user) { |
|
7148 return "@".concat(user.slug); |
|
7149 } |
|
7150 }); |
|
7151 |
|
7152 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autocompleters/index.js |
|
7153 |
|
7154 |
|
7155 |
|
7156 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js |
|
7157 var esm_extends = __webpack_require__(19); |
|
7158 |
|
7159 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/objectWithoutProperties.js + 1 modules |
|
7160 var objectWithoutProperties = __webpack_require__(21); |
|
7161 |
|
7162 // EXTERNAL MODULE: external {"this":["wp","components"]} |
|
7163 var external_this_wp_components_ = __webpack_require__(4); |
|
7164 |
|
7165 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/server-side-render/index.js |
|
7166 |
|
7167 |
|
7168 |
|
7169 |
|
7170 |
|
7171 /** |
|
7172 * WordPress dependencies |
|
7173 */ |
|
7174 |
|
7175 |
|
7176 /* harmony default export */ var server_side_render = (function (_ref) { |
|
7177 var _ref$urlQueryArgs = _ref.urlQueryArgs, |
|
7178 urlQueryArgs = _ref$urlQueryArgs === void 0 ? {} : _ref$urlQueryArgs, |
|
7179 props = Object(objectWithoutProperties["a" /* default */])(_ref, ["urlQueryArgs"]); |
|
7180 |
|
7181 var _select = Object(external_this_wp_data_["select"])('core/editor'), |
|
7182 getCurrentPostId = _select.getCurrentPostId; |
|
7183 |
|
7184 urlQueryArgs = Object(objectSpread["a" /* default */])({ |
|
7185 post_id: getCurrentPostId() |
|
7186 }, urlQueryArgs); |
|
7187 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["ServerSideRender"], Object(esm_extends["a" /* default */])({ |
|
7188 urlQueryArgs: urlQueryArgs |
|
7189 }, props)); |
|
7190 }); |
|
7191 |
|
7192 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/classCallCheck.js |
|
7193 var classCallCheck = __webpack_require__(10); |
|
7194 |
|
7195 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/createClass.js |
|
7196 var createClass = __webpack_require__(9); |
|
7197 |
|
7198 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/possibleConstructorReturn.js |
|
7199 var possibleConstructorReturn = __webpack_require__(11); |
|
7200 |
|
7201 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/getPrototypeOf.js |
|
7202 var getPrototypeOf = __webpack_require__(12); |
|
7203 |
|
7204 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/inherits.js + 1 modules |
|
7205 var inherits = __webpack_require__(13); |
|
7206 |
|
7207 // EXTERNAL MODULE: external {"this":["wp","compose"]} |
|
7208 var external_this_wp_compose_ = __webpack_require__(6); |
|
7209 |
|
7210 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/autosave-monitor/index.js |
|
7211 |
|
7212 |
|
7213 |
|
7214 |
|
7215 |
|
7216 |
|
7217 /** |
|
7218 * WordPress dependencies |
|
7219 */ |
|
7220 |
|
7221 |
|
7222 |
|
7223 var autosave_monitor_AutosaveMonitor = |
|
7224 /*#__PURE__*/ |
|
7225 function (_Component) { |
|
7226 Object(inherits["a" /* default */])(AutosaveMonitor, _Component); |
|
7227 |
|
7228 function AutosaveMonitor() { |
|
7229 Object(classCallCheck["a" /* default */])(this, AutosaveMonitor); |
|
7230 |
|
7231 return Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(AutosaveMonitor).apply(this, arguments)); |
|
7232 } |
|
7233 |
|
7234 Object(createClass["a" /* default */])(AutosaveMonitor, [{ |
|
7235 key: "componentDidUpdate", |
|
7236 value: function componentDidUpdate(prevProps) { |
|
7237 var _this$props = this.props, |
|
7238 isDirty = _this$props.isDirty, |
|
7239 editsReference = _this$props.editsReference, |
|
7240 isAutosaveable = _this$props.isAutosaveable, |
|
7241 isAutosaving = _this$props.isAutosaving; // The edits reference is held for comparison to avoid scheduling an |
|
7242 // autosave if an edit has not been made since the last autosave |
|
7243 // completion. This is assigned when the autosave completes, and reset |
|
7244 // when an edit occurs. |
|
7245 // |
|
7246 // See: https://github.com/WordPress/gutenberg/issues/12318 |
|
7247 |
|
7248 if (editsReference !== prevProps.editsReference) { |
|
7249 this.didAutosaveForEditsReference = false; |
|
7250 } |
|
7251 |
|
7252 if (!isAutosaving && prevProps.isAutosaving) { |
|
7253 this.didAutosaveForEditsReference = true; |
|
7254 } |
|
7255 |
|
7256 if (prevProps.isDirty !== isDirty || prevProps.isAutosaveable !== isAutosaveable || prevProps.editsReference !== editsReference) { |
|
7257 this.toggleTimer(isDirty && isAutosaveable && !this.didAutosaveForEditsReference); |
|
7258 } |
|
7259 } |
|
7260 }, { |
|
7261 key: "componentWillUnmount", |
|
7262 value: function componentWillUnmount() { |
|
7263 this.toggleTimer(false); |
|
7264 } |
|
7265 }, { |
|
7266 key: "toggleTimer", |
|
7267 value: function toggleTimer(isPendingSave) { |
|
7268 var _this = this; |
|
7269 |
|
7270 clearTimeout(this.pendingSave); |
|
7271 var autosaveInterval = this.props.autosaveInterval; |
|
7272 |
|
7273 if (isPendingSave) { |
|
7274 this.pendingSave = setTimeout(function () { |
|
7275 return _this.props.autosave(); |
|
7276 }, autosaveInterval * 1000); |
|
7277 } |
|
7278 } |
|
7279 }, { |
|
7280 key: "render", |
|
7281 value: function render() { |
|
7282 return null; |
|
7283 } |
|
7284 }]); |
|
7285 |
|
7286 return AutosaveMonitor; |
|
7287 }(external_this_wp_element_["Component"]); |
|
7288 /* harmony default export */ var autosave_monitor = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
7289 var _select = select('core/editor'), |
|
7290 isEditedPostDirty = _select.isEditedPostDirty, |
|
7291 isEditedPostAutosaveable = _select.isEditedPostAutosaveable, |
|
7292 getReferenceByDistinctEdits = _select.getReferenceByDistinctEdits, |
|
7293 isAutosavingPost = _select.isAutosavingPost; |
|
7294 |
|
7295 var _select$getEditorSett = select('core/editor').getEditorSettings(), |
|
7296 autosaveInterval = _select$getEditorSett.autosaveInterval; |
|
7297 |
|
7298 return { |
|
7299 isDirty: isEditedPostDirty(), |
|
7300 isAutosaveable: isEditedPostAutosaveable(), |
|
7301 editsReference: getReferenceByDistinctEdits(), |
|
7302 isAutosaving: isAutosavingPost(), |
|
7303 autosaveInterval: autosaveInterval |
|
7304 }; |
|
7305 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
7306 return { |
|
7307 autosave: dispatch('core/editor').autosave |
|
7308 }; |
|
7309 })])(autosave_monitor_AutosaveMonitor)); |
|
7310 |
|
7311 // EXTERNAL MODULE: ./node_modules/classnames/index.js |
|
7312 var classnames = __webpack_require__(16); |
|
7313 var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames); |
|
7314 |
|
7315 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/document-outline/item.js |
|
7316 |
|
7317 |
|
7318 /** |
|
7319 * External dependencies |
|
7320 */ |
|
7321 |
|
7322 /** |
|
7323 * WordPress dependencies |
|
7324 */ |
|
7325 |
|
7326 |
|
7327 |
|
7328 var item_TableOfContentsItem = function TableOfContentsItem(_ref) { |
|
7329 var children = _ref.children, |
|
7330 isValid = _ref.isValid, |
|
7331 level = _ref.level, |
|
7332 _ref$path = _ref.path, |
|
7333 path = _ref$path === void 0 ? [] : _ref$path, |
|
7334 href = _ref.href, |
|
7335 onSelect = _ref.onSelect; |
|
7336 return Object(external_this_wp_element_["createElement"])("li", { |
|
7337 className: classnames_default()('document-outline__item', "is-".concat(level.toLowerCase()), { |
|
7338 'is-invalid': !isValid |
|
7339 }) |
|
7340 }, Object(external_this_wp_element_["createElement"])("a", { |
|
7341 href: href, |
|
7342 className: "document-outline__button", |
|
7343 onClick: onSelect |
|
7344 }, Object(external_this_wp_element_["createElement"])("span", { |
|
7345 className: "document-outline__emdash", |
|
7346 "aria-hidden": "true" |
|
7347 }), // path is an array of nodes that are ancestors of the heading starting in the top level node. |
|
7348 // This mapping renders each ancestor to make it easier for the user to know where the headings are nested. |
|
7349 path.map(function (_ref2, index) { |
|
7350 var clientId = _ref2.clientId; |
|
7351 return Object(external_this_wp_element_["createElement"])("strong", { |
|
7352 key: index, |
|
7353 className: "document-outline__level" |
|
7354 }, Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["BlockTitle"], { |
|
7355 clientId: clientId |
|
7356 })); |
|
7357 }), Object(external_this_wp_element_["createElement"])("strong", { |
|
7358 className: "document-outline__level" |
|
7359 }, level), Object(external_this_wp_element_["createElement"])("span", { |
|
7360 className: "document-outline__item-content" |
|
7361 }, children))); |
|
7362 }; |
|
7363 |
|
7364 /* harmony default export */ var document_outline_item = (item_TableOfContentsItem); |
|
7365 |
|
7366 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/document-outline/index.js |
|
7367 |
|
7368 |
|
7369 |
|
7370 |
|
7371 /** |
|
7372 * External dependencies |
|
7373 */ |
|
7374 |
|
7375 /** |
|
7376 * WordPress dependencies |
|
7377 */ |
|
7378 |
|
7379 |
|
7380 |
|
7381 |
|
7382 |
|
7383 /** |
|
7384 * Internal dependencies |
|
7385 */ |
|
7386 |
|
7387 |
|
7388 /** |
|
7389 * Module constants |
|
7390 */ |
|
7391 |
|
7392 var emptyHeadingContent = Object(external_this_wp_element_["createElement"])("em", null, Object(external_this_wp_i18n_["__"])('(Empty heading)')); |
|
7393 var incorrectLevelContent = [Object(external_this_wp_element_["createElement"])("br", { |
|
7394 key: "incorrect-break" |
|
7395 }), Object(external_this_wp_element_["createElement"])("em", { |
|
7396 key: "incorrect-message" |
|
7397 }, Object(external_this_wp_i18n_["__"])('(Incorrect heading level)'))]; |
|
7398 var singleH1Headings = [Object(external_this_wp_element_["createElement"])("br", { |
|
7399 key: "incorrect-break-h1" |
|
7400 }), Object(external_this_wp_element_["createElement"])("em", { |
|
7401 key: "incorrect-message-h1" |
|
7402 }, Object(external_this_wp_i18n_["__"])('(Your theme may already use a H1 for the post title)'))]; |
|
7403 var multipleH1Headings = [Object(external_this_wp_element_["createElement"])("br", { |
|
7404 key: "incorrect-break-multiple-h1" |
|
7405 }), Object(external_this_wp_element_["createElement"])("em", { |
|
7406 key: "incorrect-message-multiple-h1" |
|
7407 }, Object(external_this_wp_i18n_["__"])('(Multiple H1 headings are not recommended)'))]; |
|
7408 /** |
|
7409 * Returns an array of heading blocks enhanced with the following properties: |
|
7410 * path - An array of blocks that are ancestors of the heading starting from a top-level node. |
|
7411 * Can be an empty array if the heading is a top-level node (is not nested inside another block). |
|
7412 * level - An integer with the heading level. |
|
7413 * isEmpty - Flag indicating if the heading has no content. |
|
7414 * |
|
7415 * @param {?Array} blocks An array of blocks. |
|
7416 * @param {?Array} path An array of blocks that are ancestors of the blocks passed as blocks. |
|
7417 * |
|
7418 * @return {Array} An array of heading blocks enhanced with the properties described above. |
|
7419 */ |
|
7420 |
|
7421 var document_outline_computeOutlineHeadings = function computeOutlineHeadings() { |
|
7422 var blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
7423 var path = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; |
|
7424 return Object(external_lodash_["flatMap"])(blocks, function () { |
|
7425 var block = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
7426 |
|
7427 if (block.name === 'core/heading') { |
|
7428 return Object(objectSpread["a" /* default */])({}, block, { |
|
7429 path: path, |
|
7430 level: block.attributes.level, |
|
7431 isEmpty: isEmptyHeading(block) |
|
7432 }); |
|
7433 } |
|
7434 |
|
7435 return computeOutlineHeadings(block.innerBlocks, [].concat(Object(toConsumableArray["a" /* default */])(path), [block])); |
|
7436 }); |
|
7437 }; |
|
7438 |
|
7439 var isEmptyHeading = function isEmptyHeading(heading) { |
|
7440 return !heading.attributes.content || heading.attributes.content.length === 0; |
|
7441 }; |
|
7442 |
|
7443 var document_outline_DocumentOutline = function DocumentOutline(_ref) { |
|
7444 var _ref$blocks = _ref.blocks, |
|
7445 blocks = _ref$blocks === void 0 ? [] : _ref$blocks, |
|
7446 title = _ref.title, |
|
7447 onSelect = _ref.onSelect, |
|
7448 isTitleSupported = _ref.isTitleSupported, |
|
7449 hasOutlineItemsDisabled = _ref.hasOutlineItemsDisabled; |
|
7450 var headings = document_outline_computeOutlineHeadings(blocks); |
|
7451 |
|
7452 if (headings.length < 1) { |
|
7453 return null; |
|
7454 } |
|
7455 |
|
7456 var prevHeadingLevel = 1; // Not great but it's the simplest way to locate the title right now. |
|
7457 |
|
7458 var titleNode = document.querySelector('.editor-post-title__input'); |
|
7459 var hasTitle = isTitleSupported && title && titleNode; |
|
7460 var countByLevel = Object(external_lodash_["countBy"])(headings, 'level'); |
|
7461 var hasMultipleH1 = countByLevel[1] > 1; |
|
7462 return Object(external_this_wp_element_["createElement"])("div", { |
|
7463 className: "document-outline" |
|
7464 }, Object(external_this_wp_element_["createElement"])("ul", null, hasTitle && Object(external_this_wp_element_["createElement"])(document_outline_item, { |
|
7465 level: Object(external_this_wp_i18n_["__"])('Title'), |
|
7466 isValid: true, |
|
7467 onSelect: onSelect, |
|
7468 href: "#".concat(titleNode.id), |
|
7469 isDisabled: hasOutlineItemsDisabled |
|
7470 }, title), headings.map(function (item, index) { |
|
7471 // Headings remain the same, go up by one, or down by any amount. |
|
7472 // Otherwise there are missing levels. |
|
7473 var isIncorrectLevel = item.level > prevHeadingLevel + 1; |
|
7474 var isValid = !item.isEmpty && !isIncorrectLevel && !!item.level && (item.level !== 1 || !hasMultipleH1 && !hasTitle); |
|
7475 prevHeadingLevel = item.level; |
|
7476 return Object(external_this_wp_element_["createElement"])(document_outline_item, { |
|
7477 key: index, |
|
7478 level: "H".concat(item.level), |
|
7479 isValid: isValid, |
|
7480 path: item.path, |
|
7481 isDisabled: hasOutlineItemsDisabled, |
|
7482 href: "#block-".concat(item.clientId), |
|
7483 onSelect: onSelect |
|
7484 }, item.isEmpty ? emptyHeadingContent : Object(external_this_wp_richText_["getTextContent"])(Object(external_this_wp_richText_["create"])({ |
|
7485 html: item.attributes.content |
|
7486 })), isIncorrectLevel && incorrectLevelContent, item.level === 1 && hasMultipleH1 && multipleH1Headings, hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings); |
|
7487 }))); |
|
7488 }; |
|
7489 /* harmony default export */ var document_outline = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select) { |
|
7490 var _select = select('core/block-editor'), |
|
7491 getBlocks = _select.getBlocks; |
|
7492 |
|
7493 var _select2 = select('core/editor'), |
|
7494 getEditedPostAttribute = _select2.getEditedPostAttribute; |
|
7495 |
|
7496 var _select3 = select('core'), |
|
7497 getPostType = _select3.getPostType; |
|
7498 |
|
7499 var postType = getPostType(getEditedPostAttribute('type')); |
|
7500 return { |
|
7501 title: getEditedPostAttribute('title'), |
|
7502 blocks: getBlocks(), |
|
7503 isTitleSupported: Object(external_lodash_["get"])(postType, ['supports', 'title'], false) |
|
7504 }; |
|
7505 }))(document_outline_DocumentOutline)); |
|
7506 |
|
7507 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/document-outline/check.js |
|
7508 /** |
|
7509 * External dependencies |
|
7510 */ |
|
7511 |
|
7512 /** |
|
7513 * WordPress dependencies |
|
7514 */ |
|
7515 |
|
7516 |
|
7517 |
|
7518 function DocumentOutlineCheck(_ref) { |
|
7519 var blocks = _ref.blocks, |
|
7520 children = _ref.children; |
|
7521 var headings = Object(external_lodash_["filter"])(blocks, function (block) { |
|
7522 return block.name === 'core/heading'; |
|
7523 }); |
|
7524 |
|
7525 if (headings.length < 1) { |
|
7526 return null; |
|
7527 } |
|
7528 |
|
7529 return children; |
|
7530 } |
|
7531 |
|
7532 /* harmony default export */ var check = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
7533 return { |
|
7534 blocks: select('core/block-editor').getBlocks() |
|
7535 }; |
|
7536 })(DocumentOutlineCheck)); |
|
7537 |
|
7538 // EXTERNAL MODULE: ./node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js |
|
7539 var assertThisInitialized = __webpack_require__(3); |
|
7540 |
|
7541 // EXTERNAL MODULE: external {"this":["wp","keycodes"]} |
|
7542 var external_this_wp_keycodes_ = __webpack_require__(18); |
|
7543 |
|
7544 // EXTERNAL MODULE: external {"this":["wp","deprecated"]} |
|
7545 var external_this_wp_deprecated_ = __webpack_require__(49); |
|
7546 var external_this_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_this_wp_deprecated_); |
|
7547 |
|
7548 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/global-keyboard-shortcuts/save-shortcut.js |
|
7549 |
|
7550 |
|
7551 |
|
7552 /** |
|
7553 * WordPress dependencies |
|
7554 */ |
|
7555 |
|
7556 |
|
7557 |
|
7558 |
|
7559 function SaveShortcut(_ref) { |
|
7560 var onSave = _ref.onSave; |
|
7561 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["KeyboardShortcuts"], { |
|
7562 bindGlobal: true, |
|
7563 shortcuts: Object(defineProperty["a" /* default */])({}, external_this_wp_keycodes_["rawShortcut"].primary('s'), function (event) { |
|
7564 event.preventDefault(); |
|
7565 onSave(); |
|
7566 }) |
|
7567 }); |
|
7568 } |
|
7569 /* harmony default export */ var save_shortcut = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
7570 var _select = select('core/editor'), |
|
7571 isEditedPostDirty = _select.isEditedPostDirty; |
|
7572 |
|
7573 return { |
|
7574 isDirty: isEditedPostDirty() |
|
7575 }; |
|
7576 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, ownProps, _ref3) { |
|
7577 var select = _ref3.select; |
|
7578 |
|
7579 var _dispatch = dispatch('core/editor'), |
|
7580 savePost = _dispatch.savePost; |
|
7581 |
|
7582 return { |
|
7583 onSave: function onSave() { |
|
7584 // TODO: This should be handled in the `savePost` effect in |
|
7585 // considering `isSaveable`. See note on `isEditedPostSaveable` |
|
7586 // selector about dirtiness and meta-boxes. |
|
7587 // |
|
7588 // See: `isEditedPostSaveable` |
|
7589 var _select2 = select('core/editor'), |
|
7590 isEditedPostDirty = _select2.isEditedPostDirty; |
|
7591 |
|
7592 if (!isEditedPostDirty()) { |
|
7593 return; |
|
7594 } |
|
7595 |
|
7596 savePost(); |
|
7597 } |
|
7598 }; |
|
7599 })])(SaveShortcut)); |
|
7600 |
|
7601 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js |
|
7602 |
|
7603 |
|
7604 |
|
7605 |
|
7606 |
|
7607 |
|
7608 |
|
7609 |
|
7610 |
|
7611 /** |
|
7612 * WordPress dependencies |
|
7613 */ |
|
7614 |
|
7615 |
|
7616 |
|
7617 |
|
7618 |
|
7619 |
|
7620 /** |
|
7621 * Internal dependencies |
|
7622 */ |
|
7623 |
|
7624 |
|
7625 |
|
7626 var visual_editor_shortcuts_VisualEditorGlobalKeyboardShortcuts = |
|
7627 /*#__PURE__*/ |
|
7628 function (_Component) { |
|
7629 Object(inherits["a" /* default */])(VisualEditorGlobalKeyboardShortcuts, _Component); |
|
7630 |
|
7631 function VisualEditorGlobalKeyboardShortcuts() { |
|
7632 var _this; |
|
7633 |
|
7634 Object(classCallCheck["a" /* default */])(this, VisualEditorGlobalKeyboardShortcuts); |
|
7635 |
|
7636 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(VisualEditorGlobalKeyboardShortcuts).apply(this, arguments)); |
|
7637 _this.undoOrRedo = _this.undoOrRedo.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
7638 return _this; |
|
7639 } |
|
7640 |
|
7641 Object(createClass["a" /* default */])(VisualEditorGlobalKeyboardShortcuts, [{ |
|
7642 key: "undoOrRedo", |
|
7643 value: function undoOrRedo(event) { |
|
7644 var _this$props = this.props, |
|
7645 onRedo = _this$props.onRedo, |
|
7646 onUndo = _this$props.onUndo; |
|
7647 |
|
7648 if (event.shiftKey) { |
|
7649 onRedo(); |
|
7650 } else { |
|
7651 onUndo(); |
|
7652 } |
|
7653 |
|
7654 event.preventDefault(); |
|
7655 } |
|
7656 }, { |
|
7657 key: "render", |
|
7658 value: function render() { |
|
7659 var _ref; |
|
7660 |
|
7661 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["BlockEditorKeyboardShortcuts"], null), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["KeyboardShortcuts"], { |
|
7662 shortcuts: (_ref = {}, Object(defineProperty["a" /* default */])(_ref, external_this_wp_keycodes_["rawShortcut"].primary('z'), this.undoOrRedo), Object(defineProperty["a" /* default */])(_ref, external_this_wp_keycodes_["rawShortcut"].primaryShift('z'), this.undoOrRedo), _ref) |
|
7663 }), Object(external_this_wp_element_["createElement"])(save_shortcut, null)); |
|
7664 } |
|
7665 }]); |
|
7666 |
|
7667 return VisualEditorGlobalKeyboardShortcuts; |
|
7668 }(external_this_wp_element_["Component"]); |
|
7669 |
|
7670 var EnhancedVisualEditorGlobalKeyboardShortcuts = Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
7671 var _dispatch = dispatch('core/editor'), |
|
7672 redo = _dispatch.redo, |
|
7673 undo = _dispatch.undo; |
|
7674 |
|
7675 return { |
|
7676 onRedo: redo, |
|
7677 onUndo: undo |
|
7678 }; |
|
7679 })(visual_editor_shortcuts_VisualEditorGlobalKeyboardShortcuts); |
|
7680 /* harmony default export */ var visual_editor_shortcuts = (EnhancedVisualEditorGlobalKeyboardShortcuts); |
|
7681 function EditorGlobalKeyboardShortcuts() { |
|
7682 external_this_wp_deprecated_default()('EditorGlobalKeyboardShortcuts', { |
|
7683 alternative: 'VisualEditorGlobalKeyboardShortcuts', |
|
7684 plugin: 'Gutenberg' |
|
7685 }); |
|
7686 return Object(external_this_wp_element_["createElement"])(EnhancedVisualEditorGlobalKeyboardShortcuts, null); |
|
7687 } |
|
7688 |
|
7689 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/global-keyboard-shortcuts/text-editor-shortcuts.js |
|
7690 |
|
7691 |
|
7692 /** |
|
7693 * Internal dependencies |
|
7694 */ |
|
7695 |
|
7696 function TextEditorGlobalKeyboardShortcuts() { |
|
7697 return Object(external_this_wp_element_["createElement"])(save_shortcut, null); |
|
7698 } |
|
7699 |
|
7700 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/editor-history/redo.js |
|
7701 |
|
7702 |
|
7703 /** |
|
7704 * WordPress dependencies |
|
7705 */ |
|
7706 |
|
7707 |
|
7708 |
|
7709 |
|
7710 |
|
7711 |
|
7712 function EditorHistoryRedo(_ref) { |
|
7713 var hasRedo = _ref.hasRedo, |
|
7714 redo = _ref.redo; |
|
7715 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
7716 icon: "redo", |
|
7717 label: Object(external_this_wp_i18n_["__"])('Redo'), |
|
7718 shortcut: external_this_wp_keycodes_["displayShortcut"].primaryShift('z') // If there are no redo levels we don't want to actually disable this |
|
7719 // button, because it will remove focus for keyboard users. |
|
7720 // See: https://github.com/WordPress/gutenberg/issues/3486 |
|
7721 , |
|
7722 "aria-disabled": !hasRedo, |
|
7723 onClick: hasRedo ? redo : undefined, |
|
7724 className: "editor-history__redo" |
|
7725 }); |
|
7726 } |
|
7727 |
|
7728 /* harmony default export */ var editor_history_redo = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
7729 return { |
|
7730 hasRedo: select('core/editor').hasEditorRedo() |
|
7731 }; |
|
7732 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
7733 return { |
|
7734 redo: dispatch('core/editor').redo |
|
7735 }; |
|
7736 })])(EditorHistoryRedo)); |
|
7737 |
|
7738 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/editor-history/undo.js |
|
7739 |
|
7740 |
|
7741 /** |
|
7742 * WordPress dependencies |
|
7743 */ |
|
7744 |
|
7745 |
|
7746 |
|
7747 |
|
7748 |
|
7749 |
|
7750 function EditorHistoryUndo(_ref) { |
|
7751 var hasUndo = _ref.hasUndo, |
|
7752 undo = _ref.undo; |
|
7753 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
7754 icon: "undo", |
|
7755 label: Object(external_this_wp_i18n_["__"])('Undo'), |
|
7756 shortcut: external_this_wp_keycodes_["displayShortcut"].primary('z') // If there are no undo levels we don't want to actually disable this |
|
7757 // button, because it will remove focus for keyboard users. |
|
7758 // See: https://github.com/WordPress/gutenberg/issues/3486 |
|
7759 , |
|
7760 "aria-disabled": !hasUndo, |
|
7761 onClick: hasUndo ? undo : undefined, |
|
7762 className: "editor-history__undo" |
|
7763 }); |
|
7764 } |
|
7765 |
|
7766 /* harmony default export */ var editor_history_undo = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
7767 return { |
|
7768 hasUndo: select('core/editor').hasEditorUndo() |
|
7769 }; |
|
7770 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
7771 return { |
|
7772 undo: dispatch('core/editor').undo |
|
7773 }; |
|
7774 })])(EditorHistoryUndo)); |
|
7775 |
|
7776 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/template-validation-notice/index.js |
|
7777 |
|
7778 |
|
7779 |
|
7780 /** |
|
7781 * WordPress dependencies |
|
7782 */ |
|
7783 |
|
7784 |
|
7785 |
|
7786 |
|
7787 |
|
7788 function TemplateValidationNotice(_ref) { |
|
7789 var isValid = _ref.isValid, |
|
7790 props = Object(objectWithoutProperties["a" /* default */])(_ref, ["isValid"]); |
|
7791 |
|
7792 if (isValid) { |
|
7793 return null; |
|
7794 } |
|
7795 |
|
7796 var confirmSynchronization = function confirmSynchronization() { |
|
7797 // eslint-disable-next-line no-alert |
|
7798 if (window.confirm(Object(external_this_wp_i18n_["__"])('Resetting the template may result in loss of content, do you want to continue?'))) { |
|
7799 props.synchronizeTemplate(); |
|
7800 } |
|
7801 }; |
|
7802 |
|
7803 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Notice"], { |
|
7804 className: "editor-template-validation-notice", |
|
7805 isDismissible: false, |
|
7806 status: "warning" |
|
7807 }, Object(external_this_wp_element_["createElement"])("p", null, Object(external_this_wp_i18n_["__"])('The content of your post doesn’t match the template assigned to your post type.')), Object(external_this_wp_element_["createElement"])("div", null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
7808 isDefault: true, |
|
7809 onClick: props.resetTemplateValidity |
|
7810 }, Object(external_this_wp_i18n_["__"])('Keep it as is')), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
7811 onClick: confirmSynchronization, |
|
7812 isPrimary: true |
|
7813 }, Object(external_this_wp_i18n_["__"])('Reset the template')))); |
|
7814 } |
|
7815 |
|
7816 /* harmony default export */ var template_validation_notice = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
7817 return { |
|
7818 isValid: select('core/block-editor').isValidTemplate() |
|
7819 }; |
|
7820 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
7821 var _dispatch = dispatch('core/block-editor'), |
|
7822 setTemplateValidity = _dispatch.setTemplateValidity, |
|
7823 synchronizeTemplate = _dispatch.synchronizeTemplate; |
|
7824 |
|
7825 return { |
|
7826 resetTemplateValidity: function resetTemplateValidity() { |
|
7827 return setTemplateValidity(true); |
|
7828 }, |
|
7829 synchronizeTemplate: synchronizeTemplate |
|
7830 }; |
|
7831 })])(TemplateValidationNotice)); |
|
7832 |
|
7833 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/editor-notices/index.js |
|
7834 |
|
7835 |
|
7836 |
|
7837 |
|
7838 /** |
|
7839 * External dependencies |
|
7840 */ |
|
7841 |
|
7842 /** |
|
7843 * WordPress dependencies |
|
7844 */ |
|
7845 |
|
7846 |
|
7847 |
|
7848 |
|
7849 /** |
|
7850 * Internal dependencies |
|
7851 */ |
|
7852 |
|
7853 |
|
7854 function EditorNotices(_ref) { |
|
7855 var dismissible = _ref.dismissible, |
|
7856 notices = _ref.notices, |
|
7857 props = Object(objectWithoutProperties["a" /* default */])(_ref, ["dismissible", "notices"]); |
|
7858 |
|
7859 if (dismissible !== undefined) { |
|
7860 notices = Object(external_lodash_["filter"])(notices, { |
|
7861 isDismissible: dismissible |
|
7862 }); |
|
7863 } |
|
7864 |
|
7865 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["NoticeList"], Object(esm_extends["a" /* default */])({ |
|
7866 notices: notices |
|
7867 }, props), dismissible !== false && Object(external_this_wp_element_["createElement"])(template_validation_notice, null)); |
|
7868 } |
|
7869 /* harmony default export */ var editor_notices = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
7870 return { |
|
7871 notices: select('core/notices').getNotices() |
|
7872 }; |
|
7873 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
7874 return { |
|
7875 onRemove: dispatch('core/notices').removeNotice |
|
7876 }; |
|
7877 })])(EditorNotices)); |
|
7878 |
|
7879 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/error-boundary/index.js |
|
7880 |
|
7881 |
|
7882 |
|
7883 |
|
7884 |
|
7885 |
|
7886 |
|
7887 |
|
7888 /** |
|
7889 * WordPress dependencies |
|
7890 */ |
|
7891 |
|
7892 |
|
7893 |
|
7894 |
|
7895 |
|
7896 |
|
7897 var error_boundary_ErrorBoundary = |
|
7898 /*#__PURE__*/ |
|
7899 function (_Component) { |
|
7900 Object(inherits["a" /* default */])(ErrorBoundary, _Component); |
|
7901 |
|
7902 function ErrorBoundary() { |
|
7903 var _this; |
|
7904 |
|
7905 Object(classCallCheck["a" /* default */])(this, ErrorBoundary); |
|
7906 |
|
7907 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(ErrorBoundary).apply(this, arguments)); |
|
7908 _this.reboot = _this.reboot.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
7909 _this.getContent = _this.getContent.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
7910 _this.state = { |
|
7911 error: null |
|
7912 }; |
|
7913 return _this; |
|
7914 } |
|
7915 |
|
7916 Object(createClass["a" /* default */])(ErrorBoundary, [{ |
|
7917 key: "componentDidCatch", |
|
7918 value: function componentDidCatch(error) { |
|
7919 this.setState({ |
|
7920 error: error |
|
7921 }); |
|
7922 } |
|
7923 }, { |
|
7924 key: "reboot", |
|
7925 value: function reboot() { |
|
7926 this.props.onError(); |
|
7927 } |
|
7928 }, { |
|
7929 key: "getContent", |
|
7930 value: function getContent() { |
|
7931 try { |
|
7932 // While `select` in a component is generally discouraged, it is |
|
7933 // used here because it (a) reduces the chance of data loss in the |
|
7934 // case of additional errors by performing a direct retrieval and |
|
7935 // (b) avoids the performance cost associated with unnecessary |
|
7936 // content serialization throughout the lifetime of a non-erroring |
|
7937 // application. |
|
7938 return Object(external_this_wp_data_["select"])('core/editor').getEditedPostContent(); |
|
7939 } catch (error) {} |
|
7940 } |
|
7941 }, { |
|
7942 key: "render", |
|
7943 value: function render() { |
|
7944 var error = this.state.error; |
|
7945 |
|
7946 if (!error) { |
|
7947 return this.props.children; |
|
7948 } |
|
7949 |
|
7950 return Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["Warning"], { |
|
7951 className: "editor-error-boundary", |
|
7952 actions: [Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
7953 key: "recovery", |
|
7954 onClick: this.reboot, |
|
7955 isLarge: true |
|
7956 }, Object(external_this_wp_i18n_["__"])('Attempt Recovery')), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["ClipboardButton"], { |
|
7957 key: "copy-post", |
|
7958 text: this.getContent, |
|
7959 isLarge: true |
|
7960 }, Object(external_this_wp_i18n_["__"])('Copy Post Text')), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["ClipboardButton"], { |
|
7961 key: "copy-error", |
|
7962 text: error.stack, |
|
7963 isLarge: true |
|
7964 }, Object(external_this_wp_i18n_["__"])('Copy Error'))] |
|
7965 }, Object(external_this_wp_i18n_["__"])('The editor has encountered an unexpected error.')); |
|
7966 } |
|
7967 }]); |
|
7968 |
|
7969 return ErrorBoundary; |
|
7970 }(external_this_wp_element_["Component"]); |
|
7971 |
|
7972 /* harmony default export */ var error_boundary = (error_boundary_ErrorBoundary); |
|
7973 |
|
7974 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/page-attributes/check.js |
|
7975 /** |
|
7976 * External dependencies |
|
7977 */ |
|
7978 |
|
7979 /** |
|
7980 * WordPress dependencies |
|
7981 */ |
|
7982 |
|
7983 |
|
7984 function PageAttributesCheck(_ref) { |
|
7985 var availableTemplates = _ref.availableTemplates, |
|
7986 postType = _ref.postType, |
|
7987 children = _ref.children; |
|
7988 var supportsPageAttributes = Object(external_lodash_["get"])(postType, ['supports', 'page-attributes'], false); // Only render fields if post type supports page attributes or available templates exist. |
|
7989 |
|
7990 if (!supportsPageAttributes && Object(external_lodash_["isEmpty"])(availableTemplates)) { |
|
7991 return null; |
|
7992 } |
|
7993 |
|
7994 return children; |
|
7995 } |
|
7996 /* harmony default export */ var page_attributes_check = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
7997 var _select = select('core/editor'), |
|
7998 getEditedPostAttribute = _select.getEditedPostAttribute, |
|
7999 getEditorSettings = _select.getEditorSettings; |
|
8000 |
|
8001 var _select2 = select('core'), |
|
8002 getPostType = _select2.getPostType; |
|
8003 |
|
8004 var _getEditorSettings = getEditorSettings(), |
|
8005 availableTemplates = _getEditorSettings.availableTemplates; |
|
8006 |
|
8007 return { |
|
8008 postType: getPostType(getEditedPostAttribute('type')), |
|
8009 availableTemplates: availableTemplates |
|
8010 }; |
|
8011 })(PageAttributesCheck)); |
|
8012 |
|
8013 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-type-support-check/index.js |
|
8014 /** |
|
8015 * External dependencies |
|
8016 */ |
|
8017 |
|
8018 /** |
|
8019 * WordPress dependencies |
|
8020 */ |
|
8021 |
|
8022 |
|
8023 /** |
|
8024 * A component which renders its own children only if the current editor post |
|
8025 * type supports one of the given `supportKeys` prop. |
|
8026 * |
|
8027 * @param {?Object} props.postType Current post type. |
|
8028 * @param {WPElement} props.children Children to be rendered if post |
|
8029 * type supports. |
|
8030 * @param {(string|string[])} props.supportKeys String or string array of keys |
|
8031 * to test. |
|
8032 * |
|
8033 * @return {WPElement} Rendered element. |
|
8034 */ |
|
8035 |
|
8036 function PostTypeSupportCheck(_ref) { |
|
8037 var postType = _ref.postType, |
|
8038 children = _ref.children, |
|
8039 supportKeys = _ref.supportKeys; |
|
8040 var isSupported = true; |
|
8041 |
|
8042 if (postType) { |
|
8043 isSupported = Object(external_lodash_["some"])(Object(external_lodash_["castArray"])(supportKeys), function (key) { |
|
8044 return !!postType.supports[key]; |
|
8045 }); |
|
8046 } |
|
8047 |
|
8048 if (!isSupported) { |
|
8049 return null; |
|
8050 } |
|
8051 |
|
8052 return children; |
|
8053 } |
|
8054 /* harmony default export */ var post_type_support_check = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8055 var _select = select('core/editor'), |
|
8056 getEditedPostAttribute = _select.getEditedPostAttribute; |
|
8057 |
|
8058 var _select2 = select('core'), |
|
8059 getPostType = _select2.getPostType; |
|
8060 |
|
8061 return { |
|
8062 postType: getPostType(getEditedPostAttribute('type')) |
|
8063 }; |
|
8064 })(PostTypeSupportCheck)); |
|
8065 |
|
8066 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/page-attributes/order.js |
|
8067 |
|
8068 |
|
8069 /** |
|
8070 * External dependencies |
|
8071 */ |
|
8072 |
|
8073 /** |
|
8074 * WordPress dependencies |
|
8075 */ |
|
8076 |
|
8077 |
|
8078 |
|
8079 |
|
8080 |
|
8081 /** |
|
8082 * Internal dependencies |
|
8083 */ |
|
8084 |
|
8085 |
|
8086 var PageAttributesOrder = Object(external_this_wp_compose_["withState"])({ |
|
8087 orderInput: null |
|
8088 })(function (_ref) { |
|
8089 var onUpdateOrder = _ref.onUpdateOrder, |
|
8090 _ref$order = _ref.order, |
|
8091 order = _ref$order === void 0 ? 0 : _ref$order, |
|
8092 orderInput = _ref.orderInput, |
|
8093 setState = _ref.setState; |
|
8094 |
|
8095 var setUpdatedOrder = function setUpdatedOrder(value) { |
|
8096 setState({ |
|
8097 orderInput: value |
|
8098 }); |
|
8099 var newOrder = Number(value); |
|
8100 |
|
8101 if (Number.isInteger(newOrder) && Object(external_lodash_["invoke"])(value, ['trim']) !== '') { |
|
8102 onUpdateOrder(Number(value)); |
|
8103 } |
|
8104 }; |
|
8105 |
|
8106 var value = orderInput === null ? order : orderInput; |
|
8107 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["TextControl"], { |
|
8108 className: "editor-page-attributes__order", |
|
8109 type: "number", |
|
8110 label: Object(external_this_wp_i18n_["__"])('Order'), |
|
8111 value: value, |
|
8112 onChange: setUpdatedOrder, |
|
8113 size: 6, |
|
8114 onBlur: function onBlur() { |
|
8115 setState({ |
|
8116 orderInput: null |
|
8117 }); |
|
8118 } |
|
8119 }); |
|
8120 }); |
|
8121 |
|
8122 function PageAttributesOrderWithChecks(props) { |
|
8123 return Object(external_this_wp_element_["createElement"])(post_type_support_check, { |
|
8124 supportKeys: "page-attributes" |
|
8125 }, Object(external_this_wp_element_["createElement"])(PageAttributesOrder, props)); |
|
8126 } |
|
8127 |
|
8128 /* harmony default export */ var page_attributes_order = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8129 return { |
|
8130 order: select('core/editor').getEditedPostAttribute('menu_order') |
|
8131 }; |
|
8132 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
8133 return { |
|
8134 onUpdateOrder: function onUpdateOrder(order) { |
|
8135 dispatch('core/editor').editPost({ |
|
8136 menu_order: order |
|
8137 }); |
|
8138 } |
|
8139 }; |
|
8140 })])(PageAttributesOrderWithChecks)); |
|
8141 |
|
8142 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/terms.js |
|
8143 |
|
8144 |
|
8145 /** |
|
8146 * External dependencies |
|
8147 */ |
|
8148 |
|
8149 /** |
|
8150 * Returns terms in a tree form. |
|
8151 * |
|
8152 * @param {Array} flatTerms Array of terms in flat format. |
|
8153 * |
|
8154 * @return {Array} Array of terms in tree format. |
|
8155 */ |
|
8156 |
|
8157 function buildTermsTree(flatTerms) { |
|
8158 var flatTermsWithParentAndChildren = flatTerms.map(function (term) { |
|
8159 return Object(objectSpread["a" /* default */])({ |
|
8160 children: [], |
|
8161 parent: null |
|
8162 }, term); |
|
8163 }); |
|
8164 var termsByParent = Object(external_lodash_["groupBy"])(flatTermsWithParentAndChildren, 'parent'); |
|
8165 |
|
8166 if (termsByParent.null && termsByParent.null.length) { |
|
8167 return flatTermsWithParentAndChildren; |
|
8168 } |
|
8169 |
|
8170 var fillWithChildren = function fillWithChildren(terms) { |
|
8171 return terms.map(function (term) { |
|
8172 var children = termsByParent[term.id]; |
|
8173 return Object(objectSpread["a" /* default */])({}, term, { |
|
8174 children: children && children.length ? fillWithChildren(children) : [] |
|
8175 }); |
|
8176 }); |
|
8177 }; |
|
8178 |
|
8179 return fillWithChildren(termsByParent['0'] || []); |
|
8180 } |
|
8181 |
|
8182 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/page-attributes/parent.js |
|
8183 |
|
8184 |
|
8185 /** |
|
8186 * External dependencies |
|
8187 */ |
|
8188 |
|
8189 /** |
|
8190 * WordPress dependencies |
|
8191 */ |
|
8192 |
|
8193 |
|
8194 |
|
8195 |
|
8196 |
|
8197 /** |
|
8198 * Internal dependencies |
|
8199 */ |
|
8200 |
|
8201 |
|
8202 function PageAttributesParent(_ref) { |
|
8203 var parent = _ref.parent, |
|
8204 postType = _ref.postType, |
|
8205 items = _ref.items, |
|
8206 onUpdateParent = _ref.onUpdateParent; |
|
8207 var isHierarchical = Object(external_lodash_["get"])(postType, ['hierarchical'], false); |
|
8208 var parentPageLabel = Object(external_lodash_["get"])(postType, ['labels', 'parent_item_colon']); |
|
8209 var pageItems = items || []; |
|
8210 |
|
8211 if (!isHierarchical || !parentPageLabel || !pageItems.length) { |
|
8212 return null; |
|
8213 } |
|
8214 |
|
8215 var pagesTree = buildTermsTree(pageItems.map(function (item) { |
|
8216 return { |
|
8217 id: item.id, |
|
8218 parent: item.parent, |
|
8219 name: item.title.raw ? item.title.raw : "#".concat(item.id, " (").concat(Object(external_this_wp_i18n_["__"])('no title'), ")") |
|
8220 }; |
|
8221 })); |
|
8222 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["TreeSelect"], { |
|
8223 className: "editor-page-attributes__parent", |
|
8224 label: parentPageLabel, |
|
8225 noOptionLabel: "(".concat(Object(external_this_wp_i18n_["__"])('no parent'), ")"), |
|
8226 tree: pagesTree, |
|
8227 selectedId: parent, |
|
8228 onChange: onUpdateParent |
|
8229 }); |
|
8230 } |
|
8231 var applyWithSelect = Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8232 var _select = select('core'), |
|
8233 getPostType = _select.getPostType, |
|
8234 getEntityRecords = _select.getEntityRecords; |
|
8235 |
|
8236 var _select2 = select('core/editor'), |
|
8237 getCurrentPostId = _select2.getCurrentPostId, |
|
8238 getEditedPostAttribute = _select2.getEditedPostAttribute; |
|
8239 |
|
8240 var postTypeSlug = getEditedPostAttribute('type'); |
|
8241 var postType = getPostType(postTypeSlug); |
|
8242 var postId = getCurrentPostId(); |
|
8243 var isHierarchical = Object(external_lodash_["get"])(postType, ['hierarchical'], false); |
|
8244 var query = { |
|
8245 per_page: -1, |
|
8246 exclude: postId, |
|
8247 parent_exclude: postId, |
|
8248 orderby: 'menu_order', |
|
8249 order: 'asc' |
|
8250 }; |
|
8251 return { |
|
8252 parent: getEditedPostAttribute('parent'), |
|
8253 items: isHierarchical ? getEntityRecords('postType', postTypeSlug, query) : [], |
|
8254 postType: postType |
|
8255 }; |
|
8256 }); |
|
8257 var applyWithDispatch = Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
8258 var _dispatch = dispatch('core/editor'), |
|
8259 editPost = _dispatch.editPost; |
|
8260 |
|
8261 return { |
|
8262 onUpdateParent: function onUpdateParent(parent) { |
|
8263 editPost({ |
|
8264 parent: parent || 0 |
|
8265 }); |
|
8266 } |
|
8267 }; |
|
8268 }); |
|
8269 /* harmony default export */ var page_attributes_parent = (Object(external_this_wp_compose_["compose"])([applyWithSelect, applyWithDispatch])(PageAttributesParent)); |
|
8270 |
|
8271 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/page-attributes/template.js |
|
8272 |
|
8273 |
|
8274 /** |
|
8275 * External dependencies |
|
8276 */ |
|
8277 |
|
8278 /** |
|
8279 * WordPress dependencies |
|
8280 */ |
|
8281 |
|
8282 |
|
8283 |
|
8284 |
|
8285 |
|
8286 function PageTemplate(_ref) { |
|
8287 var availableTemplates = _ref.availableTemplates, |
|
8288 selectedTemplate = _ref.selectedTemplate, |
|
8289 onUpdate = _ref.onUpdate; |
|
8290 |
|
8291 if (Object(external_lodash_["isEmpty"])(availableTemplates)) { |
|
8292 return null; |
|
8293 } |
|
8294 |
|
8295 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["SelectControl"], { |
|
8296 label: Object(external_this_wp_i18n_["__"])('Template:'), |
|
8297 value: selectedTemplate, |
|
8298 onChange: onUpdate, |
|
8299 className: "editor-page-attributes__template", |
|
8300 options: Object(external_lodash_["map"])(availableTemplates, function (templateName, templateSlug) { |
|
8301 return { |
|
8302 value: templateSlug, |
|
8303 label: templateName |
|
8304 }; |
|
8305 }) |
|
8306 }); |
|
8307 } |
|
8308 /* harmony default export */ var page_attributes_template = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8309 var _select = select('core/editor'), |
|
8310 getEditedPostAttribute = _select.getEditedPostAttribute, |
|
8311 getEditorSettings = _select.getEditorSettings; |
|
8312 |
|
8313 var _getEditorSettings = getEditorSettings(), |
|
8314 availableTemplates = _getEditorSettings.availableTemplates; |
|
8315 |
|
8316 return { |
|
8317 selectedTemplate: getEditedPostAttribute('template'), |
|
8318 availableTemplates: availableTemplates |
|
8319 }; |
|
8320 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
8321 return { |
|
8322 onUpdate: function onUpdate(templateSlug) { |
|
8323 dispatch('core/editor').editPost({ |
|
8324 template: templateSlug || '' |
|
8325 }); |
|
8326 } |
|
8327 }; |
|
8328 }))(PageTemplate)); |
|
8329 |
|
8330 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/check.js |
|
8331 |
|
8332 |
|
8333 /** |
|
8334 * External dependencies |
|
8335 */ |
|
8336 |
|
8337 /** |
|
8338 * WordPress dependencies |
|
8339 */ |
|
8340 |
|
8341 |
|
8342 |
|
8343 /** |
|
8344 * Internal dependencies |
|
8345 */ |
|
8346 |
|
8347 |
|
8348 function PostAuthorCheck(_ref) { |
|
8349 var hasAssignAuthorAction = _ref.hasAssignAuthorAction, |
|
8350 authors = _ref.authors, |
|
8351 children = _ref.children; |
|
8352 |
|
8353 if (!hasAssignAuthorAction || authors.length < 2) { |
|
8354 return null; |
|
8355 } |
|
8356 |
|
8357 return Object(external_this_wp_element_["createElement"])(post_type_support_check, { |
|
8358 supportKeys: "author" |
|
8359 }, children); |
|
8360 } |
|
8361 /* harmony default export */ var post_author_check = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8362 var post = select('core/editor').getCurrentPost(); |
|
8363 return { |
|
8364 hasAssignAuthorAction: Object(external_lodash_["get"])(post, ['_links', 'wp:action-assign-author'], false), |
|
8365 postType: select('core/editor').getCurrentPostType(), |
|
8366 authors: select('core').getAuthors() |
|
8367 }; |
|
8368 }), external_this_wp_compose_["withInstanceId"]])(PostAuthorCheck)); |
|
8369 |
|
8370 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-author/index.js |
|
8371 |
|
8372 |
|
8373 |
|
8374 |
|
8375 |
|
8376 |
|
8377 |
|
8378 |
|
8379 /** |
|
8380 * WordPress dependencies |
|
8381 */ |
|
8382 |
|
8383 |
|
8384 |
|
8385 |
|
8386 /** |
|
8387 * Internal dependencies |
|
8388 */ |
|
8389 |
|
8390 |
|
8391 var post_author_PostAuthor = |
|
8392 /*#__PURE__*/ |
|
8393 function (_Component) { |
|
8394 Object(inherits["a" /* default */])(PostAuthor, _Component); |
|
8395 |
|
8396 function PostAuthor() { |
|
8397 var _this; |
|
8398 |
|
8399 Object(classCallCheck["a" /* default */])(this, PostAuthor); |
|
8400 |
|
8401 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(PostAuthor).apply(this, arguments)); |
|
8402 _this.setAuthorId = _this.setAuthorId.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
8403 return _this; |
|
8404 } |
|
8405 |
|
8406 Object(createClass["a" /* default */])(PostAuthor, [{ |
|
8407 key: "setAuthorId", |
|
8408 value: function setAuthorId(event) { |
|
8409 var onUpdateAuthor = this.props.onUpdateAuthor; |
|
8410 var value = event.target.value; |
|
8411 onUpdateAuthor(Number(value)); |
|
8412 } |
|
8413 }, { |
|
8414 key: "render", |
|
8415 value: function render() { |
|
8416 var _this$props = this.props, |
|
8417 postAuthor = _this$props.postAuthor, |
|
8418 instanceId = _this$props.instanceId, |
|
8419 authors = _this$props.authors; |
|
8420 var selectId = 'post-author-selector-' + instanceId; // Disable reason: A select with an onchange throws a warning |
|
8421 |
|
8422 /* eslint-disable jsx-a11y/no-onchange */ |
|
8423 |
|
8424 return Object(external_this_wp_element_["createElement"])(post_author_check, null, Object(external_this_wp_element_["createElement"])("label", { |
|
8425 htmlFor: selectId |
|
8426 }, Object(external_this_wp_i18n_["__"])('Author')), Object(external_this_wp_element_["createElement"])("select", { |
|
8427 id: selectId, |
|
8428 value: postAuthor, |
|
8429 onChange: this.setAuthorId, |
|
8430 className: "editor-post-author__select" |
|
8431 }, authors.map(function (author) { |
|
8432 return Object(external_this_wp_element_["createElement"])("option", { |
|
8433 key: author.id, |
|
8434 value: author.id |
|
8435 }, author.name); |
|
8436 }))); |
|
8437 /* eslint-enable jsx-a11y/no-onchange */ |
|
8438 } |
|
8439 }]); |
|
8440 |
|
8441 return PostAuthor; |
|
8442 }(external_this_wp_element_["Component"]); |
|
8443 /* harmony default export */ var post_author = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8444 return { |
|
8445 postAuthor: select('core/editor').getEditedPostAttribute('author'), |
|
8446 authors: select('core').getAuthors() |
|
8447 }; |
|
8448 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
8449 return { |
|
8450 onUpdateAuthor: function onUpdateAuthor(author) { |
|
8451 dispatch('core/editor').editPost({ |
|
8452 author: author |
|
8453 }); |
|
8454 } |
|
8455 }; |
|
8456 }), external_this_wp_compose_["withInstanceId"]])(post_author_PostAuthor)); |
|
8457 |
|
8458 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-comments/index.js |
|
8459 |
|
8460 |
|
8461 |
|
8462 /** |
|
8463 * WordPress dependencies |
|
8464 */ |
|
8465 |
|
8466 |
|
8467 |
|
8468 |
|
8469 |
|
8470 function PostComments(_ref) { |
|
8471 var _ref$commentStatus = _ref.commentStatus, |
|
8472 commentStatus = _ref$commentStatus === void 0 ? 'open' : _ref$commentStatus, |
|
8473 props = Object(objectWithoutProperties["a" /* default */])(_ref, ["commentStatus"]); |
|
8474 |
|
8475 var onToggleComments = function onToggleComments() { |
|
8476 return props.editPost({ |
|
8477 comment_status: commentStatus === 'open' ? 'closed' : 'open' |
|
8478 }); |
|
8479 }; |
|
8480 |
|
8481 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["CheckboxControl"], { |
|
8482 label: Object(external_this_wp_i18n_["__"])('Allow Comments'), |
|
8483 checked: commentStatus === 'open', |
|
8484 onChange: onToggleComments |
|
8485 }); |
|
8486 } |
|
8487 |
|
8488 /* harmony default export */ var post_comments = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8489 return { |
|
8490 commentStatus: select('core/editor').getEditedPostAttribute('comment_status') |
|
8491 }; |
|
8492 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
8493 return { |
|
8494 editPost: dispatch('core/editor').editPost |
|
8495 }; |
|
8496 })])(PostComments)); |
|
8497 |
|
8498 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-excerpt/index.js |
|
8499 |
|
8500 |
|
8501 /** |
|
8502 * WordPress dependencies |
|
8503 */ |
|
8504 |
|
8505 |
|
8506 |
|
8507 |
|
8508 |
|
8509 function PostExcerpt(_ref) { |
|
8510 var excerpt = _ref.excerpt, |
|
8511 onUpdateExcerpt = _ref.onUpdateExcerpt; |
|
8512 return Object(external_this_wp_element_["createElement"])("div", { |
|
8513 className: "editor-post-excerpt" |
|
8514 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["TextareaControl"], { |
|
8515 label: Object(external_this_wp_i18n_["__"])('Write an excerpt (optional)'), |
|
8516 className: "editor-post-excerpt__textarea", |
|
8517 onChange: function onChange(value) { |
|
8518 return onUpdateExcerpt(value); |
|
8519 }, |
|
8520 value: excerpt |
|
8521 }), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["ExternalLink"], { |
|
8522 href: Object(external_this_wp_i18n_["__"])('https://codex.wordpress.org/Excerpt') |
|
8523 }, Object(external_this_wp_i18n_["__"])('Learn more about manual excerpts'))); |
|
8524 } |
|
8525 |
|
8526 /* harmony default export */ var post_excerpt = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8527 return { |
|
8528 excerpt: select('core/editor').getEditedPostAttribute('excerpt') |
|
8529 }; |
|
8530 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
8531 return { |
|
8532 onUpdateExcerpt: function onUpdateExcerpt(excerpt) { |
|
8533 dispatch('core/editor').editPost({ |
|
8534 excerpt: excerpt |
|
8535 }); |
|
8536 } |
|
8537 }; |
|
8538 })])(PostExcerpt)); |
|
8539 |
|
8540 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-excerpt/check.js |
|
8541 |
|
8542 |
|
8543 |
|
8544 /** |
|
8545 * Internal dependencies |
|
8546 */ |
|
8547 |
|
8548 |
|
8549 function PostExcerptCheck(props) { |
|
8550 return Object(external_this_wp_element_["createElement"])(post_type_support_check, Object(esm_extends["a" /* default */])({}, props, { |
|
8551 supportKeys: "excerpt" |
|
8552 })); |
|
8553 } |
|
8554 |
|
8555 /* harmony default export */ var post_excerpt_check = (PostExcerptCheck); |
|
8556 |
|
8557 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/theme-support-check/index.js |
|
8558 /** |
|
8559 * External dependencies |
|
8560 */ |
|
8561 |
|
8562 /** |
|
8563 * WordPress dependencies |
|
8564 */ |
|
8565 |
|
8566 |
|
8567 function ThemeSupportCheck(_ref) { |
|
8568 var themeSupports = _ref.themeSupports, |
|
8569 children = _ref.children, |
|
8570 postType = _ref.postType, |
|
8571 supportKeys = _ref.supportKeys; |
|
8572 var isSupported = Object(external_lodash_["some"])(Object(external_lodash_["castArray"])(supportKeys), function (key) { |
|
8573 var supported = Object(external_lodash_["get"])(themeSupports, [key], false); // 'post-thumbnails' can be boolean or an array of post types. |
|
8574 // In the latter case, we need to verify `postType` exists |
|
8575 // within `supported`. If `postType` isn't passed, then the check |
|
8576 // should fail. |
|
8577 |
|
8578 if ('post-thumbnails' === key && Object(external_lodash_["isArray"])(supported)) { |
|
8579 return Object(external_lodash_["includes"])(supported, postType); |
|
8580 } |
|
8581 |
|
8582 return supported; |
|
8583 }); |
|
8584 |
|
8585 if (!isSupported) { |
|
8586 return null; |
|
8587 } |
|
8588 |
|
8589 return children; |
|
8590 } |
|
8591 /* harmony default export */ var theme_support_check = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8592 var _select = select('core'), |
|
8593 getThemeSupports = _select.getThemeSupports; |
|
8594 |
|
8595 var _select2 = select('core/editor'), |
|
8596 getEditedPostAttribute = _select2.getEditedPostAttribute; |
|
8597 |
|
8598 return { |
|
8599 postType: getEditedPostAttribute('type'), |
|
8600 themeSupports: getThemeSupports() |
|
8601 }; |
|
8602 })(ThemeSupportCheck)); |
|
8603 |
|
8604 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-featured-image/check.js |
|
8605 |
|
8606 |
|
8607 |
|
8608 /** |
|
8609 * Internal dependencies |
|
8610 */ |
|
8611 |
|
8612 |
|
8613 |
|
8614 function PostFeaturedImageCheck(props) { |
|
8615 return Object(external_this_wp_element_["createElement"])(theme_support_check, { |
|
8616 supportKeys: "post-thumbnails" |
|
8617 }, Object(external_this_wp_element_["createElement"])(post_type_support_check, Object(esm_extends["a" /* default */])({}, props, { |
|
8618 supportKeys: "thumbnail" |
|
8619 }))); |
|
8620 } |
|
8621 |
|
8622 /* harmony default export */ var post_featured_image_check = (PostFeaturedImageCheck); |
|
8623 |
|
8624 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-featured-image/index.js |
|
8625 |
|
8626 |
|
8627 /** |
|
8628 * External dependencies |
|
8629 */ |
|
8630 |
|
8631 /** |
|
8632 * WordPress dependencies |
|
8633 */ |
|
8634 |
|
8635 |
|
8636 |
|
8637 |
|
8638 |
|
8639 |
|
8640 |
|
8641 /** |
|
8642 * Internal dependencies |
|
8643 */ |
|
8644 |
|
8645 |
|
8646 var ALLOWED_MEDIA_TYPES = ['image']; // Used when labels from post type were not yet loaded or when they are not present. |
|
8647 |
|
8648 var DEFAULT_FEATURE_IMAGE_LABEL = Object(external_this_wp_i18n_["__"])('Featured Image'); |
|
8649 |
|
8650 var DEFAULT_SET_FEATURE_IMAGE_LABEL = Object(external_this_wp_i18n_["__"])('Set featured image'); |
|
8651 |
|
8652 var DEFAULT_REMOVE_FEATURE_IMAGE_LABEL = Object(external_this_wp_i18n_["__"])('Remove image'); |
|
8653 |
|
8654 function PostFeaturedImage(_ref) { |
|
8655 var currentPostId = _ref.currentPostId, |
|
8656 featuredImageId = _ref.featuredImageId, |
|
8657 onUpdateImage = _ref.onUpdateImage, |
|
8658 onRemoveImage = _ref.onRemoveImage, |
|
8659 media = _ref.media, |
|
8660 postType = _ref.postType; |
|
8661 var postLabel = Object(external_lodash_["get"])(postType, ['labels'], {}); |
|
8662 var instructions = Object(external_this_wp_element_["createElement"])("p", null, Object(external_this_wp_i18n_["__"])('To edit the featured image, you need permission to upload media.')); |
|
8663 var mediaWidth, mediaHeight, mediaSourceUrl; |
|
8664 |
|
8665 if (media) { |
|
8666 var mediaSize = Object(external_this_wp_hooks_["applyFilters"])('editor.PostFeaturedImage.imageSize', 'post-thumbnail', media.id, currentPostId); |
|
8667 |
|
8668 if (Object(external_lodash_["has"])(media, ['media_details', 'sizes', mediaSize])) { |
|
8669 mediaWidth = media.media_details.sizes[mediaSize].width; |
|
8670 mediaHeight = media.media_details.sizes[mediaSize].height; |
|
8671 mediaSourceUrl = media.media_details.sizes[mediaSize].source_url; |
|
8672 } else { |
|
8673 mediaWidth = media.media_details.width; |
|
8674 mediaHeight = media.media_details.height; |
|
8675 mediaSourceUrl = media.source_url; |
|
8676 } |
|
8677 } |
|
8678 |
|
8679 return Object(external_this_wp_element_["createElement"])(post_featured_image_check, null, Object(external_this_wp_element_["createElement"])("div", { |
|
8680 className: "editor-post-featured-image" |
|
8681 }, Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["MediaUploadCheck"], { |
|
8682 fallback: instructions |
|
8683 }, Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["MediaUpload"], { |
|
8684 title: postLabel.featured_image || DEFAULT_FEATURE_IMAGE_LABEL, |
|
8685 onSelect: onUpdateImage, |
|
8686 allowedTypes: ALLOWED_MEDIA_TYPES, |
|
8687 modalClass: !featuredImageId ? 'editor-post-featured-image__media-modal' : 'editor-post-featured-image__media-modal', |
|
8688 render: function render(_ref2) { |
|
8689 var open = _ref2.open; |
|
8690 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
8691 className: !featuredImageId ? 'editor-post-featured-image__toggle' : 'editor-post-featured-image__preview', |
|
8692 onClick: open, |
|
8693 "aria-label": !featuredImageId ? null : Object(external_this_wp_i18n_["__"])('Edit or update the image') |
|
8694 }, !!featuredImageId && media && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["ResponsiveWrapper"], { |
|
8695 naturalWidth: mediaWidth, |
|
8696 naturalHeight: mediaHeight |
|
8697 }, Object(external_this_wp_element_["createElement"])("img", { |
|
8698 src: mediaSourceUrl, |
|
8699 alt: "" |
|
8700 })), !!featuredImageId && !media && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Spinner"], null), !featuredImageId && (postLabel.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL)); |
|
8701 }, |
|
8702 value: featuredImageId |
|
8703 })), !!featuredImageId && media && !media.isLoading && Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["MediaUploadCheck"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["MediaUpload"], { |
|
8704 title: postLabel.featured_image || DEFAULT_FEATURE_IMAGE_LABEL, |
|
8705 onSelect: onUpdateImage, |
|
8706 allowedTypes: ALLOWED_MEDIA_TYPES, |
|
8707 modalClass: "editor-post-featured-image__media-modal", |
|
8708 render: function render(_ref3) { |
|
8709 var open = _ref3.open; |
|
8710 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
8711 onClick: open, |
|
8712 isDefault: true, |
|
8713 isLarge: true |
|
8714 }, Object(external_this_wp_i18n_["__"])('Replace image')); |
|
8715 } |
|
8716 })), !!featuredImageId && Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["MediaUploadCheck"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
8717 onClick: onRemoveImage, |
|
8718 isLink: true, |
|
8719 isDestructive: true |
|
8720 }, postLabel.remove_featured_image || DEFAULT_REMOVE_FEATURE_IMAGE_LABEL)))); |
|
8721 } |
|
8722 |
|
8723 var post_featured_image_applyWithSelect = Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8724 var _select = select('core'), |
|
8725 getMedia = _select.getMedia, |
|
8726 getPostType = _select.getPostType; |
|
8727 |
|
8728 var _select2 = select('core/editor'), |
|
8729 getCurrentPostId = _select2.getCurrentPostId, |
|
8730 getEditedPostAttribute = _select2.getEditedPostAttribute; |
|
8731 |
|
8732 var featuredImageId = getEditedPostAttribute('featured_media'); |
|
8733 return { |
|
8734 media: featuredImageId ? getMedia(featuredImageId) : null, |
|
8735 currentPostId: getCurrentPostId(), |
|
8736 postType: getPostType(getEditedPostAttribute('type')), |
|
8737 featuredImageId: featuredImageId |
|
8738 }; |
|
8739 }); |
|
8740 var post_featured_image_applyWithDispatch = Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
8741 var _dispatch = dispatch('core/editor'), |
|
8742 editPost = _dispatch.editPost; |
|
8743 |
|
8744 return { |
|
8745 onUpdateImage: function onUpdateImage(image) { |
|
8746 editPost({ |
|
8747 featured_media: image.id |
|
8748 }); |
|
8749 }, |
|
8750 onRemoveImage: function onRemoveImage() { |
|
8751 editPost({ |
|
8752 featured_media: 0 |
|
8753 }); |
|
8754 } |
|
8755 }; |
|
8756 }); |
|
8757 /* harmony default export */ var post_featured_image = (Object(external_this_wp_compose_["compose"])(post_featured_image_applyWithSelect, post_featured_image_applyWithDispatch, Object(external_this_wp_components_["withFilters"])('editor.PostFeaturedImage'))(PostFeaturedImage)); |
|
8758 |
|
8759 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-format/check.js |
|
8760 |
|
8761 |
|
8762 |
|
8763 |
|
8764 /** |
|
8765 * WordPress dependencies |
|
8766 */ |
|
8767 |
|
8768 /** |
|
8769 * Internal dependencies |
|
8770 */ |
|
8771 |
|
8772 |
|
8773 |
|
8774 function PostFormatCheck(_ref) { |
|
8775 var disablePostFormats = _ref.disablePostFormats, |
|
8776 props = Object(objectWithoutProperties["a" /* default */])(_ref, ["disablePostFormats"]); |
|
8777 |
|
8778 return !disablePostFormats && Object(external_this_wp_element_["createElement"])(post_type_support_check, Object(esm_extends["a" /* default */])({}, props, { |
|
8779 supportKeys: "post-formats" |
|
8780 })); |
|
8781 } |
|
8782 |
|
8783 /* harmony default export */ var post_format_check = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8784 var editorSettings = select('core/editor').getEditorSettings(); |
|
8785 return { |
|
8786 disablePostFormats: editorSettings.disablePostFormats |
|
8787 }; |
|
8788 })(PostFormatCheck)); |
|
8789 |
|
8790 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-format/index.js |
|
8791 |
|
8792 |
|
8793 /** |
|
8794 * External dependencies |
|
8795 */ |
|
8796 |
|
8797 /** |
|
8798 * WordPress dependencies |
|
8799 */ |
|
8800 |
|
8801 |
|
8802 |
|
8803 |
|
8804 |
|
8805 /** |
|
8806 * Internal dependencies |
|
8807 */ |
|
8808 |
|
8809 |
|
8810 var POST_FORMATS = [{ |
|
8811 id: 'aside', |
|
8812 caption: Object(external_this_wp_i18n_["__"])('Aside') |
|
8813 }, { |
|
8814 id: 'gallery', |
|
8815 caption: Object(external_this_wp_i18n_["__"])('Gallery') |
|
8816 }, { |
|
8817 id: 'link', |
|
8818 caption: Object(external_this_wp_i18n_["__"])('Link') |
|
8819 }, { |
|
8820 id: 'image', |
|
8821 caption: Object(external_this_wp_i18n_["__"])('Image') |
|
8822 }, { |
|
8823 id: 'quote', |
|
8824 caption: Object(external_this_wp_i18n_["__"])('Quote') |
|
8825 }, { |
|
8826 id: 'standard', |
|
8827 caption: Object(external_this_wp_i18n_["__"])('Standard') |
|
8828 }, { |
|
8829 id: 'status', |
|
8830 caption: Object(external_this_wp_i18n_["__"])('Status') |
|
8831 }, { |
|
8832 id: 'video', |
|
8833 caption: Object(external_this_wp_i18n_["__"])('Video') |
|
8834 }, { |
|
8835 id: 'audio', |
|
8836 caption: Object(external_this_wp_i18n_["__"])('Audio') |
|
8837 }, { |
|
8838 id: 'chat', |
|
8839 caption: Object(external_this_wp_i18n_["__"])('Chat') |
|
8840 }]; |
|
8841 |
|
8842 function PostFormat(_ref) { |
|
8843 var onUpdatePostFormat = _ref.onUpdatePostFormat, |
|
8844 _ref$postFormat = _ref.postFormat, |
|
8845 postFormat = _ref$postFormat === void 0 ? 'standard' : _ref$postFormat, |
|
8846 supportedFormats = _ref.supportedFormats, |
|
8847 suggestedFormat = _ref.suggestedFormat, |
|
8848 instanceId = _ref.instanceId; |
|
8849 var postFormatSelectorId = 'post-format-selector-' + instanceId; |
|
8850 var formats = POST_FORMATS.filter(function (format) { |
|
8851 return Object(external_lodash_["includes"])(supportedFormats, format.id); |
|
8852 }); |
|
8853 var suggestion = Object(external_lodash_["find"])(formats, function (format) { |
|
8854 return format.id === suggestedFormat; |
|
8855 }); // Disable reason: We need to change the value immiediately to show/hide the suggestion if needed |
|
8856 |
|
8857 /* eslint-disable jsx-a11y/no-onchange */ |
|
8858 |
|
8859 return Object(external_this_wp_element_["createElement"])(post_format_check, null, Object(external_this_wp_element_["createElement"])("div", { |
|
8860 className: "editor-post-format" |
|
8861 }, Object(external_this_wp_element_["createElement"])("div", { |
|
8862 className: "editor-post-format__content" |
|
8863 }, Object(external_this_wp_element_["createElement"])("label", { |
|
8864 htmlFor: postFormatSelectorId |
|
8865 }, Object(external_this_wp_i18n_["__"])('Post Format')), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["SelectControl"], { |
|
8866 value: postFormat, |
|
8867 onChange: function onChange(format) { |
|
8868 return onUpdatePostFormat(format); |
|
8869 }, |
|
8870 id: postFormatSelectorId, |
|
8871 options: formats.map(function (format) { |
|
8872 return { |
|
8873 label: format.caption, |
|
8874 value: format.id |
|
8875 }; |
|
8876 }) |
|
8877 })), suggestion && suggestion.id !== postFormat && Object(external_this_wp_element_["createElement"])("div", { |
|
8878 className: "editor-post-format__suggestion" |
|
8879 }, Object(external_this_wp_i18n_["__"])('Suggestion:'), ' ', Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
8880 isLink: true, |
|
8881 onClick: function onClick() { |
|
8882 return onUpdatePostFormat(suggestion.id); |
|
8883 } |
|
8884 }, suggestion.caption)))); |
|
8885 /* eslint-enable jsx-a11y/no-onchange */ |
|
8886 } |
|
8887 |
|
8888 /* harmony default export */ var post_format = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8889 var _select = select('core/editor'), |
|
8890 getEditedPostAttribute = _select.getEditedPostAttribute, |
|
8891 getSuggestedPostFormat = _select.getSuggestedPostFormat; |
|
8892 |
|
8893 var postFormat = getEditedPostAttribute('format'); |
|
8894 var themeSupports = select('core').getThemeSupports(); // Ensure current format is always in the set. |
|
8895 // The current format may not be a format supported by the theme. |
|
8896 |
|
8897 var supportedFormats = Object(external_lodash_["union"])([postFormat], Object(external_lodash_["get"])(themeSupports, ['formats'], [])); |
|
8898 return { |
|
8899 postFormat: postFormat, |
|
8900 supportedFormats: supportedFormats, |
|
8901 suggestedFormat: getSuggestedPostFormat() |
|
8902 }; |
|
8903 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
8904 return { |
|
8905 onUpdatePostFormat: function onUpdatePostFormat(postFormat) { |
|
8906 dispatch('core/editor').editPost({ |
|
8907 format: postFormat |
|
8908 }); |
|
8909 } |
|
8910 }; |
|
8911 }), external_this_wp_compose_["withInstanceId"]])(PostFormat)); |
|
8912 |
|
8913 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-last-revision/check.js |
|
8914 |
|
8915 |
|
8916 /** |
|
8917 * WordPress dependencies |
|
8918 */ |
|
8919 |
|
8920 /** |
|
8921 * Internal dependencies |
|
8922 */ |
|
8923 |
|
8924 |
|
8925 function PostLastRevisionCheck(_ref) { |
|
8926 var lastRevisionId = _ref.lastRevisionId, |
|
8927 revisionsCount = _ref.revisionsCount, |
|
8928 children = _ref.children; |
|
8929 |
|
8930 if (!lastRevisionId || revisionsCount < 2) { |
|
8931 return null; |
|
8932 } |
|
8933 |
|
8934 return Object(external_this_wp_element_["createElement"])(post_type_support_check, { |
|
8935 supportKeys: "revisions" |
|
8936 }, children); |
|
8937 } |
|
8938 /* harmony default export */ var post_last_revision_check = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
8939 var _select = select('core/editor'), |
|
8940 getCurrentPostLastRevisionId = _select.getCurrentPostLastRevisionId, |
|
8941 getCurrentPostRevisionsCount = _select.getCurrentPostRevisionsCount; |
|
8942 |
|
8943 return { |
|
8944 lastRevisionId: getCurrentPostLastRevisionId(), |
|
8945 revisionsCount: getCurrentPostRevisionsCount() |
|
8946 }; |
|
8947 })(PostLastRevisionCheck)); |
|
8948 |
|
8949 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/url.js |
|
8950 /** |
|
8951 * External dependencies |
|
8952 */ |
|
8953 |
|
8954 /** |
|
8955 * WordPress dependencies |
|
8956 */ |
|
8957 |
|
8958 |
|
8959 /** |
|
8960 * Returns the URL of a WPAdmin Page. |
|
8961 * |
|
8962 * TODO: This should be moved to a module less specific to the editor. |
|
8963 * |
|
8964 * @param {string} page Page to navigate to. |
|
8965 * @param {Object} query Query Args. |
|
8966 * |
|
8967 * @return {string} WPAdmin URL. |
|
8968 */ |
|
8969 |
|
8970 function getWPAdminURL(page, query) { |
|
8971 return Object(external_this_wp_url_["addQueryArgs"])(page, query); |
|
8972 } |
|
8973 /** |
|
8974 * Performs some basic cleanup of a string for use as a post slug |
|
8975 * |
|
8976 * This replicates some of what santize_title() does in WordPress core, but |
|
8977 * is only designed to approximate what the slug will be. |
|
8978 * |
|
8979 * Converts whitespace, periods, forward slashes and underscores to hyphens. |
|
8980 * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin |
|
8981 * letters. Removes combining diacritical marks. Converts remaining string |
|
8982 * to lowercase. It does not touch octets, HTML entities, or other encoded |
|
8983 * characters. |
|
8984 * |
|
8985 * @param {string} string Title or slug to be processed |
|
8986 * |
|
8987 * @return {string} Processed string |
|
8988 */ |
|
8989 |
|
8990 function cleanForSlug(string) { |
|
8991 return Object(external_lodash_["toLower"])(Object(external_lodash_["deburr"])(Object(external_lodash_["trim"])(string.replace(/[\s\./_]+/g, '-'), '-'))); |
|
8992 } |
|
8993 |
|
8994 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-last-revision/index.js |
|
8995 |
|
8996 |
|
8997 /** |
|
8998 * WordPress dependencies |
|
8999 */ |
|
9000 |
|
9001 |
|
9002 |
|
9003 /** |
|
9004 * Internal dependencies |
|
9005 */ |
|
9006 |
|
9007 |
|
9008 |
|
9009 |
|
9010 function LastRevision(_ref) { |
|
9011 var lastRevisionId = _ref.lastRevisionId, |
|
9012 revisionsCount = _ref.revisionsCount; |
|
9013 return Object(external_this_wp_element_["createElement"])(post_last_revision_check, null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
9014 href: getWPAdminURL('revision.php', { |
|
9015 revision: lastRevisionId, |
|
9016 gutenberg: true |
|
9017 }), |
|
9018 className: "editor-post-last-revision__title", |
|
9019 icon: "backup" |
|
9020 }, Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["_n"])('%d Revision', '%d Revisions', revisionsCount), revisionsCount))); |
|
9021 } |
|
9022 |
|
9023 /* harmony default export */ var post_last_revision = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
9024 var _select = select('core/editor'), |
|
9025 getCurrentPostLastRevisionId = _select.getCurrentPostLastRevisionId, |
|
9026 getCurrentPostRevisionsCount = _select.getCurrentPostRevisionsCount; |
|
9027 |
|
9028 return { |
|
9029 lastRevisionId: getCurrentPostLastRevisionId(), |
|
9030 revisionsCount: getCurrentPostRevisionsCount() |
|
9031 }; |
|
9032 })(LastRevision)); |
|
9033 |
|
9034 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-preview-button/index.js |
|
9035 |
|
9036 |
|
9037 |
|
9038 |
|
9039 |
|
9040 |
|
9041 |
|
9042 |
|
9043 /** |
|
9044 * External dependencies |
|
9045 */ |
|
9046 |
|
9047 /** |
|
9048 * WordPress dependencies |
|
9049 */ |
|
9050 |
|
9051 |
|
9052 |
|
9053 |
|
9054 |
|
9055 |
|
9056 |
|
9057 |
|
9058 |
|
9059 function writeInterstitialMessage(targetDocument) { |
|
9060 var markup = Object(external_this_wp_element_["renderToString"])(Object(external_this_wp_element_["createElement"])("div", { |
|
9061 className: "editor-post-preview-button__interstitial-message" |
|
9062 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["SVG"], { |
|
9063 xmlns: "http://www.w3.org/2000/svg", |
|
9064 viewBox: "0 0 96 96" |
|
9065 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Path"], { |
|
9066 className: "outer", |
|
9067 d: "M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36", |
|
9068 fill: "none" |
|
9069 }), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Path"], { |
|
9070 className: "inner", |
|
9071 d: "M69.5 46.4c0-3.9-1.4-6.7-2.6-8.8-1.6-2.6-3.1-4.9-3.1-7.5 0-2.9 2.2-5.7 5.4-5.7h.4C63.9 19.2 56.4 16 48 16c-11.2 0-21 5.7-26.7 14.4h2.1c3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3L40 67.5l7-20.9L42 33c-1.7-.1-3.3-.3-3.3-.3-1.7-.1-1.5-2.7.2-2.6 0 0 5.3.4 8.4.4 3.3 0 8.5-.4 8.5-.4 1.7-.1 1.9 2.4.2 2.6 0 0-1.7.2-3.7.3l11.5 34.3 3.3-10.4c1.6-4.5 2.4-7.8 2.4-10.5zM16.1 48c0 12.6 7.3 23.5 18 28.7L18.8 35c-1.7 4-2.7 8.4-2.7 13zm32.5 2.8L39 78.6c2.9.8 5.9 1.3 9 1.3 3.7 0 7.3-.6 10.6-1.8-.1-.1-.2-.3-.2-.4l-9.8-26.9zM76.2 36c0 3.2-.6 6.9-2.4 11.4L64 75.6c9.5-5.5 15.9-15.8 15.9-27.6 0-5.5-1.4-10.8-3.9-15.3.1 1 .2 2.1.2 3.3z", |
|
9072 fill: "none" |
|
9073 })), Object(external_this_wp_element_["createElement"])("p", null, Object(external_this_wp_i18n_["__"])('Generating preview…')))); |
|
9074 markup += "\n\t\t<style>\n\t\t\tbody {\n\t\t\t\tmargin: 0;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message {\n\t\t\t\tdisplay: flex;\n\t\t\t\tflex-direction: column;\n\t\t\t\talign-items: center;\n\t\t\t\tjustify-content: center;\n\t\t\t\theight: 100vh;\n\t\t\t\twidth: 100vw;\n\t\t\t}\n\t\t\t@-webkit-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-moz-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@-o-keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t@keyframes paint {\n\t\t\t\t0% {\n\t\t\t\t\tstroke-dashoffset: 0;\n\t\t\t\t}\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg {\n\t\t\t\twidth: 192px;\n\t\t\t\theight: 192px;\n\t\t\t\tstroke: #555d66;\n\t\t\t\tstroke-width: 0.75;\n\t\t\t}\n\t\t\t.editor-post-preview-button__interstitial-message svg .outer,\n\t\t\t.editor-post-preview-button__interstitial-message svg .inner {\n\t\t\t\tstroke-dasharray: 280;\n\t\t\t\tstroke-dashoffset: 280;\n\t\t\t\t-webkit-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-moz-animation: paint 1.5s ease infinite alternate;\n\t\t\t\t-o-animation: paint 1.5s ease infinite alternate;\n\t\t\t\tanimation: paint 1.5s ease infinite alternate;\n\t\t\t}\n\t\t\tp {\n\t\t\t\ttext-align: center;\n\t\t\t\tfont-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", Roboto, Oxygen-Sans, Ubuntu, Cantarell, \"Helvetica Neue\", sans-serif;\n\t\t\t}\n\t\t</style>\n\t"; |
|
9075 /** |
|
9076 * Filters the interstitial message shown when generating previews. |
|
9077 * |
|
9078 * @param {String} markup The preview interstitial markup. |
|
9079 */ |
|
9080 |
|
9081 markup = Object(external_this_wp_hooks_["applyFilters"])('editor.PostPreview.interstitialMarkup', markup); |
|
9082 targetDocument.write(markup); |
|
9083 targetDocument.title = Object(external_this_wp_i18n_["__"])('Generating preview…'); |
|
9084 targetDocument.close(); |
|
9085 } |
|
9086 |
|
9087 var post_preview_button_PostPreviewButton = |
|
9088 /*#__PURE__*/ |
|
9089 function (_Component) { |
|
9090 Object(inherits["a" /* default */])(PostPreviewButton, _Component); |
|
9091 |
|
9092 function PostPreviewButton() { |
|
9093 var _this; |
|
9094 |
|
9095 Object(classCallCheck["a" /* default */])(this, PostPreviewButton); |
|
9096 |
|
9097 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(PostPreviewButton).apply(this, arguments)); |
|
9098 _this.openPreviewWindow = _this.openPreviewWindow.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
9099 return _this; |
|
9100 } |
|
9101 |
|
9102 Object(createClass["a" /* default */])(PostPreviewButton, [{ |
|
9103 key: "componentDidUpdate", |
|
9104 value: function componentDidUpdate(prevProps) { |
|
9105 var previewLink = this.props.previewLink; // This relies on the window being responsible to unset itself when |
|
9106 // navigation occurs or a new preview window is opened, to avoid |
|
9107 // unintentional forceful redirects. |
|
9108 |
|
9109 if (previewLink && !prevProps.previewLink) { |
|
9110 this.setPreviewWindowLink(previewLink); |
|
9111 } |
|
9112 } |
|
9113 /** |
|
9114 * Sets the preview window's location to the given URL, if a preview window |
|
9115 * exists and is not closed. |
|
9116 * |
|
9117 * @param {string} url URL to assign as preview window location. |
|
9118 */ |
|
9119 |
|
9120 }, { |
|
9121 key: "setPreviewWindowLink", |
|
9122 value: function setPreviewWindowLink(url) { |
|
9123 var previewWindow = this.previewWindow; |
|
9124 |
|
9125 if (previewWindow && !previewWindow.closed) { |
|
9126 previewWindow.location = url; |
|
9127 } |
|
9128 } |
|
9129 }, { |
|
9130 key: "getWindowTarget", |
|
9131 value: function getWindowTarget() { |
|
9132 var postId = this.props.postId; |
|
9133 return "wp-preview-".concat(postId); |
|
9134 } |
|
9135 }, { |
|
9136 key: "openPreviewWindow", |
|
9137 value: function openPreviewWindow(event) { |
|
9138 // Our Preview button has its 'href' and 'target' set correctly for a11y |
|
9139 // purposes. Unfortunately, though, we can't rely on the default 'click' |
|
9140 // handler since sometimes it incorrectly opens a new tab instead of reusing |
|
9141 // the existing one. |
|
9142 // https://github.com/WordPress/gutenberg/pull/8330 |
|
9143 event.preventDefault(); // Open up a Preview tab if needed. This is where we'll show the preview. |
|
9144 |
|
9145 if (!this.previewWindow || this.previewWindow.closed) { |
|
9146 this.previewWindow = window.open('', this.getWindowTarget()); |
|
9147 } // Focus the Preview tab. This might not do anything, depending on the browser's |
|
9148 // and user's preferences. |
|
9149 // https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus |
|
9150 |
|
9151 |
|
9152 this.previewWindow.focus(); // If we don't need to autosave the post before previewing, then we simply |
|
9153 // load the Preview URL in the Preview tab. |
|
9154 |
|
9155 if (!this.props.isAutosaveable) { |
|
9156 this.setPreviewWindowLink(event.target.href); |
|
9157 return; |
|
9158 } // Request an autosave. This happens asynchronously and causes the component |
|
9159 // to update when finished. |
|
9160 |
|
9161 |
|
9162 if (this.props.isDraft) { |
|
9163 this.props.savePost({ |
|
9164 isPreview: true |
|
9165 }); |
|
9166 } else { |
|
9167 this.props.autosave({ |
|
9168 isPreview: true |
|
9169 }); |
|
9170 } // Display a 'Generating preview' message in the Preview tab while we wait for the |
|
9171 // autosave to finish. |
|
9172 |
|
9173 |
|
9174 writeInterstitialMessage(this.previewWindow.document); |
|
9175 } |
|
9176 }, { |
|
9177 key: "render", |
|
9178 value: function render() { |
|
9179 var _this$props = this.props, |
|
9180 previewLink = _this$props.previewLink, |
|
9181 currentPostLink = _this$props.currentPostLink, |
|
9182 isSaveable = _this$props.isSaveable; // Link to the `?preview=true` URL if we have it, since this lets us see |
|
9183 // changes that were autosaved since the post was last published. Otherwise, |
|
9184 // just link to the post's URL. |
|
9185 |
|
9186 var href = previewLink || currentPostLink; |
|
9187 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
9188 isLarge: true, |
|
9189 className: "editor-post-preview", |
|
9190 href: href, |
|
9191 target: this.getWindowTarget(), |
|
9192 disabled: !isSaveable, |
|
9193 onClick: this.openPreviewWindow |
|
9194 }, Object(external_this_wp_i18n_["_x"])('Preview', 'imperative verb'), Object(external_this_wp_element_["createElement"])("span", { |
|
9195 className: "screen-reader-text" |
|
9196 }, |
|
9197 /* translators: accessibility text */ |
|
9198 Object(external_this_wp_i18n_["__"])('(opens in a new tab)')), Object(external_this_wp_element_["createElement"])(external_this_wp_nux_["DotTip"], { |
|
9199 tipId: "core/editor.preview" |
|
9200 }, Object(external_this_wp_i18n_["__"])('Click “Preview” to load a preview of this page, so you can make sure you’re happy with your blocks.'))); |
|
9201 } |
|
9202 }]); |
|
9203 |
|
9204 return PostPreviewButton; |
|
9205 }(external_this_wp_element_["Component"]); |
|
9206 /* harmony default export */ var post_preview_button = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, _ref) { |
|
9207 var forcePreviewLink = _ref.forcePreviewLink, |
|
9208 forceIsAutosaveable = _ref.forceIsAutosaveable; |
|
9209 |
|
9210 var _select = select('core/editor'), |
|
9211 getCurrentPostId = _select.getCurrentPostId, |
|
9212 getCurrentPostAttribute = _select.getCurrentPostAttribute, |
|
9213 getEditedPostAttribute = _select.getEditedPostAttribute, |
|
9214 isEditedPostSaveable = _select.isEditedPostSaveable, |
|
9215 isEditedPostAutosaveable = _select.isEditedPostAutosaveable, |
|
9216 getEditedPostPreviewLink = _select.getEditedPostPreviewLink; |
|
9217 |
|
9218 var _select2 = select('core'), |
|
9219 getPostType = _select2.getPostType; |
|
9220 |
|
9221 var previewLink = getEditedPostPreviewLink(); |
|
9222 var postType = getPostType(getEditedPostAttribute('type')); |
|
9223 return { |
|
9224 postId: getCurrentPostId(), |
|
9225 currentPostLink: getCurrentPostAttribute('link'), |
|
9226 previewLink: forcePreviewLink !== undefined ? forcePreviewLink : previewLink, |
|
9227 isSaveable: isEditedPostSaveable(), |
|
9228 isAutosaveable: forceIsAutosaveable || isEditedPostAutosaveable(), |
|
9229 isViewable: Object(external_lodash_["get"])(postType, ['viewable'], false), |
|
9230 isDraft: ['draft', 'auto-draft'].indexOf(getEditedPostAttribute('status')) !== -1 |
|
9231 }; |
|
9232 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
9233 return { |
|
9234 autosave: dispatch('core/editor').autosave, |
|
9235 savePost: dispatch('core/editor').savePost |
|
9236 }; |
|
9237 }), Object(external_this_wp_compose_["ifCondition"])(function (_ref2) { |
|
9238 var isViewable = _ref2.isViewable; |
|
9239 return isViewable; |
|
9240 })])(post_preview_button_PostPreviewButton)); |
|
9241 |
|
9242 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-locked-modal/index.js |
|
9243 |
|
9244 |
|
9245 |
|
9246 |
|
9247 |
|
9248 |
|
9249 |
|
9250 |
|
9251 /** |
|
9252 * External dependencies |
|
9253 */ |
|
9254 |
|
9255 /** |
|
9256 * WordPress dependencies |
|
9257 */ |
|
9258 |
|
9259 |
|
9260 |
|
9261 |
|
9262 |
|
9263 |
|
9264 |
|
9265 |
|
9266 /** |
|
9267 * Internal dependencies |
|
9268 */ |
|
9269 |
|
9270 |
|
9271 |
|
9272 |
|
9273 var post_locked_modal_PostLockedModal = |
|
9274 /*#__PURE__*/ |
|
9275 function (_Component) { |
|
9276 Object(inherits["a" /* default */])(PostLockedModal, _Component); |
|
9277 |
|
9278 function PostLockedModal() { |
|
9279 var _this; |
|
9280 |
|
9281 Object(classCallCheck["a" /* default */])(this, PostLockedModal); |
|
9282 |
|
9283 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(PostLockedModal).apply(this, arguments)); |
|
9284 _this.sendPostLock = _this.sendPostLock.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
9285 _this.receivePostLock = _this.receivePostLock.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
9286 _this.releasePostLock = _this.releasePostLock.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
9287 return _this; |
|
9288 } |
|
9289 |
|
9290 Object(createClass["a" /* default */])(PostLockedModal, [{ |
|
9291 key: "componentDidMount", |
|
9292 value: function componentDidMount() { |
|
9293 var hookName = this.getHookName(); // Details on these events on the Heartbeat API docs |
|
9294 // https://developer.wordpress.org/plugins/javascript/heartbeat-api/ |
|
9295 |
|
9296 Object(external_this_wp_hooks_["addAction"])('heartbeat.send', hookName, this.sendPostLock); |
|
9297 Object(external_this_wp_hooks_["addAction"])('heartbeat.tick', hookName, this.receivePostLock); |
|
9298 } |
|
9299 }, { |
|
9300 key: "componentWillUnmount", |
|
9301 value: function componentWillUnmount() { |
|
9302 var hookName = this.getHookName(); |
|
9303 Object(external_this_wp_hooks_["removeAction"])('heartbeat.send', hookName); |
|
9304 Object(external_this_wp_hooks_["removeAction"])('heartbeat.tick', hookName); |
|
9305 } |
|
9306 /** |
|
9307 * Returns a `@wordpress/hooks` hook name specific to the instance of the |
|
9308 * component. |
|
9309 * |
|
9310 * @return {string} Hook name prefix. |
|
9311 */ |
|
9312 |
|
9313 }, { |
|
9314 key: "getHookName", |
|
9315 value: function getHookName() { |
|
9316 var instanceId = this.props.instanceId; |
|
9317 return 'core/editor/post-locked-modal-' + instanceId; |
|
9318 } |
|
9319 /** |
|
9320 * Keep the lock refreshed. |
|
9321 * |
|
9322 * When the user does not send a heartbeat in a heartbeat-tick |
|
9323 * the user is no longer editing and another user can start editing. |
|
9324 * |
|
9325 * @param {Object} data Data to send in the heartbeat request. |
|
9326 */ |
|
9327 |
|
9328 }, { |
|
9329 key: "sendPostLock", |
|
9330 value: function sendPostLock(data) { |
|
9331 var _this$props = this.props, |
|
9332 isLocked = _this$props.isLocked, |
|
9333 activePostLock = _this$props.activePostLock, |
|
9334 postId = _this$props.postId; |
|
9335 |
|
9336 if (isLocked) { |
|
9337 return; |
|
9338 } |
|
9339 |
|
9340 data['wp-refresh-post-lock'] = { |
|
9341 lock: activePostLock, |
|
9342 post_id: postId |
|
9343 }; |
|
9344 } |
|
9345 /** |
|
9346 * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing. |
|
9347 * |
|
9348 * @param {Object} data Data received in the heartbeat request |
|
9349 */ |
|
9350 |
|
9351 }, { |
|
9352 key: "receivePostLock", |
|
9353 value: function receivePostLock(data) { |
|
9354 if (!data['wp-refresh-post-lock']) { |
|
9355 return; |
|
9356 } |
|
9357 |
|
9358 var _this$props2 = this.props, |
|
9359 autosave = _this$props2.autosave, |
|
9360 updatePostLock = _this$props2.updatePostLock; |
|
9361 var received = data['wp-refresh-post-lock']; |
|
9362 |
|
9363 if (received.lock_error) { |
|
9364 // Auto save and display the takeover modal. |
|
9365 autosave(); |
|
9366 updatePostLock({ |
|
9367 isLocked: true, |
|
9368 isTakeover: true, |
|
9369 user: { |
|
9370 avatar: received.lock_error.avatar_src |
|
9371 } |
|
9372 }); |
|
9373 } else if (received.new_lock) { |
|
9374 updatePostLock({ |
|
9375 isLocked: false, |
|
9376 activePostLock: received.new_lock |
|
9377 }); |
|
9378 } |
|
9379 } |
|
9380 /** |
|
9381 * Unlock the post before the window is exited. |
|
9382 */ |
|
9383 |
|
9384 }, { |
|
9385 key: "releasePostLock", |
|
9386 value: function releasePostLock() { |
|
9387 var _this$props3 = this.props, |
|
9388 isLocked = _this$props3.isLocked, |
|
9389 activePostLock = _this$props3.activePostLock, |
|
9390 postLockUtils = _this$props3.postLockUtils, |
|
9391 postId = _this$props3.postId; |
|
9392 |
|
9393 if (isLocked || !activePostLock) { |
|
9394 return; |
|
9395 } |
|
9396 |
|
9397 var data = new window.FormData(); |
|
9398 data.append('action', 'wp-remove-post-lock'); |
|
9399 data.append('_wpnonce', postLockUtils.unlockNonce); |
|
9400 data.append('post_ID', postId); |
|
9401 data.append('active_post_lock', activePostLock); |
|
9402 var xhr = new window.XMLHttpRequest(); |
|
9403 xhr.open('POST', postLockUtils.ajaxUrl, false); |
|
9404 xhr.send(data); |
|
9405 } |
|
9406 }, { |
|
9407 key: "render", |
|
9408 value: function render() { |
|
9409 var _this$props4 = this.props, |
|
9410 user = _this$props4.user, |
|
9411 postId = _this$props4.postId, |
|
9412 isLocked = _this$props4.isLocked, |
|
9413 isTakeover = _this$props4.isTakeover, |
|
9414 postLockUtils = _this$props4.postLockUtils, |
|
9415 postType = _this$props4.postType; |
|
9416 |
|
9417 if (!isLocked) { |
|
9418 return null; |
|
9419 } |
|
9420 |
|
9421 var userDisplayName = user.name; |
|
9422 var userAvatar = user.avatar; |
|
9423 var unlockUrl = Object(external_this_wp_url_["addQueryArgs"])('post.php', { |
|
9424 'get-post-lock': '1', |
|
9425 lockKey: true, |
|
9426 post: postId, |
|
9427 action: 'edit', |
|
9428 _wpnonce: postLockUtils.nonce |
|
9429 }); |
|
9430 var allPostsUrl = getWPAdminURL('edit.php', { |
|
9431 post_type: Object(external_lodash_["get"])(postType, ['slug']) |
|
9432 }); |
|
9433 |
|
9434 var allPostsLabel = Object(external_this_wp_i18n_["__"])('Exit the Editor'); |
|
9435 |
|
9436 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Modal"], { |
|
9437 title: isTakeover ? Object(external_this_wp_i18n_["__"])('Someone else has taken over this post.') : Object(external_this_wp_i18n_["__"])('This post is already being edited.'), |
|
9438 focusOnMount: true, |
|
9439 shouldCloseOnClickOutside: false, |
|
9440 shouldCloseOnEsc: false, |
|
9441 isDismissable: false, |
|
9442 className: "editor-post-locked-modal" |
|
9443 }, !!userAvatar && Object(external_this_wp_element_["createElement"])("img", { |
|
9444 src: userAvatar, |
|
9445 alt: Object(external_this_wp_i18n_["__"])('Avatar'), |
|
9446 className: "editor-post-locked-modal__avatar" |
|
9447 }), !!isTakeover && Object(external_this_wp_element_["createElement"])("div", null, Object(external_this_wp_element_["createElement"])("div", null, userDisplayName ? Object(external_this_wp_i18n_["sprintf"])( |
|
9448 /* translators: %s: user's display name */ |
|
9449 Object(external_this_wp_i18n_["__"])('%s now has editing control of this post. Don’t worry, your changes up to this moment have been saved.'), userDisplayName) : Object(external_this_wp_i18n_["__"])('Another user now has editing control of this post. Don’t worry, your changes up to this moment have been saved.')), Object(external_this_wp_element_["createElement"])("div", { |
|
9450 className: "editor-post-locked-modal__buttons" |
|
9451 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
9452 isPrimary: true, |
|
9453 isLarge: true, |
|
9454 href: allPostsUrl |
|
9455 }, allPostsLabel))), !isTakeover && Object(external_this_wp_element_["createElement"])("div", null, Object(external_this_wp_element_["createElement"])("div", null, userDisplayName ? Object(external_this_wp_i18n_["sprintf"])( |
|
9456 /* translators: %s: user's display name */ |
|
9457 Object(external_this_wp_i18n_["__"])('%s is currently working on this post, which means you cannot make changes, unless you take over.'), userDisplayName) : Object(external_this_wp_i18n_["__"])('Another user is currently working on this post, which means you cannot make changes, unless you take over.')), Object(external_this_wp_element_["createElement"])("div", { |
|
9458 className: "editor-post-locked-modal__buttons" |
|
9459 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
9460 isDefault: true, |
|
9461 isLarge: true, |
|
9462 href: allPostsUrl |
|
9463 }, allPostsLabel), Object(external_this_wp_element_["createElement"])(post_preview_button, null), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
9464 isPrimary: true, |
|
9465 isLarge: true, |
|
9466 href: unlockUrl |
|
9467 }, Object(external_this_wp_i18n_["__"])('Take Over'))))); |
|
9468 } |
|
9469 }]); |
|
9470 |
|
9471 return PostLockedModal; |
|
9472 }(external_this_wp_element_["Component"]); |
|
9473 |
|
9474 /* harmony default export */ var post_locked_modal = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select) { |
|
9475 var _select = select('core/editor'), |
|
9476 isPostLocked = _select.isPostLocked, |
|
9477 isPostLockTakeover = _select.isPostLockTakeover, |
|
9478 getPostLockUser = _select.getPostLockUser, |
|
9479 getCurrentPostId = _select.getCurrentPostId, |
|
9480 getActivePostLock = _select.getActivePostLock, |
|
9481 getEditedPostAttribute = _select.getEditedPostAttribute, |
|
9482 getEditorSettings = _select.getEditorSettings; |
|
9483 |
|
9484 var _select2 = select('core'), |
|
9485 getPostType = _select2.getPostType; |
|
9486 |
|
9487 return { |
|
9488 isLocked: isPostLocked(), |
|
9489 isTakeover: isPostLockTakeover(), |
|
9490 user: getPostLockUser(), |
|
9491 postId: getCurrentPostId(), |
|
9492 postLockUtils: getEditorSettings().postLockUtils, |
|
9493 activePostLock: getActivePostLock(), |
|
9494 postType: getPostType(getEditedPostAttribute('type')) |
|
9495 }; |
|
9496 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
9497 var _dispatch = dispatch('core/editor'), |
|
9498 autosave = _dispatch.autosave, |
|
9499 updatePostLock = _dispatch.updatePostLock; |
|
9500 |
|
9501 return { |
|
9502 autosave: autosave, |
|
9503 updatePostLock: updatePostLock |
|
9504 }; |
|
9505 }), external_this_wp_compose_["withInstanceId"], Object(external_this_wp_compose_["withGlobalEvents"])({ |
|
9506 beforeunload: 'releasePostLock' |
|
9507 }))(post_locked_modal_PostLockedModal)); |
|
9508 |
|
9509 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-pending-status/check.js |
|
9510 /** |
|
9511 * External dependencies |
|
9512 */ |
|
9513 |
|
9514 /** |
|
9515 * WordPress dependencies |
|
9516 */ |
|
9517 |
|
9518 |
|
9519 |
|
9520 function PostPendingStatusCheck(_ref) { |
|
9521 var hasPublishAction = _ref.hasPublishAction, |
|
9522 isPublished = _ref.isPublished, |
|
9523 children = _ref.children; |
|
9524 |
|
9525 if (isPublished || !hasPublishAction) { |
|
9526 return null; |
|
9527 } |
|
9528 |
|
9529 return children; |
|
9530 } |
|
9531 /* harmony default export */ var post_pending_status_check = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select) { |
|
9532 var _select = select('core/editor'), |
|
9533 isCurrentPostPublished = _select.isCurrentPostPublished, |
|
9534 getCurrentPostType = _select.getCurrentPostType, |
|
9535 getCurrentPost = _select.getCurrentPost; |
|
9536 |
|
9537 return { |
|
9538 hasPublishAction: Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-publish'], false), |
|
9539 isPublished: isCurrentPostPublished(), |
|
9540 postType: getCurrentPostType() |
|
9541 }; |
|
9542 }))(PostPendingStatusCheck)); |
|
9543 |
|
9544 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-pending-status/index.js |
|
9545 |
|
9546 |
|
9547 /** |
|
9548 * WordPress dependencies |
|
9549 */ |
|
9550 |
|
9551 |
|
9552 |
|
9553 |
|
9554 /** |
|
9555 * Internal dependencies |
|
9556 */ |
|
9557 |
|
9558 |
|
9559 function PostPendingStatus(_ref) { |
|
9560 var status = _ref.status, |
|
9561 onUpdateStatus = _ref.onUpdateStatus; |
|
9562 |
|
9563 var togglePendingStatus = function togglePendingStatus() { |
|
9564 var updatedStatus = status === 'pending' ? 'draft' : 'pending'; |
|
9565 onUpdateStatus(updatedStatus); |
|
9566 }; |
|
9567 |
|
9568 return Object(external_this_wp_element_["createElement"])(post_pending_status_check, null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["CheckboxControl"], { |
|
9569 label: Object(external_this_wp_i18n_["__"])('Pending Review'), |
|
9570 checked: status === 'pending', |
|
9571 onChange: togglePendingStatus |
|
9572 })); |
|
9573 } |
|
9574 /* harmony default export */ var post_pending_status = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select) { |
|
9575 return { |
|
9576 status: select('core/editor').getEditedPostAttribute('status') |
|
9577 }; |
|
9578 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
9579 return { |
|
9580 onUpdateStatus: function onUpdateStatus(status) { |
|
9581 dispatch('core/editor').editPost({ |
|
9582 status: status |
|
9583 }); |
|
9584 } |
|
9585 }; |
|
9586 }))(PostPendingStatus)); |
|
9587 |
|
9588 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-pingbacks/index.js |
|
9589 |
|
9590 |
|
9591 |
|
9592 /** |
|
9593 * WordPress dependencies |
|
9594 */ |
|
9595 |
|
9596 |
|
9597 |
|
9598 |
|
9599 |
|
9600 function PostPingbacks(_ref) { |
|
9601 var _ref$pingStatus = _ref.pingStatus, |
|
9602 pingStatus = _ref$pingStatus === void 0 ? 'open' : _ref$pingStatus, |
|
9603 props = Object(objectWithoutProperties["a" /* default */])(_ref, ["pingStatus"]); |
|
9604 |
|
9605 var onTogglePingback = function onTogglePingback() { |
|
9606 return props.editPost({ |
|
9607 ping_status: pingStatus === 'open' ? 'closed' : 'open' |
|
9608 }); |
|
9609 }; |
|
9610 |
|
9611 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["CheckboxControl"], { |
|
9612 label: Object(external_this_wp_i18n_["__"])('Allow Pingbacks & Trackbacks'), |
|
9613 checked: pingStatus === 'open', |
|
9614 onChange: onTogglePingback |
|
9615 }); |
|
9616 } |
|
9617 |
|
9618 /* harmony default export */ var post_pingbacks = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
9619 return { |
|
9620 pingStatus: select('core/editor').getEditedPostAttribute('ping_status') |
|
9621 }; |
|
9622 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
9623 return { |
|
9624 editPost: dispatch('core/editor').editPost |
|
9625 }; |
|
9626 })])(PostPingbacks)); |
|
9627 |
|
9628 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-button/label.js |
|
9629 /** |
|
9630 * External dependencies |
|
9631 */ |
|
9632 |
|
9633 /** |
|
9634 * WordPress dependencies |
|
9635 */ |
|
9636 |
|
9637 |
|
9638 |
|
9639 |
|
9640 function PublishButtonLabel(_ref) { |
|
9641 var isPublished = _ref.isPublished, |
|
9642 isBeingScheduled = _ref.isBeingScheduled, |
|
9643 isSaving = _ref.isSaving, |
|
9644 isPublishing = _ref.isPublishing, |
|
9645 hasPublishAction = _ref.hasPublishAction, |
|
9646 isAutosaving = _ref.isAutosaving; |
|
9647 |
|
9648 if (isPublishing) { |
|
9649 return Object(external_this_wp_i18n_["__"])('Publishing…'); |
|
9650 } else if (isPublished && isSaving && !isAutosaving) { |
|
9651 return Object(external_this_wp_i18n_["__"])('Updating…'); |
|
9652 } else if (isBeingScheduled && isSaving && !isAutosaving) { |
|
9653 return Object(external_this_wp_i18n_["__"])('Scheduling…'); |
|
9654 } |
|
9655 |
|
9656 if (!hasPublishAction) { |
|
9657 return Object(external_this_wp_i18n_["__"])('Submit for Review'); |
|
9658 } else if (isPublished) { |
|
9659 return Object(external_this_wp_i18n_["__"])('Update'); |
|
9660 } else if (isBeingScheduled) { |
|
9661 return Object(external_this_wp_i18n_["__"])('Schedule'); |
|
9662 } |
|
9663 |
|
9664 return Object(external_this_wp_i18n_["__"])('Publish'); |
|
9665 } |
|
9666 /* harmony default export */ var post_publish_button_label = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, _ref2) { |
|
9667 var forceIsSaving = _ref2.forceIsSaving; |
|
9668 |
|
9669 var _select = select('core/editor'), |
|
9670 isCurrentPostPublished = _select.isCurrentPostPublished, |
|
9671 isEditedPostBeingScheduled = _select.isEditedPostBeingScheduled, |
|
9672 isSavingPost = _select.isSavingPost, |
|
9673 isPublishingPost = _select.isPublishingPost, |
|
9674 getCurrentPost = _select.getCurrentPost, |
|
9675 getCurrentPostType = _select.getCurrentPostType, |
|
9676 isAutosavingPost = _select.isAutosavingPost; |
|
9677 |
|
9678 return { |
|
9679 isPublished: isCurrentPostPublished(), |
|
9680 isBeingScheduled: isEditedPostBeingScheduled(), |
|
9681 isSaving: forceIsSaving || isSavingPost(), |
|
9682 isPublishing: isPublishingPost(), |
|
9683 hasPublishAction: Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-publish'], false), |
|
9684 postType: getCurrentPostType(), |
|
9685 isAutosaving: isAutosavingPost() |
|
9686 }; |
|
9687 })])(PublishButtonLabel)); |
|
9688 |
|
9689 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-button/index.js |
|
9690 |
|
9691 |
|
9692 |
|
9693 |
|
9694 |
|
9695 |
|
9696 |
|
9697 |
|
9698 /** |
|
9699 * External dependencies |
|
9700 */ |
|
9701 |
|
9702 /** |
|
9703 * WordPress dependencies |
|
9704 */ |
|
9705 |
|
9706 |
|
9707 |
|
9708 |
|
9709 |
|
9710 |
|
9711 |
|
9712 /** |
|
9713 * Internal dependencies |
|
9714 */ |
|
9715 |
|
9716 |
|
9717 var post_publish_button_PostPublishButton = |
|
9718 /*#__PURE__*/ |
|
9719 function (_Component) { |
|
9720 Object(inherits["a" /* default */])(PostPublishButton, _Component); |
|
9721 |
|
9722 function PostPublishButton(props) { |
|
9723 var _this; |
|
9724 |
|
9725 Object(classCallCheck["a" /* default */])(this, PostPublishButton); |
|
9726 |
|
9727 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(PostPublishButton).call(this, props)); |
|
9728 _this.buttonNode = Object(external_this_wp_element_["createRef"])(); |
|
9729 return _this; |
|
9730 } |
|
9731 |
|
9732 Object(createClass["a" /* default */])(PostPublishButton, [{ |
|
9733 key: "componentDidMount", |
|
9734 value: function componentDidMount() { |
|
9735 if (this.props.focusOnMount) { |
|
9736 this.buttonNode.current.focus(); |
|
9737 } |
|
9738 } |
|
9739 }, { |
|
9740 key: "render", |
|
9741 value: function render() { |
|
9742 var _this$props = this.props, |
|
9743 forceIsDirty = _this$props.forceIsDirty, |
|
9744 forceIsSaving = _this$props.forceIsSaving, |
|
9745 hasPublishAction = _this$props.hasPublishAction, |
|
9746 isBeingScheduled = _this$props.isBeingScheduled, |
|
9747 isOpen = _this$props.isOpen, |
|
9748 isPostSavingLocked = _this$props.isPostSavingLocked, |
|
9749 isPublishable = _this$props.isPublishable, |
|
9750 isPublished = _this$props.isPublished, |
|
9751 isSaveable = _this$props.isSaveable, |
|
9752 isSaving = _this$props.isSaving, |
|
9753 isToggle = _this$props.isToggle, |
|
9754 onSave = _this$props.onSave, |
|
9755 onStatusChange = _this$props.onStatusChange, |
|
9756 _this$props$onSubmit = _this$props.onSubmit, |
|
9757 onSubmit = _this$props$onSubmit === void 0 ? external_lodash_["noop"] : _this$props$onSubmit, |
|
9758 onToggle = _this$props.onToggle, |
|
9759 visibility = _this$props.visibility; |
|
9760 var isButtonDisabled = isSaving || forceIsSaving || !isSaveable || isPostSavingLocked || !isPublishable && !forceIsDirty; |
|
9761 var isToggleDisabled = isPublished || isSaving || forceIsSaving || !isSaveable || !isPublishable && !forceIsDirty; |
|
9762 var publishStatus; |
|
9763 |
|
9764 if (!hasPublishAction) { |
|
9765 publishStatus = 'pending'; |
|
9766 } else if (isBeingScheduled) { |
|
9767 publishStatus = 'future'; |
|
9768 } else if (visibility === 'private') { |
|
9769 publishStatus = 'private'; |
|
9770 } else { |
|
9771 publishStatus = 'publish'; |
|
9772 } |
|
9773 |
|
9774 var onClickButton = function onClickButton() { |
|
9775 if (isButtonDisabled) { |
|
9776 return; |
|
9777 } |
|
9778 |
|
9779 onSubmit(); |
|
9780 onStatusChange(publishStatus); |
|
9781 onSave(); |
|
9782 }; |
|
9783 |
|
9784 var onClickToggle = function onClickToggle() { |
|
9785 if (isToggleDisabled) { |
|
9786 return; |
|
9787 } |
|
9788 |
|
9789 onToggle(); |
|
9790 }; |
|
9791 |
|
9792 var buttonProps = { |
|
9793 'aria-disabled': isButtonDisabled, |
|
9794 className: 'editor-post-publish-button', |
|
9795 isBusy: isSaving && isPublished, |
|
9796 isLarge: true, |
|
9797 isPrimary: true, |
|
9798 onClick: onClickButton |
|
9799 }; |
|
9800 var toggleProps = { |
|
9801 'aria-disabled': isToggleDisabled, |
|
9802 'aria-expanded': isOpen, |
|
9803 className: 'editor-post-publish-panel__toggle', |
|
9804 isBusy: isSaving && isPublished, |
|
9805 isPrimary: true, |
|
9806 onClick: onClickToggle |
|
9807 }; |
|
9808 var toggleChildren = isBeingScheduled ? Object(external_this_wp_i18n_["__"])('Schedule…') : Object(external_this_wp_i18n_["__"])('Publish…'); |
|
9809 var buttonChildren = Object(external_this_wp_element_["createElement"])(post_publish_button_label, { |
|
9810 forceIsSaving: forceIsSaving |
|
9811 }); |
|
9812 var componentProps = isToggle ? toggleProps : buttonProps; |
|
9813 var componentChildren = isToggle ? toggleChildren : buttonChildren; |
|
9814 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], Object(esm_extends["a" /* default */])({ |
|
9815 ref: this.buttonNode |
|
9816 }, componentProps), componentChildren, Object(external_this_wp_element_["createElement"])(external_this_wp_nux_["DotTip"], { |
|
9817 tipId: "core/editor.publish" |
|
9818 }, Object(external_this_wp_i18n_["__"])('Finished writing? That’s great, let’s get this published right now. Just click “Publish” and you’re good to go.'))); |
|
9819 } |
|
9820 }]); |
|
9821 |
|
9822 return PostPublishButton; |
|
9823 }(external_this_wp_element_["Component"]); |
|
9824 /* harmony default export */ var post_publish_button = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
9825 var _select = select('core/editor'), |
|
9826 isSavingPost = _select.isSavingPost, |
|
9827 isEditedPostBeingScheduled = _select.isEditedPostBeingScheduled, |
|
9828 getEditedPostVisibility = _select.getEditedPostVisibility, |
|
9829 isCurrentPostPublished = _select.isCurrentPostPublished, |
|
9830 isEditedPostSaveable = _select.isEditedPostSaveable, |
|
9831 isEditedPostPublishable = _select.isEditedPostPublishable, |
|
9832 isPostSavingLocked = _select.isPostSavingLocked, |
|
9833 getCurrentPost = _select.getCurrentPost, |
|
9834 getCurrentPostType = _select.getCurrentPostType; |
|
9835 |
|
9836 return { |
|
9837 isSaving: isSavingPost(), |
|
9838 isBeingScheduled: isEditedPostBeingScheduled(), |
|
9839 visibility: getEditedPostVisibility(), |
|
9840 isSaveable: isEditedPostSaveable(), |
|
9841 isPostSavingLocked: isPostSavingLocked(), |
|
9842 isPublishable: isEditedPostPublishable(), |
|
9843 isPublished: isCurrentPostPublished(), |
|
9844 hasPublishAction: Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-publish'], false), |
|
9845 postType: getCurrentPostType() |
|
9846 }; |
|
9847 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
9848 var _dispatch = dispatch('core/editor'), |
|
9849 editPost = _dispatch.editPost, |
|
9850 savePost = _dispatch.savePost; |
|
9851 |
|
9852 return { |
|
9853 onStatusChange: function onStatusChange(status) { |
|
9854 return editPost({ |
|
9855 status: status |
|
9856 }); |
|
9857 }, |
|
9858 onSave: savePost |
|
9859 }; |
|
9860 })])(post_publish_button_PostPublishButton)); |
|
9861 |
|
9862 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/utils.js |
|
9863 /** |
|
9864 * WordPress dependencies |
|
9865 */ |
|
9866 |
|
9867 var visibilityOptions = [{ |
|
9868 value: 'public', |
|
9869 label: Object(external_this_wp_i18n_["__"])('Public'), |
|
9870 info: Object(external_this_wp_i18n_["__"])('Visible to everyone.') |
|
9871 }, { |
|
9872 value: 'private', |
|
9873 label: Object(external_this_wp_i18n_["__"])('Private'), |
|
9874 info: Object(external_this_wp_i18n_["__"])('Only visible to site admins and editors.') |
|
9875 }, { |
|
9876 value: 'password', |
|
9877 label: Object(external_this_wp_i18n_["__"])('Password Protected'), |
|
9878 info: Object(external_this_wp_i18n_["__"])('Protected with a password you choose. Only those with the password can view this post.') |
|
9879 }]; |
|
9880 |
|
9881 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/index.js |
|
9882 |
|
9883 |
|
9884 |
|
9885 |
|
9886 |
|
9887 |
|
9888 |
|
9889 |
|
9890 /** |
|
9891 * WordPress dependencies |
|
9892 */ |
|
9893 |
|
9894 |
|
9895 |
|
9896 |
|
9897 /** |
|
9898 * Internal dependencies |
|
9899 */ |
|
9900 |
|
9901 |
|
9902 var post_visibility_PostVisibility = |
|
9903 /*#__PURE__*/ |
|
9904 function (_Component) { |
|
9905 Object(inherits["a" /* default */])(PostVisibility, _Component); |
|
9906 |
|
9907 function PostVisibility(props) { |
|
9908 var _this; |
|
9909 |
|
9910 Object(classCallCheck["a" /* default */])(this, PostVisibility); |
|
9911 |
|
9912 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(PostVisibility).apply(this, arguments)); |
|
9913 _this.setPublic = _this.setPublic.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
9914 _this.setPrivate = _this.setPrivate.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
9915 _this.setPasswordProtected = _this.setPasswordProtected.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
9916 _this.updatePassword = _this.updatePassword.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
9917 _this.state = { |
|
9918 hasPassword: !!props.password |
|
9919 }; |
|
9920 return _this; |
|
9921 } |
|
9922 |
|
9923 Object(createClass["a" /* default */])(PostVisibility, [{ |
|
9924 key: "setPublic", |
|
9925 value: function setPublic() { |
|
9926 var _this$props = this.props, |
|
9927 visibility = _this$props.visibility, |
|
9928 onUpdateVisibility = _this$props.onUpdateVisibility, |
|
9929 status = _this$props.status; |
|
9930 onUpdateVisibility(visibility === 'private' ? 'draft' : status); |
|
9931 this.setState({ |
|
9932 hasPassword: false |
|
9933 }); |
|
9934 } |
|
9935 }, { |
|
9936 key: "setPrivate", |
|
9937 value: function setPrivate() { |
|
9938 if (!window.confirm(Object(external_this_wp_i18n_["__"])('Would you like to privately publish this post now?'))) { |
|
9939 // eslint-disable-line no-alert |
|
9940 return; |
|
9941 } |
|
9942 |
|
9943 var _this$props2 = this.props, |
|
9944 onUpdateVisibility = _this$props2.onUpdateVisibility, |
|
9945 onSave = _this$props2.onSave; |
|
9946 onUpdateVisibility('private'); |
|
9947 this.setState({ |
|
9948 hasPassword: false |
|
9949 }); |
|
9950 onSave(); |
|
9951 } |
|
9952 }, { |
|
9953 key: "setPasswordProtected", |
|
9954 value: function setPasswordProtected() { |
|
9955 var _this$props3 = this.props, |
|
9956 visibility = _this$props3.visibility, |
|
9957 onUpdateVisibility = _this$props3.onUpdateVisibility, |
|
9958 status = _this$props3.status, |
|
9959 password = _this$props3.password; |
|
9960 onUpdateVisibility(visibility === 'private' ? 'draft' : status, password || ''); |
|
9961 this.setState({ |
|
9962 hasPassword: true |
|
9963 }); |
|
9964 } |
|
9965 }, { |
|
9966 key: "updatePassword", |
|
9967 value: function updatePassword(event) { |
|
9968 var _this$props4 = this.props, |
|
9969 status = _this$props4.status, |
|
9970 onUpdateVisibility = _this$props4.onUpdateVisibility; |
|
9971 onUpdateVisibility(status, event.target.value); |
|
9972 } |
|
9973 }, { |
|
9974 key: "render", |
|
9975 value: function render() { |
|
9976 var _this$props5 = this.props, |
|
9977 visibility = _this$props5.visibility, |
|
9978 password = _this$props5.password, |
|
9979 instanceId = _this$props5.instanceId; |
|
9980 var visibilityHandlers = { |
|
9981 public: { |
|
9982 onSelect: this.setPublic, |
|
9983 checked: visibility === 'public' && !this.state.hasPassword |
|
9984 }, |
|
9985 private: { |
|
9986 onSelect: this.setPrivate, |
|
9987 checked: visibility === 'private' |
|
9988 }, |
|
9989 password: { |
|
9990 onSelect: this.setPasswordProtected, |
|
9991 checked: this.state.hasPassword |
|
9992 } |
|
9993 }; |
|
9994 return [Object(external_this_wp_element_["createElement"])("fieldset", { |
|
9995 key: "visibility-selector", |
|
9996 className: "editor-post-visibility__dialog-fieldset" |
|
9997 }, Object(external_this_wp_element_["createElement"])("legend", { |
|
9998 className: "editor-post-visibility__dialog-legend" |
|
9999 }, Object(external_this_wp_i18n_["__"])('Post Visibility')), visibilityOptions.map(function (_ref) { |
|
10000 var value = _ref.value, |
|
10001 label = _ref.label, |
|
10002 info = _ref.info; |
|
10003 return Object(external_this_wp_element_["createElement"])("div", { |
|
10004 key: value, |
|
10005 className: "editor-post-visibility__choice" |
|
10006 }, Object(external_this_wp_element_["createElement"])("input", { |
|
10007 type: "radio", |
|
10008 name: "editor-post-visibility__setting-".concat(instanceId), |
|
10009 value: value, |
|
10010 onChange: visibilityHandlers[value].onSelect, |
|
10011 checked: visibilityHandlers[value].checked, |
|
10012 id: "editor-post-".concat(value, "-").concat(instanceId), |
|
10013 "aria-describedby": "editor-post-".concat(value, "-").concat(instanceId, "-description"), |
|
10014 className: "editor-post-visibility__dialog-radio" |
|
10015 }), Object(external_this_wp_element_["createElement"])("label", { |
|
10016 htmlFor: "editor-post-".concat(value, "-").concat(instanceId), |
|
10017 className: "editor-post-visibility__dialog-label" |
|
10018 }, label), Object(external_this_wp_element_["createElement"])("p", { |
|
10019 id: "editor-post-".concat(value, "-").concat(instanceId, "-description"), |
|
10020 className: "editor-post-visibility__dialog-info" |
|
10021 }, info)); |
|
10022 })), this.state.hasPassword && Object(external_this_wp_element_["createElement"])("div", { |
|
10023 className: "editor-post-visibility__dialog-password", |
|
10024 key: "password-selector" |
|
10025 }, Object(external_this_wp_element_["createElement"])("label", { |
|
10026 htmlFor: "editor-post-visibility__dialog-password-input-".concat(instanceId), |
|
10027 className: "screen-reader-text" |
|
10028 }, Object(external_this_wp_i18n_["__"])('Create password')), Object(external_this_wp_element_["createElement"])("input", { |
|
10029 className: "editor-post-visibility__dialog-password-input", |
|
10030 id: "editor-post-visibility__dialog-password-input-".concat(instanceId), |
|
10031 type: "text", |
|
10032 onChange: this.updatePassword, |
|
10033 value: password, |
|
10034 placeholder: Object(external_this_wp_i18n_["__"])('Use a secure password') |
|
10035 }))]; |
|
10036 } |
|
10037 }]); |
|
10038 |
|
10039 return PostVisibility; |
|
10040 }(external_this_wp_element_["Component"]); |
|
10041 /* harmony default export */ var post_visibility = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
10042 var _select = select('core/editor'), |
|
10043 getEditedPostAttribute = _select.getEditedPostAttribute, |
|
10044 getEditedPostVisibility = _select.getEditedPostVisibility; |
|
10045 |
|
10046 return { |
|
10047 status: getEditedPostAttribute('status'), |
|
10048 visibility: getEditedPostVisibility(), |
|
10049 password: getEditedPostAttribute('password') |
|
10050 }; |
|
10051 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
10052 var _dispatch = dispatch('core/editor'), |
|
10053 savePost = _dispatch.savePost, |
|
10054 editPost = _dispatch.editPost; |
|
10055 |
|
10056 return { |
|
10057 onSave: savePost, |
|
10058 onUpdateVisibility: function onUpdateVisibility(status) { |
|
10059 var password = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null; |
|
10060 editPost({ |
|
10061 status: status, |
|
10062 password: password |
|
10063 }); |
|
10064 } |
|
10065 }; |
|
10066 }), external_this_wp_compose_["withInstanceId"]])(post_visibility_PostVisibility)); |
|
10067 |
|
10068 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/label.js |
|
10069 /** |
|
10070 * External dependencies |
|
10071 */ |
|
10072 |
|
10073 /** |
|
10074 * WordPress dependencies |
|
10075 */ |
|
10076 |
|
10077 |
|
10078 /** |
|
10079 * Internal dependencies |
|
10080 */ |
|
10081 |
|
10082 |
|
10083 |
|
10084 function PostVisibilityLabel(_ref) { |
|
10085 var visibility = _ref.visibility; |
|
10086 |
|
10087 var getVisibilityLabel = function getVisibilityLabel() { |
|
10088 return Object(external_lodash_["find"])(visibilityOptions, { |
|
10089 value: visibility |
|
10090 }).label; |
|
10091 }; |
|
10092 |
|
10093 return getVisibilityLabel(visibility); |
|
10094 } |
|
10095 |
|
10096 /* harmony default export */ var post_visibility_label = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
10097 return { |
|
10098 visibility: select('core/editor').getEditedPostVisibility() |
|
10099 }; |
|
10100 })(PostVisibilityLabel)); |
|
10101 |
|
10102 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-schedule/index.js |
|
10103 |
|
10104 |
|
10105 /** |
|
10106 * WordPress dependencies |
|
10107 */ |
|
10108 |
|
10109 |
|
10110 |
|
10111 |
|
10112 function PostSchedule(_ref) { |
|
10113 var date = _ref.date, |
|
10114 onUpdateDate = _ref.onUpdateDate; |
|
10115 |
|
10116 var settings = Object(external_this_wp_date_["__experimentalGetSettings"])(); // To know if the current timezone is a 12 hour time with look for "a" in the time format |
|
10117 // We also make sure this a is not escaped by a "/" |
|
10118 |
|
10119 |
|
10120 var is12HourTime = /a(?!\\)/i.test(settings.formats.time.toLowerCase() // Test only the lower case a |
|
10121 .replace(/\\\\/g, '') // Replace "//" with empty strings |
|
10122 .split('').reverse().join('') // Reverse the string and test for "a" not followed by a slash |
|
10123 ); |
|
10124 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["DateTimePicker"], { |
|
10125 key: "date-time-picker", |
|
10126 currentDate: date, |
|
10127 onChange: onUpdateDate, |
|
10128 is12Hour: is12HourTime |
|
10129 }); |
|
10130 } |
|
10131 /* harmony default export */ var post_schedule = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
10132 return { |
|
10133 date: select('core/editor').getEditedPostAttribute('date') |
|
10134 }; |
|
10135 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
10136 return { |
|
10137 onUpdateDate: function onUpdateDate(date) { |
|
10138 dispatch('core/editor').editPost({ |
|
10139 date: date |
|
10140 }); |
|
10141 } |
|
10142 }; |
|
10143 })])(PostSchedule)); |
|
10144 |
|
10145 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-schedule/label.js |
|
10146 /** |
|
10147 * WordPress dependencies |
|
10148 */ |
|
10149 |
|
10150 |
|
10151 |
|
10152 function PostScheduleLabel(_ref) { |
|
10153 var date = _ref.date, |
|
10154 isFloating = _ref.isFloating; |
|
10155 |
|
10156 var settings = Object(external_this_wp_date_["__experimentalGetSettings"])(); |
|
10157 |
|
10158 return date && !isFloating ? Object(external_this_wp_date_["dateI18n"])(settings.formats.datetimeAbbreviated, date) : Object(external_this_wp_i18n_["__"])('Immediately'); |
|
10159 } |
|
10160 /* harmony default export */ var post_schedule_label = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
10161 return { |
|
10162 date: select('core/editor').getEditedPostAttribute('date'), |
|
10163 isFloating: select('core/editor').isEditedPostDateFloating() |
|
10164 }; |
|
10165 })(PostScheduleLabel)); |
|
10166 |
|
10167 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/flat-term-selector.js |
|
10168 |
|
10169 |
|
10170 |
|
10171 |
|
10172 |
|
10173 |
|
10174 |
|
10175 |
|
10176 |
|
10177 |
|
10178 /** |
|
10179 * External dependencies |
|
10180 */ |
|
10181 |
|
10182 /** |
|
10183 * WordPress dependencies |
|
10184 */ |
|
10185 |
|
10186 |
|
10187 |
|
10188 |
|
10189 |
|
10190 |
|
10191 |
|
10192 |
|
10193 /** |
|
10194 * Module constants |
|
10195 */ |
|
10196 |
|
10197 var DEFAULT_QUERY = { |
|
10198 per_page: -1, |
|
10199 orderby: 'count', |
|
10200 order: 'desc', |
|
10201 _fields: 'id,name' |
|
10202 }; |
|
10203 var MAX_TERMS_SUGGESTIONS = 20; |
|
10204 |
|
10205 var isSameTermName = function isSameTermName(termA, termB) { |
|
10206 return termA.toLowerCase() === termB.toLowerCase(); |
|
10207 }; |
|
10208 /** |
|
10209 * Returns a term object with name unescaped. |
|
10210 * The unescape of the name propery is done using lodash unescape function. |
|
10211 * |
|
10212 * @param {Object} term The term object to unescape. |
|
10213 * |
|
10214 * @return {Object} Term object with name property unescaped. |
|
10215 */ |
|
10216 |
|
10217 |
|
10218 var flat_term_selector_unescapeTerm = function unescapeTerm(term) { |
|
10219 return Object(objectSpread["a" /* default */])({}, term, { |
|
10220 name: Object(external_lodash_["unescape"])(term.name) |
|
10221 }); |
|
10222 }; |
|
10223 /** |
|
10224 * Returns an array of term objects with names unescaped. |
|
10225 * The unescape of each term is performed using the unescapeTerm function. |
|
10226 * |
|
10227 * @param {Object[]} terms Array of term objects to unescape. |
|
10228 * |
|
10229 * @return {Object[]} Array of therm objects unscaped. |
|
10230 */ |
|
10231 |
|
10232 |
|
10233 var flat_term_selector_unescapeTerms = function unescapeTerms(terms) { |
|
10234 return Object(external_lodash_["map"])(terms, flat_term_selector_unescapeTerm); |
|
10235 }; |
|
10236 |
|
10237 var flat_term_selector_FlatTermSelector = |
|
10238 /*#__PURE__*/ |
|
10239 function (_Component) { |
|
10240 Object(inherits["a" /* default */])(FlatTermSelector, _Component); |
|
10241 |
|
10242 function FlatTermSelector() { |
|
10243 var _this; |
|
10244 |
|
10245 Object(classCallCheck["a" /* default */])(this, FlatTermSelector); |
|
10246 |
|
10247 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(FlatTermSelector).apply(this, arguments)); |
|
10248 _this.onChange = _this.onChange.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
10249 _this.searchTerms = Object(external_lodash_["throttle"])(_this.searchTerms.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))), 500); |
|
10250 _this.findOrCreateTerm = _this.findOrCreateTerm.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
10251 _this.state = { |
|
10252 loading: !Object(external_lodash_["isEmpty"])(_this.props.terms), |
|
10253 availableTerms: [], |
|
10254 selectedTerms: [] |
|
10255 }; |
|
10256 return _this; |
|
10257 } |
|
10258 |
|
10259 Object(createClass["a" /* default */])(FlatTermSelector, [{ |
|
10260 key: "componentDidMount", |
|
10261 value: function componentDidMount() { |
|
10262 var _this2 = this; |
|
10263 |
|
10264 if (!Object(external_lodash_["isEmpty"])(this.props.terms)) { |
|
10265 this.initRequest = this.fetchTerms({ |
|
10266 include: this.props.terms.join(','), |
|
10267 per_page: -1 |
|
10268 }); |
|
10269 this.initRequest.then(function () { |
|
10270 _this2.setState({ |
|
10271 loading: false |
|
10272 }); |
|
10273 }, function (xhr) { |
|
10274 if (xhr.statusText === 'abort') { |
|
10275 return; |
|
10276 } |
|
10277 |
|
10278 _this2.setState({ |
|
10279 loading: false |
|
10280 }); |
|
10281 }); |
|
10282 } |
|
10283 } |
|
10284 }, { |
|
10285 key: "componentWillUnmount", |
|
10286 value: function componentWillUnmount() { |
|
10287 Object(external_lodash_["invoke"])(this.initRequest, ['abort']); |
|
10288 Object(external_lodash_["invoke"])(this.searchRequest, ['abort']); |
|
10289 } |
|
10290 }, { |
|
10291 key: "componentDidUpdate", |
|
10292 value: function componentDidUpdate(prevProps) { |
|
10293 if (prevProps.terms !== this.props.terms) { |
|
10294 this.updateSelectedTerms(this.props.terms); |
|
10295 } |
|
10296 } |
|
10297 }, { |
|
10298 key: "fetchTerms", |
|
10299 value: function fetchTerms() { |
|
10300 var _this3 = this; |
|
10301 |
|
10302 var params = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; |
|
10303 var taxonomy = this.props.taxonomy; |
|
10304 |
|
10305 var query = Object(objectSpread["a" /* default */])({}, DEFAULT_QUERY, params); |
|
10306 |
|
10307 var request = external_this_wp_apiFetch_default()({ |
|
10308 path: Object(external_this_wp_url_["addQueryArgs"])("/wp/v2/".concat(taxonomy.rest_base), query) |
|
10309 }); |
|
10310 request.then(flat_term_selector_unescapeTerms).then(function (terms) { |
|
10311 _this3.setState(function (state) { |
|
10312 return { |
|
10313 availableTerms: state.availableTerms.concat(terms.filter(function (term) { |
|
10314 return !Object(external_lodash_["find"])(state.availableTerms, function (availableTerm) { |
|
10315 return availableTerm.id === term.id; |
|
10316 }); |
|
10317 })) |
|
10318 }; |
|
10319 }); |
|
10320 |
|
10321 _this3.updateSelectedTerms(_this3.props.terms); |
|
10322 }); |
|
10323 return request; |
|
10324 } |
|
10325 }, { |
|
10326 key: "updateSelectedTerms", |
|
10327 value: function updateSelectedTerms() { |
|
10328 var _this4 = this; |
|
10329 |
|
10330 var terms = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : []; |
|
10331 var selectedTerms = terms.reduce(function (result, termId) { |
|
10332 var termObject = Object(external_lodash_["find"])(_this4.state.availableTerms, function (term) { |
|
10333 return term.id === termId; |
|
10334 }); |
|
10335 |
|
10336 if (termObject) { |
|
10337 result.push(termObject.name); |
|
10338 } |
|
10339 |
|
10340 return result; |
|
10341 }, []); |
|
10342 this.setState({ |
|
10343 selectedTerms: selectedTerms |
|
10344 }); |
|
10345 } |
|
10346 }, { |
|
10347 key: "findOrCreateTerm", |
|
10348 value: function findOrCreateTerm(termName) { |
|
10349 var _this5 = this; |
|
10350 |
|
10351 var taxonomy = this.props.taxonomy; |
|
10352 var termNameEscaped = Object(external_lodash_["escape"])(termName); // Tries to create a term or fetch it if it already exists. |
|
10353 |
|
10354 return external_this_wp_apiFetch_default()({ |
|
10355 path: "/wp/v2/".concat(taxonomy.rest_base), |
|
10356 method: 'POST', |
|
10357 data: { |
|
10358 name: termNameEscaped |
|
10359 } |
|
10360 }).catch(function (error) { |
|
10361 var errorCode = error.code; |
|
10362 |
|
10363 if (errorCode === 'term_exists') { |
|
10364 // If the terms exist, fetch it instead of creating a new one. |
|
10365 _this5.addRequest = external_this_wp_apiFetch_default()({ |
|
10366 path: Object(external_this_wp_url_["addQueryArgs"])("/wp/v2/".concat(taxonomy.rest_base), Object(objectSpread["a" /* default */])({}, DEFAULT_QUERY, { |
|
10367 search: termNameEscaped |
|
10368 })) |
|
10369 }).then(flat_term_selector_unescapeTerms); |
|
10370 return _this5.addRequest.then(function (searchResult) { |
|
10371 return Object(external_lodash_["find"])(searchResult, function (result) { |
|
10372 return isSameTermName(result.name, termName); |
|
10373 }); |
|
10374 }); |
|
10375 } |
|
10376 |
|
10377 return Promise.reject(error); |
|
10378 }).then(flat_term_selector_unescapeTerm); |
|
10379 } |
|
10380 }, { |
|
10381 key: "onChange", |
|
10382 value: function onChange(termNames) { |
|
10383 var _this6 = this; |
|
10384 |
|
10385 var uniqueTerms = Object(external_lodash_["uniqBy"])(termNames, function (term) { |
|
10386 return term.toLowerCase(); |
|
10387 }); |
|
10388 this.setState({ |
|
10389 selectedTerms: uniqueTerms |
|
10390 }); |
|
10391 var newTermNames = uniqueTerms.filter(function (termName) { |
|
10392 return !Object(external_lodash_["find"])(_this6.state.availableTerms, function (term) { |
|
10393 return isSameTermName(term.name, termName); |
|
10394 }); |
|
10395 }); |
|
10396 |
|
10397 var termNamesToIds = function termNamesToIds(names, availableTerms) { |
|
10398 return names.map(function (termName) { |
|
10399 return Object(external_lodash_["find"])(availableTerms, function (term) { |
|
10400 return isSameTermName(term.name, termName); |
|
10401 }).id; |
|
10402 }); |
|
10403 }; |
|
10404 |
|
10405 if (newTermNames.length === 0) { |
|
10406 return this.props.onUpdateTerms(termNamesToIds(uniqueTerms, this.state.availableTerms), this.props.taxonomy.rest_base); |
|
10407 } |
|
10408 |
|
10409 Promise.all(newTermNames.map(this.findOrCreateTerm)).then(function (newTerms) { |
|
10410 var newAvailableTerms = _this6.state.availableTerms.concat(newTerms); |
|
10411 |
|
10412 _this6.setState({ |
|
10413 availableTerms: newAvailableTerms |
|
10414 }); |
|
10415 |
|
10416 return _this6.props.onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms), _this6.props.taxonomy.rest_base); |
|
10417 }); |
|
10418 } |
|
10419 }, { |
|
10420 key: "searchTerms", |
|
10421 value: function searchTerms() { |
|
10422 var search = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ''; |
|
10423 Object(external_lodash_["invoke"])(this.searchRequest, ['abort']); |
|
10424 this.searchRequest = this.fetchTerms({ |
|
10425 search: search |
|
10426 }); |
|
10427 } |
|
10428 }, { |
|
10429 key: "render", |
|
10430 value: function render() { |
|
10431 var _this$props = this.props, |
|
10432 slug = _this$props.slug, |
|
10433 taxonomy = _this$props.taxonomy, |
|
10434 hasAssignAction = _this$props.hasAssignAction; |
|
10435 |
|
10436 if (!hasAssignAction) { |
|
10437 return null; |
|
10438 } |
|
10439 |
|
10440 var _this$state = this.state, |
|
10441 loading = _this$state.loading, |
|
10442 availableTerms = _this$state.availableTerms, |
|
10443 selectedTerms = _this$state.selectedTerms; |
|
10444 var termNames = availableTerms.map(function (term) { |
|
10445 return term.name; |
|
10446 }); |
|
10447 var newTermLabel = Object(external_lodash_["get"])(taxonomy, ['labels', 'add_new_item'], slug === 'post_tag' ? Object(external_this_wp_i18n_["__"])('Add New Tag') : Object(external_this_wp_i18n_["__"])('Add New Term')); |
|
10448 var singularName = Object(external_lodash_["get"])(taxonomy, ['labels', 'singular_name'], slug === 'post_tag' ? Object(external_this_wp_i18n_["__"])('Tag') : Object(external_this_wp_i18n_["__"])('Term')); |
|
10449 var termAddedLabel = Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["_x"])('%s added', 'term'), singularName); |
|
10450 var termRemovedLabel = Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["_x"])('%s removed', 'term'), singularName); |
|
10451 var removeTermLabel = Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["_x"])('Remove %s', 'term'), singularName); |
|
10452 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["FormTokenField"], { |
|
10453 value: selectedTerms, |
|
10454 suggestions: termNames, |
|
10455 onChange: this.onChange, |
|
10456 onInputChange: this.searchTerms, |
|
10457 maxSuggestions: MAX_TERMS_SUGGESTIONS, |
|
10458 disabled: loading, |
|
10459 label: newTermLabel, |
|
10460 messages: { |
|
10461 added: termAddedLabel, |
|
10462 removed: termRemovedLabel, |
|
10463 remove: removeTermLabel |
|
10464 } |
|
10465 }); |
|
10466 } |
|
10467 }]); |
|
10468 |
|
10469 return FlatTermSelector; |
|
10470 }(external_this_wp_element_["Component"]); |
|
10471 |
|
10472 /* harmony default export */ var flat_term_selector = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select, _ref) { |
|
10473 var slug = _ref.slug; |
|
10474 |
|
10475 var _select = select('core/editor'), |
|
10476 getCurrentPost = _select.getCurrentPost; |
|
10477 |
|
10478 var _select2 = select('core'), |
|
10479 getTaxonomy = _select2.getTaxonomy; |
|
10480 |
|
10481 var taxonomy = getTaxonomy(slug); |
|
10482 return { |
|
10483 hasCreateAction: taxonomy ? Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-create-' + taxonomy.rest_base], false) : false, |
|
10484 hasAssignAction: taxonomy ? Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-assign-' + taxonomy.rest_base], false) : false, |
|
10485 terms: taxonomy ? select('core/editor').getEditedPostAttribute(taxonomy.rest_base) : [], |
|
10486 taxonomy: taxonomy |
|
10487 }; |
|
10488 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
10489 return { |
|
10490 onUpdateTerms: function onUpdateTerms(terms, restBase) { |
|
10491 dispatch('core/editor').editPost(Object(defineProperty["a" /* default */])({}, restBase, terms)); |
|
10492 } |
|
10493 }; |
|
10494 }), Object(external_this_wp_components_["withFilters"])('editor.PostTaxonomyType'))(flat_term_selector_FlatTermSelector)); |
|
10495 |
|
10496 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/maybe-tags-panel.js |
|
10497 |
|
10498 |
|
10499 |
|
10500 |
|
10501 |
|
10502 |
|
10503 |
|
10504 /** |
|
10505 * External dependencies |
|
10506 */ |
|
10507 |
|
10508 /** |
|
10509 * WordPress dependencies |
|
10510 */ |
|
10511 |
|
10512 |
|
10513 |
|
10514 |
|
10515 |
|
10516 |
|
10517 /** |
|
10518 * Internal dependencies |
|
10519 */ |
|
10520 |
|
10521 |
|
10522 |
|
10523 var maybe_tags_panel_TagsPanel = function TagsPanel() { |
|
10524 var panelBodyTitle = [Object(external_this_wp_i18n_["__"])('Suggestion:'), Object(external_this_wp_element_["createElement"])("span", { |
|
10525 className: "editor-post-publish-panel__link", |
|
10526 key: "label" |
|
10527 }, Object(external_this_wp_i18n_["__"])('Add tags'))]; |
|
10528 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["PanelBody"], { |
|
10529 initialOpen: false, |
|
10530 title: panelBodyTitle |
|
10531 }, Object(external_this_wp_element_["createElement"])("p", null, Object(external_this_wp_i18n_["__"])('Tags help users and search engines navigate your site and find your content. Add a few keywords to describe your post.')), Object(external_this_wp_element_["createElement"])(flat_term_selector, { |
|
10532 slug: 'post_tag' |
|
10533 })); |
|
10534 }; |
|
10535 |
|
10536 var maybe_tags_panel_MaybeTagsPanel = |
|
10537 /*#__PURE__*/ |
|
10538 function (_Component) { |
|
10539 Object(inherits["a" /* default */])(MaybeTagsPanel, _Component); |
|
10540 |
|
10541 function MaybeTagsPanel(props) { |
|
10542 var _this; |
|
10543 |
|
10544 Object(classCallCheck["a" /* default */])(this, MaybeTagsPanel); |
|
10545 |
|
10546 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(MaybeTagsPanel).call(this, props)); |
|
10547 _this.state = { |
|
10548 hadTagsWhenOpeningThePanel: props.hasTags |
|
10549 }; |
|
10550 return _this; |
|
10551 } |
|
10552 /* |
|
10553 * We only want to show the tag panel if the post didn't have |
|
10554 * any tags when the user hit the Publish button. |
|
10555 * |
|
10556 * We can't use the prop.hasTags because it'll change to true |
|
10557 * if the user adds a new tag within the pre-publish panel. |
|
10558 * This would force a re-render and a new prop.hasTags check, |
|
10559 * hiding this panel and keeping the user from adding |
|
10560 * more than one tag. |
|
10561 */ |
|
10562 |
|
10563 |
|
10564 Object(createClass["a" /* default */])(MaybeTagsPanel, [{ |
|
10565 key: "render", |
|
10566 value: function render() { |
|
10567 if (!this.state.hadTagsWhenOpeningThePanel) { |
|
10568 return Object(external_this_wp_element_["createElement"])(maybe_tags_panel_TagsPanel, null); |
|
10569 } |
|
10570 |
|
10571 return null; |
|
10572 } |
|
10573 }]); |
|
10574 |
|
10575 return MaybeTagsPanel; |
|
10576 }(external_this_wp_element_["Component"]); |
|
10577 |
|
10578 /* harmony default export */ var maybe_tags_panel = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select) { |
|
10579 var postType = select('core/editor').getCurrentPostType(); |
|
10580 var tagsTaxonomy = select('core').getTaxonomy('post_tag'); |
|
10581 var tags = tagsTaxonomy && select('core/editor').getEditedPostAttribute(tagsTaxonomy.rest_base); |
|
10582 return { |
|
10583 areTagsFetched: tagsTaxonomy !== undefined, |
|
10584 isPostTypeSupported: tagsTaxonomy && Object(external_lodash_["some"])(tagsTaxonomy.types, function (type) { |
|
10585 return type === postType; |
|
10586 }), |
|
10587 hasTags: tags && tags.length |
|
10588 }; |
|
10589 }), Object(external_this_wp_compose_["ifCondition"])(function (_ref) { |
|
10590 var areTagsFetched = _ref.areTagsFetched, |
|
10591 isPostTypeSupported = _ref.isPostTypeSupported; |
|
10592 return isPostTypeSupported && areTagsFetched; |
|
10593 }))(maybe_tags_panel_MaybeTagsPanel)); |
|
10594 |
|
10595 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/maybe-post-format-panel.js |
|
10596 |
|
10597 |
|
10598 /** |
|
10599 * External dependencies |
|
10600 */ |
|
10601 |
|
10602 /** |
|
10603 * WordPress dependencies |
|
10604 */ |
|
10605 |
|
10606 |
|
10607 |
|
10608 |
|
10609 |
|
10610 /** |
|
10611 * Internal dependencies |
|
10612 */ |
|
10613 |
|
10614 |
|
10615 |
|
10616 var maybe_post_format_panel_PostFormatSuggestion = function PostFormatSuggestion(_ref) { |
|
10617 var suggestedPostFormat = _ref.suggestedPostFormat, |
|
10618 suggestionText = _ref.suggestionText, |
|
10619 onUpdatePostFormat = _ref.onUpdatePostFormat; |
|
10620 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
10621 isLink: true, |
|
10622 onClick: function onClick() { |
|
10623 return onUpdatePostFormat(suggestedPostFormat); |
|
10624 } |
|
10625 }, suggestionText); |
|
10626 }; |
|
10627 |
|
10628 var maybe_post_format_panel_PostFormatPanel = function PostFormatPanel(_ref2) { |
|
10629 var suggestion = _ref2.suggestion, |
|
10630 onUpdatePostFormat = _ref2.onUpdatePostFormat; |
|
10631 var panelBodyTitle = [Object(external_this_wp_i18n_["__"])('Suggestion:'), Object(external_this_wp_element_["createElement"])("span", { |
|
10632 className: "editor-post-publish-panel__link", |
|
10633 key: "label" |
|
10634 }, Object(external_this_wp_i18n_["__"])('Use a post format'))]; |
|
10635 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["PanelBody"], { |
|
10636 initialOpen: false, |
|
10637 title: panelBodyTitle |
|
10638 }, Object(external_this_wp_element_["createElement"])("p", null, Object(external_this_wp_i18n_["__"])('Your theme uses post formats to highlight different kinds of content, like images or videos. Apply a post format to see this special styling.')), Object(external_this_wp_element_["createElement"])("p", null, Object(external_this_wp_element_["createElement"])(maybe_post_format_panel_PostFormatSuggestion, { |
|
10639 onUpdatePostFormat: onUpdatePostFormat, |
|
10640 suggestedPostFormat: suggestion.id, |
|
10641 suggestionText: Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["__"])('Apply the "%1$s" format.'), suggestion.caption) |
|
10642 }))); |
|
10643 }; |
|
10644 |
|
10645 var maybe_post_format_panel_getSuggestion = function getSuggestion(supportedFormats, suggestedPostFormat) { |
|
10646 var formats = POST_FORMATS.filter(function (format) { |
|
10647 return Object(external_lodash_["includes"])(supportedFormats, format.id); |
|
10648 }); |
|
10649 return Object(external_lodash_["find"])(formats, function (format) { |
|
10650 return format.id === suggestedPostFormat; |
|
10651 }); |
|
10652 }; |
|
10653 |
|
10654 /* harmony default export */ var maybe_post_format_panel = (Object(external_this_wp_compose_["compose"])(Object(external_this_wp_data_["withSelect"])(function (select) { |
|
10655 var _select = select('core/editor'), |
|
10656 getEditedPostAttribute = _select.getEditedPostAttribute, |
|
10657 getSuggestedPostFormat = _select.getSuggestedPostFormat; |
|
10658 |
|
10659 var supportedFormats = Object(external_lodash_["get"])(select('core').getThemeSupports(), ['formats'], []); |
|
10660 return { |
|
10661 currentPostFormat: getEditedPostAttribute('format'), |
|
10662 suggestion: maybe_post_format_panel_getSuggestion(supportedFormats, getSuggestedPostFormat()) |
|
10663 }; |
|
10664 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
10665 return { |
|
10666 onUpdatePostFormat: function onUpdatePostFormat(postFormat) { |
|
10667 dispatch('core/editor').editPost({ |
|
10668 format: postFormat |
|
10669 }); |
|
10670 } |
|
10671 }; |
|
10672 }), Object(external_this_wp_compose_["ifCondition"])(function (_ref3) { |
|
10673 var suggestion = _ref3.suggestion, |
|
10674 currentPostFormat = _ref3.currentPostFormat; |
|
10675 return suggestion && suggestion.id !== currentPostFormat; |
|
10676 }))(maybe_post_format_panel_PostFormatPanel)); |
|
10677 |
|
10678 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/prepublish.js |
|
10679 |
|
10680 |
|
10681 /** |
|
10682 * External dependencies |
|
10683 */ |
|
10684 |
|
10685 /** |
|
10686 * WordPress dependencies |
|
10687 */ |
|
10688 |
|
10689 |
|
10690 |
|
10691 |
|
10692 |
|
10693 /** |
|
10694 * Internal dependencies |
|
10695 */ |
|
10696 |
|
10697 |
|
10698 |
|
10699 |
|
10700 |
|
10701 |
|
10702 |
|
10703 |
|
10704 function PostPublishPanelPrepublish(_ref) { |
|
10705 var hasPublishAction = _ref.hasPublishAction, |
|
10706 isBeingScheduled = _ref.isBeingScheduled, |
|
10707 children = _ref.children; |
|
10708 var prePublishTitle, prePublishBodyText; |
|
10709 |
|
10710 if (!hasPublishAction) { |
|
10711 prePublishTitle = Object(external_this_wp_i18n_["__"])('Are you ready to submit for review?'); |
|
10712 prePublishBodyText = Object(external_this_wp_i18n_["__"])('When you’re ready, submit your work for review, and an Editor will be able to approve it for you.'); |
|
10713 } else if (isBeingScheduled) { |
|
10714 prePublishTitle = Object(external_this_wp_i18n_["__"])('Are you ready to schedule?'); |
|
10715 prePublishBodyText = Object(external_this_wp_i18n_["__"])('Your work will be published at the specified date and time.'); |
|
10716 } else { |
|
10717 prePublishTitle = Object(external_this_wp_i18n_["__"])('Are you ready to publish?'); |
|
10718 prePublishBodyText = Object(external_this_wp_i18n_["__"])('Double-check your settings before publishing.'); |
|
10719 } |
|
10720 |
|
10721 return Object(external_this_wp_element_["createElement"])("div", { |
|
10722 className: "editor-post-publish-panel__prepublish" |
|
10723 }, Object(external_this_wp_element_["createElement"])("div", null, Object(external_this_wp_element_["createElement"])("strong", null, prePublishTitle)), Object(external_this_wp_element_["createElement"])("p", null, prePublishBodyText), hasPublishAction && Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["PanelBody"], { |
|
10724 initialOpen: false, |
|
10725 title: [Object(external_this_wp_i18n_["__"])('Visibility:'), Object(external_this_wp_element_["createElement"])("span", { |
|
10726 className: "editor-post-publish-panel__link", |
|
10727 key: "label" |
|
10728 }, Object(external_this_wp_element_["createElement"])(post_visibility_label, null))] |
|
10729 }, Object(external_this_wp_element_["createElement"])(post_visibility, null)), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["PanelBody"], { |
|
10730 initialOpen: false, |
|
10731 title: [Object(external_this_wp_i18n_["__"])('Publish:'), Object(external_this_wp_element_["createElement"])("span", { |
|
10732 className: "editor-post-publish-panel__link", |
|
10733 key: "label" |
|
10734 }, Object(external_this_wp_element_["createElement"])(post_schedule_label, null))] |
|
10735 }, Object(external_this_wp_element_["createElement"])(post_schedule, null)), Object(external_this_wp_element_["createElement"])(maybe_post_format_panel, null), Object(external_this_wp_element_["createElement"])(maybe_tags_panel, null), children)); |
|
10736 } |
|
10737 |
|
10738 /* harmony default export */ var prepublish = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
10739 var _select = select('core/editor'), |
|
10740 getCurrentPost = _select.getCurrentPost, |
|
10741 isEditedPostBeingScheduled = _select.isEditedPostBeingScheduled; |
|
10742 |
|
10743 return { |
|
10744 hasPublishAction: Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-publish'], false), |
|
10745 isBeingScheduled: isEditedPostBeingScheduled() |
|
10746 }; |
|
10747 })(PostPublishPanelPrepublish)); |
|
10748 |
|
10749 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/postpublish.js |
|
10750 |
|
10751 |
|
10752 |
|
10753 |
|
10754 |
|
10755 |
|
10756 |
|
10757 |
|
10758 /** |
|
10759 * External dependencies |
|
10760 */ |
|
10761 |
|
10762 /** |
|
10763 * WordPress dependencies |
|
10764 */ |
|
10765 |
|
10766 |
|
10767 |
|
10768 |
|
10769 |
|
10770 |
|
10771 /** |
|
10772 * Internal dependencies |
|
10773 */ |
|
10774 |
|
10775 |
|
10776 |
|
10777 var postpublish_PostPublishPanelPostpublish = |
|
10778 /*#__PURE__*/ |
|
10779 function (_Component) { |
|
10780 Object(inherits["a" /* default */])(PostPublishPanelPostpublish, _Component); |
|
10781 |
|
10782 function PostPublishPanelPostpublish() { |
|
10783 var _this; |
|
10784 |
|
10785 Object(classCallCheck["a" /* default */])(this, PostPublishPanelPostpublish); |
|
10786 |
|
10787 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(PostPublishPanelPostpublish).apply(this, arguments)); |
|
10788 _this.state = { |
|
10789 showCopyConfirmation: false |
|
10790 }; |
|
10791 _this.onCopy = _this.onCopy.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
10792 _this.onSelectInput = _this.onSelectInput.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
10793 _this.postLink = Object(external_this_wp_element_["createRef"])(); |
|
10794 return _this; |
|
10795 } |
|
10796 |
|
10797 Object(createClass["a" /* default */])(PostPublishPanelPostpublish, [{ |
|
10798 key: "componentDidMount", |
|
10799 value: function componentDidMount() { |
|
10800 if (this.props.focusOnMount) { |
|
10801 this.postLink.current.focus(); |
|
10802 } |
|
10803 } |
|
10804 }, { |
|
10805 key: "componentWillUnmount", |
|
10806 value: function componentWillUnmount() { |
|
10807 clearTimeout(this.dismissCopyConfirmation); |
|
10808 } |
|
10809 }, { |
|
10810 key: "onCopy", |
|
10811 value: function onCopy() { |
|
10812 var _this2 = this; |
|
10813 |
|
10814 this.setState({ |
|
10815 showCopyConfirmation: true |
|
10816 }); |
|
10817 clearTimeout(this.dismissCopyConfirmation); |
|
10818 this.dismissCopyConfirmation = setTimeout(function () { |
|
10819 _this2.setState({ |
|
10820 showCopyConfirmation: false |
|
10821 }); |
|
10822 }, 4000); |
|
10823 } |
|
10824 }, { |
|
10825 key: "onSelectInput", |
|
10826 value: function onSelectInput(event) { |
|
10827 event.target.select(); |
|
10828 } |
|
10829 }, { |
|
10830 key: "render", |
|
10831 value: function render() { |
|
10832 var _this$props = this.props, |
|
10833 children = _this$props.children, |
|
10834 isScheduled = _this$props.isScheduled, |
|
10835 post = _this$props.post, |
|
10836 postType = _this$props.postType; |
|
10837 var postLabel = Object(external_lodash_["get"])(postType, ['labels', 'singular_name']); |
|
10838 var viewPostLabel = Object(external_lodash_["get"])(postType, ['labels', 'view_item']); |
|
10839 var postPublishNonLinkHeader = isScheduled ? Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_i18n_["__"])('is now scheduled. It will go live on'), " ", Object(external_this_wp_element_["createElement"])(post_schedule_label, null), ".") : Object(external_this_wp_i18n_["__"])('is now live.'); |
|
10840 return Object(external_this_wp_element_["createElement"])("div", { |
|
10841 className: "post-publish-panel__postpublish" |
|
10842 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["PanelBody"], { |
|
10843 className: "post-publish-panel__postpublish-header" |
|
10844 }, Object(external_this_wp_element_["createElement"])("a", { |
|
10845 ref: this.postLink, |
|
10846 href: post.link |
|
10847 }, post.title || Object(external_this_wp_i18n_["__"])('(no title)')), " ", postPublishNonLinkHeader), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["PanelBody"], null, Object(external_this_wp_element_["createElement"])("p", { |
|
10848 className: "post-publish-panel__postpublish-subheader" |
|
10849 }, Object(external_this_wp_element_["createElement"])("strong", null, Object(external_this_wp_i18n_["__"])('What’s next?'))), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["TextControl"], { |
|
10850 className: "post-publish-panel__postpublish-post-address", |
|
10851 readOnly: true, |
|
10852 label: Object(external_this_wp_i18n_["sprintf"])( |
|
10853 /* translators: %s: post type singular name */ |
|
10854 Object(external_this_wp_i18n_["__"])('%s address'), postLabel), |
|
10855 value: Object(external_this_wp_url_["safeDecodeURIComponent"])(post.link), |
|
10856 onFocus: this.onSelectInput |
|
10857 }), Object(external_this_wp_element_["createElement"])("div", { |
|
10858 className: "post-publish-panel__postpublish-buttons" |
|
10859 }, !isScheduled && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
10860 isDefault: true, |
|
10861 href: post.link |
|
10862 }, viewPostLabel), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["ClipboardButton"], { |
|
10863 isDefault: true, |
|
10864 text: post.link, |
|
10865 onCopy: this.onCopy |
|
10866 }, this.state.showCopyConfirmation ? Object(external_this_wp_i18n_["__"])('Copied!') : Object(external_this_wp_i18n_["__"])('Copy Link')))), children); |
|
10867 } |
|
10868 }]); |
|
10869 |
|
10870 return PostPublishPanelPostpublish; |
|
10871 }(external_this_wp_element_["Component"]); |
|
10872 |
|
10873 /* harmony default export */ var postpublish = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
10874 var _select = select('core/editor'), |
|
10875 getEditedPostAttribute = _select.getEditedPostAttribute, |
|
10876 getCurrentPost = _select.getCurrentPost, |
|
10877 isCurrentPostScheduled = _select.isCurrentPostScheduled; |
|
10878 |
|
10879 var _select2 = select('core'), |
|
10880 getPostType = _select2.getPostType; |
|
10881 |
|
10882 return { |
|
10883 post: getCurrentPost(), |
|
10884 postType: getPostType(getEditedPostAttribute('type')), |
|
10885 isScheduled: isCurrentPostScheduled() |
|
10886 }; |
|
10887 })(postpublish_PostPublishPanelPostpublish)); |
|
10888 |
|
10889 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-publish-panel/index.js |
|
10890 |
|
10891 |
|
10892 |
|
10893 |
|
10894 |
|
10895 |
|
10896 |
|
10897 |
|
10898 |
|
10899 |
|
10900 /** |
|
10901 * External dependencies |
|
10902 */ |
|
10903 |
|
10904 /** |
|
10905 * WordPress dependencies |
|
10906 */ |
|
10907 |
|
10908 |
|
10909 |
|
10910 |
|
10911 |
|
10912 |
|
10913 /** |
|
10914 * Internal dependencies |
|
10915 */ |
|
10916 |
|
10917 |
|
10918 |
|
10919 |
|
10920 var post_publish_panel_PostPublishPanel = |
|
10921 /*#__PURE__*/ |
|
10922 function (_Component) { |
|
10923 Object(inherits["a" /* default */])(PostPublishPanel, _Component); |
|
10924 |
|
10925 function PostPublishPanel() { |
|
10926 var _this; |
|
10927 |
|
10928 Object(classCallCheck["a" /* default */])(this, PostPublishPanel); |
|
10929 |
|
10930 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(PostPublishPanel).apply(this, arguments)); |
|
10931 _this.onSubmit = _this.onSubmit.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
10932 return _this; |
|
10933 } |
|
10934 |
|
10935 Object(createClass["a" /* default */])(PostPublishPanel, [{ |
|
10936 key: "componentDidUpdate", |
|
10937 value: function componentDidUpdate(prevProps) { |
|
10938 // Automatically collapse the publish sidebar when a post |
|
10939 // is published and the user makes an edit. |
|
10940 if (prevProps.isPublished && !this.props.isSaving && this.props.isDirty) { |
|
10941 this.props.onClose(); |
|
10942 } |
|
10943 } |
|
10944 }, { |
|
10945 key: "onSubmit", |
|
10946 value: function onSubmit() { |
|
10947 var _this$props = this.props, |
|
10948 onClose = _this$props.onClose, |
|
10949 hasPublishAction = _this$props.hasPublishAction, |
|
10950 isPostTypeViewable = _this$props.isPostTypeViewable; |
|
10951 |
|
10952 if (!hasPublishAction || !isPostTypeViewable) { |
|
10953 onClose(); |
|
10954 } |
|
10955 } |
|
10956 }, { |
|
10957 key: "render", |
|
10958 value: function render() { |
|
10959 var _this$props2 = this.props, |
|
10960 forceIsDirty = _this$props2.forceIsDirty, |
|
10961 forceIsSaving = _this$props2.forceIsSaving, |
|
10962 isBeingScheduled = _this$props2.isBeingScheduled, |
|
10963 isPublished = _this$props2.isPublished, |
|
10964 isPublishSidebarEnabled = _this$props2.isPublishSidebarEnabled, |
|
10965 isScheduled = _this$props2.isScheduled, |
|
10966 isSaving = _this$props2.isSaving, |
|
10967 onClose = _this$props2.onClose, |
|
10968 onTogglePublishSidebar = _this$props2.onTogglePublishSidebar, |
|
10969 PostPublishExtension = _this$props2.PostPublishExtension, |
|
10970 PrePublishExtension = _this$props2.PrePublishExtension, |
|
10971 additionalProps = Object(objectWithoutProperties["a" /* default */])(_this$props2, ["forceIsDirty", "forceIsSaving", "isBeingScheduled", "isPublished", "isPublishSidebarEnabled", "isScheduled", "isSaving", "onClose", "onTogglePublishSidebar", "PostPublishExtension", "PrePublishExtension"]); |
|
10972 |
|
10973 var propsForPanel = Object(external_lodash_["omit"])(additionalProps, ['hasPublishAction', 'isDirty', 'isPostTypeViewable']); |
|
10974 var isPublishedOrScheduled = isPublished || isScheduled && isBeingScheduled; |
|
10975 var isPrePublish = !isPublishedOrScheduled && !isSaving; |
|
10976 var isPostPublish = isPublishedOrScheduled && !isSaving; |
|
10977 return Object(external_this_wp_element_["createElement"])("div", Object(esm_extends["a" /* default */])({ |
|
10978 className: "editor-post-publish-panel" |
|
10979 }, propsForPanel), Object(external_this_wp_element_["createElement"])("div", { |
|
10980 className: "editor-post-publish-panel__header" |
|
10981 }, isPostPublish ? Object(external_this_wp_element_["createElement"])("div", { |
|
10982 className: "editor-post-publish-panel__header-published" |
|
10983 }, isScheduled ? Object(external_this_wp_i18n_["__"])('Scheduled') : Object(external_this_wp_i18n_["__"])('Published')) : Object(external_this_wp_element_["createElement"])("div", { |
|
10984 className: "editor-post-publish-panel__header-publish-button" |
|
10985 }, Object(external_this_wp_element_["createElement"])(post_publish_button, { |
|
10986 focusOnMount: true, |
|
10987 onSubmit: this.onSubmit, |
|
10988 forceIsDirty: forceIsDirty, |
|
10989 forceIsSaving: forceIsSaving |
|
10990 }), Object(external_this_wp_element_["createElement"])("span", { |
|
10991 className: "editor-post-publish-panel__spacer" |
|
10992 })), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
10993 "aria-expanded": true, |
|
10994 onClick: onClose, |
|
10995 icon: "no-alt", |
|
10996 label: Object(external_this_wp_i18n_["__"])('Close panel') |
|
10997 })), Object(external_this_wp_element_["createElement"])("div", { |
|
10998 className: "editor-post-publish-panel__content" |
|
10999 }, isPrePublish && Object(external_this_wp_element_["createElement"])(prepublish, null, PrePublishExtension && Object(external_this_wp_element_["createElement"])(PrePublishExtension, null)), isPostPublish && Object(external_this_wp_element_["createElement"])(postpublish, { |
|
11000 focusOnMount: true |
|
11001 }, PostPublishExtension && Object(external_this_wp_element_["createElement"])(PostPublishExtension, null)), isSaving && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Spinner"], null)), Object(external_this_wp_element_["createElement"])("div", { |
|
11002 className: "editor-post-publish-panel__footer" |
|
11003 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["CheckboxControl"], { |
|
11004 label: Object(external_this_wp_i18n_["__"])('Always show pre-publish checks.'), |
|
11005 checked: isPublishSidebarEnabled, |
|
11006 onChange: onTogglePublishSidebar |
|
11007 }))); |
|
11008 } |
|
11009 }]); |
|
11010 |
|
11011 return PostPublishPanel; |
|
11012 }(external_this_wp_element_["Component"]); |
|
11013 /* harmony default export */ var post_publish_panel = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
11014 var _select = select('core'), |
|
11015 getPostType = _select.getPostType; |
|
11016 |
|
11017 var _select2 = select('core/editor'), |
|
11018 getCurrentPost = _select2.getCurrentPost, |
|
11019 getEditedPostAttribute = _select2.getEditedPostAttribute, |
|
11020 isCurrentPostPublished = _select2.isCurrentPostPublished, |
|
11021 isCurrentPostScheduled = _select2.isCurrentPostScheduled, |
|
11022 isEditedPostBeingScheduled = _select2.isEditedPostBeingScheduled, |
|
11023 isEditedPostDirty = _select2.isEditedPostDirty, |
|
11024 isSavingPost = _select2.isSavingPost; |
|
11025 |
|
11026 var _select3 = select('core/editor'), |
|
11027 isPublishSidebarEnabled = _select3.isPublishSidebarEnabled; |
|
11028 |
|
11029 var postType = getPostType(getEditedPostAttribute('type')); |
|
11030 return { |
|
11031 hasPublishAction: Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-publish'], false), |
|
11032 isPostTypeViewable: Object(external_lodash_["get"])(postType, ['viewable'], false), |
|
11033 isBeingScheduled: isEditedPostBeingScheduled(), |
|
11034 isDirty: isEditedPostDirty(), |
|
11035 isPublished: isCurrentPostPublished(), |
|
11036 isPublishSidebarEnabled: isPublishSidebarEnabled(), |
|
11037 isSaving: isSavingPost(), |
|
11038 isScheduled: isCurrentPostScheduled() |
|
11039 }; |
|
11040 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch, _ref) { |
|
11041 var isPublishSidebarEnabled = _ref.isPublishSidebarEnabled; |
|
11042 |
|
11043 var _dispatch = dispatch('core/editor'), |
|
11044 disablePublishSidebar = _dispatch.disablePublishSidebar, |
|
11045 enablePublishSidebar = _dispatch.enablePublishSidebar; |
|
11046 |
|
11047 return { |
|
11048 onTogglePublishSidebar: function onTogglePublishSidebar() { |
|
11049 if (isPublishSidebarEnabled) { |
|
11050 disablePublishSidebar(); |
|
11051 } else { |
|
11052 enablePublishSidebar(); |
|
11053 } |
|
11054 } |
|
11055 }; |
|
11056 }), external_this_wp_components_["withFocusReturn"], external_this_wp_components_["withConstrainedTabbing"]])(post_publish_panel_PostPublishPanel)); |
|
11057 |
|
11058 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-switch-to-draft-button/index.js |
|
11059 |
|
11060 |
|
11061 /** |
|
11062 * WordPress dependencies |
|
11063 */ |
|
11064 |
|
11065 |
|
11066 |
|
11067 |
|
11068 |
|
11069 function PostSwitchToDraftButton(_ref) { |
|
11070 var isSaving = _ref.isSaving, |
|
11071 isPublished = _ref.isPublished, |
|
11072 isScheduled = _ref.isScheduled, |
|
11073 onClick = _ref.onClick; |
|
11074 |
|
11075 if (!isPublished && !isScheduled) { |
|
11076 return null; |
|
11077 } |
|
11078 |
|
11079 var onSwitch = function onSwitch() { |
|
11080 var alertMessage; |
|
11081 |
|
11082 if (isPublished) { |
|
11083 alertMessage = Object(external_this_wp_i18n_["__"])('Are you sure you want to unpublish this post?'); |
|
11084 } else if (isScheduled) { |
|
11085 alertMessage = Object(external_this_wp_i18n_["__"])('Are you sure you want to unschedule this post?'); |
|
11086 } // eslint-disable-next-line no-alert |
|
11087 |
|
11088 |
|
11089 if (window.confirm(alertMessage)) { |
|
11090 onClick(); |
|
11091 } |
|
11092 }; |
|
11093 |
|
11094 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
11095 className: "editor-post-switch-to-draft", |
|
11096 onClick: onSwitch, |
|
11097 disabled: isSaving, |
|
11098 isTertiary: true |
|
11099 }, Object(external_this_wp_i18n_["__"])('Switch to Draft')); |
|
11100 } |
|
11101 |
|
11102 /* harmony default export */ var post_switch_to_draft_button = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
11103 var _select = select('core/editor'), |
|
11104 isSavingPost = _select.isSavingPost, |
|
11105 isCurrentPostPublished = _select.isCurrentPostPublished, |
|
11106 isCurrentPostScheduled = _select.isCurrentPostScheduled; |
|
11107 |
|
11108 return { |
|
11109 isSaving: isSavingPost(), |
|
11110 isPublished: isCurrentPostPublished(), |
|
11111 isScheduled: isCurrentPostScheduled() |
|
11112 }; |
|
11113 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
11114 var _dispatch = dispatch('core/editor'), |
|
11115 editPost = _dispatch.editPost, |
|
11116 savePost = _dispatch.savePost; |
|
11117 |
|
11118 return { |
|
11119 onClick: function onClick() { |
|
11120 editPost({ |
|
11121 status: 'draft' |
|
11122 }); |
|
11123 savePost(); |
|
11124 } |
|
11125 }; |
|
11126 })])(PostSwitchToDraftButton)); |
|
11127 |
|
11128 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-saved-state/index.js |
|
11129 |
|
11130 |
|
11131 |
|
11132 |
|
11133 |
|
11134 |
|
11135 |
|
11136 /** |
|
11137 * External dependencies |
|
11138 */ |
|
11139 |
|
11140 |
|
11141 /** |
|
11142 * WordPress dependencies |
|
11143 */ |
|
11144 |
|
11145 |
|
11146 |
|
11147 |
|
11148 |
|
11149 |
|
11150 |
|
11151 |
|
11152 /** |
|
11153 * Internal dependencies |
|
11154 */ |
|
11155 |
|
11156 |
|
11157 /** |
|
11158 * Component showing whether the post is saved or not and displaying save links. |
|
11159 * |
|
11160 * @param {Object} Props Component Props. |
|
11161 */ |
|
11162 |
|
11163 var post_saved_state_PostSavedState = |
|
11164 /*#__PURE__*/ |
|
11165 function (_Component) { |
|
11166 Object(inherits["a" /* default */])(PostSavedState, _Component); |
|
11167 |
|
11168 function PostSavedState() { |
|
11169 var _this; |
|
11170 |
|
11171 Object(classCallCheck["a" /* default */])(this, PostSavedState); |
|
11172 |
|
11173 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(PostSavedState).apply(this, arguments)); |
|
11174 _this.state = { |
|
11175 forceSavedMessage: false |
|
11176 }; |
|
11177 return _this; |
|
11178 } |
|
11179 |
|
11180 Object(createClass["a" /* default */])(PostSavedState, [{ |
|
11181 key: "componentDidUpdate", |
|
11182 value: function componentDidUpdate(prevProps) { |
|
11183 var _this2 = this; |
|
11184 |
|
11185 if (prevProps.isSaving && !this.props.isSaving) { |
|
11186 this.setState({ |
|
11187 forceSavedMessage: true |
|
11188 }); |
|
11189 this.props.setTimeout(function () { |
|
11190 _this2.setState({ |
|
11191 forceSavedMessage: false |
|
11192 }); |
|
11193 }, 1000); |
|
11194 } |
|
11195 } |
|
11196 }, { |
|
11197 key: "render", |
|
11198 value: function render() { |
|
11199 var _this$props = this.props, |
|
11200 post = _this$props.post, |
|
11201 isNew = _this$props.isNew, |
|
11202 isScheduled = _this$props.isScheduled, |
|
11203 isPublished = _this$props.isPublished, |
|
11204 isDirty = _this$props.isDirty, |
|
11205 isSaving = _this$props.isSaving, |
|
11206 isSaveable = _this$props.isSaveable, |
|
11207 onSave = _this$props.onSave, |
|
11208 isAutosaving = _this$props.isAutosaving, |
|
11209 isPending = _this$props.isPending, |
|
11210 isLargeViewport = _this$props.isLargeViewport; |
|
11211 var forceSavedMessage = this.state.forceSavedMessage; |
|
11212 |
|
11213 if (isSaving) { |
|
11214 // TODO: Classes generation should be common across all return |
|
11215 // paths of this function, including proper naming convention for |
|
11216 // the "Save Draft" button. |
|
11217 var classes = classnames_default()('editor-post-saved-state', 'is-saving', { |
|
11218 'is-autosaving': isAutosaving |
|
11219 }); |
|
11220 return Object(external_this_wp_element_["createElement"])("span", { |
|
11221 className: classes |
|
11222 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Dashicon"], { |
|
11223 icon: "cloud" |
|
11224 }), isAutosaving ? Object(external_this_wp_i18n_["__"])('Autosaving') : Object(external_this_wp_i18n_["__"])('Saving')); |
|
11225 } |
|
11226 |
|
11227 if (isPublished || isScheduled) { |
|
11228 return Object(external_this_wp_element_["createElement"])(post_switch_to_draft_button, null); |
|
11229 } |
|
11230 |
|
11231 if (!isSaveable) { |
|
11232 return null; |
|
11233 } |
|
11234 |
|
11235 if (forceSavedMessage || !isNew && !isDirty) { |
|
11236 return Object(external_this_wp_element_["createElement"])("span", { |
|
11237 className: "editor-post-saved-state is-saved" |
|
11238 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Dashicon"], { |
|
11239 icon: "saved" |
|
11240 }), Object(external_this_wp_i18n_["__"])('Saved')); |
|
11241 } // Once the post has been submitted for review this button |
|
11242 // is not needed for the contributor role. |
|
11243 |
|
11244 |
|
11245 var hasPublishAction = Object(external_lodash_["get"])(post, ['_links', 'wp:action-publish'], false); |
|
11246 |
|
11247 if (!hasPublishAction && isPending) { |
|
11248 return null; |
|
11249 } |
|
11250 |
|
11251 var label = isPending ? Object(external_this_wp_i18n_["__"])('Save as Pending') : Object(external_this_wp_i18n_["__"])('Save Draft'); |
|
11252 |
|
11253 if (!isLargeViewport) { |
|
11254 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
11255 className: "editor-post-save-draft", |
|
11256 label: label, |
|
11257 onClick: onSave, |
|
11258 shortcut: external_this_wp_keycodes_["displayShortcut"].primary('s'), |
|
11259 icon: "cloud-upload" |
|
11260 }); |
|
11261 } |
|
11262 |
|
11263 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
11264 className: "editor-post-save-draft", |
|
11265 onClick: onSave, |
|
11266 shortcut: external_this_wp_keycodes_["displayShortcut"].primary('s'), |
|
11267 isTertiary: true |
|
11268 }, label); |
|
11269 } |
|
11270 }]); |
|
11271 |
|
11272 return PostSavedState; |
|
11273 }(external_this_wp_element_["Component"]); |
|
11274 /* harmony default export */ var post_saved_state = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, _ref) { |
|
11275 var forceIsDirty = _ref.forceIsDirty, |
|
11276 forceIsSaving = _ref.forceIsSaving; |
|
11277 |
|
11278 var _select = select('core/editor'), |
|
11279 isEditedPostNew = _select.isEditedPostNew, |
|
11280 isCurrentPostPublished = _select.isCurrentPostPublished, |
|
11281 isCurrentPostScheduled = _select.isCurrentPostScheduled, |
|
11282 isEditedPostDirty = _select.isEditedPostDirty, |
|
11283 isSavingPost = _select.isSavingPost, |
|
11284 isEditedPostSaveable = _select.isEditedPostSaveable, |
|
11285 getCurrentPost = _select.getCurrentPost, |
|
11286 isAutosavingPost = _select.isAutosavingPost, |
|
11287 getEditedPostAttribute = _select.getEditedPostAttribute; |
|
11288 |
|
11289 return { |
|
11290 post: getCurrentPost(), |
|
11291 isNew: isEditedPostNew(), |
|
11292 isPublished: isCurrentPostPublished(), |
|
11293 isScheduled: isCurrentPostScheduled(), |
|
11294 isDirty: forceIsDirty || isEditedPostDirty(), |
|
11295 isSaving: forceIsSaving || isSavingPost(), |
|
11296 isSaveable: isEditedPostSaveable(), |
|
11297 isAutosaving: isAutosavingPost(), |
|
11298 isPending: 'pending' === getEditedPostAttribute('status') |
|
11299 }; |
|
11300 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
11301 return { |
|
11302 onSave: dispatch('core/editor').savePost |
|
11303 }; |
|
11304 }), external_this_wp_compose_["withSafeTimeout"], Object(external_this_wp_viewport_["withViewportMatch"])({ |
|
11305 isLargeViewport: 'medium' |
|
11306 })])(post_saved_state_PostSavedState)); |
|
11307 |
|
11308 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-schedule/check.js |
|
11309 /** |
|
11310 * External dependencies |
|
11311 */ |
|
11312 |
|
11313 /** |
|
11314 * WordPress dependencies |
|
11315 */ |
|
11316 |
|
11317 |
|
11318 |
|
11319 function PostScheduleCheck(_ref) { |
|
11320 var hasPublishAction = _ref.hasPublishAction, |
|
11321 children = _ref.children; |
|
11322 |
|
11323 if (!hasPublishAction) { |
|
11324 return null; |
|
11325 } |
|
11326 |
|
11327 return children; |
|
11328 } |
|
11329 /* harmony default export */ var post_schedule_check = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
11330 var _select = select('core/editor'), |
|
11331 getCurrentPost = _select.getCurrentPost, |
|
11332 getCurrentPostType = _select.getCurrentPostType; |
|
11333 |
|
11334 return { |
|
11335 hasPublishAction: Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-publish'], false), |
|
11336 postType: getCurrentPostType() |
|
11337 }; |
|
11338 })])(PostScheduleCheck)); |
|
11339 |
|
11340 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-sticky/check.js |
|
11341 /** |
|
11342 * External dependencies |
|
11343 */ |
|
11344 |
|
11345 /** |
|
11346 * WordPress dependencies |
|
11347 */ |
|
11348 |
|
11349 |
|
11350 |
|
11351 function PostStickyCheck(_ref) { |
|
11352 var hasStickyAction = _ref.hasStickyAction, |
|
11353 postType = _ref.postType, |
|
11354 children = _ref.children; |
|
11355 |
|
11356 if (postType !== 'post' || !hasStickyAction) { |
|
11357 return null; |
|
11358 } |
|
11359 |
|
11360 return children; |
|
11361 } |
|
11362 /* harmony default export */ var post_sticky_check = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
11363 var post = select('core/editor').getCurrentPost(); |
|
11364 return { |
|
11365 hasStickyAction: Object(external_lodash_["get"])(post, ['_links', 'wp:action-sticky'], false), |
|
11366 postType: select('core/editor').getCurrentPostType() |
|
11367 }; |
|
11368 })])(PostStickyCheck)); |
|
11369 |
|
11370 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-sticky/index.js |
|
11371 |
|
11372 |
|
11373 /** |
|
11374 * WordPress dependencies |
|
11375 */ |
|
11376 |
|
11377 |
|
11378 |
|
11379 |
|
11380 /** |
|
11381 * Internal dependencies |
|
11382 */ |
|
11383 |
|
11384 |
|
11385 function PostSticky(_ref) { |
|
11386 var onUpdateSticky = _ref.onUpdateSticky, |
|
11387 _ref$postSticky = _ref.postSticky, |
|
11388 postSticky = _ref$postSticky === void 0 ? false : _ref$postSticky; |
|
11389 return Object(external_this_wp_element_["createElement"])(post_sticky_check, null, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["CheckboxControl"], { |
|
11390 label: Object(external_this_wp_i18n_["__"])('Stick to the top of the blog'), |
|
11391 checked: postSticky, |
|
11392 onChange: function onChange() { |
|
11393 return onUpdateSticky(!postSticky); |
|
11394 } |
|
11395 })); |
|
11396 } |
|
11397 /* harmony default export */ var post_sticky = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
11398 return { |
|
11399 postSticky: select('core/editor').getEditedPostAttribute('sticky') |
|
11400 }; |
|
11401 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
11402 return { |
|
11403 onUpdateSticky: function onUpdateSticky(postSticky) { |
|
11404 dispatch('core/editor').editPost({ |
|
11405 sticky: postSticky |
|
11406 }); |
|
11407 } |
|
11408 }; |
|
11409 })])(PostSticky)); |
|
11410 |
|
11411 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/hierarchical-term-selector.js |
|
11412 |
|
11413 |
|
11414 |
|
11415 |
|
11416 |
|
11417 |
|
11418 |
|
11419 |
|
11420 |
|
11421 |
|
11422 |
|
11423 /** |
|
11424 * External dependencies |
|
11425 */ |
|
11426 |
|
11427 /** |
|
11428 * WordPress dependencies |
|
11429 */ |
|
11430 |
|
11431 |
|
11432 |
|
11433 |
|
11434 |
|
11435 |
|
11436 |
|
11437 |
|
11438 /** |
|
11439 * Internal dependencies |
|
11440 */ |
|
11441 |
|
11442 |
|
11443 /** |
|
11444 * Module Constants |
|
11445 */ |
|
11446 |
|
11447 var hierarchical_term_selector_DEFAULT_QUERY = { |
|
11448 per_page: -1, |
|
11449 orderby: 'name', |
|
11450 order: 'asc', |
|
11451 _fields: 'id,name,parent' |
|
11452 }; |
|
11453 var MIN_TERMS_COUNT_FOR_FILTER = 8; |
|
11454 |
|
11455 var hierarchical_term_selector_HierarchicalTermSelector = |
|
11456 /*#__PURE__*/ |
|
11457 function (_Component) { |
|
11458 Object(inherits["a" /* default */])(HierarchicalTermSelector, _Component); |
|
11459 |
|
11460 function HierarchicalTermSelector() { |
|
11461 var _this; |
|
11462 |
|
11463 Object(classCallCheck["a" /* default */])(this, HierarchicalTermSelector); |
|
11464 |
|
11465 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(HierarchicalTermSelector).apply(this, arguments)); |
|
11466 _this.findTerm = _this.findTerm.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
11467 _this.onChange = _this.onChange.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
11468 _this.onChangeFormName = _this.onChangeFormName.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
11469 _this.onChangeFormParent = _this.onChangeFormParent.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
11470 _this.onAddTerm = _this.onAddTerm.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
11471 _this.onToggleForm = _this.onToggleForm.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
11472 _this.setFilterValue = _this.setFilterValue.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
11473 _this.sortBySelected = _this.sortBySelected.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
11474 _this.state = { |
|
11475 loading: true, |
|
11476 availableTermsTree: [], |
|
11477 availableTerms: [], |
|
11478 adding: false, |
|
11479 formName: '', |
|
11480 formParent: '', |
|
11481 showForm: false, |
|
11482 filterValue: '', |
|
11483 filteredTermsTree: [] |
|
11484 }; |
|
11485 return _this; |
|
11486 } |
|
11487 |
|
11488 Object(createClass["a" /* default */])(HierarchicalTermSelector, [{ |
|
11489 key: "onChange", |
|
11490 value: function onChange(event) { |
|
11491 var _this$props = this.props, |
|
11492 onUpdateTerms = _this$props.onUpdateTerms, |
|
11493 _this$props$terms = _this$props.terms, |
|
11494 terms = _this$props$terms === void 0 ? [] : _this$props$terms, |
|
11495 taxonomy = _this$props.taxonomy; |
|
11496 var termId = parseInt(event.target.value, 10); |
|
11497 var hasTerm = terms.indexOf(termId) !== -1; |
|
11498 var newTerms = hasTerm ? Object(external_lodash_["without"])(terms, termId) : [].concat(Object(toConsumableArray["a" /* default */])(terms), [termId]); |
|
11499 onUpdateTerms(newTerms, taxonomy.rest_base); |
|
11500 } |
|
11501 }, { |
|
11502 key: "onChangeFormName", |
|
11503 value: function onChangeFormName(event) { |
|
11504 var newValue = event.target.value.trim() === '' ? '' : event.target.value; |
|
11505 this.setState({ |
|
11506 formName: newValue |
|
11507 }); |
|
11508 } |
|
11509 }, { |
|
11510 key: "onChangeFormParent", |
|
11511 value: function onChangeFormParent(newParent) { |
|
11512 this.setState({ |
|
11513 formParent: newParent |
|
11514 }); |
|
11515 } |
|
11516 }, { |
|
11517 key: "onToggleForm", |
|
11518 value: function onToggleForm() { |
|
11519 this.setState(function (state) { |
|
11520 return { |
|
11521 showForm: !state.showForm |
|
11522 }; |
|
11523 }); |
|
11524 } |
|
11525 }, { |
|
11526 key: "findTerm", |
|
11527 value: function findTerm(terms, parent, name) { |
|
11528 return Object(external_lodash_["find"])(terms, function (term) { |
|
11529 return (!term.parent && !parent || parseInt(term.parent) === parseInt(parent)) && term.name.toLowerCase() === name.toLowerCase(); |
|
11530 }); |
|
11531 } |
|
11532 }, { |
|
11533 key: "onAddTerm", |
|
11534 value: function onAddTerm(event) { |
|
11535 var _this2 = this; |
|
11536 |
|
11537 event.preventDefault(); |
|
11538 var _this$props2 = this.props, |
|
11539 onUpdateTerms = _this$props2.onUpdateTerms, |
|
11540 taxonomy = _this$props2.taxonomy, |
|
11541 terms = _this$props2.terms, |
|
11542 slug = _this$props2.slug; |
|
11543 var _this$state = this.state, |
|
11544 formName = _this$state.formName, |
|
11545 formParent = _this$state.formParent, |
|
11546 adding = _this$state.adding, |
|
11547 availableTerms = _this$state.availableTerms; |
|
11548 |
|
11549 if (formName === '' || adding) { |
|
11550 return; |
|
11551 } // check if the term we are adding already exists |
|
11552 |
|
11553 |
|
11554 var existingTerm = this.findTerm(availableTerms, formParent, formName); |
|
11555 |
|
11556 if (existingTerm) { |
|
11557 // if the term we are adding exists but is not selected select it |
|
11558 if (!Object(external_lodash_["some"])(terms, function (term) { |
|
11559 return term === existingTerm.id; |
|
11560 })) { |
|
11561 onUpdateTerms([].concat(Object(toConsumableArray["a" /* default */])(terms), [existingTerm.id]), taxonomy.rest_base); |
|
11562 } |
|
11563 |
|
11564 this.setState({ |
|
11565 formName: '', |
|
11566 formParent: '' |
|
11567 }); |
|
11568 return; |
|
11569 } |
|
11570 |
|
11571 this.setState({ |
|
11572 adding: true |
|
11573 }); |
|
11574 this.addRequest = external_this_wp_apiFetch_default()({ |
|
11575 path: "/wp/v2/".concat(taxonomy.rest_base), |
|
11576 method: 'POST', |
|
11577 data: { |
|
11578 name: formName, |
|
11579 parent: formParent ? formParent : undefined |
|
11580 } |
|
11581 }); // Tries to create a term or fetch it if it already exists |
|
11582 |
|
11583 var findOrCreatePromise = this.addRequest.catch(function (error) { |
|
11584 var errorCode = error.code; |
|
11585 |
|
11586 if (errorCode === 'term_exists') { |
|
11587 // search the new category created since last fetch |
|
11588 _this2.addRequest = external_this_wp_apiFetch_default()({ |
|
11589 path: Object(external_this_wp_url_["addQueryArgs"])("/wp/v2/".concat(taxonomy.rest_base), Object(objectSpread["a" /* default */])({}, hierarchical_term_selector_DEFAULT_QUERY, { |
|
11590 parent: formParent || 0, |
|
11591 search: formName |
|
11592 })) |
|
11593 }); |
|
11594 return _this2.addRequest.then(function (searchResult) { |
|
11595 return _this2.findTerm(searchResult, formParent, formName); |
|
11596 }); |
|
11597 } |
|
11598 |
|
11599 return Promise.reject(error); |
|
11600 }); |
|
11601 findOrCreatePromise.then(function (term) { |
|
11602 var hasTerm = !!Object(external_lodash_["find"])(_this2.state.availableTerms, function (availableTerm) { |
|
11603 return availableTerm.id === term.id; |
|
11604 }); |
|
11605 var newAvailableTerms = hasTerm ? _this2.state.availableTerms : [term].concat(Object(toConsumableArray["a" /* default */])(_this2.state.availableTerms)); |
|
11606 var termAddedMessage = Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["_x"])('%s added', 'term'), Object(external_lodash_["get"])(_this2.props.taxonomy, ['labels', 'singular_name'], slug === 'category' ? Object(external_this_wp_i18n_["__"])('Category') : Object(external_this_wp_i18n_["__"])('Term'))); |
|
11607 |
|
11608 _this2.props.speak(termAddedMessage, 'assertive'); |
|
11609 |
|
11610 _this2.addRequest = null; |
|
11611 |
|
11612 _this2.setState({ |
|
11613 adding: false, |
|
11614 formName: '', |
|
11615 formParent: '', |
|
11616 availableTerms: newAvailableTerms, |
|
11617 availableTermsTree: _this2.sortBySelected(buildTermsTree(newAvailableTerms)) |
|
11618 }); |
|
11619 |
|
11620 onUpdateTerms([].concat(Object(toConsumableArray["a" /* default */])(terms), [term.id]), taxonomy.rest_base); |
|
11621 }, function (xhr) { |
|
11622 if (xhr.statusText === 'abort') { |
|
11623 return; |
|
11624 } |
|
11625 |
|
11626 _this2.addRequest = null; |
|
11627 |
|
11628 _this2.setState({ |
|
11629 adding: false |
|
11630 }); |
|
11631 }); |
|
11632 } |
|
11633 }, { |
|
11634 key: "componentDidMount", |
|
11635 value: function componentDidMount() { |
|
11636 this.fetchTerms(); |
|
11637 } |
|
11638 }, { |
|
11639 key: "componentWillUnmount", |
|
11640 value: function componentWillUnmount() { |
|
11641 Object(external_lodash_["invoke"])(this.fetchRequest, ['abort']); |
|
11642 Object(external_lodash_["invoke"])(this.addRequest, ['abort']); |
|
11643 } |
|
11644 }, { |
|
11645 key: "componentDidUpdate", |
|
11646 value: function componentDidUpdate(prevProps) { |
|
11647 if (this.props.taxonomy !== prevProps.taxonomy) { |
|
11648 this.fetchTerms(); |
|
11649 } |
|
11650 } |
|
11651 }, { |
|
11652 key: "fetchTerms", |
|
11653 value: function fetchTerms() { |
|
11654 var _this3 = this; |
|
11655 |
|
11656 var taxonomy = this.props.taxonomy; |
|
11657 |
|
11658 if (!taxonomy) { |
|
11659 return; |
|
11660 } |
|
11661 |
|
11662 this.fetchRequest = external_this_wp_apiFetch_default()({ |
|
11663 path: Object(external_this_wp_url_["addQueryArgs"])("/wp/v2/".concat(taxonomy.rest_base), hierarchical_term_selector_DEFAULT_QUERY) |
|
11664 }); |
|
11665 this.fetchRequest.then(function (terms) { |
|
11666 // resolve |
|
11667 var availableTermsTree = _this3.sortBySelected(buildTermsTree(terms)); |
|
11668 |
|
11669 _this3.fetchRequest = null; |
|
11670 |
|
11671 _this3.setState({ |
|
11672 loading: false, |
|
11673 availableTermsTree: availableTermsTree, |
|
11674 availableTerms: terms |
|
11675 }); |
|
11676 }, function (xhr) { |
|
11677 // reject |
|
11678 if (xhr.statusText === 'abort') { |
|
11679 return; |
|
11680 } |
|
11681 |
|
11682 _this3.fetchRequest = null; |
|
11683 |
|
11684 _this3.setState({ |
|
11685 loading: false |
|
11686 }); |
|
11687 }); |
|
11688 } |
|
11689 }, { |
|
11690 key: "sortBySelected", |
|
11691 value: function sortBySelected(termsTree) { |
|
11692 var terms = this.props.terms; |
|
11693 |
|
11694 var treeHasSelection = function treeHasSelection(termTree) { |
|
11695 if (terms.indexOf(termTree.id) !== -1) { |
|
11696 return true; |
|
11697 } |
|
11698 |
|
11699 if (undefined === termTree.children) { |
|
11700 return false; |
|
11701 } |
|
11702 |
|
11703 var anyChildIsSelected = termTree.children.map(treeHasSelection).filter(function (child) { |
|
11704 return child; |
|
11705 }).length > 0; |
|
11706 |
|
11707 if (anyChildIsSelected) { |
|
11708 return true; |
|
11709 } |
|
11710 |
|
11711 return false; |
|
11712 }; |
|
11713 |
|
11714 var termOrChildIsSelected = function termOrChildIsSelected(termA, termB) { |
|
11715 var termASelected = treeHasSelection(termA); |
|
11716 var termBSelected = treeHasSelection(termB); |
|
11717 |
|
11718 if (termASelected === termBSelected) { |
|
11719 return 0; |
|
11720 } |
|
11721 |
|
11722 if (termASelected && !termBSelected) { |
|
11723 return -1; |
|
11724 } |
|
11725 |
|
11726 if (!termASelected && termBSelected) { |
|
11727 return 1; |
|
11728 } |
|
11729 |
|
11730 return 0; |
|
11731 }; |
|
11732 |
|
11733 termsTree.sort(termOrChildIsSelected); |
|
11734 return termsTree; |
|
11735 } |
|
11736 }, { |
|
11737 key: "setFilterValue", |
|
11738 value: function setFilterValue(event) { |
|
11739 var availableTermsTree = this.state.availableTermsTree; |
|
11740 var filterValue = event.target.value; |
|
11741 var filteredTermsTree = availableTermsTree.map(this.getFilterMatcher(filterValue)).filter(function (term) { |
|
11742 return term; |
|
11743 }); |
|
11744 |
|
11745 var getResultCount = function getResultCount(terms) { |
|
11746 var count = 0; |
|
11747 |
|
11748 for (var i = 0; i < terms.length; i++) { |
|
11749 count++; |
|
11750 |
|
11751 if (undefined !== terms[i].children) { |
|
11752 count += getResultCount(terms[i].children); |
|
11753 } |
|
11754 } |
|
11755 |
|
11756 return count; |
|
11757 }; |
|
11758 |
|
11759 this.setState({ |
|
11760 filterValue: filterValue, |
|
11761 filteredTermsTree: filteredTermsTree |
|
11762 }); |
|
11763 var resultCount = getResultCount(filteredTermsTree); |
|
11764 var resultsFoundMessage = Object(external_this_wp_i18n_["sprintf"])(Object(external_this_wp_i18n_["_n"])('%d result found.', '%d results found.', resultCount), resultCount); |
|
11765 this.props.debouncedSpeak(resultsFoundMessage, 'assertive'); |
|
11766 } |
|
11767 }, { |
|
11768 key: "getFilterMatcher", |
|
11769 value: function getFilterMatcher(filterValue) { |
|
11770 var matchTermsForFilter = function matchTermsForFilter(originalTerm) { |
|
11771 if ('' === filterValue) { |
|
11772 return originalTerm; |
|
11773 } // Shallow clone, because we'll be filtering the term's children and |
|
11774 // don't want to modify the original term. |
|
11775 |
|
11776 |
|
11777 var term = Object(objectSpread["a" /* default */])({}, originalTerm); // Map and filter the children, recursive so we deal with grandchildren |
|
11778 // and any deeper levels. |
|
11779 |
|
11780 |
|
11781 if (term.children.length > 0) { |
|
11782 term.children = term.children.map(matchTermsForFilter).filter(function (child) { |
|
11783 return child; |
|
11784 }); |
|
11785 } // If the term's name contains the filterValue, or it has children |
|
11786 // (i.e. some child matched at some point in the tree) then return it. |
|
11787 |
|
11788 |
|
11789 if (-1 !== term.name.toLowerCase().indexOf(filterValue) || term.children.length > 0) { |
|
11790 return term; |
|
11791 } // Otherwise, return false. After mapping, the list of terms will need |
|
11792 // to have false values filtered out. |
|
11793 |
|
11794 |
|
11795 return false; |
|
11796 }; |
|
11797 |
|
11798 return matchTermsForFilter; |
|
11799 } |
|
11800 }, { |
|
11801 key: "renderTerms", |
|
11802 value: function renderTerms(renderedTerms) { |
|
11803 var _this4 = this; |
|
11804 |
|
11805 var _this$props$terms2 = this.props.terms, |
|
11806 terms = _this$props$terms2 === void 0 ? [] : _this$props$terms2; |
|
11807 return renderedTerms.map(function (term) { |
|
11808 var id = "editor-post-taxonomies-hierarchical-term-".concat(term.id); |
|
11809 return Object(external_this_wp_element_["createElement"])("div", { |
|
11810 key: term.id, |
|
11811 className: "editor-post-taxonomies__hierarchical-terms-choice" |
|
11812 }, Object(external_this_wp_element_["createElement"])("input", { |
|
11813 id: id, |
|
11814 className: "editor-post-taxonomies__hierarchical-terms-input", |
|
11815 type: "checkbox", |
|
11816 checked: terms.indexOf(term.id) !== -1, |
|
11817 value: term.id, |
|
11818 onChange: _this4.onChange |
|
11819 }), Object(external_this_wp_element_["createElement"])("label", { |
|
11820 htmlFor: id |
|
11821 }, Object(external_lodash_["unescape"])(term.name)), !!term.children.length && Object(external_this_wp_element_["createElement"])("div", { |
|
11822 className: "editor-post-taxonomies__hierarchical-terms-subchoices" |
|
11823 }, _this4.renderTerms(term.children))); |
|
11824 }); |
|
11825 } |
|
11826 }, { |
|
11827 key: "render", |
|
11828 value: function render() { |
|
11829 var _this$props3 = this.props, |
|
11830 slug = _this$props3.slug, |
|
11831 taxonomy = _this$props3.taxonomy, |
|
11832 instanceId = _this$props3.instanceId, |
|
11833 hasCreateAction = _this$props3.hasCreateAction, |
|
11834 hasAssignAction = _this$props3.hasAssignAction; |
|
11835 |
|
11836 if (!hasAssignAction) { |
|
11837 return null; |
|
11838 } |
|
11839 |
|
11840 var _this$state2 = this.state, |
|
11841 availableTermsTree = _this$state2.availableTermsTree, |
|
11842 availableTerms = _this$state2.availableTerms, |
|
11843 filteredTermsTree = _this$state2.filteredTermsTree, |
|
11844 formName = _this$state2.formName, |
|
11845 formParent = _this$state2.formParent, |
|
11846 loading = _this$state2.loading, |
|
11847 showForm = _this$state2.showForm, |
|
11848 filterValue = _this$state2.filterValue; |
|
11849 |
|
11850 var labelWithFallback = function labelWithFallback(labelProperty, fallbackIsCategory, fallbackIsNotCategory) { |
|
11851 return Object(external_lodash_["get"])(taxonomy, ['labels', labelProperty], slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory); |
|
11852 }; |
|
11853 |
|
11854 var newTermButtonLabel = labelWithFallback('add_new_item', Object(external_this_wp_i18n_["__"])('Add new category'), Object(external_this_wp_i18n_["__"])('Add new term')); |
|
11855 var newTermLabel = labelWithFallback('new_item_name', Object(external_this_wp_i18n_["__"])('Add new category'), Object(external_this_wp_i18n_["__"])('Add new term')); |
|
11856 var parentSelectLabel = labelWithFallback('parent_item', Object(external_this_wp_i18n_["__"])('Parent Category'), Object(external_this_wp_i18n_["__"])('Parent Term')); |
|
11857 var noParentOption = "\u2014 ".concat(parentSelectLabel, " \u2014"); |
|
11858 var newTermSubmitLabel = newTermButtonLabel; |
|
11859 var inputId = "editor-post-taxonomies__hierarchical-terms-input-".concat(instanceId); |
|
11860 var filterInputId = "editor-post-taxonomies__hierarchical-terms-filter-".concat(instanceId); |
|
11861 var filterLabel = Object(external_lodash_["get"])(this.props.taxonomy, ['labels', 'search_items'], Object(external_this_wp_i18n_["__"])('Search Terms')); |
|
11862 var groupLabel = Object(external_lodash_["get"])(this.props.taxonomy, ['name'], Object(external_this_wp_i18n_["__"])('Terms')); |
|
11863 var showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER; |
|
11864 return [showFilter && Object(external_this_wp_element_["createElement"])("label", { |
|
11865 key: "filter-label", |
|
11866 htmlFor: filterInputId |
|
11867 }, filterLabel), showFilter && Object(external_this_wp_element_["createElement"])("input", { |
|
11868 type: "search", |
|
11869 id: filterInputId, |
|
11870 value: filterValue, |
|
11871 onChange: this.setFilterValue, |
|
11872 className: "editor-post-taxonomies__hierarchical-terms-filter", |
|
11873 key: "term-filter-input" |
|
11874 }), Object(external_this_wp_element_["createElement"])("div", { |
|
11875 className: "editor-post-taxonomies__hierarchical-terms-list", |
|
11876 key: "term-list", |
|
11877 tabIndex: "0", |
|
11878 role: "group", |
|
11879 "aria-label": groupLabel |
|
11880 }, this.renderTerms('' !== filterValue ? filteredTermsTree : availableTermsTree)), !loading && hasCreateAction && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
11881 key: "term-add-button", |
|
11882 onClick: this.onToggleForm, |
|
11883 className: "editor-post-taxonomies__hierarchical-terms-add", |
|
11884 "aria-expanded": showForm, |
|
11885 isLink: true |
|
11886 }, newTermButtonLabel), showForm && Object(external_this_wp_element_["createElement"])("form", { |
|
11887 onSubmit: this.onAddTerm, |
|
11888 key: "hierarchical-terms-form" |
|
11889 }, Object(external_this_wp_element_["createElement"])("label", { |
|
11890 htmlFor: inputId, |
|
11891 className: "editor-post-taxonomies__hierarchical-terms-label" |
|
11892 }, newTermLabel), Object(external_this_wp_element_["createElement"])("input", { |
|
11893 type: "text", |
|
11894 id: inputId, |
|
11895 className: "editor-post-taxonomies__hierarchical-terms-input", |
|
11896 value: formName, |
|
11897 onChange: this.onChangeFormName, |
|
11898 required: true |
|
11899 }), !!availableTerms.length && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["TreeSelect"], { |
|
11900 label: parentSelectLabel, |
|
11901 noOptionLabel: noParentOption, |
|
11902 onChange: this.onChangeFormParent, |
|
11903 selectedId: formParent, |
|
11904 tree: availableTermsTree |
|
11905 }), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
11906 isDefault: true, |
|
11907 type: "submit", |
|
11908 className: "editor-post-taxonomies__hierarchical-terms-submit" |
|
11909 }, newTermSubmitLabel))]; |
|
11910 /* eslint-enable jsx-a11y/no-onchange */ |
|
11911 } |
|
11912 }]); |
|
11913 |
|
11914 return HierarchicalTermSelector; |
|
11915 }(external_this_wp_element_["Component"]); |
|
11916 |
|
11917 /* harmony default export */ var hierarchical_term_selector = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select, _ref) { |
|
11918 var slug = _ref.slug; |
|
11919 |
|
11920 var _select = select('core/editor'), |
|
11921 getCurrentPost = _select.getCurrentPost; |
|
11922 |
|
11923 var _select2 = select('core'), |
|
11924 getTaxonomy = _select2.getTaxonomy; |
|
11925 |
|
11926 var taxonomy = getTaxonomy(slug); |
|
11927 return { |
|
11928 hasCreateAction: taxonomy ? Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-create-' + taxonomy.rest_base], false) : false, |
|
11929 hasAssignAction: taxonomy ? Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-assign-' + taxonomy.rest_base], false) : false, |
|
11930 terms: taxonomy ? select('core/editor').getEditedPostAttribute(taxonomy.rest_base) : [], |
|
11931 taxonomy: taxonomy |
|
11932 }; |
|
11933 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
11934 return { |
|
11935 onUpdateTerms: function onUpdateTerms(terms, restBase) { |
|
11936 dispatch('core/editor').editPost(Object(defineProperty["a" /* default */])({}, restBase, terms)); |
|
11937 } |
|
11938 }; |
|
11939 }), external_this_wp_components_["withSpokenMessages"], external_this_wp_compose_["withInstanceId"], Object(external_this_wp_components_["withFilters"])('editor.PostTaxonomyType')])(hierarchical_term_selector_HierarchicalTermSelector)); |
|
11940 |
|
11941 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/index.js |
|
11942 |
|
11943 |
|
11944 /** |
|
11945 * External dependencies |
|
11946 */ |
|
11947 |
|
11948 /** |
|
11949 * WordPress dependencies |
|
11950 */ |
|
11951 |
|
11952 |
|
11953 |
|
11954 |
|
11955 /** |
|
11956 * Internal dependencies |
|
11957 */ |
|
11958 |
|
11959 |
|
11960 |
|
11961 function PostTaxonomies(_ref) { |
|
11962 var postType = _ref.postType, |
|
11963 taxonomies = _ref.taxonomies, |
|
11964 _ref$taxonomyWrapper = _ref.taxonomyWrapper, |
|
11965 taxonomyWrapper = _ref$taxonomyWrapper === void 0 ? external_lodash_["identity"] : _ref$taxonomyWrapper; |
|
11966 var availableTaxonomies = Object(external_lodash_["filter"])(taxonomies, function (taxonomy) { |
|
11967 return Object(external_lodash_["includes"])(taxonomy.types, postType); |
|
11968 }); |
|
11969 var visibleTaxonomies = Object(external_lodash_["filter"])(availableTaxonomies, function (taxonomy) { |
|
11970 return taxonomy.visibility.show_ui; |
|
11971 }); |
|
11972 return visibleTaxonomies.map(function (taxonomy) { |
|
11973 var TaxonomyComponent = taxonomy.hierarchical ? hierarchical_term_selector : flat_term_selector; |
|
11974 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], { |
|
11975 key: "taxonomy-".concat(taxonomy.slug) |
|
11976 }, taxonomyWrapper(Object(external_this_wp_element_["createElement"])(TaxonomyComponent, { |
|
11977 slug: taxonomy.slug |
|
11978 }), taxonomy)); |
|
11979 }); |
|
11980 } |
|
11981 /* harmony default export */ var post_taxonomies = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
11982 return { |
|
11983 postType: select('core/editor').getCurrentPostType(), |
|
11984 taxonomies: select('core').getTaxonomies({ |
|
11985 per_page: -1 |
|
11986 }) |
|
11987 }; |
|
11988 })])(PostTaxonomies)); |
|
11989 |
|
11990 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-taxonomies/check.js |
|
11991 /** |
|
11992 * External dependencies |
|
11993 */ |
|
11994 |
|
11995 /** |
|
11996 * WordPress dependencies |
|
11997 */ |
|
11998 |
|
11999 |
|
12000 |
|
12001 function PostTaxonomiesCheck(_ref) { |
|
12002 var postType = _ref.postType, |
|
12003 taxonomies = _ref.taxonomies, |
|
12004 children = _ref.children; |
|
12005 var hasTaxonomies = Object(external_lodash_["some"])(taxonomies, function (taxonomy) { |
|
12006 return Object(external_lodash_["includes"])(taxonomy.types, postType); |
|
12007 }); |
|
12008 |
|
12009 if (!hasTaxonomies) { |
|
12010 return null; |
|
12011 } |
|
12012 |
|
12013 return children; |
|
12014 } |
|
12015 /* harmony default export */ var post_taxonomies_check = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
12016 return { |
|
12017 postType: select('core/editor').getCurrentPostType(), |
|
12018 taxonomies: select('core').getTaxonomies({ |
|
12019 per_page: -1 |
|
12020 }) |
|
12021 }; |
|
12022 })])(PostTaxonomiesCheck)); |
|
12023 |
|
12024 // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js |
|
12025 var react_autosize_textarea_lib = __webpack_require__(61); |
|
12026 var react_autosize_textarea_lib_default = /*#__PURE__*/__webpack_require__.n(react_autosize_textarea_lib); |
|
12027 |
|
12028 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-text-editor/index.js |
|
12029 |
|
12030 |
|
12031 |
|
12032 |
|
12033 |
|
12034 |
|
12035 |
|
12036 |
|
12037 /** |
|
12038 * External dependencies |
|
12039 */ |
|
12040 |
|
12041 /** |
|
12042 * WordPress dependencies |
|
12043 */ |
|
12044 |
|
12045 |
|
12046 |
|
12047 |
|
12048 |
|
12049 |
|
12050 var post_text_editor_PostTextEditor = |
|
12051 /*#__PURE__*/ |
|
12052 function (_Component) { |
|
12053 Object(inherits["a" /* default */])(PostTextEditor, _Component); |
|
12054 |
|
12055 function PostTextEditor() { |
|
12056 var _this; |
|
12057 |
|
12058 Object(classCallCheck["a" /* default */])(this, PostTextEditor); |
|
12059 |
|
12060 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(PostTextEditor).apply(this, arguments)); |
|
12061 _this.edit = _this.edit.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12062 _this.stopEditing = _this.stopEditing.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12063 _this.state = {}; |
|
12064 return _this; |
|
12065 } |
|
12066 |
|
12067 Object(createClass["a" /* default */])(PostTextEditor, [{ |
|
12068 key: "edit", |
|
12069 |
|
12070 /** |
|
12071 * Handles a textarea change event to notify the onChange prop callback and |
|
12072 * reflect the new value in the component's own state. This marks the start |
|
12073 * of the user's edits, if not already changed, preventing future props |
|
12074 * changes to value from replacing the rendered value. This is expected to |
|
12075 * be followed by a reset to dirty state via `stopEditing`. |
|
12076 * |
|
12077 * @see stopEditing |
|
12078 * |
|
12079 * @param {Event} event Change event. |
|
12080 */ |
|
12081 value: function edit(event) { |
|
12082 var value = event.target.value; |
|
12083 this.props.onChange(value); |
|
12084 this.setState({ |
|
12085 value: value, |
|
12086 isDirty: true |
|
12087 }); |
|
12088 } |
|
12089 /** |
|
12090 * Function called when the user has completed their edits, responsible for |
|
12091 * ensuring that changes, if made, are surfaced to the onPersist prop |
|
12092 * callback and resetting dirty state. |
|
12093 */ |
|
12094 |
|
12095 }, { |
|
12096 key: "stopEditing", |
|
12097 value: function stopEditing() { |
|
12098 if (this.state.isDirty) { |
|
12099 this.props.onPersist(this.state.value); |
|
12100 this.setState({ |
|
12101 isDirty: false |
|
12102 }); |
|
12103 } |
|
12104 } |
|
12105 }, { |
|
12106 key: "render", |
|
12107 value: function render() { |
|
12108 var value = this.state.value; |
|
12109 var instanceId = this.props.instanceId; |
|
12110 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])("label", { |
|
12111 htmlFor: "post-content-".concat(instanceId), |
|
12112 className: "screen-reader-text" |
|
12113 }, Object(external_this_wp_i18n_["__"])('Type text or HTML')), Object(external_this_wp_element_["createElement"])(react_autosize_textarea_lib_default.a, { |
|
12114 autoComplete: "off", |
|
12115 dir: "auto", |
|
12116 value: value, |
|
12117 onChange: this.edit, |
|
12118 onBlur: this.stopEditing, |
|
12119 className: "editor-post-text-editor", |
|
12120 id: "post-content-".concat(instanceId), |
|
12121 placeholder: Object(external_this_wp_i18n_["__"])('Start writing with text or HTML') |
|
12122 })); |
|
12123 } |
|
12124 }], [{ |
|
12125 key: "getDerivedStateFromProps", |
|
12126 value: function getDerivedStateFromProps(props, state) { |
|
12127 if (state.isDirty) { |
|
12128 return null; |
|
12129 } |
|
12130 |
|
12131 return { |
|
12132 value: props.value, |
|
12133 isDirty: false |
|
12134 }; |
|
12135 } |
|
12136 }]); |
|
12137 |
|
12138 return PostTextEditor; |
|
12139 }(external_this_wp_element_["Component"]); |
|
12140 /* harmony default export */ var post_text_editor = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
12141 var _select = select('core/editor'), |
|
12142 getEditedPostContent = _select.getEditedPostContent; |
|
12143 |
|
12144 return { |
|
12145 value: getEditedPostContent() |
|
12146 }; |
|
12147 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
12148 var _dispatch = dispatch('core/editor'), |
|
12149 editPost = _dispatch.editPost, |
|
12150 resetEditorBlocks = _dispatch.resetEditorBlocks; |
|
12151 |
|
12152 return { |
|
12153 onChange: function onChange(content) { |
|
12154 editPost({ |
|
12155 content: content |
|
12156 }); |
|
12157 }, |
|
12158 onPersist: function onPersist(content) { |
|
12159 var blocks = Object(external_this_wp_blocks_["parse"])(content); |
|
12160 resetEditorBlocks(blocks); |
|
12161 } |
|
12162 }; |
|
12163 }), external_this_wp_compose_["withInstanceId"]])(post_text_editor_PostTextEditor)); |
|
12164 |
|
12165 // EXTERNAL MODULE: external {"this":["wp","htmlEntities"]} |
|
12166 var external_this_wp_htmlEntities_ = __webpack_require__(57); |
|
12167 |
|
12168 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-permalink/editor.js |
|
12169 |
|
12170 |
|
12171 |
|
12172 |
|
12173 |
|
12174 |
|
12175 |
|
12176 |
|
12177 /** |
|
12178 * WordPress dependencies |
|
12179 */ |
|
12180 |
|
12181 |
|
12182 |
|
12183 |
|
12184 |
|
12185 /** |
|
12186 * Internal dependencies |
|
12187 */ |
|
12188 |
|
12189 |
|
12190 |
|
12191 var editor_PostPermalinkEditor = |
|
12192 /*#__PURE__*/ |
|
12193 function (_Component) { |
|
12194 Object(inherits["a" /* default */])(PostPermalinkEditor, _Component); |
|
12195 |
|
12196 function PostPermalinkEditor(_ref) { |
|
12197 var _this; |
|
12198 |
|
12199 var permalinkParts = _ref.permalinkParts, |
|
12200 slug = _ref.slug; |
|
12201 |
|
12202 Object(classCallCheck["a" /* default */])(this, PostPermalinkEditor); |
|
12203 |
|
12204 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(PostPermalinkEditor).apply(this, arguments)); |
|
12205 _this.state = { |
|
12206 editedPostName: slug || permalinkParts.postName |
|
12207 }; |
|
12208 _this.onSavePermalink = _this.onSavePermalink.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12209 return _this; |
|
12210 } |
|
12211 |
|
12212 Object(createClass["a" /* default */])(PostPermalinkEditor, [{ |
|
12213 key: "onSavePermalink", |
|
12214 value: function onSavePermalink(event) { |
|
12215 var postName = cleanForSlug(this.state.editedPostName); |
|
12216 event.preventDefault(); |
|
12217 this.props.onSave(); |
|
12218 |
|
12219 if (postName === this.props.postName) { |
|
12220 return; |
|
12221 } |
|
12222 |
|
12223 this.props.editPost({ |
|
12224 slug: postName |
|
12225 }); |
|
12226 this.setState({ |
|
12227 editedPostName: postName |
|
12228 }); |
|
12229 } |
|
12230 }, { |
|
12231 key: "render", |
|
12232 value: function render() { |
|
12233 var _this2 = this; |
|
12234 |
|
12235 var _this$props$permalink = this.props.permalinkParts, |
|
12236 prefix = _this$props$permalink.prefix, |
|
12237 suffix = _this$props$permalink.suffix; |
|
12238 var editedPostName = this.state.editedPostName; |
|
12239 /* eslint-disable jsx-a11y/no-autofocus */ |
|
12240 // Autofocus is allowed here, as this mini-UI is only loaded when the user clicks to open it. |
|
12241 |
|
12242 return Object(external_this_wp_element_["createElement"])("form", { |
|
12243 className: "editor-post-permalink-editor", |
|
12244 onSubmit: this.onSavePermalink |
|
12245 }, Object(external_this_wp_element_["createElement"])("span", { |
|
12246 className: "editor-post-permalink__editor-container" |
|
12247 }, Object(external_this_wp_element_["createElement"])("span", { |
|
12248 className: "editor-post-permalink-editor__prefix" |
|
12249 }, prefix), Object(external_this_wp_element_["createElement"])("input", { |
|
12250 className: "editor-post-permalink-editor__edit", |
|
12251 "aria-label": Object(external_this_wp_i18n_["__"])('Edit post permalink'), |
|
12252 value: editedPostName, |
|
12253 onChange: function onChange(event) { |
|
12254 return _this2.setState({ |
|
12255 editedPostName: event.target.value |
|
12256 }); |
|
12257 }, |
|
12258 type: "text", |
|
12259 autoFocus: true |
|
12260 }), Object(external_this_wp_element_["createElement"])("span", { |
|
12261 className: "editor-post-permalink-editor__suffix" |
|
12262 }, suffix), "\u200E"), Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
12263 className: "editor-post-permalink-editor__save", |
|
12264 isLarge: true, |
|
12265 onClick: this.onSavePermalink |
|
12266 }, Object(external_this_wp_i18n_["__"])('Save'))); |
|
12267 /* eslint-enable jsx-a11y/no-autofocus */ |
|
12268 } |
|
12269 }]); |
|
12270 |
|
12271 return PostPermalinkEditor; |
|
12272 }(external_this_wp_element_["Component"]); |
|
12273 |
|
12274 /* harmony default export */ var post_permalink_editor = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
12275 var _select = select('core/editor'), |
|
12276 getPermalinkParts = _select.getPermalinkParts; |
|
12277 |
|
12278 return { |
|
12279 permalinkParts: getPermalinkParts() |
|
12280 }; |
|
12281 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
12282 var _dispatch = dispatch('core/editor'), |
|
12283 editPost = _dispatch.editPost; |
|
12284 |
|
12285 return { |
|
12286 editPost: editPost |
|
12287 }; |
|
12288 })])(editor_PostPermalinkEditor)); |
|
12289 |
|
12290 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-permalink/index.js |
|
12291 |
|
12292 |
|
12293 |
|
12294 |
|
12295 |
|
12296 |
|
12297 |
|
12298 |
|
12299 /** |
|
12300 * External dependencies |
|
12301 */ |
|
12302 |
|
12303 |
|
12304 /** |
|
12305 * WordPress dependencies |
|
12306 */ |
|
12307 |
|
12308 |
|
12309 |
|
12310 |
|
12311 |
|
12312 |
|
12313 |
|
12314 /** |
|
12315 * Internal dependencies |
|
12316 */ |
|
12317 |
|
12318 |
|
12319 |
|
12320 |
|
12321 var post_permalink_PostPermalink = |
|
12322 /*#__PURE__*/ |
|
12323 function (_Component) { |
|
12324 Object(inherits["a" /* default */])(PostPermalink, _Component); |
|
12325 |
|
12326 function PostPermalink() { |
|
12327 var _this; |
|
12328 |
|
12329 Object(classCallCheck["a" /* default */])(this, PostPermalink); |
|
12330 |
|
12331 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(PostPermalink).apply(this, arguments)); |
|
12332 _this.addVisibilityCheck = _this.addVisibilityCheck.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12333 _this.onVisibilityChange = _this.onVisibilityChange.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12334 _this.state = { |
|
12335 isCopied: false, |
|
12336 isEditingPermalink: false |
|
12337 }; |
|
12338 return _this; |
|
12339 } |
|
12340 |
|
12341 Object(createClass["a" /* default */])(PostPermalink, [{ |
|
12342 key: "addVisibilityCheck", |
|
12343 value: function addVisibilityCheck() { |
|
12344 window.addEventListener('visibilitychange', this.onVisibilityChange); |
|
12345 } |
|
12346 }, { |
|
12347 key: "onVisibilityChange", |
|
12348 value: function onVisibilityChange() { |
|
12349 var _this$props = this.props, |
|
12350 isEditable = _this$props.isEditable, |
|
12351 refreshPost = _this$props.refreshPost; // If the user just returned after having clicked the "Change Permalinks" button, |
|
12352 // fetch a new copy of the post from the server, just in case they enabled permalinks. |
|
12353 |
|
12354 if (!isEditable && 'visible' === document.visibilityState) { |
|
12355 refreshPost(); |
|
12356 } |
|
12357 } |
|
12358 }, { |
|
12359 key: "componentDidUpdate", |
|
12360 value: function componentDidUpdate(prevProps, prevState) { |
|
12361 // If we've just stopped editing the permalink, focus on the new permalink. |
|
12362 if (prevState.isEditingPermalink && !this.state.isEditingPermalink) { |
|
12363 this.linkElement.focus(); |
|
12364 } |
|
12365 } |
|
12366 }, { |
|
12367 key: "componentWillUnmount", |
|
12368 value: function componentWillUnmount() { |
|
12369 window.removeEventListener('visibilitychange', this.addVisibilityCheck); |
|
12370 } |
|
12371 }, { |
|
12372 key: "render", |
|
12373 value: function render() { |
|
12374 var _this2 = this; |
|
12375 |
|
12376 var _this$props2 = this.props, |
|
12377 isEditable = _this$props2.isEditable, |
|
12378 isNew = _this$props2.isNew, |
|
12379 isPublished = _this$props2.isPublished, |
|
12380 isViewable = _this$props2.isViewable, |
|
12381 permalinkParts = _this$props2.permalinkParts, |
|
12382 postLink = _this$props2.postLink, |
|
12383 postSlug = _this$props2.postSlug, |
|
12384 postID = _this$props2.postID, |
|
12385 postTitle = _this$props2.postTitle; |
|
12386 |
|
12387 if (isNew || !isViewable || !permalinkParts || !postLink) { |
|
12388 return null; |
|
12389 } |
|
12390 |
|
12391 var _this$state = this.state, |
|
12392 isCopied = _this$state.isCopied, |
|
12393 isEditingPermalink = _this$state.isEditingPermalink; |
|
12394 var ariaLabel = isCopied ? Object(external_this_wp_i18n_["__"])('Permalink copied') : Object(external_this_wp_i18n_["__"])('Copy the permalink'); |
|
12395 var prefix = permalinkParts.prefix, |
|
12396 suffix = permalinkParts.suffix; |
|
12397 var slug = Object(external_this_wp_url_["safeDecodeURIComponent"])(postSlug) || cleanForSlug(postTitle) || postID; |
|
12398 var samplePermalink = isEditable ? prefix + slug + suffix : prefix; |
|
12399 return Object(external_this_wp_element_["createElement"])("div", { |
|
12400 className: "editor-post-permalink" |
|
12401 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["ClipboardButton"], { |
|
12402 className: classnames_default()('editor-post-permalink__copy', { |
|
12403 'is-copied': isCopied |
|
12404 }), |
|
12405 text: samplePermalink, |
|
12406 label: ariaLabel, |
|
12407 onCopy: function onCopy() { |
|
12408 return _this2.setState({ |
|
12409 isCopied: true |
|
12410 }); |
|
12411 }, |
|
12412 "aria-disabled": isCopied, |
|
12413 icon: "admin-links" |
|
12414 }), Object(external_this_wp_element_["createElement"])("span", { |
|
12415 className: "editor-post-permalink__label" |
|
12416 }, Object(external_this_wp_i18n_["__"])('Permalink:')), !isEditingPermalink && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["ExternalLink"], { |
|
12417 className: "editor-post-permalink__link", |
|
12418 href: !isPublished ? postLink : samplePermalink, |
|
12419 target: "_blank", |
|
12420 ref: function ref(linkElement) { |
|
12421 return _this2.linkElement = linkElement; |
|
12422 } |
|
12423 }, Object(external_this_wp_url_["safeDecodeURI"])(samplePermalink), "\u200E"), isEditingPermalink && Object(external_this_wp_element_["createElement"])(post_permalink_editor, { |
|
12424 slug: slug, |
|
12425 onSave: function onSave() { |
|
12426 return _this2.setState({ |
|
12427 isEditingPermalink: false |
|
12428 }); |
|
12429 } |
|
12430 }), isEditable && !isEditingPermalink && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
12431 className: "editor-post-permalink__edit", |
|
12432 isLarge: true, |
|
12433 onClick: function onClick() { |
|
12434 return _this2.setState({ |
|
12435 isEditingPermalink: true |
|
12436 }); |
|
12437 } |
|
12438 }, Object(external_this_wp_i18n_["__"])('Edit')), !isEditable && Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
12439 className: "editor-post-permalink__change", |
|
12440 isLarge: true, |
|
12441 href: getWPAdminURL('options-permalink.php'), |
|
12442 onClick: this.addVisibilityCheck, |
|
12443 target: "_blank" |
|
12444 }, Object(external_this_wp_i18n_["__"])('Change Permalinks'))); |
|
12445 } |
|
12446 }]); |
|
12447 |
|
12448 return PostPermalink; |
|
12449 }(external_this_wp_element_["Component"]); |
|
12450 |
|
12451 /* harmony default export */ var post_permalink = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
12452 var _select = select('core/editor'), |
|
12453 isEditedPostNew = _select.isEditedPostNew, |
|
12454 isPermalinkEditable = _select.isPermalinkEditable, |
|
12455 getCurrentPost = _select.getCurrentPost, |
|
12456 getPermalinkParts = _select.getPermalinkParts, |
|
12457 getEditedPostAttribute = _select.getEditedPostAttribute, |
|
12458 isCurrentPostPublished = _select.isCurrentPostPublished; |
|
12459 |
|
12460 var _select2 = select('core'), |
|
12461 getPostType = _select2.getPostType; |
|
12462 |
|
12463 var _getCurrentPost = getCurrentPost(), |
|
12464 id = _getCurrentPost.id, |
|
12465 link = _getCurrentPost.link; |
|
12466 |
|
12467 var postTypeName = getEditedPostAttribute('type'); |
|
12468 var postType = getPostType(postTypeName); |
|
12469 return { |
|
12470 isNew: isEditedPostNew(), |
|
12471 postLink: link, |
|
12472 permalinkParts: getPermalinkParts(), |
|
12473 postSlug: getEditedPostAttribute('slug'), |
|
12474 isEditable: isPermalinkEditable(), |
|
12475 isPublished: isCurrentPostPublished(), |
|
12476 postTitle: getEditedPostAttribute('title'), |
|
12477 postID: id, |
|
12478 isViewable: Object(external_lodash_["get"])(postType, ['viewable'], false) |
|
12479 }; |
|
12480 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
12481 var _dispatch = dispatch('core/editor'), |
|
12482 refreshPost = _dispatch.refreshPost; |
|
12483 |
|
12484 return { |
|
12485 refreshPost: refreshPost |
|
12486 }; |
|
12487 })])(post_permalink_PostPermalink)); |
|
12488 |
|
12489 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-title/index.js |
|
12490 |
|
12491 |
|
12492 |
|
12493 |
|
12494 |
|
12495 |
|
12496 |
|
12497 |
|
12498 /** |
|
12499 * External dependencies |
|
12500 */ |
|
12501 |
|
12502 |
|
12503 |
|
12504 /** |
|
12505 * WordPress dependencies |
|
12506 */ |
|
12507 |
|
12508 |
|
12509 |
|
12510 |
|
12511 |
|
12512 |
|
12513 |
|
12514 |
|
12515 /** |
|
12516 * Internal dependencies |
|
12517 */ |
|
12518 |
|
12519 |
|
12520 |
|
12521 /** |
|
12522 * Constants |
|
12523 */ |
|
12524 |
|
12525 var REGEXP_NEWLINES = /[\r\n]+/g; |
|
12526 |
|
12527 var post_title_PostTitle = |
|
12528 /*#__PURE__*/ |
|
12529 function (_Component) { |
|
12530 Object(inherits["a" /* default */])(PostTitle, _Component); |
|
12531 |
|
12532 function PostTitle() { |
|
12533 var _this; |
|
12534 |
|
12535 Object(classCallCheck["a" /* default */])(this, PostTitle); |
|
12536 |
|
12537 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(PostTitle).apply(this, arguments)); |
|
12538 _this.onChange = _this.onChange.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12539 _this.onSelect = _this.onSelect.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12540 _this.onUnselect = _this.onUnselect.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12541 _this.onKeyDown = _this.onKeyDown.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12542 _this.redirectHistory = _this.redirectHistory.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
12543 _this.state = { |
|
12544 isSelected: false |
|
12545 }; |
|
12546 return _this; |
|
12547 } |
|
12548 |
|
12549 Object(createClass["a" /* default */])(PostTitle, [{ |
|
12550 key: "handleFocusOutside", |
|
12551 value: function handleFocusOutside() { |
|
12552 this.onUnselect(); |
|
12553 } |
|
12554 }, { |
|
12555 key: "onSelect", |
|
12556 value: function onSelect() { |
|
12557 this.setState({ |
|
12558 isSelected: true |
|
12559 }); |
|
12560 this.props.clearSelectedBlock(); |
|
12561 } |
|
12562 }, { |
|
12563 key: "onUnselect", |
|
12564 value: function onUnselect() { |
|
12565 this.setState({ |
|
12566 isSelected: false |
|
12567 }); |
|
12568 } |
|
12569 }, { |
|
12570 key: "onChange", |
|
12571 value: function onChange(event) { |
|
12572 var newTitle = event.target.value.replace(REGEXP_NEWLINES, ' '); |
|
12573 this.props.onUpdate(newTitle); |
|
12574 } |
|
12575 }, { |
|
12576 key: "onKeyDown", |
|
12577 value: function onKeyDown(event) { |
|
12578 if (event.keyCode === external_this_wp_keycodes_["ENTER"]) { |
|
12579 event.preventDefault(); |
|
12580 this.props.onEnterPress(); |
|
12581 } |
|
12582 } |
|
12583 /** |
|
12584 * Emulates behavior of an undo or redo on its corresponding key press |
|
12585 * combination. This is a workaround to React's treatment of undo in a |
|
12586 * controlled textarea where characters are updated one at a time. |
|
12587 * Instead, leverage the store's undo handling of title changes. |
|
12588 * |
|
12589 * @see https://github.com/facebook/react/issues/8514 |
|
12590 * |
|
12591 * @param {KeyboardEvent} event Key event. |
|
12592 */ |
|
12593 |
|
12594 }, { |
|
12595 key: "redirectHistory", |
|
12596 value: function redirectHistory(event) { |
|
12597 if (event.shiftKey) { |
|
12598 this.props.onRedo(); |
|
12599 } else { |
|
12600 this.props.onUndo(); |
|
12601 } |
|
12602 |
|
12603 event.preventDefault(); |
|
12604 } |
|
12605 }, { |
|
12606 key: "render", |
|
12607 value: function render() { |
|
12608 var _this$props = this.props, |
|
12609 hasFixedToolbar = _this$props.hasFixedToolbar, |
|
12610 isCleanNewPost = _this$props.isCleanNewPost, |
|
12611 isFocusMode = _this$props.isFocusMode, |
|
12612 isPostTypeViewable = _this$props.isPostTypeViewable, |
|
12613 instanceId = _this$props.instanceId, |
|
12614 placeholder = _this$props.placeholder, |
|
12615 title = _this$props.title; |
|
12616 var isSelected = this.state.isSelected; // The wp-block className is important for editor styles. |
|
12617 |
|
12618 var className = classnames_default()('wp-block editor-post-title__block', { |
|
12619 'is-selected': isSelected, |
|
12620 'is-focus-mode': isFocusMode, |
|
12621 'has-fixed-toolbar': hasFixedToolbar |
|
12622 }); |
|
12623 var decodedPlaceholder = Object(external_this_wp_htmlEntities_["decodeEntities"])(placeholder); |
|
12624 return Object(external_this_wp_element_["createElement"])(post_type_support_check, { |
|
12625 supportKeys: "title" |
|
12626 }, Object(external_this_wp_element_["createElement"])("div", { |
|
12627 className: "editor-post-title" |
|
12628 }, Object(external_this_wp_element_["createElement"])("div", { |
|
12629 className: className |
|
12630 }, Object(external_this_wp_element_["createElement"])(external_this_wp_components_["KeyboardShortcuts"], { |
|
12631 shortcuts: { |
|
12632 'mod+z': this.redirectHistory, |
|
12633 'mod+shift+z': this.redirectHistory |
|
12634 } |
|
12635 }, Object(external_this_wp_element_["createElement"])("label", { |
|
12636 htmlFor: "post-title-".concat(instanceId), |
|
12637 className: "screen-reader-text" |
|
12638 }, decodedPlaceholder || Object(external_this_wp_i18n_["__"])('Add title')), Object(external_this_wp_element_["createElement"])(react_autosize_textarea_lib_default.a, { |
|
12639 id: "post-title-".concat(instanceId), |
|
12640 className: "editor-post-title__input", |
|
12641 value: title, |
|
12642 onChange: this.onChange, |
|
12643 placeholder: decodedPlaceholder || Object(external_this_wp_i18n_["__"])('Add title'), |
|
12644 onFocus: this.onSelect, |
|
12645 onKeyDown: this.onKeyDown, |
|
12646 onKeyPress: this.onUnselect |
|
12647 /* |
|
12648 Only autofocus the title when the post is entirely empty. |
|
12649 This should only happen for a new post, which means we |
|
12650 focus the title on new post so the author can start typing |
|
12651 right away, without needing to click anything. |
|
12652 */ |
|
12653 |
|
12654 /* eslint-disable jsx-a11y/no-autofocus */ |
|
12655 , |
|
12656 autoFocus: isCleanNewPost |
|
12657 /* eslint-enable jsx-a11y/no-autofocus */ |
|
12658 |
|
12659 })), isSelected && isPostTypeViewable && Object(external_this_wp_element_["createElement"])(post_permalink, null)))); |
|
12660 } |
|
12661 }]); |
|
12662 |
|
12663 return PostTitle; |
|
12664 }(external_this_wp_element_["Component"]); |
|
12665 |
|
12666 var post_title_applyWithSelect = Object(external_this_wp_data_["withSelect"])(function (select) { |
|
12667 var _select = select('core/editor'), |
|
12668 getEditedPostAttribute = _select.getEditedPostAttribute, |
|
12669 isCleanNewPost = _select.isCleanNewPost; |
|
12670 |
|
12671 var _select2 = select('core/block-editor'), |
|
12672 getSettings = _select2.getSettings; |
|
12673 |
|
12674 var _select3 = select('core'), |
|
12675 getPostType = _select3.getPostType; |
|
12676 |
|
12677 var postType = getPostType(getEditedPostAttribute('type')); |
|
12678 |
|
12679 var _getSettings = getSettings(), |
|
12680 titlePlaceholder = _getSettings.titlePlaceholder, |
|
12681 focusMode = _getSettings.focusMode, |
|
12682 hasFixedToolbar = _getSettings.hasFixedToolbar; |
|
12683 |
|
12684 return { |
|
12685 isCleanNewPost: isCleanNewPost(), |
|
12686 title: getEditedPostAttribute('title'), |
|
12687 isPostTypeViewable: Object(external_lodash_["get"])(postType, ['viewable'], false), |
|
12688 placeholder: titlePlaceholder, |
|
12689 isFocusMode: focusMode, |
|
12690 hasFixedToolbar: hasFixedToolbar |
|
12691 }; |
|
12692 }); |
|
12693 var post_title_applyWithDispatch = Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
12694 var _dispatch = dispatch('core/block-editor'), |
|
12695 insertDefaultBlock = _dispatch.insertDefaultBlock, |
|
12696 clearSelectedBlock = _dispatch.clearSelectedBlock; |
|
12697 |
|
12698 var _dispatch2 = dispatch('core/editor'), |
|
12699 editPost = _dispatch2.editPost, |
|
12700 undo = _dispatch2.undo, |
|
12701 redo = _dispatch2.redo; |
|
12702 |
|
12703 return { |
|
12704 onEnterPress: function onEnterPress() { |
|
12705 insertDefaultBlock(undefined, undefined, 0); |
|
12706 }, |
|
12707 onUpdate: function onUpdate(title) { |
|
12708 editPost({ |
|
12709 title: title |
|
12710 }); |
|
12711 }, |
|
12712 onUndo: undo, |
|
12713 onRedo: redo, |
|
12714 clearSelectedBlock: clearSelectedBlock |
|
12715 }; |
|
12716 }); |
|
12717 /* harmony default export */ var post_title = (Object(external_this_wp_compose_["compose"])(post_title_applyWithSelect, post_title_applyWithDispatch, external_this_wp_compose_["withInstanceId"], external_this_wp_components_["withFocusOutside"])(post_title_PostTitle)); |
|
12718 |
|
12719 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-trash/index.js |
|
12720 |
|
12721 |
|
12722 |
|
12723 /** |
|
12724 * WordPress dependencies |
|
12725 */ |
|
12726 |
|
12727 |
|
12728 |
|
12729 |
|
12730 |
|
12731 function PostTrash(_ref) { |
|
12732 var isNew = _ref.isNew, |
|
12733 postId = _ref.postId, |
|
12734 postType = _ref.postType, |
|
12735 props = Object(objectWithoutProperties["a" /* default */])(_ref, ["isNew", "postId", "postType"]); |
|
12736 |
|
12737 if (isNew || !postId) { |
|
12738 return null; |
|
12739 } |
|
12740 |
|
12741 var onClick = function onClick() { |
|
12742 return props.trashPost(postId, postType); |
|
12743 }; |
|
12744 |
|
12745 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Button"], { |
|
12746 className: "editor-post-trash button-link-delete", |
|
12747 onClick: onClick, |
|
12748 isDefault: true, |
|
12749 isLarge: true |
|
12750 }, Object(external_this_wp_i18n_["__"])('Move to trash')); |
|
12751 } |
|
12752 |
|
12753 /* harmony default export */ var post_trash = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
12754 var _select = select('core/editor'), |
|
12755 isEditedPostNew = _select.isEditedPostNew, |
|
12756 getCurrentPostId = _select.getCurrentPostId, |
|
12757 getCurrentPostType = _select.getCurrentPostType; |
|
12758 |
|
12759 return { |
|
12760 isNew: isEditedPostNew(), |
|
12761 postId: getCurrentPostId(), |
|
12762 postType: getCurrentPostType() |
|
12763 }; |
|
12764 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
12765 return { |
|
12766 trashPost: dispatch('core/editor').trashPost |
|
12767 }; |
|
12768 })])(PostTrash)); |
|
12769 |
|
12770 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-trash/check.js |
|
12771 /** |
|
12772 * WordPress dependencies |
|
12773 */ |
|
12774 |
|
12775 |
|
12776 function PostTrashCheck(_ref) { |
|
12777 var isNew = _ref.isNew, |
|
12778 postId = _ref.postId, |
|
12779 children = _ref.children; |
|
12780 |
|
12781 if (isNew || !postId) { |
|
12782 return null; |
|
12783 } |
|
12784 |
|
12785 return children; |
|
12786 } |
|
12787 |
|
12788 /* harmony default export */ var post_trash_check = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
12789 var _select = select('core/editor'), |
|
12790 isEditedPostNew = _select.isEditedPostNew, |
|
12791 getCurrentPostId = _select.getCurrentPostId; |
|
12792 |
|
12793 return { |
|
12794 isNew: isEditedPostNew(), |
|
12795 postId: getCurrentPostId() |
|
12796 }; |
|
12797 })(PostTrashCheck)); |
|
12798 |
|
12799 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/post-visibility/check.js |
|
12800 /** |
|
12801 * External dependencies |
|
12802 */ |
|
12803 |
|
12804 /** |
|
12805 * WordPress dependencies |
|
12806 */ |
|
12807 |
|
12808 |
|
12809 |
|
12810 function PostVisibilityCheck(_ref) { |
|
12811 var hasPublishAction = _ref.hasPublishAction, |
|
12812 render = _ref.render; |
|
12813 var canEdit = hasPublishAction; |
|
12814 return render({ |
|
12815 canEdit: canEdit |
|
12816 }); |
|
12817 } |
|
12818 /* harmony default export */ var post_visibility_check = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
12819 var _select = select('core/editor'), |
|
12820 getCurrentPost = _select.getCurrentPost, |
|
12821 getCurrentPostType = _select.getCurrentPostType; |
|
12822 |
|
12823 return { |
|
12824 hasPublishAction: Object(external_lodash_["get"])(getCurrentPost(), ['_links', 'wp:action-publish'], false), |
|
12825 postType: getCurrentPostType() |
|
12826 }; |
|
12827 })])(PostVisibilityCheck)); |
|
12828 |
|
12829 // EXTERNAL MODULE: external {"this":["wp","wordcount"]} |
|
12830 var external_this_wp_wordcount_ = __webpack_require__(98); |
|
12831 |
|
12832 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/word-count/index.js |
|
12833 |
|
12834 |
|
12835 /** |
|
12836 * WordPress dependencies |
|
12837 */ |
|
12838 |
|
12839 |
|
12840 |
|
12841 |
|
12842 function WordCount(_ref) { |
|
12843 var content = _ref.content; |
|
12844 |
|
12845 /* |
|
12846 * translators: If your word count is based on single characters (e.g. East Asian characters), |
|
12847 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'. |
|
12848 * Do not translate into your own language. |
|
12849 */ |
|
12850 var wordCountType = Object(external_this_wp_i18n_["_x"])('words', 'Word count type. Do not translate!'); |
|
12851 |
|
12852 return Object(external_this_wp_element_["createElement"])("span", { |
|
12853 className: "word-count" |
|
12854 }, Object(external_this_wp_wordcount_["count"])(content, wordCountType)); |
|
12855 } |
|
12856 |
|
12857 /* harmony default export */ var word_count = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
12858 return { |
|
12859 content: select('core/editor').getEditedPostAttribute('content') |
|
12860 }; |
|
12861 })(WordCount)); |
|
12862 |
|
12863 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/table-of-contents/panel.js |
|
12864 |
|
12865 |
|
12866 /** |
|
12867 * WordPress dependencies |
|
12868 */ |
|
12869 |
|
12870 |
|
12871 |
|
12872 /** |
|
12873 * Internal dependencies |
|
12874 */ |
|
12875 |
|
12876 |
|
12877 |
|
12878 |
|
12879 function TableOfContentsPanel(_ref) { |
|
12880 var headingCount = _ref.headingCount, |
|
12881 paragraphCount = _ref.paragraphCount, |
|
12882 numberOfBlocks = _ref.numberOfBlocks, |
|
12883 hasOutlineItemsDisabled = _ref.hasOutlineItemsDisabled, |
|
12884 onRequestClose = _ref.onRequestClose; |
|
12885 return Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])("div", { |
|
12886 className: "table-of-contents__counts", |
|
12887 role: "note", |
|
12888 "aria-label": Object(external_this_wp_i18n_["__"])('Document Statistics'), |
|
12889 tabIndex: "0" |
|
12890 }, Object(external_this_wp_element_["createElement"])("div", { |
|
12891 className: "table-of-contents__count" |
|
12892 }, Object(external_this_wp_i18n_["__"])('Words'), Object(external_this_wp_element_["createElement"])(word_count, null)), Object(external_this_wp_element_["createElement"])("div", { |
|
12893 className: "table-of-contents__count" |
|
12894 }, Object(external_this_wp_i18n_["__"])('Headings'), Object(external_this_wp_element_["createElement"])("span", { |
|
12895 className: "table-of-contents__number" |
|
12896 }, headingCount)), Object(external_this_wp_element_["createElement"])("div", { |
|
12897 className: "table-of-contents__count" |
|
12898 }, Object(external_this_wp_i18n_["__"])('Paragraphs'), Object(external_this_wp_element_["createElement"])("span", { |
|
12899 className: "table-of-contents__number" |
|
12900 }, paragraphCount)), Object(external_this_wp_element_["createElement"])("div", { |
|
12901 className: "table-of-contents__count" |
|
12902 }, Object(external_this_wp_i18n_["__"])('Blocks'), Object(external_this_wp_element_["createElement"])("span", { |
|
12903 className: "table-of-contents__number" |
|
12904 }, numberOfBlocks))), headingCount > 0 && Object(external_this_wp_element_["createElement"])(external_this_wp_element_["Fragment"], null, Object(external_this_wp_element_["createElement"])("hr", null), Object(external_this_wp_element_["createElement"])("span", { |
|
12905 className: "table-of-contents__title" |
|
12906 }, Object(external_this_wp_i18n_["__"])('Document Outline')), Object(external_this_wp_element_["createElement"])(document_outline, { |
|
12907 onSelect: onRequestClose, |
|
12908 hasOutlineItemsDisabled: hasOutlineItemsDisabled |
|
12909 }))); |
|
12910 } |
|
12911 |
|
12912 /* harmony default export */ var panel = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
12913 var _select = select('core/block-editor'), |
|
12914 getGlobalBlockCount = _select.getGlobalBlockCount; |
|
12915 |
|
12916 return { |
|
12917 headingCount: getGlobalBlockCount('core/heading'), |
|
12918 paragraphCount: getGlobalBlockCount('core/paragraph'), |
|
12919 numberOfBlocks: getGlobalBlockCount() |
|
12920 }; |
|
12921 })(TableOfContentsPanel)); |
|
12922 |
|
12923 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/table-of-contents/index.js |
|
12924 |
|
12925 |
|
12926 /** |
|
12927 * WordPress dependencies |
|
12928 */ |
|
12929 |
|
12930 |
|
12931 |
|
12932 /** |
|
12933 * Internal dependencies |
|
12934 */ |
|
12935 |
|
12936 |
|
12937 |
|
12938 function TableOfContents(_ref) { |
|
12939 var hasBlocks = _ref.hasBlocks, |
|
12940 hasOutlineItemsDisabled = _ref.hasOutlineItemsDisabled; |
|
12941 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["Dropdown"], { |
|
12942 position: "bottom", |
|
12943 className: "table-of-contents", |
|
12944 contentClassName: "table-of-contents__popover", |
|
12945 renderToggle: function renderToggle(_ref2) { |
|
12946 var isOpen = _ref2.isOpen, |
|
12947 onToggle = _ref2.onToggle; |
|
12948 return Object(external_this_wp_element_["createElement"])(external_this_wp_components_["IconButton"], { |
|
12949 onClick: hasBlocks ? onToggle : undefined, |
|
12950 icon: "info-outline", |
|
12951 "aria-expanded": isOpen, |
|
12952 label: Object(external_this_wp_i18n_["__"])('Content structure'), |
|
12953 labelPosition: "bottom", |
|
12954 "aria-disabled": !hasBlocks |
|
12955 }); |
|
12956 }, |
|
12957 renderContent: function renderContent(_ref3) { |
|
12958 var onClose = _ref3.onClose; |
|
12959 return Object(external_this_wp_element_["createElement"])(panel, { |
|
12960 onRequestClose: onClose, |
|
12961 hasOutlineItemsDisabled: hasOutlineItemsDisabled |
|
12962 }); |
|
12963 } |
|
12964 }); |
|
12965 } |
|
12966 |
|
12967 /* harmony default export */ var table_of_contents = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
12968 return { |
|
12969 hasBlocks: !!select('core/block-editor').getBlockCount() |
|
12970 }; |
|
12971 })(TableOfContents)); |
|
12972 |
|
12973 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/unsaved-changes-warning/index.js |
|
12974 |
|
12975 |
|
12976 |
|
12977 |
|
12978 |
|
12979 |
|
12980 |
|
12981 /** |
|
12982 * WordPress dependencies |
|
12983 */ |
|
12984 |
|
12985 |
|
12986 |
|
12987 |
|
12988 var unsaved_changes_warning_UnsavedChangesWarning = |
|
12989 /*#__PURE__*/ |
|
12990 function (_Component) { |
|
12991 Object(inherits["a" /* default */])(UnsavedChangesWarning, _Component); |
|
12992 |
|
12993 function UnsavedChangesWarning() { |
|
12994 var _this; |
|
12995 |
|
12996 Object(classCallCheck["a" /* default */])(this, UnsavedChangesWarning); |
|
12997 |
|
12998 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(UnsavedChangesWarning).apply(this, arguments)); |
|
12999 _this.warnIfUnsavedChanges = _this.warnIfUnsavedChanges.bind(Object(assertThisInitialized["a" /* default */])(Object(assertThisInitialized["a" /* default */])(_this))); |
|
13000 return _this; |
|
13001 } |
|
13002 |
|
13003 Object(createClass["a" /* default */])(UnsavedChangesWarning, [{ |
|
13004 key: "componentDidMount", |
|
13005 value: function componentDidMount() { |
|
13006 window.addEventListener('beforeunload', this.warnIfUnsavedChanges); |
|
13007 } |
|
13008 }, { |
|
13009 key: "componentWillUnmount", |
|
13010 value: function componentWillUnmount() { |
|
13011 window.removeEventListener('beforeunload', this.warnIfUnsavedChanges); |
|
13012 } |
|
13013 /** |
|
13014 * Warns the user if there are unsaved changes before leaving the editor. |
|
13015 * |
|
13016 * @param {Event} event `beforeunload` event. |
|
13017 * |
|
13018 * @return {?string} Warning prompt message, if unsaved changes exist. |
|
13019 */ |
|
13020 |
|
13021 }, { |
|
13022 key: "warnIfUnsavedChanges", |
|
13023 value: function warnIfUnsavedChanges(event) { |
|
13024 var isDirty = this.props.isDirty; |
|
13025 |
|
13026 if (isDirty) { |
|
13027 event.returnValue = Object(external_this_wp_i18n_["__"])('You have unsaved changes. If you proceed, they will be lost.'); |
|
13028 return event.returnValue; |
|
13029 } |
|
13030 } |
|
13031 }, { |
|
13032 key: "render", |
|
13033 value: function render() { |
|
13034 return null; |
|
13035 } |
|
13036 }]); |
|
13037 |
|
13038 return UnsavedChangesWarning; |
|
13039 }(external_this_wp_element_["Component"]); |
|
13040 |
|
13041 /* harmony default export */ var unsaved_changes_warning = (Object(external_this_wp_data_["withSelect"])(function (select) { |
|
13042 return { |
|
13043 isDirty: select('core/editor').isEditedPostDirty() |
|
13044 }; |
|
13045 })(unsaved_changes_warning_UnsavedChangesWarning)); |
|
13046 |
|
13047 // EXTERNAL MODULE: ./node_modules/memize/index.js |
|
13048 var memize = __webpack_require__(41); |
|
13049 var memize_default = /*#__PURE__*/__webpack_require__.n(memize); |
|
13050 |
|
13051 // EXTERNAL MODULE: ./node_modules/traverse/index.js |
|
13052 var traverse = __webpack_require__(227); |
|
13053 var traverse_default = /*#__PURE__*/__webpack_require__.n(traverse); |
|
13054 |
|
13055 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/editor-styles/ast/parse.js |
|
13056 |
|
13057 |
|
13058 /* eslint-disable @wordpress/no-unused-vars-before-return */ |
|
13059 // Adapted from https://github.com/reworkcss/css |
|
13060 // because we needed to remove source map support. |
|
13061 // http://www.w3.org/TR/CSS21/grammar.htm |
|
13062 // https://github.com/visionmedia/css-parse/pull/49#issuecomment-30088027 |
|
13063 var commentre = /\/\*[^*]*\*+([^/*][^*]*\*+)*\//g; |
|
13064 /* harmony default export */ var parse = (function (css, options) { |
|
13065 options = options || {}; |
|
13066 /** |
|
13067 * Positional. |
|
13068 */ |
|
13069 |
|
13070 var lineno = 1; |
|
13071 var column = 1; |
|
13072 /** |
|
13073 * Update lineno and column based on `str`. |
|
13074 */ |
|
13075 |
|
13076 function updatePosition(str) { |
|
13077 var lines = str.match(/\n/g); |
|
13078 |
|
13079 if (lines) { |
|
13080 lineno += lines.length; |
|
13081 } |
|
13082 |
|
13083 var i = str.lastIndexOf('\n'); // eslint-disable-next-line no-bitwise |
|
13084 |
|
13085 column = ~i ? str.length - i : column + str.length; |
|
13086 } |
|
13087 /** |
|
13088 * Mark position and patch `node.position`. |
|
13089 */ |
|
13090 |
|
13091 |
|
13092 function position() { |
|
13093 var start = { |
|
13094 line: lineno, |
|
13095 column: column |
|
13096 }; |
|
13097 return function (node) { |
|
13098 node.position = new Position(start); |
|
13099 whitespace(); |
|
13100 return node; |
|
13101 }; |
|
13102 } |
|
13103 /** |
|
13104 * Store position information for a node |
|
13105 */ |
|
13106 |
|
13107 |
|
13108 function Position(start) { |
|
13109 this.start = start; |
|
13110 this.end = { |
|
13111 line: lineno, |
|
13112 column: column |
|
13113 }; |
|
13114 this.source = options.source; |
|
13115 } |
|
13116 /** |
|
13117 * Non-enumerable source string |
|
13118 */ |
|
13119 |
|
13120 |
|
13121 Position.prototype.content = css; |
|
13122 /** |
|
13123 * Error `msg`. |
|
13124 */ |
|
13125 |
|
13126 var errorsList = []; |
|
13127 |
|
13128 function error(msg) { |
|
13129 var err = new Error(options.source + ':' + lineno + ':' + column + ': ' + msg); |
|
13130 err.reason = msg; |
|
13131 err.filename = options.source; |
|
13132 err.line = lineno; |
|
13133 err.column = column; |
|
13134 err.source = css; |
|
13135 |
|
13136 if (options.silent) { |
|
13137 errorsList.push(err); |
|
13138 } else { |
|
13139 throw err; |
|
13140 } |
|
13141 } |
|
13142 /** |
|
13143 * Parse stylesheet. |
|
13144 */ |
|
13145 |
|
13146 |
|
13147 function stylesheet() { |
|
13148 var rulesList = rules(); |
|
13149 return { |
|
13150 type: 'stylesheet', |
|
13151 stylesheet: { |
|
13152 source: options.source, |
|
13153 rules: rulesList, |
|
13154 parsingErrors: errorsList |
|
13155 } |
|
13156 }; |
|
13157 } |
|
13158 /** |
|
13159 * Opening brace. |
|
13160 */ |
|
13161 |
|
13162 |
|
13163 function open() { |
|
13164 return match(/^{\s*/); |
|
13165 } |
|
13166 /** |
|
13167 * Closing brace. |
|
13168 */ |
|
13169 |
|
13170 |
|
13171 function close() { |
|
13172 return match(/^}/); |
|
13173 } |
|
13174 /** |
|
13175 * Parse ruleset. |
|
13176 */ |
|
13177 |
|
13178 |
|
13179 function rules() { |
|
13180 var node; |
|
13181 var accumulator = []; |
|
13182 whitespace(); |
|
13183 comments(accumulator); |
|
13184 |
|
13185 while (css.length && css.charAt(0) !== '}' && (node = atrule() || rule())) { |
|
13186 if (node !== false) { |
|
13187 accumulator.push(node); |
|
13188 comments(accumulator); |
|
13189 } |
|
13190 } |
|
13191 |
|
13192 return accumulator; |
|
13193 } |
|
13194 /** |
|
13195 * Match `re` and return captures. |
|
13196 */ |
|
13197 |
|
13198 |
|
13199 function match(re) { |
|
13200 var m = re.exec(css); |
|
13201 |
|
13202 if (!m) { |
|
13203 return; |
|
13204 } |
|
13205 |
|
13206 var str = m[0]; |
|
13207 updatePosition(str); |
|
13208 css = css.slice(str.length); |
|
13209 return m; |
|
13210 } |
|
13211 /** |
|
13212 * Parse whitespace. |
|
13213 */ |
|
13214 |
|
13215 |
|
13216 function whitespace() { |
|
13217 match(/^\s*/); |
|
13218 } |
|
13219 /** |
|
13220 * Parse comments; |
|
13221 */ |
|
13222 |
|
13223 |
|
13224 function comments(accumulator) { |
|
13225 var c; |
|
13226 accumulator = accumulator || []; // eslint-disable-next-line no-cond-assign |
|
13227 |
|
13228 while (c = comment()) { |
|
13229 if (c !== false) { |
|
13230 accumulator.push(c); |
|
13231 } |
|
13232 } |
|
13233 |
|
13234 return accumulator; |
|
13235 } |
|
13236 /** |
|
13237 * Parse comment. |
|
13238 */ |
|
13239 |
|
13240 |
|
13241 function comment() { |
|
13242 var pos = position(); |
|
13243 |
|
13244 if ('/' !== css.charAt(0) || '*' !== css.charAt(1)) { |
|
13245 return; |
|
13246 } |
|
13247 |
|
13248 var i = 2; |
|
13249 |
|
13250 while ('' !== css.charAt(i) && ('*' !== css.charAt(i) || '/' !== css.charAt(i + 1))) { |
|
13251 ++i; |
|
13252 } |
|
13253 |
|
13254 i += 2; |
|
13255 |
|
13256 if ('' === css.charAt(i - 1)) { |
|
13257 return error('End of comment missing'); |
|
13258 } |
|
13259 |
|
13260 var str = css.slice(2, i - 2); |
|
13261 column += 2; |
|
13262 updatePosition(str); |
|
13263 css = css.slice(i); |
|
13264 column += 2; |
|
13265 return pos({ |
|
13266 type: 'comment', |
|
13267 comment: str |
|
13268 }); |
|
13269 } |
|
13270 /** |
|
13271 * Parse selector. |
|
13272 */ |
|
13273 |
|
13274 |
|
13275 function selector() { |
|
13276 var m = match(/^([^{]+)/); |
|
13277 |
|
13278 if (!m) { |
|
13279 return; |
|
13280 } |
|
13281 /* @fix Remove all comments from selectors |
|
13282 * http://ostermiller.org/findcomment.html */ |
|
13283 |
|
13284 |
|
13285 return trim(m[0]).replace(/\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*\/+/g, '').replace(/"(?:\\"|[^"])*"|'(?:\\'|[^'])*'/g, function (matched) { |
|
13286 return matched.replace(/,/g, "\u200C"); |
|
13287 }).split(/\s*(?![^(]*\)),\s*/).map(function (s) { |
|
13288 return s.replace(/\u200C/g, ','); |
|
13289 }); |
|
13290 } |
|
13291 /** |
|
13292 * Parse declaration. |
|
13293 */ |
|
13294 |
|
13295 |
|
13296 function declaration() { |
|
13297 var pos = position(); // prop |
|
13298 |
|
13299 var prop = match(/^(\*?[-#\/\*\\\w]+(\[[0-9a-z_-]+\])?)\s*/); |
|
13300 |
|
13301 if (!prop) { |
|
13302 return; |
|
13303 } |
|
13304 |
|
13305 prop = trim(prop[0]); // : |
|
13306 |
|
13307 if (!match(/^:\s*/)) { |
|
13308 return error("property missing ':'"); |
|
13309 } // val |
|
13310 |
|
13311 |
|
13312 var val = match(/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^\)]*?\)|[^};])+)/); |
|
13313 var ret = pos({ |
|
13314 type: 'declaration', |
|
13315 property: prop.replace(commentre, ''), |
|
13316 value: val ? trim(val[0]).replace(commentre, '') : '' |
|
13317 }); // ; |
|
13318 |
|
13319 match(/^[;\s]*/); |
|
13320 return ret; |
|
13321 } |
|
13322 /** |
|
13323 * Parse declarations. |
|
13324 */ |
|
13325 |
|
13326 |
|
13327 function declarations() { |
|
13328 var decls = []; |
|
13329 |
|
13330 if (!open()) { |
|
13331 return error("missing '{'"); |
|
13332 } |
|
13333 |
|
13334 comments(decls); // declarations |
|
13335 |
|
13336 var decl; // eslint-disable-next-line no-cond-assign |
|
13337 |
|
13338 while (decl = declaration()) { |
|
13339 if (decl !== false) { |
|
13340 decls.push(decl); |
|
13341 comments(decls); |
|
13342 } |
|
13343 } |
|
13344 |
|
13345 if (!close()) { |
|
13346 return error("missing '}'"); |
|
13347 } |
|
13348 |
|
13349 return decls; |
|
13350 } |
|
13351 /** |
|
13352 * Parse keyframe. |
|
13353 */ |
|
13354 |
|
13355 |
|
13356 function keyframe() { |
|
13357 var m; |
|
13358 var vals = []; |
|
13359 var pos = position(); // eslint-disable-next-line no-cond-assign |
|
13360 |
|
13361 while (m = match(/^((\d+\.\d+|\.\d+|\d+)%?|[a-z]+)\s*/)) { |
|
13362 vals.push(m[1]); |
|
13363 match(/^,\s*/); |
|
13364 } |
|
13365 |
|
13366 if (!vals.length) { |
|
13367 return; |
|
13368 } |
|
13369 |
|
13370 return pos({ |
|
13371 type: 'keyframe', |
|
13372 values: vals, |
|
13373 declarations: declarations() |
|
13374 }); |
|
13375 } |
|
13376 /** |
|
13377 * Parse keyframes. |
|
13378 */ |
|
13379 |
|
13380 |
|
13381 function atkeyframes() { |
|
13382 var pos = position(); |
|
13383 var m = match(/^@([-\w]+)?keyframes\s*/); |
|
13384 |
|
13385 if (!m) { |
|
13386 return; |
|
13387 } |
|
13388 |
|
13389 var vendor = m[1]; // identifier |
|
13390 |
|
13391 m = match(/^([-\w]+)\s*/); |
|
13392 |
|
13393 if (!m) { |
|
13394 return error('@keyframes missing name'); |
|
13395 } |
|
13396 |
|
13397 var name = m[1]; |
|
13398 |
|
13399 if (!open()) { |
|
13400 return error("@keyframes missing '{'"); |
|
13401 } |
|
13402 |
|
13403 var frame; |
|
13404 var frames = comments(); // eslint-disable-next-line no-cond-assign |
|
13405 |
|
13406 while (frame = keyframe()) { |
|
13407 frames.push(frame); |
|
13408 frames = frames.concat(comments()); |
|
13409 } |
|
13410 |
|
13411 if (!close()) { |
|
13412 return error("@keyframes missing '}'"); |
|
13413 } |
|
13414 |
|
13415 return pos({ |
|
13416 type: 'keyframes', |
|
13417 name: name, |
|
13418 vendor: vendor, |
|
13419 keyframes: frames |
|
13420 }); |
|
13421 } |
|
13422 /** |
|
13423 * Parse supports. |
|
13424 */ |
|
13425 |
|
13426 |
|
13427 function atsupports() { |
|
13428 var pos = position(); |
|
13429 var m = match(/^@supports *([^{]+)/); |
|
13430 |
|
13431 if (!m) { |
|
13432 return; |
|
13433 } |
|
13434 |
|
13435 var supports = trim(m[1]); |
|
13436 |
|
13437 if (!open()) { |
|
13438 return error("@supports missing '{'"); |
|
13439 } |
|
13440 |
|
13441 var style = comments().concat(rules()); |
|
13442 |
|
13443 if (!close()) { |
|
13444 return error("@supports missing '}'"); |
|
13445 } |
|
13446 |
|
13447 return pos({ |
|
13448 type: 'supports', |
|
13449 supports: supports, |
|
13450 rules: style |
|
13451 }); |
|
13452 } |
|
13453 /** |
|
13454 * Parse host. |
|
13455 */ |
|
13456 |
|
13457 |
|
13458 function athost() { |
|
13459 var pos = position(); |
|
13460 var m = match(/^@host\s*/); |
|
13461 |
|
13462 if (!m) { |
|
13463 return; |
|
13464 } |
|
13465 |
|
13466 if (!open()) { |
|
13467 return error("@host missing '{'"); |
|
13468 } |
|
13469 |
|
13470 var style = comments().concat(rules()); |
|
13471 |
|
13472 if (!close()) { |
|
13473 return error("@host missing '}'"); |
|
13474 } |
|
13475 |
|
13476 return pos({ |
|
13477 type: 'host', |
|
13478 rules: style |
|
13479 }); |
|
13480 } |
|
13481 /** |
|
13482 * Parse media. |
|
13483 */ |
|
13484 |
|
13485 |
|
13486 function atmedia() { |
|
13487 var pos = position(); |
|
13488 var m = match(/^@media *([^{]+)/); |
|
13489 |
|
13490 if (!m) { |
|
13491 return; |
|
13492 } |
|
13493 |
|
13494 var media = trim(m[1]); |
|
13495 |
|
13496 if (!open()) { |
|
13497 return error("@media missing '{'"); |
|
13498 } |
|
13499 |
|
13500 var style = comments().concat(rules()); |
|
13501 |
|
13502 if (!close()) { |
|
13503 return error("@media missing '}'"); |
|
13504 } |
|
13505 |
|
13506 return pos({ |
|
13507 type: 'media', |
|
13508 media: media, |
|
13509 rules: style |
|
13510 }); |
|
13511 } |
|
13512 /** |
|
13513 * Parse custom-media. |
|
13514 */ |
|
13515 |
|
13516 |
|
13517 function atcustommedia() { |
|
13518 var pos = position(); |
|
13519 var m = match(/^@custom-media\s+(--[^\s]+)\s*([^{;]+);/); |
|
13520 |
|
13521 if (!m) { |
|
13522 return; |
|
13523 } |
|
13524 |
|
13525 return pos({ |
|
13526 type: 'custom-media', |
|
13527 name: trim(m[1]), |
|
13528 media: trim(m[2]) |
|
13529 }); |
|
13530 } |
|
13531 /** |
|
13532 * Parse paged media. |
|
13533 */ |
|
13534 |
|
13535 |
|
13536 function atpage() { |
|
13537 var pos = position(); |
|
13538 var m = match(/^@page */); |
|
13539 |
|
13540 if (!m) { |
|
13541 return; |
|
13542 } |
|
13543 |
|
13544 var sel = selector() || []; |
|
13545 |
|
13546 if (!open()) { |
|
13547 return error("@page missing '{'"); |
|
13548 } |
|
13549 |
|
13550 var decls = comments(); // declarations |
|
13551 |
|
13552 var decl; // eslint-disable-next-line no-cond-assign |
|
13553 |
|
13554 while (decl = declaration()) { |
|
13555 decls.push(decl); |
|
13556 decls = decls.concat(comments()); |
|
13557 } |
|
13558 |
|
13559 if (!close()) { |
|
13560 return error("@page missing '}'"); |
|
13561 } |
|
13562 |
|
13563 return pos({ |
|
13564 type: 'page', |
|
13565 selectors: sel, |
|
13566 declarations: decls |
|
13567 }); |
|
13568 } |
|
13569 /** |
|
13570 * Parse document. |
|
13571 */ |
|
13572 |
|
13573 |
|
13574 function atdocument() { |
|
13575 var pos = position(); |
|
13576 var m = match(/^@([-\w]+)?document *([^{]+)/); |
|
13577 |
|
13578 if (!m) { |
|
13579 return; |
|
13580 } |
|
13581 |
|
13582 var vendor = trim(m[1]); |
|
13583 var doc = trim(m[2]); |
|
13584 |
|
13585 if (!open()) { |
|
13586 return error("@document missing '{'"); |
|
13587 } |
|
13588 |
|
13589 var style = comments().concat(rules()); |
|
13590 |
|
13591 if (!close()) { |
|
13592 return error("@document missing '}'"); |
|
13593 } |
|
13594 |
|
13595 return pos({ |
|
13596 type: 'document', |
|
13597 document: doc, |
|
13598 vendor: vendor, |
|
13599 rules: style |
|
13600 }); |
|
13601 } |
|
13602 /** |
|
13603 * Parse font-face. |
|
13604 */ |
|
13605 |
|
13606 |
|
13607 function atfontface() { |
|
13608 var pos = position(); |
|
13609 var m = match(/^@font-face\s*/); |
|
13610 |
|
13611 if (!m) { |
|
13612 return; |
|
13613 } |
|
13614 |
|
13615 if (!open()) { |
|
13616 return error("@font-face missing '{'"); |
|
13617 } |
|
13618 |
|
13619 var decls = comments(); // declarations |
|
13620 |
|
13621 var decl; // eslint-disable-next-line no-cond-assign |
|
13622 |
|
13623 while (decl = declaration()) { |
|
13624 decls.push(decl); |
|
13625 decls = decls.concat(comments()); |
|
13626 } |
|
13627 |
|
13628 if (!close()) { |
|
13629 return error("@font-face missing '}'"); |
|
13630 } |
|
13631 |
|
13632 return pos({ |
|
13633 type: 'font-face', |
|
13634 declarations: decls |
|
13635 }); |
|
13636 } |
|
13637 /** |
|
13638 * Parse import |
|
13639 */ |
|
13640 |
|
13641 |
|
13642 var atimport = _compileAtrule('import'); |
|
13643 /** |
|
13644 * Parse charset |
|
13645 */ |
|
13646 |
|
13647 |
|
13648 var atcharset = _compileAtrule('charset'); |
|
13649 /** |
|
13650 * Parse namespace |
|
13651 */ |
|
13652 |
|
13653 |
|
13654 var atnamespace = _compileAtrule('namespace'); |
|
13655 /** |
|
13656 * Parse non-block at-rules |
|
13657 */ |
|
13658 |
|
13659 |
|
13660 function _compileAtrule(name) { |
|
13661 var re = new RegExp('^@' + name + '\\s*([^;]+);'); |
|
13662 return function () { |
|
13663 var pos = position(); |
|
13664 var m = match(re); |
|
13665 |
|
13666 if (!m) { |
|
13667 return; |
|
13668 } |
|
13669 |
|
13670 var ret = { |
|
13671 type: name |
|
13672 }; |
|
13673 ret[name] = m[1].trim(); |
|
13674 return pos(ret); |
|
13675 }; |
|
13676 } |
|
13677 /** |
|
13678 * Parse at rule. |
|
13679 */ |
|
13680 |
|
13681 |
|
13682 function atrule() { |
|
13683 if (css[0] !== '@') { |
|
13684 return; |
|
13685 } |
|
13686 |
|
13687 return atkeyframes() || atmedia() || atcustommedia() || atsupports() || atimport() || atcharset() || atnamespace() || atdocument() || atpage() || athost() || atfontface(); |
|
13688 } |
|
13689 /** |
|
13690 * Parse rule. |
|
13691 */ |
|
13692 |
|
13693 |
|
13694 function rule() { |
|
13695 var pos = position(); |
|
13696 var sel = selector(); |
|
13697 |
|
13698 if (!sel) { |
|
13699 return error('selector missing'); |
|
13700 } |
|
13701 |
|
13702 comments(); |
|
13703 return pos({ |
|
13704 type: 'rule', |
|
13705 selectors: sel, |
|
13706 declarations: declarations() |
|
13707 }); |
|
13708 } |
|
13709 |
|
13710 return addParent(stylesheet()); |
|
13711 }); |
|
13712 /** |
|
13713 * Trim `str`. |
|
13714 */ |
|
13715 |
|
13716 function trim(str) { |
|
13717 return str ? str.replace(/^\s+|\s+$/g, '') : ''; |
|
13718 } |
|
13719 /** |
|
13720 * Adds non-enumerable parent node reference to each node. |
|
13721 */ |
|
13722 |
|
13723 |
|
13724 function addParent(obj, parent) { |
|
13725 var isNode = obj && typeof obj.type === 'string'; |
|
13726 var childParent = isNode ? obj : parent; |
|
13727 |
|
13728 for (var k in obj) { |
|
13729 var value = obj[k]; |
|
13730 |
|
13731 if (Array.isArray(value)) { |
|
13732 value.forEach(function (v) { |
|
13733 addParent(v, childParent); |
|
13734 }); |
|
13735 } else if (value && Object(esm_typeof["a" /* default */])(value) === 'object') { |
|
13736 addParent(value, childParent); |
|
13737 } |
|
13738 } |
|
13739 |
|
13740 if (isNode) { |
|
13741 Object.defineProperty(obj, 'parent', { |
|
13742 configurable: true, |
|
13743 writable: true, |
|
13744 enumerable: false, |
|
13745 value: parent || null |
|
13746 }); |
|
13747 } |
|
13748 |
|
13749 return obj; |
|
13750 } |
|
13751 |
|
13752 // EXTERNAL MODULE: ./node_modules/inherits/inherits_browser.js |
|
13753 var inherits_browser = __webpack_require__(109); |
|
13754 var inherits_browser_default = /*#__PURE__*/__webpack_require__.n(inherits_browser); |
|
13755 |
|
13756 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/editor-styles/ast/stringify/compiler.js |
|
13757 // Adapted from https://github.com/reworkcss/css |
|
13758 // because we needed to remove source map support. |
|
13759 |
|
13760 /** |
|
13761 * Expose `Compiler`. |
|
13762 */ |
|
13763 /* harmony default export */ var stringify_compiler = (Compiler); |
|
13764 /** |
|
13765 * Initialize a compiler. |
|
13766 * |
|
13767 * @param {Type} name |
|
13768 * @return {Type} |
|
13769 * @api public |
|
13770 */ |
|
13771 |
|
13772 function Compiler(opts) { |
|
13773 this.options = opts || {}; |
|
13774 } |
|
13775 /** |
|
13776 * Emit `str` |
|
13777 */ |
|
13778 |
|
13779 |
|
13780 Compiler.prototype.emit = function (str) { |
|
13781 return str; |
|
13782 }; |
|
13783 /** |
|
13784 * Visit `node`. |
|
13785 */ |
|
13786 |
|
13787 |
|
13788 Compiler.prototype.visit = function (node) { |
|
13789 return this[node.type](node); |
|
13790 }; |
|
13791 /** |
|
13792 * Map visit over array of `nodes`, optionally using a `delim` |
|
13793 */ |
|
13794 |
|
13795 |
|
13796 Compiler.prototype.mapVisit = function (nodes, delim) { |
|
13797 var buf = ''; |
|
13798 delim = delim || ''; |
|
13799 |
|
13800 for (var i = 0, length = nodes.length; i < length; i++) { |
|
13801 buf += this.visit(nodes[i]); |
|
13802 |
|
13803 if (delim && i < length - 1) { |
|
13804 buf += this.emit(delim); |
|
13805 } |
|
13806 } |
|
13807 |
|
13808 return buf; |
|
13809 }; |
|
13810 |
|
13811 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/editor-styles/ast/stringify/compress.js |
|
13812 // Adapted from https://github.com/reworkcss/css |
|
13813 // because we needed to remove source map support. |
|
13814 |
|
13815 /** |
|
13816 * External dependencies |
|
13817 */ |
|
13818 |
|
13819 /** |
|
13820 * Internal dependencies |
|
13821 */ |
|
13822 |
|
13823 |
|
13824 /** |
|
13825 * Expose compiler. |
|
13826 */ |
|
13827 |
|
13828 /* harmony default export */ var compress = (compress_Compiler); |
|
13829 /** |
|
13830 * Initialize a new `Compiler`. |
|
13831 */ |
|
13832 |
|
13833 function compress_Compiler(options) { |
|
13834 stringify_compiler.call(this, options); |
|
13835 } |
|
13836 /** |
|
13837 * Inherit from `Base.prototype`. |
|
13838 */ |
|
13839 |
|
13840 |
|
13841 inherits_browser_default()(compress_Compiler, stringify_compiler); |
|
13842 /** |
|
13843 * Compile `node`. |
|
13844 */ |
|
13845 |
|
13846 compress_Compiler.prototype.compile = function (node) { |
|
13847 return node.stylesheet.rules.map(this.visit, this).join(''); |
|
13848 }; |
|
13849 /** |
|
13850 * Visit comment node. |
|
13851 */ |
|
13852 |
|
13853 |
|
13854 compress_Compiler.prototype.comment = function (node) { |
|
13855 return this.emit('', node.position); |
|
13856 }; |
|
13857 /** |
|
13858 * Visit import node. |
|
13859 */ |
|
13860 |
|
13861 |
|
13862 compress_Compiler.prototype.import = function (node) { |
|
13863 return this.emit('@import ' + node.import + ';', node.position); |
|
13864 }; |
|
13865 /** |
|
13866 * Visit media node. |
|
13867 */ |
|
13868 |
|
13869 |
|
13870 compress_Compiler.prototype.media = function (node) { |
|
13871 return this.emit('@media ' + node.media, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}'); |
|
13872 }; |
|
13873 /** |
|
13874 * Visit document node. |
|
13875 */ |
|
13876 |
|
13877 |
|
13878 compress_Compiler.prototype.document = function (node) { |
|
13879 var doc = '@' + (node.vendor || '') + 'document ' + node.document; |
|
13880 return this.emit(doc, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}'); |
|
13881 }; |
|
13882 /** |
|
13883 * Visit charset node. |
|
13884 */ |
|
13885 |
|
13886 |
|
13887 compress_Compiler.prototype.charset = function (node) { |
|
13888 return this.emit('@charset ' + node.charset + ';', node.position); |
|
13889 }; |
|
13890 /** |
|
13891 * Visit namespace node. |
|
13892 */ |
|
13893 |
|
13894 |
|
13895 compress_Compiler.prototype.namespace = function (node) { |
|
13896 return this.emit('@namespace ' + node.namespace + ';', node.position); |
|
13897 }; |
|
13898 /** |
|
13899 * Visit supports node. |
|
13900 */ |
|
13901 |
|
13902 |
|
13903 compress_Compiler.prototype.supports = function (node) { |
|
13904 return this.emit('@supports ' + node.supports, node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}'); |
|
13905 }; |
|
13906 /** |
|
13907 * Visit keyframes node. |
|
13908 */ |
|
13909 |
|
13910 |
|
13911 compress_Compiler.prototype.keyframes = function (node) { |
|
13912 return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position) + this.emit('{') + this.mapVisit(node.keyframes) + this.emit('}'); |
|
13913 }; |
|
13914 /** |
|
13915 * Visit keyframe node. |
|
13916 */ |
|
13917 |
|
13918 |
|
13919 compress_Compiler.prototype.keyframe = function (node) { |
|
13920 var decls = node.declarations; |
|
13921 return this.emit(node.values.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}'); |
|
13922 }; |
|
13923 /** |
|
13924 * Visit page node. |
|
13925 */ |
|
13926 |
|
13927 |
|
13928 compress_Compiler.prototype.page = function (node) { |
|
13929 var sel = node.selectors.length ? node.selectors.join(', ') : ''; |
|
13930 return this.emit('@page ' + sel, node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}'); |
|
13931 }; |
|
13932 /** |
|
13933 * Visit font-face node. |
|
13934 */ |
|
13935 |
|
13936 |
|
13937 compress_Compiler.prototype['font-face'] = function (node) { |
|
13938 return this.emit('@font-face', node.position) + this.emit('{') + this.mapVisit(node.declarations) + this.emit('}'); |
|
13939 }; |
|
13940 /** |
|
13941 * Visit host node. |
|
13942 */ |
|
13943 |
|
13944 |
|
13945 compress_Compiler.prototype.host = function (node) { |
|
13946 return this.emit('@host', node.position) + this.emit('{') + this.mapVisit(node.rules) + this.emit('}'); |
|
13947 }; |
|
13948 /** |
|
13949 * Visit custom-media node. |
|
13950 */ |
|
13951 |
|
13952 |
|
13953 compress_Compiler.prototype['custom-media'] = function (node) { |
|
13954 return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position); |
|
13955 }; |
|
13956 /** |
|
13957 * Visit rule node. |
|
13958 */ |
|
13959 |
|
13960 |
|
13961 compress_Compiler.prototype.rule = function (node) { |
|
13962 var decls = node.declarations; |
|
13963 |
|
13964 if (!decls.length) { |
|
13965 return ''; |
|
13966 } |
|
13967 |
|
13968 return this.emit(node.selectors.join(','), node.position) + this.emit('{') + this.mapVisit(decls) + this.emit('}'); |
|
13969 }; |
|
13970 /** |
|
13971 * Visit declaration node. |
|
13972 */ |
|
13973 |
|
13974 |
|
13975 compress_Compiler.prototype.declaration = function (node) { |
|
13976 return this.emit(node.property + ':' + node.value, node.position) + this.emit(';'); |
|
13977 }; |
|
13978 |
|
13979 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/editor-styles/ast/stringify/identity.js |
|
13980 /* eslint-disable @wordpress/no-unused-vars-before-return */ |
|
13981 // Adapted from https://github.com/reworkcss/css |
|
13982 // because we needed to remove source map support. |
|
13983 |
|
13984 /** |
|
13985 * External dependencies |
|
13986 */ |
|
13987 |
|
13988 /** |
|
13989 * Internal dependencies |
|
13990 */ |
|
13991 |
|
13992 |
|
13993 /** |
|
13994 * Expose compiler. |
|
13995 */ |
|
13996 |
|
13997 /* harmony default export */ var identity = (identity_Compiler); |
|
13998 /** |
|
13999 * Initialize a new `Compiler`. |
|
14000 */ |
|
14001 |
|
14002 function identity_Compiler(options) { |
|
14003 options = options || {}; |
|
14004 stringify_compiler.call(this, options); |
|
14005 this.indentation = options.indent; |
|
14006 } |
|
14007 /** |
|
14008 * Inherit from `Base.prototype`. |
|
14009 */ |
|
14010 |
|
14011 |
|
14012 inherits_browser_default()(identity_Compiler, stringify_compiler); |
|
14013 /** |
|
14014 * Compile `node`. |
|
14015 */ |
|
14016 |
|
14017 identity_Compiler.prototype.compile = function (node) { |
|
14018 return this.stylesheet(node); |
|
14019 }; |
|
14020 /** |
|
14021 * Visit stylesheet node. |
|
14022 */ |
|
14023 |
|
14024 |
|
14025 identity_Compiler.prototype.stylesheet = function (node) { |
|
14026 return this.mapVisit(node.stylesheet.rules, '\n\n'); |
|
14027 }; |
|
14028 /** |
|
14029 * Visit comment node. |
|
14030 */ |
|
14031 |
|
14032 |
|
14033 identity_Compiler.prototype.comment = function (node) { |
|
14034 return this.emit(this.indent() + '/*' + node.comment + '*/', node.position); |
|
14035 }; |
|
14036 /** |
|
14037 * Visit import node. |
|
14038 */ |
|
14039 |
|
14040 |
|
14041 identity_Compiler.prototype.import = function (node) { |
|
14042 return this.emit('@import ' + node.import + ';', node.position); |
|
14043 }; |
|
14044 /** |
|
14045 * Visit media node. |
|
14046 */ |
|
14047 |
|
14048 |
|
14049 identity_Compiler.prototype.media = function (node) { |
|
14050 return this.emit('@media ' + node.media, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}'); |
|
14051 }; |
|
14052 /** |
|
14053 * Visit document node. |
|
14054 */ |
|
14055 |
|
14056 |
|
14057 identity_Compiler.prototype.document = function (node) { |
|
14058 var doc = '@' + (node.vendor || '') + 'document ' + node.document; |
|
14059 return this.emit(doc, node.position) + this.emit(' ' + ' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}'); |
|
14060 }; |
|
14061 /** |
|
14062 * Visit charset node. |
|
14063 */ |
|
14064 |
|
14065 |
|
14066 identity_Compiler.prototype.charset = function (node) { |
|
14067 return this.emit('@charset ' + node.charset + ';', node.position); |
|
14068 }; |
|
14069 /** |
|
14070 * Visit namespace node. |
|
14071 */ |
|
14072 |
|
14073 |
|
14074 identity_Compiler.prototype.namespace = function (node) { |
|
14075 return this.emit('@namespace ' + node.namespace + ';', node.position); |
|
14076 }; |
|
14077 /** |
|
14078 * Visit supports node. |
|
14079 */ |
|
14080 |
|
14081 |
|
14082 identity_Compiler.prototype.supports = function (node) { |
|
14083 return this.emit('@supports ' + node.supports, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}'); |
|
14084 }; |
|
14085 /** |
|
14086 * Visit keyframes node. |
|
14087 */ |
|
14088 |
|
14089 |
|
14090 identity_Compiler.prototype.keyframes = function (node) { |
|
14091 return this.emit('@' + (node.vendor || '') + 'keyframes ' + node.name, node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.keyframes, '\n') + this.emit(this.indent(-1) + '}'); |
|
14092 }; |
|
14093 /** |
|
14094 * Visit keyframe node. |
|
14095 */ |
|
14096 |
|
14097 |
|
14098 identity_Compiler.prototype.keyframe = function (node) { |
|
14099 var decls = node.declarations; |
|
14100 return this.emit(this.indent()) + this.emit(node.values.join(', '), node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(decls, '\n') + this.emit(this.indent(-1) + '\n' + this.indent() + '}\n'); |
|
14101 }; |
|
14102 /** |
|
14103 * Visit page node. |
|
14104 */ |
|
14105 |
|
14106 |
|
14107 identity_Compiler.prototype.page = function (node) { |
|
14108 var sel = node.selectors.length ? node.selectors.join(', ') + ' ' : ''; |
|
14109 return this.emit('@page ' + sel, node.position) + this.emit('{\n') + this.emit(this.indent(1)) + this.mapVisit(node.declarations, '\n') + this.emit(this.indent(-1)) + this.emit('\n}'); |
|
14110 }; |
|
14111 /** |
|
14112 * Visit font-face node. |
|
14113 */ |
|
14114 |
|
14115 |
|
14116 identity_Compiler.prototype['font-face'] = function (node) { |
|
14117 return this.emit('@font-face ', node.position) + this.emit('{\n') + this.emit(this.indent(1)) + this.mapVisit(node.declarations, '\n') + this.emit(this.indent(-1)) + this.emit('\n}'); |
|
14118 }; |
|
14119 /** |
|
14120 * Visit host node. |
|
14121 */ |
|
14122 |
|
14123 |
|
14124 identity_Compiler.prototype.host = function (node) { |
|
14125 return this.emit('@host', node.position) + this.emit(' {\n' + this.indent(1)) + this.mapVisit(node.rules, '\n\n') + this.emit(this.indent(-1) + '\n}'); |
|
14126 }; |
|
14127 /** |
|
14128 * Visit custom-media node. |
|
14129 */ |
|
14130 |
|
14131 |
|
14132 identity_Compiler.prototype['custom-media'] = function (node) { |
|
14133 return this.emit('@custom-media ' + node.name + ' ' + node.media + ';', node.position); |
|
14134 }; |
|
14135 /** |
|
14136 * Visit rule node. |
|
14137 */ |
|
14138 |
|
14139 |
|
14140 identity_Compiler.prototype.rule = function (node) { |
|
14141 var indent = this.indent(); |
|
14142 var decls = node.declarations; |
|
14143 |
|
14144 if (!decls.length) { |
|
14145 return ''; |
|
14146 } |
|
14147 |
|
14148 return this.emit(node.selectors.map(function (s) { |
|
14149 return indent + s; |
|
14150 }).join(',\n'), node.position) + this.emit(' {\n') + this.emit(this.indent(1)) + this.mapVisit(decls, '\n') + this.emit(this.indent(-1)) + this.emit('\n' + this.indent() + '}'); |
|
14151 }; |
|
14152 /** |
|
14153 * Visit declaration node. |
|
14154 */ |
|
14155 |
|
14156 |
|
14157 identity_Compiler.prototype.declaration = function (node) { |
|
14158 return this.emit(this.indent()) + this.emit(node.property + ': ' + node.value, node.position) + this.emit(';'); |
|
14159 }; |
|
14160 /** |
|
14161 * Increase, decrease or return current indentation. |
|
14162 */ |
|
14163 |
|
14164 |
|
14165 identity_Compiler.prototype.indent = function (level) { |
|
14166 this.level = this.level || 1; |
|
14167 |
|
14168 if (null !== level) { |
|
14169 this.level += level; |
|
14170 return ''; |
|
14171 } |
|
14172 |
|
14173 return Array(this.level).join(this.indentation || ' '); |
|
14174 }; |
|
14175 |
|
14176 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/editor-styles/ast/stringify/index.js |
|
14177 // Adapted from https://github.com/reworkcss/css |
|
14178 // because we needed to remove source map support. |
|
14179 |
|
14180 /** |
|
14181 * Internal dependencies |
|
14182 */ |
|
14183 |
|
14184 |
|
14185 /** |
|
14186 * Stringfy the given AST `node`. |
|
14187 * |
|
14188 * Options: |
|
14189 * |
|
14190 * - `compress` space-optimized output |
|
14191 * - `sourcemap` return an object with `.code` and `.map` |
|
14192 * |
|
14193 * @param {Object} node |
|
14194 * @param {Object} [options] |
|
14195 * @return {String} |
|
14196 * @api public |
|
14197 */ |
|
14198 |
|
14199 /* harmony default export */ var stringify = (function (node, options) { |
|
14200 options = options || {}; |
|
14201 var compiler = options.compress ? new compress(options) : new identity(options); |
|
14202 var code = compiler.compile(node); |
|
14203 return code; |
|
14204 }); |
|
14205 |
|
14206 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/editor-styles/ast/index.js |
|
14207 // Adapted from https://github.com/reworkcss/css |
|
14208 // because we needed to remove source map support. |
|
14209 |
|
14210 |
|
14211 |
|
14212 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/editor-styles/traverse.js |
|
14213 /** |
|
14214 * External dependencies |
|
14215 */ |
|
14216 |
|
14217 /** |
|
14218 * Internal dependencies |
|
14219 */ |
|
14220 |
|
14221 |
|
14222 |
|
14223 function traverseCSS(css, callback) { |
|
14224 try { |
|
14225 var parsed = parse(css); |
|
14226 var updated = traverse_default.a.map(parsed, function (node) { |
|
14227 if (!node) { |
|
14228 return node; |
|
14229 } |
|
14230 |
|
14231 var updatedNode = callback(node); |
|
14232 return this.update(updatedNode); |
|
14233 }); |
|
14234 return stringify(updated); |
|
14235 } catch (err) { |
|
14236 // eslint-disable-next-line no-console |
|
14237 console.warn('Error while traversing the CSS: ' + err); |
|
14238 return null; |
|
14239 } |
|
14240 } |
|
14241 |
|
14242 /* harmony default export */ var editor_styles_traverse = (traverseCSS); |
|
14243 |
|
14244 // EXTERNAL MODULE: ./node_modules/url/url.js |
|
14245 var url = __webpack_require__(84); |
|
14246 |
|
14247 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/editor-styles/transforms/url-rewrite.js |
|
14248 |
|
14249 |
|
14250 /** |
|
14251 * External dependencies |
|
14252 */ |
|
14253 |
|
14254 /** |
|
14255 * Return `true` if the given path is http/https. |
|
14256 * |
|
14257 * @param {string} filePath path |
|
14258 * |
|
14259 * @return {boolean} is remote path. |
|
14260 */ |
|
14261 |
|
14262 function isRemotePath(filePath) { |
|
14263 return /^(?:https?:)?\/\//.test(filePath); |
|
14264 } |
|
14265 /** |
|
14266 * Return `true` if the given filePath is an absolute url. |
|
14267 * |
|
14268 * @param {string} filePath path |
|
14269 * |
|
14270 * @return {boolean} is absolute path. |
|
14271 */ |
|
14272 |
|
14273 |
|
14274 function isAbsolutePath(filePath) { |
|
14275 return /^\/(?!\/)/.test(filePath); |
|
14276 } |
|
14277 /** |
|
14278 * Whether or not the url should be inluded. |
|
14279 * |
|
14280 * @param {Object} meta url meta info |
|
14281 * |
|
14282 * @return {boolean} is valid. |
|
14283 */ |
|
14284 |
|
14285 |
|
14286 function isValidURL(meta) { |
|
14287 // ignore hashes or data uris |
|
14288 if (meta.value.indexOf('data:') === 0 || meta.value.indexOf('#') === 0) { |
|
14289 return false; |
|
14290 } |
|
14291 |
|
14292 if (isAbsolutePath(meta.value)) { |
|
14293 return false; |
|
14294 } // do not handle the http/https urls if `includeRemote` is false |
|
14295 |
|
14296 |
|
14297 if (isRemotePath(meta.value)) { |
|
14298 return false; |
|
14299 } |
|
14300 |
|
14301 return true; |
|
14302 } |
|
14303 /** |
|
14304 * Get the absolute path of the url, relative to the basePath |
|
14305 * |
|
14306 * @param {string} str the url |
|
14307 * @param {string} baseURL base URL |
|
14308 * @param {string} absolutePath the absolute path |
|
14309 * |
|
14310 * @return {string} the full path to the file |
|
14311 */ |
|
14312 |
|
14313 |
|
14314 function getResourcePath(str, baseURL) { |
|
14315 var pathname = Object(url["parse"])(str).pathname; |
|
14316 var filePath = Object(url["resolve"])(baseURL, pathname); |
|
14317 return filePath; |
|
14318 } |
|
14319 /** |
|
14320 * Process the single `url()` pattern |
|
14321 * |
|
14322 * @param {string} baseURL the base URL for relative URLs |
|
14323 * @return {Promise} the Promise |
|
14324 */ |
|
14325 |
|
14326 |
|
14327 function processURL(baseURL) { |
|
14328 return function (meta) { |
|
14329 var URL = getResourcePath(meta.value, baseURL); |
|
14330 return Object(objectSpread["a" /* default */])({}, meta, { |
|
14331 newUrl: 'url(' + meta.before + meta.quote + URL + meta.quote + meta.after + ')' |
|
14332 }); |
|
14333 }; |
|
14334 } |
|
14335 /** |
|
14336 * Get all `url()`s, and return the meta info |
|
14337 * |
|
14338 * @param {string} value decl.value |
|
14339 * |
|
14340 * @return {Array} the urls |
|
14341 */ |
|
14342 |
|
14343 |
|
14344 function getURLs(value) { |
|
14345 var reg = /url\((\s*)(['"]?)(.+?)\2(\s*)\)/g; |
|
14346 var match; |
|
14347 var URLs = []; |
|
14348 |
|
14349 while ((match = reg.exec(value)) !== null) { |
|
14350 var meta = { |
|
14351 source: match[0], |
|
14352 before: match[1], |
|
14353 quote: match[2], |
|
14354 value: match[3], |
|
14355 after: match[4] |
|
14356 }; |
|
14357 |
|
14358 if (isValidURL(meta)) { |
|
14359 URLs.push(meta); |
|
14360 } |
|
14361 } |
|
14362 |
|
14363 return URLs; |
|
14364 } |
|
14365 /** |
|
14366 * Replace the raw value's `url()` segment to the new value |
|
14367 * |
|
14368 * @param {string} raw the raw value |
|
14369 * @param {Array} URLs the URLs to replace |
|
14370 * |
|
14371 * @return {string} the new value |
|
14372 */ |
|
14373 |
|
14374 |
|
14375 function replaceURLs(raw, URLs) { |
|
14376 URLs.forEach(function (item) { |
|
14377 raw = raw.replace(item.source, item.newUrl); |
|
14378 }); |
|
14379 return raw; |
|
14380 } |
|
14381 |
|
14382 var url_rewrite_rewrite = function rewrite(rootURL) { |
|
14383 return function (node) { |
|
14384 if (node.type === 'declaration') { |
|
14385 var updatedURLs = getURLs(node.value).map(processURL(rootURL)); |
|
14386 return Object(objectSpread["a" /* default */])({}, node, { |
|
14387 value: replaceURLs(node.value, updatedURLs) |
|
14388 }); |
|
14389 } |
|
14390 |
|
14391 return node; |
|
14392 }; |
|
14393 }; |
|
14394 |
|
14395 /* harmony default export */ var url_rewrite = (url_rewrite_rewrite); |
|
14396 |
|
14397 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/editor-styles/transforms/wrap.js |
|
14398 |
|
14399 |
|
14400 /** |
|
14401 * External dependencies |
|
14402 */ |
|
14403 |
|
14404 /** |
|
14405 * @const string IS_ROOT_TAG Regex to check if the selector is a root tag selector. |
|
14406 */ |
|
14407 |
|
14408 var IS_ROOT_TAG = /^(body|html|:root).*$/; |
|
14409 |
|
14410 var wrap_wrap = function wrap(namespace) { |
|
14411 var ignore = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : []; |
|
14412 return function (node) { |
|
14413 var updateSelector = function updateSelector(selector) { |
|
14414 if (Object(external_lodash_["includes"])(ignore, selector.trim())) { |
|
14415 return selector; |
|
14416 } // Anything other than a root tag is always prefixed. |
|
14417 |
|
14418 |
|
14419 { |
|
14420 if (!selector.match(IS_ROOT_TAG)) { |
|
14421 return namespace + ' ' + selector; |
|
14422 } |
|
14423 } // HTML and Body elements cannot be contained within our container so lets extract their styles. |
|
14424 |
|
14425 return selector.replace(/^(body|html|:root)/, namespace); |
|
14426 }; |
|
14427 |
|
14428 if (node.type === 'rule') { |
|
14429 return Object(objectSpread["a" /* default */])({}, node, { |
|
14430 selectors: node.selectors.map(updateSelector) |
|
14431 }); |
|
14432 } |
|
14433 |
|
14434 return node; |
|
14435 }; |
|
14436 }; |
|
14437 |
|
14438 /* harmony default export */ var transforms_wrap = (wrap_wrap); |
|
14439 |
|
14440 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/editor-styles/index.js |
|
14441 /** |
|
14442 * External dependencies |
|
14443 */ |
|
14444 |
|
14445 /** |
|
14446 * WordPress dependencies |
|
14447 */ |
|
14448 |
|
14449 |
|
14450 /** |
|
14451 * Internal dependencies |
|
14452 */ |
|
14453 |
|
14454 |
|
14455 |
|
14456 |
|
14457 /** |
|
14458 * Convert css rules. |
|
14459 * |
|
14460 * @param {Array} styles CSS rules. |
|
14461 * @param {string} wrapperClassName Wrapper Class Name. |
|
14462 * @return {Array} converted rules. |
|
14463 */ |
|
14464 |
|
14465 var editor_styles_transformStyles = function transformStyles(styles) { |
|
14466 var wrapperClassName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; |
|
14467 return Object(external_lodash_["map"])(styles, function (_ref) { |
|
14468 var css = _ref.css, |
|
14469 baseURL = _ref.baseURL; |
|
14470 var transforms = []; |
|
14471 |
|
14472 if (wrapperClassName) { |
|
14473 transforms.push(transforms_wrap(wrapperClassName)); |
|
14474 } |
|
14475 |
|
14476 if (baseURL) { |
|
14477 transforms.push(url_rewrite(baseURL)); |
|
14478 } |
|
14479 |
|
14480 if (transforms.length) { |
|
14481 return editor_styles_traverse(css, Object(external_this_wp_compose_["compose"])(transforms)); |
|
14482 } |
|
14483 |
|
14484 return css; |
|
14485 }); |
|
14486 }; |
|
14487 |
|
14488 /* harmony default export */ var editor_styles = (editor_styles_transformStyles); |
|
14489 |
|
14490 // EXTERNAL MODULE: external {"this":["wp","blob"]} |
|
14491 var external_this_wp_blob_ = __webpack_require__(35); |
|
14492 |
|
14493 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/media-upload/media-upload.js |
|
14494 |
|
14495 |
|
14496 |
|
14497 |
|
14498 |
|
14499 |
|
14500 |
|
14501 /** |
|
14502 * External dependencies |
|
14503 */ |
|
14504 |
|
14505 /** |
|
14506 * WordPress dependencies |
|
14507 */ |
|
14508 |
|
14509 |
|
14510 |
|
14511 |
|
14512 /** |
|
14513 * Browsers may use unexpected mime types, and they differ from browser to browser. |
|
14514 * This function computes a flexible array of mime types from the mime type structured provided by the server. |
|
14515 * Converts { jpg|jpeg|jpe: "image/jpeg" } into [ "image/jpeg", "image/jpg", "image/jpeg", "image/jpe" ] |
|
14516 * The computation of this array instead of directly using the object, |
|
14517 * solves the problem in chrome where mp3 files have audio/mp3 as mime type instead of audio/mpeg. |
|
14518 * https://bugs.chromium.org/p/chromium/issues/detail?id=227004 |
|
14519 * |
|
14520 * @param {?Object} wpMimeTypesObject Mime type object received from the server. |
|
14521 * Extensions are keys separated by '|' and values are mime types associated with an extension. |
|
14522 * |
|
14523 * @return {?Array} An array of mime types or the parameter passed if it was "falsy". |
|
14524 */ |
|
14525 |
|
14526 function getMimeTypesArray(wpMimeTypesObject) { |
|
14527 if (!wpMimeTypesObject) { |
|
14528 return wpMimeTypesObject; |
|
14529 } |
|
14530 |
|
14531 return Object(external_lodash_["flatMap"])(wpMimeTypesObject, function (mime, extensionsString) { |
|
14532 var _mime$split = mime.split('/'), |
|
14533 _mime$split2 = Object(slicedToArray["a" /* default */])(_mime$split, 1), |
|
14534 type = _mime$split2[0]; |
|
14535 |
|
14536 var extensions = extensionsString.split('|'); |
|
14537 return [mime].concat(Object(toConsumableArray["a" /* default */])(Object(external_lodash_["map"])(extensions, function (extension) { |
|
14538 return "".concat(type, "/").concat(extension); |
|
14539 }))); |
|
14540 }); |
|
14541 } |
|
14542 /** |
|
14543 * Media Upload is used by audio, image, gallery, video, and file blocks to |
|
14544 * handle uploading a media file when a file upload button is activated. |
|
14545 * |
|
14546 * TODO: future enhancement to add an upload indicator. |
|
14547 * |
|
14548 * @param {Object} $0 Parameters object passed to the function. |
|
14549 * @param {?Array} $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed. |
|
14550 * @param {?Object} $0.additionalData Additional data to include in the request. |
|
14551 * @param {Array} $0.filesList List of files. |
|
14552 * @param {?number} $0.maxUploadFileSize Maximum upload size in bytes allowed for the site. |
|
14553 * @param {Function} $0.onError Function called when an error happens. |
|
14554 * @param {Function} $0.onFileChange Function called each time a file or a temporary representation of the file is available. |
|
14555 * @param {?Object} $0.wpAllowedMimeTypes List of allowed mime types and file extensions. |
|
14556 */ |
|
14557 |
|
14558 function mediaUpload(_x) { |
|
14559 return _mediaUpload.apply(this, arguments); |
|
14560 } |
|
14561 /** |
|
14562 * @param {File} file Media File to Save. |
|
14563 * @param {?Object} additionalData Additional data to include in the request. |
|
14564 * |
|
14565 * @return {Promise} Media Object Promise. |
|
14566 */ |
|
14567 |
|
14568 function _mediaUpload() { |
|
14569 _mediaUpload = Object(asyncToGenerator["a" /* default */])( |
|
14570 /*#__PURE__*/ |
|
14571 regenerator_default.a.mark(function _callee(_ref) { |
|
14572 var allowedTypes, _ref$additionalData, additionalData, filesList, maxUploadFileSize, _ref$onError, onError, onFileChange, _ref$wpAllowedMimeTyp, wpAllowedMimeTypes, files, filesSet, setAndUpdateFiles, isAllowedType, allowedMimeTypesForUser, isAllowedMimeTypeForUser, triggerError, validFiles, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _mediaFile, idx, mediaFile, savedMedia, mediaObject, message; |
|
14573 |
|
14574 return regenerator_default.a.wrap(function _callee$(_context) { |
|
14575 while (1) { |
|
14576 switch (_context.prev = _context.next) { |
|
14577 case 0: |
|
14578 allowedTypes = _ref.allowedTypes, _ref$additionalData = _ref.additionalData, additionalData = _ref$additionalData === void 0 ? {} : _ref$additionalData, filesList = _ref.filesList, maxUploadFileSize = _ref.maxUploadFileSize, _ref$onError = _ref.onError, onError = _ref$onError === void 0 ? external_lodash_["noop"] : _ref$onError, onFileChange = _ref.onFileChange, _ref$wpAllowedMimeTyp = _ref.wpAllowedMimeTypes, wpAllowedMimeTypes = _ref$wpAllowedMimeTyp === void 0 ? null : _ref$wpAllowedMimeTyp; |
|
14579 // Cast filesList to array |
|
14580 files = Object(toConsumableArray["a" /* default */])(filesList); |
|
14581 filesSet = []; |
|
14582 |
|
14583 setAndUpdateFiles = function setAndUpdateFiles(idx, value) { |
|
14584 Object(external_this_wp_blob_["revokeBlobURL"])(Object(external_lodash_["get"])(filesSet, [idx, 'url'])); |
|
14585 filesSet[idx] = value; |
|
14586 onFileChange(Object(external_lodash_["compact"])(filesSet)); |
|
14587 }; // Allowed type specified by consumer |
|
14588 |
|
14589 |
|
14590 isAllowedType = function isAllowedType(fileType) { |
|
14591 if (!allowedTypes) { |
|
14592 return true; |
|
14593 } |
|
14594 |
|
14595 return Object(external_lodash_["some"])(allowedTypes, function (allowedType) { |
|
14596 // If a complete mimetype is specified verify if it matches exactly the mime type of the file. |
|
14597 if (Object(external_lodash_["includes"])(allowedType, '/')) { |
|
14598 return allowedType === fileType; |
|
14599 } // Otherwise a general mime type is used and we should verify if the file mimetype starts with it. |
|
14600 |
|
14601 |
|
14602 return Object(external_lodash_["startsWith"])(fileType, "".concat(allowedType, "/")); |
|
14603 }); |
|
14604 }; // Allowed types for the current WP_User |
|
14605 |
|
14606 |
|
14607 allowedMimeTypesForUser = getMimeTypesArray(wpAllowedMimeTypes); |
|
14608 |
|
14609 isAllowedMimeTypeForUser = function isAllowedMimeTypeForUser(fileType) { |
|
14610 return Object(external_lodash_["includes"])(allowedMimeTypesForUser, fileType); |
|
14611 }; // Build the error message including the filename |
|
14612 |
|
14613 |
|
14614 triggerError = function triggerError(error) { |
|
14615 error.message = [Object(external_this_wp_element_["createElement"])("strong", { |
|
14616 key: "filename" |
|
14617 }, error.file.name), ': ', error.message]; |
|
14618 onError(error); |
|
14619 }; |
|
14620 |
|
14621 validFiles = []; |
|
14622 _iteratorNormalCompletion = true; |
|
14623 _didIteratorError = false; |
|
14624 _iteratorError = undefined; |
|
14625 _context.prev = 12; |
|
14626 _iterator = files[Symbol.iterator](); |
|
14627 |
|
14628 case 14: |
|
14629 if (_iteratorNormalCompletion = (_step = _iterator.next()).done) { |
|
14630 _context.next = 34; |
|
14631 break; |
|
14632 } |
|
14633 |
|
14634 _mediaFile = _step.value; |
|
14635 |
|
14636 if (!(allowedMimeTypesForUser && !isAllowedMimeTypeForUser(_mediaFile.type))) { |
|
14637 _context.next = 19; |
|
14638 break; |
|
14639 } |
|
14640 |
|
14641 triggerError({ |
|
14642 code: 'MIME_TYPE_NOT_ALLOWED_FOR_USER', |
|
14643 message: Object(external_this_wp_i18n_["__"])('Sorry, this file type is not permitted for security reasons.'), |
|
14644 file: _mediaFile |
|
14645 }); |
|
14646 return _context.abrupt("continue", 31); |
|
14647 |
|
14648 case 19: |
|
14649 if (isAllowedType(_mediaFile.type)) { |
|
14650 _context.next = 22; |
|
14651 break; |
|
14652 } |
|
14653 |
|
14654 triggerError({ |
|
14655 code: 'MIME_TYPE_NOT_SUPPORTED', |
|
14656 message: Object(external_this_wp_i18n_["__"])('Sorry, this file type is not supported here.'), |
|
14657 file: _mediaFile |
|
14658 }); |
|
14659 return _context.abrupt("continue", 31); |
|
14660 |
|
14661 case 22: |
|
14662 if (!(maxUploadFileSize && _mediaFile.size > maxUploadFileSize)) { |
|
14663 _context.next = 25; |
|
14664 break; |
|
14665 } |
|
14666 |
|
14667 triggerError({ |
|
14668 code: 'SIZE_ABOVE_LIMIT', |
|
14669 message: Object(external_this_wp_i18n_["__"])('This file exceeds the maximum upload size for this site.'), |
|
14670 file: _mediaFile |
|
14671 }); |
|
14672 return _context.abrupt("continue", 31); |
|
14673 |
|
14674 case 25: |
|
14675 if (!(_mediaFile.size <= 0)) { |
|
14676 _context.next = 28; |
|
14677 break; |
|
14678 } |
|
14679 |
|
14680 triggerError({ |
|
14681 code: 'EMPTY_FILE', |
|
14682 message: Object(external_this_wp_i18n_["__"])('This file is empty.'), |
|
14683 file: _mediaFile |
|
14684 }); |
|
14685 return _context.abrupt("continue", 31); |
|
14686 |
|
14687 case 28: |
|
14688 validFiles.push(_mediaFile); // Set temporary URL to create placeholder media file, this is replaced |
|
14689 // with final file from media gallery when upload is `done` below |
|
14690 |
|
14691 filesSet.push({ |
|
14692 url: Object(external_this_wp_blob_["createBlobURL"])(_mediaFile) |
|
14693 }); |
|
14694 onFileChange(filesSet); |
|
14695 |
|
14696 case 31: |
|
14697 _iteratorNormalCompletion = true; |
|
14698 _context.next = 14; |
|
14699 break; |
|
14700 |
|
14701 case 34: |
|
14702 _context.next = 40; |
|
14703 break; |
|
14704 |
|
14705 case 36: |
|
14706 _context.prev = 36; |
|
14707 _context.t0 = _context["catch"](12); |
|
14708 _didIteratorError = true; |
|
14709 _iteratorError = _context.t0; |
|
14710 |
|
14711 case 40: |
|
14712 _context.prev = 40; |
|
14713 _context.prev = 41; |
|
14714 |
|
14715 if (!_iteratorNormalCompletion && _iterator.return != null) { |
|
14716 _iterator.return(); |
|
14717 } |
|
14718 |
|
14719 case 43: |
|
14720 _context.prev = 43; |
|
14721 |
|
14722 if (!_didIteratorError) { |
|
14723 _context.next = 46; |
|
14724 break; |
|
14725 } |
|
14726 |
|
14727 throw _iteratorError; |
|
14728 |
|
14729 case 46: |
|
14730 return _context.finish(43); |
|
14731 |
|
14732 case 47: |
|
14733 return _context.finish(40); |
|
14734 |
|
14735 case 48: |
|
14736 idx = 0; |
|
14737 |
|
14738 case 49: |
|
14739 if (!(idx < validFiles.length)) { |
|
14740 _context.next = 68; |
|
14741 break; |
|
14742 } |
|
14743 |
|
14744 mediaFile = validFiles[idx]; |
|
14745 _context.prev = 51; |
|
14746 _context.next = 54; |
|
14747 return createMediaFromFile(mediaFile, additionalData); |
|
14748 |
|
14749 case 54: |
|
14750 savedMedia = _context.sent; |
|
14751 mediaObject = Object(objectSpread["a" /* default */])({}, Object(external_lodash_["omit"])(savedMedia, ['alt_text', 'source_url']), { |
|
14752 alt: savedMedia.alt_text, |
|
14753 caption: Object(external_lodash_["get"])(savedMedia, ['caption', 'raw'], ''), |
|
14754 title: savedMedia.title.raw, |
|
14755 url: savedMedia.source_url |
|
14756 }); |
|
14757 setAndUpdateFiles(idx, mediaObject); |
|
14758 _context.next = 65; |
|
14759 break; |
|
14760 |
|
14761 case 59: |
|
14762 _context.prev = 59; |
|
14763 _context.t1 = _context["catch"](51); |
|
14764 // Reset to empty on failure. |
|
14765 setAndUpdateFiles(idx, null); |
|
14766 message = void 0; |
|
14767 |
|
14768 if (Object(external_lodash_["has"])(_context.t1, ['message'])) { |
|
14769 message = Object(external_lodash_["get"])(_context.t1, ['message']); |
|
14770 } else { |
|
14771 message = Object(external_this_wp_i18n_["sprintf"])( // translators: %s: file name |
|
14772 Object(external_this_wp_i18n_["__"])('Error while uploading file %s to the media library.'), mediaFile.name); |
|
14773 } |
|
14774 |
|
14775 onError({ |
|
14776 code: 'GENERAL', |
|
14777 message: message, |
|
14778 file: mediaFile |
|
14779 }); |
|
14780 |
|
14781 case 65: |
|
14782 ++idx; |
|
14783 _context.next = 49; |
|
14784 break; |
|
14785 |
|
14786 case 68: |
|
14787 case "end": |
|
14788 return _context.stop(); |
|
14789 } |
|
14790 } |
|
14791 }, _callee, this, [[12, 36, 40, 48], [41,, 43, 47], [51, 59]]); |
|
14792 })); |
|
14793 return _mediaUpload.apply(this, arguments); |
|
14794 } |
|
14795 |
|
14796 function createMediaFromFile(file, additionalData) { |
|
14797 // Create upload payload |
|
14798 var data = new window.FormData(); |
|
14799 data.append('file', file, file.name || file.type.replace('/', '.')); |
|
14800 Object(external_lodash_["forEach"])(additionalData, function (value, key) { |
|
14801 return data.append(key, value); |
|
14802 }); |
|
14803 return external_this_wp_apiFetch_default()({ |
|
14804 path: '/wp/v2/media', |
|
14805 body: data, |
|
14806 method: 'POST' |
|
14807 }); |
|
14808 } |
|
14809 |
|
14810 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/media-upload/index.js |
|
14811 |
|
14812 |
|
14813 /** |
|
14814 * External dependencies |
|
14815 */ |
|
14816 |
|
14817 /** |
|
14818 * WordPress dependencies |
|
14819 */ |
|
14820 |
|
14821 |
|
14822 /** |
|
14823 * Internal dependencies |
|
14824 */ |
|
14825 |
|
14826 |
|
14827 /** |
|
14828 * Upload a media file when the file upload button is activated. |
|
14829 * Wrapper around mediaUpload() that injects the current post ID. |
|
14830 * |
|
14831 * @param {Object} $0 Parameters object passed to the function. |
|
14832 * @param {?Object} $0.additionalData Additional data to include in the request. |
|
14833 * @param {string} $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed. |
|
14834 * @param {Array} $0.filesList List of files. |
|
14835 * @param {?number} $0.maxUploadFileSize Maximum upload size in bytes allowed for the site. |
|
14836 * @param {Function} $0.onError Function called when an error happens. |
|
14837 * @param {Function} $0.onFileChange Function called each time a file or a temporary representation of the file is available. |
|
14838 */ |
|
14839 |
|
14840 /* harmony default export */ var media_upload = (function (_ref) { |
|
14841 var _ref$additionalData = _ref.additionalData, |
|
14842 additionalData = _ref$additionalData === void 0 ? {} : _ref$additionalData, |
|
14843 allowedTypes = _ref.allowedTypes, |
|
14844 filesList = _ref.filesList, |
|
14845 maxUploadFileSize = _ref.maxUploadFileSize, |
|
14846 _ref$onError = _ref.onError, |
|
14847 _onError = _ref$onError === void 0 ? external_lodash_["noop"] : _ref$onError, |
|
14848 onFileChange = _ref.onFileChange; |
|
14849 |
|
14850 var _select = Object(external_this_wp_data_["select"])('core/editor'), |
|
14851 getCurrentPostId = _select.getCurrentPostId, |
|
14852 getEditorSettings = _select.getEditorSettings; |
|
14853 |
|
14854 var wpAllowedMimeTypes = getEditorSettings().allowedMimeTypes; |
|
14855 maxUploadFileSize = maxUploadFileSize || getEditorSettings().maxUploadFileSize; |
|
14856 mediaUpload({ |
|
14857 allowedTypes: allowedTypes, |
|
14858 filesList: filesList, |
|
14859 onFileChange: onFileChange, |
|
14860 additionalData: Object(objectSpread["a" /* default */])({ |
|
14861 post: getCurrentPostId() |
|
14862 }, additionalData), |
|
14863 maxUploadFileSize: maxUploadFileSize, |
|
14864 onError: function onError(_ref2) { |
|
14865 var message = _ref2.message; |
|
14866 return _onError(message); |
|
14867 }, |
|
14868 wpAllowedMimeTypes: wpAllowedMimeTypes |
|
14869 }); |
|
14870 }); |
|
14871 |
|
14872 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/utils/index.js |
|
14873 /** |
|
14874 * Internal dependencies |
|
14875 */ |
|
14876 |
|
14877 |
|
14878 |
|
14879 |
|
14880 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/provider/index.js |
|
14881 |
|
14882 |
|
14883 |
|
14884 |
|
14885 |
|
14886 |
|
14887 |
|
14888 |
|
14889 /** |
|
14890 * External dependencies |
|
14891 */ |
|
14892 |
|
14893 |
|
14894 /** |
|
14895 * WordPress dependencies |
|
14896 */ |
|
14897 |
|
14898 |
|
14899 |
|
14900 |
|
14901 |
|
14902 |
|
14903 /** |
|
14904 * Internal dependencies |
|
14905 */ |
|
14906 |
|
14907 |
|
14908 |
|
14909 |
|
14910 var provider_EditorProvider = |
|
14911 /*#__PURE__*/ |
|
14912 function (_Component) { |
|
14913 Object(inherits["a" /* default */])(EditorProvider, _Component); |
|
14914 |
|
14915 function EditorProvider(props) { |
|
14916 var _this; |
|
14917 |
|
14918 Object(classCallCheck["a" /* default */])(this, EditorProvider); |
|
14919 |
|
14920 _this = Object(possibleConstructorReturn["a" /* default */])(this, Object(getPrototypeOf["a" /* default */])(EditorProvider).apply(this, arguments)); |
|
14921 _this.getBlockEditorSettings = memize_default()(_this.getBlockEditorSettings, { |
|
14922 maxSize: 1 |
|
14923 }); // Assume that we don't need to initialize in the case of an error recovery. |
|
14924 |
|
14925 if (props.recovery) { |
|
14926 return Object(possibleConstructorReturn["a" /* default */])(_this); |
|
14927 } |
|
14928 |
|
14929 props.updatePostLock(props.settings.postLock); |
|
14930 props.setupEditor(props.post, props.initialEdits, props.settings.template); |
|
14931 |
|
14932 if (props.settings.autosave) { |
|
14933 props.createWarningNotice(Object(external_this_wp_i18n_["__"])('There is an autosave of this post that is more recent than the version below.'), { |
|
14934 id: 'autosave-exists', |
|
14935 actions: [{ |
|
14936 label: Object(external_this_wp_i18n_["__"])('View the autosave'), |
|
14937 url: props.settings.autosave.editLink |
|
14938 }] |
|
14939 }); |
|
14940 } |
|
14941 |
|
14942 return _this; |
|
14943 } |
|
14944 |
|
14945 Object(createClass["a" /* default */])(EditorProvider, [{ |
|
14946 key: "getBlockEditorSettings", |
|
14947 value: function getBlockEditorSettings(settings, meta, onMetaChange, reusableBlocks) { |
|
14948 return Object(objectSpread["a" /* default */])({}, Object(external_lodash_["pick"])(settings, ['alignWide', 'allowedBlockTypes', 'availableLegacyWidgets', 'bodyPlaceholder', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'focusMode', 'fontSizes', 'hasFixedToolbar', 'hasPermissionsToManageWidgets', 'imageSizes', 'isRTL', 'maxWidth', 'styles', 'template', 'templateLock', 'titlePlaceholder']), { |
|
14949 __experimentalMetaSource: { |
|
14950 value: meta, |
|
14951 onChange: onMetaChange |
|
14952 }, |
|
14953 __experimentalReusableBlocks: reusableBlocks, |
|
14954 __experimentalMediaUpload: media_upload |
|
14955 }); |
|
14956 } |
|
14957 }, { |
|
14958 key: "componentDidMount", |
|
14959 value: function componentDidMount() { |
|
14960 this.props.updateEditorSettings(this.props.settings); |
|
14961 |
|
14962 if (!this.props.settings.styles) { |
|
14963 return; |
|
14964 } |
|
14965 |
|
14966 var updatedStyles = editor_styles(this.props.settings.styles, '.editor-styles-wrapper'); |
|
14967 Object(external_lodash_["map"])(updatedStyles, function (updatedCSS) { |
|
14968 if (updatedCSS) { |
|
14969 var node = document.createElement('style'); |
|
14970 node.innerHTML = updatedCSS; |
|
14971 document.body.appendChild(node); |
|
14972 } |
|
14973 }); |
|
14974 } |
|
14975 }, { |
|
14976 key: "componentDidUpdate", |
|
14977 value: function componentDidUpdate(prevProps) { |
|
14978 if (this.props.settings !== prevProps.settings) { |
|
14979 this.props.updateEditorSettings(this.props.settings); |
|
14980 } |
|
14981 } |
|
14982 }, { |
|
14983 key: "render", |
|
14984 value: function render() { |
|
14985 var _this$props = this.props, |
|
14986 children = _this$props.children, |
|
14987 blocks = _this$props.blocks, |
|
14988 resetEditorBlocks = _this$props.resetEditorBlocks, |
|
14989 isReady = _this$props.isReady, |
|
14990 settings = _this$props.settings, |
|
14991 meta = _this$props.meta, |
|
14992 onMetaChange = _this$props.onMetaChange, |
|
14993 reusableBlocks = _this$props.reusableBlocks, |
|
14994 resetEditorBlocksWithoutUndoLevel = _this$props.resetEditorBlocksWithoutUndoLevel; |
|
14995 |
|
14996 if (!isReady) { |
|
14997 return null; |
|
14998 } |
|
14999 |
|
15000 var editorSettings = this.getBlockEditorSettings(settings, meta, onMetaChange, reusableBlocks); |
|
15001 return Object(external_this_wp_element_["createElement"])(external_this_wp_blockEditor_["BlockEditorProvider"], { |
|
15002 value: blocks, |
|
15003 onInput: resetEditorBlocksWithoutUndoLevel, |
|
15004 onChange: resetEditorBlocks, |
|
15005 settings: editorSettings |
|
15006 }, children); |
|
15007 } |
|
15008 }]); |
|
15009 |
|
15010 return EditorProvider; |
|
15011 }(external_this_wp_element_["Component"]); |
|
15012 |
|
15013 /* harmony default export */ var provider = (Object(external_this_wp_compose_["compose"])([Object(external_this_wp_data_["withSelect"])(function (select) { |
|
15014 var _select = select('core/editor'), |
|
15015 isEditorReady = _select.__unstableIsEditorReady, |
|
15016 getEditorBlocks = _select.getEditorBlocks, |
|
15017 getEditedPostAttribute = _select.getEditedPostAttribute, |
|
15018 __experimentalGetReusableBlocks = _select.__experimentalGetReusableBlocks; |
|
15019 |
|
15020 return { |
|
15021 isReady: isEditorReady(), |
|
15022 blocks: getEditorBlocks(), |
|
15023 meta: getEditedPostAttribute('meta'), |
|
15024 reusableBlocks: __experimentalGetReusableBlocks() |
|
15025 }; |
|
15026 }), Object(external_this_wp_data_["withDispatch"])(function (dispatch) { |
|
15027 var _dispatch = dispatch('core/editor'), |
|
15028 setupEditor = _dispatch.setupEditor, |
|
15029 updatePostLock = _dispatch.updatePostLock, |
|
15030 resetEditorBlocks = _dispatch.resetEditorBlocks, |
|
15031 editPost = _dispatch.editPost, |
|
15032 updateEditorSettings = _dispatch.updateEditorSettings; |
|
15033 |
|
15034 var _dispatch2 = dispatch('core/notices'), |
|
15035 createWarningNotice = _dispatch2.createWarningNotice; |
|
15036 |
|
15037 return { |
|
15038 setupEditor: setupEditor, |
|
15039 updatePostLock: updatePostLock, |
|
15040 createWarningNotice: createWarningNotice, |
|
15041 resetEditorBlocks: resetEditorBlocks, |
|
15042 updateEditorSettings: updateEditorSettings, |
|
15043 resetEditorBlocksWithoutUndoLevel: function resetEditorBlocksWithoutUndoLevel(blocks) { |
|
15044 resetEditorBlocks(blocks, { |
|
15045 __unstableShouldCreateUndoLevel: false |
|
15046 }); |
|
15047 }, |
|
15048 onMetaChange: function onMetaChange(meta) { |
|
15049 editPost({ |
|
15050 meta: meta |
|
15051 }); |
|
15052 } |
|
15053 }; |
|
15054 })])(provider_EditorProvider)); |
|
15055 |
|
15056 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/deprecated.js |
|
15057 // Block Creation Components |
|
15058 |
|
15059 /** |
|
15060 * WordPress dependencies |
|
15061 */ |
|
15062 |
|
15063 |
|
15064 |
|
15065 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/components/index.js |
|
15066 // Block Creation Components |
|
15067 |
|
15068 // Post Related Components |
|
15069 |
|
15070 |
|
15071 |
|
15072 |
|
15073 |
|
15074 |
|
15075 |
|
15076 |
|
15077 |
|
15078 |
|
15079 |
|
15080 |
|
15081 |
|
15082 |
|
15083 |
|
15084 |
|
15085 |
|
15086 |
|
15087 |
|
15088 |
|
15089 |
|
15090 |
|
15091 |
|
15092 |
|
15093 |
|
15094 |
|
15095 |
|
15096 |
|
15097 |
|
15098 |
|
15099 |
|
15100 |
|
15101 |
|
15102 |
|
15103 |
|
15104 |
|
15105 |
|
15106 |
|
15107 |
|
15108 |
|
15109 |
|
15110 |
|
15111 |
|
15112 |
|
15113 |
|
15114 |
|
15115 |
|
15116 |
|
15117 |
|
15118 |
|
15119 |
|
15120 |
|
15121 // State Related Components |
|
15122 |
|
15123 |
|
15124 |
|
15125 |
|
15126 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/hooks/default-autocompleters.js |
|
15127 /** |
|
15128 * External dependencies |
|
15129 */ |
|
15130 |
|
15131 /** |
|
15132 * WordPress dependencies |
|
15133 */ |
|
15134 |
|
15135 |
|
15136 |
|
15137 |
|
15138 /** |
|
15139 * Internal dependencies |
|
15140 */ |
|
15141 |
|
15142 |
|
15143 var defaultAutocompleters = [autocompleters_user]; |
|
15144 var default_autocompleters_fetchReusableBlocks = Object(external_lodash_["once"])(function () { |
|
15145 return Object(external_this_wp_data_["dispatch"])('core/editor').__experimentalFetchReusableBlocks(); |
|
15146 }); |
|
15147 |
|
15148 function setDefaultCompleters(completers, blockName) { |
|
15149 if (!completers) { |
|
15150 // Provide copies so filters may directly modify them. |
|
15151 completers = defaultAutocompleters.map(external_lodash_["clone"]); // Add blocks autocompleter for Paragraph block |
|
15152 |
|
15153 if (blockName === Object(external_this_wp_blocks_["getDefaultBlockName"])()) { |
|
15154 completers.push(Object(external_lodash_["clone"])(autocompleters_block)); |
|
15155 /* |
|
15156 * NOTE: This is a hack to help ensure reusable blocks are loaded |
|
15157 * so they may be included in the block completer. It can be removed |
|
15158 * once we have a way for completers to Promise options while |
|
15159 * store-based data dependencies are being resolved. |
|
15160 */ |
|
15161 |
|
15162 default_autocompleters_fetchReusableBlocks(); |
|
15163 } |
|
15164 } |
|
15165 |
|
15166 return completers; |
|
15167 } |
|
15168 |
|
15169 Object(external_this_wp_hooks_["addFilter"])('editor.Autocomplete.completers', 'editor/autocompleters/set-default-completers', setDefaultCompleters); |
|
15170 |
|
15171 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/hooks/index.js |
|
15172 /** |
|
15173 * Internal dependencies |
|
15174 */ |
|
15175 |
|
15176 |
|
15177 // CONCATENATED MODULE: ./node_modules/@wordpress/editor/build-module/index.js |
|
15178 /* concated harmony reexport ServerSideRender */__webpack_require__.d(__webpack_exports__, "ServerSideRender", function() { return server_side_render; }); |
|
15179 /* concated harmony reexport AutosaveMonitor */__webpack_require__.d(__webpack_exports__, "AutosaveMonitor", function() { return autosave_monitor; }); |
|
15180 /* concated harmony reexport DocumentOutline */__webpack_require__.d(__webpack_exports__, "DocumentOutline", function() { return document_outline; }); |
|
15181 /* concated harmony reexport DocumentOutlineCheck */__webpack_require__.d(__webpack_exports__, "DocumentOutlineCheck", function() { return check; }); |
|
15182 /* concated harmony reexport VisualEditorGlobalKeyboardShortcuts */__webpack_require__.d(__webpack_exports__, "VisualEditorGlobalKeyboardShortcuts", function() { return visual_editor_shortcuts; }); |
|
15183 /* concated harmony reexport EditorGlobalKeyboardShortcuts */__webpack_require__.d(__webpack_exports__, "EditorGlobalKeyboardShortcuts", function() { return EditorGlobalKeyboardShortcuts; }); |
|
15184 /* concated harmony reexport TextEditorGlobalKeyboardShortcuts */__webpack_require__.d(__webpack_exports__, "TextEditorGlobalKeyboardShortcuts", function() { return TextEditorGlobalKeyboardShortcuts; }); |
|
15185 /* concated harmony reexport EditorHistoryRedo */__webpack_require__.d(__webpack_exports__, "EditorHistoryRedo", function() { return editor_history_redo; }); |
|
15186 /* concated harmony reexport EditorHistoryUndo */__webpack_require__.d(__webpack_exports__, "EditorHistoryUndo", function() { return editor_history_undo; }); |
|
15187 /* concated harmony reexport EditorNotices */__webpack_require__.d(__webpack_exports__, "EditorNotices", function() { return editor_notices; }); |
|
15188 /* concated harmony reexport ErrorBoundary */__webpack_require__.d(__webpack_exports__, "ErrorBoundary", function() { return error_boundary; }); |
|
15189 /* concated harmony reexport PageAttributesCheck */__webpack_require__.d(__webpack_exports__, "PageAttributesCheck", function() { return page_attributes_check; }); |
|
15190 /* concated harmony reexport PageAttributesOrder */__webpack_require__.d(__webpack_exports__, "PageAttributesOrder", function() { return page_attributes_order; }); |
|
15191 /* concated harmony reexport PageAttributesParent */__webpack_require__.d(__webpack_exports__, "PageAttributesParent", function() { return page_attributes_parent; }); |
|
15192 /* concated harmony reexport PageTemplate */__webpack_require__.d(__webpack_exports__, "PageTemplate", function() { return page_attributes_template; }); |
|
15193 /* concated harmony reexport PostAuthor */__webpack_require__.d(__webpack_exports__, "PostAuthor", function() { return post_author; }); |
|
15194 /* concated harmony reexport PostAuthorCheck */__webpack_require__.d(__webpack_exports__, "PostAuthorCheck", function() { return post_author_check; }); |
|
15195 /* concated harmony reexport PostComments */__webpack_require__.d(__webpack_exports__, "PostComments", function() { return post_comments; }); |
|
15196 /* concated harmony reexport PostExcerpt */__webpack_require__.d(__webpack_exports__, "PostExcerpt", function() { return post_excerpt; }); |
|
15197 /* concated harmony reexport PostExcerptCheck */__webpack_require__.d(__webpack_exports__, "PostExcerptCheck", function() { return post_excerpt_check; }); |
|
15198 /* concated harmony reexport PostFeaturedImage */__webpack_require__.d(__webpack_exports__, "PostFeaturedImage", function() { return post_featured_image; }); |
|
15199 /* concated harmony reexport PostFeaturedImageCheck */__webpack_require__.d(__webpack_exports__, "PostFeaturedImageCheck", function() { return post_featured_image_check; }); |
|
15200 /* concated harmony reexport PostFormat */__webpack_require__.d(__webpack_exports__, "PostFormat", function() { return post_format; }); |
|
15201 /* concated harmony reexport PostFormatCheck */__webpack_require__.d(__webpack_exports__, "PostFormatCheck", function() { return post_format_check; }); |
|
15202 /* concated harmony reexport PostLastRevision */__webpack_require__.d(__webpack_exports__, "PostLastRevision", function() { return post_last_revision; }); |
|
15203 /* concated harmony reexport PostLastRevisionCheck */__webpack_require__.d(__webpack_exports__, "PostLastRevisionCheck", function() { return post_last_revision_check; }); |
|
15204 /* concated harmony reexport PostLockedModal */__webpack_require__.d(__webpack_exports__, "PostLockedModal", function() { return post_locked_modal; }); |
|
15205 /* concated harmony reexport PostPendingStatus */__webpack_require__.d(__webpack_exports__, "PostPendingStatus", function() { return post_pending_status; }); |
|
15206 /* concated harmony reexport PostPendingStatusCheck */__webpack_require__.d(__webpack_exports__, "PostPendingStatusCheck", function() { return post_pending_status_check; }); |
|
15207 /* concated harmony reexport PostPingbacks */__webpack_require__.d(__webpack_exports__, "PostPingbacks", function() { return post_pingbacks; }); |
|
15208 /* concated harmony reexport PostPreviewButton */__webpack_require__.d(__webpack_exports__, "PostPreviewButton", function() { return post_preview_button; }); |
|
15209 /* concated harmony reexport PostPublishButton */__webpack_require__.d(__webpack_exports__, "PostPublishButton", function() { return post_publish_button; }); |
|
15210 /* concated harmony reexport PostPublishButtonLabel */__webpack_require__.d(__webpack_exports__, "PostPublishButtonLabel", function() { return post_publish_button_label; }); |
|
15211 /* concated harmony reexport PostPublishPanel */__webpack_require__.d(__webpack_exports__, "PostPublishPanel", function() { return post_publish_panel; }); |
|
15212 /* concated harmony reexport PostSavedState */__webpack_require__.d(__webpack_exports__, "PostSavedState", function() { return post_saved_state; }); |
|
15213 /* concated harmony reexport PostSchedule */__webpack_require__.d(__webpack_exports__, "PostSchedule", function() { return post_schedule; }); |
|
15214 /* concated harmony reexport PostScheduleCheck */__webpack_require__.d(__webpack_exports__, "PostScheduleCheck", function() { return post_schedule_check; }); |
|
15215 /* concated harmony reexport PostScheduleLabel */__webpack_require__.d(__webpack_exports__, "PostScheduleLabel", function() { return post_schedule_label; }); |
|
15216 /* concated harmony reexport PostSticky */__webpack_require__.d(__webpack_exports__, "PostSticky", function() { return post_sticky; }); |
|
15217 /* concated harmony reexport PostStickyCheck */__webpack_require__.d(__webpack_exports__, "PostStickyCheck", function() { return post_sticky_check; }); |
|
15218 /* concated harmony reexport PostSwitchToDraftButton */__webpack_require__.d(__webpack_exports__, "PostSwitchToDraftButton", function() { return post_switch_to_draft_button; }); |
|
15219 /* concated harmony reexport PostTaxonomies */__webpack_require__.d(__webpack_exports__, "PostTaxonomies", function() { return post_taxonomies; }); |
|
15220 /* concated harmony reexport PostTaxonomiesCheck */__webpack_require__.d(__webpack_exports__, "PostTaxonomiesCheck", function() { return post_taxonomies_check; }); |
|
15221 /* concated harmony reexport PostTextEditor */__webpack_require__.d(__webpack_exports__, "PostTextEditor", function() { return post_text_editor; }); |
|
15222 /* concated harmony reexport PostTitle */__webpack_require__.d(__webpack_exports__, "PostTitle", function() { return post_title; }); |
|
15223 /* concated harmony reexport PostTrash */__webpack_require__.d(__webpack_exports__, "PostTrash", function() { return post_trash; }); |
|
15224 /* concated harmony reexport PostTrashCheck */__webpack_require__.d(__webpack_exports__, "PostTrashCheck", function() { return post_trash_check; }); |
|
15225 /* concated harmony reexport PostTypeSupportCheck */__webpack_require__.d(__webpack_exports__, "PostTypeSupportCheck", function() { return post_type_support_check; }); |
|
15226 /* concated harmony reexport PostVisibility */__webpack_require__.d(__webpack_exports__, "PostVisibility", function() { return post_visibility; }); |
|
15227 /* concated harmony reexport PostVisibilityLabel */__webpack_require__.d(__webpack_exports__, "PostVisibilityLabel", function() { return post_visibility_label; }); |
|
15228 /* concated harmony reexport PostVisibilityCheck */__webpack_require__.d(__webpack_exports__, "PostVisibilityCheck", function() { return post_visibility_check; }); |
|
15229 /* concated harmony reexport TableOfContents */__webpack_require__.d(__webpack_exports__, "TableOfContents", function() { return table_of_contents; }); |
|
15230 /* concated harmony reexport UnsavedChangesWarning */__webpack_require__.d(__webpack_exports__, "UnsavedChangesWarning", function() { return unsaved_changes_warning; }); |
|
15231 /* concated harmony reexport WordCount */__webpack_require__.d(__webpack_exports__, "WordCount", function() { return word_count; }); |
|
15232 /* concated harmony reexport EditorProvider */__webpack_require__.d(__webpack_exports__, "EditorProvider", function() { return provider; }); |
|
15233 /* concated harmony reexport blockAutocompleter */__webpack_require__.d(__webpack_exports__, "blockAutocompleter", function() { return autocompleters_block; }); |
|
15234 /* concated harmony reexport userAutocompleter */__webpack_require__.d(__webpack_exports__, "userAutocompleter", function() { return autocompleters_user; }); |
|
15235 /* concated harmony reexport Autocomplete */__webpack_require__.d(__webpack_exports__, "Autocomplete", function() { return external_this_wp_blockEditor_["Autocomplete"]; }); |
|
15236 /* concated harmony reexport AlignmentToolbar */__webpack_require__.d(__webpack_exports__, "AlignmentToolbar", function() { return external_this_wp_blockEditor_["AlignmentToolbar"]; }); |
|
15237 /* concated harmony reexport BlockAlignmentToolbar */__webpack_require__.d(__webpack_exports__, "BlockAlignmentToolbar", function() { return external_this_wp_blockEditor_["BlockAlignmentToolbar"]; }); |
|
15238 /* concated harmony reexport BlockControls */__webpack_require__.d(__webpack_exports__, "BlockControls", function() { return external_this_wp_blockEditor_["BlockControls"]; }); |
|
15239 /* concated harmony reexport BlockEdit */__webpack_require__.d(__webpack_exports__, "BlockEdit", function() { return external_this_wp_blockEditor_["BlockEdit"]; }); |
|
15240 /* concated harmony reexport BlockEditorKeyboardShortcuts */__webpack_require__.d(__webpack_exports__, "BlockEditorKeyboardShortcuts", function() { return external_this_wp_blockEditor_["BlockEditorKeyboardShortcuts"]; }); |
|
15241 /* concated harmony reexport BlockFormatControls */__webpack_require__.d(__webpack_exports__, "BlockFormatControls", function() { return external_this_wp_blockEditor_["BlockFormatControls"]; }); |
|
15242 /* concated harmony reexport BlockIcon */__webpack_require__.d(__webpack_exports__, "BlockIcon", function() { return external_this_wp_blockEditor_["BlockIcon"]; }); |
|
15243 /* concated harmony reexport BlockInspector */__webpack_require__.d(__webpack_exports__, "BlockInspector", function() { return external_this_wp_blockEditor_["BlockInspector"]; }); |
|
15244 /* concated harmony reexport BlockList */__webpack_require__.d(__webpack_exports__, "BlockList", function() { return external_this_wp_blockEditor_["BlockList"]; }); |
|
15245 /* concated harmony reexport BlockMover */__webpack_require__.d(__webpack_exports__, "BlockMover", function() { return external_this_wp_blockEditor_["BlockMover"]; }); |
|
15246 /* concated harmony reexport BlockNavigationDropdown */__webpack_require__.d(__webpack_exports__, "BlockNavigationDropdown", function() { return external_this_wp_blockEditor_["BlockNavigationDropdown"]; }); |
|
15247 /* concated harmony reexport BlockSelectionClearer */__webpack_require__.d(__webpack_exports__, "BlockSelectionClearer", function() { return external_this_wp_blockEditor_["BlockSelectionClearer"]; }); |
|
15248 /* concated harmony reexport BlockSettingsMenu */__webpack_require__.d(__webpack_exports__, "BlockSettingsMenu", function() { return external_this_wp_blockEditor_["BlockSettingsMenu"]; }); |
|
15249 /* concated harmony reexport BlockTitle */__webpack_require__.d(__webpack_exports__, "BlockTitle", function() { return external_this_wp_blockEditor_["BlockTitle"]; }); |
|
15250 /* concated harmony reexport BlockToolbar */__webpack_require__.d(__webpack_exports__, "BlockToolbar", function() { return external_this_wp_blockEditor_["BlockToolbar"]; }); |
|
15251 /* concated harmony reexport ColorPalette */__webpack_require__.d(__webpack_exports__, "ColorPalette", function() { return external_this_wp_blockEditor_["ColorPalette"]; }); |
|
15252 /* concated harmony reexport ContrastChecker */__webpack_require__.d(__webpack_exports__, "ContrastChecker", function() { return external_this_wp_blockEditor_["ContrastChecker"]; }); |
|
15253 /* concated harmony reexport CopyHandler */__webpack_require__.d(__webpack_exports__, "CopyHandler", function() { return external_this_wp_blockEditor_["CopyHandler"]; }); |
|
15254 /* concated harmony reexport createCustomColorsHOC */__webpack_require__.d(__webpack_exports__, "createCustomColorsHOC", function() { return external_this_wp_blockEditor_["createCustomColorsHOC"]; }); |
|
15255 /* concated harmony reexport DefaultBlockAppender */__webpack_require__.d(__webpack_exports__, "DefaultBlockAppender", function() { return external_this_wp_blockEditor_["DefaultBlockAppender"]; }); |
|
15256 /* concated harmony reexport FontSizePicker */__webpack_require__.d(__webpack_exports__, "FontSizePicker", function() { return external_this_wp_blockEditor_["FontSizePicker"]; }); |
|
15257 /* concated harmony reexport getColorClassName */__webpack_require__.d(__webpack_exports__, "getColorClassName", function() { return external_this_wp_blockEditor_["getColorClassName"]; }); |
|
15258 /* concated harmony reexport getColorObjectByAttributeValues */__webpack_require__.d(__webpack_exports__, "getColorObjectByAttributeValues", function() { return external_this_wp_blockEditor_["getColorObjectByAttributeValues"]; }); |
|
15259 /* concated harmony reexport getColorObjectByColorValue */__webpack_require__.d(__webpack_exports__, "getColorObjectByColorValue", function() { return external_this_wp_blockEditor_["getColorObjectByColorValue"]; }); |
|
15260 /* concated harmony reexport getFontSize */__webpack_require__.d(__webpack_exports__, "getFontSize", function() { return external_this_wp_blockEditor_["getFontSize"]; }); |
|
15261 /* concated harmony reexport getFontSizeClass */__webpack_require__.d(__webpack_exports__, "getFontSizeClass", function() { return external_this_wp_blockEditor_["getFontSizeClass"]; }); |
|
15262 /* concated harmony reexport Inserter */__webpack_require__.d(__webpack_exports__, "Inserter", function() { return external_this_wp_blockEditor_["Inserter"]; }); |
|
15263 /* concated harmony reexport InnerBlocks */__webpack_require__.d(__webpack_exports__, "InnerBlocks", function() { return external_this_wp_blockEditor_["InnerBlocks"]; }); |
|
15264 /* concated harmony reexport InspectorAdvancedControls */__webpack_require__.d(__webpack_exports__, "InspectorAdvancedControls", function() { return external_this_wp_blockEditor_["InspectorAdvancedControls"]; }); |
|
15265 /* concated harmony reexport InspectorControls */__webpack_require__.d(__webpack_exports__, "InspectorControls", function() { return external_this_wp_blockEditor_["InspectorControls"]; }); |
|
15266 /* concated harmony reexport PanelColorSettings */__webpack_require__.d(__webpack_exports__, "PanelColorSettings", function() { return external_this_wp_blockEditor_["PanelColorSettings"]; }); |
|
15267 /* concated harmony reexport PlainText */__webpack_require__.d(__webpack_exports__, "PlainText", function() { return external_this_wp_blockEditor_["PlainText"]; }); |
|
15268 /* concated harmony reexport RichText */__webpack_require__.d(__webpack_exports__, "RichText", function() { return external_this_wp_blockEditor_["RichText"]; }); |
|
15269 /* concated harmony reexport RichTextShortcut */__webpack_require__.d(__webpack_exports__, "RichTextShortcut", function() { return external_this_wp_blockEditor_["RichTextShortcut"]; }); |
|
15270 /* concated harmony reexport RichTextToolbarButton */__webpack_require__.d(__webpack_exports__, "RichTextToolbarButton", function() { return external_this_wp_blockEditor_["RichTextToolbarButton"]; }); |
|
15271 /* concated harmony reexport RichTextInserterItem */__webpack_require__.d(__webpack_exports__, "RichTextInserterItem", function() { return external_this_wp_blockEditor_["RichTextInserterItem"]; }); |
|
15272 /* concated harmony reexport UnstableRichTextInputEvent */__webpack_require__.d(__webpack_exports__, "UnstableRichTextInputEvent", function() { return external_this_wp_blockEditor_["UnstableRichTextInputEvent"]; }); |
|
15273 /* concated harmony reexport MediaPlaceholder */__webpack_require__.d(__webpack_exports__, "MediaPlaceholder", function() { return external_this_wp_blockEditor_["MediaPlaceholder"]; }); |
|
15274 /* concated harmony reexport MediaUpload */__webpack_require__.d(__webpack_exports__, "MediaUpload", function() { return external_this_wp_blockEditor_["MediaUpload"]; }); |
|
15275 /* concated harmony reexport MediaUploadCheck */__webpack_require__.d(__webpack_exports__, "MediaUploadCheck", function() { return external_this_wp_blockEditor_["MediaUploadCheck"]; }); |
|
15276 /* concated harmony reexport MultiBlocksSwitcher */__webpack_require__.d(__webpack_exports__, "MultiBlocksSwitcher", function() { return external_this_wp_blockEditor_["MultiBlocksSwitcher"]; }); |
|
15277 /* concated harmony reexport MultiSelectScrollIntoView */__webpack_require__.d(__webpack_exports__, "MultiSelectScrollIntoView", function() { return external_this_wp_blockEditor_["MultiSelectScrollIntoView"]; }); |
|
15278 /* concated harmony reexport NavigableToolbar */__webpack_require__.d(__webpack_exports__, "NavigableToolbar", function() { return external_this_wp_blockEditor_["NavigableToolbar"]; }); |
|
15279 /* concated harmony reexport ObserveTyping */__webpack_require__.d(__webpack_exports__, "ObserveTyping", function() { return external_this_wp_blockEditor_["ObserveTyping"]; }); |
|
15280 /* concated harmony reexport PreserveScrollInReorder */__webpack_require__.d(__webpack_exports__, "PreserveScrollInReorder", function() { return external_this_wp_blockEditor_["PreserveScrollInReorder"]; }); |
|
15281 /* concated harmony reexport SkipToSelectedBlock */__webpack_require__.d(__webpack_exports__, "SkipToSelectedBlock", function() { return external_this_wp_blockEditor_["SkipToSelectedBlock"]; }); |
|
15282 /* concated harmony reexport URLInput */__webpack_require__.d(__webpack_exports__, "URLInput", function() { return external_this_wp_blockEditor_["URLInput"]; }); |
|
15283 /* concated harmony reexport URLInputButton */__webpack_require__.d(__webpack_exports__, "URLInputButton", function() { return external_this_wp_blockEditor_["URLInputButton"]; }); |
|
15284 /* concated harmony reexport URLPopover */__webpack_require__.d(__webpack_exports__, "URLPopover", function() { return external_this_wp_blockEditor_["URLPopover"]; }); |
|
15285 /* concated harmony reexport Warning */__webpack_require__.d(__webpack_exports__, "Warning", function() { return external_this_wp_blockEditor_["Warning"]; }); |
|
15286 /* concated harmony reexport WritingFlow */__webpack_require__.d(__webpack_exports__, "WritingFlow", function() { return external_this_wp_blockEditor_["WritingFlow"]; }); |
|
15287 /* concated harmony reexport withColorContext */__webpack_require__.d(__webpack_exports__, "withColorContext", function() { return external_this_wp_blockEditor_["withColorContext"]; }); |
|
15288 /* concated harmony reexport withColors */__webpack_require__.d(__webpack_exports__, "withColors", function() { return external_this_wp_blockEditor_["withColors"]; }); |
|
15289 /* concated harmony reexport withFontSizes */__webpack_require__.d(__webpack_exports__, "withFontSizes", function() { return external_this_wp_blockEditor_["withFontSizes"]; }); |
|
15290 /* concated harmony reexport mediaUpload */__webpack_require__.d(__webpack_exports__, "mediaUpload", function() { return media_upload; }); |
|
15291 /* concated harmony reexport cleanForSlug */__webpack_require__.d(__webpack_exports__, "cleanForSlug", function() { return cleanForSlug; }); |
|
15292 /* concated harmony reexport transformStyles */__webpack_require__.d(__webpack_exports__, "transformStyles", function() { return editor_styles; }); |
|
15293 /** |
|
15294 * WordPress dependencies |
|
15295 */ |
|
15296 |
|
15297 |
|
15298 |
|
15299 |
|
15300 |
|
15301 |
|
15302 |
|
15303 /** |
|
15304 * Internal dependencies |
|
15305 */ |
|
15306 |
|
15307 |
|
15308 |
|
15309 |
|
15310 |
|
15311 |
|
15312 |
|
15313 |
|
15314 /***/ }), |
|
15315 |
|
15316 /***/ 37: |
|
15317 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
15318 |
|
15319 "use strict"; |
|
15320 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _arrayWithHoles; }); |
|
15321 function _arrayWithHoles(arr) { |
|
15322 if (Array.isArray(arr)) return arr; |
|
15323 } |
|
15324 |
|
15325 /***/ }), |
|
15326 |
|
15327 /***/ 38: |
|
15328 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
15329 |
|
15330 "use strict"; |
|
15331 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _nonIterableRest; }); |
|
15332 function _nonIterableRest() { |
|
15333 throw new TypeError("Invalid attempt to destructure non-iterable instance"); |
|
15334 } |
|
15335 |
|
15336 /***/ }), |
|
15337 |
|
15338 /***/ 4: |
|
15339 /***/ (function(module, exports) { |
|
15340 |
|
15341 (function() { module.exports = this["wp"]["components"]; }()); |
|
15342 |
|
15343 /***/ }), |
|
15344 |
|
15345 /***/ 40: |
|
15346 /***/ (function(module, exports) { |
|
15347 |
|
15348 (function() { module.exports = this["wp"]["viewport"]; }()); |
|
15349 |
|
15350 /***/ }), |
|
15351 |
|
15352 /***/ 41: |
|
15353 /***/ (function(module, exports, __webpack_require__) { |
|
15354 |
|
15355 module.exports = function memize( fn, options ) { |
|
15356 var size = 0, |
|
15357 maxSize, head, tail; |
|
15358 |
|
15359 if ( options && options.maxSize ) { |
|
15360 maxSize = options.maxSize; |
|
15361 } |
|
15362 |
|
15363 function memoized( /* ...args */ ) { |
|
15364 var node = head, |
|
15365 len = arguments.length, |
|
15366 args, i; |
|
15367 |
|
15368 searchCache: while ( node ) { |
|
15369 // Perform a shallow equality test to confirm that whether the node |
|
15370 // under test is a candidate for the arguments passed. Two arrays |
|
15371 // are shallowly equal if their length matches and each entry is |
|
15372 // strictly equal between the two sets. Avoid abstracting to a |
|
15373 // function which could incur an arguments leaking deoptimization. |
|
15374 |
|
15375 // Check whether node arguments match arguments length |
|
15376 if ( node.args.length !== arguments.length ) { |
|
15377 node = node.next; |
|
15378 continue; |
|
15379 } |
|
15380 |
|
15381 // Check whether node arguments match arguments values |
|
15382 for ( i = 0; i < len; i++ ) { |
|
15383 if ( node.args[ i ] !== arguments[ i ] ) { |
|
15384 node = node.next; |
|
15385 continue searchCache; |
|
15386 } |
|
15387 } |
|
15388 |
|
15389 // At this point we can assume we've found a match |
|
15390 |
|
15391 // Surface matched node to head if not already |
|
15392 if ( node !== head ) { |
|
15393 // As tail, shift to previous. Must only shift if not also |
|
15394 // head, since if both head and tail, there is no previous. |
|
15395 if ( node === tail ) { |
|
15396 tail = node.prev; |
|
15397 } |
|
15398 |
|
15399 // Adjust siblings to point to each other. If node was tail, |
|
15400 // this also handles new tail's empty `next` assignment. |
|
15401 node.prev.next = node.next; |
|
15402 if ( node.next ) { |
|
15403 node.next.prev = node.prev; |
|
15404 } |
|
15405 |
|
15406 node.next = head; |
|
15407 node.prev = null; |
|
15408 head.prev = node; |
|
15409 head = node; |
|
15410 } |
|
15411 |
|
15412 // Return immediately |
|
15413 return node.val; |
|
15414 } |
|
15415 |
|
15416 // No cached value found. Continue to insertion phase: |
|
15417 |
|
15418 // Create a copy of arguments (avoid leaking deoptimization) |
|
15419 args = new Array( len ); |
|
15420 for ( i = 0; i < len; i++ ) { |
|
15421 args[ i ] = arguments[ i ]; |
|
15422 } |
|
15423 |
|
15424 node = { |
|
15425 args: args, |
|
15426 |
|
15427 // Generate the result from original function |
|
15428 val: fn.apply( null, args ) |
|
15429 }; |
|
15430 |
|
15431 // Don't need to check whether node is already head, since it would |
|
15432 // have been returned above already if it was |
|
15433 |
|
15434 // Shift existing head down list |
|
15435 if ( head ) { |
|
15436 head.prev = node; |
|
15437 node.next = head; |
|
15438 } else { |
|
15439 // If no head, follows that there's no tail (at initial or reset) |
|
15440 tail = node; |
|
15441 } |
|
15442 |
|
15443 // Trim tail if we're reached max size and are pending cache insertion |
|
15444 if ( size === maxSize ) { |
|
15445 tail = tail.prev; |
|
15446 tail.next = null; |
|
15447 } else { |
|
15448 size++; |
|
15449 } |
|
15450 |
|
15451 head = node; |
|
15452 |
|
15453 return node.val; |
|
15454 } |
|
15455 |
|
15456 memoized.clear = function() { |
|
15457 head = null; |
|
15458 tail = null; |
|
15459 size = 0; |
|
15460 }; |
|
15461 |
|
15462 if ( false ) {} |
|
15463 |
|
15464 return memoized; |
|
15465 }; |
|
15466 |
|
15467 |
|
15468 /***/ }), |
|
15469 |
|
15470 /***/ 44: |
|
15471 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
15472 |
|
15473 "use strict"; |
|
15474 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _asyncToGenerator; }); |
|
15475 function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { |
|
15476 try { |
|
15477 var info = gen[key](arg); |
|
15478 var value = info.value; |
|
15479 } catch (error) { |
|
15480 reject(error); |
|
15481 return; |
|
15482 } |
|
15483 |
|
15484 if (info.done) { |
|
15485 resolve(value); |
|
15486 } else { |
|
15487 Promise.resolve(value).then(_next, _throw); |
|
15488 } |
|
15489 } |
|
15490 |
|
15491 function _asyncToGenerator(fn) { |
|
15492 return function () { |
|
15493 var self = this, |
|
15494 args = arguments; |
|
15495 return new Promise(function (resolve, reject) { |
|
15496 var gen = fn.apply(self, args); |
|
15497 |
|
15498 function _next(value) { |
|
15499 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); |
|
15500 } |
|
15501 |
|
15502 function _throw(err) { |
|
15503 asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); |
|
15504 } |
|
15505 |
|
15506 _next(undefined); |
|
15507 }); |
|
15508 }; |
|
15509 } |
|
15510 |
|
15511 /***/ }), |
|
15512 |
|
15513 /***/ 49: |
|
15514 /***/ (function(module, exports) { |
|
15515 |
|
15516 (function() { module.exports = this["wp"]["deprecated"]; }()); |
|
15517 |
|
15518 /***/ }), |
|
15519 |
|
15520 /***/ 5: |
|
15521 /***/ (function(module, exports) { |
|
15522 |
|
15523 (function() { module.exports = this["wp"]["data"]; }()); |
|
15524 |
|
15525 /***/ }), |
|
15526 |
|
15527 /***/ 50: |
|
15528 /***/ (function(module, exports) { |
|
15529 |
|
15530 (function() { module.exports = this["wp"]["date"]; }()); |
|
15531 |
|
15532 /***/ }), |
|
15533 |
|
15534 /***/ 54: |
|
15535 /***/ (function(module, exports, __webpack_require__) { |
|
15536 |
|
15537 /** |
|
15538 * Copyright (c) 2014-present, Facebook, Inc. |
|
15539 * |
|
15540 * This source code is licensed under the MIT license found in the |
|
15541 * LICENSE file in the root directory of this source tree. |
|
15542 */ |
|
15543 |
|
15544 // This method of obtaining a reference to the global object needs to be |
|
15545 // kept identical to the way it is obtained in runtime.js |
|
15546 var g = (function() { |
|
15547 return this || (typeof self === "object" && self); |
|
15548 })() || Function("return this")(); |
|
15549 |
|
15550 // Use `getOwnPropertyNames` because not all browsers support calling |
|
15551 // `hasOwnProperty` on the global `self` object in a worker. See #183. |
|
15552 var hadRuntime = g.regeneratorRuntime && |
|
15553 Object.getOwnPropertyNames(g).indexOf("regeneratorRuntime") >= 0; |
|
15554 |
|
15555 // Save the old regeneratorRuntime in case it needs to be restored later. |
|
15556 var oldRuntime = hadRuntime && g.regeneratorRuntime; |
|
15557 |
|
15558 // Force reevalutation of runtime.js. |
|
15559 g.regeneratorRuntime = undefined; |
|
15560 |
|
15561 module.exports = __webpack_require__(55); |
|
15562 |
|
15563 if (hadRuntime) { |
|
15564 // Restore the original runtime. |
|
15565 g.regeneratorRuntime = oldRuntime; |
|
15566 } else { |
|
15567 // Remove the global property added by runtime.js. |
|
15568 try { |
|
15569 delete g.regeneratorRuntime; |
|
15570 } catch(e) { |
|
15571 g.regeneratorRuntime = undefined; |
|
15572 } |
|
15573 } |
|
15574 |
|
15575 |
|
15576 /***/ }), |
|
15577 |
|
15578 /***/ 55: |
|
15579 /***/ (function(module, exports) { |
|
15580 |
|
15581 /** |
|
15582 * Copyright (c) 2014-present, Facebook, Inc. |
|
15583 * |
|
15584 * This source code is licensed under the MIT license found in the |
|
15585 * LICENSE file in the root directory of this source tree. |
|
15586 */ |
|
15587 |
|
15588 !(function(global) { |
|
15589 "use strict"; |
|
15590 |
|
15591 var Op = Object.prototype; |
|
15592 var hasOwn = Op.hasOwnProperty; |
|
15593 var undefined; // More compressible than void 0. |
|
15594 var $Symbol = typeof Symbol === "function" ? Symbol : {}; |
|
15595 var iteratorSymbol = $Symbol.iterator || "@@iterator"; |
|
15596 var asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator"; |
|
15597 var toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; |
|
15598 |
|
15599 var inModule = typeof module === "object"; |
|
15600 var runtime = global.regeneratorRuntime; |
|
15601 if (runtime) { |
|
15602 if (inModule) { |
|
15603 // If regeneratorRuntime is defined globally and we're in a module, |
|
15604 // make the exports object identical to regeneratorRuntime. |
|
15605 module.exports = runtime; |
|
15606 } |
|
15607 // Don't bother evaluating the rest of this file if the runtime was |
|
15608 // already defined globally. |
|
15609 return; |
|
15610 } |
|
15611 |
|
15612 // Define the runtime globally (as expected by generated code) as either |
|
15613 // module.exports (if we're in a module) or a new, empty object. |
|
15614 runtime = global.regeneratorRuntime = inModule ? module.exports : {}; |
|
15615 |
|
15616 function wrap(innerFn, outerFn, self, tryLocsList) { |
|
15617 // If outerFn provided and outerFn.prototype is a Generator, then outerFn.prototype instanceof Generator. |
|
15618 var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator; |
|
15619 var generator = Object.create(protoGenerator.prototype); |
|
15620 var context = new Context(tryLocsList || []); |
|
15621 |
|
15622 // The ._invoke method unifies the implementations of the .next, |
|
15623 // .throw, and .return methods. |
|
15624 generator._invoke = makeInvokeMethod(innerFn, self, context); |
|
15625 |
|
15626 return generator; |
|
15627 } |
|
15628 runtime.wrap = wrap; |
|
15629 |
|
15630 // Try/catch helper to minimize deoptimizations. Returns a completion |
|
15631 // record like context.tryEntries[i].completion. This interface could |
|
15632 // have been (and was previously) designed to take a closure to be |
|
15633 // invoked without arguments, but in all the cases we care about we |
|
15634 // already have an existing method we want to call, so there's no need |
|
15635 // to create a new function object. We can even get away with assuming |
|
15636 // the method takes exactly one argument, since that happens to be true |
|
15637 // in every case, so we don't have to touch the arguments object. The |
|
15638 // only additional allocation required is the completion record, which |
|
15639 // has a stable shape and so hopefully should be cheap to allocate. |
|
15640 function tryCatch(fn, obj, arg) { |
|
15641 try { |
|
15642 return { type: "normal", arg: fn.call(obj, arg) }; |
|
15643 } catch (err) { |
|
15644 return { type: "throw", arg: err }; |
|
15645 } |
|
15646 } |
|
15647 |
|
15648 var GenStateSuspendedStart = "suspendedStart"; |
|
15649 var GenStateSuspendedYield = "suspendedYield"; |
|
15650 var GenStateExecuting = "executing"; |
|
15651 var GenStateCompleted = "completed"; |
|
15652 |
|
15653 // Returning this object from the innerFn has the same effect as |
|
15654 // breaking out of the dispatch switch statement. |
|
15655 var ContinueSentinel = {}; |
|
15656 |
|
15657 // Dummy constructor functions that we use as the .constructor and |
|
15658 // .constructor.prototype properties for functions that return Generator |
|
15659 // objects. For full spec compliance, you may wish to configure your |
|
15660 // minifier not to mangle the names of these two functions. |
|
15661 function Generator() {} |
|
15662 function GeneratorFunction() {} |
|
15663 function GeneratorFunctionPrototype() {} |
|
15664 |
|
15665 // This is a polyfill for %IteratorPrototype% for environments that |
|
15666 // don't natively support it. |
|
15667 var IteratorPrototype = {}; |
|
15668 IteratorPrototype[iteratorSymbol] = function () { |
|
15669 return this; |
|
15670 }; |
|
15671 |
|
15672 var getProto = Object.getPrototypeOf; |
|
15673 var NativeIteratorPrototype = getProto && getProto(getProto(values([]))); |
|
15674 if (NativeIteratorPrototype && |
|
15675 NativeIteratorPrototype !== Op && |
|
15676 hasOwn.call(NativeIteratorPrototype, iteratorSymbol)) { |
|
15677 // This environment has a native %IteratorPrototype%; use it instead |
|
15678 // of the polyfill. |
|
15679 IteratorPrototype = NativeIteratorPrototype; |
|
15680 } |
|
15681 |
|
15682 var Gp = GeneratorFunctionPrototype.prototype = |
|
15683 Generator.prototype = Object.create(IteratorPrototype); |
|
15684 GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype; |
|
15685 GeneratorFunctionPrototype.constructor = GeneratorFunction; |
|
15686 GeneratorFunctionPrototype[toStringTagSymbol] = |
|
15687 GeneratorFunction.displayName = "GeneratorFunction"; |
|
15688 |
|
15689 // Helper for defining the .next, .throw, and .return methods of the |
|
15690 // Iterator interface in terms of a single ._invoke method. |
|
15691 function defineIteratorMethods(prototype) { |
|
15692 ["next", "throw", "return"].forEach(function(method) { |
|
15693 prototype[method] = function(arg) { |
|
15694 return this._invoke(method, arg); |
|
15695 }; |
|
15696 }); |
|
15697 } |
|
15698 |
|
15699 runtime.isGeneratorFunction = function(genFun) { |
|
15700 var ctor = typeof genFun === "function" && genFun.constructor; |
|
15701 return ctor |
|
15702 ? ctor === GeneratorFunction || |
|
15703 // For the native GeneratorFunction constructor, the best we can |
|
15704 // do is to check its .name property. |
|
15705 (ctor.displayName || ctor.name) === "GeneratorFunction" |
|
15706 : false; |
|
15707 }; |
|
15708 |
|
15709 runtime.mark = function(genFun) { |
|
15710 if (Object.setPrototypeOf) { |
|
15711 Object.setPrototypeOf(genFun, GeneratorFunctionPrototype); |
|
15712 } else { |
|
15713 genFun.__proto__ = GeneratorFunctionPrototype; |
|
15714 if (!(toStringTagSymbol in genFun)) { |
|
15715 genFun[toStringTagSymbol] = "GeneratorFunction"; |
|
15716 } |
|
15717 } |
|
15718 genFun.prototype = Object.create(Gp); |
|
15719 return genFun; |
|
15720 }; |
|
15721 |
|
15722 // Within the body of any async function, `await x` is transformed to |
|
15723 // `yield regeneratorRuntime.awrap(x)`, so that the runtime can test |
|
15724 // `hasOwn.call(value, "__await")` to determine if the yielded value is |
|
15725 // meant to be awaited. |
|
15726 runtime.awrap = function(arg) { |
|
15727 return { __await: arg }; |
|
15728 }; |
|
15729 |
|
15730 function AsyncIterator(generator) { |
|
15731 function invoke(method, arg, resolve, reject) { |
|
15732 var record = tryCatch(generator[method], generator, arg); |
|
15733 if (record.type === "throw") { |
|
15734 reject(record.arg); |
|
15735 } else { |
|
15736 var result = record.arg; |
|
15737 var value = result.value; |
|
15738 if (value && |
|
15739 typeof value === "object" && |
|
15740 hasOwn.call(value, "__await")) { |
|
15741 return Promise.resolve(value.__await).then(function(value) { |
|
15742 invoke("next", value, resolve, reject); |
|
15743 }, function(err) { |
|
15744 invoke("throw", err, resolve, reject); |
|
15745 }); |
|
15746 } |
|
15747 |
|
15748 return Promise.resolve(value).then(function(unwrapped) { |
|
15749 // When a yielded Promise is resolved, its final value becomes |
|
15750 // the .value of the Promise<{value,done}> result for the |
|
15751 // current iteration. |
|
15752 result.value = unwrapped; |
|
15753 resolve(result); |
|
15754 }, function(error) { |
|
15755 // If a rejected Promise was yielded, throw the rejection back |
|
15756 // into the async generator function so it can be handled there. |
|
15757 return invoke("throw", error, resolve, reject); |
|
15758 }); |
|
15759 } |
|
15760 } |
|
15761 |
|
15762 var previousPromise; |
|
15763 |
|
15764 function enqueue(method, arg) { |
|
15765 function callInvokeWithMethodAndArg() { |
|
15766 return new Promise(function(resolve, reject) { |
|
15767 invoke(method, arg, resolve, reject); |
|
15768 }); |
|
15769 } |
|
15770 |
|
15771 return previousPromise = |
|
15772 // If enqueue has been called before, then we want to wait until |
|
15773 // all previous Promises have been resolved before calling invoke, |
|
15774 // so that results are always delivered in the correct order. If |
|
15775 // enqueue has not been called before, then it is important to |
|
15776 // call invoke immediately, without waiting on a callback to fire, |
|
15777 // so that the async generator function has the opportunity to do |
|
15778 // any necessary setup in a predictable way. This predictability |
|
15779 // is why the Promise constructor synchronously invokes its |
|
15780 // executor callback, and why async functions synchronously |
|
15781 // execute code before the first await. Since we implement simple |
|
15782 // async functions in terms of async generators, it is especially |
|
15783 // important to get this right, even though it requires care. |
|
15784 previousPromise ? previousPromise.then( |
|
15785 callInvokeWithMethodAndArg, |
|
15786 // Avoid propagating failures to Promises returned by later |
|
15787 // invocations of the iterator. |
|
15788 callInvokeWithMethodAndArg |
|
15789 ) : callInvokeWithMethodAndArg(); |
|
15790 } |
|
15791 |
|
15792 // Define the unified helper method that is used to implement .next, |
|
15793 // .throw, and .return (see defineIteratorMethods). |
|
15794 this._invoke = enqueue; |
|
15795 } |
|
15796 |
|
15797 defineIteratorMethods(AsyncIterator.prototype); |
|
15798 AsyncIterator.prototype[asyncIteratorSymbol] = function () { |
|
15799 return this; |
|
15800 }; |
|
15801 runtime.AsyncIterator = AsyncIterator; |
|
15802 |
|
15803 // Note that simple async functions are implemented on top of |
|
15804 // AsyncIterator objects; they just return a Promise for the value of |
|
15805 // the final result produced by the iterator. |
|
15806 runtime.async = function(innerFn, outerFn, self, tryLocsList) { |
|
15807 var iter = new AsyncIterator( |
|
15808 wrap(innerFn, outerFn, self, tryLocsList) |
|
15809 ); |
|
15810 |
|
15811 return runtime.isGeneratorFunction(outerFn) |
|
15812 ? iter // If outerFn is a generator, return the full iterator. |
|
15813 : iter.next().then(function(result) { |
|
15814 return result.done ? result.value : iter.next(); |
|
15815 }); |
|
15816 }; |
|
15817 |
|
15818 function makeInvokeMethod(innerFn, self, context) { |
|
15819 var state = GenStateSuspendedStart; |
|
15820 |
|
15821 return function invoke(method, arg) { |
|
15822 if (state === GenStateExecuting) { |
|
15823 throw new Error("Generator is already running"); |
|
15824 } |
|
15825 |
|
15826 if (state === GenStateCompleted) { |
|
15827 if (method === "throw") { |
|
15828 throw arg; |
|
15829 } |
|
15830 |
|
15831 // Be forgiving, per 25.3.3.3.3 of the spec: |
|
15832 // https://people.mozilla.org/~jorendorff/es6-draft.html#sec-generatorresume |
|
15833 return doneResult(); |
|
15834 } |
|
15835 |
|
15836 context.method = method; |
|
15837 context.arg = arg; |
|
15838 |
|
15839 while (true) { |
|
15840 var delegate = context.delegate; |
|
15841 if (delegate) { |
|
15842 var delegateResult = maybeInvokeDelegate(delegate, context); |
|
15843 if (delegateResult) { |
|
15844 if (delegateResult === ContinueSentinel) continue; |
|
15845 return delegateResult; |
|
15846 } |
|
15847 } |
|
15848 |
|
15849 if (context.method === "next") { |
|
15850 // Setting context._sent for legacy support of Babel's |
|
15851 // function.sent implementation. |
|
15852 context.sent = context._sent = context.arg; |
|
15853 |
|
15854 } else if (context.method === "throw") { |
|
15855 if (state === GenStateSuspendedStart) { |
|
15856 state = GenStateCompleted; |
|
15857 throw context.arg; |
|
15858 } |
|
15859 |
|
15860 context.dispatchException(context.arg); |
|
15861 |
|
15862 } else if (context.method === "return") { |
|
15863 context.abrupt("return", context.arg); |
|
15864 } |
|
15865 |
|
15866 state = GenStateExecuting; |
|
15867 |
|
15868 var record = tryCatch(innerFn, self, context); |
|
15869 if (record.type === "normal") { |
|
15870 // If an exception is thrown from innerFn, we leave state === |
|
15871 // GenStateExecuting and loop back for another invocation. |
|
15872 state = context.done |
|
15873 ? GenStateCompleted |
|
15874 : GenStateSuspendedYield; |
|
15875 |
|
15876 if (record.arg === ContinueSentinel) { |
|
15877 continue; |
|
15878 } |
|
15879 |
|
15880 return { |
|
15881 value: record.arg, |
|
15882 done: context.done |
|
15883 }; |
|
15884 |
|
15885 } else if (record.type === "throw") { |
|
15886 state = GenStateCompleted; |
|
15887 // Dispatch the exception by looping back around to the |
|
15888 // context.dispatchException(context.arg) call above. |
|
15889 context.method = "throw"; |
|
15890 context.arg = record.arg; |
|
15891 } |
|
15892 } |
|
15893 }; |
|
15894 } |
|
15895 |
|
15896 // Call delegate.iterator[context.method](context.arg) and handle the |
|
15897 // result, either by returning a { value, done } result from the |
|
15898 // delegate iterator, or by modifying context.method and context.arg, |
|
15899 // setting context.delegate to null, and returning the ContinueSentinel. |
|
15900 function maybeInvokeDelegate(delegate, context) { |
|
15901 var method = delegate.iterator[context.method]; |
|
15902 if (method === undefined) { |
|
15903 // A .throw or .return when the delegate iterator has no .throw |
|
15904 // method always terminates the yield* loop. |
|
15905 context.delegate = null; |
|
15906 |
|
15907 if (context.method === "throw") { |
|
15908 if (delegate.iterator.return) { |
|
15909 // If the delegate iterator has a return method, give it a |
|
15910 // chance to clean up. |
|
15911 context.method = "return"; |
|
15912 context.arg = undefined; |
|
15913 maybeInvokeDelegate(delegate, context); |
|
15914 |
|
15915 if (context.method === "throw") { |
|
15916 // If maybeInvokeDelegate(context) changed context.method from |
|
15917 // "return" to "throw", let that override the TypeError below. |
|
15918 return ContinueSentinel; |
|
15919 } |
|
15920 } |
|
15921 |
|
15922 context.method = "throw"; |
|
15923 context.arg = new TypeError( |
|
15924 "The iterator does not provide a 'throw' method"); |
|
15925 } |
|
15926 |
|
15927 return ContinueSentinel; |
|
15928 } |
|
15929 |
|
15930 var record = tryCatch(method, delegate.iterator, context.arg); |
|
15931 |
|
15932 if (record.type === "throw") { |
|
15933 context.method = "throw"; |
|
15934 context.arg = record.arg; |
|
15935 context.delegate = null; |
|
15936 return ContinueSentinel; |
|
15937 } |
|
15938 |
|
15939 var info = record.arg; |
|
15940 |
|
15941 if (! info) { |
|
15942 context.method = "throw"; |
|
15943 context.arg = new TypeError("iterator result is not an object"); |
|
15944 context.delegate = null; |
|
15945 return ContinueSentinel; |
|
15946 } |
|
15947 |
|
15948 if (info.done) { |
|
15949 // Assign the result of the finished delegate to the temporary |
|
15950 // variable specified by delegate.resultName (see delegateYield). |
|
15951 context[delegate.resultName] = info.value; |
|
15952 |
|
15953 // Resume execution at the desired location (see delegateYield). |
|
15954 context.next = delegate.nextLoc; |
|
15955 |
|
15956 // If context.method was "throw" but the delegate handled the |
|
15957 // exception, let the outer generator proceed normally. If |
|
15958 // context.method was "next", forget context.arg since it has been |
|
15959 // "consumed" by the delegate iterator. If context.method was |
|
15960 // "return", allow the original .return call to continue in the |
|
15961 // outer generator. |
|
15962 if (context.method !== "return") { |
|
15963 context.method = "next"; |
|
15964 context.arg = undefined; |
|
15965 } |
|
15966 |
|
15967 } else { |
|
15968 // Re-yield the result returned by the delegate method. |
|
15969 return info; |
|
15970 } |
|
15971 |
|
15972 // The delegate iterator is finished, so forget it and continue with |
|
15973 // the outer generator. |
|
15974 context.delegate = null; |
|
15975 return ContinueSentinel; |
|
15976 } |
|
15977 |
|
15978 // Define Generator.prototype.{next,throw,return} in terms of the |
|
15979 // unified ._invoke helper method. |
|
15980 defineIteratorMethods(Gp); |
|
15981 |
|
15982 Gp[toStringTagSymbol] = "Generator"; |
|
15983 |
|
15984 // A Generator should always return itself as the iterator object when the |
|
15985 // @@iterator function is called on it. Some browsers' implementations of the |
|
15986 // iterator prototype chain incorrectly implement this, causing the Generator |
|
15987 // object to not be returned from this call. This ensures that doesn't happen. |
|
15988 // See https://github.com/facebook/regenerator/issues/274 for more details. |
|
15989 Gp[iteratorSymbol] = function() { |
|
15990 return this; |
|
15991 }; |
|
15992 |
|
15993 Gp.toString = function() { |
|
15994 return "[object Generator]"; |
|
15995 }; |
|
15996 |
|
15997 function pushTryEntry(locs) { |
|
15998 var entry = { tryLoc: locs[0] }; |
|
15999 |
|
16000 if (1 in locs) { |
|
16001 entry.catchLoc = locs[1]; |
|
16002 } |
|
16003 |
|
16004 if (2 in locs) { |
|
16005 entry.finallyLoc = locs[2]; |
|
16006 entry.afterLoc = locs[3]; |
|
16007 } |
|
16008 |
|
16009 this.tryEntries.push(entry); |
|
16010 } |
|
16011 |
|
16012 function resetTryEntry(entry) { |
|
16013 var record = entry.completion || {}; |
|
16014 record.type = "normal"; |
|
16015 delete record.arg; |
|
16016 entry.completion = record; |
|
16017 } |
|
16018 |
|
16019 function Context(tryLocsList) { |
|
16020 // The root entry object (effectively a try statement without a catch |
|
16021 // or a finally block) gives us a place to store values thrown from |
|
16022 // locations where there is no enclosing try statement. |
|
16023 this.tryEntries = [{ tryLoc: "root" }]; |
|
16024 tryLocsList.forEach(pushTryEntry, this); |
|
16025 this.reset(true); |
|
16026 } |
|
16027 |
|
16028 runtime.keys = function(object) { |
|
16029 var keys = []; |
|
16030 for (var key in object) { |
|
16031 keys.push(key); |
|
16032 } |
|
16033 keys.reverse(); |
|
16034 |
|
16035 // Rather than returning an object with a next method, we keep |
|
16036 // things simple and return the next function itself. |
|
16037 return function next() { |
|
16038 while (keys.length) { |
|
16039 var key = keys.pop(); |
|
16040 if (key in object) { |
|
16041 next.value = key; |
|
16042 next.done = false; |
|
16043 return next; |
|
16044 } |
|
16045 } |
|
16046 |
|
16047 // To avoid creating an additional object, we just hang the .value |
|
16048 // and .done properties off the next function object itself. This |
|
16049 // also ensures that the minifier will not anonymize the function. |
|
16050 next.done = true; |
|
16051 return next; |
|
16052 }; |
|
16053 }; |
|
16054 |
|
16055 function values(iterable) { |
|
16056 if (iterable) { |
|
16057 var iteratorMethod = iterable[iteratorSymbol]; |
|
16058 if (iteratorMethod) { |
|
16059 return iteratorMethod.call(iterable); |
|
16060 } |
|
16061 |
|
16062 if (typeof iterable.next === "function") { |
|
16063 return iterable; |
|
16064 } |
|
16065 |
|
16066 if (!isNaN(iterable.length)) { |
|
16067 var i = -1, next = function next() { |
|
16068 while (++i < iterable.length) { |
|
16069 if (hasOwn.call(iterable, i)) { |
|
16070 next.value = iterable[i]; |
|
16071 next.done = false; |
|
16072 return next; |
|
16073 } |
|
16074 } |
|
16075 |
|
16076 next.value = undefined; |
|
16077 next.done = true; |
|
16078 |
|
16079 return next; |
|
16080 }; |
|
16081 |
|
16082 return next.next = next; |
|
16083 } |
|
16084 } |
|
16085 |
|
16086 // Return an iterator with no values. |
|
16087 return { next: doneResult }; |
|
16088 } |
|
16089 runtime.values = values; |
|
16090 |
|
16091 function doneResult() { |
|
16092 return { value: undefined, done: true }; |
|
16093 } |
|
16094 |
|
16095 Context.prototype = { |
|
16096 constructor: Context, |
|
16097 |
|
16098 reset: function(skipTempReset) { |
|
16099 this.prev = 0; |
|
16100 this.next = 0; |
|
16101 // Resetting context._sent for legacy support of Babel's |
|
16102 // function.sent implementation. |
|
16103 this.sent = this._sent = undefined; |
|
16104 this.done = false; |
|
16105 this.delegate = null; |
|
16106 |
|
16107 this.method = "next"; |
|
16108 this.arg = undefined; |
|
16109 |
|
16110 this.tryEntries.forEach(resetTryEntry); |
|
16111 |
|
16112 if (!skipTempReset) { |
|
16113 for (var name in this) { |
|
16114 // Not sure about the optimal order of these conditions: |
|
16115 if (name.charAt(0) === "t" && |
|
16116 hasOwn.call(this, name) && |
|
16117 !isNaN(+name.slice(1))) { |
|
16118 this[name] = undefined; |
|
16119 } |
|
16120 } |
|
16121 } |
|
16122 }, |
|
16123 |
|
16124 stop: function() { |
|
16125 this.done = true; |
|
16126 |
|
16127 var rootEntry = this.tryEntries[0]; |
|
16128 var rootRecord = rootEntry.completion; |
|
16129 if (rootRecord.type === "throw") { |
|
16130 throw rootRecord.arg; |
|
16131 } |
|
16132 |
|
16133 return this.rval; |
|
16134 }, |
|
16135 |
|
16136 dispatchException: function(exception) { |
|
16137 if (this.done) { |
|
16138 throw exception; |
|
16139 } |
|
16140 |
|
16141 var context = this; |
|
16142 function handle(loc, caught) { |
|
16143 record.type = "throw"; |
|
16144 record.arg = exception; |
|
16145 context.next = loc; |
|
16146 |
|
16147 if (caught) { |
|
16148 // If the dispatched exception was caught by a catch block, |
|
16149 // then let that catch block handle the exception normally. |
|
16150 context.method = "next"; |
|
16151 context.arg = undefined; |
|
16152 } |
|
16153 |
|
16154 return !! caught; |
|
16155 } |
|
16156 |
|
16157 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
16158 var entry = this.tryEntries[i]; |
|
16159 var record = entry.completion; |
|
16160 |
|
16161 if (entry.tryLoc === "root") { |
|
16162 // Exception thrown outside of any try block that could handle |
|
16163 // it, so set the completion value of the entire function to |
|
16164 // throw the exception. |
|
16165 return handle("end"); |
|
16166 } |
|
16167 |
|
16168 if (entry.tryLoc <= this.prev) { |
|
16169 var hasCatch = hasOwn.call(entry, "catchLoc"); |
|
16170 var hasFinally = hasOwn.call(entry, "finallyLoc"); |
|
16171 |
|
16172 if (hasCatch && hasFinally) { |
|
16173 if (this.prev < entry.catchLoc) { |
|
16174 return handle(entry.catchLoc, true); |
|
16175 } else if (this.prev < entry.finallyLoc) { |
|
16176 return handle(entry.finallyLoc); |
|
16177 } |
|
16178 |
|
16179 } else if (hasCatch) { |
|
16180 if (this.prev < entry.catchLoc) { |
|
16181 return handle(entry.catchLoc, true); |
|
16182 } |
|
16183 |
|
16184 } else if (hasFinally) { |
|
16185 if (this.prev < entry.finallyLoc) { |
|
16186 return handle(entry.finallyLoc); |
|
16187 } |
|
16188 |
|
16189 } else { |
|
16190 throw new Error("try statement without catch or finally"); |
|
16191 } |
|
16192 } |
|
16193 } |
|
16194 }, |
|
16195 |
|
16196 abrupt: function(type, arg) { |
|
16197 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
16198 var entry = this.tryEntries[i]; |
|
16199 if (entry.tryLoc <= this.prev && |
|
16200 hasOwn.call(entry, "finallyLoc") && |
|
16201 this.prev < entry.finallyLoc) { |
|
16202 var finallyEntry = entry; |
|
16203 break; |
|
16204 } |
|
16205 } |
|
16206 |
|
16207 if (finallyEntry && |
|
16208 (type === "break" || |
|
16209 type === "continue") && |
|
16210 finallyEntry.tryLoc <= arg && |
|
16211 arg <= finallyEntry.finallyLoc) { |
|
16212 // Ignore the finally entry if control is not jumping to a |
|
16213 // location outside the try/catch block. |
|
16214 finallyEntry = null; |
|
16215 } |
|
16216 |
|
16217 var record = finallyEntry ? finallyEntry.completion : {}; |
|
16218 record.type = type; |
|
16219 record.arg = arg; |
|
16220 |
|
16221 if (finallyEntry) { |
|
16222 this.method = "next"; |
|
16223 this.next = finallyEntry.finallyLoc; |
|
16224 return ContinueSentinel; |
|
16225 } |
|
16226 |
|
16227 return this.complete(record); |
|
16228 }, |
|
16229 |
|
16230 complete: function(record, afterLoc) { |
|
16231 if (record.type === "throw") { |
|
16232 throw record.arg; |
|
16233 } |
|
16234 |
|
16235 if (record.type === "break" || |
|
16236 record.type === "continue") { |
|
16237 this.next = record.arg; |
|
16238 } else if (record.type === "return") { |
|
16239 this.rval = this.arg = record.arg; |
|
16240 this.method = "return"; |
|
16241 this.next = "end"; |
|
16242 } else if (record.type === "normal" && afterLoc) { |
|
16243 this.next = afterLoc; |
|
16244 } |
|
16245 |
|
16246 return ContinueSentinel; |
|
16247 }, |
|
16248 |
|
16249 finish: function(finallyLoc) { |
|
16250 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
16251 var entry = this.tryEntries[i]; |
|
16252 if (entry.finallyLoc === finallyLoc) { |
|
16253 this.complete(entry.completion, entry.afterLoc); |
|
16254 resetTryEntry(entry); |
|
16255 return ContinueSentinel; |
|
16256 } |
|
16257 } |
|
16258 }, |
|
16259 |
|
16260 "catch": function(tryLoc) { |
|
16261 for (var i = this.tryEntries.length - 1; i >= 0; --i) { |
|
16262 var entry = this.tryEntries[i]; |
|
16263 if (entry.tryLoc === tryLoc) { |
|
16264 var record = entry.completion; |
|
16265 if (record.type === "throw") { |
|
16266 var thrown = record.arg; |
|
16267 resetTryEntry(entry); |
|
16268 } |
|
16269 return thrown; |
|
16270 } |
|
16271 } |
|
16272 |
|
16273 // The context.catch method must only be called with a location |
|
16274 // argument that corresponds to a known catch block. |
|
16275 throw new Error("illegal catch attempt"); |
|
16276 }, |
|
16277 |
|
16278 delegateYield: function(iterable, resultName, nextLoc) { |
|
16279 this.delegate = { |
|
16280 iterator: values(iterable), |
|
16281 resultName: resultName, |
|
16282 nextLoc: nextLoc |
|
16283 }; |
|
16284 |
|
16285 if (this.method === "next") { |
|
16286 // Deliberately forget the last sent value so that we don't |
|
16287 // accidentally pass it on to the delegate. |
|
16288 this.arg = undefined; |
|
16289 } |
|
16290 |
|
16291 return ContinueSentinel; |
|
16292 } |
|
16293 }; |
|
16294 })( |
|
16295 // In sloppy mode, unbound `this` refers to the global object, fallback to |
|
16296 // Function constructor if we're in global strict mode. That is sadly a form |
|
16297 // of indirect eval which violates Content Security Policy. |
|
16298 (function() { |
|
16299 return this || (typeof self === "object" && self); |
|
16300 })() || Function("return this")() |
|
16301 ); |
|
16302 |
|
16303 |
|
16304 /***/ }), |
|
16305 |
|
16306 /***/ 57: |
|
16307 /***/ (function(module, exports) { |
|
16308 |
|
16309 (function() { module.exports = this["wp"]["htmlEntities"]; }()); |
|
16310 |
|
16311 /***/ }), |
|
16312 |
|
16313 /***/ 59: |
|
16314 /***/ (function(module, exports) { |
|
16315 |
|
16316 var g; |
|
16317 |
|
16318 // This works in non-strict mode |
|
16319 g = (function() { |
|
16320 return this; |
|
16321 })(); |
|
16322 |
|
16323 try { |
|
16324 // This works if eval is allowed (see CSP) |
|
16325 g = g || new Function("return this")(); |
|
16326 } catch (e) { |
|
16327 // This works if the window reference is available |
|
16328 if (typeof window === "object") g = window; |
|
16329 } |
|
16330 |
|
16331 // g can still be undefined, but nothing to do about it... |
|
16332 // We return undefined, instead of nothing here, so it's |
|
16333 // easier to handle this case. if(!global) { ...} |
|
16334 |
|
16335 module.exports = g; |
|
16336 |
|
16337 |
|
16338 /***/ }), |
|
16339 |
|
16340 /***/ 6: |
|
16341 /***/ (function(module, exports) { |
|
16342 |
|
16343 (function() { module.exports = this["wp"]["compose"]; }()); |
|
16344 |
|
16345 /***/ }), |
|
16346 |
|
16347 /***/ 60: |
|
16348 /***/ (function(module, exports) { |
|
16349 |
|
16350 (function() { module.exports = this["wp"]["nux"]; }()); |
|
16351 |
|
16352 /***/ }), |
|
16353 |
|
16354 /***/ 61: |
|
16355 /***/ (function(module, exports, __webpack_require__) { |
|
16356 |
|
16357 "use strict"; |
|
16358 |
|
16359 exports.__esModule = true; |
|
16360 var TextareaAutosize_1 = __webpack_require__(111); |
|
16361 exports["default"] = TextareaAutosize_1["default"]; |
|
16362 |
|
16363 |
|
16364 /***/ }), |
|
16365 |
|
16366 /***/ 62: |
|
16367 /***/ (function(module, exports, __webpack_require__) { |
|
16368 |
|
16369 module.exports = __webpack_require__(341); |
|
16370 |
|
16371 |
|
16372 /***/ }), |
|
16373 |
|
16374 /***/ 66: |
|
16375 /***/ (function(module, exports) { |
|
16376 |
|
16377 (function() { module.exports = this["wp"]["autop"]; }()); |
|
16378 |
|
16379 /***/ }), |
|
16380 |
|
16381 /***/ 7: |
|
16382 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
16383 |
|
16384 "use strict"; |
|
16385 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _objectSpread; }); |
|
16386 /* harmony import */ var _defineProperty__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(15); |
|
16387 |
|
16388 function _objectSpread(target) { |
|
16389 for (var i = 1; i < arguments.length; i++) { |
|
16390 var source = arguments[i] != null ? arguments[i] : {}; |
|
16391 var ownKeys = Object.keys(source); |
|
16392 |
|
16393 if (typeof Object.getOwnPropertySymbols === 'function') { |
|
16394 ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { |
|
16395 return Object.getOwnPropertyDescriptor(source, sym).enumerable; |
|
16396 })); |
|
16397 } |
|
16398 |
|
16399 ownKeys.forEach(function (key) { |
|
16400 Object(_defineProperty__WEBPACK_IMPORTED_MODULE_0__[/* default */ "a"])(target, key, source[key]); |
|
16401 }); |
|
16402 } |
|
16403 |
|
16404 return target; |
|
16405 } |
|
16406 |
|
16407 /***/ }), |
|
16408 |
|
16409 /***/ 70: |
|
16410 /***/ (function(module, exports, __webpack_require__) { |
|
16411 |
|
16412 "use strict"; |
|
16413 |
|
16414 |
|
16415 function flattenIntoMap( map, effects ) { |
|
16416 var i; |
|
16417 if ( Array.isArray( effects ) ) { |
|
16418 for ( i = 0; i < effects.length; i++ ) { |
|
16419 flattenIntoMap( map, effects[ i ] ); |
|
16420 } |
|
16421 } else { |
|
16422 for ( i in effects ) { |
|
16423 map[ i ] = ( map[ i ] || [] ).concat( effects[ i ] ); |
|
16424 } |
|
16425 } |
|
16426 } |
|
16427 |
|
16428 function refx( effects ) { |
|
16429 var map = {}, |
|
16430 middleware; |
|
16431 |
|
16432 flattenIntoMap( map, effects ); |
|
16433 |
|
16434 middleware = function( store ) { |
|
16435 return function( next ) { |
|
16436 return function( action ) { |
|
16437 var handlers = map[ action.type ], |
|
16438 result = next( action ), |
|
16439 i, handlerAction; |
|
16440 |
|
16441 if ( handlers ) { |
|
16442 for ( i = 0; i < handlers.length; i++ ) { |
|
16443 handlerAction = handlers[ i ]( action, store ); |
|
16444 if ( handlerAction ) { |
|
16445 store.dispatch( handlerAction ); |
|
16446 } |
|
16447 } |
|
16448 } |
|
16449 |
|
16450 return result; |
|
16451 }; |
|
16452 }; |
|
16453 }; |
|
16454 |
|
16455 middleware.effects = map; |
|
16456 |
|
16457 return middleware; |
|
16458 } |
|
16459 |
|
16460 module.exports = refx; |
|
16461 |
|
16462 |
|
16463 /***/ }), |
|
16464 |
|
16465 /***/ 72: |
|
16466 /***/ (function(module, exports) { |
|
16467 |
|
16468 (function() { module.exports = this["wp"]["coreData"]; }()); |
|
16469 |
|
16470 /***/ }), |
|
16471 |
|
16472 /***/ 8: |
|
16473 /***/ (function(module, exports) { |
|
16474 |
|
16475 (function() { module.exports = this["wp"]["blockEditor"]; }()); |
|
16476 |
|
16477 /***/ }), |
|
16478 |
|
16479 /***/ 84: |
|
16480 /***/ (function(module, exports, __webpack_require__) { |
|
16481 |
|
16482 "use strict"; |
|
16483 // Copyright Joyent, Inc. and other Node contributors. |
|
16484 // |
|
16485 // Permission is hereby granted, free of charge, to any person obtaining a |
|
16486 // copy of this software and associated documentation files (the |
|
16487 // "Software"), to deal in the Software without restriction, including |
|
16488 // without limitation the rights to use, copy, modify, merge, publish, |
|
16489 // distribute, sublicense, and/or sell copies of the Software, and to permit |
|
16490 // persons to whom the Software is furnished to do so, subject to the |
|
16491 // following conditions: |
|
16492 // |
|
16493 // The above copyright notice and this permission notice shall be included |
|
16494 // in all copies or substantial portions of the Software. |
|
16495 // |
|
16496 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS |
|
16497 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
16498 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN |
|
16499 // NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
|
16500 // DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
|
16501 // OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE |
|
16502 // USE OR OTHER DEALINGS IN THE SOFTWARE. |
|
16503 |
|
16504 |
|
16505 |
|
16506 var punycode = __webpack_require__(117); |
|
16507 var util = __webpack_require__(119); |
|
16508 |
|
16509 exports.parse = urlParse; |
|
16510 exports.resolve = urlResolve; |
|
16511 exports.resolveObject = urlResolveObject; |
|
16512 exports.format = urlFormat; |
|
16513 |
|
16514 exports.Url = Url; |
|
16515 |
|
16516 function Url() { |
|
16517 this.protocol = null; |
|
16518 this.slashes = null; |
|
16519 this.auth = null; |
|
16520 this.host = null; |
|
16521 this.port = null; |
|
16522 this.hostname = null; |
|
16523 this.hash = null; |
|
16524 this.search = null; |
|
16525 this.query = null; |
|
16526 this.pathname = null; |
|
16527 this.path = null; |
|
16528 this.href = null; |
|
16529 } |
|
16530 |
|
16531 // Reference: RFC 3986, RFC 1808, RFC 2396 |
|
16532 |
|
16533 // define these here so at least they only have to be |
|
16534 // compiled once on the first module load. |
|
16535 var protocolPattern = /^([a-z0-9.+-]+:)/i, |
|
16536 portPattern = /:[0-9]*$/, |
|
16537 |
|
16538 // Special case for a simple path URL |
|
16539 simplePathPattern = /^(\/\/?(?!\/)[^\?\s]*)(\?[^\s]*)?$/, |
|
16540 |
|
16541 // RFC 2396: characters reserved for delimiting URLs. |
|
16542 // We actually just auto-escape these. |
|
16543 delims = ['<', '>', '"', '`', ' ', '\r', '\n', '\t'], |
|
16544 |
|
16545 // RFC 2396: characters not allowed for various reasons. |
|
16546 unwise = ['{', '}', '|', '\\', '^', '`'].concat(delims), |
|
16547 |
|
16548 // Allowed by RFCs, but cause of XSS attacks. Always escape these. |
|
16549 autoEscape = ['\''].concat(unwise), |
|
16550 // Characters that are never ever allowed in a hostname. |
|
16551 // Note that any invalid chars are also handled, but these |
|
16552 // are the ones that are *expected* to be seen, so we fast-path |
|
16553 // them. |
|
16554 nonHostChars = ['%', '/', '?', ';', '#'].concat(autoEscape), |
|
16555 hostEndingChars = ['/', '?', '#'], |
|
16556 hostnameMaxLen = 255, |
|
16557 hostnamePartPattern = /^[+a-z0-9A-Z_-]{0,63}$/, |
|
16558 hostnamePartStart = /^([+a-z0-9A-Z_-]{0,63})(.*)$/, |
|
16559 // protocols that can allow "unsafe" and "unwise" chars. |
|
16560 unsafeProtocol = { |
|
16561 'javascript': true, |
|
16562 'javascript:': true |
|
16563 }, |
|
16564 // protocols that never have a hostname. |
|
16565 hostlessProtocol = { |
|
16566 'javascript': true, |
|
16567 'javascript:': true |
|
16568 }, |
|
16569 // protocols that always contain a // bit. |
|
16570 slashedProtocol = { |
|
16571 'http': true, |
|
16572 'https': true, |
|
16573 'ftp': true, |
|
16574 'gopher': true, |
|
16575 'file': true, |
|
16576 'http:': true, |
|
16577 'https:': true, |
|
16578 'ftp:': true, |
|
16579 'gopher:': true, |
|
16580 'file:': true |
|
16581 }, |
|
16582 querystring = __webpack_require__(120); |
|
16583 |
|
16584 function urlParse(url, parseQueryString, slashesDenoteHost) { |
|
16585 if (url && util.isObject(url) && url instanceof Url) return url; |
|
16586 |
|
16587 var u = new Url; |
|
16588 u.parse(url, parseQueryString, slashesDenoteHost); |
|
16589 return u; |
|
16590 } |
|
16591 |
|
16592 Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) { |
|
16593 if (!util.isString(url)) { |
|
16594 throw new TypeError("Parameter 'url' must be a string, not " + typeof url); |
|
16595 } |
|
16596 |
|
16597 // Copy chrome, IE, opera backslash-handling behavior. |
|
16598 // Back slashes before the query string get converted to forward slashes |
|
16599 // See: https://code.google.com/p/chromium/issues/detail?id=25916 |
|
16600 var queryIndex = url.indexOf('?'), |
|
16601 splitter = |
|
16602 (queryIndex !== -1 && queryIndex < url.indexOf('#')) ? '?' : '#', |
|
16603 uSplit = url.split(splitter), |
|
16604 slashRegex = /\\/g; |
|
16605 uSplit[0] = uSplit[0].replace(slashRegex, '/'); |
|
16606 url = uSplit.join(splitter); |
|
16607 |
|
16608 var rest = url; |
|
16609 |
|
16610 // trim before proceeding. |
|
16611 // This is to support parse stuff like " http://foo.com \n" |
|
16612 rest = rest.trim(); |
|
16613 |
|
16614 if (!slashesDenoteHost && url.split('#').length === 1) { |
|
16615 // Try fast path regexp |
|
16616 var simplePath = simplePathPattern.exec(rest); |
|
16617 if (simplePath) { |
|
16618 this.path = rest; |
|
16619 this.href = rest; |
|
16620 this.pathname = simplePath[1]; |
|
16621 if (simplePath[2]) { |
|
16622 this.search = simplePath[2]; |
|
16623 if (parseQueryString) { |
|
16624 this.query = querystring.parse(this.search.substr(1)); |
|
16625 } else { |
|
16626 this.query = this.search.substr(1); |
|
16627 } |
|
16628 } else if (parseQueryString) { |
|
16629 this.search = ''; |
|
16630 this.query = {}; |
|
16631 } |
|
16632 return this; |
|
16633 } |
|
16634 } |
|
16635 |
|
16636 var proto = protocolPattern.exec(rest); |
|
16637 if (proto) { |
|
16638 proto = proto[0]; |
|
16639 var lowerProto = proto.toLowerCase(); |
|
16640 this.protocol = lowerProto; |
|
16641 rest = rest.substr(proto.length); |
|
16642 } |
|
16643 |
|
16644 // figure out if it's got a host |
|
16645 // user@server is *always* interpreted as a hostname, and url |
|
16646 // resolution will treat //foo/bar as host=foo,path=bar because that's |
|
16647 // how the browser resolves relative URLs. |
|
16648 if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) { |
|
16649 var slashes = rest.substr(0, 2) === '//'; |
|
16650 if (slashes && !(proto && hostlessProtocol[proto])) { |
|
16651 rest = rest.substr(2); |
|
16652 this.slashes = true; |
|
16653 } |
|
16654 } |
|
16655 |
|
16656 if (!hostlessProtocol[proto] && |
|
16657 (slashes || (proto && !slashedProtocol[proto]))) { |
|
16658 |
|
16659 // there's a hostname. |
|
16660 // the first instance of /, ?, ;, or # ends the host. |
|
16661 // |
|
16662 // If there is an @ in the hostname, then non-host chars *are* allowed |
|
16663 // to the left of the last @ sign, unless some host-ending character |
|
16664 // comes *before* the @-sign. |
|
16665 // URLs are obnoxious. |
|
16666 // |
|
16667 // ex: |
|
16668 // http://a@b@c/ => user:a@b host:c |
|
16669 // http://a@b?@c => user:a host:c path:/?@c |
|
16670 |
|
16671 // v0.12 TODO(isaacs): This is not quite how Chrome does things. |
|
16672 // Review our test case against browsers more comprehensively. |
|
16673 |
|
16674 // find the first instance of any hostEndingChars |
|
16675 var hostEnd = -1; |
|
16676 for (var i = 0; i < hostEndingChars.length; i++) { |
|
16677 var hec = rest.indexOf(hostEndingChars[i]); |
|
16678 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) |
|
16679 hostEnd = hec; |
|
16680 } |
|
16681 |
|
16682 // at this point, either we have an explicit point where the |
|
16683 // auth portion cannot go past, or the last @ char is the decider. |
|
16684 var auth, atSign; |
|
16685 if (hostEnd === -1) { |
|
16686 // atSign can be anywhere. |
|
16687 atSign = rest.lastIndexOf('@'); |
|
16688 } else { |
|
16689 // atSign must be in auth portion. |
|
16690 // http://a@b/c@d => host:b auth:a path:/c@d |
|
16691 atSign = rest.lastIndexOf('@', hostEnd); |
|
16692 } |
|
16693 |
|
16694 // Now we have a portion which is definitely the auth. |
|
16695 // Pull that off. |
|
16696 if (atSign !== -1) { |
|
16697 auth = rest.slice(0, atSign); |
|
16698 rest = rest.slice(atSign + 1); |
|
16699 this.auth = decodeURIComponent(auth); |
|
16700 } |
|
16701 |
|
16702 // the host is the remaining to the left of the first non-host char |
|
16703 hostEnd = -1; |
|
16704 for (var i = 0; i < nonHostChars.length; i++) { |
|
16705 var hec = rest.indexOf(nonHostChars[i]); |
|
16706 if (hec !== -1 && (hostEnd === -1 || hec < hostEnd)) |
|
16707 hostEnd = hec; |
|
16708 } |
|
16709 // if we still have not hit it, then the entire thing is a host. |
|
16710 if (hostEnd === -1) |
|
16711 hostEnd = rest.length; |
|
16712 |
|
16713 this.host = rest.slice(0, hostEnd); |
|
16714 rest = rest.slice(hostEnd); |
|
16715 |
|
16716 // pull out port. |
|
16717 this.parseHost(); |
|
16718 |
|
16719 // we've indicated that there is a hostname, |
|
16720 // so even if it's empty, it has to be present. |
|
16721 this.hostname = this.hostname || ''; |
|
16722 |
|
16723 // if hostname begins with [ and ends with ] |
|
16724 // assume that it's an IPv6 address. |
|
16725 var ipv6Hostname = this.hostname[0] === '[' && |
|
16726 this.hostname[this.hostname.length - 1] === ']'; |
|
16727 |
|
16728 // validate a little. |
|
16729 if (!ipv6Hostname) { |
|
16730 var hostparts = this.hostname.split(/\./); |
|
16731 for (var i = 0, l = hostparts.length; i < l; i++) { |
|
16732 var part = hostparts[i]; |
|
16733 if (!part) continue; |
|
16734 if (!part.match(hostnamePartPattern)) { |
|
16735 var newpart = ''; |
|
16736 for (var j = 0, k = part.length; j < k; j++) { |
|
16737 if (part.charCodeAt(j) > 127) { |
|
16738 // we replace non-ASCII char with a temporary placeholder |
|
16739 // we need this to make sure size of hostname is not |
|
16740 // broken by replacing non-ASCII by nothing |
|
16741 newpart += 'x'; |
|
16742 } else { |
|
16743 newpart += part[j]; |
|
16744 } |
|
16745 } |
|
16746 // we test again with ASCII char only |
|
16747 if (!newpart.match(hostnamePartPattern)) { |
|
16748 var validParts = hostparts.slice(0, i); |
|
16749 var notHost = hostparts.slice(i + 1); |
|
16750 var bit = part.match(hostnamePartStart); |
|
16751 if (bit) { |
|
16752 validParts.push(bit[1]); |
|
16753 notHost.unshift(bit[2]); |
|
16754 } |
|
16755 if (notHost.length) { |
|
16756 rest = '/' + notHost.join('.') + rest; |
|
16757 } |
|
16758 this.hostname = validParts.join('.'); |
|
16759 break; |
|
16760 } |
|
16761 } |
|
16762 } |
|
16763 } |
|
16764 |
|
16765 if (this.hostname.length > hostnameMaxLen) { |
|
16766 this.hostname = ''; |
|
16767 } else { |
|
16768 // hostnames are always lower case. |
|
16769 this.hostname = this.hostname.toLowerCase(); |
|
16770 } |
|
16771 |
|
16772 if (!ipv6Hostname) { |
|
16773 // IDNA Support: Returns a punycoded representation of "domain". |
|
16774 // It only converts parts of the domain name that |
|
16775 // have non-ASCII characters, i.e. it doesn't matter if |
|
16776 // you call it with a domain that already is ASCII-only. |
|
16777 this.hostname = punycode.toASCII(this.hostname); |
|
16778 } |
|
16779 |
|
16780 var p = this.port ? ':' + this.port : ''; |
|
16781 var h = this.hostname || ''; |
|
16782 this.host = h + p; |
|
16783 this.href += this.host; |
|
16784 |
|
16785 // strip [ and ] from the hostname |
|
16786 // the host field still retains them, though |
|
16787 if (ipv6Hostname) { |
|
16788 this.hostname = this.hostname.substr(1, this.hostname.length - 2); |
|
16789 if (rest[0] !== '/') { |
|
16790 rest = '/' + rest; |
|
16791 } |
|
16792 } |
|
16793 } |
|
16794 |
|
16795 // now rest is set to the post-host stuff. |
|
16796 // chop off any delim chars. |
|
16797 if (!unsafeProtocol[lowerProto]) { |
|
16798 |
|
16799 // First, make 100% sure that any "autoEscape" chars get |
|
16800 // escaped, even if encodeURIComponent doesn't think they |
|
16801 // need to be. |
|
16802 for (var i = 0, l = autoEscape.length; i < l; i++) { |
|
16803 var ae = autoEscape[i]; |
|
16804 if (rest.indexOf(ae) === -1) |
|
16805 continue; |
|
16806 var esc = encodeURIComponent(ae); |
|
16807 if (esc === ae) { |
|
16808 esc = escape(ae); |
|
16809 } |
|
16810 rest = rest.split(ae).join(esc); |
|
16811 } |
|
16812 } |
|
16813 |
|
16814 |
|
16815 // chop off from the tail first. |
|
16816 var hash = rest.indexOf('#'); |
|
16817 if (hash !== -1) { |
|
16818 // got a fragment string. |
|
16819 this.hash = rest.substr(hash); |
|
16820 rest = rest.slice(0, hash); |
|
16821 } |
|
16822 var qm = rest.indexOf('?'); |
|
16823 if (qm !== -1) { |
|
16824 this.search = rest.substr(qm); |
|
16825 this.query = rest.substr(qm + 1); |
|
16826 if (parseQueryString) { |
|
16827 this.query = querystring.parse(this.query); |
|
16828 } |
|
16829 rest = rest.slice(0, qm); |
|
16830 } else if (parseQueryString) { |
|
16831 // no query string, but parseQueryString still requested |
|
16832 this.search = ''; |
|
16833 this.query = {}; |
|
16834 } |
|
16835 if (rest) this.pathname = rest; |
|
16836 if (slashedProtocol[lowerProto] && |
|
16837 this.hostname && !this.pathname) { |
|
16838 this.pathname = '/'; |
|
16839 } |
|
16840 |
|
16841 //to support http.request |
|
16842 if (this.pathname || this.search) { |
|
16843 var p = this.pathname || ''; |
|
16844 var s = this.search || ''; |
|
16845 this.path = p + s; |
|
16846 } |
|
16847 |
|
16848 // finally, reconstruct the href based on what has been validated. |
|
16849 this.href = this.format(); |
|
16850 return this; |
|
16851 }; |
|
16852 |
|
16853 // format a parsed object into a url string |
|
16854 function urlFormat(obj) { |
|
16855 // ensure it's an object, and not a string url. |
|
16856 // If it's an obj, this is a no-op. |
|
16857 // this way, you can call url_format() on strings |
|
16858 // to clean up potentially wonky urls. |
|
16859 if (util.isString(obj)) obj = urlParse(obj); |
|
16860 if (!(obj instanceof Url)) return Url.prototype.format.call(obj); |
|
16861 return obj.format(); |
|
16862 } |
|
16863 |
|
16864 Url.prototype.format = function() { |
|
16865 var auth = this.auth || ''; |
|
16866 if (auth) { |
|
16867 auth = encodeURIComponent(auth); |
|
16868 auth = auth.replace(/%3A/i, ':'); |
|
16869 auth += '@'; |
|
16870 } |
|
16871 |
|
16872 var protocol = this.protocol || '', |
|
16873 pathname = this.pathname || '', |
|
16874 hash = this.hash || '', |
|
16875 host = false, |
|
16876 query = ''; |
|
16877 |
|
16878 if (this.host) { |
|
16879 host = auth + this.host; |
|
16880 } else if (this.hostname) { |
|
16881 host = auth + (this.hostname.indexOf(':') === -1 ? |
|
16882 this.hostname : |
|
16883 '[' + this.hostname + ']'); |
|
16884 if (this.port) { |
|
16885 host += ':' + this.port; |
|
16886 } |
|
16887 } |
|
16888 |
|
16889 if (this.query && |
|
16890 util.isObject(this.query) && |
|
16891 Object.keys(this.query).length) { |
|
16892 query = querystring.stringify(this.query); |
|
16893 } |
|
16894 |
|
16895 var search = this.search || (query && ('?' + query)) || ''; |
|
16896 |
|
16897 if (protocol && protocol.substr(-1) !== ':') protocol += ':'; |
|
16898 |
|
16899 // only the slashedProtocols get the //. Not mailto:, xmpp:, etc. |
|
16900 // unless they had them to begin with. |
|
16901 if (this.slashes || |
|
16902 (!protocol || slashedProtocol[protocol]) && host !== false) { |
|
16903 host = '//' + (host || ''); |
|
16904 if (pathname && pathname.charAt(0) !== '/') pathname = '/' + pathname; |
|
16905 } else if (!host) { |
|
16906 host = ''; |
|
16907 } |
|
16908 |
|
16909 if (hash && hash.charAt(0) !== '#') hash = '#' + hash; |
|
16910 if (search && search.charAt(0) !== '?') search = '?' + search; |
|
16911 |
|
16912 pathname = pathname.replace(/[?#]/g, function(match) { |
|
16913 return encodeURIComponent(match); |
|
16914 }); |
|
16915 search = search.replace('#', '%23'); |
|
16916 |
|
16917 return protocol + host + pathname + search + hash; |
|
16918 }; |
|
16919 |
|
16920 function urlResolve(source, relative) { |
|
16921 return urlParse(source, false, true).resolve(relative); |
|
16922 } |
|
16923 |
|
16924 Url.prototype.resolve = function(relative) { |
|
16925 return this.resolveObject(urlParse(relative, false, true)).format(); |
|
16926 }; |
|
16927 |
|
16928 function urlResolveObject(source, relative) { |
|
16929 if (!source) return relative; |
|
16930 return urlParse(source, false, true).resolveObject(relative); |
|
16931 } |
|
16932 |
|
16933 Url.prototype.resolveObject = function(relative) { |
|
16934 if (util.isString(relative)) { |
|
16935 var rel = new Url(); |
|
16936 rel.parse(relative, false, true); |
|
16937 relative = rel; |
|
16938 } |
|
16939 |
|
16940 var result = new Url(); |
|
16941 var tkeys = Object.keys(this); |
|
16942 for (var tk = 0; tk < tkeys.length; tk++) { |
|
16943 var tkey = tkeys[tk]; |
|
16944 result[tkey] = this[tkey]; |
|
16945 } |
|
16946 |
|
16947 // hash is always overridden, no matter what. |
|
16948 // even href="" will remove it. |
|
16949 result.hash = relative.hash; |
|
16950 |
|
16951 // if the relative url is empty, then there's nothing left to do here. |
|
16952 if (relative.href === '') { |
|
16953 result.href = result.format(); |
|
16954 return result; |
|
16955 } |
|
16956 |
|
16957 // hrefs like //foo/bar always cut to the protocol. |
|
16958 if (relative.slashes && !relative.protocol) { |
|
16959 // take everything except the protocol from relative |
|
16960 var rkeys = Object.keys(relative); |
|
16961 for (var rk = 0; rk < rkeys.length; rk++) { |
|
16962 var rkey = rkeys[rk]; |
|
16963 if (rkey !== 'protocol') |
|
16964 result[rkey] = relative[rkey]; |
|
16965 } |
|
16966 |
|
16967 //urlParse appends trailing / to urls like http://www.example.com |
|
16968 if (slashedProtocol[result.protocol] && |
|
16969 result.hostname && !result.pathname) { |
|
16970 result.path = result.pathname = '/'; |
|
16971 } |
|
16972 |
|
16973 result.href = result.format(); |
|
16974 return result; |
|
16975 } |
|
16976 |
|
16977 if (relative.protocol && relative.protocol !== result.protocol) { |
|
16978 // if it's a known url protocol, then changing |
|
16979 // the protocol does weird things |
|
16980 // first, if it's not file:, then we MUST have a host, |
|
16981 // and if there was a path |
|
16982 // to begin with, then we MUST have a path. |
|
16983 // if it is file:, then the host is dropped, |
|
16984 // because that's known to be hostless. |
|
16985 // anything else is assumed to be absolute. |
|
16986 if (!slashedProtocol[relative.protocol]) { |
|
16987 var keys = Object.keys(relative); |
|
16988 for (var v = 0; v < keys.length; v++) { |
|
16989 var k = keys[v]; |
|
16990 result[k] = relative[k]; |
|
16991 } |
|
16992 result.href = result.format(); |
|
16993 return result; |
|
16994 } |
|
16995 |
|
16996 result.protocol = relative.protocol; |
|
16997 if (!relative.host && !hostlessProtocol[relative.protocol]) { |
|
16998 var relPath = (relative.pathname || '').split('/'); |
|
16999 while (relPath.length && !(relative.host = relPath.shift())); |
|
17000 if (!relative.host) relative.host = ''; |
|
17001 if (!relative.hostname) relative.hostname = ''; |
|
17002 if (relPath[0] !== '') relPath.unshift(''); |
|
17003 if (relPath.length < 2) relPath.unshift(''); |
|
17004 result.pathname = relPath.join('/'); |
|
17005 } else { |
|
17006 result.pathname = relative.pathname; |
|
17007 } |
|
17008 result.search = relative.search; |
|
17009 result.query = relative.query; |
|
17010 result.host = relative.host || ''; |
|
17011 result.auth = relative.auth; |
|
17012 result.hostname = relative.hostname || relative.host; |
|
17013 result.port = relative.port; |
|
17014 // to support http.request |
|
17015 if (result.pathname || result.search) { |
|
17016 var p = result.pathname || ''; |
|
17017 var s = result.search || ''; |
|
17018 result.path = p + s; |
|
17019 } |
|
17020 result.slashes = result.slashes || relative.slashes; |
|
17021 result.href = result.format(); |
|
17022 return result; |
|
17023 } |
|
17024 |
|
17025 var isSourceAbs = (result.pathname && result.pathname.charAt(0) === '/'), |
|
17026 isRelAbs = ( |
|
17027 relative.host || |
|
17028 relative.pathname && relative.pathname.charAt(0) === '/' |
|
17029 ), |
|
17030 mustEndAbs = (isRelAbs || isSourceAbs || |
|
17031 (result.host && relative.pathname)), |
|
17032 removeAllDots = mustEndAbs, |
|
17033 srcPath = result.pathname && result.pathname.split('/') || [], |
|
17034 relPath = relative.pathname && relative.pathname.split('/') || [], |
|
17035 psychotic = result.protocol && !slashedProtocol[result.protocol]; |
|
17036 |
|
17037 // if the url is a non-slashed url, then relative |
|
17038 // links like ../.. should be able |
|
17039 // to crawl up to the hostname, as well. This is strange. |
|
17040 // result.protocol has already been set by now. |
|
17041 // Later on, put the first path part into the host field. |
|
17042 if (psychotic) { |
|
17043 result.hostname = ''; |
|
17044 result.port = null; |
|
17045 if (result.host) { |
|
17046 if (srcPath[0] === '') srcPath[0] = result.host; |
|
17047 else srcPath.unshift(result.host); |
|
17048 } |
|
17049 result.host = ''; |
|
17050 if (relative.protocol) { |
|
17051 relative.hostname = null; |
|
17052 relative.port = null; |
|
17053 if (relative.host) { |
|
17054 if (relPath[0] === '') relPath[0] = relative.host; |
|
17055 else relPath.unshift(relative.host); |
|
17056 } |
|
17057 relative.host = null; |
|
17058 } |
|
17059 mustEndAbs = mustEndAbs && (relPath[0] === '' || srcPath[0] === ''); |
|
17060 } |
|
17061 |
|
17062 if (isRelAbs) { |
|
17063 // it's absolute. |
|
17064 result.host = (relative.host || relative.host === '') ? |
|
17065 relative.host : result.host; |
|
17066 result.hostname = (relative.hostname || relative.hostname === '') ? |
|
17067 relative.hostname : result.hostname; |
|
17068 result.search = relative.search; |
|
17069 result.query = relative.query; |
|
17070 srcPath = relPath; |
|
17071 // fall through to the dot-handling below. |
|
17072 } else if (relPath.length) { |
|
17073 // it's relative |
|
17074 // throw away the existing file, and take the new path instead. |
|
17075 if (!srcPath) srcPath = []; |
|
17076 srcPath.pop(); |
|
17077 srcPath = srcPath.concat(relPath); |
|
17078 result.search = relative.search; |
|
17079 result.query = relative.query; |
|
17080 } else if (!util.isNullOrUndefined(relative.search)) { |
|
17081 // just pull out the search. |
|
17082 // like href='?foo'. |
|
17083 // Put this after the other two cases because it simplifies the booleans |
|
17084 if (psychotic) { |
|
17085 result.hostname = result.host = srcPath.shift(); |
|
17086 //occationaly the auth can get stuck only in host |
|
17087 //this especially happens in cases like |
|
17088 //url.resolveObject('mailto:local1@domain1', 'local2@domain2') |
|
17089 var authInHost = result.host && result.host.indexOf('@') > 0 ? |
|
17090 result.host.split('@') : false; |
|
17091 if (authInHost) { |
|
17092 result.auth = authInHost.shift(); |
|
17093 result.host = result.hostname = authInHost.shift(); |
|
17094 } |
|
17095 } |
|
17096 result.search = relative.search; |
|
17097 result.query = relative.query; |
|
17098 //to support http.request |
|
17099 if (!util.isNull(result.pathname) || !util.isNull(result.search)) { |
|
17100 result.path = (result.pathname ? result.pathname : '') + |
|
17101 (result.search ? result.search : ''); |
|
17102 } |
|
17103 result.href = result.format(); |
|
17104 return result; |
|
17105 } |
|
17106 |
|
17107 if (!srcPath.length) { |
|
17108 // no path at all. easy. |
|
17109 // we've already handled the other stuff above. |
|
17110 result.pathname = null; |
|
17111 //to support http.request |
|
17112 if (result.search) { |
|
17113 result.path = '/' + result.search; |
|
17114 } else { |
|
17115 result.path = null; |
|
17116 } |
|
17117 result.href = result.format(); |
|
17118 return result; |
|
17119 } |
|
17120 |
|
17121 // if a url ENDs in . or .., then it must get a trailing slash. |
|
17122 // however, if it ends in anything else non-slashy, |
|
17123 // then it must NOT get a trailing slash. |
|
17124 var last = srcPath.slice(-1)[0]; |
|
17125 var hasTrailingSlash = ( |
|
17126 (result.host || relative.host || srcPath.length > 1) && |
|
17127 (last === '.' || last === '..') || last === ''); |
|
17128 |
|
17129 // strip single dots, resolve double dots to parent dir |
|
17130 // if the path tries to go above the root, `up` ends up > 0 |
|
17131 var up = 0; |
|
17132 for (var i = srcPath.length; i >= 0; i--) { |
|
17133 last = srcPath[i]; |
|
17134 if (last === '.') { |
|
17135 srcPath.splice(i, 1); |
|
17136 } else if (last === '..') { |
|
17137 srcPath.splice(i, 1); |
|
17138 up++; |
|
17139 } else if (up) { |
|
17140 srcPath.splice(i, 1); |
|
17141 up--; |
|
17142 } |
|
17143 } |
|
17144 |
|
17145 // if the path is allowed to go above the root, restore leading ..s |
|
17146 if (!mustEndAbs && !removeAllDots) { |
|
17147 for (; up--; up) { |
|
17148 srcPath.unshift('..'); |
|
17149 } |
|
17150 } |
|
17151 |
|
17152 if (mustEndAbs && srcPath[0] !== '' && |
|
17153 (!srcPath[0] || srcPath[0].charAt(0) !== '/')) { |
|
17154 srcPath.unshift(''); |
|
17155 } |
|
17156 |
|
17157 if (hasTrailingSlash && (srcPath.join('/').substr(-1) !== '/')) { |
|
17158 srcPath.push(''); |
|
17159 } |
|
17160 |
|
17161 var isAbsolute = srcPath[0] === '' || |
|
17162 (srcPath[0] && srcPath[0].charAt(0) === '/'); |
|
17163 |
|
17164 // put the host back |
|
17165 if (psychotic) { |
|
17166 result.hostname = result.host = isAbsolute ? '' : |
|
17167 srcPath.length ? srcPath.shift() : ''; |
|
17168 //occationaly the auth can get stuck only in host |
|
17169 //this especially happens in cases like |
|
17170 //url.resolveObject('mailto:local1@domain1', 'local2@domain2') |
|
17171 var authInHost = result.host && result.host.indexOf('@') > 0 ? |
|
17172 result.host.split('@') : false; |
|
17173 if (authInHost) { |
|
17174 result.auth = authInHost.shift(); |
|
17175 result.host = result.hostname = authInHost.shift(); |
|
17176 } |
|
17177 } |
|
17178 |
|
17179 mustEndAbs = mustEndAbs || (result.host && srcPath.length); |
|
17180 |
|
17181 if (mustEndAbs && !isAbsolute) { |
|
17182 srcPath.unshift(''); |
|
17183 } |
|
17184 |
|
17185 if (!srcPath.length) { |
|
17186 result.pathname = null; |
|
17187 result.path = null; |
|
17188 } else { |
|
17189 result.pathname = srcPath.join('/'); |
|
17190 } |
|
17191 |
|
17192 //to support request.http |
|
17193 if (!util.isNull(result.pathname) || !util.isNull(result.search)) { |
|
17194 result.path = (result.pathname ? result.pathname : '') + |
|
17195 (result.search ? result.search : ''); |
|
17196 } |
|
17197 result.auth = relative.auth || result.auth; |
|
17198 result.slashes = result.slashes || relative.slashes; |
|
17199 result.href = result.format(); |
|
17200 return result; |
|
17201 }; |
|
17202 |
|
17203 Url.prototype.parseHost = function() { |
|
17204 var host = this.host; |
|
17205 var port = portPattern.exec(host); |
|
17206 if (port) { |
|
17207 port = port[0]; |
|
17208 if (port !== ':') { |
|
17209 this.port = port.substr(1); |
|
17210 } |
|
17211 host = host.substr(0, host.length - port.length); |
|
17212 } |
|
17213 if (host) this.hostname = host; |
|
17214 }; |
|
17215 |
|
17216 |
|
17217 /***/ }), |
|
17218 |
|
17219 /***/ 89: |
|
17220 /***/ (function(module, exports, __webpack_require__) { |
|
17221 |
|
17222 "use strict"; |
|
17223 /** |
|
17224 * Copyright (c) 2013-present, Facebook, Inc. |
|
17225 * |
|
17226 * This source code is licensed under the MIT license found in the |
|
17227 * LICENSE file in the root directory of this source tree. |
|
17228 */ |
|
17229 |
|
17230 |
|
17231 |
|
17232 var ReactPropTypesSecret = __webpack_require__(90); |
|
17233 |
|
17234 function emptyFunction() {} |
|
17235 |
|
17236 module.exports = function() { |
|
17237 function shim(props, propName, componentName, location, propFullName, secret) { |
|
17238 if (secret === ReactPropTypesSecret) { |
|
17239 // It is still safe when called from React. |
|
17240 return; |
|
17241 } |
|
17242 var err = new Error( |
|
17243 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' + |
|
17244 'Use PropTypes.checkPropTypes() to call them. ' + |
|
17245 'Read more at http://fb.me/use-check-prop-types' |
|
17246 ); |
|
17247 err.name = 'Invariant Violation'; |
|
17248 throw err; |
|
17249 }; |
|
17250 shim.isRequired = shim; |
|
17251 function getShim() { |
|
17252 return shim; |
|
17253 }; |
|
17254 // Important! |
|
17255 // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`. |
|
17256 var ReactPropTypes = { |
|
17257 array: shim, |
|
17258 bool: shim, |
|
17259 func: shim, |
|
17260 number: shim, |
|
17261 object: shim, |
|
17262 string: shim, |
|
17263 symbol: shim, |
|
17264 |
|
17265 any: shim, |
|
17266 arrayOf: getShim, |
|
17267 element: shim, |
|
17268 instanceOf: getShim, |
|
17269 node: shim, |
|
17270 objectOf: getShim, |
|
17271 oneOf: getShim, |
|
17272 oneOfType: getShim, |
|
17273 shape: getShim, |
|
17274 exact: getShim |
|
17275 }; |
|
17276 |
|
17277 ReactPropTypes.checkPropTypes = emptyFunction; |
|
17278 ReactPropTypes.PropTypes = ReactPropTypes; |
|
17279 |
|
17280 return ReactPropTypes; |
|
17281 }; |
|
17282 |
|
17283 |
|
17284 /***/ }), |
|
17285 |
|
17286 /***/ 9: |
|
17287 /***/ (function(module, __webpack_exports__, __webpack_require__) { |
|
17288 |
|
17289 "use strict"; |
|
17290 /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return _createClass; }); |
|
17291 function _defineProperties(target, props) { |
|
17292 for (var i = 0; i < props.length; i++) { |
|
17293 var descriptor = props[i]; |
|
17294 descriptor.enumerable = descriptor.enumerable || false; |
|
17295 descriptor.configurable = true; |
|
17296 if ("value" in descriptor) descriptor.writable = true; |
|
17297 Object.defineProperty(target, descriptor.key, descriptor); |
|
17298 } |
|
17299 } |
|
17300 |
|
17301 function _createClass(Constructor, protoProps, staticProps) { |
|
17302 if (protoProps) _defineProperties(Constructor.prototype, protoProps); |
|
17303 if (staticProps) _defineProperties(Constructor, staticProps); |
|
17304 return Constructor; |
|
17305 } |
|
17306 |
|
17307 /***/ }), |
|
17308 |
|
17309 /***/ 90: |
|
17310 /***/ (function(module, exports, __webpack_require__) { |
|
17311 |
|
17312 "use strict"; |
|
17313 /** |
|
17314 * Copyright (c) 2013-present, Facebook, Inc. |
|
17315 * |
|
17316 * This source code is licensed under the MIT license found in the |
|
17317 * LICENSE file in the root directory of this source tree. |
|
17318 */ |
|
17319 |
|
17320 |
|
17321 |
|
17322 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED'; |
|
17323 |
|
17324 module.exports = ReactPropTypesSecret; |
|
17325 |
|
17326 |
|
17327 /***/ }), |
|
17328 |
|
17329 /***/ 97: |
|
17330 /***/ (function(module, exports, __webpack_require__) { |
|
17331 |
|
17332 "use strict"; |
|
17333 |
|
17334 |
|
17335 Object.defineProperty(exports, "__esModule", { |
|
17336 value: true |
|
17337 }); |
|
17338 /** |
|
17339 * Redux dispatch multiple actions |
|
17340 */ |
|
17341 |
|
17342 function multi(_ref) { |
|
17343 var dispatch = _ref.dispatch; |
|
17344 |
|
17345 return function (next) { |
|
17346 return function (action) { |
|
17347 return Array.isArray(action) ? action.filter(Boolean).map(dispatch) : next(action); |
|
17348 }; |
|
17349 }; |
|
17350 } |
|
17351 |
|
17352 /** |
|
17353 * Exports |
|
17354 */ |
|
17355 |
|
17356 exports.default = multi; |
|
17357 |
|
17358 /***/ }), |
|
17359 |
|
17360 /***/ 98: |
|
17361 /***/ (function(module, exports) { |
|
17362 |
|
17363 (function() { module.exports = this["wp"]["wordcount"]; }()); |
|
17364 |
|
17365 /***/ }) |
|
17366 |
|
17367 /******/ }); |