PluginProbe
Gutenberg / 18.5.0
Gutenberg v18.5.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 18.5.0, at build/editor/index.js

28,093 lines 970.4 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 /***/ 4827:
294 /***/ ((module) => {
295
296 // This code has been refactored for 140 bytes
297 // You can see the original here: https://github.com/twolfson/computedStyle/blob/04cd1da2e30fa45844f95f5cb1ac898e9b9ef050/lib/computedStyle.js
298 var computedStyle = function (el, prop, getComputedStyle) {
299 getComputedStyle = window.getComputedStyle;
300
301 // In one fell swoop
302 return (
303 // If we have getComputedStyle
304 getComputedStyle ?
305 // Query it
306 // TODO: From CSS-Query notes, we might need (node, null) for FF
307 getComputedStyle(el) :
308
309 // Otherwise, we are in IE and use currentStyle
310 el.currentStyle
311 )[
312 // Switch to camelCase for CSSOM
313 // DEV: Grabbed from jQuery
314 // https://github.com/jquery/jquery/blob/1.9-stable/src/css.js#L191-L194
315 // https://github.com/jquery/jquery/blob/1.9-stable/src/core.js#L593-L597
316 prop.replace(/-(\w)/gi, function (word, letter) {
317 return letter.toUpperCase();
318 })
319 ];
320 };
321
322 module.exports = computedStyle;
323
324
325 /***/ }),
326
327 /***/ 1919:
328 /***/ ((module) => {
329
330 "use strict";
331
332
333 var isMergeableObject = function isMergeableObject(value) {
334 return isNonNullObject(value)
335 && !isSpecial(value)
336 };
337
338 function isNonNullObject(value) {
339 return !!value && typeof value === 'object'
340 }
341
342 function isSpecial(value) {
343 var stringValue = Object.prototype.toString.call(value);
344
345 return stringValue === '[object RegExp]'
346 || stringValue === '[object Date]'
347 || isReactElement(value)
348 }
349
350 // see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
351 var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
352 var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
353
354 function isReactElement(value) {
355 return value.$$typeof === REACT_ELEMENT_TYPE
356 }
357
358 function emptyTarget(val) {
359 return Array.isArray(val) ? [] : {}
360 }
361
362 function cloneUnlessOtherwiseSpecified(value, options) {
363 return (options.clone !== false && options.isMergeableObject(value))
364 ? deepmerge(emptyTarget(value), value, options)
365 : value
366 }
367
368 function defaultArrayMerge(target, source, options) {
369 return target.concat(source).map(function(element) {
370 return cloneUnlessOtherwiseSpecified(element, options)
371 })
372 }
373
374 function getMergeFunction(key, options) {
375 if (!options.customMerge) {
376 return deepmerge
377 }
378 var customMerge = options.customMerge(key);
379 return typeof customMerge === 'function' ? customMerge : deepmerge
380 }
381
382 function getEnumerableOwnPropertySymbols(target) {
383 return Object.getOwnPropertySymbols
384 ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
385 return Object.propertyIsEnumerable.call(target, symbol)
386 })
387 : []
388 }
389
390 function getKeys(target) {
391 return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
392 }
393
394 function propertyIsOnObject(object, property) {
395 try {
396 return property in object
397 } catch(_) {
398 return false
399 }
400 }
401
402 // Protects from prototype poisoning and unexpected merging up the prototype chain.
403 function propertyIsUnsafe(target, key) {
404 return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
405 && !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
406 && Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
407 }
408
409 function mergeObject(target, source, options) {
410 var destination = {};
411 if (options.isMergeableObject(target)) {
412 getKeys(target).forEach(function(key) {
413 destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
414 });
415 }
416 getKeys(source).forEach(function(key) {
417 if (propertyIsUnsafe(target, key)) {
418 return
419 }
420
421 if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
422 destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
423 } else {
424 destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
425 }
426 });
427 return destination
428 }
429
430 function deepmerge(target, source, options) {
431 options = options || {};
432 options.arrayMerge = options.arrayMerge || defaultArrayMerge;
433 options.isMergeableObject = options.isMergeableObject || isMergeableObject;
434 // cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
435 // implementations can use it. The caller may not replace it.
436 options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
437
438 var sourceIsArray = Array.isArray(source);
439 var targetIsArray = Array.isArray(target);
440 var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
441
442 if (!sourceAndTargetTypesMatch) {
443 return cloneUnlessOtherwiseSpecified(source, options)
444 } else if (sourceIsArray) {
445 return options.arrayMerge(target, source, options)
446 } else {
447 return mergeObject(target, source, options)
448 }
449 }
450
451 deepmerge.all = function deepmergeAll(array, options) {
452 if (!Array.isArray(array)) {
453 throw new Error('first argument should be an array')
454 }
455
456 return array.reduce(function(prev, next) {
457 return deepmerge(prev, next, options)
458 }, {})
459 };
460
461 var deepmerge_1 = deepmerge;
462
463 module.exports = deepmerge_1;
464
465
466 /***/ }),
467
468 /***/ 2303:
469 /***/ ((module) => {
470
471 "use strict";
472
473
474 // do not edit .js files directly - edit src/index.jst
475
476
477
478 module.exports = function equal(a, b) {
479 if (a === b) return true;
480
481 if (a && b && typeof a == 'object' && typeof b == 'object') {
482 if (a.constructor !== b.constructor) return false;
483
484 var length, i, keys;
485 if (Array.isArray(a)) {
486 length = a.length;
487 if (length != b.length) return false;
488 for (i = length; i-- !== 0;)
489 if (!equal(a[i], b[i])) return false;
490 return true;
491 }
492
493
494
495 if (a.constructor === RegExp) return a.source === b.source && a.flags === b.flags;
496 if (a.valueOf !== Object.prototype.valueOf) return a.valueOf() === b.valueOf();
497 if (a.toString !== Object.prototype.toString) return a.toString() === b.toString();
498
499 keys = Object.keys(a);
500 length = keys.length;
501 if (length !== Object.keys(b).length) return false;
502
503 for (i = length; i-- !== 0;)
504 if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return false;
505
506 for (i = length; i-- !== 0;) {
507 var key = keys[i];
508
509 if (!equal(a[key], b[key])) return false;
510 }
511
512 return true;
513 }
514
515 // true if both NaN, false otherwise
516 return a!==a && b!==b;
517 };
518
519
520 /***/ }),
521
522 /***/ 9894:
523 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
524
525 // Load in dependencies
526 var computedStyle = __webpack_require__(4827);
527
528 /**
529 * Calculate the `line-height` of a given node
530 * @param {HTMLElement} node Element to calculate line height of. Must be in the DOM.
531 * @returns {Number} `line-height` of the element in pixels
532 */
533 function lineHeight(node) {
534 // Grab the line-height via style
535 var lnHeightStr = computedStyle(node, 'line-height');
536 var lnHeight = parseFloat(lnHeightStr, 10);
537
538 // If the lineHeight did not contain a unit (i.e. it was numeric), convert it to ems (e.g. '2.3' === '2.3em')
539 if (lnHeightStr === lnHeight + '') {
540 // Save the old lineHeight style and update the em unit to the element
541 var _lnHeightStyle = node.style.lineHeight;
542 node.style.lineHeight = lnHeightStr + 'em';
543
544 // Calculate the em based height
545 lnHeightStr = computedStyle(node, 'line-height');
546 lnHeight = parseFloat(lnHeightStr, 10);
547
548 // Revert the lineHeight style
549 if (_lnHeightStyle) {
550 node.style.lineHeight = _lnHeightStyle;
551 } else {
552 delete node.style.lineHeight;
553 }
554 }
555
556 // If the lineHeight is in `pt`, convert it to pixels (4px for 3pt)
557 // DEV: `em` units are converted to `pt` in IE6
558 // Conversion ratio from https://developer.mozilla.org/en-US/docs/Web/CSS/length
559 if (lnHeightStr.indexOf('pt') !== -1) {
560 lnHeight *= 4;
561 lnHeight /= 3;
562 // Otherwise, if the lineHeight is in `mm`, convert it to pixels (96px for 25.4mm)
563 } else if (lnHeightStr.indexOf('mm') !== -1) {
564 lnHeight *= 96;
565 lnHeight /= 25.4;
566 // Otherwise, if the lineHeight is in `cm`, convert it to pixels (96px for 2.54cm)
567 } else if (lnHeightStr.indexOf('cm') !== -1) {
568 lnHeight *= 96;
569 lnHeight /= 2.54;
570 // Otherwise, if the lineHeight is in `in`, convert it to pixels (96px for 1in)
571 } else if (lnHeightStr.indexOf('in') !== -1) {
572 lnHeight *= 96;
573 // Otherwise, if the lineHeight is in `pc`, convert it to pixels (12pt for 1pc)
574 } else if (lnHeightStr.indexOf('pc') !== -1) {
575 lnHeight *= 16;
576 }
577
578 // Continue our computation
579 lnHeight = Math.round(lnHeight);
580
581 // If the line-height is "normal", calculate by font-size
582 if (lnHeightStr === 'normal') {
583 // Create a temporary node
584 var nodeName = node.nodeName;
585 var _node = document.createElement(nodeName);
586 _node.innerHTML = '&nbsp;';
587
588 // If we have a text area, reset it to only 1 row
589 // https://github.com/twolfson/line-height/issues/4
590 if (nodeName.toUpperCase() === 'TEXTAREA') {
591 _node.setAttribute('rows', '1');
592 }
593
594 // Set the font-size of the element
595 var fontSizeStr = computedStyle(node, 'font-size');
596 _node.style.fontSize = fontSizeStr;
597
598 // Remove default padding/border which can affect offset height
599 // https://github.com/twolfson/line-height/issues/4
600 // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/offsetHeight
601 _node.style.padding = '0px';
602 _node.style.border = '0px';
603
604 // Append it to the body
605 var body = document.body;
606 body.appendChild(_node);
607
608 // Assume the line height of the element is the height
609 var height = _node.offsetHeight;
610 lnHeight = height;
611
612 // Remove our child from the DOM
613 body.removeChild(_node);
614 }
615
616 // Return the calculated height
617 return lnHeight;
618 }
619
620 // Export lineHeight
621 module.exports = lineHeight;
622
623
624 /***/ }),
625
626 /***/ 5372:
627 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
628
629 "use strict";
630 /**
631 * Copyright (c) 2013-present, Facebook, Inc.
632 *
633 * This source code is licensed under the MIT license found in the
634 * LICENSE file in the root directory of this source tree.
635 */
636
637
638
639 var ReactPropTypesSecret = __webpack_require__(9567);
640
641 function emptyFunction() {}
642 function emptyFunctionWithReset() {}
643 emptyFunctionWithReset.resetWarningCache = emptyFunction;
644
645 module.exports = function() {
646 function shim(props, propName, componentName, location, propFullName, secret) {
647 if (secret === ReactPropTypesSecret) {
648 // It is still safe when called from React.
649 return;
650 }
651 var err = new Error(
652 'Calling PropTypes validators directly is not supported by the `prop-types` package. ' +
653 'Use PropTypes.checkPropTypes() to call them. ' +
654 'Read more at http://fb.me/use-check-prop-types'
655 );
656 err.name = 'Invariant Violation';
657 throw err;
658 };
659 shim.isRequired = shim;
660 function getShim() {
661 return shim;
662 };
663 // Important!
664 // Keep this list in sync with production version in `./factoryWithTypeCheckers.js`.
665 var ReactPropTypes = {
666 array: shim,
667 bigint: shim,
668 bool: shim,
669 func: shim,
670 number: shim,
671 object: shim,
672 string: shim,
673 symbol: shim,
674
675 any: shim,
676 arrayOf: getShim,
677 element: shim,
678 elementType: shim,
679 instanceOf: getShim,
680 node: shim,
681 objectOf: getShim,
682 oneOf: getShim,
683 oneOfType: getShim,
684 shape: getShim,
685 exact: getShim,
686
687 checkPropTypes: emptyFunctionWithReset,
688 resetWarningCache: emptyFunction
689 };
690
691 ReactPropTypes.PropTypes = ReactPropTypes;
692
693 return ReactPropTypes;
694 };
695
696
697 /***/ }),
698
699 /***/ 2652:
700 /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
701
702 /**
703 * Copyright (c) 2013-present, Facebook, Inc.
704 *
705 * This source code is licensed under the MIT license found in the
706 * LICENSE file in the root directory of this source tree.
707 */
708
709 if (false) { var throwOnDirectAccess, ReactIs; } else {
710 // By explicitly using `prop-types` you are opting into new production behavior.
711 // http://fb.me/prop-types-in-prod
712 module.exports = __webpack_require__(5372)();
713 }
714
715
716 /***/ }),
717
718 /***/ 9567:
719 /***/ ((module) => {
720
721 "use strict";
722 /**
723 * Copyright (c) 2013-present, Facebook, Inc.
724 *
725 * This source code is licensed under the MIT license found in the
726 * LICENSE file in the root directory of this source tree.
727 */
728
729
730
731 var ReactPropTypesSecret = 'SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED';
732
733 module.exports = ReactPropTypesSecret;
734
735
736 /***/ }),
737
738 /***/ 5438:
739 /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
740
741 "use strict";
742
743 var __extends = (this && this.__extends) || (function () {
744 var extendStatics = Object.setPrototypeOf ||
745 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
746 function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
747 return function (d, b) {
748 extendStatics(d, b);
749 function __() { this.constructor = d; }
750 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
751 };
752 })();
753 var __assign = (this && this.__assign) || Object.assign || function(t) {
754 for (var s, i = 1, n = arguments.length; i < n; i++) {
755 s = arguments[i];
756 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
757 t[p] = s[p];
758 }
759 return t;
760 };
761 var __rest = (this && this.__rest) || function (s, e) {
762 var t = {};
763 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
764 t[p] = s[p];
765 if (s != null && typeof Object.getOwnPropertySymbols === "function")
766 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
767 t[p[i]] = s[p[i]];
768 return t;
769 };
770 exports.__esModule = true;
771 var React = __webpack_require__(9196);
772 var PropTypes = __webpack_require__(2652);
773 var autosize = __webpack_require__(6411);
774 var _getLineHeight = __webpack_require__(9894);
775 var getLineHeight = _getLineHeight;
776 var RESIZED = "autosize:resized";
777 /**
778 * A light replacement for built-in textarea component
779 * which automaticaly adjusts its height to match the content
780 */
781 var TextareaAutosizeClass = /** @class */ (function (_super) {
782 __extends(TextareaAutosizeClass, _super);
783 function TextareaAutosizeClass() {
784 var _this = _super !== null && _super.apply(this, arguments) || this;
785 _this.state = {
786 lineHeight: null
787 };
788 _this.textarea = null;
789 _this.onResize = function (e) {
790 if (_this.props.onResize) {
791 _this.props.onResize(e);
792 }
793 };
794 _this.updateLineHeight = function () {
795 if (_this.textarea) {
796 _this.setState({
797 lineHeight: getLineHeight(_this.textarea)
798 });
799 }
800 };
801 _this.onChange = function (e) {
802 var onChange = _this.props.onChange;
803 _this.currentValue = e.currentTarget.value;
804 onChange && onChange(e);
805 };
806 return _this;
807 }
808 TextareaAutosizeClass.prototype.componentDidMount = function () {
809 var _this = this;
810 var _a = this.props, maxRows = _a.maxRows, async = _a.async;
811 if (typeof maxRows === "number") {
812 this.updateLineHeight();
813 }
814 if (typeof maxRows === "number" || async) {
815 /*
816 the defer is needed to:
817 - force "autosize" to activate the scrollbar when this.props.maxRows is passed
818 - support StyledComponents (see #71)
819 */
820 setTimeout(function () { return _this.textarea && autosize(_this.textarea); });
821 }
822 else {
823 this.textarea && autosize(this.textarea);
824 }
825 if (this.textarea) {
826 this.textarea.addEventListener(RESIZED, this.onResize);
827 }
828 };
829 TextareaAutosizeClass.prototype.componentWillUnmount = function () {
830 if (this.textarea) {
831 this.textarea.removeEventListener(RESIZED, this.onResize);
832 autosize.destroy(this.textarea);
833 }
834 };
835 TextareaAutosizeClass.prototype.render = function () {
836 var _this = this;
837 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;
838 var maxHeight = maxRows && lineHeight ? lineHeight * maxRows : null;
839 return (React.createElement("textarea", __assign({}, props, { onChange: this.onChange, style: maxHeight ? __assign({}, style, { maxHeight: maxHeight }) : style, ref: function (element) {
840 _this.textarea = element;
841 if (typeof _this.props.innerRef === 'function') {
842 _this.props.innerRef(element);
843 }
844 else if (_this.props.innerRef) {
845 _this.props.innerRef.current = element;
846 }
847 } }), children));
848 };
849 TextareaAutosizeClass.prototype.componentDidUpdate = function () {
850 this.textarea && autosize.update(this.textarea);
851 };
852 TextareaAutosizeClass.defaultProps = {
853 rows: 1,
854 async: false
855 };
856 TextareaAutosizeClass.propTypes = {
857 rows: PropTypes.number,
858 maxRows: PropTypes.number,
859 onResize: PropTypes.func,
860 innerRef: PropTypes.any,
861 async: PropTypes.bool
862 };
863 return TextareaAutosizeClass;
864 }(React.Component));
865 exports.TextareaAutosize = React.forwardRef(function (props, ref) {
866 return React.createElement(TextareaAutosizeClass, __assign({}, props, { innerRef: ref }));
867 });
868
869
870 /***/ }),
871
872 /***/ 773:
873 /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
874
875 "use strict";
876 var __webpack_unused_export__;
877
878 __webpack_unused_export__ = true;
879 var TextareaAutosize_1 = __webpack_require__(5438);
880 exports.Z = TextareaAutosize_1.TextareaAutosize;
881
882
883 /***/ }),
884
885 /***/ 4793:
886 /***/ ((module) => {
887
888 var characterMap = {
889 "À": "A",
890 "Á": "A",
891 "Â": "A",
892 "Ã": "A",
893 "Ä": "A",
894 "Å": "A",
895 "Ấ": "A",
896 "Ắ": "A",
897 "Ẳ": "A",
898 "Ẵ": "A",
899 "Ặ": "A",
900 "Æ": "AE",
901 "Ầ": "A",
902 "Ằ": "A",
903 "Ȃ": "A",
904 "Ả": "A",
905 "Ạ": "A",
906 "Ẩ": "A",
907 "Ẫ": "A",
908 "Ậ": "A",
909 "Ç": "C",
910 "Ḉ": "C",
911 "È": "E",
912 "É": "E",
913 "Ê": "E",
914 "Ë": "E",
915 "Ế": "E",
916 "Ḗ": "E",
917 "Ề": "E",
918 "Ḕ": "E",
919 "Ḝ": "E",
920 "Ȇ": "E",
921 "Ẻ": "E",
922 "Ẽ": "E",
923 "Ẹ": "E",
924 "Ể": "E",
925 "Ễ": "E",
926 "Ệ": "E",
927 "Ì": "I",
928 "Í": "I",
929 "Î": "I",
930 "Ï": "I",
931 "Ḯ": "I",
932 "Ȋ": "I",
933 "Ỉ": "I",
934 "Ị": "I",
935 "Ð": "D",
936 "Ñ": "N",
937 "Ò": "O",
938 "Ó": "O",
939 "Ô": "O",
940 "Õ": "O",
941 "Ö": "O",
942 "Ø": "O",
943 "Ố": "O",
944 "Ṍ": "O",
945 "Ṓ": "O",
946 "Ȏ": "O",
947 "Ỏ": "O",
948 "Ọ": "O",
949 "Ổ": "O",
950 "Ỗ": "O",
951 "Ộ": "O",
952 "Ờ": "O",
953 "Ở": "O",
954 "Ỡ": "O",
955 "Ớ": "O",
956 "Ợ": "O",
957 "Ù": "U",
958 "Ú": "U",
959 "Û": "U",
960 "Ü": "U",
961 "Ủ": "U",
962 "Ụ": "U",
963 "Ử": "U",
964 "Ữ": "U",
965 "Ự": "U",
966 "Ý": "Y",
967 "à": "a",
968 "á": "a",
969 "â": "a",
970 "ã": "a",
971 "ä": "a",
972 "å": "a",
973 "ấ": "a",
974 "ắ": "a",
975 "ẳ": "a",
976 "ẵ": "a",
977 "ặ": "a",
978 "æ": "ae",
979 "ầ": "a",
980 "ằ": "a",
981 "ȃ": "a",
982 "ả": "a",
983 "ạ": "a",
984 "ẩ": "a",
985 "ẫ": "a",
986 "ậ": "a",
987 "ç": "c",
988 "ḉ": "c",
989 "è": "e",
990 "é": "e",
991 "ê": "e",
992 "ë": "e",
993 "ế": "e",
994 "ḗ": "e",
995 "ề": "e",
996 "ḕ": "e",
997 "ḝ": "e",
998 "ȇ": "e",
999 "ẻ": "e",
1000 "ẽ": "e",
1001 "ẹ": "e",
1002 "ể": "e",
1003 "ễ": "e",
1004 "ệ": "e",
1005 "ì": "i",
1006 "í": "i",
1007 "î": "i",
1008 "ï": "i",
1009 "ḯ": "i",
1010 "ȋ": "i",
1011 "ỉ": "i",
1012 "ị": "i",
1013 "ð": "d",
1014 "ñ": "n",
1015 "ò": "o",
1016 "ó": "o",
1017 "ô": "o",
1018 "õ": "o",
1019 "ö": "o",
1020 "ø": "o",
1021 "ố": "o",
1022 "ṍ": "o",
1023 "ṓ": "o",
1024 "ȏ": "o",
1025 "ỏ": "o",
1026 "ọ": "o",
1027 "ổ": "o",
1028 "ỗ": "o",
1029 "ộ": "o",
1030 "ờ": "o",
1031 "ở": "o",
1032 "ỡ": "o",
1033 "ớ": "o",
1034 "ợ": "o",
1035 "ù": "u",
1036 "ú": "u",
1037 "û": "u",
1038 "ü": "u",
1039 "ủ": "u",
1040 "ụ": "u",
1041 "ử": "u",
1042 "ữ": "u",
1043 "ự": "u",
1044 "ý": "y",
1045 "ÿ": "y",
1046 "Ā": "A",
1047 "ā": "a",
1048 "Ă": "A",
1049 "ă": "a",
1050 "Ą": "A",
1051 "ą": "a",
1052 "Ć": "C",
1053 "ć": "c",
1054 "Ĉ": "C",
1055 "ĉ": "c",
1056 "Ċ": "C",
1057 "ċ": "c",
1058 "Č": "C",
1059 "č": "c",
1060 "C̆": "C",
1061 "c̆": "c",
1062 "Ď": "D",
1063 "ď": "d",
1064 "Đ": "D",
1065 "đ": "d",
1066 "Ē": "E",
1067 "ē": "e",
1068 "Ĕ": "E",
1069 "ĕ": "e",
1070 "Ė": "E",
1071 "ė": "e",
1072 "Ę": "E",
1073 "ę": "e",
1074 "Ě": "E",
1075 "ě": "e",
1076 "Ĝ": "G",
1077 "Ǵ": "G",
1078 "ĝ": "g",
1079 "ǵ": "g",
1080 "Ğ": "G",
1081 "ğ": "g",
1082 "Ġ": "G",
1083 "ġ": "g",
1084 "Ģ": "G",
1085 "ģ": "g",
1086 "Ĥ": "H",
1087 "ĥ": "h",
1088 "Ħ": "H",
1089 "ħ": "h",
1090 "Ḫ": "H",
1091 "ḫ": "h",
1092 "Ĩ": "I",
1093 "ĩ": "i",
1094 "Ī": "I",
1095 "ī": "i",
1096 "Ĭ": "I",
1097 "ĭ": "i",
1098 "Į": "I",
1099 "į": "i",
1100 "İ": "I",
1101 "ı": "i",
1102 "IJ": "IJ",
1103 "ij": "ij",
1104 "Ĵ": "J",
1105 "ĵ": "j",
1106 "Ķ": "K",
1107 "ķ": "k",
1108 "Ḱ": "K",
1109 "ḱ": "k",
1110 "K̆": "K",
1111 "k̆": "k",
1112 "Ĺ": "L",
1113 "ĺ": "l",
1114 "Ļ": "L",
1115 "ļ": "l",
1116 "Ľ": "L",
1117 "ľ": "l",
1118 "Ŀ": "L",
1119 "ŀ": "l",
1120 "Ł": "l",
1121 "ł": "l",
1122 "Ḿ": "M",
1123 "ḿ": "m",
1124 "M̆": "M",
1125 "m̆": "m",
1126 "Ń": "N",
1127 "ń": "n",
1128 "Ņ": "N",
1129 "ņ": "n",
1130 "Ň": "N",
1131 "ň": "n",
1132 "ʼn": "n",
1133 "N̆": "N",
1134 "n̆": "n",
1135 "Ō": "O",
1136 "ō": "o",
1137 "Ŏ": "O",
1138 "ŏ": "o",
1139 "Ő": "O",
1140 "ő": "o",
1141 "Œ": "OE",
1142 "œ": "oe",
1143 "P̆": "P",
1144 "p̆": "p",
1145 "Ŕ": "R",
1146 "ŕ": "r",
1147 "Ŗ": "R",
1148 "ŗ": "r",
1149 "Ř": "R",
1150 "ř": "r",
1151 "R̆": "R",
1152 "r̆": "r",
1153 "Ȓ": "R",
1154 "ȓ": "r",
1155 "Ś": "S",
1156 "ś": "s",
1157 "Ŝ": "S",
1158 "ŝ": "s",
1159 "Ş": "S",
1160 "Ș": "S",
1161 "ș": "s",
1162 "ş": "s",
1163 "Š": "S",
1164 "š": "s",
1165 "Ţ": "T",
1166 "ţ": "t",
1167 "ț": "t",
1168 "Ț": "T",
1169 "Ť": "T",
1170 "ť": "t",
1171 "Ŧ": "T",
1172 "ŧ": "t",
1173 "T̆": "T",
1174 "t̆": "t",
1175 "Ũ": "U",
1176 "ũ": "u",
1177 "Ū": "U",
1178 "ū": "u",
1179 "Ŭ": "U",
1180 "ŭ": "u",
1181 "Ů": "U",
1182 "ů": "u",
1183 "Ű": "U",
1184 "ű": "u",
1185 "Ų": "U",
1186 "ų": "u",
1187 "Ȗ": "U",
1188 "ȗ": "u",
1189 "V̆": "V",
1190 "v̆": "v",
1191 "Ŵ": "W",
1192 "ŵ": "w",
1193 "Ẃ": "W",
1194 "ẃ": "w",
1195 "X̆": "X",
1196 "x̆": "x",
1197 "Ŷ": "Y",
1198 "ŷ": "y",
1199 "Ÿ": "Y",
1200 "Y̆": "Y",
1201 "y̆": "y",
1202 "Ź": "Z",
1203 "ź": "z",
1204 "Ż": "Z",
1205 "ż": "z",
1206 "Ž": "Z",
1207 "ž": "z",
1208 "ſ": "s",
1209 "ƒ": "f",
1210 "Ơ": "O",
1211 "ơ": "o",
1212 "Ư": "U",
1213 "ư": "u",
1214 "Ǎ": "A",
1215 "ǎ": "a",
1216 "Ǐ": "I",
1217 "ǐ": "i",
1218 "Ǒ": "O",
1219 "ǒ": "o",
1220 "Ǔ": "U",
1221 "ǔ": "u",
1222 "Ǖ": "U",
1223 "ǖ": "u",
1224 "Ǘ": "U",
1225 "ǘ": "u",
1226 "Ǚ": "U",
1227 "ǚ": "u",
1228 "Ǜ": "U",
1229 "ǜ": "u",
1230 "Ứ": "U",
1231 "ứ": "u",
1232 "Ṹ": "U",
1233 "ṹ": "u",
1234 "Ǻ": "A",
1235 "ǻ": "a",
1236 "Ǽ": "AE",
1237 "ǽ": "ae",
1238 "Ǿ": "O",
1239 "ǿ": "o",
1240 "Þ": "TH",
1241 "þ": "th",
1242 "Ṕ": "P",
1243 "ṕ": "p",
1244 "Ṥ": "S",
1245 "ṥ": "s",
1246 "X́": "X",
1247 "x́": "x",
1248 "Ѓ": "Г",
1249 "ѓ": "г",
1250 "Ќ": "К",
1251 "ќ": "к",
1252 "A̋": "A",
1253 "a̋": "a",
1254 "E̋": "E",
1255 "e̋": "e",
1256 "I̋": "I",
1257 "i̋": "i",
1258 "Ǹ": "N",
1259 "ǹ": "n",
1260 "Ồ": "O",
1261 "ồ": "o",
1262 "Ṑ": "O",
1263 "ṑ": "o",
1264 "Ừ": "U",
1265 "ừ": "u",
1266 "Ẁ": "W",
1267 "ẁ": "w",
1268 "Ỳ": "Y",
1269 "ỳ": "y",
1270 "Ȁ": "A",
1271 "ȁ": "a",
1272 "Ȅ": "E",
1273 "ȅ": "e",
1274 "Ȉ": "I",
1275 "ȉ": "i",
1276 "Ȍ": "O",
1277 "ȍ": "o",
1278 "Ȑ": "R",
1279 "ȑ": "r",
1280 "Ȕ": "U",
1281 "ȕ": "u",
1282 "B̌": "B",
1283 "b̌": "b",
1284 "Č̣": "C",
1285 "č̣": "c",
1286 "Ê̌": "E",
1287 "ê̌": "e",
1288 "F̌": "F",
1289 "f̌": "f",
1290 "Ǧ": "G",
1291 "ǧ": "g",
1292 "Ȟ": "H",
1293 "ȟ": "h",
1294 "J̌": "J",
1295 "ǰ": "j",
1296 "Ǩ": "K",
1297 "ǩ": "k",
1298 "M̌": "M",
1299 "m̌": "m",
1300 "P̌": "P",
1301 "p̌": "p",
1302 "Q̌": "Q",
1303 "q̌": "q",
1304 "Ř̩": "R",
1305 "ř̩": "r",
1306 "Ṧ": "S",
1307 "ṧ": "s",
1308 "V̌": "V",
1309 "v̌": "v",
1310 "W̌": "W",
1311 "w̌": "w",
1312 "X̌": "X",
1313 "x̌": "x",
1314 "Y̌": "Y",
1315 "y̌": "y",
1316 "A̧": "A",
1317 "a̧": "a",
1318 "B̧": "B",
1319 "b̧": "b",
1320 "Ḑ": "D",
1321 "ḑ": "d",
1322 "Ȩ": "E",
1323 "ȩ": "e",
1324 "Ɛ̧": "E",
1325 "ɛ̧": "e",
1326 "Ḩ": "H",
1327 "ḩ": "h",
1328 "I̧": "I",
1329 "i̧": "i",
1330 "Ɨ̧": "I",
1331 "ɨ̧": "i",
1332 "M̧": "M",
1333 "m̧": "m",
1334 "O̧": "O",
1335 "o̧": "o",
1336 "Q̧": "Q",
1337 "q̧": "q",
1338 "U̧": "U",
1339 "u̧": "u",
1340 "X̧": "X",
1341 "x̧": "x",
1342 "Z̧": "Z",
1343 "z̧": "z",
1344 "й":"и",
1345 "Й":"И",
1346 "ё":"е",
1347 "Ё":"Е",
1348 };
1349
1350 var chars = Object.keys(characterMap).join('|');
1351 var allAccents = new RegExp(chars, 'g');
1352 var firstAccent = new RegExp(chars, '');
1353
1354 function matcher(match) {
1355 return characterMap[match];
1356 }
1357
1358 var removeAccents = function(string) {
1359 return string.replace(allAccents, matcher);
1360 };
1361
1362 var hasAccents = function(string) {
1363 return !!string.match(firstAccent);
1364 };
1365
1366 module.exports = removeAccents;
1367 module.exports.has = hasAccents;
1368 module.exports.remove = removeAccents;
1369
1370
1371 /***/ }),
1372
1373 /***/ 9196:
1374 /***/ ((module) => {
1375
1376 "use strict";
1377 module.exports = window["React"];
1378
1379 /***/ })
1380
1381 /******/ });
1382 /************************************************************************/
1383 /******/ // The module cache
1384 /******/ var __webpack_module_cache__ = {};
1385 /******/
1386 /******/ // The require function
1387 /******/ function __webpack_require__(moduleId) {
1388 /******/ // Check if module is in cache
1389 /******/ var cachedModule = __webpack_module_cache__[moduleId];
1390 /******/ if (cachedModule !== undefined) {
1391 /******/ return cachedModule.exports;
1392 /******/ }
1393 /******/ // Create a new module (and put it into the cache)
1394 /******/ var module = __webpack_module_cache__[moduleId] = {
1395 /******/ // no module.id needed
1396 /******/ // no module.loaded needed
1397 /******/ exports: {}
1398 /******/ };
1399 /******/
1400 /******/ // Execute the module function
1401 /******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
1402 /******/
1403 /******/ // Return the exports of the module
1404 /******/ return module.exports;
1405 /******/ }
1406 /******/
1407 /************************************************************************/
1408 /******/ /* webpack/runtime/compat get default export */
1409 /******/ (() => {
1410 /******/ // getDefaultExport function for compatibility with non-harmony modules
1411 /******/ __webpack_require__.n = (module) => {
1412 /******/ var getter = module && module.__esModule ?
1413 /******/ () => (module['default']) :
1414 /******/ () => (module);
1415 /******/ __webpack_require__.d(getter, { a: getter });
1416 /******/ return getter;
1417 /******/ };
1418 /******/ })();
1419 /******/
1420 /******/ /* webpack/runtime/define property getters */
1421 /******/ (() => {
1422 /******/ // define getter functions for harmony exports
1423 /******/ __webpack_require__.d = (exports, definition) => {
1424 /******/ for(var key in definition) {
1425 /******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
1426 /******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
1427 /******/ }
1428 /******/ }
1429 /******/ };
1430 /******/ })();
1431 /******/
1432 /******/ /* webpack/runtime/hasOwnProperty shorthand */
1433 /******/ (() => {
1434 /******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
1435 /******/ })();
1436 /******/
1437 /******/ /* webpack/runtime/make namespace object */
1438 /******/ (() => {
1439 /******/ // define __esModule on exports
1440 /******/ __webpack_require__.r = (exports) => {
1441 /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
1442 /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1443 /******/ }
1444 /******/ Object.defineProperty(exports, '__esModule', { value: true });
1445 /******/ };
1446 /******/ })();
1447 /******/
1448 /************************************************************************/
1449 var __webpack_exports__ = {};
1450 // This entry need to be wrapped in an IIFE because it need to be in strict mode.
1451 (() => {
1452 "use strict";
1453 // ESM COMPAT FLAG
1454 __webpack_require__.r(__webpack_exports__);
1455
1456 // EXPORTS
1457 __webpack_require__.d(__webpack_exports__, {
1458 AlignmentToolbar: () => (/* reexport */ AlignmentToolbar),
1459 Autocomplete: () => (/* reexport */ Autocomplete),
1460 AutosaveMonitor: () => (/* reexport */ autosave_monitor),
1461 BlockAlignmentToolbar: () => (/* reexport */ BlockAlignmentToolbar),
1462 BlockControls: () => (/* reexport */ BlockControls),
1463 BlockEdit: () => (/* reexport */ BlockEdit),
1464 BlockEditorKeyboardShortcuts: () => (/* reexport */ BlockEditorKeyboardShortcuts),
1465 BlockFormatControls: () => (/* reexport */ BlockFormatControls),
1466 BlockIcon: () => (/* reexport */ BlockIcon),
1467 BlockInspector: () => (/* reexport */ BlockInspector),
1468 BlockList: () => (/* reexport */ BlockList),
1469 BlockMover: () => (/* reexport */ BlockMover),
1470 BlockNavigationDropdown: () => (/* reexport */ BlockNavigationDropdown),
1471 BlockSelectionClearer: () => (/* reexport */ BlockSelectionClearer),
1472 BlockSettingsMenu: () => (/* reexport */ BlockSettingsMenu),
1473 BlockTitle: () => (/* reexport */ BlockTitle),
1474 BlockToolbar: () => (/* reexport */ BlockToolbar),
1475 CharacterCount: () => (/* reexport */ CharacterCount),
1476 ColorPalette: () => (/* reexport */ ColorPalette),
1477 ContrastChecker: () => (/* reexport */ ContrastChecker),
1478 CopyHandler: () => (/* reexport */ CopyHandler),
1479 DefaultBlockAppender: () => (/* reexport */ DefaultBlockAppender),
1480 DocumentBar: () => (/* reexport */ DocumentBar),
1481 DocumentOutline: () => (/* reexport */ DocumentOutline),
1482 DocumentOutlineCheck: () => (/* reexport */ DocumentOutlineCheck),
1483 EditorHistoryRedo: () => (/* reexport */ editor_history_redo),
1484 EditorHistoryUndo: () => (/* reexport */ editor_history_undo),
1485 EditorKeyboardShortcuts: () => (/* reexport */ EditorKeyboardShortcuts),
1486 EditorKeyboardShortcutsRegister: () => (/* reexport */ register_shortcuts),
1487 EditorNotices: () => (/* reexport */ editor_notices),
1488 EditorProvider: () => (/* reexport */ provider),
1489 EditorSnackbars: () => (/* reexport */ EditorSnackbars),
1490 EntitiesSavedStates: () => (/* reexport */ EntitiesSavedStates),
1491 ErrorBoundary: () => (/* reexport */ error_boundary),
1492 FontSizePicker: () => (/* reexport */ FontSizePicker),
1493 InnerBlocks: () => (/* reexport */ InnerBlocks),
1494 Inserter: () => (/* reexport */ Inserter),
1495 InspectorAdvancedControls: () => (/* reexport */ InspectorAdvancedControls),
1496 InspectorControls: () => (/* reexport */ InspectorControls),
1497 LocalAutosaveMonitor: () => (/* reexport */ local_autosave_monitor),
1498 MediaPlaceholder: () => (/* reexport */ MediaPlaceholder),
1499 MediaUpload: () => (/* reexport */ MediaUpload),
1500 MediaUploadCheck: () => (/* reexport */ MediaUploadCheck),
1501 MultiSelectScrollIntoView: () => (/* reexport */ MultiSelectScrollIntoView),
1502 NavigableToolbar: () => (/* reexport */ NavigableToolbar),
1503 ObserveTyping: () => (/* reexport */ ObserveTyping),
1504 PageAttributesCheck: () => (/* reexport */ page_attributes_check),
1505 PageAttributesOrder: () => (/* reexport */ PageAttributesOrderWithChecks),
1506 PageAttributesPanel: () => (/* reexport */ PageAttributesPanel),
1507 PageAttributesParent: () => (/* reexport */ page_attributes_parent),
1508 PageTemplate: () => (/* reexport */ classic_theme),
1509 PanelColorSettings: () => (/* reexport */ PanelColorSettings),
1510 PlainText: () => (/* reexport */ PlainText),
1511 PluginBlockSettingsMenuItem: () => (/* reexport */ plugin_block_settings_menu_item),
1512 PluginDocumentSettingPanel: () => (/* reexport */ plugin_document_setting_panel),
1513 PluginMoreMenuItem: () => (/* reexport */ plugin_more_menu_item),
1514 PluginPostPublishPanel: () => (/* reexport */ plugin_post_publish_panel),
1515 PluginPostStatusInfo: () => (/* reexport */ plugin_post_status_info),
1516 PluginPrePublishPanel: () => (/* reexport */ plugin_pre_publish_panel),
1517 PluginSidebar: () => (/* reexport */ PluginSidebar),
1518 PluginSidebarMoreMenuItem: () => (/* reexport */ PluginSidebarMoreMenuItem),
1519 PostAuthor: () => (/* reexport */ post_author),
1520 PostAuthorCheck: () => (/* reexport */ PostAuthorCheck),
1521 PostAuthorPanel: () => (/* reexport */ panel),
1522 PostComments: () => (/* reexport */ post_comments),
1523 PostDiscussionPanel: () => (/* reexport */ PostDiscussionPanel),
1524 PostExcerpt: () => (/* reexport */ PostExcerpt),
1525 PostExcerptCheck: () => (/* reexport */ post_excerpt_check),
1526 PostExcerptPanel: () => (/* reexport */ PostExcerptPanel),
1527 PostFeaturedImage: () => (/* reexport */ post_featured_image),
1528 PostFeaturedImageCheck: () => (/* reexport */ post_featured_image_check),
1529 PostFeaturedImagePanel: () => (/* reexport */ PostFeaturedImagePanel),
1530 PostFormat: () => (/* reexport */ PostFormat),
1531 PostFormatCheck: () => (/* reexport */ post_format_check),
1532 PostLastRevision: () => (/* reexport */ post_last_revision),
1533 PostLastRevisionCheck: () => (/* reexport */ post_last_revision_check),
1534 PostLastRevisionPanel: () => (/* reexport */ post_last_revision_panel),
1535 PostLockedModal: () => (/* reexport */ PostLockedModal),
1536 PostPendingStatus: () => (/* reexport */ post_pending_status),
1537 PostPendingStatusCheck: () => (/* reexport */ post_pending_status_check),
1538 PostPingbacks: () => (/* reexport */ post_pingbacks),
1539 PostPreviewButton: () => (/* reexport */ PostPreviewButton),
1540 PostPublishButton: () => (/* reexport */ post_publish_button),
1541 PostPublishButtonLabel: () => (/* reexport */ PublishButtonLabel),
1542 PostPublishPanel: () => (/* reexport */ post_publish_panel),
1543 PostSavedState: () => (/* reexport */ PostSavedState),
1544 PostSchedule: () => (/* reexport */ PostSchedule),
1545 PostScheduleCheck: () => (/* reexport */ PostScheduleCheck),
1546 PostScheduleLabel: () => (/* reexport */ PostScheduleLabel),
1547 PostSchedulePanel: () => (/* reexport */ PostSchedulePanel),
1548 PostSlug: () => (/* reexport */ PostSlug),
1549 PostSlugCheck: () => (/* reexport */ PostSlugCheck),
1550 PostSticky: () => (/* reexport */ PostSticky),
1551 PostStickyCheck: () => (/* reexport */ PostStickyCheck),
1552 PostSwitchToDraftButton: () => (/* reexport */ PostSwitchToDraftButton),
1553 PostSyncStatus: () => (/* reexport */ PostSyncStatus),
1554 PostTaxonomies: () => (/* reexport */ post_taxonomies),
1555 PostTaxonomiesCheck: () => (/* reexport */ PostTaxonomiesCheck),
1556 PostTaxonomiesFlatTermSelector: () => (/* reexport */ FlatTermSelector),
1557 PostTaxonomiesHierarchicalTermSelector: () => (/* reexport */ HierarchicalTermSelector),
1558 PostTaxonomiesPanel: () => (/* reexport */ post_taxonomies_panel),
1559 PostTemplatePanel: () => (/* reexport */ PostTemplatePanel),
1560 PostTextEditor: () => (/* reexport */ PostTextEditor),
1561 PostTitle: () => (/* reexport */ post_title),
1562 PostTitleRaw: () => (/* reexport */ post_title_raw),
1563 PostTrash: () => (/* reexport */ PostTrash),
1564 PostTrashCheck: () => (/* reexport */ PostTrashCheck),
1565 PostTypeSupportCheck: () => (/* reexport */ post_type_support_check),
1566 PostURL: () => (/* reexport */ PostURL),
1567 PostURLCheck: () => (/* reexport */ PostURLCheck),
1568 PostURLLabel: () => (/* reexport */ PostURLLabel),
1569 PostURLPanel: () => (/* reexport */ PostURLPanel),
1570 PostVisibility: () => (/* reexport */ PostVisibility),
1571 PostVisibilityCheck: () => (/* reexport */ PostVisibilityCheck),
1572 PostVisibilityLabel: () => (/* reexport */ PostVisibilityLabel),
1573 RichText: () => (/* reexport */ RichText),
1574 RichTextShortcut: () => (/* reexport */ RichTextShortcut),
1575 RichTextToolbarButton: () => (/* reexport */ RichTextToolbarButton),
1576 ServerSideRender: () => (/* reexport */ (external_wp_serverSideRender_default())),
1577 SkipToSelectedBlock: () => (/* reexport */ SkipToSelectedBlock),
1578 TableOfContents: () => (/* reexport */ table_of_contents),
1579 TextEditorGlobalKeyboardShortcuts: () => (/* reexport */ TextEditorGlobalKeyboardShortcuts),
1580 ThemeSupportCheck: () => (/* reexport */ ThemeSupportCheck),
1581 TimeToRead: () => (/* reexport */ TimeToRead),
1582 URLInput: () => (/* reexport */ URLInput),
1583 URLInputButton: () => (/* reexport */ URLInputButton),
1584 URLPopover: () => (/* reexport */ URLPopover),
1585 UnsavedChangesWarning: () => (/* reexport */ UnsavedChangesWarning),
1586 VisualEditorGlobalKeyboardShortcuts: () => (/* reexport */ VisualEditorGlobalKeyboardShortcuts),
1587 Warning: () => (/* reexport */ Warning),
1588 WordCount: () => (/* reexport */ WordCount),
1589 WritingFlow: () => (/* reexport */ WritingFlow),
1590 __unstableRichTextInputEvent: () => (/* reexport */ __unstableRichTextInputEvent),
1591 cleanForSlug: () => (/* reexport */ cleanForSlug),
1592 createCustomColorsHOC: () => (/* reexport */ createCustomColorsHOC),
1593 getColorClassName: () => (/* reexport */ getColorClassName),
1594 getColorObjectByAttributeValues: () => (/* reexport */ getColorObjectByAttributeValues),
1595 getColorObjectByColorValue: () => (/* reexport */ getColorObjectByColorValue),
1596 getFontSize: () => (/* reexport */ getFontSize),
1597 getFontSizeClass: () => (/* reexport */ getFontSizeClass),
1598 getTemplatePartIcon: () => (/* reexport */ getTemplatePartIcon),
1599 mediaUpload: () => (/* reexport */ mediaUpload),
1600 privateApis: () => (/* reexport */ privateApis),
1601 store: () => (/* reexport */ store_store),
1602 storeConfig: () => (/* reexport */ storeConfig),
1603 transformStyles: () => (/* reexport */ external_wp_blockEditor_namespaceObject.transformStyles),
1604 useEntitiesSavedStatesIsDirty: () => (/* reexport */ useIsDirty),
1605 usePostScheduleLabel: () => (/* reexport */ usePostScheduleLabel),
1606 usePostURLLabel: () => (/* reexport */ usePostURLLabel),
1607 usePostVisibilityLabel: () => (/* reexport */ usePostVisibilityLabel),
1608 userAutocompleter: () => (/* reexport */ user),
1609 withColorContext: () => (/* reexport */ withColorContext),
1610 withColors: () => (/* reexport */ withColors),
1611 withFontSizes: () => (/* reexport */ withFontSizes)
1612 });
1613
1614 // NAMESPACE OBJECT: ./packages/editor/build-module/store/selectors.js
1615 var selectors_namespaceObject = {};
1616 __webpack_require__.r(selectors_namespaceObject);
1617 __webpack_require__.d(selectors_namespaceObject, {
1618 __experimentalGetDefaultTemplatePartAreas: () => (__experimentalGetDefaultTemplatePartAreas),
1619 __experimentalGetDefaultTemplateType: () => (__experimentalGetDefaultTemplateType),
1620 __experimentalGetDefaultTemplateTypes: () => (__experimentalGetDefaultTemplateTypes),
1621 __experimentalGetTemplateInfo: () => (__experimentalGetTemplateInfo),
1622 __unstableIsEditorReady: () => (__unstableIsEditorReady),
1623 canInsertBlockType: () => (canInsertBlockType),
1624 canUserUseUnfilteredHTML: () => (canUserUseUnfilteredHTML),
1625 didPostSaveRequestFail: () => (didPostSaveRequestFail),
1626 didPostSaveRequestSucceed: () => (didPostSaveRequestSucceed),
1627 getActivePostLock: () => (getActivePostLock),
1628 getAdjacentBlockClientId: () => (getAdjacentBlockClientId),
1629 getAutosaveAttribute: () => (getAutosaveAttribute),
1630 getBlock: () => (getBlock),
1631 getBlockAttributes: () => (getBlockAttributes),
1632 getBlockCount: () => (getBlockCount),
1633 getBlockHierarchyRootClientId: () => (getBlockHierarchyRootClientId),
1634 getBlockIndex: () => (getBlockIndex),
1635 getBlockInsertionPoint: () => (getBlockInsertionPoint),
1636 getBlockListSettings: () => (getBlockListSettings),
1637 getBlockMode: () => (getBlockMode),
1638 getBlockName: () => (getBlockName),
1639 getBlockOrder: () => (getBlockOrder),
1640 getBlockRootClientId: () => (getBlockRootClientId),
1641 getBlockSelectionEnd: () => (getBlockSelectionEnd),
1642 getBlockSelectionStart: () => (getBlockSelectionStart),
1643 getBlocks: () => (getBlocks),
1644 getBlocksByClientId: () => (getBlocksByClientId),
1645 getClientIdsOfDescendants: () => (getClientIdsOfDescendants),
1646 getClientIdsWithDescendants: () => (getClientIdsWithDescendants),
1647 getCurrentPost: () => (getCurrentPost),
1648 getCurrentPostAttribute: () => (getCurrentPostAttribute),
1649 getCurrentPostId: () => (getCurrentPostId),
1650 getCurrentPostLastRevisionId: () => (getCurrentPostLastRevisionId),
1651 getCurrentPostRevisionsCount: () => (getCurrentPostRevisionsCount),
1652 getCurrentPostType: () => (getCurrentPostType),
1653 getCurrentTemplateId: () => (getCurrentTemplateId),
1654 getDeviceType: () => (getDeviceType),
1655 getEditedPostAttribute: () => (getEditedPostAttribute),
1656 getEditedPostContent: () => (getEditedPostContent),
1657 getEditedPostPreviewLink: () => (getEditedPostPreviewLink),
1658 getEditedPostSlug: () => (getEditedPostSlug),
1659 getEditedPostVisibility: () => (getEditedPostVisibility),
1660 getEditorBlocks: () => (getEditorBlocks),
1661 getEditorMode: () => (getEditorMode),
1662 getEditorSelection: () => (getEditorSelection),
1663 getEditorSelectionEnd: () => (getEditorSelectionEnd),
1664 getEditorSelectionStart: () => (getEditorSelectionStart),
1665 getEditorSettings: () => (getEditorSettings),
1666 getFirstMultiSelectedBlockClientId: () => (getFirstMultiSelectedBlockClientId),
1667 getGlobalBlockCount: () => (getGlobalBlockCount),
1668 getInserterItems: () => (getInserterItems),
1669 getLastMultiSelectedBlockClientId: () => (getLastMultiSelectedBlockClientId),
1670 getMultiSelectedBlockClientIds: () => (getMultiSelectedBlockClientIds),
1671 getMultiSelectedBlocks: () => (getMultiSelectedBlocks),
1672 getMultiSelectedBlocksEndClientId: () => (getMultiSelectedBlocksEndClientId),
1673 getMultiSelectedBlocksStartClientId: () => (getMultiSelectedBlocksStartClientId),
1674 getNextBlockClientId: () => (getNextBlockClientId),
1675 getPermalink: () => (getPermalink),
1676 getPermalinkParts: () => (getPermalinkParts),
1677 getPostEdits: () => (getPostEdits),
1678 getPostLockUser: () => (getPostLockUser),
1679 getPostTypeLabel: () => (getPostTypeLabel),
1680 getPreviousBlockClientId: () => (getPreviousBlockClientId),
1681 getRenderingMode: () => (getRenderingMode),
1682 getSelectedBlock: () => (getSelectedBlock),
1683 getSelectedBlockClientId: () => (getSelectedBlockClientId),
1684 getSelectedBlockCount: () => (getSelectedBlockCount),
1685 getSelectedBlocksInitialCaretPosition: () => (getSelectedBlocksInitialCaretPosition),
1686 getStateBeforeOptimisticTransaction: () => (getStateBeforeOptimisticTransaction),
1687 getSuggestedPostFormat: () => (getSuggestedPostFormat),
1688 getTemplate: () => (getTemplate),
1689 getTemplateLock: () => (getTemplateLock),
1690 hasChangedContent: () => (hasChangedContent),
1691 hasEditorRedo: () => (hasEditorRedo),
1692 hasEditorUndo: () => (hasEditorUndo),
1693 hasInserterItems: () => (hasInserterItems),
1694 hasMultiSelection: () => (hasMultiSelection),
1695 hasNonPostEntityChanges: () => (hasNonPostEntityChanges),
1696 hasSelectedBlock: () => (hasSelectedBlock),
1697 hasSelectedInnerBlock: () => (hasSelectedInnerBlock),
1698 inSomeHistory: () => (inSomeHistory),
1699 isAncestorMultiSelected: () => (isAncestorMultiSelected),
1700 isAutosavingPost: () => (isAutosavingPost),
1701 isBlockInsertionPointVisible: () => (isBlockInsertionPointVisible),
1702 isBlockMultiSelected: () => (isBlockMultiSelected),
1703 isBlockSelected: () => (isBlockSelected),
1704 isBlockValid: () => (isBlockValid),
1705 isBlockWithinSelection: () => (isBlockWithinSelection),
1706 isCaretWithinFormattedText: () => (isCaretWithinFormattedText),
1707 isCleanNewPost: () => (isCleanNewPost),
1708 isCurrentPostPending: () => (isCurrentPostPending),
1709 isCurrentPostPublished: () => (isCurrentPostPublished),
1710 isCurrentPostScheduled: () => (isCurrentPostScheduled),
1711 isDeletingPost: () => (isDeletingPost),
1712 isEditedPostAutosaveable: () => (isEditedPostAutosaveable),
1713 isEditedPostBeingScheduled: () => (isEditedPostBeingScheduled),
1714 isEditedPostDateFloating: () => (isEditedPostDateFloating),
1715 isEditedPostDirty: () => (isEditedPostDirty),
1716 isEditedPostEmpty: () => (isEditedPostEmpty),
1717 isEditedPostNew: () => (isEditedPostNew),
1718 isEditedPostPublishable: () => (isEditedPostPublishable),
1719 isEditedPostSaveable: () => (isEditedPostSaveable),
1720 isEditorPanelEnabled: () => (isEditorPanelEnabled),
1721 isEditorPanelOpened: () => (isEditorPanelOpened),
1722 isEditorPanelRemoved: () => (isEditorPanelRemoved),
1723 isFirstMultiSelectedBlock: () => (isFirstMultiSelectedBlock),
1724 isInserterOpened: () => (isInserterOpened),
1725 isListViewOpened: () => (isListViewOpened),
1726 isMultiSelecting: () => (isMultiSelecting),
1727 isPermalinkEditable: () => (isPermalinkEditable),
1728 isPostAutosavingLocked: () => (isPostAutosavingLocked),
1729 isPostLockTakeover: () => (isPostLockTakeover),
1730 isPostLocked: () => (isPostLocked),
1731 isPostSavingLocked: () => (isPostSavingLocked),
1732 isPreviewingPost: () => (isPreviewingPost),
1733 isPublishSidebarEnabled: () => (isPublishSidebarEnabled),
1734 isPublishSidebarOpened: () => (isPublishSidebarOpened),
1735 isPublishingPost: () => (isPublishingPost),
1736 isSavingNonPostEntityChanges: () => (isSavingNonPostEntityChanges),
1737 isSavingPost: () => (isSavingPost),
1738 isSelectionEnabled: () => (isSelectionEnabled),
1739 isTyping: () => (isTyping),
1740 isValidTemplate: () => (isValidTemplate)
1741 });
1742
1743 // NAMESPACE OBJECT: ./packages/editor/build-module/store/actions.js
1744 var actions_namespaceObject = {};
1745 __webpack_require__.r(actions_namespaceObject);
1746 __webpack_require__.d(actions_namespaceObject, {
1747 __experimentalTearDownEditor: () => (__experimentalTearDownEditor),
1748 __unstableSaveForPreview: () => (__unstableSaveForPreview),
1749 autosave: () => (autosave),
1750 clearSelectedBlock: () => (clearSelectedBlock),
1751 closePublishSidebar: () => (closePublishSidebar),
1752 createUndoLevel: () => (createUndoLevel),
1753 disablePublishSidebar: () => (disablePublishSidebar),
1754 editPost: () => (editPost),
1755 enablePublishSidebar: () => (enablePublishSidebar),
1756 enterFormattedText: () => (enterFormattedText),
1757 exitFormattedText: () => (exitFormattedText),
1758 hideInsertionPoint: () => (hideInsertionPoint),
1759 insertBlock: () => (insertBlock),
1760 insertBlocks: () => (insertBlocks),
1761 insertDefaultBlock: () => (insertDefaultBlock),
1762 lockPostAutosaving: () => (lockPostAutosaving),
1763 lockPostSaving: () => (lockPostSaving),
1764 mergeBlocks: () => (mergeBlocks),
1765 moveBlockToPosition: () => (moveBlockToPosition),
1766 moveBlocksDown: () => (moveBlocksDown),
1767 moveBlocksUp: () => (moveBlocksUp),
1768 multiSelect: () => (multiSelect),
1769 openPublishSidebar: () => (openPublishSidebar),
1770 receiveBlocks: () => (receiveBlocks),
1771 redo: () => (redo),
1772 refreshPost: () => (refreshPost),
1773 removeBlock: () => (removeBlock),
1774 removeBlocks: () => (removeBlocks),
1775 removeEditorPanel: () => (removeEditorPanel),
1776 replaceBlock: () => (replaceBlock),
1777 replaceBlocks: () => (replaceBlocks),
1778 resetBlocks: () => (resetBlocks),
1779 resetEditorBlocks: () => (resetEditorBlocks),
1780 resetPost: () => (resetPost),
1781 savePost: () => (savePost),
1782 selectBlock: () => (selectBlock),
1783 setDeviceType: () => (setDeviceType),
1784 setEditedPost: () => (setEditedPost),
1785 setIsInserterOpened: () => (setIsInserterOpened),
1786 setIsListViewOpened: () => (setIsListViewOpened),
1787 setRenderingMode: () => (setRenderingMode),
1788 setTemplateValidity: () => (setTemplateValidity),
1789 setupEditor: () => (setupEditor),
1790 setupEditorState: () => (setupEditorState),
1791 showInsertionPoint: () => (showInsertionPoint),
1792 startMultiSelect: () => (startMultiSelect),
1793 startTyping: () => (startTyping),
1794 stopMultiSelect: () => (stopMultiSelect),
1795 stopTyping: () => (stopTyping),
1796 switchEditorMode: () => (switchEditorMode),
1797 synchronizeTemplate: () => (synchronizeTemplate),
1798 toggleBlockMode: () => (toggleBlockMode),
1799 toggleDistractionFree: () => (toggleDistractionFree),
1800 toggleEditorPanelEnabled: () => (toggleEditorPanelEnabled),
1801 toggleEditorPanelOpened: () => (toggleEditorPanelOpened),
1802 togglePublishSidebar: () => (togglePublishSidebar),
1803 toggleSelection: () => (toggleSelection),
1804 trashPost: () => (trashPost),
1805 undo: () => (undo),
1806 unlockPostAutosaving: () => (unlockPostAutosaving),
1807 unlockPostSaving: () => (unlockPostSaving),
1808 updateBlock: () => (updateBlock),
1809 updateBlockAttributes: () => (updateBlockAttributes),
1810 updateBlockListSettings: () => (updateBlockListSettings),
1811 updateEditorSettings: () => (updateEditorSettings),
1812 updatePost: () => (updatePost),
1813 updatePostLock: () => (updatePostLock)
1814 });
1815
1816 // NAMESPACE OBJECT: ./packages/editor/build-module/store/private-actions.js
1817 var private_actions_namespaceObject = {};
1818 __webpack_require__.r(private_actions_namespaceObject);
1819 __webpack_require__.d(private_actions_namespaceObject, {
1820 createTemplate: () => (createTemplate),
1821 hideBlockTypes: () => (hideBlockTypes),
1822 removeTemplates: () => (removeTemplates),
1823 revertTemplate: () => (revertTemplate),
1824 saveDirtyEntities: () => (saveDirtyEntities),
1825 setCurrentTemplateId: () => (setCurrentTemplateId),
1826 showBlockTypes: () => (showBlockTypes)
1827 });
1828
1829 // NAMESPACE OBJECT: ./packages/editor/build-module/store/private-selectors.js
1830 var private_selectors_namespaceObject = {};
1831 __webpack_require__.r(private_selectors_namespaceObject);
1832 __webpack_require__.d(private_selectors_namespaceObject, {
1833 getCurrentTemplateTemplateParts: () => (getCurrentTemplateTemplateParts),
1834 getInserterSidebarToggleRef: () => (getInserterSidebarToggleRef),
1835 getInsertionPoint: () => (getInsertionPoint),
1836 getListViewToggleRef: () => (getListViewToggleRef),
1837 getPostIcon: () => (getPostIcon),
1838 hasPostMetaChanges: () => (hasPostMetaChanges)
1839 });
1840
1841 // NAMESPACE OBJECT: ./packages/interface/build-module/store/actions.js
1842 var store_actions_namespaceObject = {};
1843 __webpack_require__.r(store_actions_namespaceObject);
1844 __webpack_require__.d(store_actions_namespaceObject, {
1845 closeModal: () => (closeModal),
1846 disableComplementaryArea: () => (disableComplementaryArea),
1847 enableComplementaryArea: () => (enableComplementaryArea),
1848 openModal: () => (openModal),
1849 pinItem: () => (pinItem),
1850 setDefaultComplementaryArea: () => (setDefaultComplementaryArea),
1851 setFeatureDefaults: () => (setFeatureDefaults),
1852 setFeatureValue: () => (setFeatureValue),
1853 toggleFeature: () => (toggleFeature),
1854 unpinItem: () => (unpinItem)
1855 });
1856
1857 // NAMESPACE OBJECT: ./packages/interface/build-module/store/selectors.js
1858 var store_selectors_namespaceObject = {};
1859 __webpack_require__.r(store_selectors_namespaceObject);
1860 __webpack_require__.d(store_selectors_namespaceObject, {
1861 getActiveComplementaryArea: () => (getActiveComplementaryArea),
1862 isComplementaryAreaLoading: () => (isComplementaryAreaLoading),
1863 isFeatureActive: () => (isFeatureActive),
1864 isItemPinned: () => (isItemPinned),
1865 isModalActive: () => (isModalActive)
1866 });
1867
1868 // NAMESPACE OBJECT: ./packages/interface/build-module/index.js
1869 var build_module_namespaceObject = {};
1870 __webpack_require__.r(build_module_namespaceObject);
1871 __webpack_require__.d(build_module_namespaceObject, {
1872 ActionItem: () => (action_item),
1873 ComplementaryArea: () => (complementary_area),
1874 ComplementaryAreaMoreMenuItem: () => (ComplementaryAreaMoreMenuItem),
1875 FullscreenMode: () => (fullscreen_mode),
1876 InterfaceSkeleton: () => (interface_skeleton),
1877 NavigableRegion: () => (NavigableRegion),
1878 PinnedItems: () => (pinned_items),
1879 store: () => (store)
1880 });
1881
1882 ;// CONCATENATED MODULE: external ["wp","blocks"]
1883 const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
1884 ;// CONCATENATED MODULE: external ["wp","data"]
1885 const external_wp_data_namespaceObject = window["wp"]["data"];
1886 ;// CONCATENATED MODULE: external ["wp","privateApis"]
1887 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
1888 ;// CONCATENATED MODULE: ./packages/editor/build-module/lock-unlock.js
1889 /**
1890 * WordPress dependencies
1891 */
1892
1893 const {
1894 lock,
1895 unlock
1896 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I know using unstable features means my theme or plugin will inevitably break in the next version of WordPress.', '@wordpress/editor');
1897
1898 ;// CONCATENATED MODULE: external ["wp","i18n"]
1899 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
1900 ;// CONCATENATED MODULE: external ["wp","blockEditor"]
1901 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
1902 ;// CONCATENATED MODULE: ./packages/editor/build-module/bindings/pattern-overrides.js
1903 /**
1904 * WordPress dependencies
1905 */
1906
1907
1908 const CONTENT = 'content';
1909 /* harmony default export */ const pattern_overrides = ({
1910 name: 'core/pattern-overrides',
1911 label: (0,external_wp_i18n_namespaceObject._x)('Pattern Overrides', 'block bindings source'),
1912 getValue({
1913 registry,
1914 clientId,
1915 attributeName
1916 }) {
1917 const {
1918 getBlockAttributes,
1919 getBlockParentsByBlockName
1920 } = registry.select(external_wp_blockEditor_namespaceObject.store);
1921 const currentBlockAttributes = getBlockAttributes(clientId);
1922 const [patternClientId] = getBlockParentsByBlockName(clientId, 'core/block', true);
1923 const overridableValue = getBlockAttributes(patternClientId)?.[CONTENT]?.[currentBlockAttributes?.metadata?.name]?.[attributeName];
1924
1925 // If there is no pattern client ID, or it is not overwritten, return the default value.
1926 if (!patternClientId || overridableValue === undefined) {
1927 return currentBlockAttributes[attributeName];
1928 }
1929 return overridableValue === '' ? undefined : overridableValue;
1930 },
1931 setValues({
1932 registry,
1933 clientId,
1934 attributes
1935 }) {
1936 const {
1937 getBlockAttributes,
1938 getBlockParentsByBlockName,
1939 getBlocks
1940 } = registry.select(external_wp_blockEditor_namespaceObject.store);
1941 const currentBlockAttributes = getBlockAttributes(clientId);
1942 const blockName = currentBlockAttributes?.metadata?.name;
1943 if (!blockName) {
1944 return;
1945 }
1946 const [patternClientId] = getBlockParentsByBlockName(clientId, 'core/block', true);
1947
1948 // If there is no pattern client ID, sync blocks with the same name and same attributes.
1949 if (!patternClientId) {
1950 const syncBlocksWithSameName = blocks => {
1951 for (const block of blocks) {
1952 if (block.attributes?.metadata?.name === blockName) {
1953 registry.dispatch(external_wp_blockEditor_namespaceObject.store).updateBlockAttributes(block.clientId, attributes);
1954 }
1955 syncBlocksWithSameName(block.innerBlocks);
1956 }
1957 };
1958 syncBlocksWithSameName(getBlocks());
1959 return;
1960 }
1961 const currentBindingValue = getBlockAttributes(patternClientId)?.[CONTENT];
1962 registry.dispatch(external_wp_blockEditor_namespaceObject.store).updateBlockAttributes(patternClientId, {
1963 [CONTENT]: {
1964 ...currentBindingValue,
1965 [blockName]: {
1966 ...currentBindingValue?.[blockName],
1967 ...Object.entries(attributes).reduce((acc, [key, value]) => {
1968 // TODO: We need a way to represent `undefined` in the serialized overrides.
1969 // Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871
1970 // We use an empty string to represent undefined for now until
1971 // we support a richer format for overrides and the block bindings API.
1972 acc[key] = value === undefined ? '' : value;
1973 return acc;
1974 }, {})
1975 }
1976 }
1977 });
1978 },
1979 canUserEditValue: () => true
1980 });
1981
1982 ;// CONCATENATED MODULE: external ["wp","coreData"]
1983 const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
1984 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/defaults.js
1985 /**
1986 * WordPress dependencies
1987 */
1988
1989
1990 /**
1991 * The default post editor settings.
1992 *
1993 * @property {boolean|Array} allowedBlockTypes Allowed block types
1994 * @property {boolean} richEditingEnabled Whether rich editing is enabled or not
1995 * @property {boolean} codeEditingEnabled Whether code editing is enabled or not
1996 * @property {boolean} fontLibraryEnabled Whether the font library is enabled or not.
1997 * @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.
1998 * true = the user has opted to show the Custom Fields panel at the bottom of the editor.
1999 * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
2000 * 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.
2001 * @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API.
2002 * @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage.
2003 * @property {Array?} availableTemplates The available post templates
2004 * @property {boolean} disablePostFormats Whether or not the post formats are disabled
2005 * @property {Array?} allowedMimeTypes List of allowed mime types and file extensions
2006 * @property {number} maxUploadFileSize Maximum upload file size
2007 * @property {boolean} supportsLayout Whether the editor supports layouts.
2008 */
2009 const EDITOR_SETTINGS_DEFAULTS = {
2010 ...external_wp_blockEditor_namespaceObject.SETTINGS_DEFAULTS,
2011 richEditingEnabled: true,
2012 codeEditingEnabled: true,
2013 fontLibraryEnabled: true,
2014 enableCustomFields: undefined,
2015 defaultRenderingMode: 'post-only'
2016 };
2017
2018 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/reducer.js
2019 /**
2020 * WordPress dependencies
2021 */
2022
2023
2024 /**
2025 * Internal dependencies
2026 */
2027
2028
2029 /**
2030 * Returns a post attribute value, flattening nested rendered content using its
2031 * raw value in place of its original object form.
2032 *
2033 * @param {*} value Original value.
2034 *
2035 * @return {*} Raw value.
2036 */
2037 function getPostRawValue(value) {
2038 if (value && 'object' === typeof value && 'raw' in value) {
2039 return value.raw;
2040 }
2041 return value;
2042 }
2043
2044 /**
2045 * Returns true if the two object arguments have the same keys, or false
2046 * otherwise.
2047 *
2048 * @param {Object} a First object.
2049 * @param {Object} b Second object.
2050 *
2051 * @return {boolean} Whether the two objects have the same keys.
2052 */
2053 function hasSameKeys(a, b) {
2054 const keysA = Object.keys(a).sort();
2055 const keysB = Object.keys(b).sort();
2056 return keysA.length === keysB.length && keysA.every((key, index) => keysB[index] === key);
2057 }
2058
2059 /**
2060 * Returns true if, given the currently dispatching action and the previously
2061 * dispatched action, the two actions are editing the same post property, or
2062 * false otherwise.
2063 *
2064 * @param {Object} action Currently dispatching action.
2065 * @param {Object} previousAction Previously dispatched action.
2066 *
2067 * @return {boolean} Whether actions are updating the same post property.
2068 */
2069 function isUpdatingSamePostProperty(action, previousAction) {
2070 return action.type === 'EDIT_POST' && hasSameKeys(action.edits, previousAction.edits);
2071 }
2072
2073 /**
2074 * Returns true if, given the currently dispatching action and the previously
2075 * dispatched action, the two actions are modifying the same property such that
2076 * undo history should be batched.
2077 *
2078 * @param {Object} action Currently dispatching action.
2079 * @param {Object} previousAction Previously dispatched action.
2080 *
2081 * @return {boolean} Whether to overwrite present state.
2082 */
2083 function shouldOverwriteState(action, previousAction) {
2084 if (action.type === 'RESET_EDITOR_BLOCKS') {
2085 return !action.shouldCreateUndoLevel;
2086 }
2087 if (!previousAction || action.type !== previousAction.type) {
2088 return false;
2089 }
2090 return isUpdatingSamePostProperty(action, previousAction);
2091 }
2092 function postId(state = null, action) {
2093 switch (action.type) {
2094 case 'SET_EDITED_POST':
2095 return action.postId;
2096 }
2097 return state;
2098 }
2099 function templateId(state = null, action) {
2100 switch (action.type) {
2101 case 'SET_CURRENT_TEMPLATE_ID':
2102 return action.id;
2103 }
2104 return state;
2105 }
2106 function postType(state = null, action) {
2107 switch (action.type) {
2108 case 'SET_EDITED_POST':
2109 return action.postType;
2110 }
2111 return state;
2112 }
2113
2114 /**
2115 * Reducer returning whether the post blocks match the defined template or not.
2116 *
2117 * @param {Object} state Current state.
2118 * @param {Object} action Dispatched action.
2119 *
2120 * @return {boolean} Updated state.
2121 */
2122 function template(state = {
2123 isValid: true
2124 }, action) {
2125 switch (action.type) {
2126 case 'SET_TEMPLATE_VALIDITY':
2127 return {
2128 ...state,
2129 isValid: action.isValid
2130 };
2131 }
2132 return state;
2133 }
2134
2135 /**
2136 * Reducer returning current network request state (whether a request to
2137 * the WP REST API is in progress, successful, or failed).
2138 *
2139 * @param {Object} state Current state.
2140 * @param {Object} action Dispatched action.
2141 *
2142 * @return {Object} Updated state.
2143 */
2144 function saving(state = {}, action) {
2145 switch (action.type) {
2146 case 'REQUEST_POST_UPDATE_START':
2147 case 'REQUEST_POST_UPDATE_FINISH':
2148 return {
2149 pending: action.type === 'REQUEST_POST_UPDATE_START',
2150 options: action.options || {}
2151 };
2152 }
2153 return state;
2154 }
2155
2156 /**
2157 * Reducer returning deleting post request state.
2158 *
2159 * @param {Object} state Current state.
2160 * @param {Object} action Dispatched action.
2161 *
2162 * @return {Object} Updated state.
2163 */
2164 function deleting(state = {}, action) {
2165 switch (action.type) {
2166 case 'REQUEST_POST_DELETE_START':
2167 case 'REQUEST_POST_DELETE_FINISH':
2168 return {
2169 pending: action.type === 'REQUEST_POST_DELETE_START'
2170 };
2171 }
2172 return state;
2173 }
2174
2175 /**
2176 * Post Lock State.
2177 *
2178 * @typedef {Object} PostLockState
2179 *
2180 * @property {boolean} isLocked Whether the post is locked.
2181 * @property {?boolean} isTakeover Whether the post editing has been taken over.
2182 * @property {?boolean} activePostLock Active post lock value.
2183 * @property {?Object} user User that took over the post.
2184 */
2185
2186 /**
2187 * Reducer returning the post lock status.
2188 *
2189 * @param {PostLockState} state Current state.
2190 * @param {Object} action Dispatched action.
2191 *
2192 * @return {PostLockState} Updated state.
2193 */
2194 function postLock(state = {
2195 isLocked: false
2196 }, action) {
2197 switch (action.type) {
2198 case 'UPDATE_POST_LOCK':
2199 return action.lock;
2200 }
2201 return state;
2202 }
2203
2204 /**
2205 * Post saving lock.
2206 *
2207 * When post saving is locked, the post cannot be published or updated.
2208 *
2209 * @param {PostLockState} state Current state.
2210 * @param {Object} action Dispatched action.
2211 *
2212 * @return {PostLockState} Updated state.
2213 */
2214 function postSavingLock(state = {}, action) {
2215 switch (action.type) {
2216 case 'LOCK_POST_SAVING':
2217 return {
2218 ...state,
2219 [action.lockName]: true
2220 };
2221 case 'UNLOCK_POST_SAVING':
2222 {
2223 const {
2224 [action.lockName]: removedLockName,
2225 ...restState
2226 } = state;
2227 return restState;
2228 }
2229 }
2230 return state;
2231 }
2232
2233 /**
2234 * Post autosaving lock.
2235 *
2236 * When post autosaving is locked, the post will not autosave.
2237 *
2238 * @param {PostLockState} state Current state.
2239 * @param {Object} action Dispatched action.
2240 *
2241 * @return {PostLockState} Updated state.
2242 */
2243 function postAutosavingLock(state = {}, action) {
2244 switch (action.type) {
2245 case 'LOCK_POST_AUTOSAVING':
2246 return {
2247 ...state,
2248 [action.lockName]: true
2249 };
2250 case 'UNLOCK_POST_AUTOSAVING':
2251 {
2252 const {
2253 [action.lockName]: removedLockName,
2254 ...restState
2255 } = state;
2256 return restState;
2257 }
2258 }
2259 return state;
2260 }
2261
2262 /**
2263 * Reducer returning the post editor setting.
2264 *
2265 * @param {Object} state Current state.
2266 * @param {Object} action Dispatched action.
2267 *
2268 * @return {Object} Updated state.
2269 */
2270 function editorSettings(state = EDITOR_SETTINGS_DEFAULTS, action) {
2271 switch (action.type) {
2272 case 'UPDATE_EDITOR_SETTINGS':
2273 return {
2274 ...state,
2275 ...action.settings
2276 };
2277 }
2278 return state;
2279 }
2280 function renderingMode(state = 'post-only', action) {
2281 switch (action.type) {
2282 case 'SET_RENDERING_MODE':
2283 return action.mode;
2284 }
2285 return state;
2286 }
2287
2288 /**
2289 * Reducer returning the editing canvas device type.
2290 *
2291 * @param {Object} state Current state.
2292 * @param {Object} action Dispatched action.
2293 *
2294 * @return {Object} Updated state.
2295 */
2296 function deviceType(state = 'Desktop', action) {
2297 switch (action.type) {
2298 case 'SET_DEVICE_TYPE':
2299 return action.deviceType;
2300 }
2301 return state;
2302 }
2303
2304 /**
2305 * Reducer storing the list of all programmatically removed panels.
2306 *
2307 * @param {Array} state Current state.
2308 * @param {Object} action Action object.
2309 *
2310 * @return {Array} Updated state.
2311 */
2312 function removedPanels(state = [], action) {
2313 switch (action.type) {
2314 case 'REMOVE_PANEL':
2315 if (!state.includes(action.panelName)) {
2316 return [...state, action.panelName];
2317 }
2318 }
2319 return state;
2320 }
2321
2322 /**
2323 * Reducer to set the block inserter panel open or closed.
2324 *
2325 * Note: this reducer interacts with the list view panel reducer
2326 * to make sure that only one of the two panels is open at the same time.
2327 *
2328 * @param {Object} state Current state.
2329 * @param {Object} action Dispatched action.
2330 */
2331 function blockInserterPanel(state = false, action) {
2332 switch (action.type) {
2333 case 'SET_IS_LIST_VIEW_OPENED':
2334 return action.isOpen ? false : state;
2335 case 'SET_IS_INSERTER_OPENED':
2336 return action.value;
2337 }
2338 return state;
2339 }
2340
2341 /**
2342 * Reducer to set the list view panel open or closed.
2343 *
2344 * Note: this reducer interacts with the inserter panel reducer
2345 * to make sure that only one of the two panels is open at the same time.
2346 *
2347 * @param {Object} state Current state.
2348 * @param {Object} action Dispatched action.
2349 */
2350 function listViewPanel(state = false, action) {
2351 switch (action.type) {
2352 case 'SET_IS_INSERTER_OPENED':
2353 return action.value ? false : state;
2354 case 'SET_IS_LIST_VIEW_OPENED':
2355 return action.isOpen;
2356 }
2357 return state;
2358 }
2359
2360 /**
2361 * This reducer does nothing aside initializing a ref to the list view toggle.
2362 * We will have a unique ref per "editor" instance.
2363 *
2364 * @param {Object} state
2365 * @return {Object} Reference to the list view toggle button.
2366 */
2367 function listViewToggleRef(state = {
2368 current: null
2369 }) {
2370 return state;
2371 }
2372
2373 /**
2374 * This reducer does nothing aside initializing a ref to the inserter sidebar toggle.
2375 * We will have a unique ref per "editor" instance.
2376 *
2377 * @param {Object} state
2378 * @return {Object} Reference to the inserter sidebar toggle button.
2379 */
2380 function inserterSidebarToggleRef(state = {
2381 current: null
2382 }) {
2383 return state;
2384 }
2385 function publishSidebarActive(state = false, action) {
2386 switch (action.type) {
2387 case 'OPEN_PUBLISH_SIDEBAR':
2388 return true;
2389 case 'CLOSE_PUBLISH_SIDEBAR':
2390 return false;
2391 case 'TOGGLE_PUBLISH_SIDEBAR':
2392 return !state;
2393 }
2394 return state;
2395 }
2396 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
2397 postId,
2398 postType,
2399 templateId,
2400 saving,
2401 deleting,
2402 postLock,
2403 template,
2404 postSavingLock,
2405 editorSettings,
2406 postAutosavingLock,
2407 renderingMode,
2408 deviceType,
2409 removedPanels,
2410 blockInserterPanel,
2411 inserterSidebarToggleRef,
2412 listViewPanel,
2413 listViewToggleRef,
2414 publishSidebarActive
2415 }));
2416
2417 ;// CONCATENATED MODULE: external ["wp","date"]
2418 const external_wp_date_namespaceObject = window["wp"]["date"];
2419 ;// CONCATENATED MODULE: external ["wp","url"]
2420 const external_wp_url_namespaceObject = window["wp"]["url"];
2421 ;// CONCATENATED MODULE: external ["wp","deprecated"]
2422 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
2423 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
2424 ;// CONCATENATED MODULE: external ["wp","element"]
2425 const external_wp_element_namespaceObject = window["wp"]["element"];
2426 ;// CONCATENATED MODULE: external ["wp","primitives"]
2427 const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
2428 ;// CONCATENATED MODULE: external "ReactJSXRuntime"
2429 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
2430 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/layout.js
2431 /**
2432 * WordPress dependencies
2433 */
2434
2435
2436 const layout = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2437 xmlns: "http://www.w3.org/2000/svg",
2438 viewBox: "0 0 24 24",
2439 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2440 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"
2441 })
2442 });
2443 /* harmony default export */ const library_layout = (layout);
2444
2445 ;// CONCATENATED MODULE: external ["wp","preferences"]
2446 const external_wp_preferences_namespaceObject = window["wp"]["preferences"];
2447 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/constants.js
2448 /**
2449 * Set of post properties for which edits should assume a merging behavior,
2450 * assuming an object value.
2451 *
2452 * @type {Set}
2453 */
2454 const EDIT_MERGE_PROPERTIES = new Set(['meta']);
2455
2456 /**
2457 * Constant for the store module (or reducer) key.
2458 *
2459 * @type {string}
2460 */
2461 const STORE_NAME = 'core/editor';
2462 const SAVE_POST_NOTICE_ID = 'SAVE_POST_NOTICE_ID';
2463 const TRASH_POST_NOTICE_ID = 'TRASH_POST_NOTICE_ID';
2464 const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;
2465 const ONE_MINUTE_IN_MS = 60 * 1000;
2466 const AUTOSAVE_PROPERTIES = ['title', 'excerpt', 'content'];
2467 const TEMPLATE_PART_AREA_DEFAULT_CATEGORY = 'uncategorized';
2468 const TEMPLATE_POST_TYPE = 'wp_template';
2469 const TEMPLATE_PART_POST_TYPE = 'wp_template_part';
2470 const PATTERN_POST_TYPE = 'wp_block';
2471 const NAVIGATION_POST_TYPE = 'wp_navigation';
2472 const TEMPLATE_ORIGINS = {
2473 custom: 'custom',
2474 theme: 'theme',
2475 plugin: 'plugin'
2476 };
2477 const TEMPLATE_POST_TYPES = ['wp_template', 'wp_template_part'];
2478 const GLOBAL_POST_TYPES = [...TEMPLATE_POST_TYPES, 'wp_block', 'wp_navigation'];
2479
2480 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/header.js
2481 /**
2482 * WordPress dependencies
2483 */
2484
2485
2486 const header = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2487 xmlns: "http://www.w3.org/2000/svg",
2488 viewBox: "0 0 24 24",
2489 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2490 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"
2491 })
2492 });
2493 /* harmony default export */ const library_header = (header);
2494
2495 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/footer.js
2496 /**
2497 * WordPress dependencies
2498 */
2499
2500
2501 const footer = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2502 xmlns: "http://www.w3.org/2000/svg",
2503 viewBox: "0 0 24 24",
2504 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2505 fillRule: "evenodd",
2506 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"
2507 })
2508 });
2509 /* harmony default export */ const library_footer = (footer);
2510
2511 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/sidebar.js
2512 /**
2513 * WordPress dependencies
2514 */
2515
2516
2517 const sidebar = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2518 xmlns: "http://www.w3.org/2000/svg",
2519 viewBox: "0 0 24 24",
2520 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2521 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"
2522 })
2523 });
2524 /* harmony default export */ const library_sidebar = (sidebar);
2525
2526 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/symbol-filled.js
2527 /**
2528 * WordPress dependencies
2529 */
2530
2531
2532 const symbolFilled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2533 xmlns: "http://www.w3.org/2000/svg",
2534 viewBox: "0 0 24 24",
2535 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2536 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"
2537 })
2538 });
2539 /* harmony default export */ const symbol_filled = (symbolFilled);
2540
2541 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/get-template-part-icon.js
2542 /**
2543 * WordPress dependencies
2544 */
2545
2546 /**
2547 * Helper function to retrieve the corresponding icon by name.
2548 *
2549 * @param {string} iconName The name of the icon.
2550 *
2551 * @return {Object} The corresponding icon.
2552 */
2553 function getTemplatePartIcon(iconName) {
2554 if ('header' === iconName) {
2555 return library_header;
2556 } else if ('footer' === iconName) {
2557 return library_footer;
2558 } else if ('sidebar' === iconName) {
2559 return library_sidebar;
2560 }
2561 return symbol_filled;
2562 }
2563
2564 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/selectors.js
2565 /**
2566 * WordPress dependencies
2567 */
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
2579 /**
2580 * Internal dependencies
2581 */
2582
2583
2584
2585
2586 /**
2587 * Shared reference to an empty object for cases where it is important to avoid
2588 * returning a new object reference on every invocation, as in a connected or
2589 * other pure component which performs `shouldComponentUpdate` check on props.
2590 * This should be used as a last resort, since the normalized data should be
2591 * maintained by the reducer result in state.
2592 */
2593 const EMPTY_OBJECT = {};
2594
2595 /**
2596 * Returns true if any past editor history snapshots exist, or false otherwise.
2597 *
2598 * @param {Object} state Global application state.
2599 *
2600 * @return {boolean} Whether undo history exists.
2601 */
2602 const hasEditorUndo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
2603 return select(external_wp_coreData_namespaceObject.store).hasUndo();
2604 });
2605
2606 /**
2607 * Returns true if any future editor history snapshots exist, or false
2608 * otherwise.
2609 *
2610 * @param {Object} state Global application state.
2611 *
2612 * @return {boolean} Whether redo history exists.
2613 */
2614 const hasEditorRedo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
2615 return select(external_wp_coreData_namespaceObject.store).hasRedo();
2616 });
2617
2618 /**
2619 * Returns true if the currently edited post is yet to be saved, or false if
2620 * the post has been saved.
2621 *
2622 * @param {Object} state Global application state.
2623 *
2624 * @return {boolean} Whether the post is new.
2625 */
2626 function isEditedPostNew(state) {
2627 return getCurrentPost(state).status === 'auto-draft';
2628 }
2629
2630 /**
2631 * Returns true if content includes unsaved changes, or false otherwise.
2632 *
2633 * @param {Object} state Editor state.
2634 *
2635 * @return {boolean} Whether content includes unsaved changes.
2636 */
2637 function hasChangedContent(state) {
2638 const edits = getPostEdits(state);
2639 return 'content' in edits;
2640 }
2641
2642 /**
2643 * Returns true if there are unsaved values for the current edit session, or
2644 * false if the editing state matches the saved or new post.
2645 *
2646 * @param {Object} state Global application state.
2647 *
2648 * @return {boolean} Whether unsaved values exist.
2649 */
2650 const isEditedPostDirty = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2651 // Edits should contain only fields which differ from the saved post (reset
2652 // at initial load and save complete). Thus, a non-empty edits state can be
2653 // inferred to contain unsaved values.
2654 const postType = getCurrentPostType(state);
2655 const postId = getCurrentPostId(state);
2656 return select(external_wp_coreData_namespaceObject.store).hasEditsForEntityRecord('postType', postType, postId);
2657 });
2658
2659 /**
2660 * Returns true if there are unsaved edits for entities other than
2661 * the editor's post, and false otherwise.
2662 *
2663 * @param {Object} state Global application state.
2664 *
2665 * @return {boolean} Whether there are edits or not.
2666 */
2667 const hasNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2668 const dirtyEntityRecords = select(external_wp_coreData_namespaceObject.store).__experimentalGetDirtyEntityRecords();
2669 const {
2670 type,
2671 id
2672 } = getCurrentPost(state);
2673 return dirtyEntityRecords.some(entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id);
2674 });
2675
2676 /**
2677 * Returns true if there are no unsaved values for the current edit session and
2678 * if the currently edited post is new (has never been saved before).
2679 *
2680 * @param {Object} state Global application state.
2681 *
2682 * @return {boolean} Whether new post and unsaved values exist.
2683 */
2684 function isCleanNewPost(state) {
2685 return !isEditedPostDirty(state) && isEditedPostNew(state);
2686 }
2687
2688 /**
2689 * Returns the post currently being edited in its last known saved state, not
2690 * including unsaved edits. Returns an object containing relevant default post
2691 * values if the post has not yet been saved.
2692 *
2693 * @param {Object} state Global application state.
2694 *
2695 * @return {Object} Post object.
2696 */
2697 const getCurrentPost = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2698 const postId = getCurrentPostId(state);
2699 const postType = getCurrentPostType(state);
2700 const post = select(external_wp_coreData_namespaceObject.store).getRawEntityRecord('postType', postType, postId);
2701 if (post) {
2702 return post;
2703 }
2704
2705 // This exists for compatibility with the previous selector behavior
2706 // which would guarantee an object return based on the editor reducer's
2707 // default empty object state.
2708 return EMPTY_OBJECT;
2709 });
2710
2711 /**
2712 * Returns the post type of the post currently being edited.
2713 *
2714 * @param {Object} state Global application state.
2715 *
2716 * @return {string} Post type.
2717 */
2718 function getCurrentPostType(state) {
2719 return state.postType;
2720 }
2721
2722 /**
2723 * Returns the ID of the post currently being edited, or null if the post has
2724 * not yet been saved.
2725 *
2726 * @param {Object} state Global application state.
2727 *
2728 * @return {?number} ID of current post.
2729 */
2730 function getCurrentPostId(state) {
2731 return state.postId;
2732 }
2733
2734 /**
2735 * Returns the template ID currently being rendered/edited
2736 *
2737 * @param {Object} state Global application state.
2738 *
2739 * @return {string?} Template ID.
2740 */
2741 function getCurrentTemplateId(state) {
2742 return state.templateId;
2743 }
2744
2745 /**
2746 * Returns the number of revisions of the post currently being edited.
2747 *
2748 * @param {Object} state Global application state.
2749 *
2750 * @return {number} Number of revisions.
2751 */
2752 function getCurrentPostRevisionsCount(state) {
2753 var _getCurrentPost$_link;
2754 return (_getCurrentPost$_link = getCurrentPost(state)._links?.['version-history']?.[0]?.count) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : 0;
2755 }
2756
2757 /**
2758 * Returns the last revision ID of the post currently being edited,
2759 * or null if the post has no revisions.
2760 *
2761 * @param {Object} state Global application state.
2762 *
2763 * @return {?number} ID of the last revision.
2764 */
2765 function getCurrentPostLastRevisionId(state) {
2766 var _getCurrentPost$_link2;
2767 return (_getCurrentPost$_link2 = getCurrentPost(state)._links?.['predecessor-version']?.[0]?.id) !== null && _getCurrentPost$_link2 !== void 0 ? _getCurrentPost$_link2 : null;
2768 }
2769
2770 /**
2771 * Returns any post values which have been changed in the editor but not yet
2772 * been saved.
2773 *
2774 * @param {Object} state Global application state.
2775 *
2776 * @return {Object} Object of key value pairs comprising unsaved edits.
2777 */
2778 const getPostEdits = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2779 const postType = getCurrentPostType(state);
2780 const postId = getCurrentPostId(state);
2781 return select(external_wp_coreData_namespaceObject.store).getEntityRecordEdits('postType', postType, postId) || EMPTY_OBJECT;
2782 });
2783
2784 /**
2785 * Returns an attribute value of the saved post.
2786 *
2787 * @param {Object} state Global application state.
2788 * @param {string} attributeName Post attribute name.
2789 *
2790 * @return {*} Post attribute value.
2791 */
2792 function getCurrentPostAttribute(state, attributeName) {
2793 switch (attributeName) {
2794 case 'type':
2795 return getCurrentPostType(state);
2796 case 'id':
2797 return getCurrentPostId(state);
2798 default:
2799 const post = getCurrentPost(state);
2800 if (!post.hasOwnProperty(attributeName)) {
2801 break;
2802 }
2803 return getPostRawValue(post[attributeName]);
2804 }
2805 }
2806
2807 /**
2808 * Returns a single attribute of the post being edited, preferring the unsaved
2809 * edit if one exists, but merging with the attribute value for the last known
2810 * saved state of the post (this is needed for some nested attributes like meta).
2811 *
2812 * @param {Object} state Global application state.
2813 * @param {string} attributeName Post attribute name.
2814 *
2815 * @return {*} Post attribute value.
2816 */
2817 const getNestedEditedPostProperty = (0,external_wp_data_namespaceObject.createSelector)((state, attributeName) => {
2818 const edits = getPostEdits(state);
2819 if (!edits.hasOwnProperty(attributeName)) {
2820 return getCurrentPostAttribute(state, attributeName);
2821 }
2822 return {
2823 ...getCurrentPostAttribute(state, attributeName),
2824 ...edits[attributeName]
2825 };
2826 }, (state, attributeName) => [getCurrentPostAttribute(state, attributeName), getPostEdits(state)[attributeName]]);
2827
2828 /**
2829 * Returns a single attribute of the post being edited, preferring the unsaved
2830 * edit if one exists, but falling back to the attribute for the last known
2831 * saved state of the post.
2832 *
2833 * @param {Object} state Global application state.
2834 * @param {string} attributeName Post attribute name.
2835 *
2836 * @return {*} Post attribute value.
2837 */
2838 function getEditedPostAttribute(state, attributeName) {
2839 // Special cases.
2840 switch (attributeName) {
2841 case 'content':
2842 return getEditedPostContent(state);
2843 }
2844
2845 // Fall back to saved post value if not edited.
2846 const edits = getPostEdits(state);
2847 if (!edits.hasOwnProperty(attributeName)) {
2848 return getCurrentPostAttribute(state, attributeName);
2849 }
2850
2851 // Merge properties are objects which contain only the patch edit in state,
2852 // and thus must be merged with the current post attribute.
2853 if (EDIT_MERGE_PROPERTIES.has(attributeName)) {
2854 return getNestedEditedPostProperty(state, attributeName);
2855 }
2856 return edits[attributeName];
2857 }
2858
2859 /**
2860 * Returns an attribute value of the current autosave revision for a post, or
2861 * null if there is no autosave for the post.
2862 *
2863 * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector
2864 * from the '@wordpress/core-data' package and access properties on the returned
2865 * autosave object using getPostRawValue.
2866 *
2867 * @param {Object} state Global application state.
2868 * @param {string} attributeName Autosave attribute name.
2869 *
2870 * @return {*} Autosave attribute value.
2871 */
2872 const getAutosaveAttribute = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, attributeName) => {
2873 if (!AUTOSAVE_PROPERTIES.includes(attributeName) && attributeName !== 'preview_link') {
2874 return;
2875 }
2876 const postType = getCurrentPostType(state);
2877
2878 // Currently template autosaving is not supported.
2879 if (postType === 'wp_template') {
2880 return false;
2881 }
2882 const postId = getCurrentPostId(state);
2883 const currentUserId = select(external_wp_coreData_namespaceObject.store).getCurrentUser()?.id;
2884 const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId);
2885 if (autosave) {
2886 return getPostRawValue(autosave[attributeName]);
2887 }
2888 });
2889
2890 /**
2891 * Returns the current visibility of the post being edited, preferring the
2892 * unsaved value if different than the saved post. The return value is one of
2893 * "private", "password", or "public".
2894 *
2895 * @param {Object} state Global application state.
2896 *
2897 * @return {string} Post visibility.
2898 */
2899 function getEditedPostVisibility(state) {
2900 const status = getEditedPostAttribute(state, 'status');
2901 if (status === 'private') {
2902 return 'private';
2903 }
2904 const password = getEditedPostAttribute(state, 'password');
2905 if (password) {
2906 return 'password';
2907 }
2908 return 'public';
2909 }
2910
2911 /**
2912 * Returns true if post is pending review.
2913 *
2914 * @param {Object} state Global application state.
2915 *
2916 * @return {boolean} Whether current post is pending review.
2917 */
2918 function isCurrentPostPending(state) {
2919 return getCurrentPost(state).status === 'pending';
2920 }
2921
2922 /**
2923 * Return true if the current post has already been published.
2924 *
2925 * @param {Object} state Global application state.
2926 * @param {Object?} currentPost Explicit current post for bypassing registry selector.
2927 *
2928 * @return {boolean} Whether the post has been published.
2929 */
2930 function isCurrentPostPublished(state, currentPost) {
2931 const post = currentPost || getCurrentPost(state);
2932 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));
2933 }
2934
2935 /**
2936 * Returns true if post is already scheduled.
2937 *
2938 * @param {Object} state Global application state.
2939 *
2940 * @return {boolean} Whether current post is scheduled to be posted.
2941 */
2942 function isCurrentPostScheduled(state) {
2943 return getCurrentPost(state).status === 'future' && !isCurrentPostPublished(state);
2944 }
2945
2946 /**
2947 * Return true if the post being edited can be published.
2948 *
2949 * @param {Object} state Global application state.
2950 *
2951 * @return {boolean} Whether the post can been published.
2952 */
2953 function isEditedPostPublishable(state) {
2954 const post = getCurrentPost(state);
2955
2956 // TODO: Post being publishable should be superset of condition of post
2957 // being saveable. Currently this restriction is imposed at UI.
2958 //
2959 // See: <PostPublishButton /> (`isButtonEnabled` assigned by `isSaveable`).
2960
2961 return isEditedPostDirty(state) || ['publish', 'private', 'future'].indexOf(post.status) === -1;
2962 }
2963
2964 /**
2965 * Returns true if the post can be saved, or false otherwise. A post must
2966 * contain a title, an excerpt, or non-empty content to be valid for save.
2967 *
2968 * @param {Object} state Global application state.
2969 *
2970 * @return {boolean} Whether the post can be saved.
2971 */
2972 function isEditedPostSaveable(state) {
2973 if (isSavingPost(state)) {
2974 return false;
2975 }
2976
2977 // TODO: Post should not be saveable if not dirty. Cannot be added here at
2978 // this time since posts where meta boxes are present can be saved even if
2979 // the post is not dirty. Currently this restriction is imposed at UI, but
2980 // should be moved here.
2981 //
2982 // See: `isEditedPostPublishable` (includes `isEditedPostDirty` condition)
2983 // See: <PostSavedState /> (`forceIsDirty` prop)
2984 // See: <PostPublishButton /> (`forceIsDirty` prop)
2985 // See: https://github.com/WordPress/gutenberg/pull/4184.
2986
2987 return !!getEditedPostAttribute(state, 'title') || !!getEditedPostAttribute(state, 'excerpt') || !isEditedPostEmpty(state) || external_wp_element_namespaceObject.Platform.OS === 'native';
2988 }
2989
2990 /**
2991 * Returns true if the edited post has content. A post has content if it has at
2992 * least one saveable block or otherwise has a non-empty content property
2993 * assigned.
2994 *
2995 * @param {Object} state Global application state.
2996 *
2997 * @return {boolean} Whether post has content.
2998 */
2999 const isEditedPostEmpty = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3000 // While the condition of truthy content string is sufficient to determine
3001 // emptiness, testing saveable blocks length is a trivial operation. Since
3002 // this function can be called frequently, optimize for the fast case as a
3003 // condition of the mere existence of blocks. Note that the value of edited
3004 // content takes precedent over block content, and must fall through to the
3005 // default logic.
3006 const postId = getCurrentPostId(state);
3007 const postType = getCurrentPostType(state);
3008 const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
3009 if (typeof record.content !== 'function') {
3010 return !record.content;
3011 }
3012 const blocks = getEditedPostAttribute(state, 'blocks');
3013 if (blocks.length === 0) {
3014 return true;
3015 }
3016
3017 // Pierce the abstraction of the serializer in knowing that blocks are
3018 // joined with newlines such that even if every individual block
3019 // produces an empty save result, the serialized content is non-empty.
3020 if (blocks.length > 1) {
3021 return false;
3022 }
3023
3024 // There are two conditions under which the optimization cannot be
3025 // assumed, and a fallthrough to getEditedPostContent must occur:
3026 //
3027 // 1. getBlocksForSerialization has special treatment in omitting a
3028 // single unmodified default block.
3029 // 2. Comment delimiters are omitted for a freeform or unregistered
3030 // block in its serialization. The freeform block specifically may
3031 // produce an empty string in its saved output.
3032 //
3033 // For all other content, the single block is assumed to make a post
3034 // non-empty, if only by virtue of its own comment delimiters.
3035 const blockName = blocks[0].name;
3036 if (blockName !== (0,external_wp_blocks_namespaceObject.getDefaultBlockName)() && blockName !== (0,external_wp_blocks_namespaceObject.getFreeformContentHandlerName)()) {
3037 return false;
3038 }
3039 return !getEditedPostContent(state);
3040 });
3041
3042 /**
3043 * Returns true if the post can be autosaved, or false otherwise.
3044 *
3045 * @param {Object} state Global application state.
3046 * @param {Object} autosave A raw autosave object from the REST API.
3047 *
3048 * @return {boolean} Whether the post can be autosaved.
3049 */
3050 const isEditedPostAutosaveable = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3051 // A post must contain a title, an excerpt, or non-empty content to be valid for autosaving.
3052 if (!isEditedPostSaveable(state)) {
3053 return false;
3054 }
3055
3056 // A post is not autosavable when there is a post autosave lock.
3057 if (isPostAutosavingLocked(state)) {
3058 return false;
3059 }
3060 const postType = getCurrentPostType(state);
3061
3062 // Currently template autosaving is not supported.
3063 if (postType === 'wp_template') {
3064 return false;
3065 }
3066 const postId = getCurrentPostId(state);
3067 const hasFetchedAutosave = select(external_wp_coreData_namespaceObject.store).hasFetchedAutosaves(postType, postId);
3068 const currentUserId = select(external_wp_coreData_namespaceObject.store).getCurrentUser()?.id;
3069
3070 // Disable reason - this line causes the side-effect of fetching the autosave
3071 // via a resolver, moving below the return would result in the autosave never
3072 // being fetched.
3073 // eslint-disable-next-line @wordpress/no-unused-vars-before-return
3074 const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId);
3075
3076 // If any existing autosaves have not yet been fetched, this function is
3077 // unable to determine if the post is autosaveable, so return false.
3078 if (!hasFetchedAutosave) {
3079 return false;
3080 }
3081
3082 // If we don't already have an autosave, the post is autosaveable.
3083 if (!autosave) {
3084 return true;
3085 }
3086
3087 // To avoid an expensive content serialization, use the content dirtiness
3088 // flag in place of content field comparison against the known autosave.
3089 // This is not strictly accurate, and relies on a tolerance toward autosave
3090 // request failures for unnecessary saves.
3091 if (hasChangedContent(state)) {
3092 return true;
3093 }
3094
3095 // If title, excerpt, or meta have changed, the post is autosaveable.
3096 return ['title', 'excerpt', 'meta'].some(field => getPostRawValue(autosave[field]) !== getEditedPostAttribute(state, field));
3097 });
3098
3099 /**
3100 * Return true if the post being edited is being scheduled. Preferring the
3101 * unsaved status values.
3102 *
3103 * @param {Object} state Global application state.
3104 *
3105 * @return {boolean} Whether the post has been published.
3106 */
3107 function isEditedPostBeingScheduled(state) {
3108 const date = getEditedPostAttribute(state, 'date');
3109 // Offset the date by one minute (network latency).
3110 const checkedDate = new Date(Number((0,external_wp_date_namespaceObject.getDate)(date)) - ONE_MINUTE_IN_MS);
3111 return (0,external_wp_date_namespaceObject.isInTheFuture)(checkedDate);
3112 }
3113
3114 /**
3115 * Returns whether the current post should be considered to have a "floating"
3116 * date (i.e. that it would publish "Immediately" rather than at a set time).
3117 *
3118 * Unlike in the PHP backend, the REST API returns a full date string for posts
3119 * where the 0000-00-00T00:00:00 placeholder is present in the database. To
3120 * infer that a post is set to publish "Immediately" we check whether the date
3121 * and modified date are the same.
3122 *
3123 * @param {Object} state Editor state.
3124 *
3125 * @return {boolean} Whether the edited post has a floating date value.
3126 */
3127 function isEditedPostDateFloating(state) {
3128 const date = getEditedPostAttribute(state, 'date');
3129 const modified = getEditedPostAttribute(state, 'modified');
3130
3131 // This should be the status of the persisted post
3132 // It shouldn't use the "edited" status otherwise it breaks the
3133 // inferred post data floating status
3134 // See https://github.com/WordPress/gutenberg/issues/28083.
3135 const status = getCurrentPost(state).status;
3136 if (status === 'draft' || status === 'auto-draft' || status === 'pending') {
3137 return date === modified || date === null;
3138 }
3139 return false;
3140 }
3141
3142 /**
3143 * Returns true if the post is currently being deleted, or false otherwise.
3144 *
3145 * @param {Object} state Editor state.
3146 *
3147 * @return {boolean} Whether post is being deleted.
3148 */
3149 function isDeletingPost(state) {
3150 return !!state.deleting.pending;
3151 }
3152
3153 /**
3154 * Returns true if the post is currently being saved, or false otherwise.
3155 *
3156 * @param {Object} state Global application state.
3157 *
3158 * @return {boolean} Whether post is being saved.
3159 */
3160 function isSavingPost(state) {
3161 return !!state.saving.pending;
3162 }
3163
3164 /**
3165 * Returns true if non-post entities are currently being saved, or false otherwise.
3166 *
3167 * @param {Object} state Global application state.
3168 *
3169 * @return {boolean} Whether non-post entities are being saved.
3170 */
3171 const isSavingNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3172 const entitiesBeingSaved = select(external_wp_coreData_namespaceObject.store).__experimentalGetEntitiesBeingSaved();
3173 const {
3174 type,
3175 id
3176 } = getCurrentPost(state);
3177 return entitiesBeingSaved.some(entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id);
3178 });
3179
3180 /**
3181 * Returns true if a previous post save was attempted successfully, or false
3182 * otherwise.
3183 *
3184 * @param {Object} state Global application state.
3185 *
3186 * @return {boolean} Whether the post was saved successfully.
3187 */
3188 const didPostSaveRequestSucceed = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3189 const postType = getCurrentPostType(state);
3190 const postId = getCurrentPostId(state);
3191 return !select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
3192 });
3193
3194 /**
3195 * Returns true if a previous post save was attempted but failed, or false
3196 * otherwise.
3197 *
3198 * @param {Object} state Global application state.
3199 *
3200 * @return {boolean} Whether the post save failed.
3201 */
3202 const didPostSaveRequestFail = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3203 const postType = getCurrentPostType(state);
3204 const postId = getCurrentPostId(state);
3205 return !!select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
3206 });
3207
3208 /**
3209 * Returns true if the post is autosaving, or false otherwise.
3210 *
3211 * @param {Object} state Global application state.
3212 *
3213 * @return {boolean} Whether the post is autosaving.
3214 */
3215 function isAutosavingPost(state) {
3216 return isSavingPost(state) && Boolean(state.saving.options?.isAutosave);
3217 }
3218
3219 /**
3220 * Returns true if the post is being previewed, or false otherwise.
3221 *
3222 * @param {Object} state Global application state.
3223 *
3224 * @return {boolean} Whether the post is being previewed.
3225 */
3226 function isPreviewingPost(state) {
3227 return isSavingPost(state) && Boolean(state.saving.options?.isPreview);
3228 }
3229
3230 /**
3231 * Returns the post preview link
3232 *
3233 * @param {Object} state Global application state.
3234 *
3235 * @return {string | undefined} Preview Link.
3236 */
3237 function getEditedPostPreviewLink(state) {
3238 if (state.saving.pending || isSavingPost(state)) {
3239 return;
3240 }
3241 let previewLink = getAutosaveAttribute(state, 'preview_link');
3242 // Fix for issue: https://github.com/WordPress/gutenberg/issues/33616
3243 // If the post is draft, ignore the preview link from the autosave record,
3244 // because the preview could be a stale autosave if the post was switched from
3245 // published to draft.
3246 // See: https://github.com/WordPress/gutenberg/pull/37952.
3247 if (!previewLink || 'draft' === getCurrentPost(state).status) {
3248 previewLink = getEditedPostAttribute(state, 'link');
3249 if (previewLink) {
3250 previewLink = (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
3251 preview: true
3252 });
3253 }
3254 }
3255 const featuredImageId = getEditedPostAttribute(state, 'featured_media');
3256 if (previewLink && featuredImageId) {
3257 return (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
3258 _thumbnail_id: featuredImageId
3259 });
3260 }
3261 return previewLink;
3262 }
3263
3264 /**
3265 * Returns a suggested post format for the current post, inferred only if there
3266 * is a single block within the post and it is of a type known to match a
3267 * default post format. Returns null if the format cannot be determined.
3268 *
3269 * @return {?string} Suggested post format.
3270 */
3271 const getSuggestedPostFormat = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
3272 const blocks = select(external_wp_blockEditor_namespaceObject.store).getBlocks();
3273 if (blocks.length > 2) {
3274 return null;
3275 }
3276 let name;
3277 // If there is only one block in the content of the post grab its name
3278 // so we can derive a suitable post format from it.
3279 if (blocks.length === 1) {
3280 name = blocks[0].name;
3281 // Check for core/embed `video` and `audio` eligible suggestions.
3282 if (name === 'core/embed') {
3283 const provider = blocks[0].attributes?.providerNameSlug;
3284 if (['youtube', 'vimeo'].includes(provider)) {
3285 name = 'core/video';
3286 } else if (['spotify', 'soundcloud'].includes(provider)) {
3287 name = 'core/audio';
3288 }
3289 }
3290 }
3291
3292 // If there are two blocks in the content and the last one is a text blocks
3293 // grab the name of the first one to also suggest a post format from it.
3294 if (blocks.length === 2 && blocks[1].name === 'core/paragraph') {
3295 name = blocks[0].name;
3296 }
3297
3298 // We only convert to default post formats in core.
3299 switch (name) {
3300 case 'core/image':
3301 return 'image';
3302 case 'core/quote':
3303 case 'core/pullquote':
3304 return 'quote';
3305 case 'core/gallery':
3306 return 'gallery';
3307 case 'core/video':
3308 return 'video';
3309 case 'core/audio':
3310 return 'audio';
3311 default:
3312 return null;
3313 }
3314 });
3315
3316 /**
3317 * Returns the content of the post being edited.
3318 *
3319 * @param {Object} state Global application state.
3320 *
3321 * @return {string} Post content.
3322 */
3323 const getEditedPostContent = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3324 const postId = getCurrentPostId(state);
3325 const postType = getCurrentPostType(state);
3326 const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
3327 if (record) {
3328 if (typeof record.content === 'function') {
3329 return record.content(record);
3330 } else if (record.blocks) {
3331 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
3332 } else if (record.content) {
3333 return record.content;
3334 }
3335 }
3336 return '';
3337 });
3338
3339 /**
3340 * Returns true if the post is being published, or false otherwise.
3341 *
3342 * @param {Object} state Global application state.
3343 *
3344 * @return {boolean} Whether post is being published.
3345 */
3346 function isPublishingPost(state) {
3347 return isSavingPost(state) && !isCurrentPostPublished(state) && getEditedPostAttribute(state, 'status') === 'publish';
3348 }
3349
3350 /**
3351 * Returns whether the permalink is editable or not.
3352 *
3353 * @param {Object} state Editor state.
3354 *
3355 * @return {boolean} Whether or not the permalink is editable.
3356 */
3357 function isPermalinkEditable(state) {
3358 const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
3359 return PERMALINK_POSTNAME_REGEX.test(permalinkTemplate);
3360 }
3361
3362 /**
3363 * Returns the permalink for the post.
3364 *
3365 * @param {Object} state Editor state.
3366 *
3367 * @return {?string} The permalink, or null if the post is not viewable.
3368 */
3369 function getPermalink(state) {
3370 const permalinkParts = getPermalinkParts(state);
3371 if (!permalinkParts) {
3372 return null;
3373 }
3374 const {
3375 prefix,
3376 postName,
3377 suffix
3378 } = permalinkParts;
3379 if (isPermalinkEditable(state)) {
3380 return prefix + postName + suffix;
3381 }
3382 return prefix;
3383 }
3384
3385 /**
3386 * Returns the slug for the post being edited, preferring a manually edited
3387 * value if one exists, then a sanitized version of the current post title, and
3388 * finally the post ID.
3389 *
3390 * @param {Object} state Editor state.
3391 *
3392 * @return {string} The current slug to be displayed in the editor
3393 */
3394 function getEditedPostSlug(state) {
3395 return getEditedPostAttribute(state, 'slug') || (0,external_wp_url_namespaceObject.cleanForSlug)(getEditedPostAttribute(state, 'title')) || getCurrentPostId(state);
3396 }
3397
3398 /**
3399 * Returns the permalink for a post, split into its three parts: the prefix,
3400 * the postName, and the suffix.
3401 *
3402 * @param {Object} state Editor state.
3403 *
3404 * @return {Object} An object containing the prefix, postName, and suffix for
3405 * the permalink, or null if the post is not viewable.
3406 */
3407 function getPermalinkParts(state) {
3408 const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
3409 if (!permalinkTemplate) {
3410 return null;
3411 }
3412 const postName = getEditedPostAttribute(state, 'slug') || getEditedPostAttribute(state, 'generated_slug');
3413 const [prefix, suffix] = permalinkTemplate.split(PERMALINK_POSTNAME_REGEX);
3414 return {
3415 prefix,
3416 postName,
3417 suffix
3418 };
3419 }
3420
3421 /**
3422 * Returns whether the post is locked.
3423 *
3424 * @param {Object} state Global application state.
3425 *
3426 * @return {boolean} Is locked.
3427 */
3428 function isPostLocked(state) {
3429 return state.postLock.isLocked;
3430 }
3431
3432 /**
3433 * Returns whether post saving is locked.
3434 *
3435 * @param {Object} state Global application state.
3436 *
3437 * @return {boolean} Is locked.
3438 */
3439 function isPostSavingLocked(state) {
3440 return Object.keys(state.postSavingLock).length > 0;
3441 }
3442
3443 /**
3444 * Returns whether post autosaving is locked.
3445 *
3446 * @param {Object} state Global application state.
3447 *
3448 * @return {boolean} Is locked.
3449 */
3450 function isPostAutosavingLocked(state) {
3451 return Object.keys(state.postAutosavingLock).length > 0;
3452 }
3453
3454 /**
3455 * Returns whether the edition of the post has been taken over.
3456 *
3457 * @param {Object} state Global application state.
3458 *
3459 * @return {boolean} Is post lock takeover.
3460 */
3461 function isPostLockTakeover(state) {
3462 return state.postLock.isTakeover;
3463 }
3464
3465 /**
3466 * Returns details about the post lock user.
3467 *
3468 * @param {Object} state Global application state.
3469 *
3470 * @return {Object} A user object.
3471 */
3472 function getPostLockUser(state) {
3473 return state.postLock.user;
3474 }
3475
3476 /**
3477 * Returns the active post lock.
3478 *
3479 * @param {Object} state Global application state.
3480 *
3481 * @return {Object} The lock object.
3482 */
3483 function getActivePostLock(state) {
3484 return state.postLock.activePostLock;
3485 }
3486
3487 /**
3488 * Returns whether or not the user has the unfiltered_html capability.
3489 *
3490 * @param {Object} state Editor state.
3491 *
3492 * @return {boolean} Whether the user can or can't post unfiltered HTML.
3493 */
3494 function canUserUseUnfilteredHTML(state) {
3495 return Boolean(getCurrentPost(state)._links?.hasOwnProperty('wp:action-unfiltered-html'));
3496 }
3497
3498 /**
3499 * Returns whether the pre-publish panel should be shown
3500 * or skipped when the user clicks the "publish" button.
3501 *
3502 * @return {boolean} Whether the pre-publish panel should be shown or not.
3503 */
3504 const isPublishSidebarEnabled = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => !!select(external_wp_preferences_namespaceObject.store).get('core', 'isPublishSidebarEnabled'));
3505
3506 /**
3507 * Return the current block list.
3508 *
3509 * @param {Object} state
3510 * @return {Array} Block list.
3511 */
3512 const getEditorBlocks = (0,external_wp_data_namespaceObject.createSelector)(state => {
3513 return getEditedPostAttribute(state, 'blocks') || (0,external_wp_blocks_namespaceObject.parse)(getEditedPostContent(state));
3514 }, state => [getEditedPostAttribute(state, 'blocks'), getEditedPostContent(state)]);
3515
3516 /**
3517 * Returns true if the given panel was programmatically removed, or false otherwise.
3518 * All panels are not removed by default.
3519 *
3520 * @param {Object} state Global application state.
3521 * @param {string} panelName A string that identifies the panel.
3522 *
3523 * @return {boolean} Whether or not the panel is removed.
3524 */
3525 function isEditorPanelRemoved(state, panelName) {
3526 return state.removedPanels.includes(panelName);
3527 }
3528
3529 /**
3530 * Returns true if the given panel is enabled, or false otherwise. Panels are
3531 * enabled by default.
3532 *
3533 * @param {Object} state Global application state.
3534 * @param {string} panelName A string that identifies the panel.
3535 *
3536 * @return {boolean} Whether or not the panel is enabled.
3537 */
3538 const isEditorPanelEnabled = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, panelName) => {
3539 // For backward compatibility, we check edit-post
3540 // even though now this is in "editor" package.
3541 const inactivePanels = select(external_wp_preferences_namespaceObject.store).get('core', 'inactivePanels');
3542 return !isEditorPanelRemoved(state, panelName) && !inactivePanels?.includes(panelName);
3543 });
3544
3545 /**
3546 * Returns true if the given panel is open, or false otherwise. Panels are
3547 * closed by default.
3548 *
3549 * @param {Object} state Global application state.
3550 * @param {string} panelName A string that identifies the panel.
3551 *
3552 * @return {boolean} Whether or not the panel is open.
3553 */
3554 const isEditorPanelOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, panelName) => {
3555 // For backward compatibility, we check edit-post
3556 // even though now this is in "editor" package.
3557 const openPanels = select(external_wp_preferences_namespaceObject.store).get('core', 'openPanels');
3558 return !!openPanels?.includes(panelName);
3559 });
3560
3561 /**
3562 * A block selection object.
3563 *
3564 * @typedef {Object} WPBlockSelection
3565 *
3566 * @property {string} clientId A block client ID.
3567 * @property {string} attributeKey A block attribute key.
3568 * @property {number} offset An attribute value offset, based on the rich
3569 * text value. See `wp.richText.create`.
3570 */
3571
3572 /**
3573 * Returns the current selection start.
3574 *
3575 * @param {Object} state
3576 * @return {WPBlockSelection} The selection start.
3577 *
3578 * @deprecated since Gutenberg 10.0.0.
3579 */
3580 function getEditorSelectionStart(state) {
3581 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", {
3582 since: '5.8',
3583 alternative: "select('core/editor').getEditorSelection"
3584 });
3585 return getEditedPostAttribute(state, 'selection')?.selectionStart;
3586 }
3587
3588 /**
3589 * Returns the current selection end.
3590 *
3591 * @param {Object} state
3592 * @return {WPBlockSelection} The selection end.
3593 *
3594 * @deprecated since Gutenberg 10.0.0.
3595 */
3596 function getEditorSelectionEnd(state) {
3597 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", {
3598 since: '5.8',
3599 alternative: "select('core/editor').getEditorSelection"
3600 });
3601 return getEditedPostAttribute(state, 'selection')?.selectionEnd;
3602 }
3603
3604 /**
3605 * Returns the current selection.
3606 *
3607 * @param {Object} state
3608 * @return {WPBlockSelection} The selection end.
3609 */
3610 function getEditorSelection(state) {
3611 return getEditedPostAttribute(state, 'selection');
3612 }
3613
3614 /**
3615 * Is the editor ready
3616 *
3617 * @param {Object} state
3618 * @return {boolean} is Ready.
3619 */
3620 function __unstableIsEditorReady(state) {
3621 return !!state.postId;
3622 }
3623
3624 /**
3625 * Returns the post editor settings.
3626 *
3627 * @param {Object} state Editor state.
3628 *
3629 * @return {Object} The editor settings object.
3630 */
3631 function getEditorSettings(state) {
3632 return state.editorSettings;
3633 }
3634
3635 /**
3636 * Returns the post editor's rendering mode.
3637 *
3638 * @param {Object} state Editor state.
3639 *
3640 * @return {string} Rendering mode.
3641 */
3642 function getRenderingMode(state) {
3643 return state.renderingMode;
3644 }
3645
3646 /**
3647 * Returns the current editing canvas device type.
3648 *
3649 * @param {Object} state Global application state.
3650 *
3651 * @return {string} Device type.
3652 */
3653 function getDeviceType(state) {
3654 return state.deviceType;
3655 }
3656
3657 /**
3658 * Returns true if the list view is opened.
3659 *
3660 * @param {Object} state Global application state.
3661 *
3662 * @return {boolean} Whether the list view is opened.
3663 */
3664 function isListViewOpened(state) {
3665 return state.listViewPanel;
3666 }
3667
3668 /**
3669 * Returns true if the inserter is opened.
3670 *
3671 * @param {Object} state Global application state.
3672 *
3673 * @return {boolean} Whether the inserter is opened.
3674 */
3675 function isInserterOpened(state) {
3676 return !!state.blockInserterPanel;
3677 }
3678
3679 /**
3680 * Returns the current editing mode.
3681 *
3682 * @param {Object} state Global application state.
3683 *
3684 * @return {string} Editing mode.
3685 */
3686 const getEditorMode = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
3687 var _select$get;
3688 return (_select$get = select(external_wp_preferences_namespaceObject.store).get('core', 'editorMode')) !== null && _select$get !== void 0 ? _select$get : 'visual';
3689 });
3690
3691 /*
3692 * Backward compatibility
3693 */
3694
3695 /**
3696 * Returns state object prior to a specified optimist transaction ID, or `null`
3697 * if the transaction corresponding to the given ID cannot be found.
3698 *
3699 * @deprecated since Gutenberg 9.7.0.
3700 */
3701 function getStateBeforeOptimisticTransaction() {
3702 external_wp_deprecated_default()("select('core/editor').getStateBeforeOptimisticTransaction", {
3703 since: '5.7',
3704 hint: 'No state history is kept on this store anymore'
3705 });
3706 return null;
3707 }
3708 /**
3709 * Returns true if an optimistic transaction is pending commit, for which the
3710 * before state satisfies the given predicate function.
3711 *
3712 * @deprecated since Gutenberg 9.7.0.
3713 */
3714 function inSomeHistory() {
3715 external_wp_deprecated_default()("select('core/editor').inSomeHistory", {
3716 since: '5.7',
3717 hint: 'No state history is kept on this store anymore'
3718 });
3719 return false;
3720 }
3721 function getBlockEditorSelector(name) {
3722 return (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, ...args) => {
3723 external_wp_deprecated_default()("`wp.data.select( 'core/editor' )." + name + '`', {
3724 since: '5.3',
3725 alternative: "`wp.data.select( 'core/block-editor' )." + name + '`',
3726 version: '6.2'
3727 });
3728 return select(external_wp_blockEditor_namespaceObject.store)[name](...args);
3729 });
3730 }
3731
3732 /**
3733 * @see getBlockName in core/block-editor store.
3734 */
3735 const getBlockName = getBlockEditorSelector('getBlockName');
3736
3737 /**
3738 * @see isBlockValid in core/block-editor store.
3739 */
3740 const isBlockValid = getBlockEditorSelector('isBlockValid');
3741
3742 /**
3743 * @see getBlockAttributes in core/block-editor store.
3744 */
3745 const getBlockAttributes = getBlockEditorSelector('getBlockAttributes');
3746
3747 /**
3748 * @see getBlock in core/block-editor store.
3749 */
3750 const getBlock = getBlockEditorSelector('getBlock');
3751
3752 /**
3753 * @see getBlocks in core/block-editor store.
3754 */
3755 const getBlocks = getBlockEditorSelector('getBlocks');
3756
3757 /**
3758 * @see getClientIdsOfDescendants in core/block-editor store.
3759 */
3760 const getClientIdsOfDescendants = getBlockEditorSelector('getClientIdsOfDescendants');
3761
3762 /**
3763 * @see getClientIdsWithDescendants in core/block-editor store.
3764 */
3765 const getClientIdsWithDescendants = getBlockEditorSelector('getClientIdsWithDescendants');
3766
3767 /**
3768 * @see getGlobalBlockCount in core/block-editor store.
3769 */
3770 const getGlobalBlockCount = getBlockEditorSelector('getGlobalBlockCount');
3771
3772 /**
3773 * @see getBlocksByClientId in core/block-editor store.
3774 */
3775 const getBlocksByClientId = getBlockEditorSelector('getBlocksByClientId');
3776
3777 /**
3778 * @see getBlockCount in core/block-editor store.
3779 */
3780 const getBlockCount = getBlockEditorSelector('getBlockCount');
3781
3782 /**
3783 * @see getBlockSelectionStart in core/block-editor store.
3784 */
3785 const getBlockSelectionStart = getBlockEditorSelector('getBlockSelectionStart');
3786
3787 /**
3788 * @see getBlockSelectionEnd in core/block-editor store.
3789 */
3790 const getBlockSelectionEnd = getBlockEditorSelector('getBlockSelectionEnd');
3791
3792 /**
3793 * @see getSelectedBlockCount in core/block-editor store.
3794 */
3795 const getSelectedBlockCount = getBlockEditorSelector('getSelectedBlockCount');
3796
3797 /**
3798 * @see hasSelectedBlock in core/block-editor store.
3799 */
3800 const hasSelectedBlock = getBlockEditorSelector('hasSelectedBlock');
3801
3802 /**
3803 * @see getSelectedBlockClientId in core/block-editor store.
3804 */
3805 const getSelectedBlockClientId = getBlockEditorSelector('getSelectedBlockClientId');
3806
3807 /**
3808 * @see getSelectedBlock in core/block-editor store.
3809 */
3810 const getSelectedBlock = getBlockEditorSelector('getSelectedBlock');
3811
3812 /**
3813 * @see getBlockRootClientId in core/block-editor store.
3814 */
3815 const getBlockRootClientId = getBlockEditorSelector('getBlockRootClientId');
3816
3817 /**
3818 * @see getBlockHierarchyRootClientId in core/block-editor store.
3819 */
3820 const getBlockHierarchyRootClientId = getBlockEditorSelector('getBlockHierarchyRootClientId');
3821
3822 /**
3823 * @see getAdjacentBlockClientId in core/block-editor store.
3824 */
3825 const getAdjacentBlockClientId = getBlockEditorSelector('getAdjacentBlockClientId');
3826
3827 /**
3828 * @see getPreviousBlockClientId in core/block-editor store.
3829 */
3830 const getPreviousBlockClientId = getBlockEditorSelector('getPreviousBlockClientId');
3831
3832 /**
3833 * @see getNextBlockClientId in core/block-editor store.
3834 */
3835 const getNextBlockClientId = getBlockEditorSelector('getNextBlockClientId');
3836
3837 /**
3838 * @see getSelectedBlocksInitialCaretPosition in core/block-editor store.
3839 */
3840 const getSelectedBlocksInitialCaretPosition = getBlockEditorSelector('getSelectedBlocksInitialCaretPosition');
3841
3842 /**
3843 * @see getMultiSelectedBlockClientIds in core/block-editor store.
3844 */
3845 const getMultiSelectedBlockClientIds = getBlockEditorSelector('getMultiSelectedBlockClientIds');
3846
3847 /**
3848 * @see getMultiSelectedBlocks in core/block-editor store.
3849 */
3850 const getMultiSelectedBlocks = getBlockEditorSelector('getMultiSelectedBlocks');
3851
3852 /**
3853 * @see getFirstMultiSelectedBlockClientId in core/block-editor store.
3854 */
3855 const getFirstMultiSelectedBlockClientId = getBlockEditorSelector('getFirstMultiSelectedBlockClientId');
3856
3857 /**
3858 * @see getLastMultiSelectedBlockClientId in core/block-editor store.
3859 */
3860 const getLastMultiSelectedBlockClientId = getBlockEditorSelector('getLastMultiSelectedBlockClientId');
3861
3862 /**
3863 * @see isFirstMultiSelectedBlock in core/block-editor store.
3864 */
3865 const isFirstMultiSelectedBlock = getBlockEditorSelector('isFirstMultiSelectedBlock');
3866
3867 /**
3868 * @see isBlockMultiSelected in core/block-editor store.
3869 */
3870 const isBlockMultiSelected = getBlockEditorSelector('isBlockMultiSelected');
3871
3872 /**
3873 * @see isAncestorMultiSelected in core/block-editor store.
3874 */
3875 const isAncestorMultiSelected = getBlockEditorSelector('isAncestorMultiSelected');
3876
3877 /**
3878 * @see getMultiSelectedBlocksStartClientId in core/block-editor store.
3879 */
3880 const getMultiSelectedBlocksStartClientId = getBlockEditorSelector('getMultiSelectedBlocksStartClientId');
3881
3882 /**
3883 * @see getMultiSelectedBlocksEndClientId in core/block-editor store.
3884 */
3885 const getMultiSelectedBlocksEndClientId = getBlockEditorSelector('getMultiSelectedBlocksEndClientId');
3886
3887 /**
3888 * @see getBlockOrder in core/block-editor store.
3889 */
3890 const getBlockOrder = getBlockEditorSelector('getBlockOrder');
3891
3892 /**
3893 * @see getBlockIndex in core/block-editor store.
3894 */
3895 const getBlockIndex = getBlockEditorSelector('getBlockIndex');
3896
3897 /**
3898 * @see isBlockSelected in core/block-editor store.
3899 */
3900 const isBlockSelected = getBlockEditorSelector('isBlockSelected');
3901
3902 /**
3903 * @see hasSelectedInnerBlock in core/block-editor store.
3904 */
3905 const hasSelectedInnerBlock = getBlockEditorSelector('hasSelectedInnerBlock');
3906
3907 /**
3908 * @see isBlockWithinSelection in core/block-editor store.
3909 */
3910 const isBlockWithinSelection = getBlockEditorSelector('isBlockWithinSelection');
3911
3912 /**
3913 * @see hasMultiSelection in core/block-editor store.
3914 */
3915 const hasMultiSelection = getBlockEditorSelector('hasMultiSelection');
3916
3917 /**
3918 * @see isMultiSelecting in core/block-editor store.
3919 */
3920 const isMultiSelecting = getBlockEditorSelector('isMultiSelecting');
3921
3922 /**
3923 * @see isSelectionEnabled in core/block-editor store.
3924 */
3925 const isSelectionEnabled = getBlockEditorSelector('isSelectionEnabled');
3926
3927 /**
3928 * @see getBlockMode in core/block-editor store.
3929 */
3930 const getBlockMode = getBlockEditorSelector('getBlockMode');
3931
3932 /**
3933 * @see isTyping in core/block-editor store.
3934 */
3935 const isTyping = getBlockEditorSelector('isTyping');
3936
3937 /**
3938 * @see isCaretWithinFormattedText in core/block-editor store.
3939 */
3940 const isCaretWithinFormattedText = getBlockEditorSelector('isCaretWithinFormattedText');
3941
3942 /**
3943 * @see getBlockInsertionPoint in core/block-editor store.
3944 */
3945 const getBlockInsertionPoint = getBlockEditorSelector('getBlockInsertionPoint');
3946
3947 /**
3948 * @see isBlockInsertionPointVisible in core/block-editor store.
3949 */
3950 const isBlockInsertionPointVisible = getBlockEditorSelector('isBlockInsertionPointVisible');
3951
3952 /**
3953 * @see isValidTemplate in core/block-editor store.
3954 */
3955 const isValidTemplate = getBlockEditorSelector('isValidTemplate');
3956
3957 /**
3958 * @see getTemplate in core/block-editor store.
3959 */
3960 const getTemplate = getBlockEditorSelector('getTemplate');
3961
3962 /**
3963 * @see getTemplateLock in core/block-editor store.
3964 */
3965 const getTemplateLock = getBlockEditorSelector('getTemplateLock');
3966
3967 /**
3968 * @see canInsertBlockType in core/block-editor store.
3969 */
3970 const canInsertBlockType = getBlockEditorSelector('canInsertBlockType');
3971
3972 /**
3973 * @see getInserterItems in core/block-editor store.
3974 */
3975 const getInserterItems = getBlockEditorSelector('getInserterItems');
3976
3977 /**
3978 * @see hasInserterItems in core/block-editor store.
3979 */
3980 const hasInserterItems = getBlockEditorSelector('hasInserterItems');
3981
3982 /**
3983 * @see getBlockListSettings in core/block-editor store.
3984 */
3985 const getBlockListSettings = getBlockEditorSelector('getBlockListSettings');
3986
3987 /**
3988 * Returns the default template types.
3989 *
3990 * @param {Object} state Global application state.
3991 *
3992 * @return {Object} The template types.
3993 */
3994 function __experimentalGetDefaultTemplateTypes(state) {
3995 return getEditorSettings(state)?.defaultTemplateTypes;
3996 }
3997
3998 /**
3999 * Returns the default template part areas.
4000 *
4001 * @param {Object} state Global application state.
4002 *
4003 * @return {Array} The template part areas.
4004 */
4005 const __experimentalGetDefaultTemplatePartAreas = (0,external_wp_data_namespaceObject.createSelector)(state => {
4006 var _getEditorSettings$de;
4007 const areas = (_getEditorSettings$de = getEditorSettings(state)?.defaultTemplatePartAreas) !== null && _getEditorSettings$de !== void 0 ? _getEditorSettings$de : [];
4008 return areas.map(item => {
4009 return {
4010 ...item,
4011 icon: getTemplatePartIcon(item.icon)
4012 };
4013 });
4014 }, state => [getEditorSettings(state)?.defaultTemplatePartAreas]);
4015
4016 /**
4017 * Returns a default template type searched by slug.
4018 *
4019 * @param {Object} state Global application state.
4020 * @param {string} slug The template type slug.
4021 *
4022 * @return {Object} The template type.
4023 */
4024 const __experimentalGetDefaultTemplateType = (0,external_wp_data_namespaceObject.createSelector)((state, slug) => {
4025 var _Object$values$find;
4026 const templateTypes = __experimentalGetDefaultTemplateTypes(state);
4027 if (!templateTypes) {
4028 return EMPTY_OBJECT;
4029 }
4030 return (_Object$values$find = Object.values(templateTypes).find(type => type.slug === slug)) !== null && _Object$values$find !== void 0 ? _Object$values$find : EMPTY_OBJECT;
4031 }, state => [__experimentalGetDefaultTemplateTypes(state)]);
4032
4033 /**
4034 * Given a template entity, return information about it which is ready to be
4035 * rendered, such as the title, description, and icon.
4036 *
4037 * @param {Object} state Global application state.
4038 * @param {Object} template The template for which we need information.
4039 * @return {Object} Information about the template, including title, description, and icon.
4040 */
4041 const __experimentalGetTemplateInfo = (0,external_wp_data_namespaceObject.createSelector)((state, template) => {
4042 if (!template) {
4043 return EMPTY_OBJECT;
4044 }
4045 const {
4046 description,
4047 slug,
4048 title,
4049 area
4050 } = template;
4051 const {
4052 title: defaultTitle,
4053 description: defaultDescription
4054 } = __experimentalGetDefaultTemplateType(state, slug);
4055 const templateTitle = typeof title === 'string' ? title : title?.rendered;
4056 const templateDescription = typeof description === 'string' ? description : description?.raw;
4057 const templateIcon = __experimentalGetDefaultTemplatePartAreas(state).find(item => area === item.area)?.icon || library_layout;
4058 return {
4059 title: templateTitle && templateTitle !== slug ? templateTitle : defaultTitle || slug,
4060 description: templateDescription || defaultDescription,
4061 icon: templateIcon
4062 };
4063 }, state => [__experimentalGetDefaultTemplateTypes(state), __experimentalGetDefaultTemplatePartAreas(state)]);
4064
4065 /**
4066 * Returns a post type label depending on the current post.
4067 *
4068 * @param {Object} state Global application state.
4069 *
4070 * @return {string|undefined} The post type label if available, otherwise undefined.
4071 */
4072 const getPostTypeLabel = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
4073 const currentPostType = getCurrentPostType(state);
4074 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(currentPostType);
4075 // Disable reason: Post type labels object is shaped like this.
4076 // eslint-disable-next-line camelcase
4077 return postType?.labels?.singular_name;
4078 });
4079
4080 /**
4081 * Returns true if the publish sidebar is opened.
4082 *
4083 * @param {Object} state Global application state
4084 *
4085 * @return {boolean} Whether the publish sidebar is open.
4086 */
4087 function isPublishSidebarOpened(state) {
4088 return state.publishSidebarActive;
4089 }
4090
4091 ;// CONCATENATED MODULE: external ["wp","a11y"]
4092 const external_wp_a11y_namespaceObject = window["wp"]["a11y"];
4093 ;// CONCATENATED MODULE: external ["wp","apiFetch"]
4094 const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
4095 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
4096 ;// CONCATENATED MODULE: external ["wp","notices"]
4097 const external_wp_notices_namespaceObject = window["wp"]["notices"];
4098 ;// CONCATENATED MODULE: external ["wp","hooks"]
4099 const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
4100 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/local-autosave.js
4101 /**
4102 * Function returning a sessionStorage key to set or retrieve a given post's
4103 * automatic session backup.
4104 *
4105 * Keys are crucially prefixed with 'wp-autosave-' so that wp-login.php's
4106 * `loggedout` handler can clear sessionStorage of any user-private content.
4107 *
4108 * @see https://github.com/WordPress/wordpress-develop/blob/6dad32d2aed47e6c0cf2aee8410645f6d7aba6bd/src/wp-login.php#L103
4109 *
4110 * @param {string} postId Post ID.
4111 * @param {boolean} isPostNew Whether post new.
4112 *
4113 * @return {string} sessionStorage key
4114 */
4115 function postKey(postId, isPostNew) {
4116 return `wp-autosave-block-editor-post-${isPostNew ? 'auto-draft' : postId}`;
4117 }
4118 function localAutosaveGet(postId, isPostNew) {
4119 return window.sessionStorage.getItem(postKey(postId, isPostNew));
4120 }
4121 function localAutosaveSet(postId, isPostNew, title, content, excerpt) {
4122 window.sessionStorage.setItem(postKey(postId, isPostNew), JSON.stringify({
4123 post_title: title,
4124 content,
4125 excerpt
4126 }));
4127 }
4128 function localAutosaveClear(postId, isPostNew) {
4129 window.sessionStorage.removeItem(postKey(postId, isPostNew));
4130 }
4131
4132 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/utils/notice-builder.js
4133 /**
4134 * WordPress dependencies
4135 */
4136
4137
4138 /**
4139 * Internal dependencies
4140 */
4141
4142
4143 /**
4144 * Builds the arguments for a success notification dispatch.
4145 *
4146 * @param {Object} data Incoming data to build the arguments from.
4147 *
4148 * @return {Array} Arguments for dispatch. An empty array signals no
4149 * notification should be sent.
4150 */
4151 function getNotificationArgumentsForSaveSuccess(data) {
4152 var _postType$viewable;
4153 const {
4154 previousPost,
4155 post,
4156 postType
4157 } = data;
4158 // Autosaves are neither shown a notice nor redirected.
4159 if (data.options?.isAutosave) {
4160 return [];
4161 }
4162 const publishStatus = ['publish', 'private', 'future'];
4163 const isPublished = publishStatus.includes(previousPost.status);
4164 const willPublish = publishStatus.includes(post.status);
4165 const willTrash = post.status === 'trash' && previousPost.status !== 'trash';
4166 let noticeMessage;
4167 let shouldShowLink = (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false;
4168 let isDraft;
4169
4170 // Always should a notice, which will be spoken for accessibility.
4171 if (willTrash) {
4172 noticeMessage = postType.labels.item_trashed;
4173 shouldShowLink = false;
4174 } else if (!isPublished && !willPublish) {
4175 // If saving a non-published post, don't show notice.
4176 noticeMessage = (0,external_wp_i18n_namespaceObject.__)('Draft saved.');
4177 isDraft = true;
4178 } else if (isPublished && !willPublish) {
4179 // If undoing publish status, show specific notice.
4180 noticeMessage = postType.labels.item_reverted_to_draft;
4181 shouldShowLink = false;
4182 } else if (!isPublished && willPublish) {
4183 // If publishing or scheduling a post, show the corresponding
4184 // publish message.
4185 noticeMessage = {
4186 publish: postType.labels.item_published,
4187 private: postType.labels.item_published_privately,
4188 future: postType.labels.item_scheduled
4189 }[post.status];
4190 } else {
4191 // Generic fallback notice.
4192 noticeMessage = postType.labels.item_updated;
4193 }
4194 const actions = [];
4195 if (shouldShowLink) {
4196 actions.push({
4197 label: isDraft ? (0,external_wp_i18n_namespaceObject.__)('View Preview') : postType.labels.view_item,
4198 url: post.link
4199 });
4200 }
4201 return [noticeMessage, {
4202 id: SAVE_POST_NOTICE_ID,
4203 type: 'snackbar',
4204 actions
4205 }];
4206 }
4207
4208 /**
4209 * Builds the fail notification arguments for dispatch.
4210 *
4211 * @param {Object} data Incoming data to build the arguments with.
4212 *
4213 * @return {Array} Arguments for dispatch. An empty array signals no
4214 * notification should be sent.
4215 */
4216 function getNotificationArgumentsForSaveFail(data) {
4217 const {
4218 post,
4219 edits,
4220 error
4221 } = data;
4222 if (error && 'rest_autosave_no_changes' === error.code) {
4223 // Autosave requested a new autosave, but there were no changes. This shouldn't
4224 // result in an error notice for the user.
4225 return [];
4226 }
4227 const publishStatus = ['publish', 'private', 'future'];
4228 const isPublished = publishStatus.indexOf(post.status) !== -1;
4229 // If the post was being published, we show the corresponding publish error message
4230 // Unless we publish an "updating failed" message.
4231 const messages = {
4232 publish: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'),
4233 private: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'),
4234 future: (0,external_wp_i18n_namespaceObject.__)('Scheduling failed.')
4235 };
4236 let noticeMessage = !isPublished && publishStatus.indexOf(edits.status) !== -1 ? messages[edits.status] : (0,external_wp_i18n_namespaceObject.__)('Updating failed.');
4237
4238 // Check if message string contains HTML. Notice text is currently only
4239 // supported as plaintext, and stripping the tags may muddle the meaning.
4240 if (error.message && !/<\/?[^>]*>/.test(error.message)) {
4241 noticeMessage = [noticeMessage, error.message].join(' ');
4242 }
4243 return [noticeMessage, {
4244 id: SAVE_POST_NOTICE_ID
4245 }];
4246 }
4247
4248 /**
4249 * Builds the trash fail notification arguments for dispatch.
4250 *
4251 * @param {Object} data
4252 *
4253 * @return {Array} Arguments for dispatch.
4254 */
4255 function getNotificationArgumentsForTrashFail(data) {
4256 return [data.error.message && data.error.code !== 'unknown_error' ? data.error.message : (0,external_wp_i18n_namespaceObject.__)('Trashing failed'), {
4257 id: TRASH_POST_NOTICE_ID
4258 }];
4259 }
4260
4261 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/actions.js
4262 /**
4263 * WordPress dependencies
4264 */
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
4275
4276 /**
4277 * Internal dependencies
4278 */
4279
4280
4281
4282
4283 /**
4284 * Returns an action generator used in signalling that editor has initialized with
4285 * the specified post object and editor settings.
4286 *
4287 * @param {Object} post Post object.
4288 * @param {Object} edits Initial edited attributes object.
4289 * @param {Array?} template Block Template.
4290 */
4291 const setupEditor = (post, edits, template) => ({
4292 dispatch
4293 }) => {
4294 dispatch.setEditedPost(post.type, post.id);
4295 // Apply a template for new posts only, if exists.
4296 const isNewPost = post.status === 'auto-draft';
4297 if (isNewPost && template) {
4298 // In order to ensure maximum of a single parse during setup, edits are
4299 // included as part of editor setup action. Assume edited content as
4300 // canonical if provided, falling back to post.
4301 let content;
4302 if ('content' in edits) {
4303 content = edits.content;
4304 } else {
4305 content = post.content.raw;
4306 }
4307 let blocks = (0,external_wp_blocks_namespaceObject.parse)(content);
4308 blocks = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(blocks, template);
4309 dispatch.resetEditorBlocks(blocks, {
4310 __unstableShouldCreateUndoLevel: false
4311 });
4312 }
4313 if (edits && Object.values(edits).some(([key, edit]) => {
4314 var _post$key$raw;
4315 return edit !== ((_post$key$raw = post[key]?.raw) !== null && _post$key$raw !== void 0 ? _post$key$raw : post[key]);
4316 })) {
4317 dispatch.editPost(edits);
4318 }
4319 };
4320
4321 /**
4322 * Returns an action object signalling that the editor is being destroyed and
4323 * that any necessary state or side-effect cleanup should occur.
4324 *
4325 * @deprecated
4326 *
4327 * @return {Object} Action object.
4328 */
4329 function __experimentalTearDownEditor() {
4330 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).__experimentalTearDownEditor", {
4331 since: '6.5'
4332 });
4333 return {
4334 type: 'DO_NOTHING'
4335 };
4336 }
4337
4338 /**
4339 * Returns an action object used in signalling that the latest version of the
4340 * post has been received, either by initialization or save.
4341 *
4342 * @deprecated Since WordPress 6.0.
4343 */
4344 function resetPost() {
4345 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).resetPost", {
4346 since: '6.0',
4347 version: '6.3',
4348 alternative: 'Initialize the editor with the setupEditorState action'
4349 });
4350 return {
4351 type: 'DO_NOTHING'
4352 };
4353 }
4354
4355 /**
4356 * Returns an action object used in signalling that a patch of updates for the
4357 * latest version of the post have been received.
4358 *
4359 * @return {Object} Action object.
4360 * @deprecated since Gutenberg 9.7.0.
4361 */
4362 function updatePost() {
4363 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).updatePost", {
4364 since: '5.7',
4365 alternative: 'Use the core entities store instead'
4366 });
4367 return {
4368 type: 'DO_NOTHING'
4369 };
4370 }
4371
4372 /**
4373 * Setup the editor state.
4374 *
4375 * @deprecated
4376 *
4377 * @param {Object} post Post object.
4378 */
4379 function setupEditorState(post) {
4380 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).setupEditorState", {
4381 since: '6.5',
4382 alternative: "wp.data.dispatch( 'core/editor' ).setEditedPost"
4383 });
4384 return setEditedPost(post.type, post.id);
4385 }
4386
4387 /**
4388 * Returns an action that sets the current post Type and post ID.
4389 *
4390 * @param {string} postType Post Type.
4391 * @param {string} postId Post ID.
4392 *
4393 * @return {Object} Action object.
4394 */
4395 function setEditedPost(postType, postId) {
4396 return {
4397 type: 'SET_EDITED_POST',
4398 postType,
4399 postId
4400 };
4401 }
4402
4403 /**
4404 * Returns an action object used in signalling that attributes of the post have
4405 * been edited.
4406 *
4407 * @param {Object} edits Post attributes to edit.
4408 * @param {Object} options Options for the edit.
4409 */
4410 const editPost = (edits, options) => ({
4411 select,
4412 registry
4413 }) => {
4414 const {
4415 id,
4416 type
4417 } = select.getCurrentPost();
4418 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', type, id, edits, options);
4419 };
4420
4421 /**
4422 * Action for saving the current post in the editor.
4423 *
4424 * @param {Object} options
4425 */
4426 const savePost = (options = {}) => async ({
4427 select,
4428 dispatch,
4429 registry
4430 }) => {
4431 if (!select.isEditedPostSaveable()) {
4432 return;
4433 }
4434 const content = select.getEditedPostContent();
4435 if (!options.isAutosave) {
4436 dispatch.editPost({
4437 content
4438 }, {
4439 undoIgnore: true
4440 });
4441 }
4442 const previousRecord = select.getCurrentPost();
4443 const edits = {
4444 id: previousRecord.id,
4445 ...registry.select(external_wp_coreData_namespaceObject.store).getEntityRecordNonTransientEdits('postType', previousRecord.type, previousRecord.id),
4446 content
4447 };
4448 dispatch({
4449 type: 'REQUEST_POST_UPDATE_START',
4450 options
4451 });
4452 await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', previousRecord.type, edits, options);
4453 let error = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', previousRecord.type, previousRecord.id);
4454 if (!error) {
4455 await (0,external_wp_hooks_namespaceObject.applyFilters)('editor.__unstableSavePost', Promise.resolve(), options).catch(err => {
4456 error = err;
4457 });
4458 }
4459 dispatch({
4460 type: 'REQUEST_POST_UPDATE_FINISH',
4461 options
4462 });
4463 if (error) {
4464 const args = getNotificationArgumentsForSaveFail({
4465 post: previousRecord,
4466 edits,
4467 error
4468 });
4469 if (args.length) {
4470 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...args);
4471 }
4472 } else {
4473 const updatedRecord = select.getCurrentPost();
4474 const args = getNotificationArgumentsForSaveSuccess({
4475 previousPost: previousRecord,
4476 post: updatedRecord,
4477 postType: await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(updatedRecord.type),
4478 options
4479 });
4480 if (args.length) {
4481 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(...args);
4482 }
4483 // Make sure that any edits after saving create an undo level and are
4484 // considered for change detection.
4485 if (!options.isAutosave) {
4486 registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableMarkLastChangeAsPersistent();
4487 }
4488 }
4489 };
4490
4491 /**
4492 * Action for refreshing the current post.
4493 *
4494 * @deprecated Since WordPress 6.0.
4495 */
4496 function refreshPost() {
4497 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).refreshPost", {
4498 since: '6.0',
4499 version: '6.3',
4500 alternative: 'Use the core entities store instead'
4501 });
4502 return {
4503 type: 'DO_NOTHING'
4504 };
4505 }
4506
4507 /**
4508 * Action for trashing the current post in the editor.
4509 */
4510 const trashPost = () => async ({
4511 select,
4512 dispatch,
4513 registry
4514 }) => {
4515 const postTypeSlug = select.getCurrentPostType();
4516 const postType = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
4517 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(TRASH_POST_NOTICE_ID);
4518 const {
4519 rest_base: restBase,
4520 rest_namespace: restNamespace = 'wp/v2'
4521 } = postType;
4522 dispatch({
4523 type: 'REQUEST_POST_DELETE_START'
4524 });
4525 try {
4526 const post = select.getCurrentPost();
4527 await external_wp_apiFetch_default()({
4528 path: `/${restNamespace}/${restBase}/${post.id}`,
4529 method: 'DELETE'
4530 });
4531 await dispatch.savePost();
4532 } catch (error) {
4533 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...getNotificationArgumentsForTrashFail({
4534 error
4535 }));
4536 }
4537 dispatch({
4538 type: 'REQUEST_POST_DELETE_FINISH'
4539 });
4540 };
4541
4542 /**
4543 * Action that autosaves the current post. This
4544 * includes server-side autosaving (default) and client-side (a.k.a. local)
4545 * autosaving (e.g. on the Web, the post might be committed to Session
4546 * Storage).
4547 *
4548 * @param {Object?} options Extra flags to identify the autosave.
4549 */
4550 const autosave = ({
4551 local = false,
4552 ...options
4553 } = {}) => async ({
4554 select,
4555 dispatch
4556 }) => {
4557 const post = select.getCurrentPost();
4558
4559 // Currently template autosaving is not supported.
4560 if (post.type === 'wp_template') {
4561 return;
4562 }
4563 if (local) {
4564 const isPostNew = select.isEditedPostNew();
4565 const title = select.getEditedPostAttribute('title');
4566 const content = select.getEditedPostAttribute('content');
4567 const excerpt = select.getEditedPostAttribute('excerpt');
4568 localAutosaveSet(post.id, isPostNew, title, content, excerpt);
4569 } else {
4570 await dispatch.savePost({
4571 isAutosave: true,
4572 ...options
4573 });
4574 }
4575 };
4576 const __unstableSaveForPreview = ({
4577 forceIsAutosaveable
4578 } = {}) => async ({
4579 select,
4580 dispatch
4581 }) => {
4582 if ((forceIsAutosaveable || select.isEditedPostAutosaveable()) && !select.isPostLocked()) {
4583 const isDraft = ['draft', 'auto-draft'].includes(select.getEditedPostAttribute('status'));
4584 if (isDraft) {
4585 await dispatch.savePost({
4586 isPreview: true
4587 });
4588 } else {
4589 await dispatch.autosave({
4590 isPreview: true
4591 });
4592 }
4593 }
4594 return select.getEditedPostPreviewLink();
4595 };
4596
4597 /**
4598 * Action that restores last popped state in undo history.
4599 */
4600 const redo = () => ({
4601 registry
4602 }) => {
4603 registry.dispatch(external_wp_coreData_namespaceObject.store).redo();
4604 };
4605
4606 /**
4607 * Action that pops a record from undo history and undoes the edit.
4608 */
4609 const undo = () => ({
4610 registry
4611 }) => {
4612 registry.dispatch(external_wp_coreData_namespaceObject.store).undo();
4613 };
4614
4615 /**
4616 * Action that creates an undo history record.
4617 *
4618 * @deprecated Since WordPress 6.0
4619 */
4620 function createUndoLevel() {
4621 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).createUndoLevel", {
4622 since: '6.0',
4623 version: '6.3',
4624 alternative: 'Use the core entities store instead'
4625 });
4626 return {
4627 type: 'DO_NOTHING'
4628 };
4629 }
4630
4631 /**
4632 * Action that locks the editor.
4633 *
4634 * @param {Object} lock Details about the post lock status, user, and nonce.
4635 * @return {Object} Action object.
4636 */
4637 function updatePostLock(lock) {
4638 return {
4639 type: 'UPDATE_POST_LOCK',
4640 lock
4641 };
4642 }
4643
4644 /**
4645 * Enable the publish sidebar.
4646 */
4647 const enablePublishSidebar = () => ({
4648 registry
4649 }) => {
4650 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'isPublishSidebarEnabled', true);
4651 };
4652
4653 /**
4654 * Disables the publish sidebar.
4655 */
4656 const disablePublishSidebar = () => ({
4657 registry
4658 }) => {
4659 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'isPublishSidebarEnabled', false);
4660 };
4661
4662 /**
4663 * Action that locks post saving.
4664 *
4665 * @param {string} lockName The lock name.
4666 *
4667 * @example
4668 * ```
4669 * const { subscribe } = wp.data;
4670 *
4671 * const initialPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
4672 *
4673 * // Only allow publishing posts that are set to a future date.
4674 * if ( 'publish' !== initialPostStatus ) {
4675 *
4676 * // Track locking.
4677 * let locked = false;
4678 *
4679 * // Watch for the publish event.
4680 * let unssubscribe = subscribe( () => {
4681 * const currentPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
4682 * if ( 'publish' !== currentPostStatus ) {
4683 *
4684 * // Compare the post date to the current date, lock the post if the date isn't in the future.
4685 * const postDate = new Date( wp.data.select( 'core/editor' ).getEditedPostAttribute( 'date' ) );
4686 * const currentDate = new Date();
4687 * if ( postDate.getTime() <= currentDate.getTime() ) {
4688 * if ( ! locked ) {
4689 * locked = true;
4690 * wp.data.dispatch( 'core/editor' ).lockPostSaving( 'futurelock' );
4691 * }
4692 * } else {
4693 * if ( locked ) {
4694 * locked = false;
4695 * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'futurelock' );
4696 * }
4697 * }
4698 * }
4699 * } );
4700 * }
4701 * ```
4702 *
4703 * @return {Object} Action object
4704 */
4705 function lockPostSaving(lockName) {
4706 return {
4707 type: 'LOCK_POST_SAVING',
4708 lockName
4709 };
4710 }
4711
4712 /**
4713 * Action that unlocks post saving.
4714 *
4715 * @param {string} lockName The lock name.
4716 *
4717 * @example
4718 * ```
4719 * // Unlock post saving with the lock key `mylock`:
4720 * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'mylock' );
4721 * ```
4722 *
4723 * @return {Object} Action object
4724 */
4725 function unlockPostSaving(lockName) {
4726 return {
4727 type: 'UNLOCK_POST_SAVING',
4728 lockName
4729 };
4730 }
4731
4732 /**
4733 * Action that locks post autosaving.
4734 *
4735 * @param {string} lockName The lock name.
4736 *
4737 * @example
4738 * ```
4739 * // Lock post autosaving with the lock key `mylock`:
4740 * wp.data.dispatch( 'core/editor' ).lockPostAutosaving( 'mylock' );
4741 * ```
4742 *
4743 * @return {Object} Action object
4744 */
4745 function lockPostAutosaving(lockName) {
4746 return {
4747 type: 'LOCK_POST_AUTOSAVING',
4748 lockName
4749 };
4750 }
4751
4752 /**
4753 * Action that unlocks post autosaving.
4754 *
4755 * @param {string} lockName The lock name.
4756 *
4757 * @example
4758 * ```
4759 * // Unlock post saving with the lock key `mylock`:
4760 * wp.data.dispatch( 'core/editor' ).unlockPostAutosaving( 'mylock' );
4761 * ```
4762 *
4763 * @return {Object} Action object
4764 */
4765 function unlockPostAutosaving(lockName) {
4766 return {
4767 type: 'UNLOCK_POST_AUTOSAVING',
4768 lockName
4769 };
4770 }
4771
4772 /**
4773 * Returns an action object used to signal that the blocks have been updated.
4774 *
4775 * @param {Array} blocks Block Array.
4776 * @param {?Object} options Optional options.
4777 */
4778 const resetEditorBlocks = (blocks, options = {}) => ({
4779 select,
4780 dispatch,
4781 registry
4782 }) => {
4783 const {
4784 __unstableShouldCreateUndoLevel,
4785 selection
4786 } = options;
4787 const edits = {
4788 blocks,
4789 selection
4790 };
4791 if (__unstableShouldCreateUndoLevel !== false) {
4792 const {
4793 id,
4794 type
4795 } = select.getCurrentPost();
4796 const noChange = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', type, id).blocks === edits.blocks;
4797 if (noChange) {
4798 registry.dispatch(external_wp_coreData_namespaceObject.store).__unstableCreateUndoLevel('postType', type, id);
4799 return;
4800 }
4801
4802 // We create a new function here on every persistent edit
4803 // to make sure the edit makes the post dirty and creates
4804 // a new undo level.
4805 edits.content = ({
4806 blocks: blocksForSerialization = []
4807 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
4808 }
4809 dispatch.editPost(edits);
4810 };
4811
4812 /*
4813 * Returns an action object used in signalling that the post editor settings have been updated.
4814 *
4815 * @param {Object} settings Updated settings
4816 *
4817 * @return {Object} Action object
4818 */
4819 function updateEditorSettings(settings) {
4820 return {
4821 type: 'UPDATE_EDITOR_SETTINGS',
4822 settings
4823 };
4824 }
4825
4826 /**
4827 * Returns an action used to set the rendering mode of the post editor. We support multiple rendering modes:
4828 *
4829 * - `post-only`: This mode extracts the post blocks from the template and renders only those. The idea is to allow the user to edit the post/page in isolation without the wrapping template.
4830 * - `template-locked`: This mode renders both the template and the post blocks but the template blocks are locked and can't be edited. The post blocks are editable.
4831 *
4832 * @param {string} mode Mode (one of 'post-only' or 'template-locked').
4833 */
4834 const setRenderingMode = mode => ({
4835 dispatch,
4836 registry,
4837 select
4838 }) => {
4839 if (select.__unstableIsEditorReady()) {
4840 // We clear the block selection but we also need to clear the selection from the core store.
4841 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
4842 dispatch.editPost({
4843 selection: undefined
4844 }, {
4845 undoIgnore: true
4846 });
4847 }
4848 dispatch({
4849 type: 'SET_RENDERING_MODE',
4850 mode
4851 });
4852 };
4853
4854 /**
4855 * Action that changes the width of the editing canvas.
4856 *
4857 * @param {string} deviceType
4858 *
4859 * @return {Object} Action object.
4860 */
4861 function setDeviceType(deviceType) {
4862 return {
4863 type: 'SET_DEVICE_TYPE',
4864 deviceType
4865 };
4866 }
4867
4868 /**
4869 * Returns an action object used to enable or disable a panel in the editor.
4870 *
4871 * @param {string} panelName A string that identifies the panel to enable or disable.
4872 *
4873 * @return {Object} Action object.
4874 */
4875 const toggleEditorPanelEnabled = panelName => ({
4876 registry
4877 }) => {
4878 var _registry$select$get;
4879 const inactivePanels = (_registry$select$get = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'inactivePanels')) !== null && _registry$select$get !== void 0 ? _registry$select$get : [];
4880 const isPanelInactive = !!inactivePanels?.includes(panelName);
4881
4882 // If the panel is inactive, remove it to enable it, else add it to
4883 // make it inactive.
4884 let updatedInactivePanels;
4885 if (isPanelInactive) {
4886 updatedInactivePanels = inactivePanels.filter(invactivePanelName => invactivePanelName !== panelName);
4887 } else {
4888 updatedInactivePanels = [...inactivePanels, panelName];
4889 }
4890 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'inactivePanels', updatedInactivePanels);
4891 };
4892
4893 /**
4894 * Opens a closed panel and closes an open panel.
4895 *
4896 * @param {string} panelName A string that identifies the panel to open or close.
4897 */
4898 const toggleEditorPanelOpened = panelName => ({
4899 registry
4900 }) => {
4901 var _registry$select$get2;
4902 const openPanels = (_registry$select$get2 = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'openPanels')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : [];
4903 const isPanelOpen = !!openPanels?.includes(panelName);
4904
4905 // If the panel is open, remove it to close it, else add it to
4906 // make it open.
4907 let updatedOpenPanels;
4908 if (isPanelOpen) {
4909 updatedOpenPanels = openPanels.filter(openPanelName => openPanelName !== panelName);
4910 } else {
4911 updatedOpenPanels = [...openPanels, panelName];
4912 }
4913 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'openPanels', updatedOpenPanels);
4914 };
4915
4916 /**
4917 * Returns an action object used to remove a panel from the editor.
4918 *
4919 * @param {string} panelName A string that identifies the panel to remove.
4920 *
4921 * @return {Object} Action object.
4922 */
4923 function removeEditorPanel(panelName) {
4924 return {
4925 type: 'REMOVE_PANEL',
4926 panelName
4927 };
4928 }
4929
4930 /**
4931 * Returns an action object used to open/close the inserter.
4932 *
4933 * @param {boolean|Object} value Whether the inserter should be
4934 * opened (true) or closed (false).
4935 * To specify an insertion point,
4936 * use an object.
4937 * @param {string} value.rootClientId The root client ID to insert at.
4938 * @param {number} value.insertionIndex The index to insert at.
4939 *
4940 * @return {Object} Action object.
4941 */
4942 function setIsInserterOpened(value) {
4943 return {
4944 type: 'SET_IS_INSERTER_OPENED',
4945 value
4946 };
4947 }
4948
4949 /**
4950 * Returns an action object used to open/close the list view.
4951 *
4952 * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.
4953 * @return {Object} Action object.
4954 */
4955 function setIsListViewOpened(isOpen) {
4956 return {
4957 type: 'SET_IS_LIST_VIEW_OPENED',
4958 isOpen
4959 };
4960 }
4961
4962 /**
4963 * Action that toggles Distraction free mode.
4964 * Distraction free mode expects there are no sidebars, as due to the
4965 * z-index values set, you can't close sidebars.
4966 */
4967 const toggleDistractionFree = () => ({
4968 dispatch,
4969 registry
4970 }) => {
4971 const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree');
4972 if (isDistractionFree) {
4973 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', false);
4974 }
4975 if (!isDistractionFree) {
4976 registry.batch(() => {
4977 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', true);
4978 dispatch.setIsInserterOpened(false);
4979 dispatch.setIsListViewOpened(false);
4980 });
4981 }
4982 registry.batch(() => {
4983 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'distractionFree', !isDistractionFree);
4984 registry.dispatch(external_wp_notices_namespaceObject.store).createInfoNotice(isDistractionFree ? (0,external_wp_i18n_namespaceObject.__)('Distraction free off.') : (0,external_wp_i18n_namespaceObject.__)('Distraction free on.'), {
4985 id: 'core/editor/distraction-free-mode/notice',
4986 type: 'snackbar',
4987 actions: [{
4988 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
4989 onClick: () => {
4990 registry.batch(() => {
4991 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', isDistractionFree ? true : false);
4992 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core', 'distractionFree');
4993 });
4994 }
4995 }]
4996 });
4997 });
4998 };
4999
5000 /**
5001 * Triggers an action used to switch editor mode.
5002 *
5003 * @param {string} mode The editor mode.
5004 */
5005 const switchEditorMode = mode => ({
5006 dispatch,
5007 registry
5008 }) => {
5009 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'editorMode', mode);
5010
5011 // Unselect blocks when we switch to a non visual mode.
5012 if (mode !== 'visual') {
5013 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
5014 }
5015 if (mode === 'visual') {
5016 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Visual editor selected'), 'assertive');
5017 } else if (mode === 'text') {
5018 const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree');
5019 if (isDistractionFree) {
5020 dispatch.toggleDistractionFree();
5021 }
5022 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Code editor selected'), 'assertive');
5023 }
5024 };
5025
5026 /**
5027 * Returns an action object used in signalling that the user opened the publish
5028 * sidebar.
5029 *
5030 * @return {Object} Action object
5031 */
5032 function openPublishSidebar() {
5033 return {
5034 type: 'OPEN_PUBLISH_SIDEBAR'
5035 };
5036 }
5037
5038 /**
5039 * Returns an action object used in signalling that the user closed the
5040 * publish sidebar.
5041 *
5042 * @return {Object} Action object.
5043 */
5044 function closePublishSidebar() {
5045 return {
5046 type: 'CLOSE_PUBLISH_SIDEBAR'
5047 };
5048 }
5049
5050 /**
5051 * Returns an action object used in signalling that the user toggles the publish sidebar.
5052 *
5053 * @return {Object} Action object
5054 */
5055 function togglePublishSidebar() {
5056 return {
5057 type: 'TOGGLE_PUBLISH_SIDEBAR'
5058 };
5059 }
5060
5061 /**
5062 * Backward compatibility
5063 */
5064
5065 const getBlockEditorAction = name => (...args) => ({
5066 registry
5067 }) => {
5068 external_wp_deprecated_default()("`wp.data.dispatch( 'core/editor' )." + name + '`', {
5069 since: '5.3',
5070 alternative: "`wp.data.dispatch( 'core/block-editor' )." + name + '`',
5071 version: '6.2'
5072 });
5073 registry.dispatch(external_wp_blockEditor_namespaceObject.store)[name](...args);
5074 };
5075
5076 /**
5077 * @see resetBlocks in core/block-editor store.
5078 */
5079 const resetBlocks = getBlockEditorAction('resetBlocks');
5080
5081 /**
5082 * @see receiveBlocks in core/block-editor store.
5083 */
5084 const receiveBlocks = getBlockEditorAction('receiveBlocks');
5085
5086 /**
5087 * @see updateBlock in core/block-editor store.
5088 */
5089 const updateBlock = getBlockEditorAction('updateBlock');
5090
5091 /**
5092 * @see updateBlockAttributes in core/block-editor store.
5093 */
5094 const updateBlockAttributes = getBlockEditorAction('updateBlockAttributes');
5095
5096 /**
5097 * @see selectBlock in core/block-editor store.
5098 */
5099 const selectBlock = getBlockEditorAction('selectBlock');
5100
5101 /**
5102 * @see startMultiSelect in core/block-editor store.
5103 */
5104 const startMultiSelect = getBlockEditorAction('startMultiSelect');
5105
5106 /**
5107 * @see stopMultiSelect in core/block-editor store.
5108 */
5109 const stopMultiSelect = getBlockEditorAction('stopMultiSelect');
5110
5111 /**
5112 * @see multiSelect in core/block-editor store.
5113 */
5114 const multiSelect = getBlockEditorAction('multiSelect');
5115
5116 /**
5117 * @see clearSelectedBlock in core/block-editor store.
5118 */
5119 const clearSelectedBlock = getBlockEditorAction('clearSelectedBlock');
5120
5121 /**
5122 * @see toggleSelection in core/block-editor store.
5123 */
5124 const toggleSelection = getBlockEditorAction('toggleSelection');
5125
5126 /**
5127 * @see replaceBlocks in core/block-editor store.
5128 */
5129 const replaceBlocks = getBlockEditorAction('replaceBlocks');
5130
5131 /**
5132 * @see replaceBlock in core/block-editor store.
5133 */
5134 const replaceBlock = getBlockEditorAction('replaceBlock');
5135
5136 /**
5137 * @see moveBlocksDown in core/block-editor store.
5138 */
5139 const moveBlocksDown = getBlockEditorAction('moveBlocksDown');
5140
5141 /**
5142 * @see moveBlocksUp in core/block-editor store.
5143 */
5144 const moveBlocksUp = getBlockEditorAction('moveBlocksUp');
5145
5146 /**
5147 * @see moveBlockToPosition in core/block-editor store.
5148 */
5149 const moveBlockToPosition = getBlockEditorAction('moveBlockToPosition');
5150
5151 /**
5152 * @see insertBlock in core/block-editor store.
5153 */
5154 const insertBlock = getBlockEditorAction('insertBlock');
5155
5156 /**
5157 * @see insertBlocks in core/block-editor store.
5158 */
5159 const insertBlocks = getBlockEditorAction('insertBlocks');
5160
5161 /**
5162 * @see showInsertionPoint in core/block-editor store.
5163 */
5164 const showInsertionPoint = getBlockEditorAction('showInsertionPoint');
5165
5166 /**
5167 * @see hideInsertionPoint in core/block-editor store.
5168 */
5169 const hideInsertionPoint = getBlockEditorAction('hideInsertionPoint');
5170
5171 /**
5172 * @see setTemplateValidity in core/block-editor store.
5173 */
5174 const setTemplateValidity = getBlockEditorAction('setTemplateValidity');
5175
5176 /**
5177 * @see synchronizeTemplate in core/block-editor store.
5178 */
5179 const synchronizeTemplate = getBlockEditorAction('synchronizeTemplate');
5180
5181 /**
5182 * @see mergeBlocks in core/block-editor store.
5183 */
5184 const mergeBlocks = getBlockEditorAction('mergeBlocks');
5185
5186 /**
5187 * @see removeBlocks in core/block-editor store.
5188 */
5189 const removeBlocks = getBlockEditorAction('removeBlocks');
5190
5191 /**
5192 * @see removeBlock in core/block-editor store.
5193 */
5194 const removeBlock = getBlockEditorAction('removeBlock');
5195
5196 /**
5197 * @see toggleBlockMode in core/block-editor store.
5198 */
5199 const toggleBlockMode = getBlockEditorAction('toggleBlockMode');
5200
5201 /**
5202 * @see startTyping in core/block-editor store.
5203 */
5204 const startTyping = getBlockEditorAction('startTyping');
5205
5206 /**
5207 * @see stopTyping in core/block-editor store.
5208 */
5209 const stopTyping = getBlockEditorAction('stopTyping');
5210
5211 /**
5212 * @see enterFormattedText in core/block-editor store.
5213 */
5214 const enterFormattedText = getBlockEditorAction('enterFormattedText');
5215
5216 /**
5217 * @see exitFormattedText in core/block-editor store.
5218 */
5219 const exitFormattedText = getBlockEditorAction('exitFormattedText');
5220
5221 /**
5222 * @see insertDefaultBlock in core/block-editor store.
5223 */
5224 const insertDefaultBlock = getBlockEditorAction('insertDefaultBlock');
5225
5226 /**
5227 * @see updateBlockListSettings in core/block-editor store.
5228 */
5229 const updateBlockListSettings = getBlockEditorAction('updateBlockListSettings');
5230
5231 ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
5232 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
5233 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/utils/is-template-revertable.js
5234 /**
5235 * Internal dependencies
5236 */
5237
5238
5239 // Copy of the function from packages/edit-site/src/utils/is-template-revertable.js
5240
5241 /**
5242 * Check if a template is revertable to its original theme-provided template file.
5243 *
5244 * @param {Object} template The template entity to check.
5245 * @return {boolean} Whether the template is revertable.
5246 */
5247 function isTemplateRevertable(template) {
5248 if (!template) {
5249 return false;
5250 }
5251 /* eslint-disable camelcase */
5252 return template?.source === TEMPLATE_ORIGINS.custom && template?.has_theme_file;
5253 /* eslint-enable camelcase */
5254 }
5255
5256 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/private-actions.js
5257 /**
5258 * WordPress dependencies
5259 */
5260
5261
5262
5263
5264
5265
5266
5267
5268
5269
5270 /**
5271 * Internal dependencies
5272 */
5273
5274
5275 /**
5276 * Returns an action object used to set which template is currently being used/edited.
5277 *
5278 * @param {string} id Template Id.
5279 *
5280 * @return {Object} Action object.
5281 */
5282 function setCurrentTemplateId(id) {
5283 return {
5284 type: 'SET_CURRENT_TEMPLATE_ID',
5285 id
5286 };
5287 }
5288
5289 /**
5290 * Create a block based template.
5291 *
5292 * @param {Object?} template Template to create and assign.
5293 */
5294 const createTemplate = template => async ({
5295 select,
5296 dispatch,
5297 registry
5298 }) => {
5299 const savedTemplate = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', 'wp_template', template);
5300 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', select.getCurrentPostType(), select.getCurrentPostId(), {
5301 template: savedTemplate.slug
5302 });
5303 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)("Custom template created. You're in template mode now."), {
5304 type: 'snackbar',
5305 actions: [{
5306 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
5307 onClick: () => dispatch.setRenderingMode(select.getEditorSettings().defaultRenderingMode)
5308 }]
5309 });
5310 return savedTemplate;
5311 };
5312
5313 /**
5314 * Update the provided block types to be visible.
5315 *
5316 * @param {string[]} blockNames Names of block types to show.
5317 */
5318 const showBlockTypes = blockNames => ({
5319 registry
5320 }) => {
5321 var _registry$select$get;
5322 const existingBlockNames = (_registry$select$get = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get !== void 0 ? _registry$select$get : [];
5323 const newBlockNames = existingBlockNames.filter(type => !(Array.isArray(blockNames) ? blockNames : [blockNames]).includes(type));
5324 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', newBlockNames);
5325 };
5326
5327 /**
5328 * Update the provided block types to be hidden.
5329 *
5330 * @param {string[]} blockNames Names of block types to hide.
5331 */
5332 const hideBlockTypes = blockNames => ({
5333 registry
5334 }) => {
5335 var _registry$select$get2;
5336 const existingBlockNames = (_registry$select$get2 = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : [];
5337 const mergedBlockNames = new Set([...existingBlockNames, ...(Array.isArray(blockNames) ? blockNames : [blockNames])]);
5338 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', [...mergedBlockNames]);
5339 };
5340
5341 /**
5342 * Save entity records marked as dirty.
5343 *
5344 * @param {Object} options Options for the action.
5345 * @param {Function} [options.onSave] Callback when saving happens.
5346 * @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.
5347 * @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.
5348 * @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.
5349 */
5350 const saveDirtyEntities = ({
5351 onSave,
5352 dirtyEntityRecords = [],
5353 entitiesToSkip = [],
5354 close
5355 } = {}) => ({
5356 registry
5357 }) => {
5358 const PUBLISH_ON_SAVE_ENTITIES = [{
5359 kind: 'postType',
5360 name: 'wp_navigation'
5361 }];
5362 const saveNoticeId = 'site-editor-save-success';
5363 const homeUrl = registry.select(external_wp_coreData_namespaceObject.store).getUnstableBase()?.home;
5364 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(saveNoticeId);
5365 const entitiesToSave = dirtyEntityRecords.filter(({
5366 kind,
5367 name,
5368 key,
5369 property
5370 }) => {
5371 return !entitiesToSkip.some(elt => elt.kind === kind && elt.name === name && elt.key === key && elt.property === property);
5372 });
5373 close?.(entitiesToSave);
5374 const siteItemsToSave = [];
5375 const pendingSavedRecords = [];
5376 entitiesToSave.forEach(({
5377 kind,
5378 name,
5379 key,
5380 property
5381 }) => {
5382 if ('root' === kind && 'site' === name) {
5383 siteItemsToSave.push(property);
5384 } else {
5385 if (PUBLISH_ON_SAVE_ENTITIES.some(typeToPublish => typeToPublish.kind === kind && typeToPublish.name === name)) {
5386 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord(kind, name, key, {
5387 status: 'publish'
5388 });
5389 }
5390 pendingSavedRecords.push(registry.dispatch(external_wp_coreData_namespaceObject.store).saveEditedEntityRecord(kind, name, key));
5391 }
5392 });
5393 if (siteItemsToSave.length) {
5394 pendingSavedRecords.push(registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalSaveSpecifiedEntityEdits('root', 'site', undefined, siteItemsToSave));
5395 }
5396 registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableMarkLastChangeAsPersistent();
5397 Promise.all(pendingSavedRecords).then(values => {
5398 return onSave ? onSave(values) : values;
5399 }).then(values => {
5400 if (values.some(value => typeof value === 'undefined')) {
5401 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Saving failed.'));
5402 } else {
5403 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Site updated.'), {
5404 type: 'snackbar',
5405 id: saveNoticeId,
5406 actions: [{
5407 label: (0,external_wp_i18n_namespaceObject.__)('View site'),
5408 url: homeUrl
5409 }]
5410 });
5411 }
5412 }).catch(error => registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(`${(0,external_wp_i18n_namespaceObject.__)('Saving failed.')} ${error}`));
5413 };
5414
5415 /**
5416 * Reverts a template to its original theme-provided file.
5417 *
5418 * @param {Object} template The template to revert.
5419 * @param {Object} [options]
5420 * @param {boolean} [options.allowUndo] Whether to allow the user to undo
5421 * reverting the template. Default true.
5422 */
5423 const revertTemplate = (template, {
5424 allowUndo = true
5425 } = {}) => async ({
5426 registry
5427 }) => {
5428 const noticeId = 'edit-site-template-reverted';
5429 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(noticeId);
5430 if (!isTemplateRevertable(template)) {
5431 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('This template is not revertable.'), {
5432 type: 'snackbar'
5433 });
5434 return;
5435 }
5436 try {
5437 const templateEntityConfig = registry.select(external_wp_coreData_namespaceObject.store).getEntityConfig('postType', template.type);
5438 if (!templateEntityConfig) {
5439 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
5440 type: 'snackbar'
5441 });
5442 return;
5443 }
5444 const fileTemplatePath = (0,external_wp_url_namespaceObject.addQueryArgs)(`${templateEntityConfig.baseURL}/${template.id}`, {
5445 context: 'edit',
5446 source: 'theme'
5447 });
5448 const fileTemplate = await external_wp_apiFetch_default()({
5449 path: fileTemplatePath
5450 });
5451 if (!fileTemplate) {
5452 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
5453 type: 'snackbar'
5454 });
5455 return;
5456 }
5457 const serializeBlocks = ({
5458 blocks: blocksForSerialization = []
5459 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
5460 const edited = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', template.type, template.id);
5461
5462 // We are fixing up the undo level here to make sure we can undo
5463 // the revert in the header toolbar correctly.
5464 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, template.id, {
5465 content: serializeBlocks,
5466 // Required to make the `undo` behave correctly.
5467 blocks: edited.blocks,
5468 // Required to revert the blocks in the editor.
5469 source: 'custom' // required to avoid turning the editor into a dirty state
5470 }, {
5471 undoIgnore: true // Required to merge this edit with the last undo level.
5472 });
5473 const blocks = (0,external_wp_blocks_namespaceObject.parse)(fileTemplate?.content?.raw);
5474 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, fileTemplate.id, {
5475 content: serializeBlocks,
5476 blocks,
5477 source: 'theme'
5478 });
5479 if (allowUndo) {
5480 const undoRevert = () => {
5481 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, edited.id, {
5482 content: serializeBlocks,
5483 blocks: edited.blocks,
5484 source: 'custom'
5485 });
5486 };
5487 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reset.'), {
5488 type: 'snackbar',
5489 id: noticeId,
5490 actions: [{
5491 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
5492 onClick: undoRevert
5493 }]
5494 });
5495 }
5496 } catch (error) {
5497 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('Template revert failed. Please reload.');
5498 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
5499 type: 'snackbar'
5500 });
5501 }
5502 };
5503
5504 /**
5505 * Action that removes an array of templates, template parts or patterns.
5506 *
5507 * @param {Array} items An array of template,template part or pattern objects to remove.
5508 */
5509 const removeTemplates = items => async ({
5510 registry
5511 }) => {
5512 const promiseResult = await Promise.allSettled(items.map(item => {
5513 return registry.dispatch(external_wp_coreData_namespaceObject.store).deleteEntityRecord('postType', item.type, item.id, {
5514 force: true
5515 }, {
5516 throwOnError: true
5517 });
5518 }));
5519
5520 // If all the promises were fulfilled with sucess.
5521 if (promiseResult.every(({
5522 status
5523 }) => status === 'fulfilled')) {
5524 let successMessage;
5525 if (items.length === 1) {
5526 // Depending on how the entity was retrieved its title might be
5527 // an object or simple string.
5528 const title = typeof items[0].title === 'string' ? items[0].title : items[0].title?.rendered;
5529 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */
5530 (0,external_wp_i18n_namespaceObject.__)('"%s" deleted.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title));
5531 } else {
5532 successMessage = (0,external_wp_i18n_namespaceObject.__)('Items deleted.');
5533 }
5534 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(successMessage, {
5535 type: 'snackbar',
5536 id: 'editor-template-deleted-success'
5537 });
5538 } else {
5539 // If there was at lease one failure.
5540 let errorMessage;
5541 // If we were trying to delete a single template.
5542 if (promiseResult.length === 1) {
5543 if (promiseResult[0].reason?.message) {
5544 errorMessage = promiseResult[0].reason.message;
5545 } else {
5546 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the item.');
5547 }
5548 // If we were trying to delete a multiple templates
5549 } else {
5550 const errorMessages = new Set();
5551 const failedPromises = promiseResult.filter(({
5552 status
5553 }) => status === 'rejected');
5554 for (const failedPromise of failedPromises) {
5555 if (failedPromise.reason?.message) {
5556 errorMessages.add(failedPromise.reason.message);
5557 }
5558 }
5559 if (errorMessages.size === 0) {
5560 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the items.');
5561 } else if (errorMessages.size === 1) {
5562 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
5563 (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the items: %s'), [...errorMessages][0]);
5564 } else {
5565 (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
5566 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while deleting the items: %s'), [...errorMessages].join(','));
5567 }
5568 }
5569 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
5570 type: 'snackbar'
5571 });
5572 }
5573 };
5574
5575 // EXTERNAL MODULE: ./node_modules/fast-deep-equal/index.js
5576 var fast_deep_equal = __webpack_require__(2303);
5577 var fast_deep_equal_default = /*#__PURE__*/__webpack_require__.n(fast_deep_equal);
5578 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/symbol.js
5579 /**
5580 * WordPress dependencies
5581 */
5582
5583
5584 const symbol = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
5585 xmlns: "http://www.w3.org/2000/svg",
5586 viewBox: "0 0 24 24",
5587 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5588 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-1 1.4l-5.6 5.6c-.1.1-.3.1-.4 0l-5.6-5.6c-.1-.1-.1-.3 0-.4l5.6-5.6s.1-.1.2-.1.1 0 .2.1l5.6 5.6c.1.1.1.3 0 .4zm-16.6-.4L10 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"
5589 })
5590 });
5591 /* harmony default export */ const library_symbol = (symbol);
5592
5593 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/navigation.js
5594 /**
5595 * WordPress dependencies
5596 */
5597
5598
5599 const navigation = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
5600 viewBox: "0 0 24 24",
5601 xmlns: "http://www.w3.org/2000/svg",
5602 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5603 d: "M12 4c-4.4 0-8 3.6-8 8s3.6 8 8 8 8-3.6 8-8-3.6-8-8-8zm0 14.5c-3.6 0-6.5-2.9-6.5-6.5S8.4 5.5 12 5.5s6.5 2.9 6.5 6.5-2.9 6.5-6.5 6.5zM9 16l4.5-3L15 8.4l-4.5 3L9 16z"
5604 })
5605 });
5606 /* harmony default export */ const library_navigation = (navigation);
5607
5608 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/page.js
5609 /**
5610 * WordPress dependencies
5611 */
5612
5613
5614
5615 const page = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, {
5616 xmlns: "http://www.w3.org/2000/svg",
5617 viewBox: "0 0 24 24",
5618 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5619 d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"
5620 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5621 d: "M17 4H7a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2ZM7 5.5h10a.5.5 0 0 1 .5.5v12a.5.5 0 0 1-.5.5H7a.5.5 0 0 1-.5-.5V6a.5.5 0 0 1 .5-.5Z"
5622 })]
5623 });
5624 /* harmony default export */ const library_page = (page);
5625
5626 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/verse.js
5627 /**
5628 * WordPress dependencies
5629 */
5630
5631
5632 const verse = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
5633 viewBox: "0 0 24 24",
5634 xmlns: "http://www.w3.org/2000/svg",
5635 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5636 d: "M17.8 2l-.9.3c-.1 0-3.6 1-5.2 2.1C10 5.5 9.3 6.5 8.9 7.1c-.6.9-1.7 4.7-1.7 6.3l-.9 2.3c-.2.4 0 .8.4 1 .1 0 .2.1.3.1.3 0 .6-.2.7-.5l.6-1.5c.3 0 .7-.1 1.2-.2.7-.1 1.4-.3 2.2-.5.8-.2 1.6-.5 2.4-.8.7-.3 1.4-.7 1.9-1.2s.8-1.2 1-1.9c.2-.7.3-1.6.4-2.4.1-.8.1-1.7.2-2.5 0-.8.1-1.5.2-2.1V2zm-1.9 5.6c-.1.8-.2 1.5-.3 2.1-.2.6-.4 1-.6 1.3-.3.3-.8.6-1.4.9-.7.3-1.4.5-2.2.8-.6.2-1.3.3-1.8.4L15 7.5c.3-.3.6-.7 1-1.1 0 .4 0 .8-.1 1.2zM6 20h8v-1.5H6V20z"
5637 })
5638 });
5639 /* harmony default export */ const library_verse = (verse);
5640
5641 ;// CONCATENATED MODULE: ./node_modules/memize/dist/index.js
5642 /**
5643 * Memize options object.
5644 *
5645 * @typedef MemizeOptions
5646 *
5647 * @property {number} [maxSize] Maximum size of the cache.
5648 */
5649
5650 /**
5651 * Internal cache entry.
5652 *
5653 * @typedef MemizeCacheNode
5654 *
5655 * @property {?MemizeCacheNode|undefined} [prev] Previous node.
5656 * @property {?MemizeCacheNode|undefined} [next] Next node.
5657 * @property {Array<*>} args Function arguments for cache
5658 * entry.
5659 * @property {*} val Function result.
5660 */
5661
5662 /**
5663 * Properties of the enhanced function for controlling cache.
5664 *
5665 * @typedef MemizeMemoizedFunction
5666 *
5667 * @property {()=>void} clear Clear the cache.
5668 */
5669
5670 /**
5671 * Accepts a function to be memoized, and returns a new memoized function, with
5672 * optional options.
5673 *
5674 * @template {(...args: any[]) => any} F
5675 *
5676 * @param {F} fn Function to memoize.
5677 * @param {MemizeOptions} [options] Options object.
5678 *
5679 * @return {((...args: Parameters<F>) => ReturnType<F>) & MemizeMemoizedFunction} Memoized function.
5680 */
5681 function memize(fn, options) {
5682 var size = 0;
5683
5684 /** @type {?MemizeCacheNode|undefined} */
5685 var head;
5686
5687 /** @type {?MemizeCacheNode|undefined} */
5688 var tail;
5689
5690 options = options || {};
5691
5692 function memoized(/* ...args */) {
5693 var node = head,
5694 len = arguments.length,
5695 args,
5696 i;
5697
5698 searchCache: while (node) {
5699 // Perform a shallow equality test to confirm that whether the node
5700 // under test is a candidate for the arguments passed. Two arrays
5701 // are shallowly equal if their length matches and each entry is
5702 // strictly equal between the two sets. Avoid abstracting to a
5703 // function which could incur an arguments leaking deoptimization.
5704
5705 // Check whether node arguments match arguments length
5706 if (node.args.length !== arguments.length) {
5707 node = node.next;
5708 continue;
5709 }
5710
5711 // Check whether node arguments match arguments values
5712 for (i = 0; i < len; i++) {
5713 if (node.args[i] !== arguments[i]) {
5714 node = node.next;
5715 continue searchCache;
5716 }
5717 }
5718
5719 // At this point we can assume we've found a match
5720
5721 // Surface matched node to head if not already
5722 if (node !== head) {
5723 // As tail, shift to previous. Must only shift if not also
5724 // head, since if both head and tail, there is no previous.
5725 if (node === tail) {
5726 tail = node.prev;
5727 }
5728
5729 // Adjust siblings to point to each other. If node was tail,
5730 // this also handles new tail's empty `next` assignment.
5731 /** @type {MemizeCacheNode} */ (node.prev).next = node.next;
5732 if (node.next) {
5733 node.next.prev = node.prev;
5734 }
5735
5736 node.next = head;
5737 node.prev = null;
5738 /** @type {MemizeCacheNode} */ (head).prev = node;
5739 head = node;
5740 }
5741
5742 // Return immediately
5743 return node.val;
5744 }
5745
5746 // No cached value found. Continue to insertion phase:
5747
5748 // Create a copy of arguments (avoid leaking deoptimization)
5749 args = new Array(len);
5750 for (i = 0; i < len; i++) {
5751 args[i] = arguments[i];
5752 }
5753
5754 node = {
5755 args: args,
5756
5757 // Generate the result from original function
5758 val: fn.apply(null, args),
5759 };
5760
5761 // Don't need to check whether node is already head, since it would
5762 // have been returned above already if it was
5763
5764 // Shift existing head down list
5765 if (head) {
5766 head.prev = node;
5767 node.next = head;
5768 } else {
5769 // If no head, follows that there's no tail (at initial or reset)
5770 tail = node;
5771 }
5772
5773 // Trim tail if we're reached max size and are pending cache insertion
5774 if (size === /** @type {MemizeOptions} */ (options).maxSize) {
5775 tail = /** @type {MemizeCacheNode} */ (tail).prev;
5776 /** @type {MemizeCacheNode} */ (tail).next = null;
5777 } else {
5778 size++;
5779 }
5780
5781 head = node;
5782
5783 return node.val;
5784 }
5785
5786 memoized.clear = function () {
5787 head = null;
5788 tail = null;
5789 size = 0;
5790 };
5791
5792 // Ignore reason: There's not a clear solution to create an intersection of
5793 // the function with additional properties, where the goal is to retain the
5794 // function signature of the incoming argument and add control properties
5795 // on the return value.
5796
5797 // @ts-ignore
5798 return memoized;
5799 }
5800
5801
5802
5803 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/utils/get-filtered-template-parts.js
5804 /**
5805 * External dependencies
5806 */
5807
5808
5809 /**
5810 * WordPress dependencies
5811 */
5812
5813 const EMPTY_ARRAY = [];
5814
5815 /**
5816 * Get a flattened and filtered list of template parts and the matching block for that template part.
5817 *
5818 * Takes a list of blocks defined within a template, and a list of template parts, and returns a
5819 * flattened list of template parts and the matching block for that template part.
5820 *
5821 * @param {Array} blocks Blocks to flatten.
5822 * @param {?Array} templateParts Available template parts.
5823 * @return {Array} An array of template parts and their blocks.
5824 */
5825 function getFilteredTemplatePartBlocks(blocks = EMPTY_ARRAY, templateParts) {
5826 const templatePartsById = templateParts ?
5827 // Key template parts by their ID.
5828 templateParts.reduce((newTemplateParts, part) => ({
5829 ...newTemplateParts,
5830 [part.id]: part
5831 }), {}) : {};
5832 const result = [];
5833
5834 // Iterate over all blocks, recursing into inner blocks.
5835 // Output will be based on a depth-first traversal.
5836 const stack = [...blocks];
5837 while (stack.length) {
5838 const {
5839 innerBlocks,
5840 ...block
5841 } = stack.shift();
5842 // Place inner blocks at the beginning of the stack to preserve order.
5843 stack.unshift(...innerBlocks);
5844 if ((0,external_wp_blocks_namespaceObject.isTemplatePart)(block)) {
5845 const {
5846 attributes: {
5847 theme,
5848 slug
5849 }
5850 } = block;
5851 const templatePartId = `${theme}//${slug}`;
5852 const templatePart = templatePartsById[templatePartId];
5853
5854 // Only add to output if the found template part block is in the list of available template parts.
5855 if (templatePart) {
5856 result.push({
5857 templatePart,
5858 block
5859 });
5860 }
5861 }
5862 }
5863 return result;
5864 }
5865 const memoizedGetFilteredTemplatePartBlocks = memize(getFilteredTemplatePartBlocks);
5866
5867
5868 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/private-selectors.js
5869 /**
5870 * External dependencies
5871 */
5872
5873
5874 /**
5875 * WordPress dependencies
5876 */
5877
5878
5879
5880
5881
5882 /**
5883 * Internal dependencies
5884 */
5885
5886
5887
5888 const EMPTY_INSERTION_POINT = {
5889 rootClientId: undefined,
5890 insertionIndex: undefined,
5891 filterValue: undefined
5892 };
5893
5894 /**
5895 * Get the insertion point for the inserter.
5896 *
5897 * @param {Object} state Global application state.
5898 *
5899 * @return {Object} The root client ID, index to insert at and starting filter value.
5900 */
5901 const getInsertionPoint = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)(state => {
5902 if (typeof state.blockInserterPanel === 'object') {
5903 return state.blockInserterPanel;
5904 }
5905 if (getRenderingMode(state) === 'template-locked') {
5906 const [postContentClientId] = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/post-content');
5907 if (postContentClientId) {
5908 return {
5909 rootClientId: postContentClientId,
5910 insertionIndex: undefined,
5911 filterValue: undefined
5912 };
5913 }
5914 }
5915 return EMPTY_INSERTION_POINT;
5916 }, state => {
5917 const [postContentClientId] = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/post-content');
5918 return [state.blockInserterPanel, getRenderingMode(state), postContentClientId];
5919 }));
5920 function getListViewToggleRef(state) {
5921 return state.listViewToggleRef;
5922 }
5923 function getInserterSidebarToggleRef(state) {
5924 return state.inserterSidebarToggleRef;
5925 }
5926 const CARD_ICONS = {
5927 wp_block: library_symbol,
5928 wp_navigation: library_navigation,
5929 page: library_page,
5930 post: library_verse
5931 };
5932 const getPostIcon = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, options) => {
5933 {
5934 if (postType === 'wp_template_part' || postType === 'wp_template') {
5935 return __experimentalGetDefaultTemplatePartAreas(state).find(item => options.area === item.area)?.icon || library_layout;
5936 }
5937 if (CARD_ICONS[postType]) {
5938 return CARD_ICONS[postType];
5939 }
5940 const postTypeEntity = select(external_wp_coreData_namespaceObject.store).getPostType(postType);
5941 // `icon` is the `menu_icon` property of a post type. We
5942 // only handle `dashicons` for now, even if the `menu_icon`
5943 // also supports urls and svg as values.
5944 if (postTypeEntity?.icon?.startsWith('dashicons-')) {
5945 return postTypeEntity.icon.slice(10);
5946 }
5947 return library_page;
5948 }
5949 });
5950
5951 /**
5952 * Returns the template parts and their blocks for the current edited template.
5953 *
5954 * @param {Object} state Global application state.
5955 * @return {Array} Template parts and their blocks in an array.
5956 */
5957 const getCurrentTemplateTemplateParts = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
5958 const templateParts = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', TEMPLATE_PART_POST_TYPE, {
5959 per_page: -1
5960 });
5961 const clientIds = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/template-part');
5962 const blocks = select(external_wp_blockEditor_namespaceObject.store).getBlocksByClientId(clientIds);
5963 return memoizedGetFilteredTemplatePartBlocks(blocks, templateParts);
5964 });
5965
5966 /**
5967 * Returns true if there are unsaved changes to the
5968 * post's meta fields, and false otherwise.
5969 *
5970 * @param {Object} state Global application state.
5971 * @param {string} postType The post type of the post.
5972 * @param {number} postId The ID of the post.
5973 *
5974 * @return {boolean} Whether there are edits or not in the meta fields of the relevant post.
5975 */
5976 const hasPostMetaChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, postId) => {
5977 const {
5978 type: currentPostType,
5979 id: currentPostId
5980 } = getCurrentPost(state);
5981 // If no postType or postId is passed, use the current post.
5982 const edits = select(external_wp_coreData_namespaceObject.store).getEntityRecordNonTransientEdits('postType', postType || currentPostType, postId || currentPostId);
5983 if (!edits?.meta) {
5984 return false;
5985 }
5986
5987 // Compare if anything apart from `footnotes` has changed.
5988 const originalPostMeta = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', postType || currentPostType, postId || currentPostId)?.meta;
5989 return !fast_deep_equal_default()({
5990 ...originalPostMeta,
5991 footnotes: undefined
5992 }, {
5993 ...edits.meta,
5994 footnotes: undefined
5995 });
5996 });
5997
5998 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/index.js
5999 /**
6000 * WordPress dependencies
6001 */
6002
6003
6004 /**
6005 * Internal dependencies
6006 */
6007
6008
6009
6010
6011
6012
6013
6014
6015 /**
6016 * Post editor data store configuration.
6017 *
6018 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
6019 *
6020 * @type {Object}
6021 */
6022 const storeConfig = {
6023 reducer: reducer,
6024 selectors: selectors_namespaceObject,
6025 actions: actions_namespaceObject
6026 };
6027
6028 /**
6029 * Store definition for the editor namespace.
6030 *
6031 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
6032 *
6033 * @type {Object}
6034 */
6035 const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
6036 ...storeConfig
6037 });
6038 (0,external_wp_data_namespaceObject.register)(store_store);
6039 unlock(store_store).registerPrivateActions(private_actions_namespaceObject);
6040 unlock(store_store).registerPrivateSelectors(private_selectors_namespaceObject);
6041
6042 ;// CONCATENATED MODULE: ./packages/editor/build-module/bindings/post-meta.js
6043 /**
6044 * WordPress dependencies
6045 */
6046
6047
6048
6049 /**
6050 * Internal dependencies
6051 */
6052
6053 /* harmony default export */ const post_meta = ({
6054 name: 'core/post-meta',
6055 label: (0,external_wp_i18n_namespaceObject._x)('Post Meta', 'block bindings source'),
6056 getPlaceholder({
6057 args
6058 }) {
6059 return args.key;
6060 },
6061 getValue({
6062 registry,
6063 context,
6064 args
6065 }) {
6066 return registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', context?.postType, context?.postId).meta?.[args.key];
6067 },
6068 setValue({
6069 registry,
6070 context,
6071 args,
6072 value
6073 }) {
6074 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', context?.postType, context?.postId, {
6075 meta: {
6076 [args.key]: value
6077 }
6078 });
6079 },
6080 canUserEditValue({
6081 select,
6082 context,
6083 args
6084 }) {
6085 const postType = context?.postType || select(store_store).getCurrentPostType();
6086
6087 // Check that editing is happening in the post editor and not a template.
6088 if (postType === 'wp_template') {
6089 return false;
6090 }
6091
6092 // Check that the custom field is not protected and available in the REST API.
6093 const isFieldExposed = !!select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', postType, context?.postId)?.meta?.[args.key];
6094 if (!isFieldExposed) {
6095 return false;
6096 }
6097
6098 // Check that the user has the capability to edit post meta.
6099 const canUserEdit = select(external_wp_coreData_namespaceObject.store).canUserEditEntityRecord('postType', context?.postType, context?.postId);
6100 if (!canUserEdit) {
6101 return false;
6102 }
6103 return true;
6104 }
6105 });
6106
6107 ;// CONCATENATED MODULE: ./packages/editor/build-module/bindings/index.js
6108 /**
6109 * WordPress dependencies
6110 */
6111
6112
6113 /**
6114 * Internal dependencies
6115 */
6116
6117
6118
6119 const {
6120 registerBlockBindingsSource
6121 } = unlock((0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store));
6122 registerBlockBindingsSource(post_meta);
6123 registerBlockBindingsSource(pattern_overrides);
6124
6125 ;// CONCATENATED MODULE: external ["wp","compose"]
6126 const external_wp_compose_namespaceObject = window["wp"]["compose"];
6127 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/custom-sources-backwards-compatibility.js
6128 /**
6129 * WordPress dependencies
6130 */
6131
6132
6133
6134
6135
6136
6137 /**
6138 * Internal dependencies
6139 */
6140
6141
6142 /** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */
6143 /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
6144
6145 /**
6146 * Object whose keys are the names of block attributes, where each value
6147 * represents the meta key to which the block attribute is intended to save.
6148 *
6149 * @see https://developer.wordpress.org/reference/functions/register_meta/
6150 *
6151 * @typedef {Object<string,string>} WPMetaAttributeMapping
6152 */
6153
6154 /**
6155 * Given a mapping of attribute names (meta source attributes) to their
6156 * associated meta key, returns a higher order component that overrides its
6157 * `attributes` and `setAttributes` props to sync any changes with the edited
6158 * post's meta keys.
6159 *
6160 * @param {WPMetaAttributeMapping} metaAttributes Meta attribute mapping.
6161 *
6162 * @return {WPHigherOrderComponent} Higher-order component.
6163 */
6164
6165 const createWithMetaAttributeSource = metaAttributes => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => ({
6166 attributes,
6167 setAttributes,
6168 ...props
6169 }) => {
6170 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
6171 const [meta, setMeta] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', postType, 'meta');
6172 const mergedAttributes = (0,external_wp_element_namespaceObject.useMemo)(() => ({
6173 ...attributes,
6174 ...Object.fromEntries(Object.entries(metaAttributes).map(([attributeKey, metaKey]) => [attributeKey, meta[metaKey]]))
6175 }), [attributes, meta]);
6176 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockEdit, {
6177 attributes: mergedAttributes,
6178 setAttributes: nextAttributes => {
6179 const nextMeta = Object.fromEntries(Object.entries(nextAttributes !== null && nextAttributes !== void 0 ? nextAttributes : {}).filter(
6180 // Filter to intersection of keys between the updated
6181 // attributes and those with an associated meta key.
6182 ([key]) => key in metaAttributes).map(([attributeKey, value]) => [
6183 // Rename the keys to the expected meta key name.
6184 metaAttributes[attributeKey], value]));
6185 if (Object.entries(nextMeta).length) {
6186 setMeta(nextMeta);
6187 }
6188 setAttributes(nextAttributes);
6189 },
6190 ...props
6191 });
6192 }, 'withMetaAttributeSource');
6193
6194 /**
6195 * Filters a registered block's settings to enhance a block's `edit` component
6196 * to upgrade meta-sourced attributes to use the post's meta entity property.
6197 *
6198 * @param {WPBlockSettings} settings Registered block settings.
6199 *
6200 * @return {WPBlockSettings} Filtered block settings.
6201 */
6202 function shimAttributeSource(settings) {
6203 var _settings$attributes;
6204 /** @type {WPMetaAttributeMapping} */
6205 const metaAttributes = Object.fromEntries(Object.entries((_settings$attributes = settings.attributes) !== null && _settings$attributes !== void 0 ? _settings$attributes : {}).filter(([, {
6206 source
6207 }]) => source === 'meta').map(([attributeKey, {
6208 meta
6209 }]) => [attributeKey, meta]));
6210 if (Object.entries(metaAttributes).length) {
6211 settings.edit = createWithMetaAttributeSource(metaAttributes)(settings.edit);
6212 }
6213 return settings;
6214 }
6215 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/editor/custom-sources-backwards-compatibility/shim-attribute-source', shimAttributeSource);
6216
6217 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/autocompleters/user.js
6218 /**
6219 * WordPress dependencies
6220 */
6221
6222
6223
6224
6225 /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
6226
6227
6228
6229 function getUserLabel(user) {
6230 const avatar = user.avatar_urls && user.avatar_urls[24] ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
6231 className: "editor-autocompleters__user-avatar",
6232 alt: "",
6233 src: user.avatar_urls[24]
6234 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
6235 className: "editor-autocompleters__no-avatar"
6236 });
6237 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
6238 children: [avatar, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
6239 className: "editor-autocompleters__user-name",
6240 children: user.name
6241 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
6242 className: "editor-autocompleters__user-slug",
6243 children: user.slug
6244 })]
6245 });
6246 }
6247
6248 /**
6249 * A user mentions completer.
6250 *
6251 * @type {WPCompleter}
6252 */
6253 /* harmony default export */ const user = ({
6254 name: 'users',
6255 className: 'editor-autocompleters__user',
6256 triggerPrefix: '@',
6257 useItems(filterValue) {
6258 const users = (0,external_wp_data_namespaceObject.useSelect)(select => {
6259 const {
6260 getUsers
6261 } = select(external_wp_coreData_namespaceObject.store);
6262 return getUsers({
6263 context: 'view',
6264 search: encodeURIComponent(filterValue)
6265 });
6266 }, [filterValue]);
6267 const options = (0,external_wp_element_namespaceObject.useMemo)(() => users ? users.map(user => ({
6268 key: `user-${user.slug}`,
6269 value: user,
6270 label: getUserLabel(user)
6271 })) : [], [users]);
6272 return [options];
6273 },
6274 getOptionCompletion(user) {
6275 return `@${user.slug}`;
6276 }
6277 });
6278
6279 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/default-autocompleters.js
6280 /**
6281 * WordPress dependencies
6282 */
6283
6284
6285 /**
6286 * Internal dependencies
6287 */
6288
6289 function setDefaultCompleters(completers = []) {
6290 // Provide copies so filters may directly modify them.
6291 completers.push({
6292 ...user
6293 });
6294 return completers;
6295 }
6296 (0,external_wp_hooks_namespaceObject.addFilter)('editor.Autocomplete.completers', 'editor/autocompleters/set-default-completers', setDefaultCompleters);
6297
6298 ;// CONCATENATED MODULE: external ["wp","mediaUtils"]
6299 const external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"];
6300 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/media-upload.js
6301 /**
6302 * WordPress dependencies
6303 */
6304
6305
6306 (0,external_wp_hooks_namespaceObject.addFilter)('editor.MediaUpload', 'core/editor/components/media-upload', () => external_wp_mediaUtils_namespaceObject.MediaUpload);
6307
6308 ;// CONCATENATED MODULE: external ["wp","patterns"]
6309 const external_wp_patterns_namespaceObject = window["wp"]["patterns"];
6310 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/pattern-overrides.js
6311 /**
6312 * WordPress dependencies
6313 */
6314
6315
6316
6317
6318
6319
6320
6321 /**
6322 * Internal dependencies
6323 */
6324
6325
6326
6327
6328
6329 const {
6330 PatternOverridesControls,
6331 ResetOverridesControl,
6332 PATTERN_TYPES,
6333 PARTIAL_SYNCING_SUPPORTED_BLOCKS,
6334 PATTERN_SYNC_TYPES
6335 } = unlock(external_wp_patterns_namespaceObject.privateApis);
6336
6337 /**
6338 * Override the default edit UI to include a new block inspector control for
6339 * assigning a partial syncing controls to supported blocks in the pattern editor.
6340 * Currently, only the `core/paragraph` block is supported.
6341 *
6342 * @param {Component} BlockEdit Original component.
6343 *
6344 * @return {Component} Wrapped component.
6345 */
6346 const withPatternOverrideControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
6347 const isSupportedBlock = Object.keys(PARTIAL_SYNCING_SUPPORTED_BLOCKS).includes(props.name);
6348 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
6349 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockEdit, {
6350 ...props
6351 }), props.isSelected && isSupportedBlock && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ControlsWithStoreSubscription, {
6352 ...props
6353 })]
6354 });
6355 });
6356
6357 // Split into a separate component to avoid a store subscription
6358 // on every block.
6359 function ControlsWithStoreSubscription(props) {
6360 const blockEditingMode = (0,external_wp_blockEditor_namespaceObject.useBlockEditingMode)();
6361 const {
6362 hasPatternOverridesSource,
6363 isEditingSyncedPattern
6364 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
6365 const {
6366 getBlockBindingsSource
6367 } = unlock(select(external_wp_blocks_namespaceObject.store));
6368 const {
6369 getCurrentPostType,
6370 getEditedPostAttribute
6371 } = select(store_store);
6372 return {
6373 // For editing link to the site editor if the theme and user permissions support it.
6374 hasPatternOverridesSource: !!getBlockBindingsSource('core/pattern-overrides'),
6375 isEditingSyncedPattern: getCurrentPostType() === PATTERN_TYPES.user && getEditedPostAttribute('meta')?.wp_pattern_sync_status !== PATTERN_SYNC_TYPES.unsynced && getEditedPostAttribute('wp_pattern_sync_status') !== PATTERN_SYNC_TYPES.unsynced
6376 };
6377 }, []);
6378 const bindings = props.attributes.metadata?.bindings;
6379 const hasPatternBindings = !!bindings && Object.values(bindings).some(binding => binding.source === 'core/pattern-overrides');
6380 const shouldShowPatternOverridesControls = isEditingSyncedPattern && blockEditingMode === 'default';
6381 const shouldShowResetOverridesControl = !isEditingSyncedPattern && !!props.attributes.metadata?.name && blockEditingMode !== 'disabled' && hasPatternBindings;
6382 if (!hasPatternOverridesSource) {
6383 return null;
6384 }
6385 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
6386 children: [shouldShowPatternOverridesControls && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternOverridesControls, {
6387 ...props
6388 }), shouldShowResetOverridesControl && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResetOverridesControl, {
6389 ...props
6390 })]
6391 });
6392 }
6393 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/with-pattern-override-controls', withPatternOverrideControls);
6394
6395 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/index.js
6396 /**
6397 * Internal dependencies
6398 */
6399
6400
6401
6402
6403
6404 ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
6405 const external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
6406 ;// CONCATENATED MODULE: ./node_modules/clsx/dist/clsx.mjs
6407 function r(e){var t,f,n="";if("string"==typeof e||"number"==typeof e)n+=e;else if("object"==typeof e)if(Array.isArray(e)){var o=e.length;for(t=0;t<o;t++)e[t]&&(f=r(e[t]))&&(n&&(n+=" "),n+=f)}else for(f in e)e[f]&&(n&&(n+=" "),n+=f);return n}function clsx(){for(var e,t,f=0,n="",o=arguments.length;f<o;f++)(e=arguments[f])&&(t=r(e))&&(n&&(n+=" "),n+=t);return n}/* harmony default export */ const dist_clsx = (clsx);
6408 ;// CONCATENATED MODULE: external ["wp","components"]
6409 const external_wp_components_namespaceObject = window["wp"]["components"];
6410 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/check.js
6411 /**
6412 * WordPress dependencies
6413 */
6414
6415
6416 const check = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
6417 xmlns: "http://www.w3.org/2000/svg",
6418 viewBox: "0 0 24 24",
6419 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
6420 d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
6421 })
6422 });
6423 /* harmony default export */ const library_check = (check);
6424
6425 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-filled.js
6426 /**
6427 * WordPress dependencies
6428 */
6429
6430
6431 const starFilled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
6432 xmlns: "http://www.w3.org/2000/svg",
6433 viewBox: "0 0 24 24",
6434 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
6435 d: "M11.776 4.454a.25.25 0 01.448 0l2.069 4.192a.25.25 0 00.188.137l4.626.672a.25.25 0 01.139.426l-3.348 3.263a.25.25 0 00-.072.222l.79 4.607a.25.25 0 01-.362.263l-4.138-2.175a.25.25 0 00-.232 0l-4.138 2.175a.25.25 0 01-.363-.263l.79-4.607a.25.25 0 00-.071-.222L4.754 9.881a.25.25 0 01.139-.426l4.626-.672a.25.25 0 00.188-.137l2.069-4.192z"
6436 })
6437 });
6438 /* harmony default export */ const star_filled = (starFilled);
6439
6440 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-empty.js
6441 /**
6442 * WordPress dependencies
6443 */
6444
6445
6446 const starEmpty = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
6447 xmlns: "http://www.w3.org/2000/svg",
6448 viewBox: "0 0 24 24",
6449 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
6450 fillRule: "evenodd",
6451 d: "M9.706 8.646a.25.25 0 01-.188.137l-4.626.672a.25.25 0 00-.139.427l3.348 3.262a.25.25 0 01.072.222l-.79 4.607a.25.25 0 00.362.264l4.138-2.176a.25.25 0 01.233 0l4.137 2.175a.25.25 0 00.363-.263l-.79-4.607a.25.25 0 01.072-.222l3.347-3.262a.25.25 0 00-.139-.427l-4.626-.672a.25.25 0 01-.188-.137l-2.069-4.192a.25.25 0 00-.448 0L9.706 8.646zM12 7.39l-.948 1.921a1.75 1.75 0 01-1.317.957l-2.12.308 1.534 1.495c.412.402.6.982.503 1.55l-.362 2.11 1.896-.997a1.75 1.75 0 011.629 0l1.895.997-.362-2.11a1.75 1.75 0 01.504-1.55l1.533-1.495-2.12-.308a1.75 1.75 0 01-1.317-.957L12 7.39z",
6452 clipRule: "evenodd"
6453 })
6454 });
6455 /* harmony default export */ const star_empty = (starEmpty);
6456
6457 ;// CONCATENATED MODULE: external ["wp","viewport"]
6458 const external_wp_viewport_namespaceObject = window["wp"]["viewport"];
6459 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close-small.js
6460 /**
6461 * WordPress dependencies
6462 */
6463
6464
6465 const closeSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
6466 xmlns: "http://www.w3.org/2000/svg",
6467 viewBox: "0 0 24 24",
6468 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
6469 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"
6470 })
6471 });
6472 /* harmony default export */ const close_small = (closeSmall);
6473
6474 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/deprecated.js
6475 /**
6476 * WordPress dependencies
6477 */
6478
6479 function normalizeComplementaryAreaScope(scope) {
6480 if (['core/edit-post', 'core/edit-site'].includes(scope)) {
6481 external_wp_deprecated_default()(`${scope} interface scope`, {
6482 alternative: 'core interface scope',
6483 hint: 'core/edit-post and core/edit-site are merging.',
6484 version: '6.6'
6485 });
6486 return 'core';
6487 }
6488 return scope;
6489 }
6490 function normalizeComplementaryAreaName(scope, name) {
6491 if (scope === 'core' && name === 'edit-site/template') {
6492 external_wp_deprecated_default()(`edit-site/template sidebar`, {
6493 alternative: 'edit-post/document',
6494 version: '6.6'
6495 });
6496 return 'edit-post/document';
6497 }
6498 if (scope === 'core' && name === 'edit-site/block-inspector') {
6499 external_wp_deprecated_default()(`edit-site/block-inspector sidebar`, {
6500 alternative: 'edit-post/block',
6501 version: '6.6'
6502 });
6503 return 'edit-post/block';
6504 }
6505 return name;
6506 }
6507
6508 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/actions.js
6509 /**
6510 * WordPress dependencies
6511 */
6512
6513
6514
6515 /**
6516 * Internal dependencies
6517 */
6518
6519
6520 /**
6521 * Set a default complementary area.
6522 *
6523 * @param {string} scope Complementary area scope.
6524 * @param {string} area Area identifier.
6525 *
6526 * @return {Object} Action object.
6527 */
6528 const setDefaultComplementaryArea = (scope, area) => {
6529 scope = normalizeComplementaryAreaScope(scope);
6530 area = normalizeComplementaryAreaName(scope, area);
6531 return {
6532 type: 'SET_DEFAULT_COMPLEMENTARY_AREA',
6533 scope,
6534 area
6535 };
6536 };
6537
6538 /**
6539 * Enable the complementary area.
6540 *
6541 * @param {string} scope Complementary area scope.
6542 * @param {string} area Area identifier.
6543 */
6544 const enableComplementaryArea = (scope, area) => ({
6545 registry,
6546 dispatch
6547 }) => {
6548 // Return early if there's no area.
6549 if (!area) {
6550 return;
6551 }
6552 scope = normalizeComplementaryAreaScope(scope);
6553 area = normalizeComplementaryAreaName(scope, area);
6554 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
6555 if (!isComplementaryAreaVisible) {
6556 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', true);
6557 }
6558 dispatch({
6559 type: 'ENABLE_COMPLEMENTARY_AREA',
6560 scope,
6561 area
6562 });
6563 };
6564
6565 /**
6566 * Disable the complementary area.
6567 *
6568 * @param {string} scope Complementary area scope.
6569 */
6570 const disableComplementaryArea = scope => ({
6571 registry
6572 }) => {
6573 scope = normalizeComplementaryAreaScope(scope);
6574 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
6575 if (isComplementaryAreaVisible) {
6576 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', false);
6577 }
6578 };
6579
6580 /**
6581 * Pins an item.
6582 *
6583 * @param {string} scope Item scope.
6584 * @param {string} item Item identifier.
6585 *
6586 * @return {Object} Action object.
6587 */
6588 const pinItem = (scope, item) => ({
6589 registry
6590 }) => {
6591 // Return early if there's no item.
6592 if (!item) {
6593 return;
6594 }
6595 scope = normalizeComplementaryAreaScope(scope);
6596 item = normalizeComplementaryAreaName(scope, item);
6597 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
6598
6599 // The item is already pinned, there's nothing to do.
6600 if (pinnedItems?.[item] === true) {
6601 return;
6602 }
6603 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', {
6604 ...pinnedItems,
6605 [item]: true
6606 });
6607 };
6608
6609 /**
6610 * Unpins an item.
6611 *
6612 * @param {string} scope Item scope.
6613 * @param {string} item Item identifier.
6614 */
6615 const unpinItem = (scope, item) => ({
6616 registry
6617 }) => {
6618 // Return early if there's no item.
6619 if (!item) {
6620 return;
6621 }
6622 scope = normalizeComplementaryAreaScope(scope);
6623 item = normalizeComplementaryAreaName(scope, item);
6624 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
6625 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', {
6626 ...pinnedItems,
6627 [item]: false
6628 });
6629 };
6630
6631 /**
6632 * Returns an action object used in signalling that a feature should be toggled.
6633 *
6634 * @param {string} scope The feature scope (e.g. core/edit-post).
6635 * @param {string} featureName The feature name.
6636 */
6637 function toggleFeature(scope, featureName) {
6638 return function ({
6639 registry
6640 }) {
6641 external_wp_deprecated_default()(`dispatch( 'core/interface' ).toggleFeature`, {
6642 since: '6.0',
6643 alternative: `dispatch( 'core/preferences' ).toggle`
6644 });
6645 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle(scope, featureName);
6646 };
6647 }
6648
6649 /**
6650 * Returns an action object used in signalling that a feature should be set to
6651 * a true or false value
6652 *
6653 * @param {string} scope The feature scope (e.g. core/edit-post).
6654 * @param {string} featureName The feature name.
6655 * @param {boolean} value The value to set.
6656 *
6657 * @return {Object} Action object.
6658 */
6659 function setFeatureValue(scope, featureName, value) {
6660 return function ({
6661 registry
6662 }) {
6663 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureValue`, {
6664 since: '6.0',
6665 alternative: `dispatch( 'core/preferences' ).set`
6666 });
6667 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, featureName, !!value);
6668 };
6669 }
6670
6671 /**
6672 * Returns an action object used in signalling that defaults should be set for features.
6673 *
6674 * @param {string} scope The feature scope (e.g. core/edit-post).
6675 * @param {Object<string, boolean>} defaults A key/value map of feature names to values.
6676 *
6677 * @return {Object} Action object.
6678 */
6679 function setFeatureDefaults(scope, defaults) {
6680 return function ({
6681 registry
6682 }) {
6683 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureDefaults`, {
6684 since: '6.0',
6685 alternative: `dispatch( 'core/preferences' ).setDefaults`
6686 });
6687 registry.dispatch(external_wp_preferences_namespaceObject.store).setDefaults(scope, defaults);
6688 };
6689 }
6690
6691 /**
6692 * Returns an action object used in signalling that the user opened a modal.
6693 *
6694 * @param {string} name A string that uniquely identifies the modal.
6695 *
6696 * @return {Object} Action object.
6697 */
6698 function openModal(name) {
6699 return {
6700 type: 'OPEN_MODAL',
6701 name
6702 };
6703 }
6704
6705 /**
6706 * Returns an action object signalling that the user closed a modal.
6707 *
6708 * @return {Object} Action object.
6709 */
6710 function closeModal() {
6711 return {
6712 type: 'CLOSE_MODAL'
6713 };
6714 }
6715
6716 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/selectors.js
6717 /**
6718 * WordPress dependencies
6719 */
6720
6721
6722
6723
6724 /**
6725 * Internal dependencies
6726 */
6727
6728
6729 /**
6730 * Returns the complementary area that is active in a given scope.
6731 *
6732 * @param {Object} state Global application state.
6733 * @param {string} scope Item scope.
6734 *
6735 * @return {string | null | undefined} The complementary area that is active in the given scope.
6736 */
6737 const getActiveComplementaryArea = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => {
6738 scope = normalizeComplementaryAreaScope(scope);
6739 const isComplementaryAreaVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
6740
6741 // Return `undefined` to indicate that the user has never toggled
6742 // visibility, this is the vanilla default. Other code relies on this
6743 // nuance in the return value.
6744 if (isComplementaryAreaVisible === undefined) {
6745 return undefined;
6746 }
6747
6748 // Return `null` to indicate the user hid the complementary area.
6749 if (isComplementaryAreaVisible === false) {
6750 return null;
6751 }
6752 return state?.complementaryAreas?.[scope];
6753 });
6754 const isComplementaryAreaLoading = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => {
6755 scope = normalizeComplementaryAreaScope(scope);
6756 const isVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
6757 const identifier = state?.complementaryAreas?.[scope];
6758 return isVisible && identifier === undefined;
6759 });
6760
6761 /**
6762 * Returns a boolean indicating if an item is pinned or not.
6763 *
6764 * @param {Object} state Global application state.
6765 * @param {string} scope Scope.
6766 * @param {string} item Item to check.
6767 *
6768 * @return {boolean} True if the item is pinned and false otherwise.
6769 */
6770 const isItemPinned = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, item) => {
6771 var _pinnedItems$item;
6772 scope = normalizeComplementaryAreaScope(scope);
6773 item = normalizeComplementaryAreaName(scope, item);
6774 const pinnedItems = select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
6775 return (_pinnedItems$item = pinnedItems?.[item]) !== null && _pinnedItems$item !== void 0 ? _pinnedItems$item : true;
6776 });
6777
6778 /**
6779 * Returns a boolean indicating whether a feature is active for a particular
6780 * scope.
6781 *
6782 * @param {Object} state The store state.
6783 * @param {string} scope The scope of the feature (e.g. core/edit-post).
6784 * @param {string} featureName The name of the feature.
6785 *
6786 * @return {boolean} Is the feature enabled?
6787 */
6788 const isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, featureName) => {
6789 external_wp_deprecated_default()(`select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
6790 since: '6.0',
6791 alternative: `select( 'core/preferences' ).get( scope, featureName )`
6792 });
6793 return !!select(external_wp_preferences_namespaceObject.store).get(scope, featureName);
6794 });
6795
6796 /**
6797 * Returns true if a modal is active, or false otherwise.
6798 *
6799 * @param {Object} state Global application state.
6800 * @param {string} modalName A string that uniquely identifies the modal.
6801 *
6802 * @return {boolean} Whether the modal is active.
6803 */
6804 function isModalActive(state, modalName) {
6805 return state.activeModal === modalName;
6806 }
6807
6808 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/reducer.js
6809 /**
6810 * WordPress dependencies
6811 */
6812
6813 function complementaryAreas(state = {}, action) {
6814 switch (action.type) {
6815 case 'SET_DEFAULT_COMPLEMENTARY_AREA':
6816 {
6817 const {
6818 scope,
6819 area
6820 } = action;
6821
6822 // If there's already an area, don't overwrite it.
6823 if (state[scope]) {
6824 return state;
6825 }
6826 return {
6827 ...state,
6828 [scope]: area
6829 };
6830 }
6831 case 'ENABLE_COMPLEMENTARY_AREA':
6832 {
6833 const {
6834 scope,
6835 area
6836 } = action;
6837 return {
6838 ...state,
6839 [scope]: area
6840 };
6841 }
6842 }
6843 return state;
6844 }
6845
6846 /**
6847 * Reducer for storing the name of the open modal, or null if no modal is open.
6848 *
6849 * @param {Object} state Previous state.
6850 * @param {Object} action Action object containing the `name` of the modal
6851 *
6852 * @return {Object} Updated state
6853 */
6854 function activeModal(state = null, action) {
6855 switch (action.type) {
6856 case 'OPEN_MODAL':
6857 return action.name;
6858 case 'CLOSE_MODAL':
6859 return null;
6860 }
6861 return state;
6862 }
6863 /* harmony default export */ const store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
6864 complementaryAreas,
6865 activeModal
6866 }));
6867
6868 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/constants.js
6869 /**
6870 * The identifier for the data store.
6871 *
6872 * @type {string}
6873 */
6874 const constants_STORE_NAME = 'core/interface';
6875
6876 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/index.js
6877 /**
6878 * WordPress dependencies
6879 */
6880
6881
6882 /**
6883 * Internal dependencies
6884 */
6885
6886
6887
6888
6889
6890 /**
6891 * Store definition for the interface namespace.
6892 *
6893 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
6894 *
6895 * @type {Object}
6896 */
6897 const store = (0,external_wp_data_namespaceObject.createReduxStore)(constants_STORE_NAME, {
6898 reducer: store_reducer,
6899 actions: store_actions_namespaceObject,
6900 selectors: store_selectors_namespaceObject
6901 });
6902
6903 // Once we build a more generic persistence plugin that works across types of stores
6904 // we'd be able to replace this with a register call.
6905 (0,external_wp_data_namespaceObject.register)(store);
6906
6907 ;// CONCATENATED MODULE: external ["wp","plugins"]
6908 const external_wp_plugins_namespaceObject = window["wp"]["plugins"];
6909 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-context/index.js
6910 /**
6911 * WordPress dependencies
6912 */
6913
6914 /* harmony default export */ const complementary_area_context = ((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
6915 return {
6916 icon: ownProps.icon || context.icon,
6917 identifier: ownProps.identifier || `${context.name}/${ownProps.name}`
6918 };
6919 }));
6920
6921 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-toggle/index.js
6922 /**
6923 * WordPress dependencies
6924 */
6925
6926
6927
6928 /**
6929 * Internal dependencies
6930 */
6931
6932
6933
6934 function ComplementaryAreaToggle({
6935 as = external_wp_components_namespaceObject.Button,
6936 scope,
6937 identifier,
6938 icon,
6939 selectedIcon,
6940 name,
6941 ...props
6942 }) {
6943 const ComponentToUse = as;
6944 const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(scope) === identifier, [identifier, scope]);
6945 const {
6946 enableComplementaryArea,
6947 disableComplementaryArea
6948 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
6949 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComponentToUse, {
6950 icon: selectedIcon && isSelected ? selectedIcon : icon,
6951 "aria-controls": identifier.replace('/', ':'),
6952 onClick: () => {
6953 if (isSelected) {
6954 disableComplementaryArea(scope);
6955 } else {
6956 enableComplementaryArea(scope, identifier);
6957 }
6958 },
6959 ...props
6960 });
6961 }
6962 /* harmony default export */ const complementary_area_toggle = (complementary_area_context(ComplementaryAreaToggle));
6963
6964 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-header/index.js
6965 /**
6966 * External dependencies
6967 */
6968
6969
6970 /**
6971 * WordPress dependencies
6972 */
6973
6974
6975 /**
6976 * Internal dependencies
6977 */
6978
6979
6980
6981
6982 const ComplementaryAreaHeader = ({
6983 smallScreenTitle,
6984 children,
6985 className,
6986 toggleButtonProps
6987 }) => {
6988 const toggleButton = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area_toggle, {
6989 icon: close_small,
6990 ...toggleButtonProps
6991 });
6992 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
6993 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
6994 className: "components-panel__header interface-complementary-area-header__small",
6995 children: [smallScreenTitle && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
6996 className: "interface-complementary-area-header__small-title",
6997 children: smallScreenTitle
6998 }), toggleButton]
6999 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7000 className: dist_clsx('components-panel__header', 'interface-complementary-area-header', className),
7001 tabIndex: -1,
7002 children: [children, toggleButton]
7003 })]
7004 });
7005 };
7006 /* harmony default export */ const complementary_area_header = (ComplementaryAreaHeader);
7007
7008 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/action-item/index.js
7009 /**
7010 * WordPress dependencies
7011 */
7012
7013
7014
7015 const noop = () => {};
7016 function ActionItemSlot({
7017 name,
7018 as: Component = external_wp_components_namespaceObject.ButtonGroup,
7019 fillProps = {},
7020 bubblesVirtually,
7021 ...props
7022 }) {
7023 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Slot, {
7024 name: name,
7025 bubblesVirtually: bubblesVirtually,
7026 fillProps: fillProps,
7027 children: fills => {
7028 if (!external_wp_element_namespaceObject.Children.toArray(fills).length) {
7029 return null;
7030 }
7031
7032 // Special handling exists for backward compatibility.
7033 // It ensures that menu items created by plugin authors aren't
7034 // duplicated with automatically injected menu items coming
7035 // from pinnable plugin sidebars.
7036 // @see https://github.com/WordPress/gutenberg/issues/14457
7037 const initializedByPlugins = [];
7038 external_wp_element_namespaceObject.Children.forEach(fills, ({
7039 props: {
7040 __unstableExplicitMenuItem,
7041 __unstableTarget
7042 }
7043 }) => {
7044 if (__unstableTarget && __unstableExplicitMenuItem) {
7045 initializedByPlugins.push(__unstableTarget);
7046 }
7047 });
7048 const children = external_wp_element_namespaceObject.Children.map(fills, child => {
7049 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(child.props.__unstableTarget)) {
7050 return null;
7051 }
7052 return child;
7053 });
7054 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Component, {
7055 ...props,
7056 children: children
7057 });
7058 }
7059 });
7060 }
7061 function ActionItem({
7062 name,
7063 as: Component = external_wp_components_namespaceObject.Button,
7064 onClick,
7065 ...props
7066 }) {
7067 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Fill, {
7068 name: name,
7069 children: ({
7070 onClick: fpOnClick
7071 }) => {
7072 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Component, {
7073 onClick: onClick || fpOnClick ? (...args) => {
7074 (onClick || noop)(...args);
7075 (fpOnClick || noop)(...args);
7076 } : undefined,
7077 ...props
7078 });
7079 }
7080 });
7081 }
7082 ActionItem.Slot = ActionItemSlot;
7083 /* harmony default export */ const action_item = (ActionItem);
7084
7085 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-more-menu-item/index.js
7086 /**
7087 * WordPress dependencies
7088 */
7089
7090
7091
7092 /**
7093 * Internal dependencies
7094 */
7095
7096
7097
7098 const PluginsMenuItem = ({
7099 // Menu item is marked with unstable prop for backward compatibility.
7100 // They are removed so they don't leak to DOM elements.
7101 // @see https://github.com/WordPress/gutenberg/issues/14457
7102 __unstableExplicitMenuItem,
7103 __unstableTarget,
7104 ...restProps
7105 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
7106 ...restProps
7107 });
7108 function ComplementaryAreaMoreMenuItem({
7109 scope,
7110 target,
7111 __unstableExplicitMenuItem,
7112 ...props
7113 }) {
7114 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area_toggle, {
7115 as: toggleProps => {
7116 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item, {
7117 __unstableExplicitMenuItem: __unstableExplicitMenuItem,
7118 __unstableTarget: `${scope}/${target}`,
7119 as: PluginsMenuItem,
7120 name: `${scope}/plugin-more-menu`,
7121 ...toggleProps
7122 });
7123 },
7124 role: "menuitemcheckbox",
7125 selectedIcon: library_check,
7126 name: target,
7127 scope: scope,
7128 ...props
7129 });
7130 }
7131
7132 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/pinned-items/index.js
7133 /**
7134 * External dependencies
7135 */
7136
7137
7138 /**
7139 * WordPress dependencies
7140 */
7141
7142
7143 function PinnedItems({
7144 scope,
7145 ...props
7146 }) {
7147 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Fill, {
7148 name: `PinnedItems/${scope}`,
7149 ...props
7150 });
7151 }
7152 function PinnedItemsSlot({
7153 scope,
7154 className,
7155 ...props
7156 }) {
7157 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Slot, {
7158 name: `PinnedItems/${scope}`,
7159 ...props,
7160 children: fills => fills?.length > 0 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
7161 className: dist_clsx(className, 'interface-pinned-items'),
7162 children: fills
7163 })
7164 });
7165 }
7166 PinnedItems.Slot = PinnedItemsSlot;
7167 /* harmony default export */ const pinned_items = (PinnedItems);
7168
7169 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area/index.js
7170 /**
7171 * External dependencies
7172 */
7173
7174
7175 /**
7176 * WordPress dependencies
7177 */
7178
7179
7180
7181
7182
7183
7184
7185
7186
7187 /**
7188 * Internal dependencies
7189 */
7190
7191
7192
7193
7194
7195
7196
7197
7198
7199 const ANIMATION_DURATION = 0.3;
7200 function ComplementaryAreaSlot({
7201 scope,
7202 ...props
7203 }) {
7204 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Slot, {
7205 name: `ComplementaryArea/${scope}`,
7206 ...props
7207 });
7208 }
7209 const SIDEBAR_WIDTH = 280;
7210 const variants = {
7211 open: {
7212 width: SIDEBAR_WIDTH
7213 },
7214 closed: {
7215 width: 0
7216 },
7217 mobileOpen: {
7218 width: '100vw'
7219 }
7220 };
7221 function ComplementaryAreaFill({
7222 activeArea,
7223 isActive,
7224 scope,
7225 children,
7226 className,
7227 id
7228 }) {
7229 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
7230 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
7231 // This is used to delay the exit animation to the next tick.
7232 // The reason this is done is to allow us to apply the right transition properties
7233 // When we switch from an open sidebar to another open sidebar.
7234 // we don't want to animate in this case.
7235 const previousActiveArea = (0,external_wp_compose_namespaceObject.usePrevious)(activeArea);
7236 const previousIsActive = (0,external_wp_compose_namespaceObject.usePrevious)(isActive);
7237 const [, setState] = (0,external_wp_element_namespaceObject.useState)({});
7238 (0,external_wp_element_namespaceObject.useEffect)(() => {
7239 setState({});
7240 }, [isActive]);
7241 const transition = {
7242 type: 'tween',
7243 duration: disableMotion || isMobileViewport || !!previousActiveArea && !!activeArea && activeArea !== previousActiveArea ? 0 : ANIMATION_DURATION,
7244 ease: [0.6, 0, 0.4, 1]
7245 };
7246 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Fill, {
7247 name: `ComplementaryArea/${scope}`,
7248 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
7249 initial: false,
7250 children: (previousIsActive || isActive) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
7251 variants: variants,
7252 initial: "closed",
7253 animate: isMobileViewport ? 'mobileOpen' : 'open',
7254 exit: "closed",
7255 transition: transition,
7256 className: "interface-complementary-area__fill",
7257 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
7258 id: id,
7259 className: className,
7260 style: {
7261 width: isMobileViewport ? '100vw' : SIDEBAR_WIDTH
7262 },
7263 children: children
7264 })
7265 })
7266 })
7267 });
7268 }
7269 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
7270 const previousIsSmall = (0,external_wp_element_namespaceObject.useRef)(false);
7271 const shouldOpenWhenNotSmall = (0,external_wp_element_namespaceObject.useRef)(false);
7272 const {
7273 enableComplementaryArea,
7274 disableComplementaryArea
7275 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
7276 (0,external_wp_element_namespaceObject.useEffect)(() => {
7277 // If the complementary area is active and the editor is switching from
7278 // a big to a small window size.
7279 if (isActive && isSmall && !previousIsSmall.current) {
7280 disableComplementaryArea(scope);
7281 // Flag the complementary area to be reopened when the window size
7282 // goes from small to big.
7283 shouldOpenWhenNotSmall.current = true;
7284 } else if (
7285 // If there is a flag indicating the complementary area should be
7286 // enabled when we go from small to big window size and we are going
7287 // from a small to big window size.
7288 shouldOpenWhenNotSmall.current && !isSmall && previousIsSmall.current) {
7289 // Remove the flag indicating the complementary area should be
7290 // enabled.
7291 shouldOpenWhenNotSmall.current = false;
7292 enableComplementaryArea(scope, identifier);
7293 } else if (
7294 // If the flag is indicating the current complementary should be
7295 // reopened but another complementary area becomes active, remove
7296 // the flag.
7297 shouldOpenWhenNotSmall.current && activeArea && activeArea !== identifier) {
7298 shouldOpenWhenNotSmall.current = false;
7299 }
7300 if (isSmall !== previousIsSmall.current) {
7301 previousIsSmall.current = isSmall;
7302 }
7303 }, [isActive, isSmall, scope, identifier, activeArea, disableComplementaryArea, enableComplementaryArea]);
7304 }
7305 function ComplementaryArea({
7306 children,
7307 className,
7308 closeLabel = (0,external_wp_i18n_namespaceObject.__)('Close plugin'),
7309 identifier,
7310 header,
7311 headerClassName,
7312 icon,
7313 isPinnable = true,
7314 panelClassName,
7315 scope,
7316 name,
7317 smallScreenTitle,
7318 title,
7319 toggleShortcut,
7320 isActiveByDefault
7321 }) {
7322 // This state is used to delay the rendering of the Fill
7323 // until the initial effect runs.
7324 // This prevents the animation from running on mount if
7325 // the complementary area is active by default.
7326 const [isReady, setIsReady] = (0,external_wp_element_namespaceObject.useState)(false);
7327 const {
7328 isLoading,
7329 isActive,
7330 isPinned,
7331 activeArea,
7332 isSmall,
7333 isLarge,
7334 showIconLabels
7335 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
7336 const {
7337 getActiveComplementaryArea,
7338 isComplementaryAreaLoading,
7339 isItemPinned
7340 } = select(store);
7341 const {
7342 get
7343 } = select(external_wp_preferences_namespaceObject.store);
7344 const _activeArea = getActiveComplementaryArea(scope);
7345 return {
7346 isLoading: isComplementaryAreaLoading(scope),
7347 isActive: _activeArea === identifier,
7348 isPinned: isItemPinned(scope, identifier),
7349 activeArea: _activeArea,
7350 isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'),
7351 isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large'),
7352 showIconLabels: get('core', 'showIconLabels')
7353 };
7354 }, [identifier, scope]);
7355 useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall);
7356 const {
7357 enableComplementaryArea,
7358 disableComplementaryArea,
7359 pinItem,
7360 unpinItem
7361 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
7362 (0,external_wp_element_namespaceObject.useEffect)(() => {
7363 // Set initial visibility: For large screens, enable if it's active by
7364 // default. For small screens, always initially disable.
7365 if (isActiveByDefault && activeArea === undefined && !isSmall) {
7366 enableComplementaryArea(scope, identifier);
7367 } else if (activeArea === undefined && isSmall) {
7368 disableComplementaryArea(scope, identifier);
7369 }
7370 setIsReady(true);
7371 }, [activeArea, isActiveByDefault, scope, identifier, isSmall, enableComplementaryArea, disableComplementaryArea]);
7372 if (!isReady) {
7373 return;
7374 }
7375 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
7376 children: [isPinnable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(pinned_items, {
7377 scope: scope,
7378 children: isPinned && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area_toggle, {
7379 scope: scope,
7380 identifier: identifier,
7381 isPressed: isActive && (!showIconLabels || isLarge),
7382 "aria-expanded": isActive,
7383 "aria-disabled": isLoading,
7384 label: title,
7385 icon: showIconLabels ? library_check : icon,
7386 showTooltip: !showIconLabels,
7387 variant: showIconLabels ? 'tertiary' : undefined,
7388 size: "compact"
7389 })
7390 }), name && isPinnable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaMoreMenuItem, {
7391 target: name,
7392 scope: scope,
7393 icon: icon,
7394 children: title
7395 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(ComplementaryAreaFill, {
7396 activeArea: activeArea,
7397 isActive: isActive,
7398 className: dist_clsx('interface-complementary-area', className),
7399 scope: scope,
7400 id: identifier.replace('/', ':'),
7401 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area_header, {
7402 className: headerClassName,
7403 closeLabel: closeLabel,
7404 onClose: () => disableComplementaryArea(scope),
7405 smallScreenTitle: smallScreenTitle,
7406 toggleButtonProps: {
7407 label: closeLabel,
7408 size: 'small',
7409 shortcut: toggleShortcut,
7410 scope,
7411 identifier
7412 },
7413 children: header || /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
7414 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
7415 className: "interface-complementary-area-header__title",
7416 children: title
7417 }), isPinnable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
7418 className: "interface-complementary-area__pin-unpin-item",
7419 icon: isPinned ? star_filled : star_empty,
7420 label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'),
7421 onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier),
7422 isPressed: isPinned,
7423 "aria-expanded": isPinned,
7424 size: "compact"
7425 })]
7426 })
7427 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Panel, {
7428 className: panelClassName,
7429 children: children
7430 })]
7431 })]
7432 });
7433 }
7434 const ComplementaryAreaWrapped = complementary_area_context(ComplementaryArea);
7435 ComplementaryAreaWrapped.Slot = ComplementaryAreaSlot;
7436 /* harmony default export */ const complementary_area = (ComplementaryAreaWrapped);
7437
7438 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/fullscreen-mode/index.js
7439 /**
7440 * WordPress dependencies
7441 */
7442
7443 const FullscreenMode = ({
7444 isActive
7445 }) => {
7446 (0,external_wp_element_namespaceObject.useEffect)(() => {
7447 let isSticky = false;
7448 // `is-fullscreen-mode` is set in PHP as a body class by Gutenberg, and this causes
7449 // `sticky-menu` to be applied by WordPress and prevents the admin menu being scrolled
7450 // even if `is-fullscreen-mode` is then removed. Let's remove `sticky-menu` here as
7451 // a consequence of the FullscreenMode setup.
7452 if (document.body.classList.contains('sticky-menu')) {
7453 isSticky = true;
7454 document.body.classList.remove('sticky-menu');
7455 }
7456 return () => {
7457 if (isSticky) {
7458 document.body.classList.add('sticky-menu');
7459 }
7460 };
7461 }, []);
7462 (0,external_wp_element_namespaceObject.useEffect)(() => {
7463 if (isActive) {
7464 document.body.classList.add('is-fullscreen-mode');
7465 } else {
7466 document.body.classList.remove('is-fullscreen-mode');
7467 }
7468 return () => {
7469 if (isActive) {
7470 document.body.classList.remove('is-fullscreen-mode');
7471 }
7472 };
7473 }, [isActive]);
7474 return null;
7475 };
7476 /* harmony default export */ const fullscreen_mode = (FullscreenMode);
7477
7478 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/navigable-region/index.js
7479 /**
7480 * External dependencies
7481 */
7482
7483
7484 function NavigableRegion({
7485 children,
7486 className,
7487 ariaLabel,
7488 as: Tag = 'div',
7489 ...props
7490 }) {
7491 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tag, {
7492 className: dist_clsx('interface-navigable-region', className),
7493 "aria-label": ariaLabel,
7494 role: "region",
7495 tabIndex: "-1",
7496 ...props,
7497 children: children
7498 });
7499 }
7500
7501 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/interface-skeleton/index.js
7502 /**
7503 * External dependencies
7504 */
7505
7506
7507 /**
7508 * WordPress dependencies
7509 */
7510
7511
7512
7513
7514
7515 /**
7516 * Internal dependencies
7517 */
7518
7519
7520
7521 const interface_skeleton_ANIMATION_DURATION = 0.25;
7522 const commonTransition = {
7523 type: 'tween',
7524 duration: interface_skeleton_ANIMATION_DURATION,
7525 ease: [0.6, 0, 0.4, 1]
7526 };
7527 function useHTMLClass(className) {
7528 (0,external_wp_element_namespaceObject.useEffect)(() => {
7529 const element = document && document.querySelector(`html:not(.${className})`);
7530 if (!element) {
7531 return;
7532 }
7533 element.classList.toggle(className);
7534 return () => {
7535 element.classList.toggle(className);
7536 };
7537 }, [className]);
7538 }
7539 const headerVariants = {
7540 hidden: {
7541 opacity: 1,
7542 marginTop: -60
7543 },
7544 visible: {
7545 opacity: 1,
7546 marginTop: 0
7547 },
7548 distractionFreeHover: {
7549 opacity: 1,
7550 marginTop: 0,
7551 transition: {
7552 ...commonTransition,
7553 delay: 0.2,
7554 delayChildren: 0.2
7555 }
7556 },
7557 distractionFreeHidden: {
7558 opacity: 0,
7559 marginTop: -60
7560 },
7561 distractionFreeDisabled: {
7562 opacity: 0,
7563 marginTop: 0,
7564 transition: {
7565 ...commonTransition,
7566 delay: 0.8,
7567 delayChildren: 0.8
7568 }
7569 }
7570 };
7571 function InterfaceSkeleton({
7572 isDistractionFree,
7573 footer,
7574 header,
7575 editorNotices,
7576 sidebar,
7577 secondarySidebar,
7578 content,
7579 actions,
7580 labels,
7581 className,
7582 enableRegionNavigation = true,
7583 // Todo: does this need to be a prop.
7584 // Can we use a dependency to keyboard-shortcuts directly?
7585 shortcuts
7586 }, ref) {
7587 const [secondarySidebarResizeListener, secondarySidebarSize] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
7588 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
7589 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
7590 const defaultTransition = {
7591 type: 'tween',
7592 duration: disableMotion ? 0 : interface_skeleton_ANIMATION_DURATION,
7593 ease: [0.6, 0, 0.4, 1]
7594 };
7595 const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)(shortcuts);
7596 useHTMLClass('interface-interface-skeleton__html-container');
7597 const defaultLabels = {
7598 /* translators: accessibility text for the top bar landmark region. */
7599 header: (0,external_wp_i18n_namespaceObject._x)('Header', 'header landmark area'),
7600 /* translators: accessibility text for the content landmark region. */
7601 body: (0,external_wp_i18n_namespaceObject.__)('Content'),
7602 /* translators: accessibility text for the secondary sidebar landmark region. */
7603 secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block Library'),
7604 /* translators: accessibility text for the settings landmark region. */
7605 sidebar: (0,external_wp_i18n_namespaceObject.__)('Settings'),
7606 /* translators: accessibility text for the publish landmark region. */
7607 actions: (0,external_wp_i18n_namespaceObject.__)('Publish'),
7608 /* translators: accessibility text for the footer landmark region. */
7609 footer: (0,external_wp_i18n_namespaceObject.__)('Footer')
7610 };
7611 const mergedLabels = {
7612 ...defaultLabels,
7613 ...labels
7614 };
7615 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7616 ...(enableRegionNavigation ? navigateRegionsProps : {}),
7617 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, enableRegionNavigation ? navigateRegionsProps.ref : undefined]),
7618 className: dist_clsx(className, 'interface-interface-skeleton', navigateRegionsProps.className, !!footer && 'has-footer'),
7619 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7620 className: "interface-interface-skeleton__editor",
7621 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
7622 initial: false,
7623 children: !!header && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7624 as: external_wp_components_namespaceObject.__unstableMotion.div,
7625 className: "interface-interface-skeleton__header",
7626 "aria-label": mergedLabels.header,
7627 initial: isDistractionFree ? 'distractionFreeHidden' : 'hidden',
7628 whileHover: isDistractionFree ? 'distractionFreeHover' : 'visible',
7629 animate: isDistractionFree ? 'distractionFreeDisabled' : 'visible',
7630 exit: isDistractionFree ? 'distractionFreeHidden' : 'hidden',
7631 variants: headerVariants,
7632 transition: defaultTransition,
7633 children: header
7634 })
7635 }), isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
7636 className: "interface-interface-skeleton__header",
7637 children: editorNotices
7638 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7639 className: "interface-interface-skeleton__body",
7640 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
7641 initial: false,
7642 children: !!secondarySidebar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7643 className: "interface-interface-skeleton__secondary-sidebar",
7644 ariaLabel: mergedLabels.secondarySidebar,
7645 as: external_wp_components_namespaceObject.__unstableMotion.div,
7646 initial: "closed",
7647 animate: isMobileViewport ? 'mobileOpen' : 'open',
7648 exit: "closed",
7649 variants: {
7650 open: {
7651 width: secondarySidebarSize.width
7652 },
7653 closed: {
7654 width: 0
7655 },
7656 mobileOpen: {
7657 width: '100vw'
7658 }
7659 },
7660 transition: defaultTransition,
7661 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7662 style: {
7663 position: 'absolute',
7664 width: isMobileViewport ? '100vw' : 'fit-content',
7665 height: '100%',
7666 right: 0
7667 },
7668 children: [secondarySidebarResizeListener, secondarySidebar]
7669 })
7670 })
7671 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7672 className: "interface-interface-skeleton__content",
7673 ariaLabel: mergedLabels.body,
7674 children: content
7675 }), !!sidebar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7676 className: "interface-interface-skeleton__sidebar",
7677 ariaLabel: mergedLabels.sidebar,
7678 children: sidebar
7679 }), !!actions && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7680 className: "interface-interface-skeleton__actions",
7681 ariaLabel: mergedLabels.actions,
7682 children: actions
7683 })]
7684 })]
7685 }), !!footer && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7686 className: "interface-interface-skeleton__footer",
7687 ariaLabel: mergedLabels.footer,
7688 children: footer
7689 })]
7690 });
7691 }
7692 /* harmony default export */ const interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton));
7693
7694 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/index.js
7695
7696
7697
7698
7699
7700
7701
7702
7703 ;// CONCATENATED MODULE: ./packages/interface/build-module/index.js
7704
7705
7706
7707 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/global-keyboard-shortcuts/index.js
7708 /**
7709 * WordPress dependencies
7710 */
7711
7712
7713
7714
7715
7716 /**
7717 * Internal dependencies
7718 */
7719
7720
7721 /**
7722 * Component handles the keyboard shortcuts for the editor.
7723 *
7724 * It provides functionality for various keyboard shortcuts such as toggling editor mode,
7725 * toggling distraction-free mode, undo/redo, saving the post, toggling list view,
7726 * and toggling the sidebar.
7727 */
7728 function EditorKeyboardShortcuts() {
7729 const isModeToggleDisabled = (0,external_wp_data_namespaceObject.useSelect)(select => {
7730 const {
7731 richEditingEnabled,
7732 codeEditingEnabled
7733 } = select(store_store).getEditorSettings();
7734 return !richEditingEnabled || !codeEditingEnabled;
7735 }, []);
7736 const {
7737 getBlockSelectionStart
7738 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
7739 const {
7740 getActiveComplementaryArea
7741 } = (0,external_wp_data_namespaceObject.useSelect)(store);
7742 const {
7743 enableComplementaryArea,
7744 disableComplementaryArea
7745 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
7746 const {
7747 redo,
7748 undo,
7749 savePost,
7750 setIsListViewOpened,
7751 switchEditorMode,
7752 toggleDistractionFree
7753 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
7754 const {
7755 isEditedPostDirty,
7756 isPostSavingLocked,
7757 isListViewOpened,
7758 getEditorMode
7759 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
7760 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-mode', () => {
7761 switchEditorMode(getEditorMode() === 'visual' ? 'text' : 'visual');
7762 }, {
7763 isDisabled: isModeToggleDisabled
7764 });
7765 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-distraction-free', () => {
7766 toggleDistractionFree();
7767 });
7768 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/undo', event => {
7769 undo();
7770 event.preventDefault();
7771 });
7772 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/redo', event => {
7773 redo();
7774 event.preventDefault();
7775 });
7776 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/save', event => {
7777 event.preventDefault();
7778
7779 /**
7780 * Do not save the post if post saving is locked.
7781 */
7782 if (isPostSavingLocked()) {
7783 return;
7784 }
7785
7786 // TODO: This should be handled in the `savePost` effect in
7787 // considering `isSaveable`. See note on `isEditedPostSaveable`
7788 // selector about dirtiness and meta-boxes.
7789 //
7790 // See: `isEditedPostSaveable`
7791 if (!isEditedPostDirty()) {
7792 return;
7793 }
7794 savePost();
7795 });
7796
7797 // Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar.
7798 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-list-view', event => {
7799 if (!isListViewOpened()) {
7800 event.preventDefault();
7801 setIsListViewOpened(true);
7802 }
7803 });
7804 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-sidebar', event => {
7805 // This shortcut has no known clashes, but use preventDefault to prevent any
7806 // obscure shortcuts from triggering.
7807 event.preventDefault();
7808 const isEditorSidebarOpened = ['edit-post/document', 'edit-post/block'].includes(getActiveComplementaryArea('core'));
7809 if (isEditorSidebarOpened) {
7810 disableComplementaryArea('core');
7811 } else {
7812 const sidebarToOpen = getBlockSelectionStart() ? 'edit-post/block' : 'edit-post/document';
7813 enableComplementaryArea('core', sidebarToOpen);
7814 }
7815 });
7816 return null;
7817 }
7818
7819 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/autocompleters/index.js
7820
7821
7822 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/autosave-monitor/index.js
7823 /**
7824 * WordPress dependencies
7825 */
7826
7827
7828
7829
7830
7831 /**
7832 * Internal dependencies
7833 */
7834
7835 class AutosaveMonitor extends external_wp_element_namespaceObject.Component {
7836 constructor(props) {
7837 super(props);
7838 this.needsAutosave = !!(props.isDirty && props.isAutosaveable);
7839 }
7840 componentDidMount() {
7841 if (!this.props.disableIntervalChecks) {
7842 this.setAutosaveTimer();
7843 }
7844 }
7845 componentDidUpdate(prevProps) {
7846 if (this.props.disableIntervalChecks) {
7847 if (this.props.editsReference !== prevProps.editsReference) {
7848 this.props.autosave();
7849 }
7850 return;
7851 }
7852 if (this.props.interval !== prevProps.interval) {
7853 clearTimeout(this.timerId);
7854 this.setAutosaveTimer();
7855 }
7856 if (!this.props.isDirty) {
7857 this.needsAutosave = false;
7858 return;
7859 }
7860 if (this.props.isAutosaving && !prevProps.isAutosaving) {
7861 this.needsAutosave = false;
7862 return;
7863 }
7864 if (this.props.editsReference !== prevProps.editsReference) {
7865 this.needsAutosave = true;
7866 }
7867 }
7868 componentWillUnmount() {
7869 clearTimeout(this.timerId);
7870 }
7871 setAutosaveTimer(timeout = this.props.interval * 1000) {
7872 this.timerId = setTimeout(() => {
7873 this.autosaveTimerHandler();
7874 }, timeout);
7875 }
7876 autosaveTimerHandler() {
7877 if (!this.props.isAutosaveable) {
7878 this.setAutosaveTimer(1000);
7879 return;
7880 }
7881 if (this.needsAutosave) {
7882 this.needsAutosave = false;
7883 this.props.autosave();
7884 }
7885 this.setAutosaveTimer();
7886 }
7887 render() {
7888 return null;
7889 }
7890 }
7891
7892 /**
7893 * Monitors the changes made to the edited post and triggers autosave if necessary.
7894 *
7895 * The logic is straightforward: a check is performed every `props.interval` seconds. If any changes are detected, `props.autosave()` is called.
7896 * 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
7897 * the specific way of detecting changes.
7898 *
7899 * There are two caveats:
7900 * * If `props.isAutosaveable` happens to be false at a time of checking for changes, the check is retried every second.
7901 * * The timer may be disabled by setting `props.disableIntervalChecks` to `true`. In that mode, any change will immediately trigger `props.autosave()`.
7902 *
7903 * @param {Object} props - The properties passed to the component.
7904 * @param {Function} props.autosave - The function to call when changes need to be saved.
7905 * @param {number} props.interval - The maximum time in seconds between an unsaved change and an autosave.
7906 * @param {boolean} props.isAutosaveable - If false, the check for changes is retried every second.
7907 * @param {boolean} props.disableIntervalChecks - If true, disables the timer and any change will immediately trigger `props.autosave()`.
7908 * @param {boolean} props.isDirty - Indicates if there are unsaved changes.
7909 *
7910 * @example
7911 * ```jsx
7912 * <AutosaveMonitor interval={30000} />
7913 * ```
7914 */
7915 /* harmony default export */ const autosave_monitor = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, ownProps) => {
7916 const {
7917 getReferenceByDistinctEdits
7918 } = select(external_wp_coreData_namespaceObject.store);
7919 const {
7920 isEditedPostDirty,
7921 isEditedPostAutosaveable,
7922 isAutosavingPost,
7923 getEditorSettings
7924 } = select(store_store);
7925 const {
7926 interval = getEditorSettings().autosaveInterval
7927 } = ownProps;
7928 return {
7929 editsReference: getReferenceByDistinctEdits(),
7930 isDirty: isEditedPostDirty(),
7931 isAutosaveable: isEditedPostAutosaveable(),
7932 isAutosaving: isAutosavingPost(),
7933 interval
7934 };
7935 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps) => ({
7936 autosave() {
7937 const {
7938 autosave = dispatch(store_store).autosave
7939 } = ownProps;
7940 autosave();
7941 }
7942 }))])(AutosaveMonitor));
7943
7944 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-right-small.js
7945 /**
7946 * WordPress dependencies
7947 */
7948
7949
7950 const chevronRightSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
7951 xmlns: "http://www.w3.org/2000/svg",
7952 viewBox: "0 0 24 24",
7953 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
7954 d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z"
7955 })
7956 });
7957 /* harmony default export */ const chevron_right_small = (chevronRightSmall);
7958
7959 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-left-small.js
7960 /**
7961 * WordPress dependencies
7962 */
7963
7964
7965 const chevronLeftSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
7966 xmlns: "http://www.w3.org/2000/svg",
7967 viewBox: "0 0 24 24",
7968 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
7969 d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z"
7970 })
7971 });
7972 /* harmony default export */ const chevron_left_small = (chevronLeftSmall);
7973
7974 ;// CONCATENATED MODULE: external ["wp","keycodes"]
7975 const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
7976 ;// CONCATENATED MODULE: external ["wp","commands"]
7977 const external_wp_commands_namespaceObject = window["wp"]["commands"];
7978 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-bar/index.js
7979 /**
7980 * External dependencies
7981 */
7982
7983
7984 /**
7985 * WordPress dependencies
7986 */
7987
7988
7989
7990
7991
7992
7993
7994
7995
7996
7997
7998
7999 /**
8000 * Internal dependencies
8001 */
8002
8003
8004
8005
8006
8007 const TYPE_LABELS = {
8008 // translators: 1: Pattern title.
8009 wp_pattern: (0,external_wp_i18n_namespaceObject.__)('Editing pattern: %s'),
8010 // translators: 1: Navigation menu title.
8011 wp_navigation: (0,external_wp_i18n_namespaceObject.__)('Editing navigation menu: %s'),
8012 // translators: 1: Template title.
8013 wp_template: (0,external_wp_i18n_namespaceObject.__)('Editing template: %s'),
8014 // translators: 1: Template part title.
8015 wp_template_part: (0,external_wp_i18n_namespaceObject.__)('Editing template part: %s')
8016 };
8017 const MotionButton = (0,external_wp_components_namespaceObject.__unstableMotion)(external_wp_components_namespaceObject.Button);
8018
8019 /**
8020 * This component renders a navigation bar at the top of the editor. It displays the title of the current document,
8021 * a back button (if applicable), and a command center button. It also handles different states of the document,
8022 * such as "not found" or "unsynced".
8023 *
8024 * @example
8025 * ```jsx
8026 * <DocumentBar />
8027 * ```
8028 *
8029 * @return {JSX.Element} The rendered DocumentBar component.
8030 */
8031 function DocumentBar() {
8032 const {
8033 postType,
8034 documentTitle,
8035 isNotFound,
8036 isUnsyncedPattern,
8037 templateIcon,
8038 templateTitle,
8039 onNavigateToPreviousEntityRecord
8040 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8041 const {
8042 getCurrentPostType,
8043 getCurrentPostId,
8044 getEditorSettings,
8045 __experimentalGetTemplateInfo: getTemplateInfo
8046 } = select(store_store);
8047 const {
8048 getEditedEntityRecord,
8049 isResolving: isResolvingSelector
8050 } = select(external_wp_coreData_namespaceObject.store);
8051 const _postType = getCurrentPostType();
8052 const _postId = getCurrentPostId();
8053 const _document = getEditedEntityRecord('postType', _postType, _postId);
8054 const _templateInfo = getTemplateInfo(_document);
8055 return {
8056 postType: _postType,
8057 documentTitle: _document.title,
8058 isNotFound: !_document && !isResolvingSelector('getEditedEntityRecord', 'postType', _postType, _postId),
8059 isUnsyncedPattern: _document?.wp_pattern_sync_status === 'unsynced',
8060 templateIcon: unlock(select(store_store)).getPostIcon(_postType, {
8061 area: _document?.area
8062 }),
8063 templateTitle: _templateInfo.title,
8064 onNavigateToPreviousEntityRecord: getEditorSettings().onNavigateToPreviousEntityRecord
8065 };
8066 }, []);
8067 const {
8068 open: openCommandCenter
8069 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_commands_namespaceObject.store);
8070 const isReducedMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
8071 const isTemplate = TEMPLATE_POST_TYPES.includes(postType);
8072 const isGlobalEntity = GLOBAL_POST_TYPES.includes(postType);
8073 const hasBackButton = !!onNavigateToPreviousEntityRecord;
8074 const title = isTemplate ? templateTitle : documentTitle;
8075 const mounted = (0,external_wp_element_namespaceObject.useRef)(false);
8076 (0,external_wp_element_namespaceObject.useEffect)(() => {
8077 mounted.current = true;
8078 }, []);
8079 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
8080 className: dist_clsx('editor-document-bar', {
8081 'has-back-button': hasBackButton,
8082 'is-global': isGlobalEntity && !isUnsyncedPattern
8083 }),
8084 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
8085 children: hasBackButton && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MotionButton, {
8086 className: "editor-document-bar__back",
8087 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right_small : chevron_left_small,
8088 onClick: event => {
8089 event.stopPropagation();
8090 onNavigateToPreviousEntityRecord();
8091 },
8092 size: "compact",
8093 initial: mounted.current ? {
8094 opacity: 0,
8095 transform: 'translateX(15%)'
8096 } : false // Don't show entry animation when DocumentBar mounts.
8097 ,
8098 animate: {
8099 opacity: 1,
8100 transform: 'translateX(0%)'
8101 },
8102 exit: {
8103 opacity: 0,
8104 transform: 'translateX(15%)'
8105 },
8106 transition: isReducedMotion ? {
8107 duration: 0
8108 } : undefined,
8109 children: (0,external_wp_i18n_namespaceObject.__)('Back')
8110 })
8111 }), isNotFound ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
8112 children: (0,external_wp_i18n_namespaceObject.__)('Document not found')
8113 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
8114 className: "editor-document-bar__command",
8115 onClick: () => openCommandCenter(),
8116 size: "compact",
8117 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
8118 className: "editor-document-bar__title"
8119 // Force entry animation when the back button is added or removed.
8120 ,
8121
8122 initial: mounted.current ? {
8123 opacity: 0,
8124 transform: hasBackButton ? 'translateX(15%)' : 'translateX(-15%)'
8125 } : false // Don't show entry animation when DocumentBar mounts.
8126 ,
8127 animate: {
8128 opacity: 1,
8129 transform: 'translateX(0%)'
8130 },
8131 transition: isReducedMotion ? {
8132 duration: 0
8133 } : undefined,
8134 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockIcon, {
8135 icon: templateIcon
8136 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
8137 size: "body",
8138 as: "h1",
8139 "aria-label": TYPE_LABELS[postType] ?
8140 // eslint-disable-next-line @wordpress/valid-sprintf
8141 (0,external_wp_i18n_namespaceObject.sprintf)(TYPE_LABELS[postType], title) : undefined,
8142 children: title ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title) : (0,external_wp_i18n_namespaceObject.__)('No Title')
8143 })]
8144 }, hasBackButton), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
8145 className: "editor-document-bar__shortcut",
8146 children: external_wp_keycodes_namespaceObject.displayShortcut.primary('k')
8147 })]
8148 })]
8149 });
8150 }
8151
8152 ;// CONCATENATED MODULE: external ["wp","richText"]
8153 const external_wp_richText_namespaceObject = window["wp"]["richText"];
8154 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-outline/item.js
8155 /**
8156 * External dependencies
8157 */
8158
8159
8160
8161 const TableOfContentsItem = ({
8162 children,
8163 isValid,
8164 level,
8165 href,
8166 onSelect
8167 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
8168 className: dist_clsx('document-outline__item', `is-${level.toLowerCase()}`, {
8169 'is-invalid': !isValid
8170 }),
8171 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("a", {
8172 href: href,
8173 className: "document-outline__button",
8174 onClick: onSelect,
8175 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
8176 className: "document-outline__emdash",
8177 "aria-hidden": "true"
8178 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
8179 className: "document-outline__level",
8180 children: level
8181 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
8182 className: "document-outline__item-content",
8183 children: children
8184 })]
8185 })
8186 });
8187 /* harmony default export */ const document_outline_item = (TableOfContentsItem);
8188
8189 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-outline/index.js
8190 /**
8191 * WordPress dependencies
8192 */
8193
8194
8195
8196
8197
8198
8199
8200 /**
8201 * Internal dependencies
8202 */
8203
8204
8205
8206 /**
8207 * Module constants
8208 */
8209
8210
8211 const emptyHeadingContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
8212 children: (0,external_wp_i18n_namespaceObject.__)('(Empty heading)')
8213 });
8214 const incorrectLevelContent = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}, "incorrect-break"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
8215 children: (0,external_wp_i18n_namespaceObject.__)('(Incorrect heading level)')
8216 }, "incorrect-message")];
8217 const singleH1Headings = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}, "incorrect-break-h1"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
8218 children: (0,external_wp_i18n_namespaceObject.__)('(Your theme may already use a H1 for the post title)')
8219 }, "incorrect-message-h1")];
8220 const multipleH1Headings = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}, "incorrect-break-multiple-h1"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
8221 children: (0,external_wp_i18n_namespaceObject.__)('(Multiple H1 headings are not recommended)')
8222 }, "incorrect-message-multiple-h1")];
8223 function EmptyOutlineIllustration() {
8224 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.SVG, {
8225 width: "138",
8226 height: "148",
8227 viewBox: "0 0 138 148",
8228 fill: "none",
8229 xmlns: "http://www.w3.org/2000/svg",
8230 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
8231 width: "138",
8232 height: "148",
8233 rx: "4",
8234 fill: "#F0F6FC"
8235 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
8236 x1: "44",
8237 y1: "28",
8238 x2: "24",
8239 y2: "28",
8240 stroke: "#DDDDDD"
8241 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
8242 x: "48",
8243 y: "16",
8244 width: "27",
8245 height: "23",
8246 rx: "4",
8247 fill: "#DDDDDD"
8248 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
8249 d: "M54.7585 32V23.2727H56.6037V26.8736H60.3494V23.2727H62.1903V32H60.3494V28.3949H56.6037V32H54.7585ZM67.4574 23.2727V32H65.6122V25.0241H65.5611L63.5625 26.277V24.6406L65.723 23.2727H67.4574Z",
8250 fill: "black"
8251 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
8252 x1: "55",
8253 y1: "59",
8254 x2: "24",
8255 y2: "59",
8256 stroke: "#DDDDDD"
8257 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
8258 x: "59",
8259 y: "47",
8260 width: "29",
8261 height: "23",
8262 rx: "4",
8263 fill: "#DDDDDD"
8264 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
8265 d: "M65.7585 63V54.2727H67.6037V57.8736H71.3494V54.2727H73.1903V63H71.3494V59.3949H67.6037V63H65.7585ZM74.6605 63V61.6705L77.767 58.794C78.0313 58.5384 78.2528 58.3082 78.4318 58.1037C78.6136 57.8991 78.7514 57.6989 78.8452 57.5028C78.9389 57.304 78.9858 57.0895 78.9858 56.8594C78.9858 56.6037 78.9276 56.3835 78.8111 56.1989C78.6946 56.0114 78.5355 55.8679 78.3338 55.7685C78.1321 55.6662 77.9034 55.6151 77.6477 55.6151C77.3807 55.6151 77.1477 55.669 76.9489 55.777C76.75 55.8849 76.5966 56.0398 76.4886 56.2415C76.3807 56.4432 76.3267 56.6832 76.3267 56.9616H74.5753C74.5753 56.3906 74.7045 55.8949 74.9631 55.4744C75.2216 55.054 75.5838 54.7287 76.0497 54.4986C76.5156 54.2685 77.0526 54.1534 77.6605 54.1534C78.2855 54.1534 78.8295 54.2642 79.2926 54.4858C79.7585 54.7045 80.1207 55.0085 80.3793 55.3977C80.6378 55.7869 80.767 56.233 80.767 56.7358C80.767 57.0653 80.7017 57.3906 80.571 57.7116C80.4432 58.0327 80.2145 58.3892 79.8849 58.7812C79.5554 59.1705 79.0909 59.6378 78.4915 60.1832L77.2173 61.4318V61.4915H80.8821V63H74.6605Z",
8266 fill: "black"
8267 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
8268 x1: "80",
8269 y1: "90",
8270 x2: "24",
8271 y2: "90",
8272 stroke: "#DDDDDD"
8273 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
8274 x: "84",
8275 y: "78",
8276 width: "30",
8277 height: "23",
8278 rx: "4",
8279 fill: "#F0B849"
8280 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
8281 d: "M90.7585 94V85.2727H92.6037V88.8736H96.3494V85.2727H98.1903V94H96.3494V90.3949H92.6037V94H90.7585ZM99.5284 92.4659V91.0128L103.172 85.2727H104.425V87.2841H103.683L101.386 90.919V90.9872H106.564V92.4659H99.5284ZM103.717 94V92.0227L103.751 91.3793V85.2727H105.482V94H103.717Z",
8282 fill: "black"
8283 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
8284 x1: "66",
8285 y1: "121",
8286 x2: "24",
8287 y2: "121",
8288 stroke: "#DDDDDD"
8289 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
8290 x: "70",
8291 y: "109",
8292 width: "29",
8293 height: "23",
8294 rx: "4",
8295 fill: "#DDDDDD"
8296 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
8297 d: "M76.7585 125V116.273H78.6037V119.874H82.3494V116.273H84.1903V125H82.3494V121.395H78.6037V125H76.7585ZM88.8864 125.119C88.25 125.119 87.6832 125.01 87.1861 124.791C86.6918 124.57 86.3011 124.266 86.0142 123.879C85.7301 123.49 85.5838 123.041 85.5753 122.533H87.4332C87.4446 122.746 87.5142 122.933 87.642 123.095C87.7727 123.254 87.946 123.378 88.1619 123.466C88.3778 123.554 88.6207 123.598 88.8906 123.598C89.1719 123.598 89.4205 123.548 89.6364 123.449C89.8523 123.349 90.0213 123.212 90.1435 123.036C90.2656 122.859 90.3267 122.656 90.3267 122.426C90.3267 122.193 90.2614 121.987 90.1307 121.808C90.0028 121.626 89.8182 121.484 89.5767 121.382C89.3381 121.28 89.054 121.229 88.7244 121.229H87.9105V119.874H88.7244C89.0028 119.874 89.2486 119.825 89.4616 119.729C89.6776 119.632 89.8452 119.499 89.9645 119.328C90.0838 119.155 90.1435 118.953 90.1435 118.723C90.1435 118.504 90.0909 118.312 89.9858 118.148C89.8835 117.98 89.7386 117.849 89.5511 117.756C89.3665 117.662 89.1506 117.615 88.9034 117.615C88.6534 117.615 88.4247 117.661 88.2173 117.751C88.0099 117.839 87.8438 117.966 87.7188 118.131C87.5938 118.295 87.527 118.489 87.5185 118.71H85.75C85.7585 118.207 85.902 117.764 86.1804 117.381C86.4588 116.997 86.8338 116.697 87.3054 116.482C87.7798 116.263 88.3153 116.153 88.9119 116.153C89.5142 116.153 90.0412 116.263 90.4929 116.482C90.9446 116.7 91.2955 116.996 91.5455 117.368C91.7983 117.737 91.9233 118.152 91.9205 118.612C91.9233 119.101 91.7713 119.509 91.4645 119.835C91.1605 120.162 90.7642 120.369 90.2756 120.457V120.526C90.9176 120.608 91.4063 120.831 91.7415 121.195C92.0795 121.555 92.2472 122.007 92.2443 122.55C92.2472 123.047 92.1037 123.489 91.8139 123.875C91.527 124.261 91.1307 124.565 90.625 124.787C90.1193 125.009 89.5398 125.119 88.8864 125.119Z",
8298 fill: "black"
8299 })]
8300 });
8301 }
8302
8303 /**
8304 * Returns an array of heading blocks enhanced with the following properties:
8305 * level - An integer with the heading level.
8306 * isEmpty - Flag indicating if the heading has no content.
8307 *
8308 * @param {?Array} blocks An array of blocks.
8309 *
8310 * @return {Array} An array of heading blocks enhanced with the properties described above.
8311 */
8312 const computeOutlineHeadings = (blocks = []) => {
8313 return blocks.flatMap((block = {}) => {
8314 if (block.name === 'core/heading') {
8315 return {
8316 ...block,
8317 level: block.attributes.level,
8318 isEmpty: isEmptyHeading(block)
8319 };
8320 }
8321 return computeOutlineHeadings(block.innerBlocks);
8322 });
8323 };
8324 const isEmptyHeading = heading => !heading.attributes.content || heading.attributes.content.trim().length === 0;
8325
8326 /**
8327 * Renders a document outline component.
8328 *
8329 * @param {Object} props Props.
8330 * @param {Function} props.onSelect Function to be called when an outline item is selected.
8331 * @param {boolean} props.isTitleSupported Indicates whether the title is supported.
8332 * @param {boolean} props.hasOutlineItemsDisabled Indicates whether the outline items are disabled.
8333 *
8334 * @return {Component} The component to be rendered.
8335 */
8336 function DocumentOutline({
8337 onSelect,
8338 isTitleSupported,
8339 hasOutlineItemsDisabled
8340 }) {
8341 const {
8342 selectBlock
8343 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
8344 const {
8345 blocks,
8346 title
8347 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8348 var _postType$supports$ti;
8349 const {
8350 getBlocks
8351 } = select(external_wp_blockEditor_namespaceObject.store);
8352 const {
8353 getEditedPostAttribute
8354 } = select(store_store);
8355 const {
8356 getPostType
8357 } = select(external_wp_coreData_namespaceObject.store);
8358 const postType = getPostType(getEditedPostAttribute('type'));
8359 return {
8360 title: getEditedPostAttribute('title'),
8361 blocks: getBlocks(),
8362 isTitleSupported: (_postType$supports$ti = postType?.supports?.title) !== null && _postType$supports$ti !== void 0 ? _postType$supports$ti : false
8363 };
8364 });
8365 const headings = computeOutlineHeadings(blocks);
8366 if (headings.length < 1) {
8367 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
8368 className: "editor-document-outline has-no-headings",
8369 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EmptyOutlineIllustration, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
8370 children: (0,external_wp_i18n_namespaceObject.__)('Navigate the structure of your document and address issues like empty or incorrect heading levels.')
8371 })]
8372 });
8373 }
8374 let prevHeadingLevel = 1;
8375
8376 // Not great but it's the simplest way to locate the title right now.
8377 const titleNode = document.querySelector('.editor-post-title__input');
8378 const hasTitle = isTitleSupported && title && titleNode;
8379 const countByLevel = headings.reduce((acc, heading) => ({
8380 ...acc,
8381 [heading.level]: (acc[heading.level] || 0) + 1
8382 }), {});
8383 const hasMultipleH1 = countByLevel[1] > 1;
8384 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
8385 className: "document-outline",
8386 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("ul", {
8387 children: [hasTitle && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(document_outline_item, {
8388 level: (0,external_wp_i18n_namespaceObject.__)('Title'),
8389 isValid: true,
8390 onSelect: onSelect,
8391 href: `#${titleNode.id}`,
8392 isDisabled: hasOutlineItemsDisabled,
8393 children: title
8394 }), headings.map((item, index) => {
8395 // Headings remain the same, go up by one, or down by any amount.
8396 // Otherwise there are missing levels.
8397 const isIncorrectLevel = item.level > prevHeadingLevel + 1;
8398 const isValid = !item.isEmpty && !isIncorrectLevel && !!item.level && (item.level !== 1 || !hasMultipleH1 && !hasTitle);
8399 prevHeadingLevel = item.level;
8400 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(document_outline_item, {
8401 level: `H${item.level}`,
8402 isValid: isValid,
8403 isDisabled: hasOutlineItemsDisabled,
8404 href: `#block-${item.clientId}`,
8405 onSelect: () => {
8406 selectBlock(item.clientId);
8407 onSelect?.();
8408 },
8409 children: [item.isEmpty ? emptyHeadingContent : (0,external_wp_richText_namespaceObject.getTextContent)((0,external_wp_richText_namespaceObject.create)({
8410 html: item.attributes.content
8411 })), isIncorrectLevel && incorrectLevelContent, item.level === 1 && hasMultipleH1 && multipleH1Headings, hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings]
8412 }, index);
8413 })]
8414 })
8415 });
8416 }
8417
8418 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-outline/check.js
8419 /**
8420 * WordPress dependencies
8421 */
8422
8423
8424
8425 /**
8426 * Component check if there are any headings (core/heading blocks) present in the document.
8427 *
8428 * @param {Object} props Props.
8429 * @param {Element} props.children Children to be rendered.
8430 *
8431 * @return {Component|null} The component to be rendered or null if there are headings.
8432 */
8433 function DocumentOutlineCheck({
8434 children
8435 }) {
8436 const hasHeadings = (0,external_wp_data_namespaceObject.useSelect)(select => {
8437 const {
8438 getGlobalBlockCount
8439 } = select(external_wp_blockEditor_namespaceObject.store);
8440 return getGlobalBlockCount('core/heading') > 0;
8441 });
8442 if (hasHeadings) {
8443 return null;
8444 }
8445 return children;
8446 }
8447
8448 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/global-keyboard-shortcuts/register-shortcuts.js
8449 /**
8450 * WordPress dependencies
8451 */
8452
8453
8454
8455
8456
8457
8458
8459 /**
8460 * Component for registering editor keyboard shortcuts.
8461 *
8462 * @return {Element} The component to be rendered.
8463 */
8464
8465 function EditorKeyboardShortcutsRegister() {
8466 // Registering the shortcuts.
8467 const {
8468 registerShortcut
8469 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
8470 (0,external_wp_element_namespaceObject.useEffect)(() => {
8471 registerShortcut({
8472 name: 'core/editor/toggle-mode',
8473 category: 'global',
8474 description: (0,external_wp_i18n_namespaceObject.__)('Switch between visual editor and code editor.'),
8475 keyCombination: {
8476 modifier: 'secondary',
8477 character: 'm'
8478 }
8479 });
8480 registerShortcut({
8481 name: 'core/editor/save',
8482 category: 'global',
8483 description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'),
8484 keyCombination: {
8485 modifier: 'primary',
8486 character: 's'
8487 }
8488 });
8489 registerShortcut({
8490 name: 'core/editor/undo',
8491 category: 'global',
8492 description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'),
8493 keyCombination: {
8494 modifier: 'primary',
8495 character: 'z'
8496 }
8497 });
8498 registerShortcut({
8499 name: 'core/editor/redo',
8500 category: 'global',
8501 description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'),
8502 keyCombination: {
8503 modifier: 'primaryShift',
8504 character: 'z'
8505 },
8506 // Disable on Apple OS because it conflicts with the browser's
8507 // history shortcut. It's a fine alias for both Windows and Linux.
8508 // Since there's no conflict for Ctrl+Shift+Z on both Windows and
8509 // Linux, we keep it as the default for consistency.
8510 aliases: (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? [] : [{
8511 modifier: 'primary',
8512 character: 'y'
8513 }]
8514 });
8515 registerShortcut({
8516 name: 'core/editor/toggle-list-view',
8517 category: 'global',
8518 description: (0,external_wp_i18n_namespaceObject.__)('Open the List View.'),
8519 keyCombination: {
8520 modifier: 'access',
8521 character: 'o'
8522 }
8523 });
8524 registerShortcut({
8525 name: 'core/editor/toggle-distraction-free',
8526 category: 'global',
8527 description: (0,external_wp_i18n_namespaceObject.__)('Toggle distraction free mode.'),
8528 keyCombination: {
8529 modifier: 'primaryShift',
8530 character: '\\'
8531 }
8532 });
8533 registerShortcut({
8534 name: 'core/editor/toggle-sidebar',
8535 category: 'global',
8536 description: (0,external_wp_i18n_namespaceObject.__)('Show or hide the Settings sidebar.'),
8537 keyCombination: {
8538 modifier: 'primaryShift',
8539 character: ','
8540 }
8541 });
8542 registerShortcut({
8543 name: 'core/editor/keyboard-shortcuts',
8544 category: 'main',
8545 description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'),
8546 keyCombination: {
8547 modifier: 'access',
8548 character: 'h'
8549 }
8550 });
8551 registerShortcut({
8552 name: 'core/editor/next-region',
8553 category: 'global',
8554 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'),
8555 keyCombination: {
8556 modifier: 'ctrl',
8557 character: '`'
8558 },
8559 aliases: [{
8560 modifier: 'access',
8561 character: 'n'
8562 }]
8563 });
8564 registerShortcut({
8565 name: 'core/editor/previous-region',
8566 category: 'global',
8567 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'),
8568 keyCombination: {
8569 modifier: 'ctrlShift',
8570 character: '`'
8571 },
8572 aliases: [{
8573 modifier: 'access',
8574 character: 'p'
8575 }, {
8576 modifier: 'ctrlShift',
8577 character: '~'
8578 }]
8579 });
8580 }, [registerShortcut]);
8581 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts.Register, {});
8582 }
8583 /* harmony default export */ const register_shortcuts = (EditorKeyboardShortcutsRegister);
8584
8585 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/redo.js
8586 /**
8587 * WordPress dependencies
8588 */
8589
8590
8591 const redo_redo = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8592 xmlns: "http://www.w3.org/2000/svg",
8593 viewBox: "0 0 24 24",
8594 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8595 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"
8596 })
8597 });
8598 /* harmony default export */ const library_redo = (redo_redo);
8599
8600 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/undo.js
8601 /**
8602 * WordPress dependencies
8603 */
8604
8605
8606 const undo_undo = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8607 xmlns: "http://www.w3.org/2000/svg",
8608 viewBox: "0 0 24 24",
8609 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8610 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"
8611 })
8612 });
8613 /* harmony default export */ const library_undo = (undo_undo);
8614
8615 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-history/redo.js
8616 /**
8617 * WordPress dependencies
8618 */
8619
8620
8621
8622
8623
8624
8625
8626 /**
8627 * Internal dependencies
8628 */
8629
8630
8631 function EditorHistoryRedo(props, ref) {
8632 const shortcut = (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') : external_wp_keycodes_namespaceObject.displayShortcut.primary('y');
8633 const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorRedo(), []);
8634 const {
8635 redo
8636 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
8637 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8638 ...props,
8639 ref: ref,
8640 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo
8641 /* translators: button label text should, if possible, be under 16 characters. */,
8642 label: (0,external_wp_i18n_namespaceObject.__)('Redo'),
8643 shortcut: shortcut
8644 // If there are no redo levels we don't want to actually disable this
8645 // button, because it will remove focus for keyboard users.
8646 // See: https://github.com/WordPress/gutenberg/issues/3486
8647 ,
8648 "aria-disabled": !hasRedo,
8649 onClick: hasRedo ? redo : undefined,
8650 className: "editor-history__redo"
8651 });
8652 }
8653
8654 /** @typedef {import('react').Ref<HTMLElement>} Ref */
8655
8656 /**
8657 * Renders the redo button for the editor history.
8658 *
8659 * @param {Object} props - Props.
8660 * @param {Ref} ref - Forwarded ref.
8661 *
8662 * @return {Component} The component to be rendered.
8663 */
8664 /* harmony default export */ const editor_history_redo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryRedo));
8665
8666 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-history/undo.js
8667 /**
8668 * WordPress dependencies
8669 */
8670
8671
8672
8673
8674
8675
8676
8677 /**
8678 * Internal dependencies
8679 */
8680
8681
8682 function EditorHistoryUndo(props, ref) {
8683 const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorUndo(), []);
8684 const {
8685 undo
8686 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
8687 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8688 ...props,
8689 ref: ref,
8690 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo
8691 /* translators: button label text should, if possible, be under 16 characters. */,
8692 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
8693 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z')
8694 // If there are no undo levels we don't want to actually disable this
8695 // button, because it will remove focus for keyboard users.
8696 // See: https://github.com/WordPress/gutenberg/issues/3486
8697 ,
8698 "aria-disabled": !hasUndo,
8699 onClick: hasUndo ? undo : undefined,
8700 className: "editor-history__undo"
8701 });
8702 }
8703
8704 /** @typedef {import('react').Ref<HTMLElement>} Ref */
8705
8706 /**
8707 * Renders the undo button for the editor history.
8708 *
8709 * @param {Object} props - Props.
8710 * @param {Ref} ref - Forwarded ref.
8711 *
8712 * @return {Component} The component to be rendered.
8713 */
8714 /* harmony default export */ const editor_history_undo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryUndo));
8715
8716 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-validation-notice/index.js
8717 /**
8718 * WordPress dependencies
8719 */
8720
8721
8722
8723
8724
8725
8726
8727
8728 function TemplateValidationNotice() {
8729 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
8730 const isValid = (0,external_wp_data_namespaceObject.useSelect)(select => {
8731 return select(external_wp_blockEditor_namespaceObject.store).isValidTemplate();
8732 }, []);
8733 const {
8734 setTemplateValidity,
8735 synchronizeTemplate
8736 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
8737 if (isValid) {
8738 return null;
8739 }
8740 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
8741 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
8742 className: "editor-template-validation-notice",
8743 isDismissible: false,
8744 status: "warning",
8745 actions: [{
8746 label: (0,external_wp_i18n_namespaceObject.__)('Keep it as is'),
8747 onClick: () => setTemplateValidity(true)
8748 }, {
8749 label: (0,external_wp_i18n_namespaceObject.__)('Reset the template'),
8750 onClick: () => setShowConfirmDialog(true)
8751 }],
8752 children: (0,external_wp_i18n_namespaceObject.__)('The content of your post doesn’t match the template assigned to your post type.')
8753 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
8754 isOpen: showConfirmDialog,
8755 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Reset'),
8756 onConfirm: () => {
8757 setShowConfirmDialog(false);
8758 synchronizeTemplate();
8759 },
8760 onCancel: () => setShowConfirmDialog(false),
8761 children: (0,external_wp_i18n_namespaceObject.__)('Resetting the template may result in loss of content, do you want to continue?')
8762 })]
8763 });
8764 }
8765
8766 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-notices/index.js
8767 /**
8768 * WordPress dependencies
8769 */
8770
8771
8772
8773
8774 /**
8775 * Internal dependencies
8776 */
8777
8778
8779 /**
8780 * This component renders the notices displayed in the editor. It displays pinned notices first, followed by dismissible
8781 *
8782 * @example
8783 * ```jsx
8784 * <EditorNotices />
8785 * ```
8786 *
8787 * @return {JSX.Element} The rendered EditorNotices component.
8788 */
8789
8790
8791
8792 function EditorNotices() {
8793 const {
8794 notices
8795 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
8796 notices: select(external_wp_notices_namespaceObject.store).getNotices()
8797 }), []);
8798 const {
8799 removeNotice
8800 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
8801 const dismissibleNotices = notices.filter(({
8802 isDismissible,
8803 type
8804 }) => isDismissible && type === 'default');
8805 const nonDismissibleNotices = notices.filter(({
8806 isDismissible,
8807 type
8808 }) => !isDismissible && type === 'default');
8809 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
8810 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.NoticeList, {
8811 notices: nonDismissibleNotices,
8812 className: "components-editor-notices__pinned"
8813 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.NoticeList, {
8814 notices: dismissibleNotices,
8815 className: "components-editor-notices__dismissible",
8816 onRemove: removeNotice,
8817 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateValidationNotice, {})
8818 })]
8819 });
8820 }
8821 /* harmony default export */ const editor_notices = (EditorNotices);
8822
8823 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-snackbars/index.js
8824 /**
8825 * WordPress dependencies
8826 */
8827
8828
8829
8830
8831 // Last three notices. Slices from the tail end of the list.
8832
8833 const MAX_VISIBLE_NOTICES = -3;
8834
8835 /**
8836 * Renders the editor snackbars component.
8837 *
8838 * @return {JSX.Element} The rendered component.
8839 */
8840 function EditorSnackbars() {
8841 const notices = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_notices_namespaceObject.store).getNotices(), []);
8842 const {
8843 removeNotice
8844 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
8845 const snackbarNotices = notices.filter(({
8846 type
8847 }) => type === 'snackbar').slice(MAX_VISIBLE_NOTICES);
8848 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SnackbarList, {
8849 notices: snackbarNotices,
8850 className: "components-editor-notices__snackbar",
8851 onRemove: removeNotice
8852 });
8853 }
8854
8855 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/connection.js
8856 /**
8857 * WordPress dependencies
8858 */
8859
8860
8861 const connection = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8862 viewBox: "0 0 24 24",
8863 xmlns: "http://www.w3.org/2000/svg",
8864 fillRule: "evenodd",
8865 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8866 d: "M19.53 4.47a.75.75 0 0 1 0 1.06L17.06 8l.77.769a3.155 3.155 0 0 1 .685 3.439 3.15 3.15 0 0 1-.685 1.022v.001L13.23 17.83v.001a3.15 3.15 0 0 1-4.462 0L8 17.06l-2.47 2.47a.75.75 0 0 1-1.06-1.06L6.94 16l-.77-.769a3.154 3.154 0 0 1-.685-3.439 3.15 3.15 0 0 1 .685-1.023l4.599-4.598a3.152 3.152 0 0 1 4.462 0l.769.768 2.47-2.47a.75.75 0 0 1 1.06 0Zm-2.76 7.7L15 13.94 10.06 9l1.771-1.77a1.65 1.65 0 0 1 2.338 0L16.77 9.83a1.649 1.649 0 0 1 0 2.338h-.001ZM13.94 15 9 10.06l-1.77 1.771a1.65 1.65 0 0 0 0 2.338l2.601 2.602a1.649 1.649 0 0 0 2.338 0v-.001L13.94 15Z"
8867 })
8868 });
8869 /* harmony default export */ const library_connection = (connection);
8870
8871 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/entities-saved-states/entity-record-item.js
8872 /**
8873 * WordPress dependencies
8874 */
8875
8876
8877
8878
8879
8880
8881
8882 /**
8883 * Internal dependencies
8884 */
8885
8886
8887
8888
8889
8890 function EntityRecordItem({
8891 record,
8892 checked,
8893 onChange
8894 }) {
8895 const {
8896 name,
8897 kind,
8898 title,
8899 key
8900 } = record;
8901
8902 // Handle templates that might use default descriptive titles.
8903 const {
8904 entityRecordTitle,
8905 hasPostMetaChanges
8906 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8907 if ('postType' !== kind || 'wp_template' !== name) {
8908 return {
8909 entityRecordTitle: title,
8910 hasPostMetaChanges: unlock(select(store_store)).hasPostMetaChanges(name, key)
8911 };
8912 }
8913 const template = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(kind, name, key);
8914 return {
8915 entityRecordTitle: select(store_store).__experimentalGetTemplateInfo(template).title,
8916 hasPostMetaChanges: unlock(select(store_store)).hasPostMetaChanges(name, key)
8917 };
8918 }, [name, kind, title, key]);
8919 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
8920 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
8921 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
8922 __nextHasNoMarginBottom: true,
8923 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(entityRecordTitle) || (0,external_wp_i18n_namespaceObject.__)('Untitled'),
8924 checked: checked,
8925 onChange: onChange
8926 })
8927 }), hasPostMetaChanges && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
8928 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
8929 className: "entities-saved-states__post-meta",
8930 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
8931 className: "entities-saved-states__connections-icon",
8932 icon: library_connection,
8933 size: 24
8934 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
8935 className: "entities-saved-states__bindings-text",
8936 children: (0,external_wp_i18n_namespaceObject.__)('Post Meta.')
8937 })]
8938 })
8939 })]
8940 });
8941 }
8942
8943 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/entities-saved-states/entity-type-list.js
8944 /**
8945 * WordPress dependencies
8946 */
8947
8948
8949
8950
8951
8952
8953
8954 /**
8955 * Internal dependencies
8956 */
8957
8958
8959
8960
8961 const {
8962 getGlobalStylesChanges,
8963 GlobalStylesContext
8964 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
8965 function getEntityDescription(entity, count) {
8966 switch (entity) {
8967 case 'site':
8968 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.');
8969 case 'wp_template':
8970 return (0,external_wp_i18n_namespaceObject.__)('This change will affect pages and posts that use this template.');
8971 case 'page':
8972 case 'post':
8973 return (0,external_wp_i18n_namespaceObject.__)('The following has been modified.');
8974 }
8975 }
8976 function GlobalStylesDescription({
8977 record
8978 }) {
8979 const {
8980 user: currentEditorGlobalStyles
8981 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
8982 const savedRecord = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecord(record.kind, record.name, record.key), [record.kind, record.name, record.key]);
8983 const globalStylesChanges = getGlobalStylesChanges(currentEditorGlobalStyles, savedRecord, {
8984 maxResults: 10
8985 });
8986 return globalStylesChanges.length ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
8987 className: "entities-saved-states__changes",
8988 children: globalStylesChanges.map(change => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
8989 children: change
8990 }, change))
8991 }) : null;
8992 }
8993 function EntityDescription({
8994 record,
8995 count
8996 }) {
8997 if ('globalStyles' === record?.name) {
8998 return null;
8999 }
9000 const description = getEntityDescription(record?.name, count);
9001 return description ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
9002 children: description
9003 }) : null;
9004 }
9005 function EntityTypeList({
9006 list,
9007 unselectedEntities,
9008 setUnselectedEntities
9009 }) {
9010 const count = list.length;
9011 const firstRecord = list[0];
9012 const entityConfig = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityConfig(firstRecord.kind, firstRecord.name), [firstRecord.kind, firstRecord.name]);
9013 let entityLabel = entityConfig.label;
9014 if (firstRecord?.name === 'wp_template_part') {
9015 entityLabel = 1 === count ? (0,external_wp_i18n_namespaceObject.__)('Template Part') : (0,external_wp_i18n_namespaceObject.__)('Template Parts');
9016 }
9017 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
9018 title: entityLabel,
9019 initialOpen: true,
9020 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityDescription, {
9021 record: firstRecord,
9022 count: count
9023 }), list.map(record => {
9024 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityRecordItem, {
9025 record: record,
9026 checked: !unselectedEntities.some(elt => elt.kind === record.kind && elt.name === record.name && elt.key === record.key && elt.property === record.property),
9027 onChange: value => setUnselectedEntities(record, value)
9028 }, record.key || record.property);
9029 }), 'globalStyles' === firstRecord?.name && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(GlobalStylesDescription, {
9030 record: firstRecord
9031 })]
9032 });
9033 }
9034
9035 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/entities-saved-states/hooks/use-is-dirty.js
9036 /**
9037 * WordPress dependencies
9038 */
9039
9040
9041
9042 const useIsDirty = () => {
9043 const {
9044 editedEntities,
9045 siteEdits,
9046 siteEntityConfig
9047 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9048 const {
9049 __experimentalGetDirtyEntityRecords,
9050 getEntityRecordEdits,
9051 getEntityConfig
9052 } = select(external_wp_coreData_namespaceObject.store);
9053 return {
9054 editedEntities: __experimentalGetDirtyEntityRecords(),
9055 siteEdits: getEntityRecordEdits('root', 'site'),
9056 siteEntityConfig: getEntityConfig('root', 'site')
9057 };
9058 }, []);
9059 const dirtyEntityRecords = (0,external_wp_element_namespaceObject.useMemo)(() => {
9060 var _siteEntityConfig$met;
9061 // Remove site object and decouple into its edited pieces.
9062 const editedEntitiesWithoutSite = editedEntities.filter(record => !(record.kind === 'root' && record.name === 'site'));
9063 const siteEntityLabels = (_siteEntityConfig$met = siteEntityConfig?.meta?.labels) !== null && _siteEntityConfig$met !== void 0 ? _siteEntityConfig$met : {};
9064 const editedSiteEntities = [];
9065 for (const property in siteEdits) {
9066 editedSiteEntities.push({
9067 kind: 'root',
9068 name: 'site',
9069 title: siteEntityLabels[property] || property,
9070 property
9071 });
9072 }
9073 return [...editedEntitiesWithoutSite, ...editedSiteEntities];
9074 }, [editedEntities, siteEdits, siteEntityConfig]);
9075
9076 // Unchecked entities to be ignored by save function.
9077 const [unselectedEntities, _setUnselectedEntities] = (0,external_wp_element_namespaceObject.useState)([]);
9078 const setUnselectedEntities = ({
9079 kind,
9080 name,
9081 key,
9082 property
9083 }, checked) => {
9084 if (checked) {
9085 _setUnselectedEntities(unselectedEntities.filter(elt => elt.kind !== kind || elt.name !== name || elt.key !== key || elt.property !== property));
9086 } else {
9087 _setUnselectedEntities([...unselectedEntities, {
9088 kind,
9089 name,
9090 key,
9091 property
9092 }]);
9093 }
9094 };
9095 const isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;
9096 return {
9097 dirtyEntityRecords,
9098 isDirty,
9099 setUnselectedEntities,
9100 unselectedEntities
9101 };
9102 };
9103
9104 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/entities-saved-states/index.js
9105 /**
9106 * WordPress dependencies
9107 */
9108
9109
9110
9111
9112
9113
9114 /**
9115 * Internal dependencies
9116 */
9117
9118
9119
9120
9121
9122
9123 function identity(values) {
9124 return values;
9125 }
9126 function EntitiesSavedStates({
9127 close,
9128 renderDialog = undefined
9129 }) {
9130 const isDirtyProps = useIsDirty();
9131 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntitiesSavedStatesExtensible, {
9132 close: close,
9133 renderDialog: renderDialog,
9134 ...isDirtyProps
9135 });
9136 }
9137 function EntitiesSavedStatesExtensible({
9138 additionalPrompt = undefined,
9139 close,
9140 onSave = identity,
9141 saveEnabled: saveEnabledProp = undefined,
9142 saveLabel = (0,external_wp_i18n_namespaceObject.__)('Save'),
9143 renderDialog = undefined,
9144 dirtyEntityRecords,
9145 isDirty,
9146 setUnselectedEntities,
9147 unselectedEntities
9148 }) {
9149 const saveButtonRef = (0,external_wp_element_namespaceObject.useRef)();
9150 const {
9151 saveDirtyEntities
9152 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
9153 // To group entities by type.
9154 const partitionedSavables = dirtyEntityRecords.reduce((acc, record) => {
9155 const {
9156 name
9157 } = record;
9158 if (!acc[name]) {
9159 acc[name] = [];
9160 }
9161 acc[name].push(record);
9162 return acc;
9163 }, {});
9164
9165 // Sort entity groups.
9166 const {
9167 site: siteSavables,
9168 wp_template: templateSavables,
9169 wp_template_part: templatePartSavables,
9170 ...contentSavables
9171 } = partitionedSavables;
9172 const sortedPartitionedSavables = [siteSavables, templateSavables, templatePartSavables, ...Object.values(contentSavables)].filter(Array.isArray);
9173 const saveEnabled = saveEnabledProp !== null && saveEnabledProp !== void 0 ? saveEnabledProp : isDirty;
9174 // Explicitly define this with no argument passed. Using `close` on
9175 // its own will use the event object in place of the expected saved entities.
9176 const dismissPanel = (0,external_wp_element_namespaceObject.useCallback)(() => close(), [close]);
9177 const [saveDialogRef, saveDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
9178 onClose: () => dismissPanel()
9179 });
9180 const dialogLabel = (0,external_wp_compose_namespaceObject.useInstanceId)(EntitiesSavedStatesExtensible, 'label');
9181 const dialogDescription = (0,external_wp_compose_namespaceObject.useInstanceId)(EntitiesSavedStatesExtensible, 'description');
9182 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
9183 ref: saveDialogRef,
9184 ...saveDialogProps,
9185 className: "entities-saved-states__panel",
9186 role: renderDialog ? 'dialog' : undefined,
9187 "aria-labelledby": renderDialog ? dialogLabel : undefined,
9188 "aria-describedby": renderDialog ? dialogDescription : undefined,
9189 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
9190 className: "entities-saved-states__panel-header",
9191 gap: 2,
9192 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
9193 isBlock: true,
9194 as: external_wp_components_namespaceObject.Button,
9195 ref: saveButtonRef,
9196 variant: "primary",
9197 disabled: !saveEnabled,
9198 __experimentalIsFocusable: true,
9199 onClick: () => saveDirtyEntities({
9200 onSave,
9201 dirtyEntityRecords,
9202 entitiesToSkip: unselectedEntities,
9203 close
9204 }),
9205 className: "editor-entities-saved-states__save-button",
9206 children: saveLabel
9207 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
9208 isBlock: true,
9209 as: external_wp_components_namespaceObject.Button,
9210 variant: "secondary",
9211 onClick: dismissPanel,
9212 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
9213 })]
9214 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
9215 className: "entities-saved-states__text-prompt",
9216 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
9217 className: "entities-saved-states__text-prompt--header-wrapper",
9218 id: renderDialog ? dialogLabel : undefined,
9219 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
9220 className: "entities-saved-states__text-prompt--header",
9221 children: (0,external_wp_i18n_namespaceObject.__)('Are you ready to save?')
9222 }), additionalPrompt]
9223 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
9224 id: renderDialog ? dialogDescription : undefined,
9225 children: isDirty ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of site changes waiting to be saved. */
9226 (0,external_wp_i18n_namespaceObject._n)('There is <strong>%d site change</strong> waiting to be saved.', 'There are <strong>%d site changes</strong> waiting to be saved.', sortedPartitionedSavables.length), sortedPartitionedSavables.length), {
9227 strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {})
9228 }) : (0,external_wp_i18n_namespaceObject.__)('Select the items you want to save.')
9229 })]
9230 }), sortedPartitionedSavables.map(list => {
9231 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityTypeList, {
9232 list: list,
9233 unselectedEntities: unselectedEntities,
9234 setUnselectedEntities: setUnselectedEntities
9235 }, list[0].name);
9236 })]
9237 });
9238 }
9239
9240 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/error-boundary/index.js
9241 /**
9242 * WordPress dependencies
9243 */
9244
9245
9246
9247
9248
9249
9250
9251
9252 /**
9253 * Internal dependencies
9254 */
9255
9256
9257 function getContent() {
9258 try {
9259 // While `select` in a component is generally discouraged, it is
9260 // used here because it (a) reduces the chance of data loss in the
9261 // case of additional errors by performing a direct retrieval and
9262 // (b) avoids the performance cost associated with unnecessary
9263 // content serialization throughout the lifetime of a non-erroring
9264 // application.
9265 return (0,external_wp_data_namespaceObject.select)(store_store).getEditedPostContent();
9266 } catch (error) {}
9267 }
9268 function CopyButton({
9269 text,
9270 children
9271 }) {
9272 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text);
9273 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
9274 variant: "secondary",
9275 ref: ref,
9276 children: children
9277 });
9278 }
9279 class ErrorBoundary extends external_wp_element_namespaceObject.Component {
9280 constructor() {
9281 super(...arguments);
9282 this.state = {
9283 error: null
9284 };
9285 }
9286 componentDidCatch(error) {
9287 (0,external_wp_hooks_namespaceObject.doAction)('editor.ErrorBoundary.errorLogged', error);
9288 }
9289 static getDerivedStateFromError(error) {
9290 return {
9291 error
9292 };
9293 }
9294 render() {
9295 const {
9296 error
9297 } = this.state;
9298 if (!error) {
9299 return this.props.children;
9300 }
9301 const actions = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyButton, {
9302 text: getContent,
9303 children: (0,external_wp_i18n_namespaceObject.__)('Copy Post Text')
9304 }, "copy-post"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyButton, {
9305 text: error.stack,
9306 children: (0,external_wp_i18n_namespaceObject.__)('Copy Error')
9307 }, "copy-error")];
9308 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.Warning, {
9309 className: "editor-error-boundary",
9310 actions: actions,
9311 children: (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.')
9312 });
9313 }
9314 }
9315
9316 /**
9317 * ErrorBoundary is used to catch JavaScript errors anywhere in a child component tree, log those errors, and display a fallback UI.
9318 *
9319 * It uses the lifecycle methods getDerivedStateFromError and componentDidCatch to catch errors in a child component tree.
9320 *
9321 * getDerivedStateFromError is used to render a fallback UI after an error has been thrown, and componentDidCatch is used to log error information.
9322 *
9323 * @class ErrorBoundary
9324 * @augments Component
9325 */
9326 /* harmony default export */ const error_boundary = (ErrorBoundary);
9327
9328 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/local-autosave-monitor/index.js
9329 /**
9330 * WordPress dependencies
9331 */
9332
9333
9334
9335
9336
9337
9338
9339 /**
9340 * Internal dependencies
9341 */
9342
9343
9344
9345
9346 const requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame;
9347 let hasStorageSupport;
9348
9349 /**
9350 * Function which returns true if the current environment supports browser
9351 * sessionStorage, or false otherwise. The result of this function is cached and
9352 * reused in subsequent invocations.
9353 */
9354 const hasSessionStorageSupport = () => {
9355 if (hasStorageSupport !== undefined) {
9356 return hasStorageSupport;
9357 }
9358 try {
9359 // Private Browsing in Safari 10 and earlier will throw an error when
9360 // attempting to set into sessionStorage. The test here is intentional in
9361 // causing a thrown error as condition bailing from local autosave.
9362 window.sessionStorage.setItem('__wpEditorTestSessionStorage', '');
9363 window.sessionStorage.removeItem('__wpEditorTestSessionStorage');
9364 hasStorageSupport = true;
9365 } catch {
9366 hasStorageSupport = false;
9367 }
9368 return hasStorageSupport;
9369 };
9370
9371 /**
9372 * Custom hook which manages the creation of a notice prompting the user to
9373 * restore a local autosave, if one exists.
9374 */
9375 function useAutosaveNotice() {
9376 const {
9377 postId,
9378 isEditedPostNew,
9379 hasRemoteAutosave
9380 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
9381 postId: select(store_store).getCurrentPostId(),
9382 isEditedPostNew: select(store_store).isEditedPostNew(),
9383 hasRemoteAutosave: !!select(store_store).getEditorSettings().autosave
9384 }), []);
9385 const {
9386 getEditedPostAttribute
9387 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
9388 const {
9389 createWarningNotice,
9390 removeNotice
9391 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
9392 const {
9393 editPost,
9394 resetEditorBlocks
9395 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9396 (0,external_wp_element_namespaceObject.useEffect)(() => {
9397 let localAutosave = localAutosaveGet(postId, isEditedPostNew);
9398 if (!localAutosave) {
9399 return;
9400 }
9401 try {
9402 localAutosave = JSON.parse(localAutosave);
9403 } catch {
9404 // Not usable if it can't be parsed.
9405 return;
9406 }
9407 const {
9408 post_title: title,
9409 content,
9410 excerpt
9411 } = localAutosave;
9412 const edits = {
9413 title,
9414 content,
9415 excerpt
9416 };
9417 {
9418 // Only display a notice if there is a difference between what has been
9419 // saved and that which is stored in sessionStorage.
9420 const hasDifference = Object.keys(edits).some(key => {
9421 return edits[key] !== getEditedPostAttribute(key);
9422 });
9423 if (!hasDifference) {
9424 // If there is no difference, it can be safely ejected from storage.
9425 localAutosaveClear(postId, isEditedPostNew);
9426 return;
9427 }
9428 }
9429 if (hasRemoteAutosave) {
9430 return;
9431 }
9432 const id = 'wpEditorAutosaveRestore';
9433 createWarningNotice((0,external_wp_i18n_namespaceObject.__)('The backup of this post in your browser is different from the version below.'), {
9434 id,
9435 actions: [{
9436 label: (0,external_wp_i18n_namespaceObject.__)('Restore the backup'),
9437 onClick() {
9438 const {
9439 content: editsContent,
9440 ...editsWithoutContent
9441 } = edits;
9442 editPost(editsWithoutContent);
9443 resetEditorBlocks((0,external_wp_blocks_namespaceObject.parse)(edits.content));
9444 removeNotice(id);
9445 }
9446 }]
9447 });
9448 }, [isEditedPostNew, postId]);
9449 }
9450
9451 /**
9452 * Custom hook which ejects a local autosave after a successful save occurs.
9453 */
9454 function useAutosavePurge() {
9455 const {
9456 postId,
9457 isEditedPostNew,
9458 isDirty,
9459 isAutosaving,
9460 didError
9461 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
9462 postId: select(store_store).getCurrentPostId(),
9463 isEditedPostNew: select(store_store).isEditedPostNew(),
9464 isDirty: select(store_store).isEditedPostDirty(),
9465 isAutosaving: select(store_store).isAutosavingPost(),
9466 didError: select(store_store).didPostSaveRequestFail()
9467 }), []);
9468 const lastIsDirty = (0,external_wp_element_namespaceObject.useRef)(isDirty);
9469 const lastIsAutosaving = (0,external_wp_element_namespaceObject.useRef)(isAutosaving);
9470 (0,external_wp_element_namespaceObject.useEffect)(() => {
9471 if (!didError && (lastIsAutosaving.current && !isAutosaving || lastIsDirty.current && !isDirty)) {
9472 localAutosaveClear(postId, isEditedPostNew);
9473 }
9474 lastIsDirty.current = isDirty;
9475 lastIsAutosaving.current = isAutosaving;
9476 }, [isDirty, isAutosaving, didError]);
9477
9478 // Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.
9479 const wasEditedPostNew = (0,external_wp_compose_namespaceObject.usePrevious)(isEditedPostNew);
9480 const prevPostId = (0,external_wp_compose_namespaceObject.usePrevious)(postId);
9481 (0,external_wp_element_namespaceObject.useEffect)(() => {
9482 if (prevPostId === postId && wasEditedPostNew && !isEditedPostNew) {
9483 localAutosaveClear(postId, true);
9484 }
9485 }, [isEditedPostNew, postId]);
9486 }
9487 function LocalAutosaveMonitor() {
9488 const {
9489 autosave
9490 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9491 const deferredAutosave = (0,external_wp_element_namespaceObject.useCallback)(() => {
9492 requestIdleCallback(() => autosave({
9493 local: true
9494 }));
9495 }, []);
9496 useAutosaveNotice();
9497 useAutosavePurge();
9498 const localAutosaveInterval = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditorSettings().localAutosaveInterval, []);
9499 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(autosave_monitor, {
9500 interval: localAutosaveInterval,
9501 autosave: deferredAutosave
9502 });
9503 }
9504
9505 /**
9506 * Monitors local autosaves of a post in the editor.
9507 * It uses several hooks and functions to manage autosave behavior:
9508 * - `useAutosaveNotice` hook: Manages the creation of a notice prompting the user to restore a local autosave, if one exists.
9509 * - `useAutosavePurge` hook: Ejects a local autosave after a successful save occurs.
9510 * - `hasSessionStorageSupport` function: Checks if the current environment supports browser sessionStorage.
9511 * - `LocalAutosaveMonitor` component: Uses the `AutosaveMonitor` component to perform autosaves at a specified interval.
9512 *
9513 * The module also checks for sessionStorage support and conditionally exports the `LocalAutosaveMonitor` component based on that.
9514 *
9515 * @module LocalAutosaveMonitor
9516 */
9517 /* harmony default export */ const local_autosave_monitor = ((0,external_wp_compose_namespaceObject.ifCondition)(hasSessionStorageSupport)(LocalAutosaveMonitor));
9518
9519 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/page-attributes/check.js
9520 /**
9521 * WordPress dependencies
9522 */
9523
9524
9525
9526 /**
9527 * Internal dependencies
9528 */
9529
9530
9531 /**
9532 * Wrapper component that renders its children only if the post type supports page attributes.
9533 *
9534 * @param {Object} props - The component props.
9535 * @param {Element} props.children - The child components to render.
9536 *
9537 * @return {Component|null} The rendered child components or null if page attributes are not supported.
9538 */
9539 function PageAttributesCheck({
9540 children
9541 }) {
9542 const supportsPageAttributes = (0,external_wp_data_namespaceObject.useSelect)(select => {
9543 const {
9544 getEditedPostAttribute
9545 } = select(store_store);
9546 const {
9547 getPostType
9548 } = select(external_wp_coreData_namespaceObject.store);
9549 const postType = getPostType(getEditedPostAttribute('type'));
9550 return !!postType?.supports?.['page-attributes'];
9551 }, []);
9552
9553 // Only render fields if post type supports page attributes or available templates exist.
9554 if (!supportsPageAttributes) {
9555 return null;
9556 }
9557 return children;
9558 }
9559 /* harmony default export */ const page_attributes_check = (PageAttributesCheck);
9560
9561 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-panel-row/index.js
9562 /**
9563 * External dependencies
9564 */
9565
9566
9567 /**
9568 * WordPress dependencies
9569 */
9570
9571
9572
9573
9574 const PostPanelRow = (0,external_wp_element_namespaceObject.forwardRef)(({
9575 className,
9576 label,
9577 children
9578 }, ref) => {
9579 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
9580 className: dist_clsx('editor-post-panel__row', className),
9581 ref: ref,
9582 children: [label && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
9583 className: "editor-post-panel__row-label",
9584 children: label
9585 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
9586 className: "editor-post-panel__row-control",
9587 children: children
9588 })]
9589 });
9590 });
9591 /* harmony default export */ const post_panel_row = (PostPanelRow);
9592
9593 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-type-support-check/index.js
9594 /**
9595 * WordPress dependencies
9596 */
9597
9598
9599
9600 /**
9601 * Internal dependencies
9602 */
9603
9604
9605 /**
9606 * A component which renders its own children only if the current editor post
9607 * type supports one of the given `supportKeys` prop.
9608 *
9609 * @param {Object} props Props.
9610 * @param {Element} props.children Children to be rendered if post
9611 * type supports.
9612 * @param {(string|string[])} props.supportKeys String or string array of keys
9613 * to test.
9614 *
9615 * @return {Component} The component to be rendered.
9616 */
9617 function PostTypeSupportCheck({
9618 children,
9619 supportKeys
9620 }) {
9621 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => {
9622 const {
9623 getEditedPostAttribute
9624 } = select(store_store);
9625 const {
9626 getPostType
9627 } = select(external_wp_coreData_namespaceObject.store);
9628 return getPostType(getEditedPostAttribute('type'));
9629 }, []);
9630 let isSupported = !!postType;
9631 if (postType) {
9632 isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some(key => !!postType.supports[key]);
9633 }
9634 if (!isSupported) {
9635 return null;
9636 }
9637 return children;
9638 }
9639 /* harmony default export */ const post_type_support_check = (PostTypeSupportCheck);
9640
9641 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/page-attributes/order.js
9642 /**
9643 * WordPress dependencies
9644 */
9645
9646
9647
9648
9649
9650
9651 /**
9652 * Internal dependencies
9653 */
9654
9655
9656
9657
9658
9659 function PageAttributesOrder() {
9660 const order = (0,external_wp_data_namespaceObject.useSelect)(select => {
9661 var _select$getEditedPost;
9662 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('menu_order')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 0;
9663 }, []);
9664 const {
9665 editPost
9666 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9667 const [orderInput, setOrderInput] = (0,external_wp_element_namespaceObject.useState)(null);
9668 const setUpdatedOrder = value => {
9669 setOrderInput(value);
9670 const newOrder = Number(value);
9671 if (Number.isInteger(newOrder) && value.trim?.() !== '') {
9672 editPost({
9673 menu_order: newOrder
9674 });
9675 }
9676 };
9677 const value = orderInput !== null && orderInput !== void 0 ? orderInput : order;
9678 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Flex, {
9679 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexBlock, {
9680 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNumberControl, {
9681 __next40pxDefaultSize: true,
9682 label: (0,external_wp_i18n_namespaceObject.__)('Order'),
9683 help: (0,external_wp_i18n_namespaceObject.__)('Set the page order.'),
9684 value: value,
9685 onChange: setUpdatedOrder,
9686 hideLabelFromVision: true,
9687 onBlur: () => {
9688 setOrderInput(null);
9689 }
9690 })
9691 })
9692 });
9693 }
9694
9695 /**
9696 * Renders the Page Attributes Order component. A number input in an editor interface
9697 * for setting the order of a given page.
9698 *
9699 * @return {Component} The component to be rendered.
9700 */
9701 function PageAttributesOrderWithChecks() {
9702 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
9703 supportKeys: "page-attributes",
9704 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PageAttributesOrder, {})
9705 });
9706 }
9707 function PostOrderToggle({
9708 isOpen,
9709 onClick
9710 }) {
9711 const order = (0,external_wp_data_namespaceObject.useSelect)(select => {
9712 var _select$getEditedPost2;
9713 return (_select$getEditedPost2 = select(store_store).getEditedPostAttribute('menu_order')) !== null && _select$getEditedPost2 !== void 0 ? _select$getEditedPost2 : 0;
9714 }, []);
9715 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
9716 size: "compact",
9717 className: "editor-post-order__panel-toggle",
9718 variant: "tertiary",
9719 "aria-expanded": isOpen
9720 // translators: %s: Current post parent.
9721 ,
9722 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change order: %s'), order),
9723 onClick: onClick,
9724 children: order
9725 });
9726 }
9727 function OrderRow() {
9728 // Use internal state instead of a ref to make sure that the component
9729 // re-renders when the popover's anchor updates.
9730 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
9731 // Memoize popoverProps to avoid returning a new object every time.
9732 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
9733 // Anchor the popover to the middle of the entire row so that it doesn't
9734 // move around when the label changes.
9735 anchor: popoverAnchor,
9736 placement: 'left-start',
9737 offset: 36,
9738 shift: true
9739 }), [popoverAnchor]);
9740 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
9741 label: (0,external_wp_i18n_namespaceObject.__)('Order'),
9742 ref: setPopoverAnchor,
9743 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
9744 popoverProps: popoverProps,
9745 className: "editor-post-order__panel-dropdown",
9746 contentClassName: "editor-post-order__panel-dialog",
9747 focusOnMount: true,
9748 renderToggle: ({
9749 isOpen,
9750 onToggle
9751 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostOrderToggle, {
9752 isOpen: isOpen,
9753 onClick: onToggle
9754 }),
9755 renderContent: ({
9756 onClose
9757 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
9758 className: "editor-post-order",
9759 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
9760 title: (0,external_wp_i18n_namespaceObject.__)('Order'),
9761 onClose: onClose
9762 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
9763 children: [(0,external_wp_i18n_namespaceObject.__)('This attribute determines the order of pages in the Pages List block.'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
9764 children: (0,external_wp_i18n_namespaceObject.__)('Pages with the same order value will sorted alphabetically. Negative order values are also supported.')
9765 })]
9766 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PageAttributesOrder, {})]
9767 })
9768 })
9769 });
9770 }
9771
9772 // EXTERNAL MODULE: ./node_modules/remove-accents/index.js
9773 var remove_accents = __webpack_require__(4793);
9774 var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents);
9775 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/terms.js
9776 /**
9777 * WordPress dependencies
9778 */
9779
9780
9781 /**
9782 * Returns terms in a tree form.
9783 *
9784 * @param {Array} flatTerms Array of terms in flat format.
9785 *
9786 * @return {Array} Array of terms in tree format.
9787 */
9788 function buildTermsTree(flatTerms) {
9789 const flatTermsWithParentAndChildren = flatTerms.map(term => {
9790 return {
9791 children: [],
9792 parent: null,
9793 ...term
9794 };
9795 });
9796
9797 // All terms should have a `parent` because we're about to index them by it.
9798 if (flatTermsWithParentAndChildren.some(({
9799 parent
9800 }) => parent === null)) {
9801 return flatTermsWithParentAndChildren;
9802 }
9803 const termsByParent = flatTermsWithParentAndChildren.reduce((acc, term) => {
9804 const {
9805 parent
9806 } = term;
9807 if (!acc[parent]) {
9808 acc[parent] = [];
9809 }
9810 acc[parent].push(term);
9811 return acc;
9812 }, {});
9813 const fillWithChildren = terms => {
9814 return terms.map(term => {
9815 const children = termsByParent[term.id];
9816 return {
9817 ...term,
9818 children: children && children.length ? fillWithChildren(children) : []
9819 };
9820 });
9821 };
9822 return fillWithChildren(termsByParent['0'] || []);
9823 }
9824 const unescapeString = arg => {
9825 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(arg);
9826 };
9827
9828 /**
9829 * Returns a term object with name unescaped.
9830 *
9831 * @param {Object} term The term object to unescape.
9832 *
9833 * @return {Object} Term object with name property unescaped.
9834 */
9835 const unescapeTerm = term => {
9836 return {
9837 ...term,
9838 name: unescapeString(term.name)
9839 };
9840 };
9841
9842 /**
9843 * Returns an array of term objects with names unescaped.
9844 * The unescape of each term is performed using the unescapeTerm function.
9845 *
9846 * @param {Object[]} terms Array of term objects to unescape.
9847 *
9848 * @return {Object[]} Array of term objects unescaped.
9849 */
9850 const unescapeTerms = terms => {
9851 return (terms !== null && terms !== void 0 ? terms : []).map(unescapeTerm);
9852 };
9853
9854 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/page-attributes/parent.js
9855 /**
9856 * External dependencies
9857 */
9858
9859
9860 /**
9861 * WordPress dependencies
9862 */
9863
9864
9865
9866
9867
9868
9869
9870
9871
9872 /**
9873 * Internal dependencies
9874 */
9875
9876
9877
9878
9879
9880 function getTitle(post) {
9881 return post?.title?.rendered ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title.rendered) : `#${post.id} (${(0,external_wp_i18n_namespaceObject.__)('no title')})`;
9882 }
9883 const getItemPriority = (name, searchValue) => {
9884 const normalizedName = remove_accents_default()(name || '').toLowerCase();
9885 const normalizedSearch = remove_accents_default()(searchValue || '').toLowerCase();
9886 if (normalizedName === normalizedSearch) {
9887 return 0;
9888 }
9889 if (normalizedName.startsWith(normalizedSearch)) {
9890 return normalizedName.length;
9891 }
9892 return Infinity;
9893 };
9894
9895 /**
9896 * Renders the Page Attributes Parent component. A dropdown menu in an editor interface
9897 * for selecting the parent page of a given page.
9898 *
9899 * @return {Component|null} The component to be rendered. Return null if post type is not hierarchical.
9900 */
9901 function PageAttributesParent() {
9902 const {
9903 editPost
9904 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9905 const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)(false);
9906 const {
9907 isHierarchical,
9908 parentPostId,
9909 parentPostTitle,
9910 pageItems
9911 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9912 var _pType$hierarchical;
9913 const {
9914 getPostType,
9915 getEntityRecords,
9916 getEntityRecord
9917 } = select(external_wp_coreData_namespaceObject.store);
9918 const {
9919 getCurrentPostId,
9920 getEditedPostAttribute
9921 } = select(store_store);
9922 const postTypeSlug = getEditedPostAttribute('type');
9923 const pageId = getEditedPostAttribute('parent');
9924 const pType = getPostType(postTypeSlug);
9925 const postId = getCurrentPostId();
9926 const postIsHierarchical = (_pType$hierarchical = pType?.hierarchical) !== null && _pType$hierarchical !== void 0 ? _pType$hierarchical : false;
9927 const query = {
9928 per_page: 100,
9929 exclude: postId,
9930 parent_exclude: postId,
9931 orderby: 'menu_order',
9932 order: 'asc',
9933 _fields: 'id,title,parent'
9934 };
9935
9936 // Perform a search when the field is changed.
9937 if (!!fieldValue) {
9938 query.search = fieldValue;
9939 }
9940 const parentPost = pageId ? getEntityRecord('postType', postTypeSlug, pageId) : null;
9941 return {
9942 isHierarchical: postIsHierarchical,
9943 parentPostId: pageId,
9944 parentPostTitle: parentPost ? getTitle(parentPost) : '',
9945 pageItems: postIsHierarchical ? getEntityRecords('postType', postTypeSlug, query) : null
9946 };
9947 }, [fieldValue]);
9948 const parentOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
9949 const getOptionsFromTree = (tree, level = 0) => {
9950 const mappedNodes = tree.map(treeNode => [{
9951 value: treeNode.id,
9952 label: '— '.repeat(level) + (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(treeNode.name),
9953 rawName: treeNode.name
9954 }, ...getOptionsFromTree(treeNode.children || [], level + 1)]);
9955 const sortedNodes = mappedNodes.sort(([a], [b]) => {
9956 const priorityA = getItemPriority(a.rawName, fieldValue);
9957 const priorityB = getItemPriority(b.rawName, fieldValue);
9958 return priorityA >= priorityB ? 1 : -1;
9959 });
9960 return sortedNodes.flat();
9961 };
9962 if (!pageItems) {
9963 return [];
9964 }
9965 let tree = pageItems.map(item => ({
9966 id: item.id,
9967 parent: item.parent,
9968 name: getTitle(item)
9969 }));
9970
9971 // Only build a hierarchical tree when not searching.
9972 if (!fieldValue) {
9973 tree = buildTermsTree(tree);
9974 }
9975 const opts = getOptionsFromTree(tree);
9976
9977 // Ensure the current parent is in the options list.
9978 const optsHasParent = opts.find(item => item.value === parentPostId);
9979 if (parentPostTitle && !optsHasParent) {
9980 opts.unshift({
9981 value: parentPostId,
9982 label: parentPostTitle
9983 });
9984 }
9985 return opts;
9986 }, [pageItems, fieldValue, parentPostTitle, parentPostId]);
9987 if (!isHierarchical) {
9988 return null;
9989 }
9990 /**
9991 * Handle user input.
9992 *
9993 * @param {string} inputValue The current value of the input field.
9994 */
9995 const handleKeydown = inputValue => {
9996 setFieldValue(inputValue);
9997 };
9998
9999 /**
10000 * Handle author selection.
10001 *
10002 * @param {Object} selectedPostId The selected Author.
10003 */
10004 const handleChange = selectedPostId => {
10005 editPost({
10006 parent: selectedPostId
10007 });
10008 };
10009 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ComboboxControl, {
10010 __nextHasNoMarginBottom: true,
10011 __next40pxDefaultSize: true,
10012 className: "editor-page-attributes__parent",
10013 label: (0,external_wp_i18n_namespaceObject.__)('Parent'),
10014 help: (0,external_wp_i18n_namespaceObject.__)('Choose a parent page.'),
10015 value: parentPostId,
10016 options: parentOptions,
10017 onFilterValueChange: (0,external_wp_compose_namespaceObject.debounce)(handleKeydown, 300),
10018 onChange: handleChange,
10019 hideLabelFromVision: true
10020 });
10021 }
10022 function PostParentToggle({
10023 isOpen,
10024 onClick
10025 }) {
10026 const parentPost = (0,external_wp_data_namespaceObject.useSelect)(select => {
10027 const {
10028 getEditedPostAttribute
10029 } = select(store_store);
10030 const parentPostId = getEditedPostAttribute('parent');
10031 if (!parentPostId) {
10032 return null;
10033 }
10034 const {
10035 getEntityRecord
10036 } = select(external_wp_coreData_namespaceObject.store);
10037 const postTypeSlug = getEditedPostAttribute('type');
10038 return getEntityRecord('postType', postTypeSlug, parentPostId);
10039 }, []);
10040 const parentTitle = (0,external_wp_element_namespaceObject.useMemo)(() => !parentPost ? (0,external_wp_i18n_namespaceObject.__)('None') : getTitle(parentPost), [parentPost]);
10041 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
10042 size: "compact",
10043 className: "editor-post-parent__panel-toggle",
10044 variant: "tertiary",
10045 "aria-expanded": isOpen
10046 // translators: %s: Current post parent.
10047 ,
10048 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change parent: %s'), parentTitle),
10049 onClick: onClick,
10050 children: parentTitle
10051 });
10052 }
10053 function ParentRow() {
10054 // Use internal state instead of a ref to make sure that the component
10055 // re-renders when the popover's anchor updates.
10056 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
10057 // Memoize popoverProps to avoid returning a new object every time.
10058 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
10059 // Anchor the popover to the middle of the entire row so that it doesn't
10060 // move around when the label changes.
10061 anchor: popoverAnchor,
10062 placement: 'left-start',
10063 offset: 36,
10064 shift: true
10065 }), [popoverAnchor]);
10066 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
10067 label: (0,external_wp_i18n_namespaceObject.__)('Parent'),
10068 ref: setPopoverAnchor,
10069 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
10070 popoverProps: popoverProps,
10071 className: "editor-post-parent__panel-dropdown",
10072 contentClassName: "editor-post-parent__panel-dialog",
10073 focusOnMount: true,
10074 renderToggle: ({
10075 isOpen,
10076 onToggle
10077 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostParentToggle, {
10078 isOpen: isOpen,
10079 onClick: onToggle
10080 }),
10081 renderContent: ({
10082 onClose
10083 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
10084 className: "editor-post-parent",
10085 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
10086 title: (0,external_wp_i18n_namespaceObject.__)('Parent'),
10087 onClose: onClose
10088 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
10089 children: [(0,external_wp_i18n_namespaceObject.__)("Child pages inherit characteristics from their parent, such as URL structure. For instance, if 'Web Design' is a child of 'Services,' its URL would be mysite.com/services/web-design."), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("p", {
10090 children: [(0,external_wp_i18n_namespaceObject.__)('They also show up as sub-items in the default navigation menu. '), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
10091 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'),
10092 children: (0,external_wp_i18n_namespaceObject.__)('Learn more')
10093 })]
10094 })]
10095 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PageAttributesParent, {})]
10096 })
10097 })
10098 });
10099 }
10100 /* harmony default export */ const page_attributes_parent = (PageAttributesParent);
10101
10102 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/page-attributes/panel.js
10103 /**
10104 * WordPress dependencies
10105 */
10106
10107
10108 /**
10109 * Internal dependencies
10110 */
10111
10112
10113
10114
10115
10116
10117
10118 const PANEL_NAME = 'page-attributes';
10119 function AttributesPanel() {
10120 const {
10121 isEnabled,
10122 postType
10123 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10124 const {
10125 getEditedPostAttribute,
10126 isEditorPanelEnabled
10127 } = select(store_store);
10128 const {
10129 getPostType
10130 } = select(external_wp_coreData_namespaceObject.store);
10131 return {
10132 isEnabled: isEditorPanelEnabled(PANEL_NAME),
10133 postType: getPostType(getEditedPostAttribute('type'))
10134 };
10135 }, []);
10136 if (!isEnabled || !postType) {
10137 return null;
10138 }
10139 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
10140 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ParentRow, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(OrderRow, {})]
10141 });
10142 }
10143
10144 /**
10145 * Renders the Page Attributes Panel component.
10146 *
10147 * @return {Component} The component to be rendered.
10148 */
10149 function PageAttributesPanel() {
10150 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(page_attributes_check, {
10151 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(AttributesPanel, {})
10152 });
10153 }
10154
10155 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/add-template.js
10156 /**
10157 * WordPress dependencies
10158 */
10159
10160
10161 const addTemplate = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
10162 viewBox: "0 0 24 24",
10163 xmlns: "http://www.w3.org/2000/svg",
10164 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
10165 fillRule: "evenodd",
10166 clipRule: "evenodd",
10167 d: "M18.5 5.5V8H20V5.5H22.5V4H20V1.5H18.5V4H16V5.5H18.5ZM13.9624 4H6C4.89543 4 4 4.89543 4 6V18C4 19.1046 4.89543 20 6 20H18C19.1046 20 20 19.1046 20 18V10.0391H18.5V18C18.5 18.2761 18.2761 18.5 18 18.5H10L10 10.4917L16.4589 10.5139L16.4641 9.01389L5.5 8.97618V6C5.5 5.72386 5.72386 5.5 6 5.5H13.9624V4ZM5.5 10.4762V18C5.5 18.2761 5.72386 18.5 6 18.5H8.5L8.5 10.4865L5.5 10.4762Z"
10168 })
10169 });
10170 /* harmony default export */ const add_template = (addTemplate);
10171
10172 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/create-new-template-modal.js
10173 /**
10174 * WordPress dependencies
10175 */
10176
10177
10178
10179
10180
10181
10182
10183 /**
10184 * Internal dependencies
10185 */
10186
10187
10188
10189
10190 const DEFAULT_TITLE = (0,external_wp_i18n_namespaceObject.__)('Custom Template');
10191 function CreateNewTemplateModal({
10192 onClose
10193 }) {
10194 const {
10195 defaultBlockTemplate,
10196 onNavigateToEntityRecord
10197 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10198 const {
10199 getEditorSettings,
10200 getCurrentTemplateId
10201 } = select(store_store);
10202 return {
10203 defaultBlockTemplate: getEditorSettings().defaultBlockTemplate,
10204 onNavigateToEntityRecord: getEditorSettings().onNavigateToEntityRecord,
10205 getTemplateId: getCurrentTemplateId
10206 };
10207 });
10208 const {
10209 createTemplate
10210 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
10211 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
10212 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
10213 const cancel = () => {
10214 setTitle('');
10215 onClose();
10216 };
10217 const submit = async event => {
10218 event.preventDefault();
10219 if (isBusy) {
10220 return;
10221 }
10222 setIsBusy(true);
10223 const newTemplateContent = defaultBlockTemplate !== null && defaultBlockTemplate !== void 0 ? defaultBlockTemplate : (0,external_wp_blocks_namespaceObject.serialize)([(0,external_wp_blocks_namespaceObject.createBlock)('core/group', {
10224 tagName: 'header',
10225 layout: {
10226 inherit: true
10227 }
10228 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/site-title'), (0,external_wp_blocks_namespaceObject.createBlock)('core/site-tagline')]), (0,external_wp_blocks_namespaceObject.createBlock)('core/separator'), (0,external_wp_blocks_namespaceObject.createBlock)('core/group', {
10229 tagName: 'main'
10230 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/group', {
10231 layout: {
10232 inherit: true
10233 }
10234 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/post-title')]), (0,external_wp_blocks_namespaceObject.createBlock)('core/post-content', {
10235 layout: {
10236 inherit: true
10237 }
10238 })])]);
10239 const newTemplate = await createTemplate({
10240 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(title || DEFAULT_TITLE),
10241 content: newTemplateContent,
10242 title: title || DEFAULT_TITLE
10243 });
10244 setIsBusy(false);
10245 onNavigateToEntityRecord({
10246 postId: newTemplate.id,
10247 postType: 'wp_template'
10248 });
10249 cancel();
10250 };
10251 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
10252 title: (0,external_wp_i18n_namespaceObject.__)('Create custom template'),
10253 onRequestClose: cancel,
10254 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
10255 className: "editor-post-template__create-form",
10256 onSubmit: submit,
10257 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
10258 spacing: "3",
10259 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
10260 __nextHasNoMarginBottom: true,
10261 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
10262 value: title,
10263 onChange: setTitle,
10264 placeholder: DEFAULT_TITLE,
10265 disabled: isBusy,
10266 help: (0,external_wp_i18n_namespaceObject.__)('Describe the template, e.g. "Post with sidebar". A custom template can be manually applied to any post or page.')
10267 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
10268 justify: "right",
10269 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
10270 variant: "tertiary",
10271 onClick: cancel,
10272 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
10273 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
10274 variant: "primary",
10275 type: "submit",
10276 isBusy: isBusy,
10277 "aria-disabled": isBusy,
10278 children: (0,external_wp_i18n_namespaceObject.__)('Create')
10279 })]
10280 })]
10281 })
10282 })
10283 });
10284 }
10285
10286 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/hooks.js
10287 /**
10288 * WordPress dependencies
10289 */
10290
10291
10292
10293
10294 /**
10295 * Internal dependencies
10296 */
10297
10298 function useEditedPostContext() {
10299 return (0,external_wp_data_namespaceObject.useSelect)(select => {
10300 const {
10301 getCurrentPostId,
10302 getCurrentPostType
10303 } = select(store_store);
10304 return {
10305 postId: getCurrentPostId(),
10306 postType: getCurrentPostType()
10307 };
10308 }, []);
10309 }
10310 function useAllowSwitchingTemplates() {
10311 const {
10312 postType,
10313 postId
10314 } = useEditedPostContext();
10315 return (0,external_wp_data_namespaceObject.useSelect)(select => {
10316 const {
10317 getEntityRecord,
10318 getEntityRecords
10319 } = select(external_wp_coreData_namespaceObject.store);
10320 const siteSettings = getEntityRecord('root', 'site');
10321 const templates = getEntityRecords('postType', 'wp_template', {
10322 per_page: -1
10323 });
10324 const isPostsPage = +postId === siteSettings?.page_for_posts;
10325 // If current page is set front page or posts page, we also need
10326 // to check if the current theme has a template for it. If not
10327 const isFrontPage = postType === 'page' && +postId === siteSettings?.page_on_front && templates?.some(({
10328 slug
10329 }) => slug === 'front-page');
10330 return !isPostsPage && !isFrontPage;
10331 }, [postId, postType]);
10332 }
10333 function useTemplates(postType) {
10334 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template', {
10335 per_page: -1,
10336 post_type: postType
10337 }), [postType]);
10338 }
10339 function useAvailableTemplates(postType) {
10340 const currentTemplateSlug = useCurrentTemplateSlug();
10341 const allowSwitchingTemplate = useAllowSwitchingTemplates();
10342 const templates = useTemplates(postType);
10343 return (0,external_wp_element_namespaceObject.useMemo)(() => allowSwitchingTemplate && templates?.filter(template => template.is_custom && template.slug !== currentTemplateSlug && !!template.content.raw // Skip empty templates.
10344 ), [templates, currentTemplateSlug, allowSwitchingTemplate]);
10345 }
10346 function useCurrentTemplateSlug() {
10347 const {
10348 postType,
10349 postId
10350 } = useEditedPostContext();
10351 const templates = useTemplates(postType);
10352 const entityTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => {
10353 const post = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
10354 return post?.template;
10355 }, [postType, postId]);
10356 if (!entityTemplate) {
10357 return;
10358 }
10359 // If a page has a `template` set and is not included in the list
10360 // of the theme's templates, do not return it, in order to resolve
10361 // to the current theme's default template.
10362 return templates?.find(template => template.slug === entityTemplate)?.slug;
10363 }
10364
10365 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/classic-theme.js
10366 /**
10367 * WordPress dependencies
10368 */
10369
10370
10371
10372
10373
10374
10375
10376
10377
10378 /**
10379 * Internal dependencies
10380 */
10381
10382
10383
10384
10385
10386 const POPOVER_PROPS = {
10387 className: 'editor-post-template__dropdown',
10388 placement: 'bottom-start'
10389 };
10390 function PostTemplateToggle({
10391 isOpen,
10392 onClick
10393 }) {
10394 const templateTitle = (0,external_wp_data_namespaceObject.useSelect)(select => {
10395 const templateSlug = select(store_store).getEditedPostAttribute('template');
10396 const {
10397 supportsTemplateMode,
10398 availableTemplates
10399 } = select(store_store).getEditorSettings();
10400 if (!supportsTemplateMode && availableTemplates[templateSlug]) {
10401 return availableTemplates[templateSlug];
10402 }
10403 const template = select(external_wp_coreData_namespaceObject.store).canUser('create', 'templates') && select(store_store).getCurrentTemplateId();
10404 return template?.title || template?.slug || availableTemplates?.[templateSlug];
10405 }, []);
10406 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
10407 __next40pxDefaultSize: true,
10408 variant: "tertiary",
10409 "aria-expanded": isOpen,
10410 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Template options'),
10411 onClick: onClick,
10412 children: templateTitle !== null && templateTitle !== void 0 ? templateTitle : (0,external_wp_i18n_namespaceObject.__)('Default template')
10413 });
10414 }
10415
10416 /**
10417 * Renders the dropdown content for selecting a post template.
10418 *
10419 * @param {Object} props The component props.
10420 * @param {Function} props.onClose The function to close the dropdown.
10421 *
10422 * @return {JSX.Element} The rendered dropdown content.
10423 */
10424 function PostTemplateDropdownContent({
10425 onClose
10426 }) {
10427 var _options$find, _selectedOption$value;
10428 const allowSwitchingTemplate = useAllowSwitchingTemplates();
10429 const {
10430 availableTemplates,
10431 fetchedTemplates,
10432 selectedTemplateSlug,
10433 canCreate,
10434 canEdit,
10435 currentTemplateId,
10436 onNavigateToEntityRecord,
10437 getEditorSettings
10438 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10439 const {
10440 canUser,
10441 getEntityRecords
10442 } = select(external_wp_coreData_namespaceObject.store);
10443 const editorSettings = select(store_store).getEditorSettings();
10444 const canCreateTemplates = canUser('create', 'templates');
10445 const _currentTemplateId = select(store_store).getCurrentTemplateId();
10446 return {
10447 availableTemplates: editorSettings.availableTemplates,
10448 fetchedTemplates: canCreateTemplates ? getEntityRecords('postType', 'wp_template', {
10449 post_type: select(store_store).getCurrentPostType(),
10450 per_page: -1
10451 }) : undefined,
10452 selectedTemplateSlug: select(store_store).getEditedPostAttribute('template'),
10453 canCreate: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode,
10454 canEdit: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode && !!_currentTemplateId,
10455 currentTemplateId: _currentTemplateId,
10456 onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
10457 getEditorSettings: select(store_store).getEditorSettings
10458 };
10459 }, [allowSwitchingTemplate]);
10460 const options = (0,external_wp_element_namespaceObject.useMemo)(() => Object.entries({
10461 ...availableTemplates,
10462 ...Object.fromEntries((fetchedTemplates !== null && fetchedTemplates !== void 0 ? fetchedTemplates : []).map(({
10463 slug,
10464 title
10465 }) => [slug, title.rendered]))
10466 }).map(([slug, title]) => ({
10467 value: slug,
10468 label: title
10469 })), [availableTemplates, fetchedTemplates]);
10470 const selectedOption = (_options$find = options.find(option => option.value === selectedTemplateSlug)) !== null && _options$find !== void 0 ? _options$find : options.find(option => !option.value); // The default option has '' value.
10471
10472 const {
10473 editPost
10474 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10475 const {
10476 createSuccessNotice
10477 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
10478 const [isCreateModalOpen, setIsCreateModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
10479 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
10480 className: "editor-post-template__classic-theme-dropdown",
10481 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
10482 title: (0,external_wp_i18n_namespaceObject.__)('Template'),
10483 help: (0,external_wp_i18n_namespaceObject.__)('Templates define the way content is displayed when viewing your site.'),
10484 actions: canCreate ? [{
10485 icon: add_template,
10486 label: (0,external_wp_i18n_namespaceObject.__)('Add template'),
10487 onClick: () => setIsCreateModalOpen(true)
10488 }] : [],
10489 onClose: onClose
10490 }), !allowSwitchingTemplate ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
10491 status: "warning",
10492 isDismissible: false,
10493 children: (0,external_wp_i18n_namespaceObject.__)('The posts page template cannot be changed.')
10494 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SelectControl, {
10495 __next40pxDefaultSize: true,
10496 __nextHasNoMarginBottom: true,
10497 hideLabelFromVision: true,
10498 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
10499 value: (_selectedOption$value = selectedOption?.value) !== null && _selectedOption$value !== void 0 ? _selectedOption$value : '',
10500 options: options,
10501 onChange: slug => editPost({
10502 template: slug || ''
10503 })
10504 }), canEdit && onNavigateToEntityRecord && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
10505 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
10506 variant: "link",
10507 onClick: () => {
10508 onNavigateToEntityRecord({
10509 postId: currentTemplateId,
10510 postType: 'wp_template'
10511 });
10512 onClose();
10513 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Editing template. Changes made here affect all posts and pages that use the template.'), {
10514 type: 'snackbar',
10515 actions: [{
10516 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
10517 onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord()
10518 }]
10519 });
10520 },
10521 children: (0,external_wp_i18n_namespaceObject.__)('Edit template')
10522 })
10523 }), isCreateModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateNewTemplateModal, {
10524 onClose: () => setIsCreateModalOpen(false)
10525 })]
10526 });
10527 }
10528 function ClassicThemeControl() {
10529 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
10530 popoverProps: POPOVER_PROPS,
10531 focusOnMount: true,
10532 renderToggle: ({
10533 isOpen,
10534 onToggle
10535 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTemplateToggle, {
10536 isOpen: isOpen,
10537 onClick: onToggle
10538 }),
10539 renderContent: ({
10540 onClose
10541 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTemplateDropdownContent, {
10542 onClose: onClose
10543 })
10544 });
10545 }
10546
10547 /**
10548 * Provides a dropdown menu for selecting and managing post templates.
10549 *
10550 * The dropdown menu includes a button for toggling the menu, a list of available templates, and options for creating and editing templates.
10551 *
10552 * @return {JSX.Element} The rendered ClassicThemeControl component.
10553 */
10554 /* harmony default export */ const classic_theme = (ClassicThemeControl);
10555
10556 ;// CONCATENATED MODULE: external ["wp","warning"]
10557 const external_wp_warning_namespaceObject = window["wp"]["warning"];
10558 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/preferences-modal/enable-panel.js
10559 /**
10560 * WordPress dependencies
10561 */
10562
10563
10564
10565
10566 /**
10567 * Internal dependencies
10568 */
10569
10570
10571 const {
10572 PreferenceBaseOption
10573 } = unlock(external_wp_preferences_namespaceObject.privateApis);
10574 /* harmony default export */ const enable_panel = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, {
10575 panelName
10576 }) => {
10577 const {
10578 isEditorPanelEnabled,
10579 isEditorPanelRemoved
10580 } = select(store_store);
10581 return {
10582 isRemoved: isEditorPanelRemoved(panelName),
10583 isChecked: isEditorPanelEnabled(panelName)
10584 };
10585 }), (0,external_wp_compose_namespaceObject.ifCondition)(({
10586 isRemoved
10587 }) => !isRemoved), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
10588 panelName
10589 }) => ({
10590 onChange: () => dispatch(store_store).toggleEditorPanelEnabled(panelName)
10591 })))(PreferenceBaseOption));
10592
10593 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js
10594 /**
10595 * WordPress dependencies
10596 */
10597
10598
10599 /**
10600 * Internal dependencies
10601 */
10602
10603
10604 const {
10605 Fill,
10606 Slot
10607 } = (0,external_wp_components_namespaceObject.createSlotFill)('EnablePluginDocumentSettingPanelOption');
10608 const EnablePluginDocumentSettingPanelOption = ({
10609 label,
10610 panelName
10611 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Fill, {
10612 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
10613 label: label,
10614 panelName: panelName
10615 })
10616 });
10617 EnablePluginDocumentSettingPanelOption.Slot = Slot;
10618 /* harmony default export */ const enable_plugin_document_setting_panel = (EnablePluginDocumentSettingPanelOption);
10619
10620 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-document-setting-panel/index.js
10621 /**
10622 * WordPress dependencies
10623 */
10624
10625
10626
10627
10628
10629 /**
10630 * Internal dependencies
10631 */
10632
10633
10634
10635
10636
10637 const {
10638 Fill: plugin_document_setting_panel_Fill,
10639 Slot: plugin_document_setting_panel_Slot
10640 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginDocumentSettingPanel');
10641
10642 /**
10643 * Renders items below the Status & Availability panel in the Document Sidebar.
10644 *
10645 * @param {Object} props Component properties.
10646 * @param {string} props.name Required. A machine-friendly name for the panel.
10647 * @param {string} [props.className] An optional class name added to the row.
10648 * @param {string} [props.title] The title of the panel
10649 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
10650 * @param {Element} props.children Children to be rendered
10651 *
10652 * @example
10653 * ```js
10654 * // Using ES5 syntax
10655 * var el = React.createElement;
10656 * var __ = wp.i18n.__;
10657 * var registerPlugin = wp.plugins.registerPlugin;
10658 * var PluginDocumentSettingPanel = wp.editor.PluginDocumentSettingPanel;
10659 *
10660 * function MyDocumentSettingPlugin() {
10661 * return el(
10662 * PluginDocumentSettingPanel,
10663 * {
10664 * className: 'my-document-setting-plugin',
10665 * title: 'My Panel',
10666 * name: 'my-panel',
10667 * },
10668 * __( 'My Document Setting Panel' )
10669 * );
10670 * }
10671 *
10672 * registerPlugin( 'my-document-setting-plugin', {
10673 * render: MyDocumentSettingPlugin
10674 * } );
10675 * ```
10676 *
10677 * @example
10678 * ```jsx
10679 * // Using ESNext syntax
10680 * import { registerPlugin } from '@wordpress/plugins';
10681 * import { PluginDocumentSettingPanel } from '@wordpress/editor';
10682 *
10683 * const MyDocumentSettingTest = () => (
10684 * <PluginDocumentSettingPanel className="my-document-setting-plugin" title="My Panel" name="my-panel">
10685 * <p>My Document Setting Panel</p>
10686 * </PluginDocumentSettingPanel>
10687 * );
10688 *
10689 * registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );
10690 * ```
10691 *
10692 * @return {Component} The component to be rendered.
10693 */
10694 const PluginDocumentSettingPanel = ({
10695 name,
10696 className,
10697 title,
10698 icon,
10699 children
10700 }) => {
10701 const {
10702 name: pluginName
10703 } = (0,external_wp_plugins_namespaceObject.usePluginContext)();
10704 const panelName = `${pluginName}/${name}`;
10705 const {
10706 opened,
10707 isEnabled
10708 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10709 const {
10710 isEditorPanelOpened,
10711 isEditorPanelEnabled
10712 } = select(store_store);
10713 return {
10714 opened: isEditorPanelOpened(panelName),
10715 isEnabled: isEditorPanelEnabled(panelName)
10716 };
10717 }, [panelName]);
10718 const {
10719 toggleEditorPanelOpened
10720 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10721 if (undefined === name) {
10722 false ? 0 : void 0;
10723 }
10724 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
10725 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_plugin_document_setting_panel, {
10726 label: title,
10727 panelName: panelName
10728 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_document_setting_panel_Fill, {
10729 children: isEnabled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
10730 className: className,
10731 title: title,
10732 icon: icon,
10733 opened: opened,
10734 onToggle: () => toggleEditorPanelOpened(panelName),
10735 children: children
10736 })
10737 })]
10738 });
10739 };
10740 PluginDocumentSettingPanel.Slot = plugin_document_setting_panel_Slot;
10741 /* harmony default export */ const plugin_document_setting_panel = (PluginDocumentSettingPanel);
10742
10743 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js
10744 /**
10745 * WordPress dependencies
10746 */
10747
10748
10749
10750
10751 const isEverySelectedBlockAllowed = (selected, allowed) => selected.filter(id => !allowed.includes(id)).length === 0;
10752
10753 /**
10754 * Plugins may want to add an item to the menu either for every block
10755 * or only for the specific ones provided in the `allowedBlocks` component property.
10756 *
10757 * If there are multiple blocks selected the item will be rendered if every block
10758 * is of one allowed type (not necessarily the same).
10759 *
10760 * @param {string[]} selectedBlocks Array containing the names of the blocks selected
10761 * @param {string[]} allowedBlocks Array containing the names of the blocks allowed
10762 * @return {boolean} Whether the item will be rendered or not.
10763 */
10764 const shouldRenderItem = (selectedBlocks, allowedBlocks) => !Array.isArray(allowedBlocks) || isEverySelectedBlockAllowed(selectedBlocks, allowedBlocks);
10765
10766 /**
10767 * Renders a new item in the block settings menu.
10768 *
10769 * @param {Object} props Component props.
10770 * @param {Array} [props.allowedBlocks] An array containing a list of block names for which the item should be shown. If not present, it'll be rendered for any block. If multiple blocks are selected, it'll be shown if and only if all of them are in the allowed list.
10771 * @param {WPBlockTypeIconRender} [props.icon] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element.
10772 * @param {string} props.label The menu item text.
10773 * @param {Function} props.onClick Callback function to be executed when the user click the menu item.
10774 * @param {boolean} [props.small] Whether to render the label or not.
10775 * @param {string} [props.role] The ARIA role for the menu item.
10776 *
10777 * @example
10778 * ```js
10779 * // Using ES5 syntax
10780 * var __ = wp.i18n.__;
10781 * var PluginBlockSettingsMenuItem = wp.editor.PluginBlockSettingsMenuItem;
10782 *
10783 * function doOnClick(){
10784 * // To be called when the user clicks the menu item.
10785 * }
10786 *
10787 * function MyPluginBlockSettingsMenuItem() {
10788 * return React.createElement(
10789 * PluginBlockSettingsMenuItem,
10790 * {
10791 * allowedBlocks: [ 'core/paragraph' ],
10792 * icon: 'dashicon-name',
10793 * label: __( 'Menu item text' ),
10794 * onClick: doOnClick,
10795 * }
10796 * );
10797 * }
10798 * ```
10799 *
10800 * @example
10801 * ```jsx
10802 * // Using ESNext syntax
10803 * import { __ } from '@wordpress/i18n';
10804 * import { PluginBlockSettingsMenuItem } from '@wordpress/editor';
10805 *
10806 * const doOnClick = ( ) => {
10807 * // To be called when the user clicks the menu item.
10808 * };
10809 *
10810 * const MyPluginBlockSettingsMenuItem = () => (
10811 * <PluginBlockSettingsMenuItem
10812 * allowedBlocks={ [ 'core/paragraph' ] }
10813 * icon='dashicon-name'
10814 * label={ __( 'Menu item text' ) }
10815 * onClick={ doOnClick } />
10816 * );
10817 * ```
10818 *
10819 * @return {Component} The component to be rendered.
10820 */
10821 const PluginBlockSettingsMenuItem = ({
10822 allowedBlocks,
10823 icon,
10824 label,
10825 onClick,
10826 small,
10827 role
10828 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
10829 children: ({
10830 selectedBlocks,
10831 onClose
10832 }) => {
10833 if (!shouldRenderItem(selectedBlocks, allowedBlocks)) {
10834 return null;
10835 }
10836 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
10837 onClick: (0,external_wp_compose_namespaceObject.compose)(onClick, onClose),
10838 icon: icon,
10839 label: small ? label : undefined,
10840 role: role,
10841 children: !small && label
10842 });
10843 }
10844 });
10845 /* harmony default export */ const plugin_block_settings_menu_item = (PluginBlockSettingsMenuItem);
10846
10847 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-more-menu-item/index.js
10848 /**
10849 * WordPress dependencies
10850 */
10851
10852
10853
10854
10855
10856 /**
10857 * Renders a menu item in `Plugins` group in `More Menu` drop down, and can be used to as a button or link depending on the props provided.
10858 * The text within the component appears as the menu item label.
10859 *
10860 * @param {Object} props Component properties.
10861 * @param {string} [props.href] When `href` is provided then the menu item is represented as an anchor rather than button. It corresponds to the `href` attribute of the anchor.
10862 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
10863 * @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.
10864 * @param {...*} [props.other] Any additional props are passed through to the underlying [Button](/packages/components/src/button/README.md) component.
10865 *
10866 * @example
10867 * ```js
10868 * // Using ES5 syntax
10869 * var __ = wp.i18n.__;
10870 * var PluginMoreMenuItem = wp.editor.PluginMoreMenuItem;
10871 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
10872 *
10873 * function onButtonClick() {
10874 * alert( 'Button clicked.' );
10875 * }
10876 *
10877 * function MyButtonMoreMenuItem() {
10878 * return wp.element.createElement(
10879 * PluginMoreMenuItem,
10880 * {
10881 * icon: moreIcon,
10882 * onClick: onButtonClick,
10883 * },
10884 * __( 'My button title' )
10885 * );
10886 * }
10887 * ```
10888 *
10889 * @example
10890 * ```jsx
10891 * // Using ESNext syntax
10892 * import { __ } from '@wordpress/i18n';
10893 * import { PluginMoreMenuItem } from '@wordpress/editor';
10894 * import { more } from '@wordpress/icons';
10895 *
10896 * function onButtonClick() {
10897 * alert( 'Button clicked.' );
10898 * }
10899 *
10900 * const MyButtonMoreMenuItem = () => (
10901 * <PluginMoreMenuItem
10902 * icon={ more }
10903 * onClick={ onButtonClick }
10904 * >
10905 * { __( 'My button title' ) }
10906 * </PluginMoreMenuItem>
10907 * );
10908 * ```
10909 *
10910 * @return {Component} The component to be rendered.
10911 */
10912 /* harmony default export */ const plugin_more_menu_item = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
10913 var _ownProps$as;
10914 return {
10915 as: (_ownProps$as = ownProps.as) !== null && _ownProps$as !== void 0 ? _ownProps$as : external_wp_components_namespaceObject.MenuItem,
10916 icon: ownProps.icon || context.icon,
10917 name: 'core/plugin-more-menu'
10918 };
10919 }))(action_item));
10920
10921 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-post-publish-panel/index.js
10922 /**
10923 * WordPress dependencies
10924 */
10925
10926
10927
10928 const {
10929 Fill: plugin_post_publish_panel_Fill,
10930 Slot: plugin_post_publish_panel_Slot
10931 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostPublishPanel');
10932
10933 /**
10934 * Renders provided content to the post-publish panel in the publish flow
10935 * (side panel that opens after a user publishes the post).
10936 *
10937 * @param {Object} props Component properties.
10938 * @param {string} [props.className] An optional class name added to the panel.
10939 * @param {string} [props.title] Title displayed at the top of the panel.
10940 * @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened. When no title is provided it is always opened.
10941 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
10942 * @param {Element} props.children Children to be rendered
10943 *
10944 * @example
10945 * ```jsx
10946 * // Using ESNext syntax
10947 * import { __ } from '@wordpress/i18n';
10948 * import { PluginPostPublishPanel } from '@wordpress/editor';
10949 *
10950 * const MyPluginPostPublishPanel = () => (
10951 * <PluginPostPublishPanel
10952 * className="my-plugin-post-publish-panel"
10953 * title={ __( 'My panel title' ) }
10954 * initialOpen={ true }
10955 * >
10956 * { __( 'My panel content' ) }
10957 * </PluginPostPublishPanel>
10958 * );
10959 * ```
10960 *
10961 * @return {Component} The component to be rendered.
10962 */
10963 const PluginPostPublishPanel = ({
10964 children,
10965 className,
10966 title,
10967 initialOpen = false,
10968 icon
10969 }) => {
10970 const {
10971 icon: pluginIcon
10972 } = (0,external_wp_plugins_namespaceObject.usePluginContext)();
10973 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_post_publish_panel_Fill, {
10974 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
10975 className: className,
10976 initialOpen: initialOpen || !title,
10977 title: title,
10978 icon: icon !== null && icon !== void 0 ? icon : pluginIcon,
10979 children: children
10980 })
10981 });
10982 };
10983 PluginPostPublishPanel.Slot = plugin_post_publish_panel_Slot;
10984 /* harmony default export */ const plugin_post_publish_panel = (PluginPostPublishPanel);
10985
10986 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-post-status-info/index.js
10987 /**
10988 * Defines as extensibility slot for the Summary panel.
10989 */
10990
10991 /**
10992 * WordPress dependencies
10993 */
10994
10995
10996 const {
10997 Fill: plugin_post_status_info_Fill,
10998 Slot: plugin_post_status_info_Slot
10999 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostStatusInfo');
11000
11001 /**
11002 * Renders a row in the Summary panel of the Document sidebar.
11003 * It should be noted that this is named and implemented around the function it serves
11004 * and not its location, which may change in future iterations.
11005 *
11006 * @param {Object} props Component properties.
11007 * @param {string} [props.className] An optional class name added to the row.
11008 * @param {Element} props.children Children to be rendered.
11009 *
11010 * @example
11011 * ```js
11012 * // Using ES5 syntax
11013 * var __ = wp.i18n.__;
11014 * var PluginPostStatusInfo = wp.editor.PluginPostStatusInfo;
11015 *
11016 * function MyPluginPostStatusInfo() {
11017 * return React.createElement(
11018 * PluginPostStatusInfo,
11019 * {
11020 * className: 'my-plugin-post-status-info',
11021 * },
11022 * __( 'My post status info' )
11023 * )
11024 * }
11025 * ```
11026 *
11027 * @example
11028 * ```jsx
11029 * // Using ESNext syntax
11030 * import { __ } from '@wordpress/i18n';
11031 * import { PluginPostStatusInfo } from '@wordpress/editor';
11032 *
11033 * const MyPluginPostStatusInfo = () => (
11034 * <PluginPostStatusInfo
11035 * className="my-plugin-post-status-info"
11036 * >
11037 * { __( 'My post status info' ) }
11038 * </PluginPostStatusInfo>
11039 * );
11040 * ```
11041 *
11042 * @return {Component} The component to be rendered.
11043 */
11044 const PluginPostStatusInfo = ({
11045 children,
11046 className
11047 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_post_status_info_Fill, {
11048 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
11049 className: className,
11050 children: children
11051 })
11052 });
11053 PluginPostStatusInfo.Slot = plugin_post_status_info_Slot;
11054 /* harmony default export */ const plugin_post_status_info = (PluginPostStatusInfo);
11055
11056 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-pre-publish-panel/index.js
11057 /**
11058 * WordPress dependencies
11059 */
11060
11061
11062
11063 const {
11064 Fill: plugin_pre_publish_panel_Fill,
11065 Slot: plugin_pre_publish_panel_Slot
11066 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPrePublishPanel');
11067
11068 /**
11069 * Renders provided content to the pre-publish side panel in the publish flow
11070 * (side panel that opens when a user first pushes "Publish" from the main editor).
11071 *
11072 * @param {Object} props Component props.
11073 * @param {string} [props.className] An optional class name added to the panel.
11074 * @param {string} [props.title] Title displayed at the top of the panel.
11075 * @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened.
11076 * When no title is provided it is always opened.
11077 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/)
11078 * icon slug string, or an SVG WP element, to be rendered when
11079 * the sidebar is pinned to toolbar.
11080 * @param {Element} props.children Children to be rendered
11081 *
11082 * @example
11083 * ```jsx
11084 * // Using ESNext syntax
11085 * import { __ } from '@wordpress/i18n';
11086 * import { PluginPrePublishPanel } from '@wordpress/editor';
11087 *
11088 * const MyPluginPrePublishPanel = () => (
11089 * <PluginPrePublishPanel
11090 * className="my-plugin-pre-publish-panel"
11091 * title={ __( 'My panel title' ) }
11092 * initialOpen={ true }
11093 * >
11094 * { __( 'My panel content' ) }
11095 * </PluginPrePublishPanel>
11096 * );
11097 * ```
11098 *
11099 * @return {Component} The component to be rendered.
11100 */
11101 const PluginPrePublishPanel = ({
11102 children,
11103 className,
11104 title,
11105 initialOpen = false,
11106 icon
11107 }) => {
11108 const {
11109 icon: pluginIcon
11110 } = (0,external_wp_plugins_namespaceObject.usePluginContext)();
11111 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_pre_publish_panel_Fill, {
11112 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
11113 className: className,
11114 initialOpen: initialOpen || !title,
11115 title: title,
11116 icon: icon !== null && icon !== void 0 ? icon : pluginIcon,
11117 children: children
11118 })
11119 });
11120 };
11121 PluginPrePublishPanel.Slot = plugin_pre_publish_panel_Slot;
11122 /* harmony default export */ const plugin_pre_publish_panel = (PluginPrePublishPanel);
11123
11124 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-sidebar/index.js
11125 /**
11126 * WordPress dependencies
11127 */
11128
11129
11130
11131
11132
11133 /**
11134 * Internal dependencies
11135 */
11136
11137
11138 /**
11139 * Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar.
11140 * It also automatically renders a corresponding `PluginSidebarMenuItem` component when `isPinnable` flag is set to `true`.
11141 * If you wish to display the sidebar, you can with use the `PluginSidebarMoreMenuItem` component or the `wp.data.dispatch` API:
11142 *
11143 * ```js
11144 * wp.data.dispatch( 'core/edit-post' ).openGeneralSidebar( 'plugin-name/sidebar-name' );
11145 * ```
11146 *
11147 * @see PluginSidebarMoreMenuItem
11148 *
11149 * @param {Object} props Element props.
11150 * @param {string} props.name A string identifying the sidebar. Must be unique for every sidebar registered within the scope of your plugin.
11151 * @param {string} [props.className] An optional class name added to the sidebar body.
11152 * @param {string} props.title Title displayed at the top of the sidebar.
11153 * @param {boolean} [props.isPinnable=true] Whether to allow to pin sidebar to the toolbar. When set to `true` it also automatically renders a corresponding menu item.
11154 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered when the sidebar is pinned to toolbar.
11155 *
11156 * @example
11157 * ```js
11158 * // Using ES5 syntax
11159 * var __ = wp.i18n.__;
11160 * var el = React.createElement;
11161 * var PanelBody = wp.components.PanelBody;
11162 * var PluginSidebar = wp.editor.PluginSidebar;
11163 * var moreIcon = React.createElement( 'svg' ); //... svg element.
11164 *
11165 * function MyPluginSidebar() {
11166 * return el(
11167 * PluginSidebar,
11168 * {
11169 * name: 'my-sidebar',
11170 * title: 'My sidebar title',
11171 * icon: moreIcon,
11172 * },
11173 * el(
11174 * PanelBody,
11175 * {},
11176 * __( 'My sidebar content' )
11177 * )
11178 * );
11179 * }
11180 * ```
11181 *
11182 * @example
11183 * ```jsx
11184 * // Using ESNext syntax
11185 * import { __ } from '@wordpress/i18n';
11186 * import { PanelBody } from '@wordpress/components';
11187 * import { PluginSidebar } from '@wordpress/editor';
11188 * import { more } from '@wordpress/icons';
11189 *
11190 * const MyPluginSidebar = () => (
11191 * <PluginSidebar
11192 * name="my-sidebar"
11193 * title="My sidebar title"
11194 * icon={ more }
11195 * >
11196 * <PanelBody>
11197 * { __( 'My sidebar content' ) }
11198 * </PanelBody>
11199 * </PluginSidebar>
11200 * );
11201 * ```
11202 */
11203
11204 function PluginSidebar({
11205 className,
11206 ...props
11207 }) {
11208 const {
11209 postTitle,
11210 shortcut
11211 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11212 return {
11213 postTitle: select(store_store).getEditedPostAttribute('title'),
11214 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/editor/toggle-sidebar')
11215 };
11216 }, []);
11217 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area, {
11218 panelClassName: className,
11219 className: "editor-sidebar",
11220 smallScreenTitle: postTitle || (0,external_wp_i18n_namespaceObject.__)('(no title)'),
11221 scope: "core",
11222 toggleShortcut: shortcut,
11223 ...props
11224 });
11225 }
11226
11227 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-sidebar-more-menu-item/index.js
11228 /**
11229 * WordPress dependencies
11230 */
11231
11232
11233 /**
11234 * Renders a menu item in `Plugins` group in `More Menu` drop down,
11235 * and can be used to activate the corresponding `PluginSidebar` component.
11236 * The text within the component appears as the menu item label.
11237 *
11238 * @param {Object} props Component props.
11239 * @param {string} props.target A string identifying the target sidebar you wish to be activated by this menu item. Must be the same as the `name` prop you have given to that sidebar.
11240 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element, to be rendered to the left of the menu item label.
11241 *
11242 * @example
11243 * ```js
11244 * // Using ES5 syntax
11245 * var __ = wp.i18n.__;
11246 * var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
11247 * var moreIcon = React.createElement( 'svg' ); //... svg element.
11248 *
11249 * function MySidebarMoreMenuItem() {
11250 * return React.createElement(
11251 * PluginSidebarMoreMenuItem,
11252 * {
11253 * target: 'my-sidebar',
11254 * icon: moreIcon,
11255 * },
11256 * __( 'My sidebar title' )
11257 * )
11258 * }
11259 * ```
11260 *
11261 * @example
11262 * ```jsx
11263 * // Using ESNext syntax
11264 * import { __ } from '@wordpress/i18n';
11265 * import { PluginSidebarMoreMenuItem } from '@wordpress/editor';
11266 * import { more } from '@wordpress/icons';
11267 *
11268 * const MySidebarMoreMenuItem = () => (
11269 * <PluginSidebarMoreMenuItem
11270 * target="my-sidebar"
11271 * icon={ more }
11272 * >
11273 * { __( 'My sidebar title' ) }
11274 * </PluginSidebarMoreMenuItem>
11275 * );
11276 * ```
11277 *
11278 * @return {Component} The component to be rendered.
11279 */
11280
11281 function PluginSidebarMoreMenuItem(props) {
11282 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaMoreMenuItem
11283 // Menu item is marked with unstable prop for backward compatibility.
11284 // @see https://github.com/WordPress/gutenberg/issues/14457
11285 , {
11286 __unstableExplicitMenuItem: true,
11287 scope: "core",
11288 ...props
11289 });
11290 }
11291
11292 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/swap-template-button.js
11293 /**
11294 * WordPress dependencies
11295 */
11296
11297
11298
11299
11300
11301
11302
11303
11304
11305
11306 /**
11307 * Internal dependencies
11308 */
11309
11310
11311
11312
11313 function SwapTemplateButton({
11314 onClick
11315 }) {
11316 const [showModal, setShowModal] = (0,external_wp_element_namespaceObject.useState)(false);
11317 const {
11318 postType,
11319 postId
11320 } = useEditedPostContext();
11321 const availableTemplates = useAvailableTemplates(postType);
11322 const {
11323 editEntityRecord
11324 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
11325 if (!availableTemplates?.length) {
11326 return null;
11327 }
11328 const onTemplateSelect = async template => {
11329 editEntityRecord('postType', postType, postId, {
11330 template: template.name
11331 }, {
11332 undoIgnore: true
11333 });
11334 setShowModal(false); // Close the template suggestions modal first.
11335 onClick();
11336 };
11337 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11338 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
11339 onClick: () => setShowModal(true),
11340 children: (0,external_wp_i18n_namespaceObject.__)('Swap template')
11341 }), showModal && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
11342 title: (0,external_wp_i18n_namespaceObject.__)('Choose a template'),
11343 onRequestClose: () => setShowModal(false),
11344 overlayClassName: "editor-post-template__swap-template-modal",
11345 isFullScreen: true,
11346 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
11347 className: "editor-post-template__swap-template-modal-content",
11348 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatesList, {
11349 postType: postType,
11350 onSelect: onTemplateSelect
11351 })
11352 })
11353 })]
11354 });
11355 }
11356 function TemplatesList({
11357 postType,
11358 onSelect
11359 }) {
11360 const availableTemplates = useAvailableTemplates(postType);
11361 const templatesAsPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => availableTemplates.map(template => ({
11362 name: template.slug,
11363 blocks: (0,external_wp_blocks_namespaceObject.parse)(template.content.raw),
11364 title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title.rendered),
11365 id: template.id
11366 })), [availableTemplates]);
11367 const shownTemplates = (0,external_wp_compose_namespaceObject.useAsyncList)(templatesAsPatterns);
11368 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
11369 label: (0,external_wp_i18n_namespaceObject.__)('Templates'),
11370 blockPatterns: templatesAsPatterns,
11371 shownPatterns: shownTemplates,
11372 onClickPattern: onSelect
11373 });
11374 }
11375
11376 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/reset-default-template.js
11377 /**
11378 * WordPress dependencies
11379 */
11380
11381
11382
11383
11384
11385 /**
11386 * Internal dependencies
11387 */
11388
11389
11390 function ResetDefaultTemplate({
11391 onClick
11392 }) {
11393 const currentTemplateSlug = useCurrentTemplateSlug();
11394 const allowSwitchingTemplate = useAllowSwitchingTemplates();
11395 const {
11396 postType,
11397 postId
11398 } = useEditedPostContext();
11399 const {
11400 editEntityRecord
11401 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
11402 // The default template in a post is indicated by an empty string.
11403 if (!currentTemplateSlug || !allowSwitchingTemplate) {
11404 return null;
11405 }
11406 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
11407 onClick: () => {
11408 editEntityRecord('postType', postType, postId, {
11409 template: ''
11410 }, {
11411 undoIgnore: true
11412 });
11413 onClick();
11414 },
11415 children: (0,external_wp_i18n_namespaceObject.__)('Use default template')
11416 });
11417 }
11418
11419 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/create-new-template.js
11420 /**
11421 * WordPress dependencies
11422 */
11423
11424
11425
11426
11427
11428
11429 /**
11430 * Internal dependencies
11431 */
11432
11433
11434
11435
11436
11437 function CreateNewTemplate({
11438 onClick
11439 }) {
11440 const {
11441 canCreateTemplates
11442 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11443 const {
11444 canUser
11445 } = select(external_wp_coreData_namespaceObject.store);
11446 return {
11447 canCreateTemplates: canUser('create', 'templates')
11448 };
11449 }, []);
11450 const [isCreateModalOpen, setIsCreateModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
11451 const allowSwitchingTemplate = useAllowSwitchingTemplates();
11452
11453 // The default template in a post is indicated by an empty string.
11454 if (!canCreateTemplates || !allowSwitchingTemplate) {
11455 return null;
11456 }
11457 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11458 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
11459 onClick: () => {
11460 setIsCreateModalOpen(true);
11461 },
11462 children: (0,external_wp_i18n_namespaceObject.__)('Create new template')
11463 }), isCreateModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateNewTemplateModal, {
11464 onClose: () => {
11465 setIsCreateModalOpen(false);
11466 onClick();
11467 }
11468 })]
11469 });
11470 }
11471
11472 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/block-theme.js
11473 /**
11474 * WordPress dependencies
11475 */
11476
11477
11478
11479
11480
11481
11482
11483
11484 /**
11485 * Internal dependencies
11486 */
11487
11488
11489
11490
11491
11492
11493
11494
11495 const block_theme_POPOVER_PROPS = {
11496 className: 'editor-post-template__dropdown',
11497 placement: 'bottom-start'
11498 };
11499 function BlockThemeControl({
11500 id
11501 }) {
11502 const {
11503 isTemplateHidden,
11504 onNavigateToEntityRecord,
11505 getEditorSettings,
11506 hasGoBack
11507 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11508 const {
11509 getRenderingMode,
11510 getEditorSettings: _getEditorSettings
11511 } = unlock(select(store_store));
11512 const editorSettings = _getEditorSettings();
11513 return {
11514 isTemplateHidden: getRenderingMode() === 'post-only',
11515 onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
11516 getEditorSettings: _getEditorSettings,
11517 hasGoBack: editorSettings.hasOwnProperty('onNavigateToPreviousEntityRecord')
11518 };
11519 }, []);
11520 const {
11521 editedRecord: template,
11522 hasResolved
11523 } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('postType', 'wp_template', id);
11524 const {
11525 createSuccessNotice
11526 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
11527 const {
11528 setRenderingMode
11529 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11530 const canCreateTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => {
11531 var _select$canUser;
11532 return (_select$canUser = select(external_wp_coreData_namespaceObject.store).canUser('create', 'templates')) !== null && _select$canUser !== void 0 ? _select$canUser : false;
11533 });
11534 if (!hasResolved) {
11535 return null;
11536 }
11537
11538 // The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing
11539 // and assigns its own backlink to focusMode pages.
11540 const notificationAction = hasGoBack ? [{
11541 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
11542 onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord()
11543 }] : undefined;
11544 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
11545 popoverProps: block_theme_POPOVER_PROPS,
11546 focusOnMount: true,
11547 toggleProps: {
11548 size: 'compact',
11549 variant: 'tertiary',
11550 tooltipPosition: 'middle left'
11551 },
11552 label: (0,external_wp_i18n_namespaceObject.__)('Template options'),
11553 text: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title),
11554 icon: null,
11555 children: ({
11556 onClose
11557 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11558 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
11559 children: [canCreateTemplate && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
11560 onClick: () => {
11561 onNavigateToEntityRecord({
11562 postId: template.id,
11563 postType: 'wp_template'
11564 });
11565 onClose();
11566 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Editing template. Changes made here affect all posts and pages that use the template.'), {
11567 type: 'snackbar',
11568 actions: notificationAction
11569 });
11570 },
11571 children: (0,external_wp_i18n_namespaceObject.__)('Edit template')
11572 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SwapTemplateButton, {
11573 onClick: onClose
11574 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResetDefaultTemplate, {
11575 onClick: onClose
11576 }), canCreateTemplate && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateNewTemplate, {
11577 onClick: onClose
11578 })]
11579 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
11580 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
11581 icon: !isTemplateHidden ? library_check : undefined,
11582 isSelected: !isTemplateHidden,
11583 role: "menuitemcheckbox",
11584 onClick: () => {
11585 setRenderingMode(isTemplateHidden ? 'template-locked' : 'post-only');
11586 },
11587 children: (0,external_wp_i18n_namespaceObject.__)('Show template')
11588 })
11589 })]
11590 })
11591 });
11592 }
11593
11594 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/panel.js
11595 /**
11596 * WordPress dependencies
11597 */
11598
11599
11600
11601
11602 /**
11603 * Internal dependencies
11604 */
11605
11606
11607
11608
11609
11610 /**
11611 * Displays the template controls based on the current editor settings and user permissions.
11612 *
11613 * @return {JSX.Element|null} The rendered PostTemplatePanel component.
11614 */
11615
11616 function PostTemplatePanel() {
11617 const {
11618 templateId,
11619 isBlockTheme
11620 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11621 const {
11622 getCurrentTemplateId,
11623 getEditorSettings
11624 } = select(store_store);
11625 return {
11626 templateId: getCurrentTemplateId(),
11627 isBlockTheme: getEditorSettings().__unstableIsBlockBasedTheme
11628 };
11629 }, []);
11630 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
11631 var _select$canUser;
11632 const postTypeSlug = select(store_store).getCurrentPostType();
11633 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
11634 if (!postType?.viewable) {
11635 return false;
11636 }
11637 const settings = select(store_store).getEditorSettings();
11638 const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0;
11639 if (hasTemplates) {
11640 return true;
11641 }
11642 if (!settings.supportsTemplateMode) {
11643 return false;
11644 }
11645 const canCreateTemplates = (_select$canUser = select(external_wp_coreData_namespaceObject.store).canUser('create', 'templates')) !== null && _select$canUser !== void 0 ? _select$canUser : false;
11646 return canCreateTemplates;
11647 }, []);
11648 const canViewTemplates = (0,external_wp_data_namespaceObject.useSelect)(select => {
11649 var _select$canUser2;
11650 return (_select$canUser2 = select(external_wp_coreData_namespaceObject.store).canUser('read', 'templates')) !== null && _select$canUser2 !== void 0 ? _select$canUser2 : false;
11651 }, []);
11652 if ((!isBlockTheme || !canViewTemplates) && isVisible) {
11653 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
11654 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
11655 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(classic_theme, {})
11656 });
11657 }
11658 if (isBlockTheme && !!templateId) {
11659 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
11660 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
11661 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockThemeControl, {
11662 id: templateId
11663 })
11664 });
11665 }
11666 return null;
11667 }
11668
11669 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/constants.js
11670 const BASE_QUERY = {
11671 _fields: 'id,name',
11672 context: 'view' // Allows non-admins to perform requests.
11673 };
11674 const AUTHORS_QUERY = {
11675 who: 'authors',
11676 per_page: 50,
11677 ...BASE_QUERY
11678 };
11679
11680 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/hook.js
11681 /**
11682 * WordPress dependencies
11683 */
11684
11685
11686
11687
11688
11689 /**
11690 * Internal dependencies
11691 */
11692
11693
11694 function useAuthorsQuery(search) {
11695 const {
11696 authorId,
11697 authors,
11698 postAuthor
11699 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11700 const {
11701 getUser,
11702 getUsers
11703 } = select(external_wp_coreData_namespaceObject.store);
11704 const {
11705 getEditedPostAttribute
11706 } = select(store_store);
11707 const _authorId = getEditedPostAttribute('author');
11708 const query = {
11709 ...AUTHORS_QUERY
11710 };
11711 if (search) {
11712 query.search = search;
11713 }
11714 return {
11715 authorId: _authorId,
11716 authors: getUsers(query),
11717 postAuthor: getUser(_authorId, BASE_QUERY)
11718 };
11719 }, [search]);
11720 const authorOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
11721 const fetchedAuthors = (authors !== null && authors !== void 0 ? authors : []).map(author => {
11722 return {
11723 value: author.id,
11724 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(author.name)
11725 };
11726 });
11727
11728 // Ensure the current author is included in the dropdown list.
11729 const foundAuthor = fetchedAuthors.findIndex(({
11730 value
11731 }) => postAuthor?.id === value);
11732 if (foundAuthor < 0 && postAuthor) {
11733 return [{
11734 value: postAuthor.id,
11735 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postAuthor.name)
11736 }, ...fetchedAuthors];
11737 }
11738 return fetchedAuthors;
11739 }, [authors, postAuthor]);
11740 return {
11741 authorId,
11742 authorOptions,
11743 postAuthor
11744 };
11745 }
11746
11747 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/combobox.js
11748 /**
11749 * WordPress dependencies
11750 */
11751
11752
11753
11754
11755
11756
11757 /**
11758 * Internal dependencies
11759 */
11760
11761
11762
11763 function PostAuthorCombobox() {
11764 const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)();
11765 const {
11766 editPost
11767 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11768 const {
11769 authorId,
11770 authorOptions
11771 } = useAuthorsQuery(fieldValue);
11772
11773 /**
11774 * Handle author selection.
11775 *
11776 * @param {number} postAuthorId The selected Author.
11777 */
11778 const handleSelect = postAuthorId => {
11779 if (!postAuthorId) {
11780 return;
11781 }
11782 editPost({
11783 author: postAuthorId
11784 });
11785 };
11786
11787 /**
11788 * Handle user input.
11789 *
11790 * @param {string} inputValue The current value of the input field.
11791 */
11792 const handleKeydown = inputValue => {
11793 setFieldValue(inputValue);
11794 };
11795 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ComboboxControl, {
11796 __nextHasNoMarginBottom: true,
11797 __next40pxDefaultSize: true,
11798 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
11799 options: authorOptions,
11800 value: authorId,
11801 onFilterValueChange: (0,external_wp_compose_namespaceObject.debounce)(handleKeydown, 300),
11802 onChange: handleSelect,
11803 allowReset: false,
11804 hideLabelFromVision: true
11805 });
11806 }
11807
11808 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/select.js
11809 /**
11810 * WordPress dependencies
11811 */
11812
11813
11814
11815
11816 /**
11817 * Internal dependencies
11818 */
11819
11820
11821
11822 function PostAuthorSelect() {
11823 const {
11824 editPost
11825 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11826 const {
11827 authorId,
11828 authorOptions
11829 } = useAuthorsQuery();
11830 const setAuthorId = value => {
11831 const author = Number(value);
11832 editPost({
11833 author
11834 });
11835 };
11836 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SelectControl, {
11837 __next40pxDefaultSize: true,
11838 __nextHasNoMarginBottom: true,
11839 className: "post-author-selector",
11840 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
11841 options: authorOptions,
11842 onChange: setAuthorId,
11843 value: authorId,
11844 hideLabelFromVision: true
11845 });
11846 }
11847
11848 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/index.js
11849 /**
11850 * WordPress dependencies
11851 */
11852
11853
11854
11855 /**
11856 * Internal dependencies
11857 */
11858
11859
11860
11861
11862 const minimumUsersForCombobox = 25;
11863
11864 /**
11865 * Renders the component for selecting the post author.
11866 *
11867 * @return {Component} The component to be rendered.
11868 */
11869 function PostAuthor() {
11870 const showCombobox = (0,external_wp_data_namespaceObject.useSelect)(select => {
11871 const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY);
11872 return authors?.length >= minimumUsersForCombobox;
11873 }, []);
11874 if (showCombobox) {
11875 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorCombobox, {});
11876 }
11877 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorSelect, {});
11878 }
11879 /* harmony default export */ const post_author = (PostAuthor);
11880
11881 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/check.js
11882 /**
11883 * WordPress dependencies
11884 */
11885
11886
11887
11888 /**
11889 * Internal dependencies
11890 */
11891
11892
11893
11894
11895 /**
11896 * Wrapper component that renders its children only if the post type supports the author.
11897 *
11898 * @param {Object} props The component props.
11899 * @param {Element} props.children Children to be rendered.
11900 *
11901 * @return {Component|null} The component to be rendered. Return `null` if the post type doesn't
11902 * supports the author or if there are no authors available.
11903 */
11904
11905 function PostAuthorCheck({
11906 children
11907 }) {
11908 const {
11909 hasAssignAuthorAction,
11910 hasAuthors
11911 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11912 var _post$_links$wpActio;
11913 const post = select(store_store).getCurrentPost();
11914 const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY);
11915 return {
11916 hasAssignAuthorAction: (_post$_links$wpActio = post._links?.['wp:action-assign-author']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false,
11917 hasAuthors: authors?.length >= 1
11918 };
11919 }, []);
11920 if (!hasAssignAuthorAction || !hasAuthors) {
11921 return null;
11922 }
11923 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
11924 supportKeys: "author",
11925 children: children
11926 });
11927 }
11928
11929 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/panel.js
11930 /**
11931 * WordPress dependencies
11932 */
11933
11934
11935
11936
11937
11938 /**
11939 * Internal dependencies
11940 */
11941
11942
11943
11944
11945
11946
11947 function PostAuthorToggle({
11948 isOpen,
11949 onClick
11950 }) {
11951 const {
11952 postAuthor
11953 } = useAuthorsQuery();
11954 const authorName = postAuthor?.name || '';
11955 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
11956 size: "compact",
11957 className: "editor-post-author__panel-toggle",
11958 variant: "tertiary",
11959 "aria-expanded": isOpen
11960 // translators: %s: Current post link.
11961 ,
11962 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change author: %s'), authorName),
11963 onClick: onClick,
11964 children: authorName
11965 });
11966 }
11967
11968 /**
11969 * Renders the Post Author Panel component.
11970 *
11971 * @return {Component} The component to be rendered.
11972 */
11973 function panel_PostAuthor() {
11974 // Use internal state instead of a ref to make sure that the component
11975 // re-renders when the popover's anchor updates.
11976 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
11977 // Memoize popoverProps to avoid returning a new object every time.
11978 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
11979 // Anchor the popover to the middle of the entire row so that it doesn't
11980 // move around when the label changes.
11981 anchor: popoverAnchor,
11982 placement: 'left-start',
11983 offset: 36,
11984 shift: true
11985 }), [popoverAnchor]);
11986 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorCheck, {
11987 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
11988 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
11989 ref: setPopoverAnchor,
11990 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
11991 popoverProps: popoverProps,
11992 contentClassName: "editor-post-author__panel-dialog",
11993 focusOnMount: true,
11994 renderToggle: ({
11995 isOpen,
11996 onToggle
11997 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorToggle, {
11998 isOpen: isOpen,
11999 onClick: onToggle
12000 }),
12001 renderContent: ({
12002 onClose
12003 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12004 className: "editor-post-author",
12005 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
12006 title: (0,external_wp_i18n_namespaceObject.__)('Author'),
12007 onClose: onClose
12008 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_author, {
12009 onClose: onClose
12010 })]
12011 })
12012 })
12013 })
12014 });
12015 }
12016 /* harmony default export */ const panel = (panel_PostAuthor);
12017
12018 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-comments/index.js
12019 /**
12020 * WordPress dependencies
12021 */
12022
12023
12024
12025
12026 /**
12027 * Internal dependencies
12028 */
12029
12030
12031
12032
12033 const COMMENT_OPTIONS = [{
12034 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
12035 children: [(0,external_wp_i18n_namespaceObject.__)('Open'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
12036 variant: "muted",
12037 size: 12,
12038 children: (0,external_wp_i18n_namespaceObject.__)('Visitors can add new comments and replies.')
12039 })]
12040 }),
12041 value: 'open'
12042 }, {
12043 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
12044 children: [(0,external_wp_i18n_namespaceObject.__)('Closed'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
12045 variant: "muted",
12046 size: 12,
12047 children: (0,external_wp_i18n_namespaceObject.__)('Visitors cannot add new comments or replies.')
12048 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
12049 variant: "muted",
12050 size: 12,
12051 children: (0,external_wp_i18n_namespaceObject.__)('Existing comments remain visible.')
12052 })]
12053 }),
12054 value: 'closed'
12055 }];
12056 function PostComments() {
12057 const commentStatus = (0,external_wp_data_namespaceObject.useSelect)(select => {
12058 var _select$getEditedPost;
12059 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('comment_status')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 'open';
12060 }, []);
12061 const {
12062 editPost
12063 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12064 const handleStatus = newCommentStatus => editPost({
12065 comment_status: newCommentStatus
12066 });
12067 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
12068 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
12069 spacing: 4,
12070 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
12071 className: "editor-change-status__options",
12072 hideLabelFromVision: true,
12073 label: (0,external_wp_i18n_namespaceObject.__)('Comment status'),
12074 options: COMMENT_OPTIONS,
12075 onChange: handleStatus,
12076 selected: commentStatus
12077 })
12078 })
12079 });
12080 }
12081
12082 /**
12083 * A form for managing comment status.
12084 *
12085 * @return {JSX.Element} The rendered PostComments component.
12086 */
12087 /* harmony default export */ const post_comments = (PostComments);
12088
12089 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-pingbacks/index.js
12090 /**
12091 * WordPress dependencies
12092 */
12093
12094
12095
12096
12097 /**
12098 * Internal dependencies
12099 */
12100
12101
12102 function PostPingbacks() {
12103 const pingStatus = (0,external_wp_data_namespaceObject.useSelect)(select => {
12104 var _select$getEditedPost;
12105 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('ping_status')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 'open';
12106 }, []);
12107 const {
12108 editPost
12109 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12110 const onTogglePingback = () => editPost({
12111 ping_status: pingStatus === 'open' ? 'closed' : 'open'
12112 });
12113 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
12114 __nextHasNoMarginBottom: true,
12115 label: (0,external_wp_i18n_namespaceObject.__)('Enable pingbacks & trackbacks'),
12116 checked: pingStatus === 'open',
12117 onChange: onTogglePingback,
12118 help: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
12119 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/trackbacks-and-pingbacks/'),
12120 children: (0,external_wp_i18n_namespaceObject.__)('Learn more about pingbacks & trackbacks')
12121 })
12122 });
12123 }
12124
12125 /**
12126 * Renders a control for enabling or disabling pingbacks and trackbacks
12127 * in a WordPress post.
12128 *
12129 * @module PostPingbacks
12130 */
12131 /* harmony default export */ const post_pingbacks = (PostPingbacks);
12132
12133 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-discussion/panel.js
12134 /**
12135 * WordPress dependencies
12136 */
12137
12138
12139
12140
12141
12142
12143
12144 /**
12145 * Internal dependencies
12146 */
12147
12148
12149
12150
12151
12152
12153
12154 const panel_PANEL_NAME = 'discussion-panel';
12155 function ModalContents({
12156 onClose
12157 }) {
12158 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12159 className: "editor-post-discussion",
12160 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
12161 title: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
12162 onClose: onClose
12163 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
12164 spacing: 4,
12165 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12166 supportKeys: "comments",
12167 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_comments, {})
12168 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12169 supportKeys: "trackbacks",
12170 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_pingbacks, {})
12171 })]
12172 })]
12173 });
12174 }
12175 function PostDiscussionToggle({
12176 isOpen,
12177 onClick
12178 }) {
12179 const {
12180 commentStatus,
12181 pingStatus,
12182 commentsSupported,
12183 trackbacksSupported
12184 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12185 var _getEditedPostAttribu, _getEditedPostAttribu2;
12186 const {
12187 getEditedPostAttribute
12188 } = select(store_store);
12189 const {
12190 getPostType
12191 } = select(external_wp_coreData_namespaceObject.store);
12192 const postType = getPostType(getEditedPostAttribute('type'));
12193 return {
12194 commentStatus: (_getEditedPostAttribu = getEditedPostAttribute('comment_status')) !== null && _getEditedPostAttribu !== void 0 ? _getEditedPostAttribu : 'open',
12195 pingStatus: (_getEditedPostAttribu2 = getEditedPostAttribute('ping_status')) !== null && _getEditedPostAttribu2 !== void 0 ? _getEditedPostAttribu2 : 'open',
12196 commentsSupported: !!postType.supports.comments,
12197 trackbacksSupported: !!postType.supports.trackbacks
12198 };
12199 }, []);
12200 let label;
12201 if (commentStatus === 'open') {
12202 if (pingStatus === 'open') {
12203 label = (0,external_wp_i18n_namespaceObject.__)('Open');
12204 } else {
12205 label = trackbacksSupported ? (0,external_wp_i18n_namespaceObject.__)('Comments only') : (0,external_wp_i18n_namespaceObject.__)('Open');
12206 }
12207 } else if (pingStatus === 'open') {
12208 label = commentsSupported ? (0,external_wp_i18n_namespaceObject.__)('Pings only') : (0,external_wp_i18n_namespaceObject.__)('Pings enabled');
12209 } else {
12210 label = (0,external_wp_i18n_namespaceObject.__)('Closed');
12211 }
12212 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12213 size: "compact",
12214 className: "editor-post-discussion__panel-toggle",
12215 variant: "tertiary",
12216 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Change discussion options'),
12217 "aria-expanded": isOpen,
12218 onClick: onClick,
12219 children: label
12220 });
12221 }
12222
12223 /**
12224 * This component allows to update comment and pingback
12225 * settings for the current post. Internally there are
12226 * checks whether the current post has support for the
12227 * above and if the `discussion-panel` panel is enabled.
12228 *
12229 * @return {JSX.Element|null} The rendered PostDiscussionPanel component.
12230 */
12231 function PostDiscussionPanel() {
12232 const {
12233 isEnabled
12234 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12235 const {
12236 isEditorPanelEnabled
12237 } = select(store_store);
12238 return {
12239 isEnabled: isEditorPanelEnabled(panel_PANEL_NAME)
12240 };
12241 }, []);
12242
12243 // Use internal state instead of a ref to make sure that the component
12244 // re-renders when the popover's anchor updates.
12245 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
12246 // Memoize popoverProps to avoid returning a new object every time.
12247 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
12248 // Anchor the popover to the middle of the entire row so that it doesn't
12249 // move around when the label changes.
12250 anchor: popoverAnchor,
12251 placement: 'left-start',
12252 offset: 36,
12253 shift: true
12254 }), [popoverAnchor]);
12255 if (!isEnabled) {
12256 return null;
12257 }
12258 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12259 supportKeys: ['comments', 'trackbacks'],
12260 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
12261 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
12262 ref: setPopoverAnchor,
12263 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
12264 popoverProps: popoverProps,
12265 className: "editor-post-discussion__panel-dropdown",
12266 contentClassName: "editor-post-discussion__panel-dialog",
12267 focusOnMount: true,
12268 renderToggle: ({
12269 isOpen,
12270 onToggle
12271 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostDiscussionToggle, {
12272 isOpen: isOpen,
12273 onClick: onToggle
12274 }),
12275 renderContent: ({
12276 onClose
12277 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ModalContents, {
12278 onClose: onClose
12279 })
12280 })
12281 })
12282 });
12283 }
12284
12285 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-excerpt/index.js
12286 /**
12287 * WordPress dependencies
12288 */
12289
12290
12291
12292
12293
12294 /**
12295 * Internal dependencies
12296 */
12297
12298
12299 /**
12300 * Renders an editable textarea for the post excerpt.
12301 * Templates, template parts and patterns use the `excerpt` field as a description semantically.
12302 * Additionally templates and template parts override the `excerpt` field as `description` in
12303 * REST API. So this component handles proper labeling and updating the edited entity.
12304 *
12305 * @param {Object} props - Component props.
12306 * @param {boolean} [props.hideLabelFromVision=false] - Whether to visually hide the textarea's label.
12307 * @param {boolean} [props.updateOnBlur=false] - Whether to update the post on change or use local state and update on blur.
12308 */
12309
12310 function PostExcerpt({
12311 hideLabelFromVision = false,
12312 updateOnBlur = false
12313 }) {
12314 const {
12315 excerpt,
12316 shouldUseDescriptionLabel,
12317 usedAttribute
12318 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12319 const {
12320 getCurrentPostType,
12321 getEditedPostAttribute
12322 } = select(store_store);
12323 const postType = getCurrentPostType();
12324 // This special case is unfortunate, but the REST API of wp_template and wp_template_part
12325 // support the excerpt field throught the "description" field rather than "excerpt".
12326 const _usedAttribute = ['wp_template', 'wp_template_part'].includes(postType) ? 'description' : 'excerpt';
12327 return {
12328 excerpt: getEditedPostAttribute(_usedAttribute),
12329 // There are special cases where we want to label the excerpt as a description.
12330 shouldUseDescriptionLabel: ['wp_template', 'wp_template_part', 'wp_block'].includes(postType),
12331 usedAttribute: _usedAttribute
12332 };
12333 }, []);
12334 const {
12335 editPost
12336 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12337 const [localExcerpt, setLocalExcerpt] = (0,external_wp_element_namespaceObject.useState)(excerpt);
12338 const updatePost = value => {
12339 editPost({
12340 [usedAttribute]: value
12341 });
12342 };
12343 const label = shouldUseDescriptionLabel ? (0,external_wp_i18n_namespaceObject.__)('Write a description (optional)') : (0,external_wp_i18n_namespaceObject.__)('Write an excerpt (optional)');
12344 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
12345 className: "editor-post-excerpt",
12346 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextareaControl, {
12347 __nextHasNoMarginBottom: true,
12348 label: label,
12349 hideLabelFromVision: hideLabelFromVision,
12350 className: "editor-post-excerpt__textarea",
12351 onChange: updateOnBlur ? setLocalExcerpt : updatePost,
12352 onBlur: updateOnBlur ? () => updatePost(localExcerpt) : undefined,
12353 value: updateOnBlur ? localExcerpt : excerpt,
12354 help: !shouldUseDescriptionLabel ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
12355 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt'),
12356 children: (0,external_wp_i18n_namespaceObject.__)('Learn more about manual excerpts')
12357 }) : (0,external_wp_i18n_namespaceObject.__)('Write a description')
12358 })
12359 });
12360 }
12361
12362 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-excerpt/check.js
12363 /**
12364 * Internal dependencies
12365 */
12366
12367
12368 /**
12369 * Component for checking if the post type supports the excerpt field.
12370 *
12371 * @param {Object} props Props.
12372 * @param {Element} props.children Children to be rendered.
12373 *
12374 * @return {Component} The component to be rendered.
12375 */
12376
12377 function PostExcerptCheck({
12378 children
12379 }) {
12380 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12381 supportKeys: "excerpt",
12382 children: children
12383 });
12384 }
12385 /* harmony default export */ const post_excerpt_check = (PostExcerptCheck);
12386
12387 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-excerpt/plugin.js
12388 /**
12389 * Defines as extensibility slot for the Excerpt panel.
12390 */
12391
12392 /**
12393 * WordPress dependencies
12394 */
12395
12396
12397 const {
12398 Fill: plugin_Fill,
12399 Slot: plugin_Slot
12400 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostExcerpt');
12401
12402 /**
12403 * Renders a post excerpt panel in the post sidebar.
12404 *
12405 * @param {Object} props Component properties.
12406 * @param {string} [props.className] An optional class name added to the row.
12407 * @param {Element} props.children Children to be rendered.
12408 *
12409 * @example
12410 * ```js
12411 * // Using ES5 syntax
12412 * var __ = wp.i18n.__;
12413 * var PluginPostExcerpt = wp.editPost.__experimentalPluginPostExcerpt;
12414 *
12415 * function MyPluginPostExcerpt() {
12416 * return React.createElement(
12417 * PluginPostExcerpt,
12418 * {
12419 * className: 'my-plugin-post-excerpt',
12420 * },
12421 * __( 'Post excerpt custom content' )
12422 * )
12423 * }
12424 * ```
12425 *
12426 * @example
12427 * ```jsx
12428 * // Using ESNext syntax
12429 * import { __ } from '@wordpress/i18n';
12430 * import { __experimentalPluginPostExcerpt as PluginPostExcerpt } from '@wordpress/edit-post';
12431 *
12432 * const MyPluginPostExcerpt = () => (
12433 * <PluginPostExcerpt className="my-plugin-post-excerpt">
12434 * { __( 'Post excerpt custom content' ) }
12435 * </PluginPostExcerpt>
12436 * );
12437 * ```
12438 *
12439 * @return {Component} The component to be rendered.
12440 */
12441 const PluginPostExcerpt = ({
12442 children,
12443 className
12444 }) => {
12445 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_Fill, {
12446 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
12447 className: className,
12448 children: children
12449 })
12450 });
12451 };
12452 PluginPostExcerpt.Slot = plugin_Slot;
12453 /* harmony default export */ const post_excerpt_plugin = (PluginPostExcerpt);
12454
12455 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-excerpt/panel.js
12456 /**
12457 * WordPress dependencies
12458 */
12459
12460
12461
12462
12463
12464
12465
12466 /**
12467 * Internal dependencies
12468 */
12469
12470
12471
12472
12473
12474
12475 /**
12476 * Module Constants
12477 */
12478
12479
12480
12481 const post_excerpt_panel_PANEL_NAME = 'post-excerpt';
12482 function ExcerptPanel() {
12483 const {
12484 isOpened,
12485 isEnabled,
12486 postType
12487 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12488 const {
12489 isEditorPanelOpened,
12490 isEditorPanelEnabled,
12491 getCurrentPostType
12492 } = select(store_store);
12493 return {
12494 isOpened: isEditorPanelOpened(post_excerpt_panel_PANEL_NAME),
12495 isEnabled: isEditorPanelEnabled(post_excerpt_panel_PANEL_NAME),
12496 postType: getCurrentPostType()
12497 };
12498 }, []);
12499 const {
12500 toggleEditorPanelOpened
12501 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12502 const toggleExcerptPanel = () => toggleEditorPanelOpened(post_excerpt_panel_PANEL_NAME);
12503 if (!isEnabled) {
12504 return null;
12505 }
12506
12507 // There are special cases where we want to label the excerpt as a description.
12508 const shouldUseDescriptionLabel = ['wp_template', 'wp_template_part', 'wp_block'].includes(postType);
12509 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
12510 title: shouldUseDescriptionLabel ? (0,external_wp_i18n_namespaceObject.__)('Description') : (0,external_wp_i18n_namespaceObject.__)('Excerpt'),
12511 opened: isOpened,
12512 onToggle: toggleExcerptPanel,
12513 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_plugin.Slot, {
12514 children: fills => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
12515 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostExcerpt, {}), fills]
12516 })
12517 })
12518 });
12519 }
12520
12521 /**
12522 * Is rendered if the post type supports excerpts and allows editing the excerpt.
12523 *
12524 * @return {JSX.Element} The rendered PostExcerptPanel component.
12525 */
12526 function PostExcerptPanel() {
12527 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_check, {
12528 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExcerptPanel, {})
12529 });
12530 }
12531 function PrivatePostExcerptPanel() {
12532 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_check, {
12533 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivateExcerpt, {})
12534 });
12535 }
12536 function PrivateExcerpt() {
12537 const {
12538 shouldRender,
12539 excerpt,
12540 shouldBeUsedAsDescription,
12541 allowEditing
12542 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12543 const {
12544 getCurrentPostType,
12545 getCurrentPostId,
12546 getEditedPostAttribute,
12547 isEditorPanelEnabled
12548 } = select(store_store);
12549 const postType = getCurrentPostType();
12550 const isTemplateOrTemplatePart = ['wp_template', 'wp_template_part'].includes(postType);
12551 const isPattern = postType === 'wp_block';
12552 // These post types use the `excerpt` field as a description semantically, so we need to
12553 // handle proper labeling and some flows where we should always render them as text.
12554 const _shouldBeUsedAsDescription = isTemplateOrTemplatePart || isPattern;
12555 const _usedAttribute = isTemplateOrTemplatePart ? 'description' : 'excerpt';
12556 // We need to fetch the entity in this case to check if we'll allow editing.
12557 const template = isTemplateOrTemplatePart && select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', postType, getCurrentPostId());
12558 // For post types that use excerpt as description, we do not abide
12559 // by the `isEnabled` panel flag in order to render them as text.
12560 const _shouldRender = isEditorPanelEnabled(post_excerpt_panel_PANEL_NAME) || _shouldBeUsedAsDescription;
12561 return {
12562 excerpt: getEditedPostAttribute(_usedAttribute),
12563 shouldRender: _shouldRender,
12564 shouldBeUsedAsDescription: _shouldBeUsedAsDescription,
12565 // If we should render, allow editing for all post types that are not used as description.
12566 // For the rest allow editing only for user generated entities.
12567 allowEditing: _shouldRender && (!_shouldBeUsedAsDescription || isPattern || template && template.source === TEMPLATE_ORIGINS.custom && !template.has_theme_file)
12568 };
12569 }, []);
12570 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
12571 const label = shouldBeUsedAsDescription ? (0,external_wp_i18n_namespaceObject.__)('Description') : (0,external_wp_i18n_namespaceObject.__)('Excerpt');
12572 // Memoize popoverProps to avoid returning a new object every time.
12573 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
12574 // Anchor the popover to the middle of the entire row so that it doesn't
12575 // move around when the label changes.
12576 anchor: popoverAnchor,
12577 'aria-label': label,
12578 headerTitle: label,
12579 placement: 'left-start',
12580 offset: 36,
12581 shift: true
12582 }), [popoverAnchor, label]);
12583 if (!shouldRender) {
12584 return false;
12585 }
12586 const excerptText = !!excerpt && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
12587 align: "left",
12588 numberOfLines: 4,
12589 truncate: true,
12590 children: excerpt
12591 });
12592 if (!allowEditing) {
12593 return excerptText;
12594 }
12595 const excerptPlaceholder = shouldBeUsedAsDescription ? (0,external_wp_i18n_namespaceObject.__)('Add a description…') : (0,external_wp_i18n_namespaceObject.__)('Add an excerpt…');
12596 const triggerEditLabel = shouldBeUsedAsDescription ? (0,external_wp_i18n_namespaceObject.__)('Edit description') : (0,external_wp_i18n_namespaceObject.__)('Edit excerpt');
12597 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
12598 children: [excerptText, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
12599 className: "editor-post-excerpt__dropdown",
12600 contentClassName: "editor-post-excerpt__dropdown__content",
12601 popoverProps: popoverProps,
12602 focusOnMount: true,
12603 ref: setPopoverAnchor,
12604 renderToggle: ({
12605 onToggle
12606 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12607 className: "editor-post-excerpt__dropdown__trigger",
12608 onClick: onToggle,
12609 variant: "link",
12610 children: excerptText ? triggerEditLabel : excerptPlaceholder
12611 }),
12612 renderContent: ({
12613 onClose
12614 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
12615 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
12616 title: label,
12617 onClose: onClose
12618 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
12619 spacing: 4,
12620 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_plugin.Slot, {
12621 children: fills => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
12622 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostExcerpt, {
12623 hideLabelFromVision: true,
12624 updateOnBlur: true
12625 }), fills]
12626 })
12627 })
12628 })]
12629 })
12630 })]
12631 });
12632 }
12633
12634 ;// CONCATENATED MODULE: external ["wp","blob"]
12635 const external_wp_blob_namespaceObject = window["wp"]["blob"];
12636 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/theme-support-check/index.js
12637 /**
12638 * WordPress dependencies
12639 */
12640
12641
12642
12643 /**
12644 * Internal dependencies
12645 */
12646
12647 function ThemeSupportCheck({
12648 children,
12649 supportKeys
12650 }) {
12651 const {
12652 postType,
12653 themeSupports
12654 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12655 return {
12656 postType: select(store_store).getEditedPostAttribute('type'),
12657 themeSupports: select(external_wp_coreData_namespaceObject.store).getThemeSupports()
12658 };
12659 }, []);
12660 const isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some(key => {
12661 var _themeSupports$key;
12662 const supported = (_themeSupports$key = themeSupports?.[key]) !== null && _themeSupports$key !== void 0 ? _themeSupports$key : false;
12663 // 'post-thumbnails' can be boolean or an array of post types.
12664 // In the latter case, we need to verify `postType` exists
12665 // within `supported`. If `postType` isn't passed, then the check
12666 // should fail.
12667 if ('post-thumbnails' === key && Array.isArray(supported)) {
12668 return supported.includes(postType);
12669 }
12670 return supported;
12671 });
12672 if (!isSupported) {
12673 return null;
12674 }
12675 return children;
12676 }
12677
12678 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-featured-image/check.js
12679 /**
12680 * Internal dependencies
12681 */
12682
12683
12684
12685 /**
12686 * Wrapper component that renders its children only if the post type supports a featured image
12687 * and the theme supports post thumbnails.
12688 *
12689 * @param {Object} props Props.
12690 * @param {Element} props.children Children to be rendered.
12691 *
12692 * @return {Component} The component to be rendered.
12693 */
12694
12695 function PostFeaturedImageCheck({
12696 children
12697 }) {
12698 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ThemeSupportCheck, {
12699 supportKeys: "post-thumbnails",
12700 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12701 supportKeys: "thumbnail",
12702 children: children
12703 })
12704 });
12705 }
12706 /* harmony default export */ const post_featured_image_check = (PostFeaturedImageCheck);
12707
12708 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-featured-image/index.js
12709 /**
12710 * WordPress dependencies
12711 */
12712
12713
12714
12715
12716
12717
12718
12719
12720
12721
12722 /**
12723 * Internal dependencies
12724 */
12725
12726
12727
12728
12729 const ALLOWED_MEDIA_TYPES = ['image'];
12730
12731 // Used when labels from post type were not yet loaded or when they are not present.
12732 const DEFAULT_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Featured image');
12733 const DEFAULT_SET_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Add a featured image');
12734 const instructions = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
12735 children: (0,external_wp_i18n_namespaceObject.__)('To edit the featured image, you need permission to upload media.')
12736 });
12737 function getMediaDetails(media, postId) {
12738 var _media$media_details$, _media$media_details$2;
12739 if (!media) {
12740 return {};
12741 }
12742 const defaultSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'large', media.id, postId);
12743 if (defaultSize in ((_media$media_details$ = media?.media_details?.sizes) !== null && _media$media_details$ !== void 0 ? _media$media_details$ : {})) {
12744 return {
12745 mediaWidth: media.media_details.sizes[defaultSize].width,
12746 mediaHeight: media.media_details.sizes[defaultSize].height,
12747 mediaSourceUrl: media.media_details.sizes[defaultSize].source_url
12748 };
12749 }
12750
12751 // Use fallbackSize when defaultSize is not available.
12752 const fallbackSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'thumbnail', media.id, postId);
12753 if (fallbackSize in ((_media$media_details$2 = media?.media_details?.sizes) !== null && _media$media_details$2 !== void 0 ? _media$media_details$2 : {})) {
12754 return {
12755 mediaWidth: media.media_details.sizes[fallbackSize].width,
12756 mediaHeight: media.media_details.sizes[fallbackSize].height,
12757 mediaSourceUrl: media.media_details.sizes[fallbackSize].source_url
12758 };
12759 }
12760
12761 // Use full image size when fallbackSize and defaultSize are not available.
12762 return {
12763 mediaWidth: media.media_details.width,
12764 mediaHeight: media.media_details.height,
12765 mediaSourceUrl: media.source_url
12766 };
12767 }
12768 function PostFeaturedImage({
12769 currentPostId,
12770 featuredImageId,
12771 onUpdateImage,
12772 onRemoveImage,
12773 media,
12774 postType,
12775 noticeUI,
12776 noticeOperations
12777 }) {
12778 const toggleRef = (0,external_wp_element_namespaceObject.useRef)();
12779 const [isLoading, setIsLoading] = (0,external_wp_element_namespaceObject.useState)(false);
12780 const {
12781 getSettings
12782 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
12783 const {
12784 mediaSourceUrl
12785 } = getMediaDetails(media, currentPostId);
12786 function onDropFiles(filesList) {
12787 getSettings().mediaUpload({
12788 allowedTypes: ALLOWED_MEDIA_TYPES,
12789 filesList,
12790 onFileChange([image]) {
12791 if ((0,external_wp_blob_namespaceObject.isBlobURL)(image?.url)) {
12792 setIsLoading(true);
12793 return;
12794 }
12795 if (image) {
12796 onUpdateImage(image);
12797 }
12798 setIsLoading(false);
12799 },
12800 onError(message) {
12801 noticeOperations.removeAllNotices();
12802 noticeOperations.createErrorNotice(message);
12803 }
12804 });
12805 }
12806 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(post_featured_image_check, {
12807 children: [noticeUI, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12808 className: "editor-post-featured-image",
12809 children: [media && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12810 id: `editor-post-featured-image-${featuredImageId}-describedby`,
12811 className: "hidden",
12812 children: [media.alt_text && (0,external_wp_i18n_namespaceObject.sprintf)(
12813 // Translators: %s: The selected image alt text.
12814 (0,external_wp_i18n_namespaceObject.__)('Current image: %s'), media.alt_text), !media.alt_text && (0,external_wp_i18n_namespaceObject.sprintf)(
12815 // Translators: %s: The selected image filename.
12816 (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)]
12817 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.MediaUploadCheck, {
12818 fallback: instructions,
12819 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.MediaUpload, {
12820 title: postType?.labels?.featured_image || DEFAULT_FEATURE_IMAGE_LABEL,
12821 onSelect: onUpdateImage,
12822 unstableFeaturedImageFlow: true,
12823 allowedTypes: ALLOWED_MEDIA_TYPES,
12824 modalClass: "editor-post-featured-image__media-modal",
12825 render: ({
12826 open
12827 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12828 className: "editor-post-featured-image__container",
12829 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
12830 ref: toggleRef,
12831 className: !featuredImageId ? 'editor-post-featured-image__toggle' : 'editor-post-featured-image__preview',
12832 onClick: open,
12833 "aria-label": !featuredImageId ? null : (0,external_wp_i18n_namespaceObject.__)('Edit or replace the image'),
12834 "aria-describedby": !featuredImageId ? null : `editor-post-featured-image-${featuredImageId}-describedby`,
12835 children: [!!featuredImageId && media && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
12836 className: "editor-post-featured-image__preview-image",
12837 src: mediaSourceUrl,
12838 alt: ""
12839 }), isLoading && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}), !featuredImageId && !isLoading && (postType?.labels?.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL)]
12840 }), !!featuredImageId && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
12841 className: "editor-post-featured-image__actions",
12842 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12843 className: "editor-post-featured-image__action",
12844 onClick: open,
12845 children: (0,external_wp_i18n_namespaceObject.__)('Replace')
12846 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12847 className: "editor-post-featured-image__action",
12848 onClick: () => {
12849 onRemoveImage();
12850 toggleRef.current.focus();
12851 },
12852 children: (0,external_wp_i18n_namespaceObject.__)('Remove')
12853 })]
12854 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropZone, {
12855 onFilesDrop: onDropFiles
12856 })]
12857 }),
12858 value: featuredImageId
12859 })
12860 })]
12861 })]
12862 });
12863 }
12864 const applyWithSelect = (0,external_wp_data_namespaceObject.withSelect)(select => {
12865 const {
12866 getMedia,
12867 getPostType
12868 } = select(external_wp_coreData_namespaceObject.store);
12869 const {
12870 getCurrentPostId,
12871 getEditedPostAttribute
12872 } = select(store_store);
12873 const featuredImageId = getEditedPostAttribute('featured_media');
12874 return {
12875 media: featuredImageId ? getMedia(featuredImageId, {
12876 context: 'view'
12877 }) : null,
12878 currentPostId: getCurrentPostId(),
12879 postType: getPostType(getEditedPostAttribute('type')),
12880 featuredImageId
12881 };
12882 });
12883 const applyWithDispatch = (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
12884 noticeOperations
12885 }, {
12886 select
12887 }) => {
12888 const {
12889 editPost
12890 } = dispatch(store_store);
12891 return {
12892 onUpdateImage(image) {
12893 editPost({
12894 featured_media: image.id
12895 });
12896 },
12897 onDropImage(filesList) {
12898 select(external_wp_blockEditor_namespaceObject.store).getSettings().mediaUpload({
12899 allowedTypes: ['image'],
12900 filesList,
12901 onFileChange([image]) {
12902 editPost({
12903 featured_media: image.id
12904 });
12905 },
12906 onError(message) {
12907 noticeOperations.removeAllNotices();
12908 noticeOperations.createErrorNotice(message);
12909 }
12910 });
12911 },
12912 onRemoveImage() {
12913 editPost({
12914 featured_media: 0
12915 });
12916 }
12917 };
12918 });
12919
12920 /**
12921 * Renders the component for managing the featured image of a post.
12922 *
12923 * @param {Object} props Props.
12924 * @param {number} props.currentPostId ID of the current post.
12925 * @param {number} props.featuredImageId ID of the featured image.
12926 * @param {Function} props.onUpdateImage Function to call when the image is updated.
12927 * @param {Function} props.onRemoveImage Function to call when the image is removed.
12928 * @param {Object} props.media The media object representing the featured image.
12929 * @param {string} props.postType Post type.
12930 * @param {Element} props.noticeUI UI for displaying notices.
12931 * @param {Object} props.noticeOperations Operations for managing notices.
12932 *
12933 * @return {Element} Component to be rendered .
12934 */
12935 /* 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));
12936
12937 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-featured-image/panel.js
12938 /**
12939 * WordPress dependencies
12940 */
12941
12942
12943
12944
12945
12946 /**
12947 * Internal dependencies
12948 */
12949
12950
12951
12952
12953 const post_featured_image_panel_PANEL_NAME = 'featured-image';
12954
12955 /**
12956 * Renders the panel for the post featured image.
12957 *
12958 * @param {Object} props Props.
12959 * @param {boolean} props.withPanelBody Whether to include the panel body. Default true.
12960 *
12961 * @return {Component|null} The component to be rendered.
12962 * Return Null if the editor panel is disabled for featured image.
12963 */
12964 function PostFeaturedImagePanel({
12965 withPanelBody = true
12966 }) {
12967 var _postType$labels$feat;
12968 const {
12969 postType,
12970 isEnabled,
12971 isOpened
12972 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12973 const {
12974 getEditedPostAttribute,
12975 isEditorPanelEnabled,
12976 isEditorPanelOpened
12977 } = select(store_store);
12978 const {
12979 getPostType
12980 } = select(external_wp_coreData_namespaceObject.store);
12981 return {
12982 postType: getPostType(getEditedPostAttribute('type')),
12983 isEnabled: isEditorPanelEnabled(post_featured_image_panel_PANEL_NAME),
12984 isOpened: isEditorPanelOpened(post_featured_image_panel_PANEL_NAME)
12985 };
12986 }, []);
12987 const {
12988 toggleEditorPanelOpened
12989 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12990 if (!isEnabled) {
12991 return null;
12992 }
12993 if (!withPanelBody) {
12994 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image_check, {
12995 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image, {})
12996 });
12997 }
12998 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image_check, {
12999 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
13000 title: (_postType$labels$feat = postType?.labels?.featured_image) !== null && _postType$labels$feat !== void 0 ? _postType$labels$feat : (0,external_wp_i18n_namespaceObject.__)('Featured image'),
13001 opened: isOpened,
13002 onToggle: () => toggleEditorPanelOpened(post_featured_image_panel_PANEL_NAME),
13003 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image, {})
13004 })
13005 });
13006 }
13007
13008 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-format/check.js
13009 /**
13010 * WordPress dependencies
13011 */
13012
13013
13014 /**
13015 * Internal dependencies
13016 */
13017
13018
13019
13020 function PostFormatCheck({
13021 children
13022 }) {
13023 const disablePostFormats = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditorSettings().disablePostFormats, []);
13024 if (disablePostFormats) {
13025 return null;
13026 }
13027 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
13028 supportKeys: "post-formats",
13029 children: children
13030 });
13031 }
13032
13033 /**
13034 * Component check if there are any post formats.
13035 *
13036 * @param {Object} props The component props.
13037 * @param {Element} props.children The child elements to render.
13038 *
13039 * @return {Component|null} The rendered component or null if post formats are disabled.
13040 */
13041 /* harmony default export */ const post_format_check = (PostFormatCheck);
13042
13043 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-format/index.js
13044 /**
13045 * WordPress dependencies
13046 */
13047
13048
13049
13050
13051
13052
13053 /**
13054 * Internal dependencies
13055 */
13056
13057
13058
13059 // All WP post formats, sorted alphabetically by translated name.
13060
13061
13062 const POST_FORMATS = [{
13063 id: 'aside',
13064 caption: (0,external_wp_i18n_namespaceObject.__)('Aside')
13065 }, {
13066 id: 'audio',
13067 caption: (0,external_wp_i18n_namespaceObject.__)('Audio')
13068 }, {
13069 id: 'chat',
13070 caption: (0,external_wp_i18n_namespaceObject.__)('Chat')
13071 }, {
13072 id: 'gallery',
13073 caption: (0,external_wp_i18n_namespaceObject.__)('Gallery')
13074 }, {
13075 id: 'image',
13076 caption: (0,external_wp_i18n_namespaceObject.__)('Image')
13077 }, {
13078 id: 'link',
13079 caption: (0,external_wp_i18n_namespaceObject.__)('Link')
13080 }, {
13081 id: 'quote',
13082 caption: (0,external_wp_i18n_namespaceObject.__)('Quote')
13083 }, {
13084 id: 'standard',
13085 caption: (0,external_wp_i18n_namespaceObject.__)('Standard')
13086 }, {
13087 id: 'status',
13088 caption: (0,external_wp_i18n_namespaceObject.__)('Status')
13089 }, {
13090 id: 'video',
13091 caption: (0,external_wp_i18n_namespaceObject.__)('Video')
13092 }].sort((a, b) => {
13093 const normalizedA = a.caption.toUpperCase();
13094 const normalizedB = b.caption.toUpperCase();
13095 if (normalizedA < normalizedB) {
13096 return -1;
13097 }
13098 if (normalizedA > normalizedB) {
13099 return 1;
13100 }
13101 return 0;
13102 });
13103
13104 /**
13105 * `PostFormat` a component that allows changing the post format while also providing a suggestion for the current post.
13106 *
13107 * @example
13108 * ```jsx
13109 * <PostFormat />
13110 * ```
13111 *
13112 * @return {JSX.Element} The rendered PostFormat component.
13113 */
13114 function PostFormat() {
13115 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostFormat);
13116 const postFormatSelectorId = `post-format-selector-${instanceId}`;
13117 const {
13118 postFormat,
13119 suggestedFormat,
13120 supportedFormats
13121 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13122 const {
13123 getEditedPostAttribute,
13124 getSuggestedPostFormat
13125 } = select(store_store);
13126 const _postFormat = getEditedPostAttribute('format');
13127 const themeSupports = select(external_wp_coreData_namespaceObject.store).getThemeSupports();
13128 return {
13129 postFormat: _postFormat !== null && _postFormat !== void 0 ? _postFormat : 'standard',
13130 suggestedFormat: getSuggestedPostFormat(),
13131 supportedFormats: themeSupports.formats
13132 };
13133 }, []);
13134 const formats = POST_FORMATS.filter(format => {
13135 // Ensure current format is always in the set.
13136 // The current format may not be a format supported by the theme.
13137 return supportedFormats?.includes(format.id) || postFormat === format.id;
13138 });
13139 const suggestion = formats.find(format => format.id === suggestedFormat);
13140 const {
13141 editPost
13142 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13143 const onUpdatePostFormat = format => editPost({
13144 format
13145 });
13146 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_format_check, {
13147 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13148 className: "editor-post-format",
13149 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
13150 className: "editor-post-format__options",
13151 label: (0,external_wp_i18n_namespaceObject.__)('Post Format'),
13152 selected: postFormat,
13153 onChange: format => onUpdatePostFormat(format),
13154 id: postFormatSelectorId,
13155 options: formats.map(format => ({
13156 label: format.caption,
13157 value: format.id
13158 })),
13159 hideLabelFromVision: true
13160 }), suggestion && suggestion.id !== postFormat && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13161 className: "editor-post-format__suggestion",
13162 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13163 variant: "link",
13164 onClick: () => onUpdatePostFormat(suggestion.id),
13165 children: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: post format */
13166 (0,external_wp_i18n_namespaceObject.__)('Apply suggested format: %s'), suggestion.caption)
13167 })
13168 })]
13169 })
13170 });
13171 }
13172
13173 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/backup.js
13174 /**
13175 * WordPress dependencies
13176 */
13177
13178
13179 const backup = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
13180 xmlns: "http://www.w3.org/2000/svg",
13181 viewBox: "0 0 24 24",
13182 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
13183 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"
13184 })
13185 });
13186 /* harmony default export */ const library_backup = (backup);
13187
13188 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-last-revision/check.js
13189 /**
13190 * WordPress dependencies
13191 */
13192
13193
13194 /**
13195 * Internal dependencies
13196 */
13197
13198
13199
13200 /**
13201 * Wrapper component that renders its children if the post has more than one revision.
13202 *
13203 * @param {Object} props Props.
13204 * @param {Element} props.children Children to be rendered.
13205 *
13206 * @return {Component|null} Rendered child components if post has more than one revision, otherwise null.
13207 */
13208
13209 function PostLastRevisionCheck({
13210 children
13211 }) {
13212 const {
13213 lastRevisionId,
13214 revisionsCount
13215 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13216 const {
13217 getCurrentPostLastRevisionId,
13218 getCurrentPostRevisionsCount
13219 } = select(store_store);
13220 return {
13221 lastRevisionId: getCurrentPostLastRevisionId(),
13222 revisionsCount: getCurrentPostRevisionsCount()
13223 };
13224 }, []);
13225 if (!lastRevisionId || revisionsCount < 2) {
13226 return null;
13227 }
13228 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
13229 supportKeys: "revisions",
13230 children: children
13231 });
13232 }
13233 /* harmony default export */ const post_last_revision_check = (PostLastRevisionCheck);
13234
13235 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-last-revision/index.js
13236 /**
13237 * WordPress dependencies
13238 */
13239
13240
13241
13242
13243
13244
13245 /**
13246 * Internal dependencies
13247 */
13248
13249
13250
13251 /**
13252 * Renders the component for displaying the last revision of a post.
13253 *
13254 * @return {Component} The component to be rendered.
13255 */
13256
13257 function PostLastRevision() {
13258 const {
13259 lastRevisionId,
13260 revisionsCount
13261 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13262 const {
13263 getCurrentPostLastRevisionId,
13264 getCurrentPostRevisionsCount
13265 } = select(store_store);
13266 return {
13267 lastRevisionId: getCurrentPostLastRevisionId(),
13268 revisionsCount: getCurrentPostRevisionsCount()
13269 };
13270 }, []);
13271 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision_check, {
13272 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13273 href: (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
13274 revision: lastRevisionId
13275 }),
13276 className: "editor-post-last-revision__title",
13277 icon: library_backup,
13278 iconPosition: "right",
13279 text: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: number of revisions */
13280 (0,external_wp_i18n_namespaceObject.__)('Revisions (%s)'), revisionsCount)
13281 })
13282 });
13283 }
13284 /* harmony default export */ const post_last_revision = (PostLastRevision);
13285
13286 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-last-revision/panel.js
13287 /**
13288 * WordPress dependencies
13289 */
13290
13291
13292 /**
13293 * Internal dependencies
13294 */
13295
13296
13297
13298 /**
13299 * Renders the panel for displaying the last revision of a post.
13300 *
13301 * @return {Component} The component to be rendered.
13302 */
13303
13304 function PostLastRevisionPanel() {
13305 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision_check, {
13306 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
13307 className: "editor-post-last-revision__panel",
13308 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision, {})
13309 })
13310 });
13311 }
13312 /* harmony default export */ const post_last_revision_panel = (PostLastRevisionPanel);
13313
13314 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-locked-modal/index.js
13315 /**
13316 * WordPress dependencies
13317 */
13318
13319
13320
13321
13322
13323
13324
13325
13326
13327 /**
13328 * Internal dependencies
13329 */
13330
13331
13332 /**
13333 * A modal component that is displayed when a post is locked for editing by another user.
13334 * The modal provides information about the lock status and options to take over or exit the editor.
13335 *
13336 * @return {JSX.Element|null} The rendered PostLockedModal component.
13337 */
13338
13339
13340
13341 function PostLockedModal() {
13342 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostLockedModal);
13343 const hookName = 'core/editor/post-locked-modal-' + instanceId;
13344 const {
13345 autosave,
13346 updatePostLock
13347 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13348 const {
13349 isLocked,
13350 isTakeover,
13351 user,
13352 postId,
13353 postLockUtils,
13354 activePostLock,
13355 postType,
13356 previewLink
13357 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13358 const {
13359 isPostLocked,
13360 isPostLockTakeover,
13361 getPostLockUser,
13362 getCurrentPostId,
13363 getActivePostLock,
13364 getEditedPostAttribute,
13365 getEditedPostPreviewLink,
13366 getEditorSettings
13367 } = select(store_store);
13368 const {
13369 getPostType
13370 } = select(external_wp_coreData_namespaceObject.store);
13371 return {
13372 isLocked: isPostLocked(),
13373 isTakeover: isPostLockTakeover(),
13374 user: getPostLockUser(),
13375 postId: getCurrentPostId(),
13376 postLockUtils: getEditorSettings().postLockUtils,
13377 activePostLock: getActivePostLock(),
13378 postType: getPostType(getEditedPostAttribute('type')),
13379 previewLink: getEditedPostPreviewLink()
13380 };
13381 }, []);
13382 (0,external_wp_element_namespaceObject.useEffect)(() => {
13383 /**
13384 * Keep the lock refreshed.
13385 *
13386 * When the user does not send a heartbeat in a heartbeat-tick
13387 * the user is no longer editing and another user can start editing.
13388 *
13389 * @param {Object} data Data to send in the heartbeat request.
13390 */
13391 function sendPostLock(data) {
13392 if (isLocked) {
13393 return;
13394 }
13395 data['wp-refresh-post-lock'] = {
13396 lock: activePostLock,
13397 post_id: postId
13398 };
13399 }
13400
13401 /**
13402 * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing.
13403 *
13404 * @param {Object} data Data received in the heartbeat request
13405 */
13406 function receivePostLock(data) {
13407 if (!data['wp-refresh-post-lock']) {
13408 return;
13409 }
13410 const received = data['wp-refresh-post-lock'];
13411 if (received.lock_error) {
13412 // Auto save and display the takeover modal.
13413 autosave();
13414 updatePostLock({
13415 isLocked: true,
13416 isTakeover: true,
13417 user: {
13418 name: received.lock_error.name,
13419 avatar: received.lock_error.avatar_src_2x
13420 }
13421 });
13422 } else if (received.new_lock) {
13423 updatePostLock({
13424 isLocked: false,
13425 activePostLock: received.new_lock
13426 });
13427 }
13428 }
13429
13430 /**
13431 * Unlock the post before the window is exited.
13432 */
13433 function releasePostLock() {
13434 if (isLocked || !activePostLock) {
13435 return;
13436 }
13437 const data = new window.FormData();
13438 data.append('action', 'wp-remove-post-lock');
13439 data.append('_wpnonce', postLockUtils.unlockNonce);
13440 data.append('post_ID', postId);
13441 data.append('active_post_lock', activePostLock);
13442 if (window.navigator.sendBeacon) {
13443 window.navigator.sendBeacon(postLockUtils.ajaxUrl, data);
13444 } else {
13445 const xhr = new window.XMLHttpRequest();
13446 xhr.open('POST', postLockUtils.ajaxUrl, false);
13447 xhr.send(data);
13448 }
13449 }
13450
13451 // Details on these events on the Heartbeat API docs
13452 // https://developer.wordpress.org/plugins/javascript/heartbeat-api/
13453 (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.send', hookName, sendPostLock);
13454 (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.tick', hookName, receivePostLock);
13455 window.addEventListener('beforeunload', releasePostLock);
13456 return () => {
13457 (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.send', hookName);
13458 (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.tick', hookName);
13459 window.removeEventListener('beforeunload', releasePostLock);
13460 };
13461 }, []);
13462 if (!isLocked) {
13463 return null;
13464 }
13465 const userDisplayName = user.name;
13466 const userAvatar = user.avatar;
13467 const unlockUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('post.php', {
13468 'get-post-lock': '1',
13469 lockKey: true,
13470 post: postId,
13471 action: 'edit',
13472 _wpnonce: postLockUtils.nonce
13473 });
13474 const allPostsUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
13475 post_type: postType?.slug
13476 });
13477 const allPostsLabel = (0,external_wp_i18n_namespaceObject.__)('Exit editor');
13478 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
13479 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'),
13480 focusOnMount: true,
13481 shouldCloseOnClickOutside: false,
13482 shouldCloseOnEsc: false,
13483 isDismissible: false,
13484 size: "medium",
13485 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
13486 alignment: "top",
13487 spacing: 6,
13488 children: [!!userAvatar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
13489 src: userAvatar,
13490 alt: (0,external_wp_i18n_namespaceObject.__)('Avatar'),
13491 className: "editor-post-locked-modal__avatar",
13492 width: 64,
13493 height: 64
13494 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13495 children: [!!isTakeover && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13496 children: (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: user's display name */
13497 (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.'), {
13498 strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {}),
13499 PreviewLink: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
13500 href: previewLink,
13501 children: (0,external_wp_i18n_namespaceObject.__)('preview')
13502 })
13503 })
13504 }), !isTakeover && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
13505 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13506 children: (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: user's display name */
13507 (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.'), {
13508 strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {}),
13509 PreviewLink: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
13510 href: previewLink,
13511 children: (0,external_wp_i18n_namespaceObject.__)('preview')
13512 })
13513 })
13514 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13515 children: (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.')
13516 })]
13517 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
13518 className: "editor-post-locked-modal__buttons",
13519 justify: "flex-end",
13520 children: [!isTakeover && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13521 variant: "tertiary",
13522 href: unlockUrl,
13523 children: (0,external_wp_i18n_namespaceObject.__)('Take over')
13524 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13525 variant: "primary",
13526 href: allPostsUrl,
13527 children: allPostsLabel
13528 })]
13529 })]
13530 })]
13531 })
13532 });
13533 }
13534
13535 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-pending-status/check.js
13536 /**
13537 * WordPress dependencies
13538 */
13539
13540
13541 /**
13542 * Internal dependencies
13543 */
13544
13545
13546 /**
13547 * This component checks the publishing status of the current post.
13548 * If the post is already published or the user doesn't have the
13549 * capability to publish, it returns null.
13550 *
13551 * @param {Object} props Component properties.
13552 * @param {Element} props.children Children to be rendered.
13553 *
13554 * @return {JSX.Element|null} The rendered child elements or null if the post is already published or the user doesn't have the capability to publish.
13555 */
13556 function PostPendingStatusCheck({
13557 children
13558 }) {
13559 const {
13560 hasPublishAction,
13561 isPublished
13562 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13563 var _getCurrentPost$_link;
13564 const {
13565 isCurrentPostPublished,
13566 getCurrentPost
13567 } = select(store_store);
13568 return {
13569 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
13570 isPublished: isCurrentPostPublished()
13571 };
13572 }, []);
13573 if (isPublished || !hasPublishAction) {
13574 return null;
13575 }
13576 return children;
13577 }
13578 /* harmony default export */ const post_pending_status_check = (PostPendingStatusCheck);
13579
13580 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-pending-status/index.js
13581 /**
13582 * WordPress dependencies
13583 */
13584
13585
13586
13587
13588 /**
13589 * Internal dependencies
13590 */
13591
13592
13593
13594 /**
13595 * A component for displaying and toggling the pending status of a post.
13596 *
13597 * @return {JSX.Element} The rendered component.
13598 */
13599
13600 function PostPendingStatus() {
13601 const status = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('status'), []);
13602 const {
13603 editPost
13604 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13605 const togglePendingStatus = () => {
13606 const updatedStatus = status === 'pending' ? 'draft' : 'pending';
13607 editPost({
13608 status: updatedStatus
13609 });
13610 };
13611 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_pending_status_check, {
13612 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
13613 __nextHasNoMarginBottom: true,
13614 label: (0,external_wp_i18n_namespaceObject.__)('Pending review'),
13615 checked: status === 'pending',
13616 onChange: togglePendingStatus
13617 })
13618 });
13619 }
13620 /* harmony default export */ const post_pending_status = (PostPendingStatus);
13621
13622 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-preview-button/index.js
13623 /**
13624 * WordPress dependencies
13625 */
13626
13627
13628
13629
13630
13631
13632
13633 /**
13634 * Internal dependencies
13635 */
13636
13637
13638
13639
13640 function writeInterstitialMessage(targetDocument) {
13641 let markup = (0,external_wp_element_namespaceObject.renderToString)( /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13642 className: "editor-post-preview-button__interstitial-message",
13643 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.SVG, {
13644 xmlns: "http://www.w3.org/2000/svg",
13645 viewBox: "0 0 96 96",
13646 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
13647 className: "outer",
13648 d: "M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36",
13649 fill: "none"
13650 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
13651 className: "inner",
13652 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",
13653 fill: "none"
13654 })]
13655 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13656 children: (0,external_wp_i18n_namespaceObject.__)('Generating preview…')
13657 })]
13658 }));
13659 markup += `
13660 <style>
13661 body {
13662 margin: 0;
13663 }
13664 .editor-post-preview-button__interstitial-message {
13665 display: flex;
13666 flex-direction: column;
13667 align-items: center;
13668 justify-content: center;
13669 height: 100vh;
13670 width: 100vw;
13671 }
13672 @-webkit-keyframes paint {
13673 0% {
13674 stroke-dashoffset: 0;
13675 }
13676 }
13677 @-moz-keyframes paint {
13678 0% {
13679 stroke-dashoffset: 0;
13680 }
13681 }
13682 @-o-keyframes paint {
13683 0% {
13684 stroke-dashoffset: 0;
13685 }
13686 }
13687 @keyframes paint {
13688 0% {
13689 stroke-dashoffset: 0;
13690 }
13691 }
13692 .editor-post-preview-button__interstitial-message svg {
13693 width: 192px;
13694 height: 192px;
13695 stroke: #555d66;
13696 stroke-width: 0.75;
13697 }
13698 .editor-post-preview-button__interstitial-message svg .outer,
13699 .editor-post-preview-button__interstitial-message svg .inner {
13700 stroke-dasharray: 280;
13701 stroke-dashoffset: 280;
13702 -webkit-animation: paint 1.5s ease infinite alternate;
13703 -moz-animation: paint 1.5s ease infinite alternate;
13704 -o-animation: paint 1.5s ease infinite alternate;
13705 animation: paint 1.5s ease infinite alternate;
13706 }
13707 p {
13708 text-align: center;
13709 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
13710 }
13711 </style>
13712 `;
13713
13714 /**
13715 * Filters the interstitial message shown when generating previews.
13716 *
13717 * @param {string} markup The preview interstitial markup.
13718 */
13719 markup = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostPreview.interstitialMarkup', markup);
13720 targetDocument.write(markup);
13721 targetDocument.title = (0,external_wp_i18n_namespaceObject.__)('Generating preview…');
13722 targetDocument.close();
13723 }
13724
13725 /**
13726 * Renders a button that opens a new window or tab for the preview,
13727 * writes the interstitial message to this window, and then navigates
13728 * to the actual preview link. The button is not rendered if the post
13729 * is not viewable and disabled if the post is not saveable.
13730 *
13731 * @param {Object} props The component props.
13732 * @param {string} props.className The class name for the button.
13733 * @param {string} props.textContent The text content for the button.
13734 * @param {boolean} props.forceIsAutosaveable Whether to force autosave.
13735 * @param {string} props.role The role attribute for the button.
13736 * @param {Function} props.onPreview The callback function for preview event.
13737 *
13738 * @return {JSX.Element|null} The rendered button component.
13739 */
13740 function PostPreviewButton({
13741 className,
13742 textContent,
13743 forceIsAutosaveable,
13744 role,
13745 onPreview
13746 }) {
13747 const {
13748 postId,
13749 currentPostLink,
13750 previewLink,
13751 isSaveable,
13752 isViewable
13753 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13754 var _postType$viewable;
13755 const editor = select(store_store);
13756 const core = select(external_wp_coreData_namespaceObject.store);
13757 const postType = core.getPostType(editor.getCurrentPostType('type'));
13758 return {
13759 postId: editor.getCurrentPostId(),
13760 currentPostLink: editor.getCurrentPostAttribute('link'),
13761 previewLink: editor.getEditedPostPreviewLink(),
13762 isSaveable: editor.isEditedPostSaveable(),
13763 isViewable: (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false
13764 };
13765 }, []);
13766 const {
13767 __unstableSaveForPreview
13768 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13769 if (!isViewable) {
13770 return null;
13771 }
13772 const targetId = `wp-preview-${postId}`;
13773 const openPreviewWindow = async event => {
13774 // Our Preview button has its 'href' and 'target' set correctly for a11y
13775 // purposes. Unfortunately, though, we can't rely on the default 'click'
13776 // handler since sometimes it incorrectly opens a new tab instead of reusing
13777 // the existing one.
13778 // https://github.com/WordPress/gutenberg/pull/8330
13779 event.preventDefault();
13780
13781 // Open up a Preview tab if needed. This is where we'll show the preview.
13782 const previewWindow = window.open('', targetId);
13783
13784 // Focus the Preview tab. This might not do anything, depending on the browser's
13785 // and user's preferences.
13786 // https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus
13787 previewWindow.focus();
13788 writeInterstitialMessage(previewWindow.document);
13789 const link = await __unstableSaveForPreview({
13790 forceIsAutosaveable
13791 });
13792 previewWindow.location = link;
13793 onPreview?.();
13794 };
13795
13796 // Link to the `?preview=true` URL if we have it, since this lets us see
13797 // changes that were autosaved since the post was last published. Otherwise,
13798 // just link to the post's URL.
13799 const href = previewLink || currentPostLink;
13800 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13801 variant: !className ? 'tertiary' : undefined,
13802 className: className || 'editor-post-preview',
13803 href: href,
13804 target: targetId,
13805 disabled: !isSaveable,
13806 onClick: openPreviewWindow,
13807 role: role,
13808 size: "compact",
13809 children: textContent || /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
13810 children: [(0,external_wp_i18n_namespaceObject._x)('Preview', 'imperative verb'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
13811 as: "span",
13812 children: /* translators: accessibility text */
13813 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')
13814 })]
13815 })
13816 });
13817 }
13818
13819 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-button/label.js
13820 /**
13821 * WordPress dependencies
13822 */
13823
13824
13825
13826
13827 /**
13828 * Internal dependencies
13829 */
13830
13831 function PublishButtonLabel() {
13832 const isSmallerThanMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
13833 const {
13834 isPublished,
13835 isBeingScheduled,
13836 isSaving,
13837 isPublishing,
13838 hasPublishAction,
13839 isAutosaving,
13840 hasNonPostEntityChanges,
13841 postStatusHasChanged,
13842 postStatus
13843 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13844 var _getCurrentPost$_link;
13845 const {
13846 isCurrentPostPublished,
13847 isEditedPostBeingScheduled,
13848 isSavingPost,
13849 isPublishingPost,
13850 getCurrentPost,
13851 getCurrentPostType,
13852 isAutosavingPost,
13853 getPostEdits,
13854 getEditedPostAttribute
13855 } = select(store_store);
13856 return {
13857 isPublished: isCurrentPostPublished(),
13858 isBeingScheduled: isEditedPostBeingScheduled(),
13859 isSaving: isSavingPost(),
13860 isPublishing: isPublishingPost(),
13861 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
13862 postType: getCurrentPostType(),
13863 isAutosaving: isAutosavingPost(),
13864 hasNonPostEntityChanges: select(store_store).hasNonPostEntityChanges(),
13865 postStatusHasChanged: !!getPostEdits()?.status,
13866 postStatus: getEditedPostAttribute('status')
13867 };
13868 }, []);
13869 if (isPublishing) {
13870 /* translators: button label text should, if possible, be under 16 characters. */
13871 return (0,external_wp_i18n_namespaceObject.__)('Publishing…');
13872 } else if ((isPublished || isBeingScheduled) && isSaving && !isAutosaving) {
13873 /* translators: button label text should, if possible, be under 16 characters. */
13874 return (0,external_wp_i18n_namespaceObject.__)('Saving…');
13875 }
13876 if (!hasPublishAction) {
13877 // TODO: this is because "Submit for review" string is too long in some languages.
13878 // @see https://github.com/WordPress/gutenberg/issues/10475
13879 return isSmallerThanMediumViewport ? (0,external_wp_i18n_namespaceObject.__)('Publish') : (0,external_wp_i18n_namespaceObject.__)('Submit for Review');
13880 }
13881 if (hasNonPostEntityChanges || isPublished || postStatusHasChanged && !['future', 'publish'].includes(postStatus) || !postStatusHasChanged && postStatus === 'future') {
13882 return (0,external_wp_i18n_namespaceObject.__)('Save');
13883 }
13884 if (isBeingScheduled) {
13885 return (0,external_wp_i18n_namespaceObject.__)('Schedule');
13886 }
13887 return (0,external_wp_i18n_namespaceObject.__)('Publish');
13888 }
13889
13890 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-button/index.js
13891 /**
13892 * WordPress dependencies
13893 */
13894
13895
13896
13897
13898
13899 /**
13900 * Internal dependencies
13901 */
13902
13903
13904
13905
13906
13907 const post_publish_button_noop = () => {};
13908 class PostPublishButton extends external_wp_element_namespaceObject.Component {
13909 constructor(props) {
13910 super(props);
13911 this.buttonNode = (0,external_wp_element_namespaceObject.createRef)();
13912 this.createOnClick = this.createOnClick.bind(this);
13913 this.closeEntitiesSavedStates = this.closeEntitiesSavedStates.bind(this);
13914 this.state = {
13915 entitiesSavedStatesCallback: false
13916 };
13917 }
13918 componentDidMount() {
13919 if (this.props.focusOnMount) {
13920 // This timeout is necessary to make sure the `useEffect` hook of
13921 // `useFocusReturn` gets the correct element (the button that opens the
13922 // PostPublishPanel) otherwise it will get this button.
13923 this.timeoutID = setTimeout(() => {
13924 this.buttonNode.current.focus();
13925 }, 0);
13926 }
13927 }
13928 componentWillUnmount() {
13929 clearTimeout(this.timeoutID);
13930 }
13931 createOnClick(callback) {
13932 return (...args) => {
13933 const {
13934 hasNonPostEntityChanges,
13935 hasPostMetaChanges,
13936 setEntitiesSavedStatesCallback,
13937 isPublished
13938 } = this.props;
13939 // If a post with non-post entities is published, but the user
13940 // elects to not save changes to the non-post entities, those
13941 // entities will still be dirty when the Publish button is clicked.
13942 // We also need to check that the `setEntitiesSavedStatesCallback`
13943 // prop was passed. See https://github.com/WordPress/gutenberg/pull/37383
13944 //
13945 // TODO: Explore how to manage `hasPostMetaChanges` and pre-publish workflow properly.
13946 if ((hasNonPostEntityChanges || hasPostMetaChanges && isPublished) && setEntitiesSavedStatesCallback) {
13947 // The modal for multiple entity saving will open,
13948 // hold the callback for saving/publishing the post
13949 // so that we can call it if the post entity is checked.
13950 this.setState({
13951 entitiesSavedStatesCallback: () => callback(...args)
13952 });
13953
13954 // Open the save panel by setting its callback.
13955 // To set a function on the useState hook, we must set it
13956 // with another function (() => myFunction). Passing the
13957 // function on its own will cause an error when called.
13958 setEntitiesSavedStatesCallback(() => this.closeEntitiesSavedStates);
13959 return post_publish_button_noop;
13960 }
13961 return callback(...args);
13962 };
13963 }
13964 closeEntitiesSavedStates(savedEntities) {
13965 const {
13966 postType,
13967 postId
13968 } = this.props;
13969 const {
13970 entitiesSavedStatesCallback
13971 } = this.state;
13972 this.setState({
13973 entitiesSavedStatesCallback: false
13974 }, () => {
13975 if (savedEntities && savedEntities.some(elt => elt.kind === 'postType' && elt.name === postType && elt.key === postId)) {
13976 // The post entity was checked, call the held callback from `createOnClick`.
13977 entitiesSavedStatesCallback();
13978 }
13979 });
13980 }
13981 render() {
13982 const {
13983 forceIsDirty,
13984 hasPublishAction,
13985 isBeingScheduled,
13986 isOpen,
13987 isPostSavingLocked,
13988 isPublishable,
13989 isPublished,
13990 isSaveable,
13991 isSaving,
13992 isAutoSaving,
13993 isToggle,
13994 savePostStatus,
13995 onSubmit = post_publish_button_noop,
13996 onToggle,
13997 visibility,
13998 hasNonPostEntityChanges,
13999 isSavingNonPostEntityChanges,
14000 postStatus,
14001 postStatusHasChanged
14002 } = this.props;
14003 const isButtonDisabled = (isSaving || !isSaveable || isPostSavingLocked || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
14004 const isToggleDisabled = (isPublished || isSaving || !isSaveable || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
14005
14006 // If the new status has not changed explicitely, we derive it from
14007 // other factors, like having a publish action, etc.. We need to preserve
14008 // this because it affects when to show the pre and post publish panels.
14009 // If it has changed though explicitely, we need to respect that.
14010 let publishStatus = 'publish';
14011 if (postStatusHasChanged) {
14012 publishStatus = postStatus;
14013 } else if (!hasPublishAction) {
14014 publishStatus = 'pending';
14015 } else if (visibility === 'private') {
14016 publishStatus = 'private';
14017 } else if (isBeingScheduled) {
14018 publishStatus = 'future';
14019 }
14020 const onClickButton = () => {
14021 if (isButtonDisabled) {
14022 return;
14023 }
14024 onSubmit();
14025 savePostStatus(publishStatus);
14026 };
14027
14028 // Callback to open the publish panel.
14029 const onClickToggle = () => {
14030 if (isToggleDisabled) {
14031 return;
14032 }
14033 onToggle();
14034 };
14035 const buttonProps = {
14036 'aria-disabled': isButtonDisabled,
14037 className: 'editor-post-publish-button',
14038 isBusy: !isAutoSaving && isSaving,
14039 variant: 'primary',
14040 onClick: this.createOnClick(onClickButton)
14041 };
14042 const toggleProps = {
14043 'aria-disabled': isToggleDisabled,
14044 'aria-expanded': isOpen,
14045 className: 'editor-post-publish-panel__toggle',
14046 isBusy: isSaving && isPublished,
14047 variant: 'primary',
14048 size: 'compact',
14049 onClick: this.createOnClick(onClickToggle)
14050 };
14051 const componentProps = isToggle ? toggleProps : buttonProps;
14052 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
14053 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
14054 ref: this.buttonNode,
14055 ...componentProps,
14056 className: `${componentProps.className} editor-post-publish-button__button`,
14057 size: "compact",
14058 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PublishButtonLabel, {})
14059 })
14060 });
14061 }
14062 }
14063 /* harmony default export */ const post_publish_button = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
14064 var _getCurrentPost$_link;
14065 const {
14066 isSavingPost,
14067 isAutosavingPost,
14068 isEditedPostBeingScheduled,
14069 getEditedPostVisibility,
14070 isCurrentPostPublished,
14071 isEditedPostSaveable,
14072 isEditedPostPublishable,
14073 isPostSavingLocked,
14074 getCurrentPost,
14075 getCurrentPostType,
14076 getCurrentPostId,
14077 hasNonPostEntityChanges,
14078 isSavingNonPostEntityChanges,
14079 getEditedPostAttribute,
14080 getPostEdits,
14081 hasPostMetaChanges
14082 } = unlock(select(store_store));
14083 return {
14084 isSaving: isSavingPost(),
14085 isAutoSaving: isAutosavingPost(),
14086 isBeingScheduled: isEditedPostBeingScheduled(),
14087 visibility: getEditedPostVisibility(),
14088 isSaveable: isEditedPostSaveable(),
14089 isPostSavingLocked: isPostSavingLocked(),
14090 isPublishable: isEditedPostPublishable(),
14091 isPublished: isCurrentPostPublished(),
14092 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
14093 postType: getCurrentPostType(),
14094 postId: getCurrentPostId(),
14095 postStatus: getEditedPostAttribute('status'),
14096 postStatusHasChanged: getPostEdits()?.status,
14097 hasNonPostEntityChanges: hasNonPostEntityChanges(),
14098 hasPostMetaChanges: hasPostMetaChanges(),
14099 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges()
14100 };
14101 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
14102 const {
14103 editPost,
14104 savePost
14105 } = dispatch(store_store);
14106 return {
14107 savePostStatus: status => {
14108 editPost({
14109 status
14110 }, {
14111 undoIgnore: true
14112 });
14113 savePost();
14114 }
14115 };
14116 })])(PostPublishButton));
14117
14118 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/wordpress.js
14119 /**
14120 * WordPress dependencies
14121 */
14122
14123
14124 const wordpress = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
14125 xmlns: "http://www.w3.org/2000/svg",
14126 viewBox: "-2 -2 24 24",
14127 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
14128 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"
14129 })
14130 });
14131 /* harmony default export */ const library_wordpress = (wordpress);
14132
14133 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/utils.js
14134 /**
14135 * WordPress dependencies
14136 */
14137
14138 const visibilityOptions = {
14139 public: {
14140 label: (0,external_wp_i18n_namespaceObject.__)('Public'),
14141 info: (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.')
14142 },
14143 private: {
14144 label: (0,external_wp_i18n_namespaceObject.__)('Private'),
14145 info: (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.')
14146 },
14147 password: {
14148 label: (0,external_wp_i18n_namespaceObject.__)('Password protected'),
14149 info: (0,external_wp_i18n_namespaceObject.__)('Only those with the password can view this post.')
14150 }
14151 };
14152
14153 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/index.js
14154 /**
14155 * WordPress dependencies
14156 */
14157
14158
14159
14160
14161
14162
14163
14164 /**
14165 * Internal dependencies
14166 */
14167
14168
14169
14170 /**
14171 * Allows users to set the visibility of a post.
14172 *
14173 * @param {Object} props The component props.
14174 * @param {Function} props.onClose Function to call when the popover is closed.
14175 * @return {JSX.Element} The rendered component.
14176 */
14177
14178
14179 function PostVisibility({
14180 onClose
14181 }) {
14182 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostVisibility);
14183 const {
14184 status,
14185 visibility,
14186 password
14187 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
14188 status: select(store_store).getEditedPostAttribute('status'),
14189 visibility: select(store_store).getEditedPostVisibility(),
14190 password: select(store_store).getEditedPostAttribute('password')
14191 }));
14192 const {
14193 editPost,
14194 savePost
14195 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
14196 const [hasPassword, setHasPassword] = (0,external_wp_element_namespaceObject.useState)(!!password);
14197 const [showPrivateConfirmDialog, setShowPrivateConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
14198 const setPublic = () => {
14199 editPost({
14200 status: visibility === 'private' ? 'draft' : status,
14201 password: ''
14202 });
14203 setHasPassword(false);
14204 };
14205 const setPrivate = () => {
14206 setShowPrivateConfirmDialog(true);
14207 };
14208 const confirmPrivate = () => {
14209 editPost({
14210 status: 'private',
14211 password: ''
14212 });
14213 setHasPassword(false);
14214 setShowPrivateConfirmDialog(false);
14215 savePost();
14216 };
14217 const handleDialogCancel = () => {
14218 setShowPrivateConfirmDialog(false);
14219 };
14220 const setPasswordProtected = () => {
14221 editPost({
14222 status: visibility === 'private' ? 'draft' : status,
14223 password: password || ''
14224 });
14225 setHasPassword(true);
14226 };
14227 const updatePassword = event => {
14228 editPost({
14229 password: event.target.value
14230 });
14231 };
14232 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
14233 className: "editor-post-visibility",
14234 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
14235 title: (0,external_wp_i18n_namespaceObject.__)('Visibility'),
14236 help: (0,external_wp_i18n_namespaceObject.__)('Control how this post is viewed.'),
14237 onClose: onClose
14238 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("fieldset", {
14239 className: "editor-post-visibility__fieldset",
14240 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
14241 as: "legend",
14242 children: (0,external_wp_i18n_namespaceObject.__)('Visibility')
14243 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityChoice, {
14244 instanceId: instanceId,
14245 value: "public",
14246 label: visibilityOptions.public.label,
14247 info: visibilityOptions.public.info,
14248 checked: visibility === 'public' && !hasPassword,
14249 onChange: setPublic
14250 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityChoice, {
14251 instanceId: instanceId,
14252 value: "private",
14253 label: visibilityOptions.private.label,
14254 info: visibilityOptions.private.info,
14255 checked: visibility === 'private',
14256 onChange: setPrivate
14257 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityChoice, {
14258 instanceId: instanceId,
14259 value: "password",
14260 label: visibilityOptions.password.label,
14261 info: visibilityOptions.password.info,
14262 checked: hasPassword,
14263 onChange: setPasswordProtected
14264 }), hasPassword && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
14265 className: "editor-post-visibility__password",
14266 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
14267 as: "label",
14268 htmlFor: `editor-post-visibility__password-input-${instanceId}`,
14269 children: (0,external_wp_i18n_namespaceObject.__)('Create password')
14270 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("input", {
14271 className: "editor-post-visibility__password-input",
14272 id: `editor-post-visibility__password-input-${instanceId}`,
14273 type: "text",
14274 onChange: updatePassword,
14275 value: password,
14276 placeholder: (0,external_wp_i18n_namespaceObject.__)('Use a secure password')
14277 })]
14278 })]
14279 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
14280 isOpen: showPrivateConfirmDialog,
14281 onConfirm: confirmPrivate,
14282 onCancel: handleDialogCancel,
14283 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Publish'),
14284 children: (0,external_wp_i18n_namespaceObject.__)('Would you like to privately publish this post now?')
14285 })]
14286 });
14287 }
14288 function PostVisibilityChoice({
14289 instanceId,
14290 value,
14291 label,
14292 info,
14293 ...props
14294 }) {
14295 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
14296 className: "editor-post-visibility__choice",
14297 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("input", {
14298 type: "radio",
14299 name: `editor-post-visibility__setting-${instanceId}`,
14300 value: value,
14301 id: `editor-post-${value}-${instanceId}`,
14302 "aria-describedby": `editor-post-${value}-${instanceId}-description`,
14303 className: "editor-post-visibility__radio",
14304 ...props
14305 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("label", {
14306 htmlFor: `editor-post-${value}-${instanceId}`,
14307 className: "editor-post-visibility__label",
14308 children: label
14309 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
14310 id: `editor-post-${value}-${instanceId}-description`,
14311 className: "editor-post-visibility__info",
14312 children: info
14313 })]
14314 });
14315 }
14316
14317 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/label.js
14318 /**
14319 * WordPress dependencies
14320 */
14321
14322
14323 /**
14324 * Internal dependencies
14325 */
14326
14327
14328
14329 /**
14330 * Returns the label for the current post visibility setting.
14331 *
14332 * @return {string} Post visibility label.
14333 */
14334 function PostVisibilityLabel() {
14335 return usePostVisibilityLabel();
14336 }
14337
14338 /**
14339 * Get the label for the current post visibility setting.
14340 *
14341 * @return {string} Post visibility label.
14342 */
14343 function usePostVisibilityLabel() {
14344 const visibility = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostVisibility());
14345 return visibilityOptions[visibility]?.label;
14346 }
14347
14348 ;// CONCATENATED MODULE: ./node_modules/date-fns/toDate.mjs
14349 /**
14350 * @name toDate
14351 * @category Common Helpers
14352 * @summary Convert the given argument to an instance of Date.
14353 *
14354 * @description
14355 * Convert the given argument to an instance of Date.
14356 *
14357 * If the argument is an instance of Date, the function returns its clone.
14358 *
14359 * If the argument is a number, it is treated as a timestamp.
14360 *
14361 * If the argument is none of the above, the function returns Invalid Date.
14362 *
14363 * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
14364 *
14365 * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
14366 *
14367 * @param argument - The value to convert
14368 *
14369 * @returns The parsed date in the local time zone
14370 *
14371 * @example
14372 * // Clone the date:
14373 * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
14374 * //=> Tue Feb 11 2014 11:30:30
14375 *
14376 * @example
14377 * // Convert the timestamp to date:
14378 * const result = toDate(1392098430000)
14379 * //=> Tue Feb 11 2014 11:30:30
14380 */
14381 function toDate(argument) {
14382 const argStr = Object.prototype.toString.call(argument);
14383
14384 // Clone the date
14385 if (
14386 argument instanceof Date ||
14387 (typeof argument === "object" && argStr === "[object Date]")
14388 ) {
14389 // Prevent the date to lose the milliseconds when passed to new Date() in IE10
14390 return new argument.constructor(+argument);
14391 } else if (
14392 typeof argument === "number" ||
14393 argStr === "[object Number]" ||
14394 typeof argument === "string" ||
14395 argStr === "[object String]"
14396 ) {
14397 // TODO: Can we get rid of as?
14398 return new Date(argument);
14399 } else {
14400 // TODO: Can we get rid of as?
14401 return new Date(NaN);
14402 }
14403 }
14404
14405 // Fallback for modularized imports:
14406 /* harmony default export */ const date_fns_toDate = ((/* unused pure expression or super */ null && (toDate)));
14407
14408 ;// CONCATENATED MODULE: ./node_modules/date-fns/startOfMonth.mjs
14409
14410
14411 /**
14412 * @name startOfMonth
14413 * @category Month Helpers
14414 * @summary Return the start of a month for the given date.
14415 *
14416 * @description
14417 * Return the start of a month for the given date.
14418 * The result will be in the local timezone.
14419 *
14420 * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
14421 *
14422 * @param date - The original date
14423 *
14424 * @returns The start of a month
14425 *
14426 * @example
14427 * // The start of a month for 2 September 2014 11:55:00:
14428 * const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))
14429 * //=> Mon Sep 01 2014 00:00:00
14430 */
14431 function startOfMonth(date) {
14432 const _date = toDate(date);
14433 _date.setDate(1);
14434 _date.setHours(0, 0, 0, 0);
14435 return _date;
14436 }
14437
14438 // Fallback for modularized imports:
14439 /* harmony default export */ const date_fns_startOfMonth = ((/* unused pure expression or super */ null && (startOfMonth)));
14440
14441 ;// CONCATENATED MODULE: ./node_modules/date-fns/endOfMonth.mjs
14442
14443
14444 /**
14445 * @name endOfMonth
14446 * @category Month Helpers
14447 * @summary Return the end of a month for the given date.
14448 *
14449 * @description
14450 * Return the end of a month for the given date.
14451 * The result will be in the local timezone.
14452 *
14453 * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
14454 *
14455 * @param date - The original date
14456 *
14457 * @returns The end of a month
14458 *
14459 * @example
14460 * // The end of a month for 2 September 2014 11:55:00:
14461 * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))
14462 * //=> Tue Sep 30 2014 23:59:59.999
14463 */
14464 function endOfMonth(date) {
14465 const _date = toDate(date);
14466 const month = _date.getMonth();
14467 _date.setFullYear(_date.getFullYear(), month + 1, 0);
14468 _date.setHours(23, 59, 59, 999);
14469 return _date;
14470 }
14471
14472 // Fallback for modularized imports:
14473 /* harmony default export */ const date_fns_endOfMonth = ((/* unused pure expression or super */ null && (endOfMonth)));
14474
14475 ;// CONCATENATED MODULE: ./node_modules/date-fns/constants.mjs
14476 /**
14477 * @module constants
14478 * @summary Useful constants
14479 * @description
14480 * Collection of useful date constants.
14481 *
14482 * The constants could be imported from `date-fns/constants`:
14483 *
14484 * ```ts
14485 * import { maxTime, minTime } from "./constants/date-fns/constants";
14486 *
14487 * function isAllowedTime(time) {
14488 * return time <= maxTime && time >= minTime;
14489 * }
14490 * ```
14491 */
14492
14493 /**
14494 * @constant
14495 * @name daysInWeek
14496 * @summary Days in 1 week.
14497 */
14498 const daysInWeek = 7;
14499
14500 /**
14501 * @constant
14502 * @name daysInYear
14503 * @summary Days in 1 year.
14504 *
14505 * @description
14506 * How many days in a year.
14507 *
14508 * One years equals 365.2425 days according to the formula:
14509 *
14510 * > Leap year occures every 4 years, except for years that are divisable by 100 and not divisable by 400.
14511 * > 1 mean year = (365+1/4-1/100+1/400) days = 365.2425 days
14512 */
14513 const daysInYear = 365.2425;
14514
14515 /**
14516 * @constant
14517 * @name maxTime
14518 * @summary Maximum allowed time.
14519 *
14520 * @example
14521 * import { maxTime } from "./constants/date-fns/constants";
14522 *
14523 * const isValid = 8640000000000001 <= maxTime;
14524 * //=> false
14525 *
14526 * new Date(8640000000000001);
14527 * //=> Invalid Date
14528 */
14529 const maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1000;
14530
14531 /**
14532 * @constant
14533 * @name minTime
14534 * @summary Minimum allowed time.
14535 *
14536 * @example
14537 * import { minTime } from "./constants/date-fns/constants";
14538 *
14539 * const isValid = -8640000000000001 >= minTime;
14540 * //=> false
14541 *
14542 * new Date(-8640000000000001)
14543 * //=> Invalid Date
14544 */
14545 const minTime = -maxTime;
14546
14547 /**
14548 * @constant
14549 * @name millisecondsInWeek
14550 * @summary Milliseconds in 1 week.
14551 */
14552 const millisecondsInWeek = 604800000;
14553
14554 /**
14555 * @constant
14556 * @name millisecondsInDay
14557 * @summary Milliseconds in 1 day.
14558 */
14559 const millisecondsInDay = 86400000;
14560
14561 /**
14562 * @constant
14563 * @name millisecondsInMinute
14564 * @summary Milliseconds in 1 minute
14565 */
14566 const millisecondsInMinute = 60000;
14567
14568 /**
14569 * @constant
14570 * @name millisecondsInHour
14571 * @summary Milliseconds in 1 hour
14572 */
14573 const millisecondsInHour = 3600000;
14574
14575 /**
14576 * @constant
14577 * @name millisecondsInSecond
14578 * @summary Milliseconds in 1 second
14579 */
14580 const millisecondsInSecond = 1000;
14581
14582 /**
14583 * @constant
14584 * @name minutesInYear
14585 * @summary Minutes in 1 year.
14586 */
14587 const minutesInYear = 525600;
14588
14589 /**
14590 * @constant
14591 * @name minutesInMonth
14592 * @summary Minutes in 1 month.
14593 */
14594 const minutesInMonth = 43200;
14595
14596 /**
14597 * @constant
14598 * @name minutesInDay
14599 * @summary Minutes in 1 day.
14600 */
14601 const minutesInDay = 1440;
14602
14603 /**
14604 * @constant
14605 * @name minutesInHour
14606 * @summary Minutes in 1 hour.
14607 */
14608 const minutesInHour = 60;
14609
14610 /**
14611 * @constant
14612 * @name monthsInQuarter
14613 * @summary Months in 1 quarter.
14614 */
14615 const monthsInQuarter = 3;
14616
14617 /**
14618 * @constant
14619 * @name monthsInYear
14620 * @summary Months in 1 year.
14621 */
14622 const monthsInYear = 12;
14623
14624 /**
14625 * @constant
14626 * @name quartersInYear
14627 * @summary Quarters in 1 year
14628 */
14629 const quartersInYear = 4;
14630
14631 /**
14632 * @constant
14633 * @name secondsInHour
14634 * @summary Seconds in 1 hour.
14635 */
14636 const secondsInHour = 3600;
14637
14638 /**
14639 * @constant
14640 * @name secondsInMinute
14641 * @summary Seconds in 1 minute.
14642 */
14643 const secondsInMinute = 60;
14644
14645 /**
14646 * @constant
14647 * @name secondsInDay
14648 * @summary Seconds in 1 day.
14649 */
14650 const secondsInDay = secondsInHour * 24;
14651
14652 /**
14653 * @constant
14654 * @name secondsInWeek
14655 * @summary Seconds in 1 week.
14656 */
14657 const secondsInWeek = secondsInDay * 7;
14658
14659 /**
14660 * @constant
14661 * @name secondsInYear
14662 * @summary Seconds in 1 year.
14663 */
14664 const secondsInYear = secondsInDay * daysInYear;
14665
14666 /**
14667 * @constant
14668 * @name secondsInMonth
14669 * @summary Seconds in 1 month
14670 */
14671 const secondsInMonth = secondsInYear / 12;
14672
14673 /**
14674 * @constant
14675 * @name secondsInQuarter
14676 * @summary Seconds in 1 quarter.
14677 */
14678 const secondsInQuarter = secondsInMonth * 3;
14679
14680 ;// CONCATENATED MODULE: ./node_modules/date-fns/parseISO.mjs
14681
14682
14683 /**
14684 * The {@link parseISO} function options.
14685 */
14686
14687 /**
14688 * @name parseISO
14689 * @category Common Helpers
14690 * @summary Parse ISO string
14691 *
14692 * @description
14693 * Parse the given string in ISO 8601 format and return an instance of Date.
14694 *
14695 * Function accepts complete ISO 8601 formats as well as partial implementations.
14696 * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
14697 *
14698 * If the argument isn't a string, the function cannot parse the string or
14699 * the values are invalid, it returns Invalid Date.
14700 *
14701 * @typeParam DateType - The `Date` type, the function operates on. Gets inferred from passed arguments. Allows to use extensions like [`UTCDate`](https://github.com/date-fns/utc).
14702 *
14703 * @param argument - The value to convert
14704 * @param options - An object with options
14705 *
14706 * @returns The parsed date in the local time zone
14707 *
14708 * @example
14709 * // Convert string '2014-02-11T11:30:30' to date:
14710 * const result = parseISO('2014-02-11T11:30:30')
14711 * //=> Tue Feb 11 2014 11:30:30
14712 *
14713 * @example
14714 * // Convert string '+02014101' to date,
14715 * // if the additional number of digits in the extended year format is 1:
14716 * const result = parseISO('+02014101', { additionalDigits: 1 })
14717 * //=> Fri Apr 11 2014 00:00:00
14718 */
14719 function parseISO(argument, options) {
14720 const additionalDigits = options?.additionalDigits ?? 2;
14721 const dateStrings = splitDateString(argument);
14722
14723 let date;
14724 if (dateStrings.date) {
14725 const parseYearResult = parseYear(dateStrings.date, additionalDigits);
14726 date = parseDate(parseYearResult.restDateString, parseYearResult.year);
14727 }
14728
14729 if (!date || isNaN(date.getTime())) {
14730 return new Date(NaN);
14731 }
14732
14733 const timestamp = date.getTime();
14734 let time = 0;
14735 let offset;
14736
14737 if (dateStrings.time) {
14738 time = parseTime(dateStrings.time);
14739 if (isNaN(time)) {
14740 return new Date(NaN);
14741 }
14742 }
14743
14744 if (dateStrings.timezone) {
14745 offset = parseTimezone(dateStrings.timezone);
14746 if (isNaN(offset)) {
14747 return new Date(NaN);
14748 }
14749 } else {
14750 const dirtyDate = new Date(timestamp + time);
14751 // JS parsed string assuming it's in UTC timezone
14752 // but we need it to be parsed in our timezone
14753 // so we use utc values to build date in our timezone.
14754 // Year values from 0 to 99 map to the years 1900 to 1999
14755 // so set year explicitly with setFullYear.
14756 const result = new Date(0);
14757 result.setFullYear(
14758 dirtyDate.getUTCFullYear(),
14759 dirtyDate.getUTCMonth(),
14760 dirtyDate.getUTCDate(),
14761 );
14762 result.setHours(
14763 dirtyDate.getUTCHours(),
14764 dirtyDate.getUTCMinutes(),
14765 dirtyDate.getUTCSeconds(),
14766 dirtyDate.getUTCMilliseconds(),
14767 );
14768 return result;
14769 }
14770
14771 return new Date(timestamp + time + offset);
14772 }
14773
14774 const patterns = {
14775 dateTimeDelimiter: /[T ]/,
14776 timeZoneDelimiter: /[Z ]/i,
14777 timezone: /([Z+-].*)$/,
14778 };
14779
14780 const dateRegex =
14781 /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
14782 const timeRegex =
14783 /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
14784 const timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
14785
14786 function splitDateString(dateString) {
14787 const dateStrings = {};
14788 const array = dateString.split(patterns.dateTimeDelimiter);
14789 let timeString;
14790
14791 // The regex match should only return at maximum two array elements.
14792 // [date], [time], or [date, time].
14793 if (array.length > 2) {
14794 return dateStrings;
14795 }
14796
14797 if (/:/.test(array[0])) {
14798 timeString = array[0];
14799 } else {
14800 dateStrings.date = array[0];
14801 timeString = array[1];
14802 if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
14803 dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
14804 timeString = dateString.substr(
14805 dateStrings.date.length,
14806 dateString.length,
14807 );
14808 }
14809 }
14810
14811 if (timeString) {
14812 const token = patterns.timezone.exec(timeString);
14813 if (token) {
14814 dateStrings.time = timeString.replace(token[1], "");
14815 dateStrings.timezone = token[1];
14816 } else {
14817 dateStrings.time = timeString;
14818 }
14819 }
14820
14821 return dateStrings;
14822 }
14823
14824 function parseYear(dateString, additionalDigits) {
14825 const regex = new RegExp(
14826 "^(?:(\\d{4}|[+-]\\d{" +
14827 (4 + additionalDigits) +
14828 "})|(\\d{2}|[+-]\\d{" +
14829 (2 + additionalDigits) +
14830 "})$)",
14831 );
14832
14833 const captures = dateString.match(regex);
14834 // Invalid ISO-formatted year
14835 if (!captures) return { year: NaN, restDateString: "" };
14836
14837 const year = captures[1] ? parseInt(captures[1]) : null;
14838 const century = captures[2] ? parseInt(captures[2]) : null;
14839
14840 // either year or century is null, not both
14841 return {
14842 year: century === null ? year : century * 100,
14843 restDateString: dateString.slice((captures[1] || captures[2]).length),
14844 };
14845 }
14846
14847 function parseDate(dateString, year) {
14848 // Invalid ISO-formatted year
14849 if (year === null) return new Date(NaN);
14850
14851 const captures = dateString.match(dateRegex);
14852 // Invalid ISO-formatted string
14853 if (!captures) return new Date(NaN);
14854
14855 const isWeekDate = !!captures[4];
14856 const dayOfYear = parseDateUnit(captures[1]);
14857 const month = parseDateUnit(captures[2]) - 1;
14858 const day = parseDateUnit(captures[3]);
14859 const week = parseDateUnit(captures[4]);
14860 const dayOfWeek = parseDateUnit(captures[5]) - 1;
14861
14862 if (isWeekDate) {
14863 if (!validateWeekDate(year, week, dayOfWeek)) {
14864 return new Date(NaN);
14865 }
14866 return dayOfISOWeekYear(year, week, dayOfWeek);
14867 } else {
14868 const date = new Date(0);
14869 if (
14870 !validateDate(year, month, day) ||
14871 !validateDayOfYearDate(year, dayOfYear)
14872 ) {
14873 return new Date(NaN);
14874 }
14875 date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
14876 return date;
14877 }
14878 }
14879
14880 function parseDateUnit(value) {
14881 return value ? parseInt(value) : 1;
14882 }
14883
14884 function parseTime(timeString) {
14885 const captures = timeString.match(timeRegex);
14886 if (!captures) return NaN; // Invalid ISO-formatted time
14887
14888 const hours = parseTimeUnit(captures[1]);
14889 const minutes = parseTimeUnit(captures[2]);
14890 const seconds = parseTimeUnit(captures[3]);
14891
14892 if (!validateTime(hours, minutes, seconds)) {
14893 return NaN;
14894 }
14895
14896 return (
14897 hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1000
14898 );
14899 }
14900
14901 function parseTimeUnit(value) {
14902 return (value && parseFloat(value.replace(",", "."))) || 0;
14903 }
14904
14905 function parseTimezone(timezoneString) {
14906 if (timezoneString === "Z") return 0;
14907
14908 const captures = timezoneString.match(timezoneRegex);
14909 if (!captures) return 0;
14910
14911 const sign = captures[1] === "+" ? -1 : 1;
14912 const hours = parseInt(captures[2]);
14913 const minutes = (captures[3] && parseInt(captures[3])) || 0;
14914
14915 if (!validateTimezone(hours, minutes)) {
14916 return NaN;
14917 }
14918
14919 return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
14920 }
14921
14922 function dayOfISOWeekYear(isoWeekYear, week, day) {
14923 const date = new Date(0);
14924 date.setUTCFullYear(isoWeekYear, 0, 4);
14925 const fourthOfJanuaryDay = date.getUTCDay() || 7;
14926 const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
14927 date.setUTCDate(date.getUTCDate() + diff);
14928 return date;
14929 }
14930
14931 // Validation functions
14932
14933 // February is null to handle the leap year (using ||)
14934 const daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
14935
14936 function isLeapYearIndex(year) {
14937 return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0);
14938 }
14939
14940 function validateDate(year, month, date) {
14941 return (
14942 month >= 0 &&
14943 month <= 11 &&
14944 date >= 1 &&
14945 date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28))
14946 );
14947 }
14948
14949 function validateDayOfYearDate(year, dayOfYear) {
14950 return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
14951 }
14952
14953 function validateWeekDate(_year, week, day) {
14954 return week >= 1 && week <= 53 && day >= 0 && day <= 6;
14955 }
14956
14957 function validateTime(hours, minutes, seconds) {
14958 if (hours === 24) {
14959 return minutes === 0 && seconds === 0;
14960 }
14961
14962 return (
14963 seconds >= 0 &&
14964 seconds < 60 &&
14965 minutes >= 0 &&
14966 minutes < 60 &&
14967 hours >= 0 &&
14968 hours < 25
14969 );
14970 }
14971
14972 function validateTimezone(_hours, minutes) {
14973 return minutes >= 0 && minutes <= 59;
14974 }
14975
14976 // Fallback for modularized imports:
14977 /* harmony default export */ const date_fns_parseISO = ((/* unused pure expression or super */ null && (parseISO)));
14978
14979 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-schedule/index.js
14980 /**
14981 * External dependencies
14982 */
14983
14984
14985 /**
14986 * WordPress dependencies
14987 */
14988
14989
14990
14991
14992
14993
14994 /**
14995 * Internal dependencies
14996 */
14997
14998
14999
15000 const {
15001 PrivatePublishDateTimePicker
15002 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
15003
15004 /**
15005 * Renders the PostSchedule component. It allows the user to schedule a post.
15006 *
15007 * @param {Object} props Props.
15008 * @param {Function} props.onClose Function to close the component.
15009 *
15010 * @return {Component} The component to be rendered.
15011 */
15012 function PostSchedule(props) {
15013 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostSchedule, {
15014 ...props,
15015 showPopoverHeaderActions: true,
15016 isCompact: false
15017 });
15018 }
15019 function PrivatePostSchedule({
15020 onClose,
15021 showPopoverHeaderActions,
15022 isCompact
15023 }) {
15024 const {
15025 postDate,
15026 postType
15027 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
15028 postDate: select(store_store).getEditedPostAttribute('date'),
15029 postType: select(store_store).getCurrentPostType()
15030 }), []);
15031 const {
15032 editPost
15033 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15034 const onUpdateDate = date => editPost({
15035 date
15036 });
15037 const [previewedMonth, setPreviewedMonth] = (0,external_wp_element_namespaceObject.useState)(startOfMonth(new Date(postDate)));
15038
15039 // Pick up published and schduled site posts.
15040 const eventsByPostType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', postType, {
15041 status: 'publish,future',
15042 after: startOfMonth(previewedMonth).toISOString(),
15043 before: endOfMonth(previewedMonth).toISOString(),
15044 exclude: [select(store_store).getCurrentPostId()],
15045 per_page: 100,
15046 _fields: 'id,date'
15047 }), [previewedMonth, postType]);
15048 const events = (0,external_wp_element_namespaceObject.useMemo)(() => (eventsByPostType || []).map(({
15049 date: eventDate
15050 }) => ({
15051 date: new Date(eventDate)
15052 })), [eventsByPostType]);
15053 const settings = (0,external_wp_date_namespaceObject.getSettings)();
15054
15055 // To know if the current timezone is a 12 hour time with look for "a" in the time format
15056 // We also make sure this a is not escaped by a "/"
15057 const is12HourTime = /a(?!\\)/i.test(settings.formats.time.toLowerCase() // Test only the lower case a.
15058 .replace(/\\\\/g, '') // Replace "//" with empty strings.
15059 .split('').reverse().join('') // Reverse the string and test for "a" not followed by a slash.
15060 );
15061 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePublishDateTimePicker, {
15062 currentDate: postDate,
15063 onChange: onUpdateDate,
15064 is12Hour: is12HourTime,
15065 events: events,
15066 onMonthPreviewed: date => setPreviewedMonth(parseISO(date)),
15067 onClose: onClose,
15068 isCompact: isCompact,
15069 showPopoverHeaderActions: showPopoverHeaderActions
15070 });
15071 }
15072
15073 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-schedule/label.js
15074 /**
15075 * WordPress dependencies
15076 */
15077
15078
15079
15080
15081 /**
15082 * Internal dependencies
15083 */
15084
15085
15086 /**
15087 * Renders the PostScheduleLabel component.
15088 *
15089 * @param {Object} props Props.
15090 *
15091 * @return {Component} The component to be rendered.
15092 */
15093 function PostScheduleLabel(props) {
15094 return usePostScheduleLabel(props);
15095 }
15096
15097 /**
15098 * Custom hook to get the label for post schedule.
15099 *
15100 * @param {Object} options Options for the hook.
15101 * @param {boolean} options.full Whether to get the full label or not. Default is false.
15102 *
15103 * @return {string} The label for post schedule.
15104 */
15105 function usePostScheduleLabel({
15106 full = false
15107 } = {}) {
15108 const {
15109 date,
15110 isFloating
15111 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
15112 date: select(store_store).getEditedPostAttribute('date'),
15113 isFloating: select(store_store).isEditedPostDateFloating()
15114 }), []);
15115 return full ? getFullPostScheduleLabel(date) : getPostScheduleLabel(date, {
15116 isFloating
15117 });
15118 }
15119 function getFullPostScheduleLabel(dateAttribute) {
15120 const date = (0,external_wp_date_namespaceObject.getDate)(dateAttribute);
15121 const timezoneAbbreviation = getTimezoneAbbreviation();
15122 const formattedDate = (0,external_wp_date_namespaceObject.dateI18n)(
15123 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
15124 (0,external_wp_i18n_namespaceObject._x)('F j, Y g:i\xa0a', 'post schedule full date format'), date);
15125 return (0,external_wp_i18n_namespaceObject.isRTL)() ? `${timezoneAbbreviation} ${formattedDate}` : `${formattedDate} ${timezoneAbbreviation}`;
15126 }
15127 function getPostScheduleLabel(dateAttribute, {
15128 isFloating = false,
15129 now = new Date()
15130 } = {}) {
15131 if (!dateAttribute || isFloating) {
15132 return (0,external_wp_i18n_namespaceObject.__)('Immediately');
15133 }
15134
15135 // If the user timezone does not equal the site timezone then using words
15136 // like 'tomorrow' is confusing, so show the full date.
15137 if (!isTimezoneSameAsSiteTimezone(now)) {
15138 return getFullPostScheduleLabel(dateAttribute);
15139 }
15140 const date = (0,external_wp_date_namespaceObject.getDate)(dateAttribute);
15141 if (isSameDay(date, now)) {
15142 return (0,external_wp_i18n_namespaceObject.sprintf)(
15143 // translators: %s: Time of day the post is scheduled for.
15144 (0,external_wp_i18n_namespaceObject.__)('Today at %s'),
15145 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
15146 (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_i18n_namespaceObject._x)('g:i\xa0a', 'post schedule time format'), date));
15147 }
15148 const tomorrow = new Date(now);
15149 tomorrow.setDate(tomorrow.getDate() + 1);
15150 if (isSameDay(date, tomorrow)) {
15151 return (0,external_wp_i18n_namespaceObject.sprintf)(
15152 // translators: %s: Time of day the post is scheduled for.
15153 (0,external_wp_i18n_namespaceObject.__)('Tomorrow at %s'),
15154 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
15155 (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_i18n_namespaceObject._x)('g:i\xa0a', 'post schedule time format'), date));
15156 }
15157 if (date.getFullYear() === now.getFullYear()) {
15158 return (0,external_wp_date_namespaceObject.dateI18n)(
15159 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
15160 (0,external_wp_i18n_namespaceObject._x)('F j g:i\xa0a', 'post schedule date format without year'), date);
15161 }
15162 return (0,external_wp_date_namespaceObject.dateI18n)(
15163 // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
15164 (0,external_wp_i18n_namespaceObject._x)('F j, Y g:i\xa0a', 'post schedule full date format'), date);
15165 }
15166 function getTimezoneAbbreviation() {
15167 const {
15168 timezone
15169 } = (0,external_wp_date_namespaceObject.getSettings)();
15170 if (timezone.abbr && isNaN(Number(timezone.abbr))) {
15171 return timezone.abbr;
15172 }
15173 const symbol = timezone.offset < 0 ? '' : '+';
15174 return `UTC${symbol}${timezone.offsetFormatted}`;
15175 }
15176 function isTimezoneSameAsSiteTimezone(date) {
15177 const {
15178 timezone
15179 } = (0,external_wp_date_namespaceObject.getSettings)();
15180 const siteOffset = Number(timezone.offset);
15181 const dateOffset = -1 * (date.getTimezoneOffset() / 60);
15182 return siteOffset === dateOffset;
15183 }
15184 function isSameDay(left, right) {
15185 return left.getDate() === right.getDate() && left.getMonth() === right.getMonth() && left.getFullYear() === right.getFullYear();
15186 }
15187
15188 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/most-used-terms.js
15189 /**
15190 * WordPress dependencies
15191 */
15192
15193
15194
15195
15196 /**
15197 * Internal dependencies
15198 */
15199
15200
15201
15202 const MIN_MOST_USED_TERMS = 3;
15203 const DEFAULT_QUERY = {
15204 per_page: 10,
15205 orderby: 'count',
15206 order: 'desc',
15207 hide_empty: true,
15208 _fields: 'id,name,count',
15209 context: 'view'
15210 };
15211 function MostUsedTerms({
15212 onSelect,
15213 taxonomy
15214 }) {
15215 const {
15216 _terms,
15217 showTerms
15218 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15219 const mostUsedTerms = select(external_wp_coreData_namespaceObject.store).getEntityRecords('taxonomy', taxonomy.slug, DEFAULT_QUERY);
15220 return {
15221 _terms: mostUsedTerms,
15222 showTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS
15223 };
15224 }, [taxonomy.slug]);
15225 if (!showTerms) {
15226 return null;
15227 }
15228 const terms = unescapeTerms(_terms);
15229 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
15230 className: "editor-post-taxonomies__flat-term-most-used",
15231 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.BaseControl.VisualLabel, {
15232 as: "h3",
15233 className: "editor-post-taxonomies__flat-term-most-used-label",
15234 children: taxonomy.labels.most_used
15235 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
15236 role: "list",
15237 className: "editor-post-taxonomies__flat-term-most-used-list",
15238 children: terms.map(term => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
15239 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15240 variant: "link",
15241 onClick: () => onSelect(term),
15242 children: term.name
15243 })
15244 }, term.id))
15245 })]
15246 });
15247 }
15248
15249 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/flat-term-selector.js
15250 /**
15251 * WordPress dependencies
15252 */
15253
15254
15255
15256
15257
15258
15259
15260
15261
15262 /**
15263 * Internal dependencies
15264 */
15265
15266
15267
15268
15269 /**
15270 * Shared reference to an empty array for cases where it is important to avoid
15271 * returning a new array reference on every invocation.
15272 *
15273 * @type {Array<any>}
15274 */
15275
15276
15277
15278 const flat_term_selector_EMPTY_ARRAY = [];
15279
15280 /**
15281 * Module constants
15282 */
15283 const MAX_TERMS_SUGGESTIONS = 20;
15284 const flat_term_selector_DEFAULT_QUERY = {
15285 per_page: MAX_TERMS_SUGGESTIONS,
15286 _fields: 'id,name',
15287 context: 'view'
15288 };
15289 const isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase();
15290 const termNamesToIds = (names, terms) => {
15291 return names.map(termName => terms.find(term => isSameTermName(term.name, termName))?.id).filter(id => id !== undefined);
15292 };
15293 function FlatTermSelector({
15294 slug
15295 }) {
15296 var _taxonomy$labels$add_, _taxonomy$labels$sing2;
15297 const [values, setValues] = (0,external_wp_element_namespaceObject.useState)([]);
15298 const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)('');
15299 const debouncedSearch = (0,external_wp_compose_namespaceObject.useDebounce)(setSearch, 500);
15300 const {
15301 terms,
15302 termIds,
15303 taxonomy,
15304 hasAssignAction,
15305 hasCreateAction,
15306 hasResolvedTerms
15307 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15308 var _post$_links, _post$_links2;
15309 const {
15310 getCurrentPost,
15311 getEditedPostAttribute
15312 } = select(store_store);
15313 const {
15314 getEntityRecords,
15315 getTaxonomy,
15316 hasFinishedResolution
15317 } = select(external_wp_coreData_namespaceObject.store);
15318 const post = getCurrentPost();
15319 const _taxonomy = getTaxonomy(slug);
15320 const _termIds = _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : flat_term_selector_EMPTY_ARRAY;
15321 const query = {
15322 ...flat_term_selector_DEFAULT_QUERY,
15323 include: _termIds.join(','),
15324 per_page: -1
15325 };
15326 return {
15327 hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
15328 hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false,
15329 taxonomy: _taxonomy,
15330 termIds: _termIds,
15331 terms: _termIds.length ? getEntityRecords('taxonomy', slug, query) : flat_term_selector_EMPTY_ARRAY,
15332 hasResolvedTerms: hasFinishedResolution('getEntityRecords', ['taxonomy', slug, query])
15333 };
15334 }, [slug]);
15335 const {
15336 searchResults
15337 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15338 const {
15339 getEntityRecords
15340 } = select(external_wp_coreData_namespaceObject.store);
15341 return {
15342 searchResults: !!search ? getEntityRecords('taxonomy', slug, {
15343 ...flat_term_selector_DEFAULT_QUERY,
15344 search
15345 }) : flat_term_selector_EMPTY_ARRAY
15346 };
15347 }, [search, slug]);
15348
15349 // Update terms state only after the selectors are resolved.
15350 // We're using this to avoid terms temporarily disappearing on slow networks
15351 // while core data makes REST API requests.
15352 (0,external_wp_element_namespaceObject.useEffect)(() => {
15353 if (hasResolvedTerms) {
15354 const newValues = (terms !== null && terms !== void 0 ? terms : []).map(term => unescapeString(term.name));
15355 setValues(newValues);
15356 }
15357 }, [terms, hasResolvedTerms]);
15358 const suggestions = (0,external_wp_element_namespaceObject.useMemo)(() => {
15359 return (searchResults !== null && searchResults !== void 0 ? searchResults : []).map(term => unescapeString(term.name));
15360 }, [searchResults]);
15361 const {
15362 editPost
15363 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15364 const {
15365 saveEntityRecord
15366 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
15367 const {
15368 createErrorNotice
15369 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
15370 if (!hasAssignAction) {
15371 return null;
15372 }
15373 async function findOrCreateTerm(term) {
15374 try {
15375 const newTerm = await saveEntityRecord('taxonomy', slug, term, {
15376 throwOnError: true
15377 });
15378 return unescapeTerm(newTerm);
15379 } catch (error) {
15380 if (error.code !== 'term_exists') {
15381 throw error;
15382 }
15383 return {
15384 id: error.data.term_id,
15385 name: term.name
15386 };
15387 }
15388 }
15389 function onUpdateTerms(newTermIds) {
15390 editPost({
15391 [taxonomy.rest_base]: newTermIds
15392 });
15393 }
15394 function onChange(termNames) {
15395 const availableTerms = [...(terms !== null && terms !== void 0 ? terms : []), ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])];
15396 const uniqueTerms = termNames.reduce((acc, name) => {
15397 if (!acc.some(n => n.toLowerCase() === name.toLowerCase())) {
15398 acc.push(name);
15399 }
15400 return acc;
15401 }, []);
15402 const newTermNames = uniqueTerms.filter(termName => !availableTerms.find(term => isSameTermName(term.name, termName)));
15403
15404 // Optimistically update term values.
15405 // The selector will always re-fetch terms later.
15406 setValues(uniqueTerms);
15407 if (newTermNames.length === 0) {
15408 onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
15409 return;
15410 }
15411 if (!hasCreateAction) {
15412 return;
15413 }
15414 Promise.all(newTermNames.map(termName => findOrCreateTerm({
15415 name: termName
15416 }))).then(newTerms => {
15417 const newAvailableTerms = availableTerms.concat(newTerms);
15418 onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms));
15419 }).catch(error => {
15420 createErrorNotice(error.message, {
15421 type: 'snackbar'
15422 });
15423 // In case of a failure, try assigning available terms.
15424 // This will invalidate the optimistic update.
15425 onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
15426 });
15427 }
15428 function appendTerm(newTerm) {
15429 var _taxonomy$labels$sing;
15430 if (termIds.includes(newTerm.id)) {
15431 return;
15432 }
15433 const newTermIds = [...termIds, newTerm.id];
15434 const defaultName = slug === 'post_tag' ? (0,external_wp_i18n_namespaceObject.__)('Tag') : (0,external_wp_i18n_namespaceObject.__)('Term');
15435 const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */
15436 (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);
15437 (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive');
15438 onUpdateTerms(newTermIds);
15439 }
15440 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');
15441 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');
15442 const termAddedLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */
15443 (0,external_wp_i18n_namespaceObject._x)('%s added', 'term'), singularName);
15444 const termRemovedLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */
15445 (0,external_wp_i18n_namespaceObject._x)('%s removed', 'term'), singularName);
15446 const removeTermLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */
15447 (0,external_wp_i18n_namespaceObject._x)('Remove %s', 'term'), singularName);
15448 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
15449 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FormTokenField, {
15450 __next40pxDefaultSize: true,
15451 value: values,
15452 suggestions: suggestions,
15453 onChange: onChange,
15454 onInputChange: debouncedSearch,
15455 maxSuggestions: MAX_TERMS_SUGGESTIONS,
15456 label: newTermLabel,
15457 messages: {
15458 added: termAddedLabel,
15459 removed: termRemovedLabel,
15460 remove: removeTermLabel
15461 }
15462 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MostUsedTerms, {
15463 taxonomy: taxonomy,
15464 onSelect: appendTerm
15465 })]
15466 });
15467 }
15468 /* harmony default export */ const flat_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(FlatTermSelector));
15469
15470 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/maybe-tags-panel.js
15471 /**
15472 * WordPress dependencies
15473 */
15474
15475
15476
15477
15478
15479
15480 /**
15481 * Internal dependencies
15482 */
15483
15484
15485
15486
15487 const TagsPanel = () => {
15488 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
15489 className: "editor-post-publish-panel__link",
15490 children: (0,external_wp_i18n_namespaceObject.__)('Add tags')
15491 }, "label")];
15492 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
15493 initialOpen: false,
15494 title: panelBodyTitle,
15495 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
15496 children: (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.')
15497 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(flat_term_selector, {
15498 slug: "post_tag"
15499 })]
15500 });
15501 };
15502 const MaybeTagsPanel = () => {
15503 const {
15504 hasTags,
15505 isPostTypeSupported
15506 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15507 const postType = select(store_store).getCurrentPostType();
15508 const tagsTaxonomy = select(external_wp_coreData_namespaceObject.store).getTaxonomy('post_tag');
15509 const _isPostTypeSupported = tagsTaxonomy?.types?.includes(postType);
15510 const areTagsFetched = tagsTaxonomy !== undefined;
15511 const tags = tagsTaxonomy && select(store_store).getEditedPostAttribute(tagsTaxonomy.rest_base);
15512 return {
15513 hasTags: !!tags?.length,
15514 isPostTypeSupported: areTagsFetched && _isPostTypeSupported
15515 };
15516 }, []);
15517 const [hadTagsWhenOpeningThePanel] = (0,external_wp_element_namespaceObject.useState)(hasTags);
15518 if (!isPostTypeSupported) {
15519 return null;
15520 }
15521
15522 /*
15523 * We only want to show the tag panel if the post didn't have
15524 * any tags when the user hit the Publish button.
15525 *
15526 * We can't use the prop.hasTags because it'll change to true
15527 * if the user adds a new tag within the pre-publish panel.
15528 * This would force a re-render and a new prop.hasTags check,
15529 * hiding this panel and keeping the user from adding
15530 * more than one tag.
15531 */
15532 if (!hadTagsWhenOpeningThePanel) {
15533 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TagsPanel, {});
15534 }
15535 return null;
15536 };
15537 /* harmony default export */ const maybe_tags_panel = (MaybeTagsPanel);
15538
15539 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/maybe-post-format-panel.js
15540 /**
15541 * WordPress dependencies
15542 */
15543
15544
15545
15546
15547
15548 /**
15549 * Internal dependencies
15550 */
15551
15552
15553
15554
15555 const getSuggestion = (supportedFormats, suggestedPostFormat) => {
15556 const formats = POST_FORMATS.filter(format => supportedFormats?.includes(format.id));
15557 return formats.find(format => format.id === suggestedPostFormat);
15558 };
15559 const PostFormatSuggestion = ({
15560 suggestedPostFormat,
15561 suggestionText,
15562 onUpdatePostFormat
15563 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15564 variant: "link",
15565 onClick: () => onUpdatePostFormat(suggestedPostFormat),
15566 children: suggestionText
15567 });
15568 function PostFormatPanel() {
15569 const {
15570 currentPostFormat,
15571 suggestion
15572 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15573 var _select$getThemeSuppo;
15574 const {
15575 getEditedPostAttribute,
15576 getSuggestedPostFormat
15577 } = select(store_store);
15578 const supportedFormats = (_select$getThemeSuppo = select(external_wp_coreData_namespaceObject.store).getThemeSupports().formats) !== null && _select$getThemeSuppo !== void 0 ? _select$getThemeSuppo : [];
15579 return {
15580 currentPostFormat: getEditedPostAttribute('format'),
15581 suggestion: getSuggestion(supportedFormats, getSuggestedPostFormat())
15582 };
15583 }, []);
15584 const {
15585 editPost
15586 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15587 const onUpdatePostFormat = format => editPost({
15588 format
15589 });
15590 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
15591 className: "editor-post-publish-panel__link",
15592 children: (0,external_wp_i18n_namespaceObject.__)('Use a post format')
15593 }, "label")];
15594 if (!suggestion || suggestion.id === currentPostFormat) {
15595 return null;
15596 }
15597 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
15598 initialOpen: false,
15599 title: panelBodyTitle,
15600 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
15601 children: (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.')
15602 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
15603 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFormatSuggestion, {
15604 onUpdatePostFormat: onUpdatePostFormat,
15605 suggestedPostFormat: suggestion.id,
15606 suggestionText: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: post format */
15607 (0,external_wp_i18n_namespaceObject.__)('Apply the "%1$s" format.'), suggestion.caption)
15608 })
15609 })]
15610 });
15611 }
15612
15613 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/hierarchical-term-selector.js
15614 /**
15615 * WordPress dependencies
15616 */
15617
15618
15619
15620
15621
15622
15623
15624
15625
15626
15627 /**
15628 * Internal dependencies
15629 */
15630
15631
15632
15633 /**
15634 * Module Constants
15635 */
15636
15637
15638 const hierarchical_term_selector_DEFAULT_QUERY = {
15639 per_page: -1,
15640 orderby: 'name',
15641 order: 'asc',
15642 _fields: 'id,name,parent',
15643 context: 'view'
15644 };
15645 const MIN_TERMS_COUNT_FOR_FILTER = 8;
15646 const hierarchical_term_selector_EMPTY_ARRAY = [];
15647
15648 /**
15649 * Sort Terms by Selected.
15650 *
15651 * @param {Object[]} termsTree Array of terms in tree format.
15652 * @param {number[]} terms Selected terms.
15653 *
15654 * @return {Object[]} Sorted array of terms.
15655 */
15656 function sortBySelected(termsTree, terms) {
15657 const treeHasSelection = termTree => {
15658 if (terms.indexOf(termTree.id) !== -1) {
15659 return true;
15660 }
15661 if (undefined === termTree.children) {
15662 return false;
15663 }
15664 return termTree.children.map(treeHasSelection).filter(child => child).length > 0;
15665 };
15666 const termOrChildIsSelected = (termA, termB) => {
15667 const termASelected = treeHasSelection(termA);
15668 const termBSelected = treeHasSelection(termB);
15669 if (termASelected === termBSelected) {
15670 return 0;
15671 }
15672 if (termASelected && !termBSelected) {
15673 return -1;
15674 }
15675 if (!termASelected && termBSelected) {
15676 return 1;
15677 }
15678 return 0;
15679 };
15680 const newTermTree = [...termsTree];
15681 newTermTree.sort(termOrChildIsSelected);
15682 return newTermTree;
15683 }
15684
15685 /**
15686 * Find term by parent id or name.
15687 *
15688 * @param {Object[]} terms Array of Terms.
15689 * @param {number|string} parent id.
15690 * @param {string} name Term name.
15691 * @return {Object} Term object.
15692 */
15693 function findTerm(terms, parent, name) {
15694 return terms.find(term => {
15695 return (!term.parent && !parent || parseInt(term.parent) === parseInt(parent)) && term.name.toLowerCase() === name.toLowerCase();
15696 });
15697 }
15698
15699 /**
15700 * Get filter matcher function.
15701 *
15702 * @param {string} filterValue Filter value.
15703 * @return {(function(Object): (Object|boolean))} Matcher function.
15704 */
15705 function getFilterMatcher(filterValue) {
15706 const matchTermsForFilter = originalTerm => {
15707 if ('' === filterValue) {
15708 return originalTerm;
15709 }
15710
15711 // Shallow clone, because we'll be filtering the term's children and
15712 // don't want to modify the original term.
15713 const term = {
15714 ...originalTerm
15715 };
15716
15717 // Map and filter the children, recursive so we deal with grandchildren
15718 // and any deeper levels.
15719 if (term.children.length > 0) {
15720 term.children = term.children.map(matchTermsForFilter).filter(child => child);
15721 }
15722
15723 // If the term's name contains the filterValue, or it has children
15724 // (i.e. some child matched at some point in the tree) then return it.
15725 if (-1 !== term.name.toLowerCase().indexOf(filterValue.toLowerCase()) || term.children.length > 0) {
15726 return term;
15727 }
15728
15729 // Otherwise, return false. After mapping, the list of terms will need
15730 // to have false values filtered out.
15731 return false;
15732 };
15733 return matchTermsForFilter;
15734 }
15735
15736 /**
15737 * Hierarchical term selector.
15738 *
15739 * @param {Object} props Component props.
15740 * @param {string} props.slug Taxonomy slug.
15741 * @return {Element} Hierarchical term selector component.
15742 */
15743 function HierarchicalTermSelector({
15744 slug
15745 }) {
15746 var _taxonomy$labels$sear, _taxonomy$name;
15747 const [adding, setAdding] = (0,external_wp_element_namespaceObject.useState)(false);
15748 const [formName, setFormName] = (0,external_wp_element_namespaceObject.useState)('');
15749 /**
15750 * @type {[number|'', Function]}
15751 */
15752 const [formParent, setFormParent] = (0,external_wp_element_namespaceObject.useState)('');
15753 const [showForm, setShowForm] = (0,external_wp_element_namespaceObject.useState)(false);
15754 const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
15755 const [filteredTermsTree, setFilteredTermsTree] = (0,external_wp_element_namespaceObject.useState)([]);
15756 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
15757 const {
15758 hasCreateAction,
15759 hasAssignAction,
15760 terms,
15761 loading,
15762 availableTerms,
15763 taxonomy
15764 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15765 var _post$_links, _post$_links2;
15766 const {
15767 getCurrentPost,
15768 getEditedPostAttribute
15769 } = select(store_store);
15770 const {
15771 getTaxonomy,
15772 getEntityRecords,
15773 isResolving
15774 } = select(external_wp_coreData_namespaceObject.store);
15775 const _taxonomy = getTaxonomy(slug);
15776 const post = getCurrentPost();
15777 return {
15778 hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
15779 hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false,
15780 terms: _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : hierarchical_term_selector_EMPTY_ARRAY,
15781 loading: isResolving('getEntityRecords', ['taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY]),
15782 availableTerms: getEntityRecords('taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY) || hierarchical_term_selector_EMPTY_ARRAY,
15783 taxonomy: _taxonomy
15784 };
15785 }, [slug]);
15786 const {
15787 editPost
15788 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15789 const {
15790 saveEntityRecord
15791 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
15792 const availableTermsTree = (0,external_wp_element_namespaceObject.useMemo)(() => sortBySelected(buildTermsTree(availableTerms), terms),
15793 // Remove `terms` from the dependency list to avoid reordering every time
15794 // checking or unchecking a term.
15795 [availableTerms]);
15796 const {
15797 createErrorNotice
15798 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
15799 if (!hasAssignAction) {
15800 return null;
15801 }
15802
15803 /**
15804 * Append new term.
15805 *
15806 * @param {Object} term Term object.
15807 * @return {Promise} A promise that resolves to save term object.
15808 */
15809 const addTerm = term => {
15810 return saveEntityRecord('taxonomy', slug, term, {
15811 throwOnError: true
15812 });
15813 };
15814
15815 /**
15816 * Update terms for post.
15817 *
15818 * @param {number[]} termIds Term ids.
15819 */
15820 const onUpdateTerms = termIds => {
15821 editPost({
15822 [taxonomy.rest_base]: termIds
15823 });
15824 };
15825
15826 /**
15827 * Handler for checking term.
15828 *
15829 * @param {number} termId
15830 */
15831 const onChange = termId => {
15832 const hasTerm = terms.includes(termId);
15833 const newTerms = hasTerm ? terms.filter(id => id !== termId) : [...terms, termId];
15834 onUpdateTerms(newTerms);
15835 };
15836 const onChangeFormName = value => {
15837 setFormName(value);
15838 };
15839
15840 /**
15841 * Handler for changing form parent.
15842 *
15843 * @param {number|''} parentId Parent post id.
15844 */
15845 const onChangeFormParent = parentId => {
15846 setFormParent(parentId);
15847 };
15848 const onToggleForm = () => {
15849 setShowForm(!showForm);
15850 };
15851 const onAddTerm = async event => {
15852 var _taxonomy$labels$sing;
15853 event.preventDefault();
15854 if (formName === '' || adding) {
15855 return;
15856 }
15857
15858 // Check if the term we are adding already exists.
15859 const existingTerm = findTerm(availableTerms, formParent, formName);
15860 if (existingTerm) {
15861 // If the term we are adding exists but is not selected select it.
15862 if (!terms.some(term => term === existingTerm.id)) {
15863 onUpdateTerms([...terms, existingTerm.id]);
15864 }
15865 setFormName('');
15866 setFormParent('');
15867 return;
15868 }
15869 setAdding(true);
15870 let newTerm;
15871 try {
15872 newTerm = await addTerm({
15873 name: formName,
15874 parent: formParent ? formParent : undefined
15875 });
15876 } catch (error) {
15877 createErrorNotice(error.message, {
15878 type: 'snackbar'
15879 });
15880 return;
15881 }
15882 const defaultName = slug === 'category' ? (0,external_wp_i18n_namespaceObject.__)('Category') : (0,external_wp_i18n_namespaceObject.__)('Term');
15883 const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: taxonomy name */
15884 (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);
15885 (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive');
15886 setAdding(false);
15887 setFormName('');
15888 setFormParent('');
15889 onUpdateTerms([...terms, newTerm.id]);
15890 };
15891 const setFilter = value => {
15892 const newFilteredTermsTree = availableTermsTree.map(getFilterMatcher(value)).filter(term => term);
15893 const getResultCount = termsTree => {
15894 let count = 0;
15895 for (let i = 0; i < termsTree.length; i++) {
15896 count++;
15897 if (undefined !== termsTree[i].children) {
15898 count += getResultCount(termsTree[i].children);
15899 }
15900 }
15901 return count;
15902 };
15903 setFilterValue(value);
15904 setFilteredTermsTree(newFilteredTermsTree);
15905 const resultCount = getResultCount(newFilteredTermsTree);
15906 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of results */
15907 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', resultCount), resultCount);
15908 debouncedSpeak(resultsFoundMessage, 'assertive');
15909 };
15910 const renderTerms = renderedTerms => {
15911 return renderedTerms.map(term => {
15912 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
15913 className: "editor-post-taxonomies__hierarchical-terms-choice",
15914 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
15915 __nextHasNoMarginBottom: true,
15916 checked: terms.indexOf(term.id) !== -1,
15917 onChange: () => {
15918 const termId = parseInt(term.id, 10);
15919 onChange(termId);
15920 },
15921 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(term.name)
15922 }), !!term.children.length && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
15923 className: "editor-post-taxonomies__hierarchical-terms-subchoices",
15924 children: renderTerms(term.children)
15925 })]
15926 }, term.id);
15927 });
15928 };
15929 const labelWithFallback = (labelProperty, fallbackIsCategory, fallbackIsNotCategory) => {
15930 var _taxonomy$labels$labe;
15931 return (_taxonomy$labels$labe = taxonomy?.labels?.[labelProperty]) !== null && _taxonomy$labels$labe !== void 0 ? _taxonomy$labels$labe : slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory;
15932 };
15933 const newTermButtonLabel = labelWithFallback('add_new_item', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term'));
15934 const newTermLabel = labelWithFallback('new_item_name', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term'));
15935 const parentSelectLabel = labelWithFallback('parent_item', (0,external_wp_i18n_namespaceObject.__)('Parent Category'), (0,external_wp_i18n_namespaceObject.__)('Parent Term'));
15936 const noParentOption = `— ${parentSelectLabel} —`;
15937 const newTermSubmitLabel = newTermButtonLabel;
15938 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');
15939 const groupLabel = (_taxonomy$name = taxonomy?.name) !== null && _taxonomy$name !== void 0 ? _taxonomy$name : (0,external_wp_i18n_namespaceObject.__)('Terms');
15940 const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;
15941 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
15942 direction: "column",
15943 gap: "4",
15944 children: [showFilter && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
15945 __nextHasNoMarginBottom: true,
15946 label: filterLabel,
15947 value: filterValue,
15948 onChange: setFilter
15949 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
15950 className: "editor-post-taxonomies__hierarchical-terms-list",
15951 tabIndex: "0",
15952 role: "group",
15953 "aria-label": groupLabel,
15954 children: renderTerms('' !== filterValue ? filteredTermsTree : availableTermsTree)
15955 }), !loading && hasCreateAction && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
15956 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15957 onClick: onToggleForm,
15958 className: "editor-post-taxonomies__hierarchical-terms-add",
15959 "aria-expanded": showForm,
15960 variant: "link",
15961 children: newTermButtonLabel
15962 })
15963 }), showForm && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
15964 onSubmit: onAddTerm,
15965 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
15966 direction: "column",
15967 gap: "4",
15968 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
15969 __next40pxDefaultSize: true,
15970 __nextHasNoMarginBottom: true,
15971 className: "editor-post-taxonomies__hierarchical-terms-input",
15972 label: newTermLabel,
15973 value: formName,
15974 onChange: onChangeFormName,
15975 required: true
15976 }), !!availableTerms.length && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TreeSelect, {
15977 __next40pxDefaultSize: true,
15978 __nextHasNoMarginBottom: true,
15979 label: parentSelectLabel,
15980 noOptionLabel: noParentOption,
15981 onChange: onChangeFormParent,
15982 selectedId: formParent,
15983 tree: availableTermsTree
15984 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
15985 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15986 __next40pxDefaultSize: true,
15987 variant: "secondary",
15988 type: "submit",
15989 className: "editor-post-taxonomies__hierarchical-terms-submit",
15990 children: newTermSubmitLabel
15991 })
15992 })]
15993 })
15994 })]
15995 });
15996 }
15997 /* harmony default export */ const hierarchical_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(HierarchicalTermSelector));
15998
15999 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/maybe-category-panel.js
16000 /**
16001 * WordPress dependencies
16002 */
16003
16004
16005
16006
16007
16008
16009 /**
16010 * Internal dependencies
16011 */
16012
16013
16014
16015
16016 function MaybeCategoryPanel() {
16017 const hasNoCategory = (0,external_wp_data_namespaceObject.useSelect)(select => {
16018 const postType = select(store_store).getCurrentPostType();
16019 const {
16020 canUser,
16021 getEntityRecord,
16022 getTaxonomy
16023 } = select(external_wp_coreData_namespaceObject.store);
16024 const categoriesTaxonomy = getTaxonomy('category');
16025 const defaultCategoryId = canUser('read', 'settings') ? getEntityRecord('root', 'site')?.default_category : undefined;
16026 const defaultCategory = defaultCategoryId ? getEntityRecord('taxonomy', 'category', defaultCategoryId) : undefined;
16027 const postTypeSupportsCategories = categoriesTaxonomy && categoriesTaxonomy.types.some(type => type === postType);
16028 const categories = categoriesTaxonomy && select(store_store).getEditedPostAttribute(categoriesTaxonomy.rest_base);
16029
16030 // This boolean should return true if everything is loaded
16031 // ( categoriesTaxonomy, defaultCategory )
16032 // and the post has not been assigned a category different than "uncategorized".
16033 return !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && (categories?.length === 0 || categories?.length === 1 && defaultCategory?.id === categories[0]);
16034 }, []);
16035 const [shouldShowPanel, setShouldShowPanel] = (0,external_wp_element_namespaceObject.useState)(false);
16036 (0,external_wp_element_namespaceObject.useEffect)(() => {
16037 // We use state to avoid hiding the panel if the user edits the categories
16038 // and adds one within the panel itself (while visible).
16039 if (hasNoCategory) {
16040 setShouldShowPanel(true);
16041 }
16042 }, [hasNoCategory]);
16043 if (!shouldShowPanel) {
16044 return null;
16045 }
16046 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16047 className: "editor-post-publish-panel__link",
16048 children: (0,external_wp_i18n_namespaceObject.__)('Assign a category')
16049 }, "label")];
16050 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
16051 initialOpen: false,
16052 title: panelBodyTitle,
16053 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
16054 children: (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.')
16055 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(hierarchical_term_selector, {
16056 slug: "category"
16057 })]
16058 });
16059 }
16060 /* harmony default export */ const maybe_category_panel = (MaybeCategoryPanel);
16061
16062 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/maybe-upload-media.js
16063 /**
16064 * WordPress dependencies
16065 */
16066
16067
16068
16069
16070
16071
16072
16073 /**
16074 * Internal dependencies
16075 */
16076
16077
16078
16079 function flattenBlocks(blocks) {
16080 const result = [];
16081 blocks.forEach(block => {
16082 result.push(block);
16083 result.push(...flattenBlocks(block.innerBlocks));
16084 });
16085 return result;
16086 }
16087 function Image(block) {
16088 const {
16089 selectBlock
16090 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
16091 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.img, {
16092 tabIndex: 0,
16093 role: "button",
16094 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Select image block.'),
16095 onClick: () => {
16096 selectBlock(block.clientId);
16097 },
16098 onKeyDown: event => {
16099 if (event.key === 'Enter' || event.key === ' ') {
16100 selectBlock(block.clientId);
16101 event.preventDefault();
16102 }
16103 },
16104 alt: block.attributes.alt,
16105 src: block.attributes.url,
16106 animate: {
16107 opacity: 1
16108 },
16109 exit: {
16110 opacity: 0,
16111 scale: 0
16112 },
16113 style: {
16114 width: '36px',
16115 height: '36px',
16116 objectFit: 'cover',
16117 borderRadius: '2px',
16118 cursor: 'pointer'
16119 },
16120 whileHover: {
16121 scale: 1.08
16122 }
16123 }, block.clientId);
16124 }
16125 function maybe_upload_media_PostFormatPanel() {
16126 const [isUploading, setIsUploading] = (0,external_wp_element_namespaceObject.useState)(false);
16127 const {
16128 editorBlocks,
16129 mediaUpload
16130 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
16131 editorBlocks: select(store_store).getEditorBlocks(),
16132 mediaUpload: select(external_wp_blockEditor_namespaceObject.store).getSettings().mediaUpload
16133 }), []);
16134 const externalImages = flattenBlocks(editorBlocks).filter(block => block.name === 'core/image' && block.attributes.url && !block.attributes.id);
16135 const {
16136 updateBlockAttributes
16137 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
16138 if (!mediaUpload || !externalImages.length) {
16139 return null;
16140 }
16141 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16142 className: "editor-post-publish-panel__link",
16143 children: (0,external_wp_i18n_namespaceObject.__)('External media')
16144 }, "label")];
16145 function uploadImages() {
16146 setIsUploading(true);
16147 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) => {
16148 mediaUpload({
16149 filesList: [blob],
16150 onFileChange: ([media]) => {
16151 if ((0,external_wp_blob_namespaceObject.isBlobURL)(media.url)) {
16152 return;
16153 }
16154 updateBlockAttributes(image.clientId, {
16155 id: media.id,
16156 url: media.url
16157 });
16158 resolve();
16159 },
16160 onError() {
16161 reject();
16162 }
16163 });
16164 })))).finally(() => {
16165 setIsUploading(false);
16166 });
16167 }
16168 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
16169 initialOpen: true,
16170 title: panelBodyTitle,
16171 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
16172 children: (0,external_wp_i18n_namespaceObject.__)('Upload external images to the Media Library. Images from different domains may load slowly, display incorrectly, or be removed unexpectedly.')
16173 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16174 style: {
16175 display: 'inline-flex',
16176 flexWrap: 'wrap',
16177 gap: '8px'
16178 },
16179 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
16180 children: externalImages.map(image => {
16181 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Image, {
16182 ...image
16183 }, image.clientId);
16184 })
16185 }), isUploading ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16186 variant: "primary",
16187 onClick: uploadImages,
16188 children: (0,external_wp_i18n_namespaceObject.__)('Upload')
16189 })]
16190 })]
16191 });
16192 }
16193
16194 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/prepublish.js
16195 /**
16196 * WordPress dependencies
16197 */
16198
16199
16200
16201
16202
16203
16204
16205
16206 /**
16207 * Internal dependencies
16208 */
16209
16210
16211
16212
16213
16214
16215
16216
16217
16218
16219
16220
16221 function PostPublishPanelPrepublish({
16222 children
16223 }) {
16224 const {
16225 isBeingScheduled,
16226 isRequestingSiteIcon,
16227 hasPublishAction,
16228 siteIconUrl,
16229 siteTitle,
16230 siteHome
16231 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16232 var _getCurrentPost$_link;
16233 const {
16234 getCurrentPost,
16235 isEditedPostBeingScheduled
16236 } = select(store_store);
16237 const {
16238 getEntityRecord,
16239 isResolving
16240 } = select(external_wp_coreData_namespaceObject.store);
16241 const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
16242 return {
16243 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
16244 isBeingScheduled: isEditedPostBeingScheduled(),
16245 isRequestingSiteIcon: isResolving('getEntityRecord', ['root', '__unstableBase', undefined]),
16246 siteIconUrl: siteData.site_icon_url,
16247 siteTitle: siteData.name,
16248 siteHome: siteData.home && (0,external_wp_url_namespaceObject.filterURLForDisplay)(siteData.home)
16249 };
16250 }, []);
16251 let siteIcon = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
16252 className: "components-site-icon",
16253 size: "36px",
16254 icon: library_wordpress
16255 });
16256 if (siteIconUrl) {
16257 siteIcon = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
16258 alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'),
16259 className: "components-site-icon",
16260 src: siteIconUrl
16261 });
16262 }
16263 if (isRequestingSiteIcon) {
16264 siteIcon = null;
16265 }
16266 let prePublishTitle, prePublishBodyText;
16267 if (!hasPublishAction) {
16268 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to submit for review?');
16269 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.');
16270 } else if (isBeingScheduled) {
16271 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to schedule?');
16272 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Your work will be published at the specified date and time.');
16273 } else {
16274 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to publish?');
16275 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Double-check your settings before publishing.');
16276 }
16277 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16278 className: "editor-post-publish-panel__prepublish",
16279 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16280 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
16281 children: prePublishTitle
16282 })
16283 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
16284 children: prePublishBodyText
16285 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16286 className: "components-site-card",
16287 children: [siteIcon, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16288 className: "components-site-info",
16289 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16290 className: "components-site-name",
16291 children: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle) || (0,external_wp_i18n_namespaceObject.__)('(Untitled)')
16292 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16293 className: "components-site-home",
16294 children: siteHome
16295 })]
16296 })]
16297 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(maybe_upload_media_PostFormatPanel, {}), hasPublishAction && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16298 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
16299 initialOpen: false,
16300 title: [(0,external_wp_i18n_namespaceObject.__)('Visibility:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16301 className: "editor-post-publish-panel__link",
16302 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityLabel, {})
16303 }, "label")],
16304 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibility, {})
16305 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
16306 initialOpen: false,
16307 title: [(0,external_wp_i18n_namespaceObject.__)('Publish:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16308 className: "editor-post-publish-panel__link",
16309 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostScheduleLabel, {})
16310 }, "label")],
16311 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSchedule, {})
16312 })]
16313 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFormatPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(maybe_tags_panel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(maybe_category_panel, {}), children]
16314 });
16315 }
16316 /* harmony default export */ const prepublish = (PostPublishPanelPrepublish);
16317
16318 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/postpublish.js
16319 /**
16320 * WordPress dependencies
16321 */
16322
16323
16324
16325
16326
16327
16328
16329
16330
16331 /**
16332 * Internal dependencies
16333 */
16334
16335
16336
16337
16338
16339 const POSTNAME = '%postname%';
16340 const PAGENAME = '%pagename%';
16341
16342 /**
16343 * Returns URL for a future post.
16344 *
16345 * @param {Object} post Post object.
16346 *
16347 * @return {string} PostPublish URL.
16348 */
16349
16350 const getFuturePostUrl = post => {
16351 const {
16352 slug
16353 } = post;
16354 if (post.permalink_template.includes(POSTNAME)) {
16355 return post.permalink_template.replace(POSTNAME, slug);
16356 }
16357 if (post.permalink_template.includes(PAGENAME)) {
16358 return post.permalink_template.replace(PAGENAME, slug);
16359 }
16360 return post.permalink_template;
16361 };
16362 function postpublish_CopyButton({
16363 text,
16364 onCopy,
16365 children
16366 }) {
16367 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text, onCopy);
16368 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16369 variant: "secondary",
16370 ref: ref,
16371 children: children
16372 });
16373 }
16374 class PostPublishPanelPostpublish extends external_wp_element_namespaceObject.Component {
16375 constructor() {
16376 super(...arguments);
16377 this.state = {
16378 showCopyConfirmation: false
16379 };
16380 this.onCopy = this.onCopy.bind(this);
16381 this.onSelectInput = this.onSelectInput.bind(this);
16382 this.postLink = (0,external_wp_element_namespaceObject.createRef)();
16383 }
16384 componentDidMount() {
16385 if (this.props.focusOnMount) {
16386 this.postLink.current.focus();
16387 }
16388 }
16389 componentWillUnmount() {
16390 clearTimeout(this.dismissCopyConfirmation);
16391 }
16392 onCopy() {
16393 this.setState({
16394 showCopyConfirmation: true
16395 });
16396 clearTimeout(this.dismissCopyConfirmation);
16397 this.dismissCopyConfirmation = setTimeout(() => {
16398 this.setState({
16399 showCopyConfirmation: false
16400 });
16401 }, 4000);
16402 }
16403 onSelectInput(event) {
16404 event.target.select();
16405 }
16406 render() {
16407 const {
16408 children,
16409 isScheduled,
16410 post,
16411 postType
16412 } = this.props;
16413 const postLabel = postType?.labels?.singular_name;
16414 const viewPostLabel = postType?.labels?.view_item;
16415 const addNewPostLabel = postType?.labels?.add_new_item;
16416 const link = post.status === 'future' ? getFuturePostUrl(post) : post.link;
16417 const addLink = (0,external_wp_url_namespaceObject.addQueryArgs)('post-new.php', {
16418 post_type: post.type
16419 });
16420 const postPublishNonLinkHeader = isScheduled ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16421 children: [(0,external_wp_i18n_namespaceObject.__)('is now scheduled. It will go live on'), ' ', /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostScheduleLabel, {}), "."]
16422 }) : (0,external_wp_i18n_namespaceObject.__)('is now live.');
16423 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16424 className: "post-publish-panel__postpublish",
16425 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
16426 className: "post-publish-panel__postpublish-header",
16427 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("a", {
16428 ref: this.postLink,
16429 href: link,
16430 children: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title) || (0,external_wp_i18n_namespaceObject.__)('(no title)')
16431 }), ' ', postPublishNonLinkHeader]
16432 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
16433 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
16434 className: "post-publish-panel__postpublish-subheader",
16435 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
16436 children: (0,external_wp_i18n_namespaceObject.__)('What’s next?')
16437 })
16438 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16439 className: "post-publish-panel__postpublish-post-address-container",
16440 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
16441 __nextHasNoMarginBottom: true,
16442 className: "post-publish-panel__postpublish-post-address",
16443 readOnly: true,
16444 label: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: post type singular name */
16445 (0,external_wp_i18n_namespaceObject.__)('%s address'), postLabel),
16446 value: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(link),
16447 onFocus: this.onSelectInput
16448 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16449 className: "post-publish-panel__postpublish-post-address__copy-button-wrap",
16450 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(postpublish_CopyButton, {
16451 text: link,
16452 onCopy: this.onCopy,
16453 children: this.state.showCopyConfirmation ? (0,external_wp_i18n_namespaceObject.__)('Copied!') : (0,external_wp_i18n_namespaceObject.__)('Copy')
16454 })
16455 })]
16456 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16457 className: "post-publish-panel__postpublish-buttons",
16458 children: [!isScheduled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16459 variant: "primary",
16460 href: link,
16461 children: viewPostLabel
16462 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16463 variant: isScheduled ? 'primary' : 'secondary',
16464 href: addLink,
16465 children: addNewPostLabel
16466 })]
16467 })]
16468 }), children]
16469 });
16470 }
16471 }
16472 /* harmony default export */ const postpublish = ((0,external_wp_data_namespaceObject.withSelect)(select => {
16473 const {
16474 getEditedPostAttribute,
16475 getCurrentPost,
16476 isCurrentPostScheduled
16477 } = select(store_store);
16478 const {
16479 getPostType
16480 } = select(external_wp_coreData_namespaceObject.store);
16481 return {
16482 post: getCurrentPost(),
16483 postType: getPostType(getEditedPostAttribute('type')),
16484 isScheduled: isCurrentPostScheduled()
16485 };
16486 })(PostPublishPanelPostpublish));
16487
16488 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/index.js
16489 /**
16490 * WordPress dependencies
16491 */
16492
16493
16494
16495
16496
16497
16498
16499
16500 /**
16501 * Internal dependencies
16502 */
16503
16504
16505
16506
16507
16508
16509
16510 class PostPublishPanel extends external_wp_element_namespaceObject.Component {
16511 constructor() {
16512 super(...arguments);
16513 this.onSubmit = this.onSubmit.bind(this);
16514 }
16515 componentDidUpdate(prevProps) {
16516 // Automatically collapse the publish sidebar when a post
16517 // is published and the user makes an edit.
16518 if (prevProps.isPublished && !this.props.isSaving && this.props.isDirty) {
16519 this.props.onClose();
16520 }
16521 }
16522 onSubmit() {
16523 const {
16524 onClose,
16525 hasPublishAction,
16526 isPostTypeViewable
16527 } = this.props;
16528 if (!hasPublishAction || !isPostTypeViewable) {
16529 onClose();
16530 }
16531 }
16532 render() {
16533 const {
16534 forceIsDirty,
16535 isBeingScheduled,
16536 isPublished,
16537 isPublishSidebarEnabled,
16538 isScheduled,
16539 isSaving,
16540 isSavingNonPostEntityChanges,
16541 onClose,
16542 onTogglePublishSidebar,
16543 PostPublishExtension,
16544 PrePublishExtension,
16545 ...additionalProps
16546 } = this.props;
16547 const {
16548 hasPublishAction,
16549 isDirty,
16550 isPostTypeViewable,
16551 ...propsForPanel
16552 } = additionalProps;
16553 const isPublishedOrScheduled = isPublished || isScheduled && isBeingScheduled;
16554 const isPrePublish = !isPublishedOrScheduled && !isSaving;
16555 const isPostPublish = isPublishedOrScheduled && !isSaving;
16556 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16557 className: "editor-post-publish-panel",
16558 ...propsForPanel,
16559 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16560 className: "editor-post-publish-panel__header",
16561 children: isPostPublish ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16562 onClick: onClose,
16563 icon: close_small,
16564 label: (0,external_wp_i18n_namespaceObject.__)('Close panel')
16565 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16566 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16567 className: "editor-post-publish-panel__header-publish-button",
16568 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_button, {
16569 focusOnMount: true,
16570 onSubmit: this.onSubmit,
16571 forceIsDirty: forceIsDirty
16572 })
16573 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16574 className: "editor-post-publish-panel__header-cancel-button",
16575 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16576 disabled: isSavingNonPostEntityChanges,
16577 onClick: onClose,
16578 variant: "secondary",
16579 size: "compact",
16580 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
16581 })
16582 })]
16583 })
16584 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16585 className: "editor-post-publish-panel__content",
16586 children: [isPrePublish && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(prepublish, {
16587 children: PrePublishExtension && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrePublishExtension, {})
16588 }), isPostPublish && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(postpublish, {
16589 focusOnMount: true,
16590 children: PostPublishExtension && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPublishExtension, {})
16591 }), isSaving && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {})]
16592 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16593 className: "editor-post-publish-panel__footer",
16594 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
16595 __nextHasNoMarginBottom: true,
16596 label: (0,external_wp_i18n_namespaceObject.__)('Always show pre-publish checks.'),
16597 checked: isPublishSidebarEnabled,
16598 onChange: onTogglePublishSidebar
16599 })
16600 })]
16601 });
16602 }
16603 }
16604 /* harmony default export */ const post_publish_panel = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
16605 var _getCurrentPost$_link;
16606 const {
16607 getPostType
16608 } = select(external_wp_coreData_namespaceObject.store);
16609 const {
16610 getCurrentPost,
16611 getEditedPostAttribute,
16612 isCurrentPostPublished,
16613 isCurrentPostScheduled,
16614 isEditedPostBeingScheduled,
16615 isEditedPostDirty,
16616 isAutosavingPost,
16617 isSavingPost,
16618 isSavingNonPostEntityChanges
16619 } = select(store_store);
16620 const {
16621 isPublishSidebarEnabled
16622 } = select(store_store);
16623 const postType = getPostType(getEditedPostAttribute('type'));
16624 return {
16625 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
16626 isPostTypeViewable: postType?.viewable,
16627 isBeingScheduled: isEditedPostBeingScheduled(),
16628 isDirty: isEditedPostDirty(),
16629 isPublished: isCurrentPostPublished(),
16630 isPublishSidebarEnabled: isPublishSidebarEnabled(),
16631 isSaving: isSavingPost() && !isAutosavingPost(),
16632 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges(),
16633 isScheduled: isCurrentPostScheduled()
16634 };
16635 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
16636 isPublishSidebarEnabled
16637 }) => {
16638 const {
16639 disablePublishSidebar,
16640 enablePublishSidebar
16641 } = dispatch(store_store);
16642 return {
16643 onTogglePublishSidebar: () => {
16644 if (isPublishSidebarEnabled) {
16645 disablePublishSidebar();
16646 } else {
16647 enablePublishSidebar();
16648 }
16649 }
16650 };
16651 }), external_wp_components_namespaceObject.withFocusReturn, external_wp_components_namespaceObject.withConstrainedTabbing])(PostPublishPanel));
16652
16653 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/cloud-upload.js
16654 /**
16655 * WordPress dependencies
16656 */
16657
16658
16659 const cloudUpload = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
16660 xmlns: "http://www.w3.org/2000/svg",
16661 viewBox: "0 0 24 24",
16662 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
16663 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"
16664 })
16665 });
16666 /* harmony default export */ const cloud_upload = (cloudUpload);
16667
16668 ;// CONCATENATED MODULE: ./packages/icons/build-module/icon/index.js
16669 /**
16670 * WordPress dependencies
16671 */
16672
16673
16674 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
16675
16676 /**
16677 * Return an SVG icon.
16678 *
16679 * @param {IconProps} props icon is the SVG component to render
16680 * size is a number specifiying the icon size in pixels
16681 * Other props will be passed to wrapped SVG component
16682 * @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element.
16683 *
16684 * @return {JSX.Element} Icon component
16685 */
16686 function Icon({
16687 icon,
16688 size = 24,
16689 ...props
16690 }, ref) {
16691 return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
16692 width: size,
16693 height: size,
16694 ...props,
16695 ref
16696 });
16697 }
16698 /* harmony default export */ const icon = ((0,external_wp_element_namespaceObject.forwardRef)(Icon));
16699
16700 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/cloud.js
16701 /**
16702 * WordPress dependencies
16703 */
16704
16705
16706 const cloud = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
16707 xmlns: "http://www.w3.org/2000/svg",
16708 viewBox: "0 0 24 24",
16709 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
16710 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"
16711 })
16712 });
16713 /* harmony default export */ const library_cloud = (cloud);
16714
16715 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-saved-state/index.js
16716 /**
16717 * External dependencies
16718 */
16719
16720
16721 /**
16722 * WordPress dependencies
16723 */
16724
16725
16726
16727
16728
16729
16730
16731
16732
16733 /**
16734 * Internal dependencies
16735 */
16736
16737
16738 /**
16739 * Component showing whether the post is saved or not and providing save
16740 * buttons.
16741 *
16742 * @param {Object} props Component props.
16743 * @param {?boolean} props.forceIsDirty Whether to force the post to be marked
16744 * as dirty.
16745 * @return {import('react').ComponentType} The component.
16746 */
16747
16748
16749 function PostSavedState({
16750 forceIsDirty
16751 }) {
16752 const [forceSavedMessage, setForceSavedMessage] = (0,external_wp_element_namespaceObject.useState)(false);
16753 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small');
16754 const {
16755 isAutosaving,
16756 isDirty,
16757 isNew,
16758 isPublished,
16759 isSaveable,
16760 isSaving,
16761 isScheduled,
16762 hasPublishAction,
16763 showIconLabels,
16764 postStatus,
16765 postStatusHasChanged
16766 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16767 var _getCurrentPost$_link;
16768 const {
16769 isEditedPostNew,
16770 isCurrentPostPublished,
16771 isCurrentPostScheduled,
16772 isEditedPostDirty,
16773 isSavingPost,
16774 isEditedPostSaveable,
16775 getCurrentPost,
16776 isAutosavingPost,
16777 getEditedPostAttribute,
16778 getPostEdits
16779 } = select(store_store);
16780 const {
16781 get
16782 } = select(external_wp_preferences_namespaceObject.store);
16783 return {
16784 isAutosaving: isAutosavingPost(),
16785 isDirty: forceIsDirty || isEditedPostDirty(),
16786 isNew: isEditedPostNew(),
16787 isPublished: isCurrentPostPublished(),
16788 isSaving: isSavingPost(),
16789 isSaveable: isEditedPostSaveable(),
16790 isScheduled: isCurrentPostScheduled(),
16791 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()?._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
16792 showIconLabels: get('core', 'showIconLabels'),
16793 postStatus: getEditedPostAttribute('status'),
16794 postStatusHasChanged: !!getPostEdits()?.status
16795 };
16796 }, [forceIsDirty]);
16797 const isPending = postStatus === 'pending';
16798 const {
16799 savePost
16800 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
16801 const wasSaving = (0,external_wp_compose_namespaceObject.usePrevious)(isSaving);
16802 (0,external_wp_element_namespaceObject.useEffect)(() => {
16803 let timeoutId;
16804 if (wasSaving && !isSaving) {
16805 setForceSavedMessage(true);
16806 timeoutId = setTimeout(() => {
16807 setForceSavedMessage(false);
16808 }, 1000);
16809 }
16810 return () => clearTimeout(timeoutId);
16811 }, [isSaving]);
16812
16813 // Once the post has been submitted for review this button
16814 // is not needed for the contributor role.
16815 if (!hasPublishAction && isPending) {
16816 return null;
16817 }
16818 if (isPublished || isScheduled || !['pending', 'draft', 'auto-draft'].includes(postStatus) || postStatusHasChanged && ['pending', 'draft'].includes(postStatus)) {
16819 return null;
16820 }
16821
16822 /* translators: button label text should, if possible, be under 16 characters. */
16823 const label = isPending ? (0,external_wp_i18n_namespaceObject.__)('Save as pending') : (0,external_wp_i18n_namespaceObject.__)('Save draft');
16824
16825 /* translators: button label text should, if possible, be under 16 characters. */
16826 const shortLabel = (0,external_wp_i18n_namespaceObject.__)('Save');
16827 const isSaved = forceSavedMessage || !isNew && !isDirty;
16828 const isSavedState = isSaving || isSaved;
16829 const isDisabled = isSaving || isSaved || !isSaveable;
16830 let text;
16831 if (isSaving) {
16832 text = isAutosaving ? (0,external_wp_i18n_namespaceObject.__)('Autosaving') : (0,external_wp_i18n_namespaceObject.__)('Saving');
16833 } else if (isSaved) {
16834 text = (0,external_wp_i18n_namespaceObject.__)('Saved');
16835 } else if (isLargeViewport) {
16836 text = label;
16837 } else if (showIconLabels) {
16838 text = shortLabel;
16839 }
16840
16841 // Use common Button instance for all saved states so that focus is not
16842 // lost.
16843 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
16844 className: isSaveable || isSaving ? dist_clsx({
16845 'editor-post-save-draft': !isSavedState,
16846 'editor-post-saved-state': isSavedState,
16847 'is-saving': isSaving,
16848 'is-autosaving': isAutosaving,
16849 'is-saved': isSaved,
16850 [(0,external_wp_components_namespaceObject.__unstableGetAnimateClassName)({
16851 type: 'loading'
16852 })]: isSaving
16853 }) : undefined,
16854 onClick: isDisabled ? undefined : () => savePost()
16855 /*
16856 * We want the tooltip to show the keyboard shortcut only when the
16857 * button does something, i.e. when it's not disabled.
16858 */,
16859 shortcut: isDisabled ? undefined : external_wp_keycodes_namespaceObject.displayShortcut.primary('s'),
16860 variant: "tertiary",
16861 size: "compact",
16862 icon: isLargeViewport ? undefined : cloud_upload,
16863 label: text || label,
16864 "aria-disabled": isDisabled,
16865 children: [isSavedState && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(icon, {
16866 icon: isSaved ? library_check : library_cloud
16867 }), text]
16868 });
16869 }
16870
16871 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-schedule/check.js
16872 /**
16873 * WordPress dependencies
16874 */
16875
16876
16877 /**
16878 * Internal dependencies
16879 */
16880
16881
16882 /**
16883 * Wrapper component that renders its children only if post has a publish action.
16884 *
16885 * @param {Object} props Props.
16886 * @param {Element} props.children Children to be rendered.
16887 *
16888 * @return {Component} - The component to be rendered or null if there is no publish action.
16889 */
16890 function PostScheduleCheck({
16891 children
16892 }) {
16893 const hasPublishAction = (0,external_wp_data_namespaceObject.useSelect)(select => {
16894 var _select$getCurrentPos;
16895 return (_select$getCurrentPos = select(store_store).getCurrentPost()._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false;
16896 }, []);
16897 if (!hasPublishAction) {
16898 return null;
16899 }
16900 return children;
16901 }
16902
16903 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-schedule/panel.js
16904 /**
16905 * WordPress dependencies
16906 */
16907
16908
16909
16910
16911
16912 /**
16913 * Internal dependencies
16914 */
16915
16916
16917
16918
16919
16920
16921
16922 const DESIGN_POST_TYPES = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE, NAVIGATION_POST_TYPE];
16923
16924 /**
16925 * Renders the Post Schedule Panel component.
16926 *
16927 * @return {Component} The component to be rendered.
16928 */
16929 function PostSchedulePanel() {
16930 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
16931 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
16932 // Memoize popoverProps to avoid returning a new object every time.
16933 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
16934 // Anchor the popover to the middle of the entire row so that it doesn't
16935 // move around when the label changes.
16936 anchor: popoverAnchor,
16937 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Change publish date'),
16938 placement: 'left-start',
16939 offset: 36,
16940 shift: true
16941 }), [popoverAnchor]);
16942 const label = usePostScheduleLabel();
16943 const fullLabel = usePostScheduleLabel({
16944 full: true
16945 });
16946 if (DESIGN_POST_TYPES.includes(postType)) {
16947 return null;
16948 }
16949 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostScheduleCheck, {
16950 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
16951 label: (0,external_wp_i18n_namespaceObject.__)('Publish'),
16952 ref: setPopoverAnchor,
16953 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
16954 popoverProps: popoverProps,
16955 focusOnMount: true,
16956 className: "editor-post-schedule__panel-dropdown",
16957 contentClassName: "editor-post-schedule__dialog",
16958 renderToggle: ({
16959 onToggle,
16960 isOpen
16961 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16962 size: "compact",
16963 className: "editor-post-schedule__dialog-toggle",
16964 variant: "tertiary",
16965 tooltipPosition: "middle left",
16966 onClick: onToggle,
16967 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
16968 // translators: %s: Current post date.
16969 (0,external_wp_i18n_namespaceObject.__)('Change date: %s'), label),
16970 label: fullLabel,
16971 showTooltip: label !== fullLabel,
16972 "aria-expanded": isOpen,
16973 children: label
16974 }),
16975 renderContent: ({
16976 onClose
16977 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSchedule, {
16978 onClose: onClose
16979 })
16980 })
16981 })
16982 });
16983 }
16984
16985 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-slug/check.js
16986 /**
16987 * Internal dependencies
16988 */
16989
16990
16991 function PostSlugCheck({
16992 children
16993 }) {
16994 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
16995 supportKeys: "slug",
16996 children: children
16997 });
16998 }
16999
17000 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-slug/index.js
17001 /**
17002 * WordPress dependencies
17003 */
17004
17005
17006
17007
17008
17009
17010 /**
17011 * Internal dependencies
17012 */
17013
17014
17015
17016 function PostSlugControl() {
17017 const postSlug = (0,external_wp_data_namespaceObject.useSelect)(select => {
17018 return (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(select(store_store).getEditedPostSlug());
17019 }, []);
17020 const {
17021 editPost
17022 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17023 const [forceEmptyField, setForceEmptyField] = (0,external_wp_element_namespaceObject.useState)(false);
17024 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
17025 __nextHasNoMarginBottom: true,
17026 label: (0,external_wp_i18n_namespaceObject.__)('Slug'),
17027 autoComplete: "off",
17028 spellCheck: "false",
17029 value: forceEmptyField ? '' : postSlug,
17030 onChange: newValue => {
17031 editPost({
17032 slug: newValue
17033 });
17034 // When we delete the field the permalink gets
17035 // reverted to the original value.
17036 // The forceEmptyField logic allows the user to have
17037 // the field temporarily empty while typing.
17038 if (!newValue) {
17039 if (!forceEmptyField) {
17040 setForceEmptyField(true);
17041 }
17042 return;
17043 }
17044 if (forceEmptyField) {
17045 setForceEmptyField(false);
17046 }
17047 },
17048 onBlur: event => {
17049 editPost({
17050 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(event.target.value)
17051 });
17052 if (forceEmptyField) {
17053 setForceEmptyField(false);
17054 }
17055 },
17056 className: "editor-post-slug"
17057 });
17058 }
17059 function PostSlug() {
17060 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSlugCheck, {
17061 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSlugControl, {})
17062 });
17063 }
17064
17065 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-sticky/check.js
17066 /**
17067 * WordPress dependencies
17068 */
17069
17070
17071 /**
17072 * Internal dependencies
17073 */
17074
17075 function PostStickyCheck({
17076 children
17077 }) {
17078 const {
17079 hasStickyAction,
17080 postType
17081 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17082 var _post$_links$wpActio;
17083 const post = select(store_store).getCurrentPost();
17084 return {
17085 hasStickyAction: (_post$_links$wpActio = post._links?.['wp:action-sticky']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false,
17086 postType: select(store_store).getCurrentPostType()
17087 };
17088 }, []);
17089 if (postType !== 'post' || !hasStickyAction) {
17090 return null;
17091 }
17092 return children;
17093 }
17094
17095 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-sticky/index.js
17096 /**
17097 * WordPress dependencies
17098 */
17099
17100
17101
17102
17103 /**
17104 * Internal dependencies
17105 */
17106
17107
17108
17109
17110 function PostSticky() {
17111 const postSticky = (0,external_wp_data_namespaceObject.useSelect)(select => {
17112 var _select$getEditedPost;
17113 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('sticky')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : false;
17114 }, []);
17115 const {
17116 editPost
17117 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17118 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostStickyCheck, {
17119 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
17120 label: (0,external_wp_i18n_namespaceObject.__)('Sticky'),
17121 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToggleControl, {
17122 className: "editor-post-sticky__toggle-control",
17123 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
17124 children: (0,external_wp_i18n_namespaceObject.__)('Sticky')
17125 }),
17126 checked: postSticky,
17127 onChange: () => editPost({
17128 sticky: !postSticky
17129 })
17130 })
17131 })
17132 });
17133 }
17134
17135 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-switch-to-draft-button/index.js
17136 /**
17137 * WordPress dependencies
17138 */
17139
17140
17141
17142
17143
17144 /**
17145 * Internal dependencies
17146 */
17147
17148
17149 // TODO: deprecate..
17150
17151
17152
17153 function PostSwitchToDraftButton() {
17154 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
17155 const {
17156 editPost,
17157 savePost
17158 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17159 const {
17160 isSaving,
17161 isPublished,
17162 isScheduled
17163 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17164 const {
17165 isSavingPost,
17166 isCurrentPostPublished,
17167 isCurrentPostScheduled
17168 } = select(store_store);
17169 return {
17170 isSaving: isSavingPost(),
17171 isPublished: isCurrentPostPublished(),
17172 isScheduled: isCurrentPostScheduled()
17173 };
17174 }, []);
17175 const isDisabled = isSaving || !isPublished && !isScheduled;
17176 let alertMessage;
17177 let confirmButtonText;
17178 if (isPublished) {
17179 alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unpublish this post?');
17180 confirmButtonText = (0,external_wp_i18n_namespaceObject.__)('Unpublish');
17181 } else if (isScheduled) {
17182 alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unschedule this post?');
17183 confirmButtonText = (0,external_wp_i18n_namespaceObject.__)('Unschedule');
17184 }
17185 const handleConfirm = () => {
17186 setShowConfirmDialog(false);
17187 editPost({
17188 status: 'draft'
17189 });
17190 savePost();
17191 };
17192 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
17193 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
17194 __next40pxDefaultSize: true,
17195 className: "editor-post-switch-to-draft",
17196 onClick: () => {
17197 if (!isDisabled) {
17198 setShowConfirmDialog(true);
17199 }
17200 },
17201 "aria-disabled": isDisabled,
17202 variant: "secondary",
17203 style: {
17204 flexGrow: '1',
17205 justifyContent: 'center'
17206 },
17207 children: (0,external_wp_i18n_namespaceObject.__)('Switch to draft')
17208 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
17209 isOpen: showConfirmDialog,
17210 onConfirm: handleConfirm,
17211 onCancel: () => setShowConfirmDialog(false),
17212 confirmButtonText: confirmButtonText,
17213 children: alertMessage
17214 })]
17215 });
17216 }
17217
17218 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-sync-status/index.js
17219 /**
17220 * WordPress dependencies
17221 */
17222
17223
17224
17225 /**
17226 * Internal dependencies
17227 */
17228
17229
17230
17231 function PostSyncStatus() {
17232 const {
17233 syncStatus,
17234 postType
17235 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17236 const {
17237 getEditedPostAttribute
17238 } = select(store_store);
17239 const meta = getEditedPostAttribute('meta');
17240
17241 // When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead.
17242 const currentSyncStatus = meta?.wp_pattern_sync_status === 'unsynced' ? 'unsynced' : getEditedPostAttribute('wp_pattern_sync_status');
17243 return {
17244 syncStatus: currentSyncStatus,
17245 postType: getEditedPostAttribute('type')
17246 };
17247 });
17248 if (postType !== 'wp_block') {
17249 return null;
17250 }
17251 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
17252 label: (0,external_wp_i18n_namespaceObject.__)('Sync status'),
17253 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
17254 className: "editor-post-sync-status__value",
17255 children: syncStatus === 'unsynced' ? (0,external_wp_i18n_namespaceObject._x)('Not synced', 'Text that indicates that the pattern is not synchronized') : (0,external_wp_i18n_namespaceObject._x)('Synced', 'Text that indicates that the pattern is synchronized')
17256 })
17257 });
17258 }
17259
17260 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/index.js
17261 /**
17262 * WordPress dependencies
17263 */
17264
17265
17266
17267
17268 /**
17269 * Internal dependencies
17270 */
17271
17272
17273
17274
17275 const post_taxonomies_identity = x => x;
17276 function PostTaxonomies({
17277 taxonomyWrapper = post_taxonomies_identity
17278 }) {
17279 const {
17280 postType,
17281 taxonomies
17282 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17283 return {
17284 postType: select(store_store).getCurrentPostType(),
17285 taxonomies: select(external_wp_coreData_namespaceObject.store).getTaxonomies({
17286 per_page: -1
17287 })
17288 };
17289 }, []);
17290 const visibleTaxonomies = (taxonomies !== null && taxonomies !== void 0 ? taxonomies : []).filter(taxonomy =>
17291 // In some circumstances .visibility can end up as undefined so optional chaining operator required.
17292 // https://github.com/WordPress/gutenberg/issues/40326
17293 taxonomy.types.includes(postType) && taxonomy.visibility?.show_ui);
17294 return visibleTaxonomies.map(taxonomy => {
17295 const TaxonomyComponent = taxonomy.hierarchical ? hierarchical_term_selector : flat_term_selector;
17296 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.Fragment, {
17297 children: taxonomyWrapper( /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TaxonomyComponent, {
17298 slug: taxonomy.slug
17299 }), taxonomy)
17300 }, `taxonomy-${taxonomy.slug}`);
17301 });
17302 }
17303 /* harmony default export */ const post_taxonomies = (PostTaxonomies);
17304
17305 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/check.js
17306 /**
17307 * WordPress dependencies
17308 */
17309
17310
17311
17312 /**
17313 * Internal dependencies
17314 */
17315
17316 function PostTaxonomiesCheck({
17317 children
17318 }) {
17319 const hasTaxonomies = (0,external_wp_data_namespaceObject.useSelect)(select => {
17320 const postType = select(store_store).getCurrentPostType();
17321 const taxonomies = select(external_wp_coreData_namespaceObject.store).getTaxonomies({
17322 per_page: -1
17323 });
17324 return taxonomies?.some(taxonomy => taxonomy.types.includes(postType));
17325 }, []);
17326 if (!hasTaxonomies) {
17327 return null;
17328 }
17329 return children;
17330 }
17331
17332 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/panel.js
17333 /**
17334 * WordPress dependencies
17335 */
17336
17337
17338
17339 /**
17340 * Internal dependencies
17341 */
17342
17343
17344
17345
17346 function TaxonomyPanel({
17347 taxonomy,
17348 children
17349 }) {
17350 const slug = taxonomy?.slug;
17351 const panelName = slug ? `taxonomy-panel-${slug}` : '';
17352 const {
17353 isEnabled,
17354 isOpened
17355 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17356 const {
17357 isEditorPanelEnabled,
17358 isEditorPanelOpened
17359 } = select(store_store);
17360 return {
17361 isEnabled: slug ? isEditorPanelEnabled(panelName) : false,
17362 isOpened: slug ? isEditorPanelOpened(panelName) : false
17363 };
17364 }, [panelName, slug]);
17365 const {
17366 toggleEditorPanelOpened
17367 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17368 if (!isEnabled) {
17369 return null;
17370 }
17371 const taxonomyMenuName = taxonomy?.labels?.menu_name;
17372 if (!taxonomyMenuName) {
17373 return null;
17374 }
17375 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
17376 title: taxonomyMenuName,
17377 opened: isOpened,
17378 onToggle: () => toggleEditorPanelOpened(panelName),
17379 children: children
17380 });
17381 }
17382 function panel_PostTaxonomies() {
17383 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTaxonomiesCheck, {
17384 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_taxonomies, {
17385 taxonomyWrapper: (content, taxonomy) => {
17386 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TaxonomyPanel, {
17387 taxonomy: taxonomy,
17388 children: content
17389 });
17390 }
17391 })
17392 });
17393 }
17394 /* harmony default export */ const post_taxonomies_panel = (panel_PostTaxonomies);
17395
17396 // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
17397 var lib = __webpack_require__(773);
17398 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-text-editor/index.js
17399 /**
17400 * External dependencies
17401 */
17402
17403
17404 /**
17405 * WordPress dependencies
17406 */
17407
17408
17409
17410
17411
17412
17413
17414
17415 /**
17416 * Internal dependencies
17417 */
17418
17419
17420 /**
17421 * Displays the Post Text Editor along with content in Visual and Text mode.
17422 *
17423 * @return {JSX.Element|null} The rendered PostTextEditor component.
17424 */
17425
17426
17427
17428 function PostTextEditor() {
17429 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostTextEditor);
17430 const {
17431 content,
17432 blocks,
17433 type,
17434 id
17435 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17436 const {
17437 getEditedEntityRecord
17438 } = select(external_wp_coreData_namespaceObject.store);
17439 const {
17440 getCurrentPostType,
17441 getCurrentPostId
17442 } = select(store_store);
17443 const _type = getCurrentPostType();
17444 const _id = getCurrentPostId();
17445 const editedRecord = getEditedEntityRecord('postType', _type, _id);
17446 return {
17447 content: editedRecord?.content,
17448 blocks: editedRecord?.blocks,
17449 type: _type,
17450 id: _id
17451 };
17452 }, []);
17453 const {
17454 editEntityRecord
17455 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
17456 // Replicates the logic found in getEditedPostContent().
17457 const value = (0,external_wp_element_namespaceObject.useMemo)(() => {
17458 if (content instanceof Function) {
17459 return content({
17460 blocks
17461 });
17462 } else if (blocks) {
17463 // If we have parsed blocks already, they should be our source of truth.
17464 // Parsing applies block deprecations and legacy block conversions that
17465 // unparsed content will not have.
17466 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocks);
17467 }
17468 return content;
17469 }, [content, blocks]);
17470 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
17471 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
17472 as: "label",
17473 htmlFor: `post-content-${instanceId}`,
17474 children: (0,external_wp_i18n_namespaceObject.__)('Type text or HTML')
17475 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(lib/* default */.Z, {
17476 autoComplete: "off",
17477 dir: "auto",
17478 value: value,
17479 onChange: event => {
17480 editEntityRecord('postType', type, id, {
17481 content: event.target.value,
17482 blocks: undefined,
17483 selection: undefined
17484 });
17485 },
17486 className: "editor-post-text-editor",
17487 id: `post-content-${instanceId}`,
17488 placeholder: (0,external_wp_i18n_namespaceObject.__)('Start writing with text or HTML')
17489 })]
17490 });
17491 }
17492
17493 ;// CONCATENATED MODULE: external ["wp","dom"]
17494 const external_wp_dom_namespaceObject = window["wp"]["dom"];
17495 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/constants.js
17496 const DEFAULT_CLASSNAMES = 'wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text';
17497 const REGEXP_NEWLINES = /[\r\n]+/g;
17498
17499 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/use-post-title-focus.js
17500 /**
17501 * WordPress dependencies
17502 */
17503
17504
17505
17506 /**
17507 * Internal dependencies
17508 */
17509
17510
17511 /**
17512 * Custom hook that manages the focus behavior of the post title input field.
17513 *
17514 * @param {Element} forwardedRef - The forwarded ref for the input field.
17515 *
17516 * @return {Object} - The ref object.
17517 */
17518 function usePostTitleFocus(forwardedRef) {
17519 const ref = (0,external_wp_element_namespaceObject.useRef)();
17520 const {
17521 isCleanNewPost
17522 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17523 const {
17524 isCleanNewPost: _isCleanNewPost
17525 } = select(store_store);
17526 return {
17527 isCleanNewPost: _isCleanNewPost()
17528 };
17529 }, []);
17530 (0,external_wp_element_namespaceObject.useImperativeHandle)(forwardedRef, () => ({
17531 focus: () => {
17532 ref?.current?.focus();
17533 }
17534 }));
17535 (0,external_wp_element_namespaceObject.useEffect)(() => {
17536 if (!ref.current) {
17537 return;
17538 }
17539 const {
17540 defaultView
17541 } = ref.current.ownerDocument;
17542 const {
17543 name,
17544 parent
17545 } = defaultView;
17546 const ownerDocument = name === 'editor-canvas' ? parent.document : defaultView.document;
17547 const {
17548 activeElement,
17549 body
17550 } = ownerDocument;
17551
17552 // Only autofocus the title when the post is entirely empty. This should
17553 // only happen for a new post, which means we focus the title on new
17554 // post so the author can start typing right away, without needing to
17555 // click anything.
17556 if (isCleanNewPost && (!activeElement || body === activeElement)) {
17557 ref.current.focus();
17558 }
17559 }, [isCleanNewPost]);
17560 return {
17561 ref
17562 };
17563 }
17564
17565 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/use-post-title.js
17566 /**
17567 * WordPress dependencies
17568 */
17569
17570 /**
17571 * Internal dependencies
17572 */
17573
17574
17575 /**
17576 * Custom hook for managing the post title in the editor.
17577 *
17578 * @return {Object} An object containing the current title and a function to update the title.
17579 */
17580 function usePostTitle() {
17581 const {
17582 editPost
17583 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17584 const {
17585 title
17586 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17587 const {
17588 getEditedPostAttribute
17589 } = select(store_store);
17590 return {
17591 title: getEditedPostAttribute('title')
17592 };
17593 }, []);
17594 function updateTitle(newTitle) {
17595 editPost({
17596 title: newTitle
17597 });
17598 }
17599 return {
17600 title,
17601 setTitle: updateTitle
17602 };
17603 }
17604
17605 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/index.js
17606 /**
17607 * External dependencies
17608 */
17609
17610 /**
17611 * WordPress dependencies
17612 */
17613
17614
17615
17616
17617
17618
17619
17620
17621
17622
17623
17624 /**
17625 * Internal dependencies
17626 */
17627
17628
17629
17630
17631
17632 function PostTitle(_, forwardedRef) {
17633 const {
17634 placeholder,
17635 hasFixedToolbar
17636 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17637 const {
17638 getSettings
17639 } = select(external_wp_blockEditor_namespaceObject.store);
17640 const {
17641 titlePlaceholder,
17642 hasFixedToolbar: _hasFixedToolbar
17643 } = getSettings();
17644 return {
17645 placeholder: titlePlaceholder,
17646 hasFixedToolbar: _hasFixedToolbar
17647 };
17648 }, []);
17649 const [isSelected, setIsSelected] = (0,external_wp_element_namespaceObject.useState)(false);
17650 const {
17651 ref: focusRef
17652 } = usePostTitleFocus(forwardedRef);
17653 const {
17654 title,
17655 setTitle: onUpdate
17656 } = usePostTitle();
17657 const [selection, setSelection] = (0,external_wp_element_namespaceObject.useState)({});
17658 const {
17659 clearSelectedBlock,
17660 insertBlocks,
17661 insertDefaultBlock
17662 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
17663 function onChange(value) {
17664 onUpdate(value.replace(REGEXP_NEWLINES, ' '));
17665 }
17666 function onInsertBlockAfter(blocks) {
17667 insertBlocks(blocks, 0);
17668 }
17669 function onSelect() {
17670 setIsSelected(true);
17671 clearSelectedBlock();
17672 }
17673 function onUnselect() {
17674 setIsSelected(false);
17675 setSelection({});
17676 }
17677 function onEnterPress() {
17678 insertDefaultBlock(undefined, undefined, 0);
17679 }
17680 function onKeyDown(event) {
17681 if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) {
17682 event.preventDefault();
17683 onEnterPress();
17684 }
17685 }
17686 function onPaste(event) {
17687 const clipboardData = event.clipboardData;
17688 let plainText = '';
17689 let html = '';
17690
17691 // IE11 only supports `Text` as an argument for `getData` and will
17692 // otherwise throw an invalid argument error, so we try the standard
17693 // arguments first, then fallback to `Text` if they fail.
17694 try {
17695 plainText = clipboardData.getData('text/plain');
17696 html = clipboardData.getData('text/html');
17697 } catch (error1) {
17698 try {
17699 html = clipboardData.getData('Text');
17700 } catch (error2) {
17701 // Some browsers like UC Browser paste plain text by default and
17702 // don't support clipboardData at all, so allow default
17703 // behaviour.
17704 return;
17705 }
17706 }
17707
17708 // Allows us to ask for this information when we get a report.
17709 window.console.log('Received HTML:\n\n', html);
17710 window.console.log('Received plain text:\n\n', plainText);
17711 const content = (0,external_wp_blocks_namespaceObject.pasteHandler)({
17712 HTML: html,
17713 plainText
17714 });
17715 event.preventDefault();
17716 if (!content.length) {
17717 return;
17718 }
17719 if (typeof content !== 'string') {
17720 const [firstBlock] = content;
17721 if (!title && (firstBlock.name === 'core/heading' || firstBlock.name === 'core/paragraph')) {
17722 // Strip HTML to avoid unwanted HTML being added to the title.
17723 // In the majority of cases it is assumed that HTML in the title
17724 // is undesirable.
17725 const contentNoHTML = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(firstBlock.attributes.content);
17726 onUpdate(contentNoHTML);
17727 onInsertBlockAfter(content.slice(1));
17728 } else {
17729 onInsertBlockAfter(content);
17730 }
17731 } else {
17732 const value = {
17733 ...(0,external_wp_richText_namespaceObject.create)({
17734 html: title
17735 }),
17736 ...selection
17737 };
17738
17739 // Strip HTML to avoid unwanted HTML being added to the title.
17740 // In the majority of cases it is assumed that HTML in the title
17741 // is undesirable.
17742 const contentNoHTML = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(content);
17743 const newValue = (0,external_wp_richText_namespaceObject.insert)(value, (0,external_wp_richText_namespaceObject.create)({
17744 html: contentNoHTML
17745 }));
17746 onUpdate((0,external_wp_richText_namespaceObject.toHTMLString)({
17747 value: newValue
17748 }));
17749 setSelection({
17750 start: newValue.start,
17751 end: newValue.end
17752 });
17753 }
17754 }
17755 const decodedPlaceholder = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Add title');
17756 const {
17757 ref: richTextRef
17758 } = (0,external_wp_richText_namespaceObject.__unstableUseRichText)({
17759 value: title,
17760 onChange,
17761 placeholder: decodedPlaceholder,
17762 selectionStart: selection.start,
17763 selectionEnd: selection.end,
17764 onSelectionChange(newStart, newEnd) {
17765 setSelection(sel => {
17766 const {
17767 start,
17768 end
17769 } = sel;
17770 if (start === newStart && end === newEnd) {
17771 return sel;
17772 }
17773 return {
17774 start: newStart,
17775 end: newEnd
17776 };
17777 });
17778 },
17779 __unstableDisableFormats: false
17780 });
17781
17782 // The wp-block className is important for editor styles.
17783 // This same block is used in both the visual and the code editor.
17784 const className = dist_clsx(DEFAULT_CLASSNAMES, {
17785 'is-selected': isSelected,
17786 'has-fixed-toolbar': hasFixedToolbar
17787 });
17788 return (
17789 /*#__PURE__*/
17790 /* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
17791 (0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
17792 supportKeys: "title",
17793 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h1", {
17794 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([richTextRef, focusRef]),
17795 contentEditable: true,
17796 className: className,
17797 "aria-label": decodedPlaceholder,
17798 role: "textbox",
17799 "aria-multiline": "true",
17800 onFocus: onSelect,
17801 onBlur: onUnselect,
17802 onKeyDown: onKeyDown,
17803 onKeyPress: onUnselect,
17804 onPaste: onPaste
17805 })
17806 })
17807 /* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
17808 );
17809 }
17810
17811 /**
17812 * Renders the `PostTitle` component.
17813 *
17814 * @param {Object} _ Unused parameter.
17815 * @param {Element} forwardedRef Forwarded ref for the component.
17816 *
17817 * @return {Component} The rendered PostTitle component.
17818 */
17819 /* harmony default export */ const post_title = ((0,external_wp_element_namespaceObject.forwardRef)(PostTitle));
17820
17821 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/post-title-raw.js
17822 /**
17823 * External dependencies
17824 */
17825
17826
17827 /**
17828 * WordPress dependencies
17829 */
17830
17831
17832
17833
17834
17835
17836
17837 /**
17838 * Internal dependencies
17839 */
17840
17841
17842
17843
17844 /**
17845 * Renders a raw post title input field.
17846 *
17847 * @param {Object} _ Unused parameter.
17848 * @param {Element} forwardedRef Reference to the component's DOM node.
17849 *
17850 * @return {Component} The rendered component.
17851 */
17852
17853 function PostTitleRaw(_, forwardedRef) {
17854 const {
17855 placeholder,
17856 hasFixedToolbar
17857 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17858 const {
17859 getSettings
17860 } = select(external_wp_blockEditor_namespaceObject.store);
17861 const {
17862 titlePlaceholder,
17863 hasFixedToolbar: _hasFixedToolbar
17864 } = getSettings();
17865 return {
17866 placeholder: titlePlaceholder,
17867 hasFixedToolbar: _hasFixedToolbar
17868 };
17869 }, []);
17870 const [isSelected, setIsSelected] = (0,external_wp_element_namespaceObject.useState)(false);
17871 const {
17872 title,
17873 setTitle: onUpdate
17874 } = usePostTitle();
17875 const {
17876 ref: focusRef
17877 } = usePostTitleFocus(forwardedRef);
17878 function onChange(value) {
17879 onUpdate(value.replace(REGEXP_NEWLINES, ' '));
17880 }
17881 function onSelect() {
17882 setIsSelected(true);
17883 }
17884 function onUnselect() {
17885 setIsSelected(false);
17886 }
17887
17888 // The wp-block className is important for editor styles.
17889 // This same block is used in both the visual and the code editor.
17890 const className = dist_clsx(DEFAULT_CLASSNAMES, {
17891 'is-selected': isSelected,
17892 'has-fixed-toolbar': hasFixedToolbar,
17893 'is-raw-text': true
17894 });
17895 const decodedPlaceholder = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Add title');
17896 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextareaControl, {
17897 ref: focusRef,
17898 value: title,
17899 onChange: onChange,
17900 onFocus: onSelect,
17901 onBlur: onUnselect,
17902 label: placeholder,
17903 className: className,
17904 placeholder: decodedPlaceholder,
17905 hideLabelFromVision: true,
17906 autoComplete: "off",
17907 dir: "auto",
17908 rows: 1,
17909 __nextHasNoMarginBottom: true
17910 });
17911 }
17912 /* harmony default export */ const post_title_raw = ((0,external_wp_element_namespaceObject.forwardRef)(PostTitleRaw));
17913
17914 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-trash/index.js
17915 /**
17916 * WordPress dependencies
17917 */
17918
17919
17920
17921
17922
17923 /**
17924 * Internal dependencies
17925 */
17926
17927
17928
17929
17930 function PostTrash() {
17931 const {
17932 isNew,
17933 isDeleting,
17934 postId
17935 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17936 const store = select(store_store);
17937 return {
17938 isNew: store.isEditedPostNew(),
17939 isDeleting: store.isDeletingPost(),
17940 postId: store.getCurrentPostId()
17941 };
17942 }, []);
17943 const {
17944 trashPost
17945 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17946 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
17947 if (isNew || !postId) {
17948 return null;
17949 }
17950 const handleConfirm = () => {
17951 setShowConfirmDialog(false);
17952 trashPost();
17953 };
17954 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
17955 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
17956 __next40pxDefaultSize: true,
17957 className: "editor-post-trash",
17958 isDestructive: true,
17959 variant: "secondary",
17960 isBusy: isDeleting,
17961 "aria-disabled": isDeleting,
17962 onClick: isDeleting ? undefined : () => setShowConfirmDialog(true),
17963 children: (0,external_wp_i18n_namespaceObject.__)('Move to trash')
17964 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
17965 isOpen: showConfirmDialog,
17966 onConfirm: handleConfirm,
17967 onCancel: () => setShowConfirmDialog(false),
17968 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Move to trash'),
17969 children: (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to move this post to the trash?')
17970 })]
17971 });
17972 }
17973
17974 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-trash/check.js
17975 /**
17976 * WordPress dependencies
17977 */
17978
17979
17980
17981 /**
17982 * Internal dependencies
17983 */
17984
17985 function PostTrashCheck({
17986 children
17987 }) {
17988 const {
17989 canTrashPost
17990 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17991 const {
17992 isEditedPostNew,
17993 getCurrentPostId,
17994 getCurrentPostType
17995 } = select(store_store);
17996 const {
17997 getPostType,
17998 canUser
17999 } = select(external_wp_coreData_namespaceObject.store);
18000 const postType = getPostType(getCurrentPostType());
18001 const postId = getCurrentPostId();
18002 const isNew = isEditedPostNew();
18003 const resource = postType?.rest_base || ''; // eslint-disable-line camelcase
18004 const canUserDelete = postId && resource ? canUser('delete', resource, postId) : false;
18005 return {
18006 canTrashPost: (!isNew || postId) && canUserDelete
18007 };
18008 }, []);
18009 if (!canTrashPost) {
18010 return null;
18011 }
18012 return children;
18013 }
18014
18015 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/copy-small.js
18016 /**
18017 * WordPress dependencies
18018 */
18019
18020
18021 const copySmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
18022 xmlns: "http://www.w3.org/2000/svg",
18023 viewBox: "0 0 24 24",
18024 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
18025 fillRule: "evenodd",
18026 clipRule: "evenodd",
18027 d: "M5.625 5.5h9.75c.069 0 .125.056.125.125v9.75a.125.125 0 0 1-.125.125h-9.75a.125.125 0 0 1-.125-.125v-9.75c0-.069.056-.125.125-.125ZM4 5.625C4 4.728 4.728 4 5.625 4h9.75C16.273 4 17 4.728 17 5.625v9.75c0 .898-.727 1.625-1.625 1.625h-9.75A1.625 1.625 0 0 1 4 15.375v-9.75Zm14.5 11.656v-9H20v9C20 18.8 18.77 20 17.251 20H6.25v-1.5h11.001c.69 0 1.249-.528 1.249-1.219Z"
18028 })
18029 });
18030 /* harmony default export */ const copy_small = (copySmall);
18031
18032 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-url/index.js
18033 /**
18034 * WordPress dependencies
18035 */
18036
18037
18038
18039
18040
18041
18042
18043
18044
18045
18046
18047 /**
18048 * Internal dependencies
18049 */
18050
18051
18052 /**
18053 * Renders the `PostURL` component.
18054 *
18055 * @example
18056 * ```jsx
18057 * <PostURL />
18058 * ```
18059 *
18060 * @param {Function} onClose Callback function to be executed when the popover is closed.
18061 *
18062 * @return {Component} The rendered PostURL component.
18063 */
18064
18065
18066 function PostURL({
18067 onClose
18068 }) {
18069 const {
18070 isEditable,
18071 postSlug,
18072 postLink,
18073 permalinkPrefix,
18074 permalinkSuffix,
18075 permalink
18076 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18077 var _post$_links$wpActio;
18078 const post = select(store_store).getCurrentPost();
18079 const postTypeSlug = select(store_store).getCurrentPostType();
18080 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
18081 const permalinkParts = select(store_store).getPermalinkParts();
18082 const hasPublishAction = (_post$_links$wpActio = post?._links?.['wp:action-publish']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false;
18083 return {
18084 isEditable: select(store_store).isPermalinkEditable() && hasPublishAction,
18085 postSlug: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(select(store_store).getEditedPostSlug()),
18086 viewPostLabel: postType?.labels.view_item,
18087 postLink: post.link,
18088 permalinkPrefix: permalinkParts?.prefix,
18089 permalinkSuffix: permalinkParts?.suffix,
18090 permalink: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(select(store_store).getPermalink())
18091 };
18092 }, []);
18093 const {
18094 editPost
18095 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
18096 const {
18097 createNotice
18098 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
18099 const [forceEmptyField, setForceEmptyField] = (0,external_wp_element_namespaceObject.useState)(false);
18100 const copyButtonRef = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(permalink, () => {
18101 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('Copied URL to clipboard.'), {
18102 isDismissible: true,
18103 type: 'snackbar'
18104 });
18105 });
18106 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18107 className: "editor-post-url",
18108 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
18109 title: (0,external_wp_i18n_namespaceObject.__)('Link'),
18110 onClose: onClose
18111 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
18112 spacing: 3,
18113 children: [isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18114 children: [(0,external_wp_i18n_namespaceObject.__)('Customize the last part of the URL. '), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
18115 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink'),
18116 children: (0,external_wp_i18n_namespaceObject.__)('Learn more.')
18117 })]
18118 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18119 children: [isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControl, {
18120 __next40pxDefaultSize: true,
18121 prefix: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControlPrefixWrapper, {
18122 children: "/"
18123 }),
18124 suffix: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18125 icon: copy_small,
18126 ref: copyButtonRef,
18127 label: (0,external_wp_i18n_namespaceObject.__)('Copy')
18128 }),
18129 label: (0,external_wp_i18n_namespaceObject.__)('Link'),
18130 hideLabelFromVision: true,
18131 value: forceEmptyField ? '' : postSlug,
18132 autoComplete: "off",
18133 spellCheck: "false",
18134 type: "text",
18135 className: "editor-post-url__input",
18136 onChange: newValue => {
18137 editPost({
18138 slug: newValue
18139 });
18140 // When we delete the field the permalink gets
18141 // reverted to the original value.
18142 // The forceEmptyField logic allows the user to have
18143 // the field temporarily empty while typing.
18144 if (!newValue) {
18145 if (!forceEmptyField) {
18146 setForceEmptyField(true);
18147 }
18148 return;
18149 }
18150 if (forceEmptyField) {
18151 setForceEmptyField(false);
18152 }
18153 },
18154 onBlur: event => {
18155 editPost({
18156 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(event.target.value)
18157 });
18158 if (forceEmptyField) {
18159 setForceEmptyField(false);
18160 }
18161 },
18162 help: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.ExternalLink, {
18163 className: "editor-post-url__link",
18164 href: postLink,
18165 target: "_blank",
18166 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18167 className: "editor-post-url__link-prefix",
18168 children: permalinkPrefix
18169 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18170 className: "editor-post-url__link-slug",
18171 children: postSlug
18172 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18173 className: "editor-post-url__link-suffix",
18174 children: permalinkSuffix
18175 })]
18176 })
18177 }), !isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
18178 className: "editor-post-url__link",
18179 href: postLink,
18180 target: "_blank",
18181 children: postLink
18182 })]
18183 })]
18184 })]
18185 });
18186 }
18187
18188 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-url/check.js
18189 /**
18190 * WordPress dependencies
18191 */
18192
18193
18194
18195 /**
18196 * Internal dependencies
18197 */
18198
18199
18200 /**
18201 * Check if the post URL is valid and visible.
18202 *
18203 * @param {Object} props The component props.
18204 * @param {Element} props.children The child components.
18205 *
18206 * @return {Component|null} The child components if the post URL is valid and visible, otherwise null.
18207 */
18208 function PostURLCheck({
18209 children
18210 }) {
18211 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
18212 const postTypeSlug = select(store_store).getCurrentPostType();
18213 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
18214 if (!postType?.viewable) {
18215 return false;
18216 }
18217 const post = select(store_store).getCurrentPost();
18218 if (!post.link) {
18219 return false;
18220 }
18221 const permalinkParts = select(store_store).getPermalinkParts();
18222 if (!permalinkParts) {
18223 return false;
18224 }
18225 return true;
18226 }, []);
18227 if (!isVisible) {
18228 return null;
18229 }
18230 return children;
18231 }
18232
18233 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-url/label.js
18234 /**
18235 * WordPress dependencies
18236 */
18237
18238
18239
18240 /**
18241 * Internal dependencies
18242 */
18243
18244
18245 /**
18246 * Represents a label component for a post URL.
18247 *
18248 * @return {Component} The PostURLLabel component.
18249 */
18250 function PostURLLabel() {
18251 return usePostURLLabel();
18252 }
18253
18254 /**
18255 * Custom hook to get the label for the post URL.
18256 *
18257 * @return {string} The filtered and decoded post URL label.
18258 */
18259 function usePostURLLabel() {
18260 const postLink = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getPermalink(), []);
18261 return (0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURIComponent)(postLink));
18262 }
18263
18264 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-url/panel.js
18265 /**
18266 * WordPress dependencies
18267 */
18268
18269
18270
18271
18272
18273
18274 /**
18275 * Internal dependencies
18276 */
18277
18278
18279
18280
18281
18282 /**
18283 * Renders the `PostURLPanel` component.
18284 *
18285 * @return {JSX.Element} The rendered PostURLPanel component.
18286 */
18287
18288
18289 function PostURLPanel() {
18290 // Use internal state instead of a ref to make sure that the component
18291 // re-renders when the popover's anchor updates.
18292 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
18293 // Memoize popoverProps to avoid returning a new object every time.
18294 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
18295 // Anchor the popover to the middle of the entire row so that it doesn't
18296 // move around when the label changes.
18297 anchor: popoverAnchor,
18298 placement: 'left-start',
18299 offset: 36,
18300 shift: true
18301 }), [popoverAnchor]);
18302 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURLCheck, {
18303 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
18304 label: (0,external_wp_i18n_namespaceObject.__)('Link'),
18305 ref: setPopoverAnchor,
18306 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
18307 popoverProps: popoverProps,
18308 className: "editor-post-url__panel-dropdown",
18309 contentClassName: "editor-post-url__panel-dialog",
18310 focusOnMount: true,
18311 renderToggle: ({
18312 isOpen,
18313 onToggle
18314 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURLToggle, {
18315 isOpen: isOpen,
18316 onClick: onToggle
18317 }),
18318 renderContent: ({
18319 onClose
18320 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURL, {
18321 onClose: onClose
18322 })
18323 })
18324 })
18325 });
18326 }
18327 function PostURLToggle({
18328 isOpen,
18329 onClick
18330 }) {
18331 const slug = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostSlug(), []);
18332 const decodedSlug = (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(slug);
18333 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
18334 size: "compact",
18335 className: "editor-post-url__panel-toggle",
18336 variant: "tertiary",
18337 "aria-expanded": isOpen
18338 // translators: %s: Current post link.
18339 ,
18340 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change link: %s'), decodedSlug),
18341 onClick: onClick,
18342 children: ["/", decodedSlug]
18343 });
18344 }
18345
18346 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/check.js
18347 /**
18348 * WordPress dependencies
18349 */
18350
18351
18352 /**
18353 * Internal dependencies
18354 */
18355
18356
18357 /**
18358 * Determines if the current post can be edited (published)
18359 * and passes this information to the provided render function.
18360 *
18361 * @param {Object} props The component props.
18362 * @param {Function} props.render Function to render the component.
18363 * Receives an object with a `canEdit` property.
18364 * @return {JSX.Element} The rendered component.
18365 */
18366 function PostVisibilityCheck({
18367 render
18368 }) {
18369 const canEdit = (0,external_wp_data_namespaceObject.useSelect)(select => {
18370 var _select$getCurrentPos;
18371 return (_select$getCurrentPos = select(store_store).getCurrentPost()._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false;
18372 });
18373 return render({
18374 canEdit
18375 });
18376 }
18377
18378 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/info.js
18379 /**
18380 * WordPress dependencies
18381 */
18382
18383
18384 const info = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
18385 xmlns: "http://www.w3.org/2000/svg",
18386 viewBox: "0 0 24 24",
18387 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
18388 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"
18389 })
18390 });
18391 /* harmony default export */ const library_info = (info);
18392
18393 ;// CONCATENATED MODULE: external ["wp","wordcount"]
18394 const external_wp_wordcount_namespaceObject = window["wp"]["wordcount"];
18395 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/word-count/index.js
18396 /**
18397 * WordPress dependencies
18398 */
18399
18400
18401
18402
18403 /**
18404 * Internal dependencies
18405 */
18406
18407
18408 function WordCount() {
18409 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
18410
18411 /*
18412 * translators: If your word count is based on single characters (e.g. East Asian characters),
18413 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
18414 * Do not translate into your own language.
18415 */
18416 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
18417 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18418 className: "word-count",
18419 children: (0,external_wp_wordcount_namespaceObject.count)(content, wordCountType)
18420 });
18421 }
18422
18423 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/time-to-read/index.js
18424 /**
18425 * WordPress dependencies
18426 */
18427
18428
18429
18430
18431
18432 /**
18433 * Internal dependencies
18434 */
18435
18436
18437 /**
18438 * Average reading rate - based on average taken from
18439 * https://irisreading.com/average-reading-speed-in-various-languages/
18440 * (Characters/minute used for Chinese rather than words).
18441 *
18442 * @type {number} A rough estimate of the average reading rate across multiple languages.
18443 */
18444
18445 const AVERAGE_READING_RATE = 189;
18446 function TimeToRead() {
18447 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
18448
18449 /*
18450 * translators: If your word count is based on single characters (e.g. East Asian characters),
18451 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
18452 * Do not translate into your own language.
18453 */
18454 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
18455 const minutesToRead = Math.round((0,external_wp_wordcount_namespaceObject.count)(content, wordCountType) / AVERAGE_READING_RATE);
18456 const minutesToReadString = minutesToRead === 0 ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('<span>< 1</span> minute'), {
18457 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {})
18458 }) : (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. */
18459 (0,external_wp_i18n_namespaceObject._n)('<span>%d</span> minute', '<span>%d</span> minutes', minutesToRead), minutesToRead), {
18460 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {})
18461 });
18462 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18463 className: "time-to-read",
18464 children: minutesToReadString
18465 });
18466 }
18467
18468 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/character-count/index.js
18469 /**
18470 * WordPress dependencies
18471 */
18472
18473
18474
18475 /**
18476 * Internal dependencies
18477 */
18478
18479
18480 /**
18481 * Renders the character count of the post content.
18482 *
18483 * @return {number} The character count.
18484 */
18485 function CharacterCount() {
18486 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
18487 return (0,external_wp_wordcount_namespaceObject.count)(content, 'characters_including_spaces');
18488 }
18489
18490 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/table-of-contents/panel.js
18491 /**
18492 * WordPress dependencies
18493 */
18494
18495
18496
18497
18498 /**
18499 * Internal dependencies
18500 */
18501
18502
18503
18504
18505
18506
18507
18508 function TableOfContentsPanel({
18509 hasOutlineItemsDisabled,
18510 onRequestClose
18511 }) {
18512 const {
18513 headingCount,
18514 paragraphCount,
18515 numberOfBlocks
18516 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18517 const {
18518 getGlobalBlockCount
18519 } = select(external_wp_blockEditor_namespaceObject.store);
18520 return {
18521 headingCount: getGlobalBlockCount('core/heading'),
18522 paragraphCount: getGlobalBlockCount('core/paragraph'),
18523 numberOfBlocks: getGlobalBlockCount()
18524 };
18525 }, []);
18526 return (
18527 /*#__PURE__*/
18528 /*
18529 * Disable reason: The `list` ARIA role is redundant but
18530 * Safari+VoiceOver won't announce the list otherwise.
18531 */
18532 /* eslint-disable jsx-a11y/no-redundant-roles */
18533 (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
18534 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
18535 className: "table-of-contents__wrapper",
18536 role: "note",
18537 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document Statistics'),
18538 tabIndex: "0",
18539 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("ul", {
18540 role: "list",
18541 className: "table-of-contents__counts",
18542 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18543 className: "table-of-contents__count",
18544 children: [(0,external_wp_i18n_namespaceObject.__)('Words'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WordCount, {})]
18545 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18546 className: "table-of-contents__count",
18547 children: [(0,external_wp_i18n_namespaceObject.__)('Characters'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18548 className: "table-of-contents__number",
18549 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CharacterCount, {})
18550 })]
18551 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18552 className: "table-of-contents__count",
18553 children: [(0,external_wp_i18n_namespaceObject.__)('Time to read'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TimeToRead, {})]
18554 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18555 className: "table-of-contents__count",
18556 children: [(0,external_wp_i18n_namespaceObject.__)('Headings'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18557 className: "table-of-contents__number",
18558 children: headingCount
18559 })]
18560 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18561 className: "table-of-contents__count",
18562 children: [(0,external_wp_i18n_namespaceObject.__)('Paragraphs'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18563 className: "table-of-contents__number",
18564 children: paragraphCount
18565 })]
18566 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18567 className: "table-of-contents__count",
18568 children: [(0,external_wp_i18n_namespaceObject.__)('Blocks'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18569 className: "table-of-contents__number",
18570 children: numberOfBlocks
18571 })]
18572 })]
18573 })
18574 }), headingCount > 0 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
18575 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("hr", {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
18576 className: "table-of-contents__title",
18577 children: (0,external_wp_i18n_namespaceObject.__)('Document Outline')
18578 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DocumentOutline, {
18579 onSelect: onRequestClose,
18580 hasOutlineItemsDisabled: hasOutlineItemsDisabled
18581 })]
18582 })]
18583 })
18584 /* eslint-enable jsx-a11y/no-redundant-roles */
18585 );
18586 }
18587 /* harmony default export */ const table_of_contents_panel = (TableOfContentsPanel);
18588
18589 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/table-of-contents/index.js
18590 /**
18591 * WordPress dependencies
18592 */
18593
18594
18595
18596
18597
18598
18599
18600 /**
18601 * Internal dependencies
18602 */
18603
18604
18605 function TableOfContents({
18606 hasOutlineItemsDisabled,
18607 repositionDropdown,
18608 ...props
18609 }, ref) {
18610 const hasBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_blockEditor_namespaceObject.store).getBlockCount(), []);
18611 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
18612 popoverProps: {
18613 placement: repositionDropdown ? 'right' : 'bottom'
18614 },
18615 className: "table-of-contents",
18616 contentClassName: "table-of-contents__popover",
18617 renderToggle: ({
18618 isOpen,
18619 onToggle
18620 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18621 ...props,
18622 ref: ref,
18623 onClick: hasBlocks ? onToggle : undefined,
18624 icon: library_info,
18625 "aria-expanded": isOpen,
18626 "aria-haspopup": "true"
18627 /* translators: button label text should, if possible, be under 16 characters. */,
18628 label: (0,external_wp_i18n_namespaceObject.__)('Details'),
18629 tooltipPosition: "bottom",
18630 "aria-disabled": !hasBlocks
18631 }),
18632 renderContent: ({
18633 onClose
18634 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(table_of_contents_panel, {
18635 onRequestClose: onClose,
18636 hasOutlineItemsDisabled: hasOutlineItemsDisabled
18637 })
18638 });
18639 }
18640 /* harmony default export */ const table_of_contents = ((0,external_wp_element_namespaceObject.forwardRef)(TableOfContents));
18641
18642 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/unsaved-changes-warning/index.js
18643 /**
18644 * WordPress dependencies
18645 */
18646
18647
18648
18649
18650
18651 /**
18652 * Warns the user if there are unsaved changes before leaving the editor.
18653 * Compatible with Post Editor and Site Editor.
18654 *
18655 * @return {Component} The component.
18656 */
18657 function UnsavedChangesWarning() {
18658 const {
18659 __experimentalGetDirtyEntityRecords
18660 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
18661 (0,external_wp_element_namespaceObject.useEffect)(() => {
18662 /**
18663 * Warns the user if there are unsaved changes before leaving the editor.
18664 *
18665 * @param {Event} event `beforeunload` event.
18666 *
18667 * @return {string | undefined} Warning prompt message, if unsaved changes exist.
18668 */
18669 const warnIfUnsavedChanges = event => {
18670 // We need to call the selector directly in the listener to avoid race
18671 // conditions with `BrowserURL` where `componentDidUpdate` gets the
18672 // new value of `isEditedPostDirty` before this component does,
18673 // causing this component to incorrectly think a trashed post is still dirty.
18674 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
18675 if (dirtyEntityRecords.length > 0) {
18676 event.returnValue = (0,external_wp_i18n_namespaceObject.__)('You have unsaved changes. If you proceed, they will be lost.');
18677 return event.returnValue;
18678 }
18679 };
18680 window.addEventListener('beforeunload', warnIfUnsavedChanges);
18681 return () => {
18682 window.removeEventListener('beforeunload', warnIfUnsavedChanges);
18683 };
18684 }, [__experimentalGetDirtyEntityRecords]);
18685 return null;
18686 }
18687
18688 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/with-registry-provider.js
18689 /**
18690 * WordPress dependencies
18691 */
18692
18693
18694
18695
18696
18697 /**
18698 * Internal dependencies
18699 */
18700
18701
18702 function getSubRegistry(subRegistries, registry, useSubRegistry) {
18703 if (!useSubRegistry) {
18704 return registry;
18705 }
18706 let subRegistry = subRegistries.get(registry);
18707 if (!subRegistry) {
18708 subRegistry = (0,external_wp_data_namespaceObject.createRegistry)({
18709 'core/block-editor': external_wp_blockEditor_namespaceObject.storeConfig
18710 }, registry);
18711 // Todo: The interface store should also be created per instance.
18712 subRegistry.registerStore('core/editor', storeConfig);
18713 subRegistries.set(registry, subRegistry);
18714 }
18715 return subRegistry;
18716 }
18717 const withRegistryProvider = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => ({
18718 useSubRegistry = true,
18719 ...props
18720 }) => {
18721 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
18722 const [subRegistries] = (0,external_wp_element_namespaceObject.useState)(() => new WeakMap());
18723 const subRegistry = getSubRegistry(subRegistries, registry, useSubRegistry);
18724 if (subRegistry === registry) {
18725 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, {
18726 registry: registry,
18727 ...props
18728 });
18729 }
18730 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_data_namespaceObject.RegistryProvider, {
18731 value: subRegistry,
18732 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, {
18733 registry: subRegistry,
18734 ...props
18735 })
18736 });
18737 }, 'withRegistryProvider');
18738 /* harmony default export */ const with_registry_provider = (withRegistryProvider);
18739
18740 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/media-categories/index.js
18741 /**
18742 * The `editor` settings here need to be in sync with the corresponding ones in `editor` package.
18743 * See `packages/editor/src/components/media-categories/index.js`.
18744 *
18745 * In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`.
18746 * The rest of the settings would still need to be in sync though.
18747 */
18748
18749 /**
18750 * WordPress dependencies
18751 */
18752
18753
18754
18755
18756 /**
18757 * Internal dependencies
18758 */
18759
18760
18761 /** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */
18762 /** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */
18763 /** @typedef {import('@wordpress/block-editor').InserterMediaCategory} InserterMediaCategory */
18764
18765 const getExternalLink = (url, text) => `<a ${getExternalLinkAttributes(url)}>${text}</a>`;
18766 const getExternalLinkAttributes = url => `href="${url}" target="_blank" rel="noreferrer noopener"`;
18767 const getOpenverseLicense = (license, licenseVersion) => {
18768 let licenseName = license.trim();
18769 // PDM has no abbreviation
18770 if (license !== 'pdm') {
18771 licenseName = license.toUpperCase().replace('SAMPLING', 'Sampling');
18772 }
18773 // If version is known, append version to the name.
18774 // The license has to have a version to be valid. Only
18775 // PDM (public domain mark) doesn't have a version.
18776 if (licenseVersion) {
18777 licenseName += ` ${licenseVersion}`;
18778 }
18779 // For licenses other than public-domain marks, prepend 'CC' to the name.
18780 if (!['pdm', 'cc0'].includes(license)) {
18781 licenseName = `CC ${licenseName}`;
18782 }
18783 return licenseName;
18784 };
18785 const getOpenverseCaption = item => {
18786 const {
18787 title,
18788 foreign_landing_url: foreignLandingUrl,
18789 creator,
18790 creator_url: creatorUrl,
18791 license,
18792 license_version: licenseVersion,
18793 license_url: licenseUrl
18794 } = item;
18795 const fullLicense = getOpenverseLicense(license, licenseVersion);
18796 const _creator = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(creator);
18797 let _caption;
18798 if (_creator) {
18799 _caption = title ? (0,external_wp_i18n_namespaceObject.sprintf)(
18800 // 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".
18801 (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)(
18802 // 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".
18803 (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);
18804 } else {
18805 _caption = title ? (0,external_wp_i18n_namespaceObject.sprintf)(
18806 // translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: "CC0 1.0".
18807 (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)(
18808 // translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: "CC0 1.0".
18809 (0,external_wp_i18n_namespaceObject._x)('<a %1$s>Work</a>/ %2$s', 'caption'), getExternalLinkAttributes(foreignLandingUrl), licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense);
18810 }
18811 return _caption.replace(/\s{2}/g, ' ');
18812 };
18813 const coreMediaFetch = async (query = {}) => {
18814 const mediaItems = await (0,external_wp_data_namespaceObject.resolveSelect)(external_wp_coreData_namespaceObject.store).getMediaItems({
18815 ...query,
18816 orderBy: !!query?.search ? 'relevance' : 'date'
18817 });
18818 return mediaItems.map(mediaItem => ({
18819 ...mediaItem,
18820 alt: mediaItem.alt_text,
18821 url: mediaItem.source_url,
18822 previewUrl: mediaItem.media_details?.sizes?.medium?.source_url,
18823 caption: mediaItem.caption?.raw
18824 }));
18825 };
18826
18827 /** @type {InserterMediaCategory[]} */
18828 const inserterMediaCategories = [{
18829 name: 'images',
18830 labels: {
18831 name: (0,external_wp_i18n_namespaceObject.__)('Images'),
18832 search_items: (0,external_wp_i18n_namespaceObject.__)('Search images')
18833 },
18834 mediaType: 'image',
18835 async fetch(query = {}) {
18836 return coreMediaFetch({
18837 ...query,
18838 media_type: 'image'
18839 });
18840 }
18841 }, {
18842 name: 'videos',
18843 labels: {
18844 name: (0,external_wp_i18n_namespaceObject.__)('Videos'),
18845 search_items: (0,external_wp_i18n_namespaceObject.__)('Search videos')
18846 },
18847 mediaType: 'video',
18848 async fetch(query = {}) {
18849 return coreMediaFetch({
18850 ...query,
18851 media_type: 'video'
18852 });
18853 }
18854 }, {
18855 name: 'audio',
18856 labels: {
18857 name: (0,external_wp_i18n_namespaceObject.__)('Audio'),
18858 search_items: (0,external_wp_i18n_namespaceObject.__)('Search audio')
18859 },
18860 mediaType: 'audio',
18861 async fetch(query = {}) {
18862 return coreMediaFetch({
18863 ...query,
18864 media_type: 'audio'
18865 });
18866 }
18867 }, {
18868 name: 'openverse',
18869 labels: {
18870 name: (0,external_wp_i18n_namespaceObject.__)('Openverse'),
18871 search_items: (0,external_wp_i18n_namespaceObject.__)('Search Openverse')
18872 },
18873 mediaType: 'image',
18874 async fetch(query = {}) {
18875 const defaultArgs = {
18876 mature: false,
18877 excluded_source: 'flickr,inaturalist,wikimedia',
18878 license: 'pdm,cc0'
18879 };
18880 const finalQuery = {
18881 ...query,
18882 ...defaultArgs
18883 };
18884 const mapFromInserterMediaRequest = {
18885 per_page: 'page_size',
18886 search: 'q'
18887 };
18888 const url = new URL('https://api.openverse.org/v1/images/');
18889 Object.entries(finalQuery).forEach(([key, value]) => {
18890 const queryKey = mapFromInserterMediaRequest[key] || key;
18891 url.searchParams.set(queryKey, value);
18892 });
18893 const response = await window.fetch(url, {
18894 headers: {
18895 'User-Agent': 'WordPress/inserter-media-fetch'
18896 }
18897 });
18898 const jsonResponse = await response.json();
18899 const results = jsonResponse.results;
18900 return results.map(result => ({
18901 ...result,
18902 // This is a temp solution for better titles, until Openverse API
18903 // completes the cleaning up of some titles of their upstream data.
18904 title: result.title?.toLowerCase().startsWith('file:') ? result.title.slice(5) : result.title,
18905 sourceId: result.id,
18906 id: undefined,
18907 caption: getOpenverseCaption(result),
18908 previewUrl: result.thumbnail
18909 }));
18910 },
18911 getReportUrl: ({
18912 sourceId
18913 }) => `https://wordpress.org/openverse/image/${sourceId}/report/`,
18914 isExternalResource: true
18915 }];
18916 /* harmony default export */ const media_categories = (inserterMediaCategories);
18917
18918 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/media-upload/index.js
18919 /**
18920 * WordPress dependencies
18921 */
18922
18923
18924
18925 /**
18926 * Internal dependencies
18927 */
18928
18929 const media_upload_noop = () => {};
18930
18931 /**
18932 * Upload a media file when the file upload button is activated.
18933 * Wrapper around mediaUpload() that injects the current post ID.
18934 *
18935 * @param {Object} $0 Parameters object passed to the function.
18936 * @param {?Object} $0.additionalData Additional data to include in the request.
18937 * @param {string} $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.
18938 * @param {Array} $0.filesList List of files.
18939 * @param {?number} $0.maxUploadFileSize Maximum upload size in bytes allowed for the site.
18940 * @param {Function} $0.onError Function called when an error happens.
18941 * @param {Function} $0.onFileChange Function called each time a file or a temporary representation of the file is available.
18942 */
18943 function mediaUpload({
18944 additionalData = {},
18945 allowedTypes,
18946 filesList,
18947 maxUploadFileSize,
18948 onError = media_upload_noop,
18949 onFileChange
18950 }) {
18951 const {
18952 getCurrentPost,
18953 getEditorSettings
18954 } = (0,external_wp_data_namespaceObject.select)(store_store);
18955 const wpAllowedMimeTypes = getEditorSettings().allowedMimeTypes;
18956 maxUploadFileSize = maxUploadFileSize || getEditorSettings().maxUploadFileSize;
18957 const currentPost = getCurrentPost();
18958 // Templates and template parts' numerical ID is stored in `wp_id`.
18959 const currentPostId = typeof currentPost?.id === 'number' ? currentPost.id : currentPost?.wp_id;
18960 const postData = currentPostId ? {
18961 post: currentPostId
18962 } : {};
18963 (0,external_wp_mediaUtils_namespaceObject.uploadMedia)({
18964 allowedTypes,
18965 filesList,
18966 onFileChange,
18967 additionalData: {
18968 ...postData,
18969 ...additionalData
18970 },
18971 maxUploadFileSize,
18972 onError: ({
18973 message
18974 }) => onError(message),
18975 wpAllowedMimeTypes
18976 });
18977 }
18978
18979 // EXTERNAL MODULE: ./node_modules/deepmerge/dist/cjs.js
18980 var cjs = __webpack_require__(1919);
18981 var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs);
18982 ;// CONCATENATED MODULE: ./node_modules/is-plain-object/dist/is-plain-object.mjs
18983 /*!
18984 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
18985 *
18986 * Copyright (c) 2014-2017, Jon Schlinkert.
18987 * Released under the MIT License.
18988 */
18989
18990 function isObject(o) {
18991 return Object.prototype.toString.call(o) === '[object Object]';
18992 }
18993
18994 function isPlainObject(o) {
18995 var ctor,prot;
18996
18997 if (isObject(o) === false) return false;
18998
18999 // If has modified constructor
19000 ctor = o.constructor;
19001 if (ctor === undefined) return true;
19002
19003 // If has modified prototype
19004 prot = ctor.prototype;
19005 if (isObject(prot) === false) return false;
19006
19007 // If constructor does not have an Object-specific method
19008 if (prot.hasOwnProperty('isPrototypeOf') === false) {
19009 return false;
19010 }
19011
19012 // Most likely a plain Object
19013 return true;
19014 }
19015
19016
19017
19018 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/set-nested-value.js
19019 /**
19020 * Sets the value at path of object.
19021 * If a portion of path doesn’t exist, it’s created.
19022 * Arrays are created for missing index properties while objects are created
19023 * for all other missing properties.
19024 *
19025 * This function intentionally mutates the input object.
19026 *
19027 * Inspired by _.set().
19028 *
19029 * @see https://lodash.com/docs/4.17.15#set
19030 *
19031 * @todo Needs to be deduplicated with its copy in `@wordpress/core-data`.
19032 *
19033 * @param {Object} object Object to modify
19034 * @param {Array} path Path of the property to set.
19035 * @param {*} value Value to set.
19036 */
19037 function setNestedValue(object, path, value) {
19038 if (!object || typeof object !== 'object') {
19039 return object;
19040 }
19041 path.reduce((acc, key, idx) => {
19042 if (acc[key] === undefined) {
19043 if (Number.isInteger(path[idx + 1])) {
19044 acc[key] = [];
19045 } else {
19046 acc[key] = {};
19047 }
19048 }
19049 if (idx === path.length - 1) {
19050 acc[key] = value;
19051 }
19052 return acc[key];
19053 }, object);
19054 return object;
19055 }
19056
19057 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/global-styles-provider/index.js
19058 /**
19059 * External dependencies
19060 */
19061
19062
19063
19064 /**
19065 * WordPress dependencies
19066 */
19067
19068
19069
19070
19071
19072
19073 /**
19074 * Internal dependencies
19075 */
19076
19077
19078
19079 const {
19080 GlobalStylesContext: global_styles_provider_GlobalStylesContext,
19081 cleanEmptyObject
19082 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
19083 function mergeBaseAndUserConfigs(base, user) {
19084 return cjs_default()(base, user, {
19085 // We only pass as arrays the presets,
19086 // in which case we want the new array of values
19087 // to override the old array (no merging).
19088 isMergeableObject: isPlainObject
19089 });
19090 }
19091
19092 /**
19093 * Resolves shared block style variation definitions from the user origin
19094 * under their respective block types and registers the block style if required.
19095 *
19096 * @param {Object} userConfig Current user origin global styles data.
19097 * @return {Object} Updated global styles data.
19098 */
19099 function useResolvedBlockStyleVariationsConfig(userConfig) {
19100 const {
19101 getBlockStyles
19102 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blocks_namespaceObject.store);
19103 const sharedVariations = userConfig?.styles?.blocks?.variations;
19104
19105 // Collect block style variation definitions to merge and unregistered
19106 // block styles for automatic registration.
19107 const [userConfigToMerge, unregisteredStyles] = (0,external_wp_element_namespaceObject.useMemo)(() => {
19108 if (!sharedVariations) {
19109 return [];
19110 }
19111 const variationsConfigToMerge = {};
19112 const unregisteredBlockStyles = [];
19113 Object.entries(sharedVariations).forEach(([variationName, variation]) => {
19114 if (!variation?.blockTypes?.length) {
19115 return;
19116 }
19117 variation.blockTypes.forEach(blockName => {
19118 const blockStyles = getBlockStyles(blockName);
19119 const registeredBlockStyle = blockStyles.find(({
19120 name
19121 }) => name === variationName);
19122 if (!registeredBlockStyle) {
19123 unregisteredBlockStyles.push([blockName, {
19124 name: variationName,
19125 label: variationName
19126 }]);
19127 }
19128 const path = ['styles', 'blocks', blockName, 'variations', variationName];
19129 setNestedValue(variationsConfigToMerge, path, variation);
19130 });
19131 });
19132 return [variationsConfigToMerge, unregisteredBlockStyles];
19133 }, [sharedVariations, getBlockStyles]);
19134
19135 // Automatically register missing block styles from variations.
19136 (0,external_wp_element_namespaceObject.useEffect)(() => unregisteredStyles?.forEach(unregisteredStyle => (0,external_wp_blocks_namespaceObject.registerBlockStyle)(...unregisteredStyle)), [unregisteredStyles]);
19137
19138 // Merge shared block style variation definitions into overall user config.
19139 const updatedConfig = (0,external_wp_element_namespaceObject.useMemo)(() => {
19140 if (!userConfigToMerge) {
19141 return userConfig;
19142 }
19143 return cjs_default()(userConfigToMerge, userConfig);
19144 }, [userConfigToMerge, userConfig]);
19145 return updatedConfig;
19146 }
19147 function useGlobalStylesUserConfig() {
19148 const {
19149 globalStylesId,
19150 isReady,
19151 settings,
19152 styles,
19153 _links
19154 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
19155 const {
19156 getEditedEntityRecord,
19157 hasFinishedResolution
19158 } = select(external_wp_coreData_namespaceObject.store);
19159 const _globalStylesId = select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentGlobalStylesId();
19160 const record = _globalStylesId ? getEditedEntityRecord('root', 'globalStyles', _globalStylesId) : undefined;
19161 let hasResolved = false;
19162 if (hasFinishedResolution('__experimentalGetCurrentGlobalStylesId')) {
19163 hasResolved = _globalStylesId ? hasFinishedResolution('getEditedEntityRecord', ['root', 'globalStyles', _globalStylesId]) : true;
19164 }
19165 return {
19166 globalStylesId: _globalStylesId,
19167 isReady: hasResolved,
19168 settings: record?.settings,
19169 styles: record?.styles,
19170 _links: record?._links
19171 };
19172 }, []);
19173 const {
19174 getEditedEntityRecord
19175 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
19176 const {
19177 editEntityRecord
19178 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
19179 const config = (0,external_wp_element_namespaceObject.useMemo)(() => {
19180 return {
19181 settings: settings !== null && settings !== void 0 ? settings : {},
19182 styles: styles !== null && styles !== void 0 ? styles : {},
19183 _links: _links !== null && _links !== void 0 ? _links : {}
19184 };
19185 }, [settings, styles, _links]);
19186 const setConfig = (0,external_wp_element_namespaceObject.useCallback)((callback, options = {}) => {
19187 var _record$styles, _record$settings, _record$_links;
19188 const record = getEditedEntityRecord('root', 'globalStyles', globalStylesId);
19189 const currentConfig = {
19190 styles: (_record$styles = record?.styles) !== null && _record$styles !== void 0 ? _record$styles : {},
19191 settings: (_record$settings = record?.settings) !== null && _record$settings !== void 0 ? _record$settings : {},
19192 _links: (_record$_links = record?._links) !== null && _record$_links !== void 0 ? _record$_links : {}
19193 };
19194 const updatedConfig = callback(currentConfig);
19195 editEntityRecord('root', 'globalStyles', globalStylesId, {
19196 styles: cleanEmptyObject(updatedConfig.styles) || {},
19197 settings: cleanEmptyObject(updatedConfig.settings) || {},
19198 _links: cleanEmptyObject(updatedConfig._links) || {}
19199 }, options);
19200 }, [globalStylesId]);
19201 return [isReady, config, setConfig];
19202 }
19203 function useGlobalStylesBaseConfig() {
19204 const baseConfig = (0,external_wp_data_namespaceObject.useSelect)(select => {
19205 return select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentThemeBaseGlobalStyles();
19206 }, []);
19207 return [!!baseConfig, baseConfig];
19208 }
19209 function useGlobalStylesContext() {
19210 const [isUserConfigReady, userConfig, setUserConfig] = useGlobalStylesUserConfig();
19211 const [isBaseConfigReady, baseConfig] = useGlobalStylesBaseConfig();
19212 const userConfigWithVariations = useResolvedBlockStyleVariationsConfig(userConfig);
19213 const mergedConfig = (0,external_wp_element_namespaceObject.useMemo)(() => {
19214 if (!baseConfig || !userConfigWithVariations) {
19215 return {};
19216 }
19217 return mergeBaseAndUserConfigs(baseConfig, userConfigWithVariations);
19218 }, [userConfigWithVariations, baseConfig]);
19219 const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
19220 return {
19221 isReady: isUserConfigReady && isBaseConfigReady,
19222 user: userConfigWithVariations,
19223 base: baseConfig,
19224 merged: mergedConfig,
19225 setUserConfig
19226 };
19227 }, [mergedConfig, userConfigWithVariations, baseConfig, setUserConfig, isUserConfigReady, isBaseConfigReady]);
19228 return context;
19229 }
19230 function GlobalStylesProvider({
19231 children
19232 }) {
19233 const context = useGlobalStylesContext();
19234 if (!context.isReady) {
19235 return null;
19236 }
19237 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(global_styles_provider_GlobalStylesContext.Provider, {
19238 value: context,
19239 children: children
19240 });
19241 }
19242
19243 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/use-block-editor-settings.js
19244 /**
19245 * WordPress dependencies
19246 */
19247
19248
19249
19250
19251
19252
19253
19254
19255
19256 /**
19257 * Internal dependencies
19258 */
19259
19260
19261
19262
19263
19264 const EMPTY_BLOCKS_LIST = [];
19265 const DEFAULT_STYLES = {};
19266 function __experimentalReusableBlocksSelect(select) {
19267 var _select$getEntityReco;
19268 return (_select$getEntityReco = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_block', {
19269 per_page: -1
19270 })) !== null && _select$getEntityReco !== void 0 ? _select$getEntityReco : EMPTY_BLOCKS_LIST;
19271 }
19272 const BLOCK_EDITOR_SETTINGS = ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalGlobalStylesBaseStyles', '__unstableGalleryWithImageBlocks', 'alignWide', 'blockInspectorTabs', 'allowedMimeTypes', 'bodyPlaceholder', 'canLockBlocks', 'capabilities', 'clearBlockSelection', 'codeEditingEnabled', 'colors', 'disableCustomColors', 'disableCustomFontSizes', 'disableCustomSpacingSizes', 'disableCustomGradients', 'disableLayoutStyles', 'enableCustomLineHeight', 'enableCustomSpacing', 'enableCustomUnits', 'enableOpenverseMediaCategory', 'fontSizes', 'gradients', 'generateAnchors', 'onNavigateToEntityRecord', 'imageDefaultSize', 'imageDimensions', 'imageEditing', 'imageSizes', 'isRTL', 'locale', 'maxWidth', 'postContentAttributes', 'postsPerPage', 'readOnly', 'sectionRootClientId', 'styles', 'titlePlaceholder', 'supportsLayout', 'widgetTypesToHideFromLegacyWidgetBlock', '__unstableHasCustomAppender', '__unstableIsPreviewMode', '__unstableResolvedAssets', '__unstableIsBlockBasedTheme', '__experimentalArchiveTitleTypeLabel', '__experimentalArchiveTitleNameLabel'];
19273 const {
19274 globalStylesDataKey,
19275 selectBlockPatternsKey,
19276 reusableBlocksSelectKey
19277 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
19278
19279 /**
19280 * React hook used to compute the block editor settings to use for the post editor.
19281 *
19282 * @param {Object} settings EditorProvider settings prop.
19283 * @param {string} postType Editor root level post type.
19284 * @param {string} postId Editor root level post ID.
19285 * @param {string} renderingMode Editor rendering mode.
19286 *
19287 * @return {Object} Block Editor Settings.
19288 */
19289 function useBlockEditorSettings(settings, postType, postId, renderingMode) {
19290 var _mergedGlobalStyles$s, _settings$__experimen, _settings$__experimen2;
19291 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
19292 const {
19293 allowRightClickOverrides,
19294 blockTypes,
19295 focusMode,
19296 hasFixedToolbar,
19297 isDistractionFree,
19298 keepCaretInsideBlock,
19299 hasUploadPermissions,
19300 hiddenBlockTypes,
19301 canUseUnfilteredHTML,
19302 userCanCreatePages,
19303 pageOnFront,
19304 pageForPosts,
19305 userPatternCategories,
19306 restBlockPatternCategories,
19307 sectionRootClientId
19308 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
19309 var _canUser;
19310 const {
19311 canUser,
19312 getRawEntityRecord,
19313 getEntityRecord,
19314 getUserPatternCategories,
19315 getBlockPatternCategories
19316 } = select(external_wp_coreData_namespaceObject.store);
19317 const {
19318 get
19319 } = select(external_wp_preferences_namespaceObject.store);
19320 const {
19321 getBlockTypes
19322 } = select(external_wp_blocks_namespaceObject.store);
19323 const {
19324 getBlocksByName,
19325 getBlockAttributes
19326 } = select(external_wp_blockEditor_namespaceObject.store);
19327 const siteSettings = canUser('read', 'settings') ? getEntityRecord('root', 'site') : undefined;
19328 function getSectionRootBlock() {
19329 var _getBlocksByName$find;
19330 if (renderingMode === 'template-locked') {
19331 var _getBlocksByName$;
19332 return (_getBlocksByName$ = getBlocksByName('core/post-content')?.[0]) !== null && _getBlocksByName$ !== void 0 ? _getBlocksByName$ : '';
19333 }
19334 return (_getBlocksByName$find = getBlocksByName('core/group').find(clientId => getBlockAttributes(clientId)?.tagName === 'main')) !== null && _getBlocksByName$find !== void 0 ? _getBlocksByName$find : '';
19335 }
19336 return {
19337 allowRightClickOverrides: get('core', 'allowRightClickOverrides'),
19338 blockTypes: getBlockTypes(),
19339 canUseUnfilteredHTML: getRawEntityRecord('postType', postType, postId)?._links?.hasOwnProperty('wp:action-unfiltered-html'),
19340 focusMode: get('core', 'focusMode'),
19341 hasFixedToolbar: get('core', 'fixedToolbar') || !isLargeViewport,
19342 hiddenBlockTypes: get('core', 'hiddenBlockTypes'),
19343 isDistractionFree: get('core', 'distractionFree'),
19344 keepCaretInsideBlock: get('core', 'keepCaretInsideBlock'),
19345 hasUploadPermissions: (_canUser = canUser('create', 'media')) !== null && _canUser !== void 0 ? _canUser : true,
19346 userCanCreatePages: canUser('create', 'pages'),
19347 pageOnFront: siteSettings?.page_on_front,
19348 pageForPosts: siteSettings?.page_for_posts,
19349 userPatternCategories: getUserPatternCategories(),
19350 restBlockPatternCategories: getBlockPatternCategories(),
19351 sectionRootClientId: getSectionRootBlock()
19352 };
19353 }, [postType, postId, isLargeViewport, renderingMode]);
19354 const {
19355 merged: mergedGlobalStyles
19356 } = useGlobalStylesContext();
19357 const globalStylesData = (_mergedGlobalStyles$s = mergedGlobalStyles.styles) !== null && _mergedGlobalStyles$s !== void 0 ? _mergedGlobalStyles$s : DEFAULT_STYLES;
19358 const settingsBlockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen :
19359 // WP 6.0
19360 settings.__experimentalBlockPatterns; // WP 5.9
19361 const settingsBlockPatternCategories = (_settings$__experimen2 = settings.__experimentalAdditionalBlockPatternCategories) !== null && _settings$__experimen2 !== void 0 ? _settings$__experimen2 :
19362 // WP 6.0
19363 settings.__experimentalBlockPatternCategories; // WP 5.9
19364
19365 const blockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatterns || [])].filter(({
19366 postTypes
19367 }) => {
19368 return !postTypes || Array.isArray(postTypes) && postTypes.includes(postType);
19369 }), [settingsBlockPatterns, postType]);
19370 const blockPatternCategories = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatternCategories || []), ...(restBlockPatternCategories || [])].filter((x, index, arr) => index === arr.findIndex(y => x.name === y.name)), [settingsBlockPatternCategories, restBlockPatternCategories]);
19371 const {
19372 undo,
19373 setIsInserterOpened
19374 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
19375 const {
19376 saveEntityRecord
19377 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
19378
19379 /**
19380 * Creates a Post entity.
19381 * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.
19382 *
19383 * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.
19384 * @return {Object} the post type object that was created.
19385 */
19386 const createPageEntity = (0,external_wp_element_namespaceObject.useCallback)(options => {
19387 if (!userCanCreatePages) {
19388 return Promise.reject({
19389 message: (0,external_wp_i18n_namespaceObject.__)('You do not have permission to create Pages.')
19390 });
19391 }
19392 return saveEntityRecord('postType', 'page', options);
19393 }, [saveEntityRecord, userCanCreatePages]);
19394 const allowedBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
19395 // Omit hidden block types if exists and non-empty.
19396 if (hiddenBlockTypes && hiddenBlockTypes.length > 0) {
19397 // Defer to passed setting for `allowedBlockTypes` if provided as
19398 // anything other than `true` (where `true` is equivalent to allow
19399 // all block types).
19400 const defaultAllowedBlockTypes = true === settings.allowedBlockTypes ? blockTypes.map(({
19401 name
19402 }) => name) : settings.allowedBlockTypes || [];
19403 return defaultAllowedBlockTypes.filter(type => !hiddenBlockTypes.includes(type));
19404 }
19405 return settings.allowedBlockTypes;
19406 }, [settings.allowedBlockTypes, hiddenBlockTypes, blockTypes]);
19407 const forceDisableFocusMode = settings.focusMode === false;
19408 return (0,external_wp_element_namespaceObject.useMemo)(() => {
19409 const blockEditorSettings = {
19410 ...Object.fromEntries(Object.entries(settings).filter(([key]) => BLOCK_EDITOR_SETTINGS.includes(key))),
19411 [globalStylesDataKey]: globalStylesData,
19412 allowedBlockTypes,
19413 allowRightClickOverrides,
19414 focusMode: focusMode && !forceDisableFocusMode,
19415 hasFixedToolbar,
19416 isDistractionFree,
19417 keepCaretInsideBlock,
19418 mediaUpload: hasUploadPermissions ? mediaUpload : undefined,
19419 __experimentalBlockPatterns: blockPatterns,
19420 [selectBlockPatternsKey]: select => {
19421 const {
19422 hasFinishedResolution,
19423 getBlockPatternsForPostType
19424 } = unlock(select(external_wp_coreData_namespaceObject.store));
19425 const patterns = getBlockPatternsForPostType(postType);
19426 return hasFinishedResolution('getBlockPatterns') ? patterns : undefined;
19427 },
19428 [reusableBlocksSelectKey]: __experimentalReusableBlocksSelect,
19429 __experimentalBlockPatternCategories: blockPatternCategories,
19430 __experimentalUserPatternCategories: userPatternCategories,
19431 __experimentalFetchLinkSuggestions: (search, searchOptions) => (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings),
19432 inserterMediaCategories: media_categories,
19433 __experimentalFetchRichUrlData: external_wp_coreData_namespaceObject.__experimentalFetchUrlData,
19434 // Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.
19435 // This might be better as a generic "canUser" selector.
19436 __experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,
19437 //Todo: this is only needed for native and should probably be removed.
19438 __experimentalUndo: undo,
19439 // Check whether we want all site editor frames to have outlines
19440 // including the navigation / pattern / parts editors.
19441 outlineMode: postType === 'wp_template',
19442 // Check these two properties: they were not present in the site editor.
19443 __experimentalCreatePageEntity: createPageEntity,
19444 __experimentalUserCanCreatePages: userCanCreatePages,
19445 pageOnFront,
19446 pageForPosts,
19447 __experimentalPreferPatternsOnRoot: postType === 'wp_template',
19448 templateLock: postType === 'wp_navigation' ? 'insert' : settings.templateLock,
19449 template: postType === 'wp_navigation' ? [['core/navigation', {}, []]] : settings.template,
19450 __experimentalSetIsInserterOpened: setIsInserterOpened
19451 };
19452 lock(blockEditorSettings, {
19453 sectionRootClientId
19454 });
19455 return blockEditorSettings;
19456 }, [allowedBlockTypes, allowRightClickOverrides, focusMode, forceDisableFocusMode, hasFixedToolbar, isDistractionFree, keepCaretInsideBlock, settings, hasUploadPermissions, userPatternCategories, blockPatterns, blockPatternCategories, canUseUnfilteredHTML, undo, createPageEntity, userCanCreatePages, pageOnFront, pageForPosts, postType, setIsInserterOpened, sectionRootClientId, globalStylesData]);
19457 }
19458 /* harmony default export */ const use_block_editor_settings = (useBlockEditorSettings);
19459
19460 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/disable-non-page-content-blocks.js
19461 /**
19462 * WordPress dependencies
19463 */
19464
19465
19466
19467
19468 const CONTENT_ONLY_BLOCKS = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.postContentBlockTypes', ['core/post-title', 'core/post-featured-image', 'core/post-content', 'core/template-part']);
19469
19470 /**
19471 * Component that when rendered, makes it so that the site editor allows only
19472 * page content to be edited.
19473 */
19474 function DisableNonPageContentBlocks() {
19475 // Note that there are two separate subscription because the result for each
19476 // returns a new array.
19477 const contentOnlyIds = (0,external_wp_data_namespaceObject.useSelect)(select => {
19478 const {
19479 getBlocksByName,
19480 getBlockParents,
19481 getBlockName
19482 } = select(external_wp_blockEditor_namespaceObject.store);
19483 return getBlocksByName(CONTENT_ONLY_BLOCKS).filter(clientId => getBlockParents(clientId).every(parentClientId => {
19484 const parentBlockName = getBlockName(parentClientId);
19485 return (
19486 // Ignore descendents of the query block.
19487 parentBlockName !== 'core/query' &&
19488 // Enable only the top-most block.
19489 !CONTENT_ONLY_BLOCKS.includes(parentBlockName)
19490 );
19491 }));
19492 }, []);
19493 const disabledIds = (0,external_wp_data_namespaceObject.useSelect)(select => {
19494 const {
19495 getBlocksByName,
19496 getBlockOrder
19497 } = select(external_wp_blockEditor_namespaceObject.store);
19498 return getBlocksByName(['core/template-part']).flatMap(clientId => getBlockOrder(clientId));
19499 }, []);
19500 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
19501 (0,external_wp_element_namespaceObject.useEffect)(() => {
19502 const {
19503 setBlockEditingMode,
19504 unsetBlockEditingMode
19505 } = registry.dispatch(external_wp_blockEditor_namespaceObject.store);
19506 registry.batch(() => {
19507 setBlockEditingMode('', 'disabled');
19508 for (const clientId of contentOnlyIds) {
19509 setBlockEditingMode(clientId, 'contentOnly');
19510 }
19511 for (const clientId of disabledIds) {
19512 setBlockEditingMode(clientId, 'disabled');
19513 }
19514 });
19515 return () => {
19516 registry.batch(() => {
19517 unsetBlockEditingMode('');
19518 for (const clientId of contentOnlyIds) {
19519 unsetBlockEditingMode(clientId);
19520 }
19521 for (const clientId of disabledIds) {
19522 unsetBlockEditingMode(clientId);
19523 }
19524 });
19525 };
19526 }, [contentOnlyIds, disabledIds, registry]);
19527 return null;
19528 }
19529
19530 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/navigation-block-editing-mode.js
19531 /**
19532 * WordPress dependencies
19533 */
19534
19535
19536
19537
19538 /**
19539 * For the Navigation block editor, we need to force the block editor to contentOnly for that block.
19540 *
19541 * Set block editing mode to contentOnly when entering Navigation focus mode.
19542 * this ensures that non-content controls on the block will be hidden and thus
19543 * the user can focus on editing the Navigation Menu content only.
19544 */
19545
19546 function NavigationBlockEditingMode() {
19547 // In the navigation block editor,
19548 // the navigation block is the only root block.
19549 const blockClientId = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getBlockOrder()?.[0], []);
19550 const {
19551 setBlockEditingMode,
19552 unsetBlockEditingMode
19553 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
19554 (0,external_wp_element_namespaceObject.useEffect)(() => {
19555 if (!blockClientId) {
19556 return;
19557 }
19558 setBlockEditingMode(blockClientId, 'contentOnly');
19559 return () => {
19560 unsetBlockEditingMode(blockClientId);
19561 };
19562 }, [blockClientId, unsetBlockEditingMode, setBlockEditingMode]);
19563 }
19564
19565 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/use-hide-blocks-from-inserter.js
19566 /**
19567 * WordPress dependencies
19568 */
19569
19570
19571
19572 // These post types are "structural" block lists.
19573 // We should be allowed to use
19574 // the post content and template parts blocks within them.
19575 const POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART = ['wp_block', 'wp_template', 'wp_template_part'];
19576
19577 /**
19578 * In some specific contexts,
19579 * the template part and post content blocks need to be hidden.
19580 *
19581 * @param {string} postType Post Type
19582 * @param {string} mode Rendering mode
19583 */
19584 function useHideBlocksFromInserter(postType, mode) {
19585 (0,external_wp_element_namespaceObject.useEffect)(() => {
19586 /*
19587 * Prevent adding template part in the editor.
19588 */
19589 (0,external_wp_hooks_namespaceObject.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', (canInsert, blockType) => {
19590 if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(postType) && blockType.name === 'core/template-part' && mode === 'post-only') {
19591 return false;
19592 }
19593 return canInsert;
19594 });
19595
19596 /*
19597 * Prevent adding post content block (except in query block) in the editor.
19598 */
19599 (0,external_wp_hooks_namespaceObject.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removePostContentFromInserter', (canInsert, blockType, rootClientId, {
19600 getBlockParentsByBlockName
19601 }) => {
19602 if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(postType) && blockType.name === 'core/post-content') {
19603 return getBlockParentsByBlockName(rootClientId, 'core/query').length > 0;
19604 }
19605 return canInsert;
19606 });
19607 return () => {
19608 (0,external_wp_hooks_namespaceObject.removeFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter');
19609 (0,external_wp_hooks_namespaceObject.removeFilter)('blockEditor.__unstableCanInsertBlockType', 'removePostContentFromInserter');
19610 };
19611 }, [postType, mode]);
19612 }
19613
19614 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/keyboard.js
19615 /**
19616 * WordPress dependencies
19617 */
19618
19619
19620
19621 const keyboard = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, {
19622 xmlns: "http://www.w3.org/2000/svg",
19623 viewBox: "0 0 24 24",
19624 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19625 d: "m16 15.5h-8v-1.5h8zm-7.5-2.5h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm-9-3h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2zm3 0h-2v-2h2z"
19626 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19627 d: "m18.5 6.5h-13a.5.5 0 0 0 -.5.5v9.5a.5.5 0 0 0 .5.5h13a.5.5 0 0 0 .5-.5v-9.5a.5.5 0 0 0 -.5-.5zm-13-1.5h13a2 2 0 0 1 2 2v9.5a2 2 0 0 1 -2 2h-13a2 2 0 0 1 -2-2v-9.5a2 2 0 0 1 2-2z"
19628 })]
19629 });
19630 /* harmony default export */ const library_keyboard = (keyboard);
19631
19632 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/list-view.js
19633 /**
19634 * WordPress dependencies
19635 */
19636
19637
19638 const listView = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19639 viewBox: "0 0 24 24",
19640 xmlns: "http://www.w3.org/2000/svg",
19641 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19642 d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z"
19643 })
19644 });
19645 /* harmony default export */ const list_view = (listView);
19646
19647 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/code.js
19648 /**
19649 * WordPress dependencies
19650 */
19651
19652
19653 const code = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19654 viewBox: "0 0 24 24",
19655 xmlns: "http://www.w3.org/2000/svg",
19656 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19657 d: "M20.8 10.7l-4.3-4.3-1.1 1.1 4.3 4.3c.1.1.1.3 0 .4l-4.3 4.3 1.1 1.1 4.3-4.3c.7-.8.7-1.9 0-2.6zM4.2 11.8l4.3-4.3-1-1-4.3 4.3c-.7.7-.7 1.8 0 2.5l4.3 4.3 1.1-1.1-4.3-4.3c-.2-.1-.2-.3-.1-.4z"
19658 })
19659 });
19660 /* harmony default export */ const library_code = (code);
19661
19662 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/drawer-left.js
19663 /**
19664 * WordPress dependencies
19665 */
19666
19667
19668 const drawerLeft = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19669 width: "24",
19670 height: "24",
19671 xmlns: "http://www.w3.org/2000/svg",
19672 viewBox: "0 0 24 24",
19673 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19674 fillRule: "evenodd",
19675 clipRule: "evenodd",
19676 d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zM8.5 18.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h2.5v13zm10-.5c0 .3-.2.5-.5.5h-8v-13h8c.3 0 .5.2.5.5v12z"
19677 })
19678 });
19679 /* harmony default export */ const drawer_left = (drawerLeft);
19680
19681 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/drawer-right.js
19682 /**
19683 * WordPress dependencies
19684 */
19685
19686
19687 const drawerRight = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19688 width: "24",
19689 height: "24",
19690 xmlns: "http://www.w3.org/2000/svg",
19691 viewBox: "0 0 24 24",
19692 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19693 fillRule: "evenodd",
19694 clipRule: "evenodd",
19695 d: "M18 4H6c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm-4 14.5H6c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h8v13zm4.5-.5c0 .3-.2.5-.5.5h-2.5v-13H18c.3 0 .5.2.5.5v12z"
19696 })
19697 });
19698 /* harmony default export */ const drawer_right = (drawerRight);
19699
19700 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/block-default.js
19701 /**
19702 * WordPress dependencies
19703 */
19704
19705
19706 const blockDefault = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19707 xmlns: "http://www.w3.org/2000/svg",
19708 viewBox: "0 0 24 24",
19709 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19710 d: "M19 8h-1V6h-5v2h-2V6H6v2H5c-1.1 0-2 .9-2 2v8c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2v-8c0-1.1-.9-2-2-2zm.5 10c0 .3-.2.5-.5.5H5c-.3 0-.5-.2-.5-.5v-8c0-.3.2-.5.5-.5h14c.3 0 .5.2.5.5v8z"
19711 })
19712 });
19713 /* harmony default export */ const block_default = (blockDefault);
19714
19715 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/format-list-bullets.js
19716 /**
19717 * WordPress dependencies
19718 */
19719
19720
19721 const formatListBullets = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19722 xmlns: "http://www.w3.org/2000/svg",
19723 viewBox: "0 0 24 24",
19724 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19725 d: "M11.1 15.8H20v-1.5h-8.9v1.5zm0-8.6v1.5H20V7.2h-8.9zM6 13c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-7c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z"
19726 })
19727 });
19728 /* harmony default export */ const format_list_bullets = (formatListBullets);
19729
19730 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/external.js
19731 /**
19732 * WordPress dependencies
19733 */
19734
19735
19736 const external = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19737 xmlns: "http://www.w3.org/2000/svg",
19738 viewBox: "0 0 24 24",
19739 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19740 d: "M19.5 4.5h-7V6h4.44l-5.97 5.97 1.06 1.06L18 7.06v4.44h1.5v-7Zm-13 1a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h10a2 2 0 0 0 2-2v-3H17v3a.5.5 0 0 1-.5.5h-10a.5.5 0 0 1-.5-.5v-10a.5.5 0 0 1 .5-.5h3V5.5h-3Z"
19741 })
19742 });
19743 /* harmony default export */ const library_external = (external);
19744
19745 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/pencil.js
19746 /**
19747 * WordPress dependencies
19748 */
19749
19750
19751 const pencil = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19752 xmlns: "http://www.w3.org/2000/svg",
19753 viewBox: "0 0 24 24",
19754 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19755 d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"
19756 })
19757 });
19758 /* harmony default export */ const library_pencil = (pencil);
19759
19760 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/edit.js
19761 /**
19762 * Internal dependencies
19763 */
19764
19765
19766 /* harmony default export */ const edit = (library_pencil);
19767
19768 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/pattern-rename-modal/index.js
19769 /**
19770 * WordPress dependencies
19771 */
19772
19773
19774
19775
19776
19777 /**
19778 * Internal dependencies
19779 */
19780
19781
19782
19783
19784 const {
19785 RenamePatternModal
19786 } = unlock(external_wp_patterns_namespaceObject.privateApis);
19787 const modalName = 'editor/pattern-rename';
19788 function PatternRenameModal() {
19789 const {
19790 record,
19791 postType
19792 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
19793 const {
19794 getCurrentPostType,
19795 getCurrentPostId
19796 } = select(store_store);
19797 const {
19798 getEditedEntityRecord
19799 } = select(external_wp_coreData_namespaceObject.store);
19800 const _postType = getCurrentPostType();
19801 return {
19802 record: getEditedEntityRecord('postType', _postType, getCurrentPostId()),
19803 postType: _postType
19804 };
19805 }, []);
19806 const {
19807 closeModal
19808 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
19809 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(modalName));
19810 if (!isActive || postType !== PATTERN_POST_TYPE) {
19811 return null;
19812 }
19813 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(RenamePatternModal, {
19814 onClose: closeModal,
19815 pattern: record
19816 });
19817 }
19818
19819 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/pattern-duplicate-modal/index.js
19820 /**
19821 * WordPress dependencies
19822 */
19823
19824
19825
19826
19827
19828 /**
19829 * Internal dependencies
19830 */
19831
19832
19833
19834
19835 const {
19836 DuplicatePatternModal
19837 } = unlock(external_wp_patterns_namespaceObject.privateApis);
19838 const pattern_duplicate_modal_modalName = 'editor/pattern-duplicate';
19839 function PatternDuplicateModal() {
19840 const {
19841 record,
19842 postType
19843 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
19844 const {
19845 getCurrentPostType,
19846 getCurrentPostId
19847 } = select(store_store);
19848 const {
19849 getEditedEntityRecord
19850 } = select(external_wp_coreData_namespaceObject.store);
19851 const _postType = getCurrentPostType();
19852 return {
19853 record: getEditedEntityRecord('postType', _postType, getCurrentPostId()),
19854 postType: _postType
19855 };
19856 }, []);
19857 const {
19858 closeModal
19859 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
19860 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(pattern_duplicate_modal_modalName));
19861 if (!isActive || postType !== PATTERN_POST_TYPE) {
19862 return null;
19863 }
19864 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DuplicatePatternModal, {
19865 onClose: closeModal,
19866 onSuccess: () => closeModal(),
19867 pattern: record
19868 });
19869 }
19870
19871 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/commands/index.js
19872 /**
19873 * WordPress dependencies
19874 */
19875
19876
19877
19878
19879
19880
19881
19882
19883
19884
19885 /**
19886 * Internal dependencies
19887 */
19888
19889
19890
19891
19892 function useEditorCommandLoader() {
19893 const {
19894 editorMode,
19895 isListViewOpen,
19896 showBlockBreadcrumbs,
19897 isDistractionFree,
19898 isTopToolbar,
19899 isFocusMode,
19900 isPreviewMode,
19901 isViewable,
19902 isCodeEditingEnabled,
19903 isRichEditingEnabled,
19904 isPublishSidebarEnabled
19905 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
19906 var _get, _getPostType$viewable;
19907 const {
19908 get
19909 } = select(external_wp_preferences_namespaceObject.store);
19910 const {
19911 isListViewOpened,
19912 getCurrentPostType,
19913 getEditorSettings
19914 } = select(store_store);
19915 const {
19916 getSettings
19917 } = select(external_wp_blockEditor_namespaceObject.store);
19918 const {
19919 getPostType
19920 } = select(external_wp_coreData_namespaceObject.store);
19921 return {
19922 editorMode: (_get = get('core', 'editorMode')) !== null && _get !== void 0 ? _get : 'visual',
19923 isListViewOpen: isListViewOpened(),
19924 showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'),
19925 isDistractionFree: get('core', 'distractionFree'),
19926 isFocusMode: get('core', 'focusMode'),
19927 isTopToolbar: get('core', 'fixedToolbar'),
19928 isPreviewMode: getSettings().__unstableIsPreviewMode,
19929 isViewable: (_getPostType$viewable = getPostType(getCurrentPostType())?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false,
19930 isCodeEditingEnabled: getEditorSettings().codeEditingEnabled,
19931 isRichEditingEnabled: getEditorSettings().richEditingEnabled,
19932 isPublishSidebarEnabled: select(store_store).isPublishSidebarEnabled()
19933 };
19934 }, []);
19935 const {
19936 getActiveComplementaryArea
19937 } = (0,external_wp_data_namespaceObject.useSelect)(store);
19938 const {
19939 toggle
19940 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
19941 const {
19942 createInfoNotice
19943 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
19944 const {
19945 __unstableSaveForPreview,
19946 setIsListViewOpened,
19947 switchEditorMode,
19948 toggleDistractionFree
19949 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
19950 const {
19951 openModal,
19952 enableComplementaryArea,
19953 disableComplementaryArea
19954 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
19955 const {
19956 getCurrentPostId
19957 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
19958 const allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;
19959 if (isPreviewMode) {
19960 return {
19961 commands: [],
19962 isLoading: false
19963 };
19964 }
19965 const commands = [];
19966 commands.push({
19967 name: 'core/open-shortcut-help',
19968 label: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
19969 icon: library_keyboard,
19970 callback: () => {
19971 openModal('editor/keyboard-shortcut-help');
19972 }
19973 });
19974 commands.push({
19975 name: 'core/toggle-distraction-free',
19976 label: isDistractionFree ? (0,external_wp_i18n_namespaceObject.__)('Exit Distraction Free') : (0,external_wp_i18n_namespaceObject.__)('Enter Distraction Free'),
19977 callback: ({
19978 close
19979 }) => {
19980 toggleDistractionFree();
19981 close();
19982 }
19983 });
19984 commands.push({
19985 name: 'core/open-preferences',
19986 label: (0,external_wp_i18n_namespaceObject.__)('Editor preferences'),
19987 callback: () => {
19988 openModal('editor/preferences');
19989 }
19990 });
19991 commands.push({
19992 name: 'core/toggle-spotlight-mode',
19993 label: (0,external_wp_i18n_namespaceObject.__)('Toggle spotlight'),
19994 callback: ({
19995 close
19996 }) => {
19997 toggle('core', 'focusMode');
19998 close();
19999 createInfoNotice(isFocusMode ? (0,external_wp_i18n_namespaceObject.__)('Spotlight off.') : (0,external_wp_i18n_namespaceObject.__)('Spotlight on.'), {
20000 id: 'core/editor/toggle-spotlight-mode/notice',
20001 type: 'snackbar',
20002 actions: [{
20003 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
20004 onClick: () => {
20005 toggle('core', 'focusMode');
20006 }
20007 }]
20008 });
20009 }
20010 });
20011 commands.push({
20012 name: 'core/toggle-list-view',
20013 label: isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('Close List View') : (0,external_wp_i18n_namespaceObject.__)('Open List View'),
20014 icon: list_view,
20015 callback: ({
20016 close
20017 }) => {
20018 setIsListViewOpened(!isListViewOpen);
20019 close();
20020 createInfoNotice(isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('List View off.') : (0,external_wp_i18n_namespaceObject.__)('List View on.'), {
20021 id: 'core/editor/toggle-list-view/notice',
20022 type: 'snackbar'
20023 });
20024 }
20025 });
20026 commands.push({
20027 name: 'core/toggle-top-toolbar',
20028 label: (0,external_wp_i18n_namespaceObject.__)('Toggle top toolbar'),
20029 callback: ({
20030 close
20031 }) => {
20032 toggle('core', 'fixedToolbar');
20033 if (isDistractionFree) {
20034 toggleDistractionFree();
20035 }
20036 close();
20037 createInfoNotice(isTopToolbar ? (0,external_wp_i18n_namespaceObject.__)('Top toolbar off.') : (0,external_wp_i18n_namespaceObject.__)('Top toolbar on.'), {
20038 id: 'core/editor/toggle-top-toolbar/notice',
20039 type: 'snackbar',
20040 actions: [{
20041 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
20042 onClick: () => {
20043 toggle('core', 'fixedToolbar');
20044 }
20045 }]
20046 });
20047 }
20048 });
20049 if (allowSwitchEditorMode) {
20050 commands.push({
20051 name: 'core/toggle-code-editor',
20052 label: editorMode === 'visual' ? (0,external_wp_i18n_namespaceObject.__)('Open code editor') : (0,external_wp_i18n_namespaceObject.__)('Exit code editor'),
20053 icon: library_code,
20054 callback: ({
20055 close
20056 }) => {
20057 switchEditorMode(editorMode === 'visual' ? 'text' : 'visual');
20058 close();
20059 }
20060 });
20061 }
20062 commands.push({
20063 name: 'core/toggle-breadcrumbs',
20064 label: showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Hide block breadcrumbs') : (0,external_wp_i18n_namespaceObject.__)('Show block breadcrumbs'),
20065 callback: ({
20066 close
20067 }) => {
20068 toggle('core', 'showBlockBreadcrumbs');
20069 close();
20070 createInfoNotice(showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs hidden.') : (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs visible.'), {
20071 id: 'core/editor/toggle-breadcrumbs/notice',
20072 type: 'snackbar'
20073 });
20074 }
20075 });
20076 commands.push({
20077 name: 'core/open-settings-sidebar',
20078 label: (0,external_wp_i18n_namespaceObject.__)('Toggle settings sidebar'),
20079 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right,
20080 callback: ({
20081 close
20082 }) => {
20083 const activeSidebar = getActiveComplementaryArea('core');
20084 close();
20085 if (activeSidebar === 'edit-post/document') {
20086 disableComplementaryArea('core');
20087 } else {
20088 enableComplementaryArea('core', 'edit-post/document');
20089 }
20090 }
20091 });
20092 commands.push({
20093 name: 'core/open-block-inspector',
20094 label: (0,external_wp_i18n_namespaceObject.__)('Toggle block inspector'),
20095 icon: block_default,
20096 callback: ({
20097 close
20098 }) => {
20099 const activeSidebar = getActiveComplementaryArea('core');
20100 close();
20101 if (activeSidebar === 'edit-post/block') {
20102 disableComplementaryArea('core');
20103 } else {
20104 enableComplementaryArea('core', 'edit-post/block');
20105 }
20106 }
20107 });
20108 commands.push({
20109 name: 'core/toggle-publish-sidebar',
20110 label: isPublishSidebarEnabled ? (0,external_wp_i18n_namespaceObject.__)('Disable pre-publish checks') : (0,external_wp_i18n_namespaceObject.__)('Enable pre-publish checks'),
20111 icon: format_list_bullets,
20112 callback: ({
20113 close
20114 }) => {
20115 close();
20116 toggle('core', 'isPublishSidebarEnabled');
20117 createInfoNotice(isPublishSidebarEnabled ? (0,external_wp_i18n_namespaceObject.__)('Pre-publish checks disabled.') : (0,external_wp_i18n_namespaceObject.__)('Pre-publish checks enabled.'), {
20118 id: 'core/editor/publish-sidebar/notice',
20119 type: 'snackbar'
20120 });
20121 }
20122 });
20123 if (isViewable) {
20124 commands.push({
20125 name: 'core/preview-link',
20126 label: (0,external_wp_i18n_namespaceObject.__)('Preview in a new tab'),
20127 icon: library_external,
20128 callback: async ({
20129 close
20130 }) => {
20131 close();
20132 const postId = getCurrentPostId();
20133 const link = await __unstableSaveForPreview();
20134 window.open(link, `wp-preview-${postId}`);
20135 }
20136 });
20137 }
20138 return {
20139 commands,
20140 isLoading: false
20141 };
20142 }
20143 function useEditedEntityContextualCommands() {
20144 const {
20145 postType
20146 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20147 const {
20148 getCurrentPostType
20149 } = select(store_store);
20150 return {
20151 postType: getCurrentPostType()
20152 };
20153 }, []);
20154 const {
20155 openModal
20156 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20157 const commands = [];
20158 if (postType === PATTERN_POST_TYPE) {
20159 commands.push({
20160 name: 'core/rename-pattern',
20161 label: (0,external_wp_i18n_namespaceObject.__)('Rename pattern'),
20162 icon: edit,
20163 callback: ({
20164 close
20165 }) => {
20166 openModal(modalName);
20167 close();
20168 }
20169 });
20170 commands.push({
20171 name: 'core/duplicate-pattern',
20172 label: (0,external_wp_i18n_namespaceObject.__)('Duplicate pattern'),
20173 icon: library_symbol,
20174 callback: ({
20175 close
20176 }) => {
20177 openModal(pattern_duplicate_modal_modalName);
20178 close();
20179 }
20180 });
20181 }
20182 return {
20183 isLoading: false,
20184 commands
20185 };
20186 }
20187 function useCommands() {
20188 (0,external_wp_commands_namespaceObject.useCommandLoader)({
20189 name: 'core/editor/edit-ui',
20190 hook: useEditorCommandLoader
20191 });
20192 (0,external_wp_commands_namespaceObject.useCommandLoader)({
20193 name: 'core/editor/contextual-commands',
20194 hook: useEditedEntityContextualCommands,
20195 context: 'entity-edit'
20196 });
20197 }
20198
20199 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-removal-warnings/index.js
20200 /**
20201 * WordPress dependencies
20202 */
20203
20204
20205
20206
20207
20208
20209 /**
20210 * Internal dependencies
20211 */
20212
20213
20214
20215 const {
20216 BlockRemovalWarningModal
20217 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
20218
20219 // Prevent accidental removal of certain blocks, asking the user for confirmation first.
20220 const TEMPLATE_BLOCKS = ['core/post-content', 'core/post-template', 'core/query'];
20221 const BLOCK_REMOVAL_RULES = [{
20222 // Template blocks.
20223 // The warning is only shown when a user manipulates templates or template parts.
20224 postTypes: ['wp_template', 'wp_template_part'],
20225 callback(removedBlocks) {
20226 const removedTemplateBlocks = removedBlocks.filter(({
20227 name
20228 }) => TEMPLATE_BLOCKS.includes(name));
20229 if (removedTemplateBlocks.length) {
20230 return (0,external_wp_i18n_namespaceObject._n)('Deleting this block will stop your post or page content from displaying on this template. It is not recommended.', 'Some of the deleted blocks will stop your post or page content from displaying on this template. It is not recommended.', removedBlocks.length);
20231 }
20232 }
20233 }, {
20234 // Pattern overrides.
20235 // The warning is only shown when the user edits a pattern.
20236 postTypes: ['wp_block'],
20237 callback(removedBlocks) {
20238 const removedBlocksWithOverrides = removedBlocks.filter(({
20239 attributes
20240 }) => attributes?.metadata?.bindings && Object.values(attributes.metadata.bindings).some(binding => binding.source === 'core/pattern-overrides'));
20241 if (removedBlocksWithOverrides.length) {
20242 return (0,external_wp_i18n_namespaceObject._n)('The deleted block allows instance overrides. Removing it may result in content not displaying where this pattern is used. Are you sure you want to proceed?', 'Some of the deleted blocks allow instance overrides. Removing them may result in content not displaying where this pattern is used. Are you sure you want to proceed?', removedBlocks.length);
20243 }
20244 }
20245 }];
20246 function BlockRemovalWarnings() {
20247 const currentPostType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
20248 const removalRulesForPostType = (0,external_wp_element_namespaceObject.useMemo)(() => BLOCK_REMOVAL_RULES.filter(rule => rule.postTypes.includes(currentPostType)), [currentPostType]);
20249
20250 // `BlockRemovalWarnings` is rendered in the editor provider, a shared component
20251 // across react native and web. However, `BlockRemovalWarningModal` is web only.
20252 // Check it exists before trying to render it.
20253 if (!BlockRemovalWarningModal) {
20254 return null;
20255 }
20256 if (!removalRulesForPostType) {
20257 return null;
20258 }
20259 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockRemovalWarningModal, {
20260 rules: removalRulesForPostType
20261 });
20262 }
20263
20264 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/start-page-options/index.js
20265 /**
20266 * WordPress dependencies
20267 */
20268
20269
20270
20271
20272
20273
20274
20275
20276
20277 /**
20278 * Internal dependencies
20279 */
20280
20281
20282
20283 function useStartPatterns() {
20284 // A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,
20285 // and it has no postTypes declared and the current post type is page or if
20286 // the current post type is part of the postTypes declared.
20287 const {
20288 blockPatternsWithPostContentBlockType,
20289 postType
20290 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20291 const {
20292 getPatternsByBlockTypes,
20293 getBlocksByName
20294 } = select(external_wp_blockEditor_namespaceObject.store);
20295 const {
20296 getCurrentPostType,
20297 getRenderingMode
20298 } = select(store_store);
20299 const rootClientId = getRenderingMode() === 'post-only' ? '' : getBlocksByName('core/post-content')?.[0];
20300 return {
20301 blockPatternsWithPostContentBlockType: getPatternsByBlockTypes('core/post-content', rootClientId),
20302 postType: getCurrentPostType()
20303 };
20304 }, []);
20305 return (0,external_wp_element_namespaceObject.useMemo)(() => {
20306 // filter patterns without postTypes declared if the current postType is page
20307 // or patterns that declare the current postType in its post type array.
20308 return blockPatternsWithPostContentBlockType.filter(pattern => {
20309 return postType === 'page' && !pattern.postTypes || Array.isArray(pattern.postTypes) && pattern.postTypes.includes(postType);
20310 });
20311 }, [postType, blockPatternsWithPostContentBlockType]);
20312 }
20313 function PatternSelection({
20314 blockPatterns,
20315 onChoosePattern
20316 }) {
20317 const shownBlockPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(blockPatterns);
20318 const {
20319 editEntityRecord
20320 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
20321 const {
20322 postType,
20323 postId
20324 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20325 const {
20326 getCurrentPostType,
20327 getCurrentPostId
20328 } = select(store_store);
20329 return {
20330 postType: getCurrentPostType(),
20331 postId: getCurrentPostId()
20332 };
20333 }, []);
20334 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
20335 blockPatterns: blockPatterns,
20336 shownPatterns: shownBlockPatterns,
20337 onClickPattern: (_pattern, blocks) => {
20338 editEntityRecord('postType', postType, postId, {
20339 blocks,
20340 content: ({
20341 blocks: blocksForSerialization = []
20342 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization)
20343 });
20344 onChoosePattern();
20345 }
20346 });
20347 }
20348 function StartPageOptionsModal({
20349 onClose
20350 }) {
20351 const startPatterns = useStartPatterns();
20352 const hasStartPattern = startPatterns.length > 0;
20353 if (!hasStartPattern) {
20354 return null;
20355 }
20356 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
20357 title: (0,external_wp_i18n_namespaceObject.__)('Choose a pattern'),
20358 isFullScreen: true,
20359 onRequestClose: onClose,
20360 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
20361 className: "editor-start-page-options__modal-content",
20362 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternSelection, {
20363 blockPatterns: startPatterns,
20364 onChoosePattern: onClose
20365 })
20366 })
20367 });
20368 }
20369 function StartPageOptions() {
20370 const [isClosed, setIsClosed] = (0,external_wp_element_namespaceObject.useState)(false);
20371 const {
20372 shouldEnableModal,
20373 postType,
20374 postId
20375 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20376 const {
20377 isEditedPostDirty,
20378 isEditedPostEmpty,
20379 getCurrentPostType,
20380 getCurrentPostId
20381 } = select(store_store);
20382 const _postType = getCurrentPostType();
20383 return {
20384 shouldEnableModal: !isEditedPostDirty() && isEditedPostEmpty() && TEMPLATE_POST_TYPE !== _postType,
20385 postType: _postType,
20386 postId: getCurrentPostId()
20387 };
20388 }, []);
20389 (0,external_wp_element_namespaceObject.useEffect)(() => {
20390 // Should reset the modal state when navigating to a new page/post.
20391 setIsClosed(false);
20392 }, [postType, postId]);
20393 if (!shouldEnableModal || isClosed) {
20394 return null;
20395 }
20396 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(StartPageOptionsModal, {
20397 onClose: () => setIsClosed(true)
20398 });
20399 }
20400
20401 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/keyboard-shortcut-help-modal/config.js
20402 /**
20403 * WordPress dependencies
20404 */
20405
20406 const textFormattingShortcuts = [{
20407 keyCombination: {
20408 modifier: 'primary',
20409 character: 'b'
20410 },
20411 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.')
20412 }, {
20413 keyCombination: {
20414 modifier: 'primary',
20415 character: 'i'
20416 },
20417 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.')
20418 }, {
20419 keyCombination: {
20420 modifier: 'primary',
20421 character: 'k'
20422 },
20423 description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.')
20424 }, {
20425 keyCombination: {
20426 modifier: 'primaryShift',
20427 character: 'k'
20428 },
20429 description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.')
20430 }, {
20431 keyCombination: {
20432 character: '[['
20433 },
20434 description: (0,external_wp_i18n_namespaceObject.__)('Insert a link to a post or page.')
20435 }, {
20436 keyCombination: {
20437 modifier: 'primary',
20438 character: 'u'
20439 },
20440 description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.')
20441 }, {
20442 keyCombination: {
20443 modifier: 'access',
20444 character: 'd'
20445 },
20446 description: (0,external_wp_i18n_namespaceObject.__)('Strikethrough the selected text.')
20447 }, {
20448 keyCombination: {
20449 modifier: 'access',
20450 character: 'x'
20451 },
20452 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text inline code.')
20453 }, {
20454 keyCombination: {
20455 modifier: 'access',
20456 character: '0'
20457 },
20458 aliases: [{
20459 modifier: 'access',
20460 character: '7'
20461 }],
20462 description: (0,external_wp_i18n_namespaceObject.__)('Convert the current heading to a paragraph.')
20463 }, {
20464 keyCombination: {
20465 modifier: 'access',
20466 character: '1-6'
20467 },
20468 description: (0,external_wp_i18n_namespaceObject.__)('Convert the current paragraph or heading to a heading of level 1 to 6.')
20469 }, {
20470 keyCombination: {
20471 modifier: 'primaryShift',
20472 character: 'SPACE'
20473 },
20474 description: (0,external_wp_i18n_namespaceObject.__)('Add non breaking space.')
20475 }];
20476
20477 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/keyboard-shortcut-help-modal/shortcut.js
20478 /**
20479 * WordPress dependencies
20480 */
20481
20482
20483
20484
20485
20486 function KeyCombination({
20487 keyCombination,
20488 forceAriaLabel
20489 }) {
20490 const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character;
20491 const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character;
20492 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("kbd", {
20493 className: "editor-keyboard-shortcut-help-modal__shortcut-key-combination",
20494 "aria-label": forceAriaLabel || ariaLabel,
20495 children: (Array.isArray(shortcut) ? shortcut : [shortcut]).map((character, index) => {
20496 if (character === '+') {
20497 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.Fragment, {
20498 children: character
20499 }, index);
20500 }
20501 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("kbd", {
20502 className: "editor-keyboard-shortcut-help-modal__shortcut-key",
20503 children: character
20504 }, index);
20505 })
20506 });
20507 }
20508 function Shortcut({
20509 description,
20510 keyCombination,
20511 aliases = [],
20512 ariaLabel
20513 }) {
20514 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
20515 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
20516 className: "editor-keyboard-shortcut-help-modal__shortcut-description",
20517 children: description
20518 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
20519 className: "editor-keyboard-shortcut-help-modal__shortcut-term",
20520 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(KeyCombination, {
20521 keyCombination: keyCombination,
20522 forceAriaLabel: ariaLabel
20523 }), aliases.map((alias, index) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(KeyCombination, {
20524 keyCombination: alias,
20525 forceAriaLabel: ariaLabel
20526 }, index))]
20527 })]
20528 });
20529 }
20530 /* harmony default export */ const keyboard_shortcut_help_modal_shortcut = (Shortcut);
20531
20532 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js
20533 /**
20534 * WordPress dependencies
20535 */
20536
20537
20538
20539 /**
20540 * Internal dependencies
20541 */
20542
20543
20544 function DynamicShortcut({
20545 name
20546 }) {
20547 const {
20548 keyCombination,
20549 description,
20550 aliases
20551 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20552 const {
20553 getShortcutKeyCombination,
20554 getShortcutDescription,
20555 getShortcutAliases
20556 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
20557 return {
20558 keyCombination: getShortcutKeyCombination(name),
20559 aliases: getShortcutAliases(name),
20560 description: getShortcutDescription(name)
20561 };
20562 }, [name]);
20563 if (!keyCombination) {
20564 return null;
20565 }
20566 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcut_help_modal_shortcut, {
20567 keyCombination: keyCombination,
20568 description: description,
20569 aliases: aliases
20570 });
20571 }
20572 /* harmony default export */ const dynamic_shortcut = (DynamicShortcut);
20573
20574 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/keyboard-shortcut-help-modal/index.js
20575 /**
20576 * External dependencies
20577 */
20578
20579
20580 /**
20581 * WordPress dependencies
20582 */
20583
20584
20585
20586
20587
20588
20589 /**
20590 * Internal dependencies
20591 */
20592
20593
20594
20595
20596
20597 const KEYBOARD_SHORTCUT_HELP_MODAL_NAME = 'editor/keyboard-shortcut-help';
20598 const ShortcutList = ({
20599 shortcuts
20600 }) =>
20601 /*#__PURE__*/
20602 /*
20603 * Disable reason: The `list` ARIA role is redundant but
20604 * Safari+VoiceOver won't announce the list otherwise.
20605 */
20606 /* eslint-disable jsx-a11y/no-redundant-roles */
20607 (0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
20608 className: "editor-keyboard-shortcut-help-modal__shortcut-list",
20609 role: "list",
20610 children: shortcuts.map((shortcut, index) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
20611 className: "editor-keyboard-shortcut-help-modal__shortcut",
20612 children: typeof shortcut === 'string' ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(dynamic_shortcut, {
20613 name: shortcut
20614 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcut_help_modal_shortcut, {
20615 ...shortcut
20616 })
20617 }, index))
20618 })
20619 /* eslint-enable jsx-a11y/no-redundant-roles */;
20620 const ShortcutSection = ({
20621 title,
20622 shortcuts,
20623 className
20624 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("section", {
20625 className: dist_clsx('editor-keyboard-shortcut-help-modal__section', className),
20626 children: [!!title && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
20627 className: "editor-keyboard-shortcut-help-modal__section-title",
20628 children: title
20629 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutList, {
20630 shortcuts: shortcuts
20631 })]
20632 });
20633 const ShortcutCategorySection = ({
20634 title,
20635 categoryName,
20636 additionalShortcuts = []
20637 }) => {
20638 const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => {
20639 return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName);
20640 }, [categoryName]);
20641 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, {
20642 title: title,
20643 shortcuts: categoryShortcuts.concat(additionalShortcuts)
20644 });
20645 };
20646 function KeyboardShortcutHelpModal() {
20647 const isModalActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(KEYBOARD_SHORTCUT_HELP_MODAL_NAME), []);
20648 const {
20649 openModal,
20650 closeModal
20651 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20652 const toggleModal = () => {
20653 if (isModalActive) {
20654 closeModal();
20655 } else {
20656 openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME);
20657 }
20658 };
20659 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/keyboard-shortcuts', toggleModal);
20660 if (!isModalActive) {
20661 return null;
20662 }
20663 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Modal, {
20664 className: "editor-keyboard-shortcut-help-modal",
20665 title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
20666 closeButtonLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
20667 onRequestClose: toggleModal,
20668 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, {
20669 className: "editor-keyboard-shortcut-help-modal__main-shortcuts",
20670 shortcuts: ['core/editor/keyboard-shortcuts']
20671 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
20672 title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'),
20673 categoryName: "global"
20674 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
20675 title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'),
20676 categoryName: "selection"
20677 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
20678 title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'),
20679 categoryName: "block",
20680 additionalShortcuts: [{
20681 keyCombination: {
20682 character: '/'
20683 },
20684 description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'),
20685 /* translators: The forward-slash character. e.g. '/'. */
20686 ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash')
20687 }]
20688 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, {
20689 title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'),
20690 shortcuts: textFormattingShortcuts
20691 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
20692 title: (0,external_wp_i18n_namespaceObject.__)('List View shortcuts'),
20693 categoryName: "list-view"
20694 })]
20695 });
20696 }
20697 /* harmony default export */ const keyboard_shortcut_help_modal = (KeyboardShortcutHelpModal);
20698
20699 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-settings-menu/content-only-settings-menu.js
20700 /**
20701 * WordPress dependencies
20702 */
20703
20704
20705
20706
20707
20708
20709 /**
20710 * Internal dependencies
20711 */
20712
20713
20714
20715
20716
20717 function ContentOnlySettingsMenuItems({
20718 clientId,
20719 onClose
20720 }) {
20721 const {
20722 entity,
20723 onNavigateToEntityRecord
20724 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20725 const {
20726 getBlockEditingMode,
20727 getBlockParentsByBlockName,
20728 getSettings,
20729 getBlockAttributes
20730 } = select(external_wp_blockEditor_namespaceObject.store);
20731 const contentOnly = getBlockEditingMode(clientId) === 'contentOnly';
20732 if (!contentOnly) {
20733 return {};
20734 }
20735 const patternParent = getBlockParentsByBlockName(clientId, 'core/block', true)[0];
20736 let record;
20737 if (patternParent) {
20738 record = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_block', getBlockAttributes(patternParent).ref);
20739 } else {
20740 const {
20741 getCurrentPostType,
20742 getCurrentTemplateId
20743 } = select(store_store);
20744 const currentPostType = getCurrentPostType();
20745 const templateId = getCurrentTemplateId();
20746 if (currentPostType === 'page' && templateId) {
20747 record = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_template', templateId);
20748 }
20749 }
20750 return {
20751 entity: record,
20752 onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord
20753 };
20754 }, [clientId]);
20755 if (!entity) {
20756 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateLockContentOnlyMenuItems, {
20757 clientId: clientId,
20758 onClose: onClose
20759 });
20760 }
20761 const isPattern = entity.type === 'wp_block';
20762 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
20763 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, {
20764 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
20765 onClick: () => {
20766 onNavigateToEntityRecord({
20767 postId: entity.id,
20768 postType: entity.type
20769 });
20770 },
20771 children: isPattern ? (0,external_wp_i18n_namespaceObject.__)('Edit pattern') : (0,external_wp_i18n_namespaceObject.__)('Edit template')
20772 })
20773 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
20774 variant: "muted",
20775 as: "p",
20776 className: "editor-content-only-settings-menu__description",
20777 children: isPattern ? (0,external_wp_i18n_namespaceObject.__)('Edit the pattern to move, delete, or make further changes to this block.') : (0,external_wp_i18n_namespaceObject.__)('Edit the template to move, delete, or make further changes to this block.')
20778 })]
20779 });
20780 }
20781 function TemplateLockContentOnlyMenuItems({
20782 clientId,
20783 onClose
20784 }) {
20785 const {
20786 contentLockingParent
20787 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20788 const {
20789 getContentLockingParent
20790 } = unlock(select(external_wp_blockEditor_namespaceObject.store));
20791 return {
20792 contentLockingParent: getContentLockingParent(clientId)
20793 };
20794 }, [clientId]);
20795 const blockDisplayInformation = (0,external_wp_blockEditor_namespaceObject.useBlockDisplayInformation)(contentLockingParent);
20796 // Disable reason: We're using a hook here so it has to be on top-level.
20797 // eslint-disable-next-line @wordpress/no-unused-vars-before-return
20798 const {
20799 modifyContentLockBlock,
20800 selectBlock
20801 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store));
20802 if (!blockDisplayInformation?.title) {
20803 return null;
20804 }
20805 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
20806 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, {
20807 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
20808 onClick: () => {
20809 selectBlock(contentLockingParent);
20810 modifyContentLockBlock(contentLockingParent);
20811 onClose();
20812 },
20813 children: (0,external_wp_i18n_namespaceObject.__)('Unlock')
20814 })
20815 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
20816 variant: "muted",
20817 as: "p",
20818 className: "editor-content-only-settings-menu__description",
20819 children: (0,external_wp_i18n_namespaceObject.__)('Temporarily unlock the parent block to edit, delete or make further changes to this block.')
20820 })]
20821 });
20822 }
20823 function ContentOnlySettingsMenu() {
20824 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
20825 children: ({
20826 selectedClientIds,
20827 onClose
20828 }) => selectedClientIds.length === 1 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ContentOnlySettingsMenuItems, {
20829 clientId: selectedClientIds[0],
20830 onClose: onClose
20831 })
20832 });
20833 }
20834
20835 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/start-template-options/index.js
20836 /**
20837 * WordPress dependencies
20838 */
20839
20840
20841
20842
20843
20844
20845
20846
20847
20848 /**
20849 * Internal dependencies
20850 */
20851
20852
20853
20854
20855 function useFallbackTemplateContent(slug, isCustom = false) {
20856 return (0,external_wp_data_namespaceObject.useSelect)(select => {
20857 const {
20858 getEntityRecord,
20859 getDefaultTemplateId
20860 } = select(external_wp_coreData_namespaceObject.store);
20861 const templateId = getDefaultTemplateId({
20862 slug,
20863 is_custom: isCustom,
20864 ignore_empty: true
20865 });
20866 return templateId ? getEntityRecord('postType', TEMPLATE_POST_TYPE, templateId)?.content?.raw : undefined;
20867 }, [slug, isCustom]);
20868 }
20869 function start_template_options_useStartPatterns(fallbackContent) {
20870 const {
20871 slug,
20872 patterns
20873 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20874 const {
20875 getCurrentPostType,
20876 getCurrentPostId
20877 } = select(store_store);
20878 const {
20879 getEntityRecord,
20880 getBlockPatterns
20881 } = select(external_wp_coreData_namespaceObject.store);
20882 const postId = getCurrentPostId();
20883 const postType = getCurrentPostType();
20884 const record = getEntityRecord('postType', postType, postId);
20885 return {
20886 slug: record.slug,
20887 patterns: getBlockPatterns()
20888 };
20889 }, []);
20890 const currentThemeStylesheet = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme().stylesheet);
20891
20892 // Duplicated from packages/block-library/src/pattern/edit.js.
20893 function injectThemeAttributeInBlockTemplateContent(block) {
20894 if (block.innerBlocks.find(innerBlock => innerBlock.name === 'core/template-part')) {
20895 block.innerBlocks = block.innerBlocks.map(innerBlock => {
20896 if (innerBlock.name === 'core/template-part' && innerBlock.attributes.theme === undefined) {
20897 innerBlock.attributes.theme = currentThemeStylesheet;
20898 }
20899 return innerBlock;
20900 });
20901 }
20902 if (block.name === 'core/template-part' && block.attributes.theme === undefined) {
20903 block.attributes.theme = currentThemeStylesheet;
20904 }
20905 return block;
20906 }
20907 return (0,external_wp_element_namespaceObject.useMemo)(() => {
20908 // filter patterns that are supposed to be used in the current template being edited.
20909 return [{
20910 name: 'fallback',
20911 blocks: (0,external_wp_blocks_namespaceObject.parse)(fallbackContent),
20912 title: (0,external_wp_i18n_namespaceObject.__)('Fallback content')
20913 }, ...patterns.filter(pattern => {
20914 return Array.isArray(pattern.templateTypes) && pattern.templateTypes.some(templateType => slug.startsWith(templateType));
20915 }).map(pattern => {
20916 return {
20917 ...pattern,
20918 blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content).map(block => injectThemeAttributeInBlockTemplateContent(block))
20919 };
20920 })];
20921 }, [fallbackContent, slug, patterns]);
20922 }
20923 function start_template_options_PatternSelection({
20924 fallbackContent,
20925 onChoosePattern,
20926 postType
20927 }) {
20928 const [,, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', postType);
20929 const blockPatterns = start_template_options_useStartPatterns(fallbackContent);
20930 const shownBlockPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(blockPatterns);
20931 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
20932 blockPatterns: blockPatterns,
20933 shownPatterns: shownBlockPatterns,
20934 onClickPattern: (pattern, blocks) => {
20935 onChange(blocks, {
20936 selection: undefined
20937 });
20938 onChoosePattern();
20939 }
20940 });
20941 }
20942 function StartModal({
20943 slug,
20944 isCustom,
20945 onClose,
20946 postType
20947 }) {
20948 const fallbackContent = useFallbackTemplateContent(slug, isCustom);
20949 if (!fallbackContent) {
20950 return null;
20951 }
20952 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Modal, {
20953 className: "editor-start-template-options__modal",
20954 title: (0,external_wp_i18n_namespaceObject.__)('Choose a pattern'),
20955 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Cancel'),
20956 focusOnMount: "firstElement",
20957 onRequestClose: onClose,
20958 isFullScreen: true,
20959 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
20960 className: "editor-start-template-options__modal-content",
20961 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(start_template_options_PatternSelection, {
20962 fallbackContent: fallbackContent,
20963 slug: slug,
20964 isCustom: isCustom,
20965 postType: postType,
20966 onChoosePattern: () => {
20967 onClose();
20968 }
20969 })
20970 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Flex, {
20971 className: "editor-start-template-options__modal__actions",
20972 justify: "flex-end",
20973 expanded: false,
20974 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
20975 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
20976 variant: "tertiary",
20977 onClick: onClose,
20978 children: (0,external_wp_i18n_namespaceObject.__)('Skip')
20979 })
20980 })
20981 })]
20982 });
20983 }
20984 function StartTemplateOptions() {
20985 const [isClosed, setIsClosed] = (0,external_wp_element_namespaceObject.useState)(false);
20986 const {
20987 shouldOpenModal,
20988 slug,
20989 isCustom,
20990 postType,
20991 postId
20992 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20993 const {
20994 getCurrentPostType,
20995 getCurrentPostId
20996 } = select(store_store);
20997 const _postType = getCurrentPostType();
20998 const _postId = getCurrentPostId();
20999 const {
21000 getEditedEntityRecord,
21001 hasEditsForEntityRecord
21002 } = select(external_wp_coreData_namespaceObject.store);
21003 const templateRecord = getEditedEntityRecord('postType', _postType, _postId);
21004 const hasEdits = hasEditsForEntityRecord('postType', _postType, _postId);
21005 return {
21006 shouldOpenModal: !hasEdits && '' === templateRecord.content && TEMPLATE_POST_TYPE === _postType,
21007 slug: templateRecord.slug,
21008 isCustom: templateRecord.is_custom,
21009 postType: _postType,
21010 postId: _postId
21011 };
21012 }, []);
21013 (0,external_wp_element_namespaceObject.useEffect)(() => {
21014 // Should reset the modal state when navigating to a new page/post.
21015 setIsClosed(false);
21016 }, [postType, postId]);
21017 if (!shouldOpenModal || isClosed) {
21018 return null;
21019 }
21020 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(StartModal, {
21021 slug: slug,
21022 isCustom: isCustom,
21023 postType: postType,
21024 onClose: () => setIsClosed(true)
21025 });
21026 }
21027
21028 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/index.js
21029 /**
21030 * WordPress dependencies
21031 */
21032
21033
21034
21035
21036
21037
21038
21039
21040
21041 /**
21042 * Internal dependencies
21043 */
21044
21045
21046
21047
21048
21049
21050
21051
21052
21053
21054
21055
21056
21057
21058
21059
21060
21061
21062
21063 const {
21064 ExperimentalBlockEditorProvider
21065 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
21066 const {
21067 PatternsMenuItems
21068 } = unlock(external_wp_patterns_namespaceObject.privateApis);
21069 const provider_noop = () => {};
21070
21071 /**
21072 * These are global entities that are only there to split blocks into logical units
21073 * They don't provide a "context" for the current post/page being rendered.
21074 * So we should not use their ids as post context. This is important to allow post blocks
21075 * (post content, post title) to be used within them without issues.
21076 */
21077 const NON_CONTEXTUAL_POST_TYPES = ['wp_block', 'wp_template', 'wp_navigation', 'wp_template_part'];
21078
21079 /**
21080 * Depending on the post, template and template mode,
21081 * returns the appropriate blocks and change handlers for the block editor provider.
21082 *
21083 * @param {Array} post Block list.
21084 * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.
21085 * @param {string} mode Rendering mode.
21086 *
21087 * @example
21088 * ```jsx
21089 * const [ blocks, onInput, onChange ] = useBlockEditorProps( post, template, mode );
21090 * ```
21091 *
21092 * @return {Array} Block editor props.
21093 */
21094 function useBlockEditorProps(post, template, mode) {
21095 const rootLevelPost = mode === 'post-only' || !template ? 'post' : 'template';
21096 const [postBlocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', post.type, {
21097 id: post.id
21098 });
21099 const [templateBlocks, onInputTemplate, onChangeTemplate] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', template?.type, {
21100 id: template?.id
21101 });
21102 const maybeNavigationBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
21103 if (post.type === 'wp_navigation') {
21104 return [(0,external_wp_blocks_namespaceObject.createBlock)('core/navigation', {
21105 ref: post.id,
21106 // As the parent editor is locked with `templateLock`, the template locking
21107 // must be explicitly "unset" on the block itself to allow the user to modify
21108 // the block's content.
21109 templateLock: false
21110 })];
21111 }
21112 }, [post.type, post.id]);
21113
21114 // It is important that we don't create a new instance of blocks on every change
21115 // We should only create a new instance if the blocks them selves change, not a dependency of them.
21116 const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
21117 if (maybeNavigationBlocks) {
21118 return maybeNavigationBlocks;
21119 }
21120 if (rootLevelPost === 'template') {
21121 return templateBlocks;
21122 }
21123 return postBlocks;
21124 }, [maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks]);
21125
21126 // Handle fallback to postBlocks outside of the above useMemo, to ensure
21127 // that constructed block templates that call `createBlock` are not generated
21128 // too frequently. This ensures that clientIds are stable.
21129 const disableRootLevelChanges = !!template && mode === 'template-locked' || post.type === 'wp_navigation';
21130 if (disableRootLevelChanges) {
21131 return [blocks, provider_noop, provider_noop];
21132 }
21133 return [blocks, rootLevelPost === 'post' ? onInput : onInputTemplate, rootLevelPost === 'post' ? onChange : onChangeTemplate];
21134 }
21135
21136 /**
21137 * This component provides the editor context and manages the state of the block editor.
21138 *
21139 * @param {Object} props The component props.
21140 * @param {Object} props.post The post object.
21141 * @param {Object} props.settings The editor settings.
21142 * @param {boolean} props.recovery Indicates if the editor is in recovery mode.
21143 * @param {Array} props.initialEdits The initial edits for the editor.
21144 * @param {Object} props.children The child components.
21145 * @param {Object} [props.BlockEditorProviderComponent] The block editor provider component to use. Defaults to ExperimentalBlockEditorProvider.
21146 * @param {Object} [props.__unstableTemplate] The template object.
21147 *
21148 * @example
21149 * ```jsx
21150 * <ExperimentalEditorProvider
21151 * post={ post }
21152 * settings={ settings }
21153 * recovery={ recovery }
21154 * initialEdits={ initialEdits }
21155 * __unstableTemplate={ template }
21156 * >
21157 * { children }
21158 * </ExperimentalEditorProvider>
21159 *
21160 * @return {Object} The rendered ExperimentalEditorProvider component.
21161 */
21162 const ExperimentalEditorProvider = with_registry_provider(({
21163 post,
21164 settings,
21165 recovery,
21166 initialEdits,
21167 children,
21168 BlockEditorProviderComponent = ExperimentalBlockEditorProvider,
21169 __unstableTemplate: template
21170 }) => {
21171 const mode = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getRenderingMode(), []);
21172 const shouldRenderTemplate = !!template && mode !== 'post-only';
21173 const rootLevelPost = shouldRenderTemplate ? template : post;
21174 const defaultBlockContext = (0,external_wp_element_namespaceObject.useMemo)(() => {
21175 const postContext = !NON_CONTEXTUAL_POST_TYPES.includes(rootLevelPost.type) || shouldRenderTemplate ? {
21176 postId: post.id,
21177 postType: post.type
21178 } : {};
21179 return {
21180 ...postContext,
21181 templateSlug: rootLevelPost.type === 'wp_template' ? rootLevelPost.slug : undefined
21182 };
21183 }, [shouldRenderTemplate, post.id, post.type, rootLevelPost.type, rootLevelPost.slug]);
21184 const {
21185 editorSettings,
21186 selection,
21187 isReady
21188 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21189 const {
21190 getEditorSettings,
21191 getEditorSelection,
21192 __unstableIsEditorReady
21193 } = select(store_store);
21194 return {
21195 editorSettings: getEditorSettings(),
21196 isReady: __unstableIsEditorReady(),
21197 selection: getEditorSelection()
21198 };
21199 }, []);
21200 const {
21201 id,
21202 type
21203 } = rootLevelPost;
21204 const blockEditorSettings = use_block_editor_settings(editorSettings, type, id, mode);
21205 const [blocks, onInput, onChange] = useBlockEditorProps(post, template, mode);
21206 const {
21207 updatePostLock,
21208 setupEditor,
21209 updateEditorSettings,
21210 setCurrentTemplateId,
21211 setEditedPost,
21212 setRenderingMode
21213 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
21214 const {
21215 createWarningNotice
21216 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
21217
21218 // Ideally this should be synced on each change and not just something you do once.
21219 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
21220 // Assume that we don't need to initialize in the case of an error recovery.
21221 if (recovery) {
21222 return;
21223 }
21224 updatePostLock(settings.postLock);
21225 setupEditor(post, initialEdits, settings.template);
21226 if (settings.autosave) {
21227 createWarningNotice((0,external_wp_i18n_namespaceObject.__)('There is an autosave of this post that is more recent than the version below.'), {
21228 id: 'autosave-exists',
21229 actions: [{
21230 label: (0,external_wp_i18n_namespaceObject.__)('View the autosave'),
21231 url: settings.autosave.editLink
21232 }]
21233 });
21234 }
21235 }, []);
21236
21237 // Synchronizes the active post with the state
21238 (0,external_wp_element_namespaceObject.useEffect)(() => {
21239 setEditedPost(post.type, post.id);
21240 }, [post.type, post.id, setEditedPost]);
21241
21242 // Synchronize the editor settings as they change.
21243 (0,external_wp_element_namespaceObject.useEffect)(() => {
21244 updateEditorSettings(settings);
21245 }, [settings, updateEditorSettings]);
21246
21247 // Synchronizes the active template with the state.
21248 (0,external_wp_element_namespaceObject.useEffect)(() => {
21249 setCurrentTemplateId(template?.id);
21250 }, [template?.id, setCurrentTemplateId]);
21251
21252 // Sets the right rendering mode when loading the editor.
21253 (0,external_wp_element_namespaceObject.useEffect)(() => {
21254 var _settings$defaultRend;
21255 setRenderingMode((_settings$defaultRend = settings.defaultRenderingMode) !== null && _settings$defaultRend !== void 0 ? _settings$defaultRend : 'post-only');
21256 }, [settings.defaultRenderingMode, setRenderingMode]);
21257 useHideBlocksFromInserter(post.type, mode);
21258
21259 // Register the editor commands.
21260 useCommands();
21261 if (!isReady) {
21262 return null;
21263 }
21264 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_coreData_namespaceObject.EntityProvider, {
21265 kind: "root",
21266 type: "site",
21267 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_coreData_namespaceObject.EntityProvider, {
21268 kind: "postType",
21269 type: post.type,
21270 id: post.id,
21271 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockContextProvider, {
21272 value: defaultBlockContext,
21273 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(BlockEditorProviderComponent, {
21274 value: blocks,
21275 onChange: onChange,
21276 onInput: onInput,
21277 selection: selection,
21278 settings: blockEditorSettings,
21279 useSubRegistry: false,
21280 children: [children, !settings.__unstableIsPreviewMode && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
21281 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternsMenuItems, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ContentOnlySettingsMenu, {}), mode === 'template-locked' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DisableNonPageContentBlocks, {}), type === 'wp_navigation' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigationBlockEditingMode, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EditorKeyboardShortcuts, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcut_help_modal, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockRemovalWarnings, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(StartPageOptions, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(StartTemplateOptions, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternRenameModal, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternDuplicateModal, {})]
21282 })]
21283 })
21284 })
21285 })
21286 });
21287 });
21288
21289 /**
21290 * This component establishes a new post editing context, and serves as the entry point for a new post editor (or post with template editor).
21291 *
21292 * It supports a large number of post types, including post, page, templates,
21293 * custom post types, patterns, template parts.
21294 *
21295 * All modification and changes are performed to the `@wordpress/core-data` store.
21296 *
21297 * @param {Object} props The component props.
21298 * @param {Object} [props.post] The post object to edit. This is required.
21299 * @param {Object} [props.__unstableTemplate] The template object wrapper the edited post.
21300 * This is optional and can only be used when the post type supports templates (like posts and pages).
21301 * @param {Object} [props.settings] The settings object to use for the editor.
21302 * This is optional and can be used to override the default settings.
21303 * @param {Element} [props.children] Children elements for which the BlockEditorProvider context should apply.
21304 * This is optional.
21305 *
21306 * @example
21307 * ```jsx
21308 * <EditorProvider
21309 * post={ post }
21310 * settings={ settings }
21311 * __unstableTemplate={ template }
21312 * >
21313 * { children }
21314 * </EditorProvider>
21315 * ```
21316 *
21317 * @return {JSX.Element} The rendered EditorProvider component.
21318 */
21319 function EditorProvider(props) {
21320 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExperimentalEditorProvider, {
21321 ...props,
21322 BlockEditorProviderComponent: external_wp_blockEditor_namespaceObject.BlockEditorProvider,
21323 children: props.children
21324 });
21325 }
21326 /* harmony default export */ const provider = (EditorProvider);
21327
21328 ;// CONCATENATED MODULE: external ["wp","serverSideRender"]
21329 const external_wp_serverSideRender_namespaceObject = window["wp"]["serverSideRender"];
21330 var external_wp_serverSideRender_default = /*#__PURE__*/__webpack_require__.n(external_wp_serverSideRender_namespaceObject);
21331 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/deprecated.js
21332 // Block Creation Components.
21333 /**
21334 * WordPress dependencies
21335 */
21336
21337
21338
21339
21340
21341 function deprecateComponent(name, Wrapped, staticsToHoist = []) {
21342 const Component = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
21343 external_wp_deprecated_default()('wp.editor.' + name, {
21344 since: '5.3',
21345 alternative: 'wp.blockEditor.' + name,
21346 version: '6.2'
21347 });
21348 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Wrapped, {
21349 ref: ref,
21350 ...props
21351 });
21352 });
21353 staticsToHoist.forEach(staticName => {
21354 Component[staticName] = deprecateComponent(name + '.' + staticName, Wrapped[staticName]);
21355 });
21356 return Component;
21357 }
21358 function deprecateFunction(name, func) {
21359 return (...args) => {
21360 external_wp_deprecated_default()('wp.editor.' + name, {
21361 since: '5.3',
21362 alternative: 'wp.blockEditor.' + name,
21363 version: '6.2'
21364 });
21365 return func(...args);
21366 };
21367 }
21368
21369 /**
21370 * @deprecated since 5.3, use `wp.blockEditor.RichText` instead.
21371 */
21372 const RichText = deprecateComponent('RichText', external_wp_blockEditor_namespaceObject.RichText, ['Content']);
21373 RichText.isEmpty = deprecateFunction('RichText.isEmpty', external_wp_blockEditor_namespaceObject.RichText.isEmpty);
21374
21375
21376 /**
21377 * @deprecated since 5.3, use `wp.blockEditor.Autocomplete` instead.
21378 */
21379 const Autocomplete = deprecateComponent('Autocomplete', external_wp_blockEditor_namespaceObject.Autocomplete);
21380 /**
21381 * @deprecated since 5.3, use `wp.blockEditor.AlignmentToolbar` instead.
21382 */
21383 const AlignmentToolbar = deprecateComponent('AlignmentToolbar', external_wp_blockEditor_namespaceObject.AlignmentToolbar);
21384 /**
21385 * @deprecated since 5.3, use `wp.blockEditor.BlockAlignmentToolbar` instead.
21386 */
21387 const BlockAlignmentToolbar = deprecateComponent('BlockAlignmentToolbar', external_wp_blockEditor_namespaceObject.BlockAlignmentToolbar);
21388 /**
21389 * @deprecated since 5.3, use `wp.blockEditor.BlockControls` instead.
21390 */
21391 const BlockControls = deprecateComponent('BlockControls', external_wp_blockEditor_namespaceObject.BlockControls, ['Slot']);
21392 /**
21393 * @deprecated since 5.3, use `wp.blockEditor.BlockEdit` instead.
21394 */
21395 const BlockEdit = deprecateComponent('BlockEdit', external_wp_blockEditor_namespaceObject.BlockEdit);
21396 /**
21397 * @deprecated since 5.3, use `wp.blockEditor.BlockEditorKeyboardShortcuts` instead.
21398 */
21399 const BlockEditorKeyboardShortcuts = deprecateComponent('BlockEditorKeyboardShortcuts', external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts);
21400 /**
21401 * @deprecated since 5.3, use `wp.blockEditor.BlockFormatControls` instead.
21402 */
21403 const BlockFormatControls = deprecateComponent('BlockFormatControls', external_wp_blockEditor_namespaceObject.BlockFormatControls, ['Slot']);
21404 /**
21405 * @deprecated since 5.3, use `wp.blockEditor.BlockIcon` instead.
21406 */
21407 const BlockIcon = deprecateComponent('BlockIcon', external_wp_blockEditor_namespaceObject.BlockIcon);
21408 /**
21409 * @deprecated since 5.3, use `wp.blockEditor.BlockInspector` instead.
21410 */
21411 const BlockInspector = deprecateComponent('BlockInspector', external_wp_blockEditor_namespaceObject.BlockInspector);
21412 /**
21413 * @deprecated since 5.3, use `wp.blockEditor.BlockList` instead.
21414 */
21415 const BlockList = deprecateComponent('BlockList', external_wp_blockEditor_namespaceObject.BlockList);
21416 /**
21417 * @deprecated since 5.3, use `wp.blockEditor.BlockMover` instead.
21418 */
21419 const BlockMover = deprecateComponent('BlockMover', external_wp_blockEditor_namespaceObject.BlockMover);
21420 /**
21421 * @deprecated since 5.3, use `wp.blockEditor.BlockNavigationDropdown` instead.
21422 */
21423 const BlockNavigationDropdown = deprecateComponent('BlockNavigationDropdown', external_wp_blockEditor_namespaceObject.BlockNavigationDropdown);
21424 /**
21425 * @deprecated since 5.3, use `wp.blockEditor.BlockSelectionClearer` instead.
21426 */
21427 const BlockSelectionClearer = deprecateComponent('BlockSelectionClearer', external_wp_blockEditor_namespaceObject.BlockSelectionClearer);
21428 /**
21429 * @deprecated since 5.3, use `wp.blockEditor.BlockSettingsMenu` instead.
21430 */
21431 const BlockSettingsMenu = deprecateComponent('BlockSettingsMenu', external_wp_blockEditor_namespaceObject.BlockSettingsMenu);
21432 /**
21433 * @deprecated since 5.3, use `wp.blockEditor.BlockTitle` instead.
21434 */
21435 const BlockTitle = deprecateComponent('BlockTitle', external_wp_blockEditor_namespaceObject.BlockTitle);
21436 /**
21437 * @deprecated since 5.3, use `wp.blockEditor.BlockToolbar` instead.
21438 */
21439 const BlockToolbar = deprecateComponent('BlockToolbar', external_wp_blockEditor_namespaceObject.BlockToolbar);
21440 /**
21441 * @deprecated since 5.3, use `wp.blockEditor.ColorPalette` instead.
21442 */
21443 const ColorPalette = deprecateComponent('ColorPalette', external_wp_blockEditor_namespaceObject.ColorPalette);
21444 /**
21445 * @deprecated since 5.3, use `wp.blockEditor.ContrastChecker` instead.
21446 */
21447 const ContrastChecker = deprecateComponent('ContrastChecker', external_wp_blockEditor_namespaceObject.ContrastChecker);
21448 /**
21449 * @deprecated since 5.3, use `wp.blockEditor.CopyHandler` instead.
21450 */
21451 const CopyHandler = deprecateComponent('CopyHandler', external_wp_blockEditor_namespaceObject.CopyHandler);
21452 /**
21453 * @deprecated since 5.3, use `wp.blockEditor.DefaultBlockAppender` instead.
21454 */
21455 const DefaultBlockAppender = deprecateComponent('DefaultBlockAppender', external_wp_blockEditor_namespaceObject.DefaultBlockAppender);
21456 /**
21457 * @deprecated since 5.3, use `wp.blockEditor.FontSizePicker` instead.
21458 */
21459 const FontSizePicker = deprecateComponent('FontSizePicker', external_wp_blockEditor_namespaceObject.FontSizePicker);
21460 /**
21461 * @deprecated since 5.3, use `wp.blockEditor.Inserter` instead.
21462 */
21463 const Inserter = deprecateComponent('Inserter', external_wp_blockEditor_namespaceObject.Inserter);
21464 /**
21465 * @deprecated since 5.3, use `wp.blockEditor.InnerBlocks` instead.
21466 */
21467 const InnerBlocks = deprecateComponent('InnerBlocks', external_wp_blockEditor_namespaceObject.InnerBlocks, ['ButtonBlockAppender', 'DefaultBlockAppender', 'Content']);
21468 /**
21469 * @deprecated since 5.3, use `wp.blockEditor.InspectorAdvancedControls` instead.
21470 */
21471 const InspectorAdvancedControls = deprecateComponent('InspectorAdvancedControls', external_wp_blockEditor_namespaceObject.InspectorAdvancedControls, ['Slot']);
21472 /**
21473 * @deprecated since 5.3, use `wp.blockEditor.InspectorControls` instead.
21474 */
21475 const InspectorControls = deprecateComponent('InspectorControls', external_wp_blockEditor_namespaceObject.InspectorControls, ['Slot']);
21476 /**
21477 * @deprecated since 5.3, use `wp.blockEditor.PanelColorSettings` instead.
21478 */
21479 const PanelColorSettings = deprecateComponent('PanelColorSettings', external_wp_blockEditor_namespaceObject.PanelColorSettings);
21480 /**
21481 * @deprecated since 5.3, use `wp.blockEditor.PlainText` instead.
21482 */
21483 const PlainText = deprecateComponent('PlainText', external_wp_blockEditor_namespaceObject.PlainText);
21484 /**
21485 * @deprecated since 5.3, use `wp.blockEditor.RichTextShortcut` instead.
21486 */
21487 const RichTextShortcut = deprecateComponent('RichTextShortcut', external_wp_blockEditor_namespaceObject.RichTextShortcut);
21488 /**
21489 * @deprecated since 5.3, use `wp.blockEditor.RichTextToolbarButton` instead.
21490 */
21491 const RichTextToolbarButton = deprecateComponent('RichTextToolbarButton', external_wp_blockEditor_namespaceObject.RichTextToolbarButton);
21492 /**
21493 * @deprecated since 5.3, use `wp.blockEditor.__unstableRichTextInputEvent` instead.
21494 */
21495 const __unstableRichTextInputEvent = deprecateComponent('__unstableRichTextInputEvent', external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent);
21496 /**
21497 * @deprecated since 5.3, use `wp.blockEditor.MediaPlaceholder` instead.
21498 */
21499 const MediaPlaceholder = deprecateComponent('MediaPlaceholder', external_wp_blockEditor_namespaceObject.MediaPlaceholder);
21500 /**
21501 * @deprecated since 5.3, use `wp.blockEditor.MediaUpload` instead.
21502 */
21503 const MediaUpload = deprecateComponent('MediaUpload', external_wp_blockEditor_namespaceObject.MediaUpload);
21504 /**
21505 * @deprecated since 5.3, use `wp.blockEditor.MediaUploadCheck` instead.
21506 */
21507 const MediaUploadCheck = deprecateComponent('MediaUploadCheck', external_wp_blockEditor_namespaceObject.MediaUploadCheck);
21508 /**
21509 * @deprecated since 5.3, use `wp.blockEditor.MultiSelectScrollIntoView` instead.
21510 */
21511 const MultiSelectScrollIntoView = deprecateComponent('MultiSelectScrollIntoView', external_wp_blockEditor_namespaceObject.MultiSelectScrollIntoView);
21512 /**
21513 * @deprecated since 5.3, use `wp.blockEditor.NavigableToolbar` instead.
21514 */
21515 const NavigableToolbar = deprecateComponent('NavigableToolbar', external_wp_blockEditor_namespaceObject.NavigableToolbar);
21516 /**
21517 * @deprecated since 5.3, use `wp.blockEditor.ObserveTyping` instead.
21518 */
21519 const ObserveTyping = deprecateComponent('ObserveTyping', external_wp_blockEditor_namespaceObject.ObserveTyping);
21520 /**
21521 * @deprecated since 5.3, use `wp.blockEditor.SkipToSelectedBlock` instead.
21522 */
21523 const SkipToSelectedBlock = deprecateComponent('SkipToSelectedBlock', external_wp_blockEditor_namespaceObject.SkipToSelectedBlock);
21524 /**
21525 * @deprecated since 5.3, use `wp.blockEditor.URLInput` instead.
21526 */
21527 const URLInput = deprecateComponent('URLInput', external_wp_blockEditor_namespaceObject.URLInput);
21528 /**
21529 * @deprecated since 5.3, use `wp.blockEditor.URLInputButton` instead.
21530 */
21531 const URLInputButton = deprecateComponent('URLInputButton', external_wp_blockEditor_namespaceObject.URLInputButton);
21532 /**
21533 * @deprecated since 5.3, use `wp.blockEditor.URLPopover` instead.
21534 */
21535 const URLPopover = deprecateComponent('URLPopover', external_wp_blockEditor_namespaceObject.URLPopover);
21536 /**
21537 * @deprecated since 5.3, use `wp.blockEditor.Warning` instead.
21538 */
21539 const Warning = deprecateComponent('Warning', external_wp_blockEditor_namespaceObject.Warning);
21540 /**
21541 * @deprecated since 5.3, use `wp.blockEditor.WritingFlow` instead.
21542 */
21543 const WritingFlow = deprecateComponent('WritingFlow', external_wp_blockEditor_namespaceObject.WritingFlow);
21544
21545 /**
21546 * @deprecated since 5.3, use `wp.blockEditor.createCustomColorsHOC` instead.
21547 */
21548 const createCustomColorsHOC = deprecateFunction('createCustomColorsHOC', external_wp_blockEditor_namespaceObject.createCustomColorsHOC);
21549 /**
21550 * @deprecated since 5.3, use `wp.blockEditor.getColorClassName` instead.
21551 */
21552 const getColorClassName = deprecateFunction('getColorClassName', external_wp_blockEditor_namespaceObject.getColorClassName);
21553 /**
21554 * @deprecated since 5.3, use `wp.blockEditor.getColorObjectByAttributeValues` instead.
21555 */
21556 const getColorObjectByAttributeValues = deprecateFunction('getColorObjectByAttributeValues', external_wp_blockEditor_namespaceObject.getColorObjectByAttributeValues);
21557 /**
21558 * @deprecated since 5.3, use `wp.blockEditor.getColorObjectByColorValue` instead.
21559 */
21560 const getColorObjectByColorValue = deprecateFunction('getColorObjectByColorValue', external_wp_blockEditor_namespaceObject.getColorObjectByColorValue);
21561 /**
21562 * @deprecated since 5.3, use `wp.blockEditor.getFontSize` instead.
21563 */
21564 const getFontSize = deprecateFunction('getFontSize', external_wp_blockEditor_namespaceObject.getFontSize);
21565 /**
21566 * @deprecated since 5.3, use `wp.blockEditor.getFontSizeClass` instead.
21567 */
21568 const getFontSizeClass = deprecateFunction('getFontSizeClass', external_wp_blockEditor_namespaceObject.getFontSizeClass);
21569 /**
21570 * @deprecated since 5.3, use `wp.blockEditor.createCustomColorsHOC` instead.
21571 */
21572 const withColorContext = deprecateFunction('withColorContext', external_wp_blockEditor_namespaceObject.withColorContext);
21573 /**
21574 * @deprecated since 5.3, use `wp.blockEditor.withColors` instead.
21575 */
21576 const withColors = deprecateFunction('withColors', external_wp_blockEditor_namespaceObject.withColors);
21577 /**
21578 * @deprecated since 5.3, use `wp.blockEditor.withFontSizes` instead.
21579 */
21580 const withFontSizes = deprecateFunction('withFontSizes', external_wp_blockEditor_namespaceObject.withFontSizes);
21581
21582 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/index.js
21583 /**
21584 * Internal dependencies
21585 */
21586
21587
21588 // Block Creation Components.
21589
21590
21591 // Post Related Components.
21592
21593
21594
21595
21596
21597
21598
21599
21600
21601
21602
21603
21604
21605
21606
21607
21608
21609
21610
21611
21612
21613
21614
21615
21616
21617
21618
21619
21620
21621
21622
21623
21624
21625
21626
21627
21628
21629
21630
21631
21632
21633
21634
21635
21636
21637
21638
21639
21640
21641
21642
21643
21644
21645
21646
21647
21648
21649
21650
21651
21652
21653
21654
21655
21656
21657
21658
21659
21660
21661
21662
21663
21664
21665
21666
21667
21668
21669
21670
21671
21672
21673
21674
21675
21676
21677
21678
21679
21680 // State Related Components.
21681
21682
21683 const VisualEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
21684 const TextEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
21685
21686 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/url.js
21687 /**
21688 * WordPress dependencies
21689 */
21690
21691
21692
21693 /**
21694 * Performs some basic cleanup of a string for use as a post slug
21695 *
21696 * This replicates some of what sanitize_title() does in WordPress core, but
21697 * is only designed to approximate what the slug will be.
21698 *
21699 * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin letters.
21700 * Removes combining diacritical marks. Converts whitespace, periods,
21701 * and forward slashes to hyphens. Removes any remaining non-word characters
21702 * except hyphens and underscores. Converts remaining string to lowercase.
21703 * It does not account for octets, HTML entities, or other encoded characters.
21704 *
21705 * @param {string} string Title or slug to be processed
21706 *
21707 * @return {string} Processed string
21708 */
21709 function cleanForSlug(string) {
21710 external_wp_deprecated_default()('wp.editor.cleanForSlug', {
21711 since: '12.7',
21712 plugin: 'Gutenberg',
21713 alternative: 'wp.url.cleanForSlug'
21714 });
21715 return (0,external_wp_url_namespaceObject.cleanForSlug)(string);
21716 }
21717
21718 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/index.js
21719 /**
21720 * Internal dependencies
21721 */
21722
21723
21724
21725
21726
21727 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-interface/content-slot-fill.js
21728 /**
21729 * WordPress dependencies
21730 */
21731
21732
21733 /**
21734 * Internal dependencies
21735 */
21736
21737 const {
21738 createPrivateSlotFill
21739 } = unlock(external_wp_components_namespaceObject.privateApis);
21740 const SLOT_FILL_NAME = 'EditCanvasContainerSlot';
21741 const EditorContentSlotFill = createPrivateSlotFill(SLOT_FILL_NAME);
21742 /* harmony default export */ const content_slot_fill = (EditorContentSlotFill);
21743
21744 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/header/back-button.js
21745 /**
21746 * WordPress dependencies
21747 */
21748
21749
21750 // Keeping an old name for backward compatibility.
21751
21752 const slotName = '__experimentalMainDashboardButton';
21753 const {
21754 Fill: back_button_Fill,
21755 Slot: back_button_Slot
21756 } = (0,external_wp_components_namespaceObject.createSlotFill)(slotName);
21757 const BackButton = back_button_Fill;
21758 const BackButtonSlot = ({
21759 children
21760 }) => {
21761 const fills = (0,external_wp_components_namespaceObject.__experimentalUseSlotFills)(slotName);
21762 const hasFills = Boolean(fills && fills.length);
21763 if (!hasFills) {
21764 return children;
21765 }
21766 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(back_button_Slot, {
21767 bubblesVirtually: true,
21768 fillProps: {
21769 length: !fills ? 0 : fills.length
21770 }
21771 });
21772 };
21773 BackButton.Slot = BackButtonSlot;
21774 /* harmony default export */ const back_button = (BackButton);
21775
21776 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/next.js
21777 /**
21778 * WordPress dependencies
21779 */
21780
21781
21782 const next = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
21783 xmlns: "http://www.w3.org/2000/svg",
21784 viewBox: "0 0 24 24",
21785 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
21786 d: "M6.6 6L5.4 7l4.5 5-4.5 5 1.1 1 5.5-6-5.4-6zm6 0l-1.1 1 4.5 5-4.5 5 1.1 1 5.5-6-5.5-6z"
21787 })
21788 });
21789 /* harmony default export */ const library_next = (next);
21790
21791 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/previous.js
21792 /**
21793 * WordPress dependencies
21794 */
21795
21796
21797 const previous = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
21798 xmlns: "http://www.w3.org/2000/svg",
21799 viewBox: "0 0 24 24",
21800 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
21801 d: "M11.6 7l-1.1-1L5 12l5.5 6 1.1-1L7 12l4.6-5zm6 0l-1.1-1-5.5 6 5.5 6 1.1-1-4.6-5 4.6-5z"
21802 })
21803 });
21804 /* harmony default export */ const library_previous = (previous);
21805
21806 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/collapsible-block-toolbar/index.js
21807 /**
21808 * External dependencies
21809 */
21810
21811
21812 /**
21813 * WordPress dependencies
21814 */
21815
21816
21817
21818
21819
21820
21821
21822 /**
21823 * Internal dependencies
21824 */
21825
21826
21827
21828
21829 const {
21830 useHasBlockToolbar
21831 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
21832 function CollapsableBlockToolbar({
21833 isCollapsed,
21834 onToggle
21835 }) {
21836 const {
21837 blockSelectionStart
21838 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21839 return {
21840 blockSelectionStart: select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart()
21841 };
21842 }, []);
21843 const hasBlockToolbar = useHasBlockToolbar();
21844 const hasBlockSelection = !!blockSelectionStart;
21845 (0,external_wp_element_namespaceObject.useEffect)(() => {
21846 // If we have a new block selection, show the block tools
21847 if (blockSelectionStart) {
21848 onToggle(false);
21849 }
21850 }, [blockSelectionStart, onToggle]);
21851 if (!hasBlockToolbar) {
21852 return null;
21853 }
21854 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
21855 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
21856 className: dist_clsx('editor-collapsible-block-toolbar', {
21857 'is-collapsed': isCollapsed || !hasBlockSelection
21858 }),
21859 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockToolbar, {
21860 hideDragHandle: true
21861 })
21862 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Popover.Slot, {
21863 name: "block-toolbar"
21864 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
21865 className: "editor-collapsible-block-toolbar__toggle",
21866 icon: isCollapsed ? library_next : library_previous,
21867 onClick: () => {
21868 onToggle(!isCollapsed);
21869 },
21870 label: isCollapsed ? (0,external_wp_i18n_namespaceObject.__)('Show block tools') : (0,external_wp_i18n_namespaceObject.__)('Hide block tools'),
21871 size: "compact"
21872 })]
21873 });
21874 }
21875 /* harmony default export */ const collapsible_block_toolbar = (CollapsableBlockToolbar);
21876
21877 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/plus.js
21878 /**
21879 * WordPress dependencies
21880 */
21881
21882
21883 const plus = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
21884 xmlns: "http://www.w3.org/2000/svg",
21885 viewBox: "0 0 24 24",
21886 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
21887 d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"
21888 })
21889 });
21890 /* harmony default export */ const library_plus = (plus);
21891
21892 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-tools/index.js
21893 /**
21894 * External dependencies
21895 */
21896
21897
21898 /**
21899 * WordPress dependencies
21900 */
21901
21902
21903
21904
21905
21906
21907
21908
21909
21910
21911 /**
21912 * Internal dependencies
21913 */
21914
21915
21916
21917
21918
21919
21920
21921 const preventDefault = event => {
21922 event.preventDefault();
21923 };
21924 function DocumentTools({
21925 className,
21926 disableBlockTools = false
21927 }) {
21928 const {
21929 setIsInserterOpened,
21930 setIsListViewOpened
21931 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
21932 const {
21933 isDistractionFree,
21934 isInserterOpened,
21935 isListViewOpen,
21936 listViewShortcut,
21937 inserterSidebarToggleRef,
21938 listViewToggleRef,
21939 hasFixedToolbar,
21940 showIconLabels
21941 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21942 const {
21943 getSettings
21944 } = select(external_wp_blockEditor_namespaceObject.store);
21945 const {
21946 get
21947 } = select(external_wp_preferences_namespaceObject.store);
21948 const {
21949 isListViewOpened,
21950 getEditorMode,
21951 getInserterSidebarToggleRef,
21952 getListViewToggleRef
21953 } = unlock(select(store_store));
21954 const {
21955 getShortcutRepresentation
21956 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
21957 const {
21958 __unstableGetEditorMode
21959 } = select(external_wp_blockEditor_namespaceObject.store);
21960 return {
21961 isInserterOpened: select(store_store).isInserterOpened(),
21962 isListViewOpen: isListViewOpened(),
21963 listViewShortcut: getShortcutRepresentation('core/editor/toggle-list-view'),
21964 inserterSidebarToggleRef: getInserterSidebarToggleRef(),
21965 listViewToggleRef: getListViewToggleRef(),
21966 hasFixedToolbar: getSettings().hasFixedToolbar,
21967 showIconLabels: get('core', 'showIconLabels'),
21968 isDistractionFree: get('core', 'distractionFree'),
21969 isVisualMode: getEditorMode() === 'visual',
21970 isZoomedOutView: __unstableGetEditorMode() === 'zoom-out'
21971 };
21972 }, []);
21973 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
21974 const isWideViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('wide');
21975
21976 /* translators: accessibility text for the editor toolbar */
21977 const toolbarAriaLabel = (0,external_wp_i18n_namespaceObject.__)('Document tools');
21978 const toggleListView = (0,external_wp_element_namespaceObject.useCallback)(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
21979 const toggleInserter = (0,external_wp_element_namespaceObject.useCallback)(() => setIsInserterOpened(!isInserterOpened), [isInserterOpened, setIsInserterOpened]);
21980
21981 /* translators: button label text should, if possible, be under 16 characters. */
21982 const longLabel = (0,external_wp_i18n_namespaceObject._x)('Toggle block inserter', 'Generic label for block inserter button');
21983 const shortLabel = !isInserterOpened ? (0,external_wp_i18n_namespaceObject.__)('Add') : (0,external_wp_i18n_namespaceObject.__)('Close');
21984 return (
21985 /*#__PURE__*/
21986 // Some plugins expect and use the `edit-post-header-toolbar` CSS class to
21987 // find the toolbar and inject UI elements into it. This is not officially
21988 // supported, but we're keeping it in the list of class names for backwards
21989 // compatibility.
21990 (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.NavigableToolbar, {
21991 className: dist_clsx('editor-document-tools', 'edit-post-header-toolbar', className),
21992 "aria-label": toolbarAriaLabel,
21993 variant: "unstyled",
21994 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
21995 className: "editor-document-tools__left",
21996 children: [!isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
21997 ref: inserterSidebarToggleRef,
21998 as: external_wp_components_namespaceObject.Button,
21999 className: "editor-document-tools__inserter-toggle",
22000 variant: "primary",
22001 isPressed: isInserterOpened,
22002 onMouseDown: preventDefault,
22003 onClick: toggleInserter,
22004 disabled: disableBlockTools,
22005 icon: library_plus,
22006 label: showIconLabels ? shortLabel : longLabel,
22007 showTooltip: !showIconLabels,
22008 "aria-expanded": isInserterOpened
22009 }), (isWideViewport || !showIconLabels) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22010 children: [isLargeViewport && !hasFixedToolbar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
22011 as: external_wp_blockEditor_namespaceObject.ToolSelector,
22012 showTooltip: !showIconLabels,
22013 variant: showIconLabels ? 'tertiary' : undefined,
22014 disabled: disableBlockTools,
22015 size: "compact"
22016 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
22017 as: editor_history_undo,
22018 showTooltip: !showIconLabels,
22019 variant: showIconLabels ? 'tertiary' : undefined,
22020 size: "compact"
22021 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
22022 as: editor_history_redo,
22023 showTooltip: !showIconLabels,
22024 variant: showIconLabels ? 'tertiary' : undefined,
22025 size: "compact"
22026 }), !isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
22027 as: external_wp_components_namespaceObject.Button,
22028 className: "editor-document-tools__document-overview-toggle",
22029 icon: list_view,
22030 disabled: disableBlockTools,
22031 isPressed: isListViewOpen
22032 /* translators: button label text should, if possible, be under 16 characters. */,
22033 label: (0,external_wp_i18n_namespaceObject.__)('Document Overview'),
22034 onClick: toggleListView,
22035 shortcut: listViewShortcut,
22036 showTooltip: !showIconLabels,
22037 variant: showIconLabels ? 'tertiary' : undefined,
22038 "aria-expanded": isListViewOpen,
22039 ref: listViewToggleRef,
22040 size: "compact"
22041 })]
22042 })]
22043 })
22044 })
22045 );
22046 }
22047 /* harmony default export */ const document_tools = (DocumentTools);
22048
22049 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/more-vertical.js
22050 /**
22051 * WordPress dependencies
22052 */
22053
22054
22055 const moreVertical = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
22056 xmlns: "http://www.w3.org/2000/svg",
22057 viewBox: "0 0 24 24",
22058 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
22059 d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
22060 })
22061 });
22062 /* harmony default export */ const more_vertical = (moreVertical);
22063
22064 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/more-menu/copy-content-menu-item.js
22065 /**
22066 * WordPress dependencies
22067 */
22068
22069
22070
22071
22072
22073
22074
22075
22076 /**
22077 * Internal dependencies
22078 */
22079
22080
22081 function CopyContentMenuItem() {
22082 const {
22083 createNotice
22084 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
22085 const {
22086 getCurrentPostId,
22087 getCurrentPostType
22088 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
22089 const {
22090 getEditedEntityRecord
22091 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
22092 function getText() {
22093 const record = getEditedEntityRecord('postType', getCurrentPostType(), getCurrentPostId());
22094 if (!record) {
22095 return '';
22096 }
22097 if (typeof record.content === 'function') {
22098 return record.content(record);
22099 } else if (record.blocks) {
22100 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
22101 } else if (record.content) {
22102 return record.content;
22103 }
22104 }
22105 function onSuccess() {
22106 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('All content copied.'), {
22107 isDismissible: true,
22108 type: 'snackbar'
22109 });
22110 }
22111 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(getText, onSuccess);
22112 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
22113 ref: ref,
22114 children: (0,external_wp_i18n_namespaceObject.__)('Copy all blocks')
22115 });
22116 }
22117
22118 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/mode-switcher/index.js
22119 /**
22120 * WordPress dependencies
22121 */
22122
22123
22124
22125
22126
22127 /**
22128 * Internal dependencies
22129 */
22130
22131
22132 /**
22133 * Set of available mode options.
22134 *
22135 * @type {Array}
22136 */
22137
22138 const MODES = [{
22139 value: 'visual',
22140 label: (0,external_wp_i18n_namespaceObject.__)('Visual editor')
22141 }, {
22142 value: 'text',
22143 label: (0,external_wp_i18n_namespaceObject.__)('Code editor')
22144 }];
22145 function ModeSwitcher() {
22146 const {
22147 shortcut,
22148 isRichEditingEnabled,
22149 isCodeEditingEnabled,
22150 mode
22151 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
22152 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/editor/toggle-mode'),
22153 isRichEditingEnabled: select(store_store).getEditorSettings().richEditingEnabled,
22154 isCodeEditingEnabled: select(store_store).getEditorSettings().codeEditingEnabled,
22155 mode: select(store_store).getEditorMode()
22156 }), []);
22157 const {
22158 switchEditorMode
22159 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
22160 let selectedMode = mode;
22161 if (!isRichEditingEnabled && mode === 'visual') {
22162 selectedMode = 'text';
22163 }
22164 if (!isCodeEditingEnabled && mode === 'text') {
22165 selectedMode = 'visual';
22166 }
22167 const choices = MODES.map(choice => {
22168 if (!isCodeEditingEnabled && choice.value === 'text') {
22169 choice = {
22170 ...choice,
22171 disabled: true
22172 };
22173 }
22174 if (!isRichEditingEnabled && choice.value === 'visual') {
22175 choice = {
22176 ...choice,
22177 disabled: true,
22178 info: (0,external_wp_i18n_namespaceObject.__)('You can enable the visual editor in your profile settings.')
22179 };
22180 }
22181 if (choice.value !== selectedMode && !choice.disabled) {
22182 return {
22183 ...choice,
22184 shortcut
22185 };
22186 }
22187 return choice;
22188 });
22189 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
22190 label: (0,external_wp_i18n_namespaceObject.__)('Editor'),
22191 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItemsChoice, {
22192 choices: choices,
22193 value: selectedMode,
22194 onSelect: switchEditorMode
22195 })
22196 });
22197 }
22198 /* harmony default export */ const mode_switcher = (ModeSwitcher);
22199
22200 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/more-menu/tools-more-menu-group.js
22201 /**
22202 * WordPress dependencies
22203 */
22204
22205
22206 const {
22207 Fill: ToolsMoreMenuGroup,
22208 Slot: tools_more_menu_group_Slot
22209 } = (0,external_wp_components_namespaceObject.createSlotFill)('ToolsMoreMenuGroup');
22210 ToolsMoreMenuGroup.Slot = ({
22211 fillProps
22212 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(tools_more_menu_group_Slot, {
22213 fillProps: fillProps
22214 });
22215 /* harmony default export */ const tools_more_menu_group = (ToolsMoreMenuGroup);
22216
22217 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/more-menu/view-more-menu-group.js
22218 /**
22219 * WordPress dependencies
22220 */
22221
22222
22223
22224 const {
22225 Fill: ViewMoreMenuGroup,
22226 Slot: view_more_menu_group_Slot
22227 } = (0,external_wp_components_namespaceObject.createSlotFill)(external_wp_element_namespaceObject.Platform.OS === 'web' ? Symbol('ViewMoreMenuGroup') : 'ViewMoreMenuGroup');
22228 ViewMoreMenuGroup.Slot = ({
22229 fillProps
22230 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(view_more_menu_group_Slot, {
22231 fillProps: fillProps
22232 });
22233 /* harmony default export */ const view_more_menu_group = (ViewMoreMenuGroup);
22234
22235 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/more-menu/index.js
22236 /**
22237 * WordPress dependencies
22238 */
22239
22240
22241
22242
22243
22244
22245
22246
22247 /**
22248 * Internal dependencies
22249 */
22250
22251
22252
22253
22254
22255
22256
22257
22258 function MoreMenu() {
22259 const {
22260 openModal
22261 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
22262 const {
22263 set: setPreference
22264 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
22265 const {
22266 toggleDistractionFree
22267 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
22268 const showIconLabels = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_preferences_namespaceObject.store).get('core', 'showIconLabels'), []);
22269 const turnOffDistractionFree = () => {
22270 setPreference('core', 'distractionFree', false);
22271 };
22272 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22273 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
22274 icon: more_vertical,
22275 label: (0,external_wp_i18n_namespaceObject.__)('Options'),
22276 popoverProps: {
22277 placement: 'bottom-end',
22278 className: 'more-menu-dropdown__content'
22279 },
22280 toggleProps: {
22281 showTooltip: !showIconLabels,
22282 ...(showIconLabels && {
22283 variant: 'tertiary'
22284 }),
22285 tooltipPosition: 'bottom',
22286 size: 'compact'
22287 },
22288 children: ({
22289 onClose
22290 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22291 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
22292 label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun'),
22293 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
22294 scope: "core",
22295 name: "fixedToolbar",
22296 onToggle: turnOffDistractionFree,
22297 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'),
22298 info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'),
22299 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated'),
22300 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated')
22301 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
22302 scope: "core",
22303 name: "distractionFree",
22304 label: (0,external_wp_i18n_namespaceObject.__)('Distraction free'),
22305 info: (0,external_wp_i18n_namespaceObject.__)('Write with calmness'),
22306 handleToggling: false,
22307 onToggle: toggleDistractionFree,
22308 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode activated'),
22309 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode deactivated'),
22310 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('\\')
22311 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
22312 scope: "core",
22313 name: "focusMode",
22314 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode'),
22315 info: (0,external_wp_i18n_namespaceObject.__)('Focus on one block at a time'),
22316 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode activated'),
22317 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode deactivated')
22318 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(view_more_menu_group.Slot, {
22319 fillProps: {
22320 onClose
22321 }
22322 })]
22323 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(mode_switcher, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item.Slot, {
22324 name: "core/plugin-more-menu",
22325 label: (0,external_wp_i18n_namespaceObject.__)('Plugins'),
22326 as: external_wp_components_namespaceObject.MenuGroup,
22327 fillProps: {
22328 onClick: onClose
22329 }
22330 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
22331 label: (0,external_wp_i18n_namespaceObject.__)('Tools'),
22332 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
22333 onClick: () => openModal('editor/keyboard-shortcut-help'),
22334 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h'),
22335 children: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts')
22336 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyContentMenuItem, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuItem, {
22337 icon: library_external,
22338 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/wordpress-block-editor/'),
22339 target: "_blank",
22340 rel: "noopener noreferrer",
22341 children: [(0,external_wp_i18n_namespaceObject.__)('Help'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
22342 as: "span",
22343 children: /* translators: accessibility text */
22344 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')
22345 })]
22346 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(tools_more_menu_group.Slot, {
22347 fillProps: {
22348 onClose
22349 }
22350 })]
22351 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
22352 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
22353 onClick: () => openModal('editor/preferences'),
22354 children: (0,external_wp_i18n_namespaceObject.__)('Preferences')
22355 })
22356 })]
22357 })
22358 })
22359 });
22360 }
22361
22362 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-button/post-publish-button-or-toggle.js
22363 /**
22364 * WordPress dependencies
22365 */
22366
22367
22368
22369 /**
22370 * Internal dependencies
22371 */
22372
22373
22374
22375 function PostPublishButtonOrToggle({
22376 forceIsDirty,
22377 hasPublishAction,
22378 isBeingScheduled,
22379 isPending,
22380 isPublished,
22381 isPublishSidebarEnabled,
22382 isPublishSidebarOpened,
22383 isScheduled,
22384 togglePublishSidebar,
22385 setEntitiesSavedStatesCallback,
22386 postStatusHasChanged,
22387 postStatus
22388 }) {
22389 const IS_TOGGLE = 'toggle';
22390 const IS_BUTTON = 'button';
22391 const isSmallerThanMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
22392 let component;
22393
22394 /**
22395 * Conditions to show a BUTTON (publish directly) or a TOGGLE (open publish sidebar):
22396 *
22397 * 1) We want to show a BUTTON when the post status is at the _final stage_
22398 * for a particular role (see https://wordpress.org/documentation/article/post-status/):
22399 *
22400 * - is published
22401 * - post status has changed explicitely to something different than 'future' or 'publish'
22402 * - is scheduled to be published
22403 * - is pending and can't be published (but only for viewports >= medium).
22404 * Originally, we considered showing a button for pending posts that couldn't be published
22405 * (for example, for an author with the contributor role). Some languages can have
22406 * long translations for "Submit for review", so given the lack of UI real estate available
22407 * we decided to take into account the viewport in that case.
22408 * See: https://github.com/WordPress/gutenberg/issues/10475
22409 *
22410 * 2) Then, in small viewports, we'll show a TOGGLE.
22411 *
22412 * 3) Finally, we'll use the publish sidebar status to decide:
22413 *
22414 * - if it is enabled, we show a TOGGLE
22415 * - if it is disabled, we show a BUTTON
22416 */
22417 if (isPublished || postStatusHasChanged && !['future', 'publish'].includes(postStatus) || isScheduled && isBeingScheduled || isPending && !hasPublishAction && !isSmallerThanMediumViewport) {
22418 component = IS_BUTTON;
22419 } else if (isSmallerThanMediumViewport || isPublishSidebarEnabled) {
22420 component = IS_TOGGLE;
22421 } else {
22422 component = IS_BUTTON;
22423 }
22424 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_button, {
22425 forceIsDirty: forceIsDirty,
22426 isOpen: isPublishSidebarOpened,
22427 isToggle: component === IS_TOGGLE,
22428 onToggle: togglePublishSidebar,
22429 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
22430 });
22431 }
22432 /* harmony default export */ const post_publish_button_or_toggle = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => {
22433 var _select$getCurrentPos;
22434 return {
22435 hasPublishAction: (_select$getCurrentPos = select(store_store).getCurrentPost()?._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false,
22436 isBeingScheduled: select(store_store).isEditedPostBeingScheduled(),
22437 isPending: select(store_store).isCurrentPostPending(),
22438 isPublished: select(store_store).isCurrentPostPublished(),
22439 isPublishSidebarEnabled: select(store_store).isPublishSidebarEnabled(),
22440 isPublishSidebarOpened: select(store_store).isPublishSidebarOpened(),
22441 isScheduled: select(store_store).isCurrentPostScheduled(),
22442 postStatus: select(store_store).getEditedPostAttribute('status'),
22443 postStatusHasChanged: select(store_store).getPostEdits()?.status
22444 };
22445 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
22446 const {
22447 togglePublishSidebar
22448 } = dispatch(store_store);
22449 return {
22450 togglePublishSidebar
22451 };
22452 }))(PostPublishButtonOrToggle));
22453
22454 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-view-link/index.js
22455 /**
22456 * WordPress dependencies
22457 */
22458
22459
22460
22461
22462
22463
22464
22465 /**
22466 * Internal dependencies
22467 */
22468
22469
22470 function PostViewLink() {
22471 const {
22472 hasLoaded,
22473 permalink,
22474 isPublished,
22475 label,
22476 showIconLabels
22477 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22478 // Grab post type to retrieve the view_item label.
22479 const postTypeSlug = select(store_store).getCurrentPostType();
22480 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
22481 const {
22482 get
22483 } = select(external_wp_preferences_namespaceObject.store);
22484 return {
22485 permalink: select(store_store).getPermalink(),
22486 isPublished: select(store_store).isCurrentPostPublished(),
22487 label: postType?.labels.view_item,
22488 hasLoaded: !!postType,
22489 showIconLabels: get('core', 'showIconLabels')
22490 };
22491 }, []);
22492
22493 // Only render the view button if the post is published and has a permalink.
22494 if (!isPublished || !permalink || !hasLoaded) {
22495 return null;
22496 }
22497 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
22498 icon: library_external,
22499 label: label || (0,external_wp_i18n_namespaceObject.__)('View post'),
22500 href: permalink,
22501 target: "_blank",
22502 showTooltip: !showIconLabels,
22503 size: "compact"
22504 });
22505 }
22506
22507 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/mobile.js
22508 /**
22509 * WordPress dependencies
22510 */
22511
22512
22513 const mobile = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
22514 xmlns: "http://www.w3.org/2000/svg",
22515 viewBox: "0 0 24 24",
22516 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
22517 d: "M15 4H9c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h6c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H9c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h6c.3 0 .5.2.5.5v12zm-4.5-.5h2V16h-2v1.5z"
22518 })
22519 });
22520 /* harmony default export */ const library_mobile = (mobile);
22521
22522 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/tablet.js
22523 /**
22524 * WordPress dependencies
22525 */
22526
22527
22528 const tablet = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
22529 xmlns: "http://www.w3.org/2000/svg",
22530 viewBox: "0 0 24 24",
22531 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
22532 d: "M17 4H7c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm.5 14c0 .3-.2.5-.5.5H7c-.3 0-.5-.2-.5-.5V6c0-.3.2-.5.5-.5h10c.3 0 .5.2.5.5v12zm-7.5-.5h4V16h-4v1.5z"
22533 })
22534 });
22535 /* harmony default export */ const library_tablet = (tablet);
22536
22537 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/desktop.js
22538 /**
22539 * WordPress dependencies
22540 */
22541
22542
22543 const desktop = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
22544 xmlns: "http://www.w3.org/2000/svg",
22545 viewBox: "0 0 24 24",
22546 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
22547 d: "M20.5 16h-.7V8c0-1.1-.9-2-2-2H6.2c-1.1 0-2 .9-2 2v8h-.7c-.8 0-1.5.7-1.5 1.5h20c0-.8-.7-1.5-1.5-1.5zM5.7 8c0-.3.2-.5.5-.5h11.6c.3 0 .5.2.5.5v7.6H5.7V8z"
22548 })
22549 });
22550 /* harmony default export */ const library_desktop = (desktop);
22551
22552 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/preview-dropdown/index.js
22553 /**
22554 * WordPress dependencies
22555 */
22556
22557
22558
22559
22560
22561
22562
22563
22564 /**
22565 * Internal dependencies
22566 */
22567
22568
22569
22570
22571
22572 function PreviewDropdown({
22573 forceIsAutosaveable,
22574 disabled
22575 }) {
22576 const {
22577 deviceType,
22578 homeUrl,
22579 isTemplate,
22580 isViewable,
22581 showIconLabels
22582 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22583 var _getPostType$viewable;
22584 const {
22585 getDeviceType,
22586 getCurrentPostType
22587 } = select(store_store);
22588 const {
22589 getUnstableBase,
22590 getPostType
22591 } = select(external_wp_coreData_namespaceObject.store);
22592 const {
22593 get
22594 } = select(external_wp_preferences_namespaceObject.store);
22595 const _currentPostType = getCurrentPostType();
22596 return {
22597 deviceType: getDeviceType(),
22598 homeUrl: getUnstableBase()?.home,
22599 isTemplate: _currentPostType === 'wp_template',
22600 isViewable: (_getPostType$viewable = getPostType(_currentPostType)?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false,
22601 showIconLabels: get('core', 'showIconLabels')
22602 };
22603 }, []);
22604 const {
22605 setDeviceType
22606 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
22607 const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
22608 if (isMobile) {
22609 return null;
22610 }
22611 const popoverProps = {
22612 placement: 'bottom-end'
22613 };
22614 const toggleProps = {
22615 className: 'editor-preview-dropdown__toggle',
22616 size: 'compact',
22617 showTooltip: !showIconLabels,
22618 disabled,
22619 __experimentalIsFocusable: disabled
22620 };
22621 const menuProps = {
22622 'aria-label': (0,external_wp_i18n_namespaceObject.__)('View options')
22623 };
22624 const deviceIcons = {
22625 mobile: library_mobile,
22626 tablet: library_tablet,
22627 desktop: library_desktop
22628 };
22629 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
22630 className: "editor-preview-dropdown",
22631 popoverProps: popoverProps,
22632 toggleProps: toggleProps,
22633 menuProps: menuProps,
22634 icon: deviceIcons[deviceType.toLowerCase()],
22635 label: (0,external_wp_i18n_namespaceObject.__)('View'),
22636 disableOpenOnArrowDown: disabled,
22637 children: ({
22638 onClose
22639 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22640 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
22641 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
22642 onClick: () => setDeviceType('Desktop'),
22643 icon: deviceType === 'Desktop' && library_check,
22644 children: (0,external_wp_i18n_namespaceObject.__)('Desktop')
22645 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
22646 onClick: () => setDeviceType('Tablet'),
22647 icon: deviceType === 'Tablet' && library_check,
22648 children: (0,external_wp_i18n_namespaceObject.__)('Tablet')
22649 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
22650 onClick: () => setDeviceType('Mobile'),
22651 icon: deviceType === 'Mobile' && library_check,
22652 children: (0,external_wp_i18n_namespaceObject.__)('Mobile')
22653 })]
22654 }), isTemplate && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
22655 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuItem, {
22656 href: homeUrl,
22657 target: "_blank",
22658 icon: library_external,
22659 onClick: onClose,
22660 children: [(0,external_wp_i18n_namespaceObject.__)('View site'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
22661 as: "span",
22662 children: /* translators: accessibility text */
22663 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')
22664 })]
22665 })
22666 }), isViewable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
22667 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPreviewButton, {
22668 className: "editor-preview-dropdown__button-external",
22669 role: "menuitem",
22670 forceIsAutosaveable: forceIsAutosaveable,
22671 textContent: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22672 children: [(0,external_wp_i18n_namespaceObject.__)('Preview in new tab'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
22673 icon: library_external
22674 })]
22675 }),
22676 onPreview: onClose
22677 })
22678 })]
22679 })
22680 });
22681 }
22682
22683 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/header/index.js
22684 /**
22685 * External dependencies
22686 */
22687
22688
22689 /**
22690 * WordPress dependencies
22691 */
22692
22693
22694
22695
22696
22697
22698
22699
22700 /**
22701 * Internal dependencies
22702 */
22703
22704
22705
22706
22707
22708
22709
22710
22711
22712
22713
22714
22715
22716
22717 const toolbarVariations = {
22718 distractionFreeDisabled: {
22719 y: '-50px'
22720 },
22721 distractionFreeHover: {
22722 y: 0
22723 },
22724 distractionFreeHidden: {
22725 y: '-50px'
22726 },
22727 visible: {
22728 y: 0
22729 },
22730 hidden: {
22731 y: 0
22732 }
22733 };
22734 const backButtonVariations = {
22735 distractionFreeDisabled: {
22736 x: '-100%'
22737 },
22738 distractionFreeHover: {
22739 x: 0
22740 },
22741 distractionFreeHidden: {
22742 x: '-100%'
22743 },
22744 visible: {
22745 x: 0
22746 },
22747 hidden: {
22748 x: 0
22749 }
22750 };
22751 function Header({
22752 customSaveButton,
22753 forceIsDirty,
22754 forceDisableBlockTools,
22755 setEntitiesSavedStatesCallback,
22756 title
22757 }) {
22758 const isWideViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('large');
22759 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
22760 const {
22761 isTextEditor,
22762 isPublishSidebarOpened,
22763 showIconLabels,
22764 hasFixedToolbar,
22765 isNestedEntity,
22766 isZoomedOutView
22767 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22768 const {
22769 get: getPreference
22770 } = select(external_wp_preferences_namespaceObject.store);
22771 const {
22772 getEditorMode,
22773 getEditorSettings,
22774 isPublishSidebarOpened: _isPublishSidebarOpened
22775 } = select(store_store);
22776 const {
22777 __unstableGetEditorMode
22778 } = select(external_wp_blockEditor_namespaceObject.store);
22779 return {
22780 isTextEditor: getEditorMode() === 'text',
22781 isPublishSidebarOpened: _isPublishSidebarOpened(),
22782 showIconLabels: getPreference('core', 'showIconLabels'),
22783 hasFixedToolbar: getPreference('core', 'fixedToolbar'),
22784 isNestedEntity: !!getEditorSettings().onNavigateToPreviousEntityRecord,
22785 isZoomedOutView: __unstableGetEditorMode() === 'zoom-out'
22786 };
22787 }, []);
22788 const hasTopToolbar = isLargeViewport && hasFixedToolbar;
22789 const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = (0,external_wp_element_namespaceObject.useState)(true);
22790
22791 // The edit-post-header classname is only kept for backward compatibilty
22792 // as some plugins might be relying on its presence.
22793 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
22794 className: "editor-header edit-post-header",
22795 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
22796 variants: backButtonVariations,
22797 transition: {
22798 type: 'tween'
22799 },
22800 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(back_button.Slot, {})
22801 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
22802 variants: toolbarVariations,
22803 className: "editor-header__toolbar",
22804 transition: {
22805 type: 'tween'
22806 },
22807 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(document_tools, {
22808 disableBlockTools: forceDisableBlockTools || isTextEditor
22809 }), hasTopToolbar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(collapsible_block_toolbar, {
22810 isCollapsed: isBlockToolsCollapsed,
22811 onToggle: setIsBlockToolsCollapsed
22812 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
22813 className: dist_clsx('editor-header__center', {
22814 'is-collapsed': !isBlockToolsCollapsed && hasTopToolbar
22815 }),
22816 children: !title ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
22817 supportKeys: "title",
22818 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DocumentBar, {})
22819 }) : title
22820 })]
22821 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
22822 variants: toolbarVariations,
22823 transition: {
22824 type: 'tween'
22825 },
22826 className: "editor-header__settings",
22827 children: [!customSaveButton && !isPublishSidebarOpened &&
22828 /*#__PURE__*/
22829 // This button isn't completely hidden by the publish sidebar.
22830 // We can't hide the whole toolbar when the publish sidebar is open because
22831 // we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.
22832 // We track that DOM node to return focus to the PostPublishButtonOrToggle
22833 // when the publish sidebar has been closed.
22834 (0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSavedState, {
22835 forceIsDirty: forceIsDirty
22836 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreviewDropdown, {
22837 forceIsAutosaveable: forceIsDirty,
22838 disabled: isNestedEntity || isZoomedOutView
22839 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPreviewButton, {
22840 className: "editor-header__post-preview-button",
22841 forceIsAutosaveable: forceIsDirty
22842 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostViewLink, {}), !customSaveButton && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_button_or_toggle, {
22843 forceIsDirty: forceIsDirty,
22844 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
22845 }), customSaveButton, (isWideViewport || !showIconLabels) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(pinned_items.Slot, {
22846 scope: "core"
22847 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MoreMenu, {})]
22848 })]
22849 });
22850 }
22851 /* harmony default export */ const components_header = (Header);
22852
22853 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/inserter-sidebar/index.js
22854 /**
22855 * WordPress dependencies
22856 */
22857
22858
22859
22860
22861
22862
22863
22864
22865 /**
22866 * Internal dependencies
22867 */
22868
22869
22870
22871 const {
22872 PrivateInserterLibrary
22873 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
22874 function InserterSidebar() {
22875 const {
22876 blockSectionRootClientId,
22877 inserterSidebarToggleRef,
22878 insertionPoint,
22879 showMostUsedBlocks,
22880 sidebarIsOpened
22881 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22882 const {
22883 getInserterSidebarToggleRef,
22884 getInsertionPoint,
22885 isPublishSidebarOpened
22886 } = unlock(select(store_store));
22887 const {
22888 getBlockRootClientId,
22889 __unstableGetEditorMode,
22890 getSettings
22891 } = select(external_wp_blockEditor_namespaceObject.store);
22892 const {
22893 get
22894 } = select(external_wp_preferences_namespaceObject.store);
22895 const {
22896 getActiveComplementaryArea
22897 } = select(store);
22898 const getBlockSectionRootClientId = () => {
22899 if (__unstableGetEditorMode() === 'zoom-out') {
22900 const {
22901 sectionRootClientId
22902 } = unlock(getSettings());
22903 if (sectionRootClientId) {
22904 return sectionRootClientId;
22905 }
22906 }
22907 return getBlockRootClientId();
22908 };
22909 return {
22910 inserterSidebarToggleRef: getInserterSidebarToggleRef(),
22911 insertionPoint: getInsertionPoint(),
22912 showMostUsedBlocks: get('core', 'mostUsedBlocks'),
22913 blockSectionRootClientId: getBlockSectionRootClientId(),
22914 sidebarIsOpened: !!(getActiveComplementaryArea('core') || isPublishSidebarOpened())
22915 };
22916 }, []);
22917 const {
22918 setIsInserterOpened
22919 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
22920 const {
22921 disableComplementaryArea
22922 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
22923 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
22924 const [inserterDialogRef, inserterDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
22925 onClose: () => setIsInserterOpened(false),
22926 focusOnMount: true
22927 });
22928 const libraryRef = (0,external_wp_element_namespaceObject.useRef)();
22929
22930 // When closing the inserter, focus should return to the toggle button.
22931 const closeInserterSidebar = (0,external_wp_element_namespaceObject.useCallback)(() => {
22932 setIsInserterOpened(false);
22933 inserterSidebarToggleRef.current?.focus();
22934 }, [inserterSidebarToggleRef, setIsInserterOpened]);
22935 const closeOnEscape = (0,external_wp_element_namespaceObject.useCallback)(event => {
22936 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
22937 event.preventDefault();
22938 closeInserterSidebar();
22939 }
22940 }, [closeInserterSidebar]);
22941 const inserterContents = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
22942 className: "editor-inserter-sidebar__content",
22943 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivateInserterLibrary, {
22944 showMostUsedBlocks: showMostUsedBlocks,
22945 showInserterHelpPanel: true,
22946 shouldFocusBlock: isMobileViewport,
22947 rootClientId: blockSectionRootClientId !== null && blockSectionRootClientId !== void 0 ? blockSectionRootClientId : insertionPoint.rootClientId,
22948 __experimentalInsertionIndex: insertionPoint.insertionIndex,
22949 __experimentalInitialTab: insertionPoint.tab,
22950 __experimentalInitialCategory: insertionPoint.category,
22951 __experimentalFilterValue: insertionPoint.filterValue,
22952 onPatternCategorySelection: sidebarIsOpened ? () => disableComplementaryArea('core') : undefined,
22953 ref: libraryRef,
22954 onClose: closeInserterSidebar
22955 })
22956 });
22957 if (window.__experimentalEnableZoomedOutPatternsTab) {
22958 return (
22959 /*#__PURE__*/
22960 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
22961 (0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
22962 onKeyDown: closeOnEscape,
22963 className: "editor-inserter-sidebar",
22964 children: inserterContents
22965 })
22966 );
22967 }
22968 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
22969 ref: inserterDialogRef,
22970 ...inserterDialogProps,
22971 className: "editor-inserter-sidebar",
22972 children: inserterContents
22973 });
22974 }
22975
22976 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/list-view-sidebar/list-view-outline.js
22977 /**
22978 * WordPress dependencies
22979 */
22980
22981
22982
22983 /**
22984 * Internal dependencies
22985 */
22986
22987
22988
22989
22990
22991
22992
22993 function ListViewOutline() {
22994 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22995 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
22996 className: "editor-list-view-sidebar__outline",
22997 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
22998 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
22999 children: (0,external_wp_i18n_namespaceObject.__)('Characters:')
23000 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
23001 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CharacterCount, {})
23002 })]
23003 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
23004 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
23005 children: (0,external_wp_i18n_namespaceObject.__)('Words:')
23006 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WordCount, {})]
23007 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
23008 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
23009 children: (0,external_wp_i18n_namespaceObject.__)('Time to read:')
23010 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TimeToRead, {})]
23011 })]
23012 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DocumentOutline, {})]
23013 });
23014 }
23015
23016 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/list-view-sidebar/index.js
23017 /**
23018 * WordPress dependencies
23019 */
23020
23021
23022
23023
23024
23025
23026
23027
23028
23029
23030
23031 /**
23032 * Internal dependencies
23033 */
23034
23035
23036
23037
23038
23039 const {
23040 Tabs
23041 } = unlock(external_wp_components_namespaceObject.privateApis);
23042 function ListViewSidebar() {
23043 const {
23044 setIsListViewOpened
23045 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23046 const {
23047 getListViewToggleRef
23048 } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store));
23049
23050 // This hook handles focus when the sidebar first renders.
23051 const focusOnMountRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)('firstElement');
23052
23053 // When closing the list view, focus should return to the toggle button.
23054 const closeListView = (0,external_wp_element_namespaceObject.useCallback)(() => {
23055 setIsListViewOpened(false);
23056 getListViewToggleRef().current?.focus();
23057 }, [getListViewToggleRef, setIsListViewOpened]);
23058 const closeOnEscape = (0,external_wp_element_namespaceObject.useCallback)(event => {
23059 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
23060 event.preventDefault();
23061 closeListView();
23062 }
23063 }, [closeListView]);
23064
23065 // Use internal state instead of a ref to make sure that the component
23066 // re-renders when the dropZoneElement updates.
23067 const [dropZoneElement, setDropZoneElement] = (0,external_wp_element_namespaceObject.useState)(null);
23068 // Tracks our current tab.
23069 const [tab, setTab] = (0,external_wp_element_namespaceObject.useState)('list-view');
23070
23071 // This ref refers to the sidebar as a whole.
23072 const sidebarRef = (0,external_wp_element_namespaceObject.useRef)();
23073 // This ref refers to the tab panel.
23074 const tabsRef = (0,external_wp_element_namespaceObject.useRef)();
23075 // This ref refers to the list view application area.
23076 const listViewRef = (0,external_wp_element_namespaceObject.useRef)();
23077
23078 // Must merge the refs together so focus can be handled properly in the next function.
23079 const listViewContainerRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([focusOnMountRef, listViewRef, setDropZoneElement]);
23080
23081 /*
23082 * Callback function to handle list view or outline focus.
23083 *
23084 * @param {string} currentTab The current tab. Either list view or outline.
23085 *
23086 * @return void
23087 */
23088 function handleSidebarFocus(currentTab) {
23089 // Tab panel focus.
23090 const tabPanelFocus = external_wp_dom_namespaceObject.focus.tabbable.find(tabsRef.current)[0];
23091 // List view tab is selected.
23092 if (currentTab === 'list-view') {
23093 // Either focus the list view or the tab panel. Must have a fallback because the list view does not render when there are no blocks.
23094 const listViewApplicationFocus = external_wp_dom_namespaceObject.focus.tabbable.find(listViewRef.current)[0];
23095 const listViewFocusArea = sidebarRef.current.contains(listViewApplicationFocus) ? listViewApplicationFocus : tabPanelFocus;
23096 listViewFocusArea.focus();
23097 // Outline tab is selected.
23098 } else {
23099 tabPanelFocus.focus();
23100 }
23101 }
23102 const handleToggleListViewShortcut = (0,external_wp_element_namespaceObject.useCallback)(() => {
23103 // If the sidebar has focus, it is safe to close.
23104 if (sidebarRef.current.contains(sidebarRef.current.ownerDocument.activeElement)) {
23105 closeListView();
23106 } else {
23107 // If the list view or outline does not have focus, focus should be moved to it.
23108 handleSidebarFocus(tab);
23109 }
23110 }, [closeListView, tab]);
23111
23112 // This only fires when the sidebar is open because of the conditional rendering.
23113 // It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.
23114 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-list-view', handleToggleListViewShortcut);
23115 return (
23116 /*#__PURE__*/
23117 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
23118 (0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
23119 className: "editor-list-view-sidebar",
23120 onKeyDown: closeOnEscape,
23121 ref: sidebarRef,
23122 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Tabs, {
23123 onSelect: tabName => setTab(tabName),
23124 selectOnMove: false
23125 // The initial tab value is set explicitly to avoid an initial
23126 // render where no tab is selected. This ensures that the
23127 // tabpanel height is correct so the relevant scroll container
23128 // can be rendered internally.
23129 ,
23130 defaultTabId: "list-view",
23131 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
23132 className: "editor-list-view-sidebar__header",
23133 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
23134 className: "editor-list-view-sidebar__close-button",
23135 icon: close_small,
23136 label: (0,external_wp_i18n_namespaceObject.__)('Close'),
23137 onClick: closeListView,
23138 size: "small"
23139 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Tabs.TabList, {
23140 className: "editor-list-view-sidebar__tabs-tablist",
23141 ref: tabsRef,
23142 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.Tab, {
23143 className: "editor-list-view-sidebar__tabs-tab",
23144 tabId: "list-view",
23145 children: (0,external_wp_i18n_namespaceObject._x)('List View', 'Post overview')
23146 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.Tab, {
23147 className: "editor-list-view-sidebar__tabs-tab",
23148 tabId: "outline",
23149 children: (0,external_wp_i18n_namespaceObject._x)('Outline', 'Post overview')
23150 })]
23151 })]
23152 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.TabPanel, {
23153 ref: listViewContainerRef,
23154 className: "editor-list-view-sidebar__tabs-tabpanel",
23155 tabId: "list-view",
23156 focusable: false,
23157 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
23158 className: "editor-list-view-sidebar__list-view-container",
23159 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
23160 className: "editor-list-view-sidebar__list-view-panel-content",
23161 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalListView, {
23162 dropZoneElement: dropZoneElement
23163 })
23164 })
23165 })
23166 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.TabPanel, {
23167 className: "editor-list-view-sidebar__tabs-tabpanel",
23168 tabId: "outline",
23169 focusable: false,
23170 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
23171 className: "editor-list-view-sidebar__list-view-container",
23172 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ListViewOutline, {})
23173 })
23174 })]
23175 })
23176 })
23177 );
23178 }
23179
23180 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/save-publish-panels/index.js
23181 /**
23182 * WordPress dependencies
23183 */
23184
23185
23186
23187
23188
23189 /**
23190 * Internal dependencies
23191 */
23192
23193
23194
23195
23196
23197
23198
23199
23200
23201 const {
23202 Fill: save_publish_panels_Fill,
23203 Slot: save_publish_panels_Slot
23204 } = (0,external_wp_components_namespaceObject.createSlotFill)('ActionsPanel');
23205 const ActionsPanelFill = (/* unused pure expression or super */ null && (save_publish_panels_Fill));
23206 function SavePublishPanels({
23207 setEntitiesSavedStatesCallback,
23208 closeEntitiesSavedStates,
23209 isEntitiesSavedStatesOpen,
23210 forceIsDirtyPublishPanel
23211 }) {
23212 const {
23213 closePublishSidebar,
23214 togglePublishSidebar
23215 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23216 const {
23217 publishSidebarOpened,
23218 hasNonPostEntityChanges,
23219 hasPostMetaChanges
23220 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
23221 publishSidebarOpened: select(store_store).isPublishSidebarOpened(),
23222 hasNonPostEntityChanges: select(store_store).hasNonPostEntityChanges(),
23223 hasPostMetaChanges: unlock(select(store_store)).hasPostMetaChanges()
23224 }), []);
23225 const openEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(() => setEntitiesSavedStatesCallback(true), []);
23226
23227 // It is ok for these components to be unmounted when not in visual use.
23228 // We don't want more than one present at a time, decide which to render.
23229 let unmountableContent;
23230 if (publishSidebarOpened) {
23231 unmountableContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_panel, {
23232 onClose: closePublishSidebar,
23233 forceIsDirty: forceIsDirtyPublishPanel,
23234 PrePublishExtension: plugin_pre_publish_panel.Slot,
23235 PostPublishExtension: plugin_post_publish_panel.Slot
23236 });
23237 } else if (hasNonPostEntityChanges || hasPostMetaChanges) {
23238 unmountableContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
23239 className: "editor-layout__toggle-entities-saved-states-panel",
23240 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
23241 variant: "secondary",
23242 className: "editor-layout__toggle-entities-saved-states-panel-button",
23243 onClick: openEntitiesSavedStates,
23244 "aria-expanded": false,
23245 children: (0,external_wp_i18n_namespaceObject.__)('Open save panel')
23246 })
23247 });
23248 } else {
23249 unmountableContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
23250 className: "editor-layout__toggle-publish-panel",
23251 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
23252 variant: "secondary",
23253 className: "editor-layout__toggle-publish-panel-button",
23254 onClick: togglePublishSidebar,
23255 "aria-expanded": false,
23256 children: (0,external_wp_i18n_namespaceObject.__)('Open publish panel')
23257 })
23258 });
23259 }
23260
23261 // Since EntitiesSavedStates controls its own panel, we can keep it
23262 // always mounted to retain its own component state (such as checkboxes).
23263 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23264 children: [isEntitiesSavedStatesOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntitiesSavedStates, {
23265 close: closeEntitiesSavedStates
23266 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(save_publish_panels_Slot, {
23267 bubblesVirtually: true
23268 }), !isEntitiesSavedStatesOpen && unmountableContent]
23269 });
23270 }
23271
23272 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/text-editor/index.js
23273 /**
23274 * WordPress dependencies
23275 */
23276
23277
23278
23279
23280
23281
23282 /**
23283 * Internal dependencies
23284 */
23285
23286
23287
23288
23289
23290 function TextEditor({
23291 autoFocus = false
23292 }) {
23293 const {
23294 switchEditorMode
23295 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23296 const {
23297 shortcut,
23298 isRichEditingEnabled
23299 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23300 const {
23301 getEditorSettings
23302 } = select(store_store);
23303 const {
23304 getShortcutRepresentation
23305 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
23306 return {
23307 shortcut: getShortcutRepresentation('core/editor/toggle-mode'),
23308 isRichEditingEnabled: getEditorSettings().richEditingEnabled
23309 };
23310 }, []);
23311 const titleRef = (0,external_wp_element_namespaceObject.useRef)();
23312 (0,external_wp_element_namespaceObject.useEffect)(() => {
23313 if (autoFocus) {
23314 return;
23315 }
23316 titleRef?.current?.focus();
23317 }, [autoFocus]);
23318 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
23319 className: "editor-text-editor",
23320 children: [isRichEditingEnabled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
23321 className: "editor-text-editor__toolbar",
23322 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
23323 children: (0,external_wp_i18n_namespaceObject.__)('Editing code')
23324 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
23325 variant: "tertiary",
23326 onClick: () => switchEditorMode('visual'),
23327 shortcut: shortcut,
23328 children: (0,external_wp_i18n_namespaceObject.__)('Exit code editor')
23329 })]
23330 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
23331 className: "editor-text-editor__body",
23332 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_title_raw, {
23333 ref: titleRef
23334 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTextEditor, {})]
23335 })]
23336 });
23337 }
23338
23339 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/visual-editor/edit-template-blocks-notification.js
23340 /**
23341 * WordPress dependencies
23342 */
23343
23344
23345
23346
23347
23348
23349 /**
23350 * Internal dependencies
23351 */
23352
23353
23354 /**
23355 * Component that:
23356 *
23357 * - Displays a 'Edit your template to edit this block' notification when the
23358 * user is focusing on editing page content and clicks on a disabled template
23359 * block.
23360 * - Displays a 'Edit your template to edit this block' dialog when the user
23361 * is focusing on editing page conetnt and double clicks on a disabled
23362 * template block.
23363 *
23364 * @param {Object} props
23365 * @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block
23366 * editor iframe canvas.
23367 */
23368
23369 function EditTemplateBlocksNotification({
23370 contentRef
23371 }) {
23372 const {
23373 onNavigateToEntityRecord,
23374 templateId
23375 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23376 const {
23377 getEditorSettings,
23378 getCurrentTemplateId
23379 } = select(store_store);
23380 return {
23381 onNavigateToEntityRecord: getEditorSettings().onNavigateToEntityRecord,
23382 templateId: getCurrentTemplateId()
23383 };
23384 }, []);
23385 const canEditTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => {
23386 var _select$canUser;
23387 return (_select$canUser = select(external_wp_coreData_namespaceObject.store).canUser('create', 'templates')) !== null && _select$canUser !== void 0 ? _select$canUser : false;
23388 });
23389 const [isDialogOpen, setIsDialogOpen] = (0,external_wp_element_namespaceObject.useState)(false);
23390 (0,external_wp_element_namespaceObject.useEffect)(() => {
23391 const handleDblClick = event => {
23392 if (!canEditTemplate) {
23393 return;
23394 }
23395 if (!event.target.classList.contains('is-root-container')) {
23396 return;
23397 }
23398 setIsDialogOpen(true);
23399 };
23400 const canvas = contentRef.current;
23401 canvas?.addEventListener('dblclick', handleDblClick);
23402 return () => {
23403 canvas?.removeEventListener('dblclick', handleDblClick);
23404 };
23405 }, [contentRef, canEditTemplate]);
23406 if (!canEditTemplate) {
23407 return null;
23408 }
23409 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
23410 isOpen: isDialogOpen,
23411 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Edit template'),
23412 onConfirm: () => {
23413 setIsDialogOpen(false);
23414 onNavigateToEntityRecord({
23415 postId: templateId,
23416 postType: 'wp_template'
23417 });
23418 },
23419 onCancel: () => setIsDialogOpen(false),
23420 children: (0,external_wp_i18n_namespaceObject.__)('You’ve tried to select a block that is part of a template, which may be used on other posts and pages. Would you like to edit the template?')
23421 });
23422 }
23423
23424 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/resizable-editor/resize-handle.js
23425 /**
23426 * WordPress dependencies
23427 */
23428
23429
23430
23431
23432
23433
23434 const DELTA_DISTANCE = 20; // The distance to resize per keydown in pixels.
23435
23436 function ResizeHandle({
23437 direction,
23438 resizeWidthBy
23439 }) {
23440 function handleKeyDown(event) {
23441 const {
23442 keyCode
23443 } = event;
23444 if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.LEFT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.RIGHT) {
23445 resizeWidthBy(DELTA_DISTANCE);
23446 } else if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.RIGHT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.LEFT) {
23447 resizeWidthBy(-DELTA_DISTANCE);
23448 }
23449 }
23450 const resizeHandleVariants = {
23451 active: {
23452 opacity: 1,
23453 scaleY: 1.3
23454 }
23455 };
23456 const resizableHandleHelpId = `resizable-editor__resize-help-${direction}`;
23457 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23458 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Tooltip, {
23459 text: (0,external_wp_i18n_namespaceObject.__)('Drag to resize'),
23460 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.button, {
23461 className: `editor-resizable-editor__resize-handle is-${direction}`,
23462 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Drag to resize'),
23463 "aria-describedby": resizableHandleHelpId,
23464 onKeyDown: handleKeyDown,
23465 variants: resizeHandleVariants,
23466 whileFocus: "active",
23467 whileHover: "active",
23468 whileTap: "active",
23469 role: "separator",
23470 "aria-orientation": "vertical"
23471 }, "handle")
23472 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
23473 id: resizableHandleHelpId,
23474 children: (0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to resize the canvas.')
23475 })]
23476 });
23477 }
23478
23479 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/resizable-editor/index.js
23480 /**
23481 * External dependencies
23482 */
23483
23484
23485 /**
23486 * WordPress dependencies
23487 */
23488
23489
23490
23491 /**
23492 * Internal dependencies
23493 */
23494
23495
23496 // Removes the inline styles in the drag handles.
23497
23498 const HANDLE_STYLES_OVERRIDE = {
23499 position: undefined,
23500 userSelect: undefined,
23501 cursor: undefined,
23502 width: undefined,
23503 height: undefined,
23504 top: undefined,
23505 right: undefined,
23506 bottom: undefined,
23507 left: undefined
23508 };
23509 function ResizableEditor({
23510 className,
23511 enableResizing,
23512 height,
23513 children
23514 }) {
23515 const [width, setWidth] = (0,external_wp_element_namespaceObject.useState)('100%');
23516 const resizableRef = (0,external_wp_element_namespaceObject.useRef)();
23517 const resizeWidthBy = (0,external_wp_element_namespaceObject.useCallback)(deltaPixels => {
23518 if (resizableRef.current) {
23519 setWidth(resizableRef.current.offsetWidth + deltaPixels);
23520 }
23521 }, []);
23522 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ResizableBox, {
23523 className: dist_clsx('editor-resizable-editor', className, {
23524 'is-resizable': enableResizing
23525 }),
23526 ref: api => {
23527 resizableRef.current = api?.resizable;
23528 },
23529 size: {
23530 width: enableResizing ? width : '100%',
23531 height: enableResizing && height ? height : '100%'
23532 },
23533 onResizeStop: (event, direction, element) => {
23534 setWidth(element.style.width);
23535 },
23536 minWidth: 300,
23537 maxWidth: "100%",
23538 maxHeight: "100%",
23539 enable: {
23540 left: enableResizing,
23541 right: enableResizing
23542 },
23543 showHandle: enableResizing
23544 // The editor is centered horizontally, resizing it only
23545 // moves half the distance. Hence double the ratio to correctly
23546 // align the cursor to the resizer handle.
23547 ,
23548 resizeRatio: 2,
23549 handleComponent: {
23550 left: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResizeHandle, {
23551 direction: "left",
23552 resizeWidthBy: resizeWidthBy
23553 }),
23554 right: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResizeHandle, {
23555 direction: "right",
23556 resizeWidthBy: resizeWidthBy
23557 })
23558 },
23559 handleClasses: undefined,
23560 handleStyles: {
23561 left: HANDLE_STYLES_OVERRIDE,
23562 right: HANDLE_STYLES_OVERRIDE
23563 },
23564 children: children
23565 });
23566 }
23567 /* harmony default export */ const resizable_editor = (ResizableEditor);
23568
23569 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/use-select-nearest-editable-block.js
23570 /**
23571 * WordPress dependencies
23572 */
23573
23574
23575
23576
23577 /**
23578 * Internal dependencies
23579 */
23580
23581 const DISTANCE_THRESHOLD = 500;
23582 function clamp(value, min, max) {
23583 return Math.min(Math.max(value, min), max);
23584 }
23585 function distanceFromRect(x, y, rect) {
23586 const dx = x - clamp(x, rect.left, rect.right);
23587 const dy = y - clamp(y, rect.top, rect.bottom);
23588 return Math.sqrt(dx * dx + dy * dy);
23589 }
23590 function useSelectNearestEditableBlock({
23591 isEnabled = true
23592 } = {}) {
23593 const {
23594 getEnabledClientIdsTree,
23595 getBlockName,
23596 getBlockOrder
23597 } = unlock((0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store));
23598 const {
23599 selectBlock
23600 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
23601 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
23602 if (!isEnabled) {
23603 return;
23604 }
23605 const selectNearestEditableBlock = (x, y) => {
23606 const editableBlockClientIds = getEnabledClientIdsTree().flatMap(({
23607 clientId
23608 }) => {
23609 const blockName = getBlockName(clientId);
23610 if (blockName === 'core/template-part') {
23611 return [];
23612 }
23613 if (blockName === 'core/post-content') {
23614 const innerBlocks = getBlockOrder(clientId);
23615 if (innerBlocks.length) {
23616 return innerBlocks;
23617 }
23618 }
23619 return [clientId];
23620 });
23621 let nearestDistance = Infinity,
23622 nearestClientId = null;
23623 for (const clientId of editableBlockClientIds) {
23624 const block = element.querySelector(`[data-block="${clientId}"]`);
23625 if (!block) {
23626 continue;
23627 }
23628 const rect = block.getBoundingClientRect();
23629 const distance = distanceFromRect(x, y, rect);
23630 if (distance < nearestDistance && distance < DISTANCE_THRESHOLD) {
23631 nearestDistance = distance;
23632 nearestClientId = clientId;
23633 }
23634 }
23635 if (nearestClientId) {
23636 selectBlock(nearestClientId);
23637 }
23638 };
23639 const handleClick = event => {
23640 const shouldSelect = event.target === element || event.target.classList.contains('is-root-container');
23641 if (shouldSelect) {
23642 selectNearestEditableBlock(event.clientX, event.clientY);
23643 }
23644 };
23645 element.addEventListener('click', handleClick);
23646 return () => element.removeEventListener('click', handleClick);
23647 }, [isEnabled]);
23648 }
23649
23650 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/visual-editor/index.js
23651 /**
23652 * External dependencies
23653 */
23654
23655
23656 /**
23657 * WordPress dependencies
23658 */
23659
23660
23661
23662
23663
23664
23665
23666 /**
23667 * Internal dependencies
23668 */
23669
23670
23671
23672
23673
23674
23675
23676
23677
23678
23679 const {
23680 LayoutStyle,
23681 useLayoutClasses,
23682 useLayoutStyles,
23683 ExperimentalBlockCanvas: BlockCanvas,
23684 useFlashEditableBlocks
23685 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
23686
23687 /**
23688 * These post types have a special editor where they don't allow you to fill the title
23689 * and they don't apply the layout styles.
23690 */
23691 const visual_editor_DESIGN_POST_TYPES = [PATTERN_POST_TYPE, TEMPLATE_POST_TYPE, NAVIGATION_POST_TYPE, TEMPLATE_PART_POST_TYPE];
23692
23693 /**
23694 * Given an array of nested blocks, find the first Post Content
23695 * block inside it, recursing through any nesting levels,
23696 * and return its attributes.
23697 *
23698 * @param {Array} blocks A list of blocks.
23699 *
23700 * @return {Object | undefined} The Post Content block.
23701 */
23702 function getPostContentAttributes(blocks) {
23703 for (let i = 0; i < blocks.length; i++) {
23704 if (blocks[i].name === 'core/post-content') {
23705 return blocks[i].attributes;
23706 }
23707 if (blocks[i].innerBlocks.length) {
23708 const nestedPostContent = getPostContentAttributes(blocks[i].innerBlocks);
23709 if (nestedPostContent) {
23710 return nestedPostContent;
23711 }
23712 }
23713 }
23714 }
23715 function checkForPostContentAtRootLevel(blocks) {
23716 for (let i = 0; i < blocks.length; i++) {
23717 if (blocks[i].name === 'core/post-content') {
23718 return true;
23719 }
23720 }
23721 return false;
23722 }
23723 function VisualEditor({
23724 // Ideally as we unify post and site editors, we won't need these props.
23725 autoFocus,
23726 styles,
23727 disableIframe = false,
23728 iframeProps,
23729 contentRef,
23730 className
23731 }) {
23732 const [resizeObserver, sizes] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
23733 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<');
23734 const {
23735 renderingMode,
23736 postContentAttributes,
23737 editedPostTemplate = {},
23738 wrapperBlockName,
23739 wrapperUniqueId,
23740 deviceType,
23741 isFocusedEntity,
23742 isDesignPostType,
23743 postType,
23744 isPreview
23745 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23746 const {
23747 getCurrentPostId,
23748 getCurrentPostType,
23749 getCurrentTemplateId,
23750 getEditorSettings,
23751 getRenderingMode,
23752 getDeviceType
23753 } = select(store_store);
23754 const {
23755 getPostType,
23756 canUser,
23757 getEditedEntityRecord
23758 } = select(external_wp_coreData_namespaceObject.store);
23759 const postTypeSlug = getCurrentPostType();
23760 const _renderingMode = getRenderingMode();
23761 let _wrapperBlockName;
23762 if (postTypeSlug === PATTERN_POST_TYPE) {
23763 _wrapperBlockName = 'core/block';
23764 } else if (_renderingMode === 'post-only') {
23765 _wrapperBlockName = 'core/post-content';
23766 }
23767 const editorSettings = getEditorSettings();
23768 const supportsTemplateMode = editorSettings.supportsTemplateMode;
23769 const postTypeObject = getPostType(postTypeSlug);
23770 const canEditTemplate = canUser('create', 'templates');
23771 const currentTemplateId = getCurrentTemplateId();
23772 const template = currentTemplateId ? getEditedEntityRecord('postType', TEMPLATE_POST_TYPE, currentTemplateId) : undefined;
23773 return {
23774 renderingMode: _renderingMode,
23775 postContentAttributes: editorSettings.postContentAttributes,
23776 isDesignPostType: visual_editor_DESIGN_POST_TYPES.includes(postTypeSlug),
23777 // Post template fetch returns a 404 on classic themes, which
23778 // messes with e2e tests, so check it's a block theme first.
23779 editedPostTemplate: postTypeObject?.viewable && supportsTemplateMode && canEditTemplate ? template : undefined,
23780 wrapperBlockName: _wrapperBlockName,
23781 wrapperUniqueId: getCurrentPostId(),
23782 deviceType: getDeviceType(),
23783 isFocusedEntity: !!editorSettings.onNavigateToPreviousEntityRecord,
23784 postType: postTypeSlug,
23785 isPreview: editorSettings.__unstableIsPreviewMode
23786 };
23787 }, []);
23788 const {
23789 isCleanNewPost
23790 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
23791 const {
23792 hasRootPaddingAwareAlignments,
23793 themeHasDisabledLayoutStyles,
23794 themeSupportsLayout,
23795 isZoomOutMode
23796 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23797 const {
23798 getSettings,
23799 __unstableGetEditorMode
23800 } = select(external_wp_blockEditor_namespaceObject.store);
23801 const _settings = getSettings();
23802 return {
23803 themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
23804 themeSupportsLayout: _settings.supportsLayout,
23805 hasRootPaddingAwareAlignments: _settings.__experimentalFeatures?.useRootPaddingAwareAlignments,
23806 isZoomOutMode: __unstableGetEditorMode() === 'zoom-out'
23807 };
23808 }, []);
23809 const deviceStyles = (0,external_wp_blockEditor_namespaceObject.__experimentalUseResizeCanvas)(deviceType);
23810 const [globalLayoutSettings] = (0,external_wp_blockEditor_namespaceObject.useSettings)('layout');
23811
23812 // fallbackLayout is used if there is no Post Content,
23813 // and for Post Title.
23814 const fallbackLayout = (0,external_wp_element_namespaceObject.useMemo)(() => {
23815 if (renderingMode !== 'post-only' || isDesignPostType) {
23816 return {
23817 type: 'default'
23818 };
23819 }
23820 if (themeSupportsLayout) {
23821 // We need to ensure support for wide and full alignments,
23822 // so we add the constrained type.
23823 return {
23824 ...globalLayoutSettings,
23825 type: 'constrained'
23826 };
23827 }
23828 // Set default layout for classic themes so all alignments are supported.
23829 return {
23830 type: 'default'
23831 };
23832 }, [renderingMode, themeSupportsLayout, globalLayoutSettings, isDesignPostType]);
23833 const newestPostContentAttributes = (0,external_wp_element_namespaceObject.useMemo)(() => {
23834 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks && postContentAttributes) {
23835 return postContentAttributes;
23836 }
23837 // When in template editing mode, we can access the blocks directly.
23838 if (editedPostTemplate?.blocks) {
23839 return getPostContentAttributes(editedPostTemplate?.blocks);
23840 }
23841 // If there are no blocks, we have to parse the content string.
23842 // Best double-check it's a string otherwise the parse function gets unhappy.
23843 const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
23844 return getPostContentAttributes((0,external_wp_blocks_namespaceObject.parse)(parseableContent)) || {};
23845 }, [editedPostTemplate?.content, editedPostTemplate?.blocks, postContentAttributes]);
23846 const hasPostContentAtRootLevel = (0,external_wp_element_namespaceObject.useMemo)(() => {
23847 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) {
23848 return false;
23849 }
23850 // When in template editing mode, we can access the blocks directly.
23851 if (editedPostTemplate?.blocks) {
23852 return checkForPostContentAtRootLevel(editedPostTemplate?.blocks);
23853 }
23854 // If there are no blocks, we have to parse the content string.
23855 // Best double-check it's a string otherwise the parse function gets unhappy.
23856 const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
23857 return checkForPostContentAtRootLevel((0,external_wp_blocks_namespaceObject.parse)(parseableContent)) || false;
23858 }, [editedPostTemplate?.content, editedPostTemplate?.blocks]);
23859 const {
23860 layout = {},
23861 align = ''
23862 } = newestPostContentAttributes || {};
23863 const postContentLayoutClasses = useLayoutClasses(newestPostContentAttributes, 'core/post-content');
23864 const blockListLayoutClass = dist_clsx({
23865 'is-layout-flow': !themeSupportsLayout
23866 }, themeSupportsLayout && postContentLayoutClasses, align && `align${align}`);
23867 const postContentLayoutStyles = useLayoutStyles(newestPostContentAttributes, 'core/post-content', '.block-editor-block-list__layout.is-root-container');
23868
23869 // Update type for blocks using legacy layouts.
23870 const postContentLayout = (0,external_wp_element_namespaceObject.useMemo)(() => {
23871 return layout && (layout?.type === 'constrained' || layout?.inherit || layout?.contentSize || layout?.wideSize) ? {
23872 ...globalLayoutSettings,
23873 ...layout,
23874 type: 'constrained'
23875 } : {
23876 ...globalLayoutSettings,
23877 ...layout,
23878 type: 'default'
23879 };
23880 }, [layout?.type, layout?.inherit, layout?.contentSize, layout?.wideSize, globalLayoutSettings]);
23881
23882 // If there is a Post Content block we use its layout for the block list;
23883 // if not, this must be a classic theme, in which case we use the fallback layout.
23884 const blockListLayout = postContentAttributes ? postContentLayout : fallbackLayout;
23885 const postEditorLayout = blockListLayout?.type === 'default' && !hasPostContentAtRootLevel ? fallbackLayout : blockListLayout;
23886 const observeTypingRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseTypingObserver)();
23887 const titleRef = (0,external_wp_element_namespaceObject.useRef)();
23888 (0,external_wp_element_namespaceObject.useEffect)(() => {
23889 if (!autoFocus || !isCleanNewPost()) {
23890 return;
23891 }
23892 titleRef?.current?.focus();
23893 }, [autoFocus, isCleanNewPost]);
23894
23895 // Add some styles for alignwide/alignfull Post Content and its children.
23896 const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}
23897 .is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}
23898 .is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
23899 .is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;
23900 const localRef = (0,external_wp_element_namespaceObject.useRef)();
23901 const typewriterRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseTypewriter)();
23902 contentRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([localRef, contentRef, renderingMode === 'post-only' ? typewriterRef : null, useFlashEditableBlocks({
23903 isEnabled: renderingMode === 'template-locked'
23904 }), useSelectNearestEditableBlock({
23905 isEnabled: renderingMode === 'template-locked'
23906 })]);
23907 const zoomOutProps = isZoomOutMode ? {
23908 scale: 'default',
23909 frameSize: '20px'
23910 } : {};
23911 const forceFullHeight = postType === NAVIGATION_POST_TYPE;
23912 const enableResizing = [NAVIGATION_POST_TYPE, TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE].includes(postType) &&
23913 // Disable in previews / view mode.
23914 !isPreview &&
23915 // Disable resizing in mobile viewport.
23916 !isMobileViewport &&
23917 // Dsiable resizing in zoomed-out mode.
23918 !isZoomOutMode;
23919 const shouldIframe = !disableIframe || ['Tablet', 'Mobile'].includes(deviceType);
23920 const iframeStyles = (0,external_wp_element_namespaceObject.useMemo)(() => {
23921 return [...(styles !== null && styles !== void 0 ? styles : []), {
23922 css: `.is-root-container{display:flow-root;${
23923 // Some themes will have `min-height: 100vh` for the root container,
23924 // which isn't a requirement in auto resize mode.
23925 enableResizing ? 'min-height:0!important;' : ''}}`
23926 }];
23927 }, [styles, enableResizing]);
23928 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
23929 className: dist_clsx('editor-visual-editor',
23930 // this class is here for backward compatibility reasons.
23931 'edit-post-visual-editor', className, {
23932 'has-padding': isFocusedEntity || enableResizing,
23933 'is-resizable': enableResizing,
23934 'is-iframed': shouldIframe
23935 }),
23936 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(resizable_editor, {
23937 enableResizing: enableResizing,
23938 height: sizes.height && !forceFullHeight ? sizes.height : '100%',
23939 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(BlockCanvas, {
23940 shouldIframe: shouldIframe,
23941 contentRef: contentRef,
23942 styles: iframeStyles,
23943 height: "100%",
23944 iframeProps: {
23945 ...iframeProps,
23946 ...zoomOutProps,
23947 style: {
23948 ...iframeProps?.style,
23949 ...deviceStyles
23950 }
23951 },
23952 children: [themeSupportsLayout && !themeHasDisabledLayoutStyles && renderingMode === 'post-only' && !isDesignPostType && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23953 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
23954 selector: ".editor-visual-editor__post-title-wrapper",
23955 layout: fallbackLayout
23956 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
23957 selector: ".block-editor-block-list__layout.is-root-container",
23958 layout: postEditorLayout
23959 }), align && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
23960 css: alignCSS
23961 }), postContentLayoutStyles && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
23962 layout: postContentLayout,
23963 css: postContentLayoutStyles
23964 })]
23965 }), renderingMode === 'post-only' && !isDesignPostType && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
23966 className: dist_clsx('editor-visual-editor__post-title-wrapper',
23967 // The following class is only here for backward comapatibility
23968 // some themes might be using it to style the post title.
23969 'edit-post-visual-editor__post-title-wrapper', {
23970 'has-global-padding': hasRootPaddingAwareAlignments
23971 }),
23972 contentEditable: false,
23973 ref: observeTypingRef,
23974 style: {
23975 // This is using inline styles
23976 // so it's applied for both iframed and non iframed editors.
23977 marginTop: '4rem'
23978 },
23979 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_title, {
23980 ref: titleRef
23981 })
23982 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_blockEditor_namespaceObject.RecursionProvider, {
23983 blockName: wrapperBlockName,
23984 uniqueId: wrapperUniqueId,
23985 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockList, {
23986 className: dist_clsx('is-' + deviceType.toLowerCase() + '-preview', renderingMode !== 'post-only' || isDesignPostType ? 'wp-site-blocks' : `${blockListLayoutClass} wp-block-post-content` // Ensure root level blocks receive default/flow blockGap styling rules.
23987 ),
23988 layout: blockListLayout,
23989 dropZoneElement:
23990 // When iframed, pass in the html element of the iframe to
23991 // ensure the drop zone extends to the edges of the iframe.
23992 disableIframe ? localRef.current : localRef.current?.parentNode,
23993 __unstableDisableDropZone:
23994 // In template preview mode, disable drop zones at the root of the template.
23995 renderingMode === 'template-locked' ? true : false
23996 }), renderingMode === 'template-locked' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EditTemplateBlocksNotification, {
23997 contentRef: localRef
23998 })]
23999 }),
24000 // Avoid resize listeners when not needed,
24001 // these will trigger unnecessary re-renders
24002 // when animating the iframe width.
24003 enableResizing && resizeObserver]
24004 })
24005 })
24006 });
24007 }
24008 /* harmony default export */ const visual_editor = (VisualEditor);
24009
24010 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-interface/index.js
24011 /**
24012 * External dependencies
24013 */
24014
24015
24016 /**
24017 * WordPress dependencies
24018 */
24019
24020
24021
24022
24023
24024
24025
24026
24027
24028 /**
24029 * Internal dependencies
24030 */
24031
24032
24033
24034
24035
24036
24037
24038
24039
24040
24041
24042
24043 const interfaceLabels = {
24044 /* translators: accessibility text for the editor top bar landmark region. */
24045 header: (0,external_wp_i18n_namespaceObject.__)('Editor top bar'),
24046 /* translators: accessibility text for the editor content landmark region. */
24047 body: (0,external_wp_i18n_namespaceObject.__)('Editor content'),
24048 /* translators: accessibility text for the editor settings landmark region. */
24049 sidebar: (0,external_wp_i18n_namespaceObject.__)('Editor settings'),
24050 /* translators: accessibility text for the editor publish landmark region. */
24051 actions: (0,external_wp_i18n_namespaceObject.__)('Editor publish'),
24052 /* translators: accessibility text for the editor footer landmark region. */
24053 footer: (0,external_wp_i18n_namespaceObject.__)('Editor footer')
24054 };
24055 function EditorInterface({
24056 className,
24057 enableRegionNavigation,
24058 styles,
24059 children,
24060 forceIsDirty,
24061 contentRef,
24062 disableIframe,
24063 autoFocus,
24064 customSaveButton,
24065 forceDisableBlockTools,
24066 title,
24067 iframeProps
24068 }) {
24069 const {
24070 mode,
24071 isRichEditingEnabled,
24072 isInserterOpened,
24073 isListViewOpened,
24074 isDistractionFree,
24075 isPreviewMode,
24076 previousShortcut,
24077 nextShortcut,
24078 showBlockBreadcrumbs,
24079 documentLabel,
24080 blockEditorMode
24081 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24082 const {
24083 get
24084 } = select(external_wp_preferences_namespaceObject.store);
24085 const {
24086 getEditorSettings,
24087 getPostTypeLabel
24088 } = select(store_store);
24089 const editorSettings = getEditorSettings();
24090 const postTypeLabel = getPostTypeLabel();
24091 return {
24092 mode: select(store_store).getEditorMode(),
24093 isRichEditingEnabled: editorSettings.richEditingEnabled,
24094 isInserterOpened: select(store_store).isInserterOpened(),
24095 isListViewOpened: select(store_store).isListViewOpened(),
24096 isDistractionFree: get('core', 'distractionFree'),
24097 isPreviewMode: editorSettings.__unstableIsPreviewMode,
24098 previousShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/editor/previous-region'),
24099 nextShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/editor/next-region'),
24100 showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'),
24101 // translators: Default label for the Document in the Block Breadcrumb.
24102 documentLabel: postTypeLabel || (0,external_wp_i18n_namespaceObject._x)('Document', 'noun'),
24103 blockEditorMode: select(external_wp_blockEditor_namespaceObject.store).__unstableGetEditorMode()
24104 };
24105 }, []);
24106 const isWideViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('large');
24107 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
24108 const secondarySidebarLabel = isListViewOpened ? (0,external_wp_i18n_namespaceObject.__)('Document Overview') : (0,external_wp_i18n_namespaceObject.__)('Block Library');
24109
24110 // Local state for save panel.
24111 // Note 'truthy' callback implies an open panel.
24112 const [entitiesSavedStatesCallback, setEntitiesSavedStatesCallback] = (0,external_wp_element_namespaceObject.useState)(false);
24113 const closeEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(arg => {
24114 if (typeof entitiesSavedStatesCallback === 'function') {
24115 entitiesSavedStatesCallback(arg);
24116 }
24117 setEntitiesSavedStatesCallback(false);
24118 }, [entitiesSavedStatesCallback]);
24119 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(interface_skeleton, {
24120 enableRegionNavigation: enableRegionNavigation,
24121 isDistractionFree: isDistractionFree && isWideViewport,
24122 className: dist_clsx(className, {
24123 'is-entity-save-view-open': !!entitiesSavedStatesCallback
24124 }),
24125 labels: {
24126 ...interfaceLabels,
24127 secondarySidebar: secondarySidebarLabel
24128 },
24129 header: !isPreviewMode && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(components_header, {
24130 forceIsDirty: forceIsDirty,
24131 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback,
24132 customSaveButton: customSaveButton,
24133 forceDisableBlockTools: forceDisableBlockTools,
24134 title: title
24135 }),
24136 editorNotices: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(editor_notices, {}),
24137 secondarySidebar: !isPreviewMode && mode === 'visual' && (isInserterOpened && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(InserterSidebar, {}) || isListViewOpened && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ListViewSidebar, {})),
24138 sidebar: !isPreviewMode && !isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area.Slot, {
24139 scope: "core"
24140 }),
24141 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
24142 children: [!isDistractionFree && !isPreviewMode && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(editor_notices, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(content_slot_fill.Slot, {
24143 children: ([editorCanvasView]) => !isPreviewMode && editorCanvasView ? editorCanvasView : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
24144 children: [!isPreviewMode && (mode === 'text' || !isRichEditingEnabled) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TextEditor
24145 // We should auto-focus the canvas (title) on load.
24146 // eslint-disable-next-line jsx-a11y/no-autofocus
24147 , {
24148 autoFocus: autoFocus
24149 }), !isPreviewMode && !isLargeViewport && mode === 'visual' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockToolbar, {
24150 hideDragHandle: true
24151 }), (isPreviewMode || isRichEditingEnabled && mode === 'visual') && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(visual_editor, {
24152 styles: styles,
24153 contentRef: contentRef,
24154 disableIframe: disableIframe
24155 // We should auto-focus the canvas (title) on load.
24156 // eslint-disable-next-line jsx-a11y/no-autofocus
24157 ,
24158 autoFocus: autoFocus,
24159 iframeProps: iframeProps
24160 }), children]
24161 })
24162 })]
24163 }),
24164 footer: !isPreviewMode && !isDistractionFree && isLargeViewport && showBlockBreadcrumbs && isRichEditingEnabled && blockEditorMode !== 'zoom-out' && mode === 'visual' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24165 className: "edit-post-layout__footer",
24166 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockBreadcrumb, {
24167 rootLabelText: documentLabel
24168 })
24169 }),
24170 actions: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SavePublishPanels, {
24171 closeEntitiesSavedStates: closeEntitiesSavedStates,
24172 isEntitiesSavedStatesOpen: entitiesSavedStatesCallback,
24173 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback,
24174 forceIsDirtyPublishPanel: forceIsDirty
24175 }),
24176 shortcuts: {
24177 previous: previousShortcut,
24178 next: nextShortcut
24179 }
24180 });
24181 }
24182
24183 ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs
24184 /******************************************************************************
24185 Copyright (c) Microsoft Corporation.
24186
24187 Permission to use, copy, modify, and/or distribute this software for any
24188 purpose with or without fee is hereby granted.
24189
24190 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
24191 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
24192 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
24193 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
24194 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
24195 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
24196 PERFORMANCE OF THIS SOFTWARE.
24197 ***************************************************************************** */
24198 /* global Reflect, Promise, SuppressedError, Symbol */
24199
24200 var extendStatics = function(d, b) {
24201 extendStatics = Object.setPrototypeOf ||
24202 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
24203 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
24204 return extendStatics(d, b);
24205 };
24206
24207 function __extends(d, b) {
24208 if (typeof b !== "function" && b !== null)
24209 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
24210 extendStatics(d, b);
24211 function __() { this.constructor = d; }
24212 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
24213 }
24214
24215 var __assign = function() {
24216 __assign = Object.assign || function __assign(t) {
24217 for (var s, i = 1, n = arguments.length; i < n; i++) {
24218 s = arguments[i];
24219 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
24220 }
24221 return t;
24222 }
24223 return __assign.apply(this, arguments);
24224 }
24225
24226 function __rest(s, e) {
24227 var t = {};
24228 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24229 t[p] = s[p];
24230 if (s != null && typeof Object.getOwnPropertySymbols === "function")
24231 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
24232 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
24233 t[p[i]] = s[p[i]];
24234 }
24235 return t;
24236 }
24237
24238 function __decorate(decorators, target, key, desc) {
24239 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
24240 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
24241 else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
24242 return c > 3 && r && Object.defineProperty(target, key, r), r;
24243 }
24244
24245 function __param(paramIndex, decorator) {
24246 return function (target, key) { decorator(target, key, paramIndex); }
24247 }
24248
24249 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
24250 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
24251 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
24252 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
24253 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
24254 var _, done = false;
24255 for (var i = decorators.length - 1; i >= 0; i--) {
24256 var context = {};
24257 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
24258 for (var p in contextIn.access) context.access[p] = contextIn.access[p];
24259 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
24260 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
24261 if (kind === "accessor") {
24262 if (result === void 0) continue;
24263 if (result === null || typeof result !== "object") throw new TypeError("Object expected");
24264 if (_ = accept(result.get)) descriptor.get = _;
24265 if (_ = accept(result.set)) descriptor.set = _;
24266 if (_ = accept(result.init)) initializers.unshift(_);
24267 }
24268 else if (_ = accept(result)) {
24269 if (kind === "field") initializers.unshift(_);
24270 else descriptor[key] = _;
24271 }
24272 }
24273 if (target) Object.defineProperty(target, contextIn.name, descriptor);
24274 done = true;
24275 };
24276
24277 function __runInitializers(thisArg, initializers, value) {
24278 var useValue = arguments.length > 2;
24279 for (var i = 0; i < initializers.length; i++) {
24280 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
24281 }
24282 return useValue ? value : void 0;
24283 };
24284
24285 function __propKey(x) {
24286 return typeof x === "symbol" ? x : "".concat(x);
24287 };
24288
24289 function __setFunctionName(f, name, prefix) {
24290 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
24291 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
24292 };
24293
24294 function __metadata(metadataKey, metadataValue) {
24295 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
24296 }
24297
24298 function __awaiter(thisArg, _arguments, P, generator) {
24299 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
24300 return new (P || (P = Promise))(function (resolve, reject) {
24301 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
24302 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
24303 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
24304 step((generator = generator.apply(thisArg, _arguments || [])).next());
24305 });
24306 }
24307
24308 function __generator(thisArg, body) {
24309 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24310 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24311 function verb(n) { return function (v) { return step([n, v]); }; }
24312 function step(op) {
24313 if (f) throw new TypeError("Generator is already executing.");
24314 while (g && (g = 0, op[0] && (_ = 0)), _) try {
24315 if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
24316 if (y = 0, t) op = [op[0] & 2, t.value];
24317 switch (op[0]) {
24318 case 0: case 1: t = op; break;
24319 case 4: _.label++; return { value: op[1], done: false };
24320 case 5: _.label++; y = op[1]; op = [0]; continue;
24321 case 7: op = _.ops.pop(); _.trys.pop(); continue;
24322 default:
24323 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
24324 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
24325 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
24326 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
24327 if (t[2]) _.ops.pop();
24328 _.trys.pop(); continue;
24329 }
24330 op = body.call(thisArg, _);
24331 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
24332 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
24333 }
24334 }
24335
24336 var __createBinding = Object.create ? (function(o, m, k, k2) {
24337 if (k2 === undefined) k2 = k;
24338 var desc = Object.getOwnPropertyDescriptor(m, k);
24339 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
24340 desc = { enumerable: true, get: function() { return m[k]; } };
24341 }
24342 Object.defineProperty(o, k2, desc);
24343 }) : (function(o, m, k, k2) {
24344 if (k2 === undefined) k2 = k;
24345 o[k2] = m[k];
24346 });
24347
24348 function __exportStar(m, o) {
24349 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
24350 }
24351
24352 function __values(o) {
24353 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
24354 if (m) return m.call(o);
24355 if (o && typeof o.length === "number") return {
24356 next: function () {
24357 if (o && i >= o.length) o = void 0;
24358 return { value: o && o[i++], done: !o };
24359 }
24360 };
24361 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
24362 }
24363
24364 function __read(o, n) {
24365 var m = typeof Symbol === "function" && o[Symbol.iterator];
24366 if (!m) return o;
24367 var i = m.call(o), r, ar = [], e;
24368 try {
24369 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
24370 }
24371 catch (error) { e = { error: error }; }
24372 finally {
24373 try {
24374 if (r && !r.done && (m = i["return"])) m.call(i);
24375 }
24376 finally { if (e) throw e.error; }
24377 }
24378 return ar;
24379 }
24380
24381 /** @deprecated */
24382 function __spread() {
24383 for (var ar = [], i = 0; i < arguments.length; i++)
24384 ar = ar.concat(__read(arguments[i]));
24385 return ar;
24386 }
24387
24388 /** @deprecated */
24389 function __spreadArrays() {
24390 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
24391 for (var r = Array(s), k = 0, i = 0; i < il; i++)
24392 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
24393 r[k] = a[j];
24394 return r;
24395 }
24396
24397 function __spreadArray(to, from, pack) {
24398 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
24399 if (ar || !(i in from)) {
24400 if (!ar) ar = Array.prototype.slice.call(from, 0, i);
24401 ar[i] = from[i];
24402 }
24403 }
24404 return to.concat(ar || Array.prototype.slice.call(from));
24405 }
24406
24407 function __await(v) {
24408 return this instanceof __await ? (this.v = v, this) : new __await(v);
24409 }
24410
24411 function __asyncGenerator(thisArg, _arguments, generator) {
24412 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
24413 var g = generator.apply(thisArg, _arguments || []), i, q = [];
24414 return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
24415 function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
24416 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
24417 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
24418 function fulfill(value) { resume("next", value); }
24419 function reject(value) { resume("throw", value); }
24420 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
24421 }
24422
24423 function __asyncDelegator(o) {
24424 var i, p;
24425 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
24426 function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: false } : f ? f(v) : v; } : f; }
24427 }
24428
24429 function __asyncValues(o) {
24430 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
24431 var m = o[Symbol.asyncIterator], i;
24432 return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
24433 function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
24434 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
24435 }
24436
24437 function __makeTemplateObject(cooked, raw) {
24438 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
24439 return cooked;
24440 };
24441
24442 var __setModuleDefault = Object.create ? (function(o, v) {
24443 Object.defineProperty(o, "default", { enumerable: true, value: v });
24444 }) : function(o, v) {
24445 o["default"] = v;
24446 };
24447
24448 function __importStar(mod) {
24449 if (mod && mod.__esModule) return mod;
24450 var result = {};
24451 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
24452 __setModuleDefault(result, mod);
24453 return result;
24454 }
24455
24456 function __importDefault(mod) {
24457 return (mod && mod.__esModule) ? mod : { default: mod };
24458 }
24459
24460 function __classPrivateFieldGet(receiver, state, kind, f) {
24461 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
24462 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
24463 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
24464 }
24465
24466 function __classPrivateFieldSet(receiver, state, value, kind, f) {
24467 if (kind === "m") throw new TypeError("Private method is not writable");
24468 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
24469 if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
24470 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
24471 }
24472
24473 function __classPrivateFieldIn(state, receiver) {
24474 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
24475 return typeof state === "function" ? receiver === state : state.has(receiver);
24476 }
24477
24478 function __addDisposableResource(env, value, async) {
24479 if (value !== null && value !== void 0) {
24480 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
24481 var dispose;
24482 if (async) {
24483 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
24484 dispose = value[Symbol.asyncDispose];
24485 }
24486 if (dispose === void 0) {
24487 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
24488 dispose = value[Symbol.dispose];
24489 }
24490 if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
24491 env.stack.push({ value: value, dispose: dispose, async: async });
24492 }
24493 else if (async) {
24494 env.stack.push({ async: true });
24495 }
24496 return value;
24497 }
24498
24499 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
24500 var e = new Error(message);
24501 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
24502 };
24503
24504 function __disposeResources(env) {
24505 function fail(e) {
24506 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
24507 env.hasError = true;
24508 }
24509 function next() {
24510 while (env.stack.length) {
24511 var rec = env.stack.pop();
24512 try {
24513 var result = rec.dispose && rec.dispose.call(rec.value);
24514 if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
24515 }
24516 catch (e) {
24517 fail(e);
24518 }
24519 }
24520 if (env.hasError) throw env.error;
24521 }
24522 return next();
24523 }
24524
24525 /* harmony default export */ const tslib_es6 = ({
24526 __extends,
24527 __assign,
24528 __rest,
24529 __decorate,
24530 __param,
24531 __metadata,
24532 __awaiter,
24533 __generator,
24534 __createBinding,
24535 __exportStar,
24536 __values,
24537 __read,
24538 __spread,
24539 __spreadArrays,
24540 __spreadArray,
24541 __await,
24542 __asyncGenerator,
24543 __asyncDelegator,
24544 __asyncValues,
24545 __makeTemplateObject,
24546 __importStar,
24547 __importDefault,
24548 __classPrivateFieldGet,
24549 __classPrivateFieldSet,
24550 __classPrivateFieldIn,
24551 __addDisposableResource,
24552 __disposeResources,
24553 });
24554
24555 ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
24556 /**
24557 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
24558 */
24559 var SUPPORTED_LOCALE = {
24560 tr: {
24561 regexp: /\u0130|\u0049|\u0049\u0307/g,
24562 map: {
24563 İ: "\u0069",
24564 I: "\u0131",
24565 İ: "\u0069",
24566 },
24567 },
24568 az: {
24569 regexp: /\u0130/g,
24570 map: {
24571 İ: "\u0069",
24572 I: "\u0131",
24573 İ: "\u0069",
24574 },
24575 },
24576 lt: {
24577 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
24578 map: {
24579 I: "\u0069\u0307",
24580 J: "\u006A\u0307",
24581 Į: "\u012F\u0307",
24582 Ì: "\u0069\u0307\u0300",
24583 Í: "\u0069\u0307\u0301",
24584 Ĩ: "\u0069\u0307\u0303",
24585 },
24586 },
24587 };
24588 /**
24589 * Localized lower case.
24590 */
24591 function localeLowerCase(str, locale) {
24592 var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
24593 if (lang)
24594 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
24595 return lowerCase(str);
24596 }
24597 /**
24598 * Lower case as a function.
24599 */
24600 function lowerCase(str) {
24601 return str.toLowerCase();
24602 }
24603
24604 ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
24605
24606 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
24607 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
24608 // Remove all non-word characters.
24609 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
24610 /**
24611 * Normalize the string into something other libraries can manipulate easier.
24612 */
24613 function noCase(input, options) {
24614 if (options === void 0) { options = {}; }
24615 var _a = options.splitRegexp, splitRegexp = _a === void 0 ? DEFAULT_SPLIT_REGEXP : _a, _b = options.stripRegexp, stripRegexp = _b === void 0 ? DEFAULT_STRIP_REGEXP : _b, _c = options.transform, transform = _c === void 0 ? lowerCase : _c, _d = options.delimiter, delimiter = _d === void 0 ? " " : _d;
24616 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
24617 var start = 0;
24618 var end = result.length;
24619 // Trim the delimiter from around the output string.
24620 while (result.charAt(start) === "\0")
24621 start++;
24622 while (result.charAt(end - 1) === "\0")
24623 end--;
24624 // Transform each token independently.
24625 return result.slice(start, end).split("\0").map(transform).join(delimiter);
24626 }
24627 /**
24628 * Replace `re` in the input string with the replacement value.
24629 */
24630 function replace(input, re, value) {
24631 if (re instanceof RegExp)
24632 return input.replace(re, value);
24633 return re.reduce(function (input, re) { return input.replace(re, value); }, input);
24634 }
24635
24636 ;// CONCATENATED MODULE: ./node_modules/dot-case/dist.es2015/index.js
24637
24638
24639 function dotCase(input, options) {
24640 if (options === void 0) { options = {}; }
24641 return noCase(input, __assign({ delimiter: "." }, options));
24642 }
24643
24644 ;// CONCATENATED MODULE: ./node_modules/param-case/dist.es2015/index.js
24645
24646
24647 function paramCase(input, options) {
24648 if (options === void 0) { options = {}; }
24649 return dotCase(input, __assign({ delimiter: "-" }, options));
24650 }
24651
24652 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/create-template-part-modal/utils.js
24653 /**
24654 * External dependencies
24655 */
24656
24657
24658 /**
24659 * WordPress dependencies
24660 */
24661
24662
24663
24664 /**
24665 * Internal dependencies
24666 */
24667
24668 const useExistingTemplateParts = () => {
24669 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', TEMPLATE_PART_POST_TYPE, {
24670 per_page: -1
24671 }), []);
24672 };
24673
24674 /**
24675 * Return a unique template part title based on
24676 * the given title and existing template parts.
24677 *
24678 * @param {string} title The original template part title.
24679 * @param {Object} templateParts The array of template part entities.
24680 * @return {string} A unique template part title.
24681 */
24682 const getUniqueTemplatePartTitle = (title, templateParts) => {
24683 const lowercaseTitle = title.toLowerCase();
24684 const existingTitles = templateParts.map(templatePart => templatePart.title.rendered.toLowerCase());
24685 if (!existingTitles.includes(lowercaseTitle)) {
24686 return title;
24687 }
24688 let suffix = 2;
24689 while (existingTitles.includes(`${lowercaseTitle} ${suffix}`)) {
24690 suffix++;
24691 }
24692 return `${title} ${suffix}`;
24693 };
24694
24695 /**
24696 * Get a valid slug for a template part.
24697 * Currently template parts only allow latin chars.
24698 * The fallback slug will receive suffix by default.
24699 *
24700 * @param {string} title The template part title.
24701 * @return {string} A valid template part slug.
24702 */
24703 const getCleanTemplatePartSlug = title => {
24704 return paramCase(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
24705 };
24706
24707 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/create-template-part-modal/index.js
24708 /**
24709 * WordPress dependencies
24710 */
24711
24712
24713
24714
24715
24716
24717
24718
24719
24720
24721 /**
24722 * Internal dependencies
24723 */
24724
24725
24726
24727
24728
24729 function CreateTemplatePartModal({
24730 modalTitle,
24731 ...restProps
24732 }) {
24733 const defaultModalTitle = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(TEMPLATE_PART_POST_TYPE)?.labels?.add_new_item, []);
24734 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
24735 title: modalTitle || defaultModalTitle,
24736 onRequestClose: restProps.closeModal,
24737 overlayClassName: "editor-create-template-part-modal",
24738 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateTemplatePartModalContents, {
24739 ...restProps
24740 })
24741 });
24742 }
24743 function CreateTemplatePartModalContents({
24744 defaultArea = TEMPLATE_PART_AREA_DEFAULT_CATEGORY,
24745 blocks = [],
24746 confirmLabel = (0,external_wp_i18n_namespaceObject.__)('Add'),
24747 closeModal,
24748 onCreate,
24749 onError,
24750 defaultTitle = ''
24751 }) {
24752 const {
24753 createErrorNotice
24754 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
24755 const {
24756 saveEntityRecord
24757 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
24758 const existingTemplateParts = useExistingTemplateParts();
24759 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(defaultTitle);
24760 const [area, setArea] = (0,external_wp_element_namespaceObject.useState)(defaultArea);
24761 const [isSubmitting, setIsSubmitting] = (0,external_wp_element_namespaceObject.useState)(false);
24762 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(CreateTemplatePartModal);
24763 const templatePartAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).__experimentalGetDefaultTemplatePartAreas(), []);
24764 async function createTemplatePart() {
24765 if (!title || isSubmitting) {
24766 return;
24767 }
24768 try {
24769 setIsSubmitting(true);
24770 const uniqueTitle = getUniqueTemplatePartTitle(title, existingTemplateParts);
24771 const cleanSlug = getCleanTemplatePartSlug(uniqueTitle);
24772 const templatePart = await saveEntityRecord('postType', TEMPLATE_PART_POST_TYPE, {
24773 slug: cleanSlug,
24774 title: uniqueTitle,
24775 content: (0,external_wp_blocks_namespaceObject.serialize)(blocks),
24776 area
24777 }, {
24778 throwOnError: true
24779 });
24780 await onCreate(templatePart);
24781
24782 // TODO: Add a success notice?
24783 } catch (error) {
24784 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the template part.');
24785 createErrorNotice(errorMessage, {
24786 type: 'snackbar'
24787 });
24788 onError?.();
24789 } finally {
24790 setIsSubmitting(false);
24791 }
24792 }
24793 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
24794 onSubmit: async event => {
24795 event.preventDefault();
24796 await createTemplatePart();
24797 },
24798 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
24799 spacing: "4",
24800 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
24801 __next40pxDefaultSize: true,
24802 __nextHasNoMarginBottom: true,
24803 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
24804 value: title,
24805 onChange: setTitle,
24806 required: true
24807 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.BaseControl, {
24808 label: (0,external_wp_i18n_namespaceObject.__)('Area'),
24809 id: `editor-create-template-part-modal__area-selection-${instanceId}`,
24810 className: "editor-create-template-part-modal__area-base-control",
24811 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalRadioGroup, {
24812 label: (0,external_wp_i18n_namespaceObject.__)('Area'),
24813 className: "editor-create-template-part-modal__area-radio-group",
24814 id: `editor-create-template-part-modal__area-selection-${instanceId}`,
24815 onChange: setArea,
24816 checked: area,
24817 children: templatePartAreas.map(({
24818 icon,
24819 label,
24820 area: value,
24821 description
24822 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalRadio, {
24823 value: value,
24824 className: "editor-create-template-part-modal__area-radio",
24825 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
24826 align: "start",
24827 justify: "start",
24828 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
24829 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
24830 icon: icon
24831 })
24832 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.FlexBlock, {
24833 className: "editor-create-template-part-modal__option-label",
24834 children: [label, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24835 children: description
24836 })]
24837 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
24838 className: "editor-create-template-part-modal__checkbox",
24839 children: area === value && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
24840 icon: library_check
24841 })
24842 })]
24843 })
24844 }, label))
24845 })
24846 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
24847 justify: "right",
24848 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
24849 __next40pxDefaultSize: true,
24850 variant: "tertiary",
24851 onClick: () => {
24852 closeModal();
24853 },
24854 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
24855 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
24856 __next40pxDefaultSize: true,
24857 variant: "primary",
24858 type: "submit",
24859 "aria-disabled": !title || isSubmitting,
24860 isBusy: isSubmitting,
24861 children: confirmLabel
24862 })]
24863 })]
24864 })
24865 });
24866 }
24867
24868 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/preferences-modal/enable-publish-sidebar.js
24869 /**
24870 * WordPress dependencies
24871 */
24872
24873
24874
24875
24876 /**
24877 * Internal dependencies
24878 */
24879
24880
24881 const {
24882 PreferenceBaseOption: enable_publish_sidebar_PreferenceBaseOption
24883 } = unlock(external_wp_preferences_namespaceObject.privateApis);
24884 /* harmony default export */ const enable_publish_sidebar = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => ({
24885 isChecked: select(store_store).isPublishSidebarEnabled()
24886 })), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
24887 const {
24888 enablePublishSidebar,
24889 disablePublishSidebar
24890 } = dispatch(store_store);
24891 return {
24892 onChange: isEnabled => isEnabled ? enablePublishSidebar() : disablePublishSidebar()
24893 };
24894 }))(enable_publish_sidebar_PreferenceBaseOption));
24895
24896 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-manager/checklist.js
24897 /**
24898 * WordPress dependencies
24899 */
24900
24901
24902
24903
24904 function BlockTypesChecklist({
24905 blockTypes,
24906 value,
24907 onItemChange
24908 }) {
24909 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
24910 className: "editor-block-manager__checklist",
24911 children: blockTypes.map(blockType => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
24912 className: "editor-block-manager__checklist-item",
24913 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
24914 __nextHasNoMarginBottom: true,
24915 label: blockType.title,
24916 checked: value.includes(blockType.name),
24917 onChange: (...args) => onItemChange(blockType.name, ...args)
24918 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockIcon, {
24919 icon: blockType.icon
24920 })]
24921 }, blockType.name))
24922 });
24923 }
24924 /* harmony default export */ const checklist = (BlockTypesChecklist);
24925
24926 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-manager/category.js
24927 /**
24928 * WordPress dependencies
24929 */
24930
24931
24932
24933
24934
24935
24936 /**
24937 * Internal dependencies
24938 */
24939
24940
24941
24942
24943
24944 function BlockManagerCategory({
24945 title,
24946 blockTypes
24947 }) {
24948 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockManagerCategory);
24949 const {
24950 allowedBlockTypes,
24951 hiddenBlockTypes
24952 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24953 const {
24954 getEditorSettings
24955 } = select(store_store);
24956 const {
24957 get
24958 } = select(external_wp_preferences_namespaceObject.store);
24959 return {
24960 allowedBlockTypes: getEditorSettings().allowedBlockTypes,
24961 hiddenBlockTypes: get('core', 'hiddenBlockTypes')
24962 };
24963 }, []);
24964 const filteredBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
24965 if (allowedBlockTypes === true) {
24966 return blockTypes;
24967 }
24968 return blockTypes.filter(({
24969 name
24970 }) => {
24971 return allowedBlockTypes?.includes(name);
24972 });
24973 }, [allowedBlockTypes, blockTypes]);
24974 const {
24975 showBlockTypes,
24976 hideBlockTypes
24977 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
24978 const toggleVisible = (0,external_wp_element_namespaceObject.useCallback)((blockName, nextIsChecked) => {
24979 if (nextIsChecked) {
24980 showBlockTypes(blockName);
24981 } else {
24982 hideBlockTypes(blockName);
24983 }
24984 }, [showBlockTypes, hideBlockTypes]);
24985 const toggleAllVisible = (0,external_wp_element_namespaceObject.useCallback)(nextIsChecked => {
24986 const blockNames = blockTypes.map(({
24987 name
24988 }) => name);
24989 if (nextIsChecked) {
24990 showBlockTypes(blockNames);
24991 } else {
24992 hideBlockTypes(blockNames);
24993 }
24994 }, [blockTypes, showBlockTypes, hideBlockTypes]);
24995 if (!filteredBlockTypes.length) {
24996 return null;
24997 }
24998 const checkedBlockNames = filteredBlockTypes.map(({
24999 name
25000 }) => name).filter(type => !(hiddenBlockTypes !== null && hiddenBlockTypes !== void 0 ? hiddenBlockTypes : []).includes(type));
25001 const titleId = 'editor-block-manager__category-title-' + instanceId;
25002 const isAllChecked = checkedBlockNames.length === filteredBlockTypes.length;
25003 const isIndeterminate = !isAllChecked && checkedBlockNames.length > 0;
25004 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
25005 role: "group",
25006 "aria-labelledby": titleId,
25007 className: "editor-block-manager__category",
25008 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
25009 __nextHasNoMarginBottom: true,
25010 checked: isAllChecked,
25011 onChange: toggleAllVisible,
25012 className: "editor-block-manager__category-title",
25013 indeterminate: isIndeterminate,
25014 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
25015 id: titleId,
25016 children: title
25017 })
25018 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(checklist, {
25019 blockTypes: filteredBlockTypes,
25020 value: checkedBlockNames,
25021 onItemChange: toggleVisible
25022 })]
25023 });
25024 }
25025 /* harmony default export */ const block_manager_category = (BlockManagerCategory);
25026
25027 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-manager/index.js
25028 /**
25029 * WordPress dependencies
25030 */
25031
25032
25033
25034
25035
25036
25037
25038
25039
25040 /**
25041 * Internal dependencies
25042 */
25043
25044
25045
25046
25047
25048 function BlockManager({
25049 blockTypes,
25050 categories,
25051 hasBlockSupport,
25052 isMatchingSearchTerm,
25053 numberOfHiddenBlocks,
25054 enableAllBlockTypes
25055 }) {
25056 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
25057 const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)('');
25058
25059 // Filtering occurs here (as opposed to `withSelect`) to avoid
25060 // wasted renders by consequence of `Array#filter` producing
25061 // a new value reference on each call.
25062 blockTypes = blockTypes.filter(blockType => hasBlockSupport(blockType, 'inserter', true) && (!search || isMatchingSearchTerm(blockType, search)) && (!blockType.parent || blockType.parent.includes('core/post-content')));
25063
25064 // Announce search results on change
25065 (0,external_wp_element_namespaceObject.useEffect)(() => {
25066 if (!search) {
25067 return;
25068 }
25069 const count = blockTypes.length;
25070 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of results. */
25071 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count);
25072 debouncedSpeak(resultsFoundMessage);
25073 }, [blockTypes.length, search, debouncedSpeak]);
25074 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
25075 className: "editor-block-manager__content",
25076 children: [!!numberOfHiddenBlocks && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
25077 className: "editor-block-manager__disabled-blocks-count",
25078 children: [(0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of blocks. */
25079 (0,external_wp_i18n_namespaceObject._n)('%d block is hidden.', '%d blocks are hidden.', numberOfHiddenBlocks), numberOfHiddenBlocks), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25080 variant: "link",
25081 onClick: () => enableAllBlockTypes(blockTypes),
25082 children: (0,external_wp_i18n_namespaceObject.__)('Reset')
25083 })]
25084 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SearchControl, {
25085 __nextHasNoMarginBottom: true,
25086 label: (0,external_wp_i18n_namespaceObject.__)('Search for a block'),
25087 placeholder: (0,external_wp_i18n_namespaceObject.__)('Search for a block'),
25088 value: search,
25089 onChange: nextSearch => setSearch(nextSearch),
25090 className: "editor-block-manager__search"
25091 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
25092 tabIndex: "0",
25093 role: "region",
25094 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Available block types'),
25095 className: "editor-block-manager__results",
25096 children: [blockTypes.length === 0 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
25097 className: "editor-block-manager__no-results",
25098 children: (0,external_wp_i18n_namespaceObject.__)('No blocks found.')
25099 }), categories.map(category => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_manager_category, {
25100 title: category.title,
25101 blockTypes: blockTypes.filter(blockType => blockType.category === category.slug)
25102 }, category.slug)), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_manager_category, {
25103 title: (0,external_wp_i18n_namespaceObject.__)('Uncategorized'),
25104 blockTypes: blockTypes.filter(({
25105 category
25106 }) => !category)
25107 })]
25108 })]
25109 });
25110 }
25111 /* harmony default export */ const block_manager = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
25112 var _get;
25113 const {
25114 getBlockTypes,
25115 getCategories,
25116 hasBlockSupport,
25117 isMatchingSearchTerm
25118 } = select(external_wp_blocks_namespaceObject.store);
25119 const {
25120 get
25121 } = select(external_wp_preferences_namespaceObject.store);
25122
25123 // Some hidden blocks become unregistered
25124 // by removing for instance the plugin that registered them, yet
25125 // they're still remain as hidden by the user's action.
25126 // We consider "hidden", blocks which were hidden and
25127 // are still registered.
25128 const blockTypes = getBlockTypes();
25129 const hiddenBlockTypes = ((_get = get('core', 'hiddenBlockTypes')) !== null && _get !== void 0 ? _get : []).filter(hiddenBlock => {
25130 return blockTypes.some(registeredBlock => registeredBlock.name === hiddenBlock);
25131 });
25132 const numberOfHiddenBlocks = Array.isArray(hiddenBlockTypes) && hiddenBlockTypes.length;
25133 return {
25134 blockTypes,
25135 categories: getCategories(),
25136 hasBlockSupport,
25137 isMatchingSearchTerm,
25138 numberOfHiddenBlocks
25139 };
25140 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
25141 const {
25142 showBlockTypes
25143 } = unlock(dispatch(store_store));
25144 return {
25145 enableAllBlockTypes: blockTypes => {
25146 const blockNames = blockTypes.map(({
25147 name
25148 }) => name);
25149 showBlockTypes(blockNames);
25150 }
25151 };
25152 })])(BlockManager));
25153
25154 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/preferences-modal/index.js
25155 /**
25156 * WordPress dependencies
25157 */
25158
25159
25160
25161
25162
25163
25164
25165
25166 /**
25167 * Internal dependencies
25168 */
25169
25170
25171
25172
25173
25174
25175
25176
25177
25178
25179
25180
25181
25182
25183 const {
25184 PreferencesModal,
25185 PreferencesModalTabs,
25186 PreferencesModalSection,
25187 PreferenceToggleControl
25188 } = unlock(external_wp_preferences_namespaceObject.privateApis);
25189 function EditorPreferencesModal({
25190 extraSections = {}
25191 }) {
25192 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
25193 const {
25194 isActive,
25195 showBlockBreadcrumbsOption
25196 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
25197 const {
25198 getEditorSettings
25199 } = select(store_store);
25200 const {
25201 get
25202 } = select(external_wp_preferences_namespaceObject.store);
25203 const {
25204 isModalActive
25205 } = select(store);
25206 const isRichEditingEnabled = getEditorSettings().richEditingEnabled;
25207 const isDistractionFreeEnabled = get('core', 'distractionFree');
25208 return {
25209 showBlockBreadcrumbsOption: !isDistractionFreeEnabled && isLargeViewport && isRichEditingEnabled,
25210 isActive: isModalActive('editor/preferences')
25211 };
25212 }, [isLargeViewport]);
25213 const {
25214 closeModal
25215 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
25216 const {
25217 setIsListViewOpened,
25218 setIsInserterOpened
25219 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
25220 const {
25221 set: setPreference
25222 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
25223 const sections = (0,external_wp_element_namespaceObject.useMemo)(() => [{
25224 name: 'general',
25225 tabLabel: (0,external_wp_i18n_namespaceObject.__)('General'),
25226 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
25227 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
25228 title: (0,external_wp_i18n_namespaceObject.__)('Interface'),
25229 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
25230 scope: "core",
25231 featureName: "showListViewByDefault",
25232 help: (0,external_wp_i18n_namespaceObject.__)('Opens the List View sidebar by default.'),
25233 label: (0,external_wp_i18n_namespaceObject.__)('Always open List View')
25234 }), showBlockBreadcrumbsOption && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
25235 scope: "core",
25236 featureName: "showBlockBreadcrumbs",
25237 help: (0,external_wp_i18n_namespaceObject.__)('Display the block hierarchy trail at the bottom of the editor.'),
25238 label: (0,external_wp_i18n_namespaceObject.__)('Show block breadcrumbs')
25239 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
25240 scope: "core",
25241 featureName: "allowRightClickOverrides",
25242 help: (0,external_wp_i18n_namespaceObject.__)('Allows contextual List View menus via right-click, overriding browser defaults.'),
25243 label: (0,external_wp_i18n_namespaceObject.__)('Allow right-click contextual menus')
25244 })]
25245 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
25246 title: (0,external_wp_i18n_namespaceObject.__)('Document settings'),
25247 description: (0,external_wp_i18n_namespaceObject.__)('Select what settings are shown in the document panel.'),
25248 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_plugin_document_setting_panel.Slot, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_taxonomies, {
25249 taxonomyWrapper: (content, taxonomy) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
25250 label: taxonomy.labels.menu_name,
25251 panelName: `taxonomy-panel-${taxonomy.slug}`
25252 })
25253 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image_check, {
25254 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
25255 label: (0,external_wp_i18n_namespaceObject.__)('Featured image'),
25256 panelName: "featured-image"
25257 })
25258 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_check, {
25259 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
25260 label: (0,external_wp_i18n_namespaceObject.__)('Excerpt'),
25261 panelName: "post-excerpt"
25262 })
25263 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
25264 supportKeys: ['comments', 'trackbacks'],
25265 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
25266 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
25267 panelName: "discussion-panel"
25268 })
25269 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(page_attributes_check, {
25270 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
25271 label: (0,external_wp_i18n_namespaceObject.__)('Page attributes'),
25272 panelName: "page-attributes"
25273 })
25274 })]
25275 }), isLargeViewport && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
25276 title: (0,external_wp_i18n_namespaceObject.__)('Publishing'),
25277 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_publish_sidebar, {
25278 help: (0,external_wp_i18n_namespaceObject.__)('Review settings, such as visibility and tags.'),
25279 label: (0,external_wp_i18n_namespaceObject.__)('Enable pre-publish checks')
25280 })
25281 }), extraSections?.general]
25282 })
25283 }, {
25284 name: 'appearance',
25285 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Appearance'),
25286 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
25287 title: (0,external_wp_i18n_namespaceObject.__)('Appearance'),
25288 description: (0,external_wp_i18n_namespaceObject.__)('Customize the editor interface to suit your needs.'),
25289 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
25290 scope: "core",
25291 featureName: "fixedToolbar",
25292 onToggle: () => setPreference('core', 'distractionFree', false),
25293 help: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place.'),
25294 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar')
25295 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
25296 scope: "core",
25297 featureName: "distractionFree",
25298 onToggle: () => {
25299 setPreference('core', 'fixedToolbar', true);
25300 setIsInserterOpened(false);
25301 setIsListViewOpened(false);
25302 },
25303 help: (0,external_wp_i18n_namespaceObject.__)('Reduce visual distractions by hiding the toolbar and other elements to focus on writing.'),
25304 label: (0,external_wp_i18n_namespaceObject.__)('Distraction free')
25305 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
25306 scope: "core",
25307 featureName: "focusMode",
25308 help: (0,external_wp_i18n_namespaceObject.__)('Highlights the current block and fades other content.'),
25309 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode')
25310 }), extraSections?.appearance]
25311 })
25312 }, {
25313 name: 'accessibility',
25314 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Accessibility'),
25315 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
25316 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
25317 title: (0,external_wp_i18n_namespaceObject.__)('Navigation'),
25318 description: (0,external_wp_i18n_namespaceObject.__)('Optimize the editing experience for enhanced control.'),
25319 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
25320 scope: "core",
25321 featureName: "keepCaretInsideBlock",
25322 help: (0,external_wp_i18n_namespaceObject.__)('Keeps the text cursor within the block boundaries, aiding users with screen readers by preventing unintentional cursor movement outside the block.'),
25323 label: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block')
25324 })
25325 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
25326 title: (0,external_wp_i18n_namespaceObject.__)('Interface'),
25327 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
25328 scope: "core",
25329 featureName: "showIconLabels",
25330 label: (0,external_wp_i18n_namespaceObject.__)('Show button text labels'),
25331 help: (0,external_wp_i18n_namespaceObject.__)('Show text instead of icons on buttons across the interface.')
25332 })
25333 })]
25334 })
25335 }, {
25336 name: 'blocks',
25337 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
25338 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
25339 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
25340 title: (0,external_wp_i18n_namespaceObject.__)('Inserter'),
25341 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
25342 scope: "core",
25343 featureName: "mostUsedBlocks",
25344 help: (0,external_wp_i18n_namespaceObject.__)('Adds a category with the most frequently used blocks in the inserter.'),
25345 label: (0,external_wp_i18n_namespaceObject.__)('Show most used blocks')
25346 })
25347 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
25348 title: (0,external_wp_i18n_namespaceObject.__)('Manage block visibility'),
25349 description: (0,external_wp_i18n_namespaceObject.__)("Disable blocks that you don't want to appear in the inserter. They can always be toggled back on later."),
25350 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_manager, {})
25351 })]
25352 })
25353 }], [showBlockBreadcrumbsOption, extraSections, setIsInserterOpened, setIsListViewOpened, setPreference, isLargeViewport]);
25354 if (!isActive) {
25355 return null;
25356 }
25357 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModal, {
25358 closeModal: closeModal,
25359 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalTabs, {
25360 sections: sections
25361 })
25362 });
25363 }
25364
25365 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/trash.js
25366 /**
25367 * WordPress dependencies
25368 */
25369
25370
25371 const trash = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
25372 xmlns: "http://www.w3.org/2000/svg",
25373 viewBox: "0 0 24 24",
25374 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25375 fillRule: "evenodd",
25376 clipRule: "evenodd",
25377 d: "M12 5.5A2.25 2.25 0 0 0 9.878 7h4.244A2.251 2.251 0 0 0 12 5.5ZM12 4a3.751 3.751 0 0 0-3.675 3H5v1.5h1.27l.818 8.997a2.75 2.75 0 0 0 2.739 2.501h4.347a2.75 2.75 0 0 0 2.738-2.5L17.73 8.5H19V7h-3.325A3.751 3.751 0 0 0 12 4Zm4.224 4.5H7.776l.806 8.861a1.25 1.25 0 0 0 1.245 1.137h4.347a1.25 1.25 0 0 0 1.245-1.137l.805-8.861Z"
25378 })
25379 });
25380 /* harmony default export */ const library_trash = (trash);
25381
25382 ;// CONCATENATED MODULE: ./node_modules/client-zip/index.js
25383 "stream"in Blob.prototype||Object.defineProperty(Blob.prototype,"stream",{value(){return new Response(this).body}}),"setBigUint64"in DataView.prototype||Object.defineProperty(DataView.prototype,"setBigUint64",{value(e,n,t){const i=Number(0xffffffffn&n),r=Number(n>>32n);this.setUint32(e+(t?0:4),i,t),this.setUint32(e+(t?4:0),r,t)}});var e=e=>new DataView(new ArrayBuffer(e)),n=e=>new Uint8Array(e.buffer||e),t=e=>(new TextEncoder).encode(String(e)),i=e=>Math.min(4294967295,Number(e)),client_zip_r=e=>Math.min(65535,Number(e));function f(e,i){if(void 0===i||i instanceof Date||(i=new Date(i)),e instanceof File)return{isFile:1,t:i||new Date(e.lastModified),i:e.stream()};if(e instanceof Response)return{isFile:1,t:i||new Date(e.headers.get("Last-Modified")||Date.now()),i:e.body};if(void 0===i)i=new Date;else if(isNaN(i))throw new Error("Invalid modification date.");if(void 0===e)return{isFile:0,t:i};if("string"==typeof e)return{isFile:1,t:i,i:t(e)};if(e instanceof Blob)return{isFile:1,t:i,i:e.stream()};if(e instanceof Uint8Array||e instanceof ReadableStream)return{isFile:1,t:i,i:e};if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return{isFile:1,t:i,i:n(e)};if(Symbol.asyncIterator in e)return{isFile:1,t:i,i:o(e[Symbol.asyncIterator]())};throw new TypeError("Unsupported input format.")}function o(e,n=e){return new ReadableStream({async pull(n){let t=0;for(;n.desiredSize>t;){const i=await e.next();if(!i.value){n.close();break}{const e=a(i.value);n.enqueue(e),t+=e.byteLength}}},cancel(e){n.throw?.(e)}})}function a(e){return"string"==typeof e?t(e):e instanceof Uint8Array?e:n(e)}function s(e,i,r){let[f,o]=function(e){return e?e instanceof Uint8Array?[e,1]:ArrayBuffer.isView(e)||e instanceof ArrayBuffer?[n(e),1]:[t(e),0]:[void 0,0]}(i);if(e instanceof File)return{o:d(f||t(e.name)),u:BigInt(e.size),l:o};if(e instanceof Response){const n=e.headers.get("content-disposition"),i=n&&n.match(/;\s*filename\*?=["']?(.*?)["']?$/i),a=i&&i[1]||e.url&&new URL(e.url).pathname.split("/").findLast(Boolean),s=a&&decodeURIComponent(a),u=r||+e.headers.get("content-length");return{o:d(f||t(s)),u:BigInt(u),l:o}}return f=d(f,void 0!==e||void 0!==r),"string"==typeof e?{o:f,u:BigInt(t(e).length),l:o}:e instanceof Blob?{o:f,u:BigInt(e.size),l:o}:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?{o:f,u:BigInt(e.byteLength),l:o}:{o:f,u:u(e,r),l:o}}function u(e,n){return n>-1?BigInt(n):e?void 0:0n}function d(e,n=1){if(!e||e.every((c=>47===c)))throw new Error("The file must have a name.");if(n)for(;47===e[e.length-1];)e=e.subarray(0,-1);else 47!==e[e.length-1]&&(e=new Uint8Array([...e,47]));return e}var l=new Uint32Array(256);for(let e=0;e<256;++e){let n=e;for(let e=0;e<8;++e)n=n>>>1^(1&n&&3988292384);l[e]=n}function y(e,n=0){n^=-1;for(var t=0,i=e.length;t<i;t++)n=n>>>8^l[255&n^e[t]];return(-1^n)>>>0}function w(e,n,t=0){const i=e.getSeconds()>>1|e.getMinutes()<<5|e.getHours()<<11,r=e.getDate()|e.getMonth()+1<<5|e.getFullYear()-1980<<9;n.setUint16(t,i,1),n.setUint16(t+2,r,1)}function B({o:e,l:n},t){return 8*(!n||(t??function(e){try{b.decode(e)}catch{return 0}return 1}(e)))}var b=new TextDecoder("utf8",{fatal:1});function p(t,i=0){const r=e(30);return r.setUint32(0,1347093252),r.setUint32(4,754976768|i),w(t.t,r,10),r.setUint16(26,t.o.length,1),n(r)}async function*g(e){let{i:n}=e;if("then"in n&&(n=await n),n instanceof Uint8Array)yield n,e.m=y(n,0),e.u=BigInt(n.length);else{e.u=0n;const t=n.getReader();for(;;){const{value:n,done:i}=await t.read();if(i)break;e.m=y(n,e.m),e.u+=BigInt(n.length),yield n}}}function I(t,r){const f=e(16+(r?8:0));return f.setUint32(0,1347094280),f.setUint32(4,t.isFile?t.m:0,1),r?(f.setBigUint64(8,t.u,1),f.setBigUint64(16,t.u,1)):(f.setUint32(8,i(t.u),1),f.setUint32(12,i(t.u),1)),n(f)}function v(t,r,f=0,o=0){const a=e(46);return a.setUint32(0,1347092738),a.setUint32(4,755182848),a.setUint16(8,2048|f),w(t.t,a,12),a.setUint32(16,t.isFile?t.m:0,1),a.setUint32(20,i(t.u),1),a.setUint32(24,i(t.u),1),a.setUint16(28,t.o.length,1),a.setUint16(30,o,1),a.setUint16(40,t.isFile?33204:16893,1),a.setUint32(42,i(r),1),n(a)}function h(t,i,r){const f=e(r);return f.setUint16(0,1,1),f.setUint16(2,r-4,1),16&r&&(f.setBigUint64(4,t.u,1),f.setBigUint64(12,t.u,1)),f.setBigUint64(r-8,i,1),n(f)}function D(e){return e instanceof File||e instanceof Response?[[e],[e]]:[[e.input,e.name,e.size],[e.input,e.lastModified]]}var S=e=>function(e){let n=BigInt(22),t=0n,i=0;for(const r of e){if(!r.o)throw new Error("Every file must have a non-empty name.");if(void 0===r.u)throw new Error(`Missing size for file "${(new TextDecoder).decode(r.o)}".`);const e=r.u>=0xffffffffn,f=t>=0xffffffffn;t+=BigInt(46+r.o.length+(e&&8))+r.u,n+=BigInt(r.o.length+46+(12*f|28*e)),i||(i=e)}return(i||t>=0xffffffffn)&&(n+=BigInt(76)),n+t}(function*(e){for(const n of e)yield s(...D(n)[0])}(e));function A(e,n={}){const t={"Content-Type":"application/zip","Content-Disposition":"attachment"};return("bigint"==typeof n.length||Number.isInteger(n.length))&&n.length>0&&(t["Content-Length"]=String(n.length)),n.metadata&&(t["Content-Length"]=String(S(n.metadata))),new Response(N(e,n),{headers:t})}function N(t,a={}){const u=function(e){const n=e[Symbol.iterator in e?Symbol.iterator:Symbol.asyncIterator]();return{async next(){const e=await n.next();if(e.done)return e;const[t,i]=D(e.value);return{done:0,value:Object.assign(f(...i),s(...t))}},throw:n.throw?.bind(n),[Symbol.asyncIterator](){return this}}}(t);return o(async function*(t,f){const o=[];let a=0n,s=0n,u=0;for await(const e of t){const n=B(e,f.buffersAreUTF8);yield p(e,n),yield new Uint8Array(e.o),e.isFile&&(yield*g(e));const t=e.u>=0xffffffffn,i=12*(a>=0xffffffffn)|28*t;yield I(e,t),o.push(v(e,a,n,i)),o.push(e.o),i&&o.push(h(e,a,i)),t&&(a+=8n),s++,a+=BigInt(46+e.o.length)+e.u,u||(u=t)}let d=0n;for(const e of o)yield e,d+=BigInt(e.length);if(u||a>=0xffffffffn){const t=e(76);t.setUint32(0,1347094022),t.setBigUint64(4,BigInt(44),1),t.setUint32(12,755182848),t.setBigUint64(24,s,1),t.setBigUint64(32,s,1),t.setBigUint64(40,d,1),t.setBigUint64(48,a,1),t.setUint32(56,1347094023),t.setBigUint64(64,a+d,1),t.setUint32(72,1,1),yield n(t)}const l=e(22);l.setUint32(0,1347093766),l.setUint16(8,client_zip_r(s),1),l.setUint16(10,client_zip_r(s),1),l.setUint32(12,i(d),1),l.setUint32(16,i(a),1),yield n(l)}(u,a),u)}
25384 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-actions/export-pattern-action.js
25385 /**
25386 * External dependencies
25387 */
25388
25389
25390
25391 /**
25392 * WordPress dependencies
25393 */
25394
25395
25396
25397
25398 /**
25399 * Internal dependencies
25400 */
25401
25402
25403 // Patterns.
25404 const {
25405 PATTERN_TYPES: export_pattern_action_PATTERN_TYPES
25406 } = unlock(external_wp_patterns_namespaceObject.privateApis);
25407 function getJsonFromItem(item) {
25408 return JSON.stringify({
25409 __file: item.type,
25410 title: item.title || item.name,
25411 content: item.patternPost.content.raw,
25412 syncStatus: item.patternPost.wp_pattern_sync_status
25413 }, null, 2);
25414 }
25415 const exportPatternAsJSONAction = {
25416 id: 'export-pattern',
25417 label: (0,external_wp_i18n_namespaceObject.__)('Export as JSON'),
25418 supportsBulk: true,
25419 isEligible: item => {
25420 if (!item.type) {
25421 return false;
25422 }
25423 return item.type === export_pattern_action_PATTERN_TYPES.user;
25424 },
25425 callback: async items => {
25426 if (items.length === 1) {
25427 return (0,external_wp_blob_namespaceObject.downloadBlob)(`${paramCase(items[0].title || items[0].name)}.json`, getJsonFromItem(items[0]), 'application/json');
25428 }
25429 const nameCount = {};
25430 const filesToZip = items.map(item => {
25431 const name = paramCase(item.title || item.name);
25432 nameCount[name] = (nameCount[name] || 0) + 1;
25433 return {
25434 name: `${name + (nameCount[name] > 1 ? '-' + (nameCount[name] - 1) : '')}.json`,
25435 lastModified: new Date(),
25436 input: getJsonFromItem(item)
25437 };
25438 });
25439 return (0,external_wp_blob_namespaceObject.downloadBlob)((0,external_wp_i18n_namespaceObject.__)('patterns-export') + '.zip', await A(filesToZip).blob(), 'application/zip');
25440 }
25441 };
25442
25443 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-actions/actions.js
25444 /**
25445 * WordPress dependencies
25446 */
25447
25448
25449
25450
25451
25452
25453
25454
25455
25456
25457
25458 /**
25459 * Internal dependencies
25460 */
25461
25462
25463
25464
25465
25466
25467
25468 // Patterns.
25469
25470
25471 const {
25472 PATTERN_TYPES: actions_PATTERN_TYPES,
25473 CreatePatternModalContents,
25474 useDuplicatePatternProps
25475 } = unlock(external_wp_patterns_namespaceObject.privateApis);
25476
25477 /**
25478 * Check if a template is removable.
25479 *
25480 * @param {Object} template The template entity to check.
25481 * @return {boolean} Whether the template is removable.
25482 */
25483 function isTemplateRemovable(template) {
25484 if (!template) {
25485 return false;
25486 }
25487 // In patterns list page we map the templates parts to a different object
25488 // than the one returned from the endpoint. This is why we need to check for
25489 // two props whether is custom or has a theme file.
25490 return [template.source, template.templatePart?.source].includes(TEMPLATE_ORIGINS.custom) && !template.has_theme_file && !template.templatePart?.has_theme_file;
25491 }
25492 const canDeleteOrReset = item => {
25493 const isTemplatePart = item.type === TEMPLATE_PART_POST_TYPE;
25494 const isUserPattern = item.type === actions_PATTERN_TYPES.user;
25495 return isUserPattern || isTemplatePart && item.isCustom;
25496 };
25497 function getItemTitle(item) {
25498 if (typeof item.title === 'string') {
25499 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title);
25500 }
25501 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title?.rendered || '');
25502 }
25503
25504 // This action is used for templates, patterns and template parts.
25505 // Every other post type uses the similar `trashPostAction` which
25506 // moves the post to trash.
25507 const deletePostAction = {
25508 id: 'delete-post',
25509 label: (0,external_wp_i18n_namespaceObject.__)('Delete'),
25510 isPrimary: true,
25511 icon: library_trash,
25512 isEligible(post) {
25513 if ([TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(post.type)) {
25514 return isTemplateRemovable(post);
25515 }
25516 // We can only remove user patterns.
25517 return post.type === actions_PATTERN_TYPES.user;
25518 },
25519 supportsBulk: true,
25520 hideModalHeader: true,
25521 RenderModal: ({
25522 items,
25523 closeModal,
25524 onActionStart,
25525 onActionPerformed
25526 }) => {
25527 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
25528 const {
25529 removeTemplates
25530 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
25531 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
25532 spacing: "5",
25533 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
25534 children: items.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)(
25535 // translators: %d: number of items to delete.
25536 (0,external_wp_i18n_namespaceObject._n)('Delete %d item?', 'Delete %d items?', items.length), items.length) : (0,external_wp_i18n_namespaceObject.sprintf)(
25537 // translators: %s: The template or template part's titles
25538 (0,external_wp_i18n_namespaceObject.__)('Delete "%s"?'), getItemTitle(items[0]))
25539 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
25540 justify: "right",
25541 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25542 variant: "tertiary",
25543 onClick: closeModal,
25544 disabled: isBusy,
25545 __experimentalIsFocusable: true,
25546 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
25547 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25548 variant: "primary",
25549 onClick: async () => {
25550 setIsBusy(true);
25551 if (onActionStart) {
25552 onActionStart(items);
25553 }
25554 await removeTemplates(items, {
25555 allowUndo: false
25556 });
25557 onActionPerformed?.(items);
25558 setIsBusy(false);
25559 closeModal();
25560 },
25561 isBusy: isBusy,
25562 disabled: isBusy,
25563 __experimentalIsFocusable: true,
25564 children: (0,external_wp_i18n_namespaceObject.__)('Delete')
25565 })]
25566 })]
25567 });
25568 }
25569 };
25570 const trashPostAction = {
25571 id: 'move-to-trash',
25572 label: (0,external_wp_i18n_namespaceObject.__)('Move to Trash'),
25573 isPrimary: true,
25574 icon: library_trash,
25575 isEligible(item) {
25576 return !['auto-draft', 'trash'].includes(item.status);
25577 },
25578 supportsBulk: true,
25579 hideModalHeader: true,
25580 RenderModal: ({
25581 items,
25582 closeModal,
25583 onActionStart,
25584 onActionPerformed
25585 }) => {
25586 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
25587 const {
25588 createSuccessNotice,
25589 createErrorNotice
25590 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
25591 const {
25592 deleteEntityRecord
25593 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
25594 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
25595 spacing: "5",
25596 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
25597 children: items.length === 1 ? (0,external_wp_i18n_namespaceObject.sprintf)(
25598 // translators: %s: The item's title.
25599 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to move to trash "%s"?'), getItemTitle(items[0])) : (0,external_wp_i18n_namespaceObject.sprintf)(
25600 // translators: %d: The number of items (2 or more).
25601 (0,external_wp_i18n_namespaceObject._n)('Are you sure you want to move to trash %d item?', 'Are you sure you want to move to trash %d items?', items.length), items.length)
25602 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
25603 justify: "right",
25604 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25605 variant: "tertiary",
25606 onClick: closeModal,
25607 disabled: isBusy,
25608 __experimentalIsFocusable: true,
25609 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
25610 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25611 variant: "primary",
25612 onClick: async () => {
25613 setIsBusy(true);
25614 if (onActionStart) {
25615 onActionStart(items);
25616 }
25617 const promiseResult = await Promise.allSettled(items.map(item => deleteEntityRecord('postType', item.type, item.id, {}, {
25618 throwOnError: true
25619 })));
25620 // If all the promises were fulfilled with success.
25621 if (promiseResult.every(({
25622 status
25623 }) => status === 'fulfilled')) {
25624 let successMessage;
25625 if (promiseResult.length === 1) {
25626 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The item's title. */
25627 (0,external_wp_i18n_namespaceObject.__)('"%s" moved to trash.'), getItemTitle(items[0]));
25628 } else if (items[0].type === 'page') {
25629 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of items. */
25630 (0,external_wp_i18n_namespaceObject.__)('%s items moved to trash.'), items.length);
25631 } else {
25632 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */
25633 (0,external_wp_i18n_namespaceObject.__)('%s items move to trash.'), items.length);
25634 }
25635 createSuccessNotice(successMessage, {
25636 type: 'snackbar',
25637 id: 'move-to-trash-action'
25638 });
25639 } else {
25640 // If there was at least one failure.
25641 let errorMessage;
25642 // If we were trying to delete a single item.
25643 if (promiseResult.length === 1) {
25644 if (promiseResult[0].reason?.message) {
25645 errorMessage = promiseResult[0].reason.message;
25646 } else {
25647 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving to trash the item.');
25648 }
25649 // If we were trying to delete multiple items.
25650 } else {
25651 const errorMessages = new Set();
25652 const failedPromises = promiseResult.filter(({
25653 status
25654 }) => status === 'rejected');
25655 for (const failedPromise of failedPromises) {
25656 if (failedPromise.reason?.message) {
25657 errorMessages.add(failedPromise.reason.message);
25658 }
25659 }
25660 if (errorMessages.size === 0) {
25661 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving to trash the items.');
25662 } else if (errorMessages.size === 1) {
25663 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
25664 (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving to trash the item: %s'), [...errorMessages][0]);
25665 } else {
25666 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
25667 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while moving to trash the items: %s'), [...errorMessages].join(','));
25668 }
25669 }
25670 createErrorNotice(errorMessage, {
25671 type: 'snackbar'
25672 });
25673 }
25674 if (onActionPerformed) {
25675 onActionPerformed(items);
25676 }
25677 setIsBusy(false);
25678 closeModal();
25679 },
25680 isBusy: isBusy,
25681 disabled: isBusy,
25682 __experimentalIsFocusable: true,
25683 children: (0,external_wp_i18n_namespaceObject.__)('Trash')
25684 })]
25685 })]
25686 });
25687 }
25688 };
25689 function usePermanentlyDeletePostAction() {
25690 const {
25691 createSuccessNotice,
25692 createErrorNotice
25693 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
25694 const {
25695 deleteEntityRecord
25696 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
25697 return (0,external_wp_element_namespaceObject.useMemo)(() => ({
25698 id: 'permanently-delete',
25699 label: (0,external_wp_i18n_namespaceObject.__)('Permanently delete'),
25700 supportsBulk: true,
25701 isEligible({
25702 status
25703 }) {
25704 return status === 'trash';
25705 },
25706 async callback(posts, onActionPerformed) {
25707 const promiseResult = await Promise.allSettled(posts.map(post => {
25708 return deleteEntityRecord('postType', post.type, post.id, {
25709 force: true
25710 }, {
25711 throwOnError: true
25712 });
25713 }));
25714 // If all the promises were fulfilled with success.
25715 if (promiseResult.every(({
25716 status
25717 }) => status === 'fulfilled')) {
25718 let successMessage;
25719 if (promiseResult.length === 1) {
25720 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The posts's title. */
25721 (0,external_wp_i18n_namespaceObject.__)('"%s" permanently deleted.'), getItemTitle(posts[0]));
25722 } else {
25723 successMessage = (0,external_wp_i18n_namespaceObject.__)('The posts were permanently deleted.');
25724 }
25725 createSuccessNotice(successMessage, {
25726 type: 'snackbar',
25727 id: 'permanently-delete-post-action'
25728 });
25729 if (onActionPerformed) {
25730 onActionPerformed(posts);
25731 }
25732 } else {
25733 // If there was at lease one failure.
25734 let errorMessage;
25735 // If we were trying to permanently delete a single post.
25736 if (promiseResult.length === 1) {
25737 if (promiseResult[0].reason?.message) {
25738 errorMessage = promiseResult[0].reason.message;
25739 } else {
25740 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the post.');
25741 }
25742 // If we were trying to permanently delete multiple posts
25743 } else {
25744 const errorMessages = new Set();
25745 const failedPromises = promiseResult.filter(({
25746 status
25747 }) => status === 'rejected');
25748 for (const failedPromise of failedPromises) {
25749 if (failedPromise.reason?.message) {
25750 errorMessages.add(failedPromise.reason.message);
25751 }
25752 }
25753 if (errorMessages.size === 0) {
25754 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the posts.');
25755 } else if (errorMessages.size === 1) {
25756 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
25757 (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the posts: %s'), [...errorMessages][0]);
25758 } else {
25759 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
25760 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while permanently deleting the posts: %s'), [...errorMessages].join(','));
25761 }
25762 }
25763 createErrorNotice(errorMessage, {
25764 type: 'snackbar'
25765 });
25766 }
25767 }
25768 }), [createSuccessNotice, createErrorNotice, deleteEntityRecord]);
25769 }
25770 function useRestorePostAction() {
25771 const {
25772 createSuccessNotice,
25773 createErrorNotice
25774 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
25775 const {
25776 editEntityRecord,
25777 saveEditedEntityRecord
25778 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
25779 return (0,external_wp_element_namespaceObject.useMemo)(() => ({
25780 id: 'restore',
25781 label: (0,external_wp_i18n_namespaceObject.__)('Restore'),
25782 isPrimary: true,
25783 icon: library_backup,
25784 supportsBulk: true,
25785 isEligible({
25786 status
25787 }) {
25788 return status === 'trash';
25789 },
25790 async callback(posts, onActionPerformed) {
25791 await Promise.allSettled(posts.map(post => {
25792 return editEntityRecord('postType', post.type, post.id, {
25793 status: 'draft'
25794 });
25795 }));
25796 const promiseResult = await Promise.allSettled(posts.map(post => {
25797 return saveEditedEntityRecord('postType', post.type, post.id, {
25798 throwOnError: true
25799 });
25800 }));
25801 if (promiseResult.every(({
25802 status
25803 }) => status === 'fulfilled')) {
25804 let successMessage;
25805 if (posts.length === 1) {
25806 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */
25807 (0,external_wp_i18n_namespaceObject.__)('"%s" has been restored.'), getItemTitle(posts[0]));
25808 } else if (posts[0].type === 'page') {
25809 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */
25810 (0,external_wp_i18n_namespaceObject.__)('%d pages have been restored.'), posts.length);
25811 } else {
25812 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */
25813 (0,external_wp_i18n_namespaceObject.__)('%d posts have been restored.'), posts.length);
25814 }
25815 createSuccessNotice(successMessage, {
25816 type: 'snackbar',
25817 id: 'restore-post-action'
25818 });
25819 if (onActionPerformed) {
25820 onActionPerformed(posts);
25821 }
25822 } else {
25823 // If there was at lease one failure.
25824 let errorMessage;
25825 // If we were trying to move a single post to the trash.
25826 if (promiseResult.length === 1) {
25827 if (promiseResult[0].reason?.message) {
25828 errorMessage = promiseResult[0].reason.message;
25829 } else {
25830 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the post.');
25831 }
25832 // If we were trying to move multiple posts to the trash
25833 } else {
25834 const errorMessages = new Set();
25835 const failedPromises = promiseResult.filter(({
25836 status
25837 }) => status === 'rejected');
25838 for (const failedPromise of failedPromises) {
25839 if (failedPromise.reason?.message) {
25840 errorMessages.add(failedPromise.reason.message);
25841 }
25842 }
25843 if (errorMessages.size === 0) {
25844 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the posts.');
25845 } else if (errorMessages.size === 1) {
25846 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
25847 (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the posts: %s'), [...errorMessages][0]);
25848 } else {
25849 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
25850 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while restoring the posts: %s'), [...errorMessages].join(','));
25851 }
25852 }
25853 createErrorNotice(errorMessage, {
25854 type: 'snackbar'
25855 });
25856 }
25857 }
25858 }), [createSuccessNotice, createErrorNotice, editEntityRecord, saveEditedEntityRecord]);
25859 }
25860 const viewPostAction = {
25861 id: 'view-post',
25862 label: (0,external_wp_i18n_namespaceObject.__)('View'),
25863 isPrimary: true,
25864 icon: library_external,
25865 isEligible(post) {
25866 return post.status !== 'trash';
25867 },
25868 callback(posts, onActionPerformed) {
25869 const post = posts[0];
25870 window.open(post.link, '_blank');
25871 if (onActionPerformed) {
25872 onActionPerformed(posts);
25873 }
25874 }
25875 };
25876 const postRevisionsAction = {
25877 id: 'view-post-revisions',
25878 label(items) {
25879 var _items$0$_links$versi;
25880 const revisionsCount = (_items$0$_links$versi = items[0]._links?.['version-history']?.[0]?.count) !== null && _items$0$_links$versi !== void 0 ? _items$0$_links$versi : 0;
25881 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: number of revisions */
25882 (0,external_wp_i18n_namespaceObject.__)('View revisions (%s)'), revisionsCount);
25883 },
25884 isEligible: post => {
25885 var _post$_links$predeces, _post$_links$version;
25886 if (post.status === 'trash') {
25887 return false;
25888 }
25889 const lastRevisionId = (_post$_links$predeces = post?._links?.['predecessor-version']?.[0]?.id) !== null && _post$_links$predeces !== void 0 ? _post$_links$predeces : null;
25890 const revisionsCount = (_post$_links$version = post?._links?.['version-history']?.[0]?.count) !== null && _post$_links$version !== void 0 ? _post$_links$version : 0;
25891 return lastRevisionId && revisionsCount > 1;
25892 },
25893 callback(posts, onActionPerformed) {
25894 const post = posts[0];
25895 const href = (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
25896 revision: post?._links?.['predecessor-version']?.[0]?.id
25897 });
25898 document.location.href = href;
25899 if (onActionPerformed) {
25900 onActionPerformed(posts);
25901 }
25902 }
25903 };
25904 const renamePostAction = {
25905 id: 'rename-post',
25906 label: (0,external_wp_i18n_namespaceObject.__)('Rename'),
25907 isEligible(post) {
25908 if (post.status === 'trash') {
25909 return false;
25910 }
25911 // Templates, template parts and patterns have special checks for renaming.
25912 if (![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, ...Object.values(actions_PATTERN_TYPES)].includes(post.type)) {
25913 return true;
25914 }
25915 // In the case of templates, we can only rename custom templates.
25916 if (post.type === TEMPLATE_POST_TYPE) {
25917 return isTemplateRemovable(post) && post.is_custom;
25918 }
25919 // Make necessary checks for template parts and patterns.
25920 const isTemplatePart = post.type === TEMPLATE_PART_POST_TYPE;
25921 const isUserPattern = post.type === actions_PATTERN_TYPES.user;
25922 // In patterns list page we map the templates parts to a different object
25923 // than the one returned from the endpoint. This is why we need to check for
25924 // two props whether is custom or has a theme file.
25925 const isCustomPattern = isUserPattern || isTemplatePart && (post.isCustom || post.source === TEMPLATE_ORIGINS.custom);
25926 const hasThemeFile = isTemplatePart && (post.templatePart?.has_theme_file || post.has_theme_file);
25927 return isCustomPattern && !hasThemeFile;
25928 },
25929 RenderModal: ({
25930 items,
25931 closeModal,
25932 onActionPerformed
25933 }) => {
25934 const [item] = items;
25935 const originalTitle = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(typeof item.title === 'string' ? item.title : item.title.rendered);
25936 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(() => originalTitle);
25937 const {
25938 editEntityRecord,
25939 saveEditedEntityRecord
25940 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
25941 const {
25942 createSuccessNotice,
25943 createErrorNotice
25944 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
25945 async function onRename(event) {
25946 event.preventDefault();
25947 try {
25948 await editEntityRecord('postType', item.type, item.id, {
25949 title
25950 });
25951 // Update state before saving rerenders the list.
25952 setTitle('');
25953 closeModal();
25954 // Persist edited entity.
25955 await saveEditedEntityRecord('postType', item.type, item.id, {
25956 throwOnError: true
25957 });
25958 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Name updated'), {
25959 type: 'snackbar'
25960 });
25961 onActionPerformed?.(items);
25962 } catch (error) {
25963 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while updating the name');
25964 createErrorNotice(errorMessage, {
25965 type: 'snackbar'
25966 });
25967 }
25968 }
25969 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
25970 onSubmit: onRename,
25971 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
25972 spacing: "5",
25973 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
25974 __nextHasNoMarginBottom: true,
25975 __next40pxDefaultSize: true,
25976 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
25977 value: title,
25978 onChange: setTitle,
25979 required: true
25980 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
25981 justify: "right",
25982 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25983 __next40pxDefaultSize: true,
25984 variant: "tertiary",
25985 onClick: () => {
25986 closeModal();
25987 },
25988 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
25989 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25990 __next40pxDefaultSize: true,
25991 variant: "primary",
25992 type: "submit",
25993 children: (0,external_wp_i18n_namespaceObject.__)('Save')
25994 })]
25995 })]
25996 })
25997 });
25998 }
25999 };
26000 const duplicatePostAction = {
26001 id: 'duplicate-post',
26002 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
26003 isEligible({
26004 status
26005 }) {
26006 return status !== 'trash';
26007 },
26008 RenderModal: ({
26009 items,
26010 closeModal,
26011 onActionPerformed
26012 }) => {
26013 const [item] = items;
26014 const [isCreatingPage, setIsCreatingPage] = (0,external_wp_element_namespaceObject.useState)(false);
26015 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Existing item title */
26016 (0,external_wp_i18n_namespaceObject.__)('%s (Copy)'), getItemTitle(item)));
26017 const {
26018 saveEntityRecord
26019 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
26020 const {
26021 createSuccessNotice,
26022 createErrorNotice
26023 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
26024 async function createPage(event) {
26025 event.preventDefault();
26026 if (isCreatingPage) {
26027 return;
26028 }
26029 setIsCreatingPage(true);
26030 try {
26031 const newItem = await saveEntityRecord('postType', item.type, {
26032 status: 'draft',
26033 title,
26034 slug: title || (0,external_wp_i18n_namespaceObject.__)('No title'),
26035 author: item.author,
26036 comment_status: item.comment_status,
26037 content: typeof item.content === 'string' ? item.content : item.content.raw,
26038 excerpt: item.excerpt.raw,
26039 meta: item.meta,
26040 parent: item.parent,
26041 password: item.password,
26042 template: item.template,
26043 format: item.format,
26044 featured_media: item.featured_media,
26045 menu_order: item.menu_order,
26046 ping_status: item.ping_status,
26047 categories: item.categories,
26048 tags: item.tags
26049 }, {
26050 throwOnError: true
26051 });
26052 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
26053 // translators: %s: Title of the created template e.g: "Category".
26054 (0,external_wp_i18n_namespaceObject.__)('"%s" successfully created.'), newItem.title?.rendered || title), {
26055 id: 'duplicate-post-action',
26056 type: 'snackbar'
26057 });
26058 if (onActionPerformed) {
26059 onActionPerformed([newItem]);
26060 }
26061 } catch (error) {
26062 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while duplicating the page.');
26063 createErrorNotice(errorMessage, {
26064 type: 'snackbar'
26065 });
26066 } finally {
26067 setIsCreatingPage(false);
26068 closeModal();
26069 }
26070 }
26071 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
26072 onSubmit: createPage,
26073 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
26074 spacing: 3,
26075 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
26076 label: (0,external_wp_i18n_namespaceObject.__)('Title'),
26077 onChange: setTitle,
26078 placeholder: (0,external_wp_i18n_namespaceObject.__)('No title'),
26079 value: title
26080 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
26081 spacing: 2,
26082 justify: "end",
26083 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26084 variant: "tertiary",
26085 onClick: closeModal,
26086 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
26087 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26088 variant: "primary",
26089 type: "submit",
26090 isBusy: isCreatingPage,
26091 "aria-disabled": isCreatingPage,
26092 children: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label')
26093 })]
26094 })]
26095 })
26096 });
26097 }
26098 };
26099 const isTemplatePartRevertable = item => {
26100 if (!item) {
26101 return false;
26102 }
26103 const hasThemeFile = item.templatePart?.has_theme_file;
26104 return canDeleteOrReset(item) && hasThemeFile;
26105 };
26106 const resetTemplateAction = {
26107 id: 'reset-template',
26108 label: (0,external_wp_i18n_namespaceObject.__)('Reset'),
26109 isEligible: item => {
26110 return item.type === TEMPLATE_PART_POST_TYPE ? isTemplatePartRevertable(item) : isTemplateRevertable(item);
26111 },
26112 icon: library_backup,
26113 supportsBulk: true,
26114 hideModalHeader: true,
26115 RenderModal: ({
26116 items,
26117 closeModal,
26118 onActionStart,
26119 onActionPerformed
26120 }) => {
26121 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
26122 const {
26123 revertTemplate,
26124 removeTemplates
26125 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
26126 const {
26127 saveEditedEntityRecord
26128 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
26129 const {
26130 createSuccessNotice,
26131 createErrorNotice
26132 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
26133 const onConfirm = async () => {
26134 try {
26135 if (items[0].type === TEMPLATE_PART_POST_TYPE) {
26136 await removeTemplates(items);
26137 } else {
26138 for (const template of items) {
26139 if (template.type === TEMPLATE_POST_TYPE) {
26140 await revertTemplate(template, {
26141 allowUndo: false
26142 });
26143 await saveEditedEntityRecord('postType', template.type, template.id);
26144 }
26145 }
26146 createSuccessNotice(items.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of items. */
26147 (0,external_wp_i18n_namespaceObject.__)('%s items reset.'), items.length) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */
26148 (0,external_wp_i18n_namespaceObject.__)('"%s" reset.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(getItemTitle(items[0]))), {
26149 type: 'snackbar',
26150 id: 'revert-template-action'
26151 });
26152 }
26153 } catch (error) {
26154 let fallbackErrorMessage;
26155 if (items[0].type === TEMPLATE_POST_TYPE) {
26156 fallbackErrorMessage = items.length === 1 ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the templates.');
26157 } else {
26158 fallbackErrorMessage = items.length === 1 ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template part.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the template parts.');
26159 }
26160 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : fallbackErrorMessage;
26161 createErrorNotice(errorMessage, {
26162 type: 'snackbar'
26163 });
26164 }
26165 };
26166 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
26167 spacing: "5",
26168 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26169 children: (0,external_wp_i18n_namespaceObject.__)('Reset to default and clear all customizations?')
26170 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
26171 justify: "right",
26172 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26173 variant: "tertiary",
26174 onClick: closeModal,
26175 disabled: isBusy,
26176 __experimentalIsFocusable: true,
26177 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
26178 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26179 variant: "primary",
26180 onClick: async () => {
26181 setIsBusy(true);
26182 if (onActionStart) {
26183 onActionStart(items);
26184 }
26185 await onConfirm(items);
26186 onActionPerformed?.(items);
26187 setIsBusy(false);
26188 closeModal();
26189 },
26190 isBusy: isBusy,
26191 disabled: isBusy,
26192 __experimentalIsFocusable: true,
26193 children: (0,external_wp_i18n_namespaceObject.__)('Reset')
26194 })]
26195 })]
26196 });
26197 }
26198 };
26199 const duplicatePatternAction = {
26200 id: 'duplicate-pattern',
26201 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
26202 isEligible: item => item.type !== TEMPLATE_PART_POST_TYPE,
26203 modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate pattern', 'action label'),
26204 RenderModal: ({
26205 items,
26206 closeModal
26207 }) => {
26208 const [item] = items;
26209 const isThemePattern = item.type === actions_PATTERN_TYPES.theme;
26210 const duplicatedProps = useDuplicatePatternProps({
26211 pattern: isThemePattern || !item.patternPost ? item : item.patternPost,
26212 onSuccess: () => closeModal()
26213 });
26214 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreatePatternModalContents, {
26215 onClose: closeModal,
26216 confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
26217 ...duplicatedProps
26218 });
26219 }
26220 };
26221 const duplicateTemplatePartAction = {
26222 id: 'duplicate-template-part',
26223 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
26224 isEligible: item => item.type === TEMPLATE_PART_POST_TYPE,
26225 modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate template part', 'action label'),
26226 RenderModal: ({
26227 items,
26228 closeModal
26229 }) => {
26230 const [item] = items;
26231 const {
26232 createSuccessNotice
26233 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
26234 function onTemplatePartSuccess() {
26235 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
26236 // translators: %s: The new template part's title e.g. 'Call to action (copy)'.
26237 (0,external_wp_i18n_namespaceObject.__)('"%s" duplicated.'), item.title), {
26238 type: 'snackbar',
26239 id: 'edit-site-patterns-success'
26240 });
26241 closeModal();
26242 }
26243 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateTemplatePartModalContents, {
26244 blocks: item.blocks,
26245 defaultArea: item.templatePart?.area || item.area,
26246 defaultTitle: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Existing template part title */
26247 (0,external_wp_i18n_namespaceObject.__)('%s (Copy)'), item.title),
26248 onCreate: onTemplatePartSuccess,
26249 onError: closeModal,
26250 confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label')
26251 });
26252 }
26253 };
26254 function usePostActions(postType, onActionPerformed) {
26255 const {
26256 postTypeObject
26257 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26258 const {
26259 getPostType
26260 } = select(external_wp_coreData_namespaceObject.store);
26261 return {
26262 postTypeObject: getPostType(postType)
26263 };
26264 }, [postType]);
26265 const permanentlyDeletePostAction = usePermanentlyDeletePostAction();
26266 const restorePostAction = useRestorePostAction();
26267 const isTemplateOrTemplatePart = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(postType);
26268 const isPattern = postType === PATTERN_POST_TYPE;
26269 const isLoaded = !!postTypeObject;
26270 const supportsRevisions = !!postTypeObject?.supports?.revisions;
26271 return (0,external_wp_element_namespaceObject.useMemo)(() => {
26272 if (!isLoaded) {
26273 return [];
26274 }
26275 const actions = [postTypeObject?.viewable && viewPostAction, supportsRevisions && postRevisionsAction, true ? !isTemplateOrTemplatePart && !isPattern && duplicatePostAction : 0, isTemplateOrTemplatePart && duplicateTemplatePartAction, isPattern && duplicatePatternAction, renamePostAction, isPattern && exportPatternAsJSONAction, isTemplateOrTemplatePart ? resetTemplateAction : restorePostAction, isTemplateOrTemplatePart || isPattern ? deletePostAction : trashPostAction, !isTemplateOrTemplatePart && permanentlyDeletePostAction].filter(Boolean);
26276 if (onActionPerformed) {
26277 for (let i = 0; i < actions.length; ++i) {
26278 if (actions[i].callback) {
26279 const existingCallback = actions[i].callback;
26280 actions[i] = {
26281 ...actions[i],
26282 callback: (items, _onActionPerformed) => {
26283 existingCallback(items, _items => {
26284 if (_onActionPerformed) {
26285 _onActionPerformed(_items);
26286 }
26287 onActionPerformed(actions[i].id, _items);
26288 });
26289 }
26290 };
26291 }
26292 if (actions[i].RenderModal) {
26293 const ExistingRenderModal = actions[i].RenderModal;
26294 actions[i] = {
26295 ...actions[i],
26296 RenderModal: props => {
26297 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExistingRenderModal, {
26298 ...props,
26299 onActionPerformed: _items => {
26300 if (props.onActionPerformed) {
26301 props.onActionPerformed(_items);
26302 }
26303 onActionPerformed(actions[i].id, _items);
26304 }
26305 });
26306 }
26307 };
26308 }
26309 }
26310 }
26311 return actions;
26312 }, [isTemplateOrTemplatePart, isPattern, postTypeObject?.viewable, permanentlyDeletePostAction, restorePostAction, onActionPerformed, isLoaded, supportsRevisions]);
26313 }
26314
26315 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/pattern-overrides-panel/index.js
26316 /**
26317 * WordPress dependencies
26318 */
26319
26320
26321
26322 /**
26323 * Internal dependencies
26324 */
26325
26326
26327
26328 const {
26329 OverridesPanel
26330 } = unlock(external_wp_patterns_namespaceObject.privateApis);
26331 function PatternOverridesPanel() {
26332 const supportsPatternOverridesPanel = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType() === 'wp_block', []);
26333 if (!supportsPatternOverridesPanel) {
26334 return null;
26335 }
26336 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(OverridesPanel, {});
26337 }
26338
26339 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-actions/index.js
26340 /**
26341 * WordPress dependencies
26342 */
26343
26344
26345
26346
26347
26348
26349
26350 /**
26351 * Internal dependencies
26352 */
26353
26354
26355
26356
26357
26358
26359 const {
26360 DropdownMenuV2: DropdownMenu,
26361 DropdownMenuGroupV2: DropdownMenuGroup,
26362 DropdownMenuItemV2: DropdownMenuItem,
26363 DropdownMenuItemLabelV2: DropdownMenuItemLabel,
26364 kebabCase
26365 } = unlock(external_wp_components_namespaceObject.privateApis);
26366 function PostActions({
26367 onActionPerformed,
26368 buttonProps
26369 }) {
26370 const [isActionsMenuOpen, setIsActionsMenuOpen] = (0,external_wp_element_namespaceObject.useState)(false);
26371 const {
26372 item,
26373 postType
26374 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26375 const {
26376 getCurrentPostType,
26377 getCurrentPostId
26378 } = select(store_store);
26379 const {
26380 getEditedEntityRecord
26381 } = select(external_wp_coreData_namespaceObject.store);
26382 const _postType = getCurrentPostType();
26383 return {
26384 item: getEditedEntityRecord('postType', _postType, getCurrentPostId()),
26385 postType: _postType
26386 };
26387 }, []);
26388 const allActions = usePostActions(postType, onActionPerformed);
26389 const actions = (0,external_wp_element_namespaceObject.useMemo)(() => {
26390 return allActions.filter(action => {
26391 return !action.isEligible || action.isEligible(item);
26392 });
26393 }, [allActions, item]);
26394 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenu, {
26395 open: isActionsMenuOpen,
26396 trigger: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26397 size: "small",
26398 icon: more_vertical,
26399 label: (0,external_wp_i18n_namespaceObject.__)('Actions'),
26400 disabled: !actions.length,
26401 __experimentalIsFocusable: true,
26402 className: "editor-all-actions-button",
26403 onClick: () => setIsActionsMenuOpen(!isActionsMenuOpen),
26404 ...buttonProps
26405 }),
26406 onOpenChange: setIsActionsMenuOpen,
26407 placement: "bottom-end",
26408 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ActionsDropdownMenuGroup, {
26409 actions: actions,
26410 item: item,
26411 onClose: () => {
26412 setIsActionsMenuOpen(false);
26413 }
26414 })
26415 });
26416 }
26417
26418 // From now on all the functions on this file are copied as from the dataviews packages,
26419 // The editor packages should not be using the dataviews packages directly,
26420 // and the dataviews package should not be using the editor packages directly,
26421 // so duplicating the code here seems like the least bad option.
26422
26423 // Copied as is from packages/dataviews/src/item-actions.js
26424 function DropdownMenuItemTrigger({
26425 action,
26426 onClick,
26427 items
26428 }) {
26429 const label = typeof action.label === 'string' ? action.label : action.label(items);
26430 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenuItem, {
26431 onClick: onClick,
26432 hideOnClick: !action.RenderModal,
26433 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenuItemLabel, {
26434 children: label
26435 })
26436 });
26437 }
26438
26439 // Copied as is from packages/dataviews/src/item-actions.js
26440 // With an added onClose prop.
26441 function ActionWithModal({
26442 action,
26443 item,
26444 ActionTrigger,
26445 onClose
26446 }) {
26447 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
26448 const actionTriggerProps = {
26449 action,
26450 onClick: () => setIsModalOpen(true),
26451 items: [item]
26452 };
26453 const {
26454 RenderModal,
26455 hideModalHeader
26456 } = action;
26457 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26458 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ActionTrigger, {
26459 ...actionTriggerProps
26460 }), isModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
26461 title: action.modalHeader || action.label,
26462 __experimentalHideHeader: !!hideModalHeader,
26463 onRequestClose: () => {
26464 setIsModalOpen(false);
26465 },
26466 overlayClassName: `editor-action-modal editor-action-modal__${kebabCase(action.id)}`,
26467 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(RenderModal, {
26468 items: [item],
26469 closeModal: () => {
26470 setIsModalOpen(false);
26471 onClose();
26472 }
26473 })
26474 })]
26475 });
26476 }
26477
26478 // Copied as is from packages/dataviews/src/item-actions.js
26479 // With an added onClose prop.
26480 function ActionsDropdownMenuGroup({
26481 actions,
26482 item,
26483 onClose
26484 }) {
26485 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenuGroup, {
26486 children: actions.map(action => {
26487 if (action.RenderModal) {
26488 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ActionWithModal, {
26489 action: action,
26490 item: item,
26491 ActionTrigger: DropdownMenuItemTrigger,
26492 onClose: onClose
26493 }, action.id);
26494 }
26495 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenuItemTrigger, {
26496 action: action,
26497 onClick: () => action.callback([item]),
26498 items: [item]
26499 }, action.id);
26500 })
26501 });
26502 }
26503
26504 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-card-panel/index.js
26505 /**
26506 * External dependencies
26507 */
26508
26509 /**
26510 * WordPress dependencies
26511 */
26512
26513
26514
26515
26516
26517
26518 /**
26519 * Internal dependencies
26520 */
26521
26522
26523
26524
26525
26526 function PostCardPanel({
26527 actions
26528 }) {
26529 const {
26530 isFrontPage,
26531 isPostsPage,
26532 title,
26533 icon,
26534 isSync
26535 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26536 const {
26537 getEditedPostAttribute,
26538 getCurrentPostType,
26539 getCurrentPostId,
26540 __experimentalGetTemplateInfo
26541 } = select(store_store);
26542 const {
26543 getEditedEntityRecord
26544 } = select(external_wp_coreData_namespaceObject.store);
26545 const siteSettings = getEditedEntityRecord('root', 'site');
26546 const _type = getCurrentPostType();
26547 const _id = getCurrentPostId();
26548 const _record = getEditedEntityRecord('postType', _type, _id);
26549 const _templateInfo = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(_type) && __experimentalGetTemplateInfo(_record);
26550 let _isSync = false;
26551 if (GLOBAL_POST_TYPES.includes(_type)) {
26552 if (PATTERN_POST_TYPE === _type) {
26553 // When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead.
26554 const currentSyncStatus = getEditedPostAttribute('meta')?.wp_pattern_sync_status === 'unsynced' ? 'unsynced' : getEditedPostAttribute('wp_pattern_sync_status');
26555 _isSync = currentSyncStatus !== 'unsynced';
26556 } else {
26557 _isSync = true;
26558 }
26559 }
26560 return {
26561 title: _templateInfo?.title || getEditedPostAttribute('title'),
26562 icon: unlock(select(store_store)).getPostIcon(_type, {
26563 area: _record?.area
26564 }),
26565 isSync: _isSync,
26566 isFrontPage: siteSettings?.page_on_front === _id,
26567 isPostsPage: siteSettings?.page_for_posts === _id
26568 };
26569 }, []);
26570 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
26571 className: "editor-post-card-panel",
26572 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
26573 spacing: 2,
26574 className: "editor-post-card-panel__header",
26575 align: "flex-start",
26576 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
26577 className: dist_clsx('editor-post-card-panel__icon', {
26578 'is-sync': isSync
26579 }),
26580 icon: icon
26581 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalText, {
26582 numberOfLines: 2,
26583 truncate: true,
26584 className: "editor-post-card-panel__title",
26585 weight: 500,
26586 as: "h2",
26587 lineHeight: "20px",
26588 children: [title ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title) : (0,external_wp_i18n_namespaceObject.__)('No Title'), isFrontPage && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
26589 className: "editor-post-card-panel__title-badge",
26590 children: (0,external_wp_i18n_namespaceObject.__)('Front Page')
26591 }), isPostsPage && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
26592 className: "editor-post-card-panel__title-badge",
26593 children: (0,external_wp_i18n_namespaceObject.__)('Posts Page')
26594 })]
26595 }), actions]
26596 })
26597 });
26598 }
26599
26600 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-content-information/index.js
26601 /**
26602 * WordPress dependencies
26603 */
26604
26605
26606
26607
26608
26609
26610
26611 /**
26612 * Internal dependencies
26613 */
26614
26615
26616
26617 // Taken from packages/editor/src/components/time-to-read/index.js.
26618
26619 const post_content_information_AVERAGE_READING_RATE = 189;
26620
26621 // This component renders the wordcount and reading time for the post.
26622 function PostContentInformation() {
26623 const {
26624 postContent
26625 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26626 const {
26627 getEditedPostAttribute,
26628 getCurrentPostType,
26629 getCurrentPostId
26630 } = select(store_store);
26631 const {
26632 getEntityRecord
26633 } = select(external_wp_coreData_namespaceObject.store);
26634 const siteSettings = getEntityRecord('root', 'site');
26635 const postType = getCurrentPostType();
26636 const _id = getCurrentPostId();
26637 const isPostsPage = +_id === siteSettings?.page_for_posts;
26638 const showPostContentInfo = !isPostsPage && ![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(postType);
26639 return {
26640 postContent: showPostContentInfo && getEditedPostAttribute('content')
26641 };
26642 }, []);
26643
26644 /*
26645 * translators: If your word count is based on single characters (e.g. East Asian characters),
26646 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
26647 * Do not translate into your own language.
26648 */
26649 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
26650 const wordsCounted = (0,external_wp_element_namespaceObject.useMemo)(() => postContent ? (0,external_wp_wordcount_namespaceObject.count)(postContent, wordCountType) : 0, [postContent, wordCountType]);
26651 if (!wordsCounted) {
26652 return null;
26653 }
26654 const readingTime = Math.round(wordsCounted / post_content_information_AVERAGE_READING_RATE);
26655 const wordsCountText = (0,external_wp_i18n_namespaceObject.sprintf)(
26656 // translators: %s: the number of words in the post.
26657 (0,external_wp_i18n_namespaceObject._n)('%s word', '%s words', wordsCounted), wordsCounted.toLocaleString());
26658 const minutesText = readingTime <= 1 ? (0,external_wp_i18n_namespaceObject.__)('1 minute') : (0,external_wp_i18n_namespaceObject.sprintf)(
26659 // translators: %s: the number of minutes to read the post.
26660 (0,external_wp_i18n_namespaceObject._n)('%s minute', '%s minutes', readingTime), readingTime.toLocaleString());
26661 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
26662 className: "editor-post-content-information",
26663 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26664 children: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: 1: How many words a post has. 2: the number of minutes to read the post (e.g. 130 words, 2 minutes read time.) */
26665 (0,external_wp_i18n_namespaceObject.__)('%1$s, %2$s read time.'), wordsCountText, minutesText)
26666 })
26667 });
26668 }
26669
26670 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-format/panel.js
26671 /**
26672 * WordPress dependencies
26673 */
26674
26675
26676
26677
26678
26679
26680 /**
26681 * Internal dependencies
26682 */
26683
26684
26685
26686
26687
26688 /**
26689 * Renders the Post Author Panel component.
26690 *
26691 * @return {Component} The component to be rendered.
26692 */
26693
26694
26695 function panel_PostFormat() {
26696 const {
26697 postFormat
26698 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26699 const {
26700 getEditedPostAttribute
26701 } = select(store_store);
26702 const _postFormat = getEditedPostAttribute('format');
26703 return {
26704 postFormat: _postFormat !== null && _postFormat !== void 0 ? _postFormat : 'standard'
26705 };
26706 }, []);
26707 const activeFormat = POST_FORMATS.find(format => format.id === postFormat);
26708
26709 // Use internal state instead of a ref to make sure that the component
26710 // re-renders when the popover's anchor updates.
26711 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
26712 // Memoize popoverProps to avoid returning a new object every time.
26713 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
26714 // Anchor the popover to the middle of the entire row so that it doesn't
26715 // move around when the label changes.
26716 anchor: popoverAnchor,
26717 placement: 'left-start',
26718 offset: 36,
26719 shift: true
26720 }), [popoverAnchor]);
26721 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_format_check, {
26722 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
26723 label: (0,external_wp_i18n_namespaceObject.__)('Format'),
26724 ref: setPopoverAnchor,
26725 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
26726 popoverProps: popoverProps,
26727 contentClassName: "editor-post-format__dialog",
26728 focusOnMount: true,
26729 renderToggle: ({
26730 isOpen,
26731 onToggle
26732 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26733 size: "compact",
26734 variant: "tertiary",
26735 "aria-expanded": isOpen,
26736 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
26737 // translators: %s: Current post format.
26738 (0,external_wp_i18n_namespaceObject.__)('Change format: %s'), activeFormat?.caption),
26739 onClick: onToggle,
26740 children: activeFormat?.caption
26741 }),
26742 renderContent: ({
26743 onClose
26744 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
26745 className: "editor-post-format__dialog-content",
26746 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
26747 title: (0,external_wp_i18n_namespaceObject.__)('Format'),
26748 onClose: onClose
26749 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFormat, {})]
26750 })
26751 })
26752 })
26753 });
26754 }
26755 /* harmony default export */ const post_format_panel = (panel_PostFormat);
26756
26757 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-last-edited-panel/index.js
26758 /**
26759 * WordPress dependencies
26760 */
26761
26762
26763
26764
26765
26766 /**
26767 * Internal dependencies
26768 */
26769
26770
26771 function PostLastEditedPanel() {
26772 const modified = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('modified'), []);
26773 const lastEditedText = modified && (0,external_wp_i18n_namespaceObject.sprintf)(
26774 // translators: %s: Human-readable time difference, e.g. "2 days ago".
26775 (0,external_wp_i18n_namespaceObject.__)('Last edited %s.'), (0,external_wp_date_namespaceObject.humanTimeDiff)(modified));
26776 if (!lastEditedText) {
26777 return null;
26778 }
26779 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
26780 className: "editor-post-last-edited-panel",
26781 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26782 children: lastEditedText
26783 })
26784 });
26785 }
26786
26787 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-panel-section/index.js
26788 /**
26789 * External dependencies
26790 */
26791
26792
26793 /**
26794 * WordPress dependencies
26795 */
26796
26797
26798 function PostPanelSection({
26799 className,
26800 children
26801 }) {
26802 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
26803 className: dist_clsx('editor-post-panel__section', className),
26804 children: children
26805 });
26806 }
26807 /* harmony default export */ const post_panel_section = (PostPanelSection);
26808
26809 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-status/index.js
26810 /**
26811 * WordPress dependencies
26812 */
26813
26814
26815
26816
26817
26818
26819
26820
26821 /**
26822 * Internal dependencies
26823 */
26824
26825
26826
26827
26828
26829
26830
26831 const labels = {
26832 'auto-draft': (0,external_wp_i18n_namespaceObject.__)('Draft'),
26833 draft: (0,external_wp_i18n_namespaceObject.__)('Draft'),
26834 pending: (0,external_wp_i18n_namespaceObject.__)('Pending'),
26835 private: (0,external_wp_i18n_namespaceObject.__)('Private'),
26836 future: (0,external_wp_i18n_namespaceObject.__)('Scheduled'),
26837 publish: (0,external_wp_i18n_namespaceObject.__)('Published')
26838 };
26839 const STATUS_OPTIONS = [{
26840 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26841 children: [(0,external_wp_i18n_namespaceObject.__)('Draft'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26842 variant: "muted",
26843 size: 12,
26844 children: (0,external_wp_i18n_namespaceObject.__)('Not ready to publish.')
26845 })]
26846 }),
26847 value: 'draft'
26848 }, {
26849 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26850 children: [(0,external_wp_i18n_namespaceObject.__)('Pending'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26851 variant: "muted",
26852 size: 12,
26853 children: (0,external_wp_i18n_namespaceObject.__)('Waiting for review before publishing.')
26854 })]
26855 }),
26856 value: 'pending'
26857 }, {
26858 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26859 children: [(0,external_wp_i18n_namespaceObject.__)('Private'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26860 variant: "muted",
26861 size: 12,
26862 children: (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.')
26863 })]
26864 }),
26865 value: 'private'
26866 }, {
26867 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26868 children: [(0,external_wp_i18n_namespaceObject.__)('Scheduled'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26869 variant: "muted",
26870 size: 12,
26871 children: (0,external_wp_i18n_namespaceObject.__)('Publish automatically on a chosen date.')
26872 })]
26873 }),
26874 value: 'future'
26875 }, {
26876 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26877 children: [(0,external_wp_i18n_namespaceObject.__)('Published'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26878 variant: "muted",
26879 size: 12,
26880 children: (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.')
26881 })]
26882 }),
26883 value: 'publish'
26884 }];
26885 const post_status_DESIGN_POST_TYPES = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE, NAVIGATION_POST_TYPE];
26886 function PostStatus() {
26887 const {
26888 status,
26889 date,
26890 password,
26891 postId,
26892 postType,
26893 canEdit
26894 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26895 var _getCurrentPost$_link;
26896 const {
26897 getEditedPostAttribute,
26898 getCurrentPostId,
26899 getCurrentPostType,
26900 getCurrentPost
26901 } = select(store_store);
26902 return {
26903 status: getEditedPostAttribute('status'),
26904 date: getEditedPostAttribute('date'),
26905 password: getEditedPostAttribute('password'),
26906 postId: getCurrentPostId(),
26907 postType: getCurrentPostType(),
26908 canEdit: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false
26909 };
26910 }, []);
26911 const [showPassword, setShowPassword] = (0,external_wp_element_namespaceObject.useState)(!!password);
26912 const passwordInputId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostStatus, 'editor-change-status__password-input');
26913 const {
26914 editEntityRecord
26915 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
26916 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
26917 // Memoize popoverProps to avoid returning a new object every time.
26918 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
26919 // Anchor the popover to the middle of the entire row so that it doesn't
26920 // move around when the label changes.
26921 anchor: popoverAnchor,
26922 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
26923 headerTitle: (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
26924 placement: 'left-start',
26925 offset: 36,
26926 shift: true
26927 }), [popoverAnchor]);
26928 if (post_status_DESIGN_POST_TYPES.includes(postType)) {
26929 return null;
26930 }
26931 const updatePost = ({
26932 status: newStatus = status,
26933 password: newPassword = password,
26934 date: newDate = date
26935 }) => {
26936 editEntityRecord('postType', postType, postId, {
26937 status: newStatus,
26938 date: newDate,
26939 password: newPassword
26940 });
26941 };
26942 const handleTogglePassword = value => {
26943 setShowPassword(value);
26944 if (!value) {
26945 updatePost({
26946 password: ''
26947 });
26948 }
26949 };
26950 const handleStatus = value => {
26951 let newDate = date;
26952 let newPassword = password;
26953 if (status === 'future' && new Date(date) > new Date()) {
26954 newDate = null;
26955 }
26956 if (value === 'private' && password) {
26957 newPassword = '';
26958 }
26959 updatePost({
26960 status: value,
26961 date: newDate,
26962 password: newPassword
26963 });
26964 };
26965 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
26966 label: (0,external_wp_i18n_namespaceObject.__)('Status'),
26967 ref: setPopoverAnchor,
26968 children: canEdit ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
26969 className: "editor-post-status",
26970 contentClassName: "editor-change-status__content",
26971 popoverProps: popoverProps,
26972 focusOnMount: true,
26973 renderToggle: ({
26974 onToggle
26975 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26976 variant: "tertiary",
26977 size: "compact",
26978 onClick: onToggle,
26979 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
26980 // translators: %s: Current post status.
26981 (0,external_wp_i18n_namespaceObject.__)('Change post status: %s'), labels[status]),
26982 children: labels[status]
26983 }),
26984 renderContent: ({
26985 onClose
26986 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26987 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
26988 title: (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
26989 onClose: onClose
26990 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
26991 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
26992 spacing: 4,
26993 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
26994 className: "editor-change-status__options",
26995 hideLabelFromVision: true,
26996 label: (0,external_wp_i18n_namespaceObject.__)('Status'),
26997 options: STATUS_OPTIONS,
26998 onChange: handleStatus,
26999 selected: status === 'auto-draft' ? 'draft' : status
27000 }), status === 'future' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
27001 className: "editor-change-status__publish-date-wrapper",
27002 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostSchedule, {
27003 showPopoverHeaderActions: false,
27004 isCompact: true
27005 })
27006 }), status !== 'private' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27007 as: "fieldset",
27008 spacing: 4,
27009 className: "editor-change-status__password-fieldset",
27010 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
27011 __nextHasNoMarginBottom: true,
27012 label: (0,external_wp_i18n_namespaceObject.__)('Password protected'),
27013 help: (0,external_wp_i18n_namespaceObject.__)('Only visible to those who know the password'),
27014 checked: showPassword,
27015 onChange: handleTogglePassword
27016 }), showPassword && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
27017 className: "editor-change-status__password-input",
27018 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
27019 label: (0,external_wp_i18n_namespaceObject.__)('Password'),
27020 onChange: value => updatePost({
27021 password: value
27022 }),
27023 value: password,
27024 placeholder: (0,external_wp_i18n_namespaceObject.__)('Use a secure password'),
27025 type: "text",
27026 id: passwordInputId,
27027 __next40pxDefaultSize: true,
27028 __nextHasNoMarginBottom: true
27029 })
27030 })]
27031 })]
27032 })
27033 })]
27034 })
27035 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
27036 className: "editor-post-status is-read-only",
27037 children: labels[status]
27038 })
27039 });
27040 }
27041
27042 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/blog-title/index.js
27043 /**
27044 * WordPress dependencies
27045 */
27046
27047
27048
27049
27050
27051
27052
27053
27054
27055 /**
27056 * Internal dependencies
27057 */
27058
27059
27060
27061
27062
27063
27064 const blog_title_EMPTY_OBJECT = {};
27065 function BlogTitle() {
27066 const {
27067 editEntityRecord
27068 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
27069 const {
27070 postsPageTitle,
27071 postsPageId,
27072 isTemplate,
27073 postSlug
27074 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27075 const {
27076 getEntityRecord,
27077 getEditedEntityRecord
27078 } = select(external_wp_coreData_namespaceObject.store);
27079 const siteSettings = getEntityRecord('root', 'site');
27080 const _postsPageRecord = siteSettings?.page_for_posts ? getEditedEntityRecord('postType', 'page', siteSettings?.page_for_posts) : blog_title_EMPTY_OBJECT;
27081 const {
27082 getEditedPostAttribute,
27083 getCurrentPostType
27084 } = select(store_store);
27085 return {
27086 postsPageId: _postsPageRecord?.id,
27087 postsPageTitle: _postsPageRecord?.title,
27088 isTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,
27089 postSlug: getEditedPostAttribute('slug')
27090 };
27091 }, []);
27092 // Use internal state instead of a ref to make sure that the component
27093 // re-renders when the popover's anchor updates.
27094 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
27095 // Memoize popoverProps to avoid returning a new object every time.
27096 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
27097 // Anchor the popover to the middle of the entire row so that it doesn't
27098 // move around when the label changes.
27099 anchor: popoverAnchor,
27100 placement: 'left-start',
27101 offset: 36,
27102 shift: true
27103 }), [popoverAnchor]);
27104 if (!isTemplate || !['home', 'index'].includes(postSlug) || !postsPageId) {
27105 return null;
27106 }
27107 const setPostsPageTitle = newValue => {
27108 editEntityRecord('postType', 'page', postsPageId, {
27109 title: newValue
27110 });
27111 };
27112 const decodedTitle = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postsPageTitle);
27113 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
27114 label: (0,external_wp_i18n_namespaceObject.__)('Blog title'),
27115 ref: setPopoverAnchor,
27116 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
27117 popoverProps: popoverProps,
27118 contentClassName: "editor-blog-title-dropdown__content",
27119 focusOnMount: true,
27120 renderToggle: ({
27121 isOpen,
27122 onToggle
27123 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
27124 size: "compact",
27125 variant: "tertiary",
27126 "aria-expanded": isOpen,
27127 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
27128 // translators: %s: Current post link.
27129 (0,external_wp_i18n_namespaceObject.__)('Change blog title: %s'), decodedTitle),
27130 onClick: onToggle,
27131 children: decodedTitle
27132 }),
27133 renderContent: ({
27134 onClose
27135 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27136 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
27137 title: (0,external_wp_i18n_namespaceObject.__)('Blog title'),
27138 onClose: onClose
27139 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControl, {
27140 placeholder: (0,external_wp_i18n_namespaceObject.__)('No Title'),
27141 size: "__unstable-large",
27142 value: postsPageTitle,
27143 onChange: (0,external_wp_compose_namespaceObject.debounce)(setPostsPageTitle, 300),
27144 label: (0,external_wp_i18n_namespaceObject.__)('Blog title'),
27145 help: (0,external_wp_i18n_namespaceObject.__)('Set the Posts Page title. Appears in search results, and when the page is shared on social media.'),
27146 hideLabelFromVision: true
27147 })]
27148 })
27149 })
27150 });
27151 }
27152
27153 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/posts-per-page/index.js
27154 /**
27155 * WordPress dependencies
27156 */
27157
27158
27159
27160
27161
27162
27163
27164 /**
27165 * Internal dependencies
27166 */
27167
27168
27169
27170
27171
27172
27173 function PostsPerPage() {
27174 const {
27175 editEntityRecord
27176 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
27177 const {
27178 postsPerPage,
27179 isTemplate,
27180 postSlug
27181 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27182 const {
27183 getEditedPostAttribute,
27184 getCurrentPostType
27185 } = select(store_store);
27186 const {
27187 getEditedEntityRecord
27188 } = select(external_wp_coreData_namespaceObject.store);
27189 const siteSettings = getEditedEntityRecord('root', 'site');
27190 return {
27191 isTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,
27192 postSlug: getEditedPostAttribute('slug'),
27193 postsPerPage: siteSettings?.posts_per_page || 1
27194 };
27195 }, []);
27196 // Use internal state instead of a ref to make sure that the component
27197 // re-renders when the popover's anchor updates.
27198 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
27199 // Memoize popoverProps to avoid returning a new object every time.
27200 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
27201 // Anchor the popover to the middle of the entire row so that it doesn't
27202 // move around when the label changes.
27203 anchor: popoverAnchor,
27204 placement: 'left-start',
27205 offset: 36,
27206 shift: true
27207 }), [popoverAnchor]);
27208 if (!isTemplate || !['home', 'index'].includes(postSlug)) {
27209 return null;
27210 }
27211 const setPostsPerPage = newValue => {
27212 editEntityRecord('root', 'site', undefined, {
27213 posts_per_page: newValue
27214 });
27215 };
27216 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
27217 label: (0,external_wp_i18n_namespaceObject.__)('Posts per page'),
27218 ref: setPopoverAnchor,
27219 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
27220 popoverProps: popoverProps,
27221 contentClassName: "editor-posts-per-page-dropdown__content",
27222 focusOnMount: true,
27223 renderToggle: ({
27224 isOpen,
27225 onToggle
27226 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
27227 size: "compact",
27228 variant: "tertiary",
27229 "aria-expanded": isOpen,
27230 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Change posts per page'),
27231 onClick: onToggle,
27232 children: postsPerPage
27233 }),
27234 renderContent: ({
27235 onClose
27236 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27237 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
27238 title: (0,external_wp_i18n_namespaceObject.__)('Posts per page'),
27239 onClose: onClose
27240 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNumberControl, {
27241 placeholder: 0,
27242 value: postsPerPage,
27243 size: "__unstable-large",
27244 spinControls: "custom",
27245 step: "1",
27246 min: "1",
27247 onChange: setPostsPerPage,
27248 label: (0,external_wp_i18n_namespaceObject.__)('Posts per page'),
27249 help: (0,external_wp_i18n_namespaceObject.__)('Set the default number of posts to display on blog pages, including categories and tags. Some templates may override this setting.'),
27250 hideLabelFromVision: true
27251 })]
27252 })
27253 })
27254 });
27255 }
27256
27257 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/site-discussion/index.js
27258 /**
27259 * WordPress dependencies
27260 */
27261
27262
27263
27264
27265
27266
27267
27268 /**
27269 * Internal dependencies
27270 */
27271
27272
27273
27274
27275
27276
27277 const site_discussion_COMMENT_OPTIONS = [{
27278 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27279 children: [(0,external_wp_i18n_namespaceObject.__)('Open'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27280 variant: "muted",
27281 size: 12,
27282 children: (0,external_wp_i18n_namespaceObject.__)('Visitors can add new comments and replies.')
27283 })]
27284 }),
27285 value: 'open'
27286 }, {
27287 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27288 children: [(0,external_wp_i18n_namespaceObject.__)('Closed'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27289 variant: "muted",
27290 size: 12,
27291 children: (0,external_wp_i18n_namespaceObject.__)('Visitors cannot add new comments or replies.')
27292 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27293 variant: "muted",
27294 size: 12,
27295 children: (0,external_wp_i18n_namespaceObject.__)('Existing comments remain visible.')
27296 })]
27297 }),
27298 value: ''
27299 }];
27300 function SiteDiscussion() {
27301 const {
27302 editEntityRecord
27303 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
27304 const {
27305 allowCommentsOnNewPosts,
27306 isTemplate,
27307 postSlug
27308 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27309 const {
27310 getEditedPostAttribute,
27311 getCurrentPostType
27312 } = select(store_store);
27313 const {
27314 getEditedEntityRecord
27315 } = select(external_wp_coreData_namespaceObject.store);
27316 const siteSettings = getEditedEntityRecord('root', 'site');
27317 return {
27318 isTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,
27319 postSlug: getEditedPostAttribute('slug'),
27320 allowCommentsOnNewPosts: siteSettings?.default_comment_status || ''
27321 };
27322 }, []);
27323 // Use internal state instead of a ref to make sure that the component
27324 // re-renders when the popover's anchor updates.
27325 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
27326 // Memoize popoverProps to avoid returning a new object every time.
27327 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
27328 // Anchor the popover to the middle of the entire row so that it doesn't
27329 // move around when the label changes.
27330 anchor: popoverAnchor,
27331 placement: 'left-start',
27332 offset: 36,
27333 shift: true
27334 }), [popoverAnchor]);
27335 if (!isTemplate || !['home', 'index'].includes(postSlug)) {
27336 return null;
27337 }
27338 const setAllowCommentsOnNewPosts = newValue => {
27339 editEntityRecord('root', 'site', undefined, {
27340 default_comment_status: newValue ? 'open' : null
27341 });
27342 };
27343 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
27344 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
27345 ref: setPopoverAnchor,
27346 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
27347 popoverProps: popoverProps,
27348 contentClassName: "editor-site-discussion-dropdown__content",
27349 focusOnMount: true,
27350 renderToggle: ({
27351 isOpen,
27352 onToggle
27353 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
27354 size: "compact",
27355 variant: "tertiary",
27356 "aria-expanded": isOpen,
27357 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Change discussion settings'),
27358 onClick: onToggle,
27359 children: allowCommentsOnNewPosts ? (0,external_wp_i18n_namespaceObject.__)('Comments open') : (0,external_wp_i18n_namespaceObject.__)('Comments closed')
27360 }),
27361 renderContent: ({
27362 onClose
27363 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27364 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
27365 title: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
27366 onClose: onClose
27367 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27368 spacing: 3,
27369 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27370 children: (0,external_wp_i18n_namespaceObject.__)('Changes will apply to new posts only. Individual posts may override these settings.')
27371 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
27372 className: "editor-site-discussion__options",
27373 hideLabelFromVision: true,
27374 label: (0,external_wp_i18n_namespaceObject.__)('Comment status'),
27375 options: site_discussion_COMMENT_OPTIONS,
27376 onChange: setAllowCommentsOnNewPosts,
27377 selected: allowCommentsOnNewPosts
27378 })]
27379 })]
27380 })
27381 })
27382 });
27383 }
27384
27385 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-areas/index.js
27386 /**
27387 * WordPress dependencies
27388 */
27389
27390
27391
27392
27393
27394 /**
27395 * Internal dependencies
27396 */
27397
27398
27399
27400
27401
27402 function TemplateAreaItem({
27403 area,
27404 clientId
27405 }) {
27406 const {
27407 selectBlock,
27408 toggleBlockHighlight
27409 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
27410 const templatePartArea = (0,external_wp_data_namespaceObject.useSelect)(select => {
27411 const defaultAreas = select(store_store).__experimentalGetDefaultTemplatePartAreas();
27412 return defaultAreas.find(defaultArea => defaultArea.area === area);
27413 }, [area]);
27414 const highlightBlock = () => toggleBlockHighlight(clientId, true);
27415 const cancelHighlightBlock = () => toggleBlockHighlight(clientId, false);
27416 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
27417 className: "editor-template-areas__item",
27418 icon: templatePartArea?.icon,
27419 onMouseOver: highlightBlock,
27420 onMouseLeave: cancelHighlightBlock,
27421 onFocus: highlightBlock,
27422 onBlur: cancelHighlightBlock,
27423 onClick: () => {
27424 selectBlock(clientId);
27425 },
27426 children: templatePartArea?.label
27427 });
27428 }
27429 function TemplateAreas() {
27430 const {
27431 isTemplate,
27432 templateParts
27433 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27434 const _isTemplate = select(store_store).getCurrentPostType() === TEMPLATE_POST_TYPE;
27435 return {
27436 isTemplate: _isTemplate,
27437 templateParts: _isTemplate && unlock(select(store_store)).getCurrentTemplateTemplateParts()
27438 };
27439 }, []);
27440 if (!isTemplate || !templateParts.length) {
27441 return null;
27442 }
27443 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("section", {
27444 className: "editor-template-areas",
27445 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalHeading, {
27446 level: 3,
27447 className: "editor-template-areas__title",
27448 children: (0,external_wp_i18n_namespaceObject.__)('Areas')
27449 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
27450 className: "editor-template-areas__list",
27451 children: templateParts.map(({
27452 templatePart,
27453 block
27454 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
27455 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateAreaItem, {
27456 area: templatePart.area,
27457 clientId: block.clientId
27458 })
27459 }, block.clientId))
27460 })]
27461 });
27462 }
27463
27464 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/sidebar/post-summary.js
27465 /**
27466 * WordPress dependencies
27467 */
27468
27469
27470
27471 /**
27472 * Internal dependencies
27473 */
27474
27475
27476
27477
27478
27479
27480
27481
27482
27483
27484
27485
27486
27487
27488
27489
27490
27491
27492
27493
27494
27495
27496
27497
27498 /**
27499 * Module Constants
27500 */
27501
27502
27503
27504 const post_summary_PANEL_NAME = 'post-status';
27505 function PostSummary({
27506 onActionPerformed
27507 }) {
27508 const {
27509 isRemovedPostStatusPanel
27510 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27511 // We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do
27512 // not use isEditorPanelEnabled since this panel should not be disabled through the UI.
27513 const {
27514 isEditorPanelRemoved,
27515 getCurrentPostType
27516 } = select(store_store);
27517 return {
27518 isRemovedPostStatusPanel: isEditorPanelRemoved(post_summary_PANEL_NAME),
27519 postType: getCurrentPostType()
27520 };
27521 }, []);
27522 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_section, {
27523 className: "editor-post-summary",
27524 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_post_status_info.Slot, {
27525 children: fills => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27526 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27527 spacing: 4,
27528 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostCardPanel, {
27529 actions: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostActions, {
27530 onActionPerformed: onActionPerformed
27531 })
27532 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFeaturedImagePanel, {
27533 withPanelBody: false
27534 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostExcerptPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27535 spacing: 1,
27536 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostContentInformation, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostLastEditedPanel, {})]
27537 }), !isRemovedPostStatusPanel && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27538 spacing: 2,
27539 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27540 spacing: 1,
27541 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostStatus, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSchedulePanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURLPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(panel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTemplatePanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostDiscussionPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PageAttributesPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSyncStatus, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlogTitle, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostsPerPage, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SiteDiscussion, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_format_panel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSticky, {})]
27542 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateAreas, {}), fills]
27543 })]
27544 })
27545 })
27546 })
27547 });
27548 }
27549
27550 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-transform-panel/hooks.js
27551 /**
27552 * WordPress dependencies
27553 */
27554
27555
27556
27557
27558
27559
27560 /**
27561 * Internal dependencies
27562 */
27563
27564
27565 const {
27566 EXCLUDED_PATTERN_SOURCES,
27567 PATTERN_TYPES: hooks_PATTERN_TYPES
27568 } = unlock(external_wp_patterns_namespaceObject.privateApis);
27569 function injectThemeAttributeInBlockTemplateContent(block, currentThemeStylesheet) {
27570 block.innerBlocks = block.innerBlocks.map(innerBlock => {
27571 return injectThemeAttributeInBlockTemplateContent(innerBlock, currentThemeStylesheet);
27572 });
27573 if (block.name === 'core/template-part' && block.attributes.theme === undefined) {
27574 block.attributes.theme = currentThemeStylesheet;
27575 }
27576 return block;
27577 }
27578
27579 /**
27580 * Filter all patterns and return only the ones that are compatible with the current template.
27581 *
27582 * @param {Array} patterns An array of patterns.
27583 * @param {Object} template The current template.
27584 * @return {Array} Array of patterns that are compatible with the current template.
27585 */
27586 function filterPatterns(patterns, template) {
27587 // Filter out duplicates.
27588 const filterOutDuplicatesByName = (currentItem, index, items) => index === items.findIndex(item => currentItem.name === item.name);
27589
27590 // Filter out core/directory patterns not included in theme.json.
27591 const filterOutExcludedPatternSources = pattern => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source);
27592
27593 // Looks for patterns that have the same template type as the current template,
27594 // or have a block type that matches the current template area.
27595 const filterCompatiblePatterns = pattern => pattern.templateTypes?.includes(template.slug) || pattern.blockTypes?.includes('core/template-part/' + template.area);
27596 return patterns.filter((pattern, index, items) => {
27597 return filterOutDuplicatesByName(pattern, index, items) && filterOutExcludedPatternSources(pattern) && filterCompatiblePatterns(pattern);
27598 });
27599 }
27600 function preparePatterns(patterns, currentThemeStylesheet) {
27601 return patterns.map(pattern => ({
27602 ...pattern,
27603 keywords: pattern.keywords || [],
27604 type: hooks_PATTERN_TYPES.theme,
27605 blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content, {
27606 __unstableSkipMigrationLogs: true
27607 }).map(block => injectThemeAttributeInBlockTemplateContent(block, currentThemeStylesheet))
27608 }));
27609 }
27610 function useAvailablePatterns(template) {
27611 const {
27612 blockPatterns,
27613 restBlockPatterns,
27614 currentThemeStylesheet
27615 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27616 var _settings$__experimen;
27617 const {
27618 getEditorSettings
27619 } = select(store_store);
27620 const settings = getEditorSettings();
27621 return {
27622 blockPatterns: (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : settings.__experimentalBlockPatterns,
27623 restBlockPatterns: select(external_wp_coreData_namespaceObject.store).getBlockPatterns(),
27624 currentThemeStylesheet: select(external_wp_coreData_namespaceObject.store).getCurrentTheme().stylesheet
27625 };
27626 }, []);
27627 return (0,external_wp_element_namespaceObject.useMemo)(() => {
27628 const mergedPatterns = [...(blockPatterns || []), ...(restBlockPatterns || [])];
27629 const filteredPatterns = filterPatterns(mergedPatterns, template);
27630 return preparePatterns(filteredPatterns, template, currentThemeStylesheet);
27631 }, [blockPatterns, restBlockPatterns, template, currentThemeStylesheet]);
27632 }
27633
27634 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-transform-panel/index.js
27635 /**
27636 * WordPress dependencies
27637 */
27638
27639
27640
27641
27642
27643
27644
27645
27646 /**
27647 * Internal dependencies
27648 */
27649
27650
27651
27652
27653 function post_transform_panel_TemplatesList({
27654 availableTemplates,
27655 onSelect
27656 }) {
27657 const shownTemplates = (0,external_wp_compose_namespaceObject.useAsyncList)(availableTemplates);
27658 if (!availableTemplates || availableTemplates?.length === 0) {
27659 return null;
27660 }
27661 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
27662 label: (0,external_wp_i18n_namespaceObject.__)('Templates'),
27663 blockPatterns: availableTemplates,
27664 shownPatterns: shownTemplates,
27665 onClickPattern: onSelect,
27666 showTitlesAsTooltip: true
27667 });
27668 }
27669 function PostTransform() {
27670 const {
27671 record,
27672 postType,
27673 postId
27674 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27675 const {
27676 getCurrentPostType,
27677 getCurrentPostId
27678 } = select(store_store);
27679 const {
27680 getEditedEntityRecord
27681 } = select(external_wp_coreData_namespaceObject.store);
27682 const type = getCurrentPostType();
27683 const id = getCurrentPostId();
27684 return {
27685 postType: type,
27686 postId: id,
27687 record: getEditedEntityRecord('postType', type, id)
27688 };
27689 }, []);
27690 const {
27691 editEntityRecord
27692 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
27693 const availablePatterns = useAvailablePatterns(record);
27694 const onTemplateSelect = async selectedTemplate => {
27695 await editEntityRecord('postType', postType, postId, {
27696 blocks: selectedTemplate.blocks,
27697 content: (0,external_wp_blocks_namespaceObject.serialize)(selectedTemplate.blocks)
27698 });
27699 };
27700 if (!availablePatterns?.length) {
27701 return null;
27702 }
27703 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
27704 title: (0,external_wp_i18n_namespaceObject.__)('Design'),
27705 initialOpen: record.type === TEMPLATE_PART_POST_TYPE,
27706 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_transform_panel_TemplatesList, {
27707 availableTemplates: availablePatterns,
27708 onSelect: onTemplateSelect
27709 })
27710 });
27711 }
27712 function PostTransformPanel() {
27713 const {
27714 postType
27715 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27716 const {
27717 getCurrentPostType
27718 } = select(store_store);
27719 return {
27720 postType: getCurrentPostType()
27721 };
27722 }, []);
27723 if (![TEMPLATE_PART_POST_TYPE, TEMPLATE_POST_TYPE].includes(postType)) {
27724 return null;
27725 }
27726 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTransform, {});
27727 }
27728
27729 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/sidebar/constants.js
27730 const sidebars = {
27731 document: 'edit-post/document',
27732 block: 'edit-post/block'
27733 };
27734
27735 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/sidebar/header.js
27736 /**
27737 * WordPress dependencies
27738 */
27739
27740
27741
27742
27743
27744 /**
27745 * Internal dependencies
27746 */
27747
27748
27749
27750
27751
27752 const {
27753 Tabs: header_Tabs
27754 } = unlock(external_wp_components_namespaceObject.privateApis);
27755 const SidebarHeader = (_, ref) => {
27756 const {
27757 documentLabel
27758 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27759 const {
27760 getPostTypeLabel
27761 } = select(store_store);
27762 return {
27763 // translators: Default label for the Document sidebar tab, not selected.
27764 documentLabel: getPostTypeLabel() || (0,external_wp_i18n_namespaceObject._x)('Document', 'noun')
27765 };
27766 }, []);
27767 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(header_Tabs.TabList, {
27768 ref: ref,
27769 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(header_Tabs.Tab, {
27770 tabId: sidebars.document
27771 // Used for focus management in the SettingsSidebar component.
27772 ,
27773 "data-tab-id": sidebars.document,
27774 children: documentLabel
27775 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(header_Tabs.Tab, {
27776 tabId: sidebars.block
27777 // Used for focus management in the SettingsSidebar component.
27778 ,
27779 "data-tab-id": sidebars.block,
27780 children: (0,external_wp_i18n_namespaceObject.__)('Block')
27781 })]
27782 });
27783 };
27784 /* harmony default export */ const sidebar_header = ((0,external_wp_element_namespaceObject.forwardRef)(SidebarHeader));
27785
27786 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-content-panel/index.js
27787 /**
27788 * WordPress dependencies
27789 */
27790
27791
27792
27793
27794
27795 /**
27796 * Internal dependencies
27797 */
27798
27799
27800 const {
27801 BlockQuickNavigation
27802 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
27803 const PAGE_CONTENT_BLOCKS = ['core/post-content', 'core/post-featured-image', 'core/post-title'];
27804 function TemplateContentPanel() {
27805 const clientIds = (0,external_wp_data_namespaceObject.useSelect)(select => {
27806 const {
27807 getBlocksByName
27808 } = select(external_wp_blockEditor_namespaceObject.store);
27809 return getBlocksByName(PAGE_CONTENT_BLOCKS);
27810 }, []);
27811 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
27812 title: (0,external_wp_i18n_namespaceObject.__)('Content'),
27813 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockQuickNavigation, {
27814 clientIds: clientIds
27815 })
27816 });
27817 }
27818
27819 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/use-auto-switch-editor-sidebars.js
27820 /**
27821 * WordPress dependencies
27822 */
27823
27824
27825
27826
27827
27828
27829 /**
27830 * This listener hook monitors for block selection and triggers the appropriate
27831 * sidebar state.
27832 */
27833 function useAutoSwitchEditorSidebars() {
27834 const {
27835 hasBlockSelection
27836 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27837 return {
27838 hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart()
27839 };
27840 }, []);
27841 const {
27842 getActiveComplementaryArea
27843 } = (0,external_wp_data_namespaceObject.useSelect)(store);
27844 const {
27845 enableComplementaryArea
27846 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
27847 const {
27848 get: getPreference
27849 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_preferences_namespaceObject.store);
27850 (0,external_wp_element_namespaceObject.useEffect)(() => {
27851 const activeGeneralSidebar = getActiveComplementaryArea('core');
27852 const isEditorSidebarOpened = ['edit-post/document', 'edit-post/block'].includes(activeGeneralSidebar);
27853 const isDistractionFree = getPreference('core', 'distractionFree');
27854 if (!isEditorSidebarOpened || isDistractionFree) {
27855 return;
27856 }
27857 if (hasBlockSelection) {
27858 enableComplementaryArea('core', 'edit-post/block');
27859 } else {
27860 enableComplementaryArea('core', 'edit-post/document');
27861 }
27862 }, [hasBlockSelection, getActiveComplementaryArea, enableComplementaryArea, getPreference]);
27863 }
27864 /* harmony default export */ const use_auto_switch_editor_sidebars = (useAutoSwitchEditorSidebars);
27865
27866 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/sidebar/index.js
27867 /**
27868 * WordPress dependencies
27869 */
27870
27871
27872
27873
27874
27875
27876
27877
27878
27879 /**
27880 * Internal dependencies
27881 */
27882
27883
27884
27885
27886
27887
27888
27889
27890
27891
27892
27893
27894
27895
27896
27897 const {
27898 Tabs: sidebar_Tabs
27899 } = unlock(external_wp_components_namespaceObject.privateApis);
27900 const SIDEBAR_ACTIVE_BY_DEFAULT = external_wp_element_namespaceObject.Platform.select({
27901 web: true,
27902 native: false
27903 });
27904 const SidebarContent = ({
27905 tabName,
27906 keyboardShortcut,
27907 renderingMode,
27908 onActionPerformed,
27909 extraPanels
27910 }) => {
27911 const tabListRef = (0,external_wp_element_namespaceObject.useRef)(null);
27912 // Because `PluginSidebar` renders a `ComplementaryArea`, we
27913 // need to forward the `Tabs` context so it can be passed through the
27914 // underlying slot/fill.
27915 const tabsContextValue = (0,external_wp_element_namespaceObject.useContext)(sidebar_Tabs.Context);
27916
27917 // This effect addresses a race condition caused by tabbing from the last
27918 // block in the editor into the settings sidebar. Without this effect, the
27919 // selected tab and browser focus can become separated in an unexpected way
27920 // (e.g the "block" tab is focused, but the "post" tab is selected).
27921 (0,external_wp_element_namespaceObject.useEffect)(() => {
27922 const tabsElements = Array.from(tabListRef.current?.querySelectorAll('[role="tab"]') || []);
27923 const selectedTabElement = tabsElements.find(
27924 // We are purposefully using a custom `data-tab-id` attribute here
27925 // because we don't want rely on any assumptions about `Tabs`
27926 // component internals.
27927 element => element.getAttribute('data-tab-id') === tabName);
27928 const activeElement = selectedTabElement?.ownerDocument.activeElement;
27929 const tabsHasFocus = tabsElements.some(element => {
27930 return activeElement && activeElement.id === element.id;
27931 });
27932 if (tabsHasFocus && selectedTabElement && selectedTabElement.id !== activeElement?.id) {
27933 selectedTabElement?.focus();
27934 }
27935 }, [tabName]);
27936 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PluginSidebar, {
27937 identifier: tabName,
27938 header: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_Tabs.Context.Provider, {
27939 value: tabsContextValue,
27940 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_header, {
27941 ref: tabListRef
27942 })
27943 }),
27944 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close Settings')
27945 // This classname is added so we can apply a corrective negative
27946 // margin to the panel.
27947 // see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049
27948 ,
27949 className: "editor-sidebar__panel",
27950 headerClassName: "editor-sidebar__panel-tabs"
27951 /* translators: button label text should, if possible, be under 16 characters. */,
27952 title: (0,external_wp_i18n_namespaceObject.__)('Settings'),
27953 toggleShortcut: keyboardShortcut,
27954 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right,
27955 isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT,
27956 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(sidebar_Tabs.Context.Provider, {
27957 value: tabsContextValue,
27958 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(sidebar_Tabs.TabPanel, {
27959 tabId: sidebars.document,
27960 focusable: false,
27961 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSummary, {
27962 onActionPerformed: onActionPerformed
27963 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_document_setting_panel.Slot, {}), renderingMode !== 'post-only' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateContentPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTransformPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_taxonomies_panel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternOverridesPanel, {}), extraPanels]
27964 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_Tabs.TabPanel, {
27965 tabId: sidebars.block,
27966 focusable: false,
27967 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockInspector, {})
27968 })]
27969 })
27970 });
27971 };
27972 const Sidebar = ({
27973 extraPanels,
27974 onActionPerformed
27975 }) => {
27976 use_auto_switch_editor_sidebars();
27977 const {
27978 tabName,
27979 keyboardShortcut,
27980 showSummary,
27981 renderingMode
27982 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27983 const shortcut = select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/editor/toggle-sidebar');
27984 const sidebar = select(store).getActiveComplementaryArea('core');
27985 const _isEditorSidebarOpened = [sidebars.block, sidebars.document].includes(sidebar);
27986 let _tabName = sidebar;
27987 if (!_isEditorSidebarOpened) {
27988 _tabName = !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart() ? sidebars.block : sidebars.document;
27989 }
27990 return {
27991 tabName: _tabName,
27992 keyboardShortcut: shortcut,
27993 showSummary: ![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, NAVIGATION_POST_TYPE].includes(select(store_store).getCurrentPostType()),
27994 renderingMode: select(store_store).getRenderingMode()
27995 };
27996 }, []);
27997 const {
27998 enableComplementaryArea
27999 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
28000 const onTabSelect = (0,external_wp_element_namespaceObject.useCallback)(newSelectedTabId => {
28001 if (!!newSelectedTabId) {
28002 enableComplementaryArea('core', newSelectedTabId);
28003 }
28004 }, [enableComplementaryArea]);
28005 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_Tabs, {
28006 selectedTabId: tabName,
28007 onSelect: onTabSelect,
28008 selectOnMove: false,
28009 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SidebarContent, {
28010 tabName: tabName,
28011 keyboardShortcut: keyboardShortcut,
28012 showSummary: showSummary,
28013 renderingMode: renderingMode,
28014 onActionPerformed: onActionPerformed,
28015 extraPanels: extraPanels
28016 })
28017 });
28018 };
28019 /* harmony default export */ const components_sidebar = (Sidebar);
28020
28021 ;// CONCATENATED MODULE: ./packages/editor/build-module/private-apis.js
28022 /**
28023 * WordPress dependencies
28024 */
28025
28026
28027 /**
28028 * Internal dependencies
28029 */
28030
28031
28032
28033
28034
28035
28036
28037
28038
28039
28040
28041
28042
28043
28044
28045
28046 const {
28047 store: interfaceStore,
28048 ...remainingInterfaceApis
28049 } = build_module_namespaceObject;
28050 const privateApis = {};
28051 lock(privateApis, {
28052 CreateTemplatePartModal: CreateTemplatePartModal,
28053 BackButton: back_button,
28054 ExperimentalEditorProvider: ExperimentalEditorProvider,
28055 EntitiesSavedStatesExtensible: EntitiesSavedStatesExtensible,
28056 EditorInterface: EditorInterface,
28057 EditorContentSlotFill: content_slot_fill,
28058 GlobalStylesProvider: GlobalStylesProvider,
28059 mergeBaseAndUserConfigs: mergeBaseAndUserConfigs,
28060 PluginPostExcerpt: post_excerpt_plugin,
28061 PreferencesModal: EditorPreferencesModal,
28062 usePostActions: usePostActions,
28063 ToolsMoreMenuGroup: tools_more_menu_group,
28064 ViewMoreMenuGroup: view_more_menu_group,
28065 ResizableEditor: resizable_editor,
28066 Sidebar: components_sidebar,
28067 // This is a temporary private API while we're updating the site editor to use EditorProvider.
28068 useBlockEditorSettings: use_block_editor_settings,
28069 interfaceStore,
28070 ...remainingInterfaceApis
28071 });
28072
28073 ;// CONCATENATED MODULE: ./packages/editor/build-module/index.js
28074 /**
28075 * Internal dependencies
28076 */
28077
28078
28079
28080
28081
28082
28083
28084 /*
28085 * Backward compatibility
28086 */
28087
28088
28089 })();
28090
28091 (window.wp = window.wp || {}).editor = __webpack_exports__;
28092 /******/ })()
28093 ;