PluginProbe
Gutenberg / 13.5.1
Gutenberg v13.5.1
24.0.0 23.9.1 23.9.0 23.8.0 23.7.2 23.7.1 23.7.0 23.6.1 23.6.2 23.6.0 23.5.3 23.5.2 23.5.1 23.5.0 23.4.0 23.3.2 23.3.1 23.3.0 23.2.0 23.2.1 23.2.2 23.1.1 23.1.0 23.0.1 12.6.0 All 403 releases
gutenberg / build / editor / index.js

index.js in Gutenberg 13.5.1, at build/editor/index.js

11,912 lines 374.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 /******/ (() => { // webpackBootstrap
2 /******/ var __webpack_modules__ = ({
3
4 /***/ 6411:
5 /***/ (function(module, exports) {
6
7 var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
8 autosize 4.0.2
9 license: MIT
10 http://www.jacklmoore.com/autosize
11 */
12 (function (global, factory) {
13 if (true) {
14 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [module, exports], __WEBPACK_AMD_DEFINE_FACTORY__ = (factory),
15 __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
16 (__WEBPACK_AMD_DEFINE_FACTORY__.apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__)) : __WEBPACK_AMD_DEFINE_FACTORY__),
17 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
18 } else { var mod; }
19 })(this, function (module, exports) {
20 'use strict';
21
22 var map = typeof Map === "function" ? new Map() : function () {
23 var keys = [];
24 var values = [];
25
26 return {
27 has: function has(key) {
28 return keys.indexOf(key) > -1;
29 },
30 get: function get(key) {
31 return values[keys.indexOf(key)];
32 },
33 set: function set(key, value) {
34 if (keys.indexOf(key) === -1) {
35 keys.push(key);
36 values.push(value);
37 }
38 },
39 delete: function _delete(key) {
40 var index = keys.indexOf(key);
41 if (index > -1) {
42 keys.splice(index, 1);
43 values.splice(index, 1);
44 }
45 }
46 };
47 }();
48
49 var createEvent = function createEvent(name) {
50 return new Event(name, { bubbles: true });
51 };
52 try {
53 new Event('test');
54 } catch (e) {
55 // IE does not support `new Event()`
56 createEvent = function createEvent(name) {
57 var evt = document.createEvent('Event');
58 evt.initEvent(name, true, false);
59 return evt;
60 };
61 }
62
63 function assign(ta) {
64 if (!ta || !ta.nodeName || ta.nodeName !== 'TEXTAREA' || map.has(ta)) return;
65
66 var heightOffset = null;
67 var clientWidth = null;
68 var cachedHeight = null;
69
70 function init() {
71 var style = window.getComputedStyle(ta, null);
72
73 if (style.resize === 'vertical') {
74 ta.style.resize = 'none';
75 } else if (style.resize === 'both') {
76 ta.style.resize = 'horizontal';
77 }
78
79 if (style.boxSizing === 'content-box') {
80 heightOffset = -(parseFloat(style.paddingTop) + parseFloat(style.paddingBottom));
81 } else {
82 heightOffset = parseFloat(style.borderTopWidth) + parseFloat(style.borderBottomWidth);
83 }
84 // Fix when a textarea is not on document body and heightOffset is Not a Number
85 if (isNaN(heightOffset)) {
86 heightOffset = 0;
87 }
88
89 update();
90 }
91
92 function changeOverflow(value) {
93 {
94 // Chrome/Safari-specific fix:
95 // When the textarea y-overflow is hidden, Chrome/Safari do not reflow the text to account for the space
96 // made available by removing the scrollbar. The following forces the necessary text reflow.
97 var width = ta.style.width;
98 ta.style.width = '0px';
99 // Force reflow:
100 /* jshint ignore:start */
101 ta.offsetWidth;
102 /* jshint ignore:end */
103 ta.style.width = width;
104 }
105
106 ta.style.overflowY = value;
107 }
108
109 function getParentOverflows(el) {
110 var arr = [];
111
112 while (el && el.parentNode && el.parentNode instanceof Element) {
113 if (el.parentNode.scrollTop) {
114 arr.push({
115 node: el.parentNode,
116 scrollTop: el.parentNode.scrollTop
117 });
118 }
119 el = el.parentNode;
120 }
121
122 return arr;
123 }
124
125 function resize() {
126 if (ta.scrollHeight === 0) {
127 // If the scrollHeight is 0, then the element probably has display:none or is detached from the DOM.
128 return;
129 }
130
131 var overflows = getParentOverflows(ta);
132 var docTop = document.documentElement && document.documentElement.scrollTop; // Needed for Mobile IE (ticket #240)
133
134 ta.style.height = '';
135 ta.style.height = ta.scrollHeight + heightOffset + 'px';
136
137 // used to check if an update is actually necessary on window.resize
138 clientWidth = ta.clientWidth;
139
140 // prevents scroll-position jumping
141 overflows.forEach(function (el) {
142 el.node.scrollTop = el.scrollTop;
143 });
144
145 if (docTop) {
146 document.documentElement.scrollTop = docTop;
147 }
148 }
149
150 function update() {
151 resize();
152
153 var styleHeight = Math.round(parseFloat(ta.style.height));
154 var computed = window.getComputedStyle(ta, null);
155
156 // Using offsetHeight as a replacement for computed.height in IE, because IE does not account use of border-box
157 var actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(computed.height)) : ta.offsetHeight;
158
159 // The actual height not matching the style height (set via the resize method) indicates that
160 // the max-height has been exceeded, in which case the overflow should be allowed.
161 if (actualHeight < styleHeight) {
162 if (computed.overflowY === 'hidden') {
163 changeOverflow('scroll');
164 resize();
165 actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
166 }
167 } else {
168 // Normally keep overflow set to hidden, to avoid flash of scrollbar as the textarea expands.
169 if (computed.overflowY !== 'hidden') {
170 changeOverflow('hidden');
171 resize();
172 actualHeight = computed.boxSizing === 'content-box' ? Math.round(parseFloat(window.getComputedStyle(ta, null).height)) : ta.offsetHeight;
173 }
174 }
175
176 if (cachedHeight !== actualHeight) {
177 cachedHeight = actualHeight;
178 var evt = createEvent('autosize:resized');
179 try {
180 ta.dispatchEvent(evt);
181 } catch (err) {
182 // Firefox will throw an error on dispatchEvent for a detached element
183 // https://bugzilla.mozilla.org/show_bug.cgi?id=889376
184 }
185 }
186 }
187
188 var pageResize = function pageResize() {
189 if (ta.clientWidth !== clientWidth) {
190 update();
191 }
192 };
193
194 var destroy = function (style) {
195 window.removeEventListener('resize', pageResize, false);
196 ta.removeEventListener('input', update, false);
197 ta.removeEventListener('keyup', update, false);
198 ta.removeEventListener('autosize:destroy', destroy, false);
199 ta.removeEventListener('autosize:update', update, false);
200
201 Object.keys(style).forEach(function (key) {
202 ta.style[key] = style[key];
203 });
204
205 map.delete(ta);
206 }.bind(ta, {
207 height: ta.style.height,
208 resize: ta.style.resize,
209 overflowY: ta.style.overflowY,
210 overflowX: ta.style.overflowX,
211 wordWrap: ta.style.wordWrap
212 });
213
214 ta.addEventListener('autosize:destroy', destroy, false);
215
216 // IE9 does not fire onpropertychange or oninput for deletions,
217 // so binding to onkeyup to catch most of those events.
218 // There is no way that I know of to detect something like 'cut' in IE9.
219 if ('onpropertychange' in ta && 'oninput' in ta) {
220 ta.addEventListener('keyup', update, false);
221 }
222
223 window.addEventListener('resize', pageResize, false);
224 ta.addEventListener('input', update, false);
225 ta.addEventListener('autosize:update', update, false);
226 ta.style.overflowX = 'hidden';
227 ta.style.wordWrap = 'break-word';
228
229 map.set(ta, {
230 destroy: destroy,
231 update: update
232 });
233
234 init();
235 }
236
237 function destroy(ta) {
238 var methods = map.get(ta);
239 if (methods) {
240 methods.destroy();
241 }
242 }
243
244 function update(ta) {
245 var methods = map.get(ta);
246 if (methods) {
247 methods.update();
248 }
249 }
250
251 var autosize = null;
252
253 // Do nothing in Node.js environment and IE8 (or lower)
254 if (typeof window === 'undefined' || typeof window.getComputedStyle !== 'function') {
255 autosize = function autosize(el) {
256 return el;
257 };
258 autosize.destroy = function (el) {
259 return el;
260 };
261 autosize.update = function (el) {
262 return el;
263 };
264 } else {
265 autosize = function autosize(el, options) {
266 if (el) {
267 Array.prototype.forEach.call(el.length ? el : [el], function (x) {
268 return assign(x, options);
269 });
270 }
271 return el;
272 };
273 autosize.destroy = function (el) {
274 if (el) {
275 Array.prototype.forEach.call(el.length ? el : [el], destroy);
276 }
277 return el;
278 };
279 autosize.update = function (el) {
280 if (el) {
281 Array.prototype.forEach.call(el.length ? el : [el], update);
282 }
283 return el;
284 };
285 }
286
287 exports.default = autosize;
288 module.exports = exports['default'];
289 });
290
291 /***/ }),
292
293 /***/ 4403:
294 /***/ ((module, exports) => {
295
296 var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!
297 Copyright (c) 2018 Jed Watson.
298 Licensed under the MIT License (MIT), see
299 http://jedwatson.github.io/classnames
300 */
301 /* global define */
302
303 (function () {
304 'use strict';
305
306 var hasOwn = {}.hasOwnProperty;
307
308 function classNames() {
309 var classes = [];
310
311 for (var i = 0; i < arguments.length; i++) {
312 var arg = arguments[i];
313 if (!arg) continue;
314
315 var argType = typeof arg;
316
317 if (argType === 'string' || argType === 'number') {
318 classes.push(arg);
319 } else if (Array.isArray(arg)) {
320 if (arg.length) {
321 var inner = classNames.apply(null, arg);
322 if (inner) {
323 classes.push(inner);
324 }
325 }
326 } else if (argType === 'object') {
327 if (arg.toString === Object.prototype.toString) {
328 for (var key in arg) {
329 if (hasOwn.call(arg, key) && arg[key]) {
330 classes.push(key);
331 }
332 }
333 } else {
334 classes.push(arg.toString());
335 }
336 }
337 }
338
339 return classes.join(' ');
340 }
341
342 if ( true && module.exports) {
343 classNames.default = classNames;
344 module.exports = classNames;
345 } else if (true) {
346 // register as 'classnames', consistent with npm package name
347 !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {
348 return classNames;
349 }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),
350 __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
351 } else {}
352 }());
353
354
355 /***/ }),
356
357 /***/ 4827:
358 /***/ ((module) => {
359
360 // This code has been refactored for 140 bytes
361 // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js
362 var computedStyle = function (el, prop, getComputedStyle) {
363 getComputedStyle = window.getComputedStyle;
364
365 // In one fell swoop
366 return (
367 // If we have getComputedStyle
368 getComputedStyle ?
369 // Query it
370 // TODO: From CSS-Query notes, we might need (node, null) for FF
371 getComputedStyle(el) :
372
373 // Otherwise, we are in IE and use currentStyle
374 el.currentStyle
375 )[
376 // Switch to camelCase for CSSOM
377 // DEV: Grabbed from jQuery
378 // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194
379 // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597
380 prop.replace(/-(\w)/gi, function (word, letter) {
381 return letter.toUpperCase();
382 })
383 ];
384 };
385
386 module.exports = computedStyle;
387
388
389 /***/ }),
390
391 /***/ 9894:
392 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
393
394 // Load in dependencies
395 var computedStyle = __webpack_require__(4827);
396
397 /**
398 * Calculate the `line-height` of a given node
399 * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM.
400 * @returns {Number} `line-height` of the element in pixels
401 */
402 function lineHeight(node) {
403 // Grab the line-height via style
404 var lnHeightStr = computedStyle(node, 'line-height');
405 var lnHeight = parseFloat(lnHeightStr, 10);
406
407 // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em')
408 if (lnHeightStr === lnHeight + '') {
409 // Save the old lineHeight style and update the em unit to the element
410 var _lnHeightStyle = node.style.lineHeight;
411 node.style.lineHeight = lnHeightStr + 'em';
412
413 // Calculate the em based height
414 lnHeightStr = computedStyle(node, 'line-height');
415 lnHeight = parseFloat(lnHeightStr, 10);
416
417 // Revert the lineHeight style
418 if (_lnHeightStyle) {
419 node.style.lineHeight = _lnHeightStyle;
420 } else {
421 delete node.style.lineHeight;
422 }
423 }
424
425 // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt)
426 // DEV: `em` units are converted to `pt` in IE6
427 // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length
428 if (lnHeightStr.indexOf('pt') !== -1) {
429 lnHeight *= 4;
430 lnHeight /= 3;
431 // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm)
432 } else if (lnHeightStr.indexOf('mm') !== -1) {
433 lnHeight *= 96;
434 lnHeight /= 25.4;
435 // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm)
436 } else if (lnHeightStr.indexOf('cm') !== -1) {
437 lnHeight *= 96;
438 lnHeight /= 2.54;
439 // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in)
440 } else if (lnHeightStr.indexOf('in') !== -1) {
441 lnHeight *= 96;
442 // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc)
443 } else if (lnHeightStr.indexOf('pc') !== -1) {
444 lnHeight *= 16;
445 }
446
447 // Continue our computation
448 lnHeight = Math.round(lnHeight);
449
450 // If the line-height is "normal", calculate by font-size
451 if (lnHeightStr === 'normal') {
452 // Create a temporary node
453 var nodeName = node.nodeName;
454 var _node = document.createElement(nodeName);
455 _node.innerHTML = '&nbsp;';
456
457 // If we have a text area, reset it to only 1 row
458 // https://github.com/twolfson/line-height/issues/4
459 if (nodeName.toUpperCase() === 'TEXTAREA') {
460 _node.setAttribute('rows', '1');
461 }
462
463 // Set the font-size of the element
464 var fontSizeStr = computedStyle(node, 'font-size');
465 _node.style.fontSize = fontSizeStr;
466
467 // Remove default padding/border which can affect offset height
468 // https://github.com/twolfson/line-height/issues/4
469 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight
470 _node.style.padding = '0px';
471 _node.style.border = '0px';
472
473 // Append it to the body
474 var body = document.body;
475 body.appendChild(_node);
476
477 // Assume the line height of the element is the height
478 var height = _node.offsetHeight;
479 lnHeight = height;
480
481 // Remove our child from the DOM
482 body.removeChild(_node);
483 }
484
485 // Return the calculated height
486 return lnHeight;
487 }
488
489 // Export lineHeight
490 module.exports = lineHeight;
491
492
493 /***/ }),
494
495 /***/ 5372:
496 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
497
498 "use strict";
499 /**
500 * Copyright (c) 2013-present, Facebook, Inc.
501 *
502 * This source code is licensed under the MIT license found in the
503 * LICENSE file in the root directory of this source tree.
504 */
505
506
507
508 var ReactPropTypesSecret = __webpack_require__(9567);
509
510 function emptyFunction() {}
511 function emptyFunctionWithReset() {}
512 emptyFunctionWithReset.resetWarningCache = emptyFunction;
513
514 module.exports = function() {
515 function shim(props, propName, componentName, location, propFullName, secret) {
516 if (secret === ReactPropTypesSecret) {
517 // It is still safe when called from React.
518 return;
519 }
520 var err = new Error(
521 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
522 'Use PropTypes.checkPropTypes() to call them. ' +
523 'Read more at http://fb.me/use-check-prop-types'
524 );
525 err.name = 'Invariant Violation';
526 throw err;
527 };
528 shim.isRequired = shim;
529 function getShim() {
530 return shim;
531 };
532 // Important!
533 // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
534 var ReactPropTypes = {
535 array: shim,
536 bool: shim,
537 func: shim,
538 number: shim,
539 object: shim,
540 string: shim,
541 symbol: shim,
542
543 any: shim,
544 arrayOf: getShim,
545 element: shim,
546 elementType: shim,
547 instanceOf: getShim,
548 node: shim,
549 objectOf: getShim,
550 oneOf: getShim,
551 oneOfType: getShim,
552 shape: getShim,
553 exact: getShim,
554
555 checkPropTypes: emptyFunctionWithReset,
556 resetWarningCache: emptyFunction
557 };
558
559 ReactPropTypes.PropTypes = ReactPropTypes;
560
561 return ReactPropTypes;
562 };
563
564
565 /***/ }),
566
567 /***/ 2652:
568 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
569
570 /**
571 * Copyright (c) 2013-present, Facebook, Inc.
572 *
573 * This source code is licensed under the MIT license found in the
574 * LICENSE file in the root directory of this source tree.
575 */
576
577 if (false) { var throwOnDirectAccess, ReactIs; } else {
578 // By explicitly using `prop-types` you are opting into new production behavior.
579 // http://fb.me/prop-types-in-prod
580 module.exports = __webpack_require__(5372)();
581 }
582
583
584 /***/ }),
585
586 /***/ 9567:
587 /***/ ((module) => {
588
589 "use strict";
590 /**
591 * Copyright (c) 2013-present, Facebook, Inc.
592 *
593 * This source code is licensed under the MIT license found in the
594 * LICENSE file in the root directory of this source tree.
595 */
596
597
598
599 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
600
601 module.exports = ReactPropTypesSecret;
602
603
604 /***/ }),
605
606 /***/ 5438:
607 /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
608
609 "use strict";
610
611 var __extends = (this && this.__extends) || (function () {
612 var extendStatics = Object.setPrototypeOf ||
613 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
614 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
615 return function (d, b) {
616 extendStatics(d, b);
617 function __() { this.constructor = d; }
618 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
619 };
620 })();
621 var __assign = (this && this.__assign) || Object.assign || function(t) {
622 for (var s, i = 1, n = arguments.length; i < n; i++) {
623 s = arguments[i];
624 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
625 t[p] = s[p];
626 }
627 return t;
628 };
629 var __rest = (this && this.__rest) || function (s, e) {
630 var t = {};
631 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
632 t[p] = s[p];
633 if (s != null && typeof Object.getOwnPropertySymbols === "function")
634 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
635 t[p[i]] = s[p[i]];
636 return t;
637 };
638 exports.__esModule = true;
639 var React = __webpack_require__(9196);
640 var PropTypes = __webpack_require__(2652);
641 var autosize = __webpack_require__(6411);
642 var _getLineHeight = __webpack_require__(9894);
643 var getLineHeight = _getLineHeight;
644 var RESIZED = "autosize:resized";
645 /**
646 * A light replacement for built-in textarea component
647 * which automaticaly adjusts its height to match the content
648 */
649 var TextareaAutosizeClass = /** @class */ (function (_super) {
650 __extends(TextareaAutosizeClass, _super);
651 function TextareaAutosizeClass() {
652 var _this = _super !== null && _super.apply(this, arguments) || this;
653 _this.state = {
654 lineHeight: null
655 };
656 _this.textarea = null;
657 _this.onResize = function (e) {
658 if (_this.props.onResize) {
659 _this.props.onResize(e);
660 }
661 };
662 _this.updateLineHeight = function () {
663 if (_this.textarea) {
664 _this.setState({
665 lineHeight: getLineHeight(_this.textarea)
666 });
667 }
668 };
669 _this.onChange = function (e) {
670 var onChange = _this.props.onChange;
671 _this.currentValue = e.currentTarget.value;
672 onChange && onChange(e);
673 };
674 return _this;
675 }
676 TextareaAutosizeClass.prototype.componentDidMount = function () {
677 var _this = this;
678 var _a = this.props, maxRows = _a.maxRows, async = _a.async;
679 if (typeof maxRows === "number") {
680 this.updateLineHeight();
681 }
682 if (typeof maxRows === "number" || async) {
683 /*
684 the defer is needed to:
685 - force "autosize" to activate the scrollbar when this.props.maxRows is passed
686 - support StyledComponents (see #71)
687 */
688 setTimeout(function () { return _this.textarea && autosize(_this.textarea); });
689 }
690 else {
691 this.textarea && autosize(this.textarea);
692 }
693 if (this.textarea) {
694 this.textarea.addEventListener(RESIZED, this.onResize);
695 }
696 };
697 TextareaAutosizeClass.prototype.componentWillUnmount = function () {
698 if (this.textarea) {
699 this.textarea.removeEventListener(RESIZED, this.onResize);
700 autosize.destroy(this.textarea);
701 }
702 };
703 TextareaAutosizeClass.prototype.render = function () {
704 var _this = this;
705 var _a = this, _b = _a.props, onResize = _b.onResize, maxRows = _b.maxRows, onChange = _b.onChange, style = _b.style, innerRef = _b.innerRef, children = _b.children, props = __rest(_b, ["onResize", "maxRows", "onChange", "style", "innerRef", "children"]), lineHeight = _a.state.lineHeight;
706 var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null;
707 return (React.createElement("textarea", __assign({}, props, { onChange: this.onChange, style: maxHeight ? __assign({}, style, { maxHeight: maxHeight }) : style, ref: function (element) {
708 _this.textarea = element;
709 if (typeof _this.props.innerRef === 'function') {
710 _this.props.innerRef(element);
711 }
712 else if (_this.props.innerRef) {
713 _this.props.innerRef.current = element;
714 }
715 } }), children));
716 };
717 TextareaAutosizeClass.prototype.componentDidUpdate = function () {
718 this.textarea && autosize.update(this.textarea);
719 };
720 TextareaAutosizeClass.defaultProps = {
721 rows: 1,
722 async: false
723 };
724 TextareaAutosizeClass.propTypes = {
725 rows: PropTypes.number,
726 maxRows: PropTypes.number,
727 onResize: PropTypes.func,
728 innerRef: PropTypes.any,
729 async: PropTypes.bool
730 };
731 return TextareaAutosizeClass;
732 }(React.Component));
733 exports.TextareaAutosize = React.forwardRef(function (props, ref) {
734 return React.createElement(TextareaAutosizeClass, __assign({}, props, { innerRef: ref }));
735 });
736
737
738 /***/ }),
739
740 /***/ 773:
741 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
742
743 "use strict";
744 var __webpack_unused_export__;
745
746 __webpack_unused_export__ = true;
747 var TextareaAutosize_1 = __webpack_require__(5438);
748 exports.Z = TextareaAutosize_1.TextareaAutosize;
749
750
751 /***/ }),
752
753 /***/ 9196:
754 /***/ ((module) => {
755
756 "use strict";
757 module.exports = window["React"];
758
759 /***/ })
760
761 /******/ });
762 /************************************************************************/
763 /******/ // The module cache
764 /******/ var __webpack_module_cache__ = {};
765 /******/
766 /******/ // The require function
767 /******/ function __webpack_require__(moduleId) {
768 /******/ // Check if module is in cache
769 /******/ var cachedModule = __webpack_module_cache__[moduleId];
770 /******/ if (cachedModule !== undefined) {
771 /******/ return cachedModule.exports;
772 /******/ }
773 /******/ // Create a new module (and put it into the cache)
774 /******/ var module = __webpack_module_cache__[moduleId] = {
775 /******/ // no module.id needed
776 /******/ // no module.loaded needed
777 /******/ exports: {}
778 /******/ };
779 /******/
780 /******/ // Execute the module function
781 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
782 /******/
783 /******/ // Return the exports of the module
784 /******/ return module.exports;
785 /******/ }
786 /******/
787 /************************************************************************/
788 /******/ /* webpack/runtime/compat get default export */
789 /******/ (() => {
790 /******/ // getDefaultExport function for compatibility with non-harmony modules
791 /******/ __webpack_require__.n = (module) => {
792 /******/ var getter = module && module.__esModule ?
793 /******/ () => (module['default']) :
794 /******/ () => (module);
795 /******/ __webpack_require__.d(getter, { a: getter });
796 /******/ return getter;
797 /******/ };
798 /******/ })();
799 /******/
800 /******/ /* webpack/runtime/define property getters */
801 /******/ (() => {
802 /******/ // define getter functions for harmony exports
803 /******/ __webpack_require__.d = (exports, definition) => {
804 /******/ for(var key in definition) {
805 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
806 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
807 /******/ }
808 /******/ }
809 /******/ };
810 /******/ })();
811 /******/
812 /******/ /* webpack/runtime/hasOwnProperty shorthand */
813 /******/ (() => {
814 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
815 /******/ })();
816 /******/
817 /******/ /* webpack/runtime/make namespace object */
818 /******/ (() => {
819 /******/ // define __esModule on exports
820 /******/ __webpack_require__.r = (exports) => {
821 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
822 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
823 /******/ }
824 /******/ Object.defineProperty(exports, '__esModule', { value: true });
825 /******/ };
826 /******/ })();
827 /******/
828 /************************************************************************/
829 var __webpack_exports__ = {};
830 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
831 (() => {
832 "use strict";
833 // ESM COMPAT FLAG
834 __webpack_require__.r(__webpack_exports__);
835
836 // EXPORTS
837 __webpack_require__.d(__webpack_exports__, {
838 "AlignmentToolbar": () => (/* reexport */ AlignmentToolbar),
839 "Autocomplete": () => (/* reexport */ Autocomplete),
840 "AutosaveMonitor": () => (/* reexport */ autosave_monitor),
841 "BlockAlignmentToolbar": () => (/* reexport */ BlockAlignmentToolbar),
842 "BlockControls": () => (/* reexport */ BlockControls),
843 "BlockEdit": () => (/* reexport */ BlockEdit),
844 "BlockEditorKeyboardShortcuts": () => (/* reexport */ BlockEditorKeyboardShortcuts),
845 "BlockFormatControls": () => (/* reexport */ BlockFormatControls),
846 "BlockIcon": () => (/* reexport */ BlockIcon),
847 "BlockInspector": () => (/* reexport */ BlockInspector),
848 "BlockList": () => (/* reexport */ BlockList),
849 "BlockMover": () => (/* reexport */ BlockMover),
850 "BlockNavigationDropdown": () => (/* reexport */ BlockNavigationDropdown),
851 "BlockSelectionClearer": () => (/* reexport */ BlockSelectionClearer),
852 "BlockSettingsMenu": () => (/* reexport */ BlockSettingsMenu),
853 "BlockTitle": () => (/* reexport */ BlockTitle),
854 "BlockToolbar": () => (/* reexport */ BlockToolbar),
855 "ColorPalette": () => (/* reexport */ ColorPalette),
856 "ContrastChecker": () => (/* reexport */ ContrastChecker),
857 "CopyHandler": () => (/* reexport */ CopyHandler),
858 "DefaultBlockAppender": () => (/* reexport */ DefaultBlockAppender),
859 "DocumentOutline": () => (/* reexport */ document_outline),
860 "DocumentOutlineCheck": () => (/* reexport */ check),
861 "EditorHistoryRedo": () => (/* reexport */ editor_history_redo),
862 "EditorHistoryUndo": () => (/* reexport */ editor_history_undo),
863 "EditorKeyboardShortcutsRegister": () => (/* reexport */ register_shortcuts),
864 "EditorNotices": () => (/* reexport */ editor_notices),
865 "EditorProvider": () => (/* reexport */ provider),
866 "EditorSnackbars": () => (/* reexport */ EditorSnackbars),
867 "EntitiesSavedStates": () => (/* reexport */ EntitiesSavedStates),
868 "ErrorBoundary": () => (/* reexport */ error_boundary),
869 "FontSizePicker": () => (/* reexport */ FontSizePicker),
870 "InnerBlocks": () => (/* reexport */ InnerBlocks),
871 "Inserter": () => (/* reexport */ Inserter),
872 "InspectorAdvancedControls": () => (/* reexport */ InspectorAdvancedControls),
873 "InspectorControls": () => (/* reexport */ InspectorControls),
874 "LocalAutosaveMonitor": () => (/* reexport */ local_autosave_monitor),
875 "MediaPlaceholder": () => (/* reexport */ MediaPlaceholder),
876 "MediaUpload": () => (/* reexport */ MediaUpload),
877 "MediaUploadCheck": () => (/* reexport */ MediaUploadCheck),
878 "MultiSelectScrollIntoView": () => (/* reexport */ MultiSelectScrollIntoView),
879 "NavigableToolbar": () => (/* reexport */ NavigableToolbar),
880 "ObserveTyping": () => (/* reexport */ ObserveTyping),
881 "PageAttributesCheck": () => (/* reexport */ page_attributes_check),
882 "PageAttributesOrder": () => (/* reexport */ order),
883 "PageAttributesParent": () => (/* reexport */ page_attributes_parent),
884 "PageTemplate": () => (/* reexport */ post_template),
885 "PanelColorSettings": () => (/* reexport */ PanelColorSettings),
886 "PlainText": () => (/* reexport */ PlainText),
887 "PostAuthor": () => (/* reexport */ post_author),
888 "PostAuthorCheck": () => (/* reexport */ PostAuthorCheck),
889 "PostComments": () => (/* reexport */ post_comments),
890 "PostExcerpt": () => (/* reexport */ post_excerpt),
891 "PostExcerptCheck": () => (/* reexport */ post_excerpt_check),
892 "PostFeaturedImage": () => (/* reexport */ post_featured_image),
893 "PostFeaturedImageCheck": () => (/* reexport */ post_featured_image_check),
894 "PostFormat": () => (/* reexport */ PostFormat),
895 "PostFormatCheck": () => (/* reexport */ post_format_check),
896 "PostLastRevision": () => (/* reexport */ post_last_revision),
897 "PostLastRevisionCheck": () => (/* reexport */ post_last_revision_check),
898 "PostLockedModal": () => (/* reexport */ PostLockedModal),
899 "PostPendingStatus": () => (/* reexport */ post_pending_status),
900 "PostPendingStatusCheck": () => (/* reexport */ post_pending_status_check),
901 "PostPingbacks": () => (/* reexport */ post_pingbacks),
902 "PostPreviewButton": () => (/* reexport */ post_preview_button),
903 "PostPublishButton": () => (/* reexport */ post_publish_button),
904 "PostPublishButtonLabel": () => (/* reexport */ label),
905 "PostPublishPanel": () => (/* reexport */ post_publish_panel),
906 "PostSavedState": () => (/* reexport */ PostSavedState),
907 "PostSchedule": () => (/* reexport */ PostSchedule),
908 "PostScheduleCheck": () => (/* reexport */ post_schedule_check),
909 "PostScheduleLabel": () => (/* reexport */ post_schedule_label),
910 "PostSlug": () => (/* reexport */ post_slug),
911 "PostSlugCheck": () => (/* reexport */ PostSlugCheck),
912 "PostSticky": () => (/* reexport */ post_sticky),
913 "PostStickyCheck": () => (/* reexport */ post_sticky_check),
914 "PostSwitchToDraftButton": () => (/* reexport */ post_switch_to_draft_button),
915 "PostTaxonomies": () => (/* reexport */ post_taxonomies),
916 "PostTaxonomiesCheck": () => (/* reexport */ post_taxonomies_check),
917 "PostTaxonomiesFlatTermSelector": () => (/* reexport */ flat_term_selector),
918 "PostTaxonomiesHierarchicalTermSelector": () => (/* reexport */ hierarchical_term_selector),
919 "PostTextEditor": () => (/* reexport */ PostTextEditor),
920 "PostTitle": () => (/* reexport */ post_title),
921 "PostTrash": () => (/* reexport */ PostTrash),
922 "PostTrashCheck": () => (/* reexport */ post_trash_check),
923 "PostTypeSupportCheck": () => (/* reexport */ post_type_support_check),
924 "PostVisibility": () => (/* reexport */ PostVisibility),
925 "PostVisibilityCheck": () => (/* reexport */ post_visibility_check),
926 "PostVisibilityLabel": () => (/* reexport */ PostVisibilityLabel),
927 "RichText": () => (/* reexport */ RichText),
928 "RichTextShortcut": () => (/* reexport */ RichTextShortcut),
929 "RichTextToolbarButton": () => (/* reexport */ RichTextToolbarButton),
930 "ServerSideRender": () => (/* reexport */ (external_wp_serverSideRender_default())),
931 "SkipToSelectedBlock": () => (/* reexport */ SkipToSelectedBlock),
932 "TableOfContents": () => (/* reexport */ table_of_contents),
933 "TextEditorGlobalKeyboardShortcuts": () => (/* reexport */ TextEditorGlobalKeyboardShortcuts),
934 "ThemeSupportCheck": () => (/* reexport */ theme_support_check),
935 "URLInput": () => (/* reexport */ URLInput),
936 "URLInputButton": () => (/* reexport */ URLInputButton),
937 "URLPopover": () => (/* reexport */ URLPopover),
938 "UnsavedChangesWarning": () => (/* reexport */ UnsavedChangesWarning),
939 "VisualEditorGlobalKeyboardShortcuts": () => (/* reexport */ visual_editor_shortcuts),
940 "Warning": () => (/* reexport */ Warning),
941 "WordCount": () => (/* reexport */ WordCount),
942 "WritingFlow": () => (/* reexport */ WritingFlow),
943 "__unstableRichTextInputEvent": () => (/* reexport */ __unstableRichTextInputEvent),
944 "cleanForSlug": () => (/* reexport */ cleanForSlug),
945 "createCustomColorsHOC": () => (/* reexport */ createCustomColorsHOC),
946 "getColorClassName": () => (/* reexport */ getColorClassName),
947 "getColorObjectByAttributeValues": () => (/* reexport */ getColorObjectByAttributeValues),
948 "getColorObjectByColorValue": () => (/* reexport */ getColorObjectByColorValue),
949 "getFontSize": () => (/* reexport */ getFontSize),
950 "getFontSizeClass": () => (/* reexport */ getFontSizeClass),
951 "getTemplatePartIcon": () => (/* reexport */ getTemplatePartIcon),
952 "mediaUpload": () => (/* reexport */ mediaUpload),
953 "store": () => (/* reexport */ store_store),
954 "storeConfig": () => (/* reexport */ storeConfig),
955 "transformStyles": () => (/* reexport */ external_wp_blockEditor_namespaceObject.transformStyles),
956 "userAutocompleter": () => (/* reexport */ user),
957 "withColorContext": () => (/* reexport */ withColorContext),
958 "withColors": () => (/* reexport */ withColors),
959 "withFontSizes": () => (/* reexport */ withFontSizes)
960 });
961
962 // NAMESPACE OBJECT: ./packages/editor/build-module/store/selectors.js
963 var selectors_namespaceObject = {};
964 __webpack_require__.r(selectors_namespaceObject);
965 __webpack_require__.d(selectors_namespaceObject, {
966 "__experimentalGetDefaultTemplatePartAreas": () => (__experimentalGetDefaultTemplatePartAreas),
967 "__experimentalGetDefaultTemplateType": () => (__experimentalGetDefaultTemplateType),
968 "__experimentalGetDefaultTemplateTypes": () => (__experimentalGetDefaultTemplateTypes),
969 "__experimentalGetTemplateInfo": () => (__experimentalGetTemplateInfo),
970 "__unstableIsEditorReady": () => (__unstableIsEditorReady),
971 "canInsertBlockType": () => (canInsertBlockType),
972 "canUserUseUnfilteredHTML": () => (canUserUseUnfilteredHTML),
973 "didPostSaveRequestFail": () => (didPostSaveRequestFail),
974 "didPostSaveRequestSucceed": () => (didPostSaveRequestSucceed),
975 "getActivePostLock": () => (getActivePostLock),
976 "getAdjacentBlockClientId": () => (getAdjacentBlockClientId),
977 "getAutosaveAttribute": () => (getAutosaveAttribute),
978 "getBlock": () => (getBlock),
979 "getBlockAttributes": () => (getBlockAttributes),
980 "getBlockCount": () => (getBlockCount),
981 "getBlockHierarchyRootClientId": () => (getBlockHierarchyRootClientId),
982 "getBlockIndex": () => (getBlockIndex),
983 "getBlockInsertionPoint": () => (getBlockInsertionPoint),
984 "getBlockListSettings": () => (getBlockListSettings),
985 "getBlockMode": () => (getBlockMode),
986 "getBlockName": () => (getBlockName),
987 "getBlockOrder": () => (getBlockOrder),
988 "getBlockRootClientId": () => (getBlockRootClientId),
989 "getBlockSelectionEnd": () => (getBlockSelectionEnd),
990 "getBlockSelectionStart": () => (getBlockSelectionStart),
991 "getBlocks": () => (getBlocks),
992 "getBlocksByClientId": () => (getBlocksByClientId),
993 "getClientIdsOfDescendants": () => (getClientIdsOfDescendants),
994 "getClientIdsWithDescendants": () => (getClientIdsWithDescendants),
995 "getCurrentPost": () => (getCurrentPost),
996 "getCurrentPostAttribute": () => (getCurrentPostAttribute),
997 "getCurrentPostId": () => (getCurrentPostId),
998 "getCurrentPostLastRevisionId": () => (getCurrentPostLastRevisionId),
999 "getCurrentPostRevisionsCount": () => (getCurrentPostRevisionsCount),
1000 "getCurrentPostType": () => (getCurrentPostType),
1001 "getEditedPostAttribute": () => (getEditedPostAttribute),
1002 "getEditedPostContent": () => (getEditedPostContent),
1003 "getEditedPostPreviewLink": () => (getEditedPostPreviewLink),
1004 "getEditedPostSlug": () => (getEditedPostSlug),
1005 "getEditedPostVisibility": () => (getEditedPostVisibility),
1006 "getEditorBlocks": () => (getEditorBlocks),
1007 "getEditorSelection": () => (getEditorSelection),
1008 "getEditorSelectionEnd": () => (getEditorSelectionEnd),
1009 "getEditorSelectionStart": () => (getEditorSelectionStart),
1010 "getEditorSettings": () => (getEditorSettings),
1011 "getFirstMultiSelectedBlockClientId": () => (getFirstMultiSelectedBlockClientId),
1012 "getGlobalBlockCount": () => (getGlobalBlockCount),
1013 "getInserterItems": () => (getInserterItems),
1014 "getLastMultiSelectedBlockClientId": () => (getLastMultiSelectedBlockClientId),
1015 "getMultiSelectedBlockClientIds": () => (getMultiSelectedBlockClientIds),
1016 "getMultiSelectedBlocks": () => (getMultiSelectedBlocks),
1017 "getMultiSelectedBlocksEndClientId": () => (getMultiSelectedBlocksEndClientId),
1018 "getMultiSelectedBlocksStartClientId": () => (getMultiSelectedBlocksStartClientId),
1019 "getNextBlockClientId": () => (getNextBlockClientId),
1020 "getPermalink": () => (getPermalink),
1021 "getPermalinkParts": () => (getPermalinkParts),
1022 "getPostEdits": () => (getPostEdits),
1023 "getPostLockUser": () => (getPostLockUser),
1024 "getPostTypeLabel": () => (getPostTypeLabel),
1025 "getPreviousBlockClientId": () => (getPreviousBlockClientId),
1026 "getSelectedBlock": () => (getSelectedBlock),
1027 "getSelectedBlockClientId": () => (getSelectedBlockClientId),
1028 "getSelectedBlockCount": () => (getSelectedBlockCount),
1029 "getSelectedBlocksInitialCaretPosition": () => (getSelectedBlocksInitialCaretPosition),
1030 "getStateBeforeOptimisticTransaction": () => (getStateBeforeOptimisticTransaction),
1031 "getSuggestedPostFormat": () => (getSuggestedPostFormat),
1032 "getTemplate": () => (getTemplate),
1033 "getTemplateLock": () => (getTemplateLock),
1034 "hasChangedContent": () => (hasChangedContent),
1035 "hasEditorRedo": () => (hasEditorRedo),
1036 "hasEditorUndo": () => (hasEditorUndo),
1037 "hasInserterItems": () => (hasInserterItems),
1038 "hasMultiSelection": () => (hasMultiSelection),
1039 "hasNonPostEntityChanges": () => (hasNonPostEntityChanges),
1040 "hasSelectedBlock": () => (hasSelectedBlock),
1041 "hasSelectedInnerBlock": () => (hasSelectedInnerBlock),
1042 "inSomeHistory": () => (inSomeHistory),
1043 "isAncestorMultiSelected": () => (isAncestorMultiSelected),
1044 "isAutosavingPost": () => (isAutosavingPost),
1045 "isBlockInsertionPointVisible": () => (isBlockInsertionPointVisible),
1046 "isBlockMultiSelected": () => (isBlockMultiSelected),
1047 "isBlockSelected": () => (isBlockSelected),
1048 "isBlockValid": () => (isBlockValid),
1049 "isBlockWithinSelection": () => (isBlockWithinSelection),
1050 "isCaretWithinFormattedText": () => (isCaretWithinFormattedText),
1051 "isCleanNewPost": () => (isCleanNewPost),
1052 "isCurrentPostPending": () => (isCurrentPostPending),
1053 "isCurrentPostPublished": () => (isCurrentPostPublished),
1054 "isCurrentPostScheduled": () => (isCurrentPostScheduled),
1055 "isEditedPostAutosaveable": () => (isEditedPostAutosaveable),
1056 "isEditedPostBeingScheduled": () => (isEditedPostBeingScheduled),
1057 "isEditedPostDateFloating": () => (isEditedPostDateFloating),
1058 "isEditedPostDirty": () => (isEditedPostDirty),
1059 "isEditedPostEmpty": () => (isEditedPostEmpty),
1060 "isEditedPostNew": () => (isEditedPostNew),
1061 "isEditedPostPublishable": () => (isEditedPostPublishable),
1062 "isEditedPostSaveable": () => (isEditedPostSaveable),
1063 "isFirstMultiSelectedBlock": () => (isFirstMultiSelectedBlock),
1064 "isMultiSelecting": () => (isMultiSelecting),
1065 "isPermalinkEditable": () => (isPermalinkEditable),
1066 "isPostAutosavingLocked": () => (isPostAutosavingLocked),
1067 "isPostLockTakeover": () => (isPostLockTakeover),
1068 "isPostLocked": () => (isPostLocked),
1069 "isPostSavingLocked": () => (isPostSavingLocked),
1070 "isPreviewingPost": () => (isPreviewingPost),
1071 "isPublishSidebarEnabled": () => (isPublishSidebarEnabled),
1072 "isPublishingPost": () => (isPublishingPost),
1073 "isSavingNonPostEntityChanges": () => (isSavingNonPostEntityChanges),
1074 "isSavingPost": () => (isSavingPost),
1075 "isSelectionEnabled": () => (isSelectionEnabled),
1076 "isTyping": () => (isTyping),
1077 "isValidTemplate": () => (isValidTemplate)
1078 });
1079
1080 // NAMESPACE OBJECT: ./packages/editor/build-module/store/actions.js
1081 var actions_namespaceObject = {};
1082 __webpack_require__.r(actions_namespaceObject);
1083 __webpack_require__.d(actions_namespaceObject, {
1084 "__experimentalTearDownEditor": () => (__experimentalTearDownEditor),
1085 "autosave": () => (autosave),
1086 "clearSelectedBlock": () => (clearSelectedBlock),
1087 "createUndoLevel": () => (createUndoLevel),
1088 "disablePublishSidebar": () => (disablePublishSidebar),
1089 "editPost": () => (editPost),
1090 "enablePublishSidebar": () => (enablePublishSidebar),
1091 "enterFormattedText": () => (enterFormattedText),
1092 "exitFormattedText": () => (exitFormattedText),
1093 "hideInsertionPoint": () => (hideInsertionPoint),
1094 "insertBlock": () => (insertBlock),
1095 "insertBlocks": () => (insertBlocks),
1096 "insertDefaultBlock": () => (insertDefaultBlock),
1097 "lockPostAutosaving": () => (lockPostAutosaving),
1098 "lockPostSaving": () => (lockPostSaving),
1099 "mergeBlocks": () => (mergeBlocks),
1100 "moveBlockToPosition": () => (moveBlockToPosition),
1101 "moveBlocksDown": () => (moveBlocksDown),
1102 "moveBlocksUp": () => (moveBlocksUp),
1103 "multiSelect": () => (multiSelect),
1104 "receiveBlocks": () => (receiveBlocks),
1105 "redo": () => (redo),
1106 "refreshPost": () => (refreshPost),
1107 "removeBlock": () => (removeBlock),
1108 "removeBlocks": () => (removeBlocks),
1109 "replaceBlock": () => (replaceBlock),
1110 "replaceBlocks": () => (replaceBlocks),
1111 "resetBlocks": () => (resetBlocks),
1112 "resetEditorBlocks": () => (resetEditorBlocks),
1113 "resetPost": () => (resetPost),
1114 "savePost": () => (savePost),
1115 "selectBlock": () => (selectBlock),
1116 "setTemplateValidity": () => (setTemplateValidity),
1117 "setupEditor": () => (setupEditor),
1118 "setupEditorState": () => (setupEditorState),
1119 "showInsertionPoint": () => (showInsertionPoint),
1120 "startMultiSelect": () => (startMultiSelect),
1121 "startTyping": () => (startTyping),
1122 "stopMultiSelect": () => (stopMultiSelect),
1123 "stopTyping": () => (stopTyping),
1124 "synchronizeTemplate": () => (synchronizeTemplate),
1125 "toggleBlockMode": () => (toggleBlockMode),
1126 "toggleSelection": () => (toggleSelection),
1127 "trashPost": () => (trashPost),
1128 "undo": () => (undo),
1129 "unlockPostAutosaving": () => (unlockPostAutosaving),
1130 "unlockPostSaving": () => (unlockPostSaving),
1131 "updateBlock": () => (updateBlock),
1132 "updateBlockAttributes": () => (updateBlockAttributes),
1133 "updateBlockListSettings": () => (updateBlockListSettings),
1134 "updateEditorSettings": () => (updateEditorSettings),
1135 "updatePost": () => (updatePost),
1136 "updatePostLock": () => (updatePostLock)
1137 });
1138
1139 ;// CONCATENATED MODULE: ./node_modules/@babel/runtime/helpers/esm/extends.js
1140 function _extends() {
1141 _extends = Object.assign || function (target) {
1142 for (var i = 1; i < arguments.length; i++) {
1143 var source = arguments[i];
1144
1145 for (var key in source) {
1146 if (Object.prototype.hasOwnProperty.call(source, key)) {
1147 target[key] = source[key];
1148 }
1149 }
1150 }
1151
1152 return target;
1153 };
1154
1155 return _extends.apply(this, arguments);
1156 }
1157 ;// CONCATENATED MODULE: external ["wp","element"]
1158 const external_wp_element_namespaceObject = window["wp"]["element"];
1159 ;// CONCATENATED MODULE: external "lodash"
1160 const external_lodash_namespaceObject = window["lodash"];
1161 ;// CONCATENATED MODULE: external ["wp","blocks"]
1162 const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
1163 ;// CONCATENATED MODULE: external ["wp","data"]
1164 const external_wp_data_namespaceObject = window["wp"]["data"];
1165 ;// CONCATENATED MODULE: external ["wp","coreData"]
1166 const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
1167 ;// CONCATENATED MODULE: external ["wp","compose"]
1168 const external_wp_compose_namespaceObject = window["wp"]["compose"];
1169 ;// CONCATENATED MODULE: external ["wp","hooks"]
1170 const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
1171 ;// CONCATENATED MODULE: external ["wp","blockEditor"]
1172 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
1173 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/defaults.js
1174 /**
1175 * WordPress dependencies
1176 */
1177
1178 /**
1179 * The default post editor settings.
1180 *
1181 * @property {boolean|Array} allowedBlockTypes Allowed block types
1182 * @property {boolean} richEditingEnabled Whether rich editing is enabled or not
1183 * @property {boolean} codeEditingEnabled Whether code editing is enabled or not
1184 * @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.
1185 * true = the user has opted to show the Custom Fields panel at the bottom of the editor.
1186 * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
1187 * undefined = the current environment does not support Custom Fields, so the option toggle in Preferences -> Panels to enable the Custom Fields panel is not displayed.
1188 * @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API.
1189 * @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage.
1190 * @property {Array?} availableTemplates The available post templates
1191 * @property {boolean} disablePostFormats Whether or not the post formats are disabled
1192 * @property {Array?} allowedMimeTypes List of allowed mime types and file extensions
1193 * @property {number} maxUploadFileSize Maximum upload file size
1194 * @property {boolean} supportsLayout Whether the editor supports layouts.
1195 */
1196
1197 const EDITOR_SETTINGS_DEFAULTS = { ...external_wp_blockEditor_namespaceObject.SETTINGS_DEFAULTS,
1198 richEditingEnabled: true,
1199 codeEditingEnabled: true,
1200 enableCustomFields: undefined,
1201 supportsLayout: true
1202 };
1203
1204 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/reducer.js
1205 /**
1206 * External dependencies
1207 */
1208
1209 /**
1210 * WordPress dependencies
1211 */
1212
1213
1214 /**
1215 * Internal dependencies
1216 */
1217
1218
1219 /**
1220 * Returns a post attribute value, flattening nested rendered content using its
1221 * raw value in place of its original object form.
1222 *
1223 * @param {*} value Original value.
1224 *
1225 * @return {*} Raw value.
1226 */
1227
1228 function getPostRawValue(value) {
1229 if (value && 'object' === typeof value && 'raw' in value) {
1230 return value.raw;
1231 }
1232
1233 return value;
1234 }
1235 /**
1236 * Returns true if the two object arguments have the same keys, or false
1237 * otherwise.
1238 *
1239 * @param {Object} a First object.
1240 * @param {Object} b Second object.
1241 *
1242 * @return {boolean} Whether the two objects have the same keys.
1243 */
1244
1245 function hasSameKeys(a, b) {
1246 return isEqual(keys(a), keys(b));
1247 }
1248 /**
1249 * Returns true if, given the currently dispatching action and the previously
1250 * dispatched action, the two actions are editing the same post property, or
1251 * false otherwise.
1252 *
1253 * @param {Object} action Currently dispatching action.
1254 * @param {Object} previousAction Previously dispatched action.
1255 *
1256 * @return {boolean} Whether actions are updating the same post property.
1257 */
1258
1259 function isUpdatingSamePostProperty(action, previousAction) {
1260 return action.type === 'EDIT_POST' && hasSameKeys(action.edits, previousAction.edits);
1261 }
1262 /**
1263 * Returns true if, given the currently dispatching action and the previously
1264 * dispatched action, the two actions are modifying the same property such that
1265 * undo history should be batched.
1266 *
1267 * @param {Object} action Currently dispatching action.
1268 * @param {Object} previousAction Previously dispatched action.
1269 *
1270 * @return {boolean} Whether to overwrite present state.
1271 */
1272
1273 function shouldOverwriteState(action, previousAction) {
1274 if (action.type === 'RESET_EDITOR_BLOCKS') {
1275 return !action.shouldCreateUndoLevel;
1276 }
1277
1278 if (!previousAction || action.type !== previousAction.type) {
1279 return false;
1280 }
1281
1282 return isUpdatingSamePostProperty(action, previousAction);
1283 }
1284 function postId() {
1285 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1286 let action = arguments.length > 1 ? arguments[1] : undefined;
1287
1288 switch (action.type) {
1289 case 'SETUP_EDITOR_STATE':
1290 return action.post.id;
1291 }
1292
1293 return state;
1294 }
1295 function postType() {
1296 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
1297 let action = arguments.length > 1 ? arguments[1] : undefined;
1298
1299 switch (action.type) {
1300 case 'SETUP_EDITOR_STATE':
1301 return action.post.type;
1302 }
1303
1304 return state;
1305 }
1306 /**
1307 * Reducer returning whether the post blocks match the defined template or not.
1308 *
1309 * @param {Object} state Current state.
1310 * @param {Object} action Dispatched action.
1311 *
1312 * @return {boolean} Updated state.
1313 */
1314
1315 function template() {
1316 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
1317 isValid: true
1318 };
1319 let action = arguments.length > 1 ? arguments[1] : undefined;
1320
1321 switch (action.type) {
1322 case 'SET_TEMPLATE_VALIDITY':
1323 return { ...state,
1324 isValid: action.isValid
1325 };
1326 }
1327
1328 return state;
1329 }
1330 /**
1331 * Reducer returning current network request state (whether a request to
1332 * the WP REST API is in progress, successful, or failed).
1333 *
1334 * @param {Object} state Current state.
1335 * @param {Object} action Dispatched action.
1336 *
1337 * @return {Object} Updated state.
1338 */
1339
1340 function saving() {
1341 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1342 let action = arguments.length > 1 ? arguments[1] : undefined;
1343
1344 switch (action.type) {
1345 case 'REQUEST_POST_UPDATE_START':
1346 case 'REQUEST_POST_UPDATE_FINISH':
1347 return {
1348 pending: action.type === 'REQUEST_POST_UPDATE_START',
1349 options: action.options || {}
1350 };
1351 }
1352
1353 return state;
1354 }
1355 /**
1356 * Post Lock State.
1357 *
1358 * @typedef {Object} PostLockState
1359 *
1360 * @property {boolean} isLocked Whether the post is locked.
1361 * @property {?boolean} isTakeover Whether the post editing has been taken over.
1362 * @property {?boolean} activePostLock Active post lock value.
1363 * @property {?Object} user User that took over the post.
1364 */
1365
1366 /**
1367 * Reducer returning the post lock status.
1368 *
1369 * @param {PostLockState} state Current state.
1370 * @param {Object} action Dispatched action.
1371 *
1372 * @return {PostLockState} Updated state.
1373 */
1374
1375 function postLock() {
1376 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {
1377 isLocked: false
1378 };
1379 let action = arguments.length > 1 ? arguments[1] : undefined;
1380
1381 switch (action.type) {
1382 case 'UPDATE_POST_LOCK':
1383 return action.lock;
1384 }
1385
1386 return state;
1387 }
1388 /**
1389 * Post saving lock.
1390 *
1391 * When post saving is locked, the post cannot be published or updated.
1392 *
1393 * @param {PostLockState} state Current state.
1394 * @param {Object} action Dispatched action.
1395 *
1396 * @return {PostLockState} Updated state.
1397 */
1398
1399 function postSavingLock() {
1400 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1401 let action = arguments.length > 1 ? arguments[1] : undefined;
1402
1403 switch (action.type) {
1404 case 'LOCK_POST_SAVING':
1405 return { ...state,
1406 [action.lockName]: true
1407 };
1408
1409 case 'UNLOCK_POST_SAVING':
1410 return (0,external_lodash_namespaceObject.omit)(state, action.lockName);
1411 }
1412
1413 return state;
1414 }
1415 /**
1416 * Post autosaving lock.
1417 *
1418 * When post autosaving is locked, the post will not autosave.
1419 *
1420 * @param {PostLockState} state Current state.
1421 * @param {Object} action Dispatched action.
1422 *
1423 * @return {PostLockState} Updated state.
1424 */
1425
1426 function postAutosavingLock() {
1427 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
1428 let action = arguments.length > 1 ? arguments[1] : undefined;
1429
1430 switch (action.type) {
1431 case 'LOCK_POST_AUTOSAVING':
1432 return { ...state,
1433 [action.lockName]: true
1434 };
1435
1436 case 'UNLOCK_POST_AUTOSAVING':
1437 return (0,external_lodash_namespaceObject.omit)(state, action.lockName);
1438 }
1439
1440 return state;
1441 }
1442 /**
1443 * Reducer returning whether the editor is ready to be rendered.
1444 * The editor is considered ready to be rendered once
1445 * the post object is loaded properly and the initial blocks parsed.
1446 *
1447 * @param {boolean} state
1448 * @param {Object} action
1449 *
1450 * @return {boolean} Updated state.
1451 */
1452
1453 function isReady() {
1454 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
1455 let action = arguments.length > 1 ? arguments[1] : undefined;
1456
1457 switch (action.type) {
1458 case 'SETUP_EDITOR_STATE':
1459 return true;
1460
1461 case 'TEAR_DOWN_EDITOR':
1462 return false;
1463 }
1464
1465 return state;
1466 }
1467 /**
1468 * Reducer returning the post editor setting.
1469 *
1470 * @param {Object} state Current state.
1471 * @param {Object} action Dispatched action.
1472 *
1473 * @return {Object} Updated state.
1474 */
1475
1476 function editorSettings() {
1477 let state = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : EDITOR_SETTINGS_DEFAULTS;
1478 let action = arguments.length > 1 ? arguments[1] : undefined;
1479
1480 switch (action.type) {
1481 case 'UPDATE_EDITOR_SETTINGS':
1482 return { ...state,
1483 ...action.settings
1484 };
1485 }
1486
1487 return state;
1488 }
1489 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
1490 postId,
1491 postType,
1492 saving,
1493 postLock,
1494 template,
1495 postSavingLock,
1496 isReady,
1497 editorSettings,
1498 postAutosavingLock
1499 }));
1500
1501 ;// CONCATENATED MODULE: ./node_modules/rememo/es/rememo.js
1502
1503
1504 /** @typedef {(...args: any[]) => *[]} GetDependants */
1505
1506 /** @typedef {() => void} Clear */
1507
1508 /**
1509 * @typedef {{
1510 * getDependants: GetDependants,
1511 * clear: Clear
1512 * }} EnhancedSelector
1513 */
1514
1515 /**
1516 * Internal cache entry.
1517 *
1518 * @typedef CacheNode
1519 *
1520 * @property {?CacheNode|undefined} [prev] Previous node.
1521 * @property {?CacheNode|undefined} [next] Next node.
1522 * @property {*[]} args Function arguments for cache entry.
1523 * @property {*} val Function result.
1524 */
1525
1526 /**
1527 * @typedef Cache
1528 *
1529 * @property {Clear} clear Function to clear cache.
1530 * @property {boolean} [isUniqueByDependants] Whether dependants are valid in
1531 * considering cache uniqueness. A cache is unique if dependents are all arrays
1532 * or objects.
1533 * @property {CacheNode?} [head] Cache head.
1534 * @property {*[]} [lastDependants] Dependants from previous invocation.
1535 */
1536
1537 /**
1538 * Arbitrary value used as key for referencing cache object in WeakMap tree.
1539 *
1540 * @type {{}}
1541 */
1542 var LEAF_KEY = {};
1543
1544 /**
1545 * Returns the first argument as the sole entry in an array.
1546 *
1547 * @template T
1548 *
1549 * @param {T} value Value to return.
1550 *
1551 * @return {[T]} Value returned as entry in array.
1552 */
1553 function arrayOf(value) {
1554 return [value];
1555 }
1556
1557 /**
1558 * Returns true if the value passed is object-like, or false otherwise. A value
1559 * is object-like if it can support property assignment, e.g. object or array.
1560 *
1561 * @param {*} value Value to test.
1562 *
1563 * @return {boolean} Whether value is object-like.
1564 */
1565 function isObjectLike(value) {
1566 return !!value && 'object' === typeof value;
1567 }
1568
1569 /**
1570 * Creates and returns a new cache object.
1571 *
1572 * @return {Cache} Cache object.
1573 */
1574 function createCache() {
1575 /** @type {Cache} */
1576 var cache = {
1577 clear: function () {
1578 cache.head = null;
1579 },
1580 };
1581
1582 return cache;
1583 }
1584
1585 /**
1586 * Returns true if entries within the two arrays are strictly equal by
1587 * reference from a starting index.
1588 *
1589 * @param {*[]} a First array.
1590 * @param {*[]} b Second array.
1591 * @param {number} fromIndex Index from which to start comparison.
1592 *
1593 * @return {boolean} Whether arrays are shallowly equal.
1594 */
1595 function isShallowEqual(a, b, fromIndex) {
1596 var i;
1597
1598 if (a.length !== b.length) {
1599 return false;
1600 }
1601
1602 for (i = fromIndex; i < a.length; i++) {
1603 if (a[i] !== b[i]) {
1604 return false;
1605 }
1606 }
1607
1608 return true;
1609 }
1610
1611 /**
1612 * Returns a memoized selector function. The getDependants function argument is
1613 * called before the memoized selector and is expected to return an immutable
1614 * reference or array of references on which the selector depends for computing
1615 * its own return value. The memoize cache is preserved only as long as those
1616 * dependant references remain the same. If getDependants returns a different
1617 * reference(s), the cache is cleared and the selector value regenerated.
1618 *
1619 * @template {(...args: *[]) => *} S
1620 *
1621 * @param {S} selector Selector function.
1622 * @param {GetDependants=} getDependants Dependant getter returning an array of
1623 * references used in cache bust consideration.
1624 */
1625 /* harmony default export */ function rememo(selector, getDependants) {
1626 /** @type {WeakMap<*,*>} */
1627 var rootCache;
1628
1629 /** @type {GetDependants} */
1630 var normalizedGetDependants = getDependants ? getDependants : arrayOf;
1631
1632 /**
1633 * Returns the cache for a given dependants array. When possible, a WeakMap
1634 * will be used to create a unique cache for each set of dependants. This
1635 * is feasible due to the nature of WeakMap in allowing garbage collection
1636 * to occur on entries where the key object is no longer referenced. Since
1637 * WeakMap requires the key to be an object, this is only possible when the
1638 * dependant is object-like. The root cache is created as a hierarchy where
1639 * each top-level key is the first entry in a dependants set, the value a
1640 * WeakMap where each key is the next dependant, and so on. This continues
1641 * so long as the dependants are object-like. If no dependants are object-
1642 * like, then the cache is shared across all invocations.
1643 *
1644 * @see isObjectLike
1645 *
1646 * @param {*[]} dependants Selector dependants.
1647 *
1648 * @return {Cache} Cache object.
1649 */
1650 function getCache(dependants) {
1651 var caches = rootCache,
1652 isUniqueByDependants = true,
1653 i,
1654 dependant,
1655 map,
1656 cache;
1657
1658 for (i = 0; i < dependants.length; i++) {
1659 dependant = dependants[i];
1660
1661 // Can only compose WeakMap from object-like key.
1662 if (!isObjectLike(dependant)) {
1663 isUniqueByDependants = false;
1664 break;
1665 }
1666
1667 // Does current segment of cache already have a WeakMap?
1668 if (caches.has(dependant)) {
1669 // Traverse into nested WeakMap.
1670 caches = caches.get(dependant);
1671 } else {
1672 // Create, set, and traverse into a new one.
1673 map = new WeakMap();
1674 caches.set(dependant, map);
1675 caches = map;
1676 }
1677 }
1678
1679 // We use an arbitrary (but consistent) object as key for the last item
1680 // in the WeakMap to serve as our running cache.
1681 if (!caches.has(LEAF_KEY)) {
1682 cache = createCache();
1683 cache.isUniqueByDependants = isUniqueByDependants;
1684 caches.set(LEAF_KEY, cache);
1685 }
1686
1687 return caches.get(LEAF_KEY);
1688 }
1689
1690 /**
1691 * Resets root memoization cache.
1692 */
1693 function clear() {
1694 rootCache = new WeakMap();
1695 }
1696
1697 /* eslint-disable jsdoc/check-param-names */
1698 /**
1699 * The augmented selector call, considering first whether dependants have
1700 * changed before passing it to underlying memoize function.
1701 *
1702 * @param {*} source Source object for derivation.
1703 * @param {...*} extraArgs Additional arguments to pass to selector.
1704 *
1705 * @return {*} Selector result.
1706 */
1707 /* eslint-enable jsdoc/check-param-names */
1708 function callSelector(/* source, ...extraArgs */) {
1709 var len = arguments.length,
1710 cache,
1711 node,
1712 i,
1713 args,
1714 dependants;
1715
1716 // Create copy of arguments (avoid leaking deoptimization).
1717 args = new Array(len);
1718 for (i = 0; i < len; i++) {
1719 args[i] = arguments[i];
1720 }
1721
1722 dependants = normalizedGetDependants.apply(null, args);
1723 cache = getCache(dependants);
1724
1725 // If not guaranteed uniqueness by dependants (primitive type), shallow
1726 // compare against last dependants and, if references have changed,
1727 // destroy cache to recalculate result.
1728 if (!cache.isUniqueByDependants) {
1729 if (
1730 cache.lastDependants &&
1731 !isShallowEqual(dependants, cache.lastDependants, 0)
1732 ) {
1733 cache.clear();
1734 }
1735
1736 cache.lastDependants = dependants;
1737 }
1738
1739 node = cache.head;
1740 while (node) {
1741 // Check whether node arguments match arguments
1742 if (!isShallowEqual(node.args, args, 1)) {
1743 node = node.next;
1744 continue;
1745 }
1746
1747 // At this point we can assume we've found a match
1748
1749 // Surface matched node to head if not already
1750 if (node !== cache.head) {
1751 // Adjust siblings to point to each other.
1752 /** @type {CacheNode} */ (node.prev).next = node.next;
1753 if (node.next) {
1754 node.next.prev = node.prev;
1755 }
1756
1757 node.next = cache.head;
1758 node.prev = null;
1759 /** @type {CacheNode} */ (cache.head).prev = node;
1760 cache.head = node;
1761 }
1762
1763 // Return immediately
1764 return node.val;
1765 }
1766
1767 // No cached value found. Continue to insertion phase:
1768
1769 node = /** @type {CacheNode} */ ({
1770 // Generate the result from original function
1771 val: selector.apply(null, args),
1772 });
1773
1774 // Avoid including the source object in the cache.
1775 args[0] = null;
1776 node.args = args;
1777
1778 // Don't need to check whether node is already head, since it would
1779 // have been returned above already if it was
1780
1781 // Shift existing head down list
1782 if (cache.head) {
1783 cache.head.prev = node;
1784 node.next = cache.head;
1785 }
1786
1787 cache.head = node;
1788
1789 return node.val;
1790 }
1791
1792 callSelector.getDependants = normalizedGetDependants;
1793 callSelector.clear = clear;
1794 clear();
1795
1796 return /** @type {S & EnhancedSelector} */ (callSelector);
1797 }
1798
1799 ;// CONCATENATED MODULE: external ["wp","date"]
1800 const external_wp_date_namespaceObject = window["wp"]["date"];
1801 ;// CONCATENATED MODULE: external ["wp","url"]
1802 const external_wp_url_namespaceObject = window["wp"]["url"];
1803 ;// CONCATENATED MODULE: external ["wp","deprecated"]
1804 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
1805 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
1806 ;// CONCATENATED MODULE: external ["wp","primitives"]
1807 const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
1808 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/layout.js
1809
1810
1811 /**
1812 * WordPress dependencies
1813 */
1814
1815 const layout = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1816 xmlns: "http://www.w3.org/2000/svg",
1817 viewBox: "0 0 24 24"
1818 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1819 d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
1820 }));
1821 /* harmony default export */ const library_layout = (layout);
1822
1823 ;// CONCATENATED MODULE: external ["wp","preferences"]
1824 const external_wp_preferences_namespaceObject = window["wp"]["preferences"];
1825 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/constants.js
1826 /**
1827 * Set of post properties for which edits should assume a merging behavior,
1828 * assuming an object value.
1829 *
1830 * @type {Set}
1831 */
1832 const EDIT_MERGE_PROPERTIES = new Set(['meta']);
1833 /**
1834 * Constant for the store module (or reducer) key.
1835 *
1836 * @type {string}
1837 */
1838
1839 const STORE_NAME = 'core/editor';
1840 const SAVE_POST_NOTICE_ID = 'SAVE_POST_NOTICE_ID';
1841 const TRASH_POST_NOTICE_ID = 'TRASH_POST_NOTICE_ID';
1842 const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;
1843 const ONE_MINUTE_IN_MS = 60 * 1000;
1844 const AUTOSAVE_PROPERTIES = ['title', 'excerpt', 'content'];
1845
1846 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/header.js
1847
1848
1849 /**
1850 * WordPress dependencies
1851 */
1852
1853 const header = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1854 xmlns: "http://www.w3.org/2000/svg",
1855 viewBox: "0 0 24 24"
1856 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1857 d: "M18.5 10.5H10v8h8a.5.5 0 00.5-.5v-7.5zm-10 0h-3V18a.5.5 0 00.5.5h2.5v-8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
1858 }));
1859 /* harmony default export */ const library_header = (header);
1860
1861 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/footer.js
1862
1863
1864 /**
1865 * WordPress dependencies
1866 */
1867
1868 const footer = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1869 xmlns: "http://www.w3.org/2000/svg",
1870 viewBox: "0 0 24 24"
1871 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1872 fillRule: "evenodd",
1873 d: "M18 5.5h-8v8h8.5V6a.5.5 0 00-.5-.5zm-9.5 8h-3V6a.5.5 0 01.5-.5h2.5v8zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
1874 }));
1875 /* harmony default export */ const library_footer = (footer);
1876
1877 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/sidebar.js
1878
1879
1880 /**
1881 * WordPress dependencies
1882 */
1883
1884 const sidebar = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1885 xmlns: "http://www.w3.org/2000/svg",
1886 viewBox: "0 0 24 24"
1887 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1888 d: "M18 5.5H6a.5.5 0 00-.5.5v3h13V6a.5.5 0 00-.5-.5zm.5 5H10v8h8a.5.5 0 00.5-.5v-7.5zM6 4h12a2 2 0 012 2v12a2 2 0 01-2 2H6a2 2 0 01-2-2V6a2 2 0 012-2z"
1889 }));
1890 /* harmony default export */ const library_sidebar = (sidebar);
1891
1892 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/symbol-filled.js
1893
1894
1895 /**
1896 * WordPress dependencies
1897 */
1898
1899 const symbolFilled = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
1900 xmlns: "http://www.w3.org/2000/svg",
1901 viewBox: "0 0 24 24"
1902 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
1903 d: "M21.3 10.8l-5.6-5.6c-.7-.7-1.8-.7-2.5 0l-5.6 5.6c-.7.7-.7 1.8 0 2.5l5.6 5.6c.3.3.8.5 1.2.5s.9-.2 1.2-.5l5.6-5.6c.8-.7.8-1.9.1-2.5zm-17.6 1L10 5.5l-1-1-6.3 6.3c-.7.7-.7 1.8 0 2.5L9 19.5l1.1-1.1-6.3-6.3c-.2 0-.2-.2-.1-.3z"
1904 }));
1905 /* harmony default export */ const symbol_filled = (symbolFilled);
1906
1907 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/get-template-part-icon.js
1908 /**
1909 * WordPress dependencies
1910 */
1911
1912 /**
1913 * Helper function to retrieve the corresponding icon by name.
1914 *
1915 * @param {string} iconName The name of the icon.
1916 *
1917 * @return {Object} The corresponding icon.
1918 */
1919
1920 function getTemplatePartIcon(iconName) {
1921 if ('header' === iconName) {
1922 return library_header;
1923 } else if ('footer' === iconName) {
1924 return library_footer;
1925 } else if ('sidebar' === iconName) {
1926 return library_sidebar;
1927 }
1928
1929 return symbol_filled;
1930 }
1931
1932 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/selectors.js
1933 /**
1934 * External dependencies
1935 */
1936
1937
1938 /**
1939 * WordPress dependencies
1940 */
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952 /**
1953 * Internal dependencies
1954 */
1955
1956
1957
1958
1959 /**
1960 * Shared reference to an empty object for cases where it is important to avoid
1961 * returning a new object reference on every invocation, as in a connected or
1962 * other pure component which performs `shouldComponentUpdate` check on props.
1963 * This should be used as a last resort, since the normalized data should be
1964 * maintained by the reducer result in state.
1965 */
1966
1967 const EMPTY_OBJECT = {};
1968 /**
1969 * Shared reference to an empty array for cases where it is important to avoid
1970 * returning a new array reference on every invocation, as in a connected or
1971 * other pure component which performs `shouldComponentUpdate` check on props.
1972 * This should be used as a last resort, since the normalized data should be
1973 * maintained by the reducer result in state.
1974 */
1975
1976 const EMPTY_ARRAY = [];
1977 /**
1978 * Returns true if any past editor history snapshots exist, or false otherwise.
1979 *
1980 * @param {Object} state Global application state.
1981 *
1982 * @return {boolean} Whether undo history exists.
1983 */
1984
1985 const hasEditorUndo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
1986 return select(external_wp_coreData_namespaceObject.store).hasUndo();
1987 });
1988 /**
1989 * Returns true if any future editor history snapshots exist, or false
1990 * otherwise.
1991 *
1992 * @param {Object} state Global application state.
1993 *
1994 * @return {boolean} Whether redo history exists.
1995 */
1996
1997 const hasEditorRedo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
1998 return select(external_wp_coreData_namespaceObject.store).hasRedo();
1999 });
2000 /**
2001 * Returns true if the currently edited post is yet to be saved, or false if
2002 * the post has been saved.
2003 *
2004 * @param {Object} state Global application state.
2005 *
2006 * @return {boolean} Whether the post is new.
2007 */
2008
2009 function isEditedPostNew(state) {
2010 return getCurrentPost(state).status === 'auto-draft';
2011 }
2012 /**
2013 * Returns true if content includes unsaved changes, or false otherwise.
2014 *
2015 * @param {Object} state Editor state.
2016 *
2017 * @return {boolean} Whether content includes unsaved changes.
2018 */
2019
2020 function hasChangedContent(state) {
2021 const edits = getPostEdits(state);
2022 return 'blocks' in edits || // `edits` is intended to contain only values which are different from
2023 // the saved post, so the mere presence of a property is an indicator
2024 // that the value is different than what is known to be saved. While
2025 // content in Visual mode is represented by the blocks state, in Text
2026 // mode it is tracked by `edits.content`.
2027 'content' in edits;
2028 }
2029 /**
2030 * Returns true if there are unsaved values for the current edit session, or
2031 * false if the editing state matches the saved or new post.
2032 *
2033 * @param {Object} state Global application state.
2034 *
2035 * @return {boolean} Whether unsaved values exist.
2036 */
2037
2038 const isEditedPostDirty = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2039 // Edits should contain only fields which differ from the saved post (reset
2040 // at initial load and save complete). Thus, a non-empty edits state can be
2041 // inferred to contain unsaved values.
2042 const postType = getCurrentPostType(state);
2043 const postId = getCurrentPostId(state);
2044
2045 if (select(external_wp_coreData_namespaceObject.store).hasEditsForEntityRecord('postType', postType, postId)) {
2046 return true;
2047 }
2048
2049 return false;
2050 });
2051 /**
2052 * Returns true if there are unsaved edits for entities other than
2053 * the editor's post, and false otherwise.
2054 *
2055 * @param {Object} state Global application state.
2056 *
2057 * @return {boolean} Whether there are edits or not.
2058 */
2059
2060 const hasNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2061 const dirtyEntityRecords = select(external_wp_coreData_namespaceObject.store).__experimentalGetDirtyEntityRecords();
2062
2063 const {
2064 type,
2065 id
2066 } = getCurrentPost(state);
2067 return (0,external_lodash_namespaceObject.some)(dirtyEntityRecords, entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id);
2068 });
2069 /**
2070 * Returns true if there are no unsaved values for the current edit session and
2071 * if the currently edited post is new (has never been saved before).
2072 *
2073 * @param {Object} state Global application state.
2074 *
2075 * @return {boolean} Whether new post and unsaved values exist.
2076 */
2077
2078 function isCleanNewPost(state) {
2079 return !isEditedPostDirty(state) && isEditedPostNew(state);
2080 }
2081 /**
2082 * Returns the post currently being edited in its last known saved state, not
2083 * including unsaved edits. Returns an object containing relevant default post
2084 * values if the post has not yet been saved.
2085 *
2086 * @param {Object} state Global application state.
2087 *
2088 * @return {Object} Post object.
2089 */
2090
2091 const getCurrentPost = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2092 const postId = getCurrentPostId(state);
2093 const postType = getCurrentPostType(state);
2094 const post = select(external_wp_coreData_namespaceObject.store).getRawEntityRecord('postType', postType, postId);
2095
2096 if (post) {
2097 return post;
2098 } // This exists for compatibility with the previous selector behavior
2099 // which would guarantee an object return based on the editor reducer's
2100 // default empty object state.
2101
2102
2103 return EMPTY_OBJECT;
2104 });
2105 /**
2106 * Returns the post type of the post currently being edited.
2107 *
2108 * @param {Object} state Global application state.
2109 *
2110 * @return {string} Post type.
2111 */
2112
2113 function getCurrentPostType(state) {
2114 return state.postType;
2115 }
2116 /**
2117 * Returns the ID of the post currently being edited, or null if the post has
2118 * not yet been saved.
2119 *
2120 * @param {Object} state Global application state.
2121 *
2122 * @return {?number} ID of current post.
2123 */
2124
2125 function getCurrentPostId(state) {
2126 return state.postId;
2127 }
2128 /**
2129 * Returns the number of revisions of the post currently being edited.
2130 *
2131 * @param {Object} state Global application state.
2132 *
2133 * @return {number} Number of revisions.
2134 */
2135
2136 function getCurrentPostRevisionsCount(state) {
2137 return (0,external_lodash_namespaceObject.get)(getCurrentPost(state), ['_links', 'version-history', 0, 'count'], 0);
2138 }
2139 /**
2140 * Returns the last revision ID of the post currently being edited,
2141 * or null if the post has no revisions.
2142 *
2143 * @param {Object} state Global application state.
2144 *
2145 * @return {?number} ID of the last revision.
2146 */
2147
2148 function getCurrentPostLastRevisionId(state) {
2149 return (0,external_lodash_namespaceObject.get)(getCurrentPost(state), ['_links', 'predecessor-version', 0, 'id'], null);
2150 }
2151 /**
2152 * Returns any post values which have been changed in the editor but not yet
2153 * been saved.
2154 *
2155 * @param {Object} state Global application state.
2156 *
2157 * @return {Object} Object of key value pairs comprising unsaved edits.
2158 */
2159
2160 const getPostEdits = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2161 const postType = getCurrentPostType(state);
2162 const postId = getCurrentPostId(state);
2163 return select(external_wp_coreData_namespaceObject.store).getEntityRecordEdits('postType', postType, postId) || EMPTY_OBJECT;
2164 });
2165 /**
2166 * Returns an attribute value of the saved post.
2167 *
2168 * @param {Object} state Global application state.
2169 * @param {string} attributeName Post attribute name.
2170 *
2171 * @return {*} Post attribute value.
2172 */
2173
2174 function getCurrentPostAttribute(state, attributeName) {
2175 switch (attributeName) {
2176 case 'type':
2177 return getCurrentPostType(state);
2178
2179 case 'id':
2180 return getCurrentPostId(state);
2181
2182 default:
2183 const post = getCurrentPost(state);
2184
2185 if (!post.hasOwnProperty(attributeName)) {
2186 break;
2187 }
2188
2189 return getPostRawValue(post[attributeName]);
2190 }
2191 }
2192 /**
2193 * Returns a single attribute of the post being edited, preferring the unsaved
2194 * edit if one exists, but merging with the attribute value for the last known
2195 * saved state of the post (this is needed for some nested attributes like meta).
2196 *
2197 * @param {Object} state Global application state.
2198 * @param {string} attributeName Post attribute name.
2199 *
2200 * @return {*} Post attribute value.
2201 */
2202
2203 const getNestedEditedPostProperty = (state, attributeName) => {
2204 const edits = getPostEdits(state);
2205
2206 if (!edits.hasOwnProperty(attributeName)) {
2207 return getCurrentPostAttribute(state, attributeName);
2208 }
2209
2210 return { ...getCurrentPostAttribute(state, attributeName),
2211 ...edits[attributeName]
2212 };
2213 };
2214 /**
2215 * Returns a single attribute of the post being edited, preferring the unsaved
2216 * edit if one exists, but falling back to the attribute for the last known
2217 * saved state of the post.
2218 *
2219 * @param {Object} state Global application state.
2220 * @param {string} attributeName Post attribute name.
2221 *
2222 * @return {*} Post attribute value.
2223 */
2224
2225
2226 function getEditedPostAttribute(state, attributeName) {
2227 // Special cases.
2228 switch (attributeName) {
2229 case 'content':
2230 return getEditedPostContent(state);
2231 } // Fall back to saved post value if not edited.
2232
2233
2234 const edits = getPostEdits(state);
2235
2236 if (!edits.hasOwnProperty(attributeName)) {
2237 return getCurrentPostAttribute(state, attributeName);
2238 } // Merge properties are objects which contain only the patch edit in state,
2239 // and thus must be merged with the current post attribute.
2240
2241
2242 if (EDIT_MERGE_PROPERTIES.has(attributeName)) {
2243 return getNestedEditedPostProperty(state, attributeName);
2244 }
2245
2246 return edits[attributeName];
2247 }
2248 /**
2249 * Returns an attribute value of the current autosave revision for a post, or
2250 * null if there is no autosave for the post.
2251 *
2252 * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector
2253 * from the '@wordpress/core-data' package and access properties on the returned
2254 * autosave object using getPostRawValue.
2255 *
2256 * @param {Object} state Global application state.
2257 * @param {string} attributeName Autosave attribute name.
2258 *
2259 * @return {*} Autosave attribute value.
2260 */
2261
2262 const getAutosaveAttribute = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, attributeName) => {
2263 if (!(0,external_lodash_namespaceObject.includes)(AUTOSAVE_PROPERTIES, attributeName) && attributeName !== 'preview_link') {
2264 return;
2265 }
2266
2267 const postType = getCurrentPostType(state);
2268 const postId = getCurrentPostId(state);
2269 const currentUserId = (0,external_lodash_namespaceObject.get)(select(external_wp_coreData_namespaceObject.store).getCurrentUser(), ['id']);
2270 const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId);
2271
2272 if (autosave) {
2273 return getPostRawValue(autosave[attributeName]);
2274 }
2275 });
2276 /**
2277 * Returns the current visibility of the post being edited, preferring the
2278 * unsaved value if different than the saved post. The return value is one of
2279 * "private", "password", or "public".
2280 *
2281 * @param {Object} state Global application state.
2282 *
2283 * @return {string} Post visibility.
2284 */
2285
2286 function getEditedPostVisibility(state) {
2287 const status = getEditedPostAttribute(state, 'status');
2288
2289 if (status === 'private') {
2290 return 'private';
2291 }
2292
2293 const password = getEditedPostAttribute(state, 'password');
2294
2295 if (password) {
2296 return 'password';
2297 }
2298
2299 return 'public';
2300 }
2301 /**
2302 * Returns true if post is pending review.
2303 *
2304 * @param {Object} state Global application state.
2305 *
2306 * @return {boolean} Whether current post is pending review.
2307 */
2308
2309 function isCurrentPostPending(state) {
2310 return getCurrentPost(state).status === 'pending';
2311 }
2312 /**
2313 * Return true if the current post has already been published.
2314 *
2315 * @param {Object} state Global application state.
2316 * @param {Object?} currentPost Explicit current post for bypassing registry selector.
2317 *
2318 * @return {boolean} Whether the post has been published.
2319 */
2320
2321 function isCurrentPostPublished(state, currentPost) {
2322 const post = currentPost || getCurrentPost(state);
2323 return ['publish', 'private'].indexOf(post.status) !== -1 || post.status === 'future' && !(0,external_wp_date_namespaceObject.isInTheFuture)(new Date(Number((0,external_wp_date_namespaceObject.getDate)(post.date)) - ONE_MINUTE_IN_MS));
2324 }
2325 /**
2326 * Returns true if post is already scheduled.
2327 *
2328 * @param {Object} state Global application state.
2329 *
2330 * @return {boolean} Whether current post is scheduled to be posted.
2331 */
2332
2333 function isCurrentPostScheduled(state) {
2334 return getCurrentPost(state).status === 'future' && !isCurrentPostPublished(state);
2335 }
2336 /**
2337 * Return true if the post being edited can be published.
2338 *
2339 * @param {Object} state Global application state.
2340 *
2341 * @return {boolean} Whether the post can been published.
2342 */
2343
2344 function isEditedPostPublishable(state) {
2345 const post = getCurrentPost(state); // TODO: Post being publishable should be superset of condition of post
2346 // being saveable. Currently this restriction is imposed at UI.
2347 //
2348 // See: <PostPublishButton /> (`isButtonEnabled` assigned by `isSaveable`).
2349
2350 return isEditedPostDirty(state) || ['publish', 'private', 'future'].indexOf(post.status) === -1;
2351 }
2352 /**
2353 * Returns true if the post can be saved, or false otherwise. A post must
2354 * contain a title, an excerpt, or non-empty content to be valid for save.
2355 *
2356 * @param {Object} state Global application state.
2357 *
2358 * @return {boolean} Whether the post can be saved.
2359 */
2360
2361 function isEditedPostSaveable(state) {
2362 if (isSavingPost(state)) {
2363 return false;
2364 } // TODO: Post should not be saveable if not dirty. Cannot be added here at
2365 // this time since posts where meta boxes are present can be saved even if
2366 // the post is not dirty. Currently this restriction is imposed at UI, but
2367 // should be moved here.
2368 //
2369 // See: `isEditedPostPublishable` (includes `isEditedPostDirty` condition)
2370 // See: <PostSavedState /> (`forceIsDirty` prop)
2371 // See: <PostPublishButton /> (`forceIsDirty` prop)
2372 // See: https://github.com/WordPress/gutenberg/pull/4184.
2373
2374
2375 return !!getEditedPostAttribute(state, 'title') || !!getEditedPostAttribute(state, 'excerpt') || !isEditedPostEmpty(state) || external_wp_element_namespaceObject.Platform.OS === 'native';
2376 }
2377 /**
2378 * Returns true if the edited post has content. A post has content if it has at
2379 * least one saveable block or otherwise has a non-empty content property
2380 * assigned.
2381 *
2382 * @param {Object} state Global application state.
2383 *
2384 * @return {boolean} Whether post has content.
2385 */
2386
2387 function isEditedPostEmpty(state) {
2388 // While the condition of truthy content string is sufficient to determine
2389 // emptiness, testing saveable blocks length is a trivial operation. Since
2390 // this function can be called frequently, optimize for the fast case as a
2391 // condition of the mere existence of blocks. Note that the value of edited
2392 // content takes precedent over block content, and must fall through to the
2393 // default logic.
2394 const blocks = getEditorBlocks(state);
2395
2396 if (blocks.length) {
2397 // Pierce the abstraction of the serializer in knowing that blocks are
2398 // joined with with newlines such that even if every individual block
2399 // produces an empty save result, the serialized content is non-empty.
2400 if (blocks.length > 1) {
2401 return false;
2402 } // There are two conditions under which the optimization cannot be
2403 // assumed, and a fallthrough to getEditedPostContent must occur:
2404 //
2405 // 1. getBlocksForSerialization has special treatment in omitting a
2406 // single unmodified default block.
2407 // 2. Comment delimiters are omitted for a freeform or unregistered
2408 // block in its serialization. The freeform block specifically may
2409 // produce an empty string in its saved output.
2410 //
2411 // For all other content, the single block is assumed to make a post
2412 // non-empty, if only by virtue of its own comment delimiters.
2413
2414
2415 const blockName = blocks[0].name;
2416
2417 if (blockName !== (0,external_wp_blocks_namespaceObject.getDefaultBlockName)() && blockName !== (0,external_wp_blocks_namespaceObject.getFreeformContentHandlerName)()) {
2418 return false;
2419 }
2420 }
2421
2422 return !getEditedPostContent(state);
2423 }
2424 /**
2425 * Returns true if the post can be autosaved, or false otherwise.
2426 *
2427 * @param {Object} state Global application state.
2428 * @param {Object} autosave A raw autosave object from the REST API.
2429 *
2430 * @return {boolean} Whether the post can be autosaved.
2431 */
2432
2433 const isEditedPostAutosaveable = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2434 // A post must contain a title, an excerpt, or non-empty content to be valid for autosaving.
2435 if (!isEditedPostSaveable(state)) {
2436 return false;
2437 } // A post is not autosavable when there is a post autosave lock.
2438
2439
2440 if (isPostAutosavingLocked(state)) {
2441 return false;
2442 }
2443
2444 const postType = getCurrentPostType(state);
2445 const postId = getCurrentPostId(state);
2446 const hasFetchedAutosave = select(external_wp_coreData_namespaceObject.store).hasFetchedAutosaves(postType, postId);
2447 const currentUserId = (0,external_lodash_namespaceObject.get)(select(external_wp_coreData_namespaceObject.store).getCurrentUser(), ['id']); // Disable reason - this line causes the side-effect of fetching the autosave
2448 // via a resolver, moving below the return would result in the autosave never
2449 // being fetched.
2450 // eslint-disable-next-line @wordpress/no-unused-vars-before-return
2451
2452 const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId); // If any existing autosaves have not yet been fetched, this function is
2453 // unable to determine if the post is autosaveable, so return false.
2454
2455 if (!hasFetchedAutosave) {
2456 return false;
2457 } // If we don't already have an autosave, the post is autosaveable.
2458
2459
2460 if (!autosave) {
2461 return true;
2462 } // To avoid an expensive content serialization, use the content dirtiness
2463 // flag in place of content field comparison against the known autosave.
2464 // This is not strictly accurate, and relies on a tolerance toward autosave
2465 // request failures for unnecessary saves.
2466
2467
2468 if (hasChangedContent(state)) {
2469 return true;
2470 } // If the title or excerpt has changed, the post is autosaveable.
2471
2472
2473 return ['title', 'excerpt'].some(field => getPostRawValue(autosave[field]) !== getEditedPostAttribute(state, field));
2474 });
2475 /**
2476 * Return true if the post being edited is being scheduled. Preferring the
2477 * unsaved status values.
2478 *
2479 * @param {Object} state Global application state.
2480 *
2481 * @return {boolean} Whether the post has been published.
2482 */
2483
2484 function isEditedPostBeingScheduled(state) {
2485 const date = getEditedPostAttribute(state, 'date'); // Offset the date by one minute (network latency).
2486
2487 const checkedDate = new Date(Number((0,external_wp_date_namespaceObject.getDate)(date)) - ONE_MINUTE_IN_MS);
2488 return (0,external_wp_date_namespaceObject.isInTheFuture)(checkedDate);
2489 }
2490 /**
2491 * Returns whether the current post should be considered to have a "floating"
2492 * date (i.e. that it would publish "Immediately" rather than at a set time).
2493 *
2494 * Unlike in the PHP backend, the REST API returns a full date string for posts
2495 * where the 0000-00-00T00:00:00 placeholder is present in the database. To
2496 * infer that a post is set to publish "Immediately" we check whether the date
2497 * and modified date are the same.
2498 *
2499 * @param {Object} state Editor state.
2500 *
2501 * @return {boolean} Whether the edited post has a floating date value.
2502 */
2503
2504 function isEditedPostDateFloating(state) {
2505 const date = getEditedPostAttribute(state, 'date');
2506 const modified = getEditedPostAttribute(state, 'modified'); // This should be the status of the persisted post
2507 // It shouldn't use the "edited" status otherwise it breaks the
2508 // inferred post data floating status
2509 // See https://github.com/WordPress/gutenberg/issues/28083.
2510
2511 const status = getCurrentPost(state).status;
2512
2513 if (status === 'draft' || status === 'auto-draft' || status === 'pending') {
2514 return date === modified || date === null;
2515 }
2516
2517 return false;
2518 }
2519 /**
2520 * Returns true if the post is currently being saved, or false otherwise.
2521 *
2522 * @param {Object} state Global application state.
2523 *
2524 * @return {boolean} Whether post is being saved.
2525 */
2526
2527 const isSavingPost = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2528 const postType = getCurrentPostType(state);
2529 const postId = getCurrentPostId(state);
2530 return select(external_wp_coreData_namespaceObject.store).isSavingEntityRecord('postType', postType, postId);
2531 });
2532 /**
2533 * Returns true if non-post entities are currently being saved, or false otherwise.
2534 *
2535 * @param {Object} state Global application state.
2536 *
2537 * @return {boolean} Whether non-post entities are being saved.
2538 */
2539
2540 const isSavingNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2541 const entitiesBeingSaved = select(external_wp_coreData_namespaceObject.store).__experimentalGetEntitiesBeingSaved();
2542
2543 const {
2544 type,
2545 id
2546 } = getCurrentPost(state);
2547 return (0,external_lodash_namespaceObject.some)(entitiesBeingSaved, entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id);
2548 });
2549 /**
2550 * Returns true if a previous post save was attempted successfully, or false
2551 * otherwise.
2552 *
2553 * @param {Object} state Global application state.
2554 *
2555 * @return {boolean} Whether the post was saved successfully.
2556 */
2557
2558 const didPostSaveRequestSucceed = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2559 const postType = getCurrentPostType(state);
2560 const postId = getCurrentPostId(state);
2561 return !select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
2562 });
2563 /**
2564 * Returns true if a previous post save was attempted but failed, or false
2565 * otherwise.
2566 *
2567 * @param {Object} state Global application state.
2568 *
2569 * @return {boolean} Whether the post save failed.
2570 */
2571
2572 const didPostSaveRequestFail = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2573 const postType = getCurrentPostType(state);
2574 const postId = getCurrentPostId(state);
2575 return !!select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
2576 });
2577 /**
2578 * Returns true if the post is autosaving, or false otherwise.
2579 *
2580 * @param {Object} state Global application state.
2581 *
2582 * @return {boolean} Whether the post is autosaving.
2583 */
2584
2585 function isAutosavingPost(state) {
2586 if (!isSavingPost(state)) {
2587 return false;
2588 }
2589
2590 return !!(0,external_lodash_namespaceObject.get)(state.saving, ['options', 'isAutosave']);
2591 }
2592 /**
2593 * Returns true if the post is being previewed, or false otherwise.
2594 *
2595 * @param {Object} state Global application state.
2596 *
2597 * @return {boolean} Whether the post is being previewed.
2598 */
2599
2600 function isPreviewingPost(state) {
2601 if (!isSavingPost(state)) {
2602 return false;
2603 }
2604
2605 return !!(0,external_lodash_namespaceObject.get)(state.saving, ['options', 'isPreview']);
2606 }
2607 /**
2608 * Returns the post preview link
2609 *
2610 * @param {Object} state Global application state.
2611 *
2612 * @return {string?} Preview Link.
2613 */
2614
2615 function getEditedPostPreviewLink(state) {
2616 if (state.saving.pending || isSavingPost(state)) {
2617 return;
2618 }
2619
2620 let previewLink = getAutosaveAttribute(state, 'preview_link'); // Fix for issue: https://github.com/WordPress/gutenberg/issues/33616
2621 // If the post is draft, ignore the preview link from the autosave record,
2622 // because the preview could be a stale autosave if the post was switched from
2623 // published to draft.
2624 // See: https://github.com/WordPress/gutenberg/pull/37952.
2625
2626 if (!previewLink || 'draft' === getCurrentPost(state).status) {
2627 previewLink = getEditedPostAttribute(state, 'link');
2628
2629 if (previewLink) {
2630 previewLink = (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
2631 preview: true
2632 });
2633 }
2634 }
2635
2636 const featuredImageId = getEditedPostAttribute(state, 'featured_media');
2637
2638 if (previewLink && featuredImageId) {
2639 return (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
2640 _thumbnail_id: featuredImageId
2641 });
2642 }
2643
2644 return previewLink;
2645 }
2646 /**
2647 * Returns a suggested post format for the current post, inferred only if there
2648 * is a single block within the post and it is of a type known to match a
2649 * default post format. Returns null if the format cannot be determined.
2650 *
2651 * @param {Object} state Global application state.
2652 *
2653 * @return {?string} Suggested post format.
2654 */
2655
2656 function getSuggestedPostFormat(state) {
2657 const blocks = getEditorBlocks(state);
2658 if (blocks.length > 2) return null;
2659 let name; // If there is only one block in the content of the post grab its name
2660 // so we can derive a suitable post format from it.
2661
2662 if (blocks.length === 1) {
2663 name = blocks[0].name; // Check for core/embed `video` and `audio` eligible suggestions.
2664
2665 if (name === 'core/embed') {
2666 var _blocks$0$attributes;
2667
2668 const provider = (_blocks$0$attributes = blocks[0].attributes) === null || _blocks$0$attributes === void 0 ? void 0 : _blocks$0$attributes.providerNameSlug;
2669
2670 if (['youtube', 'vimeo'].includes(provider)) {
2671 name = 'core/video';
2672 } else if (['spotify', 'soundcloud'].includes(provider)) {
2673 name = 'core/audio';
2674 }
2675 }
2676 } // If there are two blocks in the content and the last one is a text blocks
2677 // grab the name of the first one to also suggest a post format from it.
2678
2679
2680 if (blocks.length === 2 && blocks[1].name === 'core/paragraph') {
2681 name = blocks[0].name;
2682 } // We only convert to default post formats in core.
2683
2684
2685 switch (name) {
2686 case 'core/image':
2687 return 'image';
2688
2689 case 'core/quote':
2690 case 'core/pullquote':
2691 return 'quote';
2692
2693 case 'core/gallery':
2694 return 'gallery';
2695
2696 case 'core/video':
2697 return 'video';
2698
2699 case 'core/audio':
2700 return 'audio';
2701
2702 default:
2703 return null;
2704 }
2705 }
2706 /**
2707 * Returns the content of the post being edited.
2708 *
2709 * @param {Object} state Global application state.
2710 *
2711 * @return {string} Post content.
2712 */
2713
2714 const getEditedPostContent = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2715 const postId = getCurrentPostId(state);
2716 const postType = getCurrentPostType(state);
2717 const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
2718
2719 if (record) {
2720 if (typeof record.content === 'function') {
2721 return record.content(record);
2722 } else if (record.blocks) {
2723 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
2724 } else if (record.content) {
2725 return record.content;
2726 }
2727 }
2728
2729 return '';
2730 });
2731 /**
2732 * Returns true if the post is being published, or false otherwise.
2733 *
2734 * @param {Object} state Global application state.
2735 *
2736 * @return {boolean} Whether post is being published.
2737 */
2738
2739 function isPublishingPost(state) {
2740 return isSavingPost(state) && !isCurrentPostPublished(state) && getEditedPostAttribute(state, 'status') === 'publish';
2741 }
2742 /**
2743 * Returns whether the permalink is editable or not.
2744 *
2745 * @param {Object} state Editor state.
2746 *
2747 * @return {boolean} Whether or not the permalink is editable.
2748 */
2749
2750 function isPermalinkEditable(state) {
2751 const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
2752 return PERMALINK_POSTNAME_REGEX.test(permalinkTemplate);
2753 }
2754 /**
2755 * Returns the permalink for the post.
2756 *
2757 * @param {Object} state Editor state.
2758 *
2759 * @return {?string} The permalink, or null if the post is not viewable.
2760 */
2761
2762 function getPermalink(state) {
2763 const permalinkParts = getPermalinkParts(state);
2764
2765 if (!permalinkParts) {
2766 return null;
2767 }
2768
2769 const {
2770 prefix,
2771 postName,
2772 suffix
2773 } = permalinkParts;
2774
2775 if (isPermalinkEditable(state)) {
2776 return prefix + postName + suffix;
2777 }
2778
2779 return prefix;
2780 }
2781 /**
2782 * Returns the slug for the post being edited, preferring a manually edited
2783 * value if one exists, then a sanitized version of the current post title, and
2784 * finally the post ID.
2785 *
2786 * @param {Object} state Editor state.
2787 *
2788 * @return {string} The current slug to be displayed in the editor
2789 */
2790
2791 function getEditedPostSlug(state) {
2792 return getEditedPostAttribute(state, 'slug') || (0,external_wp_url_namespaceObject.cleanForSlug)(getEditedPostAttribute(state, 'title')) || getCurrentPostId(state);
2793 }
2794 /**
2795 * Returns the permalink for a post, split into it's three parts: the prefix,
2796 * the postName, and the suffix.
2797 *
2798 * @param {Object} state Editor state.
2799 *
2800 * @return {Object} An object containing the prefix, postName, and suffix for
2801 * the permalink, or null if the post is not viewable.
2802 */
2803
2804 function getPermalinkParts(state) {
2805 const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
2806
2807 if (!permalinkTemplate) {
2808 return null;
2809 }
2810
2811 const postName = getEditedPostAttribute(state, 'slug') || getEditedPostAttribute(state, 'generated_slug');
2812 const [prefix, suffix] = permalinkTemplate.split(PERMALINK_POSTNAME_REGEX);
2813 return {
2814 prefix,
2815 postName,
2816 suffix
2817 };
2818 }
2819 /**
2820 * Returns whether the post is locked.
2821 *
2822 * @param {Object} state Global application state.
2823 *
2824 * @return {boolean} Is locked.
2825 */
2826
2827 function isPostLocked(state) {
2828 return state.postLock.isLocked;
2829 }
2830 /**
2831 * Returns whether post saving is locked.
2832 *
2833 * @param {Object} state Global application state.
2834 *
2835 * @return {boolean} Is locked.
2836 */
2837
2838 function isPostSavingLocked(state) {
2839 return Object.keys(state.postSavingLock).length > 0;
2840 }
2841 /**
2842 * Returns whether post autosaving is locked.
2843 *
2844 * @param {Object} state Global application state.
2845 *
2846 * @return {boolean} Is locked.
2847 */
2848
2849 function isPostAutosavingLocked(state) {
2850 return Object.keys(state.postAutosavingLock).length > 0;
2851 }
2852 /**
2853 * Returns whether the edition of the post has been taken over.
2854 *
2855 * @param {Object} state Global application state.
2856 *
2857 * @return {boolean} Is post lock takeover.
2858 */
2859
2860 function isPostLockTakeover(state) {
2861 return state.postLock.isTakeover;
2862 }
2863 /**
2864 * Returns details about the post lock user.
2865 *
2866 * @param {Object} state Global application state.
2867 *
2868 * @return {Object} A user object.
2869 */
2870
2871 function getPostLockUser(state) {
2872 return state.postLock.user;
2873 }
2874 /**
2875 * Returns the active post lock.
2876 *
2877 * @param {Object} state Global application state.
2878 *
2879 * @return {Object} The lock object.
2880 */
2881
2882 function getActivePostLock(state) {
2883 return state.postLock.activePostLock;
2884 }
2885 /**
2886 * Returns whether or not the user has the unfiltered_html capability.
2887 *
2888 * @param {Object} state Editor state.
2889 *
2890 * @return {boolean} Whether the user can or can't post unfiltered HTML.
2891 */
2892
2893 function canUserUseUnfilteredHTML(state) {
2894 return (0,external_lodash_namespaceObject.has)(getCurrentPost(state), ['_links', 'wp:action-unfiltered-html']);
2895 }
2896 /**
2897 * Returns whether the pre-publish panel should be shown
2898 * or skipped when the user clicks the "publish" button.
2899 *
2900 * @return {boolean} Whether the pre-publish panel should be shown or not.
2901 */
2902
2903 const isPublishSidebarEnabled = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => !!select(external_wp_preferences_namespaceObject.store).get('core/edit-post', 'isPublishSidebarEnabled'));
2904 /**
2905 * Return the current block list.
2906 *
2907 * @param {Object} state
2908 * @return {Array} Block list.
2909 */
2910
2911 function getEditorBlocks(state) {
2912 return getEditedPostAttribute(state, 'blocks') || EMPTY_ARRAY;
2913 }
2914 /**
2915 * A block selection object.
2916 *
2917 * @typedef {Object} WPBlockSelection
2918 *
2919 * @property {string} clientId A block client ID.
2920 * @property {string} attributeKey A block attribute key.
2921 * @property {number} offset An attribute value offset, based on the rich
2922 * text value. See `wp.richText.create`.
2923 */
2924
2925 /**
2926 * Returns the current selection start.
2927 *
2928 * @param {Object} state
2929 * @return {WPBlockSelection} The selection start.
2930 *
2931 * @deprecated since Gutenberg 10.0.0.
2932 */
2933
2934 function getEditorSelectionStart(state) {
2935 var _getEditedPostAttribu;
2936
2937 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", {
2938 since: '5.8',
2939 alternative: "select('core/editor').getEditorSelection"
2940 });
2941 return (_getEditedPostAttribu = getEditedPostAttribute(state, 'selection')) === null || _getEditedPostAttribu === void 0 ? void 0 : _getEditedPostAttribu.selectionStart;
2942 }
2943 /**
2944 * Returns the current selection end.
2945 *
2946 * @param {Object} state
2947 * @return {WPBlockSelection} The selection end.
2948 *
2949 * @deprecated since Gutenberg 10.0.0.
2950 */
2951
2952 function getEditorSelectionEnd(state) {
2953 var _getEditedPostAttribu2;
2954
2955 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", {
2956 since: '5.8',
2957 alternative: "select('core/editor').getEditorSelection"
2958 });
2959 return (_getEditedPostAttribu2 = getEditedPostAttribute(state, 'selection')) === null || _getEditedPostAttribu2 === void 0 ? void 0 : _getEditedPostAttribu2.selectionEnd;
2960 }
2961 /**
2962 * Returns the current selection.
2963 *
2964 * @param {Object} state
2965 * @return {WPBlockSelection} The selection end.
2966 */
2967
2968 function getEditorSelection(state) {
2969 return getEditedPostAttribute(state, 'selection');
2970 }
2971 /**
2972 * Is the editor ready
2973 *
2974 * @param {Object} state
2975 * @return {boolean} is Ready.
2976 */
2977
2978 function __unstableIsEditorReady(state) {
2979 return state.isReady;
2980 }
2981 /**
2982 * Returns the post editor settings.
2983 *
2984 * @param {Object} state Editor state.
2985 *
2986 * @return {Object} The editor settings object.
2987 */
2988
2989 function getEditorSettings(state) {
2990 return state.editorSettings;
2991 }
2992 /*
2993 * Backward compatibility
2994 */
2995
2996 /**
2997 * Returns state object prior to a specified optimist transaction ID, or `null`
2998 * if the transaction corresponding to the given ID cannot be found.
2999 *
3000 * @deprecated since Gutenberg 9.7.0.
3001 */
3002
3003 function getStateBeforeOptimisticTransaction() {
3004 external_wp_deprecated_default()("select('core/editor').getStateBeforeOptimisticTransaction", {
3005 since: '5.7',
3006 hint: 'No state history is kept on this store anymore'
3007 });
3008 return null;
3009 }
3010 /**
3011 * Returns true if an optimistic transaction is pending commit, for which the
3012 * before state satisfies the given predicate function.
3013 *
3014 * @deprecated since Gutenberg 9.7.0.
3015 */
3016
3017 function inSomeHistory() {
3018 external_wp_deprecated_default()("select('core/editor').inSomeHistory", {
3019 since: '5.7',
3020 hint: 'No state history is kept on this store anymore'
3021 });
3022 return false;
3023 }
3024
3025 function getBlockEditorSelector(name) {
3026 return (0,external_wp_data_namespaceObject.createRegistrySelector)(select => function (state) {
3027 external_wp_deprecated_default()("`wp.data.select( 'core/editor' )." + name + '`', {
3028 since: '5.3',
3029 alternative: "`wp.data.select( 'core/block-editor' )." + name + '`',
3030 version: '6.2'
3031 });
3032
3033 for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
3034 args[_key - 1] = arguments[_key];
3035 }
3036
3037 return select(external_wp_blockEditor_namespaceObject.store)[name](...args);
3038 });
3039 }
3040 /**
3041 * @see getBlockName in core/block-editor store.
3042 */
3043
3044
3045 const getBlockName = getBlockEditorSelector('getBlockName');
3046 /**
3047 * @see isBlockValid in core/block-editor store.
3048 */
3049
3050 const isBlockValid = getBlockEditorSelector('isBlockValid');
3051 /**
3052 * @see getBlockAttributes in core/block-editor store.
3053 */
3054
3055 const getBlockAttributes = getBlockEditorSelector('getBlockAttributes');
3056 /**
3057 * @see getBlock in core/block-editor store.
3058 */
3059
3060 const getBlock = getBlockEditorSelector('getBlock');
3061 /**
3062 * @see getBlocks in core/block-editor store.
3063 */
3064
3065 const getBlocks = getBlockEditorSelector('getBlocks');
3066 /**
3067 * @see getClientIdsOfDescendants in core/block-editor store.
3068 */
3069
3070 const getClientIdsOfDescendants = getBlockEditorSelector('getClientIdsOfDescendants');
3071 /**
3072 * @see getClientIdsWithDescendants in core/block-editor store.
3073 */
3074
3075 const getClientIdsWithDescendants = getBlockEditorSelector('getClientIdsWithDescendants');
3076 /**
3077 * @see getGlobalBlockCount in core/block-editor store.
3078 */
3079
3080 const getGlobalBlockCount = getBlockEditorSelector('getGlobalBlockCount');
3081 /**
3082 * @see getBlocksByClientId in core/block-editor store.
3083 */
3084
3085 const getBlocksByClientId = getBlockEditorSelector('getBlocksByClientId');
3086 /**
3087 * @see getBlockCount in core/block-editor store.
3088 */
3089
3090 const getBlockCount = getBlockEditorSelector('getBlockCount');
3091 /**
3092 * @see getBlockSelectionStart in core/block-editor store.
3093 */
3094
3095 const getBlockSelectionStart = getBlockEditorSelector('getBlockSelectionStart');
3096 /**
3097 * @see getBlockSelectionEnd in core/block-editor store.
3098 */
3099
3100 const getBlockSelectionEnd = getBlockEditorSelector('getBlockSelectionEnd');
3101 /**
3102 * @see getSelectedBlockCount in core/block-editor store.
3103 */
3104
3105 const getSelectedBlockCount = getBlockEditorSelector('getSelectedBlockCount');
3106 /**
3107 * @see hasSelectedBlock in core/block-editor store.
3108 */
3109
3110 const hasSelectedBlock = getBlockEditorSelector('hasSelectedBlock');
3111 /**
3112 * @see getSelectedBlockClientId in core/block-editor store.
3113 */
3114
3115 const getSelectedBlockClientId = getBlockEditorSelector('getSelectedBlockClientId');
3116 /**
3117 * @see getSelectedBlock in core/block-editor store.
3118 */
3119
3120 const getSelectedBlock = getBlockEditorSelector('getSelectedBlock');
3121 /**
3122 * @see getBlockRootClientId in core/block-editor store.
3123 */
3124
3125 const getBlockRootClientId = getBlockEditorSelector('getBlockRootClientId');
3126 /**
3127 * @see getBlockHierarchyRootClientId in core/block-editor store.
3128 */
3129
3130 const getBlockHierarchyRootClientId = getBlockEditorSelector('getBlockHierarchyRootClientId');
3131 /**
3132 * @see getAdjacentBlockClientId in core/block-editor store.
3133 */
3134
3135 const getAdjacentBlockClientId = getBlockEditorSelector('getAdjacentBlockClientId');
3136 /**
3137 * @see getPreviousBlockClientId in core/block-editor store.
3138 */
3139
3140 const getPreviousBlockClientId = getBlockEditorSelector('getPreviousBlockClientId');
3141 /**
3142 * @see getNextBlockClientId in core/block-editor store.
3143 */
3144
3145 const getNextBlockClientId = getBlockEditorSelector('getNextBlockClientId');
3146 /**
3147 * @see getSelectedBlocksInitialCaretPosition in core/block-editor store.
3148 */
3149
3150 const getSelectedBlocksInitialCaretPosition = getBlockEditorSelector('getSelectedBlocksInitialCaretPosition');
3151 /**
3152 * @see getMultiSelectedBlockClientIds in core/block-editor store.
3153 */
3154
3155 const getMultiSelectedBlockClientIds = getBlockEditorSelector('getMultiSelectedBlockClientIds');
3156 /**
3157 * @see getMultiSelectedBlocks in core/block-editor store.
3158 */
3159
3160 const getMultiSelectedBlocks = getBlockEditorSelector('getMultiSelectedBlocks');
3161 /**
3162 * @see getFirstMultiSelectedBlockClientId in core/block-editor store.
3163 */
3164
3165 const getFirstMultiSelectedBlockClientId = getBlockEditorSelector('getFirstMultiSelectedBlockClientId');
3166 /**
3167 * @see getLastMultiSelectedBlockClientId in core/block-editor store.
3168 */
3169
3170 const getLastMultiSelectedBlockClientId = getBlockEditorSelector('getLastMultiSelectedBlockClientId');
3171 /**
3172 * @see isFirstMultiSelectedBlock in core/block-editor store.
3173 */
3174
3175 const isFirstMultiSelectedBlock = getBlockEditorSelector('isFirstMultiSelectedBlock');
3176 /**
3177 * @see isBlockMultiSelected in core/block-editor store.
3178 */
3179
3180 const isBlockMultiSelected = getBlockEditorSelector('isBlockMultiSelected');
3181 /**
3182 * @see isAncestorMultiSelected in core/block-editor store.
3183 */
3184
3185 const isAncestorMultiSelected = getBlockEditorSelector('isAncestorMultiSelected');
3186 /**
3187 * @see getMultiSelectedBlocksStartClientId in core/block-editor store.
3188 */
3189
3190 const getMultiSelectedBlocksStartClientId = getBlockEditorSelector('getMultiSelectedBlocksStartClientId');
3191 /**
3192 * @see getMultiSelectedBlocksEndClientId in core/block-editor store.
3193 */
3194
3195 const getMultiSelectedBlocksEndClientId = getBlockEditorSelector('getMultiSelectedBlocksEndClientId');
3196 /**
3197 * @see getBlockOrder in core/block-editor store.
3198 */
3199
3200 const getBlockOrder = getBlockEditorSelector('getBlockOrder');
3201 /**
3202 * @see getBlockIndex in core/block-editor store.
3203 */
3204
3205 const getBlockIndex = getBlockEditorSelector('getBlockIndex');
3206 /**
3207 * @see isBlockSelected in core/block-editor store.
3208 */
3209
3210 const isBlockSelected = getBlockEditorSelector('isBlockSelected');
3211 /**
3212 * @see hasSelectedInnerBlock in core/block-editor store.
3213 */
3214
3215 const hasSelectedInnerBlock = getBlockEditorSelector('hasSelectedInnerBlock');
3216 /**
3217 * @see isBlockWithinSelection in core/block-editor store.
3218 */
3219
3220 const isBlockWithinSelection = getBlockEditorSelector('isBlockWithinSelection');
3221 /**
3222 * @see hasMultiSelection in core/block-editor store.
3223 */
3224
3225 const hasMultiSelection = getBlockEditorSelector('hasMultiSelection');
3226 /**
3227 * @see isMultiSelecting in core/block-editor store.
3228 */
3229
3230 const isMultiSelecting = getBlockEditorSelector('isMultiSelecting');
3231 /**
3232 * @see isSelectionEnabled in core/block-editor store.
3233 */
3234
3235 const isSelectionEnabled = getBlockEditorSelector('isSelectionEnabled');
3236 /**
3237 * @see getBlockMode in core/block-editor store.
3238 */
3239
3240 const getBlockMode = getBlockEditorSelector('getBlockMode');
3241 /**
3242 * @see isTyping in core/block-editor store.
3243 */
3244
3245 const isTyping = getBlockEditorSelector('isTyping');
3246 /**
3247 * @see isCaretWithinFormattedText in core/block-editor store.
3248 */
3249
3250 const isCaretWithinFormattedText = getBlockEditorSelector('isCaretWithinFormattedText');
3251 /**
3252 * @see getBlockInsertionPoint in core/block-editor store.
3253 */
3254
3255 const getBlockInsertionPoint = getBlockEditorSelector('getBlockInsertionPoint');
3256 /**
3257 * @see isBlockInsertionPointVisible in core/block-editor store.
3258 */
3259
3260 const isBlockInsertionPointVisible = getBlockEditorSelector('isBlockInsertionPointVisible');
3261 /**
3262 * @see isValidTemplate in core/block-editor store.
3263 */
3264
3265 const isValidTemplate = getBlockEditorSelector('isValidTemplate');
3266 /**
3267 * @see getTemplate in core/block-editor store.
3268 */
3269
3270 const getTemplate = getBlockEditorSelector('getTemplate');
3271 /**
3272 * @see getTemplateLock in core/block-editor store.
3273 */
3274
3275 const getTemplateLock = getBlockEditorSelector('getTemplateLock');
3276 /**
3277 * @see canInsertBlockType in core/block-editor store.
3278 */
3279
3280 const canInsertBlockType = getBlockEditorSelector('canInsertBlockType');
3281 /**
3282 * @see getInserterItems in core/block-editor store.
3283 */
3284
3285 const getInserterItems = getBlockEditorSelector('getInserterItems');
3286 /**
3287 * @see hasInserterItems in core/block-editor store.
3288 */
3289
3290 const hasInserterItems = getBlockEditorSelector('hasInserterItems');
3291 /**
3292 * @see getBlockListSettings in core/block-editor store.
3293 */
3294
3295 const getBlockListSettings = getBlockEditorSelector('getBlockListSettings');
3296 /**
3297 * Returns the default template types.
3298 *
3299 * @param {Object} state Global application state.
3300 *
3301 * @return {Object} The template types.
3302 */
3303
3304 function __experimentalGetDefaultTemplateTypes(state) {
3305 var _getEditorSettings;
3306
3307 return (_getEditorSettings = getEditorSettings(state)) === null || _getEditorSettings === void 0 ? void 0 : _getEditorSettings.defaultTemplateTypes;
3308 }
3309 /**
3310 * Returns the default template part areas.
3311 *
3312 * @param {Object} state Global application state.
3313 *
3314 * @return {Array} The template part areas.
3315 */
3316
3317 const __experimentalGetDefaultTemplatePartAreas = rememo(state => {
3318 var _getEditorSettings2;
3319
3320 const areas = ((_getEditorSettings2 = getEditorSettings(state)) === null || _getEditorSettings2 === void 0 ? void 0 : _getEditorSettings2.defaultTemplatePartAreas) || [];
3321 return areas === null || areas === void 0 ? void 0 : areas.map(item => {
3322 return { ...item,
3323 icon: getTemplatePartIcon(item.icon)
3324 };
3325 });
3326 }, state => {
3327 var _getEditorSettings3;
3328
3329 return [(_getEditorSettings3 = getEditorSettings(state)) === null || _getEditorSettings3 === void 0 ? void 0 : _getEditorSettings3.defaultTemplatePartAreas];
3330 });
3331 /**
3332 * Returns a default template type searched by slug.
3333 *
3334 * @param {Object} state Global application state.
3335 * @param {string} slug The template type slug.
3336 *
3337 * @return {Object} The template type.
3338 */
3339
3340 const __experimentalGetDefaultTemplateType = rememo((state, slug) => (0,external_lodash_namespaceObject.find)(__experimentalGetDefaultTemplateTypes(state), {
3341 slug
3342 }) || {}, (state, slug) => [__experimentalGetDefaultTemplateTypes(state), slug]);
3343 /**
3344 * Given a template entity, return information about it which is ready to be
3345 * rendered, such as the title, description, and icon.
3346 *
3347 * @param {Object} state Global application state.
3348 * @param {Object} template The template for which we need information.
3349 * @return {Object} Information about the template, including title, description, and icon.
3350 */
3351
3352 function __experimentalGetTemplateInfo(state, template) {
3353 var _experimentalGetDefa;
3354
3355 if (!template) {
3356 return {};
3357 }
3358
3359 const {
3360 description,
3361 slug,
3362 title,
3363 area
3364 } = template;
3365
3366 const {
3367 title: defaultTitle,
3368 description: defaultDescription
3369 } = __experimentalGetDefaultTemplateType(state, slug);
3370
3371 const templateTitle = (0,external_lodash_namespaceObject.isString)(title) ? title : title === null || title === void 0 ? void 0 : title.rendered;
3372 const templateDescription = (0,external_lodash_namespaceObject.isString)(description) ? description : description === null || description === void 0 ? void 0 : description.raw;
3373 const templateIcon = ((_experimentalGetDefa = __experimentalGetDefaultTemplatePartAreas(state).find(item => area === item.area)) === null || _experimentalGetDefa === void 0 ? void 0 : _experimentalGetDefa.icon) || library_layout;
3374 return {
3375 title: templateTitle && templateTitle !== slug ? templateTitle : defaultTitle || slug,
3376 description: templateDescription || defaultDescription,
3377 icon: templateIcon
3378 };
3379 }
3380 /**
3381 * Returns a post type label depending on the current post.
3382 *
3383 * @param {Object} state Global application state.
3384 *
3385 * @return {string|undefined} The post type label if available, otherwise undefined.
3386 */
3387
3388 const getPostTypeLabel = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3389 var _postType$labels;
3390
3391 const currentPostType = getCurrentPostType(state);
3392 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(currentPostType); // Disable reason: Post type labels object is shaped like this.
3393 // eslint-disable-next-line camelcase
3394
3395 return postType === null || postType === void 0 ? void 0 : (_postType$labels = postType.labels) === null || _postType$labels === void 0 ? void 0 : _postType$labels.singular_name;
3396 });
3397
3398 ;// CONCATENATED MODULE: external ["wp","apiFetch"]
3399 const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
3400 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
3401 ;// CONCATENATED MODULE: external ["wp","notices"]
3402 const external_wp_notices_namespaceObject = window["wp"]["notices"];
3403 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/local-autosave.js
3404 /**
3405 * Function returning a sessionStorage key to set or retrieve a given post's
3406 * automatic session backup.
3407 *
3408 * Keys are crucially prefixed with 'wp-autosave-' so that wp-login.php's
3409 * `loggedout` handler can clear sessionStorage of any user-private content.
3410 *
3411 * @see https://github.com/WordPress/wordpress-develop/blob/6dad32d2aed47e6c0cf2aee8410645f6d7aba6bd/src/wp-login.php#L103
3412 *
3413 * @param {string} postId Post ID.
3414 * @param {boolean} isPostNew Whether post new.
3415 *
3416 * @return {string} sessionStorage key
3417 */
3418 function postKey(postId, isPostNew) {
3419 return `wp-autosave-block-editor-post-${isPostNew ? 'auto-draft' : postId}`;
3420 }
3421
3422 function localAutosaveGet(postId, isPostNew) {
3423 return window.sessionStorage.getItem(postKey(postId, isPostNew));
3424 }
3425 function localAutosaveSet(postId, isPostNew, title, content, excerpt) {
3426 window.sessionStorage.setItem(postKey(postId, isPostNew), JSON.stringify({
3427 post_title: title,
3428 content,
3429 excerpt
3430 }));
3431 }
3432 function localAutosaveClear(postId, isPostNew) {
3433 window.sessionStorage.removeItem(postKey(postId, isPostNew));
3434 }
3435
3436 ;// CONCATENATED MODULE: external ["wp","i18n"]
3437 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
3438 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/utils/notice-builder.js
3439 /**
3440 * WordPress dependencies
3441 */
3442
3443 /**
3444 * Internal dependencies
3445 */
3446
3447
3448 /**
3449 * External dependencies
3450 */
3451
3452
3453 /**
3454 * Builds the arguments for a success notification dispatch.
3455 *
3456 * @param {Object} data Incoming data to build the arguments from.
3457 *
3458 * @return {Array} Arguments for dispatch. An empty array signals no
3459 * notification should be sent.
3460 */
3461
3462 function getNotificationArgumentsForSaveSuccess(data) {
3463 const {
3464 previousPost,
3465 post,
3466 postType
3467 } = data; // Autosaves are neither shown a notice nor redirected.
3468
3469 if ((0,external_lodash_namespaceObject.get)(data.options, ['isAutosave'])) {
3470 return [];
3471 } // No notice is shown after trashing a post
3472
3473
3474 if (post.status === 'trash' && previousPost.status !== 'trash') {
3475 return [];
3476 }
3477
3478 const publishStatus = ['publish', 'private', 'future'];
3479 const isPublished = (0,external_lodash_namespaceObject.includes)(publishStatus, previousPost.status);
3480 const willPublish = (0,external_lodash_namespaceObject.includes)(publishStatus, post.status);
3481 let noticeMessage;
3482 let shouldShowLink = (0,external_lodash_namespaceObject.get)(postType, ['viewable'], false);
3483 let isDraft; // Always should a notice, which will be spoken for accessibility.
3484
3485 if (!isPublished && !willPublish) {
3486 // If saving a non-published post, don't show notice.
3487 noticeMessage = (0,external_wp_i18n_namespaceObject.__)('Draft saved.');
3488 isDraft = true;
3489 } else if (isPublished && !willPublish) {
3490 // If undoing publish status, show specific notice.
3491 noticeMessage = postType.labels.item_reverted_to_draft;
3492 shouldShowLink = false;
3493 } else if (!isPublished && willPublish) {
3494 // If publishing or scheduling a post, show the corresponding
3495 // publish message.
3496 noticeMessage = {
3497 publish: postType.labels.item_published,
3498 private: postType.labels.item_published_privately,
3499 future: postType.labels.item_scheduled
3500 }[post.status];
3501 } else {
3502 // Generic fallback notice.
3503 noticeMessage = postType.labels.item_updated;
3504 }
3505
3506 const actions = [];
3507
3508 if (shouldShowLink) {
3509 actions.push({
3510 label: isDraft ? (0,external_wp_i18n_namespaceObject.__)('View Preview') : postType.labels.view_item,
3511 url: post.link
3512 });
3513 }
3514
3515 return [noticeMessage, {
3516 id: SAVE_POST_NOTICE_ID,
3517 type: 'snackbar',
3518 actions
3519 }];
3520 }
3521 /**
3522 * Builds the fail notification arguments for dispatch.
3523 *
3524 * @param {Object} data Incoming data to build the arguments with.
3525 *
3526 * @return {Array} Arguments for dispatch. An empty array signals no
3527 * notification should be sent.
3528 */
3529
3530 function getNotificationArgumentsForSaveFail(data) {
3531 const {
3532 post,
3533 edits,
3534 error
3535 } = data;
3536
3537 if (error && 'rest_autosave_no_changes' === error.code) {
3538 // Autosave requested a new autosave, but there were no changes. This shouldn't
3539 // result in an error notice for the user.
3540 return [];
3541 }
3542
3543 const publishStatus = ['publish', 'private', 'future'];
3544 const isPublished = publishStatus.indexOf(post.status) !== -1; // If the post was being published, we show the corresponding publish error message
3545 // Unless we publish an "updating failed" message.
3546
3547 const messages = {
3548 publish: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'),
3549 private: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'),
3550 future: (0,external_wp_i18n_namespaceObject.__)('Scheduling failed.')
3551 };
3552 let noticeMessage = !isPublished && publishStatus.indexOf(edits.status) !== -1 ? messages[edits.status] : (0,external_wp_i18n_namespaceObject.__)('Updating failed.'); // Check if message string contains HTML. Notice text is currently only
3553 // supported as plaintext, and stripping the tags may muddle the meaning.
3554
3555 if (error.message && !/<\/?[^>]*>/.test(error.message)) {
3556 noticeMessage = [noticeMessage, error.message].join(' ');
3557 }
3558
3559 return [noticeMessage, {
3560 id: SAVE_POST_NOTICE_ID
3561 }];
3562 }
3563 /**
3564 * Builds the trash fail notification arguments for dispatch.
3565 *
3566 * @param {Object} data
3567 *
3568 * @return {Array} Arguments for dispatch.
3569 */
3570
3571 function getNotificationArgumentsForTrashFail(data) {
3572 return [data.error.message && data.error.code !== 'unknown_error' ? data.error.message : (0,external_wp_i18n_namespaceObject.__)('Trashing failed'), {
3573 id: TRASH_POST_NOTICE_ID
3574 }];
3575 }
3576
3577 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/actions.js
3578 /**
3579 * External dependencies
3580 */
3581
3582 /**
3583 * WordPress dependencies
3584 */
3585
3586
3587
3588
3589
3590
3591
3592
3593 /**
3594 * Internal dependencies
3595 */
3596
3597
3598
3599
3600 /**
3601 * Returns an action generator used in signalling that editor has initialized with
3602 * the specified post object and editor settings.
3603 *
3604 * @param {Object} post Post object.
3605 * @param {Object} edits Initial edited attributes object.
3606 * @param {Array?} template Block Template.
3607 */
3608
3609 const setupEditor = (post, edits, template) => _ref => {
3610 let {
3611 dispatch
3612 } = _ref;
3613 dispatch.setupEditorState(post); // Apply a template for new posts only, if exists.
3614
3615 const isNewPost = post.status === 'auto-draft';
3616
3617 if (isNewPost && template) {
3618 // In order to ensure maximum of a single parse during setup, edits are
3619 // included as part of editor setup action. Assume edited content as
3620 // canonical if provided, falling back to post.
3621 let content;
3622
3623 if ((0,external_lodash_namespaceObject.has)(edits, ['content'])) {
3624 content = edits.content;
3625 } else {
3626 content = post.content.raw;
3627 }
3628
3629 let blocks = (0,external_wp_blocks_namespaceObject.parse)(content);
3630 blocks = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(blocks, template);
3631 dispatch.resetEditorBlocks(blocks, {
3632 __unstableShouldCreateUndoLevel: false
3633 });
3634 }
3635
3636 if (edits && Object.values(edits).some(_ref2 => {
3637 var _post$key$raw, _post$key;
3638
3639 let [key, edit] = _ref2;
3640 return edit !== ((_post$key$raw = (_post$key = post[key]) === null || _post$key === void 0 ? void 0 : _post$key.raw) !== null && _post$key$raw !== void 0 ? _post$key$raw : post[key]);
3641 })) {
3642 dispatch.editPost(edits);
3643 }
3644 };
3645 /**
3646 * Returns an action object signalling that the editor is being destroyed and
3647 * that any necessary state or side-effect cleanup should occur.
3648 *
3649 * @return {Object} Action object.
3650 */
3651
3652 function __experimentalTearDownEditor() {
3653 return {
3654 type: 'TEAR_DOWN_EDITOR'
3655 };
3656 }
3657 /**
3658 * Returns an action object used in signalling that the latest version of the
3659 * post has been received, either by initialization or save.
3660 *
3661 * @deprecated Since WordPress 6.0.
3662 */
3663
3664 function resetPost() {
3665 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).resetPost", {
3666 since: '6.0',
3667 version: '6.3',
3668 alternative: 'Initialize the editor with the setupEditorState action'
3669 });
3670 return {
3671 type: 'DO_NOTHING'
3672 };
3673 }
3674 /**
3675 * Returns an action object used in signalling that a patch of updates for the
3676 * latest version of the post have been received.
3677 *
3678 * @return {Object} Action object.
3679 * @deprecated since Gutenberg 9.7.0.
3680 */
3681
3682 function updatePost() {
3683 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).updatePost", {
3684 since: '5.7',
3685 alternative: 'Use the core entities store instead'
3686 });
3687 return {
3688 type: 'DO_NOTHING'
3689 };
3690 }
3691 /**
3692 * Returns an action object used to setup the editor state when first opening
3693 * an editor.
3694 *
3695 * @param {Object} post Post object.
3696 *
3697 * @return {Object} Action object.
3698 */
3699
3700 function setupEditorState(post) {
3701 return {
3702 type: 'SETUP_EDITOR_STATE',
3703 post
3704 };
3705 }
3706 /**
3707 * Returns an action object used in signalling that attributes of the post have
3708 * been edited.
3709 *
3710 * @param {Object} edits Post attributes to edit.
3711 * @param {Object} options Options for the edit.
3712 */
3713
3714 const editPost = (edits, options) => _ref3 => {
3715 let {
3716 select,
3717 registry
3718 } = _ref3;
3719 const {
3720 id,
3721 type
3722 } = select.getCurrentPost();
3723 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', type, id, edits, options);
3724 };
3725 /**
3726 * Action for saving the current post in the editor.
3727 *
3728 * @param {Object} options
3729 */
3730
3731 const savePost = function () {
3732 let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3733 return async _ref4 => {
3734 let {
3735 select,
3736 dispatch,
3737 registry
3738 } = _ref4;
3739
3740 if (!select.isEditedPostSaveable()) {
3741 return;
3742 }
3743
3744 const content = select.getEditedPostContent();
3745
3746 if (!options.isAutosave) {
3747 dispatch.editPost({
3748 content
3749 }, {
3750 undoIgnore: true
3751 });
3752 }
3753
3754 const previousRecord = select.getCurrentPost();
3755 const edits = {
3756 id: previousRecord.id,
3757 ...registry.select(external_wp_coreData_namespaceObject.store).getEntityRecordNonTransientEdits('postType', previousRecord.type, previousRecord.id),
3758 content
3759 };
3760 dispatch({
3761 type: 'REQUEST_POST_UPDATE_START',
3762 options
3763 });
3764 await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', previousRecord.type, edits, options);
3765 dispatch({
3766 type: 'REQUEST_POST_UPDATE_FINISH',
3767 options
3768 });
3769 const error = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', previousRecord.type, previousRecord.id);
3770
3771 if (error) {
3772 const args = getNotificationArgumentsForSaveFail({
3773 post: previousRecord,
3774 edits,
3775 error
3776 });
3777
3778 if (args.length) {
3779 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...args);
3780 }
3781 } else {
3782 const updatedRecord = select.getCurrentPost();
3783 const args = getNotificationArgumentsForSaveSuccess({
3784 previousPost: previousRecord,
3785 post: updatedRecord,
3786 postType: await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(updatedRecord.type),
3787 options
3788 });
3789
3790 if (args.length) {
3791 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(...args);
3792 } // Make sure that any edits after saving create an undo level and are
3793 // considered for change detection.
3794
3795
3796 if (!options.isAutosave) {
3797 registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableMarkLastChangeAsPersistent();
3798 }
3799 }
3800 };
3801 };
3802 /**
3803 * Action for refreshing the current post.
3804 *
3805 * @deprecated Since WordPress 6.0.
3806 */
3807
3808 function refreshPost() {
3809 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).refreshPost", {
3810 since: '6.0',
3811 version: '6.3',
3812 alternative: 'Use the core entities store instead'
3813 });
3814 return {
3815 type: 'DO_NOTHING'
3816 };
3817 }
3818 /**
3819 * Action for trashing the current post in the editor.
3820 */
3821
3822 const trashPost = () => async _ref5 => {
3823 let {
3824 select,
3825 dispatch,
3826 registry
3827 } = _ref5;
3828 const postTypeSlug = select.getCurrentPostType();
3829 const postType = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
3830 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(TRASH_POST_NOTICE_ID);
3831
3832 try {
3833 const post = select.getCurrentPost();
3834 await external_wp_apiFetch_default()({
3835 path: `/wp/v2/${postType.rest_base}/${post.id}`,
3836 method: 'DELETE'
3837 });
3838 await dispatch.savePost();
3839 } catch (error) {
3840 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...getNotificationArgumentsForTrashFail({
3841 error
3842 }));
3843 }
3844 };
3845 /**
3846 * Action that autosaves the current post. This
3847 * includes server-side autosaving (default) and client-side (a.k.a. local)
3848 * autosaving (e.g. on the Web, the post might be committed to Session
3849 * Storage).
3850 *
3851 * @param {Object?} options Extra flags to identify the autosave.
3852 */
3853
3854 const autosave = function () {
3855 let {
3856 local = false,
3857 ...options
3858 } = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
3859 return async _ref6 => {
3860 let {
3861 select,
3862 dispatch
3863 } = _ref6;
3864
3865 if (local) {
3866 const post = select.getCurrentPost();
3867 const isPostNew = select.isEditedPostNew();
3868 const title = select.getEditedPostAttribute('title');
3869 const content = select.getEditedPostAttribute('content');
3870 const excerpt = select.getEditedPostAttribute('excerpt');
3871 localAutosaveSet(post.id, isPostNew, title, content, excerpt);
3872 } else {
3873 await dispatch.savePost({
3874 isAutosave: true,
3875 ...options
3876 });
3877 }
3878 };
3879 };
3880 /**
3881 * Action that restores last popped state in undo history.
3882 */
3883
3884 const redo = () => _ref7 => {
3885 let {
3886 registry
3887 } = _ref7;
3888 registry.dispatch(external_wp_coreData_namespaceObject.store).redo();
3889 };
3890 /**
3891 * Action that pops a record from undo history and undoes the edit.
3892 */
3893
3894 const undo = () => _ref8 => {
3895 let {
3896 registry
3897 } = _ref8;
3898 registry.dispatch(external_wp_coreData_namespaceObject.store).undo();
3899 };
3900 /**
3901 * Action that creates an undo history record.
3902 *
3903 * @deprecated Since WordPress 6.0
3904 */
3905
3906 function createUndoLevel() {
3907 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).createUndoLevel", {
3908 since: '6.0',
3909 version: '6.3',
3910 alternative: 'Use the core entities store instead'
3911 });
3912 return {
3913 type: 'DO_NOTHING'
3914 };
3915 }
3916 /**
3917 * Action that locks the editor.
3918 *
3919 * @param {Object} lock Details about the post lock status, user, and nonce.
3920 * @return {Object} Action object.
3921 */
3922
3923 function updatePostLock(lock) {
3924 return {
3925 type: 'UPDATE_POST_LOCK',
3926 lock
3927 };
3928 }
3929 /**
3930 * Enable the publish sidebar.
3931 */
3932
3933 const enablePublishSidebar = () => _ref9 => {
3934 let {
3935 registry
3936 } = _ref9;
3937 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core/edit-post', 'isPublishSidebarEnabled', true);
3938 };
3939 /**
3940 * Disables the publish sidebar.
3941 */
3942
3943 const disablePublishSidebar = () => _ref10 => {
3944 let {
3945 registry
3946 } = _ref10;
3947 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core/edit-post', 'isPublishSidebarEnabled', false);
3948 };
3949 /**
3950 * Action that locks post saving.
3951 *
3952 * @param {string} lockName The lock name.
3953 *
3954 * @example
3955 * ```
3956 * const { subscribe } = wp.data;
3957 *
3958 * const initialPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
3959 *
3960 * // Only allow publishing posts that are set to a future date.
3961 * if ( 'publish' !== initialPostStatus ) {
3962 *
3963 * // Track locking.
3964 * let locked = false;
3965 *
3966 * // Watch for the publish event.
3967 * let unssubscribe = subscribe( () => {
3968 * const currentPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
3969 * if ( 'publish' !== currentPostStatus ) {
3970 *
3971 * // Compare the post date to the current date, lock the post if the date isn't in the future.
3972 * const postDate = new Date( wp.data.select( 'core/editor' ).getEditedPostAttribute( 'date' ) );
3973 * const currentDate = new Date();
3974 * if ( postDate.getTime() <= currentDate.getTime() ) {
3975 * if ( ! locked ) {
3976 * locked = true;
3977 * wp.data.dispatch( 'core/editor' ).lockPostSaving( 'futurelock' );
3978 * }
3979 * } else {
3980 * if ( locked ) {
3981 * locked = false;
3982 * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'futurelock' );
3983 * }
3984 * }
3985 * }
3986 * } );
3987 * }
3988 * ```
3989 *
3990 * @return {Object} Action object
3991 */
3992
3993 function lockPostSaving(lockName) {
3994 return {
3995 type: 'LOCK_POST_SAVING',
3996 lockName
3997 };
3998 }
3999 /**
4000 * Action that unlocks post saving.
4001 *
4002 * @param {string} lockName The lock name.
4003 *
4004 * @example
4005 * ```
4006 * // Unlock post saving with the lock key `mylock`:
4007 * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'mylock' );
4008 * ```
4009 *
4010 * @return {Object} Action object
4011 */
4012
4013 function unlockPostSaving(lockName) {
4014 return {
4015 type: 'UNLOCK_POST_SAVING',
4016 lockName
4017 };
4018 }
4019 /**
4020 * Action that locks post autosaving.
4021 *
4022 * @param {string} lockName The lock name.
4023 *
4024 * @example
4025 * ```
4026 * // Lock post autosaving with the lock key `mylock`:
4027 * wp.data.dispatch( 'core/editor' ).lockPostAutosaving( 'mylock' );
4028 * ```
4029 *
4030 * @return {Object} Action object
4031 */
4032
4033 function lockPostAutosaving(lockName) {
4034 return {
4035 type: 'LOCK_POST_AUTOSAVING',
4036 lockName
4037 };
4038 }
4039 /**
4040 * Action that unlocks post autosaving.
4041 *
4042 * @param {string} lockName The lock name.
4043 *
4044 * @example
4045 * ```
4046 * // Unlock post saving with the lock key `mylock`:
4047 * wp.data.dispatch( 'core/editor' ).unlockPostAutosaving( 'mylock' );
4048 * ```
4049 *
4050 * @return {Object} Action object
4051 */
4052
4053 function unlockPostAutosaving(lockName) {
4054 return {
4055 type: 'UNLOCK_POST_AUTOSAVING',
4056 lockName
4057 };
4058 }
4059 /**
4060 * Returns an action object used to signal that the blocks have been updated.
4061 *
4062 * @param {Array} blocks Block Array.
4063 * @param {?Object} options Optional options.
4064 */
4065
4066 const resetEditorBlocks = function (blocks) {
4067 let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4068 return _ref11 => {
4069 let {
4070 select,
4071 dispatch,
4072 registry
4073 } = _ref11;
4074 const {
4075 __unstableShouldCreateUndoLevel,
4076 selection
4077 } = options;
4078 const edits = {
4079 blocks,
4080 selection
4081 };
4082
4083 if (__unstableShouldCreateUndoLevel !== false) {
4084 const {
4085 id,
4086 type
4087 } = select.getCurrentPost();
4088 const noChange = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', type, id).blocks === edits.blocks;
4089
4090 if (noChange) {
4091 registry.dispatch(external_wp_coreData_namespaceObject.store).__unstableCreateUndoLevel('postType', type, id);
4092
4093 return;
4094 } // We create a new function here on every persistent edit
4095 // to make sure the edit makes the post dirty and creates
4096 // a new undo level.
4097
4098
4099 edits.content = _ref12 => {
4100 let {
4101 blocks: blocksForSerialization = []
4102 } = _ref12;
4103 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
4104 };
4105 }
4106
4107 dispatch.editPost(edits);
4108 };
4109 };
4110 /*
4111 * Returns an action object used in signalling that the post editor settings have been updated.
4112 *
4113 * @param {Object} settings Updated settings
4114 *
4115 * @return {Object} Action object
4116 */
4117
4118 function updateEditorSettings(settings) {
4119 return {
4120 type: 'UPDATE_EDITOR_SETTINGS',
4121 settings
4122 };
4123 }
4124 /**
4125 * Backward compatibility
4126 */
4127
4128 const getBlockEditorAction = name => function () {
4129 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
4130 args[_key] = arguments[_key];
4131 }
4132
4133 return _ref13 => {
4134 let {
4135 registry
4136 } = _ref13;
4137 external_wp_deprecated_default()("`wp.data.dispatch( 'core/editor' )." + name + '`', {
4138 since: '5.3',
4139 alternative: "`wp.data.dispatch( 'core/block-editor' )." + name + '`',
4140 version: '6.2'
4141 });
4142 registry.dispatch(external_wp_blockEditor_namespaceObject.store)[name](...args);
4143 };
4144 };
4145 /**
4146 * @see resetBlocks in core/block-editor store.
4147 */
4148
4149
4150 const resetBlocks = getBlockEditorAction('resetBlocks');
4151 /**
4152 * @see receiveBlocks in core/block-editor store.
4153 */
4154
4155 const receiveBlocks = getBlockEditorAction('receiveBlocks');
4156 /**
4157 * @see updateBlock in core/block-editor store.
4158 */
4159
4160 const updateBlock = getBlockEditorAction('updateBlock');
4161 /**
4162 * @see updateBlockAttributes in core/block-editor store.
4163 */
4164
4165 const updateBlockAttributes = getBlockEditorAction('updateBlockAttributes');
4166 /**
4167 * @see selectBlock in core/block-editor store.
4168 */
4169
4170 const selectBlock = getBlockEditorAction('selectBlock');
4171 /**
4172 * @see startMultiSelect in core/block-editor store.
4173 */
4174
4175 const startMultiSelect = getBlockEditorAction('startMultiSelect');
4176 /**
4177 * @see stopMultiSelect in core/block-editor store.
4178 */
4179
4180 const stopMultiSelect = getBlockEditorAction('stopMultiSelect');
4181 /**
4182 * @see multiSelect in core/block-editor store.
4183 */
4184
4185 const multiSelect = getBlockEditorAction('multiSelect');
4186 /**
4187 * @see clearSelectedBlock in core/block-editor store.
4188 */
4189
4190 const clearSelectedBlock = getBlockEditorAction('clearSelectedBlock');
4191 /**
4192 * @see toggleSelection in core/block-editor store.
4193 */
4194
4195 const toggleSelection = getBlockEditorAction('toggleSelection');
4196 /**
4197 * @see replaceBlocks in core/block-editor store.
4198 */
4199
4200 const replaceBlocks = getBlockEditorAction('replaceBlocks');
4201 /**
4202 * @see replaceBlock in core/block-editor store.
4203 */
4204
4205 const replaceBlock = getBlockEditorAction('replaceBlock');
4206 /**
4207 * @see moveBlocksDown in core/block-editor store.
4208 */
4209
4210 const moveBlocksDown = getBlockEditorAction('moveBlocksDown');
4211 /**
4212 * @see moveBlocksUp in core/block-editor store.
4213 */
4214
4215 const moveBlocksUp = getBlockEditorAction('moveBlocksUp');
4216 /**
4217 * @see moveBlockToPosition in core/block-editor store.
4218 */
4219
4220 const moveBlockToPosition = getBlockEditorAction('moveBlockToPosition');
4221 /**
4222 * @see insertBlock in core/block-editor store.
4223 */
4224
4225 const insertBlock = getBlockEditorAction('insertBlock');
4226 /**
4227 * @see insertBlocks in core/block-editor store.
4228 */
4229
4230 const insertBlocks = getBlockEditorAction('insertBlocks');
4231 /**
4232 * @see showInsertionPoint in core/block-editor store.
4233 */
4234
4235 const showInsertionPoint = getBlockEditorAction('showInsertionPoint');
4236 /**
4237 * @see hideInsertionPoint in core/block-editor store.
4238 */
4239
4240 const hideInsertionPoint = getBlockEditorAction('hideInsertionPoint');
4241 /**
4242 * @see setTemplateValidity in core/block-editor store.
4243 */
4244
4245 const setTemplateValidity = getBlockEditorAction('setTemplateValidity');
4246 /**
4247 * @see synchronizeTemplate in core/block-editor store.
4248 */
4249
4250 const synchronizeTemplate = getBlockEditorAction('synchronizeTemplate');
4251 /**
4252 * @see mergeBlocks in core/block-editor store.
4253 */
4254
4255 const mergeBlocks = getBlockEditorAction('mergeBlocks');
4256 /**
4257 * @see removeBlocks in core/block-editor store.
4258 */
4259
4260 const removeBlocks = getBlockEditorAction('removeBlocks');
4261 /**
4262 * @see removeBlock in core/block-editor store.
4263 */
4264
4265 const removeBlock = getBlockEditorAction('removeBlock');
4266 /**
4267 * @see toggleBlockMode in core/block-editor store.
4268 */
4269
4270 const toggleBlockMode = getBlockEditorAction('toggleBlockMode');
4271 /**
4272 * @see startTyping in core/block-editor store.
4273 */
4274
4275 const startTyping = getBlockEditorAction('startTyping');
4276 /**
4277 * @see stopTyping in core/block-editor store.
4278 */
4279
4280 const stopTyping = getBlockEditorAction('stopTyping');
4281 /**
4282 * @see enterFormattedText in core/block-editor store.
4283 */
4284
4285 const enterFormattedText = getBlockEditorAction('enterFormattedText');
4286 /**
4287 * @see exitFormattedText in core/block-editor store.
4288 */
4289
4290 const exitFormattedText = getBlockEditorAction('exitFormattedText');
4291 /**
4292 * @see insertDefaultBlock in core/block-editor store.
4293 */
4294
4295 const insertDefaultBlock = getBlockEditorAction('insertDefaultBlock');
4296 /**
4297 * @see updateBlockListSettings in core/block-editor store.
4298 */
4299
4300 const updateBlockListSettings = getBlockEditorAction('updateBlockListSettings');
4301
4302 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/index.js
4303 /**
4304 * WordPress dependencies
4305 */
4306
4307 /**
4308 * Internal dependencies
4309 */
4310
4311
4312
4313
4314
4315 /**
4316 * Post editor data store configuration.
4317 *
4318 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
4319 *
4320 * @type {Object}
4321 */
4322
4323 const storeConfig = {
4324 reducer: reducer,
4325 selectors: selectors_namespaceObject,
4326 actions: actions_namespaceObject
4327 };
4328 /**
4329 * Store definition for the editor namespace.
4330 *
4331 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
4332 *
4333 * @type {Object}
4334 */
4335
4336 const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, { ...storeConfig
4337 });
4338 (0,external_wp_data_namespaceObject.register)(store_store);
4339
4340 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/custom-sources-backwards-compatibility.js
4341
4342
4343
4344 /**
4345 * External dependencies
4346 */
4347
4348 /**
4349 * WordPress dependencies
4350 */
4351
4352
4353
4354
4355
4356
4357
4358 /**
4359 * Internal dependencies
4360 */
4361
4362
4363 /** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */
4364
4365 /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
4366
4367 /**
4368 * Object whose keys are the names of block attributes, where each value
4369 * represents the meta key to which the block attribute is intended to save.
4370 *
4371 * @see https://developer.wordpress.org/reference/functions/register_meta/
4372 *
4373 * @typedef {Object<string,string>} WPMetaAttributeMapping
4374 */
4375
4376 /**
4377 * Given a mapping of attribute names (meta source attributes) to their
4378 * associated meta key, returns a higher order component that overrides its
4379 * `attributes` and `setAttributes` props to sync any changes with the edited
4380 * post's meta keys.
4381 *
4382 * @param {WPMetaAttributeMapping} metaAttributes Meta attribute mapping.
4383 *
4384 * @return {WPHigherOrderComponent} Higher-order component.
4385 */
4386
4387 const createWithMetaAttributeSource = metaAttributes => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => _ref => {
4388 let {
4389 attributes,
4390 setAttributes,
4391 ...props
4392 } = _ref;
4393 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
4394 const [meta, setMeta] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', postType, 'meta');
4395 const mergedAttributes = (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...attributes,
4396 ...(0,external_lodash_namespaceObject.mapValues)(metaAttributes, metaKey => meta[metaKey])
4397 }), [attributes, meta]);
4398 return (0,external_wp_element_namespaceObject.createElement)(BlockEdit, _extends({
4399 attributes: mergedAttributes,
4400 setAttributes: nextAttributes => {
4401 const nextMeta = (0,external_lodash_namespaceObject.mapKeys)( // Filter to intersection of keys between the updated
4402 // attributes and those with an associated meta key.
4403 (0,external_lodash_namespaceObject.pickBy)(nextAttributes, (value, key) => metaAttributes[key]), // Rename the keys to the expected meta key name.
4404 (value, attributeKey) => metaAttributes[attributeKey]);
4405
4406 if (!(0,external_lodash_namespaceObject.isEmpty)(nextMeta)) {
4407 setMeta(nextMeta);
4408 }
4409
4410 setAttributes(nextAttributes);
4411 }
4412 }, props));
4413 }, 'withMetaAttributeSource');
4414 /**
4415 * Filters a registered block's settings to enhance a block's `edit` component
4416 * to upgrade meta-sourced attributes to use the post's meta entity property.
4417 *
4418 * @param {WPBlockSettings} settings Registered block settings.
4419 *
4420 * @return {WPBlockSettings} Filtered block settings.
4421 */
4422
4423
4424 function shimAttributeSource(settings) {
4425 /** @type {WPMetaAttributeMapping} */
4426 const metaAttributes = (0,external_lodash_namespaceObject.mapValues)((0,external_lodash_namespaceObject.pickBy)(settings.attributes, {
4427 source: 'meta'
4428 }), 'meta');
4429
4430 if (!(0,external_lodash_namespaceObject.isEmpty)(metaAttributes)) {
4431 settings.edit = createWithMetaAttributeSource(metaAttributes)(settings.edit);
4432 }
4433
4434 return settings;
4435 }
4436
4437 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/editor/custom-sources-backwards-compatibility/shim-attribute-source', shimAttributeSource); // The above filter will only capture blocks registered after the filter was
4438 // added. There may already be blocks registered by this point, and those must
4439 // be updated to apply the shim.
4440 //
4441 // The following implementation achieves this, albeit with a couple caveats:
4442 // - Only blocks registered on the global store will be modified.
4443 // - The block settings are directly mutated, since there is currently no
4444 // mechanism to update an existing block registration. This is the reason for
4445 // `getBlockType` separate from `getBlockTypes`, since the latter returns a
4446 // _copy_ of the block registration (i.e. the mutation would not affect the
4447 // actual registered block settings).
4448 //
4449 // `getBlockTypes` or `getBlockType` implementation could change in the future
4450 // in regards to creating settings clones, but the corresponding end-to-end
4451 // tests for meta blocks should cover against any potential regressions.
4452 //
4453 // In the future, we could support updating block settings, at which point this
4454 // implementation could use that mechanism instead.
4455
4456 (0,external_wp_data_namespaceObject.select)(external_wp_blocks_namespaceObject.store).getBlockTypes().map(_ref2 => {
4457 let {
4458 name
4459 } = _ref2;
4460 return (0,external_wp_data_namespaceObject.select)(external_wp_blocks_namespaceObject.store).getBlockType(name);
4461 }).forEach(shimAttributeSource);
4462
4463 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/autocompleters/user.js
4464
4465
4466 /**
4467 * WordPress dependencies
4468 */
4469
4470
4471
4472 /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
4473
4474 function getUserLabel(user) {
4475 const avatar = user.avatar_urls && user.avatar_urls[24] ? (0,external_wp_element_namespaceObject.createElement)("img", {
4476 className: "editor-autocompleters__user-avatar",
4477 alt: "",
4478 src: user.avatar_urls[24]
4479 }) : (0,external_wp_element_namespaceObject.createElement)("span", {
4480 className: "editor-autocompleters__no-avatar"
4481 });
4482 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, avatar, (0,external_wp_element_namespaceObject.createElement)("span", {
4483 className: "editor-autocompleters__user-name"
4484 }, user.name), (0,external_wp_element_namespaceObject.createElement)("span", {
4485 className: "editor-autocompleters__user-slug"
4486 }, user.slug));
4487 }
4488 /**
4489 * A user mentions completer.
4490 *
4491 * @type {WPCompleter}
4492 */
4493
4494 /* harmony default export */ const user = ({
4495 name: 'users',
4496 className: 'editor-autocompleters__user',
4497 triggerPrefix: '@',
4498
4499 useItems(filterValue) {
4500 const users = (0,external_wp_data_namespaceObject.useSelect)(select => {
4501 const {
4502 getUsers
4503 } = select(external_wp_coreData_namespaceObject.store);
4504 return getUsers({
4505 context: 'view',
4506 search: encodeURIComponent(filterValue)
4507 });
4508 }, [filterValue]);
4509 const options = (0,external_wp_element_namespaceObject.useMemo)(() => users ? users.map(user => ({
4510 key: `user-${user.slug}`,
4511 value: user,
4512 label: getUserLabel(user)
4513 })) : [], [users]);
4514 return [options];
4515 },
4516
4517 getOptionCompletion(user) {
4518 return `@${user.slug}`;
4519 }
4520
4521 });
4522
4523 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/default-autocompleters.js
4524 /**
4525 * External dependencies
4526 */
4527
4528 /**
4529 * WordPress dependencies
4530 */
4531
4532
4533 /**
4534 * Internal dependencies
4535 */
4536
4537
4538
4539 function setDefaultCompleters() {
4540 let completers = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
4541 // Provide copies so filters may directly modify them.
4542 completers.push((0,external_lodash_namespaceObject.clone)(user));
4543 return completers;
4544 }
4545
4546 (0,external_wp_hooks_namespaceObject.addFilter)('editor.Autocomplete.completers', 'editor/autocompleters/set-default-completers', setDefaultCompleters);
4547
4548 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/index.js
4549 /**
4550 * Internal dependencies
4551 */
4552
4553
4554
4555 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/autocompleters/index.js
4556
4557
4558 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/autosave-monitor/index.js
4559 /**
4560 * WordPress dependencies
4561 */
4562
4563
4564
4565
4566 /**
4567 * Internal dependencies
4568 */
4569
4570
4571 /**
4572 * AutosaveMonitor invokes `props.autosave()` within at most `interval` seconds after an unsaved change is detected.
4573 *
4574 * The logic is straightforward: a check is performed every `props.interval` seconds. If any changes are detected, `props.autosave()` is called.
4575 * The time between the change and the autosave varies but is no larger than `props.interval` seconds. Refer to the code below for more details, such as
4576 * the specific way of detecting changes.
4577 *
4578 * There are two caveats:
4579 * * If `props.isAutosaveable` happens to be false at a time of checking for changes, the check is retried every second.
4580 * * The timer may be disabled by setting `props.disableIntervalChecks` to `true`. In that mode, any change will immediately trigger `props.autosave()`.
4581 */
4582
4583 class AutosaveMonitor extends external_wp_element_namespaceObject.Component {
4584 constructor(props) {
4585 super(props);
4586 this.needsAutosave = !!(props.isDirty && props.isAutosaveable);
4587 }
4588
4589 componentDidMount() {
4590 if (!this.props.disableIntervalChecks) {
4591 this.setAutosaveTimer();
4592 }
4593 }
4594
4595 componentDidUpdate(prevProps) {
4596 if (this.props.disableIntervalChecks) {
4597 if (this.props.editsReference !== prevProps.editsReference) {
4598 this.props.autosave();
4599 }
4600
4601 return;
4602 }
4603
4604 if (this.props.interval !== prevProps.interval) {
4605 clearTimeout(this.timerId);
4606 this.setAutosaveTimer();
4607 }
4608
4609 if (!this.props.isDirty) {
4610 this.needsAutosave = false;
4611 return;
4612 }
4613
4614 if (this.props.isAutosaving && !prevProps.isAutosaving) {
4615 this.needsAutosave = false;
4616 return;
4617 }
4618
4619 if (this.props.editsReference !== prevProps.editsReference) {
4620 this.needsAutosave = true;
4621 }
4622 }
4623
4624 componentWillUnmount() {
4625 clearTimeout(this.timerId);
4626 }
4627
4628 setAutosaveTimer() {
4629 let timeout = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.props.interval * 1000;
4630 this.timerId = setTimeout(() => {
4631 this.autosaveTimerHandler();
4632 }, timeout);
4633 }
4634
4635 autosaveTimerHandler() {
4636 if (!this.props.isAutosaveable) {
4637 this.setAutosaveTimer(1000);
4638 return;
4639 }
4640
4641 if (this.needsAutosave) {
4642 this.needsAutosave = false;
4643 this.props.autosave();
4644 }
4645
4646 this.setAutosaveTimer();
4647 }
4648
4649 render() {
4650 return null;
4651 }
4652
4653 }
4654 /* harmony default export */ const autosave_monitor = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, ownProps) => {
4655 const {
4656 getReferenceByDistinctEdits
4657 } = select(external_wp_coreData_namespaceObject.store);
4658 const {
4659 isEditedPostDirty,
4660 isEditedPostAutosaveable,
4661 isAutosavingPost,
4662 getEditorSettings
4663 } = select(store_store);
4664 const {
4665 interval = getEditorSettings().autosaveInterval
4666 } = ownProps;
4667 return {
4668 editsReference: getReferenceByDistinctEdits(),
4669 isDirty: isEditedPostDirty(),
4670 isAutosaveable: isEditedPostAutosaveable(),
4671 isAutosaving: isAutosavingPost(),
4672 interval
4673 };
4674 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps) => ({
4675 autosave() {
4676 const {
4677 autosave = dispatch(store_store).autosave
4678 } = ownProps;
4679 autosave();
4680 }
4681
4682 }))])(AutosaveMonitor));
4683
4684 ;// CONCATENATED MODULE: external ["wp","richText"]
4685 const external_wp_richText_namespaceObject = window["wp"]["richText"];
4686 // EXTERNAL MODULE: ./node_modules/classnames/index.js
4687 var classnames = __webpack_require__(4403);
4688 var classnames_default = /*#__PURE__*/__webpack_require__.n(classnames);
4689 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-outline/item.js
4690
4691
4692 /**
4693 * External dependencies
4694 */
4695
4696
4697 const TableOfContentsItem = _ref => {
4698 let {
4699 children,
4700 isValid,
4701 level,
4702 href,
4703 onSelect
4704 } = _ref;
4705 return (0,external_wp_element_namespaceObject.createElement)("li", {
4706 className: classnames_default()('document-outline__item', `is-${level.toLowerCase()}`, {
4707 'is-invalid': !isValid
4708 })
4709 }, (0,external_wp_element_namespaceObject.createElement)("a", {
4710 href: href,
4711 className: "document-outline__button",
4712 onClick: onSelect
4713 }, (0,external_wp_element_namespaceObject.createElement)("span", {
4714 className: "document-outline__emdash",
4715 "aria-hidden": "true"
4716 }), (0,external_wp_element_namespaceObject.createElement)("strong", {
4717 className: "document-outline__level"
4718 }, level), (0,external_wp_element_namespaceObject.createElement)("span", {
4719 className: "document-outline__item-content"
4720 }, children)));
4721 };
4722
4723 /* harmony default export */ const document_outline_item = (TableOfContentsItem);
4724
4725 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-outline/index.js
4726
4727
4728 /**
4729 * External dependencies
4730 */
4731
4732 /**
4733 * WordPress dependencies
4734 */
4735
4736
4737
4738
4739
4740
4741
4742 /**
4743 * Internal dependencies
4744 */
4745
4746
4747
4748 /**
4749 * Module constants
4750 */
4751
4752 const emptyHeadingContent = (0,external_wp_element_namespaceObject.createElement)("em", null, (0,external_wp_i18n_namespaceObject.__)('(Empty heading)'));
4753 const incorrectLevelContent = [(0,external_wp_element_namespaceObject.createElement)("br", {
4754 key: "incorrect-break"
4755 }), (0,external_wp_element_namespaceObject.createElement)("em", {
4756 key: "incorrect-message"
4757 }, (0,external_wp_i18n_namespaceObject.__)('(Incorrect heading level)'))];
4758 const singleH1Headings = [(0,external_wp_element_namespaceObject.createElement)("br", {
4759 key: "incorrect-break-h1"
4760 }), (0,external_wp_element_namespaceObject.createElement)("em", {
4761 key: "incorrect-message-h1"
4762 }, (0,external_wp_i18n_namespaceObject.__)('(Your theme may already use a H1 for the post title)'))];
4763 const multipleH1Headings = [(0,external_wp_element_namespaceObject.createElement)("br", {
4764 key: "incorrect-break-multiple-h1"
4765 }), (0,external_wp_element_namespaceObject.createElement)("em", {
4766 key: "incorrect-message-multiple-h1"
4767 }, (0,external_wp_i18n_namespaceObject.__)('(Multiple H1 headings are not recommended)'))];
4768 /**
4769 * Returns an array of heading blocks enhanced with the following properties:
4770 * level - An integer with the heading level.
4771 * isEmpty - Flag indicating if the heading has no content.
4772 *
4773 * @param {?Array} blocks An array of blocks.
4774 *
4775 * @return {Array} An array of heading blocks enhanced with the properties described above.
4776 */
4777
4778 const computeOutlineHeadings = function () {
4779 let blocks = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
4780 return (0,external_lodash_namespaceObject.flatMap)(blocks, function () {
4781 let block = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
4782
4783 if (block.name === 'core/heading') {
4784 return { ...block,
4785 level: block.attributes.level,
4786 isEmpty: isEmptyHeading(block)
4787 };
4788 }
4789
4790 return computeOutlineHeadings(block.innerBlocks);
4791 });
4792 };
4793
4794 const isEmptyHeading = heading => !heading.attributes.content || heading.attributes.content.length === 0;
4795
4796 const DocumentOutline = _ref => {
4797 let {
4798 blocks = [],
4799 title,
4800 onSelect,
4801 isTitleSupported,
4802 hasOutlineItemsDisabled
4803 } = _ref;
4804 const headings = computeOutlineHeadings(blocks);
4805
4806 if (headings.length < 1) {
4807 return null;
4808 }
4809
4810 let prevHeadingLevel = 1; // Not great but it's the simplest way to locate the title right now.
4811
4812 const titleNode = document.querySelector('.editor-post-title__input');
4813 const hasTitle = isTitleSupported && title && titleNode;
4814 const countByLevel = (0,external_lodash_namespaceObject.countBy)(headings, 'level');
4815 const hasMultipleH1 = countByLevel[1] > 1;
4816 return (0,external_wp_element_namespaceObject.createElement)("div", {
4817 className: "document-outline"
4818 }, (0,external_wp_element_namespaceObject.createElement)("ul", null, hasTitle && (0,external_wp_element_namespaceObject.createElement)(document_outline_item, {
4819 level: (0,external_wp_i18n_namespaceObject.__)('Title'),
4820 isValid: true,
4821 onSelect: onSelect,
4822 href: `#${titleNode.id}`,
4823 isDisabled: hasOutlineItemsDisabled
4824 }, title), headings.map((item, index) => {
4825 // Headings remain the same, go up by one, or down by any amount.
4826 // Otherwise there are missing levels.
4827 const isIncorrectLevel = item.level > prevHeadingLevel + 1;
4828 const isValid = !item.isEmpty && !isIncorrectLevel && !!item.level && (item.level !== 1 || !hasMultipleH1 && !hasTitle);
4829 prevHeadingLevel = item.level;
4830 return (0,external_wp_element_namespaceObject.createElement)(document_outline_item, {
4831 key: index,
4832 level: `H${item.level}`,
4833 isValid: isValid,
4834 isDisabled: hasOutlineItemsDisabled,
4835 href: `#block-${item.clientId}`,
4836 onSelect: onSelect
4837 }, item.isEmpty ? emptyHeadingContent : (0,external_wp_richText_namespaceObject.getTextContent)((0,external_wp_richText_namespaceObject.create)({
4838 html: item.attributes.content
4839 })), isIncorrectLevel && incorrectLevelContent, item.level === 1 && hasMultipleH1 && multipleH1Headings, hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings);
4840 })));
4841 };
4842 /* harmony default export */ const document_outline = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => {
4843 const {
4844 getBlocks
4845 } = select(external_wp_blockEditor_namespaceObject.store);
4846 const {
4847 getEditedPostAttribute
4848 } = select(store_store);
4849 const {
4850 getPostType
4851 } = select(external_wp_coreData_namespaceObject.store);
4852 const postType = getPostType(getEditedPostAttribute('type'));
4853 return {
4854 title: getEditedPostAttribute('title'),
4855 blocks: getBlocks(),
4856 isTitleSupported: (0,external_lodash_namespaceObject.get)(postType, ['supports', 'title'], false)
4857 };
4858 }))(DocumentOutline));
4859
4860 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-outline/check.js
4861 /**
4862 * External dependencies
4863 */
4864
4865 /**
4866 * WordPress dependencies
4867 */
4868
4869
4870
4871
4872 function DocumentOutlineCheck(_ref) {
4873 let {
4874 blocks,
4875 children
4876 } = _ref;
4877 const headings = (0,external_lodash_namespaceObject.filter)(blocks, block => block.name === 'core/heading');
4878
4879 if (headings.length < 1) {
4880 return null;
4881 }
4882
4883 return children;
4884 }
4885
4886 /* harmony default export */ const check = ((0,external_wp_data_namespaceObject.withSelect)(select => ({
4887 blocks: select(external_wp_blockEditor_namespaceObject.store).getBlocks()
4888 }))(DocumentOutlineCheck));
4889
4890 ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
4891 const external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
4892 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/global-keyboard-shortcuts/save-shortcut.js
4893 /**
4894 * WordPress dependencies
4895 */
4896
4897
4898
4899 /**
4900 * Internal dependencies
4901 */
4902
4903
4904
4905 function SaveShortcut(_ref) {
4906 let {
4907 resetBlocksOnSave
4908 } = _ref;
4909 const {
4910 resetEditorBlocks,
4911 savePost
4912 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
4913 const {
4914 isEditedPostDirty,
4915 getPostEdits,
4916 isPostSavingLocked
4917 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
4918 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/save', event => {
4919 event.preventDefault();
4920 /**
4921 * Do not save the post if post saving is locked.
4922 */
4923
4924 if (isPostSavingLocked()) {
4925 return;
4926 } // TODO: This should be handled in the `savePost` effect in
4927 // considering `isSaveable`. See note on `isEditedPostSaveable`
4928 // selector about dirtiness and meta-boxes.
4929 //
4930 // See: `isEditedPostSaveable`
4931
4932
4933 if (!isEditedPostDirty()) {
4934 return;
4935 } // The text editor requires that editor blocks are updated for a
4936 // save to work correctly. Usually this happens when the textarea
4937 // for the code editors blurs, but the shortcut can be used without
4938 // blurring the textarea.
4939
4940
4941 if (resetBlocksOnSave) {
4942 const postEdits = getPostEdits();
4943
4944 if (postEdits.content && typeof postEdits.content === 'string') {
4945 const blocks = (0,external_wp_blocks_namespaceObject.parse)(postEdits.content);
4946 resetEditorBlocks(blocks);
4947 }
4948 }
4949
4950 savePost();
4951 });
4952 return null;
4953 }
4954
4955 /* harmony default export */ const save_shortcut = (SaveShortcut);
4956
4957 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/global-keyboard-shortcuts/visual-editor-shortcuts.js
4958
4959
4960 /**
4961 * WordPress dependencies
4962 */
4963
4964
4965 /**
4966 * Internal dependencies
4967 */
4968
4969
4970
4971
4972 function VisualEditorGlobalKeyboardShortcuts() {
4973 const {
4974 redo,
4975 undo
4976 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
4977 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/undo', event => {
4978 undo();
4979 event.preventDefault();
4980 });
4981 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/redo', event => {
4982 redo();
4983 event.preventDefault();
4984 });
4985 return (0,external_wp_element_namespaceObject.createElement)(save_shortcut, null);
4986 }
4987
4988 /* harmony default export */ const visual_editor_shortcuts = (VisualEditorGlobalKeyboardShortcuts);
4989
4990 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/global-keyboard-shortcuts/text-editor-shortcuts.js
4991
4992
4993 /**
4994 * Internal dependencies
4995 */
4996
4997 function TextEditorGlobalKeyboardShortcuts() {
4998 return (0,external_wp_element_namespaceObject.createElement)(save_shortcut, {
4999 resetBlocksOnSave: true
5000 });
5001 }
5002
5003 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/global-keyboard-shortcuts/register-shortcuts.js
5004
5005
5006 /**
5007 * WordPress dependencies
5008 */
5009
5010
5011
5012
5013
5014
5015 function EditorKeyboardShortcutsRegister() {
5016 // Registering the shortcuts.
5017 const {
5018 registerShortcut
5019 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
5020 (0,external_wp_element_namespaceObject.useEffect)(() => {
5021 registerShortcut({
5022 name: 'core/editor/save',
5023 category: 'global',
5024 description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'),
5025 keyCombination: {
5026 modifier: 'primary',
5027 character: 's'
5028 }
5029 });
5030 registerShortcut({
5031 name: 'core/editor/undo',
5032 category: 'global',
5033 description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'),
5034 keyCombination: {
5035 modifier: 'primary',
5036 character: 'z'
5037 }
5038 });
5039 registerShortcut({
5040 name: 'core/editor/redo',
5041 category: 'global',
5042 description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'),
5043 keyCombination: {
5044 modifier: 'primaryShift',
5045 character: 'z'
5046 }
5047 });
5048 }, [registerShortcut]);
5049 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts.Register, null);
5050 }
5051
5052 /* harmony default export */ const register_shortcuts = (EditorKeyboardShortcutsRegister);
5053
5054 ;// CONCATENATED MODULE: external ["wp","components"]
5055 const external_wp_components_namespaceObject = window["wp"]["components"];
5056 ;// CONCATENATED MODULE: external ["wp","keycodes"]
5057 const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
5058 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/redo.js
5059
5060
5061 /**
5062 * WordPress dependencies
5063 */
5064
5065 const redo_redo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5066 xmlns: "http://www.w3.org/2000/svg",
5067 viewBox: "0 0 24 24"
5068 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5069 d: "M15.6 6.5l-1.1 1 2.9 3.3H8c-.9 0-1.7.3-2.3.9-1.4 1.5-1.4 4.2-1.4 5.6v.2h1.5v-.3c0-1.1 0-3.5 1-4.5.3-.3.7-.5 1.3-.5h9.2L14.5 15l1.1 1.1 4.6-4.6-4.6-5z"
5070 }));
5071 /* harmony default export */ const library_redo = (redo_redo);
5072
5073 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/undo.js
5074
5075
5076 /**
5077 * WordPress dependencies
5078 */
5079
5080 const undo_undo = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
5081 xmlns: "http://www.w3.org/2000/svg",
5082 viewBox: "0 0 24 24"
5083 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
5084 d: "M18.3 11.7c-.6-.6-1.4-.9-2.3-.9H6.7l2.9-3.3-1.1-1-4.5 5L8.5 16l1-1-2.7-2.7H16c.5 0 .9.2 1.3.5 1 1 1 3.4 1 4.5v.3h1.5v-.2c0-1.5 0-4.3-1.5-5.7z"
5085 }));
5086 /* harmony default export */ const library_undo = (undo_undo);
5087
5088 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-history/redo.js
5089
5090
5091
5092 /**
5093 * WordPress dependencies
5094 */
5095
5096
5097
5098
5099
5100
5101 /**
5102 * Internal dependencies
5103 */
5104
5105
5106
5107 function EditorHistoryRedo(props, ref) {
5108 const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorRedo(), []);
5109 const {
5110 redo
5111 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5112 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, {
5113 ref: ref,
5114 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo
5115 /* translators: button label text should, if possible, be under 16 characters. */
5116 ,
5117 label: (0,external_wp_i18n_namespaceObject.__)('Redo'),
5118 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') // If there are no redo levels we don't want to actually disable this
5119 // button, because it will remove focus for keyboard users.
5120 // See: https://github.com/WordPress/gutenberg/issues/3486
5121 ,
5122 "aria-disabled": !hasRedo,
5123 onClick: hasRedo ? redo : undefined,
5124 className: "editor-history__redo"
5125 }));
5126 }
5127
5128 /* harmony default export */ const editor_history_redo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryRedo));
5129
5130 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-history/undo.js
5131
5132
5133
5134 /**
5135 * WordPress dependencies
5136 */
5137
5138
5139
5140
5141
5142
5143 /**
5144 * Internal dependencies
5145 */
5146
5147
5148
5149 function EditorHistoryUndo(props, ref) {
5150 const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorUndo(), []);
5151 const {
5152 undo
5153 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5154 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, {
5155 ref: ref,
5156 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo
5157 /* translators: button label text should, if possible, be under 16 characters. */
5158 ,
5159 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
5160 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z') // If there are no undo levels we don't want to actually disable this
5161 // button, because it will remove focus for keyboard users.
5162 // See: https://github.com/WordPress/gutenberg/issues/3486
5163 ,
5164 "aria-disabled": !hasUndo,
5165 onClick: hasUndo ? undo : undefined,
5166 className: "editor-history__undo"
5167 }));
5168 }
5169
5170 /* harmony default export */ const editor_history_undo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryUndo));
5171
5172 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-validation-notice/index.js
5173
5174
5175 /**
5176 * WordPress dependencies
5177 */
5178
5179
5180
5181
5182
5183
5184 function TemplateValidationNotice(_ref) {
5185 let {
5186 isValid,
5187 ...props
5188 } = _ref;
5189
5190 if (isValid) {
5191 return null;
5192 }
5193
5194 const confirmSynchronization = () => {
5195 if ( // eslint-disable-next-line no-alert
5196 window.confirm((0,external_wp_i18n_namespaceObject.__)('Resetting the template may result in loss of content, do you want to continue?'))) {
5197 props.synchronizeTemplate();
5198 }
5199 };
5200
5201 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Notice, {
5202 className: "editor-template-validation-notice",
5203 isDismissible: false,
5204 status: "warning",
5205 actions: [{
5206 label: (0,external_wp_i18n_namespaceObject.__)('Keep it as is'),
5207 onClick: props.resetTemplateValidity
5208 }, {
5209 label: (0,external_wp_i18n_namespaceObject.__)('Reset the template'),
5210 onClick: confirmSynchronization
5211 }]
5212 }, (0,external_wp_i18n_namespaceObject.__)('The content of your post doesn’t match the template assigned to your post type.'));
5213 }
5214
5215 /* harmony default export */ const template_validation_notice = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => ({
5216 isValid: select(external_wp_blockEditor_namespaceObject.store).isValidTemplate()
5217 })), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
5218 const {
5219 setTemplateValidity,
5220 synchronizeTemplate
5221 } = dispatch(external_wp_blockEditor_namespaceObject.store);
5222 return {
5223 resetTemplateValidity: () => setTemplateValidity(true),
5224 synchronizeTemplate
5225 };
5226 })])(TemplateValidationNotice));
5227
5228 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-notices/index.js
5229
5230
5231 /**
5232 * External dependencies
5233 */
5234
5235 /**
5236 * WordPress dependencies
5237 */
5238
5239
5240
5241
5242
5243 /**
5244 * Internal dependencies
5245 */
5246
5247
5248 function EditorNotices(_ref) {
5249 let {
5250 notices,
5251 onRemove
5252 } = _ref;
5253 const dismissibleNotices = (0,external_lodash_namespaceObject.filter)(notices, {
5254 isDismissible: true,
5255 type: 'default'
5256 });
5257 const nonDismissibleNotices = (0,external_lodash_namespaceObject.filter)(notices, {
5258 isDismissible: false,
5259 type: 'default'
5260 });
5261 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NoticeList, {
5262 notices: nonDismissibleNotices,
5263 className: "components-editor-notices__pinned"
5264 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.NoticeList, {
5265 notices: dismissibleNotices,
5266 className: "components-editor-notices__dismissible",
5267 onRemove: onRemove
5268 }, (0,external_wp_element_namespaceObject.createElement)(template_validation_notice, null)));
5269 }
5270 /* harmony default export */ const editor_notices = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => ({
5271 notices: select(external_wp_notices_namespaceObject.store).getNotices()
5272 })), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
5273 onRemove: dispatch(external_wp_notices_namespaceObject.store).removeNotice
5274 }))])(EditorNotices));
5275
5276 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-snackbars/index.js
5277
5278
5279 /**
5280 * External dependencies
5281 */
5282
5283 /**
5284 * WordPress dependencies
5285 */
5286
5287
5288
5289
5290 function EditorSnackbars() {
5291 const notices = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_notices_namespaceObject.store).getNotices(), []);
5292 const {
5293 removeNotice
5294 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
5295 const snackbarNotices = (0,external_lodash_namespaceObject.filter)(notices, {
5296 type: 'snackbar'
5297 });
5298 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SnackbarList, {
5299 notices: snackbarNotices,
5300 className: "components-editor-notices__snackbar",
5301 onRemove: removeNotice
5302 });
5303 }
5304
5305 ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
5306 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
5307 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/entities-saved-states/entity-record-item.js
5308
5309
5310 /**
5311 * WordPress dependencies
5312 */
5313
5314
5315
5316
5317
5318
5319
5320 /**
5321 * Internal dependencies
5322 */
5323
5324
5325 function EntityRecordItem(_ref) {
5326 let {
5327 record,
5328 checked,
5329 onChange,
5330 closePanel
5331 } = _ref;
5332 const {
5333 name,
5334 kind,
5335 title,
5336 key
5337 } = record;
5338 const parentBlockId = (0,external_wp_data_namespaceObject.useSelect)(select => {
5339 var _blocks$;
5340
5341 // Get entity's blocks.
5342 const {
5343 blocks = []
5344 } = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(kind, name, key); // Get parents of the entity's first block.
5345
5346 const parents = select(external_wp_blockEditor_namespaceObject.store).getBlockParents((_blocks$ = blocks[0]) === null || _blocks$ === void 0 ? void 0 : _blocks$.clientId); // Return closest parent block's clientId.
5347
5348 return parents[parents.length - 1];
5349 }, []); // Handle templates that might use default descriptive titles.
5350
5351 const entityRecordTitle = (0,external_wp_data_namespaceObject.useSelect)(select => {
5352 if ('postType' !== kind || 'wp_template' !== name) {
5353 return title;
5354 }
5355
5356 const template = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(kind, name, key);
5357 return select(store_store).__experimentalGetTemplateInfo(template).title;
5358 }, [name, kind, title, key]);
5359 const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => {
5360 const selectedBlockId = select(external_wp_blockEditor_namespaceObject.store).getSelectedBlockClientId();
5361 return selectedBlockId === parentBlockId;
5362 }, [parentBlockId]);
5363 const isSelectedText = isSelected ? (0,external_wp_i18n_namespaceObject.__)('Selected') : (0,external_wp_i18n_namespaceObject.__)('Select');
5364 const {
5365 selectBlock
5366 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
5367 const selectParentBlock = (0,external_wp_element_namespaceObject.useCallback)(() => selectBlock(parentBlockId), [parentBlockId]);
5368 const selectAndDismiss = (0,external_wp_element_namespaceObject.useCallback)(() => {
5369 selectBlock(parentBlockId);
5370 closePanel();
5371 }, [parentBlockId]);
5372 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
5373 label: (0,external_wp_element_namespaceObject.createElement)("strong", null, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(entityRecordTitle) || (0,external_wp_i18n_namespaceObject.__)('Untitled')),
5374 checked: checked,
5375 onChange: onChange
5376 }), parentBlockId ? (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
5377 onClick: selectParentBlock,
5378 className: "entities-saved-states__find-entity",
5379 disabled: isSelected
5380 }, isSelectedText), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
5381 onClick: selectAndDismiss,
5382 className: "entities-saved-states__find-entity-small",
5383 disabled: isSelected
5384 }, isSelectedText)) : null);
5385 }
5386
5387 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/entities-saved-states/entity-type-list.js
5388
5389
5390 /**
5391 * External dependencies
5392 */
5393
5394 /**
5395 * WordPress dependencies
5396 */
5397
5398
5399
5400
5401
5402 /**
5403 * Internal dependencies
5404 */
5405
5406
5407
5408 function getEntityDescription(entity, count) {
5409 switch (entity) {
5410 case 'site':
5411 return 1 === count ? (0,external_wp_i18n_namespaceObject.__)('This change will affect your whole site.') : (0,external_wp_i18n_namespaceObject.__)('These changes will affect your whole site.');
5412
5413 case 'wp_template':
5414 return (0,external_wp_i18n_namespaceObject.__)('This change will affect pages and posts that use this template.');
5415
5416 case 'page':
5417 case 'post':
5418 return (0,external_wp_i18n_namespaceObject.__)('The following content has been modified.');
5419 }
5420 }
5421
5422 function EntityTypeList(_ref) {
5423 let {
5424 list,
5425 unselectedEntities,
5426 setUnselectedEntities,
5427 closePanel
5428 } = _ref;
5429 const count = list.length;
5430 const firstRecord = list[0];
5431 const entityConfig = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityConfig(firstRecord.kind, firstRecord.name), [firstRecord.kind, firstRecord.name]);
5432 const {
5433 name
5434 } = firstRecord;
5435 let entityLabel = entityConfig.label;
5436
5437 if (name === 'wp_template_part') {
5438 entityLabel = 1 === count ? (0,external_wp_i18n_namespaceObject.__)('Template Part') : (0,external_wp_i18n_namespaceObject.__)('Template Parts');
5439 } // Set description based on type of entity.
5440
5441
5442 const description = getEntityDescription(name, count);
5443 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
5444 title: entityLabel,
5445 initialOpen: true
5446 }, description && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelRow, null, description), list.map(record => {
5447 return (0,external_wp_element_namespaceObject.createElement)(EntityRecordItem, {
5448 key: record.key || record.property,
5449 record: record,
5450 checked: !(0,external_lodash_namespaceObject.some)(unselectedEntities, elt => elt.kind === record.kind && elt.name === record.name && elt.key === record.key && elt.property === record.property),
5451 onChange: value => setUnselectedEntities(record, value),
5452 closePanel: closePanel
5453 });
5454 }));
5455 }
5456
5457 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/entities-saved-states/index.js
5458
5459
5460
5461 /**
5462 * External dependencies
5463 */
5464
5465 /**
5466 * WordPress dependencies
5467 */
5468
5469
5470
5471
5472
5473
5474
5475
5476
5477 /**
5478 * Internal dependencies
5479 */
5480
5481
5482 const TRANSLATED_SITE_PROPERTIES = {
5483 title: (0,external_wp_i18n_namespaceObject.__)('Title'),
5484 description: (0,external_wp_i18n_namespaceObject.__)('Tagline'),
5485 site_logo: (0,external_wp_i18n_namespaceObject.__)('Logo'),
5486 site_icon: (0,external_wp_i18n_namespaceObject.__)('Icon'),
5487 show_on_front: (0,external_wp_i18n_namespaceObject.__)('Show on front'),
5488 page_on_front: (0,external_wp_i18n_namespaceObject.__)('Page on front')
5489 };
5490 const PUBLISH_ON_SAVE_ENTITIES = [{
5491 kind: 'postType',
5492 name: 'wp_navigation'
5493 }];
5494 function EntitiesSavedStates(_ref) {
5495 let {
5496 close
5497 } = _ref;
5498 const saveButtonRef = (0,external_wp_element_namespaceObject.useRef)();
5499 const {
5500 dirtyEntityRecords
5501 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
5502 const dirtyRecords = select(external_wp_coreData_namespaceObject.store).__experimentalGetDirtyEntityRecords(); // Remove site object and decouple into its edited pieces.
5503
5504
5505 const dirtyRecordsWithoutSite = dirtyRecords.filter(record => !(record.kind === 'root' && record.name === 'site'));
5506 const siteEdits = select(external_wp_coreData_namespaceObject.store).getEntityRecordEdits('root', 'site');
5507 const siteEditsAsEntities = [];
5508
5509 for (const property in siteEdits) {
5510 siteEditsAsEntities.push({
5511 kind: 'root',
5512 name: 'site',
5513 title: TRANSLATED_SITE_PROPERTIES[property] || property,
5514 property
5515 });
5516 }
5517
5518 const dirtyRecordsWithSiteItems = [...dirtyRecordsWithoutSite, ...siteEditsAsEntities];
5519 return {
5520 dirtyEntityRecords: dirtyRecordsWithSiteItems
5521 };
5522 }, []);
5523 const {
5524 editEntityRecord,
5525 saveEditedEntityRecord,
5526 __experimentalSaveSpecifiedEntityEdits: saveSpecifiedEntityEdits
5527 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
5528 const {
5529 __unstableMarkLastChangeAsPersistent
5530 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
5531 const {
5532 createSuccessNotice,
5533 createErrorNotice
5534 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); // To group entities by type.
5535
5536 const partitionedSavables = (0,external_lodash_namespaceObject.groupBy)(dirtyEntityRecords, 'name'); // Sort entity groups.
5537
5538 const {
5539 site: siteSavables,
5540 wp_template: templateSavables,
5541 wp_template_part: templatePartSavables,
5542 ...contentSavables
5543 } = partitionedSavables;
5544 const sortedPartitionedSavables = [siteSavables, templateSavables, templatePartSavables, ...Object.values(contentSavables)].filter(Array.isArray); // Unchecked entities to be ignored by save function.
5545
5546 const [unselectedEntities, _setUnselectedEntities] = (0,external_wp_element_namespaceObject.useState)([]);
5547
5548 const setUnselectedEntities = (_ref2, checked) => {
5549 let {
5550 kind,
5551 name,
5552 key,
5553 property
5554 } = _ref2;
5555
5556 if (checked) {
5557 _setUnselectedEntities(unselectedEntities.filter(elt => elt.kind !== kind || elt.name !== name || elt.key !== key || elt.property !== property));
5558 } else {
5559 _setUnselectedEntities([...unselectedEntities, {
5560 kind,
5561 name,
5562 key,
5563 property
5564 }]);
5565 }
5566 };
5567
5568 const saveCheckedEntities = () => {
5569 const entitiesToSave = dirtyEntityRecords.filter(_ref3 => {
5570 let {
5571 kind,
5572 name,
5573 key,
5574 property
5575 } = _ref3;
5576 return !(0,external_lodash_namespaceObject.some)(unselectedEntities, elt => elt.kind === kind && elt.name === name && elt.key === key && elt.property === property);
5577 });
5578 close(entitiesToSave);
5579 const siteItemsToSave = [];
5580 const pendingSavedRecords = [];
5581 entitiesToSave.forEach(_ref4 => {
5582 let {
5583 kind,
5584 name,
5585 key,
5586 property
5587 } = _ref4;
5588
5589 if ('root' === kind && 'site' === name) {
5590 siteItemsToSave.push(property);
5591 } else {
5592 if (PUBLISH_ON_SAVE_ENTITIES.some(typeToPublish => typeToPublish.kind === kind && typeToPublish.name === name)) {
5593 editEntityRecord(kind, name, key, {
5594 status: 'publish'
5595 });
5596 }
5597
5598 pendingSavedRecords.push(saveEditedEntityRecord(kind, name, key));
5599 }
5600 });
5601
5602 if (siteItemsToSave.length) {
5603 pendingSavedRecords.push(saveSpecifiedEntityEdits('root', 'site', undefined, siteItemsToSave));
5604 }
5605
5606 __unstableMarkLastChangeAsPersistent();
5607
5608 Promise.all(pendingSavedRecords).then(values => {
5609 if (values.some(value => typeof value === 'undefined')) {
5610 createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Saving failed.'));
5611 } else {
5612 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Site updated.'), {
5613 type: 'snackbar'
5614 });
5615 }
5616 }).catch(error => createErrorNotice(`${(0,external_wp_i18n_namespaceObject.__)('Saving failed.')} ${error}`));
5617 }; // Explicitly define this with no argument passed. Using `close` on
5618 // its own will use the event object in place of the expected saved entities.
5619
5620
5621 const dismissPanel = (0,external_wp_element_namespaceObject.useCallback)(() => close(), [close]);
5622 const [saveDialogRef, saveDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
5623 onClose: () => dismissPanel()
5624 });
5625 return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
5626 ref: saveDialogRef
5627 }, saveDialogProps, {
5628 className: "entities-saved-states__panel"
5629 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
5630 className: "entities-saved-states__panel-header",
5631 gap: 2
5632 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
5633 isBlock: true,
5634 as: external_wp_components_namespaceObject.Button,
5635 ref: saveButtonRef,
5636 variant: "primary",
5637 disabled: dirtyEntityRecords.length - unselectedEntities.length === 0,
5638 onClick: saveCheckedEntities,
5639 className: "editor-entities-saved-states__save-button"
5640 }, (0,external_wp_i18n_namespaceObject.__)('Save')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, {
5641 isBlock: true,
5642 as: external_wp_components_namespaceObject.Button,
5643 variant: "secondary",
5644 onClick: dismissPanel
5645 }, (0,external_wp_i18n_namespaceObject.__)('Cancel'))), (0,external_wp_element_namespaceObject.createElement)("div", {
5646 className: "entities-saved-states__text-prompt"
5647 }, (0,external_wp_element_namespaceObject.createElement)("strong", null, (0,external_wp_i18n_namespaceObject.__)('Are you ready to save?')), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('The following changes have been made to your site, templates, and content.'))), sortedPartitionedSavables.map(list => {
5648 return (0,external_wp_element_namespaceObject.createElement)(EntityTypeList, {
5649 key: list[0].name,
5650 list: list,
5651 closePanel: dismissPanel,
5652 unselectedEntities: unselectedEntities,
5653 setUnselectedEntities: setUnselectedEntities
5654 });
5655 }));
5656 }
5657
5658 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/error-boundary/index.js
5659
5660
5661 /**
5662 * WordPress dependencies
5663 */
5664
5665
5666
5667
5668
5669
5670 /**
5671 * Internal dependencies
5672 */
5673
5674
5675
5676 function CopyButton(_ref) {
5677 let {
5678 text,
5679 children
5680 } = _ref;
5681 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text);
5682 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
5683 variant: "secondary",
5684 ref: ref
5685 }, children);
5686 }
5687
5688 class ErrorBoundary extends external_wp_element_namespaceObject.Component {
5689 constructor() {
5690 super(...arguments);
5691 this.reboot = this.reboot.bind(this);
5692 this.getContent = this.getContent.bind(this);
5693 this.state = {
5694 error: null
5695 };
5696 }
5697
5698 componentDidCatch(error) {
5699 this.setState({
5700 error
5701 });
5702 }
5703
5704 reboot() {
5705 this.props.onError();
5706 }
5707
5708 getContent() {
5709 try {
5710 // While `select` in a component is generally discouraged, it is
5711 // used here because it (a) reduces the chance of data loss in the
5712 // case of additional errors by performing a direct retrieval and
5713 // (b) avoids the performance cost associated with unnecessary
5714 // content serialization throughout the lifetime of a non-erroring
5715 // application.
5716 return (0,external_wp_data_namespaceObject.select)(store_store).getEditedPostContent();
5717 } catch (error) {}
5718 }
5719
5720 render() {
5721 const {
5722 error
5723 } = this.state;
5724
5725 if (!error) {
5726 return this.props.children;
5727 }
5728
5729 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.Warning, {
5730 className: "editor-error-boundary",
5731 actions: [(0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
5732 key: "recovery",
5733 onClick: this.reboot,
5734 variant: "secondary"
5735 }, (0,external_wp_i18n_namespaceObject.__)('Attempt Recovery')), (0,external_wp_element_namespaceObject.createElement)(CopyButton, {
5736 key: "copy-post",
5737 text: this.getContent
5738 }, (0,external_wp_i18n_namespaceObject.__)('Copy Post Text')), (0,external_wp_element_namespaceObject.createElement)(CopyButton, {
5739 key: "copy-error",
5740 text: error.stack
5741 }, (0,external_wp_i18n_namespaceObject.__)('Copy Error'))]
5742 }, (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.'));
5743 }
5744
5745 }
5746
5747 /* harmony default export */ const error_boundary = (ErrorBoundary);
5748
5749 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/local-autosave-monitor/index.js
5750
5751
5752 /**
5753 * External dependencies
5754 */
5755
5756 /**
5757 * WordPress dependencies
5758 */
5759
5760
5761
5762
5763
5764
5765
5766 /**
5767 * Internal dependencies
5768 */
5769
5770
5771
5772
5773 const requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame;
5774 /**
5775 * Function which returns true if the current environment supports browser
5776 * sessionStorage, or false otherwise. The result of this function is cached and
5777 * reused in subsequent invocations.
5778 */
5779
5780 const hasSessionStorageSupport = (0,external_lodash_namespaceObject.once)(() => {
5781 try {
5782 // Private Browsing in Safari 10 and earlier will throw an error when
5783 // attempting to set into sessionStorage. The test here is intentional in
5784 // causing a thrown error as condition bailing from local autosave.
5785 window.sessionStorage.setItem('__wpEditorTestSessionStorage', '');
5786 window.sessionStorage.removeItem('__wpEditorTestSessionStorage');
5787 return true;
5788 } catch (error) {
5789 return false;
5790 }
5791 });
5792 /**
5793 * Custom hook which manages the creation of a notice prompting the user to
5794 * restore a local autosave, if one exists.
5795 */
5796
5797 function useAutosaveNotice() {
5798 const {
5799 postId,
5800 isEditedPostNew,
5801 hasRemoteAutosave
5802 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
5803 postId: select(store_store).getCurrentPostId(),
5804 isEditedPostNew: select(store_store).isEditedPostNew(),
5805 hasRemoteAutosave: !!select(store_store).getEditorSettings().autosave
5806 }), []);
5807 const {
5808 getEditedPostAttribute
5809 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
5810 const {
5811 createWarningNotice,
5812 removeNotice
5813 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
5814 const {
5815 editPost,
5816 resetEditorBlocks
5817 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5818 (0,external_wp_element_namespaceObject.useEffect)(() => {
5819 let localAutosave = localAutosaveGet(postId, isEditedPostNew);
5820
5821 if (!localAutosave) {
5822 return;
5823 }
5824
5825 try {
5826 localAutosave = JSON.parse(localAutosave);
5827 } catch (error) {
5828 // Not usable if it can't be parsed.
5829 return;
5830 }
5831
5832 const {
5833 post_title: title,
5834 content,
5835 excerpt
5836 } = localAutosave;
5837 const edits = {
5838 title,
5839 content,
5840 excerpt
5841 };
5842 {
5843 // Only display a notice if there is a difference between what has been
5844 // saved and that which is stored in sessionStorage.
5845 const hasDifference = Object.keys(edits).some(key => {
5846 return edits[key] !== getEditedPostAttribute(key);
5847 });
5848
5849 if (!hasDifference) {
5850 // If there is no difference, it can be safely ejected from storage.
5851 localAutosaveClear(postId, isEditedPostNew);
5852 return;
5853 }
5854 }
5855
5856 if (hasRemoteAutosave) {
5857 return;
5858 }
5859
5860 const noticeId = (0,external_lodash_namespaceObject.uniqueId)('wpEditorAutosaveRestore');
5861 createWarningNotice((0,external_wp_i18n_namespaceObject.__)('The backup of this post in your browser is different from the version below.'), {
5862 id: noticeId,
5863 actions: [{
5864 label: (0,external_wp_i18n_namespaceObject.__)('Restore the backup'),
5865
5866 onClick() {
5867 editPost((0,external_lodash_namespaceObject.omit)(edits, ['content']));
5868 resetEditorBlocks((0,external_wp_blocks_namespaceObject.parse)(edits.content));
5869 removeNotice(noticeId);
5870 }
5871
5872 }]
5873 });
5874 }, [isEditedPostNew, postId]);
5875 }
5876 /**
5877 * Custom hook which ejects a local autosave after a successful save occurs.
5878 */
5879
5880
5881 function useAutosavePurge() {
5882 const {
5883 postId,
5884 isEditedPostNew,
5885 isDirty,
5886 isAutosaving,
5887 didError
5888 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
5889 postId: select(store_store).getCurrentPostId(),
5890 isEditedPostNew: select(store_store).isEditedPostNew(),
5891 isDirty: select(store_store).isEditedPostDirty(),
5892 isAutosaving: select(store_store).isAutosavingPost(),
5893 didError: select(store_store).didPostSaveRequestFail()
5894 }), []);
5895 const lastIsDirty = (0,external_wp_element_namespaceObject.useRef)(isDirty);
5896 const lastIsAutosaving = (0,external_wp_element_namespaceObject.useRef)(isAutosaving);
5897 (0,external_wp_element_namespaceObject.useEffect)(() => {
5898 if (!didError && (lastIsAutosaving.current && !isAutosaving || lastIsDirty.current && !isDirty)) {
5899 localAutosaveClear(postId, isEditedPostNew);
5900 }
5901
5902 lastIsDirty.current = isDirty;
5903 lastIsAutosaving.current = isAutosaving;
5904 }, [isDirty, isAutosaving, didError]); // Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.
5905
5906 const wasEditedPostNew = (0,external_wp_compose_namespaceObject.usePrevious)(isEditedPostNew);
5907 const prevPostId = (0,external_wp_compose_namespaceObject.usePrevious)(postId);
5908 (0,external_wp_element_namespaceObject.useEffect)(() => {
5909 if (prevPostId === postId && wasEditedPostNew && !isEditedPostNew) {
5910 localAutosaveClear(postId, true);
5911 }
5912 }, [isEditedPostNew, postId]);
5913 }
5914
5915 function LocalAutosaveMonitor() {
5916 const {
5917 autosave
5918 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
5919 const deferredAutosave = (0,external_wp_element_namespaceObject.useCallback)(() => {
5920 requestIdleCallback(() => autosave({
5921 local: true
5922 }));
5923 }, []);
5924 useAutosaveNotice();
5925 useAutosavePurge();
5926 const {
5927 localAutosaveInterval
5928 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
5929 localAutosaveInterval: select(store_store).getEditorSettings().localAutosaveInterval
5930 }), []);
5931 return (0,external_wp_element_namespaceObject.createElement)(autosave_monitor, {
5932 interval: localAutosaveInterval,
5933 autosave: deferredAutosave
5934 });
5935 }
5936
5937 /* harmony default export */ const local_autosave_monitor = ((0,external_wp_compose_namespaceObject.ifCondition)(hasSessionStorageSupport)(LocalAutosaveMonitor));
5938
5939 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/page-attributes/check.js
5940 /**
5941 * External dependencies
5942 */
5943
5944 /**
5945 * WordPress dependencies
5946 */
5947
5948
5949
5950 /**
5951 * Internal dependencies
5952 */
5953
5954
5955 function PageAttributesCheck(_ref) {
5956 let {
5957 children
5958 } = _ref;
5959 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => {
5960 const {
5961 getEditedPostAttribute
5962 } = select(store_store);
5963 const {
5964 getPostType
5965 } = select(external_wp_coreData_namespaceObject.store);
5966 return getPostType(getEditedPostAttribute('type'));
5967 }, []);
5968 const supportsPageAttributes = (0,external_lodash_namespaceObject.get)(postType, ['supports', 'page-attributes'], false); // Only render fields if post type supports page attributes or available templates exist.
5969
5970 if (!supportsPageAttributes) {
5971 return null;
5972 }
5973
5974 return children;
5975 }
5976 /* harmony default export */ const page_attributes_check = (PageAttributesCheck);
5977
5978 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-type-support-check/index.js
5979 /**
5980 * External dependencies
5981 */
5982
5983 /**
5984 * WordPress dependencies
5985 */
5986
5987
5988
5989 /**
5990 * Internal dependencies
5991 */
5992
5993
5994 /**
5995 * A component which renders its own children only if the current editor post
5996 * type supports one of the given `supportKeys` prop.
5997 *
5998 * @param {Object} props Props.
5999 * @param {string} [props.postType] Current post type.
6000 * @param {WPElement} props.children Children to be rendered if post
6001 * type supports.
6002 * @param {(string|string[])} props.supportKeys String or string array of keys
6003 * to test.
6004 *
6005 * @return {WPComponent} The component to be rendered.
6006 */
6007
6008 function PostTypeSupportCheck(_ref) {
6009 let {
6010 postType,
6011 children,
6012 supportKeys
6013 } = _ref;
6014 let isSupported = true;
6015
6016 if (postType) {
6017 isSupported = (0,external_lodash_namespaceObject.some)((0,external_lodash_namespaceObject.castArray)(supportKeys), key => !!postType.supports[key]);
6018 }
6019
6020 if (!isSupported) {
6021 return null;
6022 }
6023
6024 return children;
6025 }
6026 /* harmony default export */ const post_type_support_check = ((0,external_wp_data_namespaceObject.withSelect)(select => {
6027 const {
6028 getEditedPostAttribute
6029 } = select(store_store);
6030 const {
6031 getPostType
6032 } = select(external_wp_coreData_namespaceObject.store);
6033 return {
6034 postType: getPostType(getEditedPostAttribute('type'))
6035 };
6036 })(PostTypeSupportCheck));
6037
6038 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/page-attributes/order.js
6039
6040
6041 /**
6042 * External dependencies
6043 */
6044
6045 /**
6046 * WordPress dependencies
6047 */
6048
6049
6050
6051
6052
6053
6054 /**
6055 * Internal dependencies
6056 */
6057
6058
6059
6060 const PageAttributesOrder = _ref => {
6061 let {
6062 onUpdateOrder,
6063 order = 0
6064 } = _ref;
6065 const [orderInput, setOrderInput] = (0,external_wp_element_namespaceObject.useState)(null);
6066
6067 const setUpdatedOrder = value => {
6068 setOrderInput(value);
6069 const newOrder = Number(value);
6070
6071 if (Number.isInteger(newOrder) && (0,external_lodash_namespaceObject.invoke)(value, ['trim']) !== '') {
6072 onUpdateOrder(Number(value));
6073 }
6074 };
6075
6076 const value = orderInput === null ? order : orderInput;
6077 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
6078 className: "editor-page-attributes__order",
6079 type: "number",
6080 label: (0,external_wp_i18n_namespaceObject.__)('Order'),
6081 value: value,
6082 onChange: setUpdatedOrder,
6083 size: 6,
6084 onBlur: () => {
6085 setOrderInput(null);
6086 }
6087 });
6088 };
6089
6090 function PageAttributesOrderWithChecks(props) {
6091 return (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, {
6092 supportKeys: "page-attributes"
6093 }, (0,external_wp_element_namespaceObject.createElement)(PageAttributesOrder, props));
6094 }
6095
6096 /* harmony default export */ const order = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
6097 return {
6098 order: select(store_store).getEditedPostAttribute('menu_order')
6099 };
6100 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
6101 onUpdateOrder(order) {
6102 dispatch(store_store).editPost({
6103 menu_order: order
6104 });
6105 }
6106
6107 }))])(PageAttributesOrderWithChecks));
6108
6109 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/terms.js
6110 /**
6111 * External dependencies
6112 */
6113
6114 /**
6115 * Returns terms in a tree form.
6116 *
6117 * @param {Array} flatTerms Array of terms in flat format.
6118 *
6119 * @return {Array} Array of terms in tree format.
6120 */
6121
6122 function buildTermsTree(flatTerms) {
6123 const flatTermsWithParentAndChildren = flatTerms.map(term => {
6124 return {
6125 children: [],
6126 parent: null,
6127 ...term
6128 };
6129 });
6130 const termsByParent = (0,external_lodash_namespaceObject.groupBy)(flatTermsWithParentAndChildren, 'parent');
6131
6132 if (termsByParent.null && termsByParent.null.length) {
6133 return flatTermsWithParentAndChildren;
6134 }
6135
6136 const fillWithChildren = terms => {
6137 return terms.map(term => {
6138 const children = termsByParent[term.id];
6139 return { ...term,
6140 children: children && children.length ? fillWithChildren(children) : []
6141 };
6142 });
6143 };
6144
6145 return fillWithChildren(termsByParent['0'] || []);
6146 } // Lodash unescape function handles &#39; but not &#039; which may be return in some API requests.
6147
6148 const unescapeString = arg => {
6149 return (0,external_lodash_namespaceObject.unescape)(arg.replace('&#039;', "'"));
6150 };
6151 /**
6152 * Returns a term object with name unescaped.
6153 * The unescape of the name property is done using lodash unescape function.
6154 *
6155 * @param {Object} term The term object to unescape.
6156 *
6157 * @return {Object} Term object with name property unescaped.
6158 */
6159
6160 const unescapeTerm = term => {
6161 return { ...term,
6162 name: unescapeString(term.name)
6163 };
6164 };
6165 /**
6166 * Returns an array of term objects with names unescaped.
6167 * The unescape of each term is performed using the unescapeTerm function.
6168 *
6169 * @param {Object[]} terms Array of term objects to unescape.
6170 *
6171 * @return {Object[]} Array of term objects unescaped.
6172 */
6173
6174 const unescapeTerms = terms => {
6175 return (0,external_lodash_namespaceObject.map)(terms, unescapeTerm);
6176 };
6177
6178 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/page-attributes/parent.js
6179
6180
6181 /**
6182 * External dependencies
6183 */
6184
6185 /**
6186 * WordPress dependencies
6187 */
6188
6189
6190
6191
6192
6193
6194
6195 /**
6196 * Internal dependencies
6197 */
6198
6199
6200
6201
6202 function getTitle(post) {
6203 var _post$title;
6204
6205 return post !== null && post !== void 0 && (_post$title = post.title) !== null && _post$title !== void 0 && _post$title.rendered ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title.rendered) : `#${post.id} (${(0,external_wp_i18n_namespaceObject.__)('no title')})`;
6206 }
6207
6208 const getItemPriority = (name, searchValue) => {
6209 const normalizedName = (0,external_lodash_namespaceObject.deburr)(name).toLowerCase();
6210 const normalizedSearch = (0,external_lodash_namespaceObject.deburr)(searchValue).toLowerCase();
6211
6212 if (normalizedName === normalizedSearch) {
6213 return 0;
6214 }
6215
6216 if (normalizedName.startsWith(normalizedSearch)) {
6217 return normalizedName.length;
6218 }
6219
6220 return Infinity;
6221 };
6222 function PageAttributesParent() {
6223 const {
6224 editPost
6225 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
6226 const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)(false);
6227 const {
6228 parentPost,
6229 parentPostId,
6230 items,
6231 postType
6232 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
6233 const {
6234 getPostType,
6235 getEntityRecords,
6236 getEntityRecord
6237 } = select(external_wp_coreData_namespaceObject.store);
6238 const {
6239 getCurrentPostId,
6240 getEditedPostAttribute
6241 } = select(store_store);
6242 const postTypeSlug = getEditedPostAttribute('type');
6243 const pageId = getEditedPostAttribute('parent');
6244 const pType = getPostType(postTypeSlug);
6245 const postId = getCurrentPostId();
6246 const isHierarchical = (0,external_lodash_namespaceObject.get)(pType, ['hierarchical'], false);
6247 const query = {
6248 per_page: 100,
6249 exclude: postId,
6250 parent_exclude: postId,
6251 orderby: 'menu_order',
6252 order: 'asc',
6253 _fields: 'id,title,parent'
6254 }; // Perform a search when the field is changed.
6255
6256 if (!!fieldValue) {
6257 query.search = fieldValue;
6258 }
6259
6260 return {
6261 parentPostId: pageId,
6262 parentPost: pageId ? getEntityRecord('postType', postTypeSlug, pageId) : null,
6263 items: isHierarchical ? getEntityRecords('postType', postTypeSlug, query) : [],
6264 postType: pType
6265 };
6266 }, [fieldValue]);
6267 const isHierarchical = (0,external_lodash_namespaceObject.get)(postType, ['hierarchical'], false);
6268 const parentPageLabel = (0,external_lodash_namespaceObject.get)(postType, ['labels', 'parent_item_colon']);
6269 const pageItems = items || [];
6270 const parentOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
6271 const getOptionsFromTree = function (tree) {
6272 let level = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
6273 const mappedNodes = tree.map(treeNode => [{
6274 value: treeNode.id,
6275 label: (0,external_lodash_namespaceObject.repeat)('— ', level) + (0,external_lodash_namespaceObject.unescape)(treeNode.name),
6276 rawName: treeNode.name
6277 }, ...getOptionsFromTree(treeNode.children || [], level + 1)]);
6278 const sortedNodes = mappedNodes.sort((_ref, _ref2) => {
6279 let [a] = _ref;
6280 let [b] = _ref2;
6281 const priorityA = getItemPriority(a.rawName, fieldValue);
6282 const priorityB = getItemPriority(b.rawName, fieldValue);
6283 return priorityA >= priorityB ? 1 : -1;
6284 });
6285 return (0,external_lodash_namespaceObject.flatten)(sortedNodes);
6286 };
6287
6288 let tree = pageItems.map(item => ({
6289 id: item.id,
6290 parent: item.parent,
6291 name: getTitle(item)
6292 })); // Only build a hierarchical tree when not searching.
6293
6294 if (!fieldValue) {
6295 tree = buildTermsTree(tree);
6296 }
6297
6298 const opts = getOptionsFromTree(tree); // Ensure the current parent is in the options list.
6299
6300 const optsHasParent = (0,external_lodash_namespaceObject.find)(opts, item => item.value === parentPostId);
6301
6302 if (parentPost && !optsHasParent) {
6303 opts.unshift({
6304 value: parentPostId,
6305 label: getTitle(parentPost)
6306 });
6307 }
6308
6309 return opts;
6310 }, [pageItems, fieldValue]);
6311
6312 if (!isHierarchical || !parentPageLabel) {
6313 return null;
6314 }
6315 /**
6316 * Handle user input.
6317 *
6318 * @param {string} inputValue The current value of the input field.
6319 */
6320
6321
6322 const handleKeydown = inputValue => {
6323 setFieldValue(inputValue);
6324 };
6325 /**
6326 * Handle author selection.
6327 *
6328 * @param {Object} selectedPostId The selected Author.
6329 */
6330
6331
6332 const handleChange = selectedPostId => {
6333 editPost({
6334 parent: selectedPostId
6335 });
6336 };
6337
6338 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ComboboxControl, {
6339 className: "editor-page-attributes__parent",
6340 label: parentPageLabel,
6341 value: parentPostId,
6342 options: parentOptions,
6343 onFilterValueChange: (0,external_lodash_namespaceObject.debounce)(handleKeydown, 300),
6344 onChange: handleChange
6345 });
6346 }
6347 /* harmony default export */ const page_attributes_parent = (PageAttributesParent);
6348
6349 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/index.js
6350
6351
6352 /**
6353 * External dependencies
6354 */
6355
6356 /**
6357 * WordPress dependencies
6358 */
6359
6360
6361
6362
6363
6364 /**
6365 * Internal dependencies
6366 */
6367
6368
6369 function PostTemplate(_ref) {
6370 let {} = _ref;
6371 const {
6372 availableTemplates,
6373 selectedTemplate,
6374 isViewable
6375 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
6376 var _getPostType$viewable, _getPostType;
6377
6378 const {
6379 getEditedPostAttribute,
6380 getEditorSettings,
6381 getCurrentPostType
6382 } = select(store_store);
6383 const {
6384 getPostType
6385 } = select(external_wp_coreData_namespaceObject.store);
6386 return {
6387 selectedTemplate: getEditedPostAttribute('template'),
6388 availableTemplates: getEditorSettings().availableTemplates,
6389 isViewable: (_getPostType$viewable = (_getPostType = getPostType(getCurrentPostType())) === null || _getPostType === void 0 ? void 0 : _getPostType.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false
6390 };
6391 }, []);
6392 const {
6393 editPost
6394 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
6395
6396 if (!isViewable || (0,external_lodash_namespaceObject.isEmpty)(availableTemplates)) {
6397 return null;
6398 }
6399
6400 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
6401 label: (0,external_wp_i18n_namespaceObject.__)('Template:'),
6402 value: selectedTemplate,
6403 onChange: templateSlug => {
6404 editPost({
6405 template: templateSlug || ''
6406 });
6407 },
6408 options: (0,external_lodash_namespaceObject.map)(availableTemplates, (templateName, templateSlug) => ({
6409 value: templateSlug,
6410 label: templateName
6411 }))
6412 });
6413 }
6414 /* harmony default export */ const post_template = (PostTemplate);
6415
6416 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/constants.js
6417 const AUTHORS_QUERY = {
6418 who: 'authors',
6419 per_page: 50,
6420 _fields: 'id,name',
6421 context: 'view' // Allows non-admins to perform requests.
6422
6423 };
6424
6425 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/combobox.js
6426
6427
6428 /**
6429 * External dependencies
6430 */
6431
6432 /**
6433 * WordPress dependencies
6434 */
6435
6436
6437
6438
6439
6440
6441
6442 /**
6443 * Internal dependencies
6444 */
6445
6446
6447
6448
6449 function PostAuthorCombobox() {
6450 const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)();
6451 const {
6452 authorId,
6453 isLoading,
6454 authors,
6455 postAuthor
6456 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
6457 const {
6458 getUser,
6459 getUsers,
6460 isResolving
6461 } = select(external_wp_coreData_namespaceObject.store);
6462 const {
6463 getEditedPostAttribute
6464 } = select(store_store);
6465 const author = getUser(getEditedPostAttribute('author'), {
6466 context: 'view'
6467 });
6468 const query = { ...AUTHORS_QUERY
6469 };
6470
6471 if (fieldValue) {
6472 query.search = fieldValue;
6473 }
6474
6475 return {
6476 authorId: getEditedPostAttribute('author'),
6477 postAuthor: author,
6478 authors: getUsers(query),
6479 isLoading: isResolving('core', 'getUsers', [query])
6480 };
6481 }, [fieldValue]);
6482 const {
6483 editPost
6484 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
6485 const authorOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
6486 const fetchedAuthors = (authors !== null && authors !== void 0 ? authors : []).map(author => {
6487 return {
6488 value: author.id,
6489 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(author.name)
6490 };
6491 }); // Ensure the current author is included in the dropdown list.
6492
6493 const foundAuthor = fetchedAuthors.findIndex(_ref => {
6494 let {
6495 value
6496 } = _ref;
6497 return (postAuthor === null || postAuthor === void 0 ? void 0 : postAuthor.id) === value;
6498 });
6499
6500 if (foundAuthor < 0 && postAuthor) {
6501 return [{
6502 value: postAuthor.id,
6503 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postAuthor.name)
6504 }, ...fetchedAuthors];
6505 }
6506
6507 return fetchedAuthors;
6508 }, [authors, postAuthor]);
6509 /**
6510 * Handle author selection.
6511 *
6512 * @param {number} postAuthorId The selected Author.
6513 */
6514
6515 const handleSelect = postAuthorId => {
6516 if (!postAuthorId) {
6517 return;
6518 }
6519
6520 editPost({
6521 author: postAuthorId
6522 });
6523 };
6524 /**
6525 * Handle user input.
6526 *
6527 * @param {string} inputValue The current value of the input field.
6528 */
6529
6530
6531 const handleKeydown = inputValue => {
6532 setFieldValue(inputValue);
6533 };
6534
6535 if (!postAuthor) {
6536 return null;
6537 }
6538
6539 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ComboboxControl, {
6540 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
6541 options: authorOptions,
6542 value: authorId,
6543 onFilterValueChange: (0,external_lodash_namespaceObject.debounce)(handleKeydown, 300),
6544 onChange: handleSelect,
6545 isLoading: isLoading,
6546 allowReset: false
6547 });
6548 }
6549
6550 /* harmony default export */ const combobox = (PostAuthorCombobox);
6551
6552 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/select.js
6553
6554
6555 /**
6556 * WordPress dependencies
6557 */
6558
6559
6560
6561
6562
6563
6564 /**
6565 * Internal dependencies
6566 */
6567
6568
6569
6570
6571 function PostAuthorSelect() {
6572 const {
6573 editPost
6574 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
6575 const {
6576 postAuthor,
6577 authors
6578 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
6579 return {
6580 postAuthor: select(store_store).getEditedPostAttribute('author'),
6581 authors: select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY)
6582 };
6583 }, []);
6584 const authorOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
6585 return (authors !== null && authors !== void 0 ? authors : []).map(author => {
6586 return {
6587 value: author.id,
6588 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(author.name)
6589 };
6590 });
6591 }, [authors]);
6592
6593 const setAuthorId = value => {
6594 const author = Number(value);
6595 editPost({
6596 author
6597 });
6598 };
6599
6600 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
6601 className: "post-author-selector",
6602 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
6603 options: authorOptions,
6604 onChange: setAuthorId,
6605 value: postAuthor
6606 });
6607 }
6608
6609 /* harmony default export */ const post_author_select = (PostAuthorSelect);
6610
6611 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/index.js
6612
6613
6614 /**
6615 * WordPress dependencies
6616 */
6617
6618
6619 /**
6620 * Internal dependencies
6621 */
6622
6623
6624
6625
6626 const minimumUsersForCombobox = 25;
6627
6628 function PostAuthor() {
6629 const showCombobox = (0,external_wp_data_namespaceObject.useSelect)(select => {
6630 const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY);
6631 return (authors === null || authors === void 0 ? void 0 : authors.length) >= minimumUsersForCombobox;
6632 }, []);
6633
6634 if (showCombobox) {
6635 return (0,external_wp_element_namespaceObject.createElement)(combobox, null);
6636 }
6637
6638 return (0,external_wp_element_namespaceObject.createElement)(post_author_select, null);
6639 }
6640
6641 /* harmony default export */ const post_author = (PostAuthor);
6642
6643 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/check.js
6644
6645
6646 /**
6647 * External dependencies
6648 */
6649
6650 /**
6651 * WordPress dependencies
6652 */
6653
6654
6655
6656 /**
6657 * Internal dependencies
6658 */
6659
6660
6661
6662
6663 function PostAuthorCheck(_ref) {
6664 let {
6665 children
6666 } = _ref;
6667 const {
6668 hasAssignAuthorAction,
6669 hasAuthors
6670 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
6671 const post = select(store_store).getCurrentPost();
6672 const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY);
6673 return {
6674 hasAssignAuthorAction: (0,external_lodash_namespaceObject.get)(post, ['_links', 'wp:action-assign-author'], false),
6675 hasAuthors: (authors === null || authors === void 0 ? void 0 : authors.length) >= 1
6676 };
6677 }, []);
6678
6679 if (!hasAssignAuthorAction || !hasAuthors) {
6680 return null;
6681 }
6682
6683 return (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, {
6684 supportKeys: "author"
6685 }, children);
6686 }
6687
6688 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-comments/index.js
6689
6690
6691 /**
6692 * WordPress dependencies
6693 */
6694
6695
6696
6697
6698 /**
6699 * Internal dependencies
6700 */
6701
6702
6703
6704 function PostComments(_ref) {
6705 let {
6706 commentStatus = 'open',
6707 ...props
6708 } = _ref;
6709
6710 const onToggleComments = () => props.editPost({
6711 comment_status: commentStatus === 'open' ? 'closed' : 'open'
6712 });
6713
6714 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
6715 label: (0,external_wp_i18n_namespaceObject.__)('Allow comments'),
6716 checked: commentStatus === 'open',
6717 onChange: onToggleComments
6718 });
6719 }
6720
6721 /* harmony default export */ const post_comments = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
6722 return {
6723 commentStatus: select(store_store).getEditedPostAttribute('comment_status')
6724 };
6725 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
6726 editPost: dispatch(store_store).editPost
6727 }))])(PostComments));
6728
6729 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-excerpt/index.js
6730
6731
6732 /**
6733 * WordPress dependencies
6734 */
6735
6736
6737
6738
6739 /**
6740 * Internal dependencies
6741 */
6742
6743
6744
6745 function PostExcerpt(_ref) {
6746 let {
6747 excerpt,
6748 onUpdateExcerpt
6749 } = _ref;
6750 return (0,external_wp_element_namespaceObject.createElement)("div", {
6751 className: "editor-post-excerpt"
6752 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextareaControl, {
6753 label: (0,external_wp_i18n_namespaceObject.__)('Write an excerpt (optional)'),
6754 className: "editor-post-excerpt__textarea",
6755 onChange: value => onUpdateExcerpt(value),
6756 value: excerpt
6757 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
6758 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/support/article/settings-sidebar/#excerpt')
6759 }, (0,external_wp_i18n_namespaceObject.__)('Learn more about manual excerpts')));
6760 }
6761
6762 /* harmony default export */ const post_excerpt = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
6763 return {
6764 excerpt: select(store_store).getEditedPostAttribute('excerpt')
6765 };
6766 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
6767 onUpdateExcerpt(excerpt) {
6768 dispatch(store_store).editPost({
6769 excerpt
6770 });
6771 }
6772
6773 }))])(PostExcerpt));
6774
6775 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-excerpt/check.js
6776
6777
6778
6779 /**
6780 * Internal dependencies
6781 */
6782
6783
6784 function PostExcerptCheck(props) {
6785 return (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, _extends({}, props, {
6786 supportKeys: "excerpt"
6787 }));
6788 }
6789
6790 /* harmony default export */ const post_excerpt_check = (PostExcerptCheck);
6791
6792 ;// CONCATENATED MODULE: external ["wp","blob"]
6793 const external_wp_blob_namespaceObject = window["wp"]["blob"];
6794 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/theme-support-check/index.js
6795 /**
6796 * External dependencies
6797 */
6798
6799 /**
6800 * WordPress dependencies
6801 */
6802
6803
6804
6805 /**
6806 * Internal dependencies
6807 */
6808
6809
6810 function ThemeSupportCheck(_ref) {
6811 let {
6812 themeSupports,
6813 children,
6814 postType,
6815 supportKeys
6816 } = _ref;
6817 const isSupported = (0,external_lodash_namespaceObject.some)((0,external_lodash_namespaceObject.castArray)(supportKeys), key => {
6818 const supported = (0,external_lodash_namespaceObject.get)(themeSupports, [key], false); // 'post-thumbnails' can be boolean or an array of post types.
6819 // In the latter case, we need to verify `postType` exists
6820 // within `supported`. If `postType` isn't passed, then the check
6821 // should fail.
6822
6823 if ('post-thumbnails' === key && Array.isArray(supported)) {
6824 return (0,external_lodash_namespaceObject.includes)(supported, postType);
6825 }
6826
6827 return supported;
6828 });
6829
6830 if (!isSupported) {
6831 return null;
6832 }
6833
6834 return children;
6835 }
6836 /* harmony default export */ const theme_support_check = ((0,external_wp_data_namespaceObject.withSelect)(select => {
6837 const {
6838 getThemeSupports
6839 } = select(external_wp_coreData_namespaceObject.store);
6840 const {
6841 getEditedPostAttribute
6842 } = select(store_store);
6843 return {
6844 postType: getEditedPostAttribute('type'),
6845 themeSupports: getThemeSupports()
6846 };
6847 })(ThemeSupportCheck));
6848
6849 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-featured-image/check.js
6850
6851
6852
6853 /**
6854 * Internal dependencies
6855 */
6856
6857
6858
6859 function PostFeaturedImageCheck(props) {
6860 return (0,external_wp_element_namespaceObject.createElement)(theme_support_check, {
6861 supportKeys: "post-thumbnails"
6862 }, (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, _extends({}, props, {
6863 supportKeys: "thumbnail"
6864 })));
6865 }
6866
6867 /* harmony default export */ const post_featured_image_check = (PostFeaturedImageCheck);
6868
6869 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-featured-image/index.js
6870
6871
6872 /**
6873 * External dependencies
6874 */
6875
6876 /**
6877 * WordPress dependencies
6878 */
6879
6880
6881
6882
6883
6884
6885
6886
6887
6888
6889 /**
6890 * Internal dependencies
6891 */
6892
6893
6894
6895 const ALLOWED_MEDIA_TYPES = ['image']; // Used when labels from post type were not yet loaded or when they are not present.
6896
6897 const DEFAULT_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Featured image');
6898
6899 const DEFAULT_SET_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Set featured image');
6900
6901 const DEFAULT_REMOVE_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Remove image');
6902
6903 const instructions = (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('To edit the featured image, you need permission to upload media.'));
6904
6905 function getMediaDetails(media, postId) {
6906 if (!media) {
6907 return {};
6908 }
6909
6910 const defaultSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'large', media.id, postId);
6911
6912 if ((0,external_lodash_namespaceObject.has)(media, ['media_details', 'sizes', defaultSize])) {
6913 return {
6914 mediaWidth: media.media_details.sizes[defaultSize].width,
6915 mediaHeight: media.media_details.sizes[defaultSize].height,
6916 mediaSourceUrl: media.media_details.sizes[defaultSize].source_url
6917 };
6918 } // Use fallbackSize when defaultSize is not available.
6919
6920
6921 const fallbackSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'thumbnail', media.id, postId);
6922
6923 if ((0,external_lodash_namespaceObject.has)(media, ['media_details', 'sizes', fallbackSize])) {
6924 return {
6925 mediaWidth: media.media_details.sizes[fallbackSize].width,
6926 mediaHeight: media.media_details.sizes[fallbackSize].height,
6927 mediaSourceUrl: media.media_details.sizes[fallbackSize].source_url
6928 };
6929 } // Use full image size when fallbackSize and defaultSize are not available.
6930
6931
6932 return {
6933 mediaWidth: media.media_details.width,
6934 mediaHeight: media.media_details.height,
6935 mediaSourceUrl: media.source_url
6936 };
6937 }
6938
6939 function PostFeaturedImage(_ref) {
6940 var _media$media_details$, _media$media_details$2;
6941
6942 let {
6943 currentPostId,
6944 featuredImageId,
6945 onUpdateImage,
6946 onRemoveImage,
6947 media,
6948 postType,
6949 noticeUI,
6950 noticeOperations
6951 } = _ref;
6952 const [isLoading, setIsLoading] = (0,external_wp_element_namespaceObject.useState)(false);
6953 const mediaUpload = (0,external_wp_data_namespaceObject.useSelect)(select => {
6954 return select(external_wp_blockEditor_namespaceObject.store).getSettings().mediaUpload;
6955 }, []);
6956 const postLabel = (0,external_lodash_namespaceObject.get)(postType, ['labels'], {});
6957 const {
6958 mediaWidth,
6959 mediaHeight,
6960 mediaSourceUrl
6961 } = getMediaDetails(media, currentPostId);
6962
6963 function onDropFiles(filesList) {
6964 mediaUpload({
6965 allowedTypes: ['image'],
6966 filesList,
6967
6968 onFileChange(_ref2) {
6969 let [image] = _ref2;
6970
6971 if ((0,external_wp_blob_namespaceObject.isBlobURL)(image === null || image === void 0 ? void 0 : image.url)) {
6972 setIsLoading(true);
6973 return;
6974 }
6975
6976 onUpdateImage(image);
6977 setIsLoading(false);
6978 },
6979
6980 onError(message) {
6981 noticeOperations.removeAllNotices();
6982 noticeOperations.createErrorNotice(message);
6983 }
6984
6985 });
6986 }
6987
6988 return (0,external_wp_element_namespaceObject.createElement)(post_featured_image_check, null, noticeUI, (0,external_wp_element_namespaceObject.createElement)("div", {
6989 className: "editor-post-featured-image"
6990 }, media && (0,external_wp_element_namespaceObject.createElement)("div", {
6991 id: `editor-post-featured-image-${featuredImageId}-describedby`,
6992 className: "hidden"
6993 }, media.alt_text && (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %s: The selected image alt text.
6994 (0,external_wp_i18n_namespaceObject.__)('Current image: %s'), media.alt_text), !media.alt_text && (0,external_wp_i18n_namespaceObject.sprintf)( // Translators: %s: The selected image filename.
6995 (0,external_wp_i18n_namespaceObject.__)('The current image has no alternative text. The file name is: %s'), ((_media$media_details$ = media.media_details.sizes) === null || _media$media_details$ === void 0 ? void 0 : (_media$media_details$2 = _media$media_details$.full) === null || _media$media_details$2 === void 0 ? void 0 : _media$media_details$2.file) || media.slug)), (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUploadCheck, {
6996 fallback: instructions
6997 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUpload, {
6998 title: postLabel.featured_image || DEFAULT_FEATURE_IMAGE_LABEL,
6999 onSelect: onUpdateImage,
7000 unstableFeaturedImageFlow: true,
7001 allowedTypes: ALLOWED_MEDIA_TYPES,
7002 modalClass: "editor-post-featured-image__media-modal",
7003 render: _ref3 => {
7004 let {
7005 open
7006 } = _ref3;
7007 return (0,external_wp_element_namespaceObject.createElement)("div", {
7008 className: "editor-post-featured-image__container"
7009 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
7010 className: !featuredImageId ? 'editor-post-featured-image__toggle' : 'editor-post-featured-image__preview',
7011 onClick: open,
7012 "aria-label": !featuredImageId ? null : (0,external_wp_i18n_namespaceObject.__)('Edit or update the image'),
7013 "aria-describedby": !featuredImageId ? null : `editor-post-featured-image-${featuredImageId}-describedby`
7014 }, !!featuredImageId && media && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ResponsiveWrapper, {
7015 naturalWidth: mediaWidth,
7016 naturalHeight: mediaHeight,
7017 isInline: true
7018 }, (0,external_wp_element_namespaceObject.createElement)("img", {
7019 src: mediaSourceUrl,
7020 alt: ""
7021 })), isLoading && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null), !featuredImageId && !isLoading && (postLabel.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.DropZone, {
7022 onFilesDrop: onDropFiles
7023 }));
7024 },
7025 value: featuredImageId
7026 })), !!featuredImageId && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUploadCheck, null, media && (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.MediaUpload, {
7027 title: postLabel.featured_image || DEFAULT_FEATURE_IMAGE_LABEL,
7028 onSelect: onUpdateImage,
7029 unstableFeaturedImageFlow: true,
7030 allowedTypes: ALLOWED_MEDIA_TYPES,
7031 modalClass: "editor-post-featured-image__media-modal",
7032 render: _ref4 => {
7033 let {
7034 open
7035 } = _ref4;
7036 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
7037 onClick: open,
7038 variant: "secondary"
7039 }, (0,external_wp_i18n_namespaceObject.__)('Replace Image'));
7040 }
7041 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
7042 onClick: onRemoveImage,
7043 variant: "link",
7044 isDestructive: true
7045 }, postLabel.remove_featured_image || DEFAULT_REMOVE_FEATURE_IMAGE_LABEL))));
7046 }
7047
7048 const applyWithSelect = (0,external_wp_data_namespaceObject.withSelect)(select => {
7049 const {
7050 getMedia,
7051 getPostType
7052 } = select(external_wp_coreData_namespaceObject.store);
7053 const {
7054 getCurrentPostId,
7055 getEditedPostAttribute
7056 } = select(store_store);
7057 const featuredImageId = getEditedPostAttribute('featured_media');
7058 return {
7059 media: featuredImageId ? getMedia(featuredImageId, {
7060 context: 'view'
7061 }) : null,
7062 currentPostId: getCurrentPostId(),
7063 postType: getPostType(getEditedPostAttribute('type')),
7064 featuredImageId
7065 };
7066 });
7067 const applyWithDispatch = (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref5, _ref6) => {
7068 let {
7069 noticeOperations
7070 } = _ref5;
7071 let {
7072 select
7073 } = _ref6;
7074 const {
7075 editPost
7076 } = dispatch(store_store);
7077 return {
7078 onUpdateImage(image) {
7079 editPost({
7080 featured_media: image.id
7081 });
7082 },
7083
7084 onDropImage(filesList) {
7085 select(external_wp_blockEditor_namespaceObject.store).getSettings().mediaUpload({
7086 allowedTypes: ['image'],
7087 filesList,
7088
7089 onFileChange(_ref7) {
7090 let [image] = _ref7;
7091 editPost({
7092 featured_media: image.id
7093 });
7094 },
7095
7096 onError(message) {
7097 noticeOperations.removeAllNotices();
7098 noticeOperations.createErrorNotice(message);
7099 }
7100
7101 });
7102 },
7103
7104 onRemoveImage() {
7105 editPost({
7106 featured_media: 0
7107 });
7108 }
7109
7110 };
7111 });
7112 /* harmony default export */ const post_featured_image = ((0,external_wp_compose_namespaceObject.compose)(external_wp_components_namespaceObject.withNotices, applyWithSelect, applyWithDispatch, (0,external_wp_components_namespaceObject.withFilters)('editor.PostFeaturedImage'))(PostFeaturedImage));
7113
7114 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-format/check.js
7115
7116
7117
7118 /**
7119 * WordPress dependencies
7120 */
7121
7122 /**
7123 * Internal dependencies
7124 */
7125
7126
7127
7128
7129 function PostFormatCheck(_ref) {
7130 let {
7131 disablePostFormats,
7132 ...props
7133 } = _ref;
7134 return !disablePostFormats && (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, _extends({}, props, {
7135 supportKeys: "post-formats"
7136 }));
7137 }
7138
7139 /* harmony default export */ const post_format_check = ((0,external_wp_data_namespaceObject.withSelect)(select => {
7140 const editorSettings = select(store_store).getEditorSettings();
7141 return {
7142 disablePostFormats: editorSettings.disablePostFormats
7143 };
7144 })(PostFormatCheck));
7145
7146 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-format/index.js
7147
7148
7149 /**
7150 * External dependencies
7151 */
7152
7153 /**
7154 * WordPress dependencies
7155 */
7156
7157
7158
7159
7160
7161
7162 /**
7163 * Internal dependencies
7164 */
7165
7166
7167 // All WP post formats, sorted alphabetically by translated name.
7168
7169 const POST_FORMATS = [{
7170 id: 'aside',
7171 caption: (0,external_wp_i18n_namespaceObject.__)('Aside')
7172 }, {
7173 id: 'audio',
7174 caption: (0,external_wp_i18n_namespaceObject.__)('Audio')
7175 }, {
7176 id: 'chat',
7177 caption: (0,external_wp_i18n_namespaceObject.__)('Chat')
7178 }, {
7179 id: 'gallery',
7180 caption: (0,external_wp_i18n_namespaceObject.__)('Gallery')
7181 }, {
7182 id: 'image',
7183 caption: (0,external_wp_i18n_namespaceObject.__)('Image')
7184 }, {
7185 id: 'link',
7186 caption: (0,external_wp_i18n_namespaceObject.__)('Link')
7187 }, {
7188 id: 'quote',
7189 caption: (0,external_wp_i18n_namespaceObject.__)('Quote')
7190 }, {
7191 id: 'standard',
7192 caption: (0,external_wp_i18n_namespaceObject.__)('Standard')
7193 }, {
7194 id: 'status',
7195 caption: (0,external_wp_i18n_namespaceObject.__)('Status')
7196 }, {
7197 id: 'video',
7198 caption: (0,external_wp_i18n_namespaceObject.__)('Video')
7199 }].sort((a, b) => {
7200 const normalizedA = a.caption.toUpperCase();
7201 const normalizedB = b.caption.toUpperCase();
7202
7203 if (normalizedA < normalizedB) {
7204 return -1;
7205 }
7206
7207 if (normalizedA > normalizedB) {
7208 return 1;
7209 }
7210
7211 return 0;
7212 });
7213 function PostFormat() {
7214 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostFormat);
7215 const postFormatSelectorId = `post-format-selector-${instanceId}`;
7216 const {
7217 postFormat,
7218 suggestedFormat,
7219 supportedFormats
7220 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
7221 const {
7222 getEditedPostAttribute,
7223 getSuggestedPostFormat
7224 } = select(store_store);
7225
7226 const _postFormat = getEditedPostAttribute('format');
7227
7228 const themeSupports = select(external_wp_coreData_namespaceObject.store).getThemeSupports();
7229 return {
7230 postFormat: _postFormat !== null && _postFormat !== void 0 ? _postFormat : 'standard',
7231 suggestedFormat: getSuggestedPostFormat(),
7232 supportedFormats: themeSupports.formats
7233 };
7234 }, []);
7235 const formats = POST_FORMATS.filter(format => {
7236 // Ensure current format is always in the set.
7237 // The current format may not be a format supported by the theme.
7238 return (0,external_lodash_namespaceObject.includes)(supportedFormats, format.id) || postFormat === format.id;
7239 });
7240 const suggestion = (0,external_lodash_namespaceObject.find)(formats, format => format.id === suggestedFormat);
7241 const {
7242 editPost
7243 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
7244
7245 const onUpdatePostFormat = format => editPost({
7246 format
7247 });
7248
7249 return (0,external_wp_element_namespaceObject.createElement)(post_format_check, null, (0,external_wp_element_namespaceObject.createElement)("div", {
7250 className: "editor-post-format"
7251 }, (0,external_wp_element_namespaceObject.createElement)("div", {
7252 className: "editor-post-format__content"
7253 }, (0,external_wp_element_namespaceObject.createElement)("label", {
7254 htmlFor: postFormatSelectorId
7255 }, (0,external_wp_i18n_namespaceObject.__)('Post Format')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SelectControl, {
7256 value: postFormat,
7257 onChange: format => onUpdatePostFormat(format),
7258 id: postFormatSelectorId,
7259 options: formats.map(format => ({
7260 label: format.caption,
7261 value: format.id
7262 }))
7263 })), suggestion && suggestion.id !== postFormat && (0,external_wp_element_namespaceObject.createElement)("div", {
7264 className: "editor-post-format__suggestion"
7265 }, (0,external_wp_i18n_namespaceObject.__)('Suggestion:'), ' ', (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
7266 variant: "link",
7267 onClick: () => onUpdatePostFormat(suggestion.id)
7268 }, (0,external_wp_i18n_namespaceObject.sprintf)(
7269 /* translators: %s: post format */
7270 (0,external_wp_i18n_namespaceObject.__)('Apply format: %s'), suggestion.caption)))));
7271 }
7272
7273 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/backup.js
7274
7275
7276 /**
7277 * WordPress dependencies
7278 */
7279
7280 const backup = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
7281 xmlns: "http://www.w3.org/2000/svg",
7282 viewBox: "0 0 24 24"
7283 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
7284 d: "M5.5 12h1.75l-2.5 3-2.5-3H4a8 8 0 113.134 6.35l.907-1.194A6.5 6.5 0 105.5 12zm9.53 1.97l-2.28-2.28V8.5a.75.75 0 00-1.5 0V12a.747.747 0 00.218.529l1.282-.84-1.28.842 2.5 2.5a.75.75 0 101.06-1.061z"
7285 }));
7286 /* harmony default export */ const library_backup = (backup);
7287
7288 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-last-revision/check.js
7289
7290
7291 /**
7292 * WordPress dependencies
7293 */
7294
7295 /**
7296 * Internal dependencies
7297 */
7298
7299
7300
7301 function PostLastRevisionCheck(_ref) {
7302 let {
7303 lastRevisionId,
7304 revisionsCount,
7305 children
7306 } = _ref;
7307
7308 if (!lastRevisionId || revisionsCount < 2) {
7309 return null;
7310 }
7311
7312 return (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, {
7313 supportKeys: "revisions"
7314 }, children);
7315 }
7316 /* harmony default export */ const post_last_revision_check = ((0,external_wp_data_namespaceObject.withSelect)(select => {
7317 const {
7318 getCurrentPostLastRevisionId,
7319 getCurrentPostRevisionsCount
7320 } = select(store_store);
7321 return {
7322 lastRevisionId: getCurrentPostLastRevisionId(),
7323 revisionsCount: getCurrentPostRevisionsCount()
7324 };
7325 })(PostLastRevisionCheck));
7326
7327 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-last-revision/index.js
7328
7329
7330 /**
7331 * WordPress dependencies
7332 */
7333
7334
7335
7336
7337
7338 /**
7339 * Internal dependencies
7340 */
7341
7342
7343
7344
7345 function LastRevision(_ref) {
7346 let {
7347 lastRevisionId,
7348 revisionsCount
7349 } = _ref;
7350 return (0,external_wp_element_namespaceObject.createElement)(post_last_revision_check, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
7351 href: (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
7352 revision: lastRevisionId,
7353 gutenberg: true
7354 }),
7355 className: "editor-post-last-revision__title",
7356 icon: library_backup
7357 }, (0,external_wp_i18n_namespaceObject.sprintf)(
7358 /* translators: %d: number of revisions */
7359 (0,external_wp_i18n_namespaceObject._n)('%d Revision', '%d Revisions', revisionsCount), revisionsCount)));
7360 }
7361
7362 /* harmony default export */ const post_last_revision = ((0,external_wp_data_namespaceObject.withSelect)(select => {
7363 const {
7364 getCurrentPostLastRevisionId,
7365 getCurrentPostRevisionsCount
7366 } = select(store_store);
7367 return {
7368 lastRevisionId: getCurrentPostLastRevisionId(),
7369 revisionsCount: getCurrentPostRevisionsCount()
7370 };
7371 })(LastRevision));
7372
7373 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-locked-modal/index.js
7374
7375
7376 /**
7377 * External dependencies
7378 */
7379
7380 /**
7381 * WordPress dependencies
7382 */
7383
7384
7385
7386
7387
7388
7389
7390
7391
7392 /**
7393 * Internal dependencies
7394 */
7395
7396
7397 function PostLockedModal() {
7398 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostLockedModal);
7399 const hookName = 'core/editor/post-locked-modal-' + instanceId;
7400 const {
7401 autosave,
7402 updatePostLock
7403 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
7404 const {
7405 isLocked,
7406 isTakeover,
7407 user,
7408 postId,
7409 postLockUtils,
7410 activePostLock,
7411 postType,
7412 previewLink
7413 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
7414 const {
7415 isPostLocked,
7416 isPostLockTakeover,
7417 getPostLockUser,
7418 getCurrentPostId,
7419 getActivePostLock,
7420 getEditedPostAttribute,
7421 getEditedPostPreviewLink,
7422 getEditorSettings
7423 } = select(store_store);
7424 const {
7425 getPostType
7426 } = select(external_wp_coreData_namespaceObject.store);
7427 return {
7428 isLocked: isPostLocked(),
7429 isTakeover: isPostLockTakeover(),
7430 user: getPostLockUser(),
7431 postId: getCurrentPostId(),
7432 postLockUtils: getEditorSettings().postLockUtils,
7433 activePostLock: getActivePostLock(),
7434 postType: getPostType(getEditedPostAttribute('type')),
7435 previewLink: getEditedPostPreviewLink()
7436 };
7437 }, []);
7438 (0,external_wp_element_namespaceObject.useEffect)(() => {
7439 /**
7440 * Keep the lock refreshed.
7441 *
7442 * When the user does not send a heartbeat in a heartbeat-tick
7443 * the user is no longer editing and another user can start editing.
7444 *
7445 * @param {Object} data Data to send in the heartbeat request.
7446 */
7447 function sendPostLock(data) {
7448 if (isLocked) {
7449 return;
7450 }
7451
7452 data['wp-refresh-post-lock'] = {
7453 lock: activePostLock,
7454 post_id: postId
7455 };
7456 }
7457 /**
7458 * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing.
7459 *
7460 * @param {Object} data Data received in the heartbeat request
7461 */
7462
7463
7464 function receivePostLock(data) {
7465 if (!data['wp-refresh-post-lock']) {
7466 return;
7467 }
7468
7469 const received = data['wp-refresh-post-lock'];
7470
7471 if (received.lock_error) {
7472 // Auto save and display the takeover modal.
7473 autosave();
7474 updatePostLock({
7475 isLocked: true,
7476 isTakeover: true,
7477 user: {
7478 name: received.lock_error.name,
7479 avatar: received.lock_error.avatar_src_2x
7480 }
7481 });
7482 } else if (received.new_lock) {
7483 updatePostLock({
7484 isLocked: false,
7485 activePostLock: received.new_lock
7486 });
7487 }
7488 }
7489 /**
7490 * Unlock the post before the window is exited.
7491 */
7492
7493
7494 function releasePostLock() {
7495 if (isLocked || !activePostLock) {
7496 return;
7497 }
7498
7499 const data = new window.FormData();
7500 data.append('action', 'wp-remove-post-lock');
7501 data.append('_wpnonce', postLockUtils.unlockNonce);
7502 data.append('post_ID', postId);
7503 data.append('active_post_lock', activePostLock);
7504
7505 if (window.navigator.sendBeacon) {
7506 window.navigator.sendBeacon(postLockUtils.ajaxUrl, data);
7507 } else {
7508 const xhr = new window.XMLHttpRequest();
7509 xhr.open('POST', postLockUtils.ajaxUrl, false);
7510 xhr.send(data);
7511 }
7512 } // Details on these events on the Heartbeat API docs
7513 // https://developer.wordpress.org/plugins/javascript/heartbeat-api/
7514
7515
7516 (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.send', hookName, sendPostLock);
7517 (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.tick', hookName, receivePostLock);
7518 window.addEventListener('beforeunload', releasePostLock);
7519 return () => {
7520 (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.send', hookName);
7521 (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.tick', hookName);
7522 window.removeEventListener('beforeunload', releasePostLock);
7523 };
7524 }, []);
7525
7526 if (!isLocked) {
7527 return null;
7528 }
7529
7530 const userDisplayName = user.name;
7531 const userAvatar = user.avatar;
7532 const unlockUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('post.php', {
7533 'get-post-lock': '1',
7534 lockKey: true,
7535 post: postId,
7536 action: 'edit',
7537 _wpnonce: postLockUtils.nonce
7538 });
7539 const allPostsUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
7540 post_type: (0,external_lodash_namespaceObject.get)(postType, ['slug'])
7541 });
7542
7543 const allPostsLabel = (0,external_wp_i18n_namespaceObject.__)('Exit editor');
7544
7545 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Modal, {
7546 title: isTakeover ? (0,external_wp_i18n_namespaceObject.__)('Someone else has taken over this post') : (0,external_wp_i18n_namespaceObject.__)('This post is already being edited'),
7547 focusOnMount: true,
7548 shouldCloseOnClickOutside: false,
7549 shouldCloseOnEsc: false,
7550 isDismissible: false,
7551 className: "editor-post-locked-modal"
7552 }, !!userAvatar && (0,external_wp_element_namespaceObject.createElement)("img", {
7553 src: userAvatar,
7554 alt: (0,external_wp_i18n_namespaceObject.__)('Avatar'),
7555 className: "editor-post-locked-modal__avatar",
7556 width: 64,
7557 height: 64
7558 }), (0,external_wp_element_namespaceObject.createElement)("div", null, !!isTakeover && (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)(
7559 /* translators: %s: user's display name */
7560 (0,external_wp_i18n_namespaceObject.__)('<strong>%s</strong> now has editing control of this posts (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'), userDisplayName) : (0,external_wp_i18n_namespaceObject.__)('Another user now has editing control of this post (<PreviewLink />). Don’t worry, your changes up to this moment have been saved.'), {
7561 strong: (0,external_wp_element_namespaceObject.createElement)("strong", null),
7562 PreviewLink: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
7563 href: previewLink
7564 }, (0,external_wp_i18n_namespaceObject.__)('preview'))
7565 })), !isTakeover && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)(
7566 /* translators: %s: user's display name */
7567 (0,external_wp_i18n_namespaceObject.__)('<strong>%s</strong> is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'), userDisplayName) : (0,external_wp_i18n_namespaceObject.__)('Another user is currently working on this post (<PreviewLink />), which means you cannot make changes, unless you take over.'), {
7568 strong: (0,external_wp_element_namespaceObject.createElement)("strong", null),
7569 PreviewLink: (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.ExternalLink, {
7570 href: previewLink
7571 }, (0,external_wp_i18n_namespaceObject.__)('preview'))
7572 })), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('If you take over, the other user will lose editing control to the post, but their changes will be saved.'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Flex, {
7573 className: "editor-post-locked-modal__buttons",
7574 justify: "flex-end",
7575 expanded: false
7576 }, !isTakeover && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
7577 variant: "tertiary",
7578 href: unlockUrl
7579 }, (0,external_wp_i18n_namespaceObject.__)('Take over'))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FlexItem, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
7580 variant: "primary",
7581 href: allPostsUrl
7582 }, allPostsLabel)))));
7583 }
7584
7585 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-pending-status/check.js
7586 /**
7587 * External dependencies
7588 */
7589
7590 /**
7591 * WordPress dependencies
7592 */
7593
7594
7595
7596 /**
7597 * Internal dependencies
7598 */
7599
7600
7601 function PostPendingStatusCheck(_ref) {
7602 let {
7603 hasPublishAction,
7604 isPublished,
7605 children
7606 } = _ref;
7607
7608 if (isPublished || !hasPublishAction) {
7609 return null;
7610 }
7611
7612 return children;
7613 }
7614 /* harmony default export */ const post_pending_status_check = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => {
7615 const {
7616 isCurrentPostPublished,
7617 getCurrentPostType,
7618 getCurrentPost
7619 } = select(store_store);
7620 return {
7621 hasPublishAction: (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
7622 isPublished: isCurrentPostPublished(),
7623 postType: getCurrentPostType()
7624 };
7625 }))(PostPendingStatusCheck));
7626
7627 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-pending-status/index.js
7628
7629
7630 /**
7631 * WordPress dependencies
7632 */
7633
7634
7635
7636
7637 /**
7638 * Internal dependencies
7639 */
7640
7641
7642
7643 function PostPendingStatus(_ref) {
7644 let {
7645 status,
7646 onUpdateStatus
7647 } = _ref;
7648
7649 const togglePendingStatus = () => {
7650 const updatedStatus = status === 'pending' ? 'draft' : 'pending';
7651 onUpdateStatus(updatedStatus);
7652 };
7653
7654 return (0,external_wp_element_namespaceObject.createElement)(post_pending_status_check, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
7655 label: (0,external_wp_i18n_namespaceObject.__)('Pending review'),
7656 checked: status === 'pending',
7657 onChange: togglePendingStatus
7658 }));
7659 }
7660 /* harmony default export */ const post_pending_status = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => ({
7661 status: select(store_store).getEditedPostAttribute('status')
7662 })), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
7663 onUpdateStatus(status) {
7664 dispatch(store_store).editPost({
7665 status
7666 });
7667 }
7668
7669 })))(PostPendingStatus));
7670
7671 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-pingbacks/index.js
7672
7673
7674 /**
7675 * WordPress dependencies
7676 */
7677
7678
7679
7680
7681 /**
7682 * Internal dependencies
7683 */
7684
7685
7686
7687 function PostPingbacks(_ref) {
7688 let {
7689 pingStatus = 'open',
7690 ...props
7691 } = _ref;
7692
7693 const onTogglePingback = () => props.editPost({
7694 ping_status: pingStatus === 'open' ? 'closed' : 'open'
7695 });
7696
7697 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
7698 label: (0,external_wp_i18n_namespaceObject.__)('Allow pingbacks & trackbacks'),
7699 checked: pingStatus === 'open',
7700 onChange: onTogglePingback
7701 });
7702 }
7703
7704 /* harmony default export */ const post_pingbacks = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
7705 return {
7706 pingStatus: select(store_store).getEditedPostAttribute('ping_status')
7707 };
7708 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
7709 editPost: dispatch(store_store).editPost
7710 }))])(PostPingbacks));
7711
7712 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-preview-button/index.js
7713
7714
7715 /**
7716 * External dependencies
7717 */
7718
7719
7720 /**
7721 * WordPress dependencies
7722 */
7723
7724
7725
7726
7727
7728
7729
7730
7731 /**
7732 * Internal dependencies
7733 */
7734
7735
7736
7737 function writeInterstitialMessage(targetDocument) {
7738 let markup = (0,external_wp_element_namespaceObject.renderToString)((0,external_wp_element_namespaceObject.createElement)("div", {
7739 className: "editor-post-preview-button__interstitial-message"
7740 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.SVG, {
7741 xmlns: "http://www.w3.org/2000/svg",
7742 viewBox: "0 0 96 96"
7743 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
7744 className: "outer",
7745 d: "M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36",
7746 fill: "none"
7747 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Path, {
7748 className: "inner",
7749 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",
7750 fill: "none"
7751 })), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Generating preview…'))));
7752 markup += `
7753 <style>
7754 body {
7755 margin: 0;
7756 }
7757 .editor-post-preview-button__interstitial-message {
7758 display: flex;
7759 flex-direction: column;
7760 align-items: center;
7761 justify-content: center;
7762 height: 100vh;
7763 width: 100vw;
7764 }
7765 @-webkit-keyframes paint {
7766 0% {
7767 stroke-dashoffset: 0;
7768 }
7769 }
7770 @-moz-keyframes paint {
7771 0% {
7772 stroke-dashoffset: 0;
7773 }
7774 }
7775 @-o-keyframes paint {
7776 0% {
7777 stroke-dashoffset: 0;
7778 }
7779 }
7780 @keyframes paint {
7781 0% {
7782 stroke-dashoffset: 0;
7783 }
7784 }
7785 .editor-post-preview-button__interstitial-message svg {
7786 width: 192px;
7787 height: 192px;
7788 stroke: #555d66;
7789 stroke-width: 0.75;
7790 }
7791 .editor-post-preview-button__interstitial-message svg .outer,
7792 .editor-post-preview-button__interstitial-message svg .inner {
7793 stroke-dasharray: 280;
7794 stroke-dashoffset: 280;
7795 -webkit-animation: paint 1.5s ease infinite alternate;
7796 -moz-animation: paint 1.5s ease infinite alternate;
7797 -o-animation: paint 1.5s ease infinite alternate;
7798 animation: paint 1.5s ease infinite alternate;
7799 }
7800 p {
7801 text-align: center;
7802 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
7803 }
7804 </style>
7805 `;
7806 /**
7807 * Filters the interstitial message shown when generating previews.
7808 *
7809 * @param {string} markup The preview interstitial markup.
7810 */
7811
7812 markup = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostPreview.interstitialMarkup', markup);
7813 targetDocument.write(markup);
7814 targetDocument.title = (0,external_wp_i18n_namespaceObject.__)('Generating preview…');
7815 targetDocument.close();
7816 }
7817
7818 class PostPreviewButton extends external_wp_element_namespaceObject.Component {
7819 constructor() {
7820 super(...arguments);
7821 this.buttonRef = (0,external_wp_element_namespaceObject.createRef)();
7822 this.openPreviewWindow = this.openPreviewWindow.bind(this);
7823 }
7824
7825 componentDidUpdate(prevProps) {
7826 const {
7827 previewLink
7828 } = this.props; // This relies on the window being responsible to unset itself when
7829 // navigation occurs or a new preview window is opened, to avoid
7830 // unintentional forceful redirects.
7831
7832 if (previewLink && !prevProps.previewLink) {
7833 this.setPreviewWindowLink(previewLink);
7834 }
7835 }
7836 /**
7837 * Sets the preview window's location to the given URL, if a preview window
7838 * exists and is not closed.
7839 *
7840 * @param {string} url URL to assign as preview window location.
7841 */
7842
7843
7844 setPreviewWindowLink(url) {
7845 const {
7846 previewWindow
7847 } = this;
7848
7849 if (previewWindow && !previewWindow.closed) {
7850 previewWindow.location = url;
7851
7852 if (this.buttonRef.current) {
7853 this.buttonRef.current.focus();
7854 }
7855 }
7856 }
7857
7858 getWindowTarget() {
7859 const {
7860 postId
7861 } = this.props;
7862 return `wp-preview-${postId}`;
7863 }
7864
7865 openPreviewWindow(event) {
7866 // Our Preview button has its 'href' and 'target' set correctly for a11y
7867 // purposes. Unfortunately, though, we can't rely on the default 'click'
7868 // handler since sometimes it incorrectly opens a new tab instead of reusing
7869 // the existing one.
7870 // https://github.com/WordPress/gutenberg/pull/8330
7871 event.preventDefault(); // Open up a Preview tab if needed. This is where we'll show the preview.
7872
7873 if (!this.previewWindow || this.previewWindow.closed) {
7874 this.previewWindow = window.open('', this.getWindowTarget());
7875 } // Focus the Preview tab. This might not do anything, depending on the browser's
7876 // and user's preferences.
7877 // https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus
7878
7879
7880 this.previewWindow.focus();
7881
7882 if ( // If we don't need to autosave the post before previewing, then we simply
7883 // load the Preview URL in the Preview tab.
7884 !this.props.isAutosaveable || // Do not save or overwrite the post, if the post is already locked.
7885 this.props.isPostLocked) {
7886 this.setPreviewWindowLink(event.target.href);
7887 return;
7888 } // Request an autosave. This happens asynchronously and causes the component
7889 // to update when finished.
7890
7891
7892 if (this.props.isDraft) {
7893 this.props.savePost({
7894 isPreview: true
7895 });
7896 } else {
7897 this.props.autosave({
7898 isPreview: true
7899 });
7900 } // Display a 'Generating preview' message in the Preview tab while we wait for the
7901 // autosave to finish.
7902
7903
7904 writeInterstitialMessage(this.previewWindow.document);
7905 }
7906
7907 render() {
7908 const {
7909 previewLink,
7910 currentPostLink,
7911 isSaveable,
7912 role
7913 } = this.props; // Link to the `?preview=true` URL if we have it, since this lets us see
7914 // changes that were autosaved since the post was last published. Otherwise,
7915 // just link to the post's URL.
7916
7917 const href = previewLink || currentPostLink;
7918 const classNames = classnames_default()({
7919 'editor-post-preview': !this.props.className
7920 }, this.props.className);
7921 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
7922 variant: !this.props.className ? 'tertiary' : undefined,
7923 className: classNames,
7924 href: href,
7925 target: this.getWindowTarget(),
7926 disabled: !isSaveable,
7927 onClick: this.openPreviewWindow,
7928 ref: this.buttonRef,
7929 role: role
7930 }, this.props.textContent ? this.props.textContent : (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject._x)('Preview', 'imperative verb'), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
7931 as: "span"
7932 },
7933 /* translators: accessibility text */
7934 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)'))));
7935 }
7936
7937 }
7938 /* harmony default export */ const post_preview_button = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, _ref) => {
7939 let {
7940 forcePreviewLink,
7941 forceIsAutosaveable
7942 } = _ref;
7943 const {
7944 getCurrentPostId,
7945 getCurrentPostAttribute,
7946 getEditedPostAttribute,
7947 isEditedPostSaveable,
7948 isEditedPostAutosaveable,
7949 getEditedPostPreviewLink,
7950 isPostLocked
7951 } = select(store_store);
7952 const {
7953 getPostType
7954 } = select(external_wp_coreData_namespaceObject.store);
7955 const previewLink = getEditedPostPreviewLink();
7956 const postType = getPostType(getEditedPostAttribute('type'));
7957 return {
7958 postId: getCurrentPostId(),
7959 currentPostLink: getCurrentPostAttribute('link'),
7960 previewLink: forcePreviewLink !== undefined ? forcePreviewLink : previewLink,
7961 isSaveable: isEditedPostSaveable(),
7962 isAutosaveable: forceIsAutosaveable || isEditedPostAutosaveable(),
7963 isViewable: (0,external_lodash_namespaceObject.get)(postType, ['viewable'], false),
7964 isDraft: ['draft', 'auto-draft'].indexOf(getEditedPostAttribute('status')) !== -1,
7965 isPostLocked: isPostLocked()
7966 };
7967 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => ({
7968 autosave: dispatch(store_store).autosave,
7969 savePost: dispatch(store_store).savePost
7970 })), (0,external_wp_compose_namespaceObject.ifCondition)(_ref2 => {
7971 let {
7972 isViewable
7973 } = _ref2;
7974 return isViewable;
7975 })])(PostPreviewButton));
7976
7977 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-button/label.js
7978 /**
7979 * External dependencies
7980 */
7981
7982 /**
7983 * WordPress dependencies
7984 */
7985
7986
7987
7988
7989 /**
7990 * Internal dependencies
7991 */
7992
7993
7994 function PublishButtonLabel(_ref) {
7995 let {
7996 isPublished,
7997 isBeingScheduled,
7998 isSaving,
7999 isPublishing,
8000 hasPublishAction,
8001 isAutosaving,
8002 hasNonPostEntityChanges
8003 } = _ref;
8004
8005 if (isPublishing) {
8006 /* translators: button label text should, if possible, be under 16 characters. */
8007 return (0,external_wp_i18n_namespaceObject.__)('Publishing…');
8008 } else if (isPublished && isSaving && !isAutosaving) {
8009 /* translators: button label text should, if possible, be under 16 characters. */
8010 return (0,external_wp_i18n_namespaceObject.__)('Updating…');
8011 } else if (isBeingScheduled && isSaving && !isAutosaving) {
8012 /* translators: button label text should, if possible, be under 16 characters. */
8013 return (0,external_wp_i18n_namespaceObject.__)('Scheduling…');
8014 }
8015
8016 if (!hasPublishAction) {
8017 return hasNonPostEntityChanges ? (0,external_wp_i18n_namespaceObject.__)('Submit for Review…') : (0,external_wp_i18n_namespaceObject.__)('Submit for Review');
8018 } else if (isPublished) {
8019 return hasNonPostEntityChanges ? (0,external_wp_i18n_namespaceObject.__)('Update…') : (0,external_wp_i18n_namespaceObject.__)('Update');
8020 } else if (isBeingScheduled) {
8021 return hasNonPostEntityChanges ? (0,external_wp_i18n_namespaceObject.__)('Schedule…') : (0,external_wp_i18n_namespaceObject.__)('Schedule');
8022 }
8023
8024 return (0,external_wp_i18n_namespaceObject.__)('Publish');
8025 }
8026 /* harmony default export */ const label = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, _ref2) => {
8027 let {
8028 forceIsSaving
8029 } = _ref2;
8030 const {
8031 isCurrentPostPublished,
8032 isEditedPostBeingScheduled,
8033 isSavingPost,
8034 isPublishingPost,
8035 getCurrentPost,
8036 getCurrentPostType,
8037 isAutosavingPost
8038 } = select(store_store);
8039 return {
8040 isPublished: isCurrentPostPublished(),
8041 isBeingScheduled: isEditedPostBeingScheduled(),
8042 isSaving: forceIsSaving || isSavingPost(),
8043 isPublishing: isPublishingPost(),
8044 hasPublishAction: (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
8045 postType: getCurrentPostType(),
8046 isAutosaving: isAutosavingPost()
8047 };
8048 })])(PublishButtonLabel));
8049
8050 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-button/index.js
8051
8052
8053
8054 /**
8055 * External dependencies
8056 */
8057
8058
8059 /**
8060 * WordPress dependencies
8061 */
8062
8063
8064
8065
8066
8067
8068 /**
8069 * Internal dependencies
8070 */
8071
8072
8073
8074
8075 const noop = () => {};
8076
8077 class PostPublishButton extends external_wp_element_namespaceObject.Component {
8078 constructor(props) {
8079 super(props);
8080 this.buttonNode = (0,external_wp_element_namespaceObject.createRef)();
8081 this.createOnClick = this.createOnClick.bind(this);
8082 this.closeEntitiesSavedStates = this.closeEntitiesSavedStates.bind(this);
8083 this.state = {
8084 entitiesSavedStatesCallback: false
8085 };
8086 }
8087
8088 componentDidMount() {
8089 if (this.props.focusOnMount) {
8090 this.buttonNode.current.focus();
8091 }
8092 }
8093
8094 createOnClick(callback) {
8095 var _this = this;
8096
8097 return function () {
8098 for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
8099 args[_key] = arguments[_key];
8100 }
8101
8102 const {
8103 hasNonPostEntityChanges,
8104 setEntitiesSavedStatesCallback
8105 } = _this.props; // If a post with non-post entities is published, but the user
8106 // elects to not save changes to the non-post entities, those
8107 // entities will still be dirty when the Publish button is clicked.
8108 // We also need to check that the `setEntitiesSavedStatesCallback`
8109 // prop was passed. See https://github.com/WordPress/gutenberg/pull/37383
8110
8111 if (hasNonPostEntityChanges && setEntitiesSavedStatesCallback) {
8112 // The modal for multiple entity saving will open,
8113 // hold the callback for saving/publishing the post
8114 // so that we can call it if the post entity is checked.
8115 _this.setState({
8116 entitiesSavedStatesCallback: () => callback(...args)
8117 }); // Open the save panel by setting its callback.
8118 // To set a function on the useState hook, we must set it
8119 // with another function (() => myFunction). Passing the
8120 // function on its own will cause an error when called.
8121
8122
8123 setEntitiesSavedStatesCallback(() => _this.closeEntitiesSavedStates);
8124 return noop;
8125 }
8126
8127 return callback(...args);
8128 };
8129 }
8130
8131 closeEntitiesSavedStates(savedEntities) {
8132 const {
8133 postType,
8134 postId
8135 } = this.props;
8136 const {
8137 entitiesSavedStatesCallback
8138 } = this.state;
8139 this.setState({
8140 entitiesSavedStatesCallback: false
8141 }, () => {
8142 if (savedEntities && (0,external_lodash_namespaceObject.some)(savedEntities, elt => elt.kind === 'postType' && elt.name === postType && elt.key === postId)) {
8143 // The post entity was checked, call the held callback from `createOnClick`.
8144 entitiesSavedStatesCallback();
8145 }
8146 });
8147 }
8148
8149 render() {
8150 const {
8151 forceIsDirty,
8152 forceIsSaving,
8153 hasPublishAction,
8154 isBeingScheduled,
8155 isOpen,
8156 isPostSavingLocked,
8157 isPublishable,
8158 isPublished,
8159 isSaveable,
8160 isSaving,
8161 isAutoSaving,
8162 isToggle,
8163 onSave,
8164 onStatusChange,
8165 onSubmit = noop,
8166 onToggle,
8167 visibility,
8168 hasNonPostEntityChanges,
8169 isSavingNonPostEntityChanges
8170 } = this.props;
8171 const isButtonDisabled = (isSaving || forceIsSaving || !isSaveable || isPostSavingLocked || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
8172 const isToggleDisabled = (isPublished || isSaving || forceIsSaving || !isSaveable || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
8173 let publishStatus;
8174
8175 if (!hasPublishAction) {
8176 publishStatus = 'pending';
8177 } else if (visibility === 'private') {
8178 publishStatus = 'private';
8179 } else if (isBeingScheduled) {
8180 publishStatus = 'future';
8181 } else {
8182 publishStatus = 'publish';
8183 }
8184
8185 const onClickButton = () => {
8186 if (isButtonDisabled) {
8187 return;
8188 }
8189
8190 onSubmit();
8191 onStatusChange(publishStatus);
8192 onSave();
8193 };
8194
8195 const onClickToggle = () => {
8196 if (isToggleDisabled) {
8197 return;
8198 }
8199
8200 onToggle();
8201 };
8202
8203 const buttonProps = {
8204 'aria-disabled': isButtonDisabled,
8205 className: 'editor-post-publish-button',
8206 isBusy: !isAutoSaving && isSaving && isPublished,
8207 variant: 'primary',
8208 onClick: this.createOnClick(onClickButton)
8209 };
8210 const toggleProps = {
8211 'aria-disabled': isToggleDisabled,
8212 'aria-expanded': isOpen,
8213 className: 'editor-post-publish-panel__toggle',
8214 isBusy: isSaving && isPublished,
8215 variant: 'primary',
8216 onClick: this.createOnClick(onClickToggle)
8217 };
8218 const toggleChildren = isBeingScheduled ? (0,external_wp_i18n_namespaceObject.__)('Schedule…') : (0,external_wp_i18n_namespaceObject.__)('Publish');
8219 const buttonChildren = (0,external_wp_element_namespaceObject.createElement)(label, {
8220 forceIsSaving: forceIsSaving,
8221 hasNonPostEntityChanges: hasNonPostEntityChanges
8222 });
8223 const componentProps = isToggle ? toggleProps : buttonProps;
8224 const componentChildren = isToggle ? toggleChildren : buttonChildren;
8225 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({
8226 ref: this.buttonNode
8227 }, componentProps, {
8228 className: classnames_default()(componentProps.className, 'editor-post-publish-button__button', {
8229 'has-changes-dot': hasNonPostEntityChanges
8230 })
8231 }), componentChildren));
8232 }
8233
8234 }
8235 /* harmony default export */ const post_publish_button = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
8236 const {
8237 isSavingPost,
8238 isAutosavingPost,
8239 isEditedPostBeingScheduled,
8240 getEditedPostVisibility,
8241 isCurrentPostPublished,
8242 isEditedPostSaveable,
8243 isEditedPostPublishable,
8244 isPostSavingLocked,
8245 getCurrentPost,
8246 getCurrentPostType,
8247 getCurrentPostId,
8248 hasNonPostEntityChanges,
8249 isSavingNonPostEntityChanges
8250 } = select(store_store);
8251
8252 const _isAutoSaving = isAutosavingPost();
8253
8254 return {
8255 isSaving: isSavingPost() || _isAutoSaving,
8256 isAutoSaving: _isAutoSaving,
8257 isBeingScheduled: isEditedPostBeingScheduled(),
8258 visibility: getEditedPostVisibility(),
8259 isSaveable: isEditedPostSaveable(),
8260 isPostSavingLocked: isPostSavingLocked(),
8261 isPublishable: isEditedPostPublishable(),
8262 isPublished: isCurrentPostPublished(),
8263 hasPublishAction: (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
8264 postType: getCurrentPostType(),
8265 postId: getCurrentPostId(),
8266 hasNonPostEntityChanges: hasNonPostEntityChanges(),
8267 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges()
8268 };
8269 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
8270 const {
8271 editPost,
8272 savePost
8273 } = dispatch(store_store);
8274 return {
8275 onStatusChange: status => editPost({
8276 status
8277 }, {
8278 undoIgnore: true
8279 }),
8280 onSave: savePost
8281 };
8282 })])(PostPublishButton));
8283
8284 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close-small.js
8285
8286
8287 /**
8288 * WordPress dependencies
8289 */
8290
8291 const closeSmall = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
8292 xmlns: "http://www.w3.org/2000/svg",
8293 viewBox: "0 0 24 24"
8294 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
8295 d: "M12 13.06l3.712 3.713 1.061-1.06L13.061 12l3.712-3.712-1.06-1.06L12 10.938 8.288 7.227l-1.061 1.06L10.939 12l-3.712 3.712 1.06 1.061L12 13.061z"
8296 }));
8297 /* harmony default export */ const close_small = (closeSmall);
8298
8299 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/wordpress.js
8300
8301
8302 /**
8303 * WordPress dependencies
8304 */
8305
8306 const wordpress = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
8307 xmlns: "http://www.w3.org/2000/svg",
8308 viewBox: "-2 -2 24 24"
8309 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
8310 d: "M20 10c0-5.51-4.49-10-10-10C4.48 0 0 4.49 0 10c0 5.52 4.48 10 10 10 5.51 0 10-4.48 10-10zM7.78 15.37L4.37 6.22c.55-.02 1.17-.08 1.17-.08.5-.06.44-1.13-.06-1.11 0 0-1.45.11-2.37.11-.18 0-.37 0-.58-.01C4.12 2.69 6.87 1.11 10 1.11c2.33 0 4.45.87 6.05 2.34-.68-.11-1.65.39-1.65 1.58 0 .74.45 1.36.9 2.1.35.61.55 1.36.55 2.46 0 1.49-1.4 5-1.4 5l-3.03-8.37c.54-.02.82-.17.82-.17.5-.05.44-1.25-.06-1.22 0 0-1.44.12-2.38.12-.87 0-2.33-.12-2.33-.12-.5-.03-.56 1.2-.06 1.22l.92.08 1.26 3.41zM17.41 10c.24-.64.74-1.87.43-4.25.7 1.29 1.05 2.71 1.05 4.25 0 3.29-1.73 6.24-4.4 7.78.97-2.59 1.94-5.2 2.92-7.78zM6.1 18.09C3.12 16.65 1.11 13.53 1.11 10c0-1.3.23-2.48.72-3.59C3.25 10.3 4.67 14.2 6.1 18.09zm4.03-6.63l2.58 6.98c-.86.29-1.76.45-2.71.45-.79 0-1.57-.11-2.29-.33.81-2.38 1.62-4.74 2.42-7.1z"
8311 }));
8312 /* harmony default export */ const library_wordpress = (wordpress);
8313
8314 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/utils.js
8315 /**
8316 * WordPress dependencies
8317 */
8318
8319 const visibilityOptions = {
8320 public: {
8321 label: (0,external_wp_i18n_namespaceObject.__)('Public'),
8322 info: (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.')
8323 },
8324 private: {
8325 label: (0,external_wp_i18n_namespaceObject.__)('Private'),
8326 info: (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.')
8327 },
8328 password: {
8329 label: (0,external_wp_i18n_namespaceObject.__)('Password protected'),
8330 info: (0,external_wp_i18n_namespaceObject.__)('Only those with the password can view this post.')
8331 }
8332 };
8333
8334 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/index.js
8335
8336
8337
8338 /**
8339 * WordPress dependencies
8340 */
8341
8342
8343
8344
8345
8346
8347 /**
8348 * Internal dependencies
8349 */
8350
8351
8352
8353 function PostVisibility(_ref) {
8354 let {
8355 onClose
8356 } = _ref;
8357 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostVisibility);
8358 const {
8359 status,
8360 visibility,
8361 password
8362 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
8363 status: select(store_store).getEditedPostAttribute('status'),
8364 visibility: select(store_store).getEditedPostVisibility(),
8365 password: select(store_store).getEditedPostAttribute('password')
8366 }));
8367 const {
8368 editPost,
8369 savePost
8370 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
8371 const [hasPassword, setHasPassword] = (0,external_wp_element_namespaceObject.useState)(!!password);
8372 const [showPrivateConfirmDialog, setShowPrivateConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
8373
8374 const setPublic = () => {
8375 editPost({
8376 status: visibility === 'private' ? 'draft' : status,
8377 password: ''
8378 });
8379 setHasPassword(false);
8380 };
8381
8382 const setPrivate = () => {
8383 setShowPrivateConfirmDialog(true);
8384 };
8385
8386 const confirmPrivate = () => {
8387 editPost({
8388 status: 'private',
8389 password: ''
8390 });
8391 setHasPassword(false);
8392 setShowPrivateConfirmDialog(false);
8393 savePost();
8394 };
8395
8396 const handleDialogCancel = () => {
8397 setShowPrivateConfirmDialog(false);
8398 };
8399
8400 const setPasswordProtected = () => {
8401 editPost({
8402 status: visibility === 'private' ? 'draft' : status,
8403 password: password || ''
8404 });
8405 setHasPassword(true);
8406 };
8407
8408 const updatePassword = event => {
8409 editPost({
8410 password: event.target.value
8411 });
8412 };
8413
8414 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
8415 title: (0,external_wp_i18n_namespaceObject.__)('Visibility'),
8416 help: (0,external_wp_i18n_namespaceObject.__)('Control how this post is viewed.'),
8417 onClose: onClose
8418 }), (0,external_wp_element_namespaceObject.createElement)("fieldset", {
8419 className: "editor-post-visibility__fieldset"
8420 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
8421 as: "legend"
8422 }, (0,external_wp_i18n_namespaceObject.__)('Visibility')), (0,external_wp_element_namespaceObject.createElement)(PostVisibilityChoice, {
8423 instanceId: instanceId,
8424 value: "public",
8425 label: visibilityOptions["public"].label,
8426 info: visibilityOptions["public"].info,
8427 checked: visibility === 'public' && !hasPassword,
8428 onChange: setPublic
8429 }), (0,external_wp_element_namespaceObject.createElement)(PostVisibilityChoice, {
8430 instanceId: instanceId,
8431 value: "private",
8432 label: visibilityOptions["private"].label,
8433 info: visibilityOptions["private"].info,
8434 checked: visibility === 'private',
8435 onChange: setPrivate
8436 }), (0,external_wp_element_namespaceObject.createElement)(PostVisibilityChoice, {
8437 instanceId: instanceId,
8438 value: "password",
8439 label: visibilityOptions.password.label,
8440 info: visibilityOptions.password.info,
8441 checked: hasPassword,
8442 onChange: setPasswordProtected
8443 }), hasPassword && (0,external_wp_element_namespaceObject.createElement)("div", {
8444 className: "editor-post-visibility__password"
8445 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
8446 as: "label",
8447 htmlFor: `editor-post-visibility__password-input-${instanceId}`
8448 }, (0,external_wp_i18n_namespaceObject.__)('Create password')), (0,external_wp_element_namespaceObject.createElement)("input", {
8449 className: "editor-post-visibility__password-input",
8450 id: `editor-post-visibility__password-input-${instanceId}`,
8451 type: "text",
8452 onChange: updatePassword,
8453 value: password,
8454 placeholder: (0,external_wp_i18n_namespaceObject.__)('Use a secure password')
8455 }))), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
8456 isOpen: showPrivateConfirmDialog,
8457 onConfirm: confirmPrivate,
8458 onCancel: handleDialogCancel
8459 }, (0,external_wp_i18n_namespaceObject.__)('Would you like to privately publish this post now?')));
8460 }
8461
8462 function PostVisibilityChoice(_ref2) {
8463 let {
8464 instanceId,
8465 value,
8466 label,
8467 info,
8468 ...props
8469 } = _ref2;
8470 return (0,external_wp_element_namespaceObject.createElement)("div", {
8471 className: "editor-post-visibility__choice"
8472 }, (0,external_wp_element_namespaceObject.createElement)("input", _extends({
8473 type: "radio",
8474 name: `editor-post-visibility__setting-${instanceId}`,
8475 value: value,
8476 id: `editor-post-${value}-${instanceId}`,
8477 "aria-describedby": `editor-post-${value}-${instanceId}-description`,
8478 className: "editor-post-visibility__radio"
8479 }, props)), (0,external_wp_element_namespaceObject.createElement)("label", {
8480 htmlFor: `editor-post-${value}-${instanceId}`,
8481 className: "editor-post-visibility__label"
8482 }, label), (0,external_wp_element_namespaceObject.createElement)("p", {
8483 id: `editor-post-${value}-${instanceId}-description`,
8484 className: "editor-post-visibility__info"
8485 }, info));
8486 }
8487
8488 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/label.js
8489 /**
8490 * WordPress dependencies
8491 */
8492
8493 /**
8494 * Internal dependencies
8495 */
8496
8497
8498
8499 function PostVisibilityLabel() {
8500 var _visibilityOptions$vi;
8501
8502 const visibility = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostVisibility());
8503 return (_visibilityOptions$vi = visibilityOptions[visibility]) === null || _visibilityOptions$vi === void 0 ? void 0 : _visibilityOptions$vi.label;
8504 }
8505
8506 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-schedule/index.js
8507
8508
8509 /**
8510 * WordPress dependencies
8511 */
8512
8513
8514
8515
8516
8517 /**
8518 * Internal dependencies
8519 */
8520
8521
8522
8523 function getDayOfTheMonth() {
8524 let date = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : new Date();
8525 let firstDay = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
8526 const d = new Date(date);
8527 return new Date(d.getFullYear(), d.getMonth() + (firstDay ? 0 : 1), firstDay ? 1 : 0).toISOString();
8528 }
8529
8530 function PostSchedule(_ref) {
8531 let {
8532 onClose
8533 } = _ref;
8534 const {
8535 postDate,
8536 postType
8537 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
8538 postDate: select(store_store).getEditedPostAttribute('date'),
8539 postType: select(store_store).getCurrentPostType()
8540 }), []);
8541 const {
8542 editPost
8543 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
8544
8545 const onUpdateDate = date => editPost({
8546 date
8547 });
8548
8549 const [previewedMonth, setPreviewedMonth] = (0,external_wp_element_namespaceObject.useState)(getDayOfTheMonth(postDate)); // Pick up published and schduled site posts.
8550
8551 const eventsByPostType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', postType, {
8552 status: 'publish,future',
8553 after: getDayOfTheMonth(previewedMonth),
8554 before: getDayOfTheMonth(previewedMonth, false),
8555 exclude: [select(store_store).getCurrentPostId()]
8556 }), [previewedMonth, postType]);
8557 const events = (0,external_wp_element_namespaceObject.useMemo)(() => (eventsByPostType || []).map(_ref2 => {
8558 let {
8559 title,
8560 type,
8561 date: eventDate
8562 } = _ref2;
8563 return {
8564 title: title === null || title === void 0 ? void 0 : title.rendered,
8565 type,
8566 date: new Date(eventDate)
8567 };
8568 }), [eventsByPostType]);
8569
8570 const settings = (0,external_wp_date_namespaceObject.__experimentalGetSettings)(); // To know if the current timezone is a 12 hour time with look for "a" in the time format
8571 // We also make sure this a is not escaped by a "/"
8572
8573
8574 const is12HourTime = /a(?!\\)/i.test(settings.formats.time.toLowerCase() // Test only the lower case a.
8575 .replace(/\\\\/g, '') // Replace "//" with empty strings.
8576 .split('').reverse().join('') // Reverse the string and test for "a" not followed by a slash.
8577 );
8578 return (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.__experimentalPublishDateTimePicker, {
8579 currentDate: postDate,
8580 onChange: onUpdateDate,
8581 is12Hour: is12HourTime,
8582 events: events,
8583 onMonthPreviewed: setPreviewedMonth,
8584 onClose: onClose
8585 });
8586 }
8587
8588 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-schedule/label.js
8589 /**
8590 * WordPress dependencies
8591 */
8592
8593
8594
8595 /**
8596 * Internal dependencies
8597 */
8598
8599
8600 function PostScheduleLabel(_ref) {
8601 let {
8602 date,
8603 isFloating
8604 } = _ref;
8605
8606 const settings = (0,external_wp_date_namespaceObject.__experimentalGetSettings)();
8607
8608 return date && !isFloating ? (0,external_wp_date_namespaceObject.format)(`${settings.formats.date} ${settings.formats.time}`, date) : (0,external_wp_i18n_namespaceObject.__)('Immediately');
8609 }
8610 /* harmony default export */ const post_schedule_label = ((0,external_wp_data_namespaceObject.withSelect)(select => {
8611 return {
8612 date: select(store_store).getEditedPostAttribute('date'),
8613 isFloating: select(store_store).isEditedPostDateFloating()
8614 };
8615 })(PostScheduleLabel));
8616
8617 ;// CONCATENATED MODULE: external ["wp","a11y"]
8618 const external_wp_a11y_namespaceObject = window["wp"]["a11y"];
8619 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/most-used-terms.js
8620
8621
8622 /**
8623 * External dependencies
8624 */
8625
8626 /**
8627 * WordPress dependencies
8628 */
8629
8630
8631
8632
8633 /**
8634 * Internal dependencies
8635 */
8636
8637
8638 const MIN_MOST_USED_TERMS = 3;
8639 const DEFAULT_QUERY = {
8640 per_page: 10,
8641 orderby: 'count',
8642 order: 'desc',
8643 hide_empty: true,
8644 _fields: 'id,name,count',
8645 context: 'view'
8646 };
8647 function MostUsedTerms(_ref) {
8648 let {
8649 onSelect,
8650 taxonomy
8651 } = _ref;
8652 const {
8653 _terms,
8654 showTerms
8655 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8656 const mostUsedTerms = select(external_wp_coreData_namespaceObject.store).getEntityRecords('taxonomy', taxonomy.slug, DEFAULT_QUERY);
8657 return {
8658 _terms: mostUsedTerms,
8659 showTerms: (mostUsedTerms === null || mostUsedTerms === void 0 ? void 0 : mostUsedTerms.length) >= MIN_MOST_USED_TERMS
8660 };
8661 }, []);
8662
8663 if (!showTerms) {
8664 return null;
8665 }
8666
8667 const terms = unescapeTerms(_terms);
8668 const label = (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', 'most_used']);
8669 return (0,external_wp_element_namespaceObject.createElement)("div", {
8670 className: "editor-post-taxonomies__flat-term-most-used"
8671 }, (0,external_wp_element_namespaceObject.createElement)("h3", {
8672 className: "editor-post-taxonomies__flat-term-most-used-label"
8673 }, label), (0,external_wp_element_namespaceObject.createElement)("ul", {
8674 role: "list",
8675 className: "editor-post-taxonomies__flat-term-most-used-list"
8676 }, terms.map(term => (0,external_wp_element_namespaceObject.createElement)("li", {
8677 key: term.id
8678 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
8679 variant: "link",
8680 onClick: () => onSelect(term)
8681 }, term.name)))));
8682 }
8683
8684 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/flat-term-selector.js
8685
8686
8687 /**
8688 * External dependencies
8689 */
8690
8691 /**
8692 * WordPress dependencies
8693 */
8694
8695
8696
8697
8698
8699
8700
8701
8702
8703
8704 /**
8705 * Internal dependencies
8706 */
8707
8708
8709
8710
8711 /**
8712 * Shared reference to an empty array for cases where it is important to avoid
8713 * returning a new array reference on every invocation.
8714 *
8715 * @type {Array<any>}
8716 */
8717
8718 const flat_term_selector_EMPTY_ARRAY = [];
8719 /**
8720 * Module constants
8721 */
8722
8723 const MAX_TERMS_SUGGESTIONS = 20;
8724 const flat_term_selector_DEFAULT_QUERY = {
8725 per_page: MAX_TERMS_SUGGESTIONS,
8726 orderby: 'count',
8727 order: 'desc',
8728 _fields: 'id,name',
8729 context: 'view'
8730 };
8731
8732 const isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase();
8733
8734 const termNamesToIds = (names, terms) => {
8735 return names.map(termName => (0,external_lodash_namespaceObject.find)(terms, term => isSameTermName(term.name, termName)).id);
8736 }; // Tries to create a term or fetch it if it already exists.
8737
8738
8739 function findOrCreateTerm(termName, restBase) {
8740 const escapedTermName = (0,external_lodash_namespaceObject.escape)(termName);
8741 return external_wp_apiFetch_default()({
8742 path: `/wp/v2/${restBase}`,
8743 method: 'POST',
8744 data: {
8745 name: escapedTermName
8746 }
8747 }).catch(error => {
8748 const errorCode = error.code;
8749
8750 if (errorCode === 'term_exists') {
8751 // If the terms exist, fetch it instead of creating a new one.
8752 const addRequest = external_wp_apiFetch_default()({
8753 path: (0,external_wp_url_namespaceObject.addQueryArgs)(`/wp/v2/${restBase}`, { ...flat_term_selector_DEFAULT_QUERY,
8754 search: escapedTermName
8755 })
8756 }).then(unescapeTerms);
8757 return addRequest.then(searchResult => {
8758 return (0,external_lodash_namespaceObject.find)(searchResult, result => isSameTermName(result.name, termName));
8759 });
8760 }
8761
8762 return Promise.reject(error);
8763 }).then(unescapeTerm);
8764 }
8765
8766 function FlatTermSelector(_ref) {
8767 let {
8768 slug
8769 } = _ref;
8770 const [values, setValues] = (0,external_wp_element_namespaceObject.useState)([]);
8771 const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)('');
8772 const debouncedSearch = (0,external_wp_compose_namespaceObject.useDebounce)(setSearch, 500);
8773 const {
8774 terms,
8775 termIds,
8776 taxonomy,
8777 hasAssignAction,
8778 hasCreateAction,
8779 hasResolvedTerms
8780 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8781 const {
8782 getCurrentPost,
8783 getEditedPostAttribute
8784 } = select(store_store);
8785 const {
8786 getEntityRecords,
8787 getTaxonomy,
8788 hasFinishedResolution
8789 } = select(external_wp_coreData_namespaceObject.store);
8790 const post = getCurrentPost();
8791
8792 const _taxonomy = getTaxonomy(slug);
8793
8794 const _termIds = _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : flat_term_selector_EMPTY_ARRAY;
8795
8796 const query = { ...flat_term_selector_DEFAULT_QUERY,
8797 include: _termIds.join(','),
8798 per_page: -1
8799 };
8800 return {
8801 hasCreateAction: _taxonomy ? (0,external_lodash_namespaceObject.get)(post, ['_links', 'wp:action-create-' + _taxonomy.rest_base], false) : false,
8802 hasAssignAction: _taxonomy ? (0,external_lodash_namespaceObject.get)(post, ['_links', 'wp:action-assign-' + _taxonomy.rest_base], false) : false,
8803 taxonomy: _taxonomy,
8804 termIds: _termIds,
8805 terms: _termIds.length ? getEntityRecords('taxonomy', slug, query) : flat_term_selector_EMPTY_ARRAY,
8806 hasResolvedTerms: hasFinishedResolution('getEntityRecords', ['taxonomy', slug, query])
8807 };
8808 }, [slug]);
8809 const {
8810 searchResults
8811 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8812 const {
8813 getEntityRecords
8814 } = select(external_wp_coreData_namespaceObject.store);
8815 return {
8816 searchResults: !!search ? getEntityRecords('taxonomy', slug, { ...flat_term_selector_DEFAULT_QUERY,
8817 search
8818 }) : flat_term_selector_EMPTY_ARRAY
8819 };
8820 }, [search]); // Update terms state only after the selectors are resolved.
8821 // We're using this to avoid terms temporarily disappearing on slow networks
8822 // while core data makes REST API requests.
8823
8824 (0,external_wp_element_namespaceObject.useEffect)(() => {
8825 if (hasResolvedTerms) {
8826 const newValues = (terms !== null && terms !== void 0 ? terms : []).map(term => unescapeString(term.name));
8827 setValues(newValues);
8828 }
8829 }, [terms, hasResolvedTerms]);
8830 const suggestions = (0,external_wp_element_namespaceObject.useMemo)(() => {
8831 return (searchResults !== null && searchResults !== void 0 ? searchResults : []).map(term => unescapeString(term.name));
8832 }, [searchResults]);
8833 const {
8834 editPost
8835 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
8836
8837 if (!hasAssignAction) {
8838 return null;
8839 }
8840
8841 function onUpdateTerms(newTermIds) {
8842 editPost({
8843 [taxonomy.rest_base]: newTermIds
8844 });
8845 }
8846
8847 function onChange(termNames) {
8848 const availableTerms = [...(terms !== null && terms !== void 0 ? terms : []), ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])];
8849 const uniqueTerms = (0,external_lodash_namespaceObject.uniqBy)(termNames, term => term.toLowerCase());
8850 const newTermNames = uniqueTerms.filter(termName => !(0,external_lodash_namespaceObject.find)(availableTerms, term => isSameTermName(term.name, termName))); // Optimistically update term values.
8851 // The selector will always re-fetch terms later.
8852
8853 setValues(uniqueTerms);
8854
8855 if (newTermNames.length === 0) {
8856 return onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
8857 }
8858
8859 if (!hasCreateAction) {
8860 return;
8861 }
8862
8863 Promise.all(newTermNames.map(termName => findOrCreateTerm(termName, taxonomy.rest_base))).then(newTerms => {
8864 const newAvailableTerms = availableTerms.concat(newTerms);
8865 return onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms));
8866 });
8867 }
8868
8869 function appendTerm(newTerm) {
8870 if (termIds.includes(newTerm.id)) {
8871 return;
8872 }
8873
8874 const newTermIds = [...termIds, newTerm.id];
8875 const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
8876 /* translators: %s: term name. */
8877 (0,external_wp_i18n_namespaceObject._x)('%s added', 'term'), (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', 'singular_name'], slug === 'post_tag' ? (0,external_wp_i18n_namespaceObject.__)('Tag') : (0,external_wp_i18n_namespaceObject.__)('Term')));
8878 (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive');
8879 onUpdateTerms(newTermIds);
8880 }
8881
8882 const newTermLabel = (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', 'add_new_item'], slug === 'post_tag' ? (0,external_wp_i18n_namespaceObject.__)('Add new tag') : (0,external_wp_i18n_namespaceObject.__)('Add new Term'));
8883 const singularName = (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', 'singular_name'], slug === 'post_tag' ? (0,external_wp_i18n_namespaceObject.__)('Tag') : (0,external_wp_i18n_namespaceObject.__)('Term'));
8884 const termAddedLabel = (0,external_wp_i18n_namespaceObject.sprintf)(
8885 /* translators: %s: term name. */
8886 (0,external_wp_i18n_namespaceObject._x)('%s added', 'term'), singularName);
8887 const termRemovedLabel = (0,external_wp_i18n_namespaceObject.sprintf)(
8888 /* translators: %s: term name. */
8889 (0,external_wp_i18n_namespaceObject._x)('%s removed', 'term'), singularName);
8890 const removeTermLabel = (0,external_wp_i18n_namespaceObject.sprintf)(
8891 /* translators: %s: term name. */
8892 (0,external_wp_i18n_namespaceObject._x)('Remove %s', 'term'), singularName);
8893 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.FormTokenField, {
8894 value: values,
8895 suggestions: suggestions,
8896 onChange: onChange,
8897 onInputChange: debouncedSearch,
8898 maxSuggestions: MAX_TERMS_SUGGESTIONS,
8899 label: newTermLabel,
8900 messages: {
8901 added: termAddedLabel,
8902 removed: termRemovedLabel,
8903 remove: removeTermLabel
8904 }
8905 }), (0,external_wp_element_namespaceObject.createElement)(MostUsedTerms, {
8906 taxonomy: taxonomy,
8907 onSelect: appendTerm
8908 }));
8909 }
8910
8911 /* harmony default export */ const flat_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(FlatTermSelector));
8912
8913 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/maybe-tags-panel.js
8914
8915
8916 /**
8917 * External dependencies
8918 */
8919
8920 /**
8921 * WordPress dependencies
8922 */
8923
8924
8925
8926
8927
8928
8929
8930 /**
8931 * Internal dependencies
8932 */
8933
8934
8935
8936
8937 const TagsPanel = () => {
8938 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), (0,external_wp_element_namespaceObject.createElement)("span", {
8939 className: "editor-post-publish-panel__link",
8940 key: "label"
8941 }, (0,external_wp_i18n_namespaceObject.__)('Add tags'))];
8942 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
8943 initialOpen: false,
8944 title: panelBodyTitle
8945 }, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Tags help users and search engines navigate your site and find your content. Add a few keywords to describe your post.')), (0,external_wp_element_namespaceObject.createElement)(flat_term_selector, {
8946 slug: 'post_tag'
8947 }));
8948 };
8949
8950 class MaybeTagsPanel extends external_wp_element_namespaceObject.Component {
8951 constructor(props) {
8952 super(props);
8953 this.state = {
8954 hadTagsWhenOpeningThePanel: props.hasTags
8955 };
8956 }
8957 /*
8958 * We only want to show the tag panel if the post didn't have
8959 * any tags when the user hit the Publish button.
8960 *
8961 * We can't use the prop.hasTags because it'll change to true
8962 * if the user adds a new tag within the pre-publish panel.
8963 * This would force a re-render and a new prop.hasTags check,
8964 * hiding this panel and keeping the user from adding
8965 * more than one tag.
8966 */
8967
8968
8969 render() {
8970 if (!this.state.hadTagsWhenOpeningThePanel) {
8971 return (0,external_wp_element_namespaceObject.createElement)(TagsPanel, null);
8972 }
8973
8974 return null;
8975 }
8976
8977 }
8978
8979 /* harmony default export */ const maybe_tags_panel = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => {
8980 const postType = select(store_store).getCurrentPostType();
8981 const tagsTaxonomy = select(external_wp_coreData_namespaceObject.store).getTaxonomy('post_tag');
8982 const tags = tagsTaxonomy && select(store_store).getEditedPostAttribute(tagsTaxonomy.rest_base);
8983 return {
8984 areTagsFetched: tagsTaxonomy !== undefined,
8985 isPostTypeSupported: tagsTaxonomy && (0,external_lodash_namespaceObject.some)(tagsTaxonomy.types, type => type === postType),
8986 hasTags: tags && tags.length
8987 };
8988 }), (0,external_wp_compose_namespaceObject.ifCondition)(_ref => {
8989 let {
8990 areTagsFetched,
8991 isPostTypeSupported
8992 } = _ref;
8993 return isPostTypeSupported && areTagsFetched;
8994 }))(MaybeTagsPanel));
8995
8996 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/maybe-post-format-panel.js
8997
8998
8999 /**
9000 * External dependencies
9001 */
9002
9003 /**
9004 * WordPress dependencies
9005 */
9006
9007
9008
9009
9010
9011 /**
9012 * Internal dependencies
9013 */
9014
9015
9016
9017
9018 const getSuggestion = (supportedFormats, suggestedPostFormat) => {
9019 const formats = POST_FORMATS.filter(format => (0,external_lodash_namespaceObject.includes)(supportedFormats, format.id));
9020 return (0,external_lodash_namespaceObject.find)(formats, format => format.id === suggestedPostFormat);
9021 };
9022
9023 const PostFormatSuggestion = _ref => {
9024 let {
9025 suggestedPostFormat,
9026 suggestionText,
9027 onUpdatePostFormat
9028 } = _ref;
9029 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9030 variant: "link",
9031 onClick: () => onUpdatePostFormat(suggestedPostFormat)
9032 }, suggestionText);
9033 };
9034
9035 function PostFormatPanel() {
9036 const {
9037 currentPostFormat,
9038 suggestion
9039 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9040 const {
9041 getEditedPostAttribute,
9042 getSuggestedPostFormat
9043 } = select(store_store);
9044 const supportedFormats = (0,external_lodash_namespaceObject.get)(select(external_wp_coreData_namespaceObject.store).getThemeSupports(), ['formats'], []);
9045 return {
9046 currentPostFormat: getEditedPostAttribute('format'),
9047 suggestion: getSuggestion(supportedFormats, getSuggestedPostFormat())
9048 };
9049 }, []);
9050 const {
9051 editPost
9052 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9053
9054 const onUpdatePostFormat = format => editPost({
9055 format
9056 });
9057
9058 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), (0,external_wp_element_namespaceObject.createElement)("span", {
9059 className: "editor-post-publish-panel__link",
9060 key: "label"
9061 }, (0,external_wp_i18n_namespaceObject.__)('Use a post format'))];
9062
9063 if (!suggestion || suggestion.id === currentPostFormat) {
9064 return null;
9065 }
9066
9067 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
9068 initialOpen: false,
9069 title: panelBodyTitle
9070 }, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Your theme uses post formats to highlight different kinds of content, like images or videos. Apply a post format to see this special styling.')), (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_element_namespaceObject.createElement)(PostFormatSuggestion, {
9071 onUpdatePostFormat: onUpdatePostFormat,
9072 suggestedPostFormat: suggestion.id,
9073 suggestionText: (0,external_wp_i18n_namespaceObject.sprintf)(
9074 /* translators: %s: post format */
9075 (0,external_wp_i18n_namespaceObject.__)('Apply the "%1$s" format.'), suggestion.caption)
9076 })));
9077 }
9078
9079 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/hierarchical-term-selector.js
9080
9081
9082 /**
9083 * External dependencies
9084 */
9085
9086 /**
9087 * WordPress dependencies
9088 */
9089
9090
9091
9092
9093
9094
9095
9096
9097 /**
9098 * Internal dependencies
9099 */
9100
9101
9102
9103 /**
9104 * Module Constants
9105 */
9106
9107 const hierarchical_term_selector_DEFAULT_QUERY = {
9108 per_page: -1,
9109 orderby: 'name',
9110 order: 'asc',
9111 _fields: 'id,name,parent',
9112 context: 'view'
9113 };
9114 const MIN_TERMS_COUNT_FOR_FILTER = 8;
9115 const hierarchical_term_selector_EMPTY_ARRAY = [];
9116 /**
9117 * Sort Terms by Selected.
9118 *
9119 * @param {Object[]} termsTree Array of terms in tree format.
9120 * @param {number[]} terms Selected terms.
9121 *
9122 * @return {Object[]} Sorted array of terms.
9123 */
9124
9125 function sortBySelected(termsTree, terms) {
9126 const treeHasSelection = termTree => {
9127 if (terms.indexOf(termTree.id) !== -1) {
9128 return true;
9129 }
9130
9131 if (undefined === termTree.children) {
9132 return false;
9133 }
9134
9135 return termTree.children.map(treeHasSelection).filter(child => child).length > 0;
9136 };
9137
9138 const termOrChildIsSelected = (termA, termB) => {
9139 const termASelected = treeHasSelection(termA);
9140 const termBSelected = treeHasSelection(termB);
9141
9142 if (termASelected === termBSelected) {
9143 return 0;
9144 }
9145
9146 if (termASelected && !termBSelected) {
9147 return -1;
9148 }
9149
9150 if (!termASelected && termBSelected) {
9151 return 1;
9152 }
9153
9154 return 0;
9155 };
9156
9157 const newTermTree = [...termsTree];
9158 newTermTree.sort(termOrChildIsSelected);
9159 return newTermTree;
9160 }
9161 /**
9162 * Find term by parent id or name.
9163 *
9164 * @param {Object[]} terms Array of Terms.
9165 * @param {number|string} parent id.
9166 * @param {string} name Term name.
9167 * @return {Object} Term object.
9168 */
9169
9170 function findTerm(terms, parent, name) {
9171 return (0,external_lodash_namespaceObject.find)(terms, term => {
9172 return (!term.parent && !parent || parseInt(term.parent) === parseInt(parent)) && term.name.toLowerCase() === name.toLowerCase();
9173 });
9174 }
9175 /**
9176 * Get filter matcher function.
9177 *
9178 * @param {string} filterValue Filter value.
9179 * @return {(function(Object): (Object|boolean))} Matcher function.
9180 */
9181
9182 function getFilterMatcher(filterValue) {
9183 const matchTermsForFilter = originalTerm => {
9184 if ('' === filterValue) {
9185 return originalTerm;
9186 } // Shallow clone, because we'll be filtering the term's children and
9187 // don't want to modify the original term.
9188
9189
9190 const term = { ...originalTerm
9191 }; // Map and filter the children, recursive so we deal with grandchildren
9192 // and any deeper levels.
9193
9194 if (term.children.length > 0) {
9195 term.children = term.children.map(matchTermsForFilter).filter(child => child);
9196 } // If the term's name contains the filterValue, or it has children
9197 // (i.e. some child matched at some point in the tree) then return it.
9198
9199
9200 if (-1 !== term.name.toLowerCase().indexOf(filterValue.toLowerCase()) || term.children.length > 0) {
9201 return term;
9202 } // Otherwise, return false. After mapping, the list of terms will need
9203 // to have false values filtered out.
9204
9205
9206 return false;
9207 };
9208
9209 return matchTermsForFilter;
9210 }
9211 /**
9212 * Hierarchical term selector.
9213 *
9214 * @param {Object} props Component props.
9215 * @param {string} props.slug Taxonomy slug.
9216 * @return {WPElement} Hierarchical term selector component.
9217 */
9218
9219 function HierarchicalTermSelector(_ref) {
9220 let {
9221 slug
9222 } = _ref;
9223 const [adding, setAdding] = (0,external_wp_element_namespaceObject.useState)(false);
9224 const [formName, setFormName] = (0,external_wp_element_namespaceObject.useState)('');
9225 /**
9226 * @type {[number|'', Function]}
9227 */
9228
9229 const [formParent, setFormParent] = (0,external_wp_element_namespaceObject.useState)('');
9230 const [showForm, setShowForm] = (0,external_wp_element_namespaceObject.useState)(false);
9231 const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
9232 const [filteredTermsTree, setFilteredTermsTree] = (0,external_wp_element_namespaceObject.useState)([]);
9233 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
9234 const {
9235 hasCreateAction,
9236 hasAssignAction,
9237 terms,
9238 loading,
9239 availableTerms,
9240 taxonomy
9241 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9242 const {
9243 getCurrentPost,
9244 getEditedPostAttribute
9245 } = select(store_store);
9246 const {
9247 getTaxonomy,
9248 getEntityRecords,
9249 isResolving
9250 } = select(external_wp_coreData_namespaceObject.store);
9251
9252 const _taxonomy = getTaxonomy(slug);
9253
9254 return {
9255 hasCreateAction: _taxonomy ? (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-create-' + _taxonomy.rest_base], false) : false,
9256 hasAssignAction: _taxonomy ? (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-assign-' + _taxonomy.rest_base], false) : false,
9257 terms: _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : hierarchical_term_selector_EMPTY_ARRAY,
9258 loading: isResolving('getEntityRecords', ['taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY]),
9259 availableTerms: getEntityRecords('taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY) || hierarchical_term_selector_EMPTY_ARRAY,
9260 taxonomy: _taxonomy
9261 };
9262 }, [slug]);
9263 const {
9264 editPost
9265 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9266 const {
9267 saveEntityRecord
9268 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
9269 const availableTermsTree = (0,external_wp_element_namespaceObject.useMemo)(() => sortBySelected(buildTermsTree(availableTerms), terms), // Remove `terms` from the dependency list to avoid reordering every time
9270 // checking or unchecking a term.
9271 [availableTerms]);
9272
9273 if (!hasAssignAction) {
9274 return null;
9275 }
9276 /**
9277 * Append new term.
9278 *
9279 * @param {Object} term Term object.
9280 * @return {Promise} A promise that resolves to save term object.
9281 */
9282
9283
9284 const addTerm = term => {
9285 return saveEntityRecord('taxonomy', slug, term);
9286 };
9287 /**
9288 * Update terms for post.
9289 *
9290 * @param {number[]} termIds Term ids.
9291 */
9292
9293
9294 const onUpdateTerms = termIds => {
9295 editPost({
9296 [taxonomy.rest_base]: termIds
9297 });
9298 };
9299 /**
9300 * Handler for checking term.
9301 *
9302 * @param {number} termId
9303 */
9304
9305
9306 const onChange = termId => {
9307 const hasTerm = terms.includes(termId);
9308 const newTerms = hasTerm ? (0,external_lodash_namespaceObject.without)(terms, termId) : [...terms, termId];
9309 onUpdateTerms(newTerms);
9310 };
9311
9312 const onChangeFormName = value => {
9313 setFormName(value);
9314 };
9315 /**
9316 * Handler for changing form parent.
9317 *
9318 * @param {number|''} parentId Parent post id.
9319 */
9320
9321
9322 const onChangeFormParent = parentId => {
9323 setFormParent(parentId);
9324 };
9325
9326 const onToggleForm = () => {
9327 setShowForm(!showForm);
9328 };
9329
9330 const onAddTerm = async event => {
9331 event.preventDefault();
9332
9333 if (formName === '' || adding) {
9334 return;
9335 } // Check if the term we are adding already exists.
9336
9337
9338 const existingTerm = findTerm(availableTerms, formParent, formName);
9339
9340 if (existingTerm) {
9341 // If the term we are adding exists but is not selected select it.
9342 if (!(0,external_lodash_namespaceObject.some)(terms, term => term === existingTerm.id)) {
9343 onUpdateTerms([...terms, existingTerm.id]);
9344 }
9345
9346 setFormName('');
9347 setFormParent('');
9348 return;
9349 }
9350
9351 setAdding(true);
9352 const newTerm = await addTerm({
9353 name: formName,
9354 parent: formParent ? formParent : undefined
9355 });
9356 const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
9357 /* translators: %s: taxonomy name */
9358 (0,external_wp_i18n_namespaceObject._x)('%s added', 'term'), (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', 'singular_name'], slug === 'category' ? (0,external_wp_i18n_namespaceObject.__)('Category') : (0,external_wp_i18n_namespaceObject.__)('Term')));
9359 (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive');
9360 setAdding(false);
9361 setFormName('');
9362 setFormParent('');
9363 onUpdateTerms([...terms, newTerm.id]);
9364 };
9365
9366 const setFilter = value => {
9367 const newFilteredTermsTree = availableTermsTree.map(getFilterMatcher(value)).filter(term => term);
9368
9369 const getResultCount = termsTree => {
9370 let count = 0;
9371
9372 for (let i = 0; i < termsTree.length; i++) {
9373 count++;
9374
9375 if (undefined !== termsTree[i].children) {
9376 count += getResultCount(termsTree[i].children);
9377 }
9378 }
9379
9380 return count;
9381 };
9382
9383 setFilterValue(value);
9384 setFilteredTermsTree(newFilteredTermsTree);
9385 const resultCount = getResultCount(newFilteredTermsTree);
9386 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)(
9387 /* translators: %d: number of results */
9388 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', resultCount), resultCount);
9389 debouncedSpeak(resultsFoundMessage, 'assertive');
9390 };
9391
9392 const renderTerms = renderedTerms => {
9393 return renderedTerms.map(term => {
9394 return (0,external_wp_element_namespaceObject.createElement)("div", {
9395 key: term.id,
9396 className: "editor-post-taxonomies__hierarchical-terms-choice"
9397 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
9398 checked: terms.indexOf(term.id) !== -1,
9399 onChange: () => {
9400 const termId = parseInt(term.id, 10);
9401 onChange(termId);
9402 },
9403 label: (0,external_lodash_namespaceObject.unescape)(term.name)
9404 }), !!term.children.length && (0,external_wp_element_namespaceObject.createElement)("div", {
9405 className: "editor-post-taxonomies__hierarchical-terms-subchoices"
9406 }, renderTerms(term.children)));
9407 });
9408 };
9409
9410 const labelWithFallback = (labelProperty, fallbackIsCategory, fallbackIsNotCategory) => (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', labelProperty], slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory);
9411
9412 const newTermButtonLabel = labelWithFallback('add_new_item', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term'));
9413 const newTermLabel = labelWithFallback('new_item_name', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term'));
9414 const parentSelectLabel = labelWithFallback('parent_item', (0,external_wp_i18n_namespaceObject.__)('Parent Category'), (0,external_wp_i18n_namespaceObject.__)('Parent Term'));
9415 const noParentOption = `— ${parentSelectLabel} —`;
9416 const newTermSubmitLabel = newTermButtonLabel;
9417 const filterLabel = (0,external_lodash_namespaceObject.get)(taxonomy, ['labels', 'search_items'], (0,external_wp_i18n_namespaceObject.__)('Search Terms'));
9418 const groupLabel = (0,external_lodash_namespaceObject.get)(taxonomy, ['name'], (0,external_wp_i18n_namespaceObject.__)('Terms'));
9419 const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;
9420 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, showFilter && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
9421 className: "editor-post-taxonomies__hierarchical-terms-filter",
9422 label: filterLabel,
9423 value: filterValue,
9424 onChange: setFilter
9425 }), (0,external_wp_element_namespaceObject.createElement)("div", {
9426 className: "editor-post-taxonomies__hierarchical-terms-list",
9427 tabIndex: "0",
9428 role: "group",
9429 "aria-label": groupLabel
9430 }, renderTerms('' !== filterValue ? filteredTermsTree : availableTermsTree)), !loading && hasCreateAction && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9431 onClick: onToggleForm,
9432 className: "editor-post-taxonomies__hierarchical-terms-add",
9433 "aria-expanded": showForm,
9434 variant: "link"
9435 }, newTermButtonLabel), showForm && (0,external_wp_element_namespaceObject.createElement)("form", {
9436 onSubmit: onAddTerm
9437 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
9438 className: "editor-post-taxonomies__hierarchical-terms-input",
9439 label: newTermLabel,
9440 value: formName,
9441 onChange: onChangeFormName,
9442 required: true
9443 }), !!availableTerms.length && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TreeSelect, {
9444 label: parentSelectLabel,
9445 noOptionLabel: noParentOption,
9446 onChange: onChangeFormParent,
9447 selectedId: formParent,
9448 tree: availableTermsTree
9449 }), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9450 variant: "secondary",
9451 type: "submit",
9452 className: "editor-post-taxonomies__hierarchical-terms-submit"
9453 }, newTermSubmitLabel)));
9454 }
9455
9456 /* harmony default export */ const hierarchical_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(HierarchicalTermSelector));
9457
9458 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/maybe-category-panel.js
9459
9460
9461 /**
9462 * External dependencies
9463 */
9464
9465 /**
9466 * WordPress dependencies
9467 */
9468
9469
9470
9471
9472
9473
9474 /**
9475 * Internal dependencies
9476 */
9477
9478
9479
9480
9481 function MaybeCategoryPanel() {
9482 const hasNoCategory = (0,external_wp_data_namespaceObject.useSelect)(select => {
9483 var _select$getEntityReco;
9484
9485 const postType = select(store_store).getCurrentPostType();
9486 const categoriesTaxonomy = select(external_wp_coreData_namespaceObject.store).getTaxonomy('category');
9487 const defaultCategorySlug = 'uncategorized';
9488 const defaultCategory = (_select$getEntityReco = select(external_wp_coreData_namespaceObject.store).getEntityRecords('taxonomy', 'category', {
9489 slug: defaultCategorySlug
9490 })) === null || _select$getEntityReco === void 0 ? void 0 : _select$getEntityReco[0];
9491 const postTypeSupportsCategories = categoriesTaxonomy && (0,external_lodash_namespaceObject.some)(categoriesTaxonomy.types, type => type === postType);
9492 const categories = categoriesTaxonomy && select(store_store).getEditedPostAttribute(categoriesTaxonomy.rest_base); // This boolean should return true if everything is loaded
9493 // ( categoriesTaxonomy, defaultCategory )
9494 // and the post has not been assigned a category different than "uncategorized".
9495
9496 return !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && ((categories === null || categories === void 0 ? void 0 : categories.length) === 0 || (categories === null || categories === void 0 ? void 0 : categories.length) === 1 && defaultCategory.id === categories[0]);
9497 }, []);
9498 const [shouldShowPanel, setShouldShowPanel] = (0,external_wp_element_namespaceObject.useState)(false);
9499 (0,external_wp_element_namespaceObject.useEffect)(() => {
9500 // We use state to avoid hiding the panel if the user edits the categories
9501 // and adds one within the panel itself (while visible).
9502 if (hasNoCategory) {
9503 setShouldShowPanel(true);
9504 }
9505 }, [hasNoCategory]);
9506
9507 if (!shouldShowPanel) {
9508 return null;
9509 }
9510
9511 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), (0,external_wp_element_namespaceObject.createElement)("span", {
9512 className: "editor-post-publish-panel__link",
9513 key: "label"
9514 }, (0,external_wp_i18n_namespaceObject.__)('Assign a category'))];
9515 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
9516 initialOpen: false,
9517 title: panelBodyTitle
9518 }, (0,external_wp_element_namespaceObject.createElement)("p", null, (0,external_wp_i18n_namespaceObject.__)('Categories provide a helpful way to group related posts together and to quickly tell readers what a post is about.')), (0,external_wp_element_namespaceObject.createElement)(hierarchical_term_selector, {
9519 slug: "category"
9520 }));
9521 }
9522
9523 /* harmony default export */ const maybe_category_panel = (MaybeCategoryPanel);
9524
9525 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/prepublish.js
9526
9527
9528 /**
9529 * External dependencies
9530 */
9531
9532 /**
9533 * WordPress dependencies
9534 */
9535
9536
9537
9538
9539
9540
9541
9542
9543 /**
9544 * Internal dependencies
9545 */
9546
9547
9548
9549
9550
9551
9552
9553
9554
9555
9556 function PostPublishPanelPrepublish(_ref) {
9557 let {
9558 children
9559 } = _ref;
9560 const {
9561 isBeingScheduled,
9562 isRequestingSiteIcon,
9563 hasPublishAction,
9564 siteIconUrl,
9565 siteTitle,
9566 siteHome
9567 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9568 const {
9569 getCurrentPost,
9570 isEditedPostBeingScheduled
9571 } = select(store_store);
9572 const {
9573 getEntityRecord,
9574 isResolving
9575 } = select(external_wp_coreData_namespaceObject.store);
9576 const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
9577 return {
9578 hasPublishAction: (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
9579 isBeingScheduled: isEditedPostBeingScheduled(),
9580 isRequestingSiteIcon: isResolving('getEntityRecord', ['root', '__unstableBase', undefined]),
9581 siteIconUrl: siteData.site_icon_url,
9582 siteTitle: siteData.name,
9583 siteHome: siteData.home && (0,external_wp_url_namespaceObject.filterURLForDisplay)(siteData.home)
9584 };
9585 }, []);
9586 let siteIcon = (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Icon, {
9587 className: "components-site-icon",
9588 size: "36px",
9589 icon: library_wordpress
9590 });
9591
9592 if (siteIconUrl) {
9593 siteIcon = (0,external_wp_element_namespaceObject.createElement)("img", {
9594 alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'),
9595 className: "components-site-icon",
9596 src: siteIconUrl
9597 });
9598 }
9599
9600 if (isRequestingSiteIcon) {
9601 siteIcon = null;
9602 }
9603
9604 let prePublishTitle, prePublishBodyText;
9605
9606 if (!hasPublishAction) {
9607 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to submit for review?');
9608 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('When you’re ready, submit your work for review, and an Editor will be able to approve it for you.');
9609 } else if (isBeingScheduled) {
9610 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to schedule?');
9611 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Your work will be published at the specified date and time.');
9612 } else {
9613 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to publish?');
9614 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Double-check your settings before publishing.');
9615 }
9616
9617 return (0,external_wp_element_namespaceObject.createElement)("div", {
9618 className: "editor-post-publish-panel__prepublish"
9619 }, (0,external_wp_element_namespaceObject.createElement)("div", null, (0,external_wp_element_namespaceObject.createElement)("strong", null, prePublishTitle)), (0,external_wp_element_namespaceObject.createElement)("p", null, prePublishBodyText), (0,external_wp_element_namespaceObject.createElement)("div", {
9620 className: "components-site-card"
9621 }, siteIcon, (0,external_wp_element_namespaceObject.createElement)("div", {
9622 className: "components-site-info"
9623 }, (0,external_wp_element_namespaceObject.createElement)("span", {
9624 className: "components-site-name"
9625 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle) || (0,external_wp_i18n_namespaceObject.__)('(Untitled)')), (0,external_wp_element_namespaceObject.createElement)("span", {
9626 className: "components-site-home"
9627 }, siteHome))), hasPublishAction && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
9628 initialOpen: false,
9629 title: [(0,external_wp_i18n_namespaceObject.__)('Visibility:'), (0,external_wp_element_namespaceObject.createElement)("span", {
9630 className: "editor-post-publish-panel__link",
9631 key: "label"
9632 }, (0,external_wp_element_namespaceObject.createElement)(PostVisibilityLabel, null))]
9633 }, (0,external_wp_element_namespaceObject.createElement)(PostVisibility, null)), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
9634 initialOpen: false,
9635 title: [(0,external_wp_i18n_namespaceObject.__)('Publish:'), (0,external_wp_element_namespaceObject.createElement)("span", {
9636 className: "editor-post-publish-panel__link",
9637 key: "label"
9638 }, (0,external_wp_element_namespaceObject.createElement)(post_schedule_label, null))]
9639 }, (0,external_wp_element_namespaceObject.createElement)(PostSchedule, null))), (0,external_wp_element_namespaceObject.createElement)(PostFormatPanel, null), (0,external_wp_element_namespaceObject.createElement)(maybe_tags_panel, null), (0,external_wp_element_namespaceObject.createElement)(maybe_category_panel, null), children);
9640 }
9641
9642 /* harmony default export */ const prepublish = (PostPublishPanelPrepublish);
9643
9644 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/postpublish.js
9645
9646
9647 /**
9648 * External dependencies
9649 */
9650
9651 /**
9652 * WordPress dependencies
9653 */
9654
9655
9656
9657
9658
9659
9660
9661
9662
9663 /**
9664 * Internal dependencies
9665 */
9666
9667
9668
9669 const POSTNAME = '%postname%';
9670 /**
9671 * Returns URL for a future post.
9672 *
9673 * @param {Object} post Post object.
9674 *
9675 * @return {string} PostPublish URL.
9676 */
9677
9678 const getFuturePostUrl = post => {
9679 const {
9680 slug
9681 } = post;
9682
9683 if (post.permalink_template.includes(POSTNAME)) {
9684 return post.permalink_template.replace(POSTNAME, slug);
9685 }
9686
9687 return post.permalink_template;
9688 };
9689
9690 function postpublish_CopyButton(_ref) {
9691 let {
9692 text,
9693 onCopy,
9694 children
9695 } = _ref;
9696 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text, onCopy);
9697 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9698 variant: "secondary",
9699 ref: ref
9700 }, children);
9701 }
9702
9703 class PostPublishPanelPostpublish extends external_wp_element_namespaceObject.Component {
9704 constructor() {
9705 super(...arguments);
9706 this.state = {
9707 showCopyConfirmation: false
9708 };
9709 this.onCopy = this.onCopy.bind(this);
9710 this.onSelectInput = this.onSelectInput.bind(this);
9711 this.postLink = (0,external_wp_element_namespaceObject.createRef)();
9712 }
9713
9714 componentDidMount() {
9715 if (this.props.focusOnMount) {
9716 this.postLink.current.focus();
9717 }
9718 }
9719
9720 componentWillUnmount() {
9721 clearTimeout(this.dismissCopyConfirmation);
9722 }
9723
9724 onCopy() {
9725 this.setState({
9726 showCopyConfirmation: true
9727 });
9728 clearTimeout(this.dismissCopyConfirmation);
9729 this.dismissCopyConfirmation = setTimeout(() => {
9730 this.setState({
9731 showCopyConfirmation: false
9732 });
9733 }, 4000);
9734 }
9735
9736 onSelectInput(event) {
9737 event.target.select();
9738 }
9739
9740 render() {
9741 const {
9742 children,
9743 isScheduled,
9744 post,
9745 postType
9746 } = this.props;
9747 const postLabel = (0,external_lodash_namespaceObject.get)(postType, ['labels', 'singular_name']);
9748 const viewPostLabel = (0,external_lodash_namespaceObject.get)(postType, ['labels', 'view_item']);
9749 const addNewPostLabel = (0,external_lodash_namespaceObject.get)(postType, ['labels', 'add_new_item']);
9750 const link = post.status === 'future' ? getFuturePostUrl(post) : post.link;
9751 const addLink = (0,external_wp_url_namespaceObject.addQueryArgs)('post-new.php', {
9752 post_type: post.type
9753 });
9754 const postPublishNonLinkHeader = isScheduled ? (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_i18n_namespaceObject.__)('is now scheduled. It will go live on'), ' ', (0,external_wp_element_namespaceObject.createElement)(post_schedule_label, null), ".") : (0,external_wp_i18n_namespaceObject.__)('is now live.');
9755 return (0,external_wp_element_namespaceObject.createElement)("div", {
9756 className: "post-publish-panel__postpublish"
9757 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, {
9758 className: "post-publish-panel__postpublish-header"
9759 }, (0,external_wp_element_namespaceObject.createElement)("a", {
9760 ref: this.postLink,
9761 href: link
9762 }, (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title) || (0,external_wp_i18n_namespaceObject.__)('(no title)')), ' ', postPublishNonLinkHeader), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.PanelBody, null, (0,external_wp_element_namespaceObject.createElement)("p", {
9763 className: "post-publish-panel__postpublish-subheader"
9764 }, (0,external_wp_element_namespaceObject.createElement)("strong", null, (0,external_wp_i18n_namespaceObject.__)('What’s next?'))), (0,external_wp_element_namespaceObject.createElement)("div", {
9765 className: "post-publish-panel__postpublish-post-address-container"
9766 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.TextControl, {
9767 className: "post-publish-panel__postpublish-post-address",
9768 readOnly: true,
9769 label: (0,external_wp_i18n_namespaceObject.sprintf)(
9770 /* translators: %s: post type singular name */
9771 (0,external_wp_i18n_namespaceObject.__)('%s address'), postLabel),
9772 value: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(link),
9773 onFocus: this.onSelectInput
9774 }), (0,external_wp_element_namespaceObject.createElement)("div", {
9775 className: "post-publish-panel__postpublish-post-address__copy-button-wrap"
9776 }, (0,external_wp_element_namespaceObject.createElement)(postpublish_CopyButton, {
9777 text: link,
9778 onCopy: this.onCopy
9779 }, this.state.showCopyConfirmation ? (0,external_wp_i18n_namespaceObject.__)('Copied!') : (0,external_wp_i18n_namespaceObject.__)('Copy')))), (0,external_wp_element_namespaceObject.createElement)("div", {
9780 className: "post-publish-panel__postpublish-buttons"
9781 }, !isScheduled && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9782 variant: "primary",
9783 href: link
9784 }, viewPostLabel), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9785 variant: isScheduled ? 'primary' : 'secondary',
9786 href: addLink
9787 }, addNewPostLabel))), children);
9788 }
9789
9790 }
9791
9792 /* harmony default export */ const postpublish = ((0,external_wp_data_namespaceObject.withSelect)(select => {
9793 const {
9794 getEditedPostAttribute,
9795 getCurrentPost,
9796 isCurrentPostScheduled
9797 } = select(store_store);
9798 const {
9799 getPostType
9800 } = select(external_wp_coreData_namespaceObject.store);
9801 return {
9802 post: getCurrentPost(),
9803 postType: getPostType(getEditedPostAttribute('type')),
9804 isScheduled: isCurrentPostScheduled()
9805 };
9806 })(PostPublishPanelPostpublish));
9807
9808 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/index.js
9809
9810
9811
9812 /**
9813 * External dependencies
9814 */
9815
9816 /**
9817 * WordPress dependencies
9818 */
9819
9820
9821
9822
9823
9824
9825
9826
9827 /**
9828 * Internal dependencies
9829 */
9830
9831
9832
9833
9834
9835 class PostPublishPanel extends external_wp_element_namespaceObject.Component {
9836 constructor() {
9837 super(...arguments);
9838 this.onSubmit = this.onSubmit.bind(this);
9839 }
9840
9841 componentDidUpdate(prevProps) {
9842 // Automatically collapse the publish sidebar when a post
9843 // is published and the user makes an edit.
9844 if (prevProps.isPublished && !this.props.isSaving && this.props.isDirty) {
9845 this.props.onClose();
9846 }
9847 }
9848
9849 onSubmit() {
9850 const {
9851 onClose,
9852 hasPublishAction,
9853 isPostTypeViewable
9854 } = this.props;
9855
9856 if (!hasPublishAction || !isPostTypeViewable) {
9857 onClose();
9858 }
9859 }
9860
9861 render() {
9862 const {
9863 forceIsDirty,
9864 forceIsSaving,
9865 isBeingScheduled,
9866 isPublished,
9867 isPublishSidebarEnabled,
9868 isScheduled,
9869 isSaving,
9870 isSavingNonPostEntityChanges,
9871 onClose,
9872 onTogglePublishSidebar,
9873 PostPublishExtension,
9874 PrePublishExtension,
9875 ...additionalProps
9876 } = this.props;
9877 const propsForPanel = (0,external_lodash_namespaceObject.omit)(additionalProps, ['hasPublishAction', 'isDirty', 'isPostTypeViewable']);
9878 const isPublishedOrScheduled = isPublished || isScheduled && isBeingScheduled;
9879 const isPrePublish = !isPublishedOrScheduled && !isSaving;
9880 const isPostPublish = isPublishedOrScheduled && !isSaving;
9881 return (0,external_wp_element_namespaceObject.createElement)("div", _extends({
9882 className: "editor-post-publish-panel"
9883 }, propsForPanel), (0,external_wp_element_namespaceObject.createElement)("div", {
9884 className: "editor-post-publish-panel__header"
9885 }, isPostPublish ? (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9886 onClick: onClose,
9887 icon: close_small,
9888 label: (0,external_wp_i18n_namespaceObject.__)('Close panel')
9889 }) : (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
9890 className: "editor-post-publish-panel__header-publish-button"
9891 }, (0,external_wp_element_namespaceObject.createElement)(post_publish_button, {
9892 focusOnMount: true,
9893 onSubmit: this.onSubmit,
9894 forceIsDirty: forceIsDirty,
9895 forceIsSaving: forceIsSaving
9896 })), (0,external_wp_element_namespaceObject.createElement)("div", {
9897 className: "editor-post-publish-panel__header-cancel-button"
9898 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
9899 disabled: isSavingNonPostEntityChanges,
9900 onClick: onClose,
9901 variant: "secondary"
9902 }, (0,external_wp_i18n_namespaceObject.__)('Cancel'))))), (0,external_wp_element_namespaceObject.createElement)("div", {
9903 className: "editor-post-publish-panel__content"
9904 }, isPrePublish && (0,external_wp_element_namespaceObject.createElement)(prepublish, null, PrePublishExtension && (0,external_wp_element_namespaceObject.createElement)(PrePublishExtension, null)), isPostPublish && (0,external_wp_element_namespaceObject.createElement)(postpublish, {
9905 focusOnMount: true
9906 }, PostPublishExtension && (0,external_wp_element_namespaceObject.createElement)(PostPublishExtension, null)), isSaving && (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Spinner, null)), (0,external_wp_element_namespaceObject.createElement)("div", {
9907 className: "editor-post-publish-panel__footer"
9908 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
9909 label: (0,external_wp_i18n_namespaceObject.__)('Always show pre-publish checks.'),
9910 checked: isPublishSidebarEnabled,
9911 onChange: onTogglePublishSidebar
9912 })));
9913 }
9914
9915 }
9916 /* harmony default export */ const post_publish_panel = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
9917 const {
9918 getPostType
9919 } = select(external_wp_coreData_namespaceObject.store);
9920 const {
9921 getCurrentPost,
9922 getEditedPostAttribute,
9923 isCurrentPostPublished,
9924 isCurrentPostScheduled,
9925 isEditedPostBeingScheduled,
9926 isEditedPostDirty,
9927 isSavingPost,
9928 isSavingNonPostEntityChanges
9929 } = select(store_store);
9930 const {
9931 isPublishSidebarEnabled
9932 } = select(store_store);
9933 const postType = getPostType(getEditedPostAttribute('type'));
9934 return {
9935 hasPublishAction: (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
9936 isPostTypeViewable: (0,external_lodash_namespaceObject.get)(postType, ['viewable'], false),
9937 isBeingScheduled: isEditedPostBeingScheduled(),
9938 isDirty: isEditedPostDirty(),
9939 isPublished: isCurrentPostPublished(),
9940 isPublishSidebarEnabled: isPublishSidebarEnabled(),
9941 isSaving: isSavingPost(),
9942 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges(),
9943 isScheduled: isCurrentPostScheduled()
9944 };
9945 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, _ref) => {
9946 let {
9947 isPublishSidebarEnabled
9948 } = _ref;
9949 const {
9950 disablePublishSidebar,
9951 enablePublishSidebar
9952 } = dispatch(store_store);
9953 return {
9954 onTogglePublishSidebar: () => {
9955 if (isPublishSidebarEnabled) {
9956 disablePublishSidebar();
9957 } else {
9958 enablePublishSidebar();
9959 }
9960 }
9961 };
9962 }), external_wp_components_namespaceObject.withFocusReturn, external_wp_components_namespaceObject.withConstrainedTabbing])(PostPublishPanel));
9963
9964 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/cloud-upload.js
9965
9966
9967 /**
9968 * WordPress dependencies
9969 */
9970
9971 const cloudUpload = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
9972 xmlns: "http://www.w3.org/2000/svg",
9973 viewBox: "0 0 24 24"
9974 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
9975 d: "M17.3 10.1c0-2.5-2.1-4.4-4.8-4.4-2.2 0-4.1 1.4-4.6 3.3h-.2C5.7 9 4 10.7 4 12.8c0 2.1 1.7 3.8 3.7 3.8h9c1.8 0 3.2-1.5 3.2-3.3.1-1.6-1.1-2.9-2.6-3.2zm-.5 5.1h-4v-2.4L14 14l1-1-3-3-3 3 1 1 1.2-1.2v2.4H7.7c-1.2 0-2.2-1.1-2.2-2.3s1-2.4 2.2-2.4H9l.3-1.1c.4-1.3 1.7-2.2 3.2-2.2 1.8 0 3.3 1.3 3.3 2.9v1.3l1.3.2c.8.1 1.4.9 1.4 1.8 0 1-.8 1.8-1.7 1.8z"
9976 }));
9977 /* harmony default export */ const cloud_upload = (cloudUpload);
9978
9979 ;// CONCATENATED MODULE: ./packages/icons/build-module/icon/index.js
9980 /**
9981 * WordPress dependencies
9982 */
9983
9984 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
9985
9986 /**
9987 * Return an SVG icon.
9988 *
9989 * @param {IconProps} props icon is the SVG component to render
9990 * size is a number specifiying the icon size in pixels
9991 * Other props will be passed to wrapped SVG component
9992 *
9993 * @return {JSX.Element} Icon component
9994 */
9995
9996 function Icon(_ref) {
9997 let {
9998 icon,
9999 size = 24,
10000 ...props
10001 } = _ref;
10002 return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
10003 width: size,
10004 height: size,
10005 ...props
10006 });
10007 }
10008
10009 /* harmony default export */ const icon = (Icon);
10010
10011 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/check.js
10012
10013
10014 /**
10015 * WordPress dependencies
10016 */
10017
10018 const check_check = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
10019 xmlns: "http://www.w3.org/2000/svg",
10020 viewBox: "0 0 24 24"
10021 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
10022 d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
10023 }));
10024 /* harmony default export */ const library_check = (check_check);
10025
10026 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/cloud.js
10027
10028
10029 /**
10030 * WordPress dependencies
10031 */
10032
10033 const cloud = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
10034 xmlns: "http://www.w3.org/2000/svg",
10035 viewBox: "0 0 24 24"
10036 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
10037 d: "M17.3 10.1c0-2.5-2.1-4.4-4.8-4.4-2.2 0-4.1 1.4-4.6 3.3h-.2C5.7 9 4 10.7 4 12.8c0 2.1 1.7 3.8 3.7 3.8h9c1.8 0 3.2-1.5 3.2-3.3.1-1.6-1.1-2.9-2.6-3.2zm-.5 5.1h-9c-1.2 0-2.2-1.1-2.2-2.3s1-2.4 2.2-2.4h1.3l.3-1.1c.4-1.3 1.7-2.2 3.2-2.2 1.8 0 3.3 1.3 3.3 2.9v1.3l1.3.2c.8.1 1.4.9 1.4 1.8-.1 1-.9 1.8-1.8 1.8z"
10038 }));
10039 /* harmony default export */ const library_cloud = (cloud);
10040
10041 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-switch-to-draft-button/index.js
10042
10043
10044 /**
10045 * WordPress dependencies
10046 */
10047
10048
10049
10050
10051
10052 /**
10053 * Internal dependencies
10054 */
10055
10056
10057
10058 function PostSwitchToDraftButton(_ref) {
10059 let {
10060 isSaving,
10061 isPublished,
10062 isScheduled,
10063 onClick
10064 } = _ref;
10065 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<');
10066 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
10067
10068 if (!isPublished && !isScheduled) {
10069 return null;
10070 }
10071
10072 let alertMessage;
10073
10074 if (isPublished) {
10075 alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unpublish this post?');
10076 } else if (isScheduled) {
10077 alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unschedule this post?');
10078 }
10079
10080 const handleConfirm = () => {
10081 setShowConfirmDialog(false);
10082 onClick();
10083 };
10084
10085 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
10086 className: "editor-post-switch-to-draft",
10087 onClick: () => {
10088 setShowConfirmDialog(true);
10089 },
10090 disabled: isSaving,
10091 variant: "tertiary"
10092 }, isMobileViewport ? (0,external_wp_i18n_namespaceObject.__)('Draft') : (0,external_wp_i18n_namespaceObject.__)('Switch to draft')), (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
10093 isOpen: showConfirmDialog,
10094 onConfirm: handleConfirm,
10095 onCancel: () => setShowConfirmDialog(false)
10096 }, alertMessage));
10097 }
10098
10099 /* harmony default export */ const post_switch_to_draft_button = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
10100 const {
10101 isSavingPost,
10102 isCurrentPostPublished,
10103 isCurrentPostScheduled
10104 } = select(store_store);
10105 return {
10106 isSaving: isSavingPost(),
10107 isPublished: isCurrentPostPublished(),
10108 isScheduled: isCurrentPostScheduled()
10109 };
10110 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
10111 const {
10112 editPost,
10113 savePost
10114 } = dispatch(store_store);
10115 return {
10116 onClick: () => {
10117 editPost({
10118 status: 'draft'
10119 });
10120 savePost();
10121 }
10122 };
10123 })])(PostSwitchToDraftButton));
10124
10125 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-saved-state/index.js
10126
10127
10128 /**
10129 * External dependencies
10130 */
10131
10132 /**
10133 * WordPress dependencies
10134 */
10135
10136
10137
10138
10139
10140
10141
10142
10143 /**
10144 * Internal dependencies
10145 */
10146
10147
10148
10149 /**
10150 * Component showing whether the post is saved or not and providing save
10151 * buttons.
10152 *
10153 * @param {Object} props Component props.
10154 * @param {?boolean} props.forceIsDirty Whether to force the post to be marked
10155 * as dirty.
10156 * @param {?boolean} props.forceIsSaving Whether to force the post to be marked
10157 * as being saved.
10158 * @param {?boolean} props.showIconLabels Whether interface buttons show labels instead of icons
10159 * @return {import('@wordpress/element').WPComponent} The component.
10160 */
10161
10162 function PostSavedState(_ref) {
10163 let {
10164 forceIsDirty,
10165 forceIsSaving,
10166 showIconLabels = false
10167 } = _ref;
10168 const [forceSavedMessage, setForceSavedMessage] = (0,external_wp_element_namespaceObject.useState)(false);
10169 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small');
10170 const {
10171 isAutosaving,
10172 isDirty,
10173 isNew,
10174 isPending,
10175 isPublished,
10176 isSaveable,
10177 isSaving,
10178 isScheduled,
10179 hasPublishAction
10180 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10181 var _getCurrentPost$_link, _getCurrentPost, _getCurrentPost$_link2;
10182
10183 const {
10184 isEditedPostNew,
10185 isCurrentPostPublished,
10186 isCurrentPostScheduled,
10187 isEditedPostDirty,
10188 isSavingPost,
10189 isEditedPostSaveable,
10190 getCurrentPost,
10191 isAutosavingPost,
10192 getEditedPostAttribute
10193 } = select(store_store);
10194 return {
10195 isAutosaving: isAutosavingPost(),
10196 isDirty: forceIsDirty || isEditedPostDirty(),
10197 isNew: isEditedPostNew(),
10198 isPending: 'pending' === getEditedPostAttribute('status'),
10199 isPublished: isCurrentPostPublished(),
10200 isSaving: forceIsSaving || isSavingPost(),
10201 isSaveable: isEditedPostSaveable(),
10202 isScheduled: isCurrentPostScheduled(),
10203 hasPublishAction: (_getCurrentPost$_link = (_getCurrentPost = getCurrentPost()) === null || _getCurrentPost === void 0 ? void 0 : (_getCurrentPost$_link2 = _getCurrentPost._links) === null || _getCurrentPost$_link2 === void 0 ? void 0 : _getCurrentPost$_link2['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false
10204 };
10205 }, [forceIsDirty, forceIsSaving]);
10206 const {
10207 savePost
10208 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10209 const wasSaving = (0,external_wp_compose_namespaceObject.usePrevious)(isSaving);
10210 (0,external_wp_element_namespaceObject.useEffect)(() => {
10211 let timeoutId;
10212
10213 if (wasSaving && !isSaving) {
10214 setForceSavedMessage(true);
10215 timeoutId = setTimeout(() => {
10216 setForceSavedMessage(false);
10217 }, 1000);
10218 }
10219
10220 return () => clearTimeout(timeoutId);
10221 }, [isSaving]); // Once the post has been submitted for review this button
10222 // is not needed for the contributor role.
10223
10224 if (!hasPublishAction && isPending) {
10225 return null;
10226 }
10227
10228 if (isPublished || isScheduled) {
10229 return (0,external_wp_element_namespaceObject.createElement)(post_switch_to_draft_button, null);
10230 }
10231 /* translators: button label text should, if possible, be under 16 characters. */
10232
10233
10234 const label = isPending ? (0,external_wp_i18n_namespaceObject.__)('Save as pending') : (0,external_wp_i18n_namespaceObject.__)('Save draft');
10235 /* translators: button label text should, if possible, be under 16 characters. */
10236
10237 const shortLabel = (0,external_wp_i18n_namespaceObject.__)('Save');
10238
10239 const isSaved = forceSavedMessage || !isNew && !isDirty;
10240 const isSavedState = isSaving || isSaved;
10241 const isDisabled = isSaving || isSaved || !isSaveable;
10242 let text;
10243
10244 if (isSaving) {
10245 text = isAutosaving ? (0,external_wp_i18n_namespaceObject.__)('Autosaving') : (0,external_wp_i18n_namespaceObject.__)('Saving');
10246 } else if (isSaved) {
10247 text = (0,external_wp_i18n_namespaceObject.__)('Saved');
10248 } else if (isLargeViewport) {
10249 text = label;
10250 } else if (showIconLabels) {
10251 text = shortLabel;
10252 } // Use common Button instance for all saved states so that focus is not
10253 // lost.
10254
10255
10256 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
10257 className: isSaveable || isSaving ? classnames_default()({
10258 'editor-post-save-draft': !isSavedState,
10259 'editor-post-saved-state': isSavedState,
10260 'is-saving': isSaving,
10261 'is-autosaving': isAutosaving,
10262 'is-saved': isSaved,
10263 [(0,external_wp_components_namespaceObject.__unstableGetAnimateClassName)({
10264 type: 'loading'
10265 })]: isSaving
10266 }) : undefined,
10267 onClick: isDisabled ? undefined : () => savePost(),
10268 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('s'),
10269 variant: isLargeViewport ? 'tertiary' : undefined,
10270 icon: isLargeViewport ? undefined : cloud_upload,
10271 label: showIconLabels ? undefined : label,
10272 "aria-disabled": isDisabled
10273 }, isSavedState && (0,external_wp_element_namespaceObject.createElement)(icon, {
10274 icon: isSaved ? library_check : library_cloud
10275 }), text);
10276 }
10277
10278 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-schedule/check.js
10279 /**
10280 * External dependencies
10281 */
10282
10283 /**
10284 * WordPress dependencies
10285 */
10286
10287
10288
10289 /**
10290 * Internal dependencies
10291 */
10292
10293
10294 function PostScheduleCheck(_ref) {
10295 let {
10296 hasPublishAction,
10297 children
10298 } = _ref;
10299
10300 if (!hasPublishAction) {
10301 return null;
10302 }
10303
10304 return children;
10305 }
10306 /* harmony default export */ const post_schedule_check = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
10307 const {
10308 getCurrentPost,
10309 getCurrentPostType
10310 } = select(store_store);
10311 return {
10312 hasPublishAction: (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
10313 postType: getCurrentPostType()
10314 };
10315 })])(PostScheduleCheck));
10316
10317 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-slug/check.js
10318
10319
10320 /**
10321 * Internal dependencies
10322 */
10323
10324 function PostSlugCheck(_ref) {
10325 let {
10326 children
10327 } = _ref;
10328 return (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, {
10329 supportKeys: "slug"
10330 }, children);
10331 }
10332
10333 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-slug/index.js
10334
10335
10336 /**
10337 * WordPress dependencies
10338 */
10339
10340
10341
10342
10343
10344 /**
10345 * Internal dependencies
10346 */
10347
10348
10349
10350 class PostSlug extends external_wp_element_namespaceObject.Component {
10351 constructor(_ref) {
10352 let {
10353 postSlug,
10354 postTitle,
10355 postID
10356 } = _ref;
10357 super(...arguments);
10358 this.state = {
10359 editedSlug: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(postSlug) || (0,external_wp_url_namespaceObject.cleanForSlug)(postTitle) || postID
10360 };
10361 this.setSlug = this.setSlug.bind(this);
10362 }
10363
10364 setSlug(event) {
10365 const {
10366 postSlug,
10367 onUpdateSlug
10368 } = this.props;
10369 const {
10370 value
10371 } = event.target;
10372 const editedSlug = (0,external_wp_url_namespaceObject.cleanForSlug)(value);
10373
10374 if (editedSlug === postSlug) {
10375 return;
10376 }
10377
10378 onUpdateSlug(editedSlug);
10379 }
10380
10381 render() {
10382 const {
10383 instanceId
10384 } = this.props;
10385 const {
10386 editedSlug
10387 } = this.state;
10388 const inputId = 'editor-post-slug-' + instanceId;
10389 return (0,external_wp_element_namespaceObject.createElement)(PostSlugCheck, null, (0,external_wp_element_namespaceObject.createElement)("label", {
10390 htmlFor: inputId
10391 }, (0,external_wp_i18n_namespaceObject.__)('Slug')), (0,external_wp_element_namespaceObject.createElement)("input", {
10392 autoComplete: "off",
10393 spellCheck: "false",
10394 type: "text",
10395 id: inputId,
10396 value: editedSlug,
10397 onChange: event => this.setState({
10398 editedSlug: event.target.value
10399 }),
10400 onBlur: this.setSlug,
10401 className: "editor-post-slug__input"
10402 }));
10403 }
10404
10405 }
10406 /* harmony default export */ const post_slug = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
10407 const {
10408 getCurrentPost,
10409 getEditedPostAttribute
10410 } = select(store_store);
10411 const {
10412 id
10413 } = getCurrentPost();
10414 return {
10415 postSlug: getEditedPostAttribute('slug'),
10416 postTitle: getEditedPostAttribute('title'),
10417 postID: id
10418 };
10419 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
10420 const {
10421 editPost
10422 } = dispatch(store_store);
10423 return {
10424 onUpdateSlug(slug) {
10425 editPost({
10426 slug
10427 });
10428 }
10429
10430 };
10431 }), external_wp_compose_namespaceObject.withInstanceId])(PostSlug));
10432
10433 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-sticky/check.js
10434 /**
10435 * External dependencies
10436 */
10437
10438 /**
10439 * WordPress dependencies
10440 */
10441
10442
10443
10444 /**
10445 * Internal dependencies
10446 */
10447
10448
10449 function PostStickyCheck(_ref) {
10450 let {
10451 hasStickyAction,
10452 postType,
10453 children
10454 } = _ref;
10455
10456 if (postType !== 'post' || !hasStickyAction) {
10457 return null;
10458 }
10459
10460 return children;
10461 }
10462 /* harmony default export */ const post_sticky_check = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
10463 const post = select(store_store).getCurrentPost();
10464 return {
10465 hasStickyAction: (0,external_lodash_namespaceObject.get)(post, ['_links', 'wp:action-sticky'], false),
10466 postType: select(store_store).getCurrentPostType()
10467 };
10468 })])(PostStickyCheck));
10469
10470 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-sticky/index.js
10471
10472
10473 /**
10474 * WordPress dependencies
10475 */
10476
10477
10478
10479
10480 /**
10481 * Internal dependencies
10482 */
10483
10484
10485
10486 function PostSticky(_ref) {
10487 let {
10488 onUpdateSticky,
10489 postSticky = false
10490 } = _ref;
10491 return (0,external_wp_element_namespaceObject.createElement)(post_sticky_check, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.CheckboxControl, {
10492 label: (0,external_wp_i18n_namespaceObject.__)('Stick to the top of the blog'),
10493 checked: postSticky,
10494 onChange: () => onUpdateSticky(!postSticky)
10495 }));
10496 }
10497 /* harmony default export */ const post_sticky = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
10498 return {
10499 postSticky: select(store_store).getEditedPostAttribute('sticky')
10500 };
10501 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
10502 return {
10503 onUpdateSticky(postSticky) {
10504 dispatch(store_store).editPost({
10505 sticky: postSticky
10506 });
10507 }
10508
10509 };
10510 })])(PostSticky));
10511
10512 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/index.js
10513
10514
10515 /**
10516 * External dependencies
10517 */
10518
10519 /**
10520 * WordPress dependencies
10521 */
10522
10523
10524
10525
10526
10527 /**
10528 * Internal dependencies
10529 */
10530
10531
10532
10533
10534 function PostTaxonomies(_ref) {
10535 let {
10536 postType,
10537 taxonomies,
10538 taxonomyWrapper = external_lodash_namespaceObject.identity
10539 } = _ref;
10540 const availableTaxonomies = (0,external_lodash_namespaceObject.filter)(taxonomies, taxonomy => (0,external_lodash_namespaceObject.includes)(taxonomy.types, postType));
10541 const visibleTaxonomies = (0,external_lodash_namespaceObject.filter)(availableTaxonomies, // In some circumstances .visibility can end up as undefined so optional chaining operator required.
10542 // https://github.com/WordPress/gutenberg/issues/40326
10543 taxonomy => {
10544 var _taxonomy$visibility;
10545
10546 return (_taxonomy$visibility = taxonomy.visibility) === null || _taxonomy$visibility === void 0 ? void 0 : _taxonomy$visibility.show_ui;
10547 });
10548 return visibleTaxonomies.map(taxonomy => {
10549 const TaxonomyComponent = taxonomy.hierarchical ? hierarchical_term_selector : flat_term_selector;
10550 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, {
10551 key: `taxonomy-${taxonomy.slug}`
10552 }, taxonomyWrapper((0,external_wp_element_namespaceObject.createElement)(TaxonomyComponent, {
10553 slug: taxonomy.slug
10554 }), taxonomy));
10555 });
10556 }
10557 /* harmony default export */ const post_taxonomies = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
10558 return {
10559 postType: select(store_store).getCurrentPostType(),
10560 taxonomies: select(external_wp_coreData_namespaceObject.store).getTaxonomies({
10561 per_page: -1
10562 })
10563 };
10564 })])(PostTaxonomies));
10565
10566 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/check.js
10567 /**
10568 * External dependencies
10569 */
10570
10571 /**
10572 * WordPress dependencies
10573 */
10574
10575
10576
10577
10578 /**
10579 * Internal dependencies
10580 */
10581
10582
10583 function PostTaxonomiesCheck(_ref) {
10584 let {
10585 postType,
10586 taxonomies,
10587 children
10588 } = _ref;
10589 const hasTaxonomies = (0,external_lodash_namespaceObject.some)(taxonomies, taxonomy => (0,external_lodash_namespaceObject.includes)(taxonomy.types, postType));
10590
10591 if (!hasTaxonomies) {
10592 return null;
10593 }
10594
10595 return children;
10596 }
10597 /* harmony default export */ const post_taxonomies_check = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
10598 return {
10599 postType: select(store_store).getCurrentPostType(),
10600 taxonomies: select(external_wp_coreData_namespaceObject.store).getTaxonomies({
10601 per_page: -1
10602 })
10603 };
10604 })])(PostTaxonomiesCheck));
10605
10606 // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
10607 var lib = __webpack_require__(773);
10608 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-text-editor/index.js
10609
10610
10611 /**
10612 * External dependencies
10613 */
10614
10615 /**
10616 * WordPress dependencies
10617 */
10618
10619
10620
10621
10622
10623
10624
10625 /**
10626 * Internal dependencies
10627 */
10628
10629
10630 function PostTextEditor() {
10631 const postContent = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostContent(), []);
10632 const {
10633 editPost,
10634 resetEditorBlocks
10635 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10636 const [value, setValue] = (0,external_wp_element_namespaceObject.useState)(postContent);
10637 const [isDirty, setIsDirty] = (0,external_wp_element_namespaceObject.useState)(false);
10638 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostTextEditor);
10639 const valueRef = (0,external_wp_element_namespaceObject.useRef)();
10640
10641 if (!isDirty && value !== postContent) {
10642 setValue(postContent);
10643 }
10644 /**
10645 * Handles a textarea change event to notify the onChange prop callback and
10646 * reflect the new value in the component's own state. This marks the start
10647 * of the user's edits, if not already changed, preventing future props
10648 * changes to value from replacing the rendered value. This is expected to
10649 * be followed by a reset to dirty state via `stopEditing`.
10650 *
10651 * @see stopEditing
10652 *
10653 * @param {Event} event Change event.
10654 */
10655
10656
10657 const onChange = event => {
10658 const newValue = event.target.value;
10659 editPost({
10660 content: newValue
10661 });
10662 setValue(newValue);
10663 setIsDirty(true);
10664 valueRef.current = newValue;
10665 };
10666 /**
10667 * Function called when the user has completed their edits, responsible for
10668 * ensuring that changes, if made, are surfaced to the onPersist prop
10669 * callback and resetting dirty state.
10670 */
10671
10672
10673 const stopEditing = () => {
10674 if (isDirty) {
10675 const blocks = (0,external_wp_blocks_namespaceObject.parse)(value);
10676 resetEditorBlocks(blocks);
10677 setIsDirty(false);
10678 }
10679 }; // Ensure changes aren't lost when component unmounts.
10680
10681
10682 (0,external_wp_element_namespaceObject.useEffect)(() => {
10683 return () => {
10684 if (valueRef.current) {
10685 const blocks = (0,external_wp_blocks_namespaceObject.parse)(valueRef.current);
10686 resetEditorBlocks(blocks);
10687 }
10688 };
10689 }, []);
10690 return (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.VisuallyHidden, {
10691 as: "label",
10692 htmlFor: `post-content-${instanceId}`
10693 }, (0,external_wp_i18n_namespaceObject.__)('Type text or HTML')), (0,external_wp_element_namespaceObject.createElement)(lib/* default */.Z, {
10694 autoComplete: "off",
10695 dir: "auto",
10696 value: value,
10697 onChange: onChange,
10698 onBlur: stopEditing,
10699 className: "editor-post-text-editor",
10700 id: `post-content-${instanceId}`,
10701 placeholder: (0,external_wp_i18n_namespaceObject.__)('Start writing with text or HTML')
10702 }));
10703 }
10704
10705 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/index.js
10706
10707
10708 /**
10709 * External dependencies
10710 */
10711
10712 /**
10713 * WordPress dependencies
10714 */
10715
10716
10717
10718
10719
10720
10721
10722
10723
10724
10725 /**
10726 * Internal dependencies
10727 */
10728
10729
10730
10731 /**
10732 * Constants
10733 */
10734
10735 const REGEXP_NEWLINES = /[\r\n]+/g;
10736
10737 function PostTitle(_, forwardedRef) {
10738 const ref = (0,external_wp_element_namespaceObject.useRef)();
10739 const [isSelected, setIsSelected] = (0,external_wp_element_namespaceObject.useState)(false);
10740 const {
10741 editPost
10742 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10743 const {
10744 insertDefaultBlock,
10745 clearSelectedBlock,
10746 insertBlocks
10747 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
10748 const {
10749 isCleanNewPost,
10750 title,
10751 placeholder,
10752 isFocusMode,
10753 hasFixedToolbar
10754 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10755 const {
10756 getEditedPostAttribute,
10757 isCleanNewPost: _isCleanNewPost
10758 } = select(store_store);
10759 const {
10760 getSettings
10761 } = select(external_wp_blockEditor_namespaceObject.store);
10762 const {
10763 titlePlaceholder,
10764 focusMode,
10765 hasFixedToolbar: _hasFixedToolbar
10766 } = getSettings();
10767 return {
10768 isCleanNewPost: _isCleanNewPost(),
10769 title: getEditedPostAttribute('title'),
10770 placeholder: titlePlaceholder,
10771 isFocusMode: focusMode,
10772 hasFixedToolbar: _hasFixedToolbar
10773 };
10774 }, []);
10775 (0,external_wp_element_namespaceObject.useImperativeHandle)(forwardedRef, () => ({
10776 focus: () => {
10777 var _ref$current;
10778
10779 ref === null || ref === void 0 ? void 0 : (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.focus();
10780 }
10781 }));
10782 (0,external_wp_element_namespaceObject.useEffect)(() => {
10783 if (!ref.current) {
10784 return;
10785 }
10786
10787 const {
10788 ownerDocument
10789 } = ref.current;
10790 const {
10791 activeElement,
10792 body
10793 } = ownerDocument; // Only autofocus the title when the post is entirely empty. This should
10794 // only happen for a new post, which means we focus the title on new
10795 // post so the author can start typing right away, without needing to
10796 // click anything.
10797
10798 if (isCleanNewPost && (!activeElement || body === activeElement)) {
10799 ref.current.focus();
10800 }
10801 }, [isCleanNewPost]);
10802
10803 function onEnterPress() {
10804 insertDefaultBlock(undefined, undefined, 0);
10805 }
10806
10807 function onInsertBlockAfter(blocks) {
10808 insertBlocks(blocks, 0);
10809 }
10810
10811 function onUpdate(newTitle) {
10812 editPost({
10813 title: newTitle
10814 });
10815 }
10816
10817 const [selection, setSelection] = (0,external_wp_element_namespaceObject.useState)({});
10818
10819 function onSelect() {
10820 setIsSelected(true);
10821 clearSelectedBlock();
10822 }
10823
10824 function onUnselect() {
10825 setIsSelected(false);
10826 setSelection({});
10827 }
10828
10829 function onChange(value) {
10830 onUpdate(value.replace(REGEXP_NEWLINES, ' '));
10831 }
10832
10833 function onKeyDown(event) {
10834 if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) {
10835 event.preventDefault();
10836 onEnterPress();
10837 }
10838 }
10839
10840 function onPaste(event) {
10841 const clipboardData = event.clipboardData;
10842 let plainText = '';
10843 let html = ''; // IE11 only supports `Text` as an argument for `getData` and will
10844 // otherwise throw an invalid argument error, so we try the standard
10845 // arguments first, then fallback to `Text` if they fail.
10846
10847 try {
10848 plainText = clipboardData.getData('text/plain');
10849 html = clipboardData.getData('text/html');
10850 } catch (error1) {
10851 try {
10852 html = clipboardData.getData('Text');
10853 } catch (error2) {
10854 // Some browsers like UC Browser paste plain text by default and
10855 // don't support clipboardData at all, so allow default
10856 // behaviour.
10857 return;
10858 }
10859 } // Allows us to ask for this information when we get a report.
10860
10861
10862 window.console.log('Received HTML:\n\n', html);
10863 window.console.log('Received plain text:\n\n', plainText);
10864 const content = (0,external_wp_blocks_namespaceObject.pasteHandler)({
10865 HTML: html,
10866 plainText
10867 });
10868
10869 if (typeof content !== 'string' && content.length) {
10870 event.preventDefault();
10871 const [firstBlock] = content;
10872
10873 if (!title && (firstBlock.name === 'core/heading' || firstBlock.name === 'core/paragraph')) {
10874 onUpdate(firstBlock.attributes.content);
10875 onInsertBlockAfter(content.slice(1));
10876 } else {
10877 onInsertBlockAfter(content);
10878 }
10879 }
10880 } // The wp-block className is important for editor styles.
10881 // This same block is used in both the visual and the code editor.
10882
10883
10884 const className = classnames_default()('wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text', {
10885 'is-selected': isSelected,
10886 'is-focus-mode': isFocusMode,
10887 'has-fixed-toolbar': hasFixedToolbar
10888 });
10889
10890 const decodedPlaceholder = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Add title');
10891
10892 const {
10893 ref: richTextRef
10894 } = (0,external_wp_richText_namespaceObject.__unstableUseRichText)({
10895 value: title,
10896 onChange,
10897 placeholder: decodedPlaceholder,
10898 selectionStart: selection.start,
10899 selectionEnd: selection.end,
10900
10901 onSelectionChange(newStart, newEnd) {
10902 setSelection(sel => {
10903 const {
10904 start,
10905 end
10906 } = sel;
10907
10908 if (start === newStart && end === newEnd) {
10909 return sel;
10910 }
10911
10912 return {
10913 start: newStart,
10914 end: newEnd
10915 };
10916 });
10917 },
10918
10919 __unstableDisableFormats: true,
10920 preserveWhiteSpace: true
10921 });
10922 /* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
10923
10924 return (0,external_wp_element_namespaceObject.createElement)(post_type_support_check, {
10925 supportKeys: "title"
10926 }, (0,external_wp_element_namespaceObject.createElement)("h1", {
10927 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([richTextRef, ref]),
10928 contentEditable: true,
10929 className: className,
10930 "aria-label": decodedPlaceholder,
10931 role: "textbox",
10932 "aria-multiline": "true",
10933 onFocus: onSelect,
10934 onBlur: onUnselect,
10935 onKeyDown: onKeyDown,
10936 onKeyPress: onUnselect,
10937 onPaste: onPaste
10938 }));
10939 /* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
10940 }
10941
10942 /* harmony default export */ const post_title = ((0,external_wp_element_namespaceObject.forwardRef)(PostTitle));
10943
10944 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-trash/index.js
10945
10946
10947 /**
10948 * WordPress dependencies
10949 */
10950
10951
10952
10953 /**
10954 * Internal dependencies
10955 */
10956
10957
10958 function PostTrash() {
10959 const {
10960 isNew,
10961 postId
10962 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10963 const store = select(store_store);
10964 return {
10965 isNew: store.isEditedPostNew(),
10966 postId: store.getCurrentPostId()
10967 };
10968 }, []);
10969 const {
10970 trashPost
10971 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10972
10973 if (isNew || !postId) {
10974 return null;
10975 }
10976
10977 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, {
10978 className: "editor-post-trash",
10979 isDestructive: true,
10980 variant: "secondary",
10981 onClick: () => trashPost()
10982 }, (0,external_wp_i18n_namespaceObject.__)('Move to trash'));
10983 }
10984
10985 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-trash/check.js
10986 /**
10987 * WordPress dependencies
10988 */
10989
10990
10991 /**
10992 * Internal dependencies
10993 */
10994
10995
10996
10997 function PostTrashCheck(_ref) {
10998 let {
10999 isNew,
11000 postId,
11001 canUserDelete,
11002 children
11003 } = _ref;
11004
11005 if (isNew || !postId || !canUserDelete) {
11006 return null;
11007 }
11008
11009 return children;
11010 }
11011
11012 /* harmony default export */ const post_trash_check = ((0,external_wp_data_namespaceObject.withSelect)(select => {
11013 const {
11014 isEditedPostNew,
11015 getCurrentPostId,
11016 getCurrentPostType
11017 } = select(store_store);
11018 const {
11019 getPostType,
11020 canUser
11021 } = select(external_wp_coreData_namespaceObject.store);
11022 const postId = getCurrentPostId();
11023 const postType = getPostType(getCurrentPostType());
11024 const resource = (postType === null || postType === void 0 ? void 0 : postType.rest_base) || ''; // eslint-disable-line camelcase
11025
11026 return {
11027 isNew: isEditedPostNew(),
11028 postId,
11029 canUserDelete: postId && resource ? canUser('delete', resource, postId) : false
11030 };
11031 })(PostTrashCheck));
11032
11033 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/check.js
11034 /**
11035 * External dependencies
11036 */
11037
11038 /**
11039 * WordPress dependencies
11040 */
11041
11042
11043
11044 /**
11045 * Internal dependencies
11046 */
11047
11048
11049 function PostVisibilityCheck(_ref) {
11050 let {
11051 hasPublishAction,
11052 render
11053 } = _ref;
11054 const canEdit = hasPublishAction;
11055 return render({
11056 canEdit
11057 });
11058 }
11059 /* harmony default export */ const post_visibility_check = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
11060 const {
11061 getCurrentPost,
11062 getCurrentPostType
11063 } = select(store_store);
11064 return {
11065 hasPublishAction: (0,external_lodash_namespaceObject.get)(getCurrentPost(), ['_links', 'wp:action-publish'], false),
11066 postType: getCurrentPostType()
11067 };
11068 })])(PostVisibilityCheck));
11069
11070 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/info.js
11071
11072
11073 /**
11074 * WordPress dependencies
11075 */
11076
11077 const info = (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.SVG, {
11078 xmlns: "http://www.w3.org/2000/svg",
11079 viewBox: "0 0 24 24"
11080 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_primitives_namespaceObject.Path, {
11081 d: "M12 3.2c-4.8 0-8.8 3.9-8.8 8.8 0 4.8 3.9 8.8 8.8 8.8 4.8 0 8.8-3.9 8.8-8.8 0-4.8-4-8.8-8.8-8.8zm0 16c-4 0-7.2-3.3-7.2-7.2C4.8 8 8 4.8 12 4.8s7.2 3.3 7.2 7.2c0 4-3.2 7.2-7.2 7.2zM11 17h2v-6h-2v6zm0-8h2V7h-2v2z"
11082 }));
11083 /* harmony default export */ const library_info = (info);
11084
11085 ;// CONCATENATED MODULE: external ["wp","wordcount"]
11086 const external_wp_wordcount_namespaceObject = window["wp"]["wordcount"];
11087 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/word-count/index.js
11088
11089
11090 /**
11091 * WordPress dependencies
11092 */
11093
11094
11095
11096 /**
11097 * Internal dependencies
11098 */
11099
11100
11101 function WordCount() {
11102 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
11103 /*
11104 * translators: If your word count is based on single characters (e.g. East Asian characters),
11105 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
11106 * Do not translate into your own language.
11107 */
11108
11109 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
11110
11111 return (0,external_wp_element_namespaceObject.createElement)("span", {
11112 className: "word-count"
11113 }, (0,external_wp_wordcount_namespaceObject.count)(content, wordCountType));
11114 }
11115
11116 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/character-count/index.js
11117 /**
11118 * WordPress dependencies
11119 */
11120
11121
11122 /**
11123 * Internal dependencies
11124 */
11125
11126
11127 function CharacterCount() {
11128 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
11129 return (0,external_wp_wordcount_namespaceObject.count)(content, 'characters_including_spaces');
11130 }
11131
11132 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/table-of-contents/panel.js
11133
11134
11135 /**
11136 * WordPress dependencies
11137 */
11138
11139
11140
11141 /**
11142 * Internal dependencies
11143 */
11144
11145
11146
11147
11148
11149 function TableOfContentsPanel(_ref) {
11150 let {
11151 hasOutlineItemsDisabled,
11152 onRequestClose
11153 } = _ref;
11154 const {
11155 headingCount,
11156 paragraphCount,
11157 numberOfBlocks
11158 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11159 const {
11160 getGlobalBlockCount
11161 } = select(external_wp_blockEditor_namespaceObject.store);
11162 return {
11163 headingCount: getGlobalBlockCount('core/heading'),
11164 paragraphCount: getGlobalBlockCount('core/paragraph'),
11165 numberOfBlocks: getGlobalBlockCount()
11166 };
11167 }, []);
11168 return (
11169 /*
11170 * Disable reason: The `list` ARIA role is redundant but
11171 * Safari+VoiceOver won't announce the list otherwise.
11172 */
11173
11174 /* eslint-disable jsx-a11y/no-redundant-roles */
11175 (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("div", {
11176 className: "table-of-contents__wrapper",
11177 role: "note",
11178 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document Statistics'),
11179 tabIndex: "0"
11180 }, (0,external_wp_element_namespaceObject.createElement)("ul", {
11181 role: "list",
11182 className: "table-of-contents__counts"
11183 }, (0,external_wp_element_namespaceObject.createElement)("li", {
11184 className: "table-of-contents__count"
11185 }, (0,external_wp_i18n_namespaceObject.__)('Characters'), (0,external_wp_element_namespaceObject.createElement)("span", {
11186 className: "table-of-contents__number"
11187 }, (0,external_wp_element_namespaceObject.createElement)(CharacterCount, null))), (0,external_wp_element_namespaceObject.createElement)("li", {
11188 className: "table-of-contents__count"
11189 }, (0,external_wp_i18n_namespaceObject.__)('Words'), (0,external_wp_element_namespaceObject.createElement)(WordCount, null)), (0,external_wp_element_namespaceObject.createElement)("li", {
11190 className: "table-of-contents__count"
11191 }, (0,external_wp_i18n_namespaceObject.__)('Headings'), (0,external_wp_element_namespaceObject.createElement)("span", {
11192 className: "table-of-contents__number"
11193 }, headingCount)), (0,external_wp_element_namespaceObject.createElement)("li", {
11194 className: "table-of-contents__count"
11195 }, (0,external_wp_i18n_namespaceObject.__)('Paragraphs'), (0,external_wp_element_namespaceObject.createElement)("span", {
11196 className: "table-of-contents__number"
11197 }, paragraphCount)), (0,external_wp_element_namespaceObject.createElement)("li", {
11198 className: "table-of-contents__count"
11199 }, (0,external_wp_i18n_namespaceObject.__)('Blocks'), (0,external_wp_element_namespaceObject.createElement)("span", {
11200 className: "table-of-contents__number"
11201 }, numberOfBlocks)))), headingCount > 0 && (0,external_wp_element_namespaceObject.createElement)(external_wp_element_namespaceObject.Fragment, null, (0,external_wp_element_namespaceObject.createElement)("hr", null), (0,external_wp_element_namespaceObject.createElement)("h2", {
11202 className: "table-of-contents__title"
11203 }, (0,external_wp_i18n_namespaceObject.__)('Document Outline')), (0,external_wp_element_namespaceObject.createElement)(document_outline, {
11204 onSelect: onRequestClose,
11205 hasOutlineItemsDisabled: hasOutlineItemsDisabled
11206 })))
11207 /* eslint-enable jsx-a11y/no-redundant-roles */
11208
11209 );
11210 }
11211
11212 /* harmony default export */ const panel = (TableOfContentsPanel);
11213
11214 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/table-of-contents/index.js
11215
11216
11217
11218 /**
11219 * WordPress dependencies
11220 */
11221
11222
11223
11224
11225
11226
11227 /**
11228 * Internal dependencies
11229 */
11230
11231
11232
11233 function TableOfContents(_ref, ref) {
11234 let {
11235 hasOutlineItemsDisabled,
11236 repositionDropdown,
11237 ...props
11238 } = _ref;
11239 const hasBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_blockEditor_namespaceObject.store).getBlockCount(), []);
11240 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Dropdown, {
11241 position: repositionDropdown ? 'middle right right' : 'bottom',
11242 className: "table-of-contents",
11243 contentClassName: "table-of-contents__popover",
11244 renderToggle: _ref2 => {
11245 let {
11246 isOpen,
11247 onToggle
11248 } = _ref2;
11249 return (0,external_wp_element_namespaceObject.createElement)(external_wp_components_namespaceObject.Button, _extends({}, props, {
11250 ref: ref,
11251 onClick: hasBlocks ? onToggle : undefined,
11252 icon: library_info,
11253 "aria-expanded": isOpen,
11254 "aria-haspopup": "true"
11255 /* translators: button label text should, if possible, be under 16 characters. */
11256 ,
11257 label: (0,external_wp_i18n_namespaceObject.__)('Details'),
11258 tooltipPosition: "bottom",
11259 "aria-disabled": !hasBlocks
11260 }));
11261 },
11262 renderContent: _ref3 => {
11263 let {
11264 onClose
11265 } = _ref3;
11266 return (0,external_wp_element_namespaceObject.createElement)(panel, {
11267 onRequestClose: onClose,
11268 hasOutlineItemsDisabled: hasOutlineItemsDisabled
11269 });
11270 }
11271 });
11272 }
11273
11274 /* harmony default export */ const table_of_contents = ((0,external_wp_element_namespaceObject.forwardRef)(TableOfContents));
11275
11276 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/unsaved-changes-warning/index.js
11277 /**
11278 * WordPress dependencies
11279 */
11280
11281
11282
11283
11284 /**
11285 * Warns the user if there are unsaved changes before leaving the editor.
11286 * Compatible with Post Editor and Site Editor.
11287 *
11288 * @return {WPComponent} The component.
11289 */
11290
11291 function UnsavedChangesWarning() {
11292 const isDirty = (0,external_wp_data_namespaceObject.useSelect)(select => {
11293 return () => {
11294 const {
11295 __experimentalGetDirtyEntityRecords
11296 } = select(external_wp_coreData_namespaceObject.store);
11297
11298 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
11299
11300 return dirtyEntityRecords.length > 0;
11301 };
11302 }, []);
11303 /**
11304 * Warns the user if there are unsaved changes before leaving the editor.
11305 *
11306 * @param {Event} event `beforeunload` event.
11307 *
11308 * @return {?string} Warning prompt message, if unsaved changes exist.
11309 */
11310
11311 const warnIfUnsavedChanges = event => {
11312 // We need to call the selector directly in the listener to avoid race
11313 // conditions with `BrowserURL` where `componentDidUpdate` gets the
11314 // new value of `isEditedPostDirty` before this component does,
11315 // causing this component to incorrectly think a trashed post is still dirty.
11316 if (isDirty()) {
11317 event.returnValue = (0,external_wp_i18n_namespaceObject.__)('You have unsaved changes. If you proceed, they will be lost.');
11318 return event.returnValue;
11319 }
11320 };
11321
11322 (0,external_wp_element_namespaceObject.useEffect)(() => {
11323 window.addEventListener('beforeunload', warnIfUnsavedChanges);
11324 return () => {
11325 window.removeEventListener('beforeunload', warnIfUnsavedChanges);
11326 };
11327 }, []);
11328 return null;
11329 }
11330
11331 ;// CONCATENATED MODULE: external ["wp","reusableBlocks"]
11332 const external_wp_reusableBlocks_namespaceObject = window["wp"]["reusableBlocks"];
11333 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/with-registry-provider.js
11334
11335
11336 /**
11337 * WordPress dependencies
11338 */
11339
11340
11341
11342
11343 /**
11344 * Internal dependencies
11345 */
11346
11347
11348 const withRegistryProvider = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => (0,external_wp_data_namespaceObject.withRegistry)(props => {
11349 const {
11350 useSubRegistry = true,
11351 registry,
11352 ...additionalProps
11353 } = props;
11354
11355 if (!useSubRegistry) {
11356 return (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, additionalProps);
11357 }
11358
11359 const [subRegistry, setSubRegistry] = (0,external_wp_element_namespaceObject.useState)(null);
11360 (0,external_wp_element_namespaceObject.useEffect)(() => {
11361 const newRegistry = (0,external_wp_data_namespaceObject.createRegistry)({
11362 'core/block-editor': external_wp_blockEditor_namespaceObject.storeConfig
11363 }, registry);
11364 newRegistry.registerStore('core/editor', storeConfig);
11365 setSubRegistry(newRegistry);
11366 }, [registry]);
11367
11368 if (!subRegistry) {
11369 return null;
11370 }
11371
11372 return (0,external_wp_element_namespaceObject.createElement)(external_wp_data_namespaceObject.RegistryProvider, {
11373 value: subRegistry
11374 }, (0,external_wp_element_namespaceObject.createElement)(WrappedComponent, additionalProps));
11375 }), 'withRegistryProvider');
11376 /* harmony default export */ const with_registry_provider = (withRegistryProvider);
11377
11378 ;// CONCATENATED MODULE: external ["wp","mediaUtils"]
11379 const external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"];
11380 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/media-upload/index.js
11381 /**
11382 * WordPress dependencies
11383 */
11384
11385
11386 /**
11387 * Internal dependencies
11388 */
11389
11390
11391
11392 const media_upload_noop = () => {};
11393 /**
11394 * Upload a media file when the file upload button is activated.
11395 * Wrapper around mediaUpload() that injects the current post ID.
11396 *
11397 * @param {Object} $0 Parameters object passed to the function.
11398 * @param {?Object} $0.additionalData Additional data to include in the request.
11399 * @param {string} $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.
11400 * @param {Array} $0.filesList List of files.
11401 * @param {?number} $0.maxUploadFileSize Maximum upload size in bytes allowed for the site.
11402 * @param {Function} $0.onError Function called when an error happens.
11403 * @param {Function} $0.onFileChange Function called each time a file or a temporary representation of the file is available.
11404 */
11405
11406
11407 function mediaUpload(_ref) {
11408 let {
11409 additionalData = {},
11410 allowedTypes,
11411 filesList,
11412 maxUploadFileSize,
11413 onError = media_upload_noop,
11414 onFileChange
11415 } = _ref;
11416 const {
11417 getCurrentPostId,
11418 getEditorSettings
11419 } = (0,external_wp_data_namespaceObject.select)(store_store);
11420 const wpAllowedMimeTypes = getEditorSettings().allowedMimeTypes;
11421 maxUploadFileSize = maxUploadFileSize || getEditorSettings().maxUploadFileSize;
11422 (0,external_wp_mediaUtils_namespaceObject.uploadMedia)({
11423 allowedTypes,
11424 filesList,
11425 onFileChange,
11426 additionalData: {
11427 post: getCurrentPostId(),
11428 ...additionalData
11429 },
11430 maxUploadFileSize,
11431 onError: _ref2 => {
11432 let {
11433 message
11434 } = _ref2;
11435 return onError(message);
11436 },
11437 wpAllowedMimeTypes
11438 });
11439 }
11440
11441 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/use-block-editor-settings.js
11442 /**
11443 * External dependencies
11444 */
11445
11446 /**
11447 * WordPress dependencies
11448 */
11449
11450
11451
11452
11453
11454 /**
11455 * Internal dependencies
11456 */
11457
11458
11459
11460 /**
11461 * React hook used to compute the block editor settings to use for the post editor.
11462 *
11463 * @param {Object} settings EditorProvider settings prop.
11464 * @param {boolean} hasTemplate Whether template mode is enabled.
11465 *
11466 * @return {Object} Block Editor Settings.
11467 */
11468
11469 function useBlockEditorSettings(settings, hasTemplate) {
11470 var _settings$__experimen, _settings$__experimen2;
11471
11472 const {
11473 reusableBlocks,
11474 hasUploadPermissions,
11475 canUseUnfilteredHTML,
11476 userCanCreatePages,
11477 pageOnFront
11478 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11479 var _canUser;
11480
11481 const {
11482 canUserUseUnfilteredHTML
11483 } = select(store_store);
11484 const isWeb = external_wp_element_namespaceObject.Platform.OS === 'web';
11485 const {
11486 canUser,
11487 getEntityRecord
11488 } = select(external_wp_coreData_namespaceObject.store);
11489 const siteSettings = getEntityRecord('root', 'site');
11490 return {
11491 canUseUnfilteredHTML: canUserUseUnfilteredHTML(),
11492 reusableBlocks: isWeb ? select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_block', {
11493 per_page: -1
11494 }) : [],
11495 // Reusable blocks are fetched in the native version of this hook.
11496 hasUploadPermissions: (_canUser = canUser('create', 'media')) !== null && _canUser !== void 0 ? _canUser : true,
11497 userCanCreatePages: canUser('create', 'pages'),
11498 pageOnFront: siteSettings === null || siteSettings === void 0 ? void 0 : siteSettings.page_on_front
11499 };
11500 }, []);
11501 const settingsBlockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : // WP 6.0
11502 settings.__experimentalBlockPatterns; // WP 5.9
11503
11504 const settingsBlockPatternCategories = (_settings$__experimen2 = settings.__experimentalAdditionalBlockPatternCategories) !== null && _settings$__experimen2 !== void 0 ? _settings$__experimen2 : // WP 6.0
11505 settings.__experimentalBlockPatternCategories; // WP 5.9
11506
11507 const {
11508 restBlockPatterns,
11509 restBlockPatternCategories
11510 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
11511 restBlockPatterns: select(external_wp_coreData_namespaceObject.store).getBlockPatterns(),
11512 restBlockPatternCategories: select(external_wp_coreData_namespaceObject.store).getBlockPatternCategories()
11513 }), []);
11514 const blockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_lodash_namespaceObject.unionBy)(settingsBlockPatterns, restBlockPatterns, 'name'), [settingsBlockPatterns, restBlockPatterns]);
11515 const blockPatternCategories = (0,external_wp_element_namespaceObject.useMemo)(() => (0,external_lodash_namespaceObject.unionBy)(settingsBlockPatternCategories, restBlockPatternCategories, 'name'), [settingsBlockPatternCategories, restBlockPatternCategories]);
11516 const {
11517 undo
11518 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11519 const {
11520 saveEntityRecord
11521 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
11522 /**
11523 * Creates a Post entity.
11524 * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.
11525 *
11526 * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.
11527 * @return {Object} the post type object that was created.
11528 */
11529
11530 const createPageEntity = options => {
11531 if (!userCanCreatePages) {
11532 return Promise.reject({
11533 message: (0,external_wp_i18n_namespaceObject.__)('You do not have permission to create Pages.')
11534 });
11535 }
11536
11537 return saveEntityRecord('postType', 'page', options);
11538 };
11539
11540 return (0,external_wp_element_namespaceObject.useMemo)(() => ({ ...(0,external_lodash_namespaceObject.pick)(settings, ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalPreferredStyleVariations', '__experimentalSetIsInserterOpened', '__unstableGalleryWithImageBlocks', 'alignWide', 'allowedBlockTypes', 'bodyPlaceholder', 'canLockBlocks', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomGradients', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'focusMode', 'fontSizes', 'gradients', 'generateAnchors', 'hasFixedToolbar', 'hasReducedUI', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'keepCaretInsideBlock', 'maxWidth', 'onUpdateDefaultBlockStyles', 'styles', 'template', 'templateLock', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock', '__unstableResolvedAssets']),
11541 mediaUpload: hasUploadPermissions ? mediaUpload : undefined,
11542 __experimentalReusableBlocks: reusableBlocks,
11543 __experimentalBlockPatterns: blockPatterns,
11544 __experimentalBlockPatternCategories: blockPatternCategories,
11545 __experimentalFetchLinkSuggestions: (search, searchOptions) => (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings),
11546 __experimentalFetchRichUrlData: external_wp_coreData_namespaceObject.__experimentalFetchUrlData,
11547 __experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,
11548 __experimentalUndo: undo,
11549 outlineMode: hasTemplate,
11550 __experimentalCreatePageEntity: createPageEntity,
11551 __experimentalUserCanCreatePages: userCanCreatePages,
11552 pageOnFront,
11553 __experimentalPreferPatternsOnRoot: hasTemplate
11554 }), [settings, hasUploadPermissions, reusableBlocks, blockPatterns, blockPatternCategories, canUseUnfilteredHTML, undo, hasTemplate, userCanCreatePages, pageOnFront]);
11555 }
11556
11557 /* harmony default export */ const use_block_editor_settings = (useBlockEditorSettings);
11558
11559 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/index.js
11560
11561
11562 /**
11563 * WordPress dependencies
11564 */
11565
11566
11567
11568
11569
11570
11571
11572 /**
11573 * Internal dependencies
11574 */
11575
11576
11577
11578
11579
11580 function EditorProvider(_ref) {
11581 let {
11582 __unstableTemplate,
11583 post,
11584 settings,
11585 recovery,
11586 initialEdits,
11587 children
11588 } = _ref;
11589 const defaultBlockContext = (0,external_wp_element_namespaceObject.useMemo)(() => {
11590 if (post.type === 'wp_template') {
11591 return {};
11592 }
11593
11594 return {
11595 postId: post.id,
11596 postType: post.type
11597 };
11598 }, [post.id, post.type]);
11599 const {
11600 selection,
11601 isReady
11602 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11603 const {
11604 getEditorSelection,
11605 __unstableIsEditorReady
11606 } = select(store_store);
11607 return {
11608 isReady: __unstableIsEditorReady(),
11609 selection: getEditorSelection()
11610 };
11611 }, []);
11612 const {
11613 id,
11614 type
11615 } = __unstableTemplate !== null && __unstableTemplate !== void 0 ? __unstableTemplate : post;
11616 const [blocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', type, {
11617 id
11618 });
11619 const editorSettings = use_block_editor_settings(settings, !!__unstableTemplate);
11620 const {
11621 updatePostLock,
11622 setupEditor,
11623 updateEditorSettings,
11624 __experimentalTearDownEditor
11625 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11626 const {
11627 createWarningNotice
11628 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store); // Initialize and tear down the editor.
11629 // Ideally this should be synced on each change and not just something you do once.
11630
11631 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
11632 // Assume that we don't need to initialize in the case of an error recovery.
11633 if (recovery) {
11634 return;
11635 }
11636
11637 updatePostLock(settings.postLock);
11638 setupEditor(post, initialEdits, settings.template);
11639
11640 if (settings.autosave) {
11641 createWarningNotice((0,external_wp_i18n_namespaceObject.__)('There is an autosave of this post that is more recent than the version below.'), {
11642 id: 'autosave-exists',
11643 actions: [{
11644 label: (0,external_wp_i18n_namespaceObject.__)('View the autosave'),
11645 url: settings.autosave.editLink
11646 }]
11647 });
11648 }
11649
11650 return () => {
11651 __experimentalTearDownEditor();
11652 };
11653 }, []); // Synchronize the editor settings as they change.
11654
11655 (0,external_wp_element_namespaceObject.useEffect)(() => {
11656 updateEditorSettings(settings);
11657 }, [settings]);
11658
11659 if (!isReady) {
11660 return null;
11661 }
11662
11663 return (0,external_wp_element_namespaceObject.createElement)(external_wp_coreData_namespaceObject.EntityProvider, {
11664 kind: "root",
11665 type: "site"
11666 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_coreData_namespaceObject.EntityProvider, {
11667 kind: "postType",
11668 type: post.type,
11669 id: post.id
11670 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockContextProvider, {
11671 value: defaultBlockContext
11672 }, (0,external_wp_element_namespaceObject.createElement)(external_wp_blockEditor_namespaceObject.BlockEditorProvider, {
11673 value: blocks,
11674 onChange: onChange,
11675 onInput: onInput,
11676 selection: selection,
11677 settings: editorSettings,
11678 useSubRegistry: false
11679 }, children, (0,external_wp_element_namespaceObject.createElement)(external_wp_reusableBlocks_namespaceObject.ReusableBlocksMenuItems, null)))));
11680 }
11681
11682 /* harmony default export */ const provider = (with_registry_provider(EditorProvider));
11683
11684 ;// CONCATENATED MODULE: external ["wp","serverSideRender"]
11685 const external_wp_serverSideRender_namespaceObject = window["wp"]["serverSideRender"];
11686 var external_wp_serverSideRender_default = /*#__PURE__*/__webpack_require__.n(external_wp_serverSideRender_namespaceObject);
11687 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/deprecated.js
11688
11689
11690 // Block Creation Components.
11691
11692 /**
11693 * WordPress dependencies
11694 */
11695
11696
11697
11698
11699
11700 function deprecateComponent(name, Wrapped) {
11701 let staticsToHoist = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
11702 const Component = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
11703 external_wp_deprecated_default()('wp.editor.' + name, {
11704 since: '5.3',
11705 alternative: 'wp.blockEditor.' + name,
11706 version: '6.2'
11707 });
11708 return (0,external_wp_element_namespaceObject.createElement)(Wrapped, _extends({
11709 ref: ref
11710 }, props));
11711 });
11712 staticsToHoist.forEach(staticName => {
11713 Component[staticName] = deprecateComponent(name + '.' + staticName, Wrapped[staticName]);
11714 });
11715 return Component;
11716 }
11717
11718 function deprecateFunction(name, func) {
11719 return function () {
11720 external_wp_deprecated_default()('wp.editor.' + name, {
11721 since: '5.3',
11722 alternative: 'wp.blockEditor.' + name,
11723 version: '6.2'
11724 });
11725 return func(...arguments);
11726 };
11727 }
11728
11729 const RichText = deprecateComponent('RichText', external_wp_blockEditor_namespaceObject.RichText, ['Content']);
11730 RichText.isEmpty = deprecateFunction('RichText.isEmpty', external_wp_blockEditor_namespaceObject.RichText.isEmpty);
11731
11732 const Autocomplete = deprecateComponent('Autocomplete', external_wp_blockEditor_namespaceObject.Autocomplete);
11733 const AlignmentToolbar = deprecateComponent('AlignmentToolbar', external_wp_blockEditor_namespaceObject.AlignmentToolbar);
11734 const BlockAlignmentToolbar = deprecateComponent('BlockAlignmentToolbar', external_wp_blockEditor_namespaceObject.BlockAlignmentToolbar);
11735 const BlockControls = deprecateComponent('BlockControls', external_wp_blockEditor_namespaceObject.BlockControls, ['Slot']);
11736 const BlockEdit = deprecateComponent('BlockEdit', external_wp_blockEditor_namespaceObject.BlockEdit);
11737 const BlockEditorKeyboardShortcuts = deprecateComponent('BlockEditorKeyboardShortcuts', external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts);
11738 const BlockFormatControls = deprecateComponent('BlockFormatControls', external_wp_blockEditor_namespaceObject.BlockFormatControls, ['Slot']);
11739 const BlockIcon = deprecateComponent('BlockIcon', external_wp_blockEditor_namespaceObject.BlockIcon);
11740 const BlockInspector = deprecateComponent('BlockInspector', external_wp_blockEditor_namespaceObject.BlockInspector);
11741 const BlockList = deprecateComponent('BlockList', external_wp_blockEditor_namespaceObject.BlockList);
11742 const BlockMover = deprecateComponent('BlockMover', external_wp_blockEditor_namespaceObject.BlockMover);
11743 const BlockNavigationDropdown = deprecateComponent('BlockNavigationDropdown', external_wp_blockEditor_namespaceObject.BlockNavigationDropdown);
11744 const BlockSelectionClearer = deprecateComponent('BlockSelectionClearer', external_wp_blockEditor_namespaceObject.BlockSelectionClearer);
11745 const BlockSettingsMenu = deprecateComponent('BlockSettingsMenu', external_wp_blockEditor_namespaceObject.BlockSettingsMenu);
11746 const BlockTitle = deprecateComponent('BlockTitle', external_wp_blockEditor_namespaceObject.BlockTitle);
11747 const BlockToolbar = deprecateComponent('BlockToolbar', external_wp_blockEditor_namespaceObject.BlockToolbar);
11748 const ColorPalette = deprecateComponent('ColorPalette', external_wp_blockEditor_namespaceObject.ColorPalette);
11749 const ContrastChecker = deprecateComponent('ContrastChecker', external_wp_blockEditor_namespaceObject.ContrastChecker);
11750 const CopyHandler = deprecateComponent('CopyHandler', external_wp_blockEditor_namespaceObject.CopyHandler);
11751 const DefaultBlockAppender = deprecateComponent('DefaultBlockAppender', external_wp_blockEditor_namespaceObject.DefaultBlockAppender);
11752 const FontSizePicker = deprecateComponent('FontSizePicker', external_wp_blockEditor_namespaceObject.FontSizePicker);
11753 const Inserter = deprecateComponent('Inserter', external_wp_blockEditor_namespaceObject.Inserter);
11754 const InnerBlocks = deprecateComponent('InnerBlocks', external_wp_blockEditor_namespaceObject.InnerBlocks, ['ButtonBlockAppender', 'DefaultBlockAppender', 'Content']);
11755 const InspectorAdvancedControls = deprecateComponent('InspectorAdvancedControls', external_wp_blockEditor_namespaceObject.InspectorAdvancedControls, ['Slot']);
11756 const InspectorControls = deprecateComponent('InspectorControls', external_wp_blockEditor_namespaceObject.InspectorControls, ['Slot']);
11757 const PanelColorSettings = deprecateComponent('PanelColorSettings', external_wp_blockEditor_namespaceObject.PanelColorSettings);
11758 const PlainText = deprecateComponent('PlainText', external_wp_blockEditor_namespaceObject.PlainText);
11759 const RichTextShortcut = deprecateComponent('RichTextShortcut', external_wp_blockEditor_namespaceObject.RichTextShortcut);
11760 const RichTextToolbarButton = deprecateComponent('RichTextToolbarButton', external_wp_blockEditor_namespaceObject.RichTextToolbarButton);
11761 const __unstableRichTextInputEvent = deprecateComponent('__unstableRichTextInputEvent', external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent);
11762 const MediaPlaceholder = deprecateComponent('MediaPlaceholder', external_wp_blockEditor_namespaceObject.MediaPlaceholder);
11763 const MediaUpload = deprecateComponent('MediaUpload', external_wp_blockEditor_namespaceObject.MediaUpload);
11764 const MediaUploadCheck = deprecateComponent('MediaUploadCheck', external_wp_blockEditor_namespaceObject.MediaUploadCheck);
11765 const MultiSelectScrollIntoView = deprecateComponent('MultiSelectScrollIntoView', external_wp_blockEditor_namespaceObject.MultiSelectScrollIntoView);
11766 const NavigableToolbar = deprecateComponent('NavigableToolbar', external_wp_blockEditor_namespaceObject.NavigableToolbar);
11767 const ObserveTyping = deprecateComponent('ObserveTyping', external_wp_blockEditor_namespaceObject.ObserveTyping);
11768 const SkipToSelectedBlock = deprecateComponent('SkipToSelectedBlock', external_wp_blockEditor_namespaceObject.SkipToSelectedBlock);
11769 const URLInput = deprecateComponent('URLInput', external_wp_blockEditor_namespaceObject.URLInput);
11770 const URLInputButton = deprecateComponent('URLInputButton', external_wp_blockEditor_namespaceObject.URLInputButton);
11771 const URLPopover = deprecateComponent('URLPopover', external_wp_blockEditor_namespaceObject.URLPopover);
11772 const Warning = deprecateComponent('Warning', external_wp_blockEditor_namespaceObject.Warning);
11773 const WritingFlow = deprecateComponent('WritingFlow', external_wp_blockEditor_namespaceObject.WritingFlow);
11774 const createCustomColorsHOC = deprecateFunction('createCustomColorsHOC', external_wp_blockEditor_namespaceObject.createCustomColorsHOC);
11775 const getColorClassName = deprecateFunction('getColorClassName', external_wp_blockEditor_namespaceObject.getColorClassName);
11776 const getColorObjectByAttributeValues = deprecateFunction('getColorObjectByAttributeValues', external_wp_blockEditor_namespaceObject.getColorObjectByAttributeValues);
11777 const getColorObjectByColorValue = deprecateFunction('getColorObjectByColorValue', external_wp_blockEditor_namespaceObject.getColorObjectByColorValue);
11778 const getFontSize = deprecateFunction('getFontSize', external_wp_blockEditor_namespaceObject.getFontSize);
11779 const getFontSizeClass = deprecateFunction('getFontSizeClass', external_wp_blockEditor_namespaceObject.getFontSizeClass);
11780 const withColorContext = deprecateFunction('withColorContext', external_wp_blockEditor_namespaceObject.withColorContext);
11781 const withColors = deprecateFunction('withColors', external_wp_blockEditor_namespaceObject.withColors);
11782 const withFontSizes = deprecateFunction('withFontSizes', external_wp_blockEditor_namespaceObject.withFontSizes);
11783
11784 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/index.js
11785 // Block Creation Components.
11786 // Post Related Components.
11787
11788
11789
11790
11791
11792
11793
11794
11795
11796
11797
11798
11799
11800
11801
11802
11803
11804
11805
11806
11807
11808
11809
11810
11811
11812
11813
11814
11815
11816
11817
11818
11819
11820
11821
11822
11823
11824
11825
11826
11827
11828
11829
11830
11831
11832
11833
11834
11835
11836
11837
11838
11839
11840
11841
11842
11843
11844
11845
11846
11847
11848 // State Related Components.
11849
11850
11851
11852
11853 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/url.js
11854 /**
11855 * WordPress dependencies
11856 */
11857
11858
11859 /**
11860 * Performs some basic cleanup of a string for use as a post slug
11861 *
11862 * This replicates some of what sanitize_title() does in WordPress core, but
11863 * is only designed to approximate what the slug will be.
11864 *
11865 * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin letters.
11866 * Removes combining diacritical marks. Converts whitespace, periods,
11867 * and forward slashes to hyphens. Removes any remaining non-word characters
11868 * except hyphens and underscores. Converts remaining string to lowercase.
11869 * It does not account for octets, HTML entities, or other encoded characters.
11870 *
11871 * @param {string} string Title or slug to be processed
11872 *
11873 * @return {string} Processed string
11874 */
11875
11876 function cleanForSlug(string) {
11877 external_wp_deprecated_default()('wp.editor.cleanForSlug', {
11878 since: '12.7',
11879 plugin: 'Gutenberg',
11880 alternative: 'wp.url.cleanForSlug'
11881 });
11882 return (0,external_wp_url_namespaceObject.cleanForSlug)(string);
11883 }
11884
11885 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/index.js
11886 /**
11887 * Internal dependencies
11888 */
11889
11890
11891
11892
11893
11894 ;// CONCATENATED MODULE: ./packages/editor/build-module/index.js
11895 /**
11896 * Internal dependencies
11897 */
11898
11899
11900
11901
11902 /*
11903 * Backward compatibility
11904 */
11905
11906
11907
11908 })();
11909
11910 (window.wp = window.wp || {}).editor = __webpack_exports__;
11911 /******/ })()
11912 ;