PluginProbe
Gutenberg / 16.6.0
Gutenberg v16.6.0
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 16.6.0, at build/editor/index.js

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