PluginProbe
Gutenberg / 18.9.0
Gutenberg v18.9.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.9.0, at build/editor/index.js

29,071 lines 999.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 registerEntityAction: () => (/* reexport */ api_registerEntityAction),
1602 store: () => (/* reexport */ store_store),
1603 storeConfig: () => (/* reexport */ storeConfig),
1604 transformStyles: () => (/* reexport */ external_wp_blockEditor_namespaceObject.transformStyles),
1605 unregisterEntityAction: () => (/* reexport */ api_unregisterEntityAction),
1606 useEntitiesSavedStatesIsDirty: () => (/* reexport */ useIsDirty),
1607 usePostScheduleLabel: () => (/* reexport */ usePostScheduleLabel),
1608 usePostURLLabel: () => (/* reexport */ usePostURLLabel),
1609 usePostVisibilityLabel: () => (/* reexport */ usePostVisibilityLabel),
1610 userAutocompleter: () => (/* reexport */ user),
1611 withColorContext: () => (/* reexport */ withColorContext),
1612 withColors: () => (/* reexport */ withColors),
1613 withFontSizes: () => (/* reexport */ withFontSizes)
1614 });
1615
1616 // NAMESPACE OBJECT: ./packages/editor/build-module/store/selectors.js
1617 var selectors_namespaceObject = {};
1618 __webpack_require__.r(selectors_namespaceObject);
1619 __webpack_require__.d(selectors_namespaceObject, {
1620 __experimentalGetDefaultTemplatePartAreas: () => (__experimentalGetDefaultTemplatePartAreas),
1621 __experimentalGetDefaultTemplateType: () => (__experimentalGetDefaultTemplateType),
1622 __experimentalGetDefaultTemplateTypes: () => (__experimentalGetDefaultTemplateTypes),
1623 __experimentalGetTemplateInfo: () => (__experimentalGetTemplateInfo),
1624 __unstableIsEditorReady: () => (__unstableIsEditorReady),
1625 canInsertBlockType: () => (canInsertBlockType),
1626 canUserUseUnfilteredHTML: () => (canUserUseUnfilteredHTML),
1627 didPostSaveRequestFail: () => (didPostSaveRequestFail),
1628 didPostSaveRequestSucceed: () => (didPostSaveRequestSucceed),
1629 getActivePostLock: () => (getActivePostLock),
1630 getAdjacentBlockClientId: () => (getAdjacentBlockClientId),
1631 getAutosaveAttribute: () => (getAutosaveAttribute),
1632 getBlock: () => (getBlock),
1633 getBlockAttributes: () => (getBlockAttributes),
1634 getBlockCount: () => (getBlockCount),
1635 getBlockHierarchyRootClientId: () => (getBlockHierarchyRootClientId),
1636 getBlockIndex: () => (getBlockIndex),
1637 getBlockInsertionPoint: () => (getBlockInsertionPoint),
1638 getBlockListSettings: () => (getBlockListSettings),
1639 getBlockMode: () => (getBlockMode),
1640 getBlockName: () => (getBlockName),
1641 getBlockOrder: () => (getBlockOrder),
1642 getBlockRootClientId: () => (getBlockRootClientId),
1643 getBlockSelectionEnd: () => (getBlockSelectionEnd),
1644 getBlockSelectionStart: () => (getBlockSelectionStart),
1645 getBlocks: () => (getBlocks),
1646 getBlocksByClientId: () => (getBlocksByClientId),
1647 getClientIdsOfDescendants: () => (getClientIdsOfDescendants),
1648 getClientIdsWithDescendants: () => (getClientIdsWithDescendants),
1649 getCurrentPost: () => (getCurrentPost),
1650 getCurrentPostAttribute: () => (getCurrentPostAttribute),
1651 getCurrentPostId: () => (getCurrentPostId),
1652 getCurrentPostLastRevisionId: () => (getCurrentPostLastRevisionId),
1653 getCurrentPostRevisionsCount: () => (getCurrentPostRevisionsCount),
1654 getCurrentPostType: () => (getCurrentPostType),
1655 getCurrentTemplateId: () => (getCurrentTemplateId),
1656 getDeviceType: () => (getDeviceType),
1657 getEditedPostAttribute: () => (getEditedPostAttribute),
1658 getEditedPostContent: () => (getEditedPostContent),
1659 getEditedPostPreviewLink: () => (getEditedPostPreviewLink),
1660 getEditedPostSlug: () => (getEditedPostSlug),
1661 getEditedPostVisibility: () => (getEditedPostVisibility),
1662 getEditorBlocks: () => (getEditorBlocks),
1663 getEditorMode: () => (getEditorMode),
1664 getEditorSelection: () => (getEditorSelection),
1665 getEditorSelectionEnd: () => (getEditorSelectionEnd),
1666 getEditorSelectionStart: () => (getEditorSelectionStart),
1667 getEditorSettings: () => (getEditorSettings),
1668 getFirstMultiSelectedBlockClientId: () => (getFirstMultiSelectedBlockClientId),
1669 getGlobalBlockCount: () => (getGlobalBlockCount),
1670 getInserterItems: () => (getInserterItems),
1671 getLastMultiSelectedBlockClientId: () => (getLastMultiSelectedBlockClientId),
1672 getMultiSelectedBlockClientIds: () => (getMultiSelectedBlockClientIds),
1673 getMultiSelectedBlocks: () => (getMultiSelectedBlocks),
1674 getMultiSelectedBlocksEndClientId: () => (getMultiSelectedBlocksEndClientId),
1675 getMultiSelectedBlocksStartClientId: () => (getMultiSelectedBlocksStartClientId),
1676 getNextBlockClientId: () => (getNextBlockClientId),
1677 getPermalink: () => (getPermalink),
1678 getPermalinkParts: () => (getPermalinkParts),
1679 getPostEdits: () => (getPostEdits),
1680 getPostLockUser: () => (getPostLockUser),
1681 getPostTypeLabel: () => (getPostTypeLabel),
1682 getPreviousBlockClientId: () => (getPreviousBlockClientId),
1683 getRenderingMode: () => (getRenderingMode),
1684 getSelectedBlock: () => (getSelectedBlock),
1685 getSelectedBlockClientId: () => (getSelectedBlockClientId),
1686 getSelectedBlockCount: () => (getSelectedBlockCount),
1687 getSelectedBlocksInitialCaretPosition: () => (getSelectedBlocksInitialCaretPosition),
1688 getStateBeforeOptimisticTransaction: () => (getStateBeforeOptimisticTransaction),
1689 getSuggestedPostFormat: () => (getSuggestedPostFormat),
1690 getTemplate: () => (getTemplate),
1691 getTemplateLock: () => (getTemplateLock),
1692 hasChangedContent: () => (hasChangedContent),
1693 hasEditorRedo: () => (hasEditorRedo),
1694 hasEditorUndo: () => (hasEditorUndo),
1695 hasInserterItems: () => (hasInserterItems),
1696 hasMultiSelection: () => (hasMultiSelection),
1697 hasNonPostEntityChanges: () => (hasNonPostEntityChanges),
1698 hasSelectedBlock: () => (hasSelectedBlock),
1699 hasSelectedInnerBlock: () => (hasSelectedInnerBlock),
1700 inSomeHistory: () => (inSomeHistory),
1701 isAncestorMultiSelected: () => (isAncestorMultiSelected),
1702 isAutosavingPost: () => (isAutosavingPost),
1703 isBlockInsertionPointVisible: () => (isBlockInsertionPointVisible),
1704 isBlockMultiSelected: () => (isBlockMultiSelected),
1705 isBlockSelected: () => (isBlockSelected),
1706 isBlockValid: () => (isBlockValid),
1707 isBlockWithinSelection: () => (isBlockWithinSelection),
1708 isCaretWithinFormattedText: () => (isCaretWithinFormattedText),
1709 isCleanNewPost: () => (isCleanNewPost),
1710 isCurrentPostPending: () => (isCurrentPostPending),
1711 isCurrentPostPublished: () => (isCurrentPostPublished),
1712 isCurrentPostScheduled: () => (isCurrentPostScheduled),
1713 isDeletingPost: () => (isDeletingPost),
1714 isEditedPostAutosaveable: () => (isEditedPostAutosaveable),
1715 isEditedPostBeingScheduled: () => (isEditedPostBeingScheduled),
1716 isEditedPostDateFloating: () => (isEditedPostDateFloating),
1717 isEditedPostDirty: () => (isEditedPostDirty),
1718 isEditedPostEmpty: () => (isEditedPostEmpty),
1719 isEditedPostNew: () => (isEditedPostNew),
1720 isEditedPostPublishable: () => (isEditedPostPublishable),
1721 isEditedPostSaveable: () => (isEditedPostSaveable),
1722 isEditorPanelEnabled: () => (isEditorPanelEnabled),
1723 isEditorPanelOpened: () => (isEditorPanelOpened),
1724 isEditorPanelRemoved: () => (isEditorPanelRemoved),
1725 isFirstMultiSelectedBlock: () => (isFirstMultiSelectedBlock),
1726 isInserterOpened: () => (isInserterOpened),
1727 isListViewOpened: () => (isListViewOpened),
1728 isMultiSelecting: () => (isMultiSelecting),
1729 isPermalinkEditable: () => (isPermalinkEditable),
1730 isPostAutosavingLocked: () => (isPostAutosavingLocked),
1731 isPostLockTakeover: () => (isPostLockTakeover),
1732 isPostLocked: () => (isPostLocked),
1733 isPostSavingLocked: () => (isPostSavingLocked),
1734 isPreviewingPost: () => (isPreviewingPost),
1735 isPublishSidebarEnabled: () => (isPublishSidebarEnabled),
1736 isPublishSidebarOpened: () => (isPublishSidebarOpened),
1737 isPublishingPost: () => (isPublishingPost),
1738 isSavingNonPostEntityChanges: () => (isSavingNonPostEntityChanges),
1739 isSavingPost: () => (isSavingPost),
1740 isSelectionEnabled: () => (isSelectionEnabled),
1741 isTyping: () => (isTyping),
1742 isValidTemplate: () => (isValidTemplate)
1743 });
1744
1745 // NAMESPACE OBJECT: ./packages/editor/build-module/store/actions.js
1746 var actions_namespaceObject = {};
1747 __webpack_require__.r(actions_namespaceObject);
1748 __webpack_require__.d(actions_namespaceObject, {
1749 __experimentalTearDownEditor: () => (__experimentalTearDownEditor),
1750 __unstableSaveForPreview: () => (__unstableSaveForPreview),
1751 autosave: () => (autosave),
1752 clearSelectedBlock: () => (clearSelectedBlock),
1753 closePublishSidebar: () => (closePublishSidebar),
1754 createUndoLevel: () => (createUndoLevel),
1755 disablePublishSidebar: () => (disablePublishSidebar),
1756 editPost: () => (editPost),
1757 enablePublishSidebar: () => (enablePublishSidebar),
1758 enterFormattedText: () => (enterFormattedText),
1759 exitFormattedText: () => (exitFormattedText),
1760 hideInsertionPoint: () => (hideInsertionPoint),
1761 insertBlock: () => (insertBlock),
1762 insertBlocks: () => (insertBlocks),
1763 insertDefaultBlock: () => (insertDefaultBlock),
1764 lockPostAutosaving: () => (lockPostAutosaving),
1765 lockPostSaving: () => (lockPostSaving),
1766 mergeBlocks: () => (mergeBlocks),
1767 moveBlockToPosition: () => (moveBlockToPosition),
1768 moveBlocksDown: () => (moveBlocksDown),
1769 moveBlocksUp: () => (moveBlocksUp),
1770 multiSelect: () => (multiSelect),
1771 openPublishSidebar: () => (openPublishSidebar),
1772 receiveBlocks: () => (receiveBlocks),
1773 redo: () => (redo),
1774 refreshPost: () => (refreshPost),
1775 removeBlock: () => (removeBlock),
1776 removeBlocks: () => (removeBlocks),
1777 removeEditorPanel: () => (removeEditorPanel),
1778 replaceBlock: () => (replaceBlock),
1779 replaceBlocks: () => (replaceBlocks),
1780 resetBlocks: () => (resetBlocks),
1781 resetEditorBlocks: () => (resetEditorBlocks),
1782 resetPost: () => (resetPost),
1783 savePost: () => (savePost),
1784 selectBlock: () => (selectBlock),
1785 setDeviceType: () => (setDeviceType),
1786 setEditedPost: () => (setEditedPost),
1787 setIsInserterOpened: () => (setIsInserterOpened),
1788 setIsListViewOpened: () => (setIsListViewOpened),
1789 setRenderingMode: () => (setRenderingMode),
1790 setTemplateValidity: () => (setTemplateValidity),
1791 setupEditor: () => (setupEditor),
1792 setupEditorState: () => (setupEditorState),
1793 showInsertionPoint: () => (showInsertionPoint),
1794 startMultiSelect: () => (startMultiSelect),
1795 startTyping: () => (startTyping),
1796 stopMultiSelect: () => (stopMultiSelect),
1797 stopTyping: () => (stopTyping),
1798 switchEditorMode: () => (switchEditorMode),
1799 synchronizeTemplate: () => (synchronizeTemplate),
1800 toggleBlockMode: () => (toggleBlockMode),
1801 toggleDistractionFree: () => (toggleDistractionFree),
1802 toggleEditorPanelEnabled: () => (toggleEditorPanelEnabled),
1803 toggleEditorPanelOpened: () => (toggleEditorPanelOpened),
1804 togglePublishSidebar: () => (togglePublishSidebar),
1805 toggleSelection: () => (toggleSelection),
1806 trashPost: () => (trashPost),
1807 undo: () => (undo),
1808 unlockPostAutosaving: () => (unlockPostAutosaving),
1809 unlockPostSaving: () => (unlockPostSaving),
1810 updateBlock: () => (updateBlock),
1811 updateBlockAttributes: () => (updateBlockAttributes),
1812 updateBlockListSettings: () => (updateBlockListSettings),
1813 updateEditorSettings: () => (updateEditorSettings),
1814 updatePost: () => (updatePost),
1815 updatePostLock: () => (updatePostLock)
1816 });
1817
1818 // NAMESPACE OBJECT: ./packages/editor/build-module/store/private-actions.js
1819 var store_private_actions_namespaceObject = {};
1820 __webpack_require__.r(store_private_actions_namespaceObject);
1821 __webpack_require__.d(store_private_actions_namespaceObject, {
1822 createTemplate: () => (createTemplate),
1823 hideBlockTypes: () => (hideBlockTypes),
1824 registerEntityAction: () => (registerEntityAction),
1825 removeTemplates: () => (removeTemplates),
1826 revertTemplate: () => (revertTemplate),
1827 saveDirtyEntities: () => (saveDirtyEntities),
1828 setCurrentTemplateId: () => (setCurrentTemplateId),
1829 showBlockTypes: () => (showBlockTypes),
1830 unregisterEntityAction: () => (unregisterEntityAction)
1831 });
1832
1833 // NAMESPACE OBJECT: ./packages/editor/build-module/store/private-selectors.js
1834 var store_private_selectors_namespaceObject = {};
1835 __webpack_require__.r(store_private_selectors_namespaceObject);
1836 __webpack_require__.d(store_private_selectors_namespaceObject, {
1837 getEntityActions: () => (private_selectors_getEntityActions),
1838 getInserterSidebarToggleRef: () => (getInserterSidebarToggleRef),
1839 getInsertionPoint: () => (getInsertionPoint),
1840 getListViewToggleRef: () => (getListViewToggleRef),
1841 getPostIcon: () => (getPostIcon),
1842 hasPostMetaChanges: () => (hasPostMetaChanges)
1843 });
1844
1845 // NAMESPACE OBJECT: ./packages/interface/build-module/store/actions.js
1846 var store_actions_namespaceObject = {};
1847 __webpack_require__.r(store_actions_namespaceObject);
1848 __webpack_require__.d(store_actions_namespaceObject, {
1849 closeModal: () => (closeModal),
1850 disableComplementaryArea: () => (disableComplementaryArea),
1851 enableComplementaryArea: () => (enableComplementaryArea),
1852 openModal: () => (openModal),
1853 pinItem: () => (pinItem),
1854 setDefaultComplementaryArea: () => (setDefaultComplementaryArea),
1855 setFeatureDefaults: () => (setFeatureDefaults),
1856 setFeatureValue: () => (setFeatureValue),
1857 toggleFeature: () => (toggleFeature),
1858 unpinItem: () => (unpinItem)
1859 });
1860
1861 // NAMESPACE OBJECT: ./packages/interface/build-module/store/selectors.js
1862 var store_selectors_namespaceObject = {};
1863 __webpack_require__.r(store_selectors_namespaceObject);
1864 __webpack_require__.d(store_selectors_namespaceObject, {
1865 getActiveComplementaryArea: () => (getActiveComplementaryArea),
1866 isComplementaryAreaLoading: () => (isComplementaryAreaLoading),
1867 isFeatureActive: () => (isFeatureActive),
1868 isItemPinned: () => (isItemPinned),
1869 isModalActive: () => (isModalActive)
1870 });
1871
1872 // NAMESPACE OBJECT: ./packages/interface/build-module/index.js
1873 var build_module_namespaceObject = {};
1874 __webpack_require__.r(build_module_namespaceObject);
1875 __webpack_require__.d(build_module_namespaceObject, {
1876 ActionItem: () => (action_item),
1877 ComplementaryArea: () => (complementary_area),
1878 ComplementaryAreaMoreMenuItem: () => (ComplementaryAreaMoreMenuItem),
1879 FullscreenMode: () => (fullscreen_mode),
1880 InterfaceSkeleton: () => (interface_skeleton),
1881 NavigableRegion: () => (NavigableRegion),
1882 PinnedItems: () => (pinned_items),
1883 store: () => (store)
1884 });
1885
1886 ;// CONCATENATED MODULE: external ["wp","data"]
1887 const external_wp_data_namespaceObject = window["wp"]["data"];
1888 ;// CONCATENATED MODULE: external ["wp","coreData"]
1889 const external_wp_coreData_namespaceObject = window["wp"]["coreData"];
1890 ;// CONCATENATED MODULE: external ["wp","element"]
1891 const external_wp_element_namespaceObject = window["wp"]["element"];
1892 ;// CONCATENATED MODULE: external ["wp","compose"]
1893 const external_wp_compose_namespaceObject = window["wp"]["compose"];
1894 ;// CONCATENATED MODULE: external ["wp","hooks"]
1895 const external_wp_hooks_namespaceObject = window["wp"]["hooks"];
1896 ;// CONCATENATED MODULE: external ["wp","blockEditor"]
1897 const external_wp_blockEditor_namespaceObject = window["wp"]["blockEditor"];
1898 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/defaults.js
1899 /**
1900 * WordPress dependencies
1901 */
1902
1903
1904 /**
1905 * The default post editor settings.
1906 *
1907 * @property {boolean|Array} allowedBlockTypes Allowed block types
1908 * @property {boolean} richEditingEnabled Whether rich editing is enabled or not
1909 * @property {boolean} codeEditingEnabled Whether code editing is enabled or not
1910 * @property {boolean} fontLibraryEnabled Whether the font library is enabled or not.
1911 * @property {boolean} enableCustomFields Whether the WordPress custom fields are enabled or not.
1912 * true = the user has opted to show the Custom Fields panel at the bottom of the editor.
1913 * false = the user has opted to hide the Custom Fields panel at the bottom of the editor.
1914 * 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.
1915 * @property {number} autosaveInterval How often in seconds the post will be auto-saved via the REST API.
1916 * @property {number} localAutosaveInterval How often in seconds the post will be backed up to sessionStorage.
1917 * @property {Array?} availableTemplates The available post templates
1918 * @property {boolean} disablePostFormats Whether or not the post formats are disabled
1919 * @property {Array?} allowedMimeTypes List of allowed mime types and file extensions
1920 * @property {number} maxUploadFileSize Maximum upload file size
1921 * @property {boolean} supportsLayout Whether the editor supports layouts.
1922 */
1923 const EDITOR_SETTINGS_DEFAULTS = {
1924 ...external_wp_blockEditor_namespaceObject.SETTINGS_DEFAULTS,
1925 richEditingEnabled: true,
1926 codeEditingEnabled: true,
1927 fontLibraryEnabled: true,
1928 enableCustomFields: undefined,
1929 defaultRenderingMode: 'post-only'
1930 };
1931
1932 ;// CONCATENATED MODULE: ./packages/editor/build-module/dataviews/store/reducer.js
1933 /**
1934 * WordPress dependencies
1935 */
1936
1937 function actions(state = {}, action) {
1938 var _state$action$kind$ac;
1939 switch (action.type) {
1940 case 'REGISTER_ENTITY_ACTION':
1941 return {
1942 ...state,
1943 [action.kind]: {
1944 ...state[action.kind],
1945 [action.name]: [...((_state$action$kind$ac = state[action.kind]?.[action.name]) !== null && _state$action$kind$ac !== void 0 ? _state$action$kind$ac : []).filter(_action => _action.id !== action.config.id), action.config]
1946 }
1947 };
1948 case 'UNREGISTER_ENTITY_ACTION':
1949 {
1950 var _state$action$kind$ac2;
1951 return {
1952 ...state,
1953 [action.kind]: {
1954 ...state[action.kind],
1955 [action.name]: ((_state$action$kind$ac2 = state[action.kind]?.[action.name]) !== null && _state$action$kind$ac2 !== void 0 ? _state$action$kind$ac2 : []).filter(_action => _action.id !== action.actionId)
1956 }
1957 };
1958 }
1959 }
1960 return state;
1961 }
1962 /* harmony default export */ const reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
1963 actions
1964 }));
1965
1966 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/reducer.js
1967 /**
1968 * WordPress dependencies
1969 */
1970
1971
1972 /**
1973 * Internal dependencies
1974 */
1975
1976
1977
1978 /**
1979 * Returns a post attribute value, flattening nested rendered content using its
1980 * raw value in place of its original object form.
1981 *
1982 * @param {*} value Original value.
1983 *
1984 * @return {*} Raw value.
1985 */
1986 function getPostRawValue(value) {
1987 if (value && 'object' === typeof value && 'raw' in value) {
1988 return value.raw;
1989 }
1990 return value;
1991 }
1992
1993 /**
1994 * Returns true if the two object arguments have the same keys, or false
1995 * otherwise.
1996 *
1997 * @param {Object} a First object.
1998 * @param {Object} b Second object.
1999 *
2000 * @return {boolean} Whether the two objects have the same keys.
2001 */
2002 function hasSameKeys(a, b) {
2003 const keysA = Object.keys(a).sort();
2004 const keysB = Object.keys(b).sort();
2005 return keysA.length === keysB.length && keysA.every((key, index) => keysB[index] === key);
2006 }
2007
2008 /**
2009 * Returns true if, given the currently dispatching action and the previously
2010 * dispatched action, the two actions are editing the same post property, or
2011 * false otherwise.
2012 *
2013 * @param {Object} action Currently dispatching action.
2014 * @param {Object} previousAction Previously dispatched action.
2015 *
2016 * @return {boolean} Whether actions are updating the same post property.
2017 */
2018 function isUpdatingSamePostProperty(action, previousAction) {
2019 return action.type === 'EDIT_POST' && hasSameKeys(action.edits, previousAction.edits);
2020 }
2021
2022 /**
2023 * Returns true if, given the currently dispatching action and the previously
2024 * dispatched action, the two actions are modifying the same property such that
2025 * undo history should be batched.
2026 *
2027 * @param {Object} action Currently dispatching action.
2028 * @param {Object} previousAction Previously dispatched action.
2029 *
2030 * @return {boolean} Whether to overwrite present state.
2031 */
2032 function shouldOverwriteState(action, previousAction) {
2033 if (action.type === 'RESET_EDITOR_BLOCKS') {
2034 return !action.shouldCreateUndoLevel;
2035 }
2036 if (!previousAction || action.type !== previousAction.type) {
2037 return false;
2038 }
2039 return isUpdatingSamePostProperty(action, previousAction);
2040 }
2041 function postId(state = null, action) {
2042 switch (action.type) {
2043 case 'SET_EDITED_POST':
2044 return action.postId;
2045 }
2046 return state;
2047 }
2048 function templateId(state = null, action) {
2049 switch (action.type) {
2050 case 'SET_CURRENT_TEMPLATE_ID':
2051 return action.id;
2052 }
2053 return state;
2054 }
2055 function postType(state = null, action) {
2056 switch (action.type) {
2057 case 'SET_EDITED_POST':
2058 return action.postType;
2059 }
2060 return state;
2061 }
2062
2063 /**
2064 * Reducer returning whether the post blocks match the defined template or not.
2065 *
2066 * @param {Object} state Current state.
2067 * @param {Object} action Dispatched action.
2068 *
2069 * @return {boolean} Updated state.
2070 */
2071 function template(state = {
2072 isValid: true
2073 }, action) {
2074 switch (action.type) {
2075 case 'SET_TEMPLATE_VALIDITY':
2076 return {
2077 ...state,
2078 isValid: action.isValid
2079 };
2080 }
2081 return state;
2082 }
2083
2084 /**
2085 * Reducer returning current network request state (whether a request to
2086 * the WP REST API is in progress, successful, or failed).
2087 *
2088 * @param {Object} state Current state.
2089 * @param {Object} action Dispatched action.
2090 *
2091 * @return {Object} Updated state.
2092 */
2093 function saving(state = {}, action) {
2094 switch (action.type) {
2095 case 'REQUEST_POST_UPDATE_START':
2096 case 'REQUEST_POST_UPDATE_FINISH':
2097 return {
2098 pending: action.type === 'REQUEST_POST_UPDATE_START',
2099 options: action.options || {}
2100 };
2101 }
2102 return state;
2103 }
2104
2105 /**
2106 * Reducer returning deleting post request state.
2107 *
2108 * @param {Object} state Current state.
2109 * @param {Object} action Dispatched action.
2110 *
2111 * @return {Object} Updated state.
2112 */
2113 function deleting(state = {}, action) {
2114 switch (action.type) {
2115 case 'REQUEST_POST_DELETE_START':
2116 case 'REQUEST_POST_DELETE_FINISH':
2117 return {
2118 pending: action.type === 'REQUEST_POST_DELETE_START'
2119 };
2120 }
2121 return state;
2122 }
2123
2124 /**
2125 * Post Lock State.
2126 *
2127 * @typedef {Object} PostLockState
2128 *
2129 * @property {boolean} isLocked Whether the post is locked.
2130 * @property {?boolean} isTakeover Whether the post editing has been taken over.
2131 * @property {?boolean} activePostLock Active post lock value.
2132 * @property {?Object} user User that took over the post.
2133 */
2134
2135 /**
2136 * Reducer returning the post lock status.
2137 *
2138 * @param {PostLockState} state Current state.
2139 * @param {Object} action Dispatched action.
2140 *
2141 * @return {PostLockState} Updated state.
2142 */
2143 function postLock(state = {
2144 isLocked: false
2145 }, action) {
2146 switch (action.type) {
2147 case 'UPDATE_POST_LOCK':
2148 return action.lock;
2149 }
2150 return state;
2151 }
2152
2153 /**
2154 * Post saving lock.
2155 *
2156 * When post saving is locked, the post cannot be published or updated.
2157 *
2158 * @param {PostLockState} state Current state.
2159 * @param {Object} action Dispatched action.
2160 *
2161 * @return {PostLockState} Updated state.
2162 */
2163 function postSavingLock(state = {}, action) {
2164 switch (action.type) {
2165 case 'LOCK_POST_SAVING':
2166 return {
2167 ...state,
2168 [action.lockName]: true
2169 };
2170 case 'UNLOCK_POST_SAVING':
2171 {
2172 const {
2173 [action.lockName]: removedLockName,
2174 ...restState
2175 } = state;
2176 return restState;
2177 }
2178 }
2179 return state;
2180 }
2181
2182 /**
2183 * Post autosaving lock.
2184 *
2185 * When post autosaving is locked, the post will not autosave.
2186 *
2187 * @param {PostLockState} state Current state.
2188 * @param {Object} action Dispatched action.
2189 *
2190 * @return {PostLockState} Updated state.
2191 */
2192 function postAutosavingLock(state = {}, action) {
2193 switch (action.type) {
2194 case 'LOCK_POST_AUTOSAVING':
2195 return {
2196 ...state,
2197 [action.lockName]: true
2198 };
2199 case 'UNLOCK_POST_AUTOSAVING':
2200 {
2201 const {
2202 [action.lockName]: removedLockName,
2203 ...restState
2204 } = state;
2205 return restState;
2206 }
2207 }
2208 return state;
2209 }
2210
2211 /**
2212 * Reducer returning the post editor setting.
2213 *
2214 * @param {Object} state Current state.
2215 * @param {Object} action Dispatched action.
2216 *
2217 * @return {Object} Updated state.
2218 */
2219 function editorSettings(state = EDITOR_SETTINGS_DEFAULTS, action) {
2220 switch (action.type) {
2221 case 'UPDATE_EDITOR_SETTINGS':
2222 return {
2223 ...state,
2224 ...action.settings
2225 };
2226 }
2227 return state;
2228 }
2229 function renderingMode(state = 'post-only', action) {
2230 switch (action.type) {
2231 case 'SET_RENDERING_MODE':
2232 return action.mode;
2233 }
2234 return state;
2235 }
2236
2237 /**
2238 * Reducer returning the editing canvas device type.
2239 *
2240 * @param {Object} state Current state.
2241 * @param {Object} action Dispatched action.
2242 *
2243 * @return {Object} Updated state.
2244 */
2245 function deviceType(state = 'Desktop', action) {
2246 switch (action.type) {
2247 case 'SET_DEVICE_TYPE':
2248 return action.deviceType;
2249 }
2250 return state;
2251 }
2252
2253 /**
2254 * Reducer storing the list of all programmatically removed panels.
2255 *
2256 * @param {Array} state Current state.
2257 * @param {Object} action Action object.
2258 *
2259 * @return {Array} Updated state.
2260 */
2261 function removedPanels(state = [], action) {
2262 switch (action.type) {
2263 case 'REMOVE_PANEL':
2264 if (!state.includes(action.panelName)) {
2265 return [...state, action.panelName];
2266 }
2267 }
2268 return state;
2269 }
2270
2271 /**
2272 * Reducer to set the block inserter panel open or closed.
2273 *
2274 * Note: this reducer interacts with the list view panel reducer
2275 * to make sure that only one of the two panels is open at the same time.
2276 *
2277 * @param {Object} state Current state.
2278 * @param {Object} action Dispatched action.
2279 */
2280 function blockInserterPanel(state = false, action) {
2281 switch (action.type) {
2282 case 'SET_IS_LIST_VIEW_OPENED':
2283 return action.isOpen ? false : state;
2284 case 'SET_IS_INSERTER_OPENED':
2285 return action.value;
2286 }
2287 return state;
2288 }
2289
2290 /**
2291 * Reducer to set the list view panel open or closed.
2292 *
2293 * Note: this reducer interacts with the inserter panel reducer
2294 * to make sure that only one of the two panels is open at the same time.
2295 *
2296 * @param {Object} state Current state.
2297 * @param {Object} action Dispatched action.
2298 */
2299 function listViewPanel(state = false, action) {
2300 switch (action.type) {
2301 case 'SET_IS_INSERTER_OPENED':
2302 return action.value ? false : state;
2303 case 'SET_IS_LIST_VIEW_OPENED':
2304 return action.isOpen;
2305 }
2306 return state;
2307 }
2308
2309 /**
2310 * This reducer does nothing aside initializing a ref to the list view toggle.
2311 * We will have a unique ref per "editor" instance.
2312 *
2313 * @param {Object} state
2314 * @return {Object} Reference to the list view toggle button.
2315 */
2316 function listViewToggleRef(state = {
2317 current: null
2318 }) {
2319 return state;
2320 }
2321
2322 /**
2323 * This reducer does nothing aside initializing a ref to the inserter sidebar toggle.
2324 * We will have a unique ref per "editor" instance.
2325 *
2326 * @param {Object} state
2327 * @return {Object} Reference to the inserter sidebar toggle button.
2328 */
2329 function inserterSidebarToggleRef(state = {
2330 current: null
2331 }) {
2332 return state;
2333 }
2334 function publishSidebarActive(state = false, action) {
2335 switch (action.type) {
2336 case 'OPEN_PUBLISH_SIDEBAR':
2337 return true;
2338 case 'CLOSE_PUBLISH_SIDEBAR':
2339 return false;
2340 case 'TOGGLE_PUBLISH_SIDEBAR':
2341 return !state;
2342 }
2343 return state;
2344 }
2345 /* harmony default export */ const store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
2346 postId,
2347 postType,
2348 templateId,
2349 saving,
2350 deleting,
2351 postLock,
2352 template,
2353 postSavingLock,
2354 editorSettings,
2355 postAutosavingLock,
2356 renderingMode,
2357 deviceType,
2358 removedPanels,
2359 blockInserterPanel,
2360 inserterSidebarToggleRef,
2361 listViewPanel,
2362 listViewToggleRef,
2363 publishSidebarActive,
2364 dataviews: reducer
2365 }));
2366
2367 ;// CONCATENATED MODULE: external ["wp","blocks"]
2368 const external_wp_blocks_namespaceObject = window["wp"]["blocks"];
2369 ;// CONCATENATED MODULE: external ["wp","date"]
2370 const external_wp_date_namespaceObject = window["wp"]["date"];
2371 ;// CONCATENATED MODULE: external ["wp","url"]
2372 const external_wp_url_namespaceObject = window["wp"]["url"];
2373 ;// CONCATENATED MODULE: external ["wp","deprecated"]
2374 const external_wp_deprecated_namespaceObject = window["wp"]["deprecated"];
2375 var external_wp_deprecated_default = /*#__PURE__*/__webpack_require__.n(external_wp_deprecated_namespaceObject);
2376 ;// CONCATENATED MODULE: external ["wp","primitives"]
2377 const external_wp_primitives_namespaceObject = window["wp"]["primitives"];
2378 ;// CONCATENATED MODULE: external "ReactJSXRuntime"
2379 const external_ReactJSXRuntime_namespaceObject = window["ReactJSXRuntime"];
2380 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/layout.js
2381 /**
2382 * WordPress dependencies
2383 */
2384
2385
2386 const layout = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2387 xmlns: "http://www.w3.org/2000/svg",
2388 viewBox: "0 0 24 24",
2389 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2390 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"
2391 })
2392 });
2393 /* harmony default export */ const library_layout = (layout);
2394
2395 ;// CONCATENATED MODULE: external ["wp","preferences"]
2396 const external_wp_preferences_namespaceObject = window["wp"]["preferences"];
2397 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/constants.js
2398 /**
2399 * Set of post properties for which edits should assume a merging behavior,
2400 * assuming an object value.
2401 *
2402 * @type {Set}
2403 */
2404 const EDIT_MERGE_PROPERTIES = new Set(['meta']);
2405
2406 /**
2407 * Constant for the store module (or reducer) key.
2408 *
2409 * @type {string}
2410 */
2411 const STORE_NAME = 'core/editor';
2412 const SAVE_POST_NOTICE_ID = 'SAVE_POST_NOTICE_ID';
2413 const TRASH_POST_NOTICE_ID = 'TRASH_POST_NOTICE_ID';
2414 const PERMALINK_POSTNAME_REGEX = /%(?:postname|pagename)%/;
2415 const ONE_MINUTE_IN_MS = 60 * 1000;
2416 const AUTOSAVE_PROPERTIES = ['title', 'excerpt', 'content'];
2417 const TEMPLATE_PART_AREA_DEFAULT_CATEGORY = 'uncategorized';
2418 const TEMPLATE_POST_TYPE = 'wp_template';
2419 const TEMPLATE_PART_POST_TYPE = 'wp_template_part';
2420 const PATTERN_POST_TYPE = 'wp_block';
2421 const NAVIGATION_POST_TYPE = 'wp_navigation';
2422 const TEMPLATE_ORIGINS = {
2423 custom: 'custom',
2424 theme: 'theme',
2425 plugin: 'plugin'
2426 };
2427 const TEMPLATE_POST_TYPES = ['wp_template', 'wp_template_part'];
2428 const GLOBAL_POST_TYPES = [...TEMPLATE_POST_TYPES, 'wp_block', 'wp_navigation'];
2429
2430 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/header.js
2431 /**
2432 * WordPress dependencies
2433 */
2434
2435
2436 const header = /*#__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 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"
2441 })
2442 });
2443 /* harmony default export */ const library_header = (header);
2444
2445 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/footer.js
2446 /**
2447 * WordPress dependencies
2448 */
2449
2450
2451 const footer = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2452 xmlns: "http://www.w3.org/2000/svg",
2453 viewBox: "0 0 24 24",
2454 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2455 fillRule: "evenodd",
2456 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"
2457 })
2458 });
2459 /* harmony default export */ const library_footer = (footer);
2460
2461 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/sidebar.js
2462 /**
2463 * WordPress dependencies
2464 */
2465
2466
2467 const sidebar = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2468 xmlns: "http://www.w3.org/2000/svg",
2469 viewBox: "0 0 24 24",
2470 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2471 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"
2472 })
2473 });
2474 /* harmony default export */ const library_sidebar = (sidebar);
2475
2476 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/symbol-filled.js
2477 /**
2478 * WordPress dependencies
2479 */
2480
2481
2482 const symbolFilled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
2483 xmlns: "http://www.w3.org/2000/svg",
2484 viewBox: "0 0 24 24",
2485 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
2486 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"
2487 })
2488 });
2489 /* harmony default export */ const symbol_filled = (symbolFilled);
2490
2491 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/get-template-part-icon.js
2492 /**
2493 * WordPress dependencies
2494 */
2495
2496 /**
2497 * Helper function to retrieve the corresponding icon by name.
2498 *
2499 * @param {string} iconName The name of the icon.
2500 *
2501 * @return {Object} The corresponding icon.
2502 */
2503 function getTemplatePartIcon(iconName) {
2504 if ('header' === iconName) {
2505 return library_header;
2506 } else if ('footer' === iconName) {
2507 return library_footer;
2508 } else if ('sidebar' === iconName) {
2509 return library_sidebar;
2510 }
2511 return symbol_filled;
2512 }
2513
2514 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/selectors.js
2515 /**
2516 * WordPress dependencies
2517 */
2518
2519
2520
2521
2522
2523
2524
2525
2526
2527
2528
2529 /**
2530 * Internal dependencies
2531 */
2532
2533
2534
2535
2536 /**
2537 * Shared reference to an empty object for cases where it is important to avoid
2538 * returning a new object reference on every invocation, as in a connected or
2539 * other pure component which performs `shouldComponentUpdate` check on props.
2540 * This should be used as a last resort, since the normalized data should be
2541 * maintained by the reducer result in state.
2542 */
2543 const EMPTY_OBJECT = {};
2544
2545 /**
2546 * Returns true if any past editor history snapshots exist, or false otherwise.
2547 *
2548 * @param {Object} state Global application state.
2549 *
2550 * @return {boolean} Whether undo history exists.
2551 */
2552 const hasEditorUndo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
2553 return select(external_wp_coreData_namespaceObject.store).hasUndo();
2554 });
2555
2556 /**
2557 * Returns true if any future editor history snapshots exist, or false
2558 * otherwise.
2559 *
2560 * @param {Object} state Global application state.
2561 *
2562 * @return {boolean} Whether redo history exists.
2563 */
2564 const hasEditorRedo = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
2565 return select(external_wp_coreData_namespaceObject.store).hasRedo();
2566 });
2567
2568 /**
2569 * Returns true if the currently edited post is yet to be saved, or false if
2570 * the post has been saved.
2571 *
2572 * @param {Object} state Global application state.
2573 *
2574 * @return {boolean} Whether the post is new.
2575 */
2576 function isEditedPostNew(state) {
2577 return getCurrentPost(state).status === 'auto-draft';
2578 }
2579
2580 /**
2581 * Returns true if content includes unsaved changes, or false otherwise.
2582 *
2583 * @param {Object} state Editor state.
2584 *
2585 * @return {boolean} Whether content includes unsaved changes.
2586 */
2587 function hasChangedContent(state) {
2588 const edits = getPostEdits(state);
2589 return 'content' in edits;
2590 }
2591
2592 /**
2593 * Returns true if there are unsaved values for the current edit session, or
2594 * false if the editing state matches the saved or new post.
2595 *
2596 * @param {Object} state Global application state.
2597 *
2598 * @return {boolean} Whether unsaved values exist.
2599 */
2600 const isEditedPostDirty = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2601 // Edits should contain only fields which differ from the saved post (reset
2602 // at initial load and save complete). Thus, a non-empty edits state can be
2603 // inferred to contain unsaved values.
2604 const postType = getCurrentPostType(state);
2605 const postId = getCurrentPostId(state);
2606 return select(external_wp_coreData_namespaceObject.store).hasEditsForEntityRecord('postType', postType, postId);
2607 });
2608
2609 /**
2610 * Returns true if there are unsaved edits for entities other than
2611 * the editor's post, and false otherwise.
2612 *
2613 * @param {Object} state Global application state.
2614 *
2615 * @return {boolean} Whether there are edits or not.
2616 */
2617 const hasNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2618 const dirtyEntityRecords = select(external_wp_coreData_namespaceObject.store).__experimentalGetDirtyEntityRecords();
2619 const {
2620 type,
2621 id
2622 } = getCurrentPost(state);
2623 return dirtyEntityRecords.some(entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id);
2624 });
2625
2626 /**
2627 * Returns true if there are no unsaved values for the current edit session and
2628 * if the currently edited post is new (has never been saved before).
2629 *
2630 * @param {Object} state Global application state.
2631 *
2632 * @return {boolean} Whether new post and unsaved values exist.
2633 */
2634 function isCleanNewPost(state) {
2635 return !isEditedPostDirty(state) && isEditedPostNew(state);
2636 }
2637
2638 /**
2639 * Returns the post currently being edited in its last known saved state, not
2640 * including unsaved edits. Returns an object containing relevant default post
2641 * values if the post has not yet been saved.
2642 *
2643 * @param {Object} state Global application state.
2644 *
2645 * @return {Object} Post object.
2646 */
2647 const getCurrentPost = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2648 const postId = getCurrentPostId(state);
2649 const postType = getCurrentPostType(state);
2650 const post = select(external_wp_coreData_namespaceObject.store).getRawEntityRecord('postType', postType, postId);
2651 if (post) {
2652 return post;
2653 }
2654
2655 // This exists for compatibility with the previous selector behavior
2656 // which would guarantee an object return based on the editor reducer's
2657 // default empty object state.
2658 return EMPTY_OBJECT;
2659 });
2660
2661 /**
2662 * Returns the post type of the post currently being edited.
2663 *
2664 * @param {Object} state Global application state.
2665 *
2666 * @return {string} Post type.
2667 */
2668 function getCurrentPostType(state) {
2669 return state.postType;
2670 }
2671
2672 /**
2673 * Returns the ID of the post currently being edited, or null if the post has
2674 * not yet been saved.
2675 *
2676 * @param {Object} state Global application state.
2677 *
2678 * @return {?number} ID of current post.
2679 */
2680 function getCurrentPostId(state) {
2681 return state.postId;
2682 }
2683
2684 /**
2685 * Returns the template ID currently being rendered/edited
2686 *
2687 * @param {Object} state Global application state.
2688 *
2689 * @return {string?} Template ID.
2690 */
2691 function getCurrentTemplateId(state) {
2692 return state.templateId;
2693 }
2694
2695 /**
2696 * Returns the number of revisions of the post currently being edited.
2697 *
2698 * @param {Object} state Global application state.
2699 *
2700 * @return {number} Number of revisions.
2701 */
2702 function getCurrentPostRevisionsCount(state) {
2703 var _getCurrentPost$_link;
2704 return (_getCurrentPost$_link = getCurrentPost(state)._links?.['version-history']?.[0]?.count) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : 0;
2705 }
2706
2707 /**
2708 * Returns the last revision ID of the post currently being edited,
2709 * or null if the post has no revisions.
2710 *
2711 * @param {Object} state Global application state.
2712 *
2713 * @return {?number} ID of the last revision.
2714 */
2715 function getCurrentPostLastRevisionId(state) {
2716 var _getCurrentPost$_link2;
2717 return (_getCurrentPost$_link2 = getCurrentPost(state)._links?.['predecessor-version']?.[0]?.id) !== null && _getCurrentPost$_link2 !== void 0 ? _getCurrentPost$_link2 : null;
2718 }
2719
2720 /**
2721 * Returns any post values which have been changed in the editor but not yet
2722 * been saved.
2723 *
2724 * @param {Object} state Global application state.
2725 *
2726 * @return {Object} Object of key value pairs comprising unsaved edits.
2727 */
2728 const getPostEdits = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2729 const postType = getCurrentPostType(state);
2730 const postId = getCurrentPostId(state);
2731 return select(external_wp_coreData_namespaceObject.store).getEntityRecordEdits('postType', postType, postId) || EMPTY_OBJECT;
2732 });
2733
2734 /**
2735 * Returns an attribute value of the saved post.
2736 *
2737 * @param {Object} state Global application state.
2738 * @param {string} attributeName Post attribute name.
2739 *
2740 * @return {*} Post attribute value.
2741 */
2742 function getCurrentPostAttribute(state, attributeName) {
2743 switch (attributeName) {
2744 case 'type':
2745 return getCurrentPostType(state);
2746 case 'id':
2747 return getCurrentPostId(state);
2748 default:
2749 const post = getCurrentPost(state);
2750 if (!post.hasOwnProperty(attributeName)) {
2751 break;
2752 }
2753 return getPostRawValue(post[attributeName]);
2754 }
2755 }
2756
2757 /**
2758 * Returns a single attribute of the post being edited, preferring the unsaved
2759 * edit if one exists, but merging with the attribute value for the last known
2760 * saved state of the post (this is needed for some nested attributes like meta).
2761 *
2762 * @param {Object} state Global application state.
2763 * @param {string} attributeName Post attribute name.
2764 *
2765 * @return {*} Post attribute value.
2766 */
2767 const getNestedEditedPostProperty = (0,external_wp_data_namespaceObject.createSelector)((state, attributeName) => {
2768 const edits = getPostEdits(state);
2769 if (!edits.hasOwnProperty(attributeName)) {
2770 return getCurrentPostAttribute(state, attributeName);
2771 }
2772 return {
2773 ...getCurrentPostAttribute(state, attributeName),
2774 ...edits[attributeName]
2775 };
2776 }, (state, attributeName) => [getCurrentPostAttribute(state, attributeName), getPostEdits(state)[attributeName]]);
2777
2778 /**
2779 * Returns a single attribute of the post being edited, preferring the unsaved
2780 * edit if one exists, but falling back to the attribute for the last known
2781 * saved state of the post.
2782 *
2783 * @param {Object} state Global application state.
2784 * @param {string} attributeName Post attribute name.
2785 *
2786 * @return {*} Post attribute value.
2787 */
2788 function getEditedPostAttribute(state, attributeName) {
2789 // Special cases.
2790 switch (attributeName) {
2791 case 'content':
2792 return getEditedPostContent(state);
2793 }
2794
2795 // Fall back to saved post value if not edited.
2796 const edits = getPostEdits(state);
2797 if (!edits.hasOwnProperty(attributeName)) {
2798 return getCurrentPostAttribute(state, attributeName);
2799 }
2800
2801 // Merge properties are objects which contain only the patch edit in state,
2802 // and thus must be merged with the current post attribute.
2803 if (EDIT_MERGE_PROPERTIES.has(attributeName)) {
2804 return getNestedEditedPostProperty(state, attributeName);
2805 }
2806 return edits[attributeName];
2807 }
2808
2809 /**
2810 * Returns an attribute value of the current autosave revision for a post, or
2811 * null if there is no autosave for the post.
2812 *
2813 * @deprecated since 5.6. Callers should use the `getAutosave( postType, postId, userId )` selector
2814 * from the '@wordpress/core-data' package and access properties on the returned
2815 * autosave object using getPostRawValue.
2816 *
2817 * @param {Object} state Global application state.
2818 * @param {string} attributeName Autosave attribute name.
2819 *
2820 * @return {*} Autosave attribute value.
2821 */
2822 const getAutosaveAttribute = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, attributeName) => {
2823 if (!AUTOSAVE_PROPERTIES.includes(attributeName) && attributeName !== 'preview_link') {
2824 return;
2825 }
2826 const postType = getCurrentPostType(state);
2827
2828 // Currently template autosaving is not supported.
2829 if (postType === 'wp_template') {
2830 return false;
2831 }
2832 const postId = getCurrentPostId(state);
2833 const currentUserId = select(external_wp_coreData_namespaceObject.store).getCurrentUser()?.id;
2834 const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId);
2835 if (autosave) {
2836 return getPostRawValue(autosave[attributeName]);
2837 }
2838 });
2839
2840 /**
2841 * Returns the current visibility of the post being edited, preferring the
2842 * unsaved value if different than the saved post. The return value is one of
2843 * "private", "password", or "public".
2844 *
2845 * @param {Object} state Global application state.
2846 *
2847 * @return {string} Post visibility.
2848 */
2849 function getEditedPostVisibility(state) {
2850 const status = getEditedPostAttribute(state, 'status');
2851 if (status === 'private') {
2852 return 'private';
2853 }
2854 const password = getEditedPostAttribute(state, 'password');
2855 if (password) {
2856 return 'password';
2857 }
2858 return 'public';
2859 }
2860
2861 /**
2862 * Returns true if post is pending review.
2863 *
2864 * @param {Object} state Global application state.
2865 *
2866 * @return {boolean} Whether current post is pending review.
2867 */
2868 function isCurrentPostPending(state) {
2869 return getCurrentPost(state).status === 'pending';
2870 }
2871
2872 /**
2873 * Return true if the current post has already been published.
2874 *
2875 * @param {Object} state Global application state.
2876 * @param {Object?} currentPost Explicit current post for bypassing registry selector.
2877 *
2878 * @return {boolean} Whether the post has been published.
2879 */
2880 function isCurrentPostPublished(state, currentPost) {
2881 const post = currentPost || getCurrentPost(state);
2882 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));
2883 }
2884
2885 /**
2886 * Returns true if post is already scheduled.
2887 *
2888 * @param {Object} state Global application state.
2889 *
2890 * @return {boolean} Whether current post is scheduled to be posted.
2891 */
2892 function isCurrentPostScheduled(state) {
2893 return getCurrentPost(state).status === 'future' && !isCurrentPostPublished(state);
2894 }
2895
2896 /**
2897 * Return true if the post being edited can be published.
2898 *
2899 * @param {Object} state Global application state.
2900 *
2901 * @return {boolean} Whether the post can been published.
2902 */
2903 function isEditedPostPublishable(state) {
2904 const post = getCurrentPost(state);
2905
2906 // TODO: Post being publishable should be superset of condition of post
2907 // being saveable. Currently this restriction is imposed at UI.
2908 //
2909 // See: <PostPublishButton /> (`isButtonEnabled` assigned by `isSaveable`).
2910
2911 return isEditedPostDirty(state) || ['publish', 'private', 'future'].indexOf(post.status) === -1;
2912 }
2913
2914 /**
2915 * Returns true if the post can be saved, or false otherwise. A post must
2916 * contain a title, an excerpt, or non-empty content to be valid for save.
2917 *
2918 * @param {Object} state Global application state.
2919 *
2920 * @return {boolean} Whether the post can be saved.
2921 */
2922 function isEditedPostSaveable(state) {
2923 if (isSavingPost(state)) {
2924 return false;
2925 }
2926
2927 // TODO: Post should not be saveable if not dirty. Cannot be added here at
2928 // this time since posts where meta boxes are present can be saved even if
2929 // the post is not dirty. Currently this restriction is imposed at UI, but
2930 // should be moved here.
2931 //
2932 // See: `isEditedPostPublishable` (includes `isEditedPostDirty` condition)
2933 // See: <PostSavedState /> (`forceIsDirty` prop)
2934 // See: <PostPublishButton /> (`forceIsDirty` prop)
2935 // See: https://github.com/WordPress/gutenberg/pull/4184.
2936
2937 return !!getEditedPostAttribute(state, 'title') || !!getEditedPostAttribute(state, 'excerpt') || !isEditedPostEmpty(state) || external_wp_element_namespaceObject.Platform.OS === 'native';
2938 }
2939
2940 /**
2941 * Returns true if the edited post has content. A post has content if it has at
2942 * least one saveable block or otherwise has a non-empty content property
2943 * assigned.
2944 *
2945 * @param {Object} state Global application state.
2946 *
2947 * @return {boolean} Whether post has content.
2948 */
2949 const isEditedPostEmpty = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
2950 // While the condition of truthy content string is sufficient to determine
2951 // emptiness, testing saveable blocks length is a trivial operation. Since
2952 // this function can be called frequently, optimize for the fast case as a
2953 // condition of the mere existence of blocks. Note that the value of edited
2954 // content takes precedent over block content, and must fall through to the
2955 // default logic.
2956 const postId = getCurrentPostId(state);
2957 const postType = getCurrentPostType(state);
2958 const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
2959 if (typeof record.content !== 'function') {
2960 return !record.content;
2961 }
2962 const blocks = getEditedPostAttribute(state, 'blocks');
2963 if (blocks.length === 0) {
2964 return true;
2965 }
2966
2967 // Pierce the abstraction of the serializer in knowing that blocks are
2968 // joined with newlines such that even if every individual block
2969 // produces an empty save result, the serialized content is non-empty.
2970 if (blocks.length > 1) {
2971 return false;
2972 }
2973
2974 // There are two conditions under which the optimization cannot be
2975 // assumed, and a fallthrough to getEditedPostContent must occur:
2976 //
2977 // 1. getBlocksForSerialization has special treatment in omitting a
2978 // single unmodified default block.
2979 // 2. Comment delimiters are omitted for a freeform or unregistered
2980 // block in its serialization. The freeform block specifically may
2981 // produce an empty string in its saved output.
2982 //
2983 // For all other content, the single block is assumed to make a post
2984 // non-empty, if only by virtue of its own comment delimiters.
2985 const blockName = blocks[0].name;
2986 if (blockName !== (0,external_wp_blocks_namespaceObject.getDefaultBlockName)() && blockName !== (0,external_wp_blocks_namespaceObject.getFreeformContentHandlerName)()) {
2987 return false;
2988 }
2989 return !getEditedPostContent(state);
2990 });
2991
2992 /**
2993 * Returns true if the post can be autosaved, or false otherwise.
2994 *
2995 * @param {Object} state Global application state.
2996 * @param {Object} autosave A raw autosave object from the REST API.
2997 *
2998 * @return {boolean} Whether the post can be autosaved.
2999 */
3000 const isEditedPostAutosaveable = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3001 // A post must contain a title, an excerpt, or non-empty content to be valid for autosaving.
3002 if (!isEditedPostSaveable(state)) {
3003 return false;
3004 }
3005
3006 // A post is not autosavable when there is a post autosave lock.
3007 if (isPostAutosavingLocked(state)) {
3008 return false;
3009 }
3010 const postType = getCurrentPostType(state);
3011
3012 // Currently template autosaving is not supported.
3013 if (postType === 'wp_template') {
3014 return false;
3015 }
3016 const postId = getCurrentPostId(state);
3017 const hasFetchedAutosave = select(external_wp_coreData_namespaceObject.store).hasFetchedAutosaves(postType, postId);
3018 const currentUserId = select(external_wp_coreData_namespaceObject.store).getCurrentUser()?.id;
3019
3020 // Disable reason - this line causes the side-effect of fetching the autosave
3021 // via a resolver, moving below the return would result in the autosave never
3022 // being fetched.
3023 // eslint-disable-next-line @wordpress/no-unused-vars-before-return
3024 const autosave = select(external_wp_coreData_namespaceObject.store).getAutosave(postType, postId, currentUserId);
3025
3026 // If any existing autosaves have not yet been fetched, this function is
3027 // unable to determine if the post is autosaveable, so return false.
3028 if (!hasFetchedAutosave) {
3029 return false;
3030 }
3031
3032 // If we don't already have an autosave, the post is autosaveable.
3033 if (!autosave) {
3034 return true;
3035 }
3036
3037 // To avoid an expensive content serialization, use the content dirtiness
3038 // flag in place of content field comparison against the known autosave.
3039 // This is not strictly accurate, and relies on a tolerance toward autosave
3040 // request failures for unnecessary saves.
3041 if (hasChangedContent(state)) {
3042 return true;
3043 }
3044
3045 // If title, excerpt, or meta have changed, the post is autosaveable.
3046 return ['title', 'excerpt', 'meta'].some(field => getPostRawValue(autosave[field]) !== getEditedPostAttribute(state, field));
3047 });
3048
3049 /**
3050 * Return true if the post being edited is being scheduled. Preferring the
3051 * unsaved status values.
3052 *
3053 * @param {Object} state Global application state.
3054 *
3055 * @return {boolean} Whether the post has been published.
3056 */
3057 function isEditedPostBeingScheduled(state) {
3058 const date = getEditedPostAttribute(state, 'date');
3059 // Offset the date by one minute (network latency).
3060 const checkedDate = new Date(Number((0,external_wp_date_namespaceObject.getDate)(date)) - ONE_MINUTE_IN_MS);
3061 return (0,external_wp_date_namespaceObject.isInTheFuture)(checkedDate);
3062 }
3063
3064 /**
3065 * Returns whether the current post should be considered to have a "floating"
3066 * date (i.e. that it would publish "Immediately" rather than at a set time).
3067 *
3068 * Unlike in the PHP backend, the REST API returns a full date string for posts
3069 * where the 0000-00-00T00:00:00 placeholder is present in the database. To
3070 * infer that a post is set to publish "Immediately" we check whether the date
3071 * and modified date are the same.
3072 *
3073 * @param {Object} state Editor state.
3074 *
3075 * @return {boolean} Whether the edited post has a floating date value.
3076 */
3077 function isEditedPostDateFloating(state) {
3078 const date = getEditedPostAttribute(state, 'date');
3079 const modified = getEditedPostAttribute(state, 'modified');
3080
3081 // This should be the status of the persisted post
3082 // It shouldn't use the "edited" status otherwise it breaks the
3083 // inferred post data floating status
3084 // See https://github.com/WordPress/gutenberg/issues/28083.
3085 const status = getCurrentPost(state).status;
3086 if (status === 'draft' || status === 'auto-draft' || status === 'pending') {
3087 return date === modified || date === null;
3088 }
3089 return false;
3090 }
3091
3092 /**
3093 * Returns true if the post is currently being deleted, or false otherwise.
3094 *
3095 * @param {Object} state Editor state.
3096 *
3097 * @return {boolean} Whether post is being deleted.
3098 */
3099 function isDeletingPost(state) {
3100 return !!state.deleting.pending;
3101 }
3102
3103 /**
3104 * Returns true if the post is currently being saved, or false otherwise.
3105 *
3106 * @param {Object} state Global application state.
3107 *
3108 * @return {boolean} Whether post is being saved.
3109 */
3110 function isSavingPost(state) {
3111 return !!state.saving.pending;
3112 }
3113
3114 /**
3115 * Returns true if non-post entities are currently being saved, or false otherwise.
3116 *
3117 * @param {Object} state Global application state.
3118 *
3119 * @return {boolean} Whether non-post entities are being saved.
3120 */
3121 const isSavingNonPostEntityChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3122 const entitiesBeingSaved = select(external_wp_coreData_namespaceObject.store).__experimentalGetEntitiesBeingSaved();
3123 const {
3124 type,
3125 id
3126 } = getCurrentPost(state);
3127 return entitiesBeingSaved.some(entityRecord => entityRecord.kind !== 'postType' || entityRecord.name !== type || entityRecord.key !== id);
3128 });
3129
3130 /**
3131 * Returns true if a previous post save was attempted successfully, or false
3132 * otherwise.
3133 *
3134 * @param {Object} state Global application state.
3135 *
3136 * @return {boolean} Whether the post was saved successfully.
3137 */
3138 const didPostSaveRequestSucceed = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3139 const postType = getCurrentPostType(state);
3140 const postId = getCurrentPostId(state);
3141 return !select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
3142 });
3143
3144 /**
3145 * Returns true if a previous post save was attempted but failed, or false
3146 * otherwise.
3147 *
3148 * @param {Object} state Global application state.
3149 *
3150 * @return {boolean} Whether the post save failed.
3151 */
3152 const didPostSaveRequestFail = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3153 const postType = getCurrentPostType(state);
3154 const postId = getCurrentPostId(state);
3155 return !!select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', postType, postId);
3156 });
3157
3158 /**
3159 * Returns true if the post is autosaving, or false otherwise.
3160 *
3161 * @param {Object} state Global application state.
3162 *
3163 * @return {boolean} Whether the post is autosaving.
3164 */
3165 function isAutosavingPost(state) {
3166 return isSavingPost(state) && Boolean(state.saving.options?.isAutosave);
3167 }
3168
3169 /**
3170 * Returns true if the post is being previewed, or false otherwise.
3171 *
3172 * @param {Object} state Global application state.
3173 *
3174 * @return {boolean} Whether the post is being previewed.
3175 */
3176 function isPreviewingPost(state) {
3177 return isSavingPost(state) && Boolean(state.saving.options?.isPreview);
3178 }
3179
3180 /**
3181 * Returns the post preview link
3182 *
3183 * @param {Object} state Global application state.
3184 *
3185 * @return {string | undefined} Preview Link.
3186 */
3187 function getEditedPostPreviewLink(state) {
3188 if (state.saving.pending || isSavingPost(state)) {
3189 return;
3190 }
3191 let previewLink = getAutosaveAttribute(state, 'preview_link');
3192 // Fix for issue: https://github.com/WordPress/gutenberg/issues/33616
3193 // If the post is draft, ignore the preview link from the autosave record,
3194 // because the preview could be a stale autosave if the post was switched from
3195 // published to draft.
3196 // See: https://github.com/WordPress/gutenberg/pull/37952.
3197 if (!previewLink || 'draft' === getCurrentPost(state).status) {
3198 previewLink = getEditedPostAttribute(state, 'link');
3199 if (previewLink) {
3200 previewLink = (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
3201 preview: true
3202 });
3203 }
3204 }
3205 const featuredImageId = getEditedPostAttribute(state, 'featured_media');
3206 if (previewLink && featuredImageId) {
3207 return (0,external_wp_url_namespaceObject.addQueryArgs)(previewLink, {
3208 _thumbnail_id: featuredImageId
3209 });
3210 }
3211 return previewLink;
3212 }
3213
3214 /**
3215 * Returns a suggested post format for the current post, inferred only if there
3216 * is a single block within the post and it is of a type known to match a
3217 * default post format. Returns null if the format cannot be determined.
3218 *
3219 * @return {?string} Suggested post format.
3220 */
3221 const getSuggestedPostFormat = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
3222 const blocks = select(external_wp_blockEditor_namespaceObject.store).getBlocks();
3223 if (blocks.length > 2) {
3224 return null;
3225 }
3226 let name;
3227 // If there is only one block in the content of the post grab its name
3228 // so we can derive a suitable post format from it.
3229 if (blocks.length === 1) {
3230 name = blocks[0].name;
3231 // Check for core/embed `video` and `audio` eligible suggestions.
3232 if (name === 'core/embed') {
3233 const provider = blocks[0].attributes?.providerNameSlug;
3234 if (['youtube', 'vimeo'].includes(provider)) {
3235 name = 'core/video';
3236 } else if (['spotify', 'soundcloud'].includes(provider)) {
3237 name = 'core/audio';
3238 }
3239 }
3240 }
3241
3242 // If there are two blocks in the content and the last one is a text blocks
3243 // grab the name of the first one to also suggest a post format from it.
3244 if (blocks.length === 2 && blocks[1].name === 'core/paragraph') {
3245 name = blocks[0].name;
3246 }
3247
3248 // We only convert to default post formats in core.
3249 switch (name) {
3250 case 'core/image':
3251 return 'image';
3252 case 'core/quote':
3253 case 'core/pullquote':
3254 return 'quote';
3255 case 'core/gallery':
3256 return 'gallery';
3257 case 'core/video':
3258 return 'video';
3259 case 'core/audio':
3260 return 'audio';
3261 default:
3262 return null;
3263 }
3264 });
3265
3266 /**
3267 * Returns the content of the post being edited.
3268 *
3269 * @param {Object} state Global application state.
3270 *
3271 * @return {string} Post content.
3272 */
3273 const getEditedPostContent = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
3274 const postId = getCurrentPostId(state);
3275 const postType = getCurrentPostType(state);
3276 const record = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
3277 if (record) {
3278 if (typeof record.content === 'function') {
3279 return record.content(record);
3280 } else if (record.blocks) {
3281 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
3282 } else if (record.content) {
3283 return record.content;
3284 }
3285 }
3286 return '';
3287 });
3288
3289 /**
3290 * Returns true if the post is being published, or false otherwise.
3291 *
3292 * @param {Object} state Global application state.
3293 *
3294 * @return {boolean} Whether post is being published.
3295 */
3296 function isPublishingPost(state) {
3297 return isSavingPost(state) && !isCurrentPostPublished(state) && getEditedPostAttribute(state, 'status') === 'publish';
3298 }
3299
3300 /**
3301 * Returns whether the permalink is editable or not.
3302 *
3303 * @param {Object} state Editor state.
3304 *
3305 * @return {boolean} Whether or not the permalink is editable.
3306 */
3307 function isPermalinkEditable(state) {
3308 const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
3309 return PERMALINK_POSTNAME_REGEX.test(permalinkTemplate);
3310 }
3311
3312 /**
3313 * Returns the permalink for the post.
3314 *
3315 * @param {Object} state Editor state.
3316 *
3317 * @return {?string} The permalink, or null if the post is not viewable.
3318 */
3319 function getPermalink(state) {
3320 const permalinkParts = getPermalinkParts(state);
3321 if (!permalinkParts) {
3322 return null;
3323 }
3324 const {
3325 prefix,
3326 postName,
3327 suffix
3328 } = permalinkParts;
3329 if (isPermalinkEditable(state)) {
3330 return prefix + postName + suffix;
3331 }
3332 return prefix;
3333 }
3334
3335 /**
3336 * Returns the slug for the post being edited, preferring a manually edited
3337 * value if one exists, then a sanitized version of the current post title, and
3338 * finally the post ID.
3339 *
3340 * @param {Object} state Editor state.
3341 *
3342 * @return {string} The current slug to be displayed in the editor
3343 */
3344 function getEditedPostSlug(state) {
3345 return getEditedPostAttribute(state, 'slug') || (0,external_wp_url_namespaceObject.cleanForSlug)(getEditedPostAttribute(state, 'title')) || getCurrentPostId(state);
3346 }
3347
3348 /**
3349 * Returns the permalink for a post, split into its three parts: the prefix,
3350 * the postName, and the suffix.
3351 *
3352 * @param {Object} state Editor state.
3353 *
3354 * @return {Object} An object containing the prefix, postName, and suffix for
3355 * the permalink, or null if the post is not viewable.
3356 */
3357 function getPermalinkParts(state) {
3358 const permalinkTemplate = getEditedPostAttribute(state, 'permalink_template');
3359 if (!permalinkTemplate) {
3360 return null;
3361 }
3362 const postName = getEditedPostAttribute(state, 'slug') || getEditedPostAttribute(state, 'generated_slug');
3363 const [prefix, suffix] = permalinkTemplate.split(PERMALINK_POSTNAME_REGEX);
3364 return {
3365 prefix,
3366 postName,
3367 suffix
3368 };
3369 }
3370
3371 /**
3372 * Returns whether the post is locked.
3373 *
3374 * @param {Object} state Global application state.
3375 *
3376 * @return {boolean} Is locked.
3377 */
3378 function isPostLocked(state) {
3379 return state.postLock.isLocked;
3380 }
3381
3382 /**
3383 * Returns whether post saving is locked.
3384 *
3385 * @param {Object} state Global application state.
3386 *
3387 * @return {boolean} Is locked.
3388 */
3389 function isPostSavingLocked(state) {
3390 return Object.keys(state.postSavingLock).length > 0;
3391 }
3392
3393 /**
3394 * Returns whether post autosaving is locked.
3395 *
3396 * @param {Object} state Global application state.
3397 *
3398 * @return {boolean} Is locked.
3399 */
3400 function isPostAutosavingLocked(state) {
3401 return Object.keys(state.postAutosavingLock).length > 0;
3402 }
3403
3404 /**
3405 * Returns whether the edition of the post has been taken over.
3406 *
3407 * @param {Object} state Global application state.
3408 *
3409 * @return {boolean} Is post lock takeover.
3410 */
3411 function isPostLockTakeover(state) {
3412 return state.postLock.isTakeover;
3413 }
3414
3415 /**
3416 * Returns details about the post lock user.
3417 *
3418 * @param {Object} state Global application state.
3419 *
3420 * @return {Object} A user object.
3421 */
3422 function getPostLockUser(state) {
3423 return state.postLock.user;
3424 }
3425
3426 /**
3427 * Returns the active post lock.
3428 *
3429 * @param {Object} state Global application state.
3430 *
3431 * @return {Object} The lock object.
3432 */
3433 function getActivePostLock(state) {
3434 return state.postLock.activePostLock;
3435 }
3436
3437 /**
3438 * Returns whether or not the user has the unfiltered_html capability.
3439 *
3440 * @param {Object} state Editor state.
3441 *
3442 * @return {boolean} Whether the user can or can't post unfiltered HTML.
3443 */
3444 function canUserUseUnfilteredHTML(state) {
3445 return Boolean(getCurrentPost(state)._links?.hasOwnProperty('wp:action-unfiltered-html'));
3446 }
3447
3448 /**
3449 * Returns whether the pre-publish panel should be shown
3450 * or skipped when the user clicks the "publish" button.
3451 *
3452 * @return {boolean} Whether the pre-publish panel should be shown or not.
3453 */
3454 const isPublishSidebarEnabled = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => !!select(external_wp_preferences_namespaceObject.store).get('core', 'isPublishSidebarEnabled'));
3455
3456 /**
3457 * Return the current block list.
3458 *
3459 * @param {Object} state
3460 * @return {Array} Block list.
3461 */
3462 const getEditorBlocks = (0,external_wp_data_namespaceObject.createSelector)(state => {
3463 return getEditedPostAttribute(state, 'blocks') || (0,external_wp_blocks_namespaceObject.parse)(getEditedPostContent(state));
3464 }, state => [getEditedPostAttribute(state, 'blocks'), getEditedPostContent(state)]);
3465
3466 /**
3467 * Returns true if the given panel was programmatically removed, or false otherwise.
3468 * All panels are not removed by default.
3469 *
3470 * @param {Object} state Global application state.
3471 * @param {string} panelName A string that identifies the panel.
3472 *
3473 * @return {boolean} Whether or not the panel is removed.
3474 */
3475 function isEditorPanelRemoved(state, panelName) {
3476 return state.removedPanels.includes(panelName);
3477 }
3478
3479 /**
3480 * Returns true if the given panel is enabled, or false otherwise. Panels are
3481 * enabled by default.
3482 *
3483 * @param {Object} state Global application state.
3484 * @param {string} panelName A string that identifies the panel.
3485 *
3486 * @return {boolean} Whether or not the panel is enabled.
3487 */
3488 const isEditorPanelEnabled = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, panelName) => {
3489 // For backward compatibility, we check edit-post
3490 // even though now this is in "editor" package.
3491 const inactivePanels = select(external_wp_preferences_namespaceObject.store).get('core', 'inactivePanels');
3492 return !isEditorPanelRemoved(state, panelName) && !inactivePanels?.includes(panelName);
3493 });
3494
3495 /**
3496 * Returns true if the given panel is open, or false otherwise. Panels are
3497 * closed by default.
3498 *
3499 * @param {Object} state Global application state.
3500 * @param {string} panelName A string that identifies the panel.
3501 *
3502 * @return {boolean} Whether or not the panel is open.
3503 */
3504 const isEditorPanelOpened = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, panelName) => {
3505 // For backward compatibility, we check edit-post
3506 // even though now this is in "editor" package.
3507 const openPanels = select(external_wp_preferences_namespaceObject.store).get('core', 'openPanels');
3508 return !!openPanels?.includes(panelName);
3509 });
3510
3511 /**
3512 * A block selection object.
3513 *
3514 * @typedef {Object} WPBlockSelection
3515 *
3516 * @property {string} clientId A block client ID.
3517 * @property {string} attributeKey A block attribute key.
3518 * @property {number} offset An attribute value offset, based on the rich
3519 * text value. See `wp.richText.create`.
3520 */
3521
3522 /**
3523 * Returns the current selection start.
3524 *
3525 * @param {Object} state
3526 * @return {WPBlockSelection} The selection start.
3527 *
3528 * @deprecated since Gutenberg 10.0.0.
3529 */
3530 function getEditorSelectionStart(state) {
3531 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", {
3532 since: '5.8',
3533 alternative: "select('core/editor').getEditorSelection"
3534 });
3535 return getEditedPostAttribute(state, 'selection')?.selectionStart;
3536 }
3537
3538 /**
3539 * Returns the current selection end.
3540 *
3541 * @param {Object} state
3542 * @return {WPBlockSelection} The selection end.
3543 *
3544 * @deprecated since Gutenberg 10.0.0.
3545 */
3546 function getEditorSelectionEnd(state) {
3547 external_wp_deprecated_default()("select('core/editor').getEditorSelectionStart", {
3548 since: '5.8',
3549 alternative: "select('core/editor').getEditorSelection"
3550 });
3551 return getEditedPostAttribute(state, 'selection')?.selectionEnd;
3552 }
3553
3554 /**
3555 * Returns the current selection.
3556 *
3557 * @param {Object} state
3558 * @return {WPBlockSelection} The selection end.
3559 */
3560 function getEditorSelection(state) {
3561 return getEditedPostAttribute(state, 'selection');
3562 }
3563
3564 /**
3565 * Is the editor ready
3566 *
3567 * @param {Object} state
3568 * @return {boolean} is Ready.
3569 */
3570 function __unstableIsEditorReady(state) {
3571 return !!state.postId;
3572 }
3573
3574 /**
3575 * Returns the post editor settings.
3576 *
3577 * @param {Object} state Editor state.
3578 *
3579 * @return {Object} The editor settings object.
3580 */
3581 function getEditorSettings(state) {
3582 return state.editorSettings;
3583 }
3584
3585 /**
3586 * Returns the post editor's rendering mode.
3587 *
3588 * @param {Object} state Editor state.
3589 *
3590 * @return {string} Rendering mode.
3591 */
3592 function getRenderingMode(state) {
3593 return state.renderingMode;
3594 }
3595
3596 /**
3597 * Returns the current editing canvas device type.
3598 *
3599 * @param {Object} state Global application state.
3600 *
3601 * @return {string} Device type.
3602 */
3603 function getDeviceType(state) {
3604 return state.deviceType;
3605 }
3606
3607 /**
3608 * Returns true if the list view is opened.
3609 *
3610 * @param {Object} state Global application state.
3611 *
3612 * @return {boolean} Whether the list view is opened.
3613 */
3614 function isListViewOpened(state) {
3615 return state.listViewPanel;
3616 }
3617
3618 /**
3619 * Returns true if the inserter is opened.
3620 *
3621 * @param {Object} state Global application state.
3622 *
3623 * @return {boolean} Whether the inserter is opened.
3624 */
3625 function isInserterOpened(state) {
3626 return !!state.blockInserterPanel;
3627 }
3628
3629 /**
3630 * Returns the current editing mode.
3631 *
3632 * @param {Object} state Global application state.
3633 *
3634 * @return {string} Editing mode.
3635 */
3636 const getEditorMode = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => () => {
3637 var _select$get;
3638 return (_select$get = select(external_wp_preferences_namespaceObject.store).get('core', 'editorMode')) !== null && _select$get !== void 0 ? _select$get : 'visual';
3639 });
3640
3641 /*
3642 * Backward compatibility
3643 */
3644
3645 /**
3646 * Returns state object prior to a specified optimist transaction ID, or `null`
3647 * if the transaction corresponding to the given ID cannot be found.
3648 *
3649 * @deprecated since Gutenberg 9.7.0.
3650 */
3651 function getStateBeforeOptimisticTransaction() {
3652 external_wp_deprecated_default()("select('core/editor').getStateBeforeOptimisticTransaction", {
3653 since: '5.7',
3654 hint: 'No state history is kept on this store anymore'
3655 });
3656 return null;
3657 }
3658 /**
3659 * Returns true if an optimistic transaction is pending commit, for which the
3660 * before state satisfies the given predicate function.
3661 *
3662 * @deprecated since Gutenberg 9.7.0.
3663 */
3664 function inSomeHistory() {
3665 external_wp_deprecated_default()("select('core/editor').inSomeHistory", {
3666 since: '5.7',
3667 hint: 'No state history is kept on this store anymore'
3668 });
3669 return false;
3670 }
3671 function getBlockEditorSelector(name) {
3672 return (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, ...args) => {
3673 external_wp_deprecated_default()("`wp.data.select( 'core/editor' )." + name + '`', {
3674 since: '5.3',
3675 alternative: "`wp.data.select( 'core/block-editor' )." + name + '`',
3676 version: '6.2'
3677 });
3678 return select(external_wp_blockEditor_namespaceObject.store)[name](...args);
3679 });
3680 }
3681
3682 /**
3683 * @see getBlockName in core/block-editor store.
3684 */
3685 const getBlockName = getBlockEditorSelector('getBlockName');
3686
3687 /**
3688 * @see isBlockValid in core/block-editor store.
3689 */
3690 const isBlockValid = getBlockEditorSelector('isBlockValid');
3691
3692 /**
3693 * @see getBlockAttributes in core/block-editor store.
3694 */
3695 const getBlockAttributes = getBlockEditorSelector('getBlockAttributes');
3696
3697 /**
3698 * @see getBlock in core/block-editor store.
3699 */
3700 const getBlock = getBlockEditorSelector('getBlock');
3701
3702 /**
3703 * @see getBlocks in core/block-editor store.
3704 */
3705 const getBlocks = getBlockEditorSelector('getBlocks');
3706
3707 /**
3708 * @see getClientIdsOfDescendants in core/block-editor store.
3709 */
3710 const getClientIdsOfDescendants = getBlockEditorSelector('getClientIdsOfDescendants');
3711
3712 /**
3713 * @see getClientIdsWithDescendants in core/block-editor store.
3714 */
3715 const getClientIdsWithDescendants = getBlockEditorSelector('getClientIdsWithDescendants');
3716
3717 /**
3718 * @see getGlobalBlockCount in core/block-editor store.
3719 */
3720 const getGlobalBlockCount = getBlockEditorSelector('getGlobalBlockCount');
3721
3722 /**
3723 * @see getBlocksByClientId in core/block-editor store.
3724 */
3725 const getBlocksByClientId = getBlockEditorSelector('getBlocksByClientId');
3726
3727 /**
3728 * @see getBlockCount in core/block-editor store.
3729 */
3730 const getBlockCount = getBlockEditorSelector('getBlockCount');
3731
3732 /**
3733 * @see getBlockSelectionStart in core/block-editor store.
3734 */
3735 const getBlockSelectionStart = getBlockEditorSelector('getBlockSelectionStart');
3736
3737 /**
3738 * @see getBlockSelectionEnd in core/block-editor store.
3739 */
3740 const getBlockSelectionEnd = getBlockEditorSelector('getBlockSelectionEnd');
3741
3742 /**
3743 * @see getSelectedBlockCount in core/block-editor store.
3744 */
3745 const getSelectedBlockCount = getBlockEditorSelector('getSelectedBlockCount');
3746
3747 /**
3748 * @see hasSelectedBlock in core/block-editor store.
3749 */
3750 const hasSelectedBlock = getBlockEditorSelector('hasSelectedBlock');
3751
3752 /**
3753 * @see getSelectedBlockClientId in core/block-editor store.
3754 */
3755 const getSelectedBlockClientId = getBlockEditorSelector('getSelectedBlockClientId');
3756
3757 /**
3758 * @see getSelectedBlock in core/block-editor store.
3759 */
3760 const getSelectedBlock = getBlockEditorSelector('getSelectedBlock');
3761
3762 /**
3763 * @see getBlockRootClientId in core/block-editor store.
3764 */
3765 const getBlockRootClientId = getBlockEditorSelector('getBlockRootClientId');
3766
3767 /**
3768 * @see getBlockHierarchyRootClientId in core/block-editor store.
3769 */
3770 const getBlockHierarchyRootClientId = getBlockEditorSelector('getBlockHierarchyRootClientId');
3771
3772 /**
3773 * @see getAdjacentBlockClientId in core/block-editor store.
3774 */
3775 const getAdjacentBlockClientId = getBlockEditorSelector('getAdjacentBlockClientId');
3776
3777 /**
3778 * @see getPreviousBlockClientId in core/block-editor store.
3779 */
3780 const getPreviousBlockClientId = getBlockEditorSelector('getPreviousBlockClientId');
3781
3782 /**
3783 * @see getNextBlockClientId in core/block-editor store.
3784 */
3785 const getNextBlockClientId = getBlockEditorSelector('getNextBlockClientId');
3786
3787 /**
3788 * @see getSelectedBlocksInitialCaretPosition in core/block-editor store.
3789 */
3790 const getSelectedBlocksInitialCaretPosition = getBlockEditorSelector('getSelectedBlocksInitialCaretPosition');
3791
3792 /**
3793 * @see getMultiSelectedBlockClientIds in core/block-editor store.
3794 */
3795 const getMultiSelectedBlockClientIds = getBlockEditorSelector('getMultiSelectedBlockClientIds');
3796
3797 /**
3798 * @see getMultiSelectedBlocks in core/block-editor store.
3799 */
3800 const getMultiSelectedBlocks = getBlockEditorSelector('getMultiSelectedBlocks');
3801
3802 /**
3803 * @see getFirstMultiSelectedBlockClientId in core/block-editor store.
3804 */
3805 const getFirstMultiSelectedBlockClientId = getBlockEditorSelector('getFirstMultiSelectedBlockClientId');
3806
3807 /**
3808 * @see getLastMultiSelectedBlockClientId in core/block-editor store.
3809 */
3810 const getLastMultiSelectedBlockClientId = getBlockEditorSelector('getLastMultiSelectedBlockClientId');
3811
3812 /**
3813 * @see isFirstMultiSelectedBlock in core/block-editor store.
3814 */
3815 const isFirstMultiSelectedBlock = getBlockEditorSelector('isFirstMultiSelectedBlock');
3816
3817 /**
3818 * @see isBlockMultiSelected in core/block-editor store.
3819 */
3820 const isBlockMultiSelected = getBlockEditorSelector('isBlockMultiSelected');
3821
3822 /**
3823 * @see isAncestorMultiSelected in core/block-editor store.
3824 */
3825 const isAncestorMultiSelected = getBlockEditorSelector('isAncestorMultiSelected');
3826
3827 /**
3828 * @see getMultiSelectedBlocksStartClientId in core/block-editor store.
3829 */
3830 const getMultiSelectedBlocksStartClientId = getBlockEditorSelector('getMultiSelectedBlocksStartClientId');
3831
3832 /**
3833 * @see getMultiSelectedBlocksEndClientId in core/block-editor store.
3834 */
3835 const getMultiSelectedBlocksEndClientId = getBlockEditorSelector('getMultiSelectedBlocksEndClientId');
3836
3837 /**
3838 * @see getBlockOrder in core/block-editor store.
3839 */
3840 const getBlockOrder = getBlockEditorSelector('getBlockOrder');
3841
3842 /**
3843 * @see getBlockIndex in core/block-editor store.
3844 */
3845 const getBlockIndex = getBlockEditorSelector('getBlockIndex');
3846
3847 /**
3848 * @see isBlockSelected in core/block-editor store.
3849 */
3850 const isBlockSelected = getBlockEditorSelector('isBlockSelected');
3851
3852 /**
3853 * @see hasSelectedInnerBlock in core/block-editor store.
3854 */
3855 const hasSelectedInnerBlock = getBlockEditorSelector('hasSelectedInnerBlock');
3856
3857 /**
3858 * @see isBlockWithinSelection in core/block-editor store.
3859 */
3860 const isBlockWithinSelection = getBlockEditorSelector('isBlockWithinSelection');
3861
3862 /**
3863 * @see hasMultiSelection in core/block-editor store.
3864 */
3865 const hasMultiSelection = getBlockEditorSelector('hasMultiSelection');
3866
3867 /**
3868 * @see isMultiSelecting in core/block-editor store.
3869 */
3870 const isMultiSelecting = getBlockEditorSelector('isMultiSelecting');
3871
3872 /**
3873 * @see isSelectionEnabled in core/block-editor store.
3874 */
3875 const isSelectionEnabled = getBlockEditorSelector('isSelectionEnabled');
3876
3877 /**
3878 * @see getBlockMode in core/block-editor store.
3879 */
3880 const getBlockMode = getBlockEditorSelector('getBlockMode');
3881
3882 /**
3883 * @see isTyping in core/block-editor store.
3884 */
3885 const isTyping = getBlockEditorSelector('isTyping');
3886
3887 /**
3888 * @see isCaretWithinFormattedText in core/block-editor store.
3889 */
3890 const isCaretWithinFormattedText = getBlockEditorSelector('isCaretWithinFormattedText');
3891
3892 /**
3893 * @see getBlockInsertionPoint in core/block-editor store.
3894 */
3895 const getBlockInsertionPoint = getBlockEditorSelector('getBlockInsertionPoint');
3896
3897 /**
3898 * @see isBlockInsertionPointVisible in core/block-editor store.
3899 */
3900 const isBlockInsertionPointVisible = getBlockEditorSelector('isBlockInsertionPointVisible');
3901
3902 /**
3903 * @see isValidTemplate in core/block-editor store.
3904 */
3905 const isValidTemplate = getBlockEditorSelector('isValidTemplate');
3906
3907 /**
3908 * @see getTemplate in core/block-editor store.
3909 */
3910 const getTemplate = getBlockEditorSelector('getTemplate');
3911
3912 /**
3913 * @see getTemplateLock in core/block-editor store.
3914 */
3915 const getTemplateLock = getBlockEditorSelector('getTemplateLock');
3916
3917 /**
3918 * @see canInsertBlockType in core/block-editor store.
3919 */
3920 const canInsertBlockType = getBlockEditorSelector('canInsertBlockType');
3921
3922 /**
3923 * @see getInserterItems in core/block-editor store.
3924 */
3925 const getInserterItems = getBlockEditorSelector('getInserterItems');
3926
3927 /**
3928 * @see hasInserterItems in core/block-editor store.
3929 */
3930 const hasInserterItems = getBlockEditorSelector('hasInserterItems');
3931
3932 /**
3933 * @see getBlockListSettings in core/block-editor store.
3934 */
3935 const getBlockListSettings = getBlockEditorSelector('getBlockListSettings');
3936
3937 /**
3938 * Returns the default template types.
3939 *
3940 * @param {Object} state Global application state.
3941 *
3942 * @return {Object} The template types.
3943 */
3944 function __experimentalGetDefaultTemplateTypes(state) {
3945 return getEditorSettings(state)?.defaultTemplateTypes;
3946 }
3947
3948 /**
3949 * Returns the default template part areas.
3950 *
3951 * @param {Object} state Global application state.
3952 *
3953 * @return {Array} The template part areas.
3954 */
3955 const __experimentalGetDefaultTemplatePartAreas = (0,external_wp_data_namespaceObject.createSelector)(state => {
3956 var _getEditorSettings$de;
3957 const areas = (_getEditorSettings$de = getEditorSettings(state)?.defaultTemplatePartAreas) !== null && _getEditorSettings$de !== void 0 ? _getEditorSettings$de : [];
3958 return areas.map(item => {
3959 return {
3960 ...item,
3961 icon: getTemplatePartIcon(item.icon)
3962 };
3963 });
3964 }, state => [getEditorSettings(state)?.defaultTemplatePartAreas]);
3965
3966 /**
3967 * Returns a default template type searched by slug.
3968 *
3969 * @param {Object} state Global application state.
3970 * @param {string} slug The template type slug.
3971 *
3972 * @return {Object} The template type.
3973 */
3974 const __experimentalGetDefaultTemplateType = (0,external_wp_data_namespaceObject.createSelector)((state, slug) => {
3975 var _Object$values$find;
3976 const templateTypes = __experimentalGetDefaultTemplateTypes(state);
3977 if (!templateTypes) {
3978 return EMPTY_OBJECT;
3979 }
3980 return (_Object$values$find = Object.values(templateTypes).find(type => type.slug === slug)) !== null && _Object$values$find !== void 0 ? _Object$values$find : EMPTY_OBJECT;
3981 }, state => [__experimentalGetDefaultTemplateTypes(state)]);
3982
3983 /**
3984 * Given a template entity, return information about it which is ready to be
3985 * rendered, such as the title, description, and icon.
3986 *
3987 * @param {Object} state Global application state.
3988 * @param {Object} template The template for which we need information.
3989 * @return {Object} Information about the template, including title, description, and icon.
3990 */
3991 const __experimentalGetTemplateInfo = (0,external_wp_data_namespaceObject.createSelector)((state, template) => {
3992 if (!template) {
3993 return EMPTY_OBJECT;
3994 }
3995 const {
3996 description,
3997 slug,
3998 title,
3999 area
4000 } = template;
4001 const {
4002 title: defaultTitle,
4003 description: defaultDescription
4004 } = __experimentalGetDefaultTemplateType(state, slug);
4005 const templateTitle = typeof title === 'string' ? title : title?.rendered;
4006 const templateDescription = typeof description === 'string' ? description : description?.raw;
4007 const templateIcon = __experimentalGetDefaultTemplatePartAreas(state).find(item => area === item.area)?.icon || library_layout;
4008 return {
4009 title: templateTitle && templateTitle !== slug ? templateTitle : defaultTitle || slug,
4010 description: templateDescription || defaultDescription,
4011 icon: templateIcon
4012 };
4013 }, state => [__experimentalGetDefaultTemplateTypes(state), __experimentalGetDefaultTemplatePartAreas(state)]);
4014
4015 /**
4016 * Returns a post type label depending on the current post.
4017 *
4018 * @param {Object} state Global application state.
4019 *
4020 * @return {string|undefined} The post type label if available, otherwise undefined.
4021 */
4022 const getPostTypeLabel = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => state => {
4023 const currentPostType = getCurrentPostType(state);
4024 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(currentPostType);
4025 // Disable reason: Post type labels object is shaped like this.
4026 // eslint-disable-next-line camelcase
4027 return postType?.labels?.singular_name;
4028 });
4029
4030 /**
4031 * Returns true if the publish sidebar is opened.
4032 *
4033 * @param {Object} state Global application state
4034 *
4035 * @return {boolean} Whether the publish sidebar is open.
4036 */
4037 function isPublishSidebarOpened(state) {
4038 return state.publishSidebarActive;
4039 }
4040
4041 ;// CONCATENATED MODULE: external ["wp","a11y"]
4042 const external_wp_a11y_namespaceObject = window["wp"]["a11y"];
4043 ;// CONCATENATED MODULE: external ["wp","apiFetch"]
4044 const external_wp_apiFetch_namespaceObject = window["wp"]["apiFetch"];
4045 var external_wp_apiFetch_default = /*#__PURE__*/__webpack_require__.n(external_wp_apiFetch_namespaceObject);
4046 ;// CONCATENATED MODULE: external ["wp","notices"]
4047 const external_wp_notices_namespaceObject = window["wp"]["notices"];
4048 ;// CONCATENATED MODULE: external ["wp","i18n"]
4049 const external_wp_i18n_namespaceObject = window["wp"]["i18n"];
4050 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/local-autosave.js
4051 /**
4052 * Function returning a sessionStorage key to set or retrieve a given post's
4053 * automatic session backup.
4054 *
4055 * Keys are crucially prefixed with 'wp-autosave-' so that wp-login.php's
4056 * `loggedout` handler can clear sessionStorage of any user-private content.
4057 *
4058 * @see https://github.com/WordPress/wordpress-develop/blob/6dad32d2aed47e6c0cf2aee8410645f6d7aba6bd/src/wp-login.php#L103
4059 *
4060 * @param {string} postId Post ID.
4061 * @param {boolean} isPostNew Whether post new.
4062 *
4063 * @return {string} sessionStorage key
4064 */
4065 function postKey(postId, isPostNew) {
4066 return `wp-autosave-block-editor-post-${isPostNew ? 'auto-draft' : postId}`;
4067 }
4068 function localAutosaveGet(postId, isPostNew) {
4069 return window.sessionStorage.getItem(postKey(postId, isPostNew));
4070 }
4071 function localAutosaveSet(postId, isPostNew, title, content, excerpt) {
4072 window.sessionStorage.setItem(postKey(postId, isPostNew), JSON.stringify({
4073 post_title: title,
4074 content,
4075 excerpt
4076 }));
4077 }
4078 function localAutosaveClear(postId, isPostNew) {
4079 window.sessionStorage.removeItem(postKey(postId, isPostNew));
4080 }
4081
4082 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/utils/notice-builder.js
4083 /**
4084 * WordPress dependencies
4085 */
4086
4087
4088 /**
4089 * Internal dependencies
4090 */
4091
4092
4093 /**
4094 * Builds the arguments for a success notification dispatch.
4095 *
4096 * @param {Object} data Incoming data to build the arguments from.
4097 *
4098 * @return {Array} Arguments for dispatch. An empty array signals no
4099 * notification should be sent.
4100 */
4101 function getNotificationArgumentsForSaveSuccess(data) {
4102 var _postType$viewable;
4103 const {
4104 previousPost,
4105 post,
4106 postType
4107 } = data;
4108 // Autosaves are neither shown a notice nor redirected.
4109 if (data.options?.isAutosave) {
4110 return [];
4111 }
4112 const publishStatus = ['publish', 'private', 'future'];
4113 const isPublished = publishStatus.includes(previousPost.status);
4114 const willPublish = publishStatus.includes(post.status);
4115 const willTrash = post.status === 'trash' && previousPost.status !== 'trash';
4116 let noticeMessage;
4117 let shouldShowLink = (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false;
4118 let isDraft;
4119
4120 // Always should a notice, which will be spoken for accessibility.
4121 if (willTrash) {
4122 noticeMessage = postType.labels.item_trashed;
4123 shouldShowLink = false;
4124 } else if (!isPublished && !willPublish) {
4125 // If saving a non-published post, don't show notice.
4126 noticeMessage = (0,external_wp_i18n_namespaceObject.__)('Draft saved.');
4127 isDraft = true;
4128 } else if (isPublished && !willPublish) {
4129 // If undoing publish status, show specific notice.
4130 noticeMessage = postType.labels.item_reverted_to_draft;
4131 shouldShowLink = false;
4132 } else if (!isPublished && willPublish) {
4133 // If publishing or scheduling a post, show the corresponding
4134 // publish message.
4135 noticeMessage = {
4136 publish: postType.labels.item_published,
4137 private: postType.labels.item_published_privately,
4138 future: postType.labels.item_scheduled
4139 }[post.status];
4140 } else {
4141 // Generic fallback notice.
4142 noticeMessage = postType.labels.item_updated;
4143 }
4144 const actions = [];
4145 if (shouldShowLink) {
4146 actions.push({
4147 label: isDraft ? (0,external_wp_i18n_namespaceObject.__)('View Preview') : postType.labels.view_item,
4148 url: post.link
4149 });
4150 }
4151 return [noticeMessage, {
4152 id: SAVE_POST_NOTICE_ID,
4153 type: 'snackbar',
4154 actions
4155 }];
4156 }
4157
4158 /**
4159 * Builds the fail notification arguments for dispatch.
4160 *
4161 * @param {Object} data Incoming data to build the arguments with.
4162 *
4163 * @return {Array} Arguments for dispatch. An empty array signals no
4164 * notification should be sent.
4165 */
4166 function getNotificationArgumentsForSaveFail(data) {
4167 const {
4168 post,
4169 edits,
4170 error
4171 } = data;
4172 if (error && 'rest_autosave_no_changes' === error.code) {
4173 // Autosave requested a new autosave, but there were no changes. This shouldn't
4174 // result in an error notice for the user.
4175 return [];
4176 }
4177 const publishStatus = ['publish', 'private', 'future'];
4178 const isPublished = publishStatus.indexOf(post.status) !== -1;
4179 // If the post was being published, we show the corresponding publish error message
4180 // Unless we publish an "updating failed" message.
4181 const messages = {
4182 publish: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'),
4183 private: (0,external_wp_i18n_namespaceObject.__)('Publishing failed.'),
4184 future: (0,external_wp_i18n_namespaceObject.__)('Scheduling failed.')
4185 };
4186 let noticeMessage = !isPublished && publishStatus.indexOf(edits.status) !== -1 ? messages[edits.status] : (0,external_wp_i18n_namespaceObject.__)('Updating failed.');
4187
4188 // Check if message string contains HTML. Notice text is currently only
4189 // supported as plaintext, and stripping the tags may muddle the meaning.
4190 if (error.message && !/<\/?[^>]*>/.test(error.message)) {
4191 noticeMessage = [noticeMessage, error.message].join(' ');
4192 }
4193 return [noticeMessage, {
4194 id: SAVE_POST_NOTICE_ID
4195 }];
4196 }
4197
4198 /**
4199 * Builds the trash fail notification arguments for dispatch.
4200 *
4201 * @param {Object} data
4202 *
4203 * @return {Array} Arguments for dispatch.
4204 */
4205 function getNotificationArgumentsForTrashFail(data) {
4206 return [data.error.message && data.error.code !== 'unknown_error' ? data.error.message : (0,external_wp_i18n_namespaceObject.__)('Trashing failed'), {
4207 id: TRASH_POST_NOTICE_ID
4208 }];
4209 }
4210
4211 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/actions.js
4212 /**
4213 * WordPress dependencies
4214 */
4215
4216
4217
4218
4219
4220
4221
4222
4223
4224
4225
4226 /**
4227 * Internal dependencies
4228 */
4229
4230
4231
4232
4233 /**
4234 * Returns an action generator used in signalling that editor has initialized with
4235 * the specified post object and editor settings.
4236 *
4237 * @param {Object} post Post object.
4238 * @param {Object} edits Initial edited attributes object.
4239 * @param {Array?} template Block Template.
4240 */
4241 const setupEditor = (post, edits, template) => ({
4242 dispatch
4243 }) => {
4244 dispatch.setEditedPost(post.type, post.id);
4245 // Apply a template for new posts only, if exists.
4246 const isNewPost = post.status === 'auto-draft';
4247 if (isNewPost && template) {
4248 // In order to ensure maximum of a single parse during setup, edits are
4249 // included as part of editor setup action. Assume edited content as
4250 // canonical if provided, falling back to post.
4251 let content;
4252 if ('content' in edits) {
4253 content = edits.content;
4254 } else {
4255 content = post.content.raw;
4256 }
4257 let blocks = (0,external_wp_blocks_namespaceObject.parse)(content);
4258 blocks = (0,external_wp_blocks_namespaceObject.synchronizeBlocksWithTemplate)(blocks, template);
4259 dispatch.resetEditorBlocks(blocks, {
4260 __unstableShouldCreateUndoLevel: false
4261 });
4262 }
4263 if (edits && Object.values(edits).some(([key, edit]) => {
4264 var _post$key$raw;
4265 return edit !== ((_post$key$raw = post[key]?.raw) !== null && _post$key$raw !== void 0 ? _post$key$raw : post[key]);
4266 })) {
4267 dispatch.editPost(edits);
4268 }
4269 };
4270
4271 /**
4272 * Returns an action object signalling that the editor is being destroyed and
4273 * that any necessary state or side-effect cleanup should occur.
4274 *
4275 * @deprecated
4276 *
4277 * @return {Object} Action object.
4278 */
4279 function __experimentalTearDownEditor() {
4280 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).__experimentalTearDownEditor", {
4281 since: '6.5'
4282 });
4283 return {
4284 type: 'DO_NOTHING'
4285 };
4286 }
4287
4288 /**
4289 * Returns an action object used in signalling that the latest version of the
4290 * post has been received, either by initialization or save.
4291 *
4292 * @deprecated Since WordPress 6.0.
4293 */
4294 function resetPost() {
4295 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).resetPost", {
4296 since: '6.0',
4297 version: '6.3',
4298 alternative: 'Initialize the editor with the setupEditorState action'
4299 });
4300 return {
4301 type: 'DO_NOTHING'
4302 };
4303 }
4304
4305 /**
4306 * Returns an action object used in signalling that a patch of updates for the
4307 * latest version of the post have been received.
4308 *
4309 * @return {Object} Action object.
4310 * @deprecated since Gutenberg 9.7.0.
4311 */
4312 function updatePost() {
4313 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).updatePost", {
4314 since: '5.7',
4315 alternative: 'Use the core entities store instead'
4316 });
4317 return {
4318 type: 'DO_NOTHING'
4319 };
4320 }
4321
4322 /**
4323 * Setup the editor state.
4324 *
4325 * @deprecated
4326 *
4327 * @param {Object} post Post object.
4328 */
4329 function setupEditorState(post) {
4330 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).setupEditorState", {
4331 since: '6.5',
4332 alternative: "wp.data.dispatch( 'core/editor' ).setEditedPost"
4333 });
4334 return setEditedPost(post.type, post.id);
4335 }
4336
4337 /**
4338 * Returns an action that sets the current post Type and post ID.
4339 *
4340 * @param {string} postType Post Type.
4341 * @param {string} postId Post ID.
4342 *
4343 * @return {Object} Action object.
4344 */
4345 function setEditedPost(postType, postId) {
4346 return {
4347 type: 'SET_EDITED_POST',
4348 postType,
4349 postId
4350 };
4351 }
4352
4353 /**
4354 * Returns an action object used in signalling that attributes of the post have
4355 * been edited.
4356 *
4357 * @param {Object} edits Post attributes to edit.
4358 * @param {Object} options Options for the edit.
4359 */
4360 const editPost = (edits, options) => ({
4361 select,
4362 registry
4363 }) => {
4364 const {
4365 id,
4366 type
4367 } = select.getCurrentPost();
4368 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', type, id, edits, options);
4369 };
4370
4371 /**
4372 * Action for saving the current post in the editor.
4373 *
4374 * @param {Object} options
4375 */
4376 const savePost = (options = {}) => async ({
4377 select,
4378 dispatch,
4379 registry
4380 }) => {
4381 if (!select.isEditedPostSaveable()) {
4382 return;
4383 }
4384 const content = select.getEditedPostContent();
4385 if (!options.isAutosave) {
4386 dispatch.editPost({
4387 content
4388 }, {
4389 undoIgnore: true
4390 });
4391 }
4392 const previousRecord = select.getCurrentPost();
4393 const edits = {
4394 id: previousRecord.id,
4395 ...registry.select(external_wp_coreData_namespaceObject.store).getEntityRecordNonTransientEdits('postType', previousRecord.type, previousRecord.id),
4396 content
4397 };
4398 dispatch({
4399 type: 'REQUEST_POST_UPDATE_START',
4400 options
4401 });
4402 await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', previousRecord.type, edits, options);
4403 let error = registry.select(external_wp_coreData_namespaceObject.store).getLastEntitySaveError('postType', previousRecord.type, previousRecord.id);
4404 if (!error) {
4405 await (0,external_wp_hooks_namespaceObject.applyFilters)('editor.__unstableSavePost', Promise.resolve(), options).catch(err => {
4406 error = err;
4407 });
4408 }
4409 dispatch({
4410 type: 'REQUEST_POST_UPDATE_FINISH',
4411 options
4412 });
4413 if (error) {
4414 const args = getNotificationArgumentsForSaveFail({
4415 post: previousRecord,
4416 edits,
4417 error
4418 });
4419 if (args.length) {
4420 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...args);
4421 }
4422 } else {
4423 const updatedRecord = select.getCurrentPost();
4424 const args = getNotificationArgumentsForSaveSuccess({
4425 previousPost: previousRecord,
4426 post: updatedRecord,
4427 postType: await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(updatedRecord.type),
4428 options
4429 });
4430 if (args.length) {
4431 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(...args);
4432 }
4433 // Make sure that any edits after saving create an undo level and are
4434 // considered for change detection.
4435 if (!options.isAutosave) {
4436 registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableMarkLastChangeAsPersistent();
4437 }
4438 }
4439 };
4440
4441 /**
4442 * Action for refreshing the current post.
4443 *
4444 * @deprecated Since WordPress 6.0.
4445 */
4446 function refreshPost() {
4447 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).refreshPost", {
4448 since: '6.0',
4449 version: '6.3',
4450 alternative: 'Use the core entities store instead'
4451 });
4452 return {
4453 type: 'DO_NOTHING'
4454 };
4455 }
4456
4457 /**
4458 * Action for trashing the current post in the editor.
4459 */
4460 const trashPost = () => async ({
4461 select,
4462 dispatch,
4463 registry
4464 }) => {
4465 const postTypeSlug = select.getCurrentPostType();
4466 const postType = await registry.resolveSelect(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
4467 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(TRASH_POST_NOTICE_ID);
4468 const {
4469 rest_base: restBase,
4470 rest_namespace: restNamespace = 'wp/v2'
4471 } = postType;
4472 dispatch({
4473 type: 'REQUEST_POST_DELETE_START'
4474 });
4475 try {
4476 const post = select.getCurrentPost();
4477 await external_wp_apiFetch_default()({
4478 path: `/${restNamespace}/${restBase}/${post.id}`,
4479 method: 'DELETE'
4480 });
4481 await dispatch.savePost();
4482 } catch (error) {
4483 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(...getNotificationArgumentsForTrashFail({
4484 error
4485 }));
4486 }
4487 dispatch({
4488 type: 'REQUEST_POST_DELETE_FINISH'
4489 });
4490 };
4491
4492 /**
4493 * Action that autosaves the current post. This
4494 * includes server-side autosaving (default) and client-side (a.k.a. local)
4495 * autosaving (e.g. on the Web, the post might be committed to Session
4496 * Storage).
4497 *
4498 * @param {Object?} options Extra flags to identify the autosave.
4499 */
4500 const autosave = ({
4501 local = false,
4502 ...options
4503 } = {}) => async ({
4504 select,
4505 dispatch
4506 }) => {
4507 const post = select.getCurrentPost();
4508
4509 // Currently template autosaving is not supported.
4510 if (post.type === 'wp_template') {
4511 return;
4512 }
4513 if (local) {
4514 const isPostNew = select.isEditedPostNew();
4515 const title = select.getEditedPostAttribute('title');
4516 const content = select.getEditedPostAttribute('content');
4517 const excerpt = select.getEditedPostAttribute('excerpt');
4518 localAutosaveSet(post.id, isPostNew, title, content, excerpt);
4519 } else {
4520 await dispatch.savePost({
4521 isAutosave: true,
4522 ...options
4523 });
4524 }
4525 };
4526 const __unstableSaveForPreview = ({
4527 forceIsAutosaveable
4528 } = {}) => async ({
4529 select,
4530 dispatch
4531 }) => {
4532 if ((forceIsAutosaveable || select.isEditedPostAutosaveable()) && !select.isPostLocked()) {
4533 const isDraft = ['draft', 'auto-draft'].includes(select.getEditedPostAttribute('status'));
4534 if (isDraft) {
4535 await dispatch.savePost({
4536 isPreview: true
4537 });
4538 } else {
4539 await dispatch.autosave({
4540 isPreview: true
4541 });
4542 }
4543 }
4544 return select.getEditedPostPreviewLink();
4545 };
4546
4547 /**
4548 * Action that restores last popped state in undo history.
4549 */
4550 const redo = () => ({
4551 registry
4552 }) => {
4553 registry.dispatch(external_wp_coreData_namespaceObject.store).redo();
4554 };
4555
4556 /**
4557 * Action that pops a record from undo history and undoes the edit.
4558 */
4559 const undo = () => ({
4560 registry
4561 }) => {
4562 registry.dispatch(external_wp_coreData_namespaceObject.store).undo();
4563 };
4564
4565 /**
4566 * Action that creates an undo history record.
4567 *
4568 * @deprecated Since WordPress 6.0
4569 */
4570 function createUndoLevel() {
4571 external_wp_deprecated_default()("wp.data.dispatch( 'core/editor' ).createUndoLevel", {
4572 since: '6.0',
4573 version: '6.3',
4574 alternative: 'Use the core entities store instead'
4575 });
4576 return {
4577 type: 'DO_NOTHING'
4578 };
4579 }
4580
4581 /**
4582 * Action that locks the editor.
4583 *
4584 * @param {Object} lock Details about the post lock status, user, and nonce.
4585 * @return {Object} Action object.
4586 */
4587 function updatePostLock(lock) {
4588 return {
4589 type: 'UPDATE_POST_LOCK',
4590 lock
4591 };
4592 }
4593
4594 /**
4595 * Enable the publish sidebar.
4596 */
4597 const enablePublishSidebar = () => ({
4598 registry
4599 }) => {
4600 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'isPublishSidebarEnabled', true);
4601 };
4602
4603 /**
4604 * Disables the publish sidebar.
4605 */
4606 const disablePublishSidebar = () => ({
4607 registry
4608 }) => {
4609 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'isPublishSidebarEnabled', false);
4610 };
4611
4612 /**
4613 * Action that locks post saving.
4614 *
4615 * @param {string} lockName The lock name.
4616 *
4617 * @example
4618 * ```
4619 * const { subscribe } = wp.data;
4620 *
4621 * const initialPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
4622 *
4623 * // Only allow publishing posts that are set to a future date.
4624 * if ( 'publish' !== initialPostStatus ) {
4625 *
4626 * // Track locking.
4627 * let locked = false;
4628 *
4629 * // Watch for the publish event.
4630 * let unssubscribe = subscribe( () => {
4631 * const currentPostStatus = wp.data.select( 'core/editor' ).getEditedPostAttribute( 'status' );
4632 * if ( 'publish' !== currentPostStatus ) {
4633 *
4634 * // Compare the post date to the current date, lock the post if the date isn't in the future.
4635 * const postDate = new Date( wp.data.select( 'core/editor' ).getEditedPostAttribute( 'date' ) );
4636 * const currentDate = new Date();
4637 * if ( postDate.getTime() <= currentDate.getTime() ) {
4638 * if ( ! locked ) {
4639 * locked = true;
4640 * wp.data.dispatch( 'core/editor' ).lockPostSaving( 'futurelock' );
4641 * }
4642 * } else {
4643 * if ( locked ) {
4644 * locked = false;
4645 * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'futurelock' );
4646 * }
4647 * }
4648 * }
4649 * } );
4650 * }
4651 * ```
4652 *
4653 * @return {Object} Action object
4654 */
4655 function lockPostSaving(lockName) {
4656 return {
4657 type: 'LOCK_POST_SAVING',
4658 lockName
4659 };
4660 }
4661
4662 /**
4663 * Action that unlocks post saving.
4664 *
4665 * @param {string} lockName The lock name.
4666 *
4667 * @example
4668 * ```
4669 * // Unlock post saving with the lock key `mylock`:
4670 * wp.data.dispatch( 'core/editor' ).unlockPostSaving( 'mylock' );
4671 * ```
4672 *
4673 * @return {Object} Action object
4674 */
4675 function unlockPostSaving(lockName) {
4676 return {
4677 type: 'UNLOCK_POST_SAVING',
4678 lockName
4679 };
4680 }
4681
4682 /**
4683 * Action that locks post autosaving.
4684 *
4685 * @param {string} lockName The lock name.
4686 *
4687 * @example
4688 * ```
4689 * // Lock post autosaving with the lock key `mylock`:
4690 * wp.data.dispatch( 'core/editor' ).lockPostAutosaving( 'mylock' );
4691 * ```
4692 *
4693 * @return {Object} Action object
4694 */
4695 function lockPostAutosaving(lockName) {
4696 return {
4697 type: 'LOCK_POST_AUTOSAVING',
4698 lockName
4699 };
4700 }
4701
4702 /**
4703 * Action that unlocks post autosaving.
4704 *
4705 * @param {string} lockName The lock name.
4706 *
4707 * @example
4708 * ```
4709 * // Unlock post saving with the lock key `mylock`:
4710 * wp.data.dispatch( 'core/editor' ).unlockPostAutosaving( 'mylock' );
4711 * ```
4712 *
4713 * @return {Object} Action object
4714 */
4715 function unlockPostAutosaving(lockName) {
4716 return {
4717 type: 'UNLOCK_POST_AUTOSAVING',
4718 lockName
4719 };
4720 }
4721
4722 /**
4723 * Returns an action object used to signal that the blocks have been updated.
4724 *
4725 * @param {Array} blocks Block Array.
4726 * @param {?Object} options Optional options.
4727 */
4728 const resetEditorBlocks = (blocks, options = {}) => ({
4729 select,
4730 dispatch,
4731 registry
4732 }) => {
4733 const {
4734 __unstableShouldCreateUndoLevel,
4735 selection
4736 } = options;
4737 const edits = {
4738 blocks,
4739 selection
4740 };
4741 if (__unstableShouldCreateUndoLevel !== false) {
4742 const {
4743 id,
4744 type
4745 } = select.getCurrentPost();
4746 const noChange = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', type, id).blocks === edits.blocks;
4747 if (noChange) {
4748 registry.dispatch(external_wp_coreData_namespaceObject.store).__unstableCreateUndoLevel('postType', type, id);
4749 return;
4750 }
4751
4752 // We create a new function here on every persistent edit
4753 // to make sure the edit makes the post dirty and creates
4754 // a new undo level.
4755 edits.content = ({
4756 blocks: blocksForSerialization = []
4757 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
4758 }
4759 dispatch.editPost(edits);
4760 };
4761
4762 /*
4763 * Returns an action object used in signalling that the post editor settings have been updated.
4764 *
4765 * @param {Object} settings Updated settings
4766 *
4767 * @return {Object} Action object
4768 */
4769 function updateEditorSettings(settings) {
4770 return {
4771 type: 'UPDATE_EDITOR_SETTINGS',
4772 settings
4773 };
4774 }
4775
4776 /**
4777 * Returns an action used to set the rendering mode of the post editor. We support multiple rendering modes:
4778 *
4779 * - `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.
4780 * - `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.
4781 *
4782 * @param {string} mode Mode (one of 'post-only' or 'template-locked').
4783 */
4784 const setRenderingMode = mode => ({
4785 dispatch,
4786 registry,
4787 select
4788 }) => {
4789 if (select.__unstableIsEditorReady()) {
4790 // We clear the block selection but we also need to clear the selection from the core store.
4791 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
4792 dispatch.editPost({
4793 selection: undefined
4794 }, {
4795 undoIgnore: true
4796 });
4797 }
4798 dispatch({
4799 type: 'SET_RENDERING_MODE',
4800 mode
4801 });
4802 };
4803
4804 /**
4805 * Action that changes the width of the editing canvas.
4806 *
4807 * @param {string} deviceType
4808 *
4809 * @return {Object} Action object.
4810 */
4811 function setDeviceType(deviceType) {
4812 return {
4813 type: 'SET_DEVICE_TYPE',
4814 deviceType
4815 };
4816 }
4817
4818 /**
4819 * Returns an action object used to enable or disable a panel in the editor.
4820 *
4821 * @param {string} panelName A string that identifies the panel to enable or disable.
4822 *
4823 * @return {Object} Action object.
4824 */
4825 const toggleEditorPanelEnabled = panelName => ({
4826 registry
4827 }) => {
4828 var _registry$select$get;
4829 const inactivePanels = (_registry$select$get = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'inactivePanels')) !== null && _registry$select$get !== void 0 ? _registry$select$get : [];
4830 const isPanelInactive = !!inactivePanels?.includes(panelName);
4831
4832 // If the panel is inactive, remove it to enable it, else add it to
4833 // make it inactive.
4834 let updatedInactivePanels;
4835 if (isPanelInactive) {
4836 updatedInactivePanels = inactivePanels.filter(invactivePanelName => invactivePanelName !== panelName);
4837 } else {
4838 updatedInactivePanels = [...inactivePanels, panelName];
4839 }
4840 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'inactivePanels', updatedInactivePanels);
4841 };
4842
4843 /**
4844 * Opens a closed panel and closes an open panel.
4845 *
4846 * @param {string} panelName A string that identifies the panel to open or close.
4847 */
4848 const toggleEditorPanelOpened = panelName => ({
4849 registry
4850 }) => {
4851 var _registry$select$get2;
4852 const openPanels = (_registry$select$get2 = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'openPanels')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : [];
4853 const isPanelOpen = !!openPanels?.includes(panelName);
4854
4855 // If the panel is open, remove it to close it, else add it to
4856 // make it open.
4857 let updatedOpenPanels;
4858 if (isPanelOpen) {
4859 updatedOpenPanels = openPanels.filter(openPanelName => openPanelName !== panelName);
4860 } else {
4861 updatedOpenPanels = [...openPanels, panelName];
4862 }
4863 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'openPanels', updatedOpenPanels);
4864 };
4865
4866 /**
4867 * Returns an action object used to remove a panel from the editor.
4868 *
4869 * @param {string} panelName A string that identifies the panel to remove.
4870 *
4871 * @return {Object} Action object.
4872 */
4873 function removeEditorPanel(panelName) {
4874 return {
4875 type: 'REMOVE_PANEL',
4876 panelName
4877 };
4878 }
4879
4880 /**
4881 * Returns an action object used to open/close the inserter.
4882 *
4883 * @param {boolean|Object} value Whether the inserter should be
4884 * opened (true) or closed (false).
4885 * To specify an insertion point,
4886 * use an object.
4887 * @param {string} value.rootClientId The root client ID to insert at.
4888 * @param {number} value.insertionIndex The index to insert at.
4889 *
4890 * @return {Object} Action object.
4891 */
4892 function setIsInserterOpened(value) {
4893 return {
4894 type: 'SET_IS_INSERTER_OPENED',
4895 value
4896 };
4897 }
4898
4899 /**
4900 * Returns an action object used to open/close the list view.
4901 *
4902 * @param {boolean} isOpen A boolean representing whether the list view should be opened or closed.
4903 * @return {Object} Action object.
4904 */
4905 function setIsListViewOpened(isOpen) {
4906 return {
4907 type: 'SET_IS_LIST_VIEW_OPENED',
4908 isOpen
4909 };
4910 }
4911
4912 /**
4913 * Action that toggles Distraction free mode.
4914 * Distraction free mode expects there are no sidebars, as due to the
4915 * z-index values set, you can't close sidebars.
4916 */
4917 const toggleDistractionFree = () => ({
4918 dispatch,
4919 registry
4920 }) => {
4921 const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree');
4922 if (isDistractionFree) {
4923 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', false);
4924 }
4925 if (!isDistractionFree) {
4926 registry.batch(() => {
4927 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', true);
4928 dispatch.setIsInserterOpened(false);
4929 dispatch.setIsListViewOpened(false);
4930 });
4931 }
4932 registry.batch(() => {
4933 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'distractionFree', !isDistractionFree);
4934 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.'), {
4935 id: 'core/editor/distraction-free-mode/notice',
4936 type: 'snackbar',
4937 actions: [{
4938 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
4939 onClick: () => {
4940 registry.batch(() => {
4941 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'fixedToolbar', isDistractionFree ? true : false);
4942 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle('core', 'distractionFree');
4943 });
4944 }
4945 }]
4946 });
4947 });
4948 };
4949
4950 /**
4951 * Triggers an action used to switch editor mode.
4952 *
4953 * @param {string} mode The editor mode.
4954 */
4955 const switchEditorMode = mode => ({
4956 dispatch,
4957 registry
4958 }) => {
4959 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'editorMode', mode);
4960
4961 // Unselect blocks when we switch to a non visual mode.
4962 if (mode !== 'visual') {
4963 registry.dispatch(external_wp_blockEditor_namespaceObject.store).clearSelectedBlock();
4964 }
4965 if (mode === 'visual') {
4966 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Visual editor selected'), 'assertive');
4967 } else if (mode === 'text') {
4968 const isDistractionFree = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'distractionFree');
4969 if (isDistractionFree) {
4970 dispatch.toggleDistractionFree();
4971 }
4972 (0,external_wp_a11y_namespaceObject.speak)((0,external_wp_i18n_namespaceObject.__)('Code editor selected'), 'assertive');
4973 }
4974 };
4975
4976 /**
4977 * Returns an action object used in signalling that the user opened the publish
4978 * sidebar.
4979 *
4980 * @return {Object} Action object
4981 */
4982 function openPublishSidebar() {
4983 return {
4984 type: 'OPEN_PUBLISH_SIDEBAR'
4985 };
4986 }
4987
4988 /**
4989 * Returns an action object used in signalling that the user closed the
4990 * publish sidebar.
4991 *
4992 * @return {Object} Action object.
4993 */
4994 function closePublishSidebar() {
4995 return {
4996 type: 'CLOSE_PUBLISH_SIDEBAR'
4997 };
4998 }
4999
5000 /**
5001 * Returns an action object used in signalling that the user toggles the publish sidebar.
5002 *
5003 * @return {Object} Action object
5004 */
5005 function togglePublishSidebar() {
5006 return {
5007 type: 'TOGGLE_PUBLISH_SIDEBAR'
5008 };
5009 }
5010
5011 /**
5012 * Backward compatibility
5013 */
5014
5015 const getBlockEditorAction = name => (...args) => ({
5016 registry
5017 }) => {
5018 external_wp_deprecated_default()("`wp.data.dispatch( 'core/editor' )." + name + '`', {
5019 since: '5.3',
5020 alternative: "`wp.data.dispatch( 'core/block-editor' )." + name + '`',
5021 version: '6.2'
5022 });
5023 registry.dispatch(external_wp_blockEditor_namespaceObject.store)[name](...args);
5024 };
5025
5026 /**
5027 * @see resetBlocks in core/block-editor store.
5028 */
5029 const resetBlocks = getBlockEditorAction('resetBlocks');
5030
5031 /**
5032 * @see receiveBlocks in core/block-editor store.
5033 */
5034 const receiveBlocks = getBlockEditorAction('receiveBlocks');
5035
5036 /**
5037 * @see updateBlock in core/block-editor store.
5038 */
5039 const updateBlock = getBlockEditorAction('updateBlock');
5040
5041 /**
5042 * @see updateBlockAttributes in core/block-editor store.
5043 */
5044 const updateBlockAttributes = getBlockEditorAction('updateBlockAttributes');
5045
5046 /**
5047 * @see selectBlock in core/block-editor store.
5048 */
5049 const selectBlock = getBlockEditorAction('selectBlock');
5050
5051 /**
5052 * @see startMultiSelect in core/block-editor store.
5053 */
5054 const startMultiSelect = getBlockEditorAction('startMultiSelect');
5055
5056 /**
5057 * @see stopMultiSelect in core/block-editor store.
5058 */
5059 const stopMultiSelect = getBlockEditorAction('stopMultiSelect');
5060
5061 /**
5062 * @see multiSelect in core/block-editor store.
5063 */
5064 const multiSelect = getBlockEditorAction('multiSelect');
5065
5066 /**
5067 * @see clearSelectedBlock in core/block-editor store.
5068 */
5069 const clearSelectedBlock = getBlockEditorAction('clearSelectedBlock');
5070
5071 /**
5072 * @see toggleSelection in core/block-editor store.
5073 */
5074 const toggleSelection = getBlockEditorAction('toggleSelection');
5075
5076 /**
5077 * @see replaceBlocks in core/block-editor store.
5078 */
5079 const replaceBlocks = getBlockEditorAction('replaceBlocks');
5080
5081 /**
5082 * @see replaceBlock in core/block-editor store.
5083 */
5084 const replaceBlock = getBlockEditorAction('replaceBlock');
5085
5086 /**
5087 * @see moveBlocksDown in core/block-editor store.
5088 */
5089 const moveBlocksDown = getBlockEditorAction('moveBlocksDown');
5090
5091 /**
5092 * @see moveBlocksUp in core/block-editor store.
5093 */
5094 const moveBlocksUp = getBlockEditorAction('moveBlocksUp');
5095
5096 /**
5097 * @see moveBlockToPosition in core/block-editor store.
5098 */
5099 const moveBlockToPosition = getBlockEditorAction('moveBlockToPosition');
5100
5101 /**
5102 * @see insertBlock in core/block-editor store.
5103 */
5104 const insertBlock = getBlockEditorAction('insertBlock');
5105
5106 /**
5107 * @see insertBlocks in core/block-editor store.
5108 */
5109 const insertBlocks = getBlockEditorAction('insertBlocks');
5110
5111 /**
5112 * @see showInsertionPoint in core/block-editor store.
5113 */
5114 const showInsertionPoint = getBlockEditorAction('showInsertionPoint');
5115
5116 /**
5117 * @see hideInsertionPoint in core/block-editor store.
5118 */
5119 const hideInsertionPoint = getBlockEditorAction('hideInsertionPoint');
5120
5121 /**
5122 * @see setTemplateValidity in core/block-editor store.
5123 */
5124 const setTemplateValidity = getBlockEditorAction('setTemplateValidity');
5125
5126 /**
5127 * @see synchronizeTemplate in core/block-editor store.
5128 */
5129 const synchronizeTemplate = getBlockEditorAction('synchronizeTemplate');
5130
5131 /**
5132 * @see mergeBlocks in core/block-editor store.
5133 */
5134 const mergeBlocks = getBlockEditorAction('mergeBlocks');
5135
5136 /**
5137 * @see removeBlocks in core/block-editor store.
5138 */
5139 const removeBlocks = getBlockEditorAction('removeBlocks');
5140
5141 /**
5142 * @see removeBlock in core/block-editor store.
5143 */
5144 const removeBlock = getBlockEditorAction('removeBlock');
5145
5146 /**
5147 * @see toggleBlockMode in core/block-editor store.
5148 */
5149 const toggleBlockMode = getBlockEditorAction('toggleBlockMode');
5150
5151 /**
5152 * @see startTyping in core/block-editor store.
5153 */
5154 const startTyping = getBlockEditorAction('startTyping');
5155
5156 /**
5157 * @see stopTyping in core/block-editor store.
5158 */
5159 const stopTyping = getBlockEditorAction('stopTyping');
5160
5161 /**
5162 * @see enterFormattedText in core/block-editor store.
5163 */
5164 const enterFormattedText = getBlockEditorAction('enterFormattedText');
5165
5166 /**
5167 * @see exitFormattedText in core/block-editor store.
5168 */
5169 const exitFormattedText = getBlockEditorAction('exitFormattedText');
5170
5171 /**
5172 * @see insertDefaultBlock in core/block-editor store.
5173 */
5174 const insertDefaultBlock = getBlockEditorAction('insertDefaultBlock');
5175
5176 /**
5177 * @see updateBlockListSettings in core/block-editor store.
5178 */
5179 const updateBlockListSettings = getBlockEditorAction('updateBlockListSettings');
5180
5181 ;// CONCATENATED MODULE: external ["wp","htmlEntities"]
5182 const external_wp_htmlEntities_namespaceObject = window["wp"]["htmlEntities"];
5183 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/utils/is-template-revertable.js
5184 /**
5185 * Internal dependencies
5186 */
5187
5188
5189 // Copy of the function from packages/edit-site/src/utils/is-template-revertable.js
5190
5191 /**
5192 * Check if a template or template part is revertable to its original theme-provided file.
5193 *
5194 * @param {Object} templateOrTemplatePart The entity to check.
5195 * @return {boolean} Whether the entity is revertable.
5196 */
5197 function isTemplateRevertable(templateOrTemplatePart) {
5198 if (!templateOrTemplatePart) {
5199 return false;
5200 }
5201 return templateOrTemplatePart.source === TEMPLATE_ORIGINS.custom && templateOrTemplatePart.has_theme_file;
5202 }
5203
5204 ;// CONCATENATED MODULE: ./packages/editor/build-module/dataviews/store/private-actions.js
5205 /**
5206 * WordPress dependencies
5207 */
5208
5209 function registerEntityAction(kind, name, config) {
5210 return {
5211 type: 'REGISTER_ENTITY_ACTION',
5212 kind,
5213 name,
5214 config
5215 };
5216 }
5217 function unregisterEntityAction(kind, name, actionId) {
5218 return {
5219 type: 'UNREGISTER_ENTITY_ACTION',
5220 kind,
5221 name,
5222 actionId
5223 };
5224 }
5225
5226 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/private-actions.js
5227 /**
5228 * WordPress dependencies
5229 */
5230
5231
5232
5233
5234
5235
5236
5237
5238
5239
5240 /**
5241 * Internal dependencies
5242 */
5243
5244
5245
5246 /**
5247 * Returns an action object used to set which template is currently being used/edited.
5248 *
5249 * @param {string} id Template Id.
5250 *
5251 * @return {Object} Action object.
5252 */
5253 function setCurrentTemplateId(id) {
5254 return {
5255 type: 'SET_CURRENT_TEMPLATE_ID',
5256 id
5257 };
5258 }
5259
5260 /**
5261 * Create a block based template.
5262 *
5263 * @param {Object?} template Template to create and assign.
5264 */
5265 const createTemplate = template => async ({
5266 select,
5267 dispatch,
5268 registry
5269 }) => {
5270 const savedTemplate = await registry.dispatch(external_wp_coreData_namespaceObject.store).saveEntityRecord('postType', 'wp_template', template);
5271 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', select.getCurrentPostType(), select.getCurrentPostId(), {
5272 template: savedTemplate.slug
5273 });
5274 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)("Custom template created. You're in template mode now."), {
5275 type: 'snackbar',
5276 actions: [{
5277 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
5278 onClick: () => dispatch.setRenderingMode(select.getEditorSettings().defaultRenderingMode)
5279 }]
5280 });
5281 return savedTemplate;
5282 };
5283
5284 /**
5285 * Update the provided block types to be visible.
5286 *
5287 * @param {string[]} blockNames Names of block types to show.
5288 */
5289 const showBlockTypes = blockNames => ({
5290 registry
5291 }) => {
5292 var _registry$select$get;
5293 const existingBlockNames = (_registry$select$get = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get !== void 0 ? _registry$select$get : [];
5294 const newBlockNames = existingBlockNames.filter(type => !(Array.isArray(blockNames) ? blockNames : [blockNames]).includes(type));
5295 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', newBlockNames);
5296 };
5297
5298 /**
5299 * Update the provided block types to be hidden.
5300 *
5301 * @param {string[]} blockNames Names of block types to hide.
5302 */
5303 const hideBlockTypes = blockNames => ({
5304 registry
5305 }) => {
5306 var _registry$select$get2;
5307 const existingBlockNames = (_registry$select$get2 = registry.select(external_wp_preferences_namespaceObject.store).get('core', 'hiddenBlockTypes')) !== null && _registry$select$get2 !== void 0 ? _registry$select$get2 : [];
5308 const mergedBlockNames = new Set([...existingBlockNames, ...(Array.isArray(blockNames) ? blockNames : [blockNames])]);
5309 registry.dispatch(external_wp_preferences_namespaceObject.store).set('core', 'hiddenBlockTypes', [...mergedBlockNames]);
5310 };
5311
5312 /**
5313 * Save entity records marked as dirty.
5314 *
5315 * @param {Object} options Options for the action.
5316 * @param {Function} [options.onSave] Callback when saving happens.
5317 * @param {object[]} [options.dirtyEntityRecords] Array of dirty entities.
5318 * @param {object[]} [options.entitiesToSkip] Array of entities to skip saving.
5319 * @param {Function} [options.close] Callback when the actions is called. It should be consolidated with `onSave`.
5320 */
5321 const saveDirtyEntities = ({
5322 onSave,
5323 dirtyEntityRecords = [],
5324 entitiesToSkip = [],
5325 close
5326 } = {}) => ({
5327 registry
5328 }) => {
5329 const PUBLISH_ON_SAVE_ENTITIES = [{
5330 kind: 'postType',
5331 name: 'wp_navigation'
5332 }];
5333 const saveNoticeId = 'site-editor-save-success';
5334 const homeUrl = registry.select(external_wp_coreData_namespaceObject.store).getUnstableBase()?.home;
5335 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(saveNoticeId);
5336 const entitiesToSave = dirtyEntityRecords.filter(({
5337 kind,
5338 name,
5339 key,
5340 property
5341 }) => {
5342 return !entitiesToSkip.some(elt => elt.kind === kind && elt.name === name && elt.key === key && elt.property === property);
5343 });
5344 close?.(entitiesToSave);
5345 const siteItemsToSave = [];
5346 const pendingSavedRecords = [];
5347 entitiesToSave.forEach(({
5348 kind,
5349 name,
5350 key,
5351 property
5352 }) => {
5353 if ('root' === kind && 'site' === name) {
5354 siteItemsToSave.push(property);
5355 } else {
5356 if (PUBLISH_ON_SAVE_ENTITIES.some(typeToPublish => typeToPublish.kind === kind && typeToPublish.name === name)) {
5357 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord(kind, name, key, {
5358 status: 'publish'
5359 });
5360 }
5361 pendingSavedRecords.push(registry.dispatch(external_wp_coreData_namespaceObject.store).saveEditedEntityRecord(kind, name, key));
5362 }
5363 });
5364 if (siteItemsToSave.length) {
5365 pendingSavedRecords.push(registry.dispatch(external_wp_coreData_namespaceObject.store).__experimentalSaveSpecifiedEntityEdits('root', 'site', undefined, siteItemsToSave));
5366 }
5367 registry.dispatch(external_wp_blockEditor_namespaceObject.store).__unstableMarkLastChangeAsPersistent();
5368 Promise.all(pendingSavedRecords).then(values => {
5369 return onSave ? onSave(values) : values;
5370 }).then(values => {
5371 if (values.some(value => typeof value === 'undefined')) {
5372 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('Saving failed.'));
5373 } else {
5374 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Site updated.'), {
5375 type: 'snackbar',
5376 id: saveNoticeId,
5377 actions: [{
5378 label: (0,external_wp_i18n_namespaceObject.__)('View site'),
5379 url: homeUrl
5380 }]
5381 });
5382 }
5383 }).catch(error => registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(`${(0,external_wp_i18n_namespaceObject.__)('Saving failed.')} ${error}`));
5384 };
5385
5386 /**
5387 * Reverts a template to its original theme-provided file.
5388 *
5389 * @param {Object} template The template to revert.
5390 * @param {Object} [options]
5391 * @param {boolean} [options.allowUndo] Whether to allow the user to undo
5392 * reverting the template. Default true.
5393 */
5394 const revertTemplate = (template, {
5395 allowUndo = true
5396 } = {}) => async ({
5397 registry
5398 }) => {
5399 const noticeId = 'edit-site-template-reverted';
5400 registry.dispatch(external_wp_notices_namespaceObject.store).removeNotice(noticeId);
5401 if (!isTemplateRevertable(template)) {
5402 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('This template is not revertable.'), {
5403 type: 'snackbar'
5404 });
5405 return;
5406 }
5407 try {
5408 const templateEntityConfig = registry.select(external_wp_coreData_namespaceObject.store).getEntityConfig('postType', template.type);
5409 if (!templateEntityConfig) {
5410 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
5411 type: 'snackbar'
5412 });
5413 return;
5414 }
5415 const fileTemplatePath = (0,external_wp_url_namespaceObject.addQueryArgs)(`${templateEntityConfig.baseURL}/${template.id}`, {
5416 context: 'edit',
5417 source: 'theme'
5418 });
5419 const fileTemplate = await external_wp_apiFetch_default()({
5420 path: fileTemplatePath
5421 });
5422 if (!fileTemplate) {
5423 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice((0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error. Please reload.'), {
5424 type: 'snackbar'
5425 });
5426 return;
5427 }
5428 const serializeBlocks = ({
5429 blocks: blocksForSerialization = []
5430 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization);
5431 const edited = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', template.type, template.id);
5432
5433 // We are fixing up the undo level here to make sure we can undo
5434 // the revert in the header toolbar correctly.
5435 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, template.id, {
5436 content: serializeBlocks,
5437 // Required to make the `undo` behave correctly.
5438 blocks: edited.blocks,
5439 // Required to revert the blocks in the editor.
5440 source: 'custom' // required to avoid turning the editor into a dirty state
5441 }, {
5442 undoIgnore: true // Required to merge this edit with the last undo level.
5443 });
5444 const blocks = (0,external_wp_blocks_namespaceObject.parse)(fileTemplate?.content?.raw);
5445 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, fileTemplate.id, {
5446 content: serializeBlocks,
5447 blocks,
5448 source: 'theme'
5449 });
5450 if (allowUndo) {
5451 const undoRevert = () => {
5452 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', template.type, edited.id, {
5453 content: serializeBlocks,
5454 blocks: edited.blocks,
5455 source: 'custom'
5456 });
5457 };
5458 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template reset.'), {
5459 type: 'snackbar',
5460 id: noticeId,
5461 actions: [{
5462 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
5463 onClick: undoRevert
5464 }]
5465 });
5466 }
5467 } catch (error) {
5468 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('Template revert failed. Please reload.');
5469 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
5470 type: 'snackbar'
5471 });
5472 }
5473 };
5474
5475 /**
5476 * Action that removes an array of templates, template parts or patterns.
5477 *
5478 * @param {Array} items An array of template,template part or pattern objects to remove.
5479 */
5480 const removeTemplates = items => async ({
5481 registry
5482 }) => {
5483 const isResetting = items.every(item => item?.has_theme_file);
5484 const promiseResult = await Promise.allSettled(items.map(item => {
5485 return registry.dispatch(external_wp_coreData_namespaceObject.store).deleteEntityRecord('postType', item.type, item.id, {
5486 force: true
5487 }, {
5488 throwOnError: true
5489 });
5490 }));
5491
5492 // If all the promises were fulfilled with sucess.
5493 if (promiseResult.every(({
5494 status
5495 }) => status === 'fulfilled')) {
5496 let successMessage;
5497 if (items.length === 1) {
5498 // Depending on how the entity was retrieved its title might be
5499 // an object or simple string.
5500 const title = typeof items[0].title === 'string' ? items[0].title : items[0].title?.rendered;
5501 successMessage = isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */
5502 (0,external_wp_i18n_namespaceObject.__)('"%s" reset.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title)) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */
5503 (0,external_wp_i18n_namespaceObject.__)('"%s" deleted.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title));
5504 } else {
5505 successMessage = isResetting ? (0,external_wp_i18n_namespaceObject.__)('Items reset.') : (0,external_wp_i18n_namespaceObject.__)('Items deleted.');
5506 }
5507 registry.dispatch(external_wp_notices_namespaceObject.store).createSuccessNotice(successMessage, {
5508 type: 'snackbar',
5509 id: 'editor-template-deleted-success'
5510 });
5511 } else {
5512 // If there was at lease one failure.
5513 let errorMessage;
5514 // If we were trying to delete a single template.
5515 if (promiseResult.length === 1) {
5516 if (promiseResult[0].reason?.message) {
5517 errorMessage = promiseResult[0].reason.message;
5518 } else {
5519 errorMessage = isResetting ? (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the item.') : (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the item.');
5520 }
5521 // If we were trying to delete a multiple templates
5522 } else {
5523 const errorMessages = new Set();
5524 const failedPromises = promiseResult.filter(({
5525 status
5526 }) => status === 'rejected');
5527 for (const failedPromise of failedPromises) {
5528 if (failedPromise.reason?.message) {
5529 errorMessages.add(failedPromise.reason.message);
5530 }
5531 }
5532 if (errorMessages.size === 0) {
5533 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the items.');
5534 } else if (errorMessages.size === 1) {
5535 errorMessage = isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
5536 (0,external_wp_i18n_namespaceObject.__)('An error occurred while reverting the items: %s'), [...errorMessages][0]) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
5537 (0,external_wp_i18n_namespaceObject.__)('An error occurred while deleting the items: %s'), [...errorMessages][0]);
5538 } else {
5539 errorMessage = isResetting ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
5540 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while reverting the items: %s'), [...errorMessages].join(',')) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
5541 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while deleting the items: %s'), [...errorMessages].join(','));
5542 }
5543 }
5544 registry.dispatch(external_wp_notices_namespaceObject.store).createErrorNotice(errorMessage, {
5545 type: 'snackbar'
5546 });
5547 }
5548 };
5549
5550 // EXTERNAL MODULE: ./node_modules/fast-deep-equal/index.js
5551 var fast_deep_equal = __webpack_require__(2303);
5552 var fast_deep_equal_default = /*#__PURE__*/__webpack_require__.n(fast_deep_equal);
5553 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/symbol.js
5554 /**
5555 * WordPress dependencies
5556 */
5557
5558
5559 const symbol = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
5560 xmlns: "http://www.w3.org/2000/svg",
5561 viewBox: "0 0 24 24",
5562 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5563 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"
5564 })
5565 });
5566 /* harmony default export */ const library_symbol = (symbol);
5567
5568 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/navigation.js
5569 /**
5570 * WordPress dependencies
5571 */
5572
5573
5574 const navigation = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
5575 viewBox: "0 0 24 24",
5576 xmlns: "http://www.w3.org/2000/svg",
5577 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5578 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"
5579 })
5580 });
5581 /* harmony default export */ const library_navigation = (navigation);
5582
5583 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/page.js
5584 /**
5585 * WordPress dependencies
5586 */
5587
5588
5589
5590 const page = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, {
5591 xmlns: "http://www.w3.org/2000/svg",
5592 viewBox: "0 0 24 24",
5593 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5594 d: "M15.5 7.5h-7V9h7V7.5Zm-7 3.5h7v1.5h-7V11Zm7 3.5h-7V16h7v-1.5Z"
5595 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5596 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"
5597 })]
5598 });
5599 /* harmony default export */ const library_page = (page);
5600
5601 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/verse.js
5602 /**
5603 * WordPress dependencies
5604 */
5605
5606
5607 const verse = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
5608 viewBox: "0 0 24 24",
5609 xmlns: "http://www.w3.org/2000/svg",
5610 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
5611 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"
5612 })
5613 });
5614 /* harmony default export */ const library_verse = (verse);
5615
5616 ;// CONCATENATED MODULE: ./packages/editor/build-module/dataviews/store/private-selectors.js
5617 /**
5618 * WordPress dependencies
5619 */
5620
5621
5622 /**
5623 * Internal dependencies
5624 */
5625
5626 const getEntityActions = (0,external_wp_data_namespaceObject.createSelector)((state, kind, name) => {
5627 var _state$actions$kind$n, _state$actions$kind$;
5628 return [...((_state$actions$kind$n = state.actions[kind]?.[name]) !== null && _state$actions$kind$n !== void 0 ? _state$actions$kind$n : []), ...((_state$actions$kind$ = state.actions[kind]?.['*']) !== null && _state$actions$kind$ !== void 0 ? _state$actions$kind$ : [])];
5629 }, (state, kind, name) => [state.actions[kind]?.[name], state.actions[kind]?.['*']]);
5630
5631 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/private-selectors.js
5632 /**
5633 * External dependencies
5634 */
5635
5636
5637 /**
5638 * WordPress dependencies
5639 */
5640
5641
5642
5643
5644
5645 /**
5646 * Internal dependencies
5647 */
5648
5649
5650 const EMPTY_INSERTION_POINT = {
5651 rootClientId: undefined,
5652 insertionIndex: undefined,
5653 filterValue: undefined
5654 };
5655
5656 /**
5657 * Get the insertion point for the inserter.
5658 *
5659 * @param {Object} state Global application state.
5660 *
5661 * @return {Object} The root client ID, index to insert at and starting filter value.
5662 */
5663 const getInsertionPoint = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (0,external_wp_data_namespaceObject.createSelector)(state => {
5664 if (typeof state.blockInserterPanel === 'object') {
5665 return state.blockInserterPanel;
5666 }
5667 if (getRenderingMode(state) === 'template-locked') {
5668 const [postContentClientId] = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/post-content');
5669 if (postContentClientId) {
5670 return {
5671 rootClientId: postContentClientId,
5672 insertionIndex: undefined,
5673 filterValue: undefined
5674 };
5675 }
5676 }
5677 return EMPTY_INSERTION_POINT;
5678 }, state => {
5679 const [postContentClientId] = select(external_wp_blockEditor_namespaceObject.store).getBlocksByName('core/post-content');
5680 return [state.blockInserterPanel, getRenderingMode(state), postContentClientId];
5681 }));
5682 function getListViewToggleRef(state) {
5683 return state.listViewToggleRef;
5684 }
5685 function getInserterSidebarToggleRef(state) {
5686 return state.inserterSidebarToggleRef;
5687 }
5688 const CARD_ICONS = {
5689 wp_block: library_symbol,
5690 wp_navigation: library_navigation,
5691 page: library_page,
5692 post: library_verse
5693 };
5694 const getPostIcon = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, options) => {
5695 {
5696 if (postType === 'wp_template_part' || postType === 'wp_template') {
5697 return __experimentalGetDefaultTemplatePartAreas(state).find(item => options.area === item.area)?.icon || library_layout;
5698 }
5699 if (CARD_ICONS[postType]) {
5700 return CARD_ICONS[postType];
5701 }
5702 const postTypeEntity = select(external_wp_coreData_namespaceObject.store).getPostType(postType);
5703 // `icon` is the `menu_icon` property of a post type. We
5704 // only handle `dashicons` for now, even if the `menu_icon`
5705 // also supports urls and svg as values.
5706 if (postTypeEntity?.icon?.startsWith('dashicons-')) {
5707 return postTypeEntity.icon.slice(10);
5708 }
5709 return library_page;
5710 }
5711 });
5712
5713 /**
5714 * Returns true if there are unsaved changes to the
5715 * post's meta fields, and false otherwise.
5716 *
5717 * @param {Object} state Global application state.
5718 * @param {string} postType The post type of the post.
5719 * @param {number} postId The ID of the post.
5720 *
5721 * @return {boolean} Whether there are edits or not in the meta fields of the relevant post.
5722 */
5723 const hasPostMetaChanges = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, postType, postId) => {
5724 const {
5725 type: currentPostType,
5726 id: currentPostId
5727 } = getCurrentPost(state);
5728 // If no postType or postId is passed, use the current post.
5729 const edits = select(external_wp_coreData_namespaceObject.store).getEntityRecordNonTransientEdits('postType', postType || currentPostType, postId || currentPostId);
5730 if (!edits?.meta) {
5731 return false;
5732 }
5733
5734 // Compare if anything apart from `footnotes` has changed.
5735 const originalPostMeta = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', postType || currentPostType, postId || currentPostId)?.meta;
5736 return !fast_deep_equal_default()({
5737 ...originalPostMeta,
5738 footnotes: undefined
5739 }, {
5740 ...edits.meta,
5741 footnotes: undefined
5742 });
5743 });
5744 function private_selectors_getEntityActions(state, ...args) {
5745 return getEntityActions(state.dataviews, ...args);
5746 }
5747
5748 ;// CONCATENATED MODULE: external ["wp","privateApis"]
5749 const external_wp_privateApis_namespaceObject = window["wp"]["privateApis"];
5750 ;// CONCATENATED MODULE: ./packages/editor/build-module/lock-unlock.js
5751 /**
5752 * WordPress dependencies
5753 */
5754
5755 const {
5756 lock,
5757 unlock
5758 } = (0,external_wp_privateApis_namespaceObject.__dangerousOptInToUnstableAPIsOnlyForCoreModules)('I acknowledge private features are not for use in themes or plugins and doing so will break in the next version of WordPress.', '@wordpress/editor');
5759
5760 ;// CONCATENATED MODULE: ./packages/editor/build-module/store/index.js
5761 /**
5762 * WordPress dependencies
5763 */
5764
5765
5766 /**
5767 * Internal dependencies
5768 */
5769
5770
5771
5772
5773
5774
5775
5776
5777 /**
5778 * Post editor data store configuration.
5779 *
5780 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#registerStore
5781 *
5782 * @type {Object}
5783 */
5784 const storeConfig = {
5785 reducer: store_reducer,
5786 selectors: selectors_namespaceObject,
5787 actions: actions_namespaceObject
5788 };
5789
5790 /**
5791 * Store definition for the editor namespace.
5792 *
5793 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
5794 *
5795 * @type {Object}
5796 */
5797 const store_store = (0,external_wp_data_namespaceObject.createReduxStore)(STORE_NAME, {
5798 ...storeConfig
5799 });
5800 (0,external_wp_data_namespaceObject.register)(store_store);
5801 unlock(store_store).registerPrivateActions(store_private_actions_namespaceObject);
5802 unlock(store_store).registerPrivateSelectors(store_private_selectors_namespaceObject);
5803
5804 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/custom-sources-backwards-compatibility.js
5805 /**
5806 * WordPress dependencies
5807 */
5808
5809
5810
5811
5812
5813
5814 /**
5815 * Internal dependencies
5816 */
5817
5818
5819 /** @typedef {import('@wordpress/compose').WPHigherOrderComponent} WPHigherOrderComponent */
5820 /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
5821
5822 /**
5823 * Object whose keys are the names of block attributes, where each value
5824 * represents the meta key to which the block attribute is intended to save.
5825 *
5826 * @see https://developer.wordpress.org/reference/functions/register_meta/
5827 *
5828 * @typedef {Object<string,string>} WPMetaAttributeMapping
5829 */
5830
5831 /**
5832 * Given a mapping of attribute names (meta source attributes) to their
5833 * associated meta key, returns a higher order component that overrides its
5834 * `attributes` and `setAttributes` props to sync any changes with the edited
5835 * post's meta keys.
5836 *
5837 * @param {WPMetaAttributeMapping} metaAttributes Meta attribute mapping.
5838 *
5839 * @return {WPHigherOrderComponent} Higher-order component.
5840 */
5841
5842 const createWithMetaAttributeSource = metaAttributes => (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => ({
5843 attributes,
5844 setAttributes,
5845 ...props
5846 }) => {
5847 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
5848 const [meta, setMeta] = (0,external_wp_coreData_namespaceObject.useEntityProp)('postType', postType, 'meta');
5849 const mergedAttributes = (0,external_wp_element_namespaceObject.useMemo)(() => ({
5850 ...attributes,
5851 ...Object.fromEntries(Object.entries(metaAttributes).map(([attributeKey, metaKey]) => [attributeKey, meta[metaKey]]))
5852 }), [attributes, meta]);
5853 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockEdit, {
5854 attributes: mergedAttributes,
5855 setAttributes: nextAttributes => {
5856 const nextMeta = Object.fromEntries(Object.entries(nextAttributes !== null && nextAttributes !== void 0 ? nextAttributes : {}).filter(
5857 // Filter to intersection of keys between the updated
5858 // attributes and those with an associated meta key.
5859 ([key]) => key in metaAttributes).map(([attributeKey, value]) => [
5860 // Rename the keys to the expected meta key name.
5861 metaAttributes[attributeKey], value]));
5862 if (Object.entries(nextMeta).length) {
5863 setMeta(nextMeta);
5864 }
5865 setAttributes(nextAttributes);
5866 },
5867 ...props
5868 });
5869 }, 'withMetaAttributeSource');
5870
5871 /**
5872 * Filters a registered block's settings to enhance a block's `edit` component
5873 * to upgrade meta-sourced attributes to use the post's meta entity property.
5874 *
5875 * @param {WPBlockSettings} settings Registered block settings.
5876 *
5877 * @return {WPBlockSettings} Filtered block settings.
5878 */
5879 function shimAttributeSource(settings) {
5880 var _settings$attributes;
5881 /** @type {WPMetaAttributeMapping} */
5882 const metaAttributes = Object.fromEntries(Object.entries((_settings$attributes = settings.attributes) !== null && _settings$attributes !== void 0 ? _settings$attributes : {}).filter(([, {
5883 source
5884 }]) => source === 'meta').map(([attributeKey, {
5885 meta
5886 }]) => [attributeKey, meta]));
5887 if (Object.entries(metaAttributes).length) {
5888 settings.edit = createWithMetaAttributeSource(metaAttributes)(settings.edit);
5889 }
5890 return settings;
5891 }
5892 (0,external_wp_hooks_namespaceObject.addFilter)('blocks.registerBlockType', 'core/editor/custom-sources-backwards-compatibility/shim-attribute-source', shimAttributeSource);
5893
5894 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/autocompleters/user.js
5895 /**
5896 * WordPress dependencies
5897 */
5898
5899
5900
5901
5902 /** @typedef {import('@wordpress/components').WPCompleter} WPCompleter */
5903
5904
5905
5906 function getUserLabel(user) {
5907 const avatar = user.avatar_urls && user.avatar_urls[24] ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
5908 className: "editor-autocompleters__user-avatar",
5909 alt: "",
5910 src: user.avatar_urls[24]
5911 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
5912 className: "editor-autocompleters__no-avatar"
5913 });
5914 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
5915 children: [avatar, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
5916 className: "editor-autocompleters__user-name",
5917 children: user.name
5918 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
5919 className: "editor-autocompleters__user-slug",
5920 children: user.slug
5921 })]
5922 });
5923 }
5924
5925 /**
5926 * A user mentions completer.
5927 *
5928 * @type {WPCompleter}
5929 */
5930 /* harmony default export */ const user = ({
5931 name: 'users',
5932 className: 'editor-autocompleters__user',
5933 triggerPrefix: '@',
5934 useItems(filterValue) {
5935 const users = (0,external_wp_data_namespaceObject.useSelect)(select => {
5936 const {
5937 getUsers
5938 } = select(external_wp_coreData_namespaceObject.store);
5939 return getUsers({
5940 context: 'view',
5941 search: encodeURIComponent(filterValue)
5942 });
5943 }, [filterValue]);
5944 const options = (0,external_wp_element_namespaceObject.useMemo)(() => users ? users.map(user => ({
5945 key: `user-${user.slug}`,
5946 value: user,
5947 label: getUserLabel(user)
5948 })) : [], [users]);
5949 return [options];
5950 },
5951 getOptionCompletion(user) {
5952 return `@${user.slug}`;
5953 }
5954 });
5955
5956 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/default-autocompleters.js
5957 /**
5958 * WordPress dependencies
5959 */
5960
5961
5962 /**
5963 * Internal dependencies
5964 */
5965
5966 function setDefaultCompleters(completers = []) {
5967 // Provide copies so filters may directly modify them.
5968 completers.push({
5969 ...user
5970 });
5971 return completers;
5972 }
5973 (0,external_wp_hooks_namespaceObject.addFilter)('editor.Autocomplete.completers', 'editor/autocompleters/set-default-completers', setDefaultCompleters);
5974
5975 ;// CONCATENATED MODULE: external ["wp","mediaUtils"]
5976 const external_wp_mediaUtils_namespaceObject = window["wp"]["mediaUtils"];
5977 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/media-upload.js
5978 /**
5979 * WordPress dependencies
5980 */
5981
5982
5983 (0,external_wp_hooks_namespaceObject.addFilter)('editor.MediaUpload', 'core/editor/components/media-upload', () => external_wp_mediaUtils_namespaceObject.MediaUpload);
5984
5985 ;// CONCATENATED MODULE: external ["wp","patterns"]
5986 const external_wp_patterns_namespaceObject = window["wp"]["patterns"];
5987 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/pattern-overrides.js
5988 /**
5989 * WordPress dependencies
5990 */
5991
5992
5993
5994
5995
5996
5997
5998 /**
5999 * Internal dependencies
6000 */
6001
6002
6003
6004 /** @typedef {import('@wordpress/blocks').WPBlockSettings} WPBlockSettings */
6005
6006
6007
6008 const {
6009 PatternOverridesControls,
6010 ResetOverridesControl,
6011 PatternOverridesBlockControls,
6012 PATTERN_TYPES,
6013 PARTIAL_SYNCING_SUPPORTED_BLOCKS,
6014 PATTERN_SYNC_TYPES
6015 } = unlock(external_wp_patterns_namespaceObject.privateApis);
6016
6017 /**
6018 * Override the default edit UI to include a new block inspector control for
6019 * assigning a partial syncing controls to supported blocks in the pattern editor.
6020 * Currently, only the `core/paragraph` block is supported.
6021 *
6022 * @param {Component} BlockEdit Original component.
6023 *
6024 * @return {Component} Wrapped component.
6025 */
6026 const withPatternOverrideControls = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(BlockEdit => props => {
6027 const isSupportedBlock = !!PARTIAL_SYNCING_SUPPORTED_BLOCKS[props.name];
6028 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
6029 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockEdit, {
6030 ...props
6031 }, "edit"), props.isSelected && isSupportedBlock && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ControlsWithStoreSubscription, {
6032 ...props
6033 }), isSupportedBlock && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternOverridesBlockControls, {})]
6034 });
6035 }, 'withPatternOverrideControls');
6036
6037 // Split into a separate component to avoid a store subscription
6038 // on every block.
6039 function ControlsWithStoreSubscription(props) {
6040 const blockEditingMode = (0,external_wp_blockEditor_namespaceObject.useBlockEditingMode)();
6041 const {
6042 hasPatternOverridesSource,
6043 isEditingSyncedPattern
6044 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
6045 const {
6046 getBlockBindingsSource
6047 } = unlock(select(external_wp_blocks_namespaceObject.store));
6048 const {
6049 getCurrentPostType,
6050 getEditedPostAttribute
6051 } = select(store_store);
6052 return {
6053 // For editing link to the site editor if the theme and user permissions support it.
6054 hasPatternOverridesSource: !!getBlockBindingsSource('core/pattern-overrides'),
6055 isEditingSyncedPattern: getCurrentPostType() === PATTERN_TYPES.user && getEditedPostAttribute('meta')?.wp_pattern_sync_status !== PATTERN_SYNC_TYPES.unsynced && getEditedPostAttribute('wp_pattern_sync_status') !== PATTERN_SYNC_TYPES.unsynced
6056 };
6057 }, []);
6058 const bindings = props.attributes.metadata?.bindings;
6059 const hasPatternBindings = !!bindings && Object.values(bindings).some(binding => binding.source === 'core/pattern-overrides');
6060 const shouldShowPatternOverridesControls = isEditingSyncedPattern && blockEditingMode === 'default';
6061 const shouldShowResetOverridesControl = !isEditingSyncedPattern && !!props.attributes.metadata?.name && blockEditingMode !== 'disabled' && hasPatternBindings;
6062 if (!hasPatternOverridesSource) {
6063 return null;
6064 }
6065 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
6066 children: [shouldShowPatternOverridesControls && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternOverridesControls, {
6067 ...props
6068 }), shouldShowResetOverridesControl && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResetOverridesControl, {
6069 ...props
6070 })]
6071 });
6072 }
6073 (0,external_wp_hooks_namespaceObject.addFilter)('editor.BlockEdit', 'core/editor/with-pattern-override-controls', withPatternOverrideControls);
6074
6075 ;// CONCATENATED MODULE: ./packages/editor/build-module/hooks/index.js
6076 /**
6077 * Internal dependencies
6078 */
6079
6080
6081
6082
6083
6084 ;// CONCATENATED MODULE: external ["wp","keyboardShortcuts"]
6085 const external_wp_keyboardShortcuts_namespaceObject = window["wp"]["keyboardShortcuts"];
6086 ;// CONCATENATED MODULE: ./node_modules/clsx/dist/clsx.mjs
6087 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);
6088 ;// CONCATENATED MODULE: external ["wp","components"]
6089 const external_wp_components_namespaceObject = window["wp"]["components"];
6090 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/check.js
6091 /**
6092 * WordPress dependencies
6093 */
6094
6095
6096 const check = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
6097 xmlns: "http://www.w3.org/2000/svg",
6098 viewBox: "0 0 24 24",
6099 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
6100 d: "M16.7 7.1l-6.3 8.5-3.3-2.5-.9 1.2 4.5 3.4L17.9 8z"
6101 })
6102 });
6103 /* harmony default export */ const library_check = (check);
6104
6105 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-filled.js
6106 /**
6107 * WordPress dependencies
6108 */
6109
6110
6111 const starFilled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
6112 xmlns: "http://www.w3.org/2000/svg",
6113 viewBox: "0 0 24 24",
6114 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
6115 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"
6116 })
6117 });
6118 /* harmony default export */ const star_filled = (starFilled);
6119
6120 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/star-empty.js
6121 /**
6122 * WordPress dependencies
6123 */
6124
6125
6126 const starEmpty = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
6127 xmlns: "http://www.w3.org/2000/svg",
6128 viewBox: "0 0 24 24",
6129 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
6130 fillRule: "evenodd",
6131 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",
6132 clipRule: "evenodd"
6133 })
6134 });
6135 /* harmony default export */ const star_empty = (starEmpty);
6136
6137 ;// CONCATENATED MODULE: external ["wp","viewport"]
6138 const external_wp_viewport_namespaceObject = window["wp"]["viewport"];
6139 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/close-small.js
6140 /**
6141 * WordPress dependencies
6142 */
6143
6144
6145 const closeSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
6146 xmlns: "http://www.w3.org/2000/svg",
6147 viewBox: "0 0 24 24",
6148 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
6149 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"
6150 })
6151 });
6152 /* harmony default export */ const close_small = (closeSmall);
6153
6154 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/deprecated.js
6155 /**
6156 * WordPress dependencies
6157 */
6158
6159 function normalizeComplementaryAreaScope(scope) {
6160 if (['core/edit-post', 'core/edit-site'].includes(scope)) {
6161 external_wp_deprecated_default()(`${scope} interface scope`, {
6162 alternative: 'core interface scope',
6163 hint: 'core/edit-post and core/edit-site are merging.',
6164 version: '6.6'
6165 });
6166 return 'core';
6167 }
6168 return scope;
6169 }
6170 function normalizeComplementaryAreaName(scope, name) {
6171 if (scope === 'core' && name === 'edit-site/template') {
6172 external_wp_deprecated_default()(`edit-site/template sidebar`, {
6173 alternative: 'edit-post/document',
6174 version: '6.6'
6175 });
6176 return 'edit-post/document';
6177 }
6178 if (scope === 'core' && name === 'edit-site/block-inspector') {
6179 external_wp_deprecated_default()(`edit-site/block-inspector sidebar`, {
6180 alternative: 'edit-post/block',
6181 version: '6.6'
6182 });
6183 return 'edit-post/block';
6184 }
6185 return name;
6186 }
6187
6188 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/actions.js
6189 /**
6190 * WordPress dependencies
6191 */
6192
6193
6194
6195 /**
6196 * Internal dependencies
6197 */
6198
6199
6200 /**
6201 * Set a default complementary area.
6202 *
6203 * @param {string} scope Complementary area scope.
6204 * @param {string} area Area identifier.
6205 *
6206 * @return {Object} Action object.
6207 */
6208 const setDefaultComplementaryArea = (scope, area) => {
6209 scope = normalizeComplementaryAreaScope(scope);
6210 area = normalizeComplementaryAreaName(scope, area);
6211 return {
6212 type: 'SET_DEFAULT_COMPLEMENTARY_AREA',
6213 scope,
6214 area
6215 };
6216 };
6217
6218 /**
6219 * Enable the complementary area.
6220 *
6221 * @param {string} scope Complementary area scope.
6222 * @param {string} area Area identifier.
6223 */
6224 const enableComplementaryArea = (scope, area) => ({
6225 registry,
6226 dispatch
6227 }) => {
6228 // Return early if there's no area.
6229 if (!area) {
6230 return;
6231 }
6232 scope = normalizeComplementaryAreaScope(scope);
6233 area = normalizeComplementaryAreaName(scope, area);
6234 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
6235 if (!isComplementaryAreaVisible) {
6236 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', true);
6237 }
6238 dispatch({
6239 type: 'ENABLE_COMPLEMENTARY_AREA',
6240 scope,
6241 area
6242 });
6243 };
6244
6245 /**
6246 * Disable the complementary area.
6247 *
6248 * @param {string} scope Complementary area scope.
6249 */
6250 const disableComplementaryArea = scope => ({
6251 registry
6252 }) => {
6253 scope = normalizeComplementaryAreaScope(scope);
6254 const isComplementaryAreaVisible = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
6255 if (isComplementaryAreaVisible) {
6256 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'isComplementaryAreaVisible', false);
6257 }
6258 };
6259
6260 /**
6261 * Pins an item.
6262 *
6263 * @param {string} scope Item scope.
6264 * @param {string} item Item identifier.
6265 *
6266 * @return {Object} Action object.
6267 */
6268 const pinItem = (scope, item) => ({
6269 registry
6270 }) => {
6271 // Return early if there's no item.
6272 if (!item) {
6273 return;
6274 }
6275 scope = normalizeComplementaryAreaScope(scope);
6276 item = normalizeComplementaryAreaName(scope, item);
6277 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
6278
6279 // The item is already pinned, there's nothing to do.
6280 if (pinnedItems?.[item] === true) {
6281 return;
6282 }
6283 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', {
6284 ...pinnedItems,
6285 [item]: true
6286 });
6287 };
6288
6289 /**
6290 * Unpins an item.
6291 *
6292 * @param {string} scope Item scope.
6293 * @param {string} item Item identifier.
6294 */
6295 const unpinItem = (scope, item) => ({
6296 registry
6297 }) => {
6298 // Return early if there's no item.
6299 if (!item) {
6300 return;
6301 }
6302 scope = normalizeComplementaryAreaScope(scope);
6303 item = normalizeComplementaryAreaName(scope, item);
6304 const pinnedItems = registry.select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
6305 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, 'pinnedItems', {
6306 ...pinnedItems,
6307 [item]: false
6308 });
6309 };
6310
6311 /**
6312 * Returns an action object used in signalling that a feature should be toggled.
6313 *
6314 * @param {string} scope The feature scope (e.g. core/edit-post).
6315 * @param {string} featureName The feature name.
6316 */
6317 function toggleFeature(scope, featureName) {
6318 return function ({
6319 registry
6320 }) {
6321 external_wp_deprecated_default()(`dispatch( 'core/interface' ).toggleFeature`, {
6322 since: '6.0',
6323 alternative: `dispatch( 'core/preferences' ).toggle`
6324 });
6325 registry.dispatch(external_wp_preferences_namespaceObject.store).toggle(scope, featureName);
6326 };
6327 }
6328
6329 /**
6330 * Returns an action object used in signalling that a feature should be set to
6331 * a true or false value
6332 *
6333 * @param {string} scope The feature scope (e.g. core/edit-post).
6334 * @param {string} featureName The feature name.
6335 * @param {boolean} value The value to set.
6336 *
6337 * @return {Object} Action object.
6338 */
6339 function setFeatureValue(scope, featureName, value) {
6340 return function ({
6341 registry
6342 }) {
6343 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureValue`, {
6344 since: '6.0',
6345 alternative: `dispatch( 'core/preferences' ).set`
6346 });
6347 registry.dispatch(external_wp_preferences_namespaceObject.store).set(scope, featureName, !!value);
6348 };
6349 }
6350
6351 /**
6352 * Returns an action object used in signalling that defaults should be set for features.
6353 *
6354 * @param {string} scope The feature scope (e.g. core/edit-post).
6355 * @param {Object<string, boolean>} defaults A key/value map of feature names to values.
6356 *
6357 * @return {Object} Action object.
6358 */
6359 function setFeatureDefaults(scope, defaults) {
6360 return function ({
6361 registry
6362 }) {
6363 external_wp_deprecated_default()(`dispatch( 'core/interface' ).setFeatureDefaults`, {
6364 since: '6.0',
6365 alternative: `dispatch( 'core/preferences' ).setDefaults`
6366 });
6367 registry.dispatch(external_wp_preferences_namespaceObject.store).setDefaults(scope, defaults);
6368 };
6369 }
6370
6371 /**
6372 * Returns an action object used in signalling that the user opened a modal.
6373 *
6374 * @param {string} name A string that uniquely identifies the modal.
6375 *
6376 * @return {Object} Action object.
6377 */
6378 function openModal(name) {
6379 return {
6380 type: 'OPEN_MODAL',
6381 name
6382 };
6383 }
6384
6385 /**
6386 * Returns an action object signalling that the user closed a modal.
6387 *
6388 * @return {Object} Action object.
6389 */
6390 function closeModal() {
6391 return {
6392 type: 'CLOSE_MODAL'
6393 };
6394 }
6395
6396 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/selectors.js
6397 /**
6398 * WordPress dependencies
6399 */
6400
6401
6402
6403
6404 /**
6405 * Internal dependencies
6406 */
6407
6408
6409 /**
6410 * Returns the complementary area that is active in a given scope.
6411 *
6412 * @param {Object} state Global application state.
6413 * @param {string} scope Item scope.
6414 *
6415 * @return {string | null | undefined} The complementary area that is active in the given scope.
6416 */
6417 const getActiveComplementaryArea = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => {
6418 scope = normalizeComplementaryAreaScope(scope);
6419 const isComplementaryAreaVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
6420
6421 // Return `undefined` to indicate that the user has never toggled
6422 // visibility, this is the vanilla default. Other code relies on this
6423 // nuance in the return value.
6424 if (isComplementaryAreaVisible === undefined) {
6425 return undefined;
6426 }
6427
6428 // Return `null` to indicate the user hid the complementary area.
6429 if (isComplementaryAreaVisible === false) {
6430 return null;
6431 }
6432 return state?.complementaryAreas?.[scope];
6433 });
6434 const isComplementaryAreaLoading = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope) => {
6435 scope = normalizeComplementaryAreaScope(scope);
6436 const isVisible = select(external_wp_preferences_namespaceObject.store).get(scope, 'isComplementaryAreaVisible');
6437 const identifier = state?.complementaryAreas?.[scope];
6438 return isVisible && identifier === undefined;
6439 });
6440
6441 /**
6442 * Returns a boolean indicating if an item is pinned or not.
6443 *
6444 * @param {Object} state Global application state.
6445 * @param {string} scope Scope.
6446 * @param {string} item Item to check.
6447 *
6448 * @return {boolean} True if the item is pinned and false otherwise.
6449 */
6450 const isItemPinned = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, item) => {
6451 var _pinnedItems$item;
6452 scope = normalizeComplementaryAreaScope(scope);
6453 item = normalizeComplementaryAreaName(scope, item);
6454 const pinnedItems = select(external_wp_preferences_namespaceObject.store).get(scope, 'pinnedItems');
6455 return (_pinnedItems$item = pinnedItems?.[item]) !== null && _pinnedItems$item !== void 0 ? _pinnedItems$item : true;
6456 });
6457
6458 /**
6459 * Returns a boolean indicating whether a feature is active for a particular
6460 * scope.
6461 *
6462 * @param {Object} state The store state.
6463 * @param {string} scope The scope of the feature (e.g. core/edit-post).
6464 * @param {string} featureName The name of the feature.
6465 *
6466 * @return {boolean} Is the feature enabled?
6467 */
6468 const isFeatureActive = (0,external_wp_data_namespaceObject.createRegistrySelector)(select => (state, scope, featureName) => {
6469 external_wp_deprecated_default()(`select( 'core/interface' ).isFeatureActive( scope, featureName )`, {
6470 since: '6.0',
6471 alternative: `select( 'core/preferences' ).get( scope, featureName )`
6472 });
6473 return !!select(external_wp_preferences_namespaceObject.store).get(scope, featureName);
6474 });
6475
6476 /**
6477 * Returns true if a modal is active, or false otherwise.
6478 *
6479 * @param {Object} state Global application state.
6480 * @param {string} modalName A string that uniquely identifies the modal.
6481 *
6482 * @return {boolean} Whether the modal is active.
6483 */
6484 function isModalActive(state, modalName) {
6485 return state.activeModal === modalName;
6486 }
6487
6488 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/reducer.js
6489 /**
6490 * WordPress dependencies
6491 */
6492
6493 function complementaryAreas(state = {}, action) {
6494 switch (action.type) {
6495 case 'SET_DEFAULT_COMPLEMENTARY_AREA':
6496 {
6497 const {
6498 scope,
6499 area
6500 } = action;
6501
6502 // If there's already an area, don't overwrite it.
6503 if (state[scope]) {
6504 return state;
6505 }
6506 return {
6507 ...state,
6508 [scope]: area
6509 };
6510 }
6511 case 'ENABLE_COMPLEMENTARY_AREA':
6512 {
6513 const {
6514 scope,
6515 area
6516 } = action;
6517 return {
6518 ...state,
6519 [scope]: area
6520 };
6521 }
6522 }
6523 return state;
6524 }
6525
6526 /**
6527 * Reducer for storing the name of the open modal, or null if no modal is open.
6528 *
6529 * @param {Object} state Previous state.
6530 * @param {Object} action Action object containing the `name` of the modal
6531 *
6532 * @return {Object} Updated state
6533 */
6534 function activeModal(state = null, action) {
6535 switch (action.type) {
6536 case 'OPEN_MODAL':
6537 return action.name;
6538 case 'CLOSE_MODAL':
6539 return null;
6540 }
6541 return state;
6542 }
6543 /* harmony default export */ const build_module_store_reducer = ((0,external_wp_data_namespaceObject.combineReducers)({
6544 complementaryAreas,
6545 activeModal
6546 }));
6547
6548 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/constants.js
6549 /**
6550 * The identifier for the data store.
6551 *
6552 * @type {string}
6553 */
6554 const constants_STORE_NAME = 'core/interface';
6555
6556 ;// CONCATENATED MODULE: ./packages/interface/build-module/store/index.js
6557 /**
6558 * WordPress dependencies
6559 */
6560
6561
6562 /**
6563 * Internal dependencies
6564 */
6565
6566
6567
6568
6569
6570 /**
6571 * Store definition for the interface namespace.
6572 *
6573 * @see https://github.com/WordPress/gutenberg/blob/HEAD/packages/data/README.md#createReduxStore
6574 *
6575 * @type {Object}
6576 */
6577 const store = (0,external_wp_data_namespaceObject.createReduxStore)(constants_STORE_NAME, {
6578 reducer: build_module_store_reducer,
6579 actions: store_actions_namespaceObject,
6580 selectors: store_selectors_namespaceObject
6581 });
6582
6583 // Once we build a more generic persistence plugin that works across types of stores
6584 // we'd be able to replace this with a register call.
6585 (0,external_wp_data_namespaceObject.register)(store);
6586
6587 ;// CONCATENATED MODULE: external ["wp","plugins"]
6588 const external_wp_plugins_namespaceObject = window["wp"]["plugins"];
6589 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-context/index.js
6590 /**
6591 * WordPress dependencies
6592 */
6593
6594 /* harmony default export */ const complementary_area_context = ((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
6595 return {
6596 icon: ownProps.icon || context.icon,
6597 identifier: ownProps.identifier || `${context.name}/${ownProps.name}`
6598 };
6599 }));
6600
6601 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-toggle/index.js
6602 /**
6603 * WordPress dependencies
6604 */
6605
6606
6607
6608 /**
6609 * Internal dependencies
6610 */
6611
6612
6613
6614 function ComplementaryAreaToggle({
6615 as = external_wp_components_namespaceObject.Button,
6616 scope,
6617 identifier,
6618 icon,
6619 selectedIcon,
6620 name,
6621 ...props
6622 }) {
6623 const ComponentToUse = as;
6624 const isSelected = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).getActiveComplementaryArea(scope) === identifier, [identifier, scope]);
6625 const {
6626 enableComplementaryArea,
6627 disableComplementaryArea
6628 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
6629 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComponentToUse, {
6630 icon: selectedIcon && isSelected ? selectedIcon : icon,
6631 "aria-controls": identifier.replace('/', ':'),
6632 onClick: () => {
6633 if (isSelected) {
6634 disableComplementaryArea(scope);
6635 } else {
6636 enableComplementaryArea(scope, identifier);
6637 }
6638 },
6639 ...props
6640 });
6641 }
6642 /* harmony default export */ const complementary_area_toggle = (complementary_area_context(ComplementaryAreaToggle));
6643
6644 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-header/index.js
6645 /**
6646 * External dependencies
6647 */
6648
6649
6650 /**
6651 * WordPress dependencies
6652 */
6653
6654
6655 /**
6656 * Internal dependencies
6657 */
6658
6659
6660
6661
6662 const ComplementaryAreaHeader = ({
6663 smallScreenTitle,
6664 children,
6665 className,
6666 toggleButtonProps
6667 }) => {
6668 const toggleButton = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area_toggle, {
6669 icon: close_small,
6670 ...toggleButtonProps
6671 });
6672 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
6673 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
6674 className: "components-panel__header interface-complementary-area-header__small",
6675 children: [smallScreenTitle && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
6676 className: "interface-complementary-area-header__small-title",
6677 children: smallScreenTitle
6678 }), toggleButton]
6679 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
6680 className: dist_clsx('components-panel__header', 'interface-complementary-area-header', className),
6681 tabIndex: -1,
6682 children: [children, toggleButton]
6683 })]
6684 });
6685 };
6686 /* harmony default export */ const complementary_area_header = (ComplementaryAreaHeader);
6687
6688 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/action-item/index.js
6689 /**
6690 * WordPress dependencies
6691 */
6692
6693
6694
6695 const noop = () => {};
6696 function ActionItemSlot({
6697 name,
6698 as: Component = external_wp_components_namespaceObject.ButtonGroup,
6699 fillProps = {},
6700 bubblesVirtually,
6701 ...props
6702 }) {
6703 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Slot, {
6704 name: name,
6705 bubblesVirtually: bubblesVirtually,
6706 fillProps: fillProps,
6707 children: fills => {
6708 if (!external_wp_element_namespaceObject.Children.toArray(fills).length) {
6709 return null;
6710 }
6711
6712 // Special handling exists for backward compatibility.
6713 // It ensures that menu items created by plugin authors aren't
6714 // duplicated with automatically injected menu items coming
6715 // from pinnable plugin sidebars.
6716 // @see https://github.com/WordPress/gutenberg/issues/14457
6717 const initializedByPlugins = [];
6718 external_wp_element_namespaceObject.Children.forEach(fills, ({
6719 props: {
6720 __unstableExplicitMenuItem,
6721 __unstableTarget
6722 }
6723 }) => {
6724 if (__unstableTarget && __unstableExplicitMenuItem) {
6725 initializedByPlugins.push(__unstableTarget);
6726 }
6727 });
6728 const children = external_wp_element_namespaceObject.Children.map(fills, child => {
6729 if (!child.props.__unstableExplicitMenuItem && initializedByPlugins.includes(child.props.__unstableTarget)) {
6730 return null;
6731 }
6732 return child;
6733 });
6734 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Component, {
6735 ...props,
6736 children: children
6737 });
6738 }
6739 });
6740 }
6741 function ActionItem({
6742 name,
6743 as: Component = external_wp_components_namespaceObject.Button,
6744 onClick,
6745 ...props
6746 }) {
6747 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Fill, {
6748 name: name,
6749 children: ({
6750 onClick: fpOnClick
6751 }) => {
6752 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Component, {
6753 onClick: onClick || fpOnClick ? (...args) => {
6754 (onClick || noop)(...args);
6755 (fpOnClick || noop)(...args);
6756 } : undefined,
6757 ...props
6758 });
6759 }
6760 });
6761 }
6762 ActionItem.Slot = ActionItemSlot;
6763 /* harmony default export */ const action_item = (ActionItem);
6764
6765 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area-more-menu-item/index.js
6766 /**
6767 * WordPress dependencies
6768 */
6769
6770
6771
6772 /**
6773 * Internal dependencies
6774 */
6775
6776
6777
6778 const PluginsMenuItem = ({
6779 // Menu item is marked with unstable prop for backward compatibility.
6780 // They are removed so they don't leak to DOM elements.
6781 // @see https://github.com/WordPress/gutenberg/issues/14457
6782 __unstableExplicitMenuItem,
6783 __unstableTarget,
6784 ...restProps
6785 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
6786 ...restProps
6787 });
6788 function ComplementaryAreaMoreMenuItem({
6789 scope,
6790 target,
6791 __unstableExplicitMenuItem,
6792 ...props
6793 }) {
6794 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area_toggle, {
6795 as: toggleProps => {
6796 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item, {
6797 __unstableExplicitMenuItem: __unstableExplicitMenuItem,
6798 __unstableTarget: `${scope}/${target}`,
6799 as: PluginsMenuItem,
6800 name: `${scope}/plugin-more-menu`,
6801 ...toggleProps
6802 });
6803 },
6804 role: "menuitemcheckbox",
6805 selectedIcon: library_check,
6806 name: target,
6807 scope: scope,
6808 ...props
6809 });
6810 }
6811
6812 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/pinned-items/index.js
6813 /**
6814 * External dependencies
6815 */
6816
6817
6818 /**
6819 * WordPress dependencies
6820 */
6821
6822
6823 function PinnedItems({
6824 scope,
6825 ...props
6826 }) {
6827 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Fill, {
6828 name: `PinnedItems/${scope}`,
6829 ...props
6830 });
6831 }
6832 function PinnedItemsSlot({
6833 scope,
6834 className,
6835 ...props
6836 }) {
6837 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Slot, {
6838 name: `PinnedItems/${scope}`,
6839 ...props,
6840 children: fills => fills?.length > 0 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
6841 className: dist_clsx(className, 'interface-pinned-items'),
6842 children: fills
6843 })
6844 });
6845 }
6846 PinnedItems.Slot = PinnedItemsSlot;
6847 /* harmony default export */ const pinned_items = (PinnedItems);
6848
6849 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/complementary-area/index.js
6850 /**
6851 * External dependencies
6852 */
6853
6854
6855 /**
6856 * WordPress dependencies
6857 */
6858
6859
6860
6861
6862
6863
6864
6865
6866
6867 /**
6868 * Internal dependencies
6869 */
6870
6871
6872
6873
6874
6875
6876
6877
6878
6879 const ANIMATION_DURATION = 0.3;
6880 function ComplementaryAreaSlot({
6881 scope,
6882 ...props
6883 }) {
6884 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Slot, {
6885 name: `ComplementaryArea/${scope}`,
6886 ...props
6887 });
6888 }
6889 const SIDEBAR_WIDTH = 280;
6890 const variants = {
6891 open: {
6892 width: SIDEBAR_WIDTH
6893 },
6894 closed: {
6895 width: 0
6896 },
6897 mobileOpen: {
6898 width: '100vw'
6899 }
6900 };
6901 function ComplementaryAreaFill({
6902 activeArea,
6903 isActive,
6904 scope,
6905 children,
6906 className,
6907 id
6908 }) {
6909 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
6910 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
6911 // This is used to delay the exit animation to the next tick.
6912 // The reason this is done is to allow us to apply the right transition properties
6913 // When we switch from an open sidebar to another open sidebar.
6914 // we don't want to animate in this case.
6915 const previousActiveArea = (0,external_wp_compose_namespaceObject.usePrevious)(activeArea);
6916 const previousIsActive = (0,external_wp_compose_namespaceObject.usePrevious)(isActive);
6917 const [, setState] = (0,external_wp_element_namespaceObject.useState)({});
6918 (0,external_wp_element_namespaceObject.useEffect)(() => {
6919 setState({});
6920 }, [isActive]);
6921 const transition = {
6922 type: 'tween',
6923 duration: disableMotion || isMobileViewport || !!previousActiveArea && !!activeArea && activeArea !== previousActiveArea ? 0 : ANIMATION_DURATION,
6924 ease: [0.6, 0, 0.4, 1]
6925 };
6926 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Fill, {
6927 name: `ComplementaryArea/${scope}`,
6928 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
6929 initial: false,
6930 children: (previousIsActive || isActive) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
6931 variants: variants,
6932 initial: "closed",
6933 animate: isMobileViewport ? 'mobileOpen' : 'open',
6934 exit: "closed",
6935 transition: transition,
6936 className: "interface-complementary-area__fill",
6937 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
6938 id: id,
6939 className: className,
6940 style: {
6941 width: isMobileViewport ? '100vw' : SIDEBAR_WIDTH
6942 },
6943 children: children
6944 })
6945 })
6946 })
6947 });
6948 }
6949 function useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall) {
6950 const previousIsSmall = (0,external_wp_element_namespaceObject.useRef)(false);
6951 const shouldOpenWhenNotSmall = (0,external_wp_element_namespaceObject.useRef)(false);
6952 const {
6953 enableComplementaryArea,
6954 disableComplementaryArea
6955 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
6956 (0,external_wp_element_namespaceObject.useEffect)(() => {
6957 // If the complementary area is active and the editor is switching from
6958 // a big to a small window size.
6959 if (isActive && isSmall && !previousIsSmall.current) {
6960 disableComplementaryArea(scope);
6961 // Flag the complementary area to be reopened when the window size
6962 // goes from small to big.
6963 shouldOpenWhenNotSmall.current = true;
6964 } else if (
6965 // If there is a flag indicating the complementary area should be
6966 // enabled when we go from small to big window size and we are going
6967 // from a small to big window size.
6968 shouldOpenWhenNotSmall.current && !isSmall && previousIsSmall.current) {
6969 // Remove the flag indicating the complementary area should be
6970 // enabled.
6971 shouldOpenWhenNotSmall.current = false;
6972 enableComplementaryArea(scope, identifier);
6973 } else if (
6974 // If the flag is indicating the current complementary should be
6975 // reopened but another complementary area becomes active, remove
6976 // the flag.
6977 shouldOpenWhenNotSmall.current && activeArea && activeArea !== identifier) {
6978 shouldOpenWhenNotSmall.current = false;
6979 }
6980 if (isSmall !== previousIsSmall.current) {
6981 previousIsSmall.current = isSmall;
6982 }
6983 }, [isActive, isSmall, scope, identifier, activeArea, disableComplementaryArea, enableComplementaryArea]);
6984 }
6985 function ComplementaryArea({
6986 children,
6987 className,
6988 closeLabel = (0,external_wp_i18n_namespaceObject.__)('Close plugin'),
6989 identifier,
6990 header,
6991 headerClassName,
6992 icon,
6993 isPinnable = true,
6994 panelClassName,
6995 scope,
6996 name,
6997 smallScreenTitle,
6998 title,
6999 toggleShortcut,
7000 isActiveByDefault
7001 }) {
7002 // This state is used to delay the rendering of the Fill
7003 // until the initial effect runs.
7004 // This prevents the animation from running on mount if
7005 // the complementary area is active by default.
7006 const [isReady, setIsReady] = (0,external_wp_element_namespaceObject.useState)(false);
7007 const {
7008 isLoading,
7009 isActive,
7010 isPinned,
7011 activeArea,
7012 isSmall,
7013 isLarge,
7014 showIconLabels
7015 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
7016 const {
7017 getActiveComplementaryArea,
7018 isComplementaryAreaLoading,
7019 isItemPinned
7020 } = select(store);
7021 const {
7022 get
7023 } = select(external_wp_preferences_namespaceObject.store);
7024 const _activeArea = getActiveComplementaryArea(scope);
7025 return {
7026 isLoading: isComplementaryAreaLoading(scope),
7027 isActive: _activeArea === identifier,
7028 isPinned: isItemPinned(scope, identifier),
7029 activeArea: _activeArea,
7030 isSmall: select(external_wp_viewport_namespaceObject.store).isViewportMatch('< medium'),
7031 isLarge: select(external_wp_viewport_namespaceObject.store).isViewportMatch('large'),
7032 showIconLabels: get('core', 'showIconLabels')
7033 };
7034 }, [identifier, scope]);
7035 useAdjustComplementaryListener(scope, identifier, activeArea, isActive, isSmall);
7036 const {
7037 enableComplementaryArea,
7038 disableComplementaryArea,
7039 pinItem,
7040 unpinItem
7041 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
7042 (0,external_wp_element_namespaceObject.useEffect)(() => {
7043 // Set initial visibility: For large screens, enable if it's active by
7044 // default. For small screens, always initially disable.
7045 if (isActiveByDefault && activeArea === undefined && !isSmall) {
7046 enableComplementaryArea(scope, identifier);
7047 } else if (activeArea === undefined && isSmall) {
7048 disableComplementaryArea(scope, identifier);
7049 }
7050 setIsReady(true);
7051 }, [activeArea, isActiveByDefault, scope, identifier, isSmall, enableComplementaryArea, disableComplementaryArea]);
7052 if (!isReady) {
7053 return;
7054 }
7055 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
7056 children: [isPinnable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(pinned_items, {
7057 scope: scope,
7058 children: isPinned && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area_toggle, {
7059 scope: scope,
7060 identifier: identifier,
7061 isPressed: isActive && (!showIconLabels || isLarge),
7062 "aria-expanded": isActive,
7063 "aria-disabled": isLoading,
7064 label: title,
7065 icon: showIconLabels ? library_check : icon,
7066 showTooltip: !showIconLabels,
7067 variant: showIconLabels ? 'tertiary' : undefined,
7068 size: "compact"
7069 })
7070 }), name && isPinnable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaMoreMenuItem, {
7071 target: name,
7072 scope: scope,
7073 icon: icon,
7074 children: title
7075 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(ComplementaryAreaFill, {
7076 activeArea: activeArea,
7077 isActive: isActive,
7078 className: dist_clsx('interface-complementary-area', className),
7079 scope: scope,
7080 id: identifier.replace('/', ':'),
7081 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area_header, {
7082 className: headerClassName,
7083 closeLabel: closeLabel,
7084 onClose: () => disableComplementaryArea(scope),
7085 smallScreenTitle: smallScreenTitle,
7086 toggleButtonProps: {
7087 label: closeLabel,
7088 size: 'small',
7089 shortcut: toggleShortcut,
7090 scope,
7091 identifier
7092 },
7093 children: header || /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
7094 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
7095 className: "interface-complementary-area-header__title",
7096 children: title
7097 }), isPinnable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
7098 className: "interface-complementary-area__pin-unpin-item",
7099 icon: isPinned ? star_filled : star_empty,
7100 label: isPinned ? (0,external_wp_i18n_namespaceObject.__)('Unpin from toolbar') : (0,external_wp_i18n_namespaceObject.__)('Pin to toolbar'),
7101 onClick: () => (isPinned ? unpinItem : pinItem)(scope, identifier),
7102 isPressed: isPinned,
7103 "aria-expanded": isPinned,
7104 size: "compact"
7105 })]
7106 })
7107 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Panel, {
7108 className: panelClassName,
7109 children: children
7110 })]
7111 })]
7112 });
7113 }
7114 const ComplementaryAreaWrapped = complementary_area_context(ComplementaryArea);
7115 ComplementaryAreaWrapped.Slot = ComplementaryAreaSlot;
7116 /* harmony default export */ const complementary_area = (ComplementaryAreaWrapped);
7117
7118 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/fullscreen-mode/index.js
7119 /**
7120 * WordPress dependencies
7121 */
7122
7123 const FullscreenMode = ({
7124 isActive
7125 }) => {
7126 (0,external_wp_element_namespaceObject.useEffect)(() => {
7127 let isSticky = false;
7128 // `is-fullscreen-mode` is set in PHP as a body class by Gutenberg, and this causes
7129 // `sticky-menu` to be applied by WordPress and prevents the admin menu being scrolled
7130 // even if `is-fullscreen-mode` is then removed. Let's remove `sticky-menu` here as
7131 // a consequence of the FullscreenMode setup.
7132 if (document.body.classList.contains('sticky-menu')) {
7133 isSticky = true;
7134 document.body.classList.remove('sticky-menu');
7135 }
7136 return () => {
7137 if (isSticky) {
7138 document.body.classList.add('sticky-menu');
7139 }
7140 };
7141 }, []);
7142 (0,external_wp_element_namespaceObject.useEffect)(() => {
7143 if (isActive) {
7144 document.body.classList.add('is-fullscreen-mode');
7145 } else {
7146 document.body.classList.remove('is-fullscreen-mode');
7147 }
7148 return () => {
7149 if (isActive) {
7150 document.body.classList.remove('is-fullscreen-mode');
7151 }
7152 };
7153 }, [isActive]);
7154 return null;
7155 };
7156 /* harmony default export */ const fullscreen_mode = (FullscreenMode);
7157
7158 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/navigable-region/index.js
7159 /**
7160 * External dependencies
7161 */
7162
7163
7164 function NavigableRegion({
7165 children,
7166 className,
7167 ariaLabel,
7168 as: Tag = 'div',
7169 ...props
7170 }) {
7171 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tag, {
7172 className: dist_clsx('interface-navigable-region', className),
7173 "aria-label": ariaLabel,
7174 role: "region",
7175 tabIndex: "-1",
7176 ...props,
7177 children: children
7178 });
7179 }
7180
7181 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/interface-skeleton/index.js
7182 /**
7183 * External dependencies
7184 */
7185
7186
7187 /**
7188 * WordPress dependencies
7189 */
7190
7191
7192
7193
7194
7195 /**
7196 * Internal dependencies
7197 */
7198
7199
7200
7201 const interface_skeleton_ANIMATION_DURATION = 0.25;
7202 const commonTransition = {
7203 type: 'tween',
7204 duration: interface_skeleton_ANIMATION_DURATION,
7205 ease: [0.6, 0, 0.4, 1]
7206 };
7207 function useHTMLClass(className) {
7208 (0,external_wp_element_namespaceObject.useEffect)(() => {
7209 const element = document && document.querySelector(`html:not(.${className})`);
7210 if (!element) {
7211 return;
7212 }
7213 element.classList.toggle(className);
7214 return () => {
7215 element.classList.toggle(className);
7216 };
7217 }, [className]);
7218 }
7219 const headerVariants = {
7220 hidden: {
7221 opacity: 1,
7222 marginTop: -60
7223 },
7224 visible: {
7225 opacity: 1,
7226 marginTop: 0
7227 },
7228 distractionFreeHover: {
7229 opacity: 1,
7230 marginTop: 0,
7231 transition: {
7232 ...commonTransition,
7233 delay: 0.2,
7234 delayChildren: 0.2
7235 }
7236 },
7237 distractionFreeHidden: {
7238 opacity: 0,
7239 marginTop: -60
7240 },
7241 distractionFreeDisabled: {
7242 opacity: 0,
7243 marginTop: 0,
7244 transition: {
7245 ...commonTransition,
7246 delay: 0.8,
7247 delayChildren: 0.8
7248 }
7249 }
7250 };
7251 function InterfaceSkeleton({
7252 isDistractionFree,
7253 footer,
7254 header,
7255 editorNotices,
7256 sidebar,
7257 secondarySidebar,
7258 content,
7259 actions,
7260 labels,
7261 className,
7262 enableRegionNavigation = true,
7263 // Todo: does this need to be a prop.
7264 // Can we use a dependency to keyboard-shortcuts directly?
7265 shortcuts
7266 }, ref) {
7267 const [secondarySidebarResizeListener, secondarySidebarSize] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
7268 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
7269 const disableMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
7270 const defaultTransition = {
7271 type: 'tween',
7272 duration: disableMotion ? 0 : interface_skeleton_ANIMATION_DURATION,
7273 ease: [0.6, 0, 0.4, 1]
7274 };
7275 const navigateRegionsProps = (0,external_wp_components_namespaceObject.__unstableUseNavigateRegions)(shortcuts);
7276 useHTMLClass('interface-interface-skeleton__html-container');
7277 const defaultLabels = {
7278 /* translators: accessibility text for the top bar landmark region. */
7279 header: (0,external_wp_i18n_namespaceObject._x)('Header', 'header landmark area'),
7280 /* translators: accessibility text for the content landmark region. */
7281 body: (0,external_wp_i18n_namespaceObject.__)('Content'),
7282 /* translators: accessibility text for the secondary sidebar landmark region. */
7283 secondarySidebar: (0,external_wp_i18n_namespaceObject.__)('Block Library'),
7284 /* translators: accessibility text for the settings landmark region. */
7285 sidebar: (0,external_wp_i18n_namespaceObject.__)('Settings'),
7286 /* translators: accessibility text for the publish landmark region. */
7287 actions: (0,external_wp_i18n_namespaceObject.__)('Publish'),
7288 /* translators: accessibility text for the footer landmark region. */
7289 footer: (0,external_wp_i18n_namespaceObject.__)('Footer')
7290 };
7291 const mergedLabels = {
7292 ...defaultLabels,
7293 ...labels
7294 };
7295 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7296 ...(enableRegionNavigation ? navigateRegionsProps : {}),
7297 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([ref, enableRegionNavigation ? navigateRegionsProps.ref : undefined]),
7298 className: dist_clsx(className, 'interface-interface-skeleton', navigateRegionsProps.className, !!footer && 'has-footer'),
7299 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7300 className: "interface-interface-skeleton__editor",
7301 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
7302 initial: false,
7303 children: !!header && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7304 as: external_wp_components_namespaceObject.__unstableMotion.div,
7305 className: "interface-interface-skeleton__header",
7306 "aria-label": mergedLabels.header,
7307 initial: isDistractionFree ? 'distractionFreeHidden' : 'hidden',
7308 whileHover: isDistractionFree ? 'distractionFreeHover' : 'visible',
7309 animate: isDistractionFree ? 'distractionFreeDisabled' : 'visible',
7310 exit: isDistractionFree ? 'distractionFreeHidden' : 'hidden',
7311 variants: headerVariants,
7312 transition: defaultTransition,
7313 children: header
7314 })
7315 }), isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
7316 className: "interface-interface-skeleton__header",
7317 children: editorNotices
7318 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7319 className: "interface-interface-skeleton__body",
7320 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
7321 initial: false,
7322 children: !!secondarySidebar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7323 className: "interface-interface-skeleton__secondary-sidebar",
7324 ariaLabel: mergedLabels.secondarySidebar,
7325 as: external_wp_components_namespaceObject.__unstableMotion.div,
7326 initial: "closed",
7327 animate: isMobileViewport ? 'mobileOpen' : 'open',
7328 exit: "closed",
7329 variants: {
7330 open: {
7331 width: secondarySidebarSize.width
7332 },
7333 closed: {
7334 width: 0
7335 },
7336 mobileOpen: {
7337 width: '100vw'
7338 }
7339 },
7340 transition: defaultTransition,
7341 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7342 style: {
7343 position: 'absolute',
7344 width: isMobileViewport ? '100vw' : 'fit-content',
7345 height: '100%',
7346 right: 0
7347 },
7348 children: [secondarySidebarResizeListener, secondarySidebar]
7349 })
7350 })
7351 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7352 className: "interface-interface-skeleton__content",
7353 ariaLabel: mergedLabels.body,
7354 children: content
7355 }), !!sidebar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7356 className: "interface-interface-skeleton__sidebar",
7357 ariaLabel: mergedLabels.sidebar,
7358 children: sidebar
7359 }), !!actions && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7360 className: "interface-interface-skeleton__actions",
7361 ariaLabel: mergedLabels.actions,
7362 children: actions
7363 })]
7364 })]
7365 }), !!footer && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(NavigableRegion, {
7366 className: "interface-interface-skeleton__footer",
7367 ariaLabel: mergedLabels.footer,
7368 children: footer
7369 })]
7370 });
7371 }
7372 /* harmony default export */ const interface_skeleton = ((0,external_wp_element_namespaceObject.forwardRef)(InterfaceSkeleton));
7373
7374 ;// CONCATENATED MODULE: ./packages/interface/build-module/components/index.js
7375
7376
7377
7378
7379
7380
7381
7382
7383 ;// CONCATENATED MODULE: ./packages/interface/build-module/index.js
7384
7385
7386
7387 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/global-keyboard-shortcuts/index.js
7388 /**
7389 * WordPress dependencies
7390 */
7391
7392
7393
7394
7395
7396 /**
7397 * Internal dependencies
7398 */
7399
7400
7401 /**
7402 * Handles the keyboard shortcuts for the editor.
7403 *
7404 * It provides functionality for various keyboard shortcuts such as toggling editor mode,
7405 * toggling distraction-free mode, undo/redo, saving the post, toggling list view,
7406 * and toggling the sidebar.
7407 */
7408 function EditorKeyboardShortcuts() {
7409 const isModeToggleDisabled = (0,external_wp_data_namespaceObject.useSelect)(select => {
7410 const {
7411 richEditingEnabled,
7412 codeEditingEnabled
7413 } = select(store_store).getEditorSettings();
7414 return !richEditingEnabled || !codeEditingEnabled;
7415 }, []);
7416 const {
7417 getBlockSelectionStart
7418 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
7419 const {
7420 getActiveComplementaryArea
7421 } = (0,external_wp_data_namespaceObject.useSelect)(store);
7422 const {
7423 enableComplementaryArea,
7424 disableComplementaryArea
7425 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
7426 const {
7427 redo,
7428 undo,
7429 savePost,
7430 setIsListViewOpened,
7431 switchEditorMode,
7432 toggleDistractionFree
7433 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
7434 const {
7435 isEditedPostDirty,
7436 isPostSavingLocked,
7437 isListViewOpened,
7438 getEditorMode
7439 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
7440 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-mode', () => {
7441 switchEditorMode(getEditorMode() === 'visual' ? 'text' : 'visual');
7442 }, {
7443 isDisabled: isModeToggleDisabled
7444 });
7445 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-distraction-free', () => {
7446 toggleDistractionFree();
7447 });
7448 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/undo', event => {
7449 undo();
7450 event.preventDefault();
7451 });
7452 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/redo', event => {
7453 redo();
7454 event.preventDefault();
7455 });
7456 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/save', event => {
7457 event.preventDefault();
7458
7459 /**
7460 * Do not save the post if post saving is locked.
7461 */
7462 if (isPostSavingLocked()) {
7463 return;
7464 }
7465
7466 // TODO: This should be handled in the `savePost` effect in
7467 // considering `isSaveable`. See note on `isEditedPostSaveable`
7468 // selector about dirtiness and meta-boxes.
7469 //
7470 // See: `isEditedPostSaveable`
7471 if (!isEditedPostDirty()) {
7472 return;
7473 }
7474 savePost();
7475 });
7476
7477 // Only opens the list view. Other functionality for this shortcut happens in the rendered sidebar.
7478 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-list-view', event => {
7479 if (!isListViewOpened()) {
7480 event.preventDefault();
7481 setIsListViewOpened(true);
7482 }
7483 });
7484 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-sidebar', event => {
7485 // This shortcut has no known clashes, but use preventDefault to prevent any
7486 // obscure shortcuts from triggering.
7487 event.preventDefault();
7488 const isEditorSidebarOpened = ['edit-post/document', 'edit-post/block'].includes(getActiveComplementaryArea('core'));
7489 if (isEditorSidebarOpened) {
7490 disableComplementaryArea('core');
7491 } else {
7492 const sidebarToOpen = getBlockSelectionStart() ? 'edit-post/block' : 'edit-post/document';
7493 enableComplementaryArea('core', sidebarToOpen);
7494 }
7495 });
7496 return null;
7497 }
7498
7499 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/autocompleters/index.js
7500
7501
7502 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/autosave-monitor/index.js
7503 /**
7504 * WordPress dependencies
7505 */
7506
7507
7508
7509
7510
7511 /**
7512 * Internal dependencies
7513 */
7514
7515 class AutosaveMonitor extends external_wp_element_namespaceObject.Component {
7516 constructor(props) {
7517 super(props);
7518 this.needsAutosave = !!(props.isDirty && props.isAutosaveable);
7519 }
7520 componentDidMount() {
7521 if (!this.props.disableIntervalChecks) {
7522 this.setAutosaveTimer();
7523 }
7524 }
7525 componentDidUpdate(prevProps) {
7526 if (this.props.disableIntervalChecks) {
7527 if (this.props.editsReference !== prevProps.editsReference) {
7528 this.props.autosave();
7529 }
7530 return;
7531 }
7532 if (this.props.interval !== prevProps.interval) {
7533 clearTimeout(this.timerId);
7534 this.setAutosaveTimer();
7535 }
7536 if (!this.props.isDirty) {
7537 this.needsAutosave = false;
7538 return;
7539 }
7540 if (this.props.isAutosaving && !prevProps.isAutosaving) {
7541 this.needsAutosave = false;
7542 return;
7543 }
7544 if (this.props.editsReference !== prevProps.editsReference) {
7545 this.needsAutosave = true;
7546 }
7547 }
7548 componentWillUnmount() {
7549 clearTimeout(this.timerId);
7550 }
7551 setAutosaveTimer(timeout = this.props.interval * 1000) {
7552 this.timerId = setTimeout(() => {
7553 this.autosaveTimerHandler();
7554 }, timeout);
7555 }
7556 autosaveTimerHandler() {
7557 if (!this.props.isAutosaveable) {
7558 this.setAutosaveTimer(1000);
7559 return;
7560 }
7561 if (this.needsAutosave) {
7562 this.needsAutosave = false;
7563 this.props.autosave();
7564 }
7565 this.setAutosaveTimer();
7566 }
7567 render() {
7568 return null;
7569 }
7570 }
7571
7572 /**
7573 * Monitors the changes made to the edited post and triggers autosave if necessary.
7574 *
7575 * The logic is straightforward: a check is performed every `props.interval` seconds. If any changes are detected, `props.autosave()` is called.
7576 * 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
7577 * the specific way of detecting changes.
7578 *
7579 * There are two caveats:
7580 * * If `props.isAutosaveable` happens to be false at a time of checking for changes, the check is retried every second.
7581 * * The timer may be disabled by setting `props.disableIntervalChecks` to `true`. In that mode, any change will immediately trigger `props.autosave()`.
7582 *
7583 * @param {Object} props - The properties passed to the component.
7584 * @param {Function} props.autosave - The function to call when changes need to be saved.
7585 * @param {number} props.interval - The maximum time in seconds between an unsaved change and an autosave.
7586 * @param {boolean} props.isAutosaveable - If false, the check for changes is retried every second.
7587 * @param {boolean} props.disableIntervalChecks - If true, disables the timer and any change will immediately trigger `props.autosave()`.
7588 * @param {boolean} props.isDirty - Indicates if there are unsaved changes.
7589 *
7590 * @example
7591 * ```jsx
7592 * <AutosaveMonitor interval={30000} />
7593 * ```
7594 */
7595 /* harmony default export */ const autosave_monitor = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)((select, ownProps) => {
7596 const {
7597 getReferenceByDistinctEdits
7598 } = select(external_wp_coreData_namespaceObject.store);
7599 const {
7600 isEditedPostDirty,
7601 isEditedPostAutosaveable,
7602 isAutosavingPost,
7603 getEditorSettings
7604 } = select(store_store);
7605 const {
7606 interval = getEditorSettings().autosaveInterval
7607 } = ownProps;
7608 return {
7609 editsReference: getReferenceByDistinctEdits(),
7610 isDirty: isEditedPostDirty(),
7611 isAutosaveable: isEditedPostAutosaveable(),
7612 isAutosaving: isAutosavingPost(),
7613 interval
7614 };
7615 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, ownProps) => ({
7616 autosave() {
7617 const {
7618 autosave = dispatch(store_store).autosave
7619 } = ownProps;
7620 autosave();
7621 }
7622 }))])(AutosaveMonitor));
7623
7624 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-right-small.js
7625 /**
7626 * WordPress dependencies
7627 */
7628
7629
7630 const chevronRightSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
7631 xmlns: "http://www.w3.org/2000/svg",
7632 viewBox: "0 0 24 24",
7633 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
7634 d: "M10.8622 8.04053L14.2805 12.0286L10.8622 16.0167L9.72327 15.0405L12.3049 12.0286L9.72327 9.01672L10.8622 8.04053Z"
7635 })
7636 });
7637 /* harmony default export */ const chevron_right_small = (chevronRightSmall);
7638
7639 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/chevron-left-small.js
7640 /**
7641 * WordPress dependencies
7642 */
7643
7644
7645 const chevronLeftSmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
7646 xmlns: "http://www.w3.org/2000/svg",
7647 viewBox: "0 0 24 24",
7648 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
7649 d: "m13.1 16-3.4-4 3.4-4 1.1 1-2.6 3 2.6 3-1.1 1z"
7650 })
7651 });
7652 /* harmony default export */ const chevron_left_small = (chevronLeftSmall);
7653
7654 ;// CONCATENATED MODULE: external ["wp","keycodes"]
7655 const external_wp_keycodes_namespaceObject = window["wp"]["keycodes"];
7656 ;// CONCATENATED MODULE: external ["wp","commands"]
7657 const external_wp_commands_namespaceObject = window["wp"]["commands"];
7658 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-bar/index.js
7659 /**
7660 * External dependencies
7661 */
7662
7663
7664 /**
7665 * WordPress dependencies
7666 */
7667
7668
7669
7670
7671
7672
7673
7674
7675
7676
7677
7678
7679 /**
7680 * Internal dependencies
7681 */
7682
7683
7684
7685
7686
7687 const TYPE_LABELS = {
7688 // translators: 1: Pattern title.
7689 wp_pattern: (0,external_wp_i18n_namespaceObject.__)('Editing pattern: %s'),
7690 // translators: 1: Navigation menu title.
7691 wp_navigation: (0,external_wp_i18n_namespaceObject.__)('Editing navigation menu: %s'),
7692 // translators: 1: Template title.
7693 wp_template: (0,external_wp_i18n_namespaceObject.__)('Editing template: %s'),
7694 // translators: 1: Template part title.
7695 wp_template_part: (0,external_wp_i18n_namespaceObject.__)('Editing template part: %s')
7696 };
7697 const MotionButton = (0,external_wp_components_namespaceObject.__unstableMotion)(external_wp_components_namespaceObject.Button);
7698
7699 /**
7700 * This component renders a navigation bar at the top of the editor. It displays the title of the current document,
7701 * a back button (if applicable), and a command center button. It also handles different states of the document,
7702 * such as "not found" or "unsynced".
7703 *
7704 * @example
7705 * ```jsx
7706 * <DocumentBar />
7707 * ```
7708 * @param {Object} props The component props.
7709 * @param {string} props.title A title for the document, defaulting to the document or
7710 * template title currently being edited.
7711 * @param {import("@wordpress/components").IconType} props.icon An icon for the document, defaulting to an icon for document
7712 * or template currently being edited.
7713 *
7714 * @return {JSX.Element} The rendered DocumentBar component.
7715 */
7716 function DocumentBar(props) {
7717 const {
7718 postType,
7719 documentTitle,
7720 isNotFound,
7721 isUnsyncedPattern,
7722 templateIcon,
7723 templateTitle,
7724 onNavigateToPreviousEntityRecord
7725 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
7726 const {
7727 getCurrentPostType,
7728 getCurrentPostId,
7729 getEditorSettings,
7730 __experimentalGetTemplateInfo: getTemplateInfo
7731 } = select(store_store);
7732 const {
7733 getEditedEntityRecord,
7734 isResolving: isResolvingSelector
7735 } = select(external_wp_coreData_namespaceObject.store);
7736 const _postType = getCurrentPostType();
7737 const _postId = getCurrentPostId();
7738 const _document = getEditedEntityRecord('postType', _postType, _postId);
7739 const _templateInfo = getTemplateInfo(_document);
7740 return {
7741 postType: _postType,
7742 documentTitle: _document.title,
7743 isNotFound: !_document && !isResolvingSelector('getEditedEntityRecord', 'postType', _postType, _postId),
7744 isUnsyncedPattern: _document?.wp_pattern_sync_status === 'unsynced',
7745 templateIcon: unlock(select(store_store)).getPostIcon(_postType, {
7746 area: _document?.area
7747 }),
7748 templateTitle: _templateInfo.title,
7749 onNavigateToPreviousEntityRecord: getEditorSettings().onNavigateToPreviousEntityRecord
7750 };
7751 }, []);
7752 const {
7753 open: openCommandCenter
7754 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_commands_namespaceObject.store);
7755 const isReducedMotion = (0,external_wp_compose_namespaceObject.useReducedMotion)();
7756 const isTemplate = TEMPLATE_POST_TYPES.includes(postType);
7757 const isGlobalEntity = GLOBAL_POST_TYPES.includes(postType);
7758 const hasBackButton = !!onNavigateToPreviousEntityRecord;
7759 const entityTitle = isTemplate ? templateTitle : documentTitle;
7760 const title = props.title || entityTitle;
7761 const icon = props.icon || templateIcon;
7762 const mounted = (0,external_wp_element_namespaceObject.useRef)(false);
7763 (0,external_wp_element_namespaceObject.useEffect)(() => {
7764 mounted.current = true;
7765 }, []);
7766 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
7767 className: dist_clsx('editor-document-bar', {
7768 'has-back-button': hasBackButton,
7769 'is-global': isGlobalEntity && !isUnsyncedPattern
7770 }),
7771 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
7772 children: hasBackButton && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MotionButton, {
7773 className: "editor-document-bar__back",
7774 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? chevron_right_small : chevron_left_small,
7775 onClick: event => {
7776 event.stopPropagation();
7777 onNavigateToPreviousEntityRecord();
7778 },
7779 size: "compact",
7780 initial: mounted.current ? {
7781 opacity: 0,
7782 transform: 'translateX(15%)'
7783 } : false // Don't show entry animation when DocumentBar mounts.
7784 ,
7785 animate: {
7786 opacity: 1,
7787 transform: 'translateX(0%)'
7788 },
7789 exit: {
7790 opacity: 0,
7791 transform: 'translateX(15%)'
7792 },
7793 transition: isReducedMotion ? {
7794 duration: 0
7795 } : undefined,
7796 children: (0,external_wp_i18n_namespaceObject.__)('Back')
7797 })
7798 }), isNotFound ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
7799 children: (0,external_wp_i18n_namespaceObject.__)('Document not found')
7800 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
7801 className: "editor-document-bar__command",
7802 onClick: () => openCommandCenter(),
7803 size: "compact",
7804 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
7805 className: "editor-document-bar__title"
7806 // Force entry animation when the back button is added or removed.
7807 ,
7808
7809 initial: mounted.current ? {
7810 opacity: 0,
7811 transform: hasBackButton ? 'translateX(15%)' : 'translateX(-15%)'
7812 } : false // Don't show entry animation when DocumentBar mounts.
7813 ,
7814 animate: {
7815 opacity: 1,
7816 transform: 'translateX(0%)'
7817 },
7818 transition: isReducedMotion ? {
7819 duration: 0
7820 } : undefined,
7821 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockIcon, {
7822 icon: icon
7823 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
7824 size: "body",
7825 as: "h1",
7826 "aria-label": !props.title && TYPE_LABELS[postType] ?
7827 // eslint-disable-next-line @wordpress/valid-sprintf
7828 (0,external_wp_i18n_namespaceObject.sprintf)(TYPE_LABELS[postType], title) : undefined,
7829 children: title ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title) : (0,external_wp_i18n_namespaceObject.__)('No Title')
7830 })]
7831 }, hasBackButton), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
7832 className: "editor-document-bar__shortcut",
7833 children: external_wp_keycodes_namespaceObject.displayShortcut.primary('k')
7834 })]
7835 })]
7836 });
7837 }
7838
7839 ;// CONCATENATED MODULE: external ["wp","richText"]
7840 const external_wp_richText_namespaceObject = window["wp"]["richText"];
7841 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-outline/item.js
7842 /**
7843 * External dependencies
7844 */
7845
7846
7847
7848 const TableOfContentsItem = ({
7849 children,
7850 isValid,
7851 level,
7852 href,
7853 onSelect
7854 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
7855 className: dist_clsx('document-outline__item', `is-${level.toLowerCase()}`, {
7856 'is-invalid': !isValid
7857 }),
7858 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("a", {
7859 href: href,
7860 className: "document-outline__button",
7861 onClick: onSelect,
7862 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
7863 className: "document-outline__emdash",
7864 "aria-hidden": "true"
7865 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
7866 className: "document-outline__level",
7867 children: level
7868 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
7869 className: "document-outline__item-content",
7870 children: children
7871 })]
7872 })
7873 });
7874 /* harmony default export */ const document_outline_item = (TableOfContentsItem);
7875
7876 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-outline/index.js
7877 /**
7878 * WordPress dependencies
7879 */
7880
7881
7882
7883
7884
7885
7886
7887 /**
7888 * Internal dependencies
7889 */
7890
7891
7892
7893 /**
7894 * Module constants
7895 */
7896
7897
7898 const emptyHeadingContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
7899 children: (0,external_wp_i18n_namespaceObject.__)('(Empty heading)')
7900 });
7901 const incorrectLevelContent = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}, "incorrect-break"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
7902 children: (0,external_wp_i18n_namespaceObject.__)('(Incorrect heading level)')
7903 }, "incorrect-message")];
7904 const singleH1Headings = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}, "incorrect-break-h1"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
7905 children: (0,external_wp_i18n_namespaceObject.__)('(Your theme may already use a H1 for the post title)')
7906 }, "incorrect-message-h1")];
7907 const multipleH1Headings = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("br", {}, "incorrect-break-multiple-h1"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("em", {
7908 children: (0,external_wp_i18n_namespaceObject.__)('(Multiple H1 headings are not recommended)')
7909 }, "incorrect-message-multiple-h1")];
7910 function EmptyOutlineIllustration() {
7911 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.SVG, {
7912 width: "138",
7913 height: "148",
7914 viewBox: "0 0 138 148",
7915 fill: "none",
7916 xmlns: "http://www.w3.org/2000/svg",
7917 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
7918 width: "138",
7919 height: "148",
7920 rx: "4",
7921 fill: "#F0F6FC"
7922 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
7923 x1: "44",
7924 y1: "28",
7925 x2: "24",
7926 y2: "28",
7927 stroke: "#DDDDDD"
7928 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
7929 x: "48",
7930 y: "16",
7931 width: "27",
7932 height: "23",
7933 rx: "4",
7934 fill: "#DDDDDD"
7935 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
7936 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",
7937 fill: "black"
7938 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
7939 x1: "55",
7940 y1: "59",
7941 x2: "24",
7942 y2: "59",
7943 stroke: "#DDDDDD"
7944 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
7945 x: "59",
7946 y: "47",
7947 width: "29",
7948 height: "23",
7949 rx: "4",
7950 fill: "#DDDDDD"
7951 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
7952 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",
7953 fill: "black"
7954 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
7955 x1: "80",
7956 y1: "90",
7957 x2: "24",
7958 y2: "90",
7959 stroke: "#DDDDDD"
7960 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
7961 x: "84",
7962 y: "78",
7963 width: "30",
7964 height: "23",
7965 rx: "4",
7966 fill: "#F0B849"
7967 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
7968 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",
7969 fill: "black"
7970 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Line, {
7971 x1: "66",
7972 y1: "121",
7973 x2: "24",
7974 y2: "121",
7975 stroke: "#DDDDDD"
7976 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Rect, {
7977 x: "70",
7978 y: "109",
7979 width: "29",
7980 height: "23",
7981 rx: "4",
7982 fill: "#DDDDDD"
7983 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
7984 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",
7985 fill: "black"
7986 })]
7987 });
7988 }
7989
7990 /**
7991 * Returns an array of heading blocks enhanced with the following properties:
7992 * level - An integer with the heading level.
7993 * isEmpty - Flag indicating if the heading has no content.
7994 *
7995 * @param {?Array} blocks An array of blocks.
7996 *
7997 * @return {Array} An array of heading blocks enhanced with the properties described above.
7998 */
7999 const computeOutlineHeadings = (blocks = []) => {
8000 return blocks.flatMap((block = {}) => {
8001 if (block.name === 'core/heading') {
8002 return {
8003 ...block,
8004 level: block.attributes.level,
8005 isEmpty: isEmptyHeading(block)
8006 };
8007 }
8008 return computeOutlineHeadings(block.innerBlocks);
8009 });
8010 };
8011 const isEmptyHeading = heading => !heading.attributes.content || heading.attributes.content.trim().length === 0;
8012
8013 /**
8014 * Renders a document outline component.
8015 *
8016 * @param {Object} props Props.
8017 * @param {Function} props.onSelect Function to be called when an outline item is selected.
8018 * @param {boolean} props.isTitleSupported Indicates whether the title is supported.
8019 * @param {boolean} props.hasOutlineItemsDisabled Indicates whether the outline items are disabled.
8020 *
8021 * @return {Component} The component to be rendered.
8022 */
8023 function DocumentOutline({
8024 onSelect,
8025 isTitleSupported,
8026 hasOutlineItemsDisabled
8027 }) {
8028 const {
8029 selectBlock
8030 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
8031 const {
8032 blocks,
8033 title
8034 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8035 var _postType$supports$ti;
8036 const {
8037 getBlocks
8038 } = select(external_wp_blockEditor_namespaceObject.store);
8039 const {
8040 getEditedPostAttribute
8041 } = select(store_store);
8042 const {
8043 getPostType
8044 } = select(external_wp_coreData_namespaceObject.store);
8045 const postType = getPostType(getEditedPostAttribute('type'));
8046 return {
8047 title: getEditedPostAttribute('title'),
8048 blocks: getBlocks(),
8049 isTitleSupported: (_postType$supports$ti = postType?.supports?.title) !== null && _postType$supports$ti !== void 0 ? _postType$supports$ti : false
8050 };
8051 });
8052 const headings = computeOutlineHeadings(blocks);
8053 if (headings.length < 1) {
8054 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
8055 className: "editor-document-outline has-no-headings",
8056 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EmptyOutlineIllustration, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
8057 children: (0,external_wp_i18n_namespaceObject.__)('Navigate the structure of your document and address issues like empty or incorrect heading levels.')
8058 })]
8059 });
8060 }
8061 let prevHeadingLevel = 1;
8062
8063 // Not great but it's the simplest way to locate the title right now.
8064 const titleNode = document.querySelector('.editor-post-title__input');
8065 const hasTitle = isTitleSupported && title && titleNode;
8066 const countByLevel = headings.reduce((acc, heading) => ({
8067 ...acc,
8068 [heading.level]: (acc[heading.level] || 0) + 1
8069 }), {});
8070 const hasMultipleH1 = countByLevel[1] > 1;
8071 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
8072 className: "document-outline",
8073 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("ul", {
8074 children: [hasTitle && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(document_outline_item, {
8075 level: (0,external_wp_i18n_namespaceObject.__)('Title'),
8076 isValid: true,
8077 onSelect: onSelect,
8078 href: `#${titleNode.id}`,
8079 isDisabled: hasOutlineItemsDisabled,
8080 children: title
8081 }), headings.map((item, index) => {
8082 // Headings remain the same, go up by one, or down by any amount.
8083 // Otherwise there are missing levels.
8084 const isIncorrectLevel = item.level > prevHeadingLevel + 1;
8085 const isValid = !item.isEmpty && !isIncorrectLevel && !!item.level && (item.level !== 1 || !hasMultipleH1 && !hasTitle);
8086 prevHeadingLevel = item.level;
8087 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(document_outline_item, {
8088 level: `H${item.level}`,
8089 isValid: isValid,
8090 isDisabled: hasOutlineItemsDisabled,
8091 href: `#block-${item.clientId}`,
8092 onSelect: () => {
8093 selectBlock(item.clientId);
8094 onSelect?.();
8095 },
8096 children: [item.isEmpty ? emptyHeadingContent : (0,external_wp_richText_namespaceObject.getTextContent)((0,external_wp_richText_namespaceObject.create)({
8097 html: item.attributes.content
8098 })), isIncorrectLevel && incorrectLevelContent, item.level === 1 && hasMultipleH1 && multipleH1Headings, hasTitle && item.level === 1 && !hasMultipleH1 && singleH1Headings]
8099 }, index);
8100 })]
8101 })
8102 });
8103 }
8104
8105 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-outline/check.js
8106 /**
8107 * WordPress dependencies
8108 */
8109
8110
8111
8112 /**
8113 * Component check if there are any headings (core/heading blocks) present in the document.
8114 *
8115 * @param {Object} props Props.
8116 * @param {Element} props.children Children to be rendered.
8117 *
8118 * @return {Component|null} The component to be rendered or null if there are headings.
8119 */
8120 function DocumentOutlineCheck({
8121 children
8122 }) {
8123 const hasHeadings = (0,external_wp_data_namespaceObject.useSelect)(select => {
8124 const {
8125 getGlobalBlockCount
8126 } = select(external_wp_blockEditor_namespaceObject.store);
8127 return getGlobalBlockCount('core/heading') > 0;
8128 });
8129 if (hasHeadings) {
8130 return null;
8131 }
8132 return children;
8133 }
8134
8135 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/global-keyboard-shortcuts/register-shortcuts.js
8136 /**
8137 * WordPress dependencies
8138 */
8139
8140
8141
8142
8143
8144
8145
8146 /**
8147 * Component for registering editor keyboard shortcuts.
8148 *
8149 * @return {Element} The component to be rendered.
8150 */
8151
8152 function EditorKeyboardShortcutsRegister() {
8153 // Registering the shortcuts.
8154 const {
8155 registerShortcut
8156 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_keyboardShortcuts_namespaceObject.store);
8157 (0,external_wp_element_namespaceObject.useEffect)(() => {
8158 registerShortcut({
8159 name: 'core/editor/toggle-mode',
8160 category: 'global',
8161 description: (0,external_wp_i18n_namespaceObject.__)('Switch between visual editor and code editor.'),
8162 keyCombination: {
8163 modifier: 'secondary',
8164 character: 'm'
8165 }
8166 });
8167 registerShortcut({
8168 name: 'core/editor/save',
8169 category: 'global',
8170 description: (0,external_wp_i18n_namespaceObject.__)('Save your changes.'),
8171 keyCombination: {
8172 modifier: 'primary',
8173 character: 's'
8174 }
8175 });
8176 registerShortcut({
8177 name: 'core/editor/undo',
8178 category: 'global',
8179 description: (0,external_wp_i18n_namespaceObject.__)('Undo your last changes.'),
8180 keyCombination: {
8181 modifier: 'primary',
8182 character: 'z'
8183 }
8184 });
8185 registerShortcut({
8186 name: 'core/editor/redo',
8187 category: 'global',
8188 description: (0,external_wp_i18n_namespaceObject.__)('Redo your last undo.'),
8189 keyCombination: {
8190 modifier: 'primaryShift',
8191 character: 'z'
8192 },
8193 // Disable on Apple OS because it conflicts with the browser's
8194 // history shortcut. It's a fine alias for both Windows and Linux.
8195 // Since there's no conflict for Ctrl+Shift+Z on both Windows and
8196 // Linux, we keep it as the default for consistency.
8197 aliases: (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? [] : [{
8198 modifier: 'primary',
8199 character: 'y'
8200 }]
8201 });
8202 registerShortcut({
8203 name: 'core/editor/toggle-list-view',
8204 category: 'global',
8205 description: (0,external_wp_i18n_namespaceObject.__)('Open the List View.'),
8206 keyCombination: {
8207 modifier: 'access',
8208 character: 'o'
8209 }
8210 });
8211 registerShortcut({
8212 name: 'core/editor/toggle-distraction-free',
8213 category: 'global',
8214 description: (0,external_wp_i18n_namespaceObject.__)('Toggle distraction free mode.'),
8215 keyCombination: {
8216 modifier: 'primaryShift',
8217 character: '\\'
8218 }
8219 });
8220 registerShortcut({
8221 name: 'core/editor/toggle-sidebar',
8222 category: 'global',
8223 description: (0,external_wp_i18n_namespaceObject.__)('Show or hide the Settings sidebar.'),
8224 keyCombination: {
8225 modifier: 'primaryShift',
8226 character: ','
8227 }
8228 });
8229 registerShortcut({
8230 name: 'core/editor/keyboard-shortcuts',
8231 category: 'main',
8232 description: (0,external_wp_i18n_namespaceObject.__)('Display these keyboard shortcuts.'),
8233 keyCombination: {
8234 modifier: 'access',
8235 character: 'h'
8236 }
8237 });
8238 registerShortcut({
8239 name: 'core/editor/next-region',
8240 category: 'global',
8241 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the next part of the editor.'),
8242 keyCombination: {
8243 modifier: 'ctrl',
8244 character: '`'
8245 },
8246 aliases: [{
8247 modifier: 'access',
8248 character: 'n'
8249 }]
8250 });
8251 registerShortcut({
8252 name: 'core/editor/previous-region',
8253 category: 'global',
8254 description: (0,external_wp_i18n_namespaceObject.__)('Navigate to the previous part of the editor.'),
8255 keyCombination: {
8256 modifier: 'ctrlShift',
8257 character: '`'
8258 },
8259 aliases: [{
8260 modifier: 'access',
8261 character: 'p'
8262 }, {
8263 modifier: 'ctrlShift',
8264 character: '~'
8265 }]
8266 });
8267 }, [registerShortcut]);
8268 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts.Register, {});
8269 }
8270 /* harmony default export */ const register_shortcuts = (EditorKeyboardShortcutsRegister);
8271
8272 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/redo.js
8273 /**
8274 * WordPress dependencies
8275 */
8276
8277
8278 const redo_redo = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8279 xmlns: "http://www.w3.org/2000/svg",
8280 viewBox: "0 0 24 24",
8281 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8282 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"
8283 })
8284 });
8285 /* harmony default export */ const library_redo = (redo_redo);
8286
8287 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/undo.js
8288 /**
8289 * WordPress dependencies
8290 */
8291
8292
8293 const undo_undo = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
8294 xmlns: "http://www.w3.org/2000/svg",
8295 viewBox: "0 0 24 24",
8296 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
8297 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"
8298 })
8299 });
8300 /* harmony default export */ const library_undo = (undo_undo);
8301
8302 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-history/redo.js
8303 /**
8304 * WordPress dependencies
8305 */
8306
8307
8308
8309
8310
8311
8312
8313 /**
8314 * Internal dependencies
8315 */
8316
8317
8318 function EditorHistoryRedo(props, ref) {
8319 const shortcut = (0,external_wp_keycodes_namespaceObject.isAppleOS)() ? external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('z') : external_wp_keycodes_namespaceObject.displayShortcut.primary('y');
8320 const hasRedo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorRedo(), []);
8321 const {
8322 redo
8323 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
8324 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8325 ...props,
8326 ref: ref,
8327 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_redo : library_undo
8328 /* translators: button label text should, if possible, be under 16 characters. */,
8329 label: (0,external_wp_i18n_namespaceObject.__)('Redo'),
8330 shortcut: shortcut
8331 // If there are no redo levels we don't want to actually disable this
8332 // button, because it will remove focus for keyboard users.
8333 // See: https://github.com/WordPress/gutenberg/issues/3486
8334 ,
8335 "aria-disabled": !hasRedo,
8336 onClick: hasRedo ? redo : undefined,
8337 className: "editor-history__redo"
8338 });
8339 }
8340
8341 /** @typedef {import('react').Ref<HTMLElement>} Ref */
8342
8343 /**
8344 * Renders the redo button for the editor history.
8345 *
8346 * @param {Object} props - Props.
8347 * @param {Ref} ref - Forwarded ref.
8348 *
8349 * @return {Component} The component to be rendered.
8350 */
8351 /* harmony default export */ const editor_history_redo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryRedo));
8352
8353 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-history/undo.js
8354 /**
8355 * WordPress dependencies
8356 */
8357
8358
8359
8360
8361
8362
8363
8364 /**
8365 * Internal dependencies
8366 */
8367
8368
8369 function EditorHistoryUndo(props, ref) {
8370 const hasUndo = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).hasEditorUndo(), []);
8371 const {
8372 undo
8373 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
8374 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8375 ...props,
8376 ref: ref,
8377 icon: !(0,external_wp_i18n_namespaceObject.isRTL)() ? library_undo : library_redo
8378 /* translators: button label text should, if possible, be under 16 characters. */,
8379 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
8380 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primary('z')
8381 // If there are no undo levels we don't want to actually disable this
8382 // button, because it will remove focus for keyboard users.
8383 // See: https://github.com/WordPress/gutenberg/issues/3486
8384 ,
8385 "aria-disabled": !hasUndo,
8386 onClick: hasUndo ? undo : undefined,
8387 className: "editor-history__undo"
8388 });
8389 }
8390
8391 /** @typedef {import('react').Ref<HTMLElement>} Ref */
8392
8393 /**
8394 * Renders the undo button for the editor history.
8395 *
8396 * @param {Object} props - Props.
8397 * @param {Ref} ref - Forwarded ref.
8398 *
8399 * @return {Component} The component to be rendered.
8400 */
8401 /* harmony default export */ const editor_history_undo = ((0,external_wp_element_namespaceObject.forwardRef)(EditorHistoryUndo));
8402
8403 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-validation-notice/index.js
8404 /**
8405 * WordPress dependencies
8406 */
8407
8408
8409
8410
8411
8412
8413
8414
8415 function TemplateValidationNotice() {
8416 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
8417 const isValid = (0,external_wp_data_namespaceObject.useSelect)(select => {
8418 return select(external_wp_blockEditor_namespaceObject.store).isValidTemplate();
8419 }, []);
8420 const {
8421 setTemplateValidity,
8422 synchronizeTemplate
8423 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
8424 if (isValid) {
8425 return null;
8426 }
8427 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
8428 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
8429 className: "editor-template-validation-notice",
8430 isDismissible: false,
8431 status: "warning",
8432 actions: [{
8433 label: (0,external_wp_i18n_namespaceObject.__)('Keep it as is'),
8434 onClick: () => setTemplateValidity(true)
8435 }, {
8436 label: (0,external_wp_i18n_namespaceObject.__)('Reset the template'),
8437 onClick: () => setShowConfirmDialog(true)
8438 }],
8439 children: (0,external_wp_i18n_namespaceObject.__)('The content of your post doesn’t match the template assigned to your post type.')
8440 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
8441 isOpen: showConfirmDialog,
8442 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Reset'),
8443 onConfirm: () => {
8444 setShowConfirmDialog(false);
8445 synchronizeTemplate();
8446 },
8447 onCancel: () => setShowConfirmDialog(false),
8448 size: "medium",
8449 children: (0,external_wp_i18n_namespaceObject.__)('Resetting the template may result in loss of content, do you want to continue?')
8450 })]
8451 });
8452 }
8453
8454 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-notices/index.js
8455 /**
8456 * WordPress dependencies
8457 */
8458
8459
8460
8461
8462 /**
8463 * Internal dependencies
8464 */
8465
8466
8467 /**
8468 * This component renders the notices displayed in the editor. It displays pinned notices first, followed by dismissible
8469 *
8470 * @example
8471 * ```jsx
8472 * <EditorNotices />
8473 * ```
8474 *
8475 * @return {JSX.Element} The rendered EditorNotices component.
8476 */
8477
8478
8479
8480 function EditorNotices() {
8481 const {
8482 notices
8483 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
8484 notices: select(external_wp_notices_namespaceObject.store).getNotices()
8485 }), []);
8486 const {
8487 removeNotice
8488 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
8489 const dismissibleNotices = notices.filter(({
8490 isDismissible,
8491 type
8492 }) => isDismissible && type === 'default');
8493 const nonDismissibleNotices = notices.filter(({
8494 isDismissible,
8495 type
8496 }) => !isDismissible && type === 'default');
8497 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
8498 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.NoticeList, {
8499 notices: nonDismissibleNotices,
8500 className: "components-editor-notices__pinned"
8501 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.NoticeList, {
8502 notices: dismissibleNotices,
8503 className: "components-editor-notices__dismissible",
8504 onRemove: removeNotice,
8505 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateValidationNotice, {})
8506 })]
8507 });
8508 }
8509 /* harmony default export */ const editor_notices = (EditorNotices);
8510
8511 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-snackbars/index.js
8512 /**
8513 * WordPress dependencies
8514 */
8515
8516
8517
8518
8519 // Last three notices. Slices from the tail end of the list.
8520
8521 const MAX_VISIBLE_NOTICES = -3;
8522
8523 /**
8524 * Renders the editor snackbars component.
8525 *
8526 * @return {JSX.Element} The rendered component.
8527 */
8528 function EditorSnackbars() {
8529 const notices = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_notices_namespaceObject.store).getNotices(), []);
8530 const {
8531 removeNotice
8532 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
8533 const snackbarNotices = notices.filter(({
8534 type
8535 }) => type === 'snackbar').slice(MAX_VISIBLE_NOTICES);
8536 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SnackbarList, {
8537 notices: snackbarNotices,
8538 className: "components-editor-notices__snackbar",
8539 onRemove: removeNotice
8540 });
8541 }
8542
8543 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/entities-saved-states/entity-record-item.js
8544 /**
8545 * WordPress dependencies
8546 */
8547
8548
8549
8550
8551
8552
8553 /**
8554 * Internal dependencies
8555 */
8556
8557
8558
8559
8560
8561 function EntityRecordItem({
8562 record,
8563 checked,
8564 onChange
8565 }) {
8566 const {
8567 name,
8568 kind,
8569 title,
8570 key
8571 } = record;
8572
8573 // Handle templates that might use default descriptive titles.
8574 const {
8575 entityRecordTitle,
8576 hasPostMetaChanges
8577 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8578 if ('postType' !== kind || 'wp_template' !== name) {
8579 return {
8580 entityRecordTitle: title,
8581 hasPostMetaChanges: unlock(select(store_store)).hasPostMetaChanges(name, key)
8582 };
8583 }
8584 const template = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord(kind, name, key);
8585 return {
8586 entityRecordTitle: select(store_store).__experimentalGetTemplateInfo(template).title,
8587 hasPostMetaChanges: unlock(select(store_store)).hasPostMetaChanges(name, key)
8588 };
8589 }, [name, kind, title, key]);
8590 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
8591 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
8592 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
8593 __nextHasNoMarginBottom: true,
8594 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(entityRecordTitle) || (0,external_wp_i18n_namespaceObject.__)('Untitled'),
8595 checked: checked,
8596 onChange: onChange
8597 })
8598 }), hasPostMetaChanges && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
8599 className: "entities-saved-states__changes",
8600 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
8601 children: (0,external_wp_i18n_namespaceObject.__)('Post Meta.')
8602 })
8603 })]
8604 });
8605 }
8606
8607 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/entities-saved-states/entity-type-list.js
8608 /**
8609 * WordPress dependencies
8610 */
8611
8612
8613
8614
8615
8616
8617
8618 /**
8619 * Internal dependencies
8620 */
8621
8622
8623
8624
8625 const {
8626 getGlobalStylesChanges,
8627 GlobalStylesContext
8628 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
8629 function getEntityDescription(entity, count) {
8630 switch (entity) {
8631 case 'site':
8632 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.');
8633 case 'wp_template':
8634 return (0,external_wp_i18n_namespaceObject.__)('This change will affect pages and posts that use this template.');
8635 case 'page':
8636 case 'post':
8637 return (0,external_wp_i18n_namespaceObject.__)('The following has been modified.');
8638 }
8639 }
8640 function GlobalStylesDescription({
8641 record
8642 }) {
8643 const {
8644 user: currentEditorGlobalStyles
8645 } = (0,external_wp_element_namespaceObject.useContext)(GlobalStylesContext);
8646 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]);
8647 const globalStylesChanges = getGlobalStylesChanges(currentEditorGlobalStyles, savedRecord, {
8648 maxResults: 10
8649 });
8650 return globalStylesChanges.length ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
8651 className: "entities-saved-states__changes",
8652 children: globalStylesChanges.map(change => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
8653 children: change
8654 }, change))
8655 }) : null;
8656 }
8657 function EntityDescription({
8658 record,
8659 count
8660 }) {
8661 if ('globalStyles' === record?.name) {
8662 return null;
8663 }
8664 const description = getEntityDescription(record?.name, count);
8665 return description ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
8666 children: description
8667 }) : null;
8668 }
8669 function EntityTypeList({
8670 list,
8671 unselectedEntities,
8672 setUnselectedEntities
8673 }) {
8674 const count = list.length;
8675 const firstRecord = list[0];
8676 const entityConfig = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityConfig(firstRecord.kind, firstRecord.name), [firstRecord.kind, firstRecord.name]);
8677 let entityLabel = entityConfig.label;
8678 if (firstRecord?.name === 'wp_template_part') {
8679 entityLabel = 1 === count ? (0,external_wp_i18n_namespaceObject.__)('Template Part') : (0,external_wp_i18n_namespaceObject.__)('Template Parts');
8680 }
8681 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
8682 title: entityLabel,
8683 initialOpen: true,
8684 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityDescription, {
8685 record: firstRecord,
8686 count: count
8687 }), list.map(record => {
8688 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityRecordItem, {
8689 record: record,
8690 checked: !unselectedEntities.some(elt => elt.kind === record.kind && elt.name === record.name && elt.key === record.key && elt.property === record.property),
8691 onChange: value => setUnselectedEntities(record, value)
8692 }, record.key || record.property);
8693 }), 'globalStyles' === firstRecord?.name && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(GlobalStylesDescription, {
8694 record: firstRecord
8695 })]
8696 });
8697 }
8698
8699 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/entities-saved-states/hooks/use-is-dirty.js
8700 /**
8701 * WordPress dependencies
8702 */
8703
8704
8705
8706
8707 /**
8708 * Custom hook that determines if any entities are dirty (edited) and provides a way to manage selected/unselected entities.
8709 *
8710 * @return {Object} An object containing the following properties:
8711 * - dirtyEntityRecords: An array of dirty entity records.
8712 * - isDirty: A boolean indicating if there are any dirty entity records.
8713 * - setUnselectedEntities: A function to set the unselected entities.
8714 * - unselectedEntities: An array of unselected entities.
8715 */
8716 const useIsDirty = () => {
8717 const {
8718 editedEntities,
8719 siteEdits,
8720 siteEntityConfig
8721 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
8722 const {
8723 __experimentalGetDirtyEntityRecords,
8724 getEntityRecordEdits,
8725 getEntityConfig
8726 } = select(external_wp_coreData_namespaceObject.store);
8727 return {
8728 editedEntities: __experimentalGetDirtyEntityRecords(),
8729 siteEdits: getEntityRecordEdits('root', 'site'),
8730 siteEntityConfig: getEntityConfig('root', 'site')
8731 };
8732 }, []);
8733 const dirtyEntityRecords = (0,external_wp_element_namespaceObject.useMemo)(() => {
8734 var _siteEntityConfig$met;
8735 // Remove site object and decouple into its edited pieces.
8736 const editedEntitiesWithoutSite = editedEntities.filter(record => !(record.kind === 'root' && record.name === 'site'));
8737 const siteEntityLabels = (_siteEntityConfig$met = siteEntityConfig?.meta?.labels) !== null && _siteEntityConfig$met !== void 0 ? _siteEntityConfig$met : {};
8738 const editedSiteEntities = [];
8739 for (const property in siteEdits) {
8740 editedSiteEntities.push({
8741 kind: 'root',
8742 name: 'site',
8743 title: siteEntityLabels[property] || property,
8744 property
8745 });
8746 }
8747 return [...editedEntitiesWithoutSite, ...editedSiteEntities];
8748 }, [editedEntities, siteEdits, siteEntityConfig]);
8749
8750 // Unchecked entities to be ignored by save function.
8751 const [unselectedEntities, _setUnselectedEntities] = (0,external_wp_element_namespaceObject.useState)([]);
8752 const setUnselectedEntities = ({
8753 kind,
8754 name,
8755 key,
8756 property
8757 }, checked) => {
8758 if (checked) {
8759 _setUnselectedEntities(unselectedEntities.filter(elt => elt.kind !== kind || elt.name !== name || elt.key !== key || elt.property !== property));
8760 } else {
8761 _setUnselectedEntities([...unselectedEntities, {
8762 kind,
8763 name,
8764 key,
8765 property
8766 }]);
8767 }
8768 };
8769 const isDirty = dirtyEntityRecords.length - unselectedEntities.length > 0;
8770 return {
8771 dirtyEntityRecords,
8772 isDirty,
8773 setUnselectedEntities,
8774 unselectedEntities
8775 };
8776 };
8777
8778 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/entities-saved-states/index.js
8779 /**
8780 * WordPress dependencies
8781 */
8782
8783
8784
8785
8786
8787
8788 /**
8789 * Internal dependencies
8790 */
8791
8792
8793
8794
8795
8796
8797 function identity(values) {
8798 return values;
8799 }
8800
8801 /**
8802 * Renders the component for managing saved states of entities.
8803 *
8804 * @param {Object} props The component props.
8805 * @param {Function} props.close The function to close the dialog.
8806 * @param {Function} props.renderDialog The function to render the dialog.
8807 *
8808 * @return {JSX.Element} The rendered component.
8809 */
8810 function EntitiesSavedStates({
8811 close,
8812 renderDialog = undefined
8813 }) {
8814 const isDirtyProps = useIsDirty();
8815 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntitiesSavedStatesExtensible, {
8816 close: close,
8817 renderDialog: renderDialog,
8818 ...isDirtyProps
8819 });
8820 }
8821
8822 /**
8823 * Renders a panel for saving entities with dirty records.
8824 *
8825 * @param {Object} props The component props.
8826 * @param {string} props.additionalPrompt Additional prompt to display.
8827 * @param {Function} props.close Function to close the panel.
8828 * @param {Function} props.onSave Function to call when saving entities.
8829 * @param {boolean} props.saveEnabled Flag indicating if save is enabled.
8830 * @param {string} props.saveLabel Label for the save button.
8831 * @param {Function} props.renderDialog Function to render a custom dialog.
8832 * @param {Array} props.dirtyEntityRecords Array of dirty entity records.
8833 * @param {boolean} props.isDirty Flag indicating if there are dirty entities.
8834 * @param {Function} props.setUnselectedEntities Function to set unselected entities.
8835 * @param {Array} props.unselectedEntities Array of unselected entities.
8836 *
8837 * @return {JSX.Element} The rendered component.
8838 */
8839 function EntitiesSavedStatesExtensible({
8840 additionalPrompt = undefined,
8841 close,
8842 onSave = identity,
8843 saveEnabled: saveEnabledProp = undefined,
8844 saveLabel = (0,external_wp_i18n_namespaceObject.__)('Save'),
8845 renderDialog = undefined,
8846 dirtyEntityRecords,
8847 isDirty,
8848 setUnselectedEntities,
8849 unselectedEntities
8850 }) {
8851 const saveButtonRef = (0,external_wp_element_namespaceObject.useRef)();
8852 const {
8853 saveDirtyEntities
8854 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
8855 // To group entities by type.
8856 const partitionedSavables = dirtyEntityRecords.reduce((acc, record) => {
8857 const {
8858 name
8859 } = record;
8860 if (!acc[name]) {
8861 acc[name] = [];
8862 }
8863 acc[name].push(record);
8864 return acc;
8865 }, {});
8866
8867 // Sort entity groups.
8868 const {
8869 site: siteSavables,
8870 wp_template: templateSavables,
8871 wp_template_part: templatePartSavables,
8872 ...contentSavables
8873 } = partitionedSavables;
8874 const sortedPartitionedSavables = [siteSavables, templateSavables, templatePartSavables, ...Object.values(contentSavables)].filter(Array.isArray);
8875 const saveEnabled = saveEnabledProp !== null && saveEnabledProp !== void 0 ? saveEnabledProp : isDirty;
8876 // Explicitly define this with no argument passed. Using `close` on
8877 // its own will use the event object in place of the expected saved entities.
8878 const dismissPanel = (0,external_wp_element_namespaceObject.useCallback)(() => close(), [close]);
8879 const [saveDialogRef, saveDialogProps] = (0,external_wp_compose_namespaceObject.__experimentalUseDialog)({
8880 onClose: () => dismissPanel()
8881 });
8882 const dialogLabel = (0,external_wp_compose_namespaceObject.useInstanceId)(EntitiesSavedStatesExtensible, 'label');
8883 const dialogDescription = (0,external_wp_compose_namespaceObject.useInstanceId)(EntitiesSavedStatesExtensible, 'description');
8884 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
8885 ref: saveDialogRef,
8886 ...saveDialogProps,
8887 className: "entities-saved-states__panel",
8888 role: renderDialog ? 'dialog' : undefined,
8889 "aria-labelledby": renderDialog ? dialogLabel : undefined,
8890 "aria-describedby": renderDialog ? dialogDescription : undefined,
8891 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
8892 className: "entities-saved-states__panel-header",
8893 gap: 2,
8894 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
8895 isBlock: true,
8896 as: external_wp_components_namespaceObject.Button,
8897 ref: saveButtonRef,
8898 variant: "primary",
8899 disabled: !saveEnabled,
8900 accessibleWhenDisabled: true,
8901 onClick: () => saveDirtyEntities({
8902 onSave,
8903 dirtyEntityRecords,
8904 entitiesToSkip: unselectedEntities,
8905 close
8906 }),
8907 className: "editor-entities-saved-states__save-button",
8908 children: saveLabel
8909 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
8910 isBlock: true,
8911 as: external_wp_components_namespaceObject.Button,
8912 variant: "secondary",
8913 onClick: dismissPanel,
8914 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
8915 })]
8916 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
8917 className: "entities-saved-states__text-prompt",
8918 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
8919 className: "entities-saved-states__text-prompt--header-wrapper",
8920 id: renderDialog ? dialogLabel : undefined,
8921 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
8922 className: "entities-saved-states__text-prompt--header",
8923 children: (0,external_wp_i18n_namespaceObject.__)('Are you ready to save?')
8924 }), additionalPrompt]
8925 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
8926 id: renderDialog ? dialogDescription : undefined,
8927 children: isDirty ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of site changes waiting to be saved. */
8928 (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), {
8929 strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {})
8930 }) : (0,external_wp_i18n_namespaceObject.__)('Select the items you want to save.')
8931 })]
8932 }), sortedPartitionedSavables.map(list => {
8933 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntityTypeList, {
8934 list: list,
8935 unselectedEntities: unselectedEntities,
8936 setUnselectedEntities: setUnselectedEntities
8937 }, list[0].name);
8938 })]
8939 });
8940 }
8941
8942 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/error-boundary/index.js
8943 /**
8944 * WordPress dependencies
8945 */
8946
8947
8948
8949
8950
8951
8952
8953
8954 /**
8955 * Internal dependencies
8956 */
8957
8958
8959 function getContent() {
8960 try {
8961 // While `select` in a component is generally discouraged, it is
8962 // used here because it (a) reduces the chance of data loss in the
8963 // case of additional errors by performing a direct retrieval and
8964 // (b) avoids the performance cost associated with unnecessary
8965 // content serialization throughout the lifetime of a non-erroring
8966 // application.
8967 return (0,external_wp_data_namespaceObject.select)(store_store).getEditedPostContent();
8968 } catch (error) {}
8969 }
8970 function CopyButton({
8971 text,
8972 children
8973 }) {
8974 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text);
8975 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
8976 variant: "secondary",
8977 ref: ref,
8978 children: children
8979 });
8980 }
8981 class ErrorBoundary extends external_wp_element_namespaceObject.Component {
8982 constructor() {
8983 super(...arguments);
8984 this.state = {
8985 error: null
8986 };
8987 }
8988 componentDidCatch(error) {
8989 (0,external_wp_hooks_namespaceObject.doAction)('editor.ErrorBoundary.errorLogged', error);
8990 }
8991 static getDerivedStateFromError(error) {
8992 return {
8993 error
8994 };
8995 }
8996 render() {
8997 const {
8998 error
8999 } = this.state;
9000 if (!error) {
9001 return this.props.children;
9002 }
9003 const actions = [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyButton, {
9004 text: getContent,
9005 children: (0,external_wp_i18n_namespaceObject.__)('Copy Post Text')
9006 }, "copy-post"), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyButton, {
9007 text: error.stack,
9008 children: (0,external_wp_i18n_namespaceObject.__)('Copy Error')
9009 }, "copy-error")];
9010 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.Warning, {
9011 className: "editor-error-boundary",
9012 actions: actions,
9013 children: (0,external_wp_i18n_namespaceObject.__)('The editor has encountered an unexpected error.')
9014 });
9015 }
9016 }
9017
9018 /**
9019 * ErrorBoundary is used to catch JavaScript errors anywhere in a child component tree, log those errors, and display a fallback UI.
9020 *
9021 * It uses the lifecycle methods getDerivedStateFromError and componentDidCatch to catch errors in a child component tree.
9022 *
9023 * getDerivedStateFromError is used to render a fallback UI after an error has been thrown, and componentDidCatch is used to log error information.
9024 *
9025 * @class ErrorBoundary
9026 * @augments Component
9027 */
9028 /* harmony default export */ const error_boundary = (ErrorBoundary);
9029
9030 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/local-autosave-monitor/index.js
9031 /**
9032 * WordPress dependencies
9033 */
9034
9035
9036
9037
9038
9039
9040
9041 /**
9042 * Internal dependencies
9043 */
9044
9045
9046
9047
9048 const requestIdleCallback = window.requestIdleCallback ? window.requestIdleCallback : window.requestAnimationFrame;
9049 let hasStorageSupport;
9050
9051 /**
9052 * Function which returns true if the current environment supports browser
9053 * sessionStorage, or false otherwise. The result of this function is cached and
9054 * reused in subsequent invocations.
9055 */
9056 const hasSessionStorageSupport = () => {
9057 if (hasStorageSupport !== undefined) {
9058 return hasStorageSupport;
9059 }
9060 try {
9061 // Private Browsing in Safari 10 and earlier will throw an error when
9062 // attempting to set into sessionStorage. The test here is intentional in
9063 // causing a thrown error as condition bailing from local autosave.
9064 window.sessionStorage.setItem('__wpEditorTestSessionStorage', '');
9065 window.sessionStorage.removeItem('__wpEditorTestSessionStorage');
9066 hasStorageSupport = true;
9067 } catch {
9068 hasStorageSupport = false;
9069 }
9070 return hasStorageSupport;
9071 };
9072
9073 /**
9074 * Custom hook which manages the creation of a notice prompting the user to
9075 * restore a local autosave, if one exists.
9076 */
9077 function useAutosaveNotice() {
9078 const {
9079 postId,
9080 isEditedPostNew,
9081 hasRemoteAutosave
9082 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
9083 postId: select(store_store).getCurrentPostId(),
9084 isEditedPostNew: select(store_store).isEditedPostNew(),
9085 hasRemoteAutosave: !!select(store_store).getEditorSettings().autosave
9086 }), []);
9087 const {
9088 getEditedPostAttribute
9089 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
9090 const {
9091 createWarningNotice,
9092 removeNotice
9093 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
9094 const {
9095 editPost,
9096 resetEditorBlocks
9097 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9098 (0,external_wp_element_namespaceObject.useEffect)(() => {
9099 let localAutosave = localAutosaveGet(postId, isEditedPostNew);
9100 if (!localAutosave) {
9101 return;
9102 }
9103 try {
9104 localAutosave = JSON.parse(localAutosave);
9105 } catch {
9106 // Not usable if it can't be parsed.
9107 return;
9108 }
9109 const {
9110 post_title: title,
9111 content,
9112 excerpt
9113 } = localAutosave;
9114 const edits = {
9115 title,
9116 content,
9117 excerpt
9118 };
9119 {
9120 // Only display a notice if there is a difference between what has been
9121 // saved and that which is stored in sessionStorage.
9122 const hasDifference = Object.keys(edits).some(key => {
9123 return edits[key] !== getEditedPostAttribute(key);
9124 });
9125 if (!hasDifference) {
9126 // If there is no difference, it can be safely ejected from storage.
9127 localAutosaveClear(postId, isEditedPostNew);
9128 return;
9129 }
9130 }
9131 if (hasRemoteAutosave) {
9132 return;
9133 }
9134 const id = 'wpEditorAutosaveRestore';
9135 createWarningNotice((0,external_wp_i18n_namespaceObject.__)('The backup of this post in your browser is different from the version below.'), {
9136 id,
9137 actions: [{
9138 label: (0,external_wp_i18n_namespaceObject.__)('Restore the backup'),
9139 onClick() {
9140 const {
9141 content: editsContent,
9142 ...editsWithoutContent
9143 } = edits;
9144 editPost(editsWithoutContent);
9145 resetEditorBlocks((0,external_wp_blocks_namespaceObject.parse)(edits.content));
9146 removeNotice(id);
9147 }
9148 }]
9149 });
9150 }, [isEditedPostNew, postId]);
9151 }
9152
9153 /**
9154 * Custom hook which ejects a local autosave after a successful save occurs.
9155 */
9156 function useAutosavePurge() {
9157 const {
9158 postId,
9159 isEditedPostNew,
9160 isDirty,
9161 isAutosaving,
9162 didError
9163 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
9164 postId: select(store_store).getCurrentPostId(),
9165 isEditedPostNew: select(store_store).isEditedPostNew(),
9166 isDirty: select(store_store).isEditedPostDirty(),
9167 isAutosaving: select(store_store).isAutosavingPost(),
9168 didError: select(store_store).didPostSaveRequestFail()
9169 }), []);
9170 const lastIsDirty = (0,external_wp_element_namespaceObject.useRef)(isDirty);
9171 const lastIsAutosaving = (0,external_wp_element_namespaceObject.useRef)(isAutosaving);
9172 (0,external_wp_element_namespaceObject.useEffect)(() => {
9173 if (!didError && (lastIsAutosaving.current && !isAutosaving || lastIsDirty.current && !isDirty)) {
9174 localAutosaveClear(postId, isEditedPostNew);
9175 }
9176 lastIsDirty.current = isDirty;
9177 lastIsAutosaving.current = isAutosaving;
9178 }, [isDirty, isAutosaving, didError]);
9179
9180 // Once the isEditedPostNew changes from true to false, let's clear the auto-draft autosave.
9181 const wasEditedPostNew = (0,external_wp_compose_namespaceObject.usePrevious)(isEditedPostNew);
9182 const prevPostId = (0,external_wp_compose_namespaceObject.usePrevious)(postId);
9183 (0,external_wp_element_namespaceObject.useEffect)(() => {
9184 if (prevPostId === postId && wasEditedPostNew && !isEditedPostNew) {
9185 localAutosaveClear(postId, true);
9186 }
9187 }, [isEditedPostNew, postId]);
9188 }
9189 function LocalAutosaveMonitor() {
9190 const {
9191 autosave
9192 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9193 const deferredAutosave = (0,external_wp_element_namespaceObject.useCallback)(() => {
9194 requestIdleCallback(() => autosave({
9195 local: true
9196 }));
9197 }, []);
9198 useAutosaveNotice();
9199 useAutosavePurge();
9200 const localAutosaveInterval = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditorSettings().localAutosaveInterval, []);
9201 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(autosave_monitor, {
9202 interval: localAutosaveInterval,
9203 autosave: deferredAutosave
9204 });
9205 }
9206
9207 /**
9208 * Monitors local autosaves of a post in the editor.
9209 * It uses several hooks and functions to manage autosave behavior:
9210 * - `useAutosaveNotice` hook: Manages the creation of a notice prompting the user to restore a local autosave, if one exists.
9211 * - `useAutosavePurge` hook: Ejects a local autosave after a successful save occurs.
9212 * - `hasSessionStorageSupport` function: Checks if the current environment supports browser sessionStorage.
9213 * - `LocalAutosaveMonitor` component: Uses the `AutosaveMonitor` component to perform autosaves at a specified interval.
9214 *
9215 * The module also checks for sessionStorage support and conditionally exports the `LocalAutosaveMonitor` component based on that.
9216 *
9217 * @module LocalAutosaveMonitor
9218 */
9219 /* harmony default export */ const local_autosave_monitor = ((0,external_wp_compose_namespaceObject.ifCondition)(hasSessionStorageSupport)(LocalAutosaveMonitor));
9220
9221 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/page-attributes/check.js
9222 /**
9223 * WordPress dependencies
9224 */
9225
9226
9227
9228 /**
9229 * Internal dependencies
9230 */
9231
9232
9233 /**
9234 * Wrapper component that renders its children only if the post type supports page attributes.
9235 *
9236 * @param {Object} props - The component props.
9237 * @param {Element} props.children - The child components to render.
9238 *
9239 * @return {Component|null} The rendered child components or null if page attributes are not supported.
9240 */
9241 function PageAttributesCheck({
9242 children
9243 }) {
9244 const supportsPageAttributes = (0,external_wp_data_namespaceObject.useSelect)(select => {
9245 const {
9246 getEditedPostAttribute
9247 } = select(store_store);
9248 const {
9249 getPostType
9250 } = select(external_wp_coreData_namespaceObject.store);
9251 const postType = getPostType(getEditedPostAttribute('type'));
9252 return !!postType?.supports?.['page-attributes'];
9253 }, []);
9254
9255 // Only render fields if post type supports page attributes or available templates exist.
9256 if (!supportsPageAttributes) {
9257 return null;
9258 }
9259 return children;
9260 }
9261 /* harmony default export */ const page_attributes_check = (PageAttributesCheck);
9262
9263 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-type-support-check/index.js
9264 /**
9265 * WordPress dependencies
9266 */
9267
9268
9269
9270 /**
9271 * Internal dependencies
9272 */
9273
9274
9275 /**
9276 * A component which renders its own children only if the current editor post
9277 * type supports one of the given `supportKeys` prop.
9278 *
9279 * @param {Object} props Props.
9280 * @param {Element} props.children Children to be rendered if post
9281 * type supports.
9282 * @param {(string|string[])} props.supportKeys String or string array of keys
9283 * to test.
9284 *
9285 * @return {Component} The component to be rendered.
9286 */
9287 function PostTypeSupportCheck({
9288 children,
9289 supportKeys
9290 }) {
9291 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => {
9292 const {
9293 getEditedPostAttribute
9294 } = select(store_store);
9295 const {
9296 getPostType
9297 } = select(external_wp_coreData_namespaceObject.store);
9298 return getPostType(getEditedPostAttribute('type'));
9299 }, []);
9300 let isSupported = !!postType;
9301 if (postType) {
9302 isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some(key => !!postType.supports[key]);
9303 }
9304 if (!isSupported) {
9305 return null;
9306 }
9307 return children;
9308 }
9309 /* harmony default export */ const post_type_support_check = (PostTypeSupportCheck);
9310
9311 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/page-attributes/order.js
9312 /**
9313 * WordPress dependencies
9314 */
9315
9316
9317
9318
9319
9320 /**
9321 * Internal dependencies
9322 */
9323
9324
9325
9326 function PageAttributesOrder() {
9327 const order = (0,external_wp_data_namespaceObject.useSelect)(select => {
9328 var _select$getEditedPost;
9329 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('menu_order')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 0;
9330 }, []);
9331 const {
9332 editPost
9333 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9334 const [orderInput, setOrderInput] = (0,external_wp_element_namespaceObject.useState)(null);
9335 const setUpdatedOrder = value => {
9336 setOrderInput(value);
9337 const newOrder = Number(value);
9338 if (Number.isInteger(newOrder) && value.trim?.() !== '') {
9339 editPost({
9340 menu_order: newOrder
9341 });
9342 }
9343 };
9344 const value = orderInput !== null && orderInput !== void 0 ? orderInput : order;
9345 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Flex, {
9346 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexBlock, {
9347 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNumberControl, {
9348 __next40pxDefaultSize: true,
9349 label: (0,external_wp_i18n_namespaceObject.__)('Order'),
9350 help: (0,external_wp_i18n_namespaceObject.__)('Set the page order.'),
9351 value: value,
9352 onChange: setUpdatedOrder,
9353 hideLabelFromVision: true,
9354 onBlur: () => {
9355 setOrderInput(null);
9356 }
9357 })
9358 })
9359 });
9360 }
9361
9362 /**
9363 * Renders the Page Attributes Order component. A number input in an editor interface
9364 * for setting the order of a given page.
9365 * The component is now not used in core but was kept for backward compatibility.
9366 *
9367 * @return {Component} The component to be rendered.
9368 */
9369 function PageAttributesOrderWithChecks() {
9370 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
9371 supportKeys: "page-attributes",
9372 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PageAttributesOrder, {})
9373 });
9374 }
9375
9376 // EXTERNAL MODULE: ./node_modules/remove-accents/index.js
9377 var remove_accents = __webpack_require__(4793);
9378 var remove_accents_default = /*#__PURE__*/__webpack_require__.n(remove_accents);
9379 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-panel-row/index.js
9380 /**
9381 * External dependencies
9382 */
9383
9384
9385 /**
9386 * WordPress dependencies
9387 */
9388
9389
9390
9391
9392 const PostPanelRow = (0,external_wp_element_namespaceObject.forwardRef)(({
9393 className,
9394 label,
9395 children
9396 }, ref) => {
9397 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
9398 className: dist_clsx('editor-post-panel__row', className),
9399 ref: ref,
9400 children: [label && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
9401 className: "editor-post-panel__row-label",
9402 children: label
9403 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
9404 className: "editor-post-panel__row-control",
9405 children: children
9406 })]
9407 });
9408 });
9409 /* harmony default export */ const post_panel_row = (PostPanelRow);
9410
9411 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/terms.js
9412 /**
9413 * WordPress dependencies
9414 */
9415
9416
9417 /**
9418 * Returns terms in a tree form.
9419 *
9420 * @param {Array} flatTerms Array of terms in flat format.
9421 *
9422 * @return {Array} Array of terms in tree format.
9423 */
9424 function buildTermsTree(flatTerms) {
9425 const flatTermsWithParentAndChildren = flatTerms.map(term => {
9426 return {
9427 children: [],
9428 parent: null,
9429 ...term
9430 };
9431 });
9432
9433 // All terms should have a `parent` because we're about to index them by it.
9434 if (flatTermsWithParentAndChildren.some(({
9435 parent
9436 }) => parent === null)) {
9437 return flatTermsWithParentAndChildren;
9438 }
9439 const termsByParent = flatTermsWithParentAndChildren.reduce((acc, term) => {
9440 const {
9441 parent
9442 } = term;
9443 if (!acc[parent]) {
9444 acc[parent] = [];
9445 }
9446 acc[parent].push(term);
9447 return acc;
9448 }, {});
9449 const fillWithChildren = terms => {
9450 return terms.map(term => {
9451 const children = termsByParent[term.id];
9452 return {
9453 ...term,
9454 children: children && children.length ? fillWithChildren(children) : []
9455 };
9456 });
9457 };
9458 return fillWithChildren(termsByParent['0'] || []);
9459 }
9460 const unescapeString = arg => {
9461 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(arg);
9462 };
9463
9464 /**
9465 * Returns a term object with name unescaped.
9466 *
9467 * @param {Object} term The term object to unescape.
9468 *
9469 * @return {Object} Term object with name property unescaped.
9470 */
9471 const unescapeTerm = term => {
9472 return {
9473 ...term,
9474 name: unescapeString(term.name)
9475 };
9476 };
9477
9478 /**
9479 * Returns an array of term objects with names unescaped.
9480 * The unescape of each term is performed using the unescapeTerm function.
9481 *
9482 * @param {Object[]} terms Array of term objects to unescape.
9483 *
9484 * @return {Object[]} Array of term objects unescaped.
9485 */
9486 const unescapeTerms = terms => {
9487 return (terms !== null && terms !== void 0 ? terms : []).map(unescapeTerm);
9488 };
9489
9490 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/page-attributes/parent.js
9491 /**
9492 * External dependencies
9493 */
9494
9495
9496 /**
9497 * WordPress dependencies
9498 */
9499
9500
9501
9502
9503
9504
9505
9506
9507
9508 /**
9509 * Internal dependencies
9510 */
9511
9512
9513
9514
9515
9516 function getTitle(post) {
9517 return post?.title?.rendered ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title.rendered) : `#${post.id} (${(0,external_wp_i18n_namespaceObject.__)('no title')})`;
9518 }
9519 const getItemPriority = (name, searchValue) => {
9520 const normalizedName = remove_accents_default()(name || '').toLowerCase();
9521 const normalizedSearch = remove_accents_default()(searchValue || '').toLowerCase();
9522 if (normalizedName === normalizedSearch) {
9523 return 0;
9524 }
9525 if (normalizedName.startsWith(normalizedSearch)) {
9526 return normalizedName.length;
9527 }
9528 return Infinity;
9529 };
9530
9531 /**
9532 * Renders the Page Attributes Parent component. A dropdown menu in an editor interface
9533 * for selecting the parent page of a given page.
9534 *
9535 * @return {Component|null} The component to be rendered. Return null if post type is not hierarchical.
9536 */
9537 function PageAttributesParent() {
9538 const {
9539 editPost
9540 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
9541 const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)(false);
9542 const {
9543 isHierarchical,
9544 parentPostId,
9545 parentPostTitle,
9546 pageItems
9547 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9548 var _pType$hierarchical;
9549 const {
9550 getPostType,
9551 getEntityRecords,
9552 getEntityRecord
9553 } = select(external_wp_coreData_namespaceObject.store);
9554 const {
9555 getCurrentPostId,
9556 getEditedPostAttribute
9557 } = select(store_store);
9558 const postTypeSlug = getEditedPostAttribute('type');
9559 const pageId = getEditedPostAttribute('parent');
9560 const pType = getPostType(postTypeSlug);
9561 const postId = getCurrentPostId();
9562 const postIsHierarchical = (_pType$hierarchical = pType?.hierarchical) !== null && _pType$hierarchical !== void 0 ? _pType$hierarchical : false;
9563 const query = {
9564 per_page: 100,
9565 exclude: postId,
9566 parent_exclude: postId,
9567 orderby: 'menu_order',
9568 order: 'asc',
9569 _fields: 'id,title,parent'
9570 };
9571
9572 // Perform a search when the field is changed.
9573 if (!!fieldValue) {
9574 query.search = fieldValue;
9575 }
9576 const parentPost = pageId ? getEntityRecord('postType', postTypeSlug, pageId) : null;
9577 return {
9578 isHierarchical: postIsHierarchical,
9579 parentPostId: pageId,
9580 parentPostTitle: parentPost ? getTitle(parentPost) : '',
9581 pageItems: postIsHierarchical ? getEntityRecords('postType', postTypeSlug, query) : null
9582 };
9583 }, [fieldValue]);
9584 const parentOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
9585 const getOptionsFromTree = (tree, level = 0) => {
9586 const mappedNodes = tree.map(treeNode => [{
9587 value: treeNode.id,
9588 label: '— '.repeat(level) + (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(treeNode.name),
9589 rawName: treeNode.name
9590 }, ...getOptionsFromTree(treeNode.children || [], level + 1)]);
9591 const sortedNodes = mappedNodes.sort(([a], [b]) => {
9592 const priorityA = getItemPriority(a.rawName, fieldValue);
9593 const priorityB = getItemPriority(b.rawName, fieldValue);
9594 return priorityA >= priorityB ? 1 : -1;
9595 });
9596 return sortedNodes.flat();
9597 };
9598 if (!pageItems) {
9599 return [];
9600 }
9601 let tree = pageItems.map(item => ({
9602 id: item.id,
9603 parent: item.parent,
9604 name: getTitle(item)
9605 }));
9606
9607 // Only build a hierarchical tree when not searching.
9608 if (!fieldValue) {
9609 tree = buildTermsTree(tree);
9610 }
9611 const opts = getOptionsFromTree(tree);
9612
9613 // Ensure the current parent is in the options list.
9614 const optsHasParent = opts.find(item => item.value === parentPostId);
9615 if (parentPostTitle && !optsHasParent) {
9616 opts.unshift({
9617 value: parentPostId,
9618 label: parentPostTitle
9619 });
9620 }
9621 return opts;
9622 }, [pageItems, fieldValue, parentPostTitle, parentPostId]);
9623 if (!isHierarchical) {
9624 return null;
9625 }
9626 /**
9627 * Handle user input.
9628 *
9629 * @param {string} inputValue The current value of the input field.
9630 */
9631 const handleKeydown = inputValue => {
9632 setFieldValue(inputValue);
9633 };
9634
9635 /**
9636 * Handle author selection.
9637 *
9638 * @param {Object} selectedPostId The selected Author.
9639 */
9640 const handleChange = selectedPostId => {
9641 editPost({
9642 parent: selectedPostId
9643 });
9644 };
9645 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ComboboxControl, {
9646 __nextHasNoMarginBottom: true,
9647 __next40pxDefaultSize: true,
9648 className: "editor-page-attributes__parent",
9649 label: (0,external_wp_i18n_namespaceObject.__)('Parent'),
9650 help: (0,external_wp_i18n_namespaceObject.__)('Choose a parent page.'),
9651 value: parentPostId,
9652 options: parentOptions,
9653 onFilterValueChange: (0,external_wp_compose_namespaceObject.debounce)(handleKeydown, 300),
9654 onChange: handleChange,
9655 hideLabelFromVision: true
9656 });
9657 }
9658 function PostParentToggle({
9659 isOpen,
9660 onClick
9661 }) {
9662 const parentPost = (0,external_wp_data_namespaceObject.useSelect)(select => {
9663 const {
9664 getEditedPostAttribute
9665 } = select(store_store);
9666 const parentPostId = getEditedPostAttribute('parent');
9667 if (!parentPostId) {
9668 return null;
9669 }
9670 const {
9671 getEntityRecord
9672 } = select(external_wp_coreData_namespaceObject.store);
9673 const postTypeSlug = getEditedPostAttribute('type');
9674 return getEntityRecord('postType', postTypeSlug, parentPostId);
9675 }, []);
9676 const parentTitle = (0,external_wp_element_namespaceObject.useMemo)(() => !parentPost ? (0,external_wp_i18n_namespaceObject.__)('None') : getTitle(parentPost), [parentPost]);
9677 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
9678 size: "compact",
9679 className: "editor-post-parent__panel-toggle",
9680 variant: "tertiary",
9681 "aria-expanded": isOpen
9682 // translators: %s: Current post parent.
9683 ,
9684 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change parent: %s'), parentTitle),
9685 onClick: onClick,
9686 children: parentTitle
9687 });
9688 }
9689 function ParentRow() {
9690 // Use internal state instead of a ref to make sure that the component
9691 // re-renders when the popover's anchor updates.
9692 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
9693 // Memoize popoverProps to avoid returning a new object every time.
9694 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
9695 // Anchor the popover to the middle of the entire row so that it doesn't
9696 // move around when the label changes.
9697 anchor: popoverAnchor,
9698 placement: 'left-start',
9699 offset: 36,
9700 shift: true
9701 }), [popoverAnchor]);
9702 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
9703 label: (0,external_wp_i18n_namespaceObject.__)('Parent'),
9704 ref: setPopoverAnchor,
9705 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
9706 popoverProps: popoverProps,
9707 className: "editor-post-parent__panel-dropdown",
9708 contentClassName: "editor-post-parent__panel-dialog",
9709 focusOnMount: true,
9710 renderToggle: ({
9711 isOpen,
9712 onToggle
9713 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostParentToggle, {
9714 isOpen: isOpen,
9715 onClick: onToggle
9716 }),
9717 renderContent: ({
9718 onClose
9719 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
9720 className: "editor-post-parent",
9721 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
9722 title: (0,external_wp_i18n_namespaceObject.__)('Parent'),
9723 onClose: onClose
9724 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
9725 children: [/* translators: The domain name should be a reserved domain name to prevent linking to third party sites outside the WordPress project's control. You may also wish to use wordpress.org or a wordpress.org sub-domain. */
9726 (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 example.org/services/web-design."), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("p", {
9727 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, {
9728 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#page-attributes'),
9729 children: (0,external_wp_i18n_namespaceObject.__)('Learn more')
9730 })]
9731 })]
9732 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PageAttributesParent, {})]
9733 })
9734 })
9735 });
9736 }
9737 /* harmony default export */ const page_attributes_parent = (PageAttributesParent);
9738
9739 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/page-attributes/panel.js
9740 /**
9741 * WordPress dependencies
9742 */
9743
9744
9745 /**
9746 * Internal dependencies
9747 */
9748
9749
9750
9751
9752 const PANEL_NAME = 'page-attributes';
9753 function AttributesPanel() {
9754 const {
9755 isEnabled,
9756 postType
9757 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9758 const {
9759 getEditedPostAttribute,
9760 isEditorPanelEnabled
9761 } = select(store_store);
9762 const {
9763 getPostType
9764 } = select(external_wp_coreData_namespaceObject.store);
9765 return {
9766 isEnabled: isEditorPanelEnabled(PANEL_NAME),
9767 postType: getPostType(getEditedPostAttribute('type'))
9768 };
9769 }, []);
9770 if (!isEnabled || !postType) {
9771 return null;
9772 }
9773 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ParentRow, {});
9774 }
9775
9776 /**
9777 * Renders the Page Attributes Panel component.
9778 *
9779 * @return {Component} The component to be rendered.
9780 */
9781 function PageAttributesPanel() {
9782 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(page_attributes_check, {
9783 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(AttributesPanel, {})
9784 });
9785 }
9786
9787 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/add-template.js
9788 /**
9789 * WordPress dependencies
9790 */
9791
9792
9793 const addTemplate = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
9794 viewBox: "0 0 24 24",
9795 xmlns: "http://www.w3.org/2000/svg",
9796 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
9797 fillRule: "evenodd",
9798 clipRule: "evenodd",
9799 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"
9800 })
9801 });
9802 /* harmony default export */ const add_template = (addTemplate);
9803
9804 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/create-new-template-modal.js
9805 /**
9806 * WordPress dependencies
9807 */
9808
9809
9810
9811
9812
9813
9814
9815 /**
9816 * Internal dependencies
9817 */
9818
9819
9820
9821
9822 const DEFAULT_TITLE = (0,external_wp_i18n_namespaceObject.__)('Custom Template');
9823 function CreateNewTemplateModal({
9824 onClose
9825 }) {
9826 const {
9827 defaultBlockTemplate,
9828 onNavigateToEntityRecord
9829 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
9830 const {
9831 getEditorSettings,
9832 getCurrentTemplateId
9833 } = select(store_store);
9834 return {
9835 defaultBlockTemplate: getEditorSettings().defaultBlockTemplate,
9836 onNavigateToEntityRecord: getEditorSettings().onNavigateToEntityRecord,
9837 getTemplateId: getCurrentTemplateId
9838 };
9839 });
9840 const {
9841 createTemplate
9842 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
9843 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)('');
9844 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
9845 const cancel = () => {
9846 setTitle('');
9847 onClose();
9848 };
9849 const submit = async event => {
9850 event.preventDefault();
9851 if (isBusy) {
9852 return;
9853 }
9854 setIsBusy(true);
9855 const newTemplateContent = defaultBlockTemplate !== null && defaultBlockTemplate !== void 0 ? defaultBlockTemplate : (0,external_wp_blocks_namespaceObject.serialize)([(0,external_wp_blocks_namespaceObject.createBlock)('core/group', {
9856 tagName: 'header',
9857 layout: {
9858 inherit: true
9859 }
9860 }, [(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', {
9861 tagName: 'main'
9862 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/group', {
9863 layout: {
9864 inherit: true
9865 }
9866 }, [(0,external_wp_blocks_namespaceObject.createBlock)('core/post-title')]), (0,external_wp_blocks_namespaceObject.createBlock)('core/post-content', {
9867 layout: {
9868 inherit: true
9869 }
9870 })])]);
9871 const newTemplate = await createTemplate({
9872 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(title || DEFAULT_TITLE),
9873 content: newTemplateContent,
9874 title: title || DEFAULT_TITLE
9875 });
9876 setIsBusy(false);
9877 onNavigateToEntityRecord({
9878 postId: newTemplate.id,
9879 postType: 'wp_template'
9880 });
9881 cancel();
9882 };
9883 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
9884 title: (0,external_wp_i18n_namespaceObject.__)('Create custom template'),
9885 onRequestClose: cancel,
9886 focusOnMount: "firstContentElement",
9887 size: "small",
9888 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
9889 className: "editor-post-template__create-form",
9890 onSubmit: submit,
9891 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
9892 spacing: "3",
9893 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
9894 __nextHasNoMarginBottom: true,
9895 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
9896 value: title,
9897 onChange: setTitle,
9898 placeholder: DEFAULT_TITLE,
9899 disabled: isBusy,
9900 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.')
9901 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
9902 justify: "right",
9903 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
9904 variant: "tertiary",
9905 onClick: cancel,
9906 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
9907 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
9908 variant: "primary",
9909 type: "submit",
9910 isBusy: isBusy,
9911 "aria-disabled": isBusy,
9912 children: (0,external_wp_i18n_namespaceObject.__)('Create')
9913 })]
9914 })]
9915 })
9916 })
9917 });
9918 }
9919
9920 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/hooks.js
9921 /**
9922 * WordPress dependencies
9923 */
9924
9925
9926
9927
9928 /**
9929 * Internal dependencies
9930 */
9931
9932 function useEditedPostContext() {
9933 return (0,external_wp_data_namespaceObject.useSelect)(select => {
9934 const {
9935 getCurrentPostId,
9936 getCurrentPostType
9937 } = select(store_store);
9938 return {
9939 postId: getCurrentPostId(),
9940 postType: getCurrentPostType()
9941 };
9942 }, []);
9943 }
9944 function useAllowSwitchingTemplates() {
9945 const {
9946 postType,
9947 postId
9948 } = useEditedPostContext();
9949 return (0,external_wp_data_namespaceObject.useSelect)(select => {
9950 const {
9951 canUser,
9952 getEntityRecord,
9953 getEntityRecords
9954 } = select(external_wp_coreData_namespaceObject.store);
9955 const siteSettings = canUser('read', {
9956 kind: 'root',
9957 name: 'site'
9958 }) ? getEntityRecord('root', 'site') : undefined;
9959 const templates = getEntityRecords('postType', 'wp_template', {
9960 per_page: -1
9961 });
9962 const isPostsPage = +postId === siteSettings?.page_for_posts;
9963 // If current page is set front page or posts page, we also need
9964 // to check if the current theme has a template for it. If not
9965 const isFrontPage = postType === 'page' && +postId === siteSettings?.page_on_front && templates?.some(({
9966 slug
9967 }) => slug === 'front-page');
9968 return !isPostsPage && !isFrontPage;
9969 }, [postId, postType]);
9970 }
9971 function useTemplates(postType) {
9972 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_template', {
9973 per_page: -1,
9974 post_type: postType
9975 }), [postType]);
9976 }
9977 function useAvailableTemplates(postType) {
9978 const currentTemplateSlug = useCurrentTemplateSlug();
9979 const allowSwitchingTemplate = useAllowSwitchingTemplates();
9980 const templates = useTemplates(postType);
9981 return (0,external_wp_element_namespaceObject.useMemo)(() => allowSwitchingTemplate && templates?.filter(template => template.is_custom && template.slug !== currentTemplateSlug && !!template.content.raw // Skip empty templates.
9982 ), [templates, currentTemplateSlug, allowSwitchingTemplate]);
9983 }
9984 function useCurrentTemplateSlug() {
9985 const {
9986 postType,
9987 postId
9988 } = useEditedPostContext();
9989 const templates = useTemplates(postType);
9990 const entityTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => {
9991 const post = select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', postType, postId);
9992 return post?.template;
9993 }, [postType, postId]);
9994 if (!entityTemplate) {
9995 return;
9996 }
9997 // If a page has a `template` set and is not included in the list
9998 // of the theme's templates, do not return it, in order to resolve
9999 // to the current theme's default template.
10000 return templates?.find(template => template.slug === entityTemplate)?.slug;
10001 }
10002
10003 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/classic-theme.js
10004 /**
10005 * WordPress dependencies
10006 */
10007
10008
10009
10010
10011
10012
10013
10014
10015
10016 /**
10017 * Internal dependencies
10018 */
10019
10020
10021
10022
10023
10024 const POPOVER_PROPS = {
10025 className: 'editor-post-template__dropdown',
10026 placement: 'bottom-start'
10027 };
10028 function PostTemplateToggle({
10029 isOpen,
10030 onClick
10031 }) {
10032 const templateTitle = (0,external_wp_data_namespaceObject.useSelect)(select => {
10033 const templateSlug = select(store_store).getEditedPostAttribute('template');
10034 const {
10035 supportsTemplateMode,
10036 availableTemplates
10037 } = select(store_store).getEditorSettings();
10038 if (!supportsTemplateMode && availableTemplates[templateSlug]) {
10039 return availableTemplates[templateSlug];
10040 }
10041 const template = select(external_wp_coreData_namespaceObject.store).canUser('create', {
10042 kind: 'postType',
10043 name: 'wp_template'
10044 }) && select(store_store).getCurrentTemplateId();
10045 return template?.title || template?.slug || availableTemplates?.[templateSlug];
10046 }, []);
10047 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
10048 __next40pxDefaultSize: true,
10049 variant: "tertiary",
10050 "aria-expanded": isOpen,
10051 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Template options'),
10052 onClick: onClick,
10053 children: templateTitle !== null && templateTitle !== void 0 ? templateTitle : (0,external_wp_i18n_namespaceObject.__)('Default template')
10054 });
10055 }
10056
10057 /**
10058 * Renders the dropdown content for selecting a post template.
10059 *
10060 * @param {Object} props The component props.
10061 * @param {Function} props.onClose The function to close the dropdown.
10062 *
10063 * @return {JSX.Element} The rendered dropdown content.
10064 */
10065 function PostTemplateDropdownContent({
10066 onClose
10067 }) {
10068 var _options$find, _selectedOption$value;
10069 const allowSwitchingTemplate = useAllowSwitchingTemplates();
10070 const {
10071 availableTemplates,
10072 fetchedTemplates,
10073 selectedTemplateSlug,
10074 canCreate,
10075 canEdit,
10076 currentTemplateId,
10077 onNavigateToEntityRecord,
10078 getEditorSettings
10079 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10080 const {
10081 canUser,
10082 getEntityRecords
10083 } = select(external_wp_coreData_namespaceObject.store);
10084 const editorSettings = select(store_store).getEditorSettings();
10085 const canCreateTemplates = canUser('create', {
10086 kind: 'postType',
10087 name: 'wp_template'
10088 });
10089 const _currentTemplateId = select(store_store).getCurrentTemplateId();
10090 return {
10091 availableTemplates: editorSettings.availableTemplates,
10092 fetchedTemplates: canCreateTemplates ? getEntityRecords('postType', 'wp_template', {
10093 post_type: select(store_store).getCurrentPostType(),
10094 per_page: -1
10095 }) : undefined,
10096 selectedTemplateSlug: select(store_store).getEditedPostAttribute('template'),
10097 canCreate: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode,
10098 canEdit: allowSwitchingTemplate && canCreateTemplates && editorSettings.supportsTemplateMode && !!_currentTemplateId,
10099 currentTemplateId: _currentTemplateId,
10100 onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
10101 getEditorSettings: select(store_store).getEditorSettings
10102 };
10103 }, [allowSwitchingTemplate]);
10104 const options = (0,external_wp_element_namespaceObject.useMemo)(() => Object.entries({
10105 ...availableTemplates,
10106 ...Object.fromEntries((fetchedTemplates !== null && fetchedTemplates !== void 0 ? fetchedTemplates : []).map(({
10107 slug,
10108 title
10109 }) => [slug, title.rendered]))
10110 }).map(([slug, title]) => ({
10111 value: slug,
10112 label: title
10113 })), [availableTemplates, fetchedTemplates]);
10114 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.
10115
10116 const {
10117 editPost
10118 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10119 const {
10120 createSuccessNotice
10121 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
10122 const [isCreateModalOpen, setIsCreateModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
10123 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
10124 className: "editor-post-template__classic-theme-dropdown",
10125 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
10126 title: (0,external_wp_i18n_namespaceObject.__)('Template'),
10127 help: (0,external_wp_i18n_namespaceObject.__)('Templates define the way content is displayed when viewing your site.'),
10128 actions: canCreate ? [{
10129 icon: add_template,
10130 label: (0,external_wp_i18n_namespaceObject.__)('Add template'),
10131 onClick: () => setIsCreateModalOpen(true)
10132 }] : [],
10133 onClose: onClose
10134 }), !allowSwitchingTemplate ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
10135 status: "warning",
10136 isDismissible: false,
10137 children: (0,external_wp_i18n_namespaceObject.__)('The posts page template cannot be changed.')
10138 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SelectControl, {
10139 __next40pxDefaultSize: true,
10140 __nextHasNoMarginBottom: true,
10141 hideLabelFromVision: true,
10142 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
10143 value: (_selectedOption$value = selectedOption?.value) !== null && _selectedOption$value !== void 0 ? _selectedOption$value : '',
10144 options: options,
10145 onChange: slug => editPost({
10146 template: slug || ''
10147 })
10148 }), canEdit && onNavigateToEntityRecord && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
10149 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
10150 variant: "link",
10151 onClick: () => {
10152 onNavigateToEntityRecord({
10153 postId: currentTemplateId,
10154 postType: 'wp_template'
10155 });
10156 onClose();
10157 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Editing template. Changes made here affect all posts and pages that use the template.'), {
10158 type: 'snackbar',
10159 actions: [{
10160 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
10161 onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord()
10162 }]
10163 });
10164 },
10165 children: (0,external_wp_i18n_namespaceObject.__)('Edit template')
10166 })
10167 }), isCreateModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateNewTemplateModal, {
10168 onClose: () => setIsCreateModalOpen(false)
10169 })]
10170 });
10171 }
10172 function ClassicThemeControl() {
10173 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
10174 popoverProps: POPOVER_PROPS,
10175 focusOnMount: true,
10176 renderToggle: ({
10177 isOpen,
10178 onToggle
10179 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTemplateToggle, {
10180 isOpen: isOpen,
10181 onClick: onToggle
10182 }),
10183 renderContent: ({
10184 onClose
10185 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTemplateDropdownContent, {
10186 onClose: onClose
10187 })
10188 });
10189 }
10190
10191 /**
10192 * Provides a dropdown menu for selecting and managing post templates.
10193 *
10194 * The dropdown menu includes a button for toggling the menu, a list of available templates, and options for creating and editing templates.
10195 *
10196 * @return {JSX.Element} The rendered ClassicThemeControl component.
10197 */
10198 /* harmony default export */ const classic_theme = (ClassicThemeControl);
10199
10200 ;// CONCATENATED MODULE: external ["wp","warning"]
10201 const external_wp_warning_namespaceObject = window["wp"]["warning"];
10202 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/preferences-modal/enable-panel.js
10203 /**
10204 * WordPress dependencies
10205 */
10206
10207
10208
10209
10210 /**
10211 * Internal dependencies
10212 */
10213
10214
10215 const {
10216 PreferenceBaseOption
10217 } = unlock(external_wp_preferences_namespaceObject.privateApis);
10218 /* harmony default export */ const enable_panel = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)((select, {
10219 panelName
10220 }) => {
10221 const {
10222 isEditorPanelEnabled,
10223 isEditorPanelRemoved
10224 } = select(store_store);
10225 return {
10226 isRemoved: isEditorPanelRemoved(panelName),
10227 isChecked: isEditorPanelEnabled(panelName)
10228 };
10229 }), (0,external_wp_compose_namespaceObject.ifCondition)(({
10230 isRemoved
10231 }) => !isRemoved), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
10232 panelName
10233 }) => ({
10234 onChange: () => dispatch(store_store).toggleEditorPanelEnabled(panelName)
10235 })))(PreferenceBaseOption));
10236
10237 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/preferences-modal/enable-plugin-document-setting-panel.js
10238 /**
10239 * WordPress dependencies
10240 */
10241
10242
10243 /**
10244 * Internal dependencies
10245 */
10246
10247
10248 const {
10249 Fill,
10250 Slot
10251 } = (0,external_wp_components_namespaceObject.createSlotFill)('EnablePluginDocumentSettingPanelOption');
10252 const EnablePluginDocumentSettingPanelOption = ({
10253 label,
10254 panelName
10255 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Fill, {
10256 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
10257 label: label,
10258 panelName: panelName
10259 })
10260 });
10261 EnablePluginDocumentSettingPanelOption.Slot = Slot;
10262 /* harmony default export */ const enable_plugin_document_setting_panel = (EnablePluginDocumentSettingPanelOption);
10263
10264 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-document-setting-panel/index.js
10265 /**
10266 * WordPress dependencies
10267 */
10268
10269
10270
10271
10272
10273 /**
10274 * Internal dependencies
10275 */
10276
10277
10278
10279
10280
10281 const {
10282 Fill: plugin_document_setting_panel_Fill,
10283 Slot: plugin_document_setting_panel_Slot
10284 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginDocumentSettingPanel');
10285
10286 /**
10287 * Renders items below the Status & Availability panel in the Document Sidebar.
10288 *
10289 * @param {Object} props Component properties.
10290 * @param {string} props.name Required. A machine-friendly name for the panel.
10291 * @param {string} [props.className] An optional class name added to the row.
10292 * @param {string} [props.title] The title of the panel
10293 * @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.
10294 * @param {Element} props.children Children to be rendered
10295 *
10296 * @example
10297 * ```js
10298 * // Using ES5 syntax
10299 * var el = React.createElement;
10300 * var __ = wp.i18n.__;
10301 * var registerPlugin = wp.plugins.registerPlugin;
10302 * var PluginDocumentSettingPanel = wp.editor.PluginDocumentSettingPanel;
10303 *
10304 * function MyDocumentSettingPlugin() {
10305 * return el(
10306 * PluginDocumentSettingPanel,
10307 * {
10308 * className: 'my-document-setting-plugin',
10309 * title: 'My Panel',
10310 * name: 'my-panel',
10311 * },
10312 * __( 'My Document Setting Panel' )
10313 * );
10314 * }
10315 *
10316 * registerPlugin( 'my-document-setting-plugin', {
10317 * render: MyDocumentSettingPlugin
10318 * } );
10319 * ```
10320 *
10321 * @example
10322 * ```jsx
10323 * // Using ESNext syntax
10324 * import { registerPlugin } from '@wordpress/plugins';
10325 * import { PluginDocumentSettingPanel } from '@wordpress/editor';
10326 *
10327 * const MyDocumentSettingTest = () => (
10328 * <PluginDocumentSettingPanel className="my-document-setting-plugin" title="My Panel" name="my-panel">
10329 * <p>My Document Setting Panel</p>
10330 * </PluginDocumentSettingPanel>
10331 * );
10332 *
10333 * registerPlugin( 'document-setting-test', { render: MyDocumentSettingTest } );
10334 * ```
10335 *
10336 * @return {Component} The component to be rendered.
10337 */
10338 const PluginDocumentSettingPanel = ({
10339 name,
10340 className,
10341 title,
10342 icon,
10343 children
10344 }) => {
10345 const {
10346 name: pluginName
10347 } = (0,external_wp_plugins_namespaceObject.usePluginContext)();
10348 const panelName = `${pluginName}/${name}`;
10349 const {
10350 opened,
10351 isEnabled
10352 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10353 const {
10354 isEditorPanelOpened,
10355 isEditorPanelEnabled
10356 } = select(store_store);
10357 return {
10358 opened: isEditorPanelOpened(panelName),
10359 isEnabled: isEditorPanelEnabled(panelName)
10360 };
10361 }, [panelName]);
10362 const {
10363 toggleEditorPanelOpened
10364 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
10365 if (undefined === name) {
10366 false ? 0 : void 0;
10367 }
10368 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
10369 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_plugin_document_setting_panel, {
10370 label: title,
10371 panelName: panelName
10372 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_document_setting_panel_Fill, {
10373 children: isEnabled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
10374 className: className,
10375 title: title,
10376 icon: icon,
10377 opened: opened,
10378 onToggle: () => toggleEditorPanelOpened(panelName),
10379 children: children
10380 })
10381 })]
10382 });
10383 };
10384 PluginDocumentSettingPanel.Slot = plugin_document_setting_panel_Slot;
10385 /* harmony default export */ const plugin_document_setting_panel = (PluginDocumentSettingPanel);
10386
10387 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-settings-menu/plugin-block-settings-menu-item.js
10388 /**
10389 * WordPress dependencies
10390 */
10391
10392
10393
10394
10395 const isEverySelectedBlockAllowed = (selected, allowed) => selected.filter(id => !allowed.includes(id)).length === 0;
10396
10397 /**
10398 * Plugins may want to add an item to the menu either for every block
10399 * or only for the specific ones provided in the `allowedBlocks` component property.
10400 *
10401 * If there are multiple blocks selected the item will be rendered if every block
10402 * is of one allowed type (not necessarily the same).
10403 *
10404 * @param {string[]} selectedBlocks Array containing the names of the blocks selected
10405 * @param {string[]} allowedBlocks Array containing the names of the blocks allowed
10406 * @return {boolean} Whether the item will be rendered or not.
10407 */
10408 const shouldRenderItem = (selectedBlocks, allowedBlocks) => !Array.isArray(allowedBlocks) || isEverySelectedBlockAllowed(selectedBlocks, allowedBlocks);
10409
10410 /**
10411 * Renders a new item in the block settings menu.
10412 *
10413 * @param {Object} props Component props.
10414 * @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.
10415 * @param {WPBlockTypeIconRender} [props.icon] The [Dashicon](https://developer.wordpress.org/resource/dashicons/) icon slug string, or an SVG WP element.
10416 * @param {string} props.label The menu item text.
10417 * @param {Function} props.onClick Callback function to be executed when the user click the menu item.
10418 * @param {boolean} [props.small] Whether to render the label or not.
10419 * @param {string} [props.role] The ARIA role for the menu item.
10420 *
10421 * @example
10422 * ```js
10423 * // Using ES5 syntax
10424 * var __ = wp.i18n.__;
10425 * var PluginBlockSettingsMenuItem = wp.editor.PluginBlockSettingsMenuItem;
10426 *
10427 * function doOnClick(){
10428 * // To be called when the user clicks the menu item.
10429 * }
10430 *
10431 * function MyPluginBlockSettingsMenuItem() {
10432 * return React.createElement(
10433 * PluginBlockSettingsMenuItem,
10434 * {
10435 * allowedBlocks: [ 'core/paragraph' ],
10436 * icon: 'dashicon-name',
10437 * label: __( 'Menu item text' ),
10438 * onClick: doOnClick,
10439 * }
10440 * );
10441 * }
10442 * ```
10443 *
10444 * @example
10445 * ```jsx
10446 * // Using ESNext syntax
10447 * import { __ } from '@wordpress/i18n';
10448 * import { PluginBlockSettingsMenuItem } from '@wordpress/editor';
10449 *
10450 * const doOnClick = ( ) => {
10451 * // To be called when the user clicks the menu item.
10452 * };
10453 *
10454 * const MyPluginBlockSettingsMenuItem = () => (
10455 * <PluginBlockSettingsMenuItem
10456 * allowedBlocks={ [ 'core/paragraph' ] }
10457 * icon='dashicon-name'
10458 * label={ __( 'Menu item text' ) }
10459 * onClick={ doOnClick } />
10460 * );
10461 * ```
10462 *
10463 * @return {Component} The component to be rendered.
10464 */
10465 const PluginBlockSettingsMenuItem = ({
10466 allowedBlocks,
10467 icon,
10468 label,
10469 onClick,
10470 small,
10471 role
10472 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
10473 children: ({
10474 selectedBlocks,
10475 onClose
10476 }) => {
10477 if (!shouldRenderItem(selectedBlocks, allowedBlocks)) {
10478 return null;
10479 }
10480 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
10481 onClick: (0,external_wp_compose_namespaceObject.compose)(onClick, onClose),
10482 icon: icon,
10483 label: small ? label : undefined,
10484 role: role,
10485 children: !small && label
10486 });
10487 }
10488 });
10489 /* harmony default export */ const plugin_block_settings_menu_item = (PluginBlockSettingsMenuItem);
10490
10491 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-more-menu-item/index.js
10492 /**
10493 * WordPress dependencies
10494 */
10495
10496
10497
10498
10499
10500 /**
10501 * 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.
10502 * The text within the component appears as the menu item label.
10503 *
10504 * @param {Object} props Component properties.
10505 * @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.
10506 * @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.
10507 * @param {Function} [props.onClick=noop] The callback function to be executed when the user clicks the menu item.
10508 * @param {...*} [props.other] Any additional props are passed through to the underlying [Button](/packages/components/src/button/README.md) component.
10509 *
10510 * @example
10511 * ```js
10512 * // Using ES5 syntax
10513 * var __ = wp.i18n.__;
10514 * var PluginMoreMenuItem = wp.editor.PluginMoreMenuItem;
10515 * var moreIcon = wp.element.createElement( 'svg' ); //... svg element.
10516 *
10517 * function onButtonClick() {
10518 * alert( 'Button clicked.' );
10519 * }
10520 *
10521 * function MyButtonMoreMenuItem() {
10522 * return wp.element.createElement(
10523 * PluginMoreMenuItem,
10524 * {
10525 * icon: moreIcon,
10526 * onClick: onButtonClick,
10527 * },
10528 * __( 'My button title' )
10529 * );
10530 * }
10531 * ```
10532 *
10533 * @example
10534 * ```jsx
10535 * // Using ESNext syntax
10536 * import { __ } from '@wordpress/i18n';
10537 * import { PluginMoreMenuItem } from '@wordpress/editor';
10538 * import { more } from '@wordpress/icons';
10539 *
10540 * function onButtonClick() {
10541 * alert( 'Button clicked.' );
10542 * }
10543 *
10544 * const MyButtonMoreMenuItem = () => (
10545 * <PluginMoreMenuItem
10546 * icon={ more }
10547 * onClick={ onButtonClick }
10548 * >
10549 * { __( 'My button title' ) }
10550 * </PluginMoreMenuItem>
10551 * );
10552 * ```
10553 *
10554 * @return {Component} The component to be rendered.
10555 */
10556 /* harmony default export */ const plugin_more_menu_item = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_plugins_namespaceObject.withPluginContext)((context, ownProps) => {
10557 var _ownProps$as;
10558 return {
10559 as: (_ownProps$as = ownProps.as) !== null && _ownProps$as !== void 0 ? _ownProps$as : external_wp_components_namespaceObject.MenuItem,
10560 icon: ownProps.icon || context.icon,
10561 name: 'core/plugin-more-menu'
10562 };
10563 }))(action_item));
10564
10565 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-post-publish-panel/index.js
10566 /**
10567 * WordPress dependencies
10568 */
10569
10570
10571
10572 const {
10573 Fill: plugin_post_publish_panel_Fill,
10574 Slot: plugin_post_publish_panel_Slot
10575 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostPublishPanel');
10576
10577 /**
10578 * Renders provided content to the post-publish panel in the publish flow
10579 * (side panel that opens after a user publishes the post).
10580 *
10581 * @param {Object} props Component properties.
10582 * @param {string} [props.className] An optional class name added to the panel.
10583 * @param {string} [props.title] Title displayed at the top of the panel.
10584 * @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened. When no title is provided it is always opened.
10585 * @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.
10586 * @param {Element} props.children Children to be rendered
10587 *
10588 * @example
10589 * ```jsx
10590 * // Using ESNext syntax
10591 * import { __ } from '@wordpress/i18n';
10592 * import { PluginPostPublishPanel } from '@wordpress/editor';
10593 *
10594 * const MyPluginPostPublishPanel = () => (
10595 * <PluginPostPublishPanel
10596 * className="my-plugin-post-publish-panel"
10597 * title={ __( 'My panel title' ) }
10598 * initialOpen={ true }
10599 * >
10600 * { __( 'My panel content' ) }
10601 * </PluginPostPublishPanel>
10602 * );
10603 * ```
10604 *
10605 * @return {Component} The component to be rendered.
10606 */
10607 const PluginPostPublishPanel = ({
10608 children,
10609 className,
10610 title,
10611 initialOpen = false,
10612 icon
10613 }) => {
10614 const {
10615 icon: pluginIcon
10616 } = (0,external_wp_plugins_namespaceObject.usePluginContext)();
10617 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_post_publish_panel_Fill, {
10618 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
10619 className: className,
10620 initialOpen: initialOpen || !title,
10621 title: title,
10622 icon: icon !== null && icon !== void 0 ? icon : pluginIcon,
10623 children: children
10624 })
10625 });
10626 };
10627 PluginPostPublishPanel.Slot = plugin_post_publish_panel_Slot;
10628 /* harmony default export */ const plugin_post_publish_panel = (PluginPostPublishPanel);
10629
10630 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-post-status-info/index.js
10631 /**
10632 * Defines as extensibility slot for the Summary panel.
10633 */
10634
10635 /**
10636 * WordPress dependencies
10637 */
10638
10639
10640 const {
10641 Fill: plugin_post_status_info_Fill,
10642 Slot: plugin_post_status_info_Slot
10643 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostStatusInfo');
10644
10645 /**
10646 * Renders a row in the Summary panel of the Document sidebar.
10647 * It should be noted that this is named and implemented around the function it serves
10648 * and not its location, which may change in future iterations.
10649 *
10650 * @param {Object} props Component properties.
10651 * @param {string} [props.className] An optional class name added to the row.
10652 * @param {Element} props.children Children to be rendered.
10653 *
10654 * @example
10655 * ```js
10656 * // Using ES5 syntax
10657 * var __ = wp.i18n.__;
10658 * var PluginPostStatusInfo = wp.editor.PluginPostStatusInfo;
10659 *
10660 * function MyPluginPostStatusInfo() {
10661 * return React.createElement(
10662 * PluginPostStatusInfo,
10663 * {
10664 * className: 'my-plugin-post-status-info',
10665 * },
10666 * __( 'My post status info' )
10667 * )
10668 * }
10669 * ```
10670 *
10671 * @example
10672 * ```jsx
10673 * // Using ESNext syntax
10674 * import { __ } from '@wordpress/i18n';
10675 * import { PluginPostStatusInfo } from '@wordpress/editor';
10676 *
10677 * const MyPluginPostStatusInfo = () => (
10678 * <PluginPostStatusInfo
10679 * className="my-plugin-post-status-info"
10680 * >
10681 * { __( 'My post status info' ) }
10682 * </PluginPostStatusInfo>
10683 * );
10684 * ```
10685 *
10686 * @return {Component} The component to be rendered.
10687 */
10688 const PluginPostStatusInfo = ({
10689 children,
10690 className
10691 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_post_status_info_Fill, {
10692 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
10693 className: className,
10694 children: children
10695 })
10696 });
10697 PluginPostStatusInfo.Slot = plugin_post_status_info_Slot;
10698 /* harmony default export */ const plugin_post_status_info = (PluginPostStatusInfo);
10699
10700 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-pre-publish-panel/index.js
10701 /**
10702 * WordPress dependencies
10703 */
10704
10705
10706
10707 const {
10708 Fill: plugin_pre_publish_panel_Fill,
10709 Slot: plugin_pre_publish_panel_Slot
10710 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPrePublishPanel');
10711
10712 /**
10713 * Renders provided content to the pre-publish side panel in the publish flow
10714 * (side panel that opens when a user first pushes "Publish" from the main editor).
10715 *
10716 * @param {Object} props Component props.
10717 * @param {string} [props.className] An optional class name added to the panel.
10718 * @param {string} [props.title] Title displayed at the top of the panel.
10719 * @param {boolean} [props.initialOpen=false] Whether to have the panel initially opened.
10720 * When no title is provided it is always opened.
10721 * @param {WPBlockTypeIconRender} [props.icon=inherits from the plugin] The [Dashicon](https://developer.wordpress.org/resource/dashicons/)
10722 * icon slug string, or an SVG WP element, to be rendered when
10723 * the sidebar is pinned to toolbar.
10724 * @param {Element} props.children Children to be rendered
10725 *
10726 * @example
10727 * ```jsx
10728 * // Using ESNext syntax
10729 * import { __ } from '@wordpress/i18n';
10730 * import { PluginPrePublishPanel } from '@wordpress/editor';
10731 *
10732 * const MyPluginPrePublishPanel = () => (
10733 * <PluginPrePublishPanel
10734 * className="my-plugin-pre-publish-panel"
10735 * title={ __( 'My panel title' ) }
10736 * initialOpen={ true }
10737 * >
10738 * { __( 'My panel content' ) }
10739 * </PluginPrePublishPanel>
10740 * );
10741 * ```
10742 *
10743 * @return {Component} The component to be rendered.
10744 */
10745 const PluginPrePublishPanel = ({
10746 children,
10747 className,
10748 title,
10749 initialOpen = false,
10750 icon
10751 }) => {
10752 const {
10753 icon: pluginIcon
10754 } = (0,external_wp_plugins_namespaceObject.usePluginContext)();
10755 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_pre_publish_panel_Fill, {
10756 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
10757 className: className,
10758 initialOpen: initialOpen || !title,
10759 title: title,
10760 icon: icon !== null && icon !== void 0 ? icon : pluginIcon,
10761 children: children
10762 })
10763 });
10764 };
10765 PluginPrePublishPanel.Slot = plugin_pre_publish_panel_Slot;
10766 /* harmony default export */ const plugin_pre_publish_panel = (PluginPrePublishPanel);
10767
10768 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-sidebar/index.js
10769 /**
10770 * WordPress dependencies
10771 */
10772
10773
10774
10775
10776
10777 /**
10778 * Internal dependencies
10779 */
10780
10781
10782 /**
10783 * Renders a sidebar when activated. The contents within the `PluginSidebar` will appear as content within the sidebar.
10784 * It also automatically renders a corresponding `PluginSidebarMenuItem` component when `isPinnable` flag is set to `true`.
10785 * If you wish to display the sidebar, you can with use the `PluginSidebarMoreMenuItem` component or the `wp.data.dispatch` API:
10786 *
10787 * ```js
10788 * wp.data.dispatch( 'core/edit-post' ).openGeneralSidebar( 'plugin-name/sidebar-name' );
10789 * ```
10790 *
10791 * @see PluginSidebarMoreMenuItem
10792 *
10793 * @param {Object} props Element props.
10794 * @param {string} props.name A string identifying the sidebar. Must be unique for every sidebar registered within the scope of your plugin.
10795 * @param {string} [props.className] An optional class name added to the sidebar body.
10796 * @param {string} props.title Title displayed at the top of the sidebar.
10797 * @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.
10798 * @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.
10799 *
10800 * @example
10801 * ```js
10802 * // Using ES5 syntax
10803 * var __ = wp.i18n.__;
10804 * var el = React.createElement;
10805 * var PanelBody = wp.components.PanelBody;
10806 * var PluginSidebar = wp.editor.PluginSidebar;
10807 * var moreIcon = React.createElement( 'svg' ); //... svg element.
10808 *
10809 * function MyPluginSidebar() {
10810 * return el(
10811 * PluginSidebar,
10812 * {
10813 * name: 'my-sidebar',
10814 * title: 'My sidebar title',
10815 * icon: moreIcon,
10816 * },
10817 * el(
10818 * PanelBody,
10819 * {},
10820 * __( 'My sidebar content' )
10821 * )
10822 * );
10823 * }
10824 * ```
10825 *
10826 * @example
10827 * ```jsx
10828 * // Using ESNext syntax
10829 * import { __ } from '@wordpress/i18n';
10830 * import { PanelBody } from '@wordpress/components';
10831 * import { PluginSidebar } from '@wordpress/editor';
10832 * import { more } from '@wordpress/icons';
10833 *
10834 * const MyPluginSidebar = () => (
10835 * <PluginSidebar
10836 * name="my-sidebar"
10837 * title="My sidebar title"
10838 * icon={ more }
10839 * >
10840 * <PanelBody>
10841 * { __( 'My sidebar content' ) }
10842 * </PanelBody>
10843 * </PluginSidebar>
10844 * );
10845 * ```
10846 */
10847
10848 function PluginSidebar({
10849 className,
10850 ...props
10851 }) {
10852 const {
10853 postTitle,
10854 shortcut
10855 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
10856 return {
10857 postTitle: select(store_store).getEditedPostAttribute('title'),
10858 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/editor/toggle-sidebar')
10859 };
10860 }, []);
10861 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area, {
10862 panelClassName: className,
10863 className: "editor-sidebar",
10864 smallScreenTitle: postTitle || (0,external_wp_i18n_namespaceObject.__)('(no title)'),
10865 scope: "core",
10866 toggleShortcut: shortcut,
10867 ...props
10868 });
10869 }
10870
10871 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/plugin-sidebar-more-menu-item/index.js
10872 /**
10873 * WordPress dependencies
10874 */
10875
10876
10877 /**
10878 * Renders a menu item in `Plugins` group in `More Menu` drop down,
10879 * and can be used to activate the corresponding `PluginSidebar` component.
10880 * The text within the component appears as the menu item label.
10881 *
10882 * @param {Object} props Component props.
10883 * @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.
10884 * @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.
10885 *
10886 * @example
10887 * ```js
10888 * // Using ES5 syntax
10889 * var __ = wp.i18n.__;
10890 * var PluginSidebarMoreMenuItem = wp.editor.PluginSidebarMoreMenuItem;
10891 * var moreIcon = React.createElement( 'svg' ); //... svg element.
10892 *
10893 * function MySidebarMoreMenuItem() {
10894 * return React.createElement(
10895 * PluginSidebarMoreMenuItem,
10896 * {
10897 * target: 'my-sidebar',
10898 * icon: moreIcon,
10899 * },
10900 * __( 'My sidebar title' )
10901 * )
10902 * }
10903 * ```
10904 *
10905 * @example
10906 * ```jsx
10907 * // Using ESNext syntax
10908 * import { __ } from '@wordpress/i18n';
10909 * import { PluginSidebarMoreMenuItem } from '@wordpress/editor';
10910 * import { more } from '@wordpress/icons';
10911 *
10912 * const MySidebarMoreMenuItem = () => (
10913 * <PluginSidebarMoreMenuItem
10914 * target="my-sidebar"
10915 * icon={ more }
10916 * >
10917 * { __( 'My sidebar title' ) }
10918 * </PluginSidebarMoreMenuItem>
10919 * );
10920 * ```
10921 *
10922 * @return {Component} The component to be rendered.
10923 */
10924
10925 function PluginSidebarMoreMenuItem(props) {
10926 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ComplementaryAreaMoreMenuItem
10927 // Menu item is marked with unstable prop for backward compatibility.
10928 // @see https://github.com/WordPress/gutenberg/issues/14457
10929 , {
10930 __unstableExplicitMenuItem: true,
10931 scope: "core",
10932 ...props
10933 });
10934 }
10935
10936 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/swap-template-button.js
10937 /**
10938 * WordPress dependencies
10939 */
10940
10941
10942
10943
10944
10945
10946
10947
10948
10949
10950 /**
10951 * Internal dependencies
10952 */
10953
10954
10955
10956
10957 function SwapTemplateButton({
10958 onClick
10959 }) {
10960 const [showModal, setShowModal] = (0,external_wp_element_namespaceObject.useState)(false);
10961 const {
10962 postType,
10963 postId
10964 } = useEditedPostContext();
10965 const availableTemplates = useAvailableTemplates(postType);
10966 const {
10967 editEntityRecord
10968 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
10969 if (!availableTemplates?.length) {
10970 return null;
10971 }
10972 const onTemplateSelect = async template => {
10973 editEntityRecord('postType', postType, postId, {
10974 template: template.name
10975 }, {
10976 undoIgnore: true
10977 });
10978 setShowModal(false); // Close the template suggestions modal first.
10979 onClick();
10980 };
10981 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
10982 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
10983 onClick: () => setShowModal(true),
10984 children: (0,external_wp_i18n_namespaceObject.__)('Swap template')
10985 }), showModal && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
10986 title: (0,external_wp_i18n_namespaceObject.__)('Choose a template'),
10987 onRequestClose: () => setShowModal(false),
10988 overlayClassName: "editor-post-template__swap-template-modal",
10989 isFullScreen: true,
10990 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
10991 className: "editor-post-template__swap-template-modal-content",
10992 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatesList, {
10993 postType: postType,
10994 onSelect: onTemplateSelect
10995 })
10996 })
10997 })]
10998 });
10999 }
11000 function TemplatesList({
11001 postType,
11002 onSelect
11003 }) {
11004 const availableTemplates = useAvailableTemplates(postType);
11005 const templatesAsPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => availableTemplates.map(template => ({
11006 name: template.slug,
11007 blocks: (0,external_wp_blocks_namespaceObject.parse)(template.content.raw),
11008 title: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title.rendered),
11009 id: template.id
11010 })), [availableTemplates]);
11011 const shownTemplates = (0,external_wp_compose_namespaceObject.useAsyncList)(templatesAsPatterns);
11012 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
11013 label: (0,external_wp_i18n_namespaceObject.__)('Templates'),
11014 blockPatterns: templatesAsPatterns,
11015 shownPatterns: shownTemplates,
11016 onClickPattern: onSelect
11017 });
11018 }
11019
11020 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/reset-default-template.js
11021 /**
11022 * WordPress dependencies
11023 */
11024
11025
11026
11027
11028
11029 /**
11030 * Internal dependencies
11031 */
11032
11033
11034 function ResetDefaultTemplate({
11035 onClick
11036 }) {
11037 const currentTemplateSlug = useCurrentTemplateSlug();
11038 const allowSwitchingTemplate = useAllowSwitchingTemplates();
11039 const {
11040 postType,
11041 postId
11042 } = useEditedPostContext();
11043 const {
11044 editEntityRecord
11045 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
11046 // The default template in a post is indicated by an empty string.
11047 if (!currentTemplateSlug || !allowSwitchingTemplate) {
11048 return null;
11049 }
11050 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
11051 onClick: () => {
11052 editEntityRecord('postType', postType, postId, {
11053 template: ''
11054 }, {
11055 undoIgnore: true
11056 });
11057 onClick();
11058 },
11059 children: (0,external_wp_i18n_namespaceObject.__)('Use default template')
11060 });
11061 }
11062
11063 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/create-new-template.js
11064 /**
11065 * WordPress dependencies
11066 */
11067
11068
11069
11070
11071
11072
11073 /**
11074 * Internal dependencies
11075 */
11076
11077
11078
11079
11080
11081 function CreateNewTemplate({
11082 onClick
11083 }) {
11084 const {
11085 canCreateTemplates
11086 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11087 const {
11088 canUser
11089 } = select(external_wp_coreData_namespaceObject.store);
11090 return {
11091 canCreateTemplates: canUser('create', {
11092 kind: 'postType',
11093 name: 'wp_template'
11094 })
11095 };
11096 }, []);
11097 const [isCreateModalOpen, setIsCreateModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
11098 const allowSwitchingTemplate = useAllowSwitchingTemplates();
11099
11100 // The default template in a post is indicated by an empty string.
11101 if (!canCreateTemplates || !allowSwitchingTemplate) {
11102 return null;
11103 }
11104 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11105 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
11106 onClick: () => {
11107 setIsCreateModalOpen(true);
11108 },
11109 children: (0,external_wp_i18n_namespaceObject.__)('Create new template')
11110 }), isCreateModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateNewTemplateModal, {
11111 onClose: () => {
11112 setIsCreateModalOpen(false);
11113 onClick();
11114 }
11115 })]
11116 });
11117 }
11118
11119 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/block-theme.js
11120 /**
11121 * WordPress dependencies
11122 */
11123
11124
11125
11126
11127
11128
11129
11130
11131 /**
11132 * Internal dependencies
11133 */
11134
11135
11136
11137
11138
11139
11140
11141
11142 const block_theme_POPOVER_PROPS = {
11143 className: 'editor-post-template__dropdown',
11144 placement: 'bottom-start'
11145 };
11146 function BlockThemeControl({
11147 id
11148 }) {
11149 const {
11150 isTemplateHidden,
11151 onNavigateToEntityRecord,
11152 getEditorSettings,
11153 hasGoBack
11154 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11155 const {
11156 getRenderingMode,
11157 getEditorSettings: _getEditorSettings
11158 } = unlock(select(store_store));
11159 const editorSettings = _getEditorSettings();
11160 return {
11161 isTemplateHidden: getRenderingMode() === 'post-only',
11162 onNavigateToEntityRecord: editorSettings.onNavigateToEntityRecord,
11163 getEditorSettings: _getEditorSettings,
11164 hasGoBack: editorSettings.hasOwnProperty('onNavigateToPreviousEntityRecord')
11165 };
11166 }, []);
11167 const {
11168 editedRecord: template,
11169 hasResolved
11170 } = (0,external_wp_coreData_namespaceObject.useEntityRecord)('postType', 'wp_template', id);
11171 const {
11172 createSuccessNotice
11173 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
11174 const {
11175 setRenderingMode
11176 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11177 const canCreateTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_coreData_namespaceObject.store).canUser('create', {
11178 kind: 'postType',
11179 name: 'wp_template'
11180 }), []);
11181 if (!hasResolved) {
11182 return null;
11183 }
11184
11185 // The site editor does not have a `onNavigateToPreviousEntityRecord` setting as it uses its own routing
11186 // and assigns its own backlink to focusMode pages.
11187 const notificationAction = hasGoBack ? [{
11188 label: (0,external_wp_i18n_namespaceObject.__)('Go back'),
11189 onClick: () => getEditorSettings().onNavigateToPreviousEntityRecord()
11190 }] : undefined;
11191 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
11192 popoverProps: block_theme_POPOVER_PROPS,
11193 focusOnMount: true,
11194 toggleProps: {
11195 size: 'compact',
11196 variant: 'tertiary',
11197 tooltipPosition: 'middle left'
11198 },
11199 label: (0,external_wp_i18n_namespaceObject.__)('Template options'),
11200 text: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(template.title),
11201 icon: null,
11202 children: ({
11203 onClose
11204 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11205 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
11206 children: [canCreateTemplate && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
11207 onClick: () => {
11208 onNavigateToEntityRecord({
11209 postId: template.id,
11210 postType: 'wp_template'
11211 });
11212 onClose();
11213 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Editing template. Changes made here affect all posts and pages that use the template.'), {
11214 type: 'snackbar',
11215 actions: notificationAction
11216 });
11217 },
11218 children: (0,external_wp_i18n_namespaceObject.__)('Edit template')
11219 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SwapTemplateButton, {
11220 onClick: onClose
11221 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResetDefaultTemplate, {
11222 onClick: onClose
11223 }), canCreateTemplate && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateNewTemplate, {
11224 onClick: onClose
11225 })]
11226 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
11227 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
11228 icon: !isTemplateHidden ? library_check : undefined,
11229 isSelected: !isTemplateHidden,
11230 role: "menuitemcheckbox",
11231 onClick: () => {
11232 setRenderingMode(isTemplateHidden ? 'template-locked' : 'post-only');
11233 },
11234 children: (0,external_wp_i18n_namespaceObject.__)('Show template')
11235 })
11236 })]
11237 })
11238 });
11239 }
11240
11241 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-template/panel.js
11242 /**
11243 * WordPress dependencies
11244 */
11245
11246
11247
11248
11249 /**
11250 * Internal dependencies
11251 */
11252
11253
11254
11255
11256
11257 /**
11258 * Displays the template controls based on the current editor settings and user permissions.
11259 *
11260 * @return {JSX.Element|null} The rendered PostTemplatePanel component.
11261 */
11262
11263 function PostTemplatePanel() {
11264 const {
11265 templateId,
11266 isBlockTheme
11267 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11268 const {
11269 getCurrentTemplateId,
11270 getEditorSettings
11271 } = select(store_store);
11272 return {
11273 templateId: getCurrentTemplateId(),
11274 isBlockTheme: getEditorSettings().__unstableIsBlockBasedTheme
11275 };
11276 }, []);
11277 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
11278 var _select$canUser;
11279 const postTypeSlug = select(store_store).getCurrentPostType();
11280 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
11281 if (!postType?.viewable) {
11282 return false;
11283 }
11284 const settings = select(store_store).getEditorSettings();
11285 const hasTemplates = !!settings.availableTemplates && Object.keys(settings.availableTemplates).length > 0;
11286 if (hasTemplates) {
11287 return true;
11288 }
11289 if (!settings.supportsTemplateMode) {
11290 return false;
11291 }
11292 const canCreateTemplates = (_select$canUser = select(external_wp_coreData_namespaceObject.store).canUser('create', {
11293 kind: 'postType',
11294 name: 'wp_template'
11295 })) !== null && _select$canUser !== void 0 ? _select$canUser : false;
11296 return canCreateTemplates;
11297 }, []);
11298 const canViewTemplates = (0,external_wp_data_namespaceObject.useSelect)(select => {
11299 var _select$canUser2;
11300 return (_select$canUser2 = select(external_wp_coreData_namespaceObject.store).canUser('read', {
11301 kind: 'postType',
11302 name: 'wp_template'
11303 })) !== null && _select$canUser2 !== void 0 ? _select$canUser2 : false;
11304 }, []);
11305 if ((!isBlockTheme || !canViewTemplates) && isVisible) {
11306 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
11307 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
11308 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(classic_theme, {})
11309 });
11310 }
11311 if (isBlockTheme && !!templateId) {
11312 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
11313 label: (0,external_wp_i18n_namespaceObject.__)('Template'),
11314 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockThemeControl, {
11315 id: templateId
11316 })
11317 });
11318 }
11319 return null;
11320 }
11321
11322 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/constants.js
11323 const BASE_QUERY = {
11324 _fields: 'id,name',
11325 context: 'view' // Allows non-admins to perform requests.
11326 };
11327 const AUTHORS_QUERY = {
11328 who: 'authors',
11329 per_page: 50,
11330 ...BASE_QUERY
11331 };
11332
11333 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/hook.js
11334 /**
11335 * WordPress dependencies
11336 */
11337
11338
11339
11340
11341
11342 /**
11343 * Internal dependencies
11344 */
11345
11346
11347 function useAuthorsQuery(search) {
11348 const {
11349 authorId,
11350 authors,
11351 postAuthor
11352 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11353 const {
11354 getUser,
11355 getUsers
11356 } = select(external_wp_coreData_namespaceObject.store);
11357 const {
11358 getEditedPostAttribute
11359 } = select(store_store);
11360 const _authorId = getEditedPostAttribute('author');
11361 const query = {
11362 ...AUTHORS_QUERY
11363 };
11364 if (search) {
11365 query.search = search;
11366 }
11367 return {
11368 authorId: _authorId,
11369 authors: getUsers(query),
11370 postAuthor: getUser(_authorId, BASE_QUERY)
11371 };
11372 }, [search]);
11373 const authorOptions = (0,external_wp_element_namespaceObject.useMemo)(() => {
11374 const fetchedAuthors = (authors !== null && authors !== void 0 ? authors : []).map(author => {
11375 return {
11376 value: author.id,
11377 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(author.name)
11378 };
11379 });
11380
11381 // Ensure the current author is included in the dropdown list.
11382 const foundAuthor = fetchedAuthors.findIndex(({
11383 value
11384 }) => postAuthor?.id === value);
11385 if (foundAuthor < 0 && postAuthor) {
11386 return [{
11387 value: postAuthor.id,
11388 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postAuthor.name)
11389 }, ...fetchedAuthors];
11390 }
11391 return fetchedAuthors;
11392 }, [authors, postAuthor]);
11393 return {
11394 authorId,
11395 authorOptions,
11396 postAuthor
11397 };
11398 }
11399
11400 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/combobox.js
11401 /**
11402 * WordPress dependencies
11403 */
11404
11405
11406
11407
11408
11409
11410 /**
11411 * Internal dependencies
11412 */
11413
11414
11415
11416 function PostAuthorCombobox() {
11417 const [fieldValue, setFieldValue] = (0,external_wp_element_namespaceObject.useState)();
11418 const {
11419 editPost
11420 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11421 const {
11422 authorId,
11423 authorOptions
11424 } = useAuthorsQuery(fieldValue);
11425
11426 /**
11427 * Handle author selection.
11428 *
11429 * @param {number} postAuthorId The selected Author.
11430 */
11431 const handleSelect = postAuthorId => {
11432 if (!postAuthorId) {
11433 return;
11434 }
11435 editPost({
11436 author: postAuthorId
11437 });
11438 };
11439
11440 /**
11441 * Handle user input.
11442 *
11443 * @param {string} inputValue The current value of the input field.
11444 */
11445 const handleKeydown = inputValue => {
11446 setFieldValue(inputValue);
11447 };
11448 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ComboboxControl, {
11449 __nextHasNoMarginBottom: true,
11450 __next40pxDefaultSize: true,
11451 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
11452 options: authorOptions,
11453 value: authorId,
11454 onFilterValueChange: (0,external_wp_compose_namespaceObject.debounce)(handleKeydown, 300),
11455 onChange: handleSelect,
11456 allowReset: false,
11457 hideLabelFromVision: true
11458 });
11459 }
11460
11461 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/select.js
11462 /**
11463 * WordPress dependencies
11464 */
11465
11466
11467
11468
11469 /**
11470 * Internal dependencies
11471 */
11472
11473
11474
11475 function PostAuthorSelect() {
11476 const {
11477 editPost
11478 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11479 const {
11480 authorId,
11481 authorOptions
11482 } = useAuthorsQuery();
11483 const setAuthorId = value => {
11484 const author = Number(value);
11485 editPost({
11486 author
11487 });
11488 };
11489 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SelectControl, {
11490 __next40pxDefaultSize: true,
11491 __nextHasNoMarginBottom: true,
11492 className: "post-author-selector",
11493 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
11494 options: authorOptions,
11495 onChange: setAuthorId,
11496 value: authorId,
11497 hideLabelFromVision: true
11498 });
11499 }
11500
11501 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/index.js
11502 /**
11503 * WordPress dependencies
11504 */
11505
11506
11507
11508 /**
11509 * Internal dependencies
11510 */
11511
11512
11513
11514
11515 const minimumUsersForCombobox = 25;
11516
11517 /**
11518 * Renders the component for selecting the post author.
11519 *
11520 * @return {Component} The component to be rendered.
11521 */
11522 function PostAuthor() {
11523 const showCombobox = (0,external_wp_data_namespaceObject.useSelect)(select => {
11524 const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY);
11525 return authors?.length >= minimumUsersForCombobox;
11526 }, []);
11527 if (showCombobox) {
11528 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorCombobox, {});
11529 }
11530 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorSelect, {});
11531 }
11532 /* harmony default export */ const post_author = (PostAuthor);
11533
11534 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/check.js
11535 /**
11536 * WordPress dependencies
11537 */
11538
11539
11540
11541 /**
11542 * Internal dependencies
11543 */
11544
11545
11546
11547
11548 /**
11549 * Wrapper component that renders its children only if the post type supports the author.
11550 *
11551 * @param {Object} props The component props.
11552 * @param {Element} props.children Children to be rendered.
11553 *
11554 * @return {Component|null} The component to be rendered. Return `null` if the post type doesn't
11555 * supports the author or if there are no authors available.
11556 */
11557
11558 function PostAuthorCheck({
11559 children
11560 }) {
11561 const {
11562 hasAssignAuthorAction,
11563 hasAuthors
11564 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11565 var _post$_links$wpActio;
11566 const post = select(store_store).getCurrentPost();
11567 const authors = select(external_wp_coreData_namespaceObject.store).getUsers(AUTHORS_QUERY);
11568 return {
11569 hasAssignAuthorAction: (_post$_links$wpActio = post._links?.['wp:action-assign-author']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false,
11570 hasAuthors: authors?.length >= 1
11571 };
11572 }, []);
11573 if (!hasAssignAuthorAction || !hasAuthors) {
11574 return null;
11575 }
11576 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
11577 supportKeys: "author",
11578 children: children
11579 });
11580 }
11581
11582 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-author/panel.js
11583 /**
11584 * WordPress dependencies
11585 */
11586
11587
11588
11589
11590
11591 /**
11592 * Internal dependencies
11593 */
11594
11595
11596
11597
11598
11599
11600 function PostAuthorToggle({
11601 isOpen,
11602 onClick
11603 }) {
11604 const {
11605 postAuthor
11606 } = useAuthorsQuery();
11607 const authorName = postAuthor?.name || '';
11608 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
11609 size: "compact",
11610 className: "editor-post-author__panel-toggle",
11611 variant: "tertiary",
11612 "aria-expanded": isOpen
11613 // translators: %s: Current post link.
11614 ,
11615 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change author: %s'), authorName),
11616 onClick: onClick,
11617 children: authorName
11618 });
11619 }
11620
11621 /**
11622 * Renders the Post Author Panel component.
11623 *
11624 * @return {Component} The component to be rendered.
11625 */
11626 function panel_PostAuthor() {
11627 // Use internal state instead of a ref to make sure that the component
11628 // re-renders when the popover's anchor updates.
11629 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
11630 // Memoize popoverProps to avoid returning a new object every time.
11631 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
11632 // Anchor the popover to the middle of the entire row so that it doesn't
11633 // move around when the label changes.
11634 anchor: popoverAnchor,
11635 placement: 'left-start',
11636 offset: 36,
11637 shift: true
11638 }), [popoverAnchor]);
11639 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorCheck, {
11640 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
11641 label: (0,external_wp_i18n_namespaceObject.__)('Author'),
11642 ref: setPopoverAnchor,
11643 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
11644 popoverProps: popoverProps,
11645 contentClassName: "editor-post-author__panel-dialog",
11646 focusOnMount: true,
11647 renderToggle: ({
11648 isOpen,
11649 onToggle
11650 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostAuthorToggle, {
11651 isOpen: isOpen,
11652 onClick: onToggle
11653 }),
11654 renderContent: ({
11655 onClose
11656 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
11657 className: "editor-post-author",
11658 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
11659 title: (0,external_wp_i18n_namespaceObject.__)('Author'),
11660 onClose: onClose
11661 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_author, {
11662 onClose: onClose
11663 })]
11664 })
11665 })
11666 })
11667 });
11668 }
11669 /* harmony default export */ const panel = (panel_PostAuthor);
11670
11671 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-comments/index.js
11672 /**
11673 * WordPress dependencies
11674 */
11675
11676
11677
11678
11679 /**
11680 * Internal dependencies
11681 */
11682
11683
11684
11685
11686 const COMMENT_OPTIONS = [{
11687 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11688 children: [(0,external_wp_i18n_namespaceObject._x)('Open', 'Adjective: e.g. "Comments are open"'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
11689 variant: "muted",
11690 size: 12,
11691 children: (0,external_wp_i18n_namespaceObject.__)('Visitors can add new comments and replies.')
11692 })]
11693 }),
11694 value: 'open'
11695 }, {
11696 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
11697 children: [(0,external_wp_i18n_namespaceObject.__)('Closed'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
11698 variant: "muted",
11699 size: 12,
11700 children: (0,external_wp_i18n_namespaceObject.__)('Visitors cannot add new comments or replies.')
11701 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
11702 variant: "muted",
11703 size: 12,
11704 children: (0,external_wp_i18n_namespaceObject.__)('Existing comments remain visible.')
11705 })]
11706 }),
11707 value: 'closed'
11708 }];
11709 function PostComments() {
11710 const commentStatus = (0,external_wp_data_namespaceObject.useSelect)(select => {
11711 var _select$getEditedPost;
11712 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('comment_status')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 'open';
11713 }, []);
11714 const {
11715 editPost
11716 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11717 const handleStatus = newCommentStatus => editPost({
11718 comment_status: newCommentStatus
11719 });
11720 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
11721 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
11722 spacing: 4,
11723 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
11724 className: "editor-change-status__options",
11725 hideLabelFromVision: true,
11726 label: (0,external_wp_i18n_namespaceObject.__)('Comment status'),
11727 options: COMMENT_OPTIONS,
11728 onChange: handleStatus,
11729 selected: commentStatus
11730 })
11731 })
11732 });
11733 }
11734
11735 /**
11736 * A form for managing comment status.
11737 *
11738 * @return {JSX.Element} The rendered PostComments component.
11739 */
11740 /* harmony default export */ const post_comments = (PostComments);
11741
11742 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-pingbacks/index.js
11743 /**
11744 * WordPress dependencies
11745 */
11746
11747
11748
11749
11750 /**
11751 * Internal dependencies
11752 */
11753
11754
11755 function PostPingbacks() {
11756 const pingStatus = (0,external_wp_data_namespaceObject.useSelect)(select => {
11757 var _select$getEditedPost;
11758 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('ping_status')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : 'open';
11759 }, []);
11760 const {
11761 editPost
11762 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11763 const onTogglePingback = () => editPost({
11764 ping_status: pingStatus === 'open' ? 'closed' : 'open'
11765 });
11766 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
11767 __nextHasNoMarginBottom: true,
11768 label: (0,external_wp_i18n_namespaceObject.__)('Enable pingbacks & trackbacks'),
11769 checked: pingStatus === 'open',
11770 onChange: onTogglePingback,
11771 help: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
11772 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/trackbacks-and-pingbacks/'),
11773 children: (0,external_wp_i18n_namespaceObject.__)('Learn more about pingbacks & trackbacks')
11774 })
11775 });
11776 }
11777
11778 /**
11779 * Renders a control for enabling or disabling pingbacks and trackbacks
11780 * in a WordPress post.
11781 *
11782 * @module PostPingbacks
11783 */
11784 /* harmony default export */ const post_pingbacks = (PostPingbacks);
11785
11786 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-discussion/panel.js
11787 /**
11788 * WordPress dependencies
11789 */
11790
11791
11792
11793
11794
11795
11796
11797 /**
11798 * Internal dependencies
11799 */
11800
11801
11802
11803
11804
11805
11806
11807 const panel_PANEL_NAME = 'discussion-panel';
11808 function ModalContents({
11809 onClose
11810 }) {
11811 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
11812 className: "editor-post-discussion",
11813 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
11814 title: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
11815 onClose: onClose
11816 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
11817 spacing: 4,
11818 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
11819 supportKeys: "comments",
11820 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_comments, {})
11821 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
11822 supportKeys: "trackbacks",
11823 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_pingbacks, {})
11824 })]
11825 })]
11826 });
11827 }
11828 function PostDiscussionToggle({
11829 isOpen,
11830 onClick
11831 }) {
11832 const {
11833 commentStatus,
11834 pingStatus,
11835 commentsSupported,
11836 trackbacksSupported
11837 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11838 var _getEditedPostAttribu, _getEditedPostAttribu2;
11839 const {
11840 getEditedPostAttribute
11841 } = select(store_store);
11842 const {
11843 getPostType
11844 } = select(external_wp_coreData_namespaceObject.store);
11845 const postType = getPostType(getEditedPostAttribute('type'));
11846 return {
11847 commentStatus: (_getEditedPostAttribu = getEditedPostAttribute('comment_status')) !== null && _getEditedPostAttribu !== void 0 ? _getEditedPostAttribu : 'open',
11848 pingStatus: (_getEditedPostAttribu2 = getEditedPostAttribute('ping_status')) !== null && _getEditedPostAttribu2 !== void 0 ? _getEditedPostAttribu2 : 'open',
11849 commentsSupported: !!postType.supports.comments,
11850 trackbacksSupported: !!postType.supports.trackbacks
11851 };
11852 }, []);
11853 let label;
11854 if (commentStatus === 'open') {
11855 if (pingStatus === 'open') {
11856 label = (0,external_wp_i18n_namespaceObject._x)('Open', 'Adjective: e.g. "Comments are open"');
11857 } else {
11858 label = trackbacksSupported ? (0,external_wp_i18n_namespaceObject.__)('Comments only') : (0,external_wp_i18n_namespaceObject._x)('Open', 'Adjective: e.g. "Comments are open"');
11859 }
11860 } else if (pingStatus === 'open') {
11861 label = commentsSupported ? (0,external_wp_i18n_namespaceObject.__)('Pings only') : (0,external_wp_i18n_namespaceObject.__)('Pings enabled');
11862 } else {
11863 label = (0,external_wp_i18n_namespaceObject.__)('Closed');
11864 }
11865 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
11866 size: "compact",
11867 className: "editor-post-discussion__panel-toggle",
11868 variant: "tertiary",
11869 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Change discussion options'),
11870 "aria-expanded": isOpen,
11871 onClick: onClick,
11872 children: label
11873 });
11874 }
11875
11876 /**
11877 * This component allows to update comment and pingback
11878 * settings for the current post. Internally there are
11879 * checks whether the current post has support for the
11880 * above and if the `discussion-panel` panel is enabled.
11881 *
11882 * @return {JSX.Element|null} The rendered PostDiscussionPanel component.
11883 */
11884 function PostDiscussionPanel() {
11885 const {
11886 isEnabled
11887 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11888 const {
11889 isEditorPanelEnabled
11890 } = select(store_store);
11891 return {
11892 isEnabled: isEditorPanelEnabled(panel_PANEL_NAME)
11893 };
11894 }, []);
11895
11896 // Use internal state instead of a ref to make sure that the component
11897 // re-renders when the popover's anchor updates.
11898 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
11899 // Memoize popoverProps to avoid returning a new object every time.
11900 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
11901 // Anchor the popover to the middle of the entire row so that it doesn't
11902 // move around when the label changes.
11903 anchor: popoverAnchor,
11904 placement: 'left-start',
11905 offset: 36,
11906 shift: true
11907 }), [popoverAnchor]);
11908 if (!isEnabled) {
11909 return null;
11910 }
11911 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
11912 supportKeys: ['comments', 'trackbacks'],
11913 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
11914 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
11915 ref: setPopoverAnchor,
11916 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
11917 popoverProps: popoverProps,
11918 className: "editor-post-discussion__panel-dropdown",
11919 contentClassName: "editor-post-discussion__panel-dialog",
11920 focusOnMount: true,
11921 renderToggle: ({
11922 isOpen,
11923 onToggle
11924 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostDiscussionToggle, {
11925 isOpen: isOpen,
11926 onClick: onToggle
11927 }),
11928 renderContent: ({
11929 onClose
11930 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ModalContents, {
11931 onClose: onClose
11932 })
11933 })
11934 })
11935 });
11936 }
11937
11938 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-excerpt/index.js
11939 /**
11940 * WordPress dependencies
11941 */
11942
11943
11944
11945
11946
11947
11948 /**
11949 * Internal dependencies
11950 */
11951
11952
11953 /**
11954 * Renders an editable textarea for the post excerpt.
11955 * Templates, template parts and patterns use the `excerpt` field as a description semantically.
11956 * Additionally templates and template parts override the `excerpt` field as `description` in
11957 * REST API. So this component handles proper labeling and updating the edited entity.
11958 *
11959 * @param {Object} props - Component props.
11960 * @param {boolean} [props.hideLabelFromVision=false] - Whether to visually hide the textarea's label.
11961 * @param {boolean} [props.updateOnBlur=false] - Whether to update the post on change or use local state and update on blur.
11962 */
11963
11964 function PostExcerpt({
11965 hideLabelFromVision = false,
11966 updateOnBlur = false
11967 }) {
11968 const {
11969 excerpt,
11970 shouldUseDescriptionLabel,
11971 usedAttribute
11972 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
11973 const {
11974 getCurrentPostType,
11975 getEditedPostAttribute
11976 } = select(store_store);
11977 const postType = getCurrentPostType();
11978 // This special case is unfortunate, but the REST API of wp_template and wp_template_part
11979 // support the excerpt field throught the "description" field rather than "excerpt".
11980 const _usedAttribute = ['wp_template', 'wp_template_part'].includes(postType) ? 'description' : 'excerpt';
11981 return {
11982 excerpt: getEditedPostAttribute(_usedAttribute),
11983 // There are special cases where we want to label the excerpt as a description.
11984 shouldUseDescriptionLabel: ['wp_template', 'wp_template_part', 'wp_block'].includes(postType),
11985 usedAttribute: _usedAttribute
11986 };
11987 }, []);
11988 const {
11989 editPost
11990 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
11991 const [localExcerpt, setLocalExcerpt] = (0,external_wp_element_namespaceObject.useState)((0,external_wp_htmlEntities_namespaceObject.decodeEntities)(excerpt));
11992 const updatePost = value => {
11993 editPost({
11994 [usedAttribute]: value
11995 });
11996 };
11997 const label = shouldUseDescriptionLabel ? (0,external_wp_i18n_namespaceObject.__)('Write a description (optional)') : (0,external_wp_i18n_namespaceObject.__)('Write an excerpt (optional)');
11998 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
11999 className: "editor-post-excerpt",
12000 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextareaControl, {
12001 __nextHasNoMarginBottom: true,
12002 label: label,
12003 hideLabelFromVision: hideLabelFromVision,
12004 className: "editor-post-excerpt__textarea",
12005 onChange: updateOnBlur ? setLocalExcerpt : updatePost,
12006 onBlur: updateOnBlur ? () => updatePost(localExcerpt) : undefined,
12007 value: updateOnBlur ? localExcerpt : excerpt,
12008 help: !shouldUseDescriptionLabel ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
12009 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#excerpt'),
12010 children: (0,external_wp_i18n_namespaceObject.__)('Learn more about manual excerpts')
12011 }) : (0,external_wp_i18n_namespaceObject.__)('Write a description')
12012 })
12013 });
12014 }
12015
12016 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-excerpt/check.js
12017 /**
12018 * Internal dependencies
12019 */
12020
12021
12022 /**
12023 * Component for checking if the post type supports the excerpt field.
12024 *
12025 * @param {Object} props Props.
12026 * @param {Element} props.children Children to be rendered.
12027 *
12028 * @return {Component} The component to be rendered.
12029 */
12030
12031 function PostExcerptCheck({
12032 children
12033 }) {
12034 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12035 supportKeys: "excerpt",
12036 children: children
12037 });
12038 }
12039 /* harmony default export */ const post_excerpt_check = (PostExcerptCheck);
12040
12041 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-excerpt/plugin.js
12042 /**
12043 * Defines as extensibility slot for the Excerpt panel.
12044 */
12045
12046 /**
12047 * WordPress dependencies
12048 */
12049
12050
12051 const {
12052 Fill: plugin_Fill,
12053 Slot: plugin_Slot
12054 } = (0,external_wp_components_namespaceObject.createSlotFill)('PluginPostExcerpt');
12055
12056 /**
12057 * Renders a post excerpt panel in the post sidebar.
12058 *
12059 * @param {Object} props Component properties.
12060 * @param {string} [props.className] An optional class name added to the row.
12061 * @param {Element} props.children Children to be rendered.
12062 *
12063 * @example
12064 * ```js
12065 * // Using ES5 syntax
12066 * var __ = wp.i18n.__;
12067 * var PluginPostExcerpt = wp.editPost.__experimentalPluginPostExcerpt;
12068 *
12069 * function MyPluginPostExcerpt() {
12070 * return React.createElement(
12071 * PluginPostExcerpt,
12072 * {
12073 * className: 'my-plugin-post-excerpt',
12074 * },
12075 * __( 'Post excerpt custom content' )
12076 * )
12077 * }
12078 * ```
12079 *
12080 * @example
12081 * ```jsx
12082 * // Using ESNext syntax
12083 * import { __ } from '@wordpress/i18n';
12084 * import { __experimentalPluginPostExcerpt as PluginPostExcerpt } from '@wordpress/edit-post';
12085 *
12086 * const MyPluginPostExcerpt = () => (
12087 * <PluginPostExcerpt className="my-plugin-post-excerpt">
12088 * { __( 'Post excerpt custom content' ) }
12089 * </PluginPostExcerpt>
12090 * );
12091 * ```
12092 *
12093 * @return {Component} The component to be rendered.
12094 */
12095 const PluginPostExcerpt = ({
12096 children,
12097 className
12098 }) => {
12099 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_Fill, {
12100 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelRow, {
12101 className: className,
12102 children: children
12103 })
12104 });
12105 };
12106 PluginPostExcerpt.Slot = plugin_Slot;
12107 /* harmony default export */ const post_excerpt_plugin = (PluginPostExcerpt);
12108
12109 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-excerpt/panel.js
12110 /**
12111 * WordPress dependencies
12112 */
12113
12114
12115
12116
12117
12118
12119
12120
12121 /**
12122 * Internal dependencies
12123 */
12124
12125
12126
12127
12128
12129
12130 /**
12131 * Module Constants
12132 */
12133
12134
12135
12136 const post_excerpt_panel_PANEL_NAME = 'post-excerpt';
12137 function ExcerptPanel() {
12138 const {
12139 isOpened,
12140 isEnabled,
12141 postType
12142 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12143 const {
12144 isEditorPanelOpened,
12145 isEditorPanelEnabled,
12146 getCurrentPostType
12147 } = select(store_store);
12148 return {
12149 isOpened: isEditorPanelOpened(post_excerpt_panel_PANEL_NAME),
12150 isEnabled: isEditorPanelEnabled(post_excerpt_panel_PANEL_NAME),
12151 postType: getCurrentPostType()
12152 };
12153 }, []);
12154 const {
12155 toggleEditorPanelOpened
12156 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12157 const toggleExcerptPanel = () => toggleEditorPanelOpened(post_excerpt_panel_PANEL_NAME);
12158 if (!isEnabled) {
12159 return null;
12160 }
12161
12162 // There are special cases where we want to label the excerpt as a description.
12163 const shouldUseDescriptionLabel = ['wp_template', 'wp_template_part', 'wp_block'].includes(postType);
12164 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
12165 title: shouldUseDescriptionLabel ? (0,external_wp_i18n_namespaceObject.__)('Description') : (0,external_wp_i18n_namespaceObject.__)('Excerpt'),
12166 opened: isOpened,
12167 onToggle: toggleExcerptPanel,
12168 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_plugin.Slot, {
12169 children: fills => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
12170 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostExcerpt, {}), fills]
12171 })
12172 })
12173 });
12174 }
12175
12176 /**
12177 * Is rendered if the post type supports excerpts and allows editing the excerpt.
12178 *
12179 * @return {JSX.Element} The rendered PostExcerptPanel component.
12180 */
12181 function PostExcerptPanel() {
12182 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_check, {
12183 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExcerptPanel, {})
12184 });
12185 }
12186 function PrivatePostExcerptPanel() {
12187 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_check, {
12188 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivateExcerpt, {})
12189 });
12190 }
12191 function PrivateExcerpt() {
12192 const {
12193 shouldRender,
12194 excerpt,
12195 shouldBeUsedAsDescription,
12196 allowEditing
12197 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12198 const {
12199 getCurrentPostType,
12200 getCurrentPostId,
12201 getEditedPostAttribute,
12202 isEditorPanelEnabled
12203 } = select(store_store);
12204 const postType = getCurrentPostType();
12205 const isTemplateOrTemplatePart = ['wp_template', 'wp_template_part'].includes(postType);
12206 const isPattern = postType === 'wp_block';
12207 // These post types use the `excerpt` field as a description semantically, so we need to
12208 // handle proper labeling and some flows where we should always render them as text.
12209 const _shouldBeUsedAsDescription = isTemplateOrTemplatePart || isPattern;
12210 const _usedAttribute = isTemplateOrTemplatePart ? 'description' : 'excerpt';
12211 // We need to fetch the entity in this case to check if we'll allow editing.
12212 const template = isTemplateOrTemplatePart && select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', postType, getCurrentPostId());
12213 // For post types that use excerpt as description, we do not abide
12214 // by the `isEnabled` panel flag in order to render them as text.
12215 const _shouldRender = isEditorPanelEnabled(post_excerpt_panel_PANEL_NAME) || _shouldBeUsedAsDescription;
12216 return {
12217 excerpt: getEditedPostAttribute(_usedAttribute),
12218 shouldRender: _shouldRender,
12219 shouldBeUsedAsDescription: _shouldBeUsedAsDescription,
12220 // If we should render, allow editing for all post types that are not used as description.
12221 // For the rest allow editing only for user generated entities.
12222 allowEditing: _shouldRender && (!_shouldBeUsedAsDescription || isPattern || template && template.source === TEMPLATE_ORIGINS.custom && !template.has_theme_file && template.is_custom)
12223 };
12224 }, []);
12225 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
12226 const label = shouldBeUsedAsDescription ? (0,external_wp_i18n_namespaceObject.__)('Description') : (0,external_wp_i18n_namespaceObject.__)('Excerpt');
12227 // Memoize popoverProps to avoid returning a new object every time.
12228 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
12229 // Anchor the popover to the middle of the entire row so that it doesn't
12230 // move around when the label changes.
12231 anchor: popoverAnchor,
12232 'aria-label': label,
12233 headerTitle: label,
12234 placement: 'left-start',
12235 offset: 36,
12236 shift: true
12237 }), [popoverAnchor, label]);
12238 if (!shouldRender) {
12239 return false;
12240 }
12241 const excerptText = !!excerpt && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
12242 align: "left",
12243 numberOfLines: 4,
12244 truncate: allowEditing,
12245 children: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(excerpt)
12246 });
12247 if (!allowEditing) {
12248 return excerptText;
12249 }
12250 const excerptPlaceholder = shouldBeUsedAsDescription ? (0,external_wp_i18n_namespaceObject.__)('Add a description…') : (0,external_wp_i18n_namespaceObject.__)('Add an excerpt…');
12251 const triggerEditLabel = shouldBeUsedAsDescription ? (0,external_wp_i18n_namespaceObject.__)('Edit description') : (0,external_wp_i18n_namespaceObject.__)('Edit excerpt');
12252 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
12253 children: [excerptText, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
12254 className: "editor-post-excerpt__dropdown",
12255 contentClassName: "editor-post-excerpt__dropdown__content",
12256 popoverProps: popoverProps,
12257 focusOnMount: true,
12258 ref: setPopoverAnchor,
12259 renderToggle: ({
12260 onToggle
12261 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12262 className: "editor-post-excerpt__dropdown__trigger",
12263 onClick: onToggle,
12264 variant: "link",
12265 children: excerptText ? triggerEditLabel : excerptPlaceholder
12266 }),
12267 renderContent: ({
12268 onClose
12269 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
12270 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
12271 title: label,
12272 onClose: onClose
12273 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
12274 spacing: 4,
12275 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_plugin.Slot, {
12276 children: fills => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
12277 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostExcerpt, {
12278 hideLabelFromVision: true,
12279 updateOnBlur: true
12280 }), fills]
12281 })
12282 })
12283 })]
12284 })
12285 })]
12286 });
12287 }
12288
12289 ;// CONCATENATED MODULE: external ["wp","blob"]
12290 const external_wp_blob_namespaceObject = window["wp"]["blob"];
12291 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/theme-support-check/index.js
12292 /**
12293 * WordPress dependencies
12294 */
12295
12296
12297
12298 /**
12299 * Internal dependencies
12300 */
12301
12302
12303 /**
12304 * Checks if the current theme supports specific features and renders the children if supported.
12305 *
12306 * @param {Object} props The component props.
12307 * @param {Element} props.children The children to render if the theme supports the specified features.
12308 * @param {string|string[]} props.supportKeys The key(s) of the theme support(s) to check.
12309 *
12310 * @return {JSX.Element|null} The rendered children if the theme supports the specified features, otherwise null.
12311 */
12312 function ThemeSupportCheck({
12313 children,
12314 supportKeys
12315 }) {
12316 const {
12317 postType,
12318 themeSupports
12319 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12320 return {
12321 postType: select(store_store).getEditedPostAttribute('type'),
12322 themeSupports: select(external_wp_coreData_namespaceObject.store).getThemeSupports()
12323 };
12324 }, []);
12325 const isSupported = (Array.isArray(supportKeys) ? supportKeys : [supportKeys]).some(key => {
12326 var _themeSupports$key;
12327 const supported = (_themeSupports$key = themeSupports?.[key]) !== null && _themeSupports$key !== void 0 ? _themeSupports$key : false;
12328 // 'post-thumbnails' can be boolean or an array of post types.
12329 // In the latter case, we need to verify `postType` exists
12330 // within `supported`. If `postType` isn't passed, then the check
12331 // should fail.
12332 if ('post-thumbnails' === key && Array.isArray(supported)) {
12333 return supported.includes(postType);
12334 }
12335 return supported;
12336 });
12337 if (!isSupported) {
12338 return null;
12339 }
12340 return children;
12341 }
12342
12343 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-featured-image/check.js
12344 /**
12345 * Internal dependencies
12346 */
12347
12348
12349
12350 /**
12351 * Wrapper component that renders its children only if the post type supports a featured image
12352 * and the theme supports post thumbnails.
12353 *
12354 * @param {Object} props Props.
12355 * @param {Element} props.children Children to be rendered.
12356 *
12357 * @return {Component} The component to be rendered.
12358 */
12359
12360 function PostFeaturedImageCheck({
12361 children
12362 }) {
12363 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ThemeSupportCheck, {
12364 supportKeys: "post-thumbnails",
12365 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12366 supportKeys: "thumbnail",
12367 children: children
12368 })
12369 });
12370 }
12371 /* harmony default export */ const post_featured_image_check = (PostFeaturedImageCheck);
12372
12373 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-featured-image/index.js
12374 /**
12375 * WordPress dependencies
12376 */
12377
12378
12379
12380
12381
12382
12383
12384
12385
12386
12387 /**
12388 * Internal dependencies
12389 */
12390
12391
12392
12393
12394 const ALLOWED_MEDIA_TYPES = ['image'];
12395
12396 // Used when labels from post type were not yet loaded or when they are not present.
12397 const DEFAULT_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Featured image');
12398 const DEFAULT_SET_FEATURE_IMAGE_LABEL = (0,external_wp_i18n_namespaceObject.__)('Add a featured image');
12399 const instructions = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
12400 children: (0,external_wp_i18n_namespaceObject.__)('To edit the featured image, you need permission to upload media.')
12401 });
12402 function getMediaDetails(media, postId) {
12403 var _media$media_details$, _media$media_details$2;
12404 if (!media) {
12405 return {};
12406 }
12407 const defaultSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'large', media.id, postId);
12408 if (defaultSize in ((_media$media_details$ = media?.media_details?.sizes) !== null && _media$media_details$ !== void 0 ? _media$media_details$ : {})) {
12409 return {
12410 mediaWidth: media.media_details.sizes[defaultSize].width,
12411 mediaHeight: media.media_details.sizes[defaultSize].height,
12412 mediaSourceUrl: media.media_details.sizes[defaultSize].source_url
12413 };
12414 }
12415
12416 // Use fallbackSize when defaultSize is not available.
12417 const fallbackSize = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostFeaturedImage.imageSize', 'thumbnail', media.id, postId);
12418 if (fallbackSize in ((_media$media_details$2 = media?.media_details?.sizes) !== null && _media$media_details$2 !== void 0 ? _media$media_details$2 : {})) {
12419 return {
12420 mediaWidth: media.media_details.sizes[fallbackSize].width,
12421 mediaHeight: media.media_details.sizes[fallbackSize].height,
12422 mediaSourceUrl: media.media_details.sizes[fallbackSize].source_url
12423 };
12424 }
12425
12426 // Use full image size when fallbackSize and defaultSize are not available.
12427 return {
12428 mediaWidth: media.media_details.width,
12429 mediaHeight: media.media_details.height,
12430 mediaSourceUrl: media.source_url
12431 };
12432 }
12433 function PostFeaturedImage({
12434 currentPostId,
12435 featuredImageId,
12436 onUpdateImage,
12437 onRemoveImage,
12438 media,
12439 postType,
12440 noticeUI,
12441 noticeOperations
12442 }) {
12443 const toggleRef = (0,external_wp_element_namespaceObject.useRef)();
12444 const [isLoading, setIsLoading] = (0,external_wp_element_namespaceObject.useState)(false);
12445 const {
12446 getSettings
12447 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
12448 const {
12449 mediaSourceUrl
12450 } = getMediaDetails(media, currentPostId);
12451 function onDropFiles(filesList) {
12452 getSettings().mediaUpload({
12453 allowedTypes: ALLOWED_MEDIA_TYPES,
12454 filesList,
12455 onFileChange([image]) {
12456 if ((0,external_wp_blob_namespaceObject.isBlobURL)(image?.url)) {
12457 setIsLoading(true);
12458 return;
12459 }
12460 if (image) {
12461 onUpdateImage(image);
12462 }
12463 setIsLoading(false);
12464 },
12465 onError(message) {
12466 noticeOperations.removeAllNotices();
12467 noticeOperations.createErrorNotice(message);
12468 }
12469 });
12470 }
12471 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(post_featured_image_check, {
12472 children: [noticeUI, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12473 className: "editor-post-featured-image",
12474 children: [media && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12475 id: `editor-post-featured-image-${featuredImageId}-describedby`,
12476 className: "hidden",
12477 children: [media.alt_text && (0,external_wp_i18n_namespaceObject.sprintf)(
12478 // Translators: %s: The selected image alt text.
12479 (0,external_wp_i18n_namespaceObject.__)('Current image: %s'), media.alt_text), !media.alt_text && (0,external_wp_i18n_namespaceObject.sprintf)(
12480 // Translators: %s: The selected image filename.
12481 (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)]
12482 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.MediaUploadCheck, {
12483 fallback: instructions,
12484 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.MediaUpload, {
12485 title: postType?.labels?.featured_image || DEFAULT_FEATURE_IMAGE_LABEL,
12486 onSelect: onUpdateImage,
12487 unstableFeaturedImageFlow: true,
12488 allowedTypes: ALLOWED_MEDIA_TYPES,
12489 modalClass: "editor-post-featured-image__media-modal",
12490 render: ({
12491 open
12492 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12493 className: "editor-post-featured-image__container",
12494 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
12495 ref: toggleRef,
12496 className: !featuredImageId ? 'editor-post-featured-image__toggle' : 'editor-post-featured-image__preview',
12497 onClick: open,
12498 "aria-label": !featuredImageId ? null : (0,external_wp_i18n_namespaceObject.__)('Edit or replace the featured image'),
12499 "aria-describedby": !featuredImageId ? null : `editor-post-featured-image-${featuredImageId}-describedby`,
12500 "aria-haspopup": "dialog",
12501 children: [!!featuredImageId && media && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
12502 className: "editor-post-featured-image__preview-image",
12503 src: mediaSourceUrl,
12504 alt: ""
12505 }), isLoading && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}), !featuredImageId && !isLoading && (postType?.labels?.set_featured_image || DEFAULT_SET_FEATURE_IMAGE_LABEL)]
12506 }), !!featuredImageId && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
12507 className: "editor-post-featured-image__actions",
12508 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12509 className: "editor-post-featured-image__action",
12510 onClick: open,
12511 "aria-haspopup": "dialog",
12512 children: (0,external_wp_i18n_namespaceObject.__)('Replace')
12513 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12514 className: "editor-post-featured-image__action",
12515 onClick: () => {
12516 onRemoveImage();
12517 toggleRef.current.focus();
12518 },
12519 children: (0,external_wp_i18n_namespaceObject.__)('Remove')
12520 })]
12521 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropZone, {
12522 onFilesDrop: onDropFiles
12523 })]
12524 }),
12525 value: featuredImageId
12526 })
12527 })]
12528 })]
12529 });
12530 }
12531 const applyWithSelect = (0,external_wp_data_namespaceObject.withSelect)(select => {
12532 const {
12533 getMedia,
12534 getPostType
12535 } = select(external_wp_coreData_namespaceObject.store);
12536 const {
12537 getCurrentPostId,
12538 getEditedPostAttribute
12539 } = select(store_store);
12540 const featuredImageId = getEditedPostAttribute('featured_media');
12541 return {
12542 media: featuredImageId ? getMedia(featuredImageId, {
12543 context: 'view'
12544 }) : null,
12545 currentPostId: getCurrentPostId(),
12546 postType: getPostType(getEditedPostAttribute('type')),
12547 featuredImageId
12548 };
12549 });
12550 const applyWithDispatch = (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
12551 noticeOperations
12552 }, {
12553 select
12554 }) => {
12555 const {
12556 editPost
12557 } = dispatch(store_store);
12558 return {
12559 onUpdateImage(image) {
12560 editPost({
12561 featured_media: image.id
12562 });
12563 },
12564 onDropImage(filesList) {
12565 select(external_wp_blockEditor_namespaceObject.store).getSettings().mediaUpload({
12566 allowedTypes: ['image'],
12567 filesList,
12568 onFileChange([image]) {
12569 editPost({
12570 featured_media: image.id
12571 });
12572 },
12573 onError(message) {
12574 noticeOperations.removeAllNotices();
12575 noticeOperations.createErrorNotice(message);
12576 }
12577 });
12578 },
12579 onRemoveImage() {
12580 editPost({
12581 featured_media: 0
12582 });
12583 }
12584 };
12585 });
12586
12587 /**
12588 * Renders the component for managing the featured image of a post.
12589 *
12590 * @param {Object} props Props.
12591 * @param {number} props.currentPostId ID of the current post.
12592 * @param {number} props.featuredImageId ID of the featured image.
12593 * @param {Function} props.onUpdateImage Function to call when the image is updated.
12594 * @param {Function} props.onRemoveImage Function to call when the image is removed.
12595 * @param {Object} props.media The media object representing the featured image.
12596 * @param {string} props.postType Post type.
12597 * @param {Element} props.noticeUI UI for displaying notices.
12598 * @param {Object} props.noticeOperations Operations for managing notices.
12599 *
12600 * @return {Element} Component to be rendered .
12601 */
12602 /* 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));
12603
12604 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-featured-image/panel.js
12605 /**
12606 * WordPress dependencies
12607 */
12608
12609
12610
12611
12612
12613 /**
12614 * Internal dependencies
12615 */
12616
12617
12618
12619
12620 const post_featured_image_panel_PANEL_NAME = 'featured-image';
12621
12622 /**
12623 * Renders the panel for the post featured image.
12624 *
12625 * @param {Object} props Props.
12626 * @param {boolean} props.withPanelBody Whether to include the panel body. Default true.
12627 *
12628 * @return {Component|null} The component to be rendered.
12629 * Return Null if the editor panel is disabled for featured image.
12630 */
12631 function PostFeaturedImagePanel({
12632 withPanelBody = true
12633 }) {
12634 var _postType$labels$feat;
12635 const {
12636 postType,
12637 isEnabled,
12638 isOpened
12639 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12640 const {
12641 getEditedPostAttribute,
12642 isEditorPanelEnabled,
12643 isEditorPanelOpened
12644 } = select(store_store);
12645 const {
12646 getPostType
12647 } = select(external_wp_coreData_namespaceObject.store);
12648 return {
12649 postType: getPostType(getEditedPostAttribute('type')),
12650 isEnabled: isEditorPanelEnabled(post_featured_image_panel_PANEL_NAME),
12651 isOpened: isEditorPanelOpened(post_featured_image_panel_PANEL_NAME)
12652 };
12653 }, []);
12654 const {
12655 toggleEditorPanelOpened
12656 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12657 if (!isEnabled) {
12658 return null;
12659 }
12660 if (!withPanelBody) {
12661 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image_check, {
12662 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image, {})
12663 });
12664 }
12665 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image_check, {
12666 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
12667 title: (_postType$labels$feat = postType?.labels?.featured_image) !== null && _postType$labels$feat !== void 0 ? _postType$labels$feat : (0,external_wp_i18n_namespaceObject.__)('Featured image'),
12668 opened: isOpened,
12669 onToggle: () => toggleEditorPanelOpened(post_featured_image_panel_PANEL_NAME),
12670 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image, {})
12671 })
12672 });
12673 }
12674
12675 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-format/check.js
12676 /**
12677 * WordPress dependencies
12678 */
12679
12680
12681 /**
12682 * Internal dependencies
12683 */
12684
12685
12686
12687 function PostFormatCheck({
12688 children
12689 }) {
12690 const disablePostFormats = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditorSettings().disablePostFormats, []);
12691 if (disablePostFormats) {
12692 return null;
12693 }
12694 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12695 supportKeys: "post-formats",
12696 children: children
12697 });
12698 }
12699
12700 /**
12701 * Component check if there are any post formats.
12702 *
12703 * @param {Object} props The component props.
12704 * @param {Element} props.children The child elements to render.
12705 *
12706 * @return {Component|null} The rendered component or null if post formats are disabled.
12707 */
12708 /* harmony default export */ const post_format_check = (PostFormatCheck);
12709
12710 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-format/index.js
12711 /**
12712 * WordPress dependencies
12713 */
12714
12715
12716
12717
12718
12719
12720 /**
12721 * Internal dependencies
12722 */
12723
12724
12725
12726 // All WP post formats, sorted alphabetically by translated name.
12727
12728
12729 const POST_FORMATS = [{
12730 id: 'aside',
12731 caption: (0,external_wp_i18n_namespaceObject.__)('Aside')
12732 }, {
12733 id: 'audio',
12734 caption: (0,external_wp_i18n_namespaceObject.__)('Audio')
12735 }, {
12736 id: 'chat',
12737 caption: (0,external_wp_i18n_namespaceObject.__)('Chat')
12738 }, {
12739 id: 'gallery',
12740 caption: (0,external_wp_i18n_namespaceObject.__)('Gallery')
12741 }, {
12742 id: 'image',
12743 caption: (0,external_wp_i18n_namespaceObject.__)('Image')
12744 }, {
12745 id: 'link',
12746 caption: (0,external_wp_i18n_namespaceObject.__)('Link')
12747 }, {
12748 id: 'quote',
12749 caption: (0,external_wp_i18n_namespaceObject.__)('Quote')
12750 }, {
12751 id: 'standard',
12752 caption: (0,external_wp_i18n_namespaceObject.__)('Standard')
12753 }, {
12754 id: 'status',
12755 caption: (0,external_wp_i18n_namespaceObject.__)('Status')
12756 }, {
12757 id: 'video',
12758 caption: (0,external_wp_i18n_namespaceObject.__)('Video')
12759 }].sort((a, b) => {
12760 const normalizedA = a.caption.toUpperCase();
12761 const normalizedB = b.caption.toUpperCase();
12762 if (normalizedA < normalizedB) {
12763 return -1;
12764 }
12765 if (normalizedA > normalizedB) {
12766 return 1;
12767 }
12768 return 0;
12769 });
12770
12771 /**
12772 * `PostFormat` a component that allows changing the post format while also providing a suggestion for the current post.
12773 *
12774 * @example
12775 * ```jsx
12776 * <PostFormat />
12777 * ```
12778 *
12779 * @return {JSX.Element} The rendered PostFormat component.
12780 */
12781 function PostFormat() {
12782 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostFormat);
12783 const postFormatSelectorId = `post-format-selector-${instanceId}`;
12784 const {
12785 postFormat,
12786 suggestedFormat,
12787 supportedFormats
12788 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12789 const {
12790 getEditedPostAttribute,
12791 getSuggestedPostFormat
12792 } = select(store_store);
12793 const _postFormat = getEditedPostAttribute('format');
12794 const themeSupports = select(external_wp_coreData_namespaceObject.store).getThemeSupports();
12795 return {
12796 postFormat: _postFormat !== null && _postFormat !== void 0 ? _postFormat : 'standard',
12797 suggestedFormat: getSuggestedPostFormat(),
12798 supportedFormats: themeSupports.formats
12799 };
12800 }, []);
12801 const formats = POST_FORMATS.filter(format => {
12802 // Ensure current format is always in the set.
12803 // The current format may not be a format supported by the theme.
12804 return supportedFormats?.includes(format.id) || postFormat === format.id;
12805 });
12806 const suggestion = formats.find(format => format.id === suggestedFormat);
12807 const {
12808 editPost
12809 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
12810 const onUpdatePostFormat = format => editPost({
12811 format
12812 });
12813 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_format_check, {
12814 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
12815 className: "editor-post-format",
12816 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
12817 className: "editor-post-format__options",
12818 label: (0,external_wp_i18n_namespaceObject.__)('Post Format'),
12819 selected: postFormat,
12820 onChange: format => onUpdatePostFormat(format),
12821 id: postFormatSelectorId,
12822 options: formats.map(format => ({
12823 label: format.caption,
12824 value: format.id
12825 })),
12826 hideLabelFromVision: true
12827 }), suggestion && suggestion.id !== postFormat && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
12828 className: "editor-post-format__suggestion",
12829 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12830 variant: "link",
12831 onClick: () => onUpdatePostFormat(suggestion.id),
12832 children: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: post format */
12833 (0,external_wp_i18n_namespaceObject.__)('Apply suggested format: %s'), suggestion.caption)
12834 })
12835 })]
12836 })
12837 });
12838 }
12839
12840 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/backup.js
12841 /**
12842 * WordPress dependencies
12843 */
12844
12845
12846 const backup = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
12847 xmlns: "http://www.w3.org/2000/svg",
12848 viewBox: "0 0 24 24",
12849 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
12850 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"
12851 })
12852 });
12853 /* harmony default export */ const library_backup = (backup);
12854
12855 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-last-revision/check.js
12856 /**
12857 * WordPress dependencies
12858 */
12859
12860
12861 /**
12862 * Internal dependencies
12863 */
12864
12865
12866
12867 /**
12868 * Wrapper component that renders its children if the post has more than one revision.
12869 *
12870 * @param {Object} props Props.
12871 * @param {Element} props.children Children to be rendered.
12872 *
12873 * @return {Component|null} Rendered child components if post has more than one revision, otherwise null.
12874 */
12875
12876 function PostLastRevisionCheck({
12877 children
12878 }) {
12879 const {
12880 lastRevisionId,
12881 revisionsCount
12882 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
12883 const {
12884 getCurrentPostLastRevisionId,
12885 getCurrentPostRevisionsCount
12886 } = select(store_store);
12887 return {
12888 lastRevisionId: getCurrentPostLastRevisionId(),
12889 revisionsCount: getCurrentPostRevisionsCount()
12890 };
12891 }, []);
12892 if (!lastRevisionId || revisionsCount < 2) {
12893 return null;
12894 }
12895 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
12896 supportKeys: "revisions",
12897 children: children
12898 });
12899 }
12900 /* harmony default export */ const post_last_revision_check = (PostLastRevisionCheck);
12901
12902 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-last-revision/index.js
12903 /**
12904 * WordPress dependencies
12905 */
12906
12907
12908
12909
12910
12911
12912 /**
12913 * Internal dependencies
12914 */
12915
12916
12917
12918
12919 function usePostLastRevisionInfo() {
12920 return (0,external_wp_data_namespaceObject.useSelect)(select => {
12921 const {
12922 getCurrentPostLastRevisionId,
12923 getCurrentPostRevisionsCount
12924 } = select(store_store);
12925 return {
12926 lastRevisionId: getCurrentPostLastRevisionId(),
12927 revisionsCount: getCurrentPostRevisionsCount()
12928 };
12929 }, []);
12930 }
12931
12932 /**
12933 * Renders the component for displaying the last revision of a post.
12934 *
12935 * @return {Component} The component to be rendered.
12936 */
12937 function PostLastRevision() {
12938 const {
12939 lastRevisionId,
12940 revisionsCount
12941 } = usePostLastRevisionInfo();
12942 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision_check, {
12943 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12944 href: (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
12945 revision: lastRevisionId
12946 }),
12947 className: "editor-post-last-revision__title",
12948 icon: library_backup,
12949 iconPosition: "right",
12950 text: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: number of revisions */
12951 (0,external_wp_i18n_namespaceObject.__)('Revisions (%s)'), revisionsCount)
12952 })
12953 });
12954 }
12955 function PrivatePostLastRevision() {
12956 const {
12957 lastRevisionId,
12958 revisionsCount
12959 } = usePostLastRevisionInfo();
12960 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision_check, {
12961 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
12962 label: (0,external_wp_i18n_namespaceObject.__)('Revisions'),
12963 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
12964 href: (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
12965 revision: lastRevisionId
12966 }),
12967 className: "editor-private-post-last-revision__button",
12968 text: revisionsCount,
12969 variant: "tertiary",
12970 size: "compact"
12971 })
12972 })
12973 });
12974 }
12975 /* harmony default export */ const post_last_revision = (PostLastRevision);
12976
12977 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-last-revision/panel.js
12978 /**
12979 * WordPress dependencies
12980 */
12981
12982
12983 /**
12984 * Internal dependencies
12985 */
12986
12987
12988
12989 /**
12990 * Renders the panel for displaying the last revision of a post.
12991 *
12992 * @return {Component} The component to be rendered.
12993 */
12994
12995 function PostLastRevisionPanel() {
12996 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision_check, {
12997 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
12998 className: "editor-post-last-revision__panel",
12999 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_last_revision, {})
13000 })
13001 });
13002 }
13003 /* harmony default export */ const post_last_revision_panel = (PostLastRevisionPanel);
13004
13005 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-locked-modal/index.js
13006 /**
13007 * WordPress dependencies
13008 */
13009
13010
13011
13012
13013
13014
13015
13016
13017
13018 /**
13019 * Internal dependencies
13020 */
13021
13022
13023 /**
13024 * A modal component that is displayed when a post is locked for editing by another user.
13025 * The modal provides information about the lock status and options to take over or exit the editor.
13026 *
13027 * @return {JSX.Element|null} The rendered PostLockedModal component.
13028 */
13029
13030
13031
13032 function PostLockedModal() {
13033 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostLockedModal);
13034 const hookName = 'core/editor/post-locked-modal-' + instanceId;
13035 const {
13036 autosave,
13037 updatePostLock
13038 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13039 const {
13040 isLocked,
13041 isTakeover,
13042 user,
13043 postId,
13044 postLockUtils,
13045 activePostLock,
13046 postType,
13047 previewLink
13048 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13049 const {
13050 isPostLocked,
13051 isPostLockTakeover,
13052 getPostLockUser,
13053 getCurrentPostId,
13054 getActivePostLock,
13055 getEditedPostAttribute,
13056 getEditedPostPreviewLink,
13057 getEditorSettings
13058 } = select(store_store);
13059 const {
13060 getPostType
13061 } = select(external_wp_coreData_namespaceObject.store);
13062 return {
13063 isLocked: isPostLocked(),
13064 isTakeover: isPostLockTakeover(),
13065 user: getPostLockUser(),
13066 postId: getCurrentPostId(),
13067 postLockUtils: getEditorSettings().postLockUtils,
13068 activePostLock: getActivePostLock(),
13069 postType: getPostType(getEditedPostAttribute('type')),
13070 previewLink: getEditedPostPreviewLink()
13071 };
13072 }, []);
13073 (0,external_wp_element_namespaceObject.useEffect)(() => {
13074 /**
13075 * Keep the lock refreshed.
13076 *
13077 * When the user does not send a heartbeat in a heartbeat-tick
13078 * the user is no longer editing and another user can start editing.
13079 *
13080 * @param {Object} data Data to send in the heartbeat request.
13081 */
13082 function sendPostLock(data) {
13083 if (isLocked) {
13084 return;
13085 }
13086 data['wp-refresh-post-lock'] = {
13087 lock: activePostLock,
13088 post_id: postId
13089 };
13090 }
13091
13092 /**
13093 * Refresh post locks: update the lock string or show the dialog if somebody has taken over editing.
13094 *
13095 * @param {Object} data Data received in the heartbeat request
13096 */
13097 function receivePostLock(data) {
13098 if (!data['wp-refresh-post-lock']) {
13099 return;
13100 }
13101 const received = data['wp-refresh-post-lock'];
13102 if (received.lock_error) {
13103 // Auto save and display the takeover modal.
13104 autosave();
13105 updatePostLock({
13106 isLocked: true,
13107 isTakeover: true,
13108 user: {
13109 name: received.lock_error.name,
13110 avatar: received.lock_error.avatar_src_2x
13111 }
13112 });
13113 } else if (received.new_lock) {
13114 updatePostLock({
13115 isLocked: false,
13116 activePostLock: received.new_lock
13117 });
13118 }
13119 }
13120
13121 /**
13122 * Unlock the post before the window is exited.
13123 */
13124 function releasePostLock() {
13125 if (isLocked || !activePostLock) {
13126 return;
13127 }
13128 const data = new window.FormData();
13129 data.append('action', 'wp-remove-post-lock');
13130 data.append('_wpnonce', postLockUtils.unlockNonce);
13131 data.append('post_ID', postId);
13132 data.append('active_post_lock', activePostLock);
13133 if (window.navigator.sendBeacon) {
13134 window.navigator.sendBeacon(postLockUtils.ajaxUrl, data);
13135 } else {
13136 const xhr = new window.XMLHttpRequest();
13137 xhr.open('POST', postLockUtils.ajaxUrl, false);
13138 xhr.send(data);
13139 }
13140 }
13141
13142 // Details on these events on the Heartbeat API docs
13143 // https://developer.wordpress.org/plugins/javascript/heartbeat-api/
13144 (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.send', hookName, sendPostLock);
13145 (0,external_wp_hooks_namespaceObject.addAction)('heartbeat.tick', hookName, receivePostLock);
13146 window.addEventListener('beforeunload', releasePostLock);
13147 return () => {
13148 (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.send', hookName);
13149 (0,external_wp_hooks_namespaceObject.removeAction)('heartbeat.tick', hookName);
13150 window.removeEventListener('beforeunload', releasePostLock);
13151 };
13152 }, []);
13153 if (!isLocked) {
13154 return null;
13155 }
13156 const userDisplayName = user.name;
13157 const userAvatar = user.avatar;
13158 const unlockUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('post.php', {
13159 'get-post-lock': '1',
13160 lockKey: true,
13161 post: postId,
13162 action: 'edit',
13163 _wpnonce: postLockUtils.nonce
13164 });
13165 const allPostsUrl = (0,external_wp_url_namespaceObject.addQueryArgs)('edit.php', {
13166 post_type: postType?.slug
13167 });
13168 const allPostsLabel = (0,external_wp_i18n_namespaceObject.__)('Exit editor');
13169 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
13170 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'),
13171 focusOnMount: true,
13172 shouldCloseOnClickOutside: false,
13173 shouldCloseOnEsc: false,
13174 isDismissible: false,
13175 size: "medium",
13176 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
13177 alignment: "top",
13178 spacing: 6,
13179 children: [!!userAvatar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
13180 src: userAvatar,
13181 alt: (0,external_wp_i18n_namespaceObject.__)('Avatar'),
13182 className: "editor-post-locked-modal__avatar",
13183 width: 64,
13184 height: 64
13185 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13186 children: [!!isTakeover && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13187 children: (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: user's display name */
13188 (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.'), {
13189 strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {}),
13190 PreviewLink: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
13191 href: previewLink,
13192 children: (0,external_wp_i18n_namespaceObject.__)('preview')
13193 })
13194 })
13195 }), !isTakeover && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
13196 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13197 children: (0,external_wp_element_namespaceObject.createInterpolateElement)(userDisplayName ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: user's display name */
13198 (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.'), {
13199 strong: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {}),
13200 PreviewLink: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
13201 href: previewLink,
13202 children: (0,external_wp_i18n_namespaceObject.__)('preview')
13203 })
13204 })
13205 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13206 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.')
13207 })]
13208 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
13209 className: "editor-post-locked-modal__buttons",
13210 justify: "flex-end",
13211 children: [!isTakeover && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13212 variant: "tertiary",
13213 href: unlockUrl,
13214 children: (0,external_wp_i18n_namespaceObject.__)('Take over')
13215 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13216 variant: "primary",
13217 href: allPostsUrl,
13218 children: allPostsLabel
13219 })]
13220 })]
13221 })]
13222 })
13223 });
13224 }
13225
13226 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-pending-status/check.js
13227 /**
13228 * WordPress dependencies
13229 */
13230
13231
13232 /**
13233 * Internal dependencies
13234 */
13235
13236
13237 /**
13238 * This component checks the publishing status of the current post.
13239 * If the post is already published or the user doesn't have the
13240 * capability to publish, it returns null.
13241 *
13242 * @param {Object} props Component properties.
13243 * @param {Element} props.children Children to be rendered.
13244 *
13245 * @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.
13246 */
13247 function PostPendingStatusCheck({
13248 children
13249 }) {
13250 const {
13251 hasPublishAction,
13252 isPublished
13253 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13254 var _getCurrentPost$_link;
13255 const {
13256 isCurrentPostPublished,
13257 getCurrentPost
13258 } = select(store_store);
13259 return {
13260 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
13261 isPublished: isCurrentPostPublished()
13262 };
13263 }, []);
13264 if (isPublished || !hasPublishAction) {
13265 return null;
13266 }
13267 return children;
13268 }
13269 /* harmony default export */ const post_pending_status_check = (PostPendingStatusCheck);
13270
13271 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-pending-status/index.js
13272 /**
13273 * WordPress dependencies
13274 */
13275
13276
13277
13278
13279 /**
13280 * Internal dependencies
13281 */
13282
13283
13284
13285 /**
13286 * A component for displaying and toggling the pending status of a post.
13287 *
13288 * @return {JSX.Element} The rendered component.
13289 */
13290
13291 function PostPendingStatus() {
13292 const status = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('status'), []);
13293 const {
13294 editPost
13295 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13296 const togglePendingStatus = () => {
13297 const updatedStatus = status === 'pending' ? 'draft' : 'pending';
13298 editPost({
13299 status: updatedStatus
13300 });
13301 };
13302 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_pending_status_check, {
13303 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
13304 __nextHasNoMarginBottom: true,
13305 label: (0,external_wp_i18n_namespaceObject.__)('Pending review'),
13306 checked: status === 'pending',
13307 onChange: togglePendingStatus
13308 })
13309 });
13310 }
13311 /* harmony default export */ const post_pending_status = (PostPendingStatus);
13312
13313 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-preview-button/index.js
13314 /**
13315 * WordPress dependencies
13316 */
13317
13318
13319
13320
13321
13322
13323
13324 /**
13325 * Internal dependencies
13326 */
13327
13328
13329
13330
13331 function writeInterstitialMessage(targetDocument) {
13332 let markup = (0,external_wp_element_namespaceObject.renderToString)( /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13333 className: "editor-post-preview-button__interstitial-message",
13334 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.SVG, {
13335 xmlns: "http://www.w3.org/2000/svg",
13336 viewBox: "0 0 96 96",
13337 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
13338 className: "outer",
13339 d: "M48 12c19.9 0 36 16.1 36 36S67.9 84 48 84 12 67.9 12 48s16.1-36 36-36",
13340 fill: "none"
13341 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Path, {
13342 className: "inner",
13343 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",
13344 fill: "none"
13345 })]
13346 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
13347 children: (0,external_wp_i18n_namespaceObject.__)('Generating preview…')
13348 })]
13349 }));
13350 markup += `
13351 <style>
13352 body {
13353 margin: 0;
13354 }
13355 .editor-post-preview-button__interstitial-message {
13356 display: flex;
13357 flex-direction: column;
13358 align-items: center;
13359 justify-content: center;
13360 height: 100vh;
13361 width: 100vw;
13362 }
13363 @-webkit-keyframes paint {
13364 0% {
13365 stroke-dashoffset: 0;
13366 }
13367 }
13368 @-moz-keyframes paint {
13369 0% {
13370 stroke-dashoffset: 0;
13371 }
13372 }
13373 @-o-keyframes paint {
13374 0% {
13375 stroke-dashoffset: 0;
13376 }
13377 }
13378 @keyframes paint {
13379 0% {
13380 stroke-dashoffset: 0;
13381 }
13382 }
13383 .editor-post-preview-button__interstitial-message svg {
13384 width: 192px;
13385 height: 192px;
13386 stroke: #555d66;
13387 stroke-width: 0.75;
13388 }
13389 .editor-post-preview-button__interstitial-message svg .outer,
13390 .editor-post-preview-button__interstitial-message svg .inner {
13391 stroke-dasharray: 280;
13392 stroke-dashoffset: 280;
13393 -webkit-animation: paint 1.5s ease infinite alternate;
13394 -moz-animation: paint 1.5s ease infinite alternate;
13395 -o-animation: paint 1.5s ease infinite alternate;
13396 animation: paint 1.5s ease infinite alternate;
13397 }
13398 p {
13399 text-align: center;
13400 font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
13401 }
13402 </style>
13403 `;
13404
13405 /**
13406 * Filters the interstitial message shown when generating previews.
13407 *
13408 * @param {string} markup The preview interstitial markup.
13409 */
13410 markup = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.PostPreview.interstitialMarkup', markup);
13411 targetDocument.write(markup);
13412 targetDocument.title = (0,external_wp_i18n_namespaceObject.__)('Generating preview…');
13413 targetDocument.close();
13414 }
13415
13416 /**
13417 * Renders a button that opens a new window or tab for the preview,
13418 * writes the interstitial message to this window, and then navigates
13419 * to the actual preview link. The button is not rendered if the post
13420 * is not viewable and disabled if the post is not saveable.
13421 *
13422 * @param {Object} props The component props.
13423 * @param {string} props.className The class name for the button.
13424 * @param {string} props.textContent The text content for the button.
13425 * @param {boolean} props.forceIsAutosaveable Whether to force autosave.
13426 * @param {string} props.role The role attribute for the button.
13427 * @param {Function} props.onPreview The callback function for preview event.
13428 *
13429 * @return {JSX.Element|null} The rendered button component.
13430 */
13431 function PostPreviewButton({
13432 className,
13433 textContent,
13434 forceIsAutosaveable,
13435 role,
13436 onPreview
13437 }) {
13438 const {
13439 postId,
13440 currentPostLink,
13441 previewLink,
13442 isSaveable,
13443 isViewable
13444 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13445 var _postType$viewable;
13446 const editor = select(store_store);
13447 const core = select(external_wp_coreData_namespaceObject.store);
13448 const postType = core.getPostType(editor.getCurrentPostType('type'));
13449 return {
13450 postId: editor.getCurrentPostId(),
13451 currentPostLink: editor.getCurrentPostAttribute('link'),
13452 previewLink: editor.getEditedPostPreviewLink(),
13453 isSaveable: editor.isEditedPostSaveable(),
13454 isViewable: (_postType$viewable = postType?.viewable) !== null && _postType$viewable !== void 0 ? _postType$viewable : false
13455 };
13456 }, []);
13457 const {
13458 __unstableSaveForPreview
13459 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13460 if (!isViewable) {
13461 return null;
13462 }
13463 const targetId = `wp-preview-${postId}`;
13464 const openPreviewWindow = async event => {
13465 // Our Preview button has its 'href' and 'target' set correctly for a11y
13466 // purposes. Unfortunately, though, we can't rely on the default 'click'
13467 // handler since sometimes it incorrectly opens a new tab instead of reusing
13468 // the existing one.
13469 // https://github.com/WordPress/gutenberg/pull/8330
13470 event.preventDefault();
13471
13472 // Open up a Preview tab if needed. This is where we'll show the preview.
13473 const previewWindow = window.open('', targetId);
13474
13475 // Focus the Preview tab. This might not do anything, depending on the browser's
13476 // and user's preferences.
13477 // https://html.spec.whatwg.org/multipage/interaction.html#dom-window-focus
13478 previewWindow.focus();
13479 writeInterstitialMessage(previewWindow.document);
13480 const link = await __unstableSaveForPreview({
13481 forceIsAutosaveable
13482 });
13483 previewWindow.location = link;
13484 onPreview?.();
13485 };
13486
13487 // Link to the `?preview=true` URL if we have it, since this lets us see
13488 // changes that were autosaved since the post was last published. Otherwise,
13489 // just link to the post's URL.
13490 const href = previewLink || currentPostLink;
13491 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13492 variant: !className ? 'tertiary' : undefined,
13493 className: className || 'editor-post-preview',
13494 href: href,
13495 target: targetId,
13496 accessibleWhenDisabled: true,
13497 disabled: !isSaveable,
13498 onClick: openPreviewWindow,
13499 role: role,
13500 size: "compact",
13501 children: textContent || /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
13502 children: [(0,external_wp_i18n_namespaceObject._x)('Preview', 'imperative verb'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
13503 as: "span",
13504 children: /* translators: accessibility text */
13505 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')
13506 })]
13507 })
13508 });
13509 }
13510
13511 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-button/label.js
13512 /**
13513 * WordPress dependencies
13514 */
13515
13516
13517
13518
13519 /**
13520 * Internal dependencies
13521 */
13522
13523
13524 /**
13525 * Renders the label for the publish button.
13526 *
13527 * @return {string} The label for the publish button.
13528 */
13529 function PublishButtonLabel() {
13530 const isSmallerThanMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
13531 const {
13532 isPublished,
13533 isBeingScheduled,
13534 isSaving,
13535 isPublishing,
13536 hasPublishAction,
13537 isAutosaving,
13538 hasNonPostEntityChanges,
13539 postStatusHasChanged,
13540 postStatus
13541 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
13542 var _getCurrentPost$_link;
13543 const {
13544 isCurrentPostPublished,
13545 isEditedPostBeingScheduled,
13546 isSavingPost,
13547 isPublishingPost,
13548 getCurrentPost,
13549 getCurrentPostType,
13550 isAutosavingPost,
13551 getPostEdits,
13552 getEditedPostAttribute
13553 } = select(store_store);
13554 return {
13555 isPublished: isCurrentPostPublished(),
13556 isBeingScheduled: isEditedPostBeingScheduled(),
13557 isSaving: isSavingPost(),
13558 isPublishing: isPublishingPost(),
13559 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
13560 postType: getCurrentPostType(),
13561 isAutosaving: isAutosavingPost(),
13562 hasNonPostEntityChanges: select(store_store).hasNonPostEntityChanges(),
13563 postStatusHasChanged: !!getPostEdits()?.status,
13564 postStatus: getEditedPostAttribute('status')
13565 };
13566 }, []);
13567 if (isPublishing) {
13568 /* translators: button label text should, if possible, be under 16 characters. */
13569 return (0,external_wp_i18n_namespaceObject.__)('Publishing…');
13570 } else if ((isPublished || isBeingScheduled) && isSaving && !isAutosaving) {
13571 /* translators: button label text should, if possible, be under 16 characters. */
13572 return (0,external_wp_i18n_namespaceObject.__)('Saving…');
13573 }
13574 if (!hasPublishAction) {
13575 // TODO: this is because "Submit for review" string is too long in some languages.
13576 // @see https://github.com/WordPress/gutenberg/issues/10475
13577 return isSmallerThanMediumViewport ? (0,external_wp_i18n_namespaceObject.__)('Publish') : (0,external_wp_i18n_namespaceObject.__)('Submit for Review');
13578 }
13579 if (hasNonPostEntityChanges || isPublished || postStatusHasChanged && !['future', 'publish'].includes(postStatus) || !postStatusHasChanged && postStatus === 'future') {
13580 return (0,external_wp_i18n_namespaceObject.__)('Save');
13581 }
13582 if (isBeingScheduled) {
13583 return (0,external_wp_i18n_namespaceObject.__)('Schedule');
13584 }
13585 return (0,external_wp_i18n_namespaceObject.__)('Publish');
13586 }
13587
13588 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-button/index.js
13589 /**
13590 * WordPress dependencies
13591 */
13592
13593
13594
13595
13596
13597 /**
13598 * Internal dependencies
13599 */
13600
13601
13602
13603
13604 const post_publish_button_noop = () => {};
13605 class PostPublishButton extends external_wp_element_namespaceObject.Component {
13606 constructor(props) {
13607 super(props);
13608 this.buttonNode = (0,external_wp_element_namespaceObject.createRef)();
13609 this.createOnClick = this.createOnClick.bind(this);
13610 this.closeEntitiesSavedStates = this.closeEntitiesSavedStates.bind(this);
13611 this.state = {
13612 entitiesSavedStatesCallback: false
13613 };
13614 }
13615 componentDidMount() {
13616 if (this.props.focusOnMount) {
13617 // This timeout is necessary to make sure the `useEffect` hook of
13618 // `useFocusReturn` gets the correct element (the button that opens the
13619 // PostPublishPanel) otherwise it will get this button.
13620 this.timeoutID = setTimeout(() => {
13621 this.buttonNode.current.focus();
13622 }, 0);
13623 }
13624 }
13625 componentWillUnmount() {
13626 clearTimeout(this.timeoutID);
13627 }
13628 createOnClick(callback) {
13629 return (...args) => {
13630 const {
13631 hasNonPostEntityChanges,
13632 setEntitiesSavedStatesCallback
13633 } = this.props;
13634 // If a post with non-post entities is published, but the user
13635 // elects to not save changes to the non-post entities, those
13636 // entities will still be dirty when the Publish button is clicked.
13637 // We also need to check that the `setEntitiesSavedStatesCallback`
13638 // prop was passed. See https://github.com/WordPress/gutenberg/pull/37383
13639 if (hasNonPostEntityChanges && setEntitiesSavedStatesCallback) {
13640 // The modal for multiple entity saving will open,
13641 // hold the callback for saving/publishing the post
13642 // so that we can call it if the post entity is checked.
13643 this.setState({
13644 entitiesSavedStatesCallback: () => callback(...args)
13645 });
13646
13647 // Open the save panel by setting its callback.
13648 // To set a function on the useState hook, we must set it
13649 // with another function (() => myFunction). Passing the
13650 // function on its own will cause an error when called.
13651 setEntitiesSavedStatesCallback(() => this.closeEntitiesSavedStates);
13652 return post_publish_button_noop;
13653 }
13654 return callback(...args);
13655 };
13656 }
13657 closeEntitiesSavedStates(savedEntities) {
13658 const {
13659 postType,
13660 postId
13661 } = this.props;
13662 const {
13663 entitiesSavedStatesCallback
13664 } = this.state;
13665 this.setState({
13666 entitiesSavedStatesCallback: false
13667 }, () => {
13668 if (savedEntities && savedEntities.some(elt => elt.kind === 'postType' && elt.name === postType && elt.key === postId)) {
13669 // The post entity was checked, call the held callback from `createOnClick`.
13670 entitiesSavedStatesCallback();
13671 }
13672 });
13673 }
13674 render() {
13675 const {
13676 forceIsDirty,
13677 hasPublishAction,
13678 isBeingScheduled,
13679 isOpen,
13680 isPostSavingLocked,
13681 isPublishable,
13682 isPublished,
13683 isSaveable,
13684 isSaving,
13685 isAutoSaving,
13686 isToggle,
13687 savePostStatus,
13688 onSubmit = post_publish_button_noop,
13689 onToggle,
13690 visibility,
13691 hasNonPostEntityChanges,
13692 isSavingNonPostEntityChanges,
13693 postStatus,
13694 postStatusHasChanged
13695 } = this.props;
13696 const isButtonDisabled = (isSaving || !isSaveable || isPostSavingLocked || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
13697 const isToggleDisabled = (isPublished || isSaving || !isSaveable || !isPublishable && !forceIsDirty) && (!hasNonPostEntityChanges || isSavingNonPostEntityChanges);
13698
13699 // If the new status has not changed explicitely, we derive it from
13700 // other factors, like having a publish action, etc.. We need to preserve
13701 // this because it affects when to show the pre and post publish panels.
13702 // If it has changed though explicitely, we need to respect that.
13703 let publishStatus = 'publish';
13704 if (postStatusHasChanged) {
13705 publishStatus = postStatus;
13706 } else if (!hasPublishAction) {
13707 publishStatus = 'pending';
13708 } else if (visibility === 'private') {
13709 publishStatus = 'private';
13710 } else if (isBeingScheduled) {
13711 publishStatus = 'future';
13712 }
13713 const onClickButton = () => {
13714 if (isButtonDisabled) {
13715 return;
13716 }
13717 onSubmit();
13718 savePostStatus(publishStatus);
13719 };
13720
13721 // Callback to open the publish panel.
13722 const onClickToggle = () => {
13723 if (isToggleDisabled) {
13724 return;
13725 }
13726 onToggle();
13727 };
13728 const buttonProps = {
13729 'aria-disabled': isButtonDisabled,
13730 className: 'editor-post-publish-button',
13731 isBusy: !isAutoSaving && isSaving,
13732 variant: 'primary',
13733 onClick: this.createOnClick(onClickButton)
13734 };
13735 const toggleProps = {
13736 'aria-disabled': isToggleDisabled,
13737 'aria-expanded': isOpen,
13738 className: 'editor-post-publish-panel__toggle',
13739 isBusy: isSaving && isPublished,
13740 variant: 'primary',
13741 size: 'compact',
13742 onClick: this.createOnClick(onClickToggle)
13743 };
13744 const componentProps = isToggle ? toggleProps : buttonProps;
13745 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
13746 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
13747 ref: this.buttonNode,
13748 ...componentProps,
13749 className: `${componentProps.className} editor-post-publish-button__button`,
13750 size: "compact",
13751 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PublishButtonLabel, {})
13752 })
13753 });
13754 }
13755 }
13756
13757 /**
13758 * Renders the publish button.
13759 */
13760 /* harmony default export */ const post_publish_button = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
13761 var _getCurrentPost$_link;
13762 const {
13763 isSavingPost,
13764 isAutosavingPost,
13765 isEditedPostBeingScheduled,
13766 getEditedPostVisibility,
13767 isCurrentPostPublished,
13768 isEditedPostSaveable,
13769 isEditedPostPublishable,
13770 isPostSavingLocked,
13771 getCurrentPost,
13772 getCurrentPostType,
13773 getCurrentPostId,
13774 hasNonPostEntityChanges,
13775 isSavingNonPostEntityChanges,
13776 getEditedPostAttribute,
13777 getPostEdits
13778 } = select(store_store);
13779 return {
13780 isSaving: isSavingPost(),
13781 isAutoSaving: isAutosavingPost(),
13782 isBeingScheduled: isEditedPostBeingScheduled(),
13783 visibility: getEditedPostVisibility(),
13784 isSaveable: isEditedPostSaveable(),
13785 isPostSavingLocked: isPostSavingLocked(),
13786 isPublishable: isEditedPostPublishable(),
13787 isPublished: isCurrentPostPublished(),
13788 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
13789 postType: getCurrentPostType(),
13790 postId: getCurrentPostId(),
13791 postStatus: getEditedPostAttribute('status'),
13792 postStatusHasChanged: getPostEdits()?.status,
13793 hasNonPostEntityChanges: hasNonPostEntityChanges(),
13794 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges()
13795 };
13796 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
13797 const {
13798 editPost,
13799 savePost
13800 } = dispatch(store_store);
13801 return {
13802 savePostStatus: status => {
13803 editPost({
13804 status
13805 }, {
13806 undoIgnore: true
13807 });
13808 savePost();
13809 }
13810 };
13811 })])(PostPublishButton));
13812
13813 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/wordpress.js
13814 /**
13815 * WordPress dependencies
13816 */
13817
13818
13819 const wordpress = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
13820 xmlns: "http://www.w3.org/2000/svg",
13821 viewBox: "-2 -2 24 24",
13822 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
13823 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"
13824 })
13825 });
13826 /* harmony default export */ const library_wordpress = (wordpress);
13827
13828 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/utils.js
13829 /**
13830 * WordPress dependencies
13831 */
13832
13833 const visibilityOptions = {
13834 public: {
13835 label: (0,external_wp_i18n_namespaceObject.__)('Public'),
13836 info: (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.')
13837 },
13838 private: {
13839 label: (0,external_wp_i18n_namespaceObject.__)('Private'),
13840 info: (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.')
13841 },
13842 password: {
13843 label: (0,external_wp_i18n_namespaceObject.__)('Password protected'),
13844 info: (0,external_wp_i18n_namespaceObject.__)('Only those with the password can view this post.')
13845 }
13846 };
13847
13848 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/index.js
13849 /**
13850 * WordPress dependencies
13851 */
13852
13853
13854
13855
13856
13857
13858
13859 /**
13860 * Internal dependencies
13861 */
13862
13863
13864
13865 /**
13866 * Allows users to set the visibility of a post.
13867 *
13868 * @param {Object} props The component props.
13869 * @param {Function} props.onClose Function to call when the popover is closed.
13870 * @return {JSX.Element} The rendered component.
13871 */
13872
13873
13874 function PostVisibility({
13875 onClose
13876 }) {
13877 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostVisibility);
13878 const {
13879 status,
13880 visibility,
13881 password
13882 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
13883 status: select(store_store).getEditedPostAttribute('status'),
13884 visibility: select(store_store).getEditedPostVisibility(),
13885 password: select(store_store).getEditedPostAttribute('password')
13886 }));
13887 const {
13888 editPost,
13889 savePost
13890 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
13891 const [hasPassword, setHasPassword] = (0,external_wp_element_namespaceObject.useState)(!!password);
13892 const [showPrivateConfirmDialog, setShowPrivateConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
13893 const setPublic = () => {
13894 editPost({
13895 status: visibility === 'private' ? 'draft' : status,
13896 password: ''
13897 });
13898 setHasPassword(false);
13899 };
13900 const setPrivate = () => {
13901 setShowPrivateConfirmDialog(true);
13902 };
13903 const confirmPrivate = () => {
13904 editPost({
13905 status: 'private',
13906 password: ''
13907 });
13908 setHasPassword(false);
13909 setShowPrivateConfirmDialog(false);
13910 savePost();
13911 };
13912 const handleDialogCancel = () => {
13913 setShowPrivateConfirmDialog(false);
13914 };
13915 const setPasswordProtected = () => {
13916 editPost({
13917 status: visibility === 'private' ? 'draft' : status,
13918 password: password || ''
13919 });
13920 setHasPassword(true);
13921 };
13922 const updatePassword = event => {
13923 editPost({
13924 password: event.target.value
13925 });
13926 };
13927 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13928 className: "editor-post-visibility",
13929 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
13930 title: (0,external_wp_i18n_namespaceObject.__)('Visibility'),
13931 help: (0,external_wp_i18n_namespaceObject.__)('Control how this post is viewed.'),
13932 onClose: onClose
13933 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("fieldset", {
13934 className: "editor-post-visibility__fieldset",
13935 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
13936 as: "legend",
13937 children: (0,external_wp_i18n_namespaceObject.__)('Visibility')
13938 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityChoice, {
13939 instanceId: instanceId,
13940 value: "public",
13941 label: visibilityOptions.public.label,
13942 info: visibilityOptions.public.info,
13943 checked: visibility === 'public' && !hasPassword,
13944 onChange: setPublic
13945 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityChoice, {
13946 instanceId: instanceId,
13947 value: "private",
13948 label: visibilityOptions.private.label,
13949 info: visibilityOptions.private.info,
13950 checked: visibility === 'private',
13951 onChange: setPrivate
13952 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityChoice, {
13953 instanceId: instanceId,
13954 value: "password",
13955 label: visibilityOptions.password.label,
13956 info: visibilityOptions.password.info,
13957 checked: hasPassword,
13958 onChange: setPasswordProtected
13959 }), hasPassword && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13960 className: "editor-post-visibility__password",
13961 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
13962 as: "label",
13963 htmlFor: `editor-post-visibility__password-input-${instanceId}`,
13964 children: (0,external_wp_i18n_namespaceObject.__)('Create password')
13965 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("input", {
13966 className: "editor-post-visibility__password-input",
13967 id: `editor-post-visibility__password-input-${instanceId}`,
13968 type: "text",
13969 onChange: updatePassword,
13970 value: password,
13971 placeholder: (0,external_wp_i18n_namespaceObject.__)('Use a secure password')
13972 })]
13973 })]
13974 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
13975 isOpen: showPrivateConfirmDialog,
13976 onConfirm: confirmPrivate,
13977 onCancel: handleDialogCancel,
13978 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Publish'),
13979 size: "medium",
13980 children: (0,external_wp_i18n_namespaceObject.__)('Would you like to privately publish this post now?')
13981 })]
13982 });
13983 }
13984 function PostVisibilityChoice({
13985 instanceId,
13986 value,
13987 label,
13988 info,
13989 ...props
13990 }) {
13991 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
13992 className: "editor-post-visibility__choice",
13993 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("input", {
13994 type: "radio",
13995 name: `editor-post-visibility__setting-${instanceId}`,
13996 value: value,
13997 id: `editor-post-${value}-${instanceId}`,
13998 "aria-describedby": `editor-post-${value}-${instanceId}-description`,
13999 className: "editor-post-visibility__radio",
14000 ...props
14001 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("label", {
14002 htmlFor: `editor-post-${value}-${instanceId}`,
14003 className: "editor-post-visibility__label",
14004 children: label
14005 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
14006 id: `editor-post-${value}-${instanceId}-description`,
14007 className: "editor-post-visibility__info",
14008 children: info
14009 })]
14010 });
14011 }
14012
14013 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/label.js
14014 /**
14015 * WordPress dependencies
14016 */
14017
14018
14019 /**
14020 * Internal dependencies
14021 */
14022
14023
14024
14025 /**
14026 * Returns the label for the current post visibility setting.
14027 *
14028 * @return {string} Post visibility label.
14029 */
14030 function PostVisibilityLabel() {
14031 return usePostVisibilityLabel();
14032 }
14033
14034 /**
14035 * Get the label for the current post visibility setting.
14036 *
14037 * @return {string} Post visibility label.
14038 */
14039 function usePostVisibilityLabel() {
14040 const visibility = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostVisibility());
14041 return visibilityOptions[visibility]?.label;
14042 }
14043
14044 ;// CONCATENATED MODULE: ./node_modules/date-fns/toDate.mjs
14045 /**
14046 * @name toDate
14047 * @category Common Helpers
14048 * @summary Convert the given argument to an instance of Date.
14049 *
14050 * @description
14051 * Convert the given argument to an instance of Date.
14052 *
14053 * If the argument is an instance of Date, the function returns its clone.
14054 *
14055 * If the argument is a number, it is treated as a timestamp.
14056 *
14057 * If the argument is none of the above, the function returns Invalid Date.
14058 *
14059 * **Note**: *all* Date arguments passed to any *date-fns* function is processed by `toDate`.
14060 *
14061 * @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).
14062 *
14063 * @param argument - The value to convert
14064 *
14065 * @returns The parsed date in the local time zone
14066 *
14067 * @example
14068 * // Clone the date:
14069 * const result = toDate(new Date(2014, 1, 11, 11, 30, 30))
14070 * //=> Tue Feb 11 2014 11:30:30
14071 *
14072 * @example
14073 * // Convert the timestamp to date:
14074 * const result = toDate(1392098430000)
14075 * //=> Tue Feb 11 2014 11:30:30
14076 */
14077 function toDate(argument) {
14078 const argStr = Object.prototype.toString.call(argument);
14079
14080 // Clone the date
14081 if (
14082 argument instanceof Date ||
14083 (typeof argument === "object" && argStr === "[object Date]")
14084 ) {
14085 // Prevent the date to lose the milliseconds when passed to new Date() in IE10
14086 return new argument.constructor(+argument);
14087 } else if (
14088 typeof argument === "number" ||
14089 argStr === "[object Number]" ||
14090 typeof argument === "string" ||
14091 argStr === "[object String]"
14092 ) {
14093 // TODO: Can we get rid of as?
14094 return new Date(argument);
14095 } else {
14096 // TODO: Can we get rid of as?
14097 return new Date(NaN);
14098 }
14099 }
14100
14101 // Fallback for modularized imports:
14102 /* harmony default export */ const date_fns_toDate = ((/* unused pure expression or super */ null && (toDate)));
14103
14104 ;// CONCATENATED MODULE: ./node_modules/date-fns/startOfMonth.mjs
14105
14106
14107 /**
14108 * @name startOfMonth
14109 * @category Month Helpers
14110 * @summary Return the start of a month for the given date.
14111 *
14112 * @description
14113 * Return the start of a month for the given date.
14114 * The result will be in the local timezone.
14115 *
14116 * @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).
14117 *
14118 * @param date - The original date
14119 *
14120 * @returns The start of a month
14121 *
14122 * @example
14123 * // The start of a month for 2 September 2014 11:55:00:
14124 * const result = startOfMonth(new Date(2014, 8, 2, 11, 55, 0))
14125 * //=> Mon Sep 01 2014 00:00:00
14126 */
14127 function startOfMonth(date) {
14128 const _date = toDate(date);
14129 _date.setDate(1);
14130 _date.setHours(0, 0, 0, 0);
14131 return _date;
14132 }
14133
14134 // Fallback for modularized imports:
14135 /* harmony default export */ const date_fns_startOfMonth = ((/* unused pure expression or super */ null && (startOfMonth)));
14136
14137 ;// CONCATENATED MODULE: ./node_modules/date-fns/endOfMonth.mjs
14138
14139
14140 /**
14141 * @name endOfMonth
14142 * @category Month Helpers
14143 * @summary Return the end of a month for the given date.
14144 *
14145 * @description
14146 * Return the end of a month for the given date.
14147 * The result will be in the local timezone.
14148 *
14149 * @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).
14150 *
14151 * @param date - The original date
14152 *
14153 * @returns The end of a month
14154 *
14155 * @example
14156 * // The end of a month for 2 September 2014 11:55:00:
14157 * const result = endOfMonth(new Date(2014, 8, 2, 11, 55, 0))
14158 * //=> Tue Sep 30 2014 23:59:59.999
14159 */
14160 function endOfMonth(date) {
14161 const _date = toDate(date);
14162 const month = _date.getMonth();
14163 _date.setFullYear(_date.getFullYear(), month + 1, 0);
14164 _date.setHours(23, 59, 59, 999);
14165 return _date;
14166 }
14167
14168 // Fallback for modularized imports:
14169 /* harmony default export */ const date_fns_endOfMonth = ((/* unused pure expression or super */ null && (endOfMonth)));
14170
14171 ;// CONCATENATED MODULE: ./node_modules/date-fns/constants.mjs
14172 /**
14173 * @module constants
14174 * @summary Useful constants
14175 * @description
14176 * Collection of useful date constants.
14177 *
14178 * The constants could be imported from `date-fns/constants`:
14179 *
14180 * ```ts
14181 * import { maxTime, minTime } from "./constants/date-fns/constants";
14182 *
14183 * function isAllowedTime(time) {
14184 * return time <= maxTime && time >= minTime;
14185 * }
14186 * ```
14187 */
14188
14189 /**
14190 * @constant
14191 * @name daysInWeek
14192 * @summary Days in 1 week.
14193 */
14194 const daysInWeek = 7;
14195
14196 /**
14197 * @constant
14198 * @name daysInYear
14199 * @summary Days in 1 year.
14200 *
14201 * @description
14202 * How many days in a year.
14203 *
14204 * One years equals 365.2425 days according to the formula:
14205 *
14206 * > Leap year occures every 4 years, except for years that are divisable by 100 and not divisable by 400.
14207 * > 1 mean year = (365+1/4-1/100+1/400) days = 365.2425 days
14208 */
14209 const daysInYear = 365.2425;
14210
14211 /**
14212 * @constant
14213 * @name maxTime
14214 * @summary Maximum allowed time.
14215 *
14216 * @example
14217 * import { maxTime } from "./constants/date-fns/constants";
14218 *
14219 * const isValid = 8640000000000001 <= maxTime;
14220 * //=> false
14221 *
14222 * new Date(8640000000000001);
14223 * //=> Invalid Date
14224 */
14225 const maxTime = Math.pow(10, 8) * 24 * 60 * 60 * 1000;
14226
14227 /**
14228 * @constant
14229 * @name minTime
14230 * @summary Minimum allowed time.
14231 *
14232 * @example
14233 * import { minTime } from "./constants/date-fns/constants";
14234 *
14235 * const isValid = -8640000000000001 >= minTime;
14236 * //=> false
14237 *
14238 * new Date(-8640000000000001)
14239 * //=> Invalid Date
14240 */
14241 const minTime = -maxTime;
14242
14243 /**
14244 * @constant
14245 * @name millisecondsInWeek
14246 * @summary Milliseconds in 1 week.
14247 */
14248 const millisecondsInWeek = 604800000;
14249
14250 /**
14251 * @constant
14252 * @name millisecondsInDay
14253 * @summary Milliseconds in 1 day.
14254 */
14255 const millisecondsInDay = 86400000;
14256
14257 /**
14258 * @constant
14259 * @name millisecondsInMinute
14260 * @summary Milliseconds in 1 minute
14261 */
14262 const millisecondsInMinute = 60000;
14263
14264 /**
14265 * @constant
14266 * @name millisecondsInHour
14267 * @summary Milliseconds in 1 hour
14268 */
14269 const millisecondsInHour = 3600000;
14270
14271 /**
14272 * @constant
14273 * @name millisecondsInSecond
14274 * @summary Milliseconds in 1 second
14275 */
14276 const millisecondsInSecond = 1000;
14277
14278 /**
14279 * @constant
14280 * @name minutesInYear
14281 * @summary Minutes in 1 year.
14282 */
14283 const minutesInYear = 525600;
14284
14285 /**
14286 * @constant
14287 * @name minutesInMonth
14288 * @summary Minutes in 1 month.
14289 */
14290 const minutesInMonth = 43200;
14291
14292 /**
14293 * @constant
14294 * @name minutesInDay
14295 * @summary Minutes in 1 day.
14296 */
14297 const minutesInDay = 1440;
14298
14299 /**
14300 * @constant
14301 * @name minutesInHour
14302 * @summary Minutes in 1 hour.
14303 */
14304 const minutesInHour = 60;
14305
14306 /**
14307 * @constant
14308 * @name monthsInQuarter
14309 * @summary Months in 1 quarter.
14310 */
14311 const monthsInQuarter = 3;
14312
14313 /**
14314 * @constant
14315 * @name monthsInYear
14316 * @summary Months in 1 year.
14317 */
14318 const monthsInYear = 12;
14319
14320 /**
14321 * @constant
14322 * @name quartersInYear
14323 * @summary Quarters in 1 year
14324 */
14325 const quartersInYear = 4;
14326
14327 /**
14328 * @constant
14329 * @name secondsInHour
14330 * @summary Seconds in 1 hour.
14331 */
14332 const secondsInHour = 3600;
14333
14334 /**
14335 * @constant
14336 * @name secondsInMinute
14337 * @summary Seconds in 1 minute.
14338 */
14339 const secondsInMinute = 60;
14340
14341 /**
14342 * @constant
14343 * @name secondsInDay
14344 * @summary Seconds in 1 day.
14345 */
14346 const secondsInDay = secondsInHour * 24;
14347
14348 /**
14349 * @constant
14350 * @name secondsInWeek
14351 * @summary Seconds in 1 week.
14352 */
14353 const secondsInWeek = secondsInDay * 7;
14354
14355 /**
14356 * @constant
14357 * @name secondsInYear
14358 * @summary Seconds in 1 year.
14359 */
14360 const secondsInYear = secondsInDay * daysInYear;
14361
14362 /**
14363 * @constant
14364 * @name secondsInMonth
14365 * @summary Seconds in 1 month
14366 */
14367 const secondsInMonth = secondsInYear / 12;
14368
14369 /**
14370 * @constant
14371 * @name secondsInQuarter
14372 * @summary Seconds in 1 quarter.
14373 */
14374 const secondsInQuarter = secondsInMonth * 3;
14375
14376 ;// CONCATENATED MODULE: ./node_modules/date-fns/parseISO.mjs
14377
14378
14379 /**
14380 * The {@link parseISO} function options.
14381 */
14382
14383 /**
14384 * @name parseISO
14385 * @category Common Helpers
14386 * @summary Parse ISO string
14387 *
14388 * @description
14389 * Parse the given string in ISO 8601 format and return an instance of Date.
14390 *
14391 * Function accepts complete ISO 8601 formats as well as partial implementations.
14392 * ISO 8601: http://en.wikipedia.org/wiki/ISO_8601
14393 *
14394 * If the argument isn't a string, the function cannot parse the string or
14395 * the values are invalid, it returns Invalid Date.
14396 *
14397 * @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).
14398 *
14399 * @param argument - The value to convert
14400 * @param options - An object with options
14401 *
14402 * @returns The parsed date in the local time zone
14403 *
14404 * @example
14405 * // Convert string '2014-02-11T11:30:30' to date:
14406 * const result = parseISO('2014-02-11T11:30:30')
14407 * //=> Tue Feb 11 2014 11:30:30
14408 *
14409 * @example
14410 * // Convert string '+02014101' to date,
14411 * // if the additional number of digits in the extended year format is 1:
14412 * const result = parseISO('+02014101', { additionalDigits: 1 })
14413 * //=> Fri Apr 11 2014 00:00:00
14414 */
14415 function parseISO(argument, options) {
14416 const additionalDigits = options?.additionalDigits ?? 2;
14417 const dateStrings = splitDateString(argument);
14418
14419 let date;
14420 if (dateStrings.date) {
14421 const parseYearResult = parseYear(dateStrings.date, additionalDigits);
14422 date = parseDate(parseYearResult.restDateString, parseYearResult.year);
14423 }
14424
14425 if (!date || isNaN(date.getTime())) {
14426 return new Date(NaN);
14427 }
14428
14429 const timestamp = date.getTime();
14430 let time = 0;
14431 let offset;
14432
14433 if (dateStrings.time) {
14434 time = parseTime(dateStrings.time);
14435 if (isNaN(time)) {
14436 return new Date(NaN);
14437 }
14438 }
14439
14440 if (dateStrings.timezone) {
14441 offset = parseTimezone(dateStrings.timezone);
14442 if (isNaN(offset)) {
14443 return new Date(NaN);
14444 }
14445 } else {
14446 const dirtyDate = new Date(timestamp + time);
14447 // JS parsed string assuming it's in UTC timezone
14448 // but we need it to be parsed in our timezone
14449 // so we use utc values to build date in our timezone.
14450 // Year values from 0 to 99 map to the years 1900 to 1999
14451 // so set year explicitly with setFullYear.
14452 const result = new Date(0);
14453 result.setFullYear(
14454 dirtyDate.getUTCFullYear(),
14455 dirtyDate.getUTCMonth(),
14456 dirtyDate.getUTCDate(),
14457 );
14458 result.setHours(
14459 dirtyDate.getUTCHours(),
14460 dirtyDate.getUTCMinutes(),
14461 dirtyDate.getUTCSeconds(),
14462 dirtyDate.getUTCMilliseconds(),
14463 );
14464 return result;
14465 }
14466
14467 return new Date(timestamp + time + offset);
14468 }
14469
14470 const patterns = {
14471 dateTimeDelimiter: /[T ]/,
14472 timeZoneDelimiter: /[Z ]/i,
14473 timezone: /([Z+-].*)$/,
14474 };
14475
14476 const dateRegex =
14477 /^-?(?:(\d{3})|(\d{2})(?:-?(\d{2}))?|W(\d{2})(?:-?(\d{1}))?|)$/;
14478 const timeRegex =
14479 /^(\d{2}(?:[.,]\d*)?)(?::?(\d{2}(?:[.,]\d*)?))?(?::?(\d{2}(?:[.,]\d*)?))?$/;
14480 const timezoneRegex = /^([+-])(\d{2})(?::?(\d{2}))?$/;
14481
14482 function splitDateString(dateString) {
14483 const dateStrings = {};
14484 const array = dateString.split(patterns.dateTimeDelimiter);
14485 let timeString;
14486
14487 // The regex match should only return at maximum two array elements.
14488 // [date], [time], or [date, time].
14489 if (array.length > 2) {
14490 return dateStrings;
14491 }
14492
14493 if (/:/.test(array[0])) {
14494 timeString = array[0];
14495 } else {
14496 dateStrings.date = array[0];
14497 timeString = array[1];
14498 if (patterns.timeZoneDelimiter.test(dateStrings.date)) {
14499 dateStrings.date = dateString.split(patterns.timeZoneDelimiter)[0];
14500 timeString = dateString.substr(
14501 dateStrings.date.length,
14502 dateString.length,
14503 );
14504 }
14505 }
14506
14507 if (timeString) {
14508 const token = patterns.timezone.exec(timeString);
14509 if (token) {
14510 dateStrings.time = timeString.replace(token[1], "");
14511 dateStrings.timezone = token[1];
14512 } else {
14513 dateStrings.time = timeString;
14514 }
14515 }
14516
14517 return dateStrings;
14518 }
14519
14520 function parseYear(dateString, additionalDigits) {
14521 const regex = new RegExp(
14522 "^(?:(\\d{4}|[+-]\\d{" +
14523 (4 + additionalDigits) +
14524 "})|(\\d{2}|[+-]\\d{" +
14525 (2 + additionalDigits) +
14526 "})$)",
14527 );
14528
14529 const captures = dateString.match(regex);
14530 // Invalid ISO-formatted year
14531 if (!captures) return { year: NaN, restDateString: "" };
14532
14533 const year = captures[1] ? parseInt(captures[1]) : null;
14534 const century = captures[2] ? parseInt(captures[2]) : null;
14535
14536 // either year or century is null, not both
14537 return {
14538 year: century === null ? year : century * 100,
14539 restDateString: dateString.slice((captures[1] || captures[2]).length),
14540 };
14541 }
14542
14543 function parseDate(dateString, year) {
14544 // Invalid ISO-formatted year
14545 if (year === null) return new Date(NaN);
14546
14547 const captures = dateString.match(dateRegex);
14548 // Invalid ISO-formatted string
14549 if (!captures) return new Date(NaN);
14550
14551 const isWeekDate = !!captures[4];
14552 const dayOfYear = parseDateUnit(captures[1]);
14553 const month = parseDateUnit(captures[2]) - 1;
14554 const day = parseDateUnit(captures[3]);
14555 const week = parseDateUnit(captures[4]);
14556 const dayOfWeek = parseDateUnit(captures[5]) - 1;
14557
14558 if (isWeekDate) {
14559 if (!validateWeekDate(year, week, dayOfWeek)) {
14560 return new Date(NaN);
14561 }
14562 return dayOfISOWeekYear(year, week, dayOfWeek);
14563 } else {
14564 const date = new Date(0);
14565 if (
14566 !validateDate(year, month, day) ||
14567 !validateDayOfYearDate(year, dayOfYear)
14568 ) {
14569 return new Date(NaN);
14570 }
14571 date.setUTCFullYear(year, month, Math.max(dayOfYear, day));
14572 return date;
14573 }
14574 }
14575
14576 function parseDateUnit(value) {
14577 return value ? parseInt(value) : 1;
14578 }
14579
14580 function parseTime(timeString) {
14581 const captures = timeString.match(timeRegex);
14582 if (!captures) return NaN; // Invalid ISO-formatted time
14583
14584 const hours = parseTimeUnit(captures[1]);
14585 const minutes = parseTimeUnit(captures[2]);
14586 const seconds = parseTimeUnit(captures[3]);
14587
14588 if (!validateTime(hours, minutes, seconds)) {
14589 return NaN;
14590 }
14591
14592 return (
14593 hours * millisecondsInHour + minutes * millisecondsInMinute + seconds * 1000
14594 );
14595 }
14596
14597 function parseTimeUnit(value) {
14598 return (value && parseFloat(value.replace(",", "."))) || 0;
14599 }
14600
14601 function parseTimezone(timezoneString) {
14602 if (timezoneString === "Z") return 0;
14603
14604 const captures = timezoneString.match(timezoneRegex);
14605 if (!captures) return 0;
14606
14607 const sign = captures[1] === "+" ? -1 : 1;
14608 const hours = parseInt(captures[2]);
14609 const minutes = (captures[3] && parseInt(captures[3])) || 0;
14610
14611 if (!validateTimezone(hours, minutes)) {
14612 return NaN;
14613 }
14614
14615 return sign * (hours * millisecondsInHour + minutes * millisecondsInMinute);
14616 }
14617
14618 function dayOfISOWeekYear(isoWeekYear, week, day) {
14619 const date = new Date(0);
14620 date.setUTCFullYear(isoWeekYear, 0, 4);
14621 const fourthOfJanuaryDay = date.getUTCDay() || 7;
14622 const diff = (week - 1) * 7 + day + 1 - fourthOfJanuaryDay;
14623 date.setUTCDate(date.getUTCDate() + diff);
14624 return date;
14625 }
14626
14627 // Validation functions
14628
14629 // February is null to handle the leap year (using ||)
14630 const daysInMonths = [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
14631
14632 function isLeapYearIndex(year) {
14633 return year % 400 === 0 || (year % 4 === 0 && year % 100 !== 0);
14634 }
14635
14636 function validateDate(year, month, date) {
14637 return (
14638 month >= 0 &&
14639 month <= 11 &&
14640 date >= 1 &&
14641 date <= (daysInMonths[month] || (isLeapYearIndex(year) ? 29 : 28))
14642 );
14643 }
14644
14645 function validateDayOfYearDate(year, dayOfYear) {
14646 return dayOfYear >= 1 && dayOfYear <= (isLeapYearIndex(year) ? 366 : 365);
14647 }
14648
14649 function validateWeekDate(_year, week, day) {
14650 return week >= 1 && week <= 53 && day >= 0 && day <= 6;
14651 }
14652
14653 function validateTime(hours, minutes, seconds) {
14654 if (hours === 24) {
14655 return minutes === 0 && seconds === 0;
14656 }
14657
14658 return (
14659 seconds >= 0 &&
14660 seconds < 60 &&
14661 minutes >= 0 &&
14662 minutes < 60 &&
14663 hours >= 0 &&
14664 hours < 25
14665 );
14666 }
14667
14668 function validateTimezone(_hours, minutes) {
14669 return minutes >= 0 && minutes <= 59;
14670 }
14671
14672 // Fallback for modularized imports:
14673 /* harmony default export */ const date_fns_parseISO = ((/* unused pure expression or super */ null && (parseISO)));
14674
14675 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-schedule/index.js
14676 /**
14677 * External dependencies
14678 */
14679
14680
14681 /**
14682 * WordPress dependencies
14683 */
14684
14685
14686
14687
14688
14689
14690
14691 /**
14692 * Internal dependencies
14693 */
14694
14695
14696
14697 const {
14698 PrivatePublishDateTimePicker
14699 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
14700
14701 /**
14702 * Renders the PostSchedule component. It allows the user to schedule a post.
14703 *
14704 * @param {Object} props Props.
14705 * @param {Function} props.onClose Function to close the component.
14706 *
14707 * @return {Component} The component to be rendered.
14708 */
14709 function PostSchedule(props) {
14710 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostSchedule, {
14711 ...props,
14712 showPopoverHeaderActions: true,
14713 isCompact: false
14714 });
14715 }
14716 function PrivatePostSchedule({
14717 onClose,
14718 showPopoverHeaderActions,
14719 isCompact
14720 }) {
14721 const {
14722 postDate,
14723 postType
14724 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
14725 postDate: select(store_store).getEditedPostAttribute('date'),
14726 postType: select(store_store).getCurrentPostType()
14727 }), []);
14728 const {
14729 editPost
14730 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
14731 const onUpdateDate = date => editPost({
14732 date
14733 });
14734 const [previewedMonth, setPreviewedMonth] = (0,external_wp_element_namespaceObject.useState)(startOfMonth(new Date(postDate)));
14735
14736 // Pick up published and schduled site posts.
14737 const eventsByPostType = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', postType, {
14738 status: 'publish,future',
14739 after: startOfMonth(previewedMonth).toISOString(),
14740 before: endOfMonth(previewedMonth).toISOString(),
14741 exclude: [select(store_store).getCurrentPostId()],
14742 per_page: 100,
14743 _fields: 'id,date'
14744 }), [previewedMonth, postType]);
14745 const events = (0,external_wp_element_namespaceObject.useMemo)(() => (eventsByPostType || []).map(({
14746 date: eventDate
14747 }) => ({
14748 date: new Date(eventDate)
14749 })), [eventsByPostType]);
14750 const settings = (0,external_wp_date_namespaceObject.getSettings)();
14751
14752 // To know if the current timezone is a 12 hour time with look for "a" in the time format
14753 // We also make sure this a is not escaped by a "/"
14754 const is12HourTime = /a(?!\\)/i.test(settings.formats.time.toLowerCase() // Test only the lower case a.
14755 .replace(/\\\\/g, '') // Replace "//" with empty strings.
14756 .split('').reverse().join('') // Reverse the string and test for "a" not followed by a slash.
14757 );
14758 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePublishDateTimePicker, {
14759 currentDate: postDate,
14760 onChange: onUpdateDate,
14761 is12Hour: is12HourTime,
14762 dateOrder: /* translators: Order of day, month, and year. Available formats are 'dmy', 'mdy', and 'ymd'. */
14763 (0,external_wp_i18n_namespaceObject._x)('dmy', 'date order'),
14764 events: events,
14765 onMonthPreviewed: date => setPreviewedMonth(parseISO(date)),
14766 onClose: onClose,
14767 isCompact: isCompact,
14768 showPopoverHeaderActions: showPopoverHeaderActions
14769 });
14770 }
14771
14772 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-schedule/label.js
14773 /**
14774 * WordPress dependencies
14775 */
14776
14777
14778
14779
14780 /**
14781 * Internal dependencies
14782 */
14783
14784
14785 /**
14786 * Renders the PostScheduleLabel component.
14787 *
14788 * @param {Object} props Props.
14789 *
14790 * @return {Component} The component to be rendered.
14791 */
14792 function PostScheduleLabel(props) {
14793 return usePostScheduleLabel(props);
14794 }
14795
14796 /**
14797 * Custom hook to get the label for post schedule.
14798 *
14799 * @param {Object} options Options for the hook.
14800 * @param {boolean} options.full Whether to get the full label or not. Default is false.
14801 *
14802 * @return {string} The label for post schedule.
14803 */
14804 function usePostScheduleLabel({
14805 full = false
14806 } = {}) {
14807 const {
14808 date,
14809 isFloating
14810 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
14811 date: select(store_store).getEditedPostAttribute('date'),
14812 isFloating: select(store_store).isEditedPostDateFloating()
14813 }), []);
14814 return full ? getFullPostScheduleLabel(date) : getPostScheduleLabel(date, {
14815 isFloating
14816 });
14817 }
14818 function getFullPostScheduleLabel(dateAttribute) {
14819 const date = (0,external_wp_date_namespaceObject.getDate)(dateAttribute);
14820 const timezoneAbbreviation = getTimezoneAbbreviation();
14821 const formattedDate = (0,external_wp_date_namespaceObject.dateI18n)(
14822 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
14823 (0,external_wp_i18n_namespaceObject._x)('F j, Y g:i\xa0a', 'post schedule full date format'), date);
14824 return (0,external_wp_i18n_namespaceObject.isRTL)() ? `${timezoneAbbreviation} ${formattedDate}` : `${formattedDate} ${timezoneAbbreviation}`;
14825 }
14826 function getPostScheduleLabel(dateAttribute, {
14827 isFloating = false,
14828 now = new Date()
14829 } = {}) {
14830 if (!dateAttribute || isFloating) {
14831 return (0,external_wp_i18n_namespaceObject.__)('Immediately');
14832 }
14833
14834 // If the user timezone does not equal the site timezone then using words
14835 // like 'tomorrow' is confusing, so show the full date.
14836 if (!isTimezoneSameAsSiteTimezone(now)) {
14837 return getFullPostScheduleLabel(dateAttribute);
14838 }
14839 const date = (0,external_wp_date_namespaceObject.getDate)(dateAttribute);
14840 if (isSameDay(date, now)) {
14841 return (0,external_wp_i18n_namespaceObject.sprintf)(
14842 // translators: %s: Time of day the post is scheduled for.
14843 (0,external_wp_i18n_namespaceObject.__)('Today at %s'),
14844 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
14845 (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_i18n_namespaceObject._x)('g:i\xa0a', 'post schedule time format'), date));
14846 }
14847 const tomorrow = new Date(now);
14848 tomorrow.setDate(tomorrow.getDate() + 1);
14849 if (isSameDay(date, tomorrow)) {
14850 return (0,external_wp_i18n_namespaceObject.sprintf)(
14851 // translators: %s: Time of day the post is scheduled for.
14852 (0,external_wp_i18n_namespaceObject.__)('Tomorrow at %s'),
14853 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
14854 (0,external_wp_date_namespaceObject.dateI18n)((0,external_wp_i18n_namespaceObject._x)('g:i\xa0a', 'post schedule time format'), date));
14855 }
14856 if (date.getFullYear() === now.getFullYear()) {
14857 return (0,external_wp_date_namespaceObject.dateI18n)(
14858 // translators: If using a space between 'g:i' and 'a', use a non-breaking space.
14859 (0,external_wp_i18n_namespaceObject._x)('F j g:i\xa0a', 'post schedule date format without year'), date);
14860 }
14861 return (0,external_wp_date_namespaceObject.dateI18n)(
14862 // translators: Use a non-breaking space between 'g:i' and 'a' if appropriate.
14863 (0,external_wp_i18n_namespaceObject._x)('F j, Y g:i\xa0a', 'post schedule full date format'), date);
14864 }
14865 function getTimezoneAbbreviation() {
14866 const {
14867 timezone
14868 } = (0,external_wp_date_namespaceObject.getSettings)();
14869 if (timezone.abbr && isNaN(Number(timezone.abbr))) {
14870 return timezone.abbr;
14871 }
14872 const symbol = timezone.offset < 0 ? '' : '+';
14873 return `UTC${symbol}${timezone.offsetFormatted}`;
14874 }
14875 function isTimezoneSameAsSiteTimezone(date) {
14876 const {
14877 timezone
14878 } = (0,external_wp_date_namespaceObject.getSettings)();
14879 const siteOffset = Number(timezone.offset);
14880 const dateOffset = -1 * (date.getTimezoneOffset() / 60);
14881 return siteOffset === dateOffset;
14882 }
14883 function isSameDay(left, right) {
14884 return left.getDate() === right.getDate() && left.getMonth() === right.getMonth() && left.getFullYear() === right.getFullYear();
14885 }
14886
14887 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/most-used-terms.js
14888 /**
14889 * WordPress dependencies
14890 */
14891
14892
14893
14894
14895 /**
14896 * Internal dependencies
14897 */
14898
14899
14900
14901 const MIN_MOST_USED_TERMS = 3;
14902 const DEFAULT_QUERY = {
14903 per_page: 10,
14904 orderby: 'count',
14905 order: 'desc',
14906 hide_empty: true,
14907 _fields: 'id,name,count',
14908 context: 'view'
14909 };
14910 function MostUsedTerms({
14911 onSelect,
14912 taxonomy
14913 }) {
14914 const {
14915 _terms,
14916 showTerms
14917 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
14918 const mostUsedTerms = select(external_wp_coreData_namespaceObject.store).getEntityRecords('taxonomy', taxonomy.slug, DEFAULT_QUERY);
14919 return {
14920 _terms: mostUsedTerms,
14921 showTerms: mostUsedTerms?.length >= MIN_MOST_USED_TERMS
14922 };
14923 }, [taxonomy.slug]);
14924 if (!showTerms) {
14925 return null;
14926 }
14927 const terms = unescapeTerms(_terms);
14928 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
14929 className: "editor-post-taxonomies__flat-term-most-used",
14930 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.BaseControl.VisualLabel, {
14931 as: "h3",
14932 className: "editor-post-taxonomies__flat-term-most-used-label",
14933 children: taxonomy.labels.most_used
14934 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
14935 role: "list",
14936 className: "editor-post-taxonomies__flat-term-most-used-list",
14937 children: terms.map(term => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
14938 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
14939 variant: "link",
14940 onClick: () => onSelect(term),
14941 children: term.name
14942 })
14943 }, term.id))
14944 })]
14945 });
14946 }
14947
14948 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/flat-term-selector.js
14949 /**
14950 * WordPress dependencies
14951 */
14952
14953
14954
14955
14956
14957
14958
14959
14960
14961
14962 /**
14963 * Internal dependencies
14964 */
14965
14966
14967
14968
14969 /**
14970 * Shared reference to an empty array for cases where it is important to avoid
14971 * returning a new array reference on every invocation.
14972 *
14973 * @type {Array<any>}
14974 */
14975
14976
14977
14978 const EMPTY_ARRAY = [];
14979
14980 /**
14981 * How the max suggestions limit was chosen:
14982 * - Matches the `per_page` range set by the REST API.
14983 * - Can't use "unbound" query. The `FormTokenField` needs a fixed number.
14984 * - Matches default for `FormTokenField`.
14985 */
14986 const MAX_TERMS_SUGGESTIONS = 100;
14987 const flat_term_selector_DEFAULT_QUERY = {
14988 per_page: MAX_TERMS_SUGGESTIONS,
14989 _fields: 'id,name',
14990 context: 'view'
14991 };
14992 const isSameTermName = (termA, termB) => unescapeString(termA).toLowerCase() === unescapeString(termB).toLowerCase();
14993 const termNamesToIds = (names, terms) => {
14994 return names.map(termName => terms.find(term => isSameTermName(term.name, termName))?.id).filter(id => id !== undefined);
14995 };
14996
14997 /**
14998 * Renders a flat term selector component.
14999 *
15000 * @param {Object} props The component props.
15001 * @param {string} props.slug The slug of the taxonomy.
15002 * @param {boolean} props.__nextHasNoMarginBottom Start opting into the new margin-free styles that will become the default in a future version, currently scheduled to be WordPress 7.0. (The prop can be safely removed once this happens.)
15003 *
15004 * @return {JSX.Element} The rendered flat term selector component.
15005 */
15006 function FlatTermSelector({
15007 slug,
15008 __nextHasNoMarginBottom
15009 }) {
15010 var _taxonomy$labels$add_, _taxonomy$labels$sing2;
15011 const [values, setValues] = (0,external_wp_element_namespaceObject.useState)([]);
15012 const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)('');
15013 const debouncedSearch = (0,external_wp_compose_namespaceObject.useDebounce)(setSearch, 500);
15014 if (!__nextHasNoMarginBottom) {
15015 external_wp_deprecated_default()('Bottom margin styles for wp.editor.PostTaxonomiesFlatTermSelector', {
15016 since: '6.7',
15017 version: '7.0',
15018 hint: 'Set the `__nextHasNoMarginBottom` prop to true to start opting into the new styles, which will become the default in a future version.'
15019 });
15020 }
15021 const {
15022 terms,
15023 termIds,
15024 taxonomy,
15025 hasAssignAction,
15026 hasCreateAction,
15027 hasResolvedTerms
15028 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15029 var _post$_links, _post$_links2;
15030 const {
15031 getCurrentPost,
15032 getEditedPostAttribute
15033 } = select(store_store);
15034 const {
15035 getEntityRecords,
15036 getTaxonomy,
15037 hasFinishedResolution
15038 } = select(external_wp_coreData_namespaceObject.store);
15039 const post = getCurrentPost();
15040 const _taxonomy = getTaxonomy(slug);
15041 const _termIds = _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : EMPTY_ARRAY;
15042 const query = {
15043 ...flat_term_selector_DEFAULT_QUERY,
15044 include: _termIds?.join(','),
15045 per_page: -1
15046 };
15047 return {
15048 hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
15049 hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false,
15050 taxonomy: _taxonomy,
15051 termIds: _termIds,
15052 terms: _termIds?.length ? getEntityRecords('taxonomy', slug, query) : EMPTY_ARRAY,
15053 hasResolvedTerms: hasFinishedResolution('getEntityRecords', ['taxonomy', slug, query])
15054 };
15055 }, [slug]);
15056 const {
15057 searchResults
15058 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15059 const {
15060 getEntityRecords
15061 } = select(external_wp_coreData_namespaceObject.store);
15062 return {
15063 searchResults: !!search ? getEntityRecords('taxonomy', slug, {
15064 ...flat_term_selector_DEFAULT_QUERY,
15065 search
15066 }) : EMPTY_ARRAY
15067 };
15068 }, [search, slug]);
15069
15070 // Update terms state only after the selectors are resolved.
15071 // We're using this to avoid terms temporarily disappearing on slow networks
15072 // while core data makes REST API requests.
15073 (0,external_wp_element_namespaceObject.useEffect)(() => {
15074 if (hasResolvedTerms) {
15075 const newValues = (terms !== null && terms !== void 0 ? terms : []).map(term => unescapeString(term.name));
15076 setValues(newValues);
15077 }
15078 }, [terms, hasResolvedTerms]);
15079 const suggestions = (0,external_wp_element_namespaceObject.useMemo)(() => {
15080 return (searchResults !== null && searchResults !== void 0 ? searchResults : []).map(term => unescapeString(term.name));
15081 }, [searchResults]);
15082 const {
15083 editPost
15084 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15085 const {
15086 saveEntityRecord
15087 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
15088 const {
15089 createErrorNotice
15090 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
15091 if (!hasAssignAction) {
15092 return null;
15093 }
15094 async function findOrCreateTerm(term) {
15095 try {
15096 const newTerm = await saveEntityRecord('taxonomy', slug, term, {
15097 throwOnError: true
15098 });
15099 return unescapeTerm(newTerm);
15100 } catch (error) {
15101 if (error.code !== 'term_exists') {
15102 throw error;
15103 }
15104 return {
15105 id: error.data.term_id,
15106 name: term.name
15107 };
15108 }
15109 }
15110 function onUpdateTerms(newTermIds) {
15111 editPost({
15112 [taxonomy.rest_base]: newTermIds
15113 });
15114 }
15115 function onChange(termNames) {
15116 const availableTerms = [...(terms !== null && terms !== void 0 ? terms : []), ...(searchResults !== null && searchResults !== void 0 ? searchResults : [])];
15117 const uniqueTerms = termNames.reduce((acc, name) => {
15118 if (!acc.some(n => n.toLowerCase() === name.toLowerCase())) {
15119 acc.push(name);
15120 }
15121 return acc;
15122 }, []);
15123 const newTermNames = uniqueTerms.filter(termName => !availableTerms.find(term => isSameTermName(term.name, termName)));
15124
15125 // Optimistically update term values.
15126 // The selector will always re-fetch terms later.
15127 setValues(uniqueTerms);
15128 if (newTermNames.length === 0) {
15129 onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
15130 return;
15131 }
15132 if (!hasCreateAction) {
15133 return;
15134 }
15135 Promise.all(newTermNames.map(termName => findOrCreateTerm({
15136 name: termName
15137 }))).then(newTerms => {
15138 const newAvailableTerms = availableTerms.concat(newTerms);
15139 onUpdateTerms(termNamesToIds(uniqueTerms, newAvailableTerms));
15140 }).catch(error => {
15141 createErrorNotice(error.message, {
15142 type: 'snackbar'
15143 });
15144 // In case of a failure, try assigning available terms.
15145 // This will invalidate the optimistic update.
15146 onUpdateTerms(termNamesToIds(uniqueTerms, availableTerms));
15147 });
15148 }
15149 function appendTerm(newTerm) {
15150 var _taxonomy$labels$sing;
15151 if (termIds.includes(newTerm.id)) {
15152 return;
15153 }
15154 const newTermIds = [...termIds, newTerm.id];
15155 const defaultName = slug === 'post_tag' ? (0,external_wp_i18n_namespaceObject.__)('Tag') : (0,external_wp_i18n_namespaceObject.__)('Term');
15156 const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */
15157 (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);
15158 (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive');
15159 onUpdateTerms(newTermIds);
15160 }
15161 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');
15162 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');
15163 const termAddedLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */
15164 (0,external_wp_i18n_namespaceObject._x)('%s added', 'term'), singularName);
15165 const termRemovedLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */
15166 (0,external_wp_i18n_namespaceObject._x)('%s removed', 'term'), singularName);
15167 const removeTermLabel = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: term name. */
15168 (0,external_wp_i18n_namespaceObject._x)('Remove %s', 'term'), singularName);
15169 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
15170 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FormTokenField, {
15171 __next40pxDefaultSize: true,
15172 value: values,
15173 suggestions: suggestions,
15174 onChange: onChange,
15175 onInputChange: debouncedSearch,
15176 maxSuggestions: MAX_TERMS_SUGGESTIONS,
15177 label: newTermLabel,
15178 messages: {
15179 added: termAddedLabel,
15180 removed: termRemovedLabel,
15181 remove: removeTermLabel
15182 },
15183 __nextHasNoMarginBottom: __nextHasNoMarginBottom
15184 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MostUsedTerms, {
15185 taxonomy: taxonomy,
15186 onSelect: appendTerm
15187 })]
15188 });
15189 }
15190 /* harmony default export */ const flat_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(FlatTermSelector));
15191
15192 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/maybe-tags-panel.js
15193 /**
15194 * WordPress dependencies
15195 */
15196
15197
15198
15199
15200
15201
15202 /**
15203 * Internal dependencies
15204 */
15205
15206
15207
15208
15209 const TagsPanel = () => {
15210 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
15211 className: "editor-post-publish-panel__link",
15212 children: (0,external_wp_i18n_namespaceObject.__)('Add tags')
15213 }, "label")];
15214 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
15215 initialOpen: false,
15216 title: panelBodyTitle,
15217 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
15218 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.')
15219 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(flat_term_selector, {
15220 slug: "post_tag",
15221 __nextHasNoMarginBottom: true
15222 })]
15223 });
15224 };
15225 const MaybeTagsPanel = () => {
15226 const {
15227 hasTags,
15228 isPostTypeSupported
15229 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15230 const postType = select(store_store).getCurrentPostType();
15231 const tagsTaxonomy = select(external_wp_coreData_namespaceObject.store).getTaxonomy('post_tag');
15232 const _isPostTypeSupported = tagsTaxonomy?.types?.includes(postType);
15233 const areTagsFetched = tagsTaxonomy !== undefined;
15234 const tags = tagsTaxonomy && select(store_store).getEditedPostAttribute(tagsTaxonomy.rest_base);
15235 return {
15236 hasTags: !!tags?.length,
15237 isPostTypeSupported: areTagsFetched && _isPostTypeSupported
15238 };
15239 }, []);
15240 const [hadTagsWhenOpeningThePanel] = (0,external_wp_element_namespaceObject.useState)(hasTags);
15241 if (!isPostTypeSupported) {
15242 return null;
15243 }
15244
15245 /*
15246 * We only want to show the tag panel if the post didn't have
15247 * any tags when the user hit the Publish button.
15248 *
15249 * We can't use the prop.hasTags because it'll change to true
15250 * if the user adds a new tag within the pre-publish panel.
15251 * This would force a re-render and a new prop.hasTags check,
15252 * hiding this panel and keeping the user from adding
15253 * more than one tag.
15254 */
15255 if (!hadTagsWhenOpeningThePanel) {
15256 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TagsPanel, {});
15257 }
15258 return null;
15259 };
15260 /* harmony default export */ const maybe_tags_panel = (MaybeTagsPanel);
15261
15262 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/maybe-post-format-panel.js
15263 /**
15264 * WordPress dependencies
15265 */
15266
15267
15268
15269
15270
15271 /**
15272 * Internal dependencies
15273 */
15274
15275
15276
15277
15278 const getSuggestion = (supportedFormats, suggestedPostFormat) => {
15279 const formats = POST_FORMATS.filter(format => supportedFormats?.includes(format.id));
15280 return formats.find(format => format.id === suggestedPostFormat);
15281 };
15282 const PostFormatSuggestion = ({
15283 suggestedPostFormat,
15284 suggestionText,
15285 onUpdatePostFormat
15286 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15287 variant: "link",
15288 onClick: () => onUpdatePostFormat(suggestedPostFormat),
15289 children: suggestionText
15290 });
15291 function PostFormatPanel() {
15292 const {
15293 currentPostFormat,
15294 suggestion
15295 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15296 var _select$getThemeSuppo;
15297 const {
15298 getEditedPostAttribute,
15299 getSuggestedPostFormat
15300 } = select(store_store);
15301 const supportedFormats = (_select$getThemeSuppo = select(external_wp_coreData_namespaceObject.store).getThemeSupports().formats) !== null && _select$getThemeSuppo !== void 0 ? _select$getThemeSuppo : [];
15302 return {
15303 currentPostFormat: getEditedPostAttribute('format'),
15304 suggestion: getSuggestion(supportedFormats, getSuggestedPostFormat())
15305 };
15306 }, []);
15307 const {
15308 editPost
15309 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15310 const onUpdatePostFormat = format => editPost({
15311 format
15312 });
15313 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
15314 className: "editor-post-publish-panel__link",
15315 children: (0,external_wp_i18n_namespaceObject.__)('Use a post format')
15316 }, "label")];
15317 if (!suggestion || suggestion.id === currentPostFormat) {
15318 return null;
15319 }
15320 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
15321 initialOpen: false,
15322 title: panelBodyTitle,
15323 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
15324 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.')
15325 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
15326 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFormatSuggestion, {
15327 onUpdatePostFormat: onUpdatePostFormat,
15328 suggestedPostFormat: suggestion.id,
15329 suggestionText: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: post format */
15330 (0,external_wp_i18n_namespaceObject.__)('Apply the "%1$s" format.'), suggestion.caption)
15331 })
15332 })]
15333 });
15334 }
15335
15336 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/hierarchical-term-selector.js
15337 /**
15338 * WordPress dependencies
15339 */
15340
15341
15342
15343
15344
15345
15346
15347
15348
15349
15350 /**
15351 * Internal dependencies
15352 */
15353
15354
15355
15356 /**
15357 * Module Constants
15358 */
15359
15360
15361 const hierarchical_term_selector_DEFAULT_QUERY = {
15362 per_page: -1,
15363 orderby: 'name',
15364 order: 'asc',
15365 _fields: 'id,name,parent',
15366 context: 'view'
15367 };
15368 const MIN_TERMS_COUNT_FOR_FILTER = 8;
15369 const hierarchical_term_selector_EMPTY_ARRAY = [];
15370
15371 /**
15372 * Sort Terms by Selected.
15373 *
15374 * @param {Object[]} termsTree Array of terms in tree format.
15375 * @param {number[]} terms Selected terms.
15376 *
15377 * @return {Object[]} Sorted array of terms.
15378 */
15379 function sortBySelected(termsTree, terms) {
15380 const treeHasSelection = termTree => {
15381 if (terms.indexOf(termTree.id) !== -1) {
15382 return true;
15383 }
15384 if (undefined === termTree.children) {
15385 return false;
15386 }
15387 return termTree.children.map(treeHasSelection).filter(child => child).length > 0;
15388 };
15389 const termOrChildIsSelected = (termA, termB) => {
15390 const termASelected = treeHasSelection(termA);
15391 const termBSelected = treeHasSelection(termB);
15392 if (termASelected === termBSelected) {
15393 return 0;
15394 }
15395 if (termASelected && !termBSelected) {
15396 return -1;
15397 }
15398 if (!termASelected && termBSelected) {
15399 return 1;
15400 }
15401 return 0;
15402 };
15403 const newTermTree = [...termsTree];
15404 newTermTree.sort(termOrChildIsSelected);
15405 return newTermTree;
15406 }
15407
15408 /**
15409 * Find term by parent id or name.
15410 *
15411 * @param {Object[]} terms Array of Terms.
15412 * @param {number|string} parent id.
15413 * @param {string} name Term name.
15414 * @return {Object} Term object.
15415 */
15416 function findTerm(terms, parent, name) {
15417 return terms.find(term => {
15418 return (!term.parent && !parent || parseInt(term.parent) === parseInt(parent)) && term.name.toLowerCase() === name.toLowerCase();
15419 });
15420 }
15421
15422 /**
15423 * Get filter matcher function.
15424 *
15425 * @param {string} filterValue Filter value.
15426 * @return {(function(Object): (Object|boolean))} Matcher function.
15427 */
15428 function getFilterMatcher(filterValue) {
15429 const matchTermsForFilter = originalTerm => {
15430 if ('' === filterValue) {
15431 return originalTerm;
15432 }
15433
15434 // Shallow clone, because we'll be filtering the term's children and
15435 // don't want to modify the original term.
15436 const term = {
15437 ...originalTerm
15438 };
15439
15440 // Map and filter the children, recursive so we deal with grandchildren
15441 // and any deeper levels.
15442 if (term.children.length > 0) {
15443 term.children = term.children.map(matchTermsForFilter).filter(child => child);
15444 }
15445
15446 // If the term's name contains the filterValue, or it has children
15447 // (i.e. some child matched at some point in the tree) then return it.
15448 if (-1 !== term.name.toLowerCase().indexOf(filterValue.toLowerCase()) || term.children.length > 0) {
15449 return term;
15450 }
15451
15452 // Otherwise, return false. After mapping, the list of terms will need
15453 // to have false values filtered out.
15454 return false;
15455 };
15456 return matchTermsForFilter;
15457 }
15458
15459 /**
15460 * Hierarchical term selector.
15461 *
15462 * @param {Object} props Component props.
15463 * @param {string} props.slug Taxonomy slug.
15464 * @return {Element} Hierarchical term selector component.
15465 */
15466 function HierarchicalTermSelector({
15467 slug
15468 }) {
15469 var _taxonomy$labels$sear, _taxonomy$name;
15470 const [adding, setAdding] = (0,external_wp_element_namespaceObject.useState)(false);
15471 const [formName, setFormName] = (0,external_wp_element_namespaceObject.useState)('');
15472 /**
15473 * @type {[number|'', Function]}
15474 */
15475 const [formParent, setFormParent] = (0,external_wp_element_namespaceObject.useState)('');
15476 const [showForm, setShowForm] = (0,external_wp_element_namespaceObject.useState)(false);
15477 const [filterValue, setFilterValue] = (0,external_wp_element_namespaceObject.useState)('');
15478 const [filteredTermsTree, setFilteredTermsTree] = (0,external_wp_element_namespaceObject.useState)([]);
15479 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
15480 const {
15481 hasCreateAction,
15482 hasAssignAction,
15483 terms,
15484 loading,
15485 availableTerms,
15486 taxonomy
15487 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15488 var _post$_links, _post$_links2;
15489 const {
15490 getCurrentPost,
15491 getEditedPostAttribute
15492 } = select(store_store);
15493 const {
15494 getTaxonomy,
15495 getEntityRecords,
15496 isResolving
15497 } = select(external_wp_coreData_namespaceObject.store);
15498 const _taxonomy = getTaxonomy(slug);
15499 const post = getCurrentPost();
15500 return {
15501 hasCreateAction: _taxonomy ? (_post$_links = post._links?.['wp:action-create-' + _taxonomy.rest_base]) !== null && _post$_links !== void 0 ? _post$_links : false : false,
15502 hasAssignAction: _taxonomy ? (_post$_links2 = post._links?.['wp:action-assign-' + _taxonomy.rest_base]) !== null && _post$_links2 !== void 0 ? _post$_links2 : false : false,
15503 terms: _taxonomy ? getEditedPostAttribute(_taxonomy.rest_base) : hierarchical_term_selector_EMPTY_ARRAY,
15504 loading: isResolving('getEntityRecords', ['taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY]),
15505 availableTerms: getEntityRecords('taxonomy', slug, hierarchical_term_selector_DEFAULT_QUERY) || hierarchical_term_selector_EMPTY_ARRAY,
15506 taxonomy: _taxonomy
15507 };
15508 }, [slug]);
15509 const {
15510 editPost
15511 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
15512 const {
15513 saveEntityRecord
15514 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
15515 const availableTermsTree = (0,external_wp_element_namespaceObject.useMemo)(() => sortBySelected(buildTermsTree(availableTerms), terms),
15516 // Remove `terms` from the dependency list to avoid reordering every time
15517 // checking or unchecking a term.
15518 [availableTerms]);
15519 const {
15520 createErrorNotice
15521 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
15522 if (!hasAssignAction) {
15523 return null;
15524 }
15525
15526 /**
15527 * Append new term.
15528 *
15529 * @param {Object} term Term object.
15530 * @return {Promise} A promise that resolves to save term object.
15531 */
15532 const addTerm = term => {
15533 return saveEntityRecord('taxonomy', slug, term, {
15534 throwOnError: true
15535 });
15536 };
15537
15538 /**
15539 * Update terms for post.
15540 *
15541 * @param {number[]} termIds Term ids.
15542 */
15543 const onUpdateTerms = termIds => {
15544 editPost({
15545 [taxonomy.rest_base]: termIds
15546 });
15547 };
15548
15549 /**
15550 * Handler for checking term.
15551 *
15552 * @param {number} termId
15553 */
15554 const onChange = termId => {
15555 const hasTerm = terms.includes(termId);
15556 const newTerms = hasTerm ? terms.filter(id => id !== termId) : [...terms, termId];
15557 onUpdateTerms(newTerms);
15558 };
15559 const onChangeFormName = value => {
15560 setFormName(value);
15561 };
15562
15563 /**
15564 * Handler for changing form parent.
15565 *
15566 * @param {number|''} parentId Parent post id.
15567 */
15568 const onChangeFormParent = parentId => {
15569 setFormParent(parentId);
15570 };
15571 const onToggleForm = () => {
15572 setShowForm(!showForm);
15573 };
15574 const onAddTerm = async event => {
15575 var _taxonomy$labels$sing;
15576 event.preventDefault();
15577 if (formName === '' || adding) {
15578 return;
15579 }
15580
15581 // Check if the term we are adding already exists.
15582 const existingTerm = findTerm(availableTerms, formParent, formName);
15583 if (existingTerm) {
15584 // If the term we are adding exists but is not selected select it.
15585 if (!terms.some(term => term === existingTerm.id)) {
15586 onUpdateTerms([...terms, existingTerm.id]);
15587 }
15588 setFormName('');
15589 setFormParent('');
15590 return;
15591 }
15592 setAdding(true);
15593 let newTerm;
15594 try {
15595 newTerm = await addTerm({
15596 name: formName,
15597 parent: formParent ? formParent : undefined
15598 });
15599 } catch (error) {
15600 createErrorNotice(error.message, {
15601 type: 'snackbar'
15602 });
15603 return;
15604 }
15605 const defaultName = slug === 'category' ? (0,external_wp_i18n_namespaceObject.__)('Category') : (0,external_wp_i18n_namespaceObject.__)('Term');
15606 const termAddedMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: taxonomy name */
15607 (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);
15608 (0,external_wp_a11y_namespaceObject.speak)(termAddedMessage, 'assertive');
15609 setAdding(false);
15610 setFormName('');
15611 setFormParent('');
15612 onUpdateTerms([...terms, newTerm.id]);
15613 };
15614 const setFilter = value => {
15615 const newFilteredTermsTree = availableTermsTree.map(getFilterMatcher(value)).filter(term => term);
15616 const getResultCount = termsTree => {
15617 let count = 0;
15618 for (let i = 0; i < termsTree.length; i++) {
15619 count++;
15620 if (undefined !== termsTree[i].children) {
15621 count += getResultCount(termsTree[i].children);
15622 }
15623 }
15624 return count;
15625 };
15626 setFilterValue(value);
15627 setFilteredTermsTree(newFilteredTermsTree);
15628 const resultCount = getResultCount(newFilteredTermsTree);
15629 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of results */
15630 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', resultCount), resultCount);
15631 debouncedSpeak(resultsFoundMessage, 'assertive');
15632 };
15633 const renderTerms = renderedTerms => {
15634 return renderedTerms.map(term => {
15635 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
15636 className: "editor-post-taxonomies__hierarchical-terms-choice",
15637 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
15638 __nextHasNoMarginBottom: true,
15639 checked: terms.indexOf(term.id) !== -1,
15640 onChange: () => {
15641 const termId = parseInt(term.id, 10);
15642 onChange(termId);
15643 },
15644 label: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(term.name)
15645 }), !!term.children.length && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
15646 className: "editor-post-taxonomies__hierarchical-terms-subchoices",
15647 children: renderTerms(term.children)
15648 })]
15649 }, term.id);
15650 });
15651 };
15652 const labelWithFallback = (labelProperty, fallbackIsCategory, fallbackIsNotCategory) => {
15653 var _taxonomy$labels$labe;
15654 return (_taxonomy$labels$labe = taxonomy?.labels?.[labelProperty]) !== null && _taxonomy$labels$labe !== void 0 ? _taxonomy$labels$labe : slug === 'category' ? fallbackIsCategory : fallbackIsNotCategory;
15655 };
15656 const newTermButtonLabel = labelWithFallback('add_new_item', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term'));
15657 const newTermLabel = labelWithFallback('new_item_name', (0,external_wp_i18n_namespaceObject.__)('Add new category'), (0,external_wp_i18n_namespaceObject.__)('Add new term'));
15658 const parentSelectLabel = labelWithFallback('parent_item', (0,external_wp_i18n_namespaceObject.__)('Parent Category'), (0,external_wp_i18n_namespaceObject.__)('Parent Term'));
15659 const noParentOption = `— ${parentSelectLabel} —`;
15660 const newTermSubmitLabel = newTermButtonLabel;
15661 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');
15662 const groupLabel = (_taxonomy$name = taxonomy?.name) !== null && _taxonomy$name !== void 0 ? _taxonomy$name : (0,external_wp_i18n_namespaceObject.__)('Terms');
15663 const showFilter = availableTerms.length >= MIN_TERMS_COUNT_FOR_FILTER;
15664 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
15665 direction: "column",
15666 gap: "4",
15667 children: [showFilter && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
15668 __nextHasNoMarginBottom: true,
15669 label: filterLabel,
15670 value: filterValue,
15671 onChange: setFilter
15672 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
15673 className: "editor-post-taxonomies__hierarchical-terms-list",
15674 tabIndex: "0",
15675 role: "group",
15676 "aria-label": groupLabel,
15677 children: renderTerms('' !== filterValue ? filteredTermsTree : availableTermsTree)
15678 }), !loading && hasCreateAction && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
15679 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15680 onClick: onToggleForm,
15681 className: "editor-post-taxonomies__hierarchical-terms-add",
15682 "aria-expanded": showForm,
15683 variant: "link",
15684 children: newTermButtonLabel
15685 })
15686 }), showForm && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
15687 onSubmit: onAddTerm,
15688 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
15689 direction: "column",
15690 gap: "4",
15691 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
15692 __next40pxDefaultSize: true,
15693 __nextHasNoMarginBottom: true,
15694 className: "editor-post-taxonomies__hierarchical-terms-input",
15695 label: newTermLabel,
15696 value: formName,
15697 onChange: onChangeFormName,
15698 required: true
15699 }), !!availableTerms.length && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TreeSelect, {
15700 __next40pxDefaultSize: true,
15701 __nextHasNoMarginBottom: true,
15702 label: parentSelectLabel,
15703 noOptionLabel: noParentOption,
15704 onChange: onChangeFormParent,
15705 selectedId: formParent,
15706 tree: availableTermsTree
15707 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
15708 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15709 __next40pxDefaultSize: true,
15710 variant: "secondary",
15711 type: "submit",
15712 className: "editor-post-taxonomies__hierarchical-terms-submit",
15713 children: newTermSubmitLabel
15714 })
15715 })]
15716 })
15717 })]
15718 });
15719 }
15720 /* harmony default export */ const hierarchical_term_selector = ((0,external_wp_components_namespaceObject.withFilters)('editor.PostTaxonomyType')(HierarchicalTermSelector));
15721
15722 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/maybe-category-panel.js
15723 /**
15724 * WordPress dependencies
15725 */
15726
15727
15728
15729
15730
15731
15732 /**
15733 * Internal dependencies
15734 */
15735
15736
15737
15738
15739 function MaybeCategoryPanel() {
15740 const hasNoCategory = (0,external_wp_data_namespaceObject.useSelect)(select => {
15741 const postType = select(store_store).getCurrentPostType();
15742 const {
15743 canUser,
15744 getEntityRecord,
15745 getTaxonomy
15746 } = select(external_wp_coreData_namespaceObject.store);
15747 const categoriesTaxonomy = getTaxonomy('category');
15748 const defaultCategoryId = canUser('read', {
15749 kind: 'root',
15750 name: 'site'
15751 }) ? getEntityRecord('root', 'site')?.default_category : undefined;
15752 const defaultCategory = defaultCategoryId ? getEntityRecord('taxonomy', 'category', defaultCategoryId) : undefined;
15753 const postTypeSupportsCategories = categoriesTaxonomy && categoriesTaxonomy.types.some(type => type === postType);
15754 const categories = categoriesTaxonomy && select(store_store).getEditedPostAttribute(categoriesTaxonomy.rest_base);
15755
15756 // This boolean should return true if everything is loaded
15757 // ( categoriesTaxonomy, defaultCategory )
15758 // and the post has not been assigned a category different than "uncategorized".
15759 return !!categoriesTaxonomy && !!defaultCategory && postTypeSupportsCategories && (categories?.length === 0 || categories?.length === 1 && defaultCategory?.id === categories[0]);
15760 }, []);
15761 const [shouldShowPanel, setShouldShowPanel] = (0,external_wp_element_namespaceObject.useState)(false);
15762 (0,external_wp_element_namespaceObject.useEffect)(() => {
15763 // We use state to avoid hiding the panel if the user edits the categories
15764 // and adds one within the panel itself (while visible).
15765 if (hasNoCategory) {
15766 setShouldShowPanel(true);
15767 }
15768 }, [hasNoCategory]);
15769 if (!shouldShowPanel) {
15770 return null;
15771 }
15772 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
15773 className: "editor-post-publish-panel__link",
15774 children: (0,external_wp_i18n_namespaceObject.__)('Assign a category')
15775 }, "label")];
15776 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
15777 initialOpen: false,
15778 title: panelBodyTitle,
15779 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
15780 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.')
15781 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(hierarchical_term_selector, {
15782 slug: "category"
15783 })]
15784 });
15785 }
15786 /* harmony default export */ const maybe_category_panel = (MaybeCategoryPanel);
15787
15788 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/maybe-upload-media.js
15789 /**
15790 * WordPress dependencies
15791 */
15792
15793
15794
15795
15796
15797
15798
15799 /**
15800 * Internal dependencies
15801 */
15802
15803
15804
15805 function flattenBlocks(blocks) {
15806 const result = [];
15807 blocks.forEach(block => {
15808 result.push(block);
15809 result.push(...flattenBlocks(block.innerBlocks));
15810 });
15811 return result;
15812 }
15813 function Image(block) {
15814 const {
15815 selectBlock
15816 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
15817 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.img, {
15818 tabIndex: 0,
15819 role: "button",
15820 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Select image block.'),
15821 onClick: () => {
15822 selectBlock(block.clientId);
15823 },
15824 onKeyDown: event => {
15825 if (event.key === 'Enter' || event.key === ' ') {
15826 selectBlock(block.clientId);
15827 event.preventDefault();
15828 }
15829 },
15830 alt: block.attributes.alt,
15831 src: block.attributes.url,
15832 animate: {
15833 opacity: 1
15834 },
15835 exit: {
15836 opacity: 0,
15837 scale: 0
15838 },
15839 style: {
15840 width: '36px',
15841 height: '36px',
15842 objectFit: 'cover',
15843 borderRadius: '2px',
15844 cursor: 'pointer'
15845 },
15846 whileHover: {
15847 scale: 1.08
15848 }
15849 }, block.clientId);
15850 }
15851 function maybe_upload_media_PostFormatPanel() {
15852 const [isUploading, setIsUploading] = (0,external_wp_element_namespaceObject.useState)(false);
15853 const {
15854 editorBlocks,
15855 mediaUpload
15856 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
15857 editorBlocks: select(store_store).getEditorBlocks(),
15858 mediaUpload: select(external_wp_blockEditor_namespaceObject.store).getSettings().mediaUpload
15859 }), []);
15860 const externalImages = flattenBlocks(editorBlocks).filter(block => block.name === 'core/image' && block.attributes.url && !block.attributes.id);
15861 const {
15862 updateBlockAttributes
15863 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
15864 if (!mediaUpload || !externalImages.length) {
15865 return null;
15866 }
15867 const panelBodyTitle = [(0,external_wp_i18n_namespaceObject.__)('Suggestion:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
15868 className: "editor-post-publish-panel__link",
15869 children: (0,external_wp_i18n_namespaceObject.__)('External media')
15870 }, "label")];
15871 function uploadImages() {
15872 setIsUploading(true);
15873 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) => {
15874 mediaUpload({
15875 filesList: [blob],
15876 onFileChange: ([media]) => {
15877 if ((0,external_wp_blob_namespaceObject.isBlobURL)(media.url)) {
15878 return;
15879 }
15880 updateBlockAttributes(image.clientId, {
15881 id: media.id,
15882 url: media.url
15883 });
15884 resolve();
15885 },
15886 onError() {
15887 reject();
15888 }
15889 });
15890 })))).finally(() => {
15891 setIsUploading(false);
15892 });
15893 }
15894 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
15895 initialOpen: true,
15896 title: panelBodyTitle,
15897 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
15898 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.')
15899 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
15900 style: {
15901 display: 'inline-flex',
15902 flexWrap: 'wrap',
15903 gap: '8px'
15904 },
15905 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableAnimatePresence, {
15906 children: externalImages.map(image => {
15907 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Image, {
15908 ...image
15909 }, image.clientId);
15910 })
15911 }), isUploading ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {}) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
15912 variant: "primary",
15913 onClick: uploadImages,
15914 children: (0,external_wp_i18n_namespaceObject.__)('Upload')
15915 })]
15916 })]
15917 });
15918 }
15919
15920 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/prepublish.js
15921 /**
15922 * WordPress dependencies
15923 */
15924
15925
15926
15927
15928
15929
15930
15931
15932 /**
15933 * Internal dependencies
15934 */
15935
15936
15937
15938
15939
15940
15941
15942
15943
15944
15945
15946
15947 function PostPublishPanelPrepublish({
15948 children
15949 }) {
15950 const {
15951 isBeingScheduled,
15952 isRequestingSiteIcon,
15953 hasPublishAction,
15954 siteIconUrl,
15955 siteTitle,
15956 siteHome
15957 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
15958 var _getCurrentPost$_link;
15959 const {
15960 getCurrentPost,
15961 isEditedPostBeingScheduled
15962 } = select(store_store);
15963 const {
15964 getEntityRecord,
15965 isResolving
15966 } = select(external_wp_coreData_namespaceObject.store);
15967 const siteData = getEntityRecord('root', '__unstableBase', undefined) || {};
15968 return {
15969 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
15970 isBeingScheduled: isEditedPostBeingScheduled(),
15971 isRequestingSiteIcon: isResolving('getEntityRecord', ['root', '__unstableBase', undefined]),
15972 siteIconUrl: siteData.site_icon_url,
15973 siteTitle: siteData.name,
15974 siteHome: siteData.home && (0,external_wp_url_namespaceObject.filterURLForDisplay)(siteData.home)
15975 };
15976 }, []);
15977 let siteIcon = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
15978 className: "components-site-icon",
15979 size: "36px",
15980 icon: library_wordpress
15981 });
15982 if (siteIconUrl) {
15983 siteIcon = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("img", {
15984 alt: (0,external_wp_i18n_namespaceObject.__)('Site Icon'),
15985 className: "components-site-icon",
15986 src: siteIconUrl
15987 });
15988 }
15989 if (isRequestingSiteIcon) {
15990 siteIcon = null;
15991 }
15992 let prePublishTitle, prePublishBodyText;
15993 if (!hasPublishAction) {
15994 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to submit for review?');
15995 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.');
15996 } else if (isBeingScheduled) {
15997 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to schedule?');
15998 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Your work will be published at the specified date and time.');
15999 } else {
16000 prePublishTitle = (0,external_wp_i18n_namespaceObject.__)('Are you ready to publish?');
16001 prePublishBodyText = (0,external_wp_i18n_namespaceObject.__)('Double-check your settings before publishing.');
16002 }
16003 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16004 className: "editor-post-publish-panel__prepublish",
16005 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16006 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
16007 children: prePublishTitle
16008 })
16009 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
16010 children: prePublishBodyText
16011 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16012 className: "components-site-card",
16013 children: [siteIcon, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16014 className: "components-site-info",
16015 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16016 className: "components-site-name",
16017 children: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(siteTitle) || (0,external_wp_i18n_namespaceObject.__)('(Untitled)')
16018 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16019 className: "components-site-home",
16020 children: siteHome
16021 })]
16022 })]
16023 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(maybe_upload_media_PostFormatPanel, {}), hasPublishAction && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16024 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
16025 initialOpen: false,
16026 title: [(0,external_wp_i18n_namespaceObject.__)('Visibility:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16027 className: "editor-post-publish-panel__link",
16028 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibilityLabel, {})
16029 }, "label")],
16030 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostVisibility, {})
16031 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
16032 initialOpen: false,
16033 title: [(0,external_wp_i18n_namespaceObject.__)('Publish:'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
16034 className: "editor-post-publish-panel__link",
16035 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostScheduleLabel, {})
16036 }, "label")],
16037 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSchedule, {})
16038 })]
16039 }), /*#__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]
16040 });
16041 }
16042 /* harmony default export */ const prepublish = (PostPublishPanelPrepublish);
16043
16044 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/postpublish.js
16045 /**
16046 * WordPress dependencies
16047 */
16048
16049
16050
16051
16052
16053
16054
16055
16056
16057 /**
16058 * Internal dependencies
16059 */
16060
16061
16062
16063
16064
16065 const POSTNAME = '%postname%';
16066 const PAGENAME = '%pagename%';
16067
16068 /**
16069 * Returns URL for a future post.
16070 *
16071 * @param {Object} post Post object.
16072 *
16073 * @return {string} PostPublish URL.
16074 */
16075
16076 const getFuturePostUrl = post => {
16077 const {
16078 slug
16079 } = post;
16080 if (post.permalink_template.includes(POSTNAME)) {
16081 return post.permalink_template.replace(POSTNAME, slug);
16082 }
16083 if (post.permalink_template.includes(PAGENAME)) {
16084 return post.permalink_template.replace(PAGENAME, slug);
16085 }
16086 return post.permalink_template;
16087 };
16088 function postpublish_CopyButton({
16089 text,
16090 onCopy,
16091 children
16092 }) {
16093 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(text, onCopy);
16094 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16095 variant: "secondary",
16096 ref: ref,
16097 children: children
16098 });
16099 }
16100 class PostPublishPanelPostpublish extends external_wp_element_namespaceObject.Component {
16101 constructor() {
16102 super(...arguments);
16103 this.state = {
16104 showCopyConfirmation: false
16105 };
16106 this.onCopy = this.onCopy.bind(this);
16107 this.onSelectInput = this.onSelectInput.bind(this);
16108 this.postLink = (0,external_wp_element_namespaceObject.createRef)();
16109 }
16110 componentDidMount() {
16111 if (this.props.focusOnMount) {
16112 this.postLink.current.focus();
16113 }
16114 }
16115 componentWillUnmount() {
16116 clearTimeout(this.dismissCopyConfirmation);
16117 }
16118 onCopy() {
16119 this.setState({
16120 showCopyConfirmation: true
16121 });
16122 clearTimeout(this.dismissCopyConfirmation);
16123 this.dismissCopyConfirmation = setTimeout(() => {
16124 this.setState({
16125 showCopyConfirmation: false
16126 });
16127 }, 4000);
16128 }
16129 onSelectInput(event) {
16130 event.target.select();
16131 }
16132 render() {
16133 const {
16134 children,
16135 isScheduled,
16136 post,
16137 postType
16138 } = this.props;
16139 const postLabel = postType?.labels?.singular_name;
16140 const viewPostLabel = postType?.labels?.view_item;
16141 const addNewPostLabel = postType?.labels?.add_new_item;
16142 const link = post.status === 'future' ? getFuturePostUrl(post) : post.link;
16143 const addLink = (0,external_wp_url_namespaceObject.addQueryArgs)('post-new.php', {
16144 post_type: post.type
16145 });
16146 const postPublishNonLinkHeader = isScheduled ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16147 children: [(0,external_wp_i18n_namespaceObject.__)('is now scheduled. It will go live on'), ' ', /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostScheduleLabel, {}), "."]
16148 }) : (0,external_wp_i18n_namespaceObject.__)('is now live.');
16149 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16150 className: "post-publish-panel__postpublish",
16151 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
16152 className: "post-publish-panel__postpublish-header",
16153 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("a", {
16154 ref: this.postLink,
16155 href: link,
16156 children: (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(post.title) || (0,external_wp_i18n_namespaceObject.__)('(no title)')
16157 }), ' ', postPublishNonLinkHeader]
16158 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.PanelBody, {
16159 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
16160 className: "post-publish-panel__postpublish-subheader",
16161 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("strong", {
16162 children: (0,external_wp_i18n_namespaceObject.__)('What’s next?')
16163 })
16164 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16165 className: "post-publish-panel__postpublish-post-address-container",
16166 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
16167 __nextHasNoMarginBottom: true,
16168 className: "post-publish-panel__postpublish-post-address",
16169 readOnly: true,
16170 label: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: post type singular name */
16171 (0,external_wp_i18n_namespaceObject.__)('%s address'), postLabel),
16172 value: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(link),
16173 onFocus: this.onSelectInput
16174 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16175 className: "post-publish-panel__postpublish-post-address__copy-button-wrap",
16176 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(postpublish_CopyButton, {
16177 text: link,
16178 onCopy: this.onCopy,
16179 children: this.state.showCopyConfirmation ? (0,external_wp_i18n_namespaceObject.__)('Copied!') : (0,external_wp_i18n_namespaceObject.__)('Copy')
16180 })
16181 })]
16182 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16183 className: "post-publish-panel__postpublish-buttons",
16184 children: [!isScheduled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16185 variant: "primary",
16186 href: link,
16187 children: viewPostLabel
16188 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16189 variant: isScheduled ? 'primary' : 'secondary',
16190 href: addLink,
16191 children: addNewPostLabel
16192 })]
16193 })]
16194 }), children]
16195 });
16196 }
16197 }
16198 /* harmony default export */ const postpublish = ((0,external_wp_data_namespaceObject.withSelect)(select => {
16199 const {
16200 getEditedPostAttribute,
16201 getCurrentPost,
16202 isCurrentPostScheduled
16203 } = select(store_store);
16204 const {
16205 getPostType
16206 } = select(external_wp_coreData_namespaceObject.store);
16207 return {
16208 post: getCurrentPost(),
16209 postType: getPostType(getEditedPostAttribute('type')),
16210 isScheduled: isCurrentPostScheduled()
16211 };
16212 })(PostPublishPanelPostpublish));
16213
16214 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-panel/index.js
16215 /**
16216 * WordPress dependencies
16217 */
16218
16219
16220
16221
16222
16223
16224
16225
16226 /**
16227 * Internal dependencies
16228 */
16229
16230
16231
16232
16233
16234
16235
16236 class PostPublishPanel extends external_wp_element_namespaceObject.Component {
16237 constructor() {
16238 super(...arguments);
16239 this.onSubmit = this.onSubmit.bind(this);
16240 }
16241 componentDidUpdate(prevProps) {
16242 // Automatically collapse the publish sidebar when a post
16243 // is published and the user makes an edit.
16244 if (prevProps.isPublished && !this.props.isSaving && this.props.isDirty) {
16245 this.props.onClose();
16246 }
16247 }
16248 onSubmit() {
16249 const {
16250 onClose,
16251 hasPublishAction,
16252 isPostTypeViewable
16253 } = this.props;
16254 if (!hasPublishAction || !isPostTypeViewable) {
16255 onClose();
16256 }
16257 }
16258 render() {
16259 const {
16260 forceIsDirty,
16261 isBeingScheduled,
16262 isPublished,
16263 isPublishSidebarEnabled,
16264 isScheduled,
16265 isSaving,
16266 isSavingNonPostEntityChanges,
16267 onClose,
16268 onTogglePublishSidebar,
16269 PostPublishExtension,
16270 PrePublishExtension,
16271 ...additionalProps
16272 } = this.props;
16273 const {
16274 hasPublishAction,
16275 isDirty,
16276 isPostTypeViewable,
16277 ...propsForPanel
16278 } = additionalProps;
16279 const isPublishedOrScheduled = isPublished || isScheduled && isBeingScheduled;
16280 const isPrePublish = !isPublishedOrScheduled && !isSaving;
16281 const isPostPublish = isPublishedOrScheduled && !isSaving;
16282 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16283 className: "editor-post-publish-panel",
16284 ...propsForPanel,
16285 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16286 className: "editor-post-publish-panel__header",
16287 children: isPostPublish ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16288 onClick: onClose,
16289 icon: close_small,
16290 label: (0,external_wp_i18n_namespaceObject.__)('Close panel')
16291 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16292 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16293 className: "editor-post-publish-panel__header-publish-button",
16294 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_button, {
16295 focusOnMount: true,
16296 onSubmit: this.onSubmit,
16297 forceIsDirty: forceIsDirty
16298 })
16299 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16300 className: "editor-post-publish-panel__header-cancel-button",
16301 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16302 accessibleWhenDisabled: true,
16303 disabled: isSavingNonPostEntityChanges,
16304 onClick: onClose,
16305 variant: "secondary",
16306 size: "compact",
16307 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
16308 })
16309 })]
16310 })
16311 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
16312 className: "editor-post-publish-panel__content",
16313 children: [isPrePublish && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(prepublish, {
16314 children: PrePublishExtension && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrePublishExtension, {})
16315 }), isPostPublish && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(postpublish, {
16316 focusOnMount: true,
16317 children: PostPublishExtension && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPublishExtension, {})
16318 }), isSaving && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Spinner, {})]
16319 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16320 className: "editor-post-publish-panel__footer",
16321 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
16322 __nextHasNoMarginBottom: true,
16323 label: (0,external_wp_i18n_namespaceObject.__)('Always show pre-publish checks.'),
16324 checked: isPublishSidebarEnabled,
16325 onChange: onTogglePublishSidebar
16326 })
16327 })]
16328 });
16329 }
16330 }
16331
16332 /**
16333 * Renders a panel for publishing a post.
16334 */
16335 /* harmony default export */ const post_publish_panel = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
16336 var _getCurrentPost$_link;
16337 const {
16338 getPostType
16339 } = select(external_wp_coreData_namespaceObject.store);
16340 const {
16341 getCurrentPost,
16342 getEditedPostAttribute,
16343 isCurrentPostPublished,
16344 isCurrentPostScheduled,
16345 isEditedPostBeingScheduled,
16346 isEditedPostDirty,
16347 isAutosavingPost,
16348 isSavingPost,
16349 isSavingNonPostEntityChanges
16350 } = select(store_store);
16351 const {
16352 isPublishSidebarEnabled
16353 } = select(store_store);
16354 const postType = getPostType(getEditedPostAttribute('type'));
16355 return {
16356 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
16357 isPostTypeViewable: postType?.viewable,
16358 isBeingScheduled: isEditedPostBeingScheduled(),
16359 isDirty: isEditedPostDirty(),
16360 isPublished: isCurrentPostPublished(),
16361 isPublishSidebarEnabled: isPublishSidebarEnabled(),
16362 isSaving: isSavingPost() && !isAutosavingPost(),
16363 isSavingNonPostEntityChanges: isSavingNonPostEntityChanges(),
16364 isScheduled: isCurrentPostScheduled()
16365 };
16366 }), (0,external_wp_data_namespaceObject.withDispatch)((dispatch, {
16367 isPublishSidebarEnabled
16368 }) => {
16369 const {
16370 disablePublishSidebar,
16371 enablePublishSidebar
16372 } = dispatch(store_store);
16373 return {
16374 onTogglePublishSidebar: () => {
16375 if (isPublishSidebarEnabled) {
16376 disablePublishSidebar();
16377 } else {
16378 enablePublishSidebar();
16379 }
16380 }
16381 };
16382 }), external_wp_components_namespaceObject.withFocusReturn, external_wp_components_namespaceObject.withConstrainedTabbing])(PostPublishPanel));
16383
16384 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/cloud-upload.js
16385 /**
16386 * WordPress dependencies
16387 */
16388
16389
16390 const cloudUpload = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
16391 xmlns: "http://www.w3.org/2000/svg",
16392 viewBox: "0 0 24 24",
16393 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
16394 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"
16395 })
16396 });
16397 /* harmony default export */ const cloud_upload = (cloudUpload);
16398
16399 ;// CONCATENATED MODULE: ./packages/icons/build-module/icon/index.js
16400 /**
16401 * WordPress dependencies
16402 */
16403
16404
16405 /** @typedef {{icon: JSX.Element, size?: number} & import('@wordpress/primitives').SVGProps} IconProps */
16406
16407 /**
16408 * Return an SVG icon.
16409 *
16410 * @param {IconProps} props icon is the SVG component to render
16411 * size is a number specifiying the icon size in pixels
16412 * Other props will be passed to wrapped SVG component
16413 * @param {import('react').ForwardedRef<HTMLElement>} ref The forwarded ref to the SVG element.
16414 *
16415 * @return {JSX.Element} Icon component
16416 */
16417 function Icon({
16418 icon,
16419 size = 24,
16420 ...props
16421 }, ref) {
16422 return (0,external_wp_element_namespaceObject.cloneElement)(icon, {
16423 width: size,
16424 height: size,
16425 ...props,
16426 ref
16427 });
16428 }
16429 /* harmony default export */ const icon = ((0,external_wp_element_namespaceObject.forwardRef)(Icon));
16430
16431 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/cloud.js
16432 /**
16433 * WordPress dependencies
16434 */
16435
16436
16437 const cloud = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
16438 xmlns: "http://www.w3.org/2000/svg",
16439 viewBox: "0 0 24 24",
16440 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
16441 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"
16442 })
16443 });
16444 /* harmony default export */ const library_cloud = (cloud);
16445
16446 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/drafts.js
16447 /**
16448 * WordPress dependencies
16449 */
16450
16451
16452 const drafts = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
16453 xmlns: "http://www.w3.org/2000/svg",
16454 viewBox: "0 0 24 24",
16455 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
16456 fillRule: "evenodd",
16457 clipRule: "evenodd",
16458 d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm8 4a4 4 0 0 0 4-4H8a4 4 0 0 0 4 4Z"
16459 })
16460 });
16461 /* harmony default export */ const library_drafts = (drafts);
16462
16463 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/pending.js
16464 /**
16465 * WordPress dependencies
16466 */
16467
16468
16469 const pending = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
16470 xmlns: "http://www.w3.org/2000/svg",
16471 viewBox: "0 0 24 24",
16472 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
16473 fillRule: "evenodd",
16474 clipRule: "evenodd",
16475 d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm8 4a4 4 0 0 1-4-4h4V8a4 4 0 0 1 0 8Z"
16476 })
16477 });
16478 /* harmony default export */ const library_pending = (pending);
16479
16480 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/not-allowed.js
16481 /**
16482 * WordPress dependencies
16483 */
16484
16485
16486 const notAllowed = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
16487 xmlns: "http://www.w3.org/2000/svg",
16488 viewBox: "0 0 24 24",
16489 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
16490 fillRule: "evenodd",
16491 clipRule: "evenodd",
16492 d: "M12 18.5A6.5 6.5 0 0 1 6.93 7.931l9.139 9.138A6.473 6.473 0 0 1 12 18.5Zm5.123-2.498a6.5 6.5 0 0 0-9.124-9.124l9.124 9.124ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Z"
16493 })
16494 });
16495 /* harmony default export */ const not_allowed = (notAllowed);
16496
16497 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/scheduled.js
16498 /**
16499 * WordPress dependencies
16500 */
16501
16502
16503 const scheduled = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
16504 xmlns: "http://www.w3.org/2000/svg",
16505 viewBox: "0 0 24 24",
16506 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
16507 fillRule: "evenodd",
16508 clipRule: "evenodd",
16509 d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm9 1V8h-1.5v3.5h-2V13H13Z"
16510 })
16511 });
16512 /* harmony default export */ const library_scheduled = (scheduled);
16513
16514 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/published.js
16515 /**
16516 * WordPress dependencies
16517 */
16518
16519
16520 const published = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
16521 xmlns: "http://www.w3.org/2000/svg",
16522 viewBox: "0 0 24 24",
16523 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
16524 fillRule: "evenodd",
16525 clipRule: "evenodd",
16526 d: "M12 18.5a6.5 6.5 0 1 1 0-13 6.5 6.5 0 0 1 0 13ZM4 12a8 8 0 1 1 16 0 8 8 0 0 1-16 0Zm11.53-1.47-1.06-1.06L11 12.94l-1.47-1.47-1.06 1.06L11 15.06l4.53-4.53Z"
16527 })
16528 });
16529 /* harmony default export */ const library_published = (published);
16530
16531 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-sticky/check.js
16532 /**
16533 * WordPress dependencies
16534 */
16535
16536
16537 /**
16538 * Internal dependencies
16539 */
16540
16541
16542 /**
16543 * Wrapper component that renders its children only if post has a sticky action.
16544 *
16545 * @param {Object} props Props.
16546 * @param {Element} props.children Children to be rendered.
16547 *
16548 * @return {Component} The component to be rendered or null if post type is not 'post' or hasStickyAction is false.
16549 */
16550 function PostStickyCheck({
16551 children
16552 }) {
16553 const {
16554 hasStickyAction,
16555 postType
16556 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16557 var _post$_links$wpActio;
16558 const post = select(store_store).getCurrentPost();
16559 return {
16560 hasStickyAction: (_post$_links$wpActio = post._links?.['wp:action-sticky']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false,
16561 postType: select(store_store).getCurrentPostType()
16562 };
16563 }, []);
16564 if (postType !== 'post' || !hasStickyAction) {
16565 return null;
16566 }
16567 return children;
16568 }
16569
16570 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-sticky/index.js
16571 /**
16572 * WordPress dependencies
16573 */
16574
16575
16576
16577
16578 /**
16579 * Internal dependencies
16580 */
16581
16582
16583
16584 /**
16585 * Renders the PostSticky component. It provides a checkbox control for the sticky post feature.
16586 *
16587 * @return {Component} The component to be rendered.
16588 */
16589
16590 function PostSticky() {
16591 const postSticky = (0,external_wp_data_namespaceObject.useSelect)(select => {
16592 var _select$getEditedPost;
16593 return (_select$getEditedPost = select(store_store).getEditedPostAttribute('sticky')) !== null && _select$getEditedPost !== void 0 ? _select$getEditedPost : false;
16594 }, []);
16595 const {
16596 editPost
16597 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
16598 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostStickyCheck, {
16599 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
16600 className: "editor-post-sticky__checkbox-control",
16601 label: (0,external_wp_i18n_namespaceObject.__)('Sticky'),
16602 help: (0,external_wp_i18n_namespaceObject.__)('Pin this post to the top of the blog'),
16603 checked: postSticky,
16604 onChange: () => editPost({
16605 sticky: !postSticky
16606 }),
16607 __nextHasNoMarginBottom: true
16608 })
16609 });
16610 }
16611
16612 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-status/index.js
16613 /**
16614 * WordPress dependencies
16615 */
16616
16617
16618
16619
16620
16621
16622
16623
16624
16625 /**
16626 * Internal dependencies
16627 */
16628
16629
16630
16631
16632
16633
16634
16635
16636 const postStatusesInfo = {
16637 'auto-draft': {
16638 label: (0,external_wp_i18n_namespaceObject.__)('Draft'),
16639 icon: library_drafts
16640 },
16641 draft: {
16642 label: (0,external_wp_i18n_namespaceObject.__)('Draft'),
16643 icon: library_drafts
16644 },
16645 pending: {
16646 label: (0,external_wp_i18n_namespaceObject.__)('Pending'),
16647 icon: library_pending
16648 },
16649 private: {
16650 label: (0,external_wp_i18n_namespaceObject.__)('Private'),
16651 icon: not_allowed
16652 },
16653 future: {
16654 label: (0,external_wp_i18n_namespaceObject.__)('Scheduled'),
16655 icon: library_scheduled
16656 },
16657 publish: {
16658 label: (0,external_wp_i18n_namespaceObject.__)('Published'),
16659 icon: library_published
16660 }
16661 };
16662 const STATUS_OPTIONS = [{
16663 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16664 children: [(0,external_wp_i18n_namespaceObject.__)('Draft'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
16665 variant: "muted",
16666 size: 12,
16667 children: (0,external_wp_i18n_namespaceObject.__)('Not ready to publish.')
16668 })]
16669 }),
16670 value: 'draft'
16671 }, {
16672 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16673 children: [(0,external_wp_i18n_namespaceObject.__)('Pending'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
16674 variant: "muted",
16675 size: 12,
16676 children: (0,external_wp_i18n_namespaceObject.__)('Waiting for review before publishing.')
16677 })]
16678 }),
16679 value: 'pending'
16680 }, {
16681 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16682 children: [(0,external_wp_i18n_namespaceObject.__)('Private'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
16683 variant: "muted",
16684 size: 12,
16685 children: (0,external_wp_i18n_namespaceObject.__)('Only visible to site admins and editors.')
16686 })]
16687 }),
16688 value: 'private'
16689 }, {
16690 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16691 children: [(0,external_wp_i18n_namespaceObject.__)('Scheduled'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
16692 variant: "muted",
16693 size: 12,
16694 children: (0,external_wp_i18n_namespaceObject.__)('Publish automatically on a chosen date.')
16695 })]
16696 }),
16697 value: 'future'
16698 }, {
16699 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16700 children: [(0,external_wp_i18n_namespaceObject.__)('Published'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
16701 variant: "muted",
16702 size: 12,
16703 children: (0,external_wp_i18n_namespaceObject.__)('Visible to everyone.')
16704 })]
16705 }),
16706 value: 'publish'
16707 }];
16708 const DESIGN_POST_TYPES = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE, NAVIGATION_POST_TYPE];
16709 function PostStatus() {
16710 const {
16711 status,
16712 date,
16713 password,
16714 postId,
16715 postType,
16716 canEdit
16717 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16718 var _getCurrentPost$_link;
16719 const {
16720 getEditedPostAttribute,
16721 getCurrentPostId,
16722 getCurrentPostType,
16723 getCurrentPost
16724 } = select(store_store);
16725 return {
16726 status: getEditedPostAttribute('status'),
16727 date: getEditedPostAttribute('date'),
16728 password: getEditedPostAttribute('password'),
16729 postId: getCurrentPostId(),
16730 postType: getCurrentPostType(),
16731 canEdit: (_getCurrentPost$_link = getCurrentPost()._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false
16732 };
16733 }, []);
16734 const [showPassword, setShowPassword] = (0,external_wp_element_namespaceObject.useState)(!!password);
16735 const passwordInputId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostStatus, 'editor-change-status__password-input');
16736 const {
16737 editEntityRecord
16738 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
16739 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
16740 // Memoize popoverProps to avoid returning a new object every time.
16741 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
16742 // Anchor the popover to the middle of the entire row so that it doesn't
16743 // move around when the label changes.
16744 anchor: popoverAnchor,
16745 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
16746 headerTitle: (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
16747 placement: 'left-start',
16748 offset: 36,
16749 shift: true
16750 }), [popoverAnchor]);
16751 if (DESIGN_POST_TYPES.includes(postType)) {
16752 return null;
16753 }
16754 const updatePost = ({
16755 status: newStatus = status,
16756 password: newPassword = password,
16757 date: newDate = date
16758 }) => {
16759 editEntityRecord('postType', postType, postId, {
16760 status: newStatus,
16761 date: newDate,
16762 password: newPassword
16763 });
16764 };
16765 const handleTogglePassword = value => {
16766 setShowPassword(value);
16767 if (!value) {
16768 updatePost({
16769 password: ''
16770 });
16771 }
16772 };
16773 const handleStatus = value => {
16774 let newDate = date;
16775 let newPassword = password;
16776 if (status === 'future' && new Date(date) > new Date()) {
16777 newDate = null;
16778 }
16779 if (value === 'private' && password) {
16780 newPassword = '';
16781 }
16782 updatePost({
16783 status: value,
16784 date: newDate,
16785 password: newPassword
16786 });
16787 };
16788 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
16789 label: (0,external_wp_i18n_namespaceObject.__)('Status'),
16790 ref: setPopoverAnchor,
16791 children: canEdit ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
16792 className: "editor-post-status",
16793 contentClassName: "editor-change-status__content",
16794 popoverProps: popoverProps,
16795 focusOnMount: true,
16796 renderToggle: ({
16797 onToggle
16798 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
16799 variant: "tertiary",
16800 size: "compact",
16801 onClick: onToggle,
16802 icon: postStatusesInfo[status]?.icon,
16803 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
16804 // translators: %s: Current post status.
16805 (0,external_wp_i18n_namespaceObject.__)('Change post status: %s'), postStatusesInfo[status]?.label),
16806 children: postStatusesInfo[status]?.label
16807 }),
16808 renderContent: ({
16809 onClose
16810 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
16811 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
16812 title: (0,external_wp_i18n_namespaceObject.__)('Status & visibility'),
16813 onClose: onClose
16814 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
16815 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
16816 spacing: 4,
16817 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
16818 className: "editor-change-status__options",
16819 hideLabelFromVision: true,
16820 label: (0,external_wp_i18n_namespaceObject.__)('Status'),
16821 options: STATUS_OPTIONS,
16822 onChange: handleStatus,
16823 selected: status === 'auto-draft' ? 'draft' : status
16824 }), status === 'future' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16825 className: "editor-change-status__publish-date-wrapper",
16826 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostSchedule, {
16827 showPopoverHeaderActions: false,
16828 isCompact: true
16829 })
16830 }), status !== 'private' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
16831 as: "fieldset",
16832 spacing: 4,
16833 className: "editor-change-status__password-fieldset",
16834 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
16835 __nextHasNoMarginBottom: true,
16836 label: (0,external_wp_i18n_namespaceObject.__)('Password protected'),
16837 help: (0,external_wp_i18n_namespaceObject.__)('Only visible to those who know the password'),
16838 checked: showPassword,
16839 onChange: handleTogglePassword
16840 }), showPassword && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16841 className: "editor-change-status__password-input",
16842 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
16843 label: (0,external_wp_i18n_namespaceObject.__)('Password'),
16844 onChange: value => updatePost({
16845 password: value
16846 }),
16847 value: password,
16848 placeholder: (0,external_wp_i18n_namespaceObject.__)('Use a secure password'),
16849 type: "text",
16850 id: passwordInputId,
16851 __next40pxDefaultSize: true,
16852 __nextHasNoMarginBottom: true
16853 })
16854 })]
16855 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSticky, {})]
16856 })
16857 })]
16858 })
16859 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
16860 className: "editor-post-status is-read-only",
16861 children: postStatusesInfo[status]?.label
16862 })
16863 });
16864 }
16865
16866 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-saved-state/index.js
16867 /**
16868 * External dependencies
16869 */
16870
16871
16872 /**
16873 * WordPress dependencies
16874 */
16875
16876
16877
16878
16879
16880
16881
16882
16883
16884 /**
16885 * Internal dependencies
16886 */
16887
16888
16889
16890 /**
16891 * Component showing whether the post is saved or not and providing save
16892 * buttons.
16893 *
16894 * @param {Object} props Component props.
16895 * @param {?boolean} props.forceIsDirty Whether to force the post to be marked
16896 * as dirty.
16897 * @return {import('react').ComponentType} The component.
16898 */
16899
16900
16901 function PostSavedState({
16902 forceIsDirty
16903 }) {
16904 const [forceSavedMessage, setForceSavedMessage] = (0,external_wp_element_namespaceObject.useState)(false);
16905 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small');
16906 const {
16907 isAutosaving,
16908 isDirty,
16909 isNew,
16910 isPublished,
16911 isSaveable,
16912 isSaving,
16913 isScheduled,
16914 hasPublishAction,
16915 showIconLabels,
16916 postStatus,
16917 postStatusHasChanged
16918 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
16919 var _getCurrentPost$_link;
16920 const {
16921 isEditedPostNew,
16922 isCurrentPostPublished,
16923 isCurrentPostScheduled,
16924 isEditedPostDirty,
16925 isSavingPost,
16926 isEditedPostSaveable,
16927 getCurrentPost,
16928 isAutosavingPost,
16929 getEditedPostAttribute,
16930 getPostEdits
16931 } = select(store_store);
16932 const {
16933 get
16934 } = select(external_wp_preferences_namespaceObject.store);
16935 return {
16936 isAutosaving: isAutosavingPost(),
16937 isDirty: forceIsDirty || isEditedPostDirty(),
16938 isNew: isEditedPostNew(),
16939 isPublished: isCurrentPostPublished(),
16940 isSaving: isSavingPost(),
16941 isSaveable: isEditedPostSaveable(),
16942 isScheduled: isCurrentPostScheduled(),
16943 hasPublishAction: (_getCurrentPost$_link = getCurrentPost()?._links?.['wp:action-publish']) !== null && _getCurrentPost$_link !== void 0 ? _getCurrentPost$_link : false,
16944 showIconLabels: get('core', 'showIconLabels'),
16945 postStatus: getEditedPostAttribute('status'),
16946 postStatusHasChanged: !!getPostEdits()?.status
16947 };
16948 }, [forceIsDirty]);
16949 const isPending = postStatus === 'pending';
16950 const {
16951 savePost
16952 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
16953 const wasSaving = (0,external_wp_compose_namespaceObject.usePrevious)(isSaving);
16954 (0,external_wp_element_namespaceObject.useEffect)(() => {
16955 let timeoutId;
16956 if (wasSaving && !isSaving) {
16957 setForceSavedMessage(true);
16958 timeoutId = setTimeout(() => {
16959 setForceSavedMessage(false);
16960 }, 1000);
16961 }
16962 return () => clearTimeout(timeoutId);
16963 }, [isSaving]);
16964
16965 // Once the post has been submitted for review this button
16966 // is not needed for the contributor role.
16967 if (!hasPublishAction && isPending) {
16968 return null;
16969 }
16970
16971 // We shouldn't render the button if the post has not one of the following statuses: pending, draft, auto-draft.
16972 // The reason for this is that this button handles the `save as pending` and `save draft` actions.
16973 // An exception for this is when the post has a custom status and there should be a way to save changes without
16974 // having to publish. This should be handled better in the future when custom statuses have better support.
16975 // @see https://github.com/WordPress/gutenberg/issues/3144.
16976 const isIneligibleStatus = !['pending', 'draft', 'auto-draft'].includes(postStatus) && STATUS_OPTIONS.map(({
16977 value
16978 }) => value).includes(postStatus);
16979 if (isPublished || isScheduled || isIneligibleStatus || postStatusHasChanged && ['pending', 'draft'].includes(postStatus)) {
16980 return null;
16981 }
16982
16983 /* translators: button label text should, if possible, be under 16 characters. */
16984 const label = isPending ? (0,external_wp_i18n_namespaceObject.__)('Save as pending') : (0,external_wp_i18n_namespaceObject.__)('Save draft');
16985
16986 /* translators: button label text should, if possible, be under 16 characters. */
16987 const shortLabel = (0,external_wp_i18n_namespaceObject.__)('Save');
16988 const isSaved = forceSavedMessage || !isNew && !isDirty;
16989 const isSavedState = isSaving || isSaved;
16990 const isDisabled = isSaving || isSaved || !isSaveable;
16991 let text;
16992 if (isSaving) {
16993 text = isAutosaving ? (0,external_wp_i18n_namespaceObject.__)('Autosaving') : (0,external_wp_i18n_namespaceObject.__)('Saving');
16994 } else if (isSaved) {
16995 text = (0,external_wp_i18n_namespaceObject.__)('Saved');
16996 } else if (isLargeViewport) {
16997 text = label;
16998 } else if (showIconLabels) {
16999 text = shortLabel;
17000 }
17001
17002 // Use common Button instance for all saved states so that focus is not
17003 // lost.
17004 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Button, {
17005 className: isSaveable || isSaving ? dist_clsx({
17006 'editor-post-save-draft': !isSavedState,
17007 'editor-post-saved-state': isSavedState,
17008 'is-saving': isSaving,
17009 'is-autosaving': isAutosaving,
17010 'is-saved': isSaved,
17011 [(0,external_wp_components_namespaceObject.__unstableGetAnimateClassName)({
17012 type: 'loading'
17013 })]: isSaving
17014 }) : undefined,
17015 onClick: isDisabled ? undefined : () => savePost()
17016 /*
17017 * We want the tooltip to show the keyboard shortcut only when the
17018 * button does something, i.e. when it's not disabled.
17019 */,
17020 shortcut: isDisabled ? undefined : external_wp_keycodes_namespaceObject.displayShortcut.primary('s'),
17021 variant: "tertiary",
17022 size: "compact",
17023 icon: isLargeViewport ? undefined : cloud_upload,
17024 label: text || label,
17025 "aria-disabled": isDisabled,
17026 children: [isSavedState && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(icon, {
17027 icon: isSaved ? library_check : library_cloud
17028 }), text]
17029 });
17030 }
17031
17032 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-schedule/check.js
17033 /**
17034 * WordPress dependencies
17035 */
17036
17037
17038 /**
17039 * Internal dependencies
17040 */
17041
17042
17043 /**
17044 * Wrapper component that renders its children only if post has a publish action.
17045 *
17046 * @param {Object} props Props.
17047 * @param {Element} props.children Children to be rendered.
17048 *
17049 * @return {Component} - The component to be rendered or null if there is no publish action.
17050 */
17051 function PostScheduleCheck({
17052 children
17053 }) {
17054 const hasPublishAction = (0,external_wp_data_namespaceObject.useSelect)(select => {
17055 var _select$getCurrentPos;
17056 return (_select$getCurrentPos = select(store_store).getCurrentPost()._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false;
17057 }, []);
17058 if (!hasPublishAction) {
17059 return null;
17060 }
17061 return children;
17062 }
17063
17064 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-schedule/panel.js
17065 /**
17066 * WordPress dependencies
17067 */
17068
17069
17070
17071
17072
17073 /**
17074 * Internal dependencies
17075 */
17076
17077
17078
17079
17080
17081
17082
17083 const panel_DESIGN_POST_TYPES = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE, NAVIGATION_POST_TYPE];
17084
17085 /**
17086 * Renders the Post Schedule Panel component.
17087 *
17088 * @return {Component} The component to be rendered.
17089 */
17090 function PostSchedulePanel() {
17091 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
17092 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
17093 // Memoize popoverProps to avoid returning a new object every time.
17094 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
17095 // Anchor the popover to the middle of the entire row so that it doesn't
17096 // move around when the label changes.
17097 anchor: popoverAnchor,
17098 'aria-label': (0,external_wp_i18n_namespaceObject.__)('Change publish date'),
17099 placement: 'left-start',
17100 offset: 36,
17101 shift: true
17102 }), [popoverAnchor]);
17103 const label = usePostScheduleLabel();
17104 const fullLabel = usePostScheduleLabel({
17105 full: true
17106 });
17107 if (panel_DESIGN_POST_TYPES.includes(postType)) {
17108 return null;
17109 }
17110 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostScheduleCheck, {
17111 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
17112 label: (0,external_wp_i18n_namespaceObject.__)('Publish'),
17113 ref: setPopoverAnchor,
17114 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
17115 popoverProps: popoverProps,
17116 focusOnMount: true,
17117 className: "editor-post-schedule__panel-dropdown",
17118 contentClassName: "editor-post-schedule__dialog",
17119 renderToggle: ({
17120 onToggle,
17121 isOpen
17122 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
17123 size: "compact",
17124 className: "editor-post-schedule__dialog-toggle",
17125 variant: "tertiary",
17126 tooltipPosition: "middle left",
17127 onClick: onToggle,
17128 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
17129 // translators: %s: Current post date.
17130 (0,external_wp_i18n_namespaceObject.__)('Change date: %s'), label),
17131 label: fullLabel,
17132 showTooltip: label !== fullLabel,
17133 "aria-expanded": isOpen,
17134 children: label
17135 }),
17136 renderContent: ({
17137 onClose
17138 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSchedule, {
17139 onClose: onClose
17140 })
17141 })
17142 })
17143 });
17144 }
17145
17146 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-slug/check.js
17147 /**
17148 * Internal dependencies
17149 */
17150
17151
17152 /**
17153 * Wrapper component that renders its children only if the post type supports the slug.
17154 *
17155 * @param {Object} props Props.
17156 * @param {Element} props.children Children to be rendered.
17157 *
17158 * @return {Component} The component to be rendered.
17159 */
17160
17161 function PostSlugCheck({
17162 children
17163 }) {
17164 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
17165 supportKeys: "slug",
17166 children: children
17167 });
17168 }
17169
17170 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-slug/index.js
17171 /**
17172 * WordPress dependencies
17173 */
17174
17175
17176
17177
17178
17179
17180 /**
17181 * Internal dependencies
17182 */
17183
17184
17185
17186 function PostSlugControl() {
17187 const postSlug = (0,external_wp_data_namespaceObject.useSelect)(select => {
17188 return (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(select(store_store).getEditedPostSlug());
17189 }, []);
17190 const {
17191 editPost
17192 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17193 const [forceEmptyField, setForceEmptyField] = (0,external_wp_element_namespaceObject.useState)(false);
17194 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
17195 __nextHasNoMarginBottom: true,
17196 label: (0,external_wp_i18n_namespaceObject.__)('Slug'),
17197 autoComplete: "off",
17198 spellCheck: "false",
17199 value: forceEmptyField ? '' : postSlug,
17200 onChange: newValue => {
17201 editPost({
17202 slug: newValue
17203 });
17204 // When we delete the field the permalink gets
17205 // reverted to the original value.
17206 // The forceEmptyField logic allows the user to have
17207 // the field temporarily empty while typing.
17208 if (!newValue) {
17209 if (!forceEmptyField) {
17210 setForceEmptyField(true);
17211 }
17212 return;
17213 }
17214 if (forceEmptyField) {
17215 setForceEmptyField(false);
17216 }
17217 },
17218 onBlur: event => {
17219 editPost({
17220 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(event.target.value)
17221 });
17222 if (forceEmptyField) {
17223 setForceEmptyField(false);
17224 }
17225 },
17226 className: "editor-post-slug"
17227 });
17228 }
17229
17230 /**
17231 * Renders the PostSlug component. It provide a control for editing the post slug.
17232 *
17233 * @return {Component} The component to be rendered.
17234 */
17235 function PostSlug() {
17236 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSlugCheck, {
17237 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSlugControl, {})
17238 });
17239 }
17240
17241 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-switch-to-draft-button/index.js
17242 /**
17243 * WordPress dependencies
17244 */
17245
17246
17247
17248
17249
17250
17251 /**
17252 * Internal dependencies
17253 */
17254
17255
17256 /**
17257 * Renders a button component that allows the user to switch a post to draft status.
17258 *
17259 * @return {JSX.Element} The rendered component.
17260 */
17261
17262
17263
17264 function PostSwitchToDraftButton() {
17265 external_wp_deprecated_default()('wp.editor.PostSwitchToDraftButton', {
17266 since: '6.7',
17267 version: '6.9'
17268 });
17269 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
17270 const {
17271 editPost,
17272 savePost
17273 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17274 const {
17275 isSaving,
17276 isPublished,
17277 isScheduled
17278 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17279 const {
17280 isSavingPost,
17281 isCurrentPostPublished,
17282 isCurrentPostScheduled
17283 } = select(store_store);
17284 return {
17285 isSaving: isSavingPost(),
17286 isPublished: isCurrentPostPublished(),
17287 isScheduled: isCurrentPostScheduled()
17288 };
17289 }, []);
17290 const isDisabled = isSaving || !isPublished && !isScheduled;
17291 let alertMessage;
17292 let confirmButtonText;
17293 if (isPublished) {
17294 alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unpublish this post?');
17295 confirmButtonText = (0,external_wp_i18n_namespaceObject.__)('Unpublish');
17296 } else if (isScheduled) {
17297 alertMessage = (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to unschedule this post?');
17298 confirmButtonText = (0,external_wp_i18n_namespaceObject.__)('Unschedule');
17299 }
17300 const handleConfirm = () => {
17301 setShowConfirmDialog(false);
17302 editPost({
17303 status: 'draft'
17304 });
17305 savePost();
17306 };
17307 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
17308 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
17309 __next40pxDefaultSize: true,
17310 className: "editor-post-switch-to-draft",
17311 onClick: () => {
17312 if (!isDisabled) {
17313 setShowConfirmDialog(true);
17314 }
17315 },
17316 "aria-disabled": isDisabled,
17317 variant: "secondary",
17318 style: {
17319 flexGrow: '1',
17320 justifyContent: 'center'
17321 },
17322 children: (0,external_wp_i18n_namespaceObject.__)('Switch to draft')
17323 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
17324 isOpen: showConfirmDialog,
17325 onConfirm: handleConfirm,
17326 onCancel: () => setShowConfirmDialog(false),
17327 confirmButtonText: confirmButtonText,
17328 children: alertMessage
17329 })]
17330 });
17331 }
17332
17333 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-sync-status/index.js
17334 /**
17335 * WordPress dependencies
17336 */
17337
17338
17339
17340 /**
17341 * Internal dependencies
17342 */
17343
17344
17345
17346 /**
17347 * Renders the sync status of a post.
17348 *
17349 * @return {JSX.Element|null} The rendered sync status component.
17350 */
17351
17352 function PostSyncStatus() {
17353 const {
17354 syncStatus,
17355 postType
17356 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17357 const {
17358 getEditedPostAttribute
17359 } = select(store_store);
17360 const meta = getEditedPostAttribute('meta');
17361
17362 // When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead.
17363 const currentSyncStatus = meta?.wp_pattern_sync_status === 'unsynced' ? 'unsynced' : getEditedPostAttribute('wp_pattern_sync_status');
17364 return {
17365 syncStatus: currentSyncStatus,
17366 postType: getEditedPostAttribute('type')
17367 };
17368 });
17369 if (postType !== 'wp_block') {
17370 return null;
17371 }
17372 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
17373 label: (0,external_wp_i18n_namespaceObject.__)('Sync status'),
17374 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
17375 className: "editor-post-sync-status__value",
17376 children: syncStatus === 'unsynced' ? (0,external_wp_i18n_namespaceObject._x)('Not synced', 'pattern (singular)') : (0,external_wp_i18n_namespaceObject._x)('Synced', 'pattern (singular)')
17377 })
17378 });
17379 }
17380
17381 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/index.js
17382 /**
17383 * WordPress dependencies
17384 */
17385
17386
17387
17388
17389 /**
17390 * Internal dependencies
17391 */
17392
17393
17394
17395
17396 const post_taxonomies_identity = x => x;
17397 function PostTaxonomies({
17398 taxonomyWrapper = post_taxonomies_identity
17399 }) {
17400 const {
17401 postType,
17402 taxonomies
17403 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17404 return {
17405 postType: select(store_store).getCurrentPostType(),
17406 taxonomies: select(external_wp_coreData_namespaceObject.store).getTaxonomies({
17407 per_page: -1
17408 })
17409 };
17410 }, []);
17411 const visibleTaxonomies = (taxonomies !== null && taxonomies !== void 0 ? taxonomies : []).filter(taxonomy =>
17412 // In some circumstances .visibility can end up as undefined so optional chaining operator required.
17413 // https://github.com/WordPress/gutenberg/issues/40326
17414 taxonomy.types.includes(postType) && taxonomy.visibility?.show_ui);
17415 return visibleTaxonomies.map(taxonomy => {
17416 const TaxonomyComponent = taxonomy.hierarchical ? hierarchical_term_selector : flat_term_selector;
17417 const taxonomyComponentProps = {
17418 slug: taxonomy.slug,
17419 ...(taxonomy.hierarchical ? {} : {
17420 __nextHasNoMarginBottom: true
17421 })
17422 };
17423 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.Fragment, {
17424 children: taxonomyWrapper( /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TaxonomyComponent, {
17425 ...taxonomyComponentProps
17426 }), taxonomy)
17427 }, `taxonomy-${taxonomy.slug}`);
17428 });
17429 }
17430
17431 /**
17432 * Renders the taxonomies associated with a post.
17433 *
17434 * @param {Object} props The component props.
17435 * @param {Function} props.taxonomyWrapper The wrapper function for each taxonomy component.
17436 *
17437 * @return {Array} An array of JSX elements representing the visible taxonomies.
17438 */
17439 /* harmony default export */ const post_taxonomies = (PostTaxonomies);
17440
17441 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/check.js
17442 /**
17443 * WordPress dependencies
17444 */
17445
17446
17447
17448 /**
17449 * Internal dependencies
17450 */
17451
17452
17453 /**
17454 * Renders the children components only if the current post type has taxonomies.
17455 *
17456 * @param {Object} props The component props.
17457 * @param {Element} props.children The children components to render.
17458 *
17459 * @return {Component|null} The rendered children components or null if the current post type has no taxonomies.
17460 */
17461 function PostTaxonomiesCheck({
17462 children
17463 }) {
17464 const hasTaxonomies = (0,external_wp_data_namespaceObject.useSelect)(select => {
17465 const postType = select(store_store).getCurrentPostType();
17466 const taxonomies = select(external_wp_coreData_namespaceObject.store).getTaxonomies({
17467 per_page: -1
17468 });
17469 return taxonomies?.some(taxonomy => taxonomy.types.includes(postType));
17470 }, []);
17471 if (!hasTaxonomies) {
17472 return null;
17473 }
17474 return children;
17475 }
17476
17477 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-taxonomies/panel.js
17478 /**
17479 * WordPress dependencies
17480 */
17481
17482
17483
17484 /**
17485 * Internal dependencies
17486 */
17487
17488
17489
17490
17491 function TaxonomyPanel({
17492 taxonomy,
17493 children
17494 }) {
17495 const slug = taxonomy?.slug;
17496 const panelName = slug ? `taxonomy-panel-${slug}` : '';
17497 const {
17498 isEnabled,
17499 isOpened
17500 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17501 const {
17502 isEditorPanelEnabled,
17503 isEditorPanelOpened
17504 } = select(store_store);
17505 return {
17506 isEnabled: slug ? isEditorPanelEnabled(panelName) : false,
17507 isOpened: slug ? isEditorPanelOpened(panelName) : false
17508 };
17509 }, [panelName, slug]);
17510 const {
17511 toggleEditorPanelOpened
17512 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17513 if (!isEnabled) {
17514 return null;
17515 }
17516 const taxonomyMenuName = taxonomy?.labels?.menu_name;
17517 if (!taxonomyMenuName) {
17518 return null;
17519 }
17520 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
17521 title: taxonomyMenuName,
17522 opened: isOpened,
17523 onToggle: () => toggleEditorPanelOpened(panelName),
17524 children: children
17525 });
17526 }
17527 function panel_PostTaxonomies() {
17528 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTaxonomiesCheck, {
17529 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_taxonomies, {
17530 taxonomyWrapper: (content, taxonomy) => {
17531 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TaxonomyPanel, {
17532 taxonomy: taxonomy,
17533 children: content
17534 });
17535 }
17536 })
17537 });
17538 }
17539
17540 /**
17541 * Renders a panel for a specific taxonomy.
17542 *
17543 * @param {Object} props The component props.
17544 * @param {Object} props.taxonomy The taxonomy object.
17545 * @param {Element} props.children The child components.
17546 *
17547 * @return {Component} The rendered taxonomy panel.
17548 */
17549 /* harmony default export */ const post_taxonomies_panel = (panel_PostTaxonomies);
17550
17551 // EXTERNAL MODULE: ./node_modules/react-autosize-textarea/lib/index.js
17552 var lib = __webpack_require__(773);
17553 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-text-editor/index.js
17554 /**
17555 * External dependencies
17556 */
17557
17558
17559 /**
17560 * WordPress dependencies
17561 */
17562
17563
17564
17565
17566
17567
17568
17569
17570 /**
17571 * Internal dependencies
17572 */
17573
17574
17575 /**
17576 * Displays the Post Text Editor along with content in Visual and Text mode.
17577 *
17578 * @return {JSX.Element|null} The rendered PostTextEditor component.
17579 */
17580
17581
17582
17583 function PostTextEditor() {
17584 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(PostTextEditor);
17585 const {
17586 content,
17587 blocks,
17588 type,
17589 id
17590 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17591 const {
17592 getEditedEntityRecord
17593 } = select(external_wp_coreData_namespaceObject.store);
17594 const {
17595 getCurrentPostType,
17596 getCurrentPostId
17597 } = select(store_store);
17598 const _type = getCurrentPostType();
17599 const _id = getCurrentPostId();
17600 const editedRecord = getEditedEntityRecord('postType', _type, _id);
17601 return {
17602 content: editedRecord?.content,
17603 blocks: editedRecord?.blocks,
17604 type: _type,
17605 id: _id
17606 };
17607 }, []);
17608 const {
17609 editEntityRecord
17610 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
17611 // Replicates the logic found in getEditedPostContent().
17612 const value = (0,external_wp_element_namespaceObject.useMemo)(() => {
17613 if (content instanceof Function) {
17614 return content({
17615 blocks
17616 });
17617 } else if (blocks) {
17618 // If we have parsed blocks already, they should be our source of truth.
17619 // Parsing applies block deprecations and legacy block conversions that
17620 // unparsed content will not have.
17621 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocks);
17622 }
17623 return content;
17624 }, [content, blocks]);
17625 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
17626 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
17627 as: "label",
17628 htmlFor: `post-content-${instanceId}`,
17629 children: (0,external_wp_i18n_namespaceObject.__)('Type text or HTML')
17630 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(lib/* default */.Z, {
17631 autoComplete: "off",
17632 dir: "auto",
17633 value: value,
17634 onChange: event => {
17635 editEntityRecord('postType', type, id, {
17636 content: event.target.value,
17637 blocks: undefined,
17638 selection: undefined
17639 });
17640 },
17641 className: "editor-post-text-editor",
17642 id: `post-content-${instanceId}`,
17643 placeholder: (0,external_wp_i18n_namespaceObject.__)('Start writing with text or HTML')
17644 })]
17645 });
17646 }
17647
17648 ;// CONCATENATED MODULE: external ["wp","dom"]
17649 const external_wp_dom_namespaceObject = window["wp"]["dom"];
17650 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/constants.js
17651 const DEFAULT_CLASSNAMES = 'wp-block wp-block-post-title block-editor-block-list__block editor-post-title editor-post-title__input rich-text';
17652 const REGEXP_NEWLINES = /[\r\n]+/g;
17653
17654 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/use-post-title-focus.js
17655 /**
17656 * WordPress dependencies
17657 */
17658
17659
17660
17661 /**
17662 * Internal dependencies
17663 */
17664
17665
17666 /**
17667 * Custom hook that manages the focus behavior of the post title input field.
17668 *
17669 * @param {Element} forwardedRef - The forwarded ref for the input field.
17670 *
17671 * @return {Object} - The ref object.
17672 */
17673 function usePostTitleFocus(forwardedRef) {
17674 const ref = (0,external_wp_element_namespaceObject.useRef)();
17675 const {
17676 isCleanNewPost
17677 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17678 const {
17679 isCleanNewPost: _isCleanNewPost
17680 } = select(store_store);
17681 return {
17682 isCleanNewPost: _isCleanNewPost()
17683 };
17684 }, []);
17685 (0,external_wp_element_namespaceObject.useImperativeHandle)(forwardedRef, () => ({
17686 focus: () => {
17687 ref?.current?.focus();
17688 }
17689 }));
17690 (0,external_wp_element_namespaceObject.useEffect)(() => {
17691 if (!ref.current) {
17692 return;
17693 }
17694 const {
17695 defaultView
17696 } = ref.current.ownerDocument;
17697 const {
17698 name,
17699 parent
17700 } = defaultView;
17701 const ownerDocument = name === 'editor-canvas' ? parent.document : defaultView.document;
17702 const {
17703 activeElement,
17704 body
17705 } = ownerDocument;
17706
17707 // Only autofocus the title when the post is entirely empty. This should
17708 // only happen for a new post, which means we focus the title on new
17709 // post so the author can start typing right away, without needing to
17710 // click anything.
17711 if (isCleanNewPost && (!activeElement || body === activeElement)) {
17712 ref.current.focus();
17713 }
17714 }, [isCleanNewPost]);
17715 return {
17716 ref
17717 };
17718 }
17719
17720 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/use-post-title.js
17721 /**
17722 * WordPress dependencies
17723 */
17724
17725 /**
17726 * Internal dependencies
17727 */
17728
17729
17730 /**
17731 * Custom hook for managing the post title in the editor.
17732 *
17733 * @return {Object} An object containing the current title and a function to update the title.
17734 */
17735 function usePostTitle() {
17736 const {
17737 editPost
17738 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
17739 const {
17740 title
17741 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17742 const {
17743 getEditedPostAttribute
17744 } = select(store_store);
17745 return {
17746 title: getEditedPostAttribute('title')
17747 };
17748 }, []);
17749 function updateTitle(newTitle) {
17750 editPost({
17751 title: newTitle
17752 });
17753 }
17754 return {
17755 title,
17756 setTitle: updateTitle
17757 };
17758 }
17759
17760 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/index.js
17761 /**
17762 * External dependencies
17763 */
17764
17765 /**
17766 * WordPress dependencies
17767 */
17768
17769
17770
17771
17772
17773
17774
17775
17776
17777
17778
17779 /**
17780 * Internal dependencies
17781 */
17782
17783
17784
17785
17786
17787 function PostTitle(_, forwardedRef) {
17788 const {
17789 placeholder
17790 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
17791 const {
17792 getSettings
17793 } = select(external_wp_blockEditor_namespaceObject.store);
17794 const {
17795 titlePlaceholder
17796 } = getSettings();
17797 return {
17798 placeholder: titlePlaceholder
17799 };
17800 }, []);
17801 const [isSelected, setIsSelected] = (0,external_wp_element_namespaceObject.useState)(false);
17802 const {
17803 ref: focusRef
17804 } = usePostTitleFocus(forwardedRef);
17805 const {
17806 title,
17807 setTitle: onUpdate
17808 } = usePostTitle();
17809 const [selection, setSelection] = (0,external_wp_element_namespaceObject.useState)({});
17810 const {
17811 clearSelectedBlock,
17812 insertBlocks,
17813 insertDefaultBlock
17814 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
17815 function onChange(value) {
17816 onUpdate(value.replace(REGEXP_NEWLINES, ' '));
17817 }
17818 function onInsertBlockAfter(blocks) {
17819 insertBlocks(blocks, 0);
17820 }
17821 function onSelect() {
17822 setIsSelected(true);
17823 clearSelectedBlock();
17824 }
17825 function onUnselect() {
17826 setIsSelected(false);
17827 setSelection({});
17828 }
17829 function onEnterPress() {
17830 insertDefaultBlock(undefined, undefined, 0);
17831 }
17832 function onKeyDown(event) {
17833 if (event.keyCode === external_wp_keycodes_namespaceObject.ENTER) {
17834 event.preventDefault();
17835 onEnterPress();
17836 }
17837 }
17838 function onPaste(event) {
17839 const clipboardData = event.clipboardData;
17840 let plainText = '';
17841 let html = '';
17842 try {
17843 plainText = clipboardData.getData('text/plain');
17844 html = clipboardData.getData('text/html');
17845 } catch (error) {
17846 // Some browsers like UC Browser paste plain text by default and
17847 // don't support clipboardData at all, so allow default
17848 // behaviour.
17849 return;
17850 }
17851
17852 // Allows us to ask for this information when we get a report.
17853 window.console.log('Received HTML:\n\n', html);
17854 window.console.log('Received plain text:\n\n', plainText);
17855 const content = (0,external_wp_blocks_namespaceObject.pasteHandler)({
17856 HTML: html,
17857 plainText
17858 });
17859 event.preventDefault();
17860 if (!content.length) {
17861 return;
17862 }
17863 if (typeof content !== 'string') {
17864 const [firstBlock] = content;
17865 if (!title && (firstBlock.name === 'core/heading' || firstBlock.name === 'core/paragraph')) {
17866 // Strip HTML to avoid unwanted HTML being added to the title.
17867 // In the majority of cases it is assumed that HTML in the title
17868 // is undesirable.
17869 const contentNoHTML = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(firstBlock.attributes.content);
17870 onUpdate(contentNoHTML);
17871 onInsertBlockAfter(content.slice(1));
17872 } else {
17873 onInsertBlockAfter(content);
17874 }
17875 } else {
17876 const value = {
17877 ...(0,external_wp_richText_namespaceObject.create)({
17878 html: title
17879 }),
17880 ...selection
17881 };
17882
17883 // Strip HTML to avoid unwanted HTML being added to the title.
17884 // In the majority of cases it is assumed that HTML in the title
17885 // is undesirable.
17886 const contentNoHTML = (0,external_wp_dom_namespaceObject.__unstableStripHTML)(content);
17887 const newValue = (0,external_wp_richText_namespaceObject.insert)(value, (0,external_wp_richText_namespaceObject.create)({
17888 html: contentNoHTML
17889 }));
17890 onUpdate((0,external_wp_richText_namespaceObject.toHTMLString)({
17891 value: newValue
17892 }));
17893 setSelection({
17894 start: newValue.start,
17895 end: newValue.end
17896 });
17897 }
17898 }
17899 const decodedPlaceholder = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Add title');
17900 const {
17901 ref: richTextRef
17902 } = (0,external_wp_richText_namespaceObject.__unstableUseRichText)({
17903 value: title,
17904 onChange,
17905 placeholder: decodedPlaceholder,
17906 selectionStart: selection.start,
17907 selectionEnd: selection.end,
17908 onSelectionChange(newStart, newEnd) {
17909 setSelection(sel => {
17910 const {
17911 start,
17912 end
17913 } = sel;
17914 if (start === newStart && end === newEnd) {
17915 return sel;
17916 }
17917 return {
17918 start: newStart,
17919 end: newEnd
17920 };
17921 });
17922 },
17923 __unstableDisableFormats: false
17924 });
17925
17926 // The wp-block className is important for editor styles.
17927 // This same block is used in both the visual and the code editor.
17928 const className = dist_clsx(DEFAULT_CLASSNAMES, {
17929 'is-selected': isSelected
17930 });
17931 return (
17932 /*#__PURE__*/
17933 /* eslint-disable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
17934 (0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
17935 supportKeys: "title",
17936 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h1", {
17937 ref: (0,external_wp_compose_namespaceObject.useMergeRefs)([richTextRef, focusRef]),
17938 contentEditable: true,
17939 className: className,
17940 "aria-label": decodedPlaceholder,
17941 role: "textbox",
17942 "aria-multiline": "true",
17943 onFocus: onSelect,
17944 onBlur: onUnselect,
17945 onKeyDown: onKeyDown,
17946 onKeyPress: onUnselect,
17947 onPaste: onPaste
17948 })
17949 })
17950 /* eslint-enable jsx-a11y/heading-has-content, jsx-a11y/no-noninteractive-element-to-interactive-role */
17951 );
17952 }
17953
17954 /**
17955 * Renders the `PostTitle` component.
17956 *
17957 * @param {Object} _ Unused parameter.
17958 * @param {Element} forwardedRef Forwarded ref for the component.
17959 *
17960 * @return {Component} The rendered PostTitle component.
17961 */
17962 /* harmony default export */ const post_title = ((0,external_wp_element_namespaceObject.forwardRef)(PostTitle));
17963
17964 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-title/post-title-raw.js
17965 /**
17966 * External dependencies
17967 */
17968
17969
17970 /**
17971 * WordPress dependencies
17972 */
17973
17974
17975
17976
17977
17978
17979
17980 /**
17981 * Internal dependencies
17982 */
17983
17984
17985
17986
17987 /**
17988 * Renders a raw post title input field.
17989 *
17990 * @param {Object} _ Unused parameter.
17991 * @param {Element} forwardedRef Reference to the component's DOM node.
17992 *
17993 * @return {Component} The rendered component.
17994 */
17995
17996 function PostTitleRaw(_, forwardedRef) {
17997 const {
17998 placeholder
17999 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18000 const {
18001 getSettings
18002 } = select(external_wp_blockEditor_namespaceObject.store);
18003 const {
18004 titlePlaceholder
18005 } = getSettings();
18006 return {
18007 placeholder: titlePlaceholder
18008 };
18009 }, []);
18010 const [isSelected, setIsSelected] = (0,external_wp_element_namespaceObject.useState)(false);
18011 const {
18012 title,
18013 setTitle: onUpdate
18014 } = usePostTitle();
18015 const {
18016 ref: focusRef
18017 } = usePostTitleFocus(forwardedRef);
18018 function onChange(value) {
18019 onUpdate(value.replace(REGEXP_NEWLINES, ' '));
18020 }
18021 function onSelect() {
18022 setIsSelected(true);
18023 }
18024 function onUnselect() {
18025 setIsSelected(false);
18026 }
18027
18028 // The wp-block className is important for editor styles.
18029 // This same block is used in both the visual and the code editor.
18030 const className = dist_clsx(DEFAULT_CLASSNAMES, {
18031 'is-selected': isSelected,
18032 'is-raw-text': true
18033 });
18034 const decodedPlaceholder = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(placeholder) || (0,external_wp_i18n_namespaceObject.__)('Add title');
18035 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextareaControl, {
18036 ref: focusRef,
18037 value: title,
18038 onChange: onChange,
18039 onFocus: onSelect,
18040 onBlur: onUnselect,
18041 label: placeholder,
18042 className: className,
18043 placeholder: decodedPlaceholder,
18044 hideLabelFromVision: true,
18045 autoComplete: "off",
18046 dir: "auto",
18047 rows: 1,
18048 __nextHasNoMarginBottom: true
18049 });
18050 }
18051 /* harmony default export */ const post_title_raw = ((0,external_wp_element_namespaceObject.forwardRef)(PostTitleRaw));
18052
18053 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-trash/index.js
18054 /**
18055 * WordPress dependencies
18056 */
18057
18058
18059
18060
18061
18062 /**
18063 * Internal dependencies
18064 */
18065
18066
18067 /**
18068 * Displays the Post Trash Button and Confirm Dialog in the Editor.
18069 *
18070 * @return {JSX.Element|null} The rendered PostTrash component.
18071 */
18072
18073
18074
18075 function PostTrash() {
18076 const {
18077 isNew,
18078 isDeleting,
18079 postId
18080 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18081 const store = select(store_store);
18082 return {
18083 isNew: store.isEditedPostNew(),
18084 isDeleting: store.isDeletingPost(),
18085 postId: store.getCurrentPostId()
18086 };
18087 }, []);
18088 const {
18089 trashPost
18090 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
18091 const [showConfirmDialog, setShowConfirmDialog] = (0,external_wp_element_namespaceObject.useState)(false);
18092 if (isNew || !postId) {
18093 return null;
18094 }
18095 const handleConfirm = () => {
18096 setShowConfirmDialog(false);
18097 trashPost();
18098 };
18099 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
18100 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18101 __next40pxDefaultSize: true,
18102 className: "editor-post-trash",
18103 isDestructive: true,
18104 variant: "secondary",
18105 isBusy: isDeleting,
18106 "aria-disabled": isDeleting,
18107 onClick: isDeleting ? undefined : () => setShowConfirmDialog(true),
18108 children: (0,external_wp_i18n_namespaceObject.__)('Move to trash')
18109 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
18110 isOpen: showConfirmDialog,
18111 onConfirm: handleConfirm,
18112 onCancel: () => setShowConfirmDialog(false),
18113 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Move to trash'),
18114 size: "medium",
18115 children: (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to move this post to the trash?')
18116 })]
18117 });
18118 }
18119
18120 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-trash/check.js
18121 /**
18122 * WordPress dependencies
18123 */
18124
18125
18126
18127 /**
18128 * Internal dependencies
18129 */
18130
18131
18132 /**
18133 * Wrapper component that renders its children only if the post can trashed.
18134 *
18135 * @param {Object} props - The component props.
18136 * @param {Element} props.children - The child components to render.
18137 *
18138 * @return {Component|null} The rendered child components or null if the post can not trashed.
18139 */
18140 function PostTrashCheck({
18141 children
18142 }) {
18143 const {
18144 canTrashPost
18145 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18146 const {
18147 isEditedPostNew,
18148 getCurrentPostId,
18149 getCurrentPostType
18150 } = select(store_store);
18151 const {
18152 canUser
18153 } = select(external_wp_coreData_namespaceObject.store);
18154 const postType = getCurrentPostType();
18155 const postId = getCurrentPostId();
18156 const isNew = isEditedPostNew();
18157 const canUserDelete = !!postId ? canUser('delete', {
18158 kind: 'postType',
18159 name: postType,
18160 id: postId
18161 }) : false;
18162 return {
18163 canTrashPost: (!isNew || postId) && canUserDelete
18164 };
18165 }, []);
18166 if (!canTrashPost) {
18167 return null;
18168 }
18169 return children;
18170 }
18171
18172 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/copy-small.js
18173 /**
18174 * WordPress dependencies
18175 */
18176
18177
18178 const copySmall = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
18179 xmlns: "http://www.w3.org/2000/svg",
18180 viewBox: "0 0 24 24",
18181 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
18182 fillRule: "evenodd",
18183 clipRule: "evenodd",
18184 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"
18185 })
18186 });
18187 /* harmony default export */ const copy_small = (copySmall);
18188
18189 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-url/index.js
18190 /**
18191 * WordPress dependencies
18192 */
18193
18194
18195
18196
18197
18198
18199
18200
18201
18202
18203
18204 /**
18205 * Internal dependencies
18206 */
18207
18208
18209 /**
18210 * Renders the `PostURL` component.
18211 *
18212 * @example
18213 * ```jsx
18214 * <PostURL />
18215 * ```
18216 *
18217 * @param {Function} onClose Callback function to be executed when the popover is closed.
18218 *
18219 * @return {Component} The rendered PostURL component.
18220 */
18221
18222
18223 function PostURL({
18224 onClose
18225 }) {
18226 const {
18227 isEditable,
18228 postSlug,
18229 postLink,
18230 permalinkPrefix,
18231 permalinkSuffix,
18232 permalink
18233 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18234 var _post$_links$wpActio;
18235 const post = select(store_store).getCurrentPost();
18236 const postTypeSlug = select(store_store).getCurrentPostType();
18237 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
18238 const permalinkParts = select(store_store).getPermalinkParts();
18239 const hasPublishAction = (_post$_links$wpActio = post?._links?.['wp:action-publish']) !== null && _post$_links$wpActio !== void 0 ? _post$_links$wpActio : false;
18240 return {
18241 isEditable: select(store_store).isPermalinkEditable() && hasPublishAction,
18242 postSlug: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(select(store_store).getEditedPostSlug()),
18243 viewPostLabel: postType?.labels.view_item,
18244 postLink: post.link,
18245 permalinkPrefix: permalinkParts?.prefix,
18246 permalinkSuffix: permalinkParts?.suffix,
18247 permalink: (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(select(store_store).getPermalink())
18248 };
18249 }, []);
18250 const {
18251 editPost
18252 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
18253 const {
18254 createNotice
18255 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
18256 const [forceEmptyField, setForceEmptyField] = (0,external_wp_element_namespaceObject.useState)(false);
18257 const copyButtonRef = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(permalink, () => {
18258 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('Copied URL to clipboard.'), {
18259 isDismissible: true,
18260 type: 'snackbar'
18261 });
18262 });
18263 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18264 className: "editor-post-url",
18265 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
18266 title: (0,external_wp_i18n_namespaceObject.__)('Link'),
18267 onClose: onClose
18268 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
18269 spacing: 3,
18270 children: [isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18271 children: [(0,external_wp_i18n_namespaceObject.__)('Customize the last part of the URL. '), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
18272 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/page-post-settings-sidebar/#permalink'),
18273 children: (0,external_wp_i18n_namespaceObject.__)('Learn more.')
18274 })]
18275 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
18276 children: [isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControl, {
18277 __next40pxDefaultSize: true,
18278 prefix: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControlPrefixWrapper, {
18279 children: "/"
18280 }),
18281 suffix: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18282 icon: copy_small,
18283 ref: copyButtonRef,
18284 label: (0,external_wp_i18n_namespaceObject.__)('Copy')
18285 }),
18286 label: (0,external_wp_i18n_namespaceObject.__)('Link'),
18287 hideLabelFromVision: true,
18288 value: forceEmptyField ? '' : postSlug,
18289 autoComplete: "off",
18290 spellCheck: "false",
18291 type: "text",
18292 className: "editor-post-url__input",
18293 onChange: newValue => {
18294 editPost({
18295 slug: newValue
18296 });
18297 // When we delete the field the permalink gets
18298 // reverted to the original value.
18299 // The forceEmptyField logic allows the user to have
18300 // the field temporarily empty while typing.
18301 if (!newValue) {
18302 if (!forceEmptyField) {
18303 setForceEmptyField(true);
18304 }
18305 return;
18306 }
18307 if (forceEmptyField) {
18308 setForceEmptyField(false);
18309 }
18310 },
18311 onBlur: event => {
18312 editPost({
18313 slug: (0,external_wp_url_namespaceObject.cleanForSlug)(event.target.value)
18314 });
18315 if (forceEmptyField) {
18316 setForceEmptyField(false);
18317 }
18318 },
18319 help: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.ExternalLink, {
18320 className: "editor-post-url__link",
18321 href: postLink,
18322 target: "_blank",
18323 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18324 className: "editor-post-url__link-prefix",
18325 children: permalinkPrefix
18326 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18327 className: "editor-post-url__link-slug",
18328 children: postSlug
18329 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18330 className: "editor-post-url__link-suffix",
18331 children: permalinkSuffix
18332 })]
18333 })
18334 }), !isEditable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ExternalLink, {
18335 className: "editor-post-url__link",
18336 href: postLink,
18337 target: "_blank",
18338 children: postLink
18339 })]
18340 })]
18341 })]
18342 });
18343 }
18344
18345 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-url/check.js
18346 /**
18347 * WordPress dependencies
18348 */
18349
18350
18351
18352 /**
18353 * Internal dependencies
18354 */
18355
18356
18357 /**
18358 * Check if the post URL is valid and visible.
18359 *
18360 * @param {Object} props The component props.
18361 * @param {Element} props.children The child components.
18362 *
18363 * @return {Component|null} The child components if the post URL is valid and visible, otherwise null.
18364 */
18365 function PostURLCheck({
18366 children
18367 }) {
18368 const isVisible = (0,external_wp_data_namespaceObject.useSelect)(select => {
18369 const postTypeSlug = select(store_store).getCurrentPostType();
18370 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
18371 if (!postType?.viewable) {
18372 return false;
18373 }
18374 const post = select(store_store).getCurrentPost();
18375 if (!post.link) {
18376 return false;
18377 }
18378 const permalinkParts = select(store_store).getPermalinkParts();
18379 if (!permalinkParts) {
18380 return false;
18381 }
18382 return true;
18383 }, []);
18384 if (!isVisible) {
18385 return null;
18386 }
18387 return children;
18388 }
18389
18390 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-url/label.js
18391 /**
18392 * WordPress dependencies
18393 */
18394
18395
18396
18397 /**
18398 * Internal dependencies
18399 */
18400
18401
18402 /**
18403 * Represents a label component for a post URL.
18404 *
18405 * @return {Component} The PostURLLabel component.
18406 */
18407 function PostURLLabel() {
18408 return usePostURLLabel();
18409 }
18410
18411 /**
18412 * Custom hook to get the label for the post URL.
18413 *
18414 * @return {string} The filtered and decoded post URL label.
18415 */
18416 function usePostURLLabel() {
18417 const postLink = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getPermalink(), []);
18418 return (0,external_wp_url_namespaceObject.filterURLForDisplay)((0,external_wp_url_namespaceObject.safeDecodeURIComponent)(postLink));
18419 }
18420
18421 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-url/panel.js
18422 /**
18423 * WordPress dependencies
18424 */
18425
18426
18427
18428
18429
18430
18431
18432 /**
18433 * Internal dependencies
18434 */
18435
18436
18437
18438
18439
18440 /**
18441 * Renders the `PostURLPanel` component.
18442 *
18443 * @return {JSX.Element} The rendered PostURLPanel component.
18444 */
18445
18446
18447
18448 function PostURLPanel() {
18449 // Use internal state instead of a ref to make sure that the component
18450 // re-renders when the popover's anchor updates.
18451 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
18452 // Memoize popoverProps to avoid returning a new object every time.
18453 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
18454 // Anchor the popover to the middle of the entire row so that it doesn't
18455 // move around when the label changes.
18456 anchor: popoverAnchor,
18457 placement: 'left-start',
18458 offset: 36,
18459 shift: true
18460 }), [popoverAnchor]);
18461 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURLCheck, {
18462 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
18463 label: (0,external_wp_i18n_namespaceObject.__)('Link'),
18464 ref: setPopoverAnchor,
18465 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
18466 popoverProps: popoverProps,
18467 className: "editor-post-url__panel-dropdown",
18468 contentClassName: "editor-post-url__panel-dialog",
18469 focusOnMount: true,
18470 renderToggle: ({
18471 isOpen,
18472 onToggle
18473 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURLToggle, {
18474 isOpen: isOpen,
18475 onClick: onToggle
18476 }),
18477 renderContent: ({
18478 onClose
18479 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostURL, {
18480 onClose: onClose
18481 })
18482 })
18483 })
18484 });
18485 }
18486 function PostURLToggle({
18487 isOpen,
18488 onClick
18489 }) {
18490 const {
18491 slug,
18492 isFrontPage,
18493 postLink
18494 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18495 const {
18496 getCurrentPostId,
18497 getCurrentPost
18498 } = select(store_store);
18499 const {
18500 getEditedEntityRecord,
18501 canUser
18502 } = select(external_wp_coreData_namespaceObject.store);
18503 const siteSettings = canUser('read', {
18504 kind: 'root',
18505 name: 'site'
18506 }) ? getEditedEntityRecord('root', 'site') : undefined;
18507 const _id = getCurrentPostId();
18508 return {
18509 slug: select(store_store).getEditedPostSlug(),
18510 isFrontPage: siteSettings?.page_on_front === _id,
18511 postLink: getCurrentPost()?.link
18512 };
18513 }, []);
18514 const decodedSlug = (0,external_wp_url_namespaceObject.safeDecodeURIComponent)(slug);
18515 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18516 size: "compact",
18517 className: "editor-post-url__panel-toggle",
18518 variant: "tertiary",
18519 "aria-expanded": isOpen
18520 // translators: %s: Current post link.
18521 ,
18522 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)((0,external_wp_i18n_namespaceObject.__)('Change link: %s'), decodedSlug),
18523 onClick: onClick,
18524 children: isFrontPage ? postLink : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
18525 children: ["/", decodedSlug]
18526 })
18527 });
18528 }
18529
18530 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-visibility/check.js
18531 /**
18532 * WordPress dependencies
18533 */
18534
18535
18536 /**
18537 * Internal dependencies
18538 */
18539
18540
18541 /**
18542 * Determines if the current post can be edited (published)
18543 * and passes this information to the provided render function.
18544 *
18545 * @param {Object} props The component props.
18546 * @param {Function} props.render Function to render the component.
18547 * Receives an object with a `canEdit` property.
18548 * @return {JSX.Element} The rendered component.
18549 */
18550 function PostVisibilityCheck({
18551 render
18552 }) {
18553 const canEdit = (0,external_wp_data_namespaceObject.useSelect)(select => {
18554 var _select$getCurrentPos;
18555 return (_select$getCurrentPos = select(store_store).getCurrentPost()._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false;
18556 });
18557 return render({
18558 canEdit
18559 });
18560 }
18561
18562 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/info.js
18563 /**
18564 * WordPress dependencies
18565 */
18566
18567
18568 const info = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
18569 xmlns: "http://www.w3.org/2000/svg",
18570 viewBox: "0 0 24 24",
18571 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
18572 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"
18573 })
18574 });
18575 /* harmony default export */ const library_info = (info);
18576
18577 ;// CONCATENATED MODULE: external ["wp","wordcount"]
18578 const external_wp_wordcount_namespaceObject = window["wp"]["wordcount"];
18579 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/word-count/index.js
18580 /**
18581 * WordPress dependencies
18582 */
18583
18584
18585
18586
18587 /**
18588 * Internal dependencies
18589 */
18590
18591
18592 /**
18593 * Renders the word count of the post content.
18594 *
18595 * @return {JSX.Element|null} The rendered WordCount component.
18596 */
18597
18598 function WordCount() {
18599 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
18600
18601 /*
18602 * translators: If your word count is based on single characters (e.g. East Asian characters),
18603 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
18604 * Do not translate into your own language.
18605 */
18606 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
18607 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18608 className: "word-count",
18609 children: (0,external_wp_wordcount_namespaceObject.count)(content, wordCountType)
18610 });
18611 }
18612
18613 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/time-to-read/index.js
18614 /**
18615 * WordPress dependencies
18616 */
18617
18618
18619
18620
18621
18622 /**
18623 * Internal dependencies
18624 */
18625
18626
18627 /**
18628 * Average reading rate - based on average taken from
18629 * https://irisreading.com/average-reading-speed-in-various-languages/
18630 * (Characters/minute used for Chinese rather than words).
18631 *
18632 * @type {number} A rough estimate of the average reading rate across multiple languages.
18633 */
18634
18635 const AVERAGE_READING_RATE = 189;
18636
18637 /**
18638 * Component for showing Time To Read in Content.
18639 *
18640 * @return {JSX.Element} The rendered TimeToRead component.
18641 */
18642 function TimeToRead() {
18643 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
18644
18645 /*
18646 * translators: If your word count is based on single characters (e.g. East Asian characters),
18647 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
18648 * Do not translate into your own language.
18649 */
18650 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
18651 const minutesToRead = Math.round((0,external_wp_wordcount_namespaceObject.count)(content, wordCountType) / AVERAGE_READING_RATE);
18652 const minutesToReadString = minutesToRead === 0 ? (0,external_wp_element_namespaceObject.createInterpolateElement)((0,external_wp_i18n_namespaceObject.__)('<span>< 1</span> minute'), {
18653 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {})
18654 }) : (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. */
18655 (0,external_wp_i18n_namespaceObject._n)('<span>%d</span> minute', '<span>%d</span> minutes', minutesToRead), minutesToRead), {
18656 span: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {})
18657 });
18658 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18659 className: "time-to-read",
18660 children: minutesToReadString
18661 });
18662 }
18663
18664 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/character-count/index.js
18665 /**
18666 * WordPress dependencies
18667 */
18668
18669
18670
18671 /**
18672 * Internal dependencies
18673 */
18674
18675
18676 /**
18677 * Renders the character count of the post content.
18678 *
18679 * @return {number} The character count.
18680 */
18681 function CharacterCount() {
18682 const content = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('content'), []);
18683 return (0,external_wp_wordcount_namespaceObject.count)(content, 'characters_including_spaces');
18684 }
18685
18686 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/table-of-contents/panel.js
18687 /**
18688 * WordPress dependencies
18689 */
18690
18691
18692
18693
18694 /**
18695 * Internal dependencies
18696 */
18697
18698
18699
18700
18701
18702
18703
18704 function TableOfContentsPanel({
18705 hasOutlineItemsDisabled,
18706 onRequestClose
18707 }) {
18708 const {
18709 headingCount,
18710 paragraphCount,
18711 numberOfBlocks
18712 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
18713 const {
18714 getGlobalBlockCount
18715 } = select(external_wp_blockEditor_namespaceObject.store);
18716 return {
18717 headingCount: getGlobalBlockCount('core/heading'),
18718 paragraphCount: getGlobalBlockCount('core/paragraph'),
18719 numberOfBlocks: getGlobalBlockCount()
18720 };
18721 }, []);
18722 return (
18723 /*#__PURE__*/
18724 /*
18725 * Disable reason: The `list` ARIA role is redundant but
18726 * Safari+VoiceOver won't announce the list otherwise.
18727 */
18728 /* eslint-disable jsx-a11y/no-redundant-roles */
18729 (0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
18730 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
18731 className: "table-of-contents__wrapper",
18732 role: "note",
18733 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Document Statistics'),
18734 tabIndex: "0",
18735 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("ul", {
18736 role: "list",
18737 className: "table-of-contents__counts",
18738 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18739 className: "table-of-contents__count",
18740 children: [(0,external_wp_i18n_namespaceObject.__)('Words'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WordCount, {})]
18741 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18742 className: "table-of-contents__count",
18743 children: [(0,external_wp_i18n_namespaceObject.__)('Characters'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18744 className: "table-of-contents__number",
18745 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CharacterCount, {})
18746 })]
18747 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18748 className: "table-of-contents__count",
18749 children: [(0,external_wp_i18n_namespaceObject.__)('Time to read'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TimeToRead, {})]
18750 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18751 className: "table-of-contents__count",
18752 children: [(0,external_wp_i18n_namespaceObject.__)('Headings'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18753 className: "table-of-contents__number",
18754 children: headingCount
18755 })]
18756 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18757 className: "table-of-contents__count",
18758 children: [(0,external_wp_i18n_namespaceObject.__)('Paragraphs'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18759 className: "table-of-contents__number",
18760 children: paragraphCount
18761 })]
18762 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
18763 className: "table-of-contents__count",
18764 children: [(0,external_wp_i18n_namespaceObject.__)('Blocks'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
18765 className: "table-of-contents__number",
18766 children: numberOfBlocks
18767 })]
18768 })]
18769 })
18770 }), headingCount > 0 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
18771 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("hr", {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
18772 className: "table-of-contents__title",
18773 children: (0,external_wp_i18n_namespaceObject.__)('Document Outline')
18774 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DocumentOutline, {
18775 onSelect: onRequestClose,
18776 hasOutlineItemsDisabled: hasOutlineItemsDisabled
18777 })]
18778 })]
18779 })
18780 /* eslint-enable jsx-a11y/no-redundant-roles */
18781 );
18782 }
18783 /* harmony default export */ const table_of_contents_panel = (TableOfContentsPanel);
18784
18785 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/table-of-contents/index.js
18786 /**
18787 * WordPress dependencies
18788 */
18789
18790
18791
18792
18793
18794
18795
18796 /**
18797 * Internal dependencies
18798 */
18799
18800
18801 function TableOfContents({
18802 hasOutlineItemsDisabled,
18803 repositionDropdown,
18804 ...props
18805 }, ref) {
18806 const hasBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_blockEditor_namespaceObject.store).getBlockCount(), []);
18807 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
18808 popoverProps: {
18809 placement: repositionDropdown ? 'right' : 'bottom'
18810 },
18811 className: "table-of-contents",
18812 contentClassName: "table-of-contents__popover",
18813 renderToggle: ({
18814 isOpen,
18815 onToggle
18816 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
18817 ...props,
18818 ref: ref,
18819 onClick: hasBlocks ? onToggle : undefined,
18820 icon: library_info,
18821 "aria-expanded": isOpen,
18822 "aria-haspopup": "true"
18823 /* translators: button label text should, if possible, be under 16 characters. */,
18824 label: (0,external_wp_i18n_namespaceObject.__)('Details'),
18825 tooltipPosition: "bottom",
18826 "aria-disabled": !hasBlocks
18827 }),
18828 renderContent: ({
18829 onClose
18830 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(table_of_contents_panel, {
18831 onRequestClose: onClose,
18832 hasOutlineItemsDisabled: hasOutlineItemsDisabled
18833 })
18834 });
18835 }
18836
18837 /**
18838 * Renders a table of contents component.
18839 *
18840 * @param {Object} props The component props.
18841 * @param {boolean} props.hasOutlineItemsDisabled Whether outline items are disabled.
18842 * @param {boolean} props.repositionDropdown Whether to reposition the dropdown.
18843 * @param {Element.ref} ref The component's ref.
18844 *
18845 * @return {JSX.Element} The rendered table of contents component.
18846 */
18847 /* harmony default export */ const table_of_contents = ((0,external_wp_element_namespaceObject.forwardRef)(TableOfContents));
18848
18849 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/unsaved-changes-warning/index.js
18850 /**
18851 * WordPress dependencies
18852 */
18853
18854
18855
18856
18857
18858 /**
18859 * Warns the user if there are unsaved changes before leaving the editor.
18860 * Compatible with Post Editor and Site Editor.
18861 *
18862 * @return {Component} The component.
18863 */
18864 function UnsavedChangesWarning() {
18865 const {
18866 __experimentalGetDirtyEntityRecords
18867 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
18868 (0,external_wp_element_namespaceObject.useEffect)(() => {
18869 /**
18870 * Warns the user if there are unsaved changes before leaving the editor.
18871 *
18872 * @param {Event} event `beforeunload` event.
18873 *
18874 * @return {string | undefined} Warning prompt message, if unsaved changes exist.
18875 */
18876 const warnIfUnsavedChanges = event => {
18877 // We need to call the selector directly in the listener to avoid race
18878 // conditions with `BrowserURL` where `componentDidUpdate` gets the
18879 // new value of `isEditedPostDirty` before this component does,
18880 // causing this component to incorrectly think a trashed post is still dirty.
18881 const dirtyEntityRecords = __experimentalGetDirtyEntityRecords();
18882 if (dirtyEntityRecords.length > 0) {
18883 event.returnValue = (0,external_wp_i18n_namespaceObject.__)('You have unsaved changes. If you proceed, they will be lost.');
18884 return event.returnValue;
18885 }
18886 };
18887 window.addEventListener('beforeunload', warnIfUnsavedChanges);
18888 return () => {
18889 window.removeEventListener('beforeunload', warnIfUnsavedChanges);
18890 };
18891 }, [__experimentalGetDirtyEntityRecords]);
18892 return null;
18893 }
18894
18895 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/with-registry-provider.js
18896 /**
18897 * WordPress dependencies
18898 */
18899
18900
18901
18902
18903
18904 /**
18905 * Internal dependencies
18906 */
18907
18908
18909 function getSubRegistry(subRegistries, registry, useSubRegistry) {
18910 if (!useSubRegistry) {
18911 return registry;
18912 }
18913 let subRegistry = subRegistries.get(registry);
18914 if (!subRegistry) {
18915 subRegistry = (0,external_wp_data_namespaceObject.createRegistry)({
18916 'core/block-editor': external_wp_blockEditor_namespaceObject.storeConfig
18917 }, registry);
18918 // Todo: The interface store should also be created per instance.
18919 subRegistry.registerStore('core/editor', storeConfig);
18920 subRegistries.set(registry, subRegistry);
18921 }
18922 return subRegistry;
18923 }
18924 const withRegistryProvider = (0,external_wp_compose_namespaceObject.createHigherOrderComponent)(WrappedComponent => ({
18925 useSubRegistry = true,
18926 ...props
18927 }) => {
18928 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
18929 const [subRegistries] = (0,external_wp_element_namespaceObject.useState)(() => new WeakMap());
18930 const subRegistry = getSubRegistry(subRegistries, registry, useSubRegistry);
18931 if (subRegistry === registry) {
18932 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, {
18933 registry: registry,
18934 ...props
18935 });
18936 }
18937 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_data_namespaceObject.RegistryProvider, {
18938 value: subRegistry,
18939 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WrappedComponent, {
18940 registry: subRegistry,
18941 ...props
18942 })
18943 });
18944 }, 'withRegistryProvider');
18945 /* harmony default export */ const with_registry_provider = (withRegistryProvider);
18946
18947 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/media-categories/index.js
18948 /**
18949 * The `editor` settings here need to be in sync with the corresponding ones in `editor` package.
18950 * See `packages/editor/src/components/media-categories/index.js`.
18951 *
18952 * In the future we could consider creating an Openvese package that can be used in both `editor` and `site-editor`.
18953 * The rest of the settings would still need to be in sync though.
18954 */
18955
18956 /**
18957 * WordPress dependencies
18958 */
18959
18960
18961
18962
18963 /**
18964 * Internal dependencies
18965 */
18966
18967
18968 /** @typedef {import('@wordpress/block-editor').InserterMediaRequest} InserterMediaRequest */
18969 /** @typedef {import('@wordpress/block-editor').InserterMediaItem} InserterMediaItem */
18970 /** @typedef {import('@wordpress/block-editor').InserterMediaCategory} InserterMediaCategory */
18971
18972 const getExternalLink = (url, text) => `<a ${getExternalLinkAttributes(url)}>${text}</a>`;
18973 const getExternalLinkAttributes = url => `href="${url}" target="_blank" rel="noreferrer noopener"`;
18974 const getOpenverseLicense = (license, licenseVersion) => {
18975 let licenseName = license.trim();
18976 // PDM has no abbreviation
18977 if (license !== 'pdm') {
18978 licenseName = license.toUpperCase().replace('SAMPLING', 'Sampling');
18979 }
18980 // If version is known, append version to the name.
18981 // The license has to have a version to be valid. Only
18982 // PDM (public domain mark) doesn't have a version.
18983 if (licenseVersion) {
18984 licenseName += ` ${licenseVersion}`;
18985 }
18986 // For licenses other than public-domain marks, prepend 'CC' to the name.
18987 if (!['pdm', 'cc0'].includes(license)) {
18988 licenseName = `CC ${licenseName}`;
18989 }
18990 return licenseName;
18991 };
18992 const getOpenverseCaption = item => {
18993 const {
18994 title,
18995 foreign_landing_url: foreignLandingUrl,
18996 creator,
18997 creator_url: creatorUrl,
18998 license,
18999 license_version: licenseVersion,
19000 license_url: licenseUrl
19001 } = item;
19002 const fullLicense = getOpenverseLicense(license, licenseVersion);
19003 const _creator = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(creator);
19004 let _caption;
19005 if (_creator) {
19006 _caption = title ? (0,external_wp_i18n_namespaceObject.sprintf)(
19007 // 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".
19008 (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)(
19009 // 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".
19010 (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);
19011 } else {
19012 _caption = title ? (0,external_wp_i18n_namespaceObject.sprintf)(
19013 // translators: %1s: Title of a media work from Openverse; %2s: Work's licence e.g: "CC0 1.0".
19014 (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)(
19015 // translators: %1s: Link attributes for a given Openverse media work; %2s: Works's licence e.g: "CC0 1.0".
19016 (0,external_wp_i18n_namespaceObject._x)('<a %1$s>Work</a>/ %2$s', 'caption'), getExternalLinkAttributes(foreignLandingUrl), licenseUrl ? getExternalLink(`${licenseUrl}?ref=openverse`, fullLicense) : fullLicense);
19017 }
19018 return _caption.replace(/\s{2}/g, ' ');
19019 };
19020 const coreMediaFetch = async (query = {}) => {
19021 const mediaItems = await (0,external_wp_data_namespaceObject.resolveSelect)(external_wp_coreData_namespaceObject.store).getMediaItems({
19022 ...query,
19023 orderBy: !!query?.search ? 'relevance' : 'date'
19024 });
19025 return mediaItems.map(mediaItem => ({
19026 ...mediaItem,
19027 alt: mediaItem.alt_text,
19028 url: mediaItem.source_url,
19029 previewUrl: mediaItem.media_details?.sizes?.medium?.source_url,
19030 caption: mediaItem.caption?.raw
19031 }));
19032 };
19033
19034 /** @type {InserterMediaCategory[]} */
19035 const inserterMediaCategories = [{
19036 name: 'images',
19037 labels: {
19038 name: (0,external_wp_i18n_namespaceObject.__)('Images'),
19039 search_items: (0,external_wp_i18n_namespaceObject.__)('Search images')
19040 },
19041 mediaType: 'image',
19042 async fetch(query = {}) {
19043 return coreMediaFetch({
19044 ...query,
19045 media_type: 'image'
19046 });
19047 }
19048 }, {
19049 name: 'videos',
19050 labels: {
19051 name: (0,external_wp_i18n_namespaceObject.__)('Videos'),
19052 search_items: (0,external_wp_i18n_namespaceObject.__)('Search videos')
19053 },
19054 mediaType: 'video',
19055 async fetch(query = {}) {
19056 return coreMediaFetch({
19057 ...query,
19058 media_type: 'video'
19059 });
19060 }
19061 }, {
19062 name: 'audio',
19063 labels: {
19064 name: (0,external_wp_i18n_namespaceObject.__)('Audio'),
19065 search_items: (0,external_wp_i18n_namespaceObject.__)('Search audio')
19066 },
19067 mediaType: 'audio',
19068 async fetch(query = {}) {
19069 return coreMediaFetch({
19070 ...query,
19071 media_type: 'audio'
19072 });
19073 }
19074 }, {
19075 name: 'openverse',
19076 labels: {
19077 name: (0,external_wp_i18n_namespaceObject.__)('Openverse'),
19078 search_items: (0,external_wp_i18n_namespaceObject.__)('Search Openverse')
19079 },
19080 mediaType: 'image',
19081 async fetch(query = {}) {
19082 const defaultArgs = {
19083 mature: false,
19084 excluded_source: 'flickr,inaturalist,wikimedia',
19085 license: 'pdm,cc0'
19086 };
19087 const finalQuery = {
19088 ...query,
19089 ...defaultArgs
19090 };
19091 const mapFromInserterMediaRequest = {
19092 per_page: 'page_size',
19093 search: 'q'
19094 };
19095 const url = new URL('https://api.openverse.org/v1/images/');
19096 Object.entries(finalQuery).forEach(([key, value]) => {
19097 const queryKey = mapFromInserterMediaRequest[key] || key;
19098 url.searchParams.set(queryKey, value);
19099 });
19100 const response = await window.fetch(url, {
19101 headers: {
19102 'User-Agent': 'WordPress/inserter-media-fetch'
19103 }
19104 });
19105 const jsonResponse = await response.json();
19106 const results = jsonResponse.results;
19107 return results.map(result => ({
19108 ...result,
19109 // This is a temp solution for better titles, until Openverse API
19110 // completes the cleaning up of some titles of their upstream data.
19111 title: result.title?.toLowerCase().startsWith('file:') ? result.title.slice(5) : result.title,
19112 sourceId: result.id,
19113 id: undefined,
19114 caption: getOpenverseCaption(result),
19115 previewUrl: result.thumbnail
19116 }));
19117 },
19118 getReportUrl: ({
19119 sourceId
19120 }) => `https://wordpress.org/openverse/image/${sourceId}/report/`,
19121 isExternalResource: true
19122 }];
19123 /* harmony default export */ const media_categories = (inserterMediaCategories);
19124
19125 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/native.js
19126 const randomUUID = typeof crypto !== 'undefined' && crypto.randomUUID && crypto.randomUUID.bind(crypto);
19127 /* harmony default export */ const esm_browser_native = ({
19128 randomUUID
19129 });
19130 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/rng.js
19131 // Unique ID creation requires a high quality random # generator. In the browser we therefore
19132 // require the crypto API and do not support built-in fallback to lower quality random number
19133 // generators (like Math.random()).
19134 let getRandomValues;
19135 const rnds8 = new Uint8Array(16);
19136 function rng() {
19137 // lazy load so that environments that need to polyfill have a chance to do so
19138 if (!getRandomValues) {
19139 // getRandomValues needs to be invoked in a context where "this" is a Crypto implementation.
19140 getRandomValues = typeof crypto !== 'undefined' && crypto.getRandomValues && crypto.getRandomValues.bind(crypto);
19141
19142 if (!getRandomValues) {
19143 throw new Error('crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported');
19144 }
19145 }
19146
19147 return getRandomValues(rnds8);
19148 }
19149 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/stringify.js
19150
19151 /**
19152 * Convert array of 16 byte values to UUID string format of the form:
19153 * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX
19154 */
19155
19156 const byteToHex = [];
19157
19158 for (let i = 0; i < 256; ++i) {
19159 byteToHex.push((i + 0x100).toString(16).slice(1));
19160 }
19161
19162 function unsafeStringify(arr, offset = 0) {
19163 // Note: Be careful editing this code! It's been tuned for performance
19164 // and works in ways you may not expect. See https://github.com/uuidjs/uuid/pull/434
19165 return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + '-' + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + '-' + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + '-' + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + '-' + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
19166 }
19167
19168 function stringify(arr, offset = 0) {
19169 const uuid = unsafeStringify(arr, offset); // Consistency check for valid UUID. If this throws, it's likely due to one
19170 // of the following:
19171 // - One or more input array values don't map to a hex octet (leading to
19172 // "undefined" in the uuid)
19173 // - Invalid input values for the RFC `version` or `variant` fields
19174
19175 if (!validate(uuid)) {
19176 throw TypeError('Stringified UUID is invalid');
19177 }
19178
19179 return uuid;
19180 }
19181
19182 /* harmony default export */ const esm_browser_stringify = ((/* unused pure expression or super */ null && (stringify)));
19183 ;// CONCATENATED MODULE: ./node_modules/uuid/dist/esm-browser/v4.js
19184
19185
19186
19187
19188 function v4(options, buf, offset) {
19189 if (esm_browser_native.randomUUID && !buf && !options) {
19190 return esm_browser_native.randomUUID();
19191 }
19192
19193 options = options || {};
19194 const rnds = options.random || (options.rng || rng)(); // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
19195
19196 rnds[6] = rnds[6] & 0x0f | 0x40;
19197 rnds[8] = rnds[8] & 0x3f | 0x80; // Copy bytes to buffer, if provided
19198
19199 if (buf) {
19200 offset = offset || 0;
19201
19202 for (let i = 0; i < 16; ++i) {
19203 buf[offset + i] = rnds[i];
19204 }
19205
19206 return buf;
19207 }
19208
19209 return unsafeStringify(rnds);
19210 }
19211
19212 /* harmony default export */ const esm_browser_v4 = (v4);
19213 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/media-upload/index.js
19214 /**
19215 * External dependencies
19216 */
19217
19218
19219 /**
19220 * WordPress dependencies
19221 */
19222
19223
19224
19225 /**
19226 * Internal dependencies
19227 */
19228
19229 const media_upload_noop = () => {};
19230
19231 /**
19232 * Upload a media file when the file upload button is activated.
19233 * Wrapper around mediaUpload() that injects the current post ID.
19234 *
19235 * @param {Object} $0 Parameters object passed to the function.
19236 * @param {?Object} $0.additionalData Additional data to include in the request.
19237 * @param {string} $0.allowedTypes Array with the types of media that can be uploaded, if unset all types are allowed.
19238 * @param {Array} $0.filesList List of files.
19239 * @param {?number} $0.maxUploadFileSize Maximum upload size in bytes allowed for the site.
19240 * @param {Function} $0.onError Function called when an error happens.
19241 * @param {Function} $0.onFileChange Function called each time a file or a temporary representation of the file is available.
19242 */
19243 function mediaUpload({
19244 additionalData = {},
19245 allowedTypes,
19246 filesList,
19247 maxUploadFileSize,
19248 onError = media_upload_noop,
19249 onFileChange
19250 }) {
19251 const {
19252 getCurrentPost,
19253 getEditorSettings
19254 } = (0,external_wp_data_namespaceObject.select)(store_store);
19255 const {
19256 lockPostAutosaving,
19257 unlockPostAutosaving,
19258 lockPostSaving,
19259 unlockPostSaving
19260 } = (0,external_wp_data_namespaceObject.dispatch)(store_store);
19261 const wpAllowedMimeTypes = getEditorSettings().allowedMimeTypes;
19262 const lockKey = `image-upload-${esm_browser_v4()}`;
19263 let imageIsUploading = false;
19264 maxUploadFileSize = maxUploadFileSize || getEditorSettings().maxUploadFileSize;
19265 const currentPost = getCurrentPost();
19266 // Templates and template parts' numerical ID is stored in `wp_id`.
19267 const currentPostId = typeof currentPost?.id === 'number' ? currentPost.id : currentPost?.wp_id;
19268 const setSaveLock = () => {
19269 lockPostSaving(lockKey);
19270 lockPostAutosaving(lockKey);
19271 imageIsUploading = true;
19272 };
19273 const postData = currentPostId ? {
19274 post: currentPostId
19275 } : {};
19276 const clearSaveLock = () => {
19277 unlockPostSaving(lockKey);
19278 unlockPostAutosaving(lockKey);
19279 imageIsUploading = false;
19280 };
19281 (0,external_wp_mediaUtils_namespaceObject.uploadMedia)({
19282 allowedTypes,
19283 filesList,
19284 onFileChange: file => {
19285 if (!imageIsUploading) {
19286 setSaveLock();
19287 } else {
19288 clearSaveLock();
19289 }
19290 onFileChange(file);
19291 },
19292 additionalData: {
19293 ...postData,
19294 ...additionalData
19295 },
19296 maxUploadFileSize,
19297 onError: ({
19298 message
19299 }) => {
19300 clearSaveLock();
19301 onError(message);
19302 },
19303 wpAllowedMimeTypes
19304 });
19305 }
19306
19307 // EXTERNAL MODULE: ./node_modules/deepmerge/dist/cjs.js
19308 var cjs = __webpack_require__(1919);
19309 var cjs_default = /*#__PURE__*/__webpack_require__.n(cjs);
19310 ;// CONCATENATED MODULE: ./node_modules/is-plain-object/dist/is-plain-object.mjs
19311 /*!
19312 * is-plain-object <https://github.com/jonschlinkert/is-plain-object>
19313 *
19314 * Copyright (c) 2014-2017, Jon Schlinkert.
19315 * Released under the MIT License.
19316 */
19317
19318 function isObject(o) {
19319 return Object.prototype.toString.call(o) === '[object Object]';
19320 }
19321
19322 function isPlainObject(o) {
19323 var ctor,prot;
19324
19325 if (isObject(o) === false) return false;
19326
19327 // If has modified constructor
19328 ctor = o.constructor;
19329 if (ctor === undefined) return true;
19330
19331 // If has modified prototype
19332 prot = ctor.prototype;
19333 if (isObject(prot) === false) return false;
19334
19335 // If constructor does not have an Object-specific method
19336 if (prot.hasOwnProperty('isPrototypeOf') === false) {
19337 return false;
19338 }
19339
19340 // Most likely a plain Object
19341 return true;
19342 }
19343
19344
19345
19346 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/global-styles-provider/index.js
19347 /**
19348 * External dependencies
19349 */
19350
19351
19352
19353 /**
19354 * WordPress dependencies
19355 */
19356
19357
19358
19359
19360
19361 /**
19362 * Internal dependencies
19363 */
19364
19365
19366 const {
19367 GlobalStylesContext: global_styles_provider_GlobalStylesContext,
19368 cleanEmptyObject
19369 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
19370 function mergeBaseAndUserConfigs(base, user) {
19371 return cjs_default()(base, user, {
19372 // We only pass as arrays the presets,
19373 // in which case we want the new array of values
19374 // to override the old array (no merging).
19375 isMergeableObject: isPlainObject
19376 });
19377 }
19378 function useGlobalStylesUserConfig() {
19379 const {
19380 globalStylesId,
19381 isReady,
19382 settings,
19383 styles,
19384 _links
19385 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
19386 const {
19387 getEditedEntityRecord,
19388 hasFinishedResolution,
19389 canUser
19390 } = select(external_wp_coreData_namespaceObject.store);
19391 const _globalStylesId = select(external_wp_coreData_namespaceObject.store).__experimentalGetCurrentGlobalStylesId();
19392 const record = _globalStylesId && canUser('read', {
19393 kind: 'root',
19394 name: 'globalStyles',
19395 id: _globalStylesId
19396 }) ? getEditedEntityRecord('root', 'globalStyles', _globalStylesId) : undefined;
19397 let hasResolved = false;
19398 if (hasFinishedResolution('__experimentalGetCurrentGlobalStylesId')) {
19399 hasResolved = _globalStylesId ? hasFinishedResolution('getEditedEntityRecord', ['root', 'globalStyles', _globalStylesId]) : true;
19400 }
19401 return {
19402 globalStylesId: _globalStylesId,
19403 isReady: hasResolved,
19404 settings: record?.settings,
19405 styles: record?.styles,
19406 _links: record?._links
19407 };
19408 }, []);
19409 const {
19410 getEditedEntityRecord
19411 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
19412 const {
19413 editEntityRecord
19414 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
19415 const config = (0,external_wp_element_namespaceObject.useMemo)(() => {
19416 return {
19417 settings: settings !== null && settings !== void 0 ? settings : {},
19418 styles: styles !== null && styles !== void 0 ? styles : {},
19419 _links: _links !== null && _links !== void 0 ? _links : {}
19420 };
19421 }, [settings, styles, _links]);
19422 const setConfig = (0,external_wp_element_namespaceObject.useCallback)(
19423 /**
19424 * Set the global styles config.
19425 * @param {Function|Object} callbackOrObject If the callbackOrObject is a function, pass the current config to the callback so the consumer can merge values.
19426 * Otherwise, overwrite the current config with the incoming object.
19427 * @param {Object} options Options for editEntityRecord Core selector.
19428 */
19429 (callbackOrObject, options = {}) => {
19430 var _record$styles, _record$settings, _record$_links;
19431 const record = getEditedEntityRecord('root', 'globalStyles', globalStylesId);
19432 const currentConfig = {
19433 styles: (_record$styles = record?.styles) !== null && _record$styles !== void 0 ? _record$styles : {},
19434 settings: (_record$settings = record?.settings) !== null && _record$settings !== void 0 ? _record$settings : {},
19435 _links: (_record$_links = record?._links) !== null && _record$_links !== void 0 ? _record$_links : {}
19436 };
19437 const updatedConfig = typeof callbackOrObject === 'function' ? callbackOrObject(currentConfig) : callbackOrObject;
19438 editEntityRecord('root', 'globalStyles', globalStylesId, {
19439 styles: cleanEmptyObject(updatedConfig.styles) || {},
19440 settings: cleanEmptyObject(updatedConfig.settings) || {},
19441 _links: cleanEmptyObject(updatedConfig._links) || {}
19442 }, options);
19443 }, [globalStylesId, editEntityRecord, getEditedEntityRecord]);
19444 return [isReady, config, setConfig];
19445 }
19446 function useGlobalStylesBaseConfig() {
19447 const baseConfig = (0,external_wp_data_namespaceObject.useSelect)(select => {
19448 const {
19449 __experimentalGetCurrentThemeBaseGlobalStyles,
19450 canUser
19451 } = select(external_wp_coreData_namespaceObject.store);
19452 return canUser('read', {
19453 kind: 'root',
19454 name: 'theme'
19455 }) && __experimentalGetCurrentThemeBaseGlobalStyles();
19456 }, []);
19457 return [!!baseConfig, baseConfig];
19458 }
19459 function useGlobalStylesContext() {
19460 const [isUserConfigReady, userConfig, setUserConfig] = useGlobalStylesUserConfig();
19461 const [isBaseConfigReady, baseConfig] = useGlobalStylesBaseConfig();
19462 const mergedConfig = (0,external_wp_element_namespaceObject.useMemo)(() => {
19463 if (!baseConfig || !userConfig) {
19464 return {};
19465 }
19466 return mergeBaseAndUserConfigs(baseConfig, userConfig);
19467 }, [userConfig, baseConfig]);
19468 const context = (0,external_wp_element_namespaceObject.useMemo)(() => {
19469 return {
19470 isReady: isUserConfigReady && isBaseConfigReady,
19471 user: userConfig,
19472 base: baseConfig,
19473 merged: mergedConfig,
19474 setUserConfig
19475 };
19476 }, [mergedConfig, userConfig, baseConfig, setUserConfig, isUserConfigReady, isBaseConfigReady]);
19477 return context;
19478 }
19479 function GlobalStylesProvider({
19480 children
19481 }) {
19482 const context = useGlobalStylesContext();
19483 if (!context.isReady) {
19484 return null;
19485 }
19486 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(global_styles_provider_GlobalStylesContext.Provider, {
19487 value: context,
19488 children: children
19489 });
19490 }
19491
19492 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/use-block-editor-settings.js
19493 /**
19494 * WordPress dependencies
19495 */
19496
19497
19498
19499
19500
19501
19502
19503
19504
19505 /**
19506 * Internal dependencies
19507 */
19508
19509
19510
19511
19512
19513 const EMPTY_BLOCKS_LIST = [];
19514 const use_block_editor_settings_EMPTY_OBJECT = {};
19515 function __experimentalReusableBlocksSelect(select) {
19516 var _select$getEntityReco;
19517 return (_select$getEntityReco = select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', 'wp_block', {
19518 per_page: -1
19519 })) !== null && _select$getEntityReco !== void 0 ? _select$getEntityReco : EMPTY_BLOCKS_LIST;
19520 }
19521 const BLOCK_EDITOR_SETTINGS = ['__experimentalBlockDirectory', '__experimentalDiscussionSettings', '__experimentalFeatures', '__experimentalGlobalStylesBaseStyles', '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'];
19522 const {
19523 globalStylesDataKey,
19524 globalStylesLinksDataKey,
19525 selectBlockPatternsKey,
19526 reusableBlocksSelectKey
19527 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
19528
19529 /**
19530 * React hook used to compute the block editor settings to use for the post editor.
19531 *
19532 * @param {Object} settings EditorProvider settings prop.
19533 * @param {string} postType Editor root level post type.
19534 * @param {string} postId Editor root level post ID.
19535 * @param {string} renderingMode Editor rendering mode.
19536 *
19537 * @return {Object} Block Editor Settings.
19538 */
19539 function useBlockEditorSettings(settings, postType, postId, renderingMode) {
19540 var _mergedGlobalStyles$s, _mergedGlobalStyles$_, _settings$__experimen, _settings$__experimen2;
19541 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
19542 const {
19543 allowRightClickOverrides,
19544 blockTypes,
19545 focusMode,
19546 hasFixedToolbar,
19547 isDistractionFree,
19548 keepCaretInsideBlock,
19549 hasUploadPermissions,
19550 hiddenBlockTypes,
19551 canUseUnfilteredHTML,
19552 userCanCreatePages,
19553 pageOnFront,
19554 pageForPosts,
19555 userPatternCategories,
19556 restBlockPatternCategories,
19557 sectionRootClientId
19558 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
19559 var _canUser;
19560 const {
19561 canUser,
19562 getRawEntityRecord,
19563 getEntityRecord,
19564 getUserPatternCategories,
19565 getBlockPatternCategories
19566 } = select(external_wp_coreData_namespaceObject.store);
19567 const {
19568 get
19569 } = select(external_wp_preferences_namespaceObject.store);
19570 const {
19571 getBlockTypes
19572 } = select(external_wp_blocks_namespaceObject.store);
19573 const {
19574 getBlocksByName,
19575 getBlockAttributes
19576 } = select(external_wp_blockEditor_namespaceObject.store);
19577 const siteSettings = canUser('read', {
19578 kind: 'root',
19579 name: 'site'
19580 }) ? getEntityRecord('root', 'site') : undefined;
19581 function getSectionRootBlock() {
19582 var _getBlocksByName$find;
19583 if (renderingMode === 'template-locked') {
19584 var _getBlocksByName$;
19585 return (_getBlocksByName$ = getBlocksByName('core/post-content')?.[0]) !== null && _getBlocksByName$ !== void 0 ? _getBlocksByName$ : '';
19586 }
19587 return (_getBlocksByName$find = getBlocksByName('core/group').find(clientId => getBlockAttributes(clientId)?.tagName === 'main')) !== null && _getBlocksByName$find !== void 0 ? _getBlocksByName$find : '';
19588 }
19589 return {
19590 allowRightClickOverrides: get('core', 'allowRightClickOverrides'),
19591 blockTypes: getBlockTypes(),
19592 canUseUnfilteredHTML: getRawEntityRecord('postType', postType, postId)?._links?.hasOwnProperty('wp:action-unfiltered-html'),
19593 focusMode: get('core', 'focusMode'),
19594 hasFixedToolbar: get('core', 'fixedToolbar') || !isLargeViewport,
19595 hiddenBlockTypes: get('core', 'hiddenBlockTypes'),
19596 isDistractionFree: get('core', 'distractionFree'),
19597 keepCaretInsideBlock: get('core', 'keepCaretInsideBlock'),
19598 hasUploadPermissions: (_canUser = canUser('create', {
19599 kind: 'root',
19600 name: 'media'
19601 })) !== null && _canUser !== void 0 ? _canUser : true,
19602 userCanCreatePages: canUser('create', {
19603 kind: 'postType',
19604 name: 'page'
19605 }),
19606 pageOnFront: siteSettings?.page_on_front,
19607 pageForPosts: siteSettings?.page_for_posts,
19608 userPatternCategories: getUserPatternCategories(),
19609 restBlockPatternCategories: getBlockPatternCategories(),
19610 sectionRootClientId: getSectionRootBlock()
19611 };
19612 }, [postType, postId, isLargeViewport, renderingMode]);
19613 const {
19614 merged: mergedGlobalStyles
19615 } = useGlobalStylesContext();
19616 const globalStylesData = (_mergedGlobalStyles$s = mergedGlobalStyles.styles) !== null && _mergedGlobalStyles$s !== void 0 ? _mergedGlobalStyles$s : use_block_editor_settings_EMPTY_OBJECT;
19617 const globalStylesLinksData = (_mergedGlobalStyles$_ = mergedGlobalStyles._links) !== null && _mergedGlobalStyles$_ !== void 0 ? _mergedGlobalStyles$_ : use_block_editor_settings_EMPTY_OBJECT;
19618 const settingsBlockPatterns = (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen :
19619 // WP 6.0
19620 settings.__experimentalBlockPatterns; // WP 5.9
19621 const settingsBlockPatternCategories = (_settings$__experimen2 = settings.__experimentalAdditionalBlockPatternCategories) !== null && _settings$__experimen2 !== void 0 ? _settings$__experimen2 :
19622 // WP 6.0
19623 settings.__experimentalBlockPatternCategories; // WP 5.9
19624
19625 const blockPatterns = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatterns || [])].filter(({
19626 postTypes
19627 }) => {
19628 return !postTypes || Array.isArray(postTypes) && postTypes.includes(postType);
19629 }), [settingsBlockPatterns, postType]);
19630 const blockPatternCategories = (0,external_wp_element_namespaceObject.useMemo)(() => [...(settingsBlockPatternCategories || []), ...(restBlockPatternCategories || [])].filter((x, index, arr) => index === arr.findIndex(y => x.name === y.name)), [settingsBlockPatternCategories, restBlockPatternCategories]);
19631 const {
19632 undo,
19633 setIsInserterOpened
19634 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
19635 const {
19636 saveEntityRecord
19637 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
19638
19639 /**
19640 * Creates a Post entity.
19641 * This is utilised by the Link UI to allow for on-the-fly creation of Posts/Pages.
19642 *
19643 * @param {Object} options parameters for the post being created. These mirror those used on 3rd param of saveEntityRecord.
19644 * @return {Object} the post type object that was created.
19645 */
19646 const createPageEntity = (0,external_wp_element_namespaceObject.useCallback)(options => {
19647 if (!userCanCreatePages) {
19648 return Promise.reject({
19649 message: (0,external_wp_i18n_namespaceObject.__)('You do not have permission to create Pages.')
19650 });
19651 }
19652 return saveEntityRecord('postType', 'page', options);
19653 }, [saveEntityRecord, userCanCreatePages]);
19654 const allowedBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
19655 // Omit hidden block types if exists and non-empty.
19656 if (hiddenBlockTypes && hiddenBlockTypes.length > 0) {
19657 // Defer to passed setting for `allowedBlockTypes` if provided as
19658 // anything other than `true` (where `true` is equivalent to allow
19659 // all block types).
19660 const defaultAllowedBlockTypes = true === settings.allowedBlockTypes ? blockTypes.map(({
19661 name
19662 }) => name) : settings.allowedBlockTypes || [];
19663 return defaultAllowedBlockTypes.filter(type => !hiddenBlockTypes.includes(type));
19664 }
19665 return settings.allowedBlockTypes;
19666 }, [settings.allowedBlockTypes, hiddenBlockTypes, blockTypes]);
19667 const forceDisableFocusMode = settings.focusMode === false;
19668 return (0,external_wp_element_namespaceObject.useMemo)(() => {
19669 const blockEditorSettings = {
19670 ...Object.fromEntries(Object.entries(settings).filter(([key]) => BLOCK_EDITOR_SETTINGS.includes(key))),
19671 [globalStylesDataKey]: globalStylesData,
19672 [globalStylesLinksDataKey]: globalStylesLinksData,
19673 allowedBlockTypes,
19674 allowRightClickOverrides,
19675 focusMode: focusMode && !forceDisableFocusMode,
19676 hasFixedToolbar,
19677 isDistractionFree,
19678 keepCaretInsideBlock,
19679 mediaUpload: hasUploadPermissions ? mediaUpload : undefined,
19680 __experimentalBlockPatterns: blockPatterns,
19681 [selectBlockPatternsKey]: select => {
19682 const {
19683 hasFinishedResolution,
19684 getBlockPatternsForPostType
19685 } = unlock(select(external_wp_coreData_namespaceObject.store));
19686 const patterns = getBlockPatternsForPostType(postType);
19687 return hasFinishedResolution('getBlockPatterns') ? patterns : undefined;
19688 },
19689 [reusableBlocksSelectKey]: __experimentalReusableBlocksSelect,
19690 __experimentalBlockPatternCategories: blockPatternCategories,
19691 __experimentalUserPatternCategories: userPatternCategories,
19692 __experimentalFetchLinkSuggestions: (search, searchOptions) => (0,external_wp_coreData_namespaceObject.__experimentalFetchLinkSuggestions)(search, searchOptions, settings),
19693 inserterMediaCategories: media_categories,
19694 __experimentalFetchRichUrlData: external_wp_coreData_namespaceObject.__experimentalFetchUrlData,
19695 // Todo: This only checks the top level post, not the post within a template or any other entity that can be edited.
19696 // This might be better as a generic "canUser" selector.
19697 __experimentalCanUserUseUnfilteredHTML: canUseUnfilteredHTML,
19698 //Todo: this is only needed for native and should probably be removed.
19699 __experimentalUndo: undo,
19700 // Check whether we want all site editor frames to have outlines
19701 // including the navigation / pattern / parts editors.
19702 outlineMode: !isDistractionFree && postType === 'wp_template',
19703 // Check these two properties: they were not present in the site editor.
19704 __experimentalCreatePageEntity: createPageEntity,
19705 __experimentalUserCanCreatePages: userCanCreatePages,
19706 pageOnFront,
19707 pageForPosts,
19708 __experimentalPreferPatternsOnRoot: postType === 'wp_template',
19709 templateLock: postType === 'wp_navigation' ? 'insert' : settings.templateLock,
19710 template: postType === 'wp_navigation' ? [['core/navigation', {}, []]] : settings.template,
19711 __experimentalSetIsInserterOpened: setIsInserterOpened
19712 };
19713 lock(blockEditorSettings, {
19714 sectionRootClientId
19715 });
19716 return blockEditorSettings;
19717 }, [allowedBlockTypes, allowRightClickOverrides, focusMode, forceDisableFocusMode, hasFixedToolbar, isDistractionFree, keepCaretInsideBlock, settings, hasUploadPermissions, userPatternCategories, blockPatterns, blockPatternCategories, canUseUnfilteredHTML, undo, createPageEntity, userCanCreatePages, pageOnFront, pageForPosts, postType, setIsInserterOpened, sectionRootClientId, globalStylesData, globalStylesLinksData]);
19718 }
19719 /* harmony default export */ const use_block_editor_settings = (useBlockEditorSettings);
19720
19721 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/disable-non-page-content-blocks.js
19722 /**
19723 * WordPress dependencies
19724 */
19725
19726
19727
19728
19729 const DEFAULT_CONTENT_ONLY_BLOCKS = ['core/post-title', 'core/post-featured-image', 'core/post-content', 'core/template-part'];
19730
19731 /**
19732 * Component that when rendered, makes it so that the site editor allows only
19733 * page content to be edited.
19734 */
19735 function DisableNonPageContentBlocks() {
19736 const contentOnlyBlocks = (0,external_wp_hooks_namespaceObject.applyFilters)('editor.postContentBlockTypes', DEFAULT_CONTENT_ONLY_BLOCKS);
19737
19738 // Note that there are two separate subscription because the result for each
19739 // returns a new array.
19740 const contentOnlyIds = (0,external_wp_data_namespaceObject.useSelect)(select => {
19741 const {
19742 getBlocksByName,
19743 getBlockParents,
19744 getBlockName
19745 } = select(external_wp_blockEditor_namespaceObject.store);
19746 return getBlocksByName(contentOnlyBlocks).filter(clientId => getBlockParents(clientId).every(parentClientId => {
19747 const parentBlockName = getBlockName(parentClientId);
19748 return (
19749 // Ignore descendents of the query block.
19750 parentBlockName !== 'core/query' &&
19751 // Enable only the top-most block.
19752 !contentOnlyBlocks.includes(parentBlockName)
19753 );
19754 }));
19755 }, []);
19756 const disabledIds = (0,external_wp_data_namespaceObject.useSelect)(select => {
19757 const {
19758 getBlocksByName,
19759 getBlockOrder
19760 } = select(external_wp_blockEditor_namespaceObject.store);
19761 return getBlocksByName(['core/template-part']).flatMap(clientId => getBlockOrder(clientId));
19762 }, []);
19763 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
19764 (0,external_wp_element_namespaceObject.useEffect)(() => {
19765 const {
19766 setBlockEditingMode,
19767 unsetBlockEditingMode
19768 } = registry.dispatch(external_wp_blockEditor_namespaceObject.store);
19769 registry.batch(() => {
19770 setBlockEditingMode('', 'disabled');
19771 for (const clientId of contentOnlyIds) {
19772 setBlockEditingMode(clientId, 'contentOnly');
19773 }
19774 for (const clientId of disabledIds) {
19775 setBlockEditingMode(clientId, 'disabled');
19776 }
19777 });
19778 return () => {
19779 registry.batch(() => {
19780 unsetBlockEditingMode('');
19781 for (const clientId of contentOnlyIds) {
19782 unsetBlockEditingMode(clientId);
19783 }
19784 for (const clientId of disabledIds) {
19785 unsetBlockEditingMode(clientId);
19786 }
19787 });
19788 };
19789 }, [contentOnlyIds, disabledIds, registry]);
19790 return null;
19791 }
19792
19793 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/navigation-block-editing-mode.js
19794 /**
19795 * WordPress dependencies
19796 */
19797
19798
19799
19800
19801 /**
19802 * For the Navigation block editor, we need to force the block editor to contentOnly for that block.
19803 *
19804 * Set block editing mode to contentOnly when entering Navigation focus mode.
19805 * this ensures that non-content controls on the block will be hidden and thus
19806 * the user can focus on editing the Navigation Menu content only.
19807 */
19808
19809 function NavigationBlockEditingMode() {
19810 // In the navigation block editor,
19811 // the navigation block is the only root block.
19812 const blockClientId = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).getBlockOrder()?.[0], []);
19813 const {
19814 setBlockEditingMode,
19815 unsetBlockEditingMode
19816 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
19817 (0,external_wp_element_namespaceObject.useEffect)(() => {
19818 if (!blockClientId) {
19819 return;
19820 }
19821 setBlockEditingMode(blockClientId, 'contentOnly');
19822 return () => {
19823 unsetBlockEditingMode(blockClientId);
19824 };
19825 }, [blockClientId, unsetBlockEditingMode, setBlockEditingMode]);
19826 }
19827
19828 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/use-hide-blocks-from-inserter.js
19829 /**
19830 * WordPress dependencies
19831 */
19832
19833
19834
19835 // These post types are "structural" block lists.
19836 // We should be allowed to use
19837 // the post content and template parts blocks within them.
19838 const POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART = ['wp_block', 'wp_template', 'wp_template_part'];
19839
19840 /**
19841 * In some specific contexts,
19842 * the template part and post content blocks need to be hidden.
19843 *
19844 * @param {string} postType Post Type
19845 * @param {string} mode Rendering mode
19846 */
19847 function useHideBlocksFromInserter(postType, mode) {
19848 (0,external_wp_element_namespaceObject.useEffect)(() => {
19849 /*
19850 * Prevent adding template part in the editor.
19851 */
19852 (0,external_wp_hooks_namespaceObject.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter', (canInsert, blockType) => {
19853 if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(postType) && blockType.name === 'core/template-part' && mode === 'post-only') {
19854 return false;
19855 }
19856 return canInsert;
19857 });
19858
19859 /*
19860 * Prevent adding post content block (except in query block) in the editor.
19861 */
19862 (0,external_wp_hooks_namespaceObject.addFilter)('blockEditor.__unstableCanInsertBlockType', 'removePostContentFromInserter', (canInsert, blockType, rootClientId, {
19863 getBlockParentsByBlockName
19864 }) => {
19865 if (!POST_TYPES_ALLOWING_POST_CONTENT_TEMPLATE_PART.includes(postType) && blockType.name === 'core/post-content') {
19866 return getBlockParentsByBlockName(rootClientId, 'core/query').length > 0;
19867 }
19868 return canInsert;
19869 });
19870 return () => {
19871 (0,external_wp_hooks_namespaceObject.removeFilter)('blockEditor.__unstableCanInsertBlockType', 'removeTemplatePartsFromInserter');
19872 (0,external_wp_hooks_namespaceObject.removeFilter)('blockEditor.__unstableCanInsertBlockType', 'removePostContentFromInserter');
19873 };
19874 }, [postType, mode]);
19875 }
19876
19877 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/keyboard.js
19878 /**
19879 * WordPress dependencies
19880 */
19881
19882
19883
19884 const keyboard = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_primitives_namespaceObject.SVG, {
19885 xmlns: "http://www.w3.org/2000/svg",
19886 viewBox: "0 0 24 24",
19887 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19888 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"
19889 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19890 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"
19891 })]
19892 });
19893 /* harmony default export */ const library_keyboard = (keyboard);
19894
19895 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/list-view.js
19896 /**
19897 * WordPress dependencies
19898 */
19899
19900
19901 const listView = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19902 viewBox: "0 0 24 24",
19903 xmlns: "http://www.w3.org/2000/svg",
19904 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19905 d: "M3 6h11v1.5H3V6Zm3.5 5.5h11V13h-11v-1.5ZM21 17H10v1.5h11V17Z"
19906 })
19907 });
19908 /* harmony default export */ const list_view = (listView);
19909
19910 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/code.js
19911 /**
19912 * WordPress dependencies
19913 */
19914
19915
19916 const code = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19917 viewBox: "0 0 24 24",
19918 xmlns: "http://www.w3.org/2000/svg",
19919 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19920 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"
19921 })
19922 });
19923 /* harmony default export */ const library_code = (code);
19924
19925 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/drawer-left.js
19926 /**
19927 * WordPress dependencies
19928 */
19929
19930
19931 const drawerLeft = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19932 width: "24",
19933 height: "24",
19934 xmlns: "http://www.w3.org/2000/svg",
19935 viewBox: "0 0 24 24",
19936 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19937 fillRule: "evenodd",
19938 clipRule: "evenodd",
19939 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"
19940 })
19941 });
19942 /* harmony default export */ const drawer_left = (drawerLeft);
19943
19944 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/drawer-right.js
19945 /**
19946 * WordPress dependencies
19947 */
19948
19949
19950 const drawerRight = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19951 width: "24",
19952 height: "24",
19953 xmlns: "http://www.w3.org/2000/svg",
19954 viewBox: "0 0 24 24",
19955 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19956 fillRule: "evenodd",
19957 clipRule: "evenodd",
19958 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"
19959 })
19960 });
19961 /* harmony default export */ const drawer_right = (drawerRight);
19962
19963 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/block-default.js
19964 /**
19965 * WordPress dependencies
19966 */
19967
19968
19969 const blockDefault = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19970 xmlns: "http://www.w3.org/2000/svg",
19971 viewBox: "0 0 24 24",
19972 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19973 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"
19974 })
19975 });
19976 /* harmony default export */ const block_default = (blockDefault);
19977
19978 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/format-list-bullets.js
19979 /**
19980 * WordPress dependencies
19981 */
19982
19983
19984 const formatListBullets = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
19985 xmlns: "http://www.w3.org/2000/svg",
19986 viewBox: "0 0 24 24",
19987 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
19988 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"
19989 })
19990 });
19991 /* harmony default export */ const format_list_bullets = (formatListBullets);
19992
19993 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/external.js
19994 /**
19995 * WordPress dependencies
19996 */
19997
19998
19999 const external = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
20000 xmlns: "http://www.w3.org/2000/svg",
20001 viewBox: "0 0 24 24",
20002 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
20003 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"
20004 })
20005 });
20006 /* harmony default export */ const library_external = (external);
20007
20008 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/pencil.js
20009 /**
20010 * WordPress dependencies
20011 */
20012
20013
20014 const pencil = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
20015 xmlns: "http://www.w3.org/2000/svg",
20016 viewBox: "0 0 24 24",
20017 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
20018 d: "m19 7-3-3-8.5 8.5-1 4 4-1L19 7Zm-7 11.5H5V20h7v-1.5Z"
20019 })
20020 });
20021 /* harmony default export */ const library_pencil = (pencil);
20022
20023 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/edit.js
20024 /**
20025 * Internal dependencies
20026 */
20027
20028
20029 /* harmony default export */ const edit = (library_pencil);
20030
20031 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/pattern-rename-modal/index.js
20032 /**
20033 * WordPress dependencies
20034 */
20035
20036
20037
20038
20039
20040 /**
20041 * Internal dependencies
20042 */
20043
20044
20045
20046
20047 const {
20048 RenamePatternModal
20049 } = unlock(external_wp_patterns_namespaceObject.privateApis);
20050 const modalName = 'editor/pattern-rename';
20051 function PatternRenameModal() {
20052 const {
20053 record,
20054 postType
20055 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20056 const {
20057 getCurrentPostType,
20058 getCurrentPostId
20059 } = select(store_store);
20060 const {
20061 getEditedEntityRecord
20062 } = select(external_wp_coreData_namespaceObject.store);
20063 const _postType = getCurrentPostType();
20064 return {
20065 record: getEditedEntityRecord('postType', _postType, getCurrentPostId()),
20066 postType: _postType
20067 };
20068 }, []);
20069 const {
20070 closeModal
20071 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20072 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(modalName));
20073 if (!isActive || postType !== PATTERN_POST_TYPE) {
20074 return null;
20075 }
20076 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(RenamePatternModal, {
20077 onClose: closeModal,
20078 pattern: record
20079 });
20080 }
20081
20082 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/pattern-duplicate-modal/index.js
20083 /**
20084 * WordPress dependencies
20085 */
20086
20087
20088
20089
20090
20091 /**
20092 * Internal dependencies
20093 */
20094
20095
20096
20097
20098 const {
20099 DuplicatePatternModal
20100 } = unlock(external_wp_patterns_namespaceObject.privateApis);
20101 const pattern_duplicate_modal_modalName = 'editor/pattern-duplicate';
20102 function PatternDuplicateModal() {
20103 const {
20104 record,
20105 postType
20106 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20107 const {
20108 getCurrentPostType,
20109 getCurrentPostId
20110 } = select(store_store);
20111 const {
20112 getEditedEntityRecord
20113 } = select(external_wp_coreData_namespaceObject.store);
20114 const _postType = getCurrentPostType();
20115 return {
20116 record: getEditedEntityRecord('postType', _postType, getCurrentPostId()),
20117 postType: _postType
20118 };
20119 }, []);
20120 const {
20121 closeModal
20122 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20123 const isActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(pattern_duplicate_modal_modalName));
20124 if (!isActive || postType !== PATTERN_POST_TYPE) {
20125 return null;
20126 }
20127 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DuplicatePatternModal, {
20128 onClose: closeModal,
20129 onSuccess: () => closeModal(),
20130 pattern: record
20131 });
20132 }
20133
20134 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/commands/index.js
20135 /**
20136 * WordPress dependencies
20137 */
20138
20139
20140
20141
20142
20143
20144
20145
20146
20147
20148 /**
20149 * Internal dependencies
20150 */
20151
20152
20153
20154
20155 function useEditorCommandLoader() {
20156 const {
20157 editorMode,
20158 isListViewOpen,
20159 showBlockBreadcrumbs,
20160 isDistractionFree,
20161 isTopToolbar,
20162 isFocusMode,
20163 isPreviewMode,
20164 isViewable,
20165 isCodeEditingEnabled,
20166 isRichEditingEnabled,
20167 isPublishSidebarEnabled
20168 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20169 var _get, _getPostType$viewable;
20170 const {
20171 get
20172 } = select(external_wp_preferences_namespaceObject.store);
20173 const {
20174 isListViewOpened,
20175 getCurrentPostType,
20176 getEditorSettings
20177 } = select(store_store);
20178 const {
20179 getSettings
20180 } = select(external_wp_blockEditor_namespaceObject.store);
20181 const {
20182 getPostType
20183 } = select(external_wp_coreData_namespaceObject.store);
20184 return {
20185 editorMode: (_get = get('core', 'editorMode')) !== null && _get !== void 0 ? _get : 'visual',
20186 isListViewOpen: isListViewOpened(),
20187 showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'),
20188 isDistractionFree: get('core', 'distractionFree'),
20189 isFocusMode: get('core', 'focusMode'),
20190 isTopToolbar: get('core', 'fixedToolbar'),
20191 isPreviewMode: getSettings().__unstableIsPreviewMode,
20192 isViewable: (_getPostType$viewable = getPostType(getCurrentPostType())?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false,
20193 isCodeEditingEnabled: getEditorSettings().codeEditingEnabled,
20194 isRichEditingEnabled: getEditorSettings().richEditingEnabled,
20195 isPublishSidebarEnabled: select(store_store).isPublishSidebarEnabled()
20196 };
20197 }, []);
20198 const {
20199 getActiveComplementaryArea
20200 } = (0,external_wp_data_namespaceObject.useSelect)(store);
20201 const {
20202 toggle
20203 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
20204 const {
20205 createInfoNotice
20206 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
20207 const {
20208 __unstableSaveForPreview,
20209 setIsListViewOpened,
20210 switchEditorMode,
20211 toggleDistractionFree
20212 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
20213 const {
20214 openModal,
20215 enableComplementaryArea,
20216 disableComplementaryArea
20217 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20218 const {
20219 getCurrentPostId
20220 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
20221 const allowSwitchEditorMode = isCodeEditingEnabled && isRichEditingEnabled;
20222 if (isPreviewMode) {
20223 return {
20224 commands: [],
20225 isLoading: false
20226 };
20227 }
20228 const commands = [];
20229 commands.push({
20230 name: 'core/open-shortcut-help',
20231 label: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
20232 icon: library_keyboard,
20233 callback: () => {
20234 openModal('editor/keyboard-shortcut-help');
20235 }
20236 });
20237 commands.push({
20238 name: 'core/toggle-distraction-free',
20239 label: isDistractionFree ? (0,external_wp_i18n_namespaceObject.__)('Exit Distraction Free') : (0,external_wp_i18n_namespaceObject.__)('Enter Distraction Free'),
20240 callback: ({
20241 close
20242 }) => {
20243 toggleDistractionFree();
20244 close();
20245 }
20246 });
20247 commands.push({
20248 name: 'core/open-preferences',
20249 label: (0,external_wp_i18n_namespaceObject.__)('Editor preferences'),
20250 callback: () => {
20251 openModal('editor/preferences');
20252 }
20253 });
20254 commands.push({
20255 name: 'core/toggle-spotlight-mode',
20256 label: (0,external_wp_i18n_namespaceObject.__)('Toggle spotlight'),
20257 callback: ({
20258 close
20259 }) => {
20260 toggle('core', 'focusMode');
20261 close();
20262 createInfoNotice(isFocusMode ? (0,external_wp_i18n_namespaceObject.__)('Spotlight off.') : (0,external_wp_i18n_namespaceObject.__)('Spotlight on.'), {
20263 id: 'core/editor/toggle-spotlight-mode/notice',
20264 type: 'snackbar',
20265 actions: [{
20266 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
20267 onClick: () => {
20268 toggle('core', 'focusMode');
20269 }
20270 }]
20271 });
20272 }
20273 });
20274 commands.push({
20275 name: 'core/toggle-list-view',
20276 label: isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('Close List View') : (0,external_wp_i18n_namespaceObject.__)('Open List View'),
20277 icon: list_view,
20278 callback: ({
20279 close
20280 }) => {
20281 setIsListViewOpened(!isListViewOpen);
20282 close();
20283 createInfoNotice(isListViewOpen ? (0,external_wp_i18n_namespaceObject.__)('List View off.') : (0,external_wp_i18n_namespaceObject.__)('List View on.'), {
20284 id: 'core/editor/toggle-list-view/notice',
20285 type: 'snackbar'
20286 });
20287 }
20288 });
20289 commands.push({
20290 name: 'core/toggle-top-toolbar',
20291 label: (0,external_wp_i18n_namespaceObject.__)('Toggle top toolbar'),
20292 callback: ({
20293 close
20294 }) => {
20295 toggle('core', 'fixedToolbar');
20296 if (isDistractionFree) {
20297 toggleDistractionFree();
20298 }
20299 close();
20300 createInfoNotice(isTopToolbar ? (0,external_wp_i18n_namespaceObject.__)('Top toolbar off.') : (0,external_wp_i18n_namespaceObject.__)('Top toolbar on.'), {
20301 id: 'core/editor/toggle-top-toolbar/notice',
20302 type: 'snackbar',
20303 actions: [{
20304 label: (0,external_wp_i18n_namespaceObject.__)('Undo'),
20305 onClick: () => {
20306 toggle('core', 'fixedToolbar');
20307 }
20308 }]
20309 });
20310 }
20311 });
20312 if (allowSwitchEditorMode) {
20313 commands.push({
20314 name: 'core/toggle-code-editor',
20315 label: editorMode === 'visual' ? (0,external_wp_i18n_namespaceObject.__)('Open code editor') : (0,external_wp_i18n_namespaceObject.__)('Exit code editor'),
20316 icon: library_code,
20317 callback: ({
20318 close
20319 }) => {
20320 switchEditorMode(editorMode === 'visual' ? 'text' : 'visual');
20321 close();
20322 }
20323 });
20324 }
20325 commands.push({
20326 name: 'core/toggle-breadcrumbs',
20327 label: showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Hide block breadcrumbs') : (0,external_wp_i18n_namespaceObject.__)('Show block breadcrumbs'),
20328 callback: ({
20329 close
20330 }) => {
20331 toggle('core', 'showBlockBreadcrumbs');
20332 close();
20333 createInfoNotice(showBlockBreadcrumbs ? (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs hidden.') : (0,external_wp_i18n_namespaceObject.__)('Breadcrumbs visible.'), {
20334 id: 'core/editor/toggle-breadcrumbs/notice',
20335 type: 'snackbar'
20336 });
20337 }
20338 });
20339 commands.push({
20340 name: 'core/open-settings-sidebar',
20341 label: (0,external_wp_i18n_namespaceObject.__)('Toggle settings sidebar'),
20342 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right,
20343 callback: ({
20344 close
20345 }) => {
20346 const activeSidebar = getActiveComplementaryArea('core');
20347 close();
20348 if (activeSidebar === 'edit-post/document') {
20349 disableComplementaryArea('core');
20350 } else {
20351 enableComplementaryArea('core', 'edit-post/document');
20352 }
20353 }
20354 });
20355 commands.push({
20356 name: 'core/open-block-inspector',
20357 label: (0,external_wp_i18n_namespaceObject.__)('Toggle block inspector'),
20358 icon: block_default,
20359 callback: ({
20360 close
20361 }) => {
20362 const activeSidebar = getActiveComplementaryArea('core');
20363 close();
20364 if (activeSidebar === 'edit-post/block') {
20365 disableComplementaryArea('core');
20366 } else {
20367 enableComplementaryArea('core', 'edit-post/block');
20368 }
20369 }
20370 });
20371 commands.push({
20372 name: 'core/toggle-publish-sidebar',
20373 label: isPublishSidebarEnabled ? (0,external_wp_i18n_namespaceObject.__)('Disable pre-publish checks') : (0,external_wp_i18n_namespaceObject.__)('Enable pre-publish checks'),
20374 icon: format_list_bullets,
20375 callback: ({
20376 close
20377 }) => {
20378 close();
20379 toggle('core', 'isPublishSidebarEnabled');
20380 createInfoNotice(isPublishSidebarEnabled ? (0,external_wp_i18n_namespaceObject.__)('Pre-publish checks disabled.') : (0,external_wp_i18n_namespaceObject.__)('Pre-publish checks enabled.'), {
20381 id: 'core/editor/publish-sidebar/notice',
20382 type: 'snackbar'
20383 });
20384 }
20385 });
20386 if (isViewable) {
20387 commands.push({
20388 name: 'core/preview-link',
20389 label: (0,external_wp_i18n_namespaceObject.__)('Preview in a new tab'),
20390 icon: library_external,
20391 callback: async ({
20392 close
20393 }) => {
20394 close();
20395 const postId = getCurrentPostId();
20396 const link = await __unstableSaveForPreview();
20397 window.open(link, `wp-preview-${postId}`);
20398 }
20399 });
20400 }
20401 return {
20402 commands,
20403 isLoading: false
20404 };
20405 }
20406 function useEditedEntityContextualCommands() {
20407 const {
20408 postType
20409 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20410 const {
20411 getCurrentPostType
20412 } = select(store_store);
20413 return {
20414 postType: getCurrentPostType()
20415 };
20416 }, []);
20417 const {
20418 openModal
20419 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20420 const commands = [];
20421 if (postType === PATTERN_POST_TYPE) {
20422 commands.push({
20423 name: 'core/rename-pattern',
20424 label: (0,external_wp_i18n_namespaceObject.__)('Rename pattern'),
20425 icon: edit,
20426 callback: ({
20427 close
20428 }) => {
20429 openModal(modalName);
20430 close();
20431 }
20432 });
20433 commands.push({
20434 name: 'core/duplicate-pattern',
20435 label: (0,external_wp_i18n_namespaceObject.__)('Duplicate pattern'),
20436 icon: library_symbol,
20437 callback: ({
20438 close
20439 }) => {
20440 openModal(pattern_duplicate_modal_modalName);
20441 close();
20442 }
20443 });
20444 }
20445 return {
20446 isLoading: false,
20447 commands
20448 };
20449 }
20450 function useCommands() {
20451 (0,external_wp_commands_namespaceObject.useCommandLoader)({
20452 name: 'core/editor/edit-ui',
20453 hook: useEditorCommandLoader
20454 });
20455 (0,external_wp_commands_namespaceObject.useCommandLoader)({
20456 name: 'core/editor/contextual-commands',
20457 hook: useEditedEntityContextualCommands,
20458 context: 'entity-edit'
20459 });
20460 }
20461
20462 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-removal-warnings/index.js
20463 /**
20464 * WordPress dependencies
20465 */
20466
20467
20468
20469
20470
20471
20472 /**
20473 * Internal dependencies
20474 */
20475
20476
20477
20478 const {
20479 BlockRemovalWarningModal
20480 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
20481
20482 // Prevent accidental removal of certain blocks, asking the user for confirmation first.
20483 const TEMPLATE_BLOCKS = ['core/post-content', 'core/post-template', 'core/query'];
20484 const BLOCK_REMOVAL_RULES = [{
20485 // Template blocks.
20486 // The warning is only shown when a user manipulates templates or template parts.
20487 postTypes: ['wp_template', 'wp_template_part'],
20488 callback(removedBlocks) {
20489 const removedTemplateBlocks = removedBlocks.filter(({
20490 name
20491 }) => TEMPLATE_BLOCKS.includes(name));
20492 if (removedTemplateBlocks.length) {
20493 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);
20494 }
20495 }
20496 }, {
20497 // Pattern overrides.
20498 // The warning is only shown when the user edits a pattern.
20499 postTypes: ['wp_block'],
20500 callback(removedBlocks) {
20501 const removedBlocksWithOverrides = removedBlocks.filter(({
20502 attributes
20503 }) => attributes?.metadata?.bindings && Object.values(attributes.metadata.bindings).some(binding => binding.source === 'core/pattern-overrides'));
20504 if (removedBlocksWithOverrides.length) {
20505 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);
20506 }
20507 }
20508 }];
20509 function BlockRemovalWarnings() {
20510 const currentPostType = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType(), []);
20511 const removalRulesForPostType = (0,external_wp_element_namespaceObject.useMemo)(() => BLOCK_REMOVAL_RULES.filter(rule => rule.postTypes.includes(currentPostType)), [currentPostType]);
20512
20513 // `BlockRemovalWarnings` is rendered in the editor provider, a shared component
20514 // across react native and web. However, `BlockRemovalWarningModal` is web only.
20515 // Check it exists before trying to render it.
20516 if (!BlockRemovalWarningModal) {
20517 return null;
20518 }
20519 if (!removalRulesForPostType) {
20520 return null;
20521 }
20522 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockRemovalWarningModal, {
20523 rules: removalRulesForPostType
20524 });
20525 }
20526
20527 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/start-page-options/index.js
20528 /**
20529 * WordPress dependencies
20530 */
20531
20532
20533
20534
20535
20536
20537
20538
20539
20540 /**
20541 * Internal dependencies
20542 */
20543
20544
20545
20546 function useStartPatterns() {
20547 // A pattern is a start pattern if it includes 'core/post-content' in its blockTypes,
20548 // and it has no postTypes declared and the current post type is page or if
20549 // the current post type is part of the postTypes declared.
20550 const {
20551 blockPatternsWithPostContentBlockType,
20552 postType
20553 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20554 const {
20555 getPatternsByBlockTypes,
20556 getBlocksByName
20557 } = select(external_wp_blockEditor_namespaceObject.store);
20558 const {
20559 getCurrentPostType,
20560 getRenderingMode
20561 } = select(store_store);
20562 const rootClientId = getRenderingMode() === 'post-only' ? '' : getBlocksByName('core/post-content')?.[0];
20563 return {
20564 blockPatternsWithPostContentBlockType: getPatternsByBlockTypes('core/post-content', rootClientId),
20565 postType: getCurrentPostType()
20566 };
20567 }, []);
20568 return (0,external_wp_element_namespaceObject.useMemo)(() => {
20569 // filter patterns without postTypes declared if the current postType is page
20570 // or patterns that declare the current postType in its post type array.
20571 return blockPatternsWithPostContentBlockType.filter(pattern => {
20572 return postType === 'page' && !pattern.postTypes || Array.isArray(pattern.postTypes) && pattern.postTypes.includes(postType);
20573 });
20574 }, [postType, blockPatternsWithPostContentBlockType]);
20575 }
20576 function PatternSelection({
20577 blockPatterns,
20578 onChoosePattern
20579 }) {
20580 const shownBlockPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(blockPatterns);
20581 const {
20582 editEntityRecord
20583 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
20584 const {
20585 postType,
20586 postId
20587 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20588 const {
20589 getCurrentPostType,
20590 getCurrentPostId
20591 } = select(store_store);
20592 return {
20593 postType: getCurrentPostType(),
20594 postId: getCurrentPostId()
20595 };
20596 }, []);
20597 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
20598 blockPatterns: blockPatterns,
20599 shownPatterns: shownBlockPatterns,
20600 onClickPattern: (_pattern, blocks) => {
20601 editEntityRecord('postType', postType, postId, {
20602 blocks,
20603 content: ({
20604 blocks: blocksForSerialization = []
20605 }) => (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(blocksForSerialization)
20606 });
20607 onChoosePattern();
20608 }
20609 });
20610 }
20611 function StartPageOptionsModal({
20612 onClose
20613 }) {
20614 const startPatterns = useStartPatterns();
20615 const hasStartPattern = startPatterns.length > 0;
20616 if (!hasStartPattern) {
20617 return null;
20618 }
20619 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
20620 title: (0,external_wp_i18n_namespaceObject.__)('Choose a pattern'),
20621 isFullScreen: true,
20622 onRequestClose: onClose,
20623 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
20624 className: "editor-start-page-options__modal-content",
20625 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternSelection, {
20626 blockPatterns: startPatterns,
20627 onChoosePattern: onClose
20628 })
20629 })
20630 });
20631 }
20632 function StartPageOptions() {
20633 const [isClosed, setIsClosed] = (0,external_wp_element_namespaceObject.useState)(false);
20634 const {
20635 shouldEnableModal,
20636 postType,
20637 postId
20638 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20639 const {
20640 isEditedPostDirty,
20641 isEditedPostEmpty,
20642 getCurrentPostType,
20643 getCurrentPostId
20644 } = select(store_store);
20645 const _postType = getCurrentPostType();
20646 return {
20647 shouldEnableModal: !isEditedPostDirty() && isEditedPostEmpty() && TEMPLATE_POST_TYPE !== _postType,
20648 postType: _postType,
20649 postId: getCurrentPostId()
20650 };
20651 }, []);
20652 (0,external_wp_element_namespaceObject.useEffect)(() => {
20653 // Should reset the modal state when navigating to a new page/post.
20654 setIsClosed(false);
20655 }, [postType, postId]);
20656 if (!shouldEnableModal || isClosed) {
20657 return null;
20658 }
20659 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(StartPageOptionsModal, {
20660 onClose: () => setIsClosed(true)
20661 });
20662 }
20663
20664 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/keyboard-shortcut-help-modal/config.js
20665 /**
20666 * WordPress dependencies
20667 */
20668
20669 const textFormattingShortcuts = [{
20670 keyCombination: {
20671 modifier: 'primary',
20672 character: 'b'
20673 },
20674 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text bold.')
20675 }, {
20676 keyCombination: {
20677 modifier: 'primary',
20678 character: 'i'
20679 },
20680 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text italic.')
20681 }, {
20682 keyCombination: {
20683 modifier: 'primary',
20684 character: 'k'
20685 },
20686 description: (0,external_wp_i18n_namespaceObject.__)('Convert the selected text into a link.')
20687 }, {
20688 keyCombination: {
20689 modifier: 'primaryShift',
20690 character: 'k'
20691 },
20692 description: (0,external_wp_i18n_namespaceObject.__)('Remove a link.')
20693 }, {
20694 keyCombination: {
20695 character: '[['
20696 },
20697 description: (0,external_wp_i18n_namespaceObject.__)('Insert a link to a post or page.')
20698 }, {
20699 keyCombination: {
20700 modifier: 'primary',
20701 character: 'u'
20702 },
20703 description: (0,external_wp_i18n_namespaceObject.__)('Underline the selected text.')
20704 }, {
20705 keyCombination: {
20706 modifier: 'access',
20707 character: 'd'
20708 },
20709 description: (0,external_wp_i18n_namespaceObject.__)('Strikethrough the selected text.')
20710 }, {
20711 keyCombination: {
20712 modifier: 'access',
20713 character: 'x'
20714 },
20715 description: (0,external_wp_i18n_namespaceObject.__)('Make the selected text inline code.')
20716 }, {
20717 keyCombination: {
20718 modifier: 'access',
20719 character: '0'
20720 },
20721 aliases: [{
20722 modifier: 'access',
20723 character: '7'
20724 }],
20725 description: (0,external_wp_i18n_namespaceObject.__)('Convert the current heading to a paragraph.')
20726 }, {
20727 keyCombination: {
20728 modifier: 'access',
20729 character: '1-6'
20730 },
20731 description: (0,external_wp_i18n_namespaceObject.__)('Convert the current paragraph or heading to a heading of level 1 to 6.')
20732 }, {
20733 keyCombination: {
20734 modifier: 'primaryShift',
20735 character: 'SPACE'
20736 },
20737 description: (0,external_wp_i18n_namespaceObject.__)('Add non breaking space.')
20738 }];
20739
20740 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/keyboard-shortcut-help-modal/shortcut.js
20741 /**
20742 * WordPress dependencies
20743 */
20744
20745
20746
20747
20748
20749 function KeyCombination({
20750 keyCombination,
20751 forceAriaLabel
20752 }) {
20753 const shortcut = keyCombination.modifier ? external_wp_keycodes_namespaceObject.displayShortcutList[keyCombination.modifier](keyCombination.character) : keyCombination.character;
20754 const ariaLabel = keyCombination.modifier ? external_wp_keycodes_namespaceObject.shortcutAriaLabel[keyCombination.modifier](keyCombination.character) : keyCombination.character;
20755 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("kbd", {
20756 className: "editor-keyboard-shortcut-help-modal__shortcut-key-combination",
20757 "aria-label": forceAriaLabel || ariaLabel,
20758 children: (Array.isArray(shortcut) ? shortcut : [shortcut]).map((character, index) => {
20759 if (character === '+') {
20760 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_element_namespaceObject.Fragment, {
20761 children: character
20762 }, index);
20763 }
20764 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("kbd", {
20765 className: "editor-keyboard-shortcut-help-modal__shortcut-key",
20766 children: character
20767 }, index);
20768 })
20769 });
20770 }
20771 function Shortcut({
20772 description,
20773 keyCombination,
20774 aliases = [],
20775 ariaLabel
20776 }) {
20777 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
20778 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
20779 className: "editor-keyboard-shortcut-help-modal__shortcut-description",
20780 children: description
20781 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
20782 className: "editor-keyboard-shortcut-help-modal__shortcut-term",
20783 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(KeyCombination, {
20784 keyCombination: keyCombination,
20785 forceAriaLabel: ariaLabel
20786 }), aliases.map((alias, index) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(KeyCombination, {
20787 keyCombination: alias,
20788 forceAriaLabel: ariaLabel
20789 }, index))]
20790 })]
20791 });
20792 }
20793 /* harmony default export */ const keyboard_shortcut_help_modal_shortcut = (Shortcut);
20794
20795 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/keyboard-shortcut-help-modal/dynamic-shortcut.js
20796 /**
20797 * WordPress dependencies
20798 */
20799
20800
20801
20802 /**
20803 * Internal dependencies
20804 */
20805
20806
20807 function DynamicShortcut({
20808 name
20809 }) {
20810 const {
20811 keyCombination,
20812 description,
20813 aliases
20814 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20815 const {
20816 getShortcutKeyCombination,
20817 getShortcutDescription,
20818 getShortcutAliases
20819 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
20820 return {
20821 keyCombination: getShortcutKeyCombination(name),
20822 aliases: getShortcutAliases(name),
20823 description: getShortcutDescription(name)
20824 };
20825 }, [name]);
20826 if (!keyCombination) {
20827 return null;
20828 }
20829 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcut_help_modal_shortcut, {
20830 keyCombination: keyCombination,
20831 description: description,
20832 aliases: aliases
20833 });
20834 }
20835 /* harmony default export */ const dynamic_shortcut = (DynamicShortcut);
20836
20837 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/keyboard-shortcut-help-modal/index.js
20838 /**
20839 * External dependencies
20840 */
20841
20842
20843 /**
20844 * WordPress dependencies
20845 */
20846
20847
20848
20849
20850
20851
20852 /**
20853 * Internal dependencies
20854 */
20855
20856
20857
20858
20859
20860 const KEYBOARD_SHORTCUT_HELP_MODAL_NAME = 'editor/keyboard-shortcut-help';
20861 const ShortcutList = ({
20862 shortcuts
20863 }) =>
20864 /*#__PURE__*/
20865 /*
20866 * Disable reason: The `list` ARIA role is redundant but
20867 * Safari+VoiceOver won't announce the list otherwise.
20868 */
20869 /* eslint-disable jsx-a11y/no-redundant-roles */
20870 (0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
20871 className: "editor-keyboard-shortcut-help-modal__shortcut-list",
20872 role: "list",
20873 children: shortcuts.map((shortcut, index) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("li", {
20874 className: "editor-keyboard-shortcut-help-modal__shortcut",
20875 children: typeof shortcut === 'string' ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(dynamic_shortcut, {
20876 name: shortcut
20877 }) : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(keyboard_shortcut_help_modal_shortcut, {
20878 ...shortcut
20879 })
20880 }, index))
20881 })
20882 /* eslint-enable jsx-a11y/no-redundant-roles */;
20883 const ShortcutSection = ({
20884 title,
20885 shortcuts,
20886 className
20887 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("section", {
20888 className: dist_clsx('editor-keyboard-shortcut-help-modal__section', className),
20889 children: [!!title && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
20890 className: "editor-keyboard-shortcut-help-modal__section-title",
20891 children: title
20892 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutList, {
20893 shortcuts: shortcuts
20894 })]
20895 });
20896 const ShortcutCategorySection = ({
20897 title,
20898 categoryName,
20899 additionalShortcuts = []
20900 }) => {
20901 const categoryShortcuts = (0,external_wp_data_namespaceObject.useSelect)(select => {
20902 return select(external_wp_keyboardShortcuts_namespaceObject.store).getCategoryShortcuts(categoryName);
20903 }, [categoryName]);
20904 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, {
20905 title: title,
20906 shortcuts: categoryShortcuts.concat(additionalShortcuts)
20907 });
20908 };
20909 function KeyboardShortcutHelpModal() {
20910 const isModalActive = (0,external_wp_data_namespaceObject.useSelect)(select => select(store).isModalActive(KEYBOARD_SHORTCUT_HELP_MODAL_NAME), []);
20911 const {
20912 openModal,
20913 closeModal
20914 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
20915 const toggleModal = () => {
20916 if (isModalActive) {
20917 closeModal();
20918 } else {
20919 openModal(KEYBOARD_SHORTCUT_HELP_MODAL_NAME);
20920 }
20921 };
20922 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/keyboard-shortcuts', toggleModal);
20923 if (!isModalActive) {
20924 return null;
20925 }
20926 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Modal, {
20927 className: "editor-keyboard-shortcut-help-modal",
20928 title: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts'),
20929 closeButtonLabel: (0,external_wp_i18n_namespaceObject.__)('Close'),
20930 onRequestClose: toggleModal,
20931 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, {
20932 className: "editor-keyboard-shortcut-help-modal__main-shortcuts",
20933 shortcuts: ['core/editor/keyboard-shortcuts']
20934 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
20935 title: (0,external_wp_i18n_namespaceObject.__)('Global shortcuts'),
20936 categoryName: "global"
20937 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
20938 title: (0,external_wp_i18n_namespaceObject.__)('Selection shortcuts'),
20939 categoryName: "selection"
20940 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
20941 title: (0,external_wp_i18n_namespaceObject.__)('Block shortcuts'),
20942 categoryName: "block",
20943 additionalShortcuts: [{
20944 keyCombination: {
20945 character: '/'
20946 },
20947 description: (0,external_wp_i18n_namespaceObject.__)('Change the block type after adding a new paragraph.'),
20948 /* translators: The forward-slash character. e.g. '/'. */
20949 ariaLabel: (0,external_wp_i18n_namespaceObject.__)('Forward-slash')
20950 }]
20951 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutSection, {
20952 title: (0,external_wp_i18n_namespaceObject.__)('Text formatting'),
20953 shortcuts: textFormattingShortcuts
20954 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ShortcutCategorySection, {
20955 title: (0,external_wp_i18n_namespaceObject.__)('List View shortcuts'),
20956 categoryName: "list-view"
20957 })]
20958 });
20959 }
20960 /* harmony default export */ const keyboard_shortcut_help_modal = (KeyboardShortcutHelpModal);
20961
20962 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-settings-menu/content-only-settings-menu.js
20963 /**
20964 * WordPress dependencies
20965 */
20966
20967
20968
20969
20970
20971
20972 /**
20973 * Internal dependencies
20974 */
20975
20976
20977
20978
20979
20980 function ContentOnlySettingsMenuItems({
20981 clientId,
20982 onClose
20983 }) {
20984 const {
20985 entity,
20986 onNavigateToEntityRecord,
20987 canEditTemplates
20988 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
20989 const {
20990 getBlockEditingMode,
20991 getBlockParentsByBlockName,
20992 getSettings,
20993 getBlockAttributes
20994 } = select(external_wp_blockEditor_namespaceObject.store);
20995 const contentOnly = getBlockEditingMode(clientId) === 'contentOnly';
20996 if (!contentOnly) {
20997 return {};
20998 }
20999 const patternParent = getBlockParentsByBlockName(clientId, 'core/block', true)[0];
21000 let record;
21001 if (patternParent) {
21002 record = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_block', getBlockAttributes(patternParent).ref);
21003 } else {
21004 const {
21005 getCurrentTemplateId
21006 } = select(store_store);
21007 const templateId = getCurrentTemplateId();
21008 const {
21009 getContentLockingParent
21010 } = unlock(select(external_wp_blockEditor_namespaceObject.store));
21011 if (!getContentLockingParent(clientId) && templateId) {
21012 record = select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', 'wp_template', templateId);
21013 }
21014 }
21015 const _canEditTemplates = select(external_wp_coreData_namespaceObject.store).canUser('create', {
21016 kind: 'postType',
21017 name: 'wp_template'
21018 });
21019 return {
21020 canEditTemplates: _canEditTemplates,
21021 entity: record,
21022 onNavigateToEntityRecord: getSettings().onNavigateToEntityRecord
21023 };
21024 }, [clientId]);
21025 if (!entity) {
21026 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateLockContentOnlyMenuItems, {
21027 clientId: clientId,
21028 onClose: onClose
21029 });
21030 }
21031 const isPattern = entity.type === 'wp_block';
21032 let helpText = 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.');
21033 if (!canEditTemplates) {
21034 helpText = (0,external_wp_i18n_namespaceObject.__)('Only users with permissions to edit the template can move or delete this block');
21035 }
21036 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
21037 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, {
21038 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
21039 onClick: () => {
21040 onNavigateToEntityRecord({
21041 postId: entity.id,
21042 postType: entity.type
21043 });
21044 },
21045 disabled: !canEditTemplates,
21046 children: isPattern ? (0,external_wp_i18n_namespaceObject.__)('Edit pattern') : (0,external_wp_i18n_namespaceObject.__)('Edit template')
21047 })
21048 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
21049 variant: "muted",
21050 as: "p",
21051 className: "editor-content-only-settings-menu__description",
21052 children: helpText
21053 })]
21054 });
21055 }
21056 function TemplateLockContentOnlyMenuItems({
21057 clientId,
21058 onClose
21059 }) {
21060 const {
21061 contentLockingParent
21062 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21063 const {
21064 getContentLockingParent
21065 } = unlock(select(external_wp_blockEditor_namespaceObject.store));
21066 return {
21067 contentLockingParent: getContentLockingParent(clientId)
21068 };
21069 }, [clientId]);
21070 const blockDisplayInformation = (0,external_wp_blockEditor_namespaceObject.useBlockDisplayInformation)(contentLockingParent);
21071 // Disable reason: We're using a hook here so it has to be on top-level.
21072 // eslint-disable-next-line @wordpress/no-unused-vars-before-return
21073 const {
21074 modifyContentLockBlock,
21075 selectBlock
21076 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store));
21077 if (!blockDisplayInformation?.title) {
21078 return null;
21079 }
21080 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
21081 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__unstableBlockSettingsMenuFirstItem, {
21082 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
21083 onClick: () => {
21084 selectBlock(contentLockingParent);
21085 modifyContentLockBlock(contentLockingParent);
21086 onClose();
21087 },
21088 children: (0,external_wp_i18n_namespaceObject.__)('Unlock')
21089 })
21090 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
21091 variant: "muted",
21092 as: "p",
21093 className: "editor-content-only-settings-menu__description",
21094 children: (0,external_wp_i18n_namespaceObject.__)('Temporarily unlock the parent block to edit, delete or make further changes to this block.')
21095 })]
21096 });
21097 }
21098 function ContentOnlySettingsMenu() {
21099 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
21100 children: ({
21101 selectedClientIds,
21102 onClose
21103 }) => selectedClientIds.length === 1 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ContentOnlySettingsMenuItems, {
21104 clientId: selectedClientIds[0],
21105 onClose: onClose
21106 })
21107 });
21108 }
21109
21110 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/start-template-options/index.js
21111 /**
21112 * WordPress dependencies
21113 */
21114
21115
21116
21117
21118
21119
21120
21121
21122
21123 /**
21124 * Internal dependencies
21125 */
21126
21127
21128
21129
21130 function useFallbackTemplateContent(slug, isCustom = false) {
21131 return (0,external_wp_data_namespaceObject.useSelect)(select => {
21132 const {
21133 getEntityRecord,
21134 getDefaultTemplateId
21135 } = select(external_wp_coreData_namespaceObject.store);
21136 const templateId = getDefaultTemplateId({
21137 slug,
21138 is_custom: isCustom,
21139 ignore_empty: true
21140 });
21141 return templateId ? getEntityRecord('postType', TEMPLATE_POST_TYPE, templateId)?.content?.raw : undefined;
21142 }, [slug, isCustom]);
21143 }
21144 function start_template_options_useStartPatterns(fallbackContent) {
21145 const {
21146 slug,
21147 patterns
21148 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21149 const {
21150 getCurrentPostType,
21151 getCurrentPostId
21152 } = select(store_store);
21153 const {
21154 getEntityRecord,
21155 getBlockPatterns
21156 } = select(external_wp_coreData_namespaceObject.store);
21157 const postId = getCurrentPostId();
21158 const postType = getCurrentPostType();
21159 const record = getEntityRecord('postType', postType, postId);
21160 return {
21161 slug: record.slug,
21162 patterns: getBlockPatterns()
21163 };
21164 }, []);
21165 const currentThemeStylesheet = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getCurrentTheme().stylesheet);
21166
21167 // Duplicated from packages/block-library/src/pattern/edit.js.
21168 function injectThemeAttributeInBlockTemplateContent(block) {
21169 if (block.innerBlocks.find(innerBlock => innerBlock.name === 'core/template-part')) {
21170 block.innerBlocks = block.innerBlocks.map(innerBlock => {
21171 if (innerBlock.name === 'core/template-part' && innerBlock.attributes.theme === undefined) {
21172 innerBlock.attributes.theme = currentThemeStylesheet;
21173 }
21174 return innerBlock;
21175 });
21176 }
21177 if (block.name === 'core/template-part' && block.attributes.theme === undefined) {
21178 block.attributes.theme = currentThemeStylesheet;
21179 }
21180 return block;
21181 }
21182 return (0,external_wp_element_namespaceObject.useMemo)(() => {
21183 // filter patterns that are supposed to be used in the current template being edited.
21184 return [{
21185 name: 'fallback',
21186 blocks: (0,external_wp_blocks_namespaceObject.parse)(fallbackContent),
21187 title: (0,external_wp_i18n_namespaceObject.__)('Fallback content')
21188 }, ...patterns.filter(pattern => {
21189 return Array.isArray(pattern.templateTypes) && pattern.templateTypes.some(templateType => slug.startsWith(templateType));
21190 }).map(pattern => {
21191 return {
21192 ...pattern,
21193 blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content).map(block => injectThemeAttributeInBlockTemplateContent(block))
21194 };
21195 })];
21196 }, [fallbackContent, slug, patterns]);
21197 }
21198 function start_template_options_PatternSelection({
21199 fallbackContent,
21200 onChoosePattern,
21201 postType
21202 }) {
21203 const [,, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', postType);
21204 const blockPatterns = start_template_options_useStartPatterns(fallbackContent);
21205 const shownBlockPatterns = (0,external_wp_compose_namespaceObject.useAsyncList)(blockPatterns);
21206 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
21207 blockPatterns: blockPatterns,
21208 shownPatterns: shownBlockPatterns,
21209 onClickPattern: (pattern, blocks) => {
21210 onChange(blocks, {
21211 selection: undefined
21212 });
21213 onChoosePattern();
21214 }
21215 });
21216 }
21217 function StartModal({
21218 slug,
21219 isCustom,
21220 onClose,
21221 postType
21222 }) {
21223 const fallbackContent = useFallbackTemplateContent(slug, isCustom);
21224 if (!fallbackContent) {
21225 return null;
21226 }
21227 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Modal, {
21228 className: "editor-start-template-options__modal",
21229 title: (0,external_wp_i18n_namespaceObject.__)('Choose a pattern'),
21230 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Cancel'),
21231 focusOnMount: "firstElement",
21232 onRequestClose: onClose,
21233 isFullScreen: true,
21234 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
21235 className: "editor-start-template-options__modal-content",
21236 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(start_template_options_PatternSelection, {
21237 fallbackContent: fallbackContent,
21238 slug: slug,
21239 isCustom: isCustom,
21240 postType: postType,
21241 onChoosePattern: () => {
21242 onClose();
21243 }
21244 })
21245 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Flex, {
21246 className: "editor-start-template-options__modal__actions",
21247 justify: "flex-end",
21248 expanded: false,
21249 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
21250 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
21251 variant: "tertiary",
21252 onClick: onClose,
21253 children: (0,external_wp_i18n_namespaceObject.__)('Skip')
21254 })
21255 })
21256 })]
21257 });
21258 }
21259 function StartTemplateOptions() {
21260 const [isClosed, setIsClosed] = (0,external_wp_element_namespaceObject.useState)(false);
21261 const {
21262 shouldOpenModal,
21263 slug,
21264 isCustom,
21265 postType,
21266 postId
21267 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
21268 const {
21269 getCurrentPostType,
21270 getCurrentPostId
21271 } = select(store_store);
21272 const _postType = getCurrentPostType();
21273 const _postId = getCurrentPostId();
21274 const {
21275 getEditedEntityRecord,
21276 hasEditsForEntityRecord
21277 } = select(external_wp_coreData_namespaceObject.store);
21278 const templateRecord = getEditedEntityRecord('postType', _postType, _postId);
21279 const hasEdits = hasEditsForEntityRecord('postType', _postType, _postId);
21280 return {
21281 shouldOpenModal: !hasEdits && '' === templateRecord.content && TEMPLATE_POST_TYPE === _postType,
21282 slug: templateRecord.slug,
21283 isCustom: templateRecord.is_custom,
21284 postType: _postType,
21285 postId: _postId
21286 };
21287 }, []);
21288 (0,external_wp_element_namespaceObject.useEffect)(() => {
21289 // Should reset the modal state when navigating to a new page/post.
21290 setIsClosed(false);
21291 }, [postType, postId]);
21292 if (!shouldOpenModal || isClosed) {
21293 return null;
21294 }
21295 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(StartModal, {
21296 slug: slug,
21297 isCustom: isCustom,
21298 postType: postType,
21299 onClose: () => setIsClosed(true)
21300 });
21301 }
21302
21303 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-part-menu-items/convert-to-regular.js
21304 /**
21305 * WordPress dependencies
21306 */
21307
21308
21309
21310
21311
21312 function ConvertToRegularBlocks({
21313 clientId,
21314 onClose
21315 }) {
21316 const {
21317 getBlocks
21318 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store);
21319 const {
21320 replaceBlocks
21321 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
21322 const canRemove = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_blockEditor_namespaceObject.store).canRemoveBlock(clientId), [clientId]);
21323 if (!canRemove) {
21324 return null;
21325 }
21326 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
21327 onClick: () => {
21328 replaceBlocks(clientId, getBlocks(clientId));
21329 onClose();
21330 },
21331 children: (0,external_wp_i18n_namespaceObject.__)('Detach')
21332 });
21333 }
21334
21335 ;// CONCATENATED MODULE: ./node_modules/tslib/tslib.es6.mjs
21336 /******************************************************************************
21337 Copyright (c) Microsoft Corporation.
21338
21339 Permission to use, copy, modify, and/or distribute this software for any
21340 purpose with or without fee is hereby granted.
21341
21342 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
21343 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
21344 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
21345 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
21346 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
21347 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
21348 PERFORMANCE OF THIS SOFTWARE.
21349 ***************************************************************************** */
21350 /* global Reflect, Promise, SuppressedError, Symbol */
21351
21352 var extendStatics = function(d, b) {
21353 extendStatics = Object.setPrototypeOf ||
21354 ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
21355 function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
21356 return extendStatics(d, b);
21357 };
21358
21359 function __extends(d, b) {
21360 if (typeof b !== "function" && b !== null)
21361 throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
21362 extendStatics(d, b);
21363 function __() { this.constructor = d; }
21364 d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
21365 }
21366
21367 var __assign = function() {
21368 __assign = Object.assign || function __assign(t) {
21369 for (var s, i = 1, n = arguments.length; i < n; i++) {
21370 s = arguments[i];
21371 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
21372 }
21373 return t;
21374 }
21375 return __assign.apply(this, arguments);
21376 }
21377
21378 function __rest(s, e) {
21379 var t = {};
21380 for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
21381 t[p] = s[p];
21382 if (s != null && typeof Object.getOwnPropertySymbols === "function")
21383 for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
21384 if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
21385 t[p[i]] = s[p[i]];
21386 }
21387 return t;
21388 }
21389
21390 function __decorate(decorators, target, key, desc) {
21391 var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
21392 if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
21393 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;
21394 return c > 3 && r && Object.defineProperty(target, key, r), r;
21395 }
21396
21397 function __param(paramIndex, decorator) {
21398 return function (target, key) { decorator(target, key, paramIndex); }
21399 }
21400
21401 function __esDecorate(ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
21402 function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
21403 var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
21404 var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
21405 var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
21406 var _, done = false;
21407 for (var i = decorators.length - 1; i >= 0; i--) {
21408 var context = {};
21409 for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
21410 for (var p in contextIn.access) context.access[p] = contextIn.access[p];
21411 context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
21412 var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
21413 if (kind === "accessor") {
21414 if (result === void 0) continue;
21415 if (result === null || typeof result !== "object") throw new TypeError("Object expected");
21416 if (_ = accept(result.get)) descriptor.get = _;
21417 if (_ = accept(result.set)) descriptor.set = _;
21418 if (_ = accept(result.init)) initializers.unshift(_);
21419 }
21420 else if (_ = accept(result)) {
21421 if (kind === "field") initializers.unshift(_);
21422 else descriptor[key] = _;
21423 }
21424 }
21425 if (target) Object.defineProperty(target, contextIn.name, descriptor);
21426 done = true;
21427 };
21428
21429 function __runInitializers(thisArg, initializers, value) {
21430 var useValue = arguments.length > 2;
21431 for (var i = 0; i < initializers.length; i++) {
21432 value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
21433 }
21434 return useValue ? value : void 0;
21435 };
21436
21437 function __propKey(x) {
21438 return typeof x === "symbol" ? x : "".concat(x);
21439 };
21440
21441 function __setFunctionName(f, name, prefix) {
21442 if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
21443 return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
21444 };
21445
21446 function __metadata(metadataKey, metadataValue) {
21447 if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
21448 }
21449
21450 function __awaiter(thisArg, _arguments, P, generator) {
21451 function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
21452 return new (P || (P = Promise))(function (resolve, reject) {
21453 function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21454 function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
21455 function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21456 step((generator = generator.apply(thisArg, _arguments || [])).next());
21457 });
21458 }
21459
21460 function __generator(thisArg, body) {
21461 var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
21462 return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
21463 function verb(n) { return function (v) { return step([n, v]); }; }
21464 function step(op) {
21465 if (f) throw new TypeError("Generator is already executing.");
21466 while (g && (g = 0, op[0] && (_ = 0)), _) try {
21467 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;
21468 if (y = 0, t) op = [op[0] & 2, t.value];
21469 switch (op[0]) {
21470 case 0: case 1: t = op; break;
21471 case 4: _.label++; return { value: op[1], done: false };
21472 case 5: _.label++; y = op[1]; op = [0]; continue;
21473 case 7: op = _.ops.pop(); _.trys.pop(); continue;
21474 default:
21475 if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
21476 if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
21477 if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
21478 if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
21479 if (t[2]) _.ops.pop();
21480 _.trys.pop(); continue;
21481 }
21482 op = body.call(thisArg, _);
21483 } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
21484 if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
21485 }
21486 }
21487
21488 var __createBinding = Object.create ? (function(o, m, k, k2) {
21489 if (k2 === undefined) k2 = k;
21490 var desc = Object.getOwnPropertyDescriptor(m, k);
21491 if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
21492 desc = { enumerable: true, get: function() { return m[k]; } };
21493 }
21494 Object.defineProperty(o, k2, desc);
21495 }) : (function(o, m, k, k2) {
21496 if (k2 === undefined) k2 = k;
21497 o[k2] = m[k];
21498 });
21499
21500 function __exportStar(m, o) {
21501 for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p);
21502 }
21503
21504 function __values(o) {
21505 var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
21506 if (m) return m.call(o);
21507 if (o && typeof o.length === "number") return {
21508 next: function () {
21509 if (o && i >= o.length) o = void 0;
21510 return { value: o && o[i++], done: !o };
21511 }
21512 };
21513 throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
21514 }
21515
21516 function __read(o, n) {
21517 var m = typeof Symbol === "function" && o[Symbol.iterator];
21518 if (!m) return o;
21519 var i = m.call(o), r, ar = [], e;
21520 try {
21521 while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
21522 }
21523 catch (error) { e = { error: error }; }
21524 finally {
21525 try {
21526 if (r && !r.done && (m = i["return"])) m.call(i);
21527 }
21528 finally { if (e) throw e.error; }
21529 }
21530 return ar;
21531 }
21532
21533 /** @deprecated */
21534 function __spread() {
21535 for (var ar = [], i = 0; i < arguments.length; i++)
21536 ar = ar.concat(__read(arguments[i]));
21537 return ar;
21538 }
21539
21540 /** @deprecated */
21541 function __spreadArrays() {
21542 for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
21543 for (var r = Array(s), k = 0, i = 0; i < il; i++)
21544 for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
21545 r[k] = a[j];
21546 return r;
21547 }
21548
21549 function __spreadArray(to, from, pack) {
21550 if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
21551 if (ar || !(i in from)) {
21552 if (!ar) ar = Array.prototype.slice.call(from, 0, i);
21553 ar[i] = from[i];
21554 }
21555 }
21556 return to.concat(ar || Array.prototype.slice.call(from));
21557 }
21558
21559 function __await(v) {
21560 return this instanceof __await ? (this.v = v, this) : new __await(v);
21561 }
21562
21563 function __asyncGenerator(thisArg, _arguments, generator) {
21564 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
21565 var g = generator.apply(thisArg, _arguments || []), i, q = [];
21566 return i = {}, verb("next"), verb("throw"), verb("return", awaitReturn), i[Symbol.asyncIterator] = function () { return this; }, i;
21567 function awaitReturn(f) { return function (v) { return Promise.resolve(v).then(f, reject); }; }
21568 function verb(n, f) { if (g[n]) { i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; if (f) i[n] = f(i[n]); } }
21569 function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
21570 function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
21571 function fulfill(value) { resume("next", value); }
21572 function reject(value) { resume("throw", value); }
21573 function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
21574 }
21575
21576 function __asyncDelegator(o) {
21577 var i, p;
21578 return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
21579 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; }
21580 }
21581
21582 function __asyncValues(o) {
21583 if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
21584 var m = o[Symbol.asyncIterator], i;
21585 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);
21586 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); }); }; }
21587 function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
21588 }
21589
21590 function __makeTemplateObject(cooked, raw) {
21591 if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
21592 return cooked;
21593 };
21594
21595 var __setModuleDefault = Object.create ? (function(o, v) {
21596 Object.defineProperty(o, "default", { enumerable: true, value: v });
21597 }) : function(o, v) {
21598 o["default"] = v;
21599 };
21600
21601 function __importStar(mod) {
21602 if (mod && mod.__esModule) return mod;
21603 var result = {};
21604 if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
21605 __setModuleDefault(result, mod);
21606 return result;
21607 }
21608
21609 function __importDefault(mod) {
21610 return (mod && mod.__esModule) ? mod : { default: mod };
21611 }
21612
21613 function __classPrivateFieldGet(receiver, state, kind, f) {
21614 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
21615 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");
21616 return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
21617 }
21618
21619 function __classPrivateFieldSet(receiver, state, value, kind, f) {
21620 if (kind === "m") throw new TypeError("Private method is not writable");
21621 if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
21622 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");
21623 return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
21624 }
21625
21626 function __classPrivateFieldIn(state, receiver) {
21627 if (receiver === null || (typeof receiver !== "object" && typeof receiver !== "function")) throw new TypeError("Cannot use 'in' operator on non-object");
21628 return typeof state === "function" ? receiver === state : state.has(receiver);
21629 }
21630
21631 function __addDisposableResource(env, value, async) {
21632 if (value !== null && value !== void 0) {
21633 if (typeof value !== "object" && typeof value !== "function") throw new TypeError("Object expected.");
21634 var dispose, inner;
21635 if (async) {
21636 if (!Symbol.asyncDispose) throw new TypeError("Symbol.asyncDispose is not defined.");
21637 dispose = value[Symbol.asyncDispose];
21638 }
21639 if (dispose === void 0) {
21640 if (!Symbol.dispose) throw new TypeError("Symbol.dispose is not defined.");
21641 dispose = value[Symbol.dispose];
21642 if (async) inner = dispose;
21643 }
21644 if (typeof dispose !== "function") throw new TypeError("Object not disposable.");
21645 if (inner) dispose = function() { try { inner.call(this); } catch (e) { return Promise.reject(e); } };
21646 env.stack.push({ value: value, dispose: dispose, async: async });
21647 }
21648 else if (async) {
21649 env.stack.push({ async: true });
21650 }
21651 return value;
21652 }
21653
21654 var _SuppressedError = typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
21655 var e = new Error(message);
21656 return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
21657 };
21658
21659 function __disposeResources(env) {
21660 function fail(e) {
21661 env.error = env.hasError ? new _SuppressedError(e, env.error, "An error was suppressed during disposal.") : e;
21662 env.hasError = true;
21663 }
21664 function next() {
21665 while (env.stack.length) {
21666 var rec = env.stack.pop();
21667 try {
21668 var result = rec.dispose && rec.dispose.call(rec.value);
21669 if (rec.async) return Promise.resolve(result).then(next, function(e) { fail(e); return next(); });
21670 }
21671 catch (e) {
21672 fail(e);
21673 }
21674 }
21675 if (env.hasError) throw env.error;
21676 }
21677 return next();
21678 }
21679
21680 /* harmony default export */ const tslib_es6 = ({
21681 __extends,
21682 __assign,
21683 __rest,
21684 __decorate,
21685 __param,
21686 __metadata,
21687 __awaiter,
21688 __generator,
21689 __createBinding,
21690 __exportStar,
21691 __values,
21692 __read,
21693 __spread,
21694 __spreadArrays,
21695 __spreadArray,
21696 __await,
21697 __asyncGenerator,
21698 __asyncDelegator,
21699 __asyncValues,
21700 __makeTemplateObject,
21701 __importStar,
21702 __importDefault,
21703 __classPrivateFieldGet,
21704 __classPrivateFieldSet,
21705 __classPrivateFieldIn,
21706 __addDisposableResource,
21707 __disposeResources,
21708 });
21709
21710 ;// CONCATENATED MODULE: ./node_modules/lower-case/dist.es2015/index.js
21711 /**
21712 * Source: ftp://ftp.unicode.org/Public/UCD/latest/ucd/SpecialCasing.txt
21713 */
21714 var SUPPORTED_LOCALE = {
21715 tr: {
21716 regexp: /\u0130|\u0049|\u0049\u0307/g,
21717 map: {
21718 İ: "\u0069",
21719 I: "\u0131",
21720 İ: "\u0069",
21721 },
21722 },
21723 az: {
21724 regexp: /\u0130/g,
21725 map: {
21726 İ: "\u0069",
21727 I: "\u0131",
21728 İ: "\u0069",
21729 },
21730 },
21731 lt: {
21732 regexp: /\u0049|\u004A|\u012E|\u00CC|\u00CD|\u0128/g,
21733 map: {
21734 I: "\u0069\u0307",
21735 J: "\u006A\u0307",
21736 Į: "\u012F\u0307",
21737 Ì: "\u0069\u0307\u0300",
21738 Í: "\u0069\u0307\u0301",
21739 Ĩ: "\u0069\u0307\u0303",
21740 },
21741 },
21742 };
21743 /**
21744 * Localized lower case.
21745 */
21746 function localeLowerCase(str, locale) {
21747 var lang = SUPPORTED_LOCALE[locale.toLowerCase()];
21748 if (lang)
21749 return lowerCase(str.replace(lang.regexp, function (m) { return lang.map[m]; }));
21750 return lowerCase(str);
21751 }
21752 /**
21753 * Lower case as a function.
21754 */
21755 function lowerCase(str) {
21756 return str.toLowerCase();
21757 }
21758
21759 ;// CONCATENATED MODULE: ./node_modules/no-case/dist.es2015/index.js
21760
21761 // Support camel case ("camelCase" -> "camel Case" and "CAMELCase" -> "CAMEL Case").
21762 var DEFAULT_SPLIT_REGEXP = [/([a-z0-9])([A-Z])/g, /([A-Z])([A-Z][a-z])/g];
21763 // Remove all non-word characters.
21764 var DEFAULT_STRIP_REGEXP = /[^A-Z0-9]+/gi;
21765 /**
21766 * Normalize the string into something other libraries can manipulate easier.
21767 */
21768 function noCase(input, options) {
21769 if (options === void 0) { options = {}; }
21770 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;
21771 var result = replace(replace(input, splitRegexp, "$1\0$2"), stripRegexp, "\0");
21772 var start = 0;
21773 var end = result.length;
21774 // Trim the delimiter from around the output string.
21775 while (result.charAt(start) === "\0")
21776 start++;
21777 while (result.charAt(end - 1) === "\0")
21778 end--;
21779 // Transform each token independently.
21780 return result.slice(start, end).split("\0").map(transform).join(delimiter);
21781 }
21782 /**
21783 * Replace `re` in the input string with the replacement value.
21784 */
21785 function replace(input, re, value) {
21786 if (re instanceof RegExp)
21787 return input.replace(re, value);
21788 return re.reduce(function (input, re) { return input.replace(re, value); }, input);
21789 }
21790
21791 ;// CONCATENATED MODULE: ./node_modules/dot-case/dist.es2015/index.js
21792
21793
21794 function dotCase(input, options) {
21795 if (options === void 0) { options = {}; }
21796 return noCase(input, __assign({ delimiter: "." }, options));
21797 }
21798
21799 ;// CONCATENATED MODULE: ./node_modules/param-case/dist.es2015/index.js
21800
21801
21802 function paramCase(input, options) {
21803 if (options === void 0) { options = {}; }
21804 return dotCase(input, __assign({ delimiter: "-" }, options));
21805 }
21806
21807 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/create-template-part-modal/utils.js
21808 /**
21809 * External dependencies
21810 */
21811
21812
21813 /**
21814 * WordPress dependencies
21815 */
21816
21817
21818
21819 /**
21820 * Internal dependencies
21821 */
21822
21823 const useExistingTemplateParts = () => {
21824 return (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getEntityRecords('postType', TEMPLATE_PART_POST_TYPE, {
21825 per_page: -1
21826 }), []);
21827 };
21828
21829 /**
21830 * Return a unique template part title based on
21831 * the given title and existing template parts.
21832 *
21833 * @param {string} title The original template part title.
21834 * @param {Object} templateParts The array of template part entities.
21835 * @return {string} A unique template part title.
21836 */
21837 const getUniqueTemplatePartTitle = (title, templateParts) => {
21838 const lowercaseTitle = title.toLowerCase();
21839 const existingTitles = templateParts.map(templatePart => templatePart.title.rendered.toLowerCase());
21840 if (!existingTitles.includes(lowercaseTitle)) {
21841 return title;
21842 }
21843 let suffix = 2;
21844 while (existingTitles.includes(`${lowercaseTitle} ${suffix}`)) {
21845 suffix++;
21846 }
21847 return `${title} ${suffix}`;
21848 };
21849
21850 /**
21851 * Get a valid slug for a template part.
21852 * Currently template parts only allow latin chars.
21853 * The fallback slug will receive suffix by default.
21854 *
21855 * @param {string} title The template part title.
21856 * @return {string} A valid template part slug.
21857 */
21858 const getCleanTemplatePartSlug = title => {
21859 return paramCase(title).replace(/[^\w-]+/g, '') || 'wp-custom-part';
21860 };
21861
21862 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/create-template-part-modal/index.js
21863 /**
21864 * WordPress dependencies
21865 */
21866
21867
21868
21869
21870
21871
21872
21873
21874
21875
21876 /**
21877 * Internal dependencies
21878 */
21879
21880
21881
21882
21883
21884 function CreateTemplatePartModal({
21885 modalTitle,
21886 ...restProps
21887 }) {
21888 const defaultModalTitle = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_coreData_namespaceObject.store).getPostType(TEMPLATE_PART_POST_TYPE)?.labels?.add_new_item, []);
21889 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
21890 title: modalTitle || defaultModalTitle,
21891 onRequestClose: restProps.closeModal,
21892 overlayClassName: "editor-create-template-part-modal",
21893 focusOnMount: "firstContentElement",
21894 size: "medium",
21895 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateTemplatePartModalContents, {
21896 ...restProps
21897 })
21898 });
21899 }
21900 function CreateTemplatePartModalContents({
21901 defaultArea = TEMPLATE_PART_AREA_DEFAULT_CATEGORY,
21902 blocks = [],
21903 confirmLabel = (0,external_wp_i18n_namespaceObject.__)('Add'),
21904 closeModal,
21905 onCreate,
21906 onError,
21907 defaultTitle = ''
21908 }) {
21909 const {
21910 createErrorNotice
21911 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
21912 const {
21913 saveEntityRecord
21914 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
21915 const existingTemplateParts = useExistingTemplateParts();
21916 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(defaultTitle);
21917 const [area, setArea] = (0,external_wp_element_namespaceObject.useState)(defaultArea);
21918 const [isSubmitting, setIsSubmitting] = (0,external_wp_element_namespaceObject.useState)(false);
21919 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(CreateTemplatePartModal);
21920 const templatePartAreas = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).__experimentalGetDefaultTemplatePartAreas(), []);
21921 async function createTemplatePart() {
21922 if (!title || isSubmitting) {
21923 return;
21924 }
21925 try {
21926 setIsSubmitting(true);
21927 const uniqueTitle = getUniqueTemplatePartTitle(title, existingTemplateParts);
21928 const cleanSlug = getCleanTemplatePartSlug(uniqueTitle);
21929 const templatePart = await saveEntityRecord('postType', TEMPLATE_PART_POST_TYPE, {
21930 slug: cleanSlug,
21931 title: uniqueTitle,
21932 content: (0,external_wp_blocks_namespaceObject.serialize)(blocks),
21933 area
21934 }, {
21935 throwOnError: true
21936 });
21937 await onCreate(templatePart);
21938
21939 // TODO: Add a success notice?
21940 } catch (error) {
21941 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while creating the template part.');
21942 createErrorNotice(errorMessage, {
21943 type: 'snackbar'
21944 });
21945 onError?.();
21946 } finally {
21947 setIsSubmitting(false);
21948 }
21949 }
21950 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
21951 onSubmit: async event => {
21952 event.preventDefault();
21953 await createTemplatePart();
21954 },
21955 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
21956 spacing: "4",
21957 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
21958 __next40pxDefaultSize: true,
21959 __nextHasNoMarginBottom: true,
21960 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
21961 value: title,
21962 onChange: setTitle,
21963 required: true
21964 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.BaseControl, {
21965 label: (0,external_wp_i18n_namespaceObject.__)('Area'),
21966 id: `editor-create-template-part-modal__area-selection-${instanceId}`,
21967 className: "editor-create-template-part-modal__area-base-control",
21968 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalRadioGroup, {
21969 label: (0,external_wp_i18n_namespaceObject.__)('Area'),
21970 className: "editor-create-template-part-modal__area-radio-group",
21971 id: `editor-create-template-part-modal__area-selection-${instanceId}`,
21972 onChange: setArea,
21973 checked: area,
21974 children: templatePartAreas.map(({
21975 icon,
21976 label,
21977 area: value,
21978 description
21979 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalRadio, {
21980 value: value,
21981 className: "editor-create-template-part-modal__area-radio",
21982 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.Flex, {
21983 align: "start",
21984 justify: "start",
21985 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
21986 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
21987 icon: icon
21988 })
21989 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.FlexBlock, {
21990 className: "editor-create-template-part-modal__option-label",
21991 children: [label, /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
21992 children: description
21993 })]
21994 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.FlexItem, {
21995 className: "editor-create-template-part-modal__checkbox",
21996 children: area === value && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
21997 icon: library_check
21998 })
21999 })]
22000 })
22001 }, label))
22002 })
22003 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
22004 justify: "right",
22005 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
22006 __next40pxDefaultSize: true,
22007 variant: "tertiary",
22008 onClick: () => {
22009 closeModal();
22010 },
22011 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
22012 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
22013 __next40pxDefaultSize: true,
22014 variant: "primary",
22015 type: "submit",
22016 "aria-disabled": !title || isSubmitting,
22017 isBusy: isSubmitting,
22018 children: confirmLabel
22019 })]
22020 })]
22021 })
22022 });
22023 }
22024
22025 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-part-menu-items/convert-to-template-part.js
22026 /**
22027 * WordPress dependencies
22028 */
22029
22030
22031
22032
22033
22034
22035
22036
22037
22038 /**
22039 * Internal dependencies
22040 */
22041
22042
22043
22044
22045 function ConvertToTemplatePart({
22046 clientIds,
22047 blocks
22048 }) {
22049 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
22050 const {
22051 replaceBlocks
22052 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
22053 const {
22054 createSuccessNotice
22055 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
22056 const {
22057 canCreate
22058 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22059 return {
22060 canCreate: select(external_wp_blockEditor_namespaceObject.store).canInsertBlockType('core/template-part')
22061 };
22062 }, []);
22063 if (!canCreate) {
22064 return null;
22065 }
22066 const onConvert = async templatePart => {
22067 replaceBlocks(clientIds, (0,external_wp_blocks_namespaceObject.createBlock)('core/template-part', {
22068 slug: templatePart.slug,
22069 theme: templatePart.theme
22070 }));
22071 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Template part created.'), {
22072 type: 'snackbar'
22073 });
22074
22075 // The modal and this component will be unmounted because of `replaceBlocks` above,
22076 // so no need to call `closeModal` or `onClose`.
22077 };
22078 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22079 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
22080 icon: symbol_filled,
22081 onClick: () => {
22082 setIsModalOpen(true);
22083 },
22084 "aria-expanded": isModalOpen,
22085 "aria-haspopup": "dialog",
22086 children: (0,external_wp_i18n_namespaceObject.__)('Create template part')
22087 }), isModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateTemplatePartModal, {
22088 closeModal: () => {
22089 setIsModalOpen(false);
22090 },
22091 blocks: blocks,
22092 onCreate: onConvert
22093 })]
22094 });
22095 }
22096
22097 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-part-menu-items/index.js
22098 /**
22099 * WordPress dependencies
22100 */
22101
22102
22103
22104 /**
22105 * Internal dependencies
22106 */
22107
22108
22109
22110 function TemplatePartMenuItems() {
22111 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockSettingsMenuControls, {
22112 children: ({
22113 selectedClientIds,
22114 onClose
22115 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatePartConverterMenuItem, {
22116 clientIds: selectedClientIds,
22117 onClose: onClose
22118 })
22119 });
22120 }
22121 function TemplatePartConverterMenuItem({
22122 clientIds,
22123 onClose
22124 }) {
22125 const {
22126 isContentOnly,
22127 blocks
22128 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22129 const {
22130 getBlocksByClientId,
22131 getBlockEditingMode
22132 } = select(external_wp_blockEditor_namespaceObject.store);
22133 return {
22134 blocks: getBlocksByClientId(clientIds),
22135 isContentOnly: clientIds.length === 1 && getBlockEditingMode(clientIds[0]) === 'contentOnly'
22136 };
22137 }, [clientIds]);
22138
22139 // Do not show the convert button if the block is in content-only mode.
22140 if (isContentOnly) {
22141 return null;
22142 }
22143
22144 // Allow converting a single template part to standard blocks.
22145 if (blocks.length === 1 && blocks[0]?.name === 'core/template-part') {
22146 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ConvertToRegularBlocks, {
22147 clientId: clientIds[0],
22148 onClose: onClose
22149 });
22150 }
22151 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ConvertToTemplatePart, {
22152 clientIds: clientIds,
22153 blocks: blocks
22154 });
22155 }
22156
22157 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/index.js
22158 /**
22159 * WordPress dependencies
22160 */
22161
22162
22163
22164
22165
22166
22167
22168
22169
22170 /**
22171 * Internal dependencies
22172 */
22173
22174
22175
22176
22177
22178
22179
22180
22181
22182
22183
22184
22185
22186
22187
22188
22189
22190
22191
22192
22193 const {
22194 ExperimentalBlockEditorProvider
22195 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
22196 const {
22197 PatternsMenuItems
22198 } = unlock(external_wp_patterns_namespaceObject.privateApis);
22199 const provider_noop = () => {};
22200
22201 /**
22202 * These are global entities that are only there to split blocks into logical units
22203 * They don't provide a "context" for the current post/page being rendered.
22204 * So we should not use their ids as post context. This is important to allow post blocks
22205 * (post content, post title) to be used within them without issues.
22206 */
22207 const NON_CONTEXTUAL_POST_TYPES = ['wp_block', 'wp_template', 'wp_navigation', 'wp_template_part'];
22208
22209 /**
22210 * Depending on the post, template and template mode,
22211 * returns the appropriate blocks and change handlers for the block editor provider.
22212 *
22213 * @param {Array} post Block list.
22214 * @param {boolean} template Whether the page content has focus (and the surrounding template is inert). If `true` return page content blocks. Default `false`.
22215 * @param {string} mode Rendering mode.
22216 *
22217 * @example
22218 * ```jsx
22219 * const [ blocks, onInput, onChange ] = useBlockEditorProps( post, template, mode );
22220 * ```
22221 *
22222 * @return {Array} Block editor props.
22223 */
22224 function useBlockEditorProps(post, template, mode) {
22225 const rootLevelPost = mode === 'post-only' || !template ? 'post' : 'template';
22226 const [postBlocks, onInput, onChange] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', post.type, {
22227 id: post.id
22228 });
22229 const [templateBlocks, onInputTemplate, onChangeTemplate] = (0,external_wp_coreData_namespaceObject.useEntityBlockEditor)('postType', template?.type, {
22230 id: template?.id
22231 });
22232 const maybeNavigationBlocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
22233 if (post.type === 'wp_navigation') {
22234 return [(0,external_wp_blocks_namespaceObject.createBlock)('core/navigation', {
22235 ref: post.id,
22236 // As the parent editor is locked with `templateLock`, the template locking
22237 // must be explicitly "unset" on the block itself to allow the user to modify
22238 // the block's content.
22239 templateLock: false
22240 })];
22241 }
22242 }, [post.type, post.id]);
22243
22244 // It is important that we don't create a new instance of blocks on every change
22245 // We should only create a new instance if the blocks them selves change, not a dependency of them.
22246 const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
22247 if (maybeNavigationBlocks) {
22248 return maybeNavigationBlocks;
22249 }
22250 if (rootLevelPost === 'template') {
22251 return templateBlocks;
22252 }
22253 return postBlocks;
22254 }, [maybeNavigationBlocks, rootLevelPost, templateBlocks, postBlocks]);
22255
22256 // Handle fallback to postBlocks outside of the above useMemo, to ensure
22257 // that constructed block templates that call `createBlock` are not generated
22258 // too frequently. This ensures that clientIds are stable.
22259 const disableRootLevelChanges = !!template && mode === 'template-locked' || post.type === 'wp_navigation';
22260 if (disableRootLevelChanges) {
22261 return [blocks, provider_noop, provider_noop];
22262 }
22263 return [blocks, rootLevelPost === 'post' ? onInput : onInputTemplate, rootLevelPost === 'post' ? onChange : onChangeTemplate];
22264 }
22265
22266 /**
22267 * This component provides the editor context and manages the state of the block editor.
22268 *
22269 * @param {Object} props The component props.
22270 * @param {Object} props.post The post object.
22271 * @param {Object} props.settings The editor settings.
22272 * @param {boolean} props.recovery Indicates if the editor is in recovery mode.
22273 * @param {Array} props.initialEdits The initial edits for the editor.
22274 * @param {Object} props.children The child components.
22275 * @param {Object} [props.BlockEditorProviderComponent] The block editor provider component to use. Defaults to ExperimentalBlockEditorProvider.
22276 * @param {Object} [props.__unstableTemplate] The template object.
22277 *
22278 * @example
22279 * ```jsx
22280 * <ExperimentalEditorProvider
22281 * post={ post }
22282 * settings={ settings }
22283 * recovery={ recovery }
22284 * initialEdits={ initialEdits }
22285 * __unstableTemplate={ template }
22286 * >
22287 * { children }
22288 * </ExperimentalEditorProvider>
22289 *
22290 * @return {Object} The rendered ExperimentalEditorProvider component.
22291 */
22292 const ExperimentalEditorProvider = with_registry_provider(({
22293 post,
22294 settings,
22295 recovery,
22296 initialEdits,
22297 children,
22298 BlockEditorProviderComponent = ExperimentalBlockEditorProvider,
22299 __unstableTemplate: template
22300 }) => {
22301 const {
22302 editorSettings,
22303 selection,
22304 isReady,
22305 mode
22306 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22307 const {
22308 getEditorSettings,
22309 getEditorSelection,
22310 getRenderingMode,
22311 __unstableIsEditorReady
22312 } = select(store_store);
22313 return {
22314 editorSettings: getEditorSettings(),
22315 isReady: __unstableIsEditorReady(),
22316 mode: getRenderingMode(),
22317 selection: getEditorSelection()
22318 };
22319 }, []);
22320 const shouldRenderTemplate = !!template && mode !== 'post-only';
22321 const rootLevelPost = shouldRenderTemplate ? template : post;
22322 const defaultBlockContext = (0,external_wp_element_namespaceObject.useMemo)(() => {
22323 const postContext = !NON_CONTEXTUAL_POST_TYPES.includes(rootLevelPost.type) || shouldRenderTemplate ? {
22324 postId: post.id,
22325 postType: post.type
22326 } : {};
22327 return {
22328 ...postContext,
22329 templateSlug: rootLevelPost.type === 'wp_template' ? rootLevelPost.slug : undefined
22330 };
22331 }, [shouldRenderTemplate, post.id, post.type, rootLevelPost.type, rootLevelPost.slug]);
22332 const {
22333 id,
22334 type
22335 } = rootLevelPost;
22336 const blockEditorSettings = use_block_editor_settings(editorSettings, type, id, mode);
22337 const [blocks, onInput, onChange] = useBlockEditorProps(post, template, mode);
22338 const {
22339 updatePostLock,
22340 setupEditor,
22341 updateEditorSettings,
22342 setCurrentTemplateId,
22343 setEditedPost,
22344 setRenderingMode
22345 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
22346 const {
22347 createWarningNotice
22348 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
22349
22350 // Ideally this should be synced on each change and not just something you do once.
22351 (0,external_wp_element_namespaceObject.useLayoutEffect)(() => {
22352 // Assume that we don't need to initialize in the case of an error recovery.
22353 if (recovery) {
22354 return;
22355 }
22356 updatePostLock(settings.postLock);
22357 setupEditor(post, initialEdits, settings.template);
22358 if (settings.autosave) {
22359 createWarningNotice((0,external_wp_i18n_namespaceObject.__)('There is an autosave of this post that is more recent than the version below.'), {
22360 id: 'autosave-exists',
22361 actions: [{
22362 label: (0,external_wp_i18n_namespaceObject.__)('View the autosave'),
22363 url: settings.autosave.editLink
22364 }]
22365 });
22366 }
22367 }, []);
22368
22369 // Synchronizes the active post with the state
22370 (0,external_wp_element_namespaceObject.useEffect)(() => {
22371 setEditedPost(post.type, post.id);
22372 }, [post.type, post.id, setEditedPost]);
22373
22374 // Synchronize the editor settings as they change.
22375 (0,external_wp_element_namespaceObject.useEffect)(() => {
22376 updateEditorSettings(settings);
22377 }, [settings, updateEditorSettings]);
22378
22379 // Synchronizes the active template with the state.
22380 (0,external_wp_element_namespaceObject.useEffect)(() => {
22381 setCurrentTemplateId(template?.id);
22382 }, [template?.id, setCurrentTemplateId]);
22383
22384 // Sets the right rendering mode when loading the editor.
22385 (0,external_wp_element_namespaceObject.useEffect)(() => {
22386 var _settings$defaultRend;
22387 setRenderingMode((_settings$defaultRend = settings.defaultRenderingMode) !== null && _settings$defaultRend !== void 0 ? _settings$defaultRend : 'post-only');
22388 }, [settings.defaultRenderingMode, setRenderingMode]);
22389 useHideBlocksFromInserter(post.type, mode);
22390
22391 // Register the editor commands.
22392 useCommands();
22393 if (!isReady) {
22394 return null;
22395 }
22396 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_coreData_namespaceObject.EntityProvider, {
22397 kind: "root",
22398 type: "site",
22399 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_coreData_namespaceObject.EntityProvider, {
22400 kind: "postType",
22401 type: post.type,
22402 id: post.id,
22403 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockContextProvider, {
22404 value: defaultBlockContext,
22405 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(BlockEditorProviderComponent, {
22406 value: blocks,
22407 onChange: onChange,
22408 onInput: onInput,
22409 selection: selection,
22410 settings: blockEditorSettings,
22411 useSubRegistry: false,
22412 children: [children, !settings.__unstableIsPreviewMode && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
22413 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternsMenuItems, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatePartMenuItems, {}), /*#__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, {})]
22414 })]
22415 })
22416 })
22417 })
22418 });
22419 });
22420
22421 /**
22422 * This component establishes a new post editing context, and serves as the entry point for a new post editor (or post with template editor).
22423 *
22424 * It supports a large number of post types, including post, page, templates,
22425 * custom post types, patterns, template parts.
22426 *
22427 * All modification and changes are performed to the `@wordpress/core-data` store.
22428 *
22429 * @param {Object} props The component props.
22430 * @param {Object} [props.post] The post object to edit. This is required.
22431 * @param {Object} [props.__unstableTemplate] The template object wrapper the edited post.
22432 * This is optional and can only be used when the post type supports templates (like posts and pages).
22433 * @param {Object} [props.settings] The settings object to use for the editor.
22434 * This is optional and can be used to override the default settings.
22435 * @param {Element} [props.children] Children elements for which the BlockEditorProvider context should apply.
22436 * This is optional.
22437 *
22438 * @example
22439 * ```jsx
22440 * <EditorProvider
22441 * post={ post }
22442 * settings={ settings }
22443 * __unstableTemplate={ template }
22444 * >
22445 * { children }
22446 * </EditorProvider>
22447 * ```
22448 *
22449 * @return {JSX.Element} The rendered EditorProvider component.
22450 */
22451 function EditorProvider(props) {
22452 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExperimentalEditorProvider, {
22453 ...props,
22454 BlockEditorProviderComponent: external_wp_blockEditor_namespaceObject.BlockEditorProvider,
22455 children: props.children
22456 });
22457 }
22458 /* harmony default export */ const provider = (EditorProvider);
22459
22460 ;// CONCATENATED MODULE: external ["wp","serverSideRender"]
22461 const external_wp_serverSideRender_namespaceObject = window["wp"]["serverSideRender"];
22462 var external_wp_serverSideRender_default = /*#__PURE__*/__webpack_require__.n(external_wp_serverSideRender_namespaceObject);
22463 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/deprecated.js
22464 // Block Creation Components.
22465 /**
22466 * WordPress dependencies
22467 */
22468
22469
22470
22471
22472
22473 function deprecateComponent(name, Wrapped, staticsToHoist = []) {
22474 const Component = (0,external_wp_element_namespaceObject.forwardRef)((props, ref) => {
22475 external_wp_deprecated_default()('wp.editor.' + name, {
22476 since: '5.3',
22477 alternative: 'wp.blockEditor.' + name,
22478 version: '6.2'
22479 });
22480 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Wrapped, {
22481 ref: ref,
22482 ...props
22483 });
22484 });
22485 staticsToHoist.forEach(staticName => {
22486 Component[staticName] = deprecateComponent(name + '.' + staticName, Wrapped[staticName]);
22487 });
22488 return Component;
22489 }
22490 function deprecateFunction(name, func) {
22491 return (...args) => {
22492 external_wp_deprecated_default()('wp.editor.' + name, {
22493 since: '5.3',
22494 alternative: 'wp.blockEditor.' + name,
22495 version: '6.2'
22496 });
22497 return func(...args);
22498 };
22499 }
22500
22501 /**
22502 * @deprecated since 5.3, use `wp.blockEditor.RichText` instead.
22503 */
22504 const RichText = deprecateComponent('RichText', external_wp_blockEditor_namespaceObject.RichText, ['Content']);
22505 RichText.isEmpty = deprecateFunction('RichText.isEmpty', external_wp_blockEditor_namespaceObject.RichText.isEmpty);
22506
22507
22508 /**
22509 * @deprecated since 5.3, use `wp.blockEditor.Autocomplete` instead.
22510 */
22511 const Autocomplete = deprecateComponent('Autocomplete', external_wp_blockEditor_namespaceObject.Autocomplete);
22512 /**
22513 * @deprecated since 5.3, use `wp.blockEditor.AlignmentToolbar` instead.
22514 */
22515 const AlignmentToolbar = deprecateComponent('AlignmentToolbar', external_wp_blockEditor_namespaceObject.AlignmentToolbar);
22516 /**
22517 * @deprecated since 5.3, use `wp.blockEditor.BlockAlignmentToolbar` instead.
22518 */
22519 const BlockAlignmentToolbar = deprecateComponent('BlockAlignmentToolbar', external_wp_blockEditor_namespaceObject.BlockAlignmentToolbar);
22520 /**
22521 * @deprecated since 5.3, use `wp.blockEditor.BlockControls` instead.
22522 */
22523 const BlockControls = deprecateComponent('BlockControls', external_wp_blockEditor_namespaceObject.BlockControls, ['Slot']);
22524 /**
22525 * @deprecated since 5.3, use `wp.blockEditor.BlockEdit` instead.
22526 */
22527 const BlockEdit = deprecateComponent('BlockEdit', external_wp_blockEditor_namespaceObject.BlockEdit);
22528 /**
22529 * @deprecated since 5.3, use `wp.blockEditor.BlockEditorKeyboardShortcuts` instead.
22530 */
22531 const BlockEditorKeyboardShortcuts = deprecateComponent('BlockEditorKeyboardShortcuts', external_wp_blockEditor_namespaceObject.BlockEditorKeyboardShortcuts);
22532 /**
22533 * @deprecated since 5.3, use `wp.blockEditor.BlockFormatControls` instead.
22534 */
22535 const BlockFormatControls = deprecateComponent('BlockFormatControls', external_wp_blockEditor_namespaceObject.BlockFormatControls, ['Slot']);
22536 /**
22537 * @deprecated since 5.3, use `wp.blockEditor.BlockIcon` instead.
22538 */
22539 const BlockIcon = deprecateComponent('BlockIcon', external_wp_blockEditor_namespaceObject.BlockIcon);
22540 /**
22541 * @deprecated since 5.3, use `wp.blockEditor.BlockInspector` instead.
22542 */
22543 const BlockInspector = deprecateComponent('BlockInspector', external_wp_blockEditor_namespaceObject.BlockInspector);
22544 /**
22545 * @deprecated since 5.3, use `wp.blockEditor.BlockList` instead.
22546 */
22547 const BlockList = deprecateComponent('BlockList', external_wp_blockEditor_namespaceObject.BlockList);
22548 /**
22549 * @deprecated since 5.3, use `wp.blockEditor.BlockMover` instead.
22550 */
22551 const BlockMover = deprecateComponent('BlockMover', external_wp_blockEditor_namespaceObject.BlockMover);
22552 /**
22553 * @deprecated since 5.3, use `wp.blockEditor.BlockNavigationDropdown` instead.
22554 */
22555 const BlockNavigationDropdown = deprecateComponent('BlockNavigationDropdown', external_wp_blockEditor_namespaceObject.BlockNavigationDropdown);
22556 /**
22557 * @deprecated since 5.3, use `wp.blockEditor.BlockSelectionClearer` instead.
22558 */
22559 const BlockSelectionClearer = deprecateComponent('BlockSelectionClearer', external_wp_blockEditor_namespaceObject.BlockSelectionClearer);
22560 /**
22561 * @deprecated since 5.3, use `wp.blockEditor.BlockSettingsMenu` instead.
22562 */
22563 const BlockSettingsMenu = deprecateComponent('BlockSettingsMenu', external_wp_blockEditor_namespaceObject.BlockSettingsMenu);
22564 /**
22565 * @deprecated since 5.3, use `wp.blockEditor.BlockTitle` instead.
22566 */
22567 const BlockTitle = deprecateComponent('BlockTitle', external_wp_blockEditor_namespaceObject.BlockTitle);
22568 /**
22569 * @deprecated since 5.3, use `wp.blockEditor.BlockToolbar` instead.
22570 */
22571 const BlockToolbar = deprecateComponent('BlockToolbar', external_wp_blockEditor_namespaceObject.BlockToolbar);
22572 /**
22573 * @deprecated since 5.3, use `wp.blockEditor.ColorPalette` instead.
22574 */
22575 const ColorPalette = deprecateComponent('ColorPalette', external_wp_blockEditor_namespaceObject.ColorPalette);
22576 /**
22577 * @deprecated since 5.3, use `wp.blockEditor.ContrastChecker` instead.
22578 */
22579 const ContrastChecker = deprecateComponent('ContrastChecker', external_wp_blockEditor_namespaceObject.ContrastChecker);
22580 /**
22581 * @deprecated since 5.3, use `wp.blockEditor.CopyHandler` instead.
22582 */
22583 const CopyHandler = deprecateComponent('CopyHandler', external_wp_blockEditor_namespaceObject.CopyHandler);
22584 /**
22585 * @deprecated since 5.3, use `wp.blockEditor.DefaultBlockAppender` instead.
22586 */
22587 const DefaultBlockAppender = deprecateComponent('DefaultBlockAppender', external_wp_blockEditor_namespaceObject.DefaultBlockAppender);
22588 /**
22589 * @deprecated since 5.3, use `wp.blockEditor.FontSizePicker` instead.
22590 */
22591 const FontSizePicker = deprecateComponent('FontSizePicker', external_wp_blockEditor_namespaceObject.FontSizePicker);
22592 /**
22593 * @deprecated since 5.3, use `wp.blockEditor.Inserter` instead.
22594 */
22595 const Inserter = deprecateComponent('Inserter', external_wp_blockEditor_namespaceObject.Inserter);
22596 /**
22597 * @deprecated since 5.3, use `wp.blockEditor.InnerBlocks` instead.
22598 */
22599 const InnerBlocks = deprecateComponent('InnerBlocks', external_wp_blockEditor_namespaceObject.InnerBlocks, ['ButtonBlockAppender', 'DefaultBlockAppender', 'Content']);
22600 /**
22601 * @deprecated since 5.3, use `wp.blockEditor.InspectorAdvancedControls` instead.
22602 */
22603 const InspectorAdvancedControls = deprecateComponent('InspectorAdvancedControls', external_wp_blockEditor_namespaceObject.InspectorAdvancedControls, ['Slot']);
22604 /**
22605 * @deprecated since 5.3, use `wp.blockEditor.InspectorControls` instead.
22606 */
22607 const InspectorControls = deprecateComponent('InspectorControls', external_wp_blockEditor_namespaceObject.InspectorControls, ['Slot']);
22608 /**
22609 * @deprecated since 5.3, use `wp.blockEditor.PanelColorSettings` instead.
22610 */
22611 const PanelColorSettings = deprecateComponent('PanelColorSettings', external_wp_blockEditor_namespaceObject.PanelColorSettings);
22612 /**
22613 * @deprecated since 5.3, use `wp.blockEditor.PlainText` instead.
22614 */
22615 const PlainText = deprecateComponent('PlainText', external_wp_blockEditor_namespaceObject.PlainText);
22616 /**
22617 * @deprecated since 5.3, use `wp.blockEditor.RichTextShortcut` instead.
22618 */
22619 const RichTextShortcut = deprecateComponent('RichTextShortcut', external_wp_blockEditor_namespaceObject.RichTextShortcut);
22620 /**
22621 * @deprecated since 5.3, use `wp.blockEditor.RichTextToolbarButton` instead.
22622 */
22623 const RichTextToolbarButton = deprecateComponent('RichTextToolbarButton', external_wp_blockEditor_namespaceObject.RichTextToolbarButton);
22624 /**
22625 * @deprecated since 5.3, use `wp.blockEditor.__unstableRichTextInputEvent` instead.
22626 */
22627 const __unstableRichTextInputEvent = deprecateComponent('__unstableRichTextInputEvent', external_wp_blockEditor_namespaceObject.__unstableRichTextInputEvent);
22628 /**
22629 * @deprecated since 5.3, use `wp.blockEditor.MediaPlaceholder` instead.
22630 */
22631 const MediaPlaceholder = deprecateComponent('MediaPlaceholder', external_wp_blockEditor_namespaceObject.MediaPlaceholder);
22632 /**
22633 * @deprecated since 5.3, use `wp.blockEditor.MediaUpload` instead.
22634 */
22635 const MediaUpload = deprecateComponent('MediaUpload', external_wp_blockEditor_namespaceObject.MediaUpload);
22636 /**
22637 * @deprecated since 5.3, use `wp.blockEditor.MediaUploadCheck` instead.
22638 */
22639 const MediaUploadCheck = deprecateComponent('MediaUploadCheck', external_wp_blockEditor_namespaceObject.MediaUploadCheck);
22640 /**
22641 * @deprecated since 5.3, use `wp.blockEditor.MultiSelectScrollIntoView` instead.
22642 */
22643 const MultiSelectScrollIntoView = deprecateComponent('MultiSelectScrollIntoView', external_wp_blockEditor_namespaceObject.MultiSelectScrollIntoView);
22644 /**
22645 * @deprecated since 5.3, use `wp.blockEditor.NavigableToolbar` instead.
22646 */
22647 const NavigableToolbar = deprecateComponent('NavigableToolbar', external_wp_blockEditor_namespaceObject.NavigableToolbar);
22648 /**
22649 * @deprecated since 5.3, use `wp.blockEditor.ObserveTyping` instead.
22650 */
22651 const ObserveTyping = deprecateComponent('ObserveTyping', external_wp_blockEditor_namespaceObject.ObserveTyping);
22652 /**
22653 * @deprecated since 5.3, use `wp.blockEditor.SkipToSelectedBlock` instead.
22654 */
22655 const SkipToSelectedBlock = deprecateComponent('SkipToSelectedBlock', external_wp_blockEditor_namespaceObject.SkipToSelectedBlock);
22656 /**
22657 * @deprecated since 5.3, use `wp.blockEditor.URLInput` instead.
22658 */
22659 const URLInput = deprecateComponent('URLInput', external_wp_blockEditor_namespaceObject.URLInput);
22660 /**
22661 * @deprecated since 5.3, use `wp.blockEditor.URLInputButton` instead.
22662 */
22663 const URLInputButton = deprecateComponent('URLInputButton', external_wp_blockEditor_namespaceObject.URLInputButton);
22664 /**
22665 * @deprecated since 5.3, use `wp.blockEditor.URLPopover` instead.
22666 */
22667 const URLPopover = deprecateComponent('URLPopover', external_wp_blockEditor_namespaceObject.URLPopover);
22668 /**
22669 * @deprecated since 5.3, use `wp.blockEditor.Warning` instead.
22670 */
22671 const Warning = deprecateComponent('Warning', external_wp_blockEditor_namespaceObject.Warning);
22672 /**
22673 * @deprecated since 5.3, use `wp.blockEditor.WritingFlow` instead.
22674 */
22675 const WritingFlow = deprecateComponent('WritingFlow', external_wp_blockEditor_namespaceObject.WritingFlow);
22676
22677 /**
22678 * @deprecated since 5.3, use `wp.blockEditor.createCustomColorsHOC` instead.
22679 */
22680 const createCustomColorsHOC = deprecateFunction('createCustomColorsHOC', external_wp_blockEditor_namespaceObject.createCustomColorsHOC);
22681 /**
22682 * @deprecated since 5.3, use `wp.blockEditor.getColorClassName` instead.
22683 */
22684 const getColorClassName = deprecateFunction('getColorClassName', external_wp_blockEditor_namespaceObject.getColorClassName);
22685 /**
22686 * @deprecated since 5.3, use `wp.blockEditor.getColorObjectByAttributeValues` instead.
22687 */
22688 const getColorObjectByAttributeValues = deprecateFunction('getColorObjectByAttributeValues', external_wp_blockEditor_namespaceObject.getColorObjectByAttributeValues);
22689 /**
22690 * @deprecated since 5.3, use `wp.blockEditor.getColorObjectByColorValue` instead.
22691 */
22692 const getColorObjectByColorValue = deprecateFunction('getColorObjectByColorValue', external_wp_blockEditor_namespaceObject.getColorObjectByColorValue);
22693 /**
22694 * @deprecated since 5.3, use `wp.blockEditor.getFontSize` instead.
22695 */
22696 const getFontSize = deprecateFunction('getFontSize', external_wp_blockEditor_namespaceObject.getFontSize);
22697 /**
22698 * @deprecated since 5.3, use `wp.blockEditor.getFontSizeClass` instead.
22699 */
22700 const getFontSizeClass = deprecateFunction('getFontSizeClass', external_wp_blockEditor_namespaceObject.getFontSizeClass);
22701 /**
22702 * @deprecated since 5.3, use `wp.blockEditor.createCustomColorsHOC` instead.
22703 */
22704 const withColorContext = deprecateFunction('withColorContext', external_wp_blockEditor_namespaceObject.withColorContext);
22705 /**
22706 * @deprecated since 5.3, use `wp.blockEditor.withColors` instead.
22707 */
22708 const withColors = deprecateFunction('withColors', external_wp_blockEditor_namespaceObject.withColors);
22709 /**
22710 * @deprecated since 5.3, use `wp.blockEditor.withFontSizes` instead.
22711 */
22712 const withFontSizes = deprecateFunction('withFontSizes', external_wp_blockEditor_namespaceObject.withFontSizes);
22713
22714 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/index.js
22715 /**
22716 * Internal dependencies
22717 */
22718
22719
22720 // Block Creation Components.
22721
22722
22723 // Post Related Components.
22724
22725
22726
22727
22728
22729
22730
22731
22732
22733
22734
22735
22736
22737
22738
22739
22740
22741
22742
22743
22744
22745
22746
22747
22748
22749
22750
22751
22752
22753
22754
22755
22756
22757
22758
22759
22760
22761
22762
22763
22764
22765
22766
22767
22768
22769
22770
22771
22772
22773
22774
22775
22776
22777
22778
22779
22780
22781
22782
22783
22784
22785
22786
22787
22788
22789
22790
22791
22792
22793
22794
22795
22796
22797
22798
22799
22800
22801
22802
22803
22804
22805
22806
22807
22808
22809
22810
22811
22812 // State Related Components.
22813
22814
22815
22816 /**
22817 * Handles the keyboard shortcuts for the editor.
22818 *
22819 * It provides functionality for various keyboard shortcuts such as toggling editor mode,
22820 * toggling distraction-free mode, undo/redo, saving the post, toggling list view,
22821 * and toggling the sidebar.
22822 */
22823 const VisualEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
22824
22825 /**
22826 * Handles the keyboard shortcuts for the editor.
22827 *
22828 * It provides functionality for various keyboard shortcuts such as toggling editor mode,
22829 * toggling distraction-free mode, undo/redo, saving the post, toggling list view,
22830 * and toggling the sidebar.
22831 */
22832 const TextEditorGlobalKeyboardShortcuts = EditorKeyboardShortcuts;
22833
22834 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/url.js
22835 /**
22836 * WordPress dependencies
22837 */
22838
22839
22840
22841 /**
22842 * Performs some basic cleanup of a string for use as a post slug
22843 *
22844 * This replicates some of what sanitize_title() does in WordPress core, but
22845 * is only designed to approximate what the slug will be.
22846 *
22847 * Converts Latin-1 Supplement and Latin Extended-A letters to basic Latin letters.
22848 * Removes combining diacritical marks. Converts whitespace, periods,
22849 * and forward slashes to hyphens. Removes any remaining non-word characters
22850 * except hyphens and underscores. Converts remaining string to lowercase.
22851 * It does not account for octets, HTML entities, or other encoded characters.
22852 *
22853 * @param {string} string Title or slug to be processed
22854 *
22855 * @return {string} Processed string
22856 */
22857 function cleanForSlug(string) {
22858 external_wp_deprecated_default()('wp.editor.cleanForSlug', {
22859 since: '12.7',
22860 plugin: 'Gutenberg',
22861 alternative: 'wp.url.cleanForSlug'
22862 });
22863 return (0,external_wp_url_namespaceObject.cleanForSlug)(string);
22864 }
22865
22866 ;// CONCATENATED MODULE: ./packages/editor/build-module/utils/index.js
22867 /**
22868 * Internal dependencies
22869 */
22870
22871
22872
22873
22874
22875 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-interface/content-slot-fill.js
22876 /**
22877 * WordPress dependencies
22878 */
22879
22880
22881 /**
22882 * Internal dependencies
22883 */
22884
22885 const {
22886 createPrivateSlotFill
22887 } = unlock(external_wp_components_namespaceObject.privateApis);
22888 const SLOT_FILL_NAME = 'EditCanvasContainerSlot';
22889 const EditorContentSlotFill = createPrivateSlotFill(SLOT_FILL_NAME);
22890 /* harmony default export */ const content_slot_fill = (EditorContentSlotFill);
22891
22892 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/header/back-button.js
22893 /**
22894 * WordPress dependencies
22895 */
22896
22897
22898 // Keeping an old name for backward compatibility.
22899
22900 const slotName = '__experimentalMainDashboardButton';
22901 const useHasBackButton = () => {
22902 const fills = (0,external_wp_components_namespaceObject.__experimentalUseSlotFills)(slotName);
22903 return Boolean(fills && fills.length);
22904 };
22905 const {
22906 Fill: back_button_Fill,
22907 Slot: back_button_Slot
22908 } = (0,external_wp_components_namespaceObject.createSlotFill)(slotName);
22909 const BackButton = back_button_Fill;
22910 const BackButtonSlot = () => {
22911 const fills = (0,external_wp_components_namespaceObject.__experimentalUseSlotFills)(slotName);
22912 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(back_button_Slot, {
22913 bubblesVirtually: true,
22914 fillProps: {
22915 length: !fills ? 0 : fills.length
22916 }
22917 });
22918 };
22919 BackButton.Slot = BackButtonSlot;
22920 /* harmony default export */ const back_button = (BackButton);
22921
22922 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/next.js
22923 /**
22924 * WordPress dependencies
22925 */
22926
22927
22928 const next = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
22929 xmlns: "http://www.w3.org/2000/svg",
22930 viewBox: "0 0 24 24",
22931 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
22932 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"
22933 })
22934 });
22935 /* harmony default export */ const library_next = (next);
22936
22937 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/previous.js
22938 /**
22939 * WordPress dependencies
22940 */
22941
22942
22943 const previous = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
22944 xmlns: "http://www.w3.org/2000/svg",
22945 viewBox: "0 0 24 24",
22946 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
22947 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"
22948 })
22949 });
22950 /* harmony default export */ const library_previous = (previous);
22951
22952 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/collapsible-block-toolbar/index.js
22953 /**
22954 * External dependencies
22955 */
22956
22957
22958 /**
22959 * WordPress dependencies
22960 */
22961
22962
22963
22964
22965
22966
22967
22968 /**
22969 * Internal dependencies
22970 */
22971
22972
22973
22974
22975 const {
22976 useHasBlockToolbar
22977 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
22978 function CollapsibleBlockToolbar({
22979 isCollapsed,
22980 onToggle
22981 }) {
22982 const {
22983 blockSelectionStart
22984 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
22985 return {
22986 blockSelectionStart: select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart()
22987 };
22988 }, []);
22989 const hasBlockToolbar = useHasBlockToolbar();
22990 const hasBlockSelection = !!blockSelectionStart;
22991 (0,external_wp_element_namespaceObject.useEffect)(() => {
22992 // If we have a new block selection, show the block tools
22993 if (blockSelectionStart) {
22994 onToggle(false);
22995 }
22996 }, [blockSelectionStart, onToggle]);
22997 if (!hasBlockToolbar) {
22998 return null;
22999 }
23000 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23001 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
23002 className: dist_clsx('editor-collapsible-block-toolbar', {
23003 'is-collapsed': isCollapsed || !hasBlockSelection
23004 }),
23005 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockToolbar, {
23006 hideDragHandle: true
23007 })
23008 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Popover.Slot, {
23009 name: "block-toolbar"
23010 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
23011 className: "editor-collapsible-block-toolbar__toggle",
23012 icon: isCollapsed ? library_next : library_previous,
23013 onClick: () => {
23014 onToggle(!isCollapsed);
23015 },
23016 label: isCollapsed ? (0,external_wp_i18n_namespaceObject.__)('Show block tools') : (0,external_wp_i18n_namespaceObject.__)('Hide block tools'),
23017 size: "compact"
23018 })]
23019 });
23020 }
23021
23022 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/plus.js
23023 /**
23024 * WordPress dependencies
23025 */
23026
23027
23028 const plus = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23029 xmlns: "http://www.w3.org/2000/svg",
23030 viewBox: "0 0 24 24",
23031 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23032 d: "M11 12.5V17.5H12.5V12.5H17.5V11H12.5V6H11V11H6V12.5H11Z"
23033 })
23034 });
23035 /* harmony default export */ const library_plus = (plus);
23036
23037 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/document-tools/index.js
23038 /**
23039 * External dependencies
23040 */
23041
23042
23043 /**
23044 * WordPress dependencies
23045 */
23046
23047
23048
23049
23050
23051
23052
23053
23054
23055
23056 /**
23057 * Internal dependencies
23058 */
23059
23060
23061
23062
23063
23064
23065
23066 function DocumentTools({
23067 className,
23068 disableBlockTools = false
23069 }) {
23070 const {
23071 setIsInserterOpened,
23072 setIsListViewOpened
23073 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23074 const {
23075 isDistractionFree,
23076 isInserterOpened,
23077 isListViewOpen,
23078 listViewShortcut,
23079 inserterSidebarToggleRef,
23080 listViewToggleRef,
23081 hasFixedToolbar,
23082 showIconLabels
23083 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23084 const {
23085 getSettings
23086 } = select(external_wp_blockEditor_namespaceObject.store);
23087 const {
23088 get
23089 } = select(external_wp_preferences_namespaceObject.store);
23090 const {
23091 isListViewOpened,
23092 getEditorMode,
23093 getInserterSidebarToggleRef,
23094 getListViewToggleRef
23095 } = unlock(select(store_store));
23096 const {
23097 getShortcutRepresentation
23098 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
23099 const {
23100 __unstableGetEditorMode
23101 } = select(external_wp_blockEditor_namespaceObject.store);
23102 return {
23103 isInserterOpened: select(store_store).isInserterOpened(),
23104 isListViewOpen: isListViewOpened(),
23105 listViewShortcut: getShortcutRepresentation('core/editor/toggle-list-view'),
23106 inserterSidebarToggleRef: getInserterSidebarToggleRef(),
23107 listViewToggleRef: getListViewToggleRef(),
23108 hasFixedToolbar: getSettings().hasFixedToolbar,
23109 showIconLabels: get('core', 'showIconLabels'),
23110 isDistractionFree: get('core', 'distractionFree'),
23111 isVisualMode: getEditorMode() === 'visual',
23112 isZoomedOutView: __unstableGetEditorMode() === 'zoom-out'
23113 };
23114 }, []);
23115 const preventDefault = event => {
23116 // Because the inserter behaves like a dialog,
23117 // if the inserter is opened already then when we click on the toggle button
23118 // then the initial click event will close the inserter and then be propagated
23119 // to the inserter toggle and it will open it again.
23120 // To prevent this we need to stop the propagation of the event.
23121 // This won't be necessary when the inserter no longer behaves like a dialog.
23122
23123 if (isInserterOpened) {
23124 event.preventDefault();
23125 }
23126 };
23127 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
23128 const isWideViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('wide');
23129
23130 /* translators: accessibility text for the editor toolbar */
23131 const toolbarAriaLabel = (0,external_wp_i18n_namespaceObject.__)('Document tools');
23132 const toggleListView = (0,external_wp_element_namespaceObject.useCallback)(() => setIsListViewOpened(!isListViewOpen), [setIsListViewOpened, isListViewOpen]);
23133 const toggleInserter = (0,external_wp_element_namespaceObject.useCallback)(() => setIsInserterOpened(!isInserterOpened), [isInserterOpened, setIsInserterOpened]);
23134
23135 /* translators: button label text should, if possible, be under 16 characters. */
23136 const longLabel = (0,external_wp_i18n_namespaceObject._x)('Toggle block inserter', 'Generic label for block inserter button');
23137 const shortLabel = !isInserterOpened ? (0,external_wp_i18n_namespaceObject.__)('Add') : (0,external_wp_i18n_namespaceObject.__)('Close');
23138 return (
23139 /*#__PURE__*/
23140 // Some plugins expect and use the `edit-post-header-toolbar` CSS class to
23141 // find the toolbar and inject UI elements into it. This is not officially
23142 // supported, but we're keeping it in the list of class names for backwards
23143 // compatibility.
23144 (0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.NavigableToolbar, {
23145 className: dist_clsx('editor-document-tools', 'edit-post-header-toolbar', className),
23146 "aria-label": toolbarAriaLabel,
23147 variant: "unstyled",
23148 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
23149 className: "editor-document-tools__left",
23150 children: [!isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
23151 ref: inserterSidebarToggleRef,
23152 as: external_wp_components_namespaceObject.Button,
23153 className: "editor-document-tools__inserter-toggle",
23154 variant: "primary",
23155 isPressed: isInserterOpened,
23156 onMouseDown: preventDefault,
23157 onClick: toggleInserter,
23158 disabled: disableBlockTools,
23159 icon: library_plus,
23160 label: showIconLabels ? shortLabel : longLabel,
23161 showTooltip: !showIconLabels,
23162 "aria-expanded": isInserterOpened
23163 }), (isWideViewport || !showIconLabels) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23164 children: [isLargeViewport && !hasFixedToolbar && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
23165 as: external_wp_blockEditor_namespaceObject.ToolSelector,
23166 showTooltip: !showIconLabels,
23167 variant: showIconLabels ? 'tertiary' : undefined,
23168 disabled: disableBlockTools,
23169 size: "compact"
23170 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
23171 as: editor_history_undo,
23172 showTooltip: !showIconLabels,
23173 variant: showIconLabels ? 'tertiary' : undefined,
23174 size: "compact"
23175 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
23176 as: editor_history_redo,
23177 showTooltip: !showIconLabels,
23178 variant: showIconLabels ? 'tertiary' : undefined,
23179 size: "compact"
23180 }), !isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ToolbarItem, {
23181 as: external_wp_components_namespaceObject.Button,
23182 className: "editor-document-tools__document-overview-toggle",
23183 icon: list_view,
23184 disabled: disableBlockTools,
23185 isPressed: isListViewOpen
23186 /* translators: button label text should, if possible, be under 16 characters. */,
23187 label: (0,external_wp_i18n_namespaceObject.__)('Document Overview'),
23188 onClick: toggleListView,
23189 shortcut: listViewShortcut,
23190 showTooltip: !showIconLabels,
23191 variant: showIconLabels ? 'tertiary' : undefined,
23192 "aria-expanded": isListViewOpen,
23193 ref: listViewToggleRef,
23194 size: "compact"
23195 })]
23196 })]
23197 })
23198 })
23199 );
23200 }
23201 /* harmony default export */ const document_tools = (DocumentTools);
23202
23203 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/more-vertical.js
23204 /**
23205 * WordPress dependencies
23206 */
23207
23208
23209 const moreVertical = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23210 xmlns: "http://www.w3.org/2000/svg",
23211 viewBox: "0 0 24 24",
23212 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23213 d: "M13 19h-2v-2h2v2zm0-6h-2v-2h2v2zm0-6h-2V5h2v2z"
23214 })
23215 });
23216 /* harmony default export */ const more_vertical = (moreVertical);
23217
23218 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/more-menu/copy-content-menu-item.js
23219 /**
23220 * WordPress dependencies
23221 */
23222
23223
23224
23225
23226
23227
23228
23229
23230 /**
23231 * Internal dependencies
23232 */
23233
23234
23235 function CopyContentMenuItem() {
23236 const {
23237 createNotice
23238 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
23239 const {
23240 getCurrentPostId,
23241 getCurrentPostType
23242 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
23243 const {
23244 getEditedEntityRecord
23245 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_coreData_namespaceObject.store);
23246 function getText() {
23247 const record = getEditedEntityRecord('postType', getCurrentPostType(), getCurrentPostId());
23248 if (!record) {
23249 return '';
23250 }
23251 if (typeof record.content === 'function') {
23252 return record.content(record);
23253 } else if (record.blocks) {
23254 return (0,external_wp_blocks_namespaceObject.__unstableSerializeAndClean)(record.blocks);
23255 } else if (record.content) {
23256 return record.content;
23257 }
23258 }
23259 function onSuccess() {
23260 createNotice('info', (0,external_wp_i18n_namespaceObject.__)('All content copied.'), {
23261 isDismissible: true,
23262 type: 'snackbar'
23263 });
23264 }
23265 const ref = (0,external_wp_compose_namespaceObject.useCopyToClipboard)(getText, onSuccess);
23266 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
23267 ref: ref,
23268 children: (0,external_wp_i18n_namespaceObject.__)('Copy all blocks')
23269 });
23270 }
23271
23272 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/mode-switcher/index.js
23273 /**
23274 * WordPress dependencies
23275 */
23276
23277
23278
23279
23280
23281 /**
23282 * Internal dependencies
23283 */
23284
23285
23286 /**
23287 * Set of available mode options.
23288 *
23289 * @type {Array}
23290 */
23291
23292 const MODES = [{
23293 value: 'visual',
23294 label: (0,external_wp_i18n_namespaceObject.__)('Visual editor')
23295 }, {
23296 value: 'text',
23297 label: (0,external_wp_i18n_namespaceObject.__)('Code editor')
23298 }];
23299 function ModeSwitcher() {
23300 const {
23301 shortcut,
23302 isRichEditingEnabled,
23303 isCodeEditingEnabled,
23304 mode
23305 } = (0,external_wp_data_namespaceObject.useSelect)(select => ({
23306 shortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/editor/toggle-mode'),
23307 isRichEditingEnabled: select(store_store).getEditorSettings().richEditingEnabled,
23308 isCodeEditingEnabled: select(store_store).getEditorSettings().codeEditingEnabled,
23309 mode: select(store_store).getEditorMode()
23310 }), []);
23311 const {
23312 switchEditorMode
23313 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23314 let selectedMode = mode;
23315 if (!isRichEditingEnabled && mode === 'visual') {
23316 selectedMode = 'text';
23317 }
23318 if (!isCodeEditingEnabled && mode === 'text') {
23319 selectedMode = 'visual';
23320 }
23321 const choices = MODES.map(choice => {
23322 if (!isCodeEditingEnabled && choice.value === 'text') {
23323 choice = {
23324 ...choice,
23325 disabled: true
23326 };
23327 }
23328 if (!isRichEditingEnabled && choice.value === 'visual') {
23329 choice = {
23330 ...choice,
23331 disabled: true,
23332 info: (0,external_wp_i18n_namespaceObject.__)('You can enable the visual editor in your profile settings.')
23333 };
23334 }
23335 if (choice.value !== selectedMode && !choice.disabled) {
23336 return {
23337 ...choice,
23338 shortcut
23339 };
23340 }
23341 return choice;
23342 });
23343 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
23344 label: (0,external_wp_i18n_namespaceObject.__)('Editor'),
23345 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItemsChoice, {
23346 choices: choices,
23347 value: selectedMode,
23348 onSelect: switchEditorMode
23349 })
23350 });
23351 }
23352 /* harmony default export */ const mode_switcher = (ModeSwitcher);
23353
23354 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/more-menu/tools-more-menu-group.js
23355 /**
23356 * WordPress dependencies
23357 */
23358
23359
23360 const {
23361 Fill: ToolsMoreMenuGroup,
23362 Slot: tools_more_menu_group_Slot
23363 } = (0,external_wp_components_namespaceObject.createSlotFill)('ToolsMoreMenuGroup');
23364 ToolsMoreMenuGroup.Slot = ({
23365 fillProps
23366 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(tools_more_menu_group_Slot, {
23367 fillProps: fillProps
23368 });
23369 /* harmony default export */ const tools_more_menu_group = (ToolsMoreMenuGroup);
23370
23371 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/more-menu/view-more-menu-group.js
23372 /**
23373 * WordPress dependencies
23374 */
23375
23376
23377
23378 const {
23379 Fill: ViewMoreMenuGroup,
23380 Slot: view_more_menu_group_Slot
23381 } = (0,external_wp_components_namespaceObject.createSlotFill)(external_wp_element_namespaceObject.Platform.OS === 'web' ? Symbol('ViewMoreMenuGroup') : 'ViewMoreMenuGroup');
23382 ViewMoreMenuGroup.Slot = ({
23383 fillProps
23384 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(view_more_menu_group_Slot, {
23385 fillProps: fillProps
23386 });
23387 /* harmony default export */ const view_more_menu_group = (ViewMoreMenuGroup);
23388
23389 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/more-menu/index.js
23390 /**
23391 * WordPress dependencies
23392 */
23393
23394
23395
23396
23397
23398
23399
23400
23401 /**
23402 * Internal dependencies
23403 */
23404
23405
23406
23407
23408
23409
23410
23411
23412 function MoreMenu() {
23413 const {
23414 openModal
23415 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
23416 const {
23417 set: setPreference
23418 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
23419 const {
23420 toggleDistractionFree
23421 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23422 const showIconLabels = (0,external_wp_data_namespaceObject.useSelect)(select => select(external_wp_preferences_namespaceObject.store).get('core', 'showIconLabels'), []);
23423 const turnOffDistractionFree = () => {
23424 setPreference('core', 'distractionFree', false);
23425 };
23426 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23427 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
23428 icon: more_vertical,
23429 label: (0,external_wp_i18n_namespaceObject.__)('Options'),
23430 popoverProps: {
23431 placement: 'bottom-end',
23432 className: 'more-menu-dropdown__content'
23433 },
23434 toggleProps: {
23435 showTooltip: !showIconLabels,
23436 ...(showIconLabels && {
23437 variant: 'tertiary'
23438 }),
23439 tooltipPosition: 'bottom',
23440 size: 'compact'
23441 },
23442 children: ({
23443 onClose
23444 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23445 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
23446 label: (0,external_wp_i18n_namespaceObject._x)('View', 'noun'),
23447 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
23448 scope: "core",
23449 name: "fixedToolbar",
23450 onToggle: turnOffDistractionFree,
23451 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar'),
23452 info: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place'),
23453 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar activated'),
23454 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Top toolbar deactivated')
23455 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
23456 scope: "core",
23457 name: "distractionFree",
23458 label: (0,external_wp_i18n_namespaceObject.__)('Distraction free'),
23459 info: (0,external_wp_i18n_namespaceObject.__)('Write with calmness'),
23460 handleToggling: false,
23461 onToggle: toggleDistractionFree,
23462 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode activated'),
23463 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Distraction free mode deactivated'),
23464 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.primaryShift('\\')
23465 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_preferences_namespaceObject.PreferenceToggleMenuItem, {
23466 scope: "core",
23467 name: "focusMode",
23468 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode'),
23469 info: (0,external_wp_i18n_namespaceObject.__)('Focus on one block at a time'),
23470 messageActivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode activated'),
23471 messageDeactivated: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode deactivated')
23472 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(view_more_menu_group.Slot, {
23473 fillProps: {
23474 onClose
23475 }
23476 })]
23477 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(mode_switcher, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(action_item.Slot, {
23478 name: "core/plugin-more-menu",
23479 label: (0,external_wp_i18n_namespaceObject.__)('Plugins'),
23480 as: external_wp_components_namespaceObject.MenuGroup,
23481 fillProps: {
23482 onClick: onClose
23483 }
23484 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
23485 label: (0,external_wp_i18n_namespaceObject.__)('Tools'),
23486 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
23487 onClick: () => openModal('editor/keyboard-shortcut-help'),
23488 shortcut: external_wp_keycodes_namespaceObject.displayShortcut.access('h'),
23489 children: (0,external_wp_i18n_namespaceObject.__)('Keyboard shortcuts')
23490 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CopyContentMenuItem, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuItem, {
23491 icon: library_external,
23492 href: (0,external_wp_i18n_namespaceObject.__)('https://wordpress.org/documentation/article/wordpress-block-editor/'),
23493 target: "_blank",
23494 rel: "noopener noreferrer",
23495 children: [(0,external_wp_i18n_namespaceObject.__)('Help'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
23496 as: "span",
23497 children: /* translators: accessibility text */
23498 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')
23499 })]
23500 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(tools_more_menu_group.Slot, {
23501 fillProps: {
23502 onClose
23503 }
23504 })]
23505 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
23506 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
23507 onClick: () => openModal('editor/preferences'),
23508 children: (0,external_wp_i18n_namespaceObject.__)('Preferences')
23509 })
23510 })]
23511 })
23512 })
23513 });
23514 }
23515
23516 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-publish-button/post-publish-button-or-toggle.js
23517 /**
23518 * WordPress dependencies
23519 */
23520
23521
23522
23523 /**
23524 * Internal dependencies
23525 */
23526
23527
23528
23529 function PostPublishButtonOrToggle({
23530 forceIsDirty,
23531 hasPublishAction,
23532 isBeingScheduled,
23533 isPending,
23534 isPublished,
23535 isPublishSidebarEnabled,
23536 isPublishSidebarOpened,
23537 isScheduled,
23538 togglePublishSidebar,
23539 setEntitiesSavedStatesCallback,
23540 postStatusHasChanged,
23541 postStatus
23542 }) {
23543 const IS_TOGGLE = 'toggle';
23544 const IS_BUTTON = 'button';
23545 const isSmallerThanMediumViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
23546 let component;
23547
23548 /**
23549 * Conditions to show a BUTTON (publish directly) or a TOGGLE (open publish sidebar):
23550 *
23551 * 1) We want to show a BUTTON when the post status is at the _final stage_
23552 * for a particular role (see https://wordpress.org/documentation/article/post-status/):
23553 *
23554 * - is published
23555 * - post status has changed explicitely to something different than 'future' or 'publish'
23556 * - is scheduled to be published
23557 * - is pending and can't be published (but only for viewports >= medium).
23558 * Originally, we considered showing a button for pending posts that couldn't be published
23559 * (for example, for an author with the contributor role). Some languages can have
23560 * long translations for "Submit for review", so given the lack of UI real estate available
23561 * we decided to take into account the viewport in that case.
23562 * See: https://github.com/WordPress/gutenberg/issues/10475
23563 *
23564 * 2) Then, in small viewports, we'll show a TOGGLE.
23565 *
23566 * 3) Finally, we'll use the publish sidebar status to decide:
23567 *
23568 * - if it is enabled, we show a TOGGLE
23569 * - if it is disabled, we show a BUTTON
23570 */
23571 if (isPublished || postStatusHasChanged && !['future', 'publish'].includes(postStatus) || isScheduled && isBeingScheduled || isPending && !hasPublishAction && !isSmallerThanMediumViewport) {
23572 component = IS_BUTTON;
23573 } else if (isSmallerThanMediumViewport || isPublishSidebarEnabled) {
23574 component = IS_TOGGLE;
23575 } else {
23576 component = IS_BUTTON;
23577 }
23578 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_button, {
23579 forceIsDirty: forceIsDirty,
23580 isOpen: isPublishSidebarOpened,
23581 isToggle: component === IS_TOGGLE,
23582 onToggle: togglePublishSidebar,
23583 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
23584 });
23585 }
23586 /* harmony default export */ const post_publish_button_or_toggle = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => {
23587 var _select$getCurrentPos;
23588 return {
23589 hasPublishAction: (_select$getCurrentPos = select(store_store).getCurrentPost()?._links?.['wp:action-publish']) !== null && _select$getCurrentPos !== void 0 ? _select$getCurrentPos : false,
23590 isBeingScheduled: select(store_store).isEditedPostBeingScheduled(),
23591 isPending: select(store_store).isCurrentPostPending(),
23592 isPublished: select(store_store).isCurrentPostPublished(),
23593 isPublishSidebarEnabled: select(store_store).isPublishSidebarEnabled(),
23594 isPublishSidebarOpened: select(store_store).isPublishSidebarOpened(),
23595 isScheduled: select(store_store).isCurrentPostScheduled(),
23596 postStatus: select(store_store).getEditedPostAttribute('status'),
23597 postStatusHasChanged: select(store_store).getPostEdits()?.status
23598 };
23599 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
23600 const {
23601 togglePublishSidebar
23602 } = dispatch(store_store);
23603 return {
23604 togglePublishSidebar
23605 };
23606 }))(PostPublishButtonOrToggle));
23607
23608 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-view-link/index.js
23609 /**
23610 * WordPress dependencies
23611 */
23612
23613
23614
23615
23616
23617
23618
23619 /**
23620 * Internal dependencies
23621 */
23622
23623
23624 function PostViewLink() {
23625 const {
23626 hasLoaded,
23627 permalink,
23628 isPublished,
23629 label,
23630 showIconLabels
23631 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23632 // Grab post type to retrieve the view_item label.
23633 const postTypeSlug = select(store_store).getCurrentPostType();
23634 const postType = select(external_wp_coreData_namespaceObject.store).getPostType(postTypeSlug);
23635 const {
23636 get
23637 } = select(external_wp_preferences_namespaceObject.store);
23638 return {
23639 permalink: select(store_store).getPermalink(),
23640 isPublished: select(store_store).isCurrentPostPublished(),
23641 label: postType?.labels.view_item,
23642 hasLoaded: !!postType,
23643 showIconLabels: get('core', 'showIconLabels')
23644 };
23645 }, []);
23646
23647 // Only render the view button if the post is published and has a permalink.
23648 if (!isPublished || !permalink || !hasLoaded) {
23649 return null;
23650 }
23651 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
23652 icon: library_external,
23653 label: label || (0,external_wp_i18n_namespaceObject.__)('View post'),
23654 href: permalink,
23655 target: "_blank",
23656 showTooltip: !showIconLabels,
23657 size: "compact"
23658 });
23659 }
23660
23661 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/mobile.js
23662 /**
23663 * WordPress dependencies
23664 */
23665
23666
23667 const mobile = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23668 xmlns: "http://www.w3.org/2000/svg",
23669 viewBox: "0 0 24 24",
23670 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23671 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"
23672 })
23673 });
23674 /* harmony default export */ const library_mobile = (mobile);
23675
23676 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/tablet.js
23677 /**
23678 * WordPress dependencies
23679 */
23680
23681
23682 const tablet = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23683 xmlns: "http://www.w3.org/2000/svg",
23684 viewBox: "0 0 24 24",
23685 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23686 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"
23687 })
23688 });
23689 /* harmony default export */ const library_tablet = (tablet);
23690
23691 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/desktop.js
23692 /**
23693 * WordPress dependencies
23694 */
23695
23696
23697 const desktop = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
23698 xmlns: "http://www.w3.org/2000/svg",
23699 viewBox: "0 0 24 24",
23700 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
23701 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"
23702 })
23703 });
23704 /* harmony default export */ const library_desktop = (desktop);
23705
23706 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/preview-dropdown/index.js
23707 /**
23708 * WordPress dependencies
23709 */
23710
23711
23712
23713
23714
23715
23716
23717
23718 /**
23719 * Internal dependencies
23720 */
23721
23722
23723
23724
23725
23726 function PreviewDropdown({
23727 forceIsAutosaveable,
23728 disabled
23729 }) {
23730 const {
23731 deviceType,
23732 homeUrl,
23733 isTemplate,
23734 isViewable,
23735 showIconLabels
23736 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23737 var _getPostType$viewable;
23738 const {
23739 getDeviceType,
23740 getCurrentPostType
23741 } = select(store_store);
23742 const {
23743 getUnstableBase,
23744 getPostType
23745 } = select(external_wp_coreData_namespaceObject.store);
23746 const {
23747 get
23748 } = select(external_wp_preferences_namespaceObject.store);
23749 const _currentPostType = getCurrentPostType();
23750 return {
23751 deviceType: getDeviceType(),
23752 homeUrl: getUnstableBase()?.home,
23753 isTemplate: _currentPostType === 'wp_template',
23754 isViewable: (_getPostType$viewable = getPostType(_currentPostType)?.viewable) !== null && _getPostType$viewable !== void 0 ? _getPostType$viewable : false,
23755 showIconLabels: get('core', 'showIconLabels')
23756 };
23757 }, []);
23758 const {
23759 setDeviceType
23760 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
23761 const isMobile = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
23762 if (isMobile) {
23763 return null;
23764 }
23765 const popoverProps = {
23766 placement: 'bottom-end'
23767 };
23768 const toggleProps = {
23769 className: 'editor-preview-dropdown__toggle',
23770 size: 'compact',
23771 showTooltip: !showIconLabels,
23772 disabled,
23773 accessibleWhenDisabled: disabled
23774 };
23775 const menuProps = {
23776 'aria-label': (0,external_wp_i18n_namespaceObject.__)('View options')
23777 };
23778 const deviceIcons = {
23779 mobile: library_mobile,
23780 tablet: library_tablet,
23781 desktop: library_desktop
23782 };
23783 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.DropdownMenu, {
23784 className: "editor-preview-dropdown",
23785 popoverProps: popoverProps,
23786 toggleProps: toggleProps,
23787 menuProps: menuProps,
23788 icon: deviceIcons[deviceType.toLowerCase()],
23789 label: (0,external_wp_i18n_namespaceObject.__)('View'),
23790 disableOpenOnArrowDown: disabled,
23791 children: ({
23792 onClose
23793 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23794 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuGroup, {
23795 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
23796 onClick: () => setDeviceType('Desktop'),
23797 icon: deviceType === 'Desktop' && library_check,
23798 children: (0,external_wp_i18n_namespaceObject.__)('Desktop')
23799 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
23800 onClick: () => setDeviceType('Tablet'),
23801 icon: deviceType === 'Tablet' && library_check,
23802 children: (0,external_wp_i18n_namespaceObject.__)('Tablet')
23803 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuItem, {
23804 onClick: () => setDeviceType('Mobile'),
23805 icon: deviceType === 'Mobile' && library_check,
23806 children: (0,external_wp_i18n_namespaceObject.__)('Mobile')
23807 })]
23808 }), isTemplate && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
23809 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.MenuItem, {
23810 href: homeUrl,
23811 target: "_blank",
23812 icon: library_external,
23813 onClick: onClose,
23814 children: [(0,external_wp_i18n_namespaceObject.__)('View site'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
23815 as: "span",
23816 children: /* translators: accessibility text */
23817 (0,external_wp_i18n_namespaceObject.__)('(opens in a new tab)')
23818 })]
23819 })
23820 }), isViewable && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.MenuGroup, {
23821 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPreviewButton, {
23822 className: "editor-preview-dropdown__button-external",
23823 role: "menuitem",
23824 forceIsAutosaveable: forceIsAutosaveable,
23825 textContent: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
23826 children: [(0,external_wp_i18n_namespaceObject.__)('Preview in new tab'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
23827 icon: library_external
23828 })]
23829 }),
23830 onPreview: onClose
23831 })
23832 })]
23833 })
23834 });
23835 }
23836
23837 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/header/index.js
23838 /**
23839 * WordPress dependencies
23840 */
23841
23842
23843
23844
23845
23846
23847
23848
23849 /**
23850 * Internal dependencies
23851 */
23852
23853
23854
23855
23856
23857
23858
23859
23860
23861
23862
23863
23864
23865 const toolbarVariations = {
23866 distractionFreeDisabled: {
23867 y: '-50px'
23868 },
23869 distractionFreeHover: {
23870 y: 0
23871 },
23872 distractionFreeHidden: {
23873 y: '-50px'
23874 },
23875 visible: {
23876 y: 0
23877 },
23878 hidden: {
23879 y: 0
23880 }
23881 };
23882 const backButtonVariations = {
23883 distractionFreeDisabled: {
23884 x: '-100%'
23885 },
23886 distractionFreeHover: {
23887 x: 0
23888 },
23889 distractionFreeHidden: {
23890 x: '-100%'
23891 },
23892 visible: {
23893 x: 0
23894 },
23895 hidden: {
23896 x: 0
23897 }
23898 };
23899 function Header({
23900 customSaveButton,
23901 forceIsDirty,
23902 forceDisableBlockTools,
23903 setEntitiesSavedStatesCallback,
23904 title,
23905 icon
23906 }) {
23907 const isWideViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('large');
23908 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
23909 const isTooNarrowForDocumentBar = (0,external_wp_compose_namespaceObject.useMediaQuery)('(max-width: 403px)');
23910 const {
23911 isTextEditor,
23912 isPublishSidebarOpened,
23913 showIconLabels,
23914 hasFixedToolbar,
23915 isNestedEntity,
23916 isZoomedOutView
23917 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
23918 const {
23919 get: getPreference
23920 } = select(external_wp_preferences_namespaceObject.store);
23921 const {
23922 getEditorMode,
23923 getEditorSettings,
23924 isPublishSidebarOpened: _isPublishSidebarOpened
23925 } = select(store_store);
23926 const {
23927 __unstableGetEditorMode
23928 } = select(external_wp_blockEditor_namespaceObject.store);
23929 return {
23930 isTextEditor: getEditorMode() === 'text',
23931 isPublishSidebarOpened: _isPublishSidebarOpened(),
23932 showIconLabels: getPreference('core', 'showIconLabels'),
23933 hasFixedToolbar: getPreference('core', 'fixedToolbar'),
23934 isNestedEntity: !!getEditorSettings().onNavigateToPreviousEntityRecord,
23935 isZoomedOutView: __unstableGetEditorMode() === 'zoom-out'
23936 };
23937 }, []);
23938 const [isBlockToolsCollapsed, setIsBlockToolsCollapsed] = (0,external_wp_element_namespaceObject.useState)(true);
23939 const hasCenter = isBlockToolsCollapsed && !isTooNarrowForDocumentBar;
23940 const hasBackButton = useHasBackButton();
23941
23942 // The edit-post-header classname is only kept for backward compatibilty
23943 // as some plugins might be relying on its presence.
23944 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
23945 className: "editor-header edit-post-header",
23946 children: [hasBackButton && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
23947 className: "editor-header__back-button",
23948 variants: backButtonVariations,
23949 transition: {
23950 type: 'tween'
23951 },
23952 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(back_button.Slot, {})
23953 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
23954 variants: toolbarVariations,
23955 className: "editor-header__toolbar",
23956 transition: {
23957 type: 'tween'
23958 },
23959 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(document_tools, {
23960 disableBlockTools: forceDisableBlockTools || isTextEditor
23961 }), hasFixedToolbar && isLargeViewport && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CollapsibleBlockToolbar, {
23962 isCollapsed: isBlockToolsCollapsed,
23963 onToggle: setIsBlockToolsCollapsed
23964 })]
23965 }), hasCenter && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.div, {
23966 className: "editor-header__center",
23967 variants: toolbarVariations,
23968 transition: {
23969 type: 'tween'
23970 },
23971 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DocumentBar, {
23972 title: title,
23973 icon: icon
23974 })
23975 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__unstableMotion.div, {
23976 variants: toolbarVariations,
23977 transition: {
23978 type: 'tween'
23979 },
23980 className: "editor-header__settings",
23981 children: [!customSaveButton && !isPublishSidebarOpened &&
23982 /*#__PURE__*/
23983 // This button isn't completely hidden by the publish sidebar.
23984 // We can't hide the whole toolbar when the publish sidebar is open because
23985 // we want to prevent mounting/unmounting the PostPublishButtonOrToggle DOM node.
23986 // We track that DOM node to return focus to the PostPublishButtonOrToggle
23987 // when the publish sidebar has been closed.
23988 (0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSavedState, {
23989 forceIsDirty: forceIsDirty
23990 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreviewDropdown, {
23991 forceIsAutosaveable: forceIsDirty,
23992 disabled: isNestedEntity || isZoomedOutView
23993 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostPreviewButton, {
23994 className: "editor-header__post-preview-button",
23995 forceIsAutosaveable: forceIsDirty
23996 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostViewLink, {}), !customSaveButton && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_button_or_toggle, {
23997 forceIsDirty: forceIsDirty,
23998 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback
23999 }), customSaveButton, (isWideViewport || !showIconLabels) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(pinned_items.Slot, {
24000 scope: "core"
24001 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(MoreMenu, {})]
24002 })]
24003 });
24004 }
24005 /* harmony default export */ const components_header = (Header);
24006
24007 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/inserter-sidebar/index.js
24008 /**
24009 * WordPress dependencies
24010 */
24011
24012
24013
24014
24015
24016
24017
24018
24019 /**
24020 * Internal dependencies
24021 */
24022
24023
24024
24025 const {
24026 PrivateInserterLibrary
24027 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
24028 function InserterSidebar() {
24029 const {
24030 blockSectionRootClientId,
24031 inserterSidebarToggleRef,
24032 insertionPoint,
24033 showMostUsedBlocks,
24034 sidebarIsOpened
24035 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24036 const {
24037 getInserterSidebarToggleRef,
24038 getInsertionPoint,
24039 isPublishSidebarOpened
24040 } = unlock(select(store_store));
24041 const {
24042 getBlockRootClientId,
24043 __unstableGetEditorMode,
24044 getSettings
24045 } = select(external_wp_blockEditor_namespaceObject.store);
24046 const {
24047 get
24048 } = select(external_wp_preferences_namespaceObject.store);
24049 const {
24050 getActiveComplementaryArea
24051 } = select(store);
24052 const getBlockSectionRootClientId = () => {
24053 if (__unstableGetEditorMode() === 'zoom-out') {
24054 const {
24055 sectionRootClientId
24056 } = unlock(getSettings());
24057 if (sectionRootClientId) {
24058 return sectionRootClientId;
24059 }
24060 }
24061 return getBlockRootClientId();
24062 };
24063 return {
24064 inserterSidebarToggleRef: getInserterSidebarToggleRef(),
24065 insertionPoint: getInsertionPoint(),
24066 showMostUsedBlocks: get('core', 'mostUsedBlocks'),
24067 blockSectionRootClientId: getBlockSectionRootClientId(),
24068 sidebarIsOpened: !!(getActiveComplementaryArea('core') || isPublishSidebarOpened())
24069 };
24070 }, []);
24071 const {
24072 setIsInserterOpened
24073 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
24074 const {
24075 disableComplementaryArea
24076 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
24077 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium', '<');
24078 const libraryRef = (0,external_wp_element_namespaceObject.useRef)();
24079
24080 // When closing the inserter, focus should return to the toggle button.
24081 const closeInserterSidebar = (0,external_wp_element_namespaceObject.useCallback)(() => {
24082 setIsInserterOpened(false);
24083 inserterSidebarToggleRef.current?.focus();
24084 }, [inserterSidebarToggleRef, setIsInserterOpened]);
24085 const closeOnEscape = (0,external_wp_element_namespaceObject.useCallback)(event => {
24086 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
24087 event.preventDefault();
24088 closeInserterSidebar();
24089 }
24090 }, [closeInserterSidebar]);
24091 const inserterContents = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24092 className: "editor-inserter-sidebar__content",
24093 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivateInserterLibrary, {
24094 showMostUsedBlocks: showMostUsedBlocks,
24095 showInserterHelpPanel: true,
24096 shouldFocusBlock: isMobileViewport,
24097 rootClientId: blockSectionRootClientId !== null && blockSectionRootClientId !== void 0 ? blockSectionRootClientId : insertionPoint.rootClientId,
24098 __experimentalInsertionIndex: insertionPoint.insertionIndex,
24099 onSelect: insertionPoint.onSelect,
24100 __experimentalInitialTab: insertionPoint.tab,
24101 __experimentalInitialCategory: insertionPoint.category,
24102 __experimentalFilterValue: insertionPoint.filterValue,
24103 onPatternCategorySelection: sidebarIsOpened ? () => disableComplementaryArea('core') : undefined,
24104 ref: libraryRef,
24105 onClose: closeInserterSidebar
24106 })
24107 });
24108 return (
24109 /*#__PURE__*/
24110 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
24111 (0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24112 onKeyDown: closeOnEscape,
24113 className: "editor-inserter-sidebar",
24114 children: inserterContents
24115 })
24116 );
24117 }
24118
24119 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/list-view-sidebar/list-view-outline.js
24120 /**
24121 * WordPress dependencies
24122 */
24123
24124
24125
24126 /**
24127 * Internal dependencies
24128 */
24129
24130
24131
24132
24133
24134
24135
24136 function ListViewOutline() {
24137 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
24138 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24139 className: "editor-list-view-sidebar__outline",
24140 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24141 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
24142 children: (0,external_wp_i18n_namespaceObject.__)('Characters:')
24143 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
24144 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CharacterCount, {})
24145 })]
24146 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24147 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
24148 children: (0,external_wp_i18n_namespaceObject.__)('Words:')
24149 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(WordCount, {})]
24150 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24151 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
24152 children: (0,external_wp_i18n_namespaceObject.__)('Time to read:')
24153 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TimeToRead, {})]
24154 })]
24155 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DocumentOutline, {})]
24156 });
24157 }
24158
24159 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/list-view-sidebar/index.js
24160 /**
24161 * WordPress dependencies
24162 */
24163
24164
24165
24166
24167
24168
24169
24170
24171
24172 /**
24173 * Internal dependencies
24174 */
24175
24176
24177
24178
24179 const {
24180 TabbedSidebar
24181 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
24182 function ListViewSidebar() {
24183 const {
24184 setIsListViewOpened
24185 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
24186 const {
24187 getListViewToggleRef
24188 } = unlock((0,external_wp_data_namespaceObject.useSelect)(store_store));
24189
24190 // This hook handles focus when the sidebar first renders.
24191 const focusOnMountRef = (0,external_wp_compose_namespaceObject.useFocusOnMount)('firstElement');
24192
24193 // When closing the list view, focus should return to the toggle button.
24194 const closeListView = (0,external_wp_element_namespaceObject.useCallback)(() => {
24195 setIsListViewOpened(false);
24196 getListViewToggleRef().current?.focus();
24197 }, [getListViewToggleRef, setIsListViewOpened]);
24198 const closeOnEscape = (0,external_wp_element_namespaceObject.useCallback)(event => {
24199 if (event.keyCode === external_wp_keycodes_namespaceObject.ESCAPE && !event.defaultPrevented) {
24200 event.preventDefault();
24201 closeListView();
24202 }
24203 }, [closeListView]);
24204
24205 // Use internal state instead of a ref to make sure that the component
24206 // re-renders when the dropZoneElement updates.
24207 const [dropZoneElement, setDropZoneElement] = (0,external_wp_element_namespaceObject.useState)(null);
24208 // Tracks our current tab.
24209 const [tab, setTab] = (0,external_wp_element_namespaceObject.useState)('list-view');
24210
24211 // This ref refers to the sidebar as a whole.
24212 const sidebarRef = (0,external_wp_element_namespaceObject.useRef)();
24213 // This ref refers to the tab panel.
24214 const tabsRef = (0,external_wp_element_namespaceObject.useRef)();
24215 // This ref refers to the list view application area.
24216 const listViewRef = (0,external_wp_element_namespaceObject.useRef)();
24217
24218 // Must merge the refs together so focus can be handled properly in the next function.
24219 const listViewContainerRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([focusOnMountRef, listViewRef, setDropZoneElement]);
24220
24221 /*
24222 * Callback function to handle list view or outline focus.
24223 *
24224 * @param {string} currentTab The current tab. Either list view or outline.
24225 *
24226 * @return void
24227 */
24228 function handleSidebarFocus(currentTab) {
24229 // Tab panel focus.
24230 const tabPanelFocus = external_wp_dom_namespaceObject.focus.tabbable.find(tabsRef.current)[0];
24231 // List view tab is selected.
24232 if (currentTab === 'list-view') {
24233 // 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.
24234 const listViewApplicationFocus = external_wp_dom_namespaceObject.focus.tabbable.find(listViewRef.current)[0];
24235 const listViewFocusArea = sidebarRef.current.contains(listViewApplicationFocus) ? listViewApplicationFocus : tabPanelFocus;
24236 listViewFocusArea.focus();
24237 // Outline tab is selected.
24238 } else {
24239 tabPanelFocus.focus();
24240 }
24241 }
24242 const handleToggleListViewShortcut = (0,external_wp_element_namespaceObject.useCallback)(() => {
24243 // If the sidebar has focus, it is safe to close.
24244 if (sidebarRef.current.contains(sidebarRef.current.ownerDocument.activeElement)) {
24245 closeListView();
24246 } else {
24247 // If the list view or outline does not have focus, focus should be moved to it.
24248 handleSidebarFocus(tab);
24249 }
24250 }, [closeListView, tab]);
24251
24252 // This only fires when the sidebar is open because of the conditional rendering.
24253 // It is the same shortcut to open but that is defined as a global shortcut and only fires when the sidebar is closed.
24254 (0,external_wp_keyboardShortcuts_namespaceObject.useShortcut)('core/editor/toggle-list-view', handleToggleListViewShortcut);
24255 return (
24256 /*#__PURE__*/
24257 // eslint-disable-next-line jsx-a11y/no-static-element-interactions
24258 (0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24259 className: "editor-list-view-sidebar",
24260 onKeyDown: closeOnEscape,
24261 ref: sidebarRef,
24262 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TabbedSidebar, {
24263 tabs: [{
24264 name: 'list-view',
24265 title: (0,external_wp_i18n_namespaceObject._x)('List View', 'Post overview'),
24266 panel: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24267 className: "editor-list-view-sidebar__list-view-container",
24268 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24269 className: "editor-list-view-sidebar__list-view-panel-content",
24270 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalListView, {
24271 dropZoneElement: dropZoneElement
24272 })
24273 })
24274 }),
24275 panelRef: listViewContainerRef
24276 }, {
24277 name: 'outline',
24278 title: (0,external_wp_i18n_namespaceObject._x)('Outline', 'Post overview'),
24279 panel: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24280 className: "editor-list-view-sidebar__list-view-container",
24281 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ListViewOutline, {})
24282 })
24283 }],
24284 onClose: closeListView,
24285 onSelect: tabName => setTab(tabName),
24286 defaultTabId: "list-view",
24287 ref: tabsRef,
24288 closeButtonLabel: (0,external_wp_i18n_namespaceObject.__)('Close')
24289 })
24290 })
24291 );
24292 }
24293
24294 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/save-publish-panels/index.js
24295 /**
24296 * WordPress dependencies
24297 */
24298
24299
24300
24301
24302
24303 /**
24304 * Internal dependencies
24305 */
24306
24307
24308
24309
24310
24311
24312
24313
24314 const {
24315 Fill: save_publish_panels_Fill,
24316 Slot: save_publish_panels_Slot
24317 } = (0,external_wp_components_namespaceObject.createSlotFill)('ActionsPanel');
24318 const ActionsPanelFill = (/* unused pure expression or super */ null && (save_publish_panels_Fill));
24319 function SavePublishPanels({
24320 setEntitiesSavedStatesCallback,
24321 closeEntitiesSavedStates,
24322 isEntitiesSavedStatesOpen,
24323 forceIsDirtyPublishPanel
24324 }) {
24325 const {
24326 closePublishSidebar,
24327 togglePublishSidebar
24328 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
24329 const {
24330 publishSidebarOpened,
24331 isPublishable,
24332 isDirty,
24333 hasOtherEntitiesChanges
24334 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24335 const {
24336 isPublishSidebarOpened,
24337 isEditedPostPublishable,
24338 isCurrentPostPublished,
24339 isEditedPostDirty,
24340 hasNonPostEntityChanges
24341 } = select(store_store);
24342 const _hasOtherEntitiesChanges = hasNonPostEntityChanges();
24343 return {
24344 publishSidebarOpened: isPublishSidebarOpened(),
24345 isPublishable: !isCurrentPostPublished() && isEditedPostPublishable(),
24346 isDirty: _hasOtherEntitiesChanges || isEditedPostDirty(),
24347 hasOtherEntitiesChanges: _hasOtherEntitiesChanges
24348 };
24349 }, []);
24350 const openEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(() => setEntitiesSavedStatesCallback(true), []);
24351
24352 // It is ok for these components to be unmounted when not in visual use.
24353 // We don't want more than one present at a time, decide which to render.
24354 let unmountableContent;
24355 if (publishSidebarOpened) {
24356 unmountableContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_publish_panel, {
24357 onClose: closePublishSidebar,
24358 forceIsDirty: forceIsDirtyPublishPanel,
24359 PrePublishExtension: plugin_pre_publish_panel.Slot,
24360 PostPublishExtension: plugin_post_publish_panel.Slot
24361 });
24362 } else if (isPublishable && !hasOtherEntitiesChanges) {
24363 unmountableContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24364 className: "editor-layout__toggle-publish-panel",
24365 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
24366 variant: "secondary",
24367 className: "editor-layout__toggle-publish-panel-button",
24368 onClick: togglePublishSidebar,
24369 "aria-expanded": false,
24370 children: (0,external_wp_i18n_namespaceObject.__)('Open publish panel')
24371 })
24372 });
24373 } else {
24374 unmountableContent = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
24375 className: "editor-layout__toggle-entities-saved-states-panel",
24376 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
24377 variant: "secondary",
24378 className: "editor-layout__toggle-entities-saved-states-panel-button",
24379 onClick: openEntitiesSavedStates,
24380 "aria-expanded": false,
24381 disabled: !isDirty,
24382 accessibleWhenDisabled: true,
24383 children: (0,external_wp_i18n_namespaceObject.__)('Open save panel')
24384 })
24385 });
24386 }
24387
24388 // Since EntitiesSavedStates controls its own panel, we can keep it
24389 // always mounted to retain its own component state (such as checkboxes).
24390 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
24391 children: [isEntitiesSavedStatesOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EntitiesSavedStates, {
24392 close: closeEntitiesSavedStates
24393 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(save_publish_panels_Slot, {
24394 bubblesVirtually: true
24395 }), !isEntitiesSavedStatesOpen && unmountableContent]
24396 });
24397 }
24398
24399 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/text-editor/index.js
24400 /**
24401 * WordPress dependencies
24402 */
24403
24404
24405
24406
24407
24408
24409 /**
24410 * Internal dependencies
24411 */
24412
24413
24414
24415
24416
24417 function TextEditor({
24418 autoFocus = false
24419 }) {
24420 const {
24421 switchEditorMode
24422 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
24423 const {
24424 shortcut,
24425 isRichEditingEnabled
24426 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24427 const {
24428 getEditorSettings
24429 } = select(store_store);
24430 const {
24431 getShortcutRepresentation
24432 } = select(external_wp_keyboardShortcuts_namespaceObject.store);
24433 return {
24434 shortcut: getShortcutRepresentation('core/editor/toggle-mode'),
24435 isRichEditingEnabled: getEditorSettings().richEditingEnabled
24436 };
24437 }, []);
24438 const titleRef = (0,external_wp_element_namespaceObject.useRef)();
24439 (0,external_wp_element_namespaceObject.useEffect)(() => {
24440 if (autoFocus) {
24441 return;
24442 }
24443 titleRef?.current?.focus();
24444 }, [autoFocus]);
24445 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24446 className: "editor-text-editor",
24447 children: [isRichEditingEnabled && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24448 className: "editor-text-editor__toolbar",
24449 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("h2", {
24450 children: (0,external_wp_i18n_namespaceObject.__)('Editing code')
24451 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
24452 variant: "tertiary",
24453 onClick: () => switchEditorMode('visual'),
24454 shortcut: shortcut,
24455 children: (0,external_wp_i18n_namespaceObject.__)('Exit code editor')
24456 })]
24457 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
24458 className: "editor-text-editor__body",
24459 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_title_raw, {
24460 ref: titleRef
24461 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTextEditor, {})]
24462 })]
24463 });
24464 }
24465
24466 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/visual-editor/edit-template-blocks-notification.js
24467 /**
24468 * WordPress dependencies
24469 */
24470
24471
24472
24473
24474
24475
24476 /**
24477 * Internal dependencies
24478 */
24479
24480
24481 /**
24482 * Component that:
24483 *
24484 * - Displays a 'Edit your template to edit this block' notification when the
24485 * user is focusing on editing page content and clicks on a disabled template
24486 * block.
24487 * - Displays a 'Edit your template to edit this block' dialog when the user
24488 * is focusing on editing page conetnt and double clicks on a disabled
24489 * template block.
24490 *
24491 * @param {Object} props
24492 * @param {import('react').RefObject<HTMLElement>} props.contentRef Ref to the block
24493 * editor iframe canvas.
24494 */
24495
24496 function EditTemplateBlocksNotification({
24497 contentRef
24498 }) {
24499 const {
24500 onNavigateToEntityRecord,
24501 templateId
24502 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24503 const {
24504 getEditorSettings,
24505 getCurrentTemplateId
24506 } = select(store_store);
24507 return {
24508 onNavigateToEntityRecord: getEditorSettings().onNavigateToEntityRecord,
24509 templateId: getCurrentTemplateId()
24510 };
24511 }, []);
24512 const canEditTemplate = (0,external_wp_data_namespaceObject.useSelect)(select => !!select(external_wp_coreData_namespaceObject.store).canUser('create', {
24513 kind: 'postType',
24514 name: 'wp_template'
24515 }), []);
24516 const [isDialogOpen, setIsDialogOpen] = (0,external_wp_element_namespaceObject.useState)(false);
24517 (0,external_wp_element_namespaceObject.useEffect)(() => {
24518 const handleDblClick = event => {
24519 if (!canEditTemplate) {
24520 return;
24521 }
24522 if (!event.target.classList.contains('is-root-container')) {
24523 return;
24524 }
24525 setIsDialogOpen(true);
24526 };
24527 const canvas = contentRef.current;
24528 canvas?.addEventListener('dblclick', handleDblClick);
24529 return () => {
24530 canvas?.removeEventListener('dblclick', handleDblClick);
24531 };
24532 }, [contentRef, canEditTemplate]);
24533 if (!canEditTemplate) {
24534 return null;
24535 }
24536 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalConfirmDialog, {
24537 isOpen: isDialogOpen,
24538 confirmButtonText: (0,external_wp_i18n_namespaceObject.__)('Edit template'),
24539 onConfirm: () => {
24540 setIsDialogOpen(false);
24541 onNavigateToEntityRecord({
24542 postId: templateId,
24543 postType: 'wp_template'
24544 });
24545 },
24546 onCancel: () => setIsDialogOpen(false),
24547 size: "medium",
24548 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?')
24549 });
24550 }
24551
24552 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/resizable-editor/resize-handle.js
24553 /**
24554 * WordPress dependencies
24555 */
24556
24557
24558
24559
24560
24561
24562 const DELTA_DISTANCE = 20; // The distance to resize per keydown in pixels.
24563
24564 function ResizeHandle({
24565 direction,
24566 resizeWidthBy
24567 }) {
24568 function handleKeyDown(event) {
24569 const {
24570 keyCode
24571 } = event;
24572 if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.LEFT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.RIGHT) {
24573 resizeWidthBy(DELTA_DISTANCE);
24574 } else if (direction === 'left' && keyCode === external_wp_keycodes_namespaceObject.RIGHT || direction === 'right' && keyCode === external_wp_keycodes_namespaceObject.LEFT) {
24575 resizeWidthBy(-DELTA_DISTANCE);
24576 }
24577 }
24578 const resizeHandleVariants = {
24579 active: {
24580 opacity: 1,
24581 scaleY: 1.3
24582 }
24583 };
24584 const resizableHandleHelpId = `resizable-editor__resize-help-${direction}`;
24585 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
24586 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Tooltip, {
24587 text: (0,external_wp_i18n_namespaceObject.__)('Drag to resize'),
24588 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__unstableMotion.button, {
24589 className: `editor-resizable-editor__resize-handle is-${direction}`,
24590 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Drag to resize'),
24591 "aria-describedby": resizableHandleHelpId,
24592 onKeyDown: handleKeyDown,
24593 variants: resizeHandleVariants,
24594 whileFocus: "active",
24595 whileHover: "active",
24596 whileTap: "active",
24597 role: "separator",
24598 "aria-orientation": "vertical"
24599 }, "handle")
24600 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.VisuallyHidden, {
24601 id: resizableHandleHelpId,
24602 children: (0,external_wp_i18n_namespaceObject.__)('Use left and right arrow keys to resize the canvas.')
24603 })]
24604 });
24605 }
24606
24607 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/resizable-editor/index.js
24608 /**
24609 * External dependencies
24610 */
24611
24612
24613 /**
24614 * WordPress dependencies
24615 */
24616
24617
24618
24619 /**
24620 * Internal dependencies
24621 */
24622
24623
24624 // Removes the inline styles in the drag handles.
24625
24626 const HANDLE_STYLES_OVERRIDE = {
24627 position: undefined,
24628 userSelect: undefined,
24629 cursor: undefined,
24630 width: undefined,
24631 height: undefined,
24632 top: undefined,
24633 right: undefined,
24634 bottom: undefined,
24635 left: undefined
24636 };
24637 function ResizableEditor({
24638 className,
24639 enableResizing,
24640 height,
24641 children
24642 }) {
24643 const [width, setWidth] = (0,external_wp_element_namespaceObject.useState)('100%');
24644 const resizableRef = (0,external_wp_element_namespaceObject.useRef)();
24645 const resizeWidthBy = (0,external_wp_element_namespaceObject.useCallback)(deltaPixels => {
24646 if (resizableRef.current) {
24647 setWidth(resizableRef.current.offsetWidth + deltaPixels);
24648 }
24649 }, []);
24650 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.ResizableBox, {
24651 className: dist_clsx('editor-resizable-editor', className, {
24652 'is-resizable': enableResizing
24653 }),
24654 ref: api => {
24655 resizableRef.current = api?.resizable;
24656 },
24657 size: {
24658 width: enableResizing ? width : '100%',
24659 height: enableResizing && height ? height : '100%'
24660 },
24661 onResizeStop: (event, direction, element) => {
24662 setWidth(element.style.width);
24663 },
24664 minWidth: 300,
24665 maxWidth: "100%",
24666 maxHeight: "100%",
24667 enable: {
24668 left: enableResizing,
24669 right: enableResizing
24670 },
24671 showHandle: enableResizing
24672 // The editor is centered horizontally, resizing it only
24673 // moves half the distance. Hence double the ratio to correctly
24674 // align the cursor to the resizer handle.
24675 ,
24676 resizeRatio: 2,
24677 handleComponent: {
24678 left: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResizeHandle, {
24679 direction: "left",
24680 resizeWidthBy: resizeWidthBy
24681 }),
24682 right: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ResizeHandle, {
24683 direction: "right",
24684 resizeWidthBy: resizeWidthBy
24685 })
24686 },
24687 handleClasses: undefined,
24688 handleStyles: {
24689 left: HANDLE_STYLES_OVERRIDE,
24690 right: HANDLE_STYLES_OVERRIDE
24691 },
24692 children: children
24693 });
24694 }
24695 /* harmony default export */ const resizable_editor = (ResizableEditor);
24696
24697 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/visual-editor/use-select-nearest-editable-block.js
24698 /**
24699 * WordPress dependencies
24700 */
24701
24702
24703
24704
24705 /**
24706 * Internal dependencies
24707 */
24708
24709 const DISTANCE_THRESHOLD = 500;
24710 function clamp(value, min, max) {
24711 return Math.min(Math.max(value, min), max);
24712 }
24713 function distanceFromRect(x, y, rect) {
24714 const dx = x - clamp(x, rect.left, rect.right);
24715 const dy = y - clamp(y, rect.top, rect.bottom);
24716 return Math.sqrt(dx * dx + dy * dy);
24717 }
24718 function useSelectNearestEditableBlock({
24719 isEnabled = true
24720 } = {}) {
24721 const {
24722 getEnabledClientIdsTree,
24723 getBlockName,
24724 getBlockOrder
24725 } = unlock((0,external_wp_data_namespaceObject.useSelect)(external_wp_blockEditor_namespaceObject.store));
24726 const {
24727 selectBlock
24728 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_blockEditor_namespaceObject.store);
24729 return (0,external_wp_compose_namespaceObject.useRefEffect)(element => {
24730 if (!isEnabled) {
24731 return;
24732 }
24733 const selectNearestEditableBlock = (x, y) => {
24734 const editableBlockClientIds = getEnabledClientIdsTree().flatMap(({
24735 clientId
24736 }) => {
24737 const blockName = getBlockName(clientId);
24738 if (blockName === 'core/template-part') {
24739 return [];
24740 }
24741 if (blockName === 'core/post-content') {
24742 const innerBlocks = getBlockOrder(clientId);
24743 if (innerBlocks.length) {
24744 return innerBlocks;
24745 }
24746 }
24747 return [clientId];
24748 });
24749 let nearestDistance = Infinity,
24750 nearestClientId = null;
24751 for (const clientId of editableBlockClientIds) {
24752 const block = element.querySelector(`[data-block="${clientId}"]`);
24753 if (!block) {
24754 continue;
24755 }
24756 const rect = block.getBoundingClientRect();
24757 const distance = distanceFromRect(x, y, rect);
24758 if (distance < nearestDistance && distance < DISTANCE_THRESHOLD) {
24759 nearestDistance = distance;
24760 nearestClientId = clientId;
24761 }
24762 }
24763 if (nearestClientId) {
24764 selectBlock(nearestClientId);
24765 }
24766 };
24767 const handleClick = event => {
24768 const shouldSelect = event.target === element || event.target.classList.contains('is-root-container');
24769 if (shouldSelect) {
24770 selectNearestEditableBlock(event.clientX, event.clientY);
24771 }
24772 };
24773 element.addEventListener('click', handleClick);
24774 return () => element.removeEventListener('click', handleClick);
24775 }, [isEnabled]);
24776 }
24777
24778 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/visual-editor/index.js
24779 /**
24780 * External dependencies
24781 */
24782
24783
24784 /**
24785 * WordPress dependencies
24786 */
24787
24788
24789
24790
24791
24792
24793
24794 /**
24795 * Internal dependencies
24796 */
24797
24798
24799
24800
24801
24802
24803
24804
24805
24806
24807 const {
24808 LayoutStyle,
24809 useLayoutClasses,
24810 useLayoutStyles,
24811 ExperimentalBlockCanvas: BlockCanvas,
24812 useFlashEditableBlocks
24813 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
24814
24815 /**
24816 * These post types have a special editor where they don't allow you to fill the title
24817 * and they don't apply the layout styles.
24818 */
24819 const visual_editor_DESIGN_POST_TYPES = [PATTERN_POST_TYPE, TEMPLATE_POST_TYPE, NAVIGATION_POST_TYPE, TEMPLATE_PART_POST_TYPE];
24820
24821 /**
24822 * Given an array of nested blocks, find the first Post Content
24823 * block inside it, recursing through any nesting levels,
24824 * and return its attributes.
24825 *
24826 * @param {Array} blocks A list of blocks.
24827 *
24828 * @return {Object | undefined} The Post Content block.
24829 */
24830 function getPostContentAttributes(blocks) {
24831 for (let i = 0; i < blocks.length; i++) {
24832 if (blocks[i].name === 'core/post-content') {
24833 return blocks[i].attributes;
24834 }
24835 if (blocks[i].innerBlocks.length) {
24836 const nestedPostContent = getPostContentAttributes(blocks[i].innerBlocks);
24837 if (nestedPostContent) {
24838 return nestedPostContent;
24839 }
24840 }
24841 }
24842 }
24843 function checkForPostContentAtRootLevel(blocks) {
24844 for (let i = 0; i < blocks.length; i++) {
24845 if (blocks[i].name === 'core/post-content') {
24846 return true;
24847 }
24848 }
24849 return false;
24850 }
24851 function VisualEditor({
24852 // Ideally as we unify post and site editors, we won't need these props.
24853 autoFocus,
24854 styles,
24855 disableIframe = false,
24856 iframeProps,
24857 contentRef,
24858 className
24859 }) {
24860 const [resizeObserver, sizes] = (0,external_wp_compose_namespaceObject.useResizeObserver)();
24861 const isMobileViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('small', '<');
24862 const {
24863 renderingMode,
24864 postContentAttributes,
24865 editedPostTemplate = {},
24866 wrapperBlockName,
24867 wrapperUniqueId,
24868 deviceType,
24869 isFocusedEntity,
24870 isDesignPostType,
24871 postType,
24872 isPreview
24873 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24874 const {
24875 getCurrentPostId,
24876 getCurrentPostType,
24877 getCurrentTemplateId,
24878 getEditorSettings,
24879 getRenderingMode,
24880 getDeviceType
24881 } = select(store_store);
24882 const {
24883 getPostType,
24884 canUser,
24885 getEditedEntityRecord
24886 } = select(external_wp_coreData_namespaceObject.store);
24887 const postTypeSlug = getCurrentPostType();
24888 const _renderingMode = getRenderingMode();
24889 let _wrapperBlockName;
24890 if (postTypeSlug === PATTERN_POST_TYPE) {
24891 _wrapperBlockName = 'core/block';
24892 } else if (_renderingMode === 'post-only') {
24893 _wrapperBlockName = 'core/post-content';
24894 }
24895 const editorSettings = getEditorSettings();
24896 const supportsTemplateMode = editorSettings.supportsTemplateMode;
24897 const postTypeObject = getPostType(postTypeSlug);
24898 const canEditTemplate = canUser('create', {
24899 kind: 'postType',
24900 name: 'wp_template'
24901 });
24902 const currentTemplateId = getCurrentTemplateId();
24903 const template = currentTemplateId ? getEditedEntityRecord('postType', TEMPLATE_POST_TYPE, currentTemplateId) : undefined;
24904 return {
24905 renderingMode: _renderingMode,
24906 postContentAttributes: editorSettings.postContentAttributes,
24907 isDesignPostType: visual_editor_DESIGN_POST_TYPES.includes(postTypeSlug),
24908 // Post template fetch returns a 404 on classic themes, which
24909 // messes with e2e tests, so check it's a block theme first.
24910 editedPostTemplate: postTypeObject?.viewable && supportsTemplateMode && canEditTemplate ? template : undefined,
24911 wrapperBlockName: _wrapperBlockName,
24912 wrapperUniqueId: getCurrentPostId(),
24913 deviceType: getDeviceType(),
24914 isFocusedEntity: !!editorSettings.onNavigateToPreviousEntityRecord,
24915 postType: postTypeSlug,
24916 isPreview: editorSettings.__unstableIsPreviewMode
24917 };
24918 }, []);
24919 const {
24920 isCleanNewPost
24921 } = (0,external_wp_data_namespaceObject.useSelect)(store_store);
24922 const {
24923 hasRootPaddingAwareAlignments,
24924 themeHasDisabledLayoutStyles,
24925 themeSupportsLayout,
24926 isZoomOutMode
24927 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
24928 const {
24929 getSettings,
24930 __unstableGetEditorMode
24931 } = select(external_wp_blockEditor_namespaceObject.store);
24932 const _settings = getSettings();
24933 return {
24934 themeHasDisabledLayoutStyles: _settings.disableLayoutStyles,
24935 themeSupportsLayout: _settings.supportsLayout,
24936 hasRootPaddingAwareAlignments: _settings.__experimentalFeatures?.useRootPaddingAwareAlignments,
24937 isZoomOutMode: __unstableGetEditorMode() === 'zoom-out'
24938 };
24939 }, []);
24940 const deviceStyles = (0,external_wp_blockEditor_namespaceObject.__experimentalUseResizeCanvas)(deviceType);
24941 const [globalLayoutSettings] = (0,external_wp_blockEditor_namespaceObject.useSettings)('layout');
24942
24943 // fallbackLayout is used if there is no Post Content,
24944 // and for Post Title.
24945 const fallbackLayout = (0,external_wp_element_namespaceObject.useMemo)(() => {
24946 if (renderingMode !== 'post-only' || isDesignPostType) {
24947 return {
24948 type: 'default'
24949 };
24950 }
24951 if (themeSupportsLayout) {
24952 // We need to ensure support for wide and full alignments,
24953 // so we add the constrained type.
24954 return {
24955 ...globalLayoutSettings,
24956 type: 'constrained'
24957 };
24958 }
24959 // Set default layout for classic themes so all alignments are supported.
24960 return {
24961 type: 'default'
24962 };
24963 }, [renderingMode, themeSupportsLayout, globalLayoutSettings, isDesignPostType]);
24964 const newestPostContentAttributes = (0,external_wp_element_namespaceObject.useMemo)(() => {
24965 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks && postContentAttributes) {
24966 return postContentAttributes;
24967 }
24968 // When in template editing mode, we can access the blocks directly.
24969 if (editedPostTemplate?.blocks) {
24970 return getPostContentAttributes(editedPostTemplate?.blocks);
24971 }
24972 // If there are no blocks, we have to parse the content string.
24973 // Best double-check it's a string otherwise the parse function gets unhappy.
24974 const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
24975 return getPostContentAttributes((0,external_wp_blocks_namespaceObject.parse)(parseableContent)) || {};
24976 }, [editedPostTemplate?.content, editedPostTemplate?.blocks, postContentAttributes]);
24977 const hasPostContentAtRootLevel = (0,external_wp_element_namespaceObject.useMemo)(() => {
24978 if (!editedPostTemplate?.content && !editedPostTemplate?.blocks) {
24979 return false;
24980 }
24981 // When in template editing mode, we can access the blocks directly.
24982 if (editedPostTemplate?.blocks) {
24983 return checkForPostContentAtRootLevel(editedPostTemplate?.blocks);
24984 }
24985 // If there are no blocks, we have to parse the content string.
24986 // Best double-check it's a string otherwise the parse function gets unhappy.
24987 const parseableContent = typeof editedPostTemplate?.content === 'string' ? editedPostTemplate?.content : '';
24988 return checkForPostContentAtRootLevel((0,external_wp_blocks_namespaceObject.parse)(parseableContent)) || false;
24989 }, [editedPostTemplate?.content, editedPostTemplate?.blocks]);
24990 const {
24991 layout = {},
24992 align = ''
24993 } = newestPostContentAttributes || {};
24994 const postContentLayoutClasses = useLayoutClasses(newestPostContentAttributes, 'core/post-content');
24995 const blockListLayoutClass = dist_clsx({
24996 'is-layout-flow': !themeSupportsLayout
24997 }, themeSupportsLayout && postContentLayoutClasses, align && `align${align}`);
24998 const postContentLayoutStyles = useLayoutStyles(newestPostContentAttributes, 'core/post-content', '.block-editor-block-list__layout.is-root-container');
24999
25000 // Update type for blocks using legacy layouts.
25001 const postContentLayout = (0,external_wp_element_namespaceObject.useMemo)(() => {
25002 return layout && (layout?.type === 'constrained' || layout?.inherit || layout?.contentSize || layout?.wideSize) ? {
25003 ...globalLayoutSettings,
25004 ...layout,
25005 type: 'constrained'
25006 } : {
25007 ...globalLayoutSettings,
25008 ...layout,
25009 type: 'default'
25010 };
25011 }, [layout?.type, layout?.inherit, layout?.contentSize, layout?.wideSize, globalLayoutSettings]);
25012
25013 // If there is a Post Content block we use its layout for the block list;
25014 // if not, this must be a classic theme, in which case we use the fallback layout.
25015 const blockListLayout = postContentAttributes ? postContentLayout : fallbackLayout;
25016 const postEditorLayout = blockListLayout?.type === 'default' && !hasPostContentAtRootLevel ? fallbackLayout : blockListLayout;
25017 const observeTypingRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseTypingObserver)();
25018 const titleRef = (0,external_wp_element_namespaceObject.useRef)();
25019 (0,external_wp_element_namespaceObject.useEffect)(() => {
25020 if (!autoFocus || !isCleanNewPost()) {
25021 return;
25022 }
25023 titleRef?.current?.focus();
25024 }, [autoFocus, isCleanNewPost]);
25025
25026 // Add some styles for alignwide/alignfull Post Content and its children.
25027 const alignCSS = `.is-root-container.alignwide { max-width: var(--wp--style--global--wide-size); margin-left: auto; margin-right: auto;}
25028 .is-root-container.alignwide:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: var(--wp--style--global--wide-size);}
25029 .is-root-container.alignfull { max-width: none; margin-left: auto; margin-right: auto;}
25030 .is-root-container.alignfull:where(.is-layout-flow) > :not(.alignleft):not(.alignright) { max-width: none;}`;
25031 const localRef = (0,external_wp_element_namespaceObject.useRef)();
25032 const typewriterRef = (0,external_wp_blockEditor_namespaceObject.__unstableUseTypewriter)();
25033 contentRef = (0,external_wp_compose_namespaceObject.useMergeRefs)([localRef, contentRef, renderingMode === 'post-only' ? typewriterRef : null, useFlashEditableBlocks({
25034 isEnabled: renderingMode === 'template-locked'
25035 }), useSelectNearestEditableBlock({
25036 isEnabled: renderingMode === 'template-locked'
25037 })]);
25038 const zoomOutProps = isZoomOutMode ? {
25039 scale: 'default',
25040 frameSize: '48px'
25041 } : {};
25042 const forceFullHeight = postType === NAVIGATION_POST_TYPE;
25043 const enableResizing = [NAVIGATION_POST_TYPE, TEMPLATE_PART_POST_TYPE, PATTERN_POST_TYPE].includes(postType) &&
25044 // Disable in previews / view mode.
25045 !isPreview &&
25046 // Disable resizing in mobile viewport.
25047 !isMobileViewport &&
25048 // Dsiable resizing in zoomed-out mode.
25049 !isZoomOutMode;
25050 const shouldIframe = !disableIframe || ['Tablet', 'Mobile'].includes(deviceType);
25051 const iframeStyles = (0,external_wp_element_namespaceObject.useMemo)(() => {
25052 return [...(styles !== null && styles !== void 0 ? styles : []), {
25053 css: `.is-root-container{display:flow-root;${
25054 // Some themes will have `min-height: 100vh` for the root container,
25055 // which isn't a requirement in auto resize mode.
25056 enableResizing ? 'min-height:0!important;' : ''}}`
25057 }];
25058 }, [styles, enableResizing]);
25059 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
25060 className: dist_clsx('editor-visual-editor',
25061 // this class is here for backward compatibility reasons.
25062 'edit-post-visual-editor', className, {
25063 'has-padding': isFocusedEntity || enableResizing,
25064 'is-resizable': enableResizing,
25065 'is-iframed': shouldIframe
25066 }),
25067 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(resizable_editor, {
25068 enableResizing: enableResizing,
25069 height: sizes.height && !forceFullHeight ? sizes.height : '100%',
25070 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(BlockCanvas, {
25071 shouldIframe: shouldIframe,
25072 contentRef: contentRef,
25073 styles: iframeStyles,
25074 height: "100%",
25075 iframeProps: {
25076 ...iframeProps,
25077 ...zoomOutProps,
25078 style: {
25079 ...iframeProps?.style,
25080 ...deviceStyles
25081 }
25082 },
25083 children: [themeSupportsLayout && !themeHasDisabledLayoutStyles && renderingMode === 'post-only' && !isDesignPostType && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
25084 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
25085 selector: ".editor-visual-editor__post-title-wrapper",
25086 layout: fallbackLayout
25087 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
25088 selector: ".block-editor-block-list__layout.is-root-container",
25089 layout: postEditorLayout
25090 }), align && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
25091 css: alignCSS
25092 }), postContentLayoutStyles && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(LayoutStyle, {
25093 layout: postContentLayout,
25094 css: postContentLayoutStyles
25095 })]
25096 }), renderingMode === 'post-only' && !isDesignPostType && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
25097 className: dist_clsx('editor-visual-editor__post-title-wrapper',
25098 // The following class is only here for backward comapatibility
25099 // some themes might be using it to style the post title.
25100 'edit-post-visual-editor__post-title-wrapper', {
25101 'has-global-padding': hasRootPaddingAwareAlignments
25102 }),
25103 contentEditable: false,
25104 ref: observeTypingRef,
25105 style: {
25106 // This is using inline styles
25107 // so it's applied for both iframed and non iframed editors.
25108 marginTop: '4rem'
25109 },
25110 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_title, {
25111 ref: titleRef
25112 })
25113 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_blockEditor_namespaceObject.RecursionProvider, {
25114 blockName: wrapperBlockName,
25115 uniqueId: wrapperUniqueId,
25116 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockList, {
25117 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.
25118 ),
25119 layout: blockListLayout,
25120 dropZoneElement:
25121 // When iframed, pass in the html element of the iframe to
25122 // ensure the drop zone extends to the edges of the iframe.
25123 disableIframe ? localRef.current : localRef.current?.parentNode,
25124 __unstableDisableDropZone:
25125 // In template preview mode, disable drop zones at the root of the template.
25126 renderingMode === 'template-locked' ? true : false
25127 }), renderingMode === 'template-locked' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EditTemplateBlocksNotification, {
25128 contentRef: localRef
25129 })]
25130 }),
25131 // Avoid resize listeners when not needed,
25132 // these will trigger unnecessary re-renders
25133 // when animating the iframe width.
25134 enableResizing && resizeObserver]
25135 })
25136 })
25137 });
25138 }
25139 /* harmony default export */ const visual_editor = (VisualEditor);
25140
25141 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor-interface/index.js
25142 /**
25143 * External dependencies
25144 */
25145
25146
25147 /**
25148 * WordPress dependencies
25149 */
25150
25151
25152
25153
25154
25155
25156
25157
25158
25159 /**
25160 * Internal dependencies
25161 */
25162
25163
25164
25165
25166
25167
25168
25169
25170
25171
25172
25173
25174 const interfaceLabels = {
25175 /* translators: accessibility text for the editor top bar landmark region. */
25176 header: (0,external_wp_i18n_namespaceObject.__)('Editor top bar'),
25177 /* translators: accessibility text for the editor content landmark region. */
25178 body: (0,external_wp_i18n_namespaceObject.__)('Editor content'),
25179 /* translators: accessibility text for the editor settings landmark region. */
25180 sidebar: (0,external_wp_i18n_namespaceObject.__)('Editor settings'),
25181 /* translators: accessibility text for the editor publish landmark region. */
25182 actions: (0,external_wp_i18n_namespaceObject.__)('Editor publish'),
25183 /* translators: accessibility text for the editor footer landmark region. */
25184 footer: (0,external_wp_i18n_namespaceObject.__)('Editor footer')
25185 };
25186 function EditorInterface({
25187 className,
25188 enableRegionNavigation,
25189 styles,
25190 children,
25191 forceIsDirty,
25192 contentRef,
25193 disableIframe,
25194 autoFocus,
25195 customSaveButton,
25196 customSavePanel,
25197 forceDisableBlockTools,
25198 title,
25199 icon,
25200 iframeProps
25201 }) {
25202 const {
25203 mode,
25204 isRichEditingEnabled,
25205 isInserterOpened,
25206 isListViewOpened,
25207 isDistractionFree,
25208 isPreviewMode,
25209 previousShortcut,
25210 nextShortcut,
25211 showBlockBreadcrumbs,
25212 documentLabel,
25213 blockEditorMode
25214 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
25215 const {
25216 get
25217 } = select(external_wp_preferences_namespaceObject.store);
25218 const {
25219 getEditorSettings,
25220 getPostTypeLabel
25221 } = select(store_store);
25222 const editorSettings = getEditorSettings();
25223 const postTypeLabel = getPostTypeLabel();
25224 return {
25225 mode: select(store_store).getEditorMode(),
25226 isRichEditingEnabled: editorSettings.richEditingEnabled,
25227 isInserterOpened: select(store_store).isInserterOpened(),
25228 isListViewOpened: select(store_store).isListViewOpened(),
25229 isDistractionFree: get('core', 'distractionFree'),
25230 isPreviewMode: editorSettings.__unstableIsPreviewMode,
25231 previousShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/editor/previous-region'),
25232 nextShortcut: select(external_wp_keyboardShortcuts_namespaceObject.store).getAllShortcutKeyCombinations('core/editor/next-region'),
25233 showBlockBreadcrumbs: get('core', 'showBlockBreadcrumbs'),
25234 // translators: Default label for the Document in the Block Breadcrumb.
25235 documentLabel: postTypeLabel || (0,external_wp_i18n_namespaceObject._x)('Document', 'noun'),
25236 blockEditorMode: select(external_wp_blockEditor_namespaceObject.store).__unstableGetEditorMode()
25237 };
25238 }, []);
25239 const isWideViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('large');
25240 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
25241 const secondarySidebarLabel = isListViewOpened ? (0,external_wp_i18n_namespaceObject.__)('Document Overview') : (0,external_wp_i18n_namespaceObject.__)('Block Library');
25242
25243 // Local state for save panel.
25244 // Note 'truthy' callback implies an open panel.
25245 const [entitiesSavedStatesCallback, setEntitiesSavedStatesCallback] = (0,external_wp_element_namespaceObject.useState)(false);
25246 const closeEntitiesSavedStates = (0,external_wp_element_namespaceObject.useCallback)(arg => {
25247 if (typeof entitiesSavedStatesCallback === 'function') {
25248 entitiesSavedStatesCallback(arg);
25249 }
25250 setEntitiesSavedStatesCallback(false);
25251 }, [entitiesSavedStatesCallback]);
25252 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(interface_skeleton, {
25253 enableRegionNavigation: enableRegionNavigation,
25254 isDistractionFree: isDistractionFree && isWideViewport,
25255 className: dist_clsx('editor-editor-interface', className, {
25256 'is-entity-save-view-open': !!entitiesSavedStatesCallback,
25257 'is-distraction-free': isDistractionFree && isWideViewport && !isPreviewMode
25258 }),
25259 labels: {
25260 ...interfaceLabels,
25261 secondarySidebar: secondarySidebarLabel
25262 },
25263 header: !isPreviewMode && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(components_header, {
25264 forceIsDirty: forceIsDirty,
25265 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback,
25266 customSaveButton: customSaveButton,
25267 forceDisableBlockTools: forceDisableBlockTools,
25268 title: title,
25269 icon: icon
25270 }),
25271 editorNotices: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(editor_notices, {}),
25272 secondarySidebar: !isPreviewMode && mode === 'visual' && (isInserterOpened && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(InserterSidebar, {}) || isListViewOpened && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ListViewSidebar, {})),
25273 sidebar: !isPreviewMode && !isDistractionFree && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(complementary_area.Slot, {
25274 scope: "core"
25275 }),
25276 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
25277 children: [!isDistractionFree && !isPreviewMode && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(editor_notices, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(content_slot_fill.Slot, {
25278 children: ([editorCanvasView]) => editorCanvasView ? editorCanvasView : /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
25279 children: [!isPreviewMode && (mode === 'text' || !isRichEditingEnabled) && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TextEditor
25280 // We should auto-focus the canvas (title) on load.
25281 // eslint-disable-next-line jsx-a11y/no-autofocus
25282 , {
25283 autoFocus: autoFocus
25284 }), !isPreviewMode && !isLargeViewport && mode === 'visual' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockToolbar, {
25285 hideDragHandle: true
25286 }), (isPreviewMode || isRichEditingEnabled && mode === 'visual') && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(visual_editor, {
25287 styles: styles,
25288 contentRef: contentRef,
25289 disableIframe: disableIframe
25290 // We should auto-focus the canvas (title) on load.
25291 // eslint-disable-next-line jsx-a11y/no-autofocus
25292 ,
25293 autoFocus: autoFocus,
25294 iframeProps: iframeProps
25295 }), children]
25296 })
25297 })]
25298 }),
25299 footer: !isPreviewMode && !isDistractionFree && isLargeViewport && showBlockBreadcrumbs && isRichEditingEnabled && blockEditorMode !== 'zoom-out' && mode === 'visual' && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockBreadcrumb, {
25300 rootLabelText: documentLabel
25301 }),
25302 actions: !isPreviewMode ? customSavePanel || /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SavePublishPanels, {
25303 closeEntitiesSavedStates: closeEntitiesSavedStates,
25304 isEntitiesSavedStatesOpen: entitiesSavedStatesCallback,
25305 setEntitiesSavedStatesCallback: setEntitiesSavedStatesCallback,
25306 forceIsDirtyPublishPanel: forceIsDirty
25307 }) : undefined,
25308 shortcuts: {
25309 previous: previousShortcut,
25310 next: nextShortcut
25311 }
25312 });
25313 }
25314
25315 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/pattern-overrides-panel/index.js
25316 /**
25317 * WordPress dependencies
25318 */
25319
25320
25321
25322 /**
25323 * Internal dependencies
25324 */
25325
25326
25327
25328 const {
25329 OverridesPanel
25330 } = unlock(external_wp_patterns_namespaceObject.privateApis);
25331 function PatternOverridesPanel() {
25332 const supportsPatternOverridesPanel = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getCurrentPostType() === 'wp_block', []);
25333 if (!supportsPatternOverridesPanel) {
25334 return null;
25335 }
25336 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(OverridesPanel, {});
25337 }
25338
25339 ;// CONCATENATED MODULE: ./packages/icons/build-module/library/trash.js
25340 /**
25341 * WordPress dependencies
25342 */
25343
25344
25345 const trash = /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.SVG, {
25346 xmlns: "http://www.w3.org/2000/svg",
25347 viewBox: "0 0 24 24",
25348 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_primitives_namespaceObject.Path, {
25349 fillRule: "evenodd",
25350 clipRule: "evenodd",
25351 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"
25352 })
25353 });
25354 /* harmony default export */ const library_trash = (trash);
25355
25356 ;// CONCATENATED MODULE: ./packages/dataviews/build-module/normalize-fields.js
25357 /**
25358 * Internal dependencies
25359 */
25360
25361 /**
25362 * Apply default values and normalize the fields config.
25363 *
25364 * @param fields Fields config.
25365 * @return Normalized fields config.
25366 */
25367 function normalizeFields(fields) {
25368 return fields.map(field => {
25369 const getValue = field.getValue || (({
25370 item
25371 }) => item[field.id]);
25372 return {
25373 ...field,
25374 label: field.label || field.id,
25375 getValue,
25376 render: field.render || getValue
25377 };
25378 });
25379 }
25380
25381 ;// CONCATENATED MODULE: ./packages/dataviews/build-module/components/dataform/index.js
25382 /**
25383 * External dependencies
25384 */
25385
25386 /**
25387 * WordPress dependencies
25388 */
25389
25390
25391
25392 /**
25393 * Internal dependencies
25394 */
25395
25396
25397
25398 function DataFormTextControl({
25399 data,
25400 field,
25401 onChange
25402 }) {
25403 const {
25404 id,
25405 label,
25406 placeholder
25407 } = field;
25408 const value = field.getValue({
25409 item: data
25410 });
25411 const onChangeControl = (0,external_wp_element_namespaceObject.useCallback)(newValue => onChange(prevItem => ({
25412 ...prevItem,
25413 [id]: newValue
25414 })), [id, onChange]);
25415 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
25416 label: label,
25417 placeholder: placeholder,
25418 value: value !== null && value !== void 0 ? value : '',
25419 onChange: onChangeControl,
25420 __next40pxDefaultSize: true
25421 });
25422 }
25423 const controls = {
25424 text: DataFormTextControl
25425 };
25426 function getControlForField(field) {
25427 if (!field.type) {
25428 return null;
25429 }
25430 if (!Object.keys(controls).includes(field.type)) {
25431 return null;
25432 }
25433 return controls[field.type];
25434 }
25435 function DataForm({
25436 data,
25437 fields,
25438 form,
25439 onChange
25440 }) {
25441 const visibleFields = (0,external_wp_element_namespaceObject.useMemo)(() => normalizeFields(fields.filter(({
25442 id
25443 }) => !!form.visibleFields?.includes(id))), [fields, form.visibleFields]);
25444 return visibleFields.map(field => {
25445 const DataFormControl = getControlForField(field);
25446 return DataFormControl ? /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DataFormControl, {
25447 data: data,
25448 field: field,
25449 onChange: onChange
25450 }, field.id) : null;
25451 });
25452 }
25453
25454 ;// CONCATENATED MODULE: ./packages/editor/build-module/dataviews/actions/utils.js
25455 /**
25456 * WordPress dependencies
25457 */
25458
25459
25460 /**
25461 * Internal dependencies
25462 */
25463
25464 function isTemplateOrTemplatePart(p) {
25465 return p.type === TEMPLATE_POST_TYPE || p.type === TEMPLATE_PART_POST_TYPE;
25466 }
25467 function getItemTitle(item) {
25468 if (typeof item.title === 'string') {
25469 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title);
25470 }
25471 if ('rendered' in item.title) {
25472 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title.rendered);
25473 }
25474 if ('raw' in item.title) {
25475 return (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(item.title.raw);
25476 }
25477 return '';
25478 }
25479
25480 /**
25481 * Check if a template is removable.
25482 *
25483 * @param template The template entity to check.
25484 * @return Whether the template is removable.
25485 */
25486 function isTemplateRemovable(template) {
25487 if (!template) {
25488 return false;
25489 }
25490 // In patterns list page we map the templates parts to a different object
25491 // than the one returned from the endpoint. This is why we need to check for
25492 // two props whether is custom or has a theme file.
25493 return [template.source, template.source].includes(TEMPLATE_ORIGINS.custom) && !template.has_theme_file;
25494 }
25495
25496 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-actions/actions.js
25497 /**
25498 * WordPress dependencies
25499 */
25500
25501
25502
25503
25504
25505
25506
25507
25508
25509
25510
25511
25512
25513 /**
25514 * Internal dependencies
25515 */
25516
25517
25518
25519
25520
25521
25522 // Patterns.
25523
25524
25525 const {
25526 PATTERN_TYPES: actions_PATTERN_TYPES,
25527 CreatePatternModalContents,
25528 useDuplicatePatternProps
25529 } = unlock(external_wp_patterns_namespaceObject.privateApis);
25530
25531 // TODO: this should be shared with other components (page-pages).
25532 const fields = [{
25533 type: 'text',
25534 header: (0,external_wp_i18n_namespaceObject.__)('Title'),
25535 id: 'title',
25536 placeholder: (0,external_wp_i18n_namespaceObject.__)('No title'),
25537 getValue: ({
25538 item
25539 }) => item.title
25540 }];
25541 const actions_form = {
25542 visibleFields: ['title']
25543 };
25544
25545 /**
25546 * Check if a template is removable.
25547 *
25548 * @param {Object} template The template entity to check.
25549 * @return {boolean} Whether the template is removable.
25550 */
25551 function actions_isTemplateRemovable(template) {
25552 if (!template) {
25553 return false;
25554 }
25555 // In patterns list page we map the templates parts to a different object
25556 // than the one returned from the endpoint. This is why we need to check for
25557 // two props whether is custom or has a theme file.
25558 return template?.source === TEMPLATE_ORIGINS.custom && !template?.has_theme_file;
25559 }
25560 const trashPostAction = {
25561 id: 'move-to-trash',
25562 label: (0,external_wp_i18n_namespaceObject.__)('Move to Trash'),
25563 isPrimary: true,
25564 icon: library_trash,
25565 isEligible(item) {
25566 return !['auto-draft', 'trash'].includes(item.status);
25567 },
25568 supportsBulk: true,
25569 hideModalHeader: true,
25570 RenderModal: ({
25571 items,
25572 closeModal,
25573 onActionPerformed
25574 }) => {
25575 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
25576 const {
25577 createSuccessNotice,
25578 createErrorNotice
25579 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
25580 const {
25581 deleteEntityRecord
25582 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
25583 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
25584 spacing: "5",
25585 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
25586 children: items.length === 1 ? (0,external_wp_i18n_namespaceObject.sprintf)(
25587 // translators: %s: The item's title.
25588 (0,external_wp_i18n_namespaceObject.__)('Are you sure you want to move to trash "%s"?'), getItemTitle(items[0])) : (0,external_wp_i18n_namespaceObject.sprintf)(
25589 // translators: %d: The number of items (2 or more).
25590 (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)
25591 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
25592 justify: "right",
25593 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25594 variant: "tertiary",
25595 onClick: closeModal,
25596 disabled: isBusy,
25597 accessibleWhenDisabled: true,
25598 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
25599 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25600 variant: "primary",
25601 onClick: async () => {
25602 setIsBusy(true);
25603 const promiseResult = await Promise.allSettled(items.map(item => deleteEntityRecord('postType', item.type, item.id, {}, {
25604 throwOnError: true
25605 })));
25606 // If all the promises were fulfilled with success.
25607 if (promiseResult.every(({
25608 status
25609 }) => status === 'fulfilled')) {
25610 let successMessage;
25611 if (promiseResult.length === 1) {
25612 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The item's title. */
25613 (0,external_wp_i18n_namespaceObject.__)('"%s" moved to trash.'), getItemTitle(items[0]));
25614 } else {
25615 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of items. */
25616 (0,external_wp_i18n_namespaceObject._n)('%s item moved to trash.', '%s items moved to trash.', items.length), items.length);
25617 }
25618 createSuccessNotice(successMessage, {
25619 type: 'snackbar',
25620 id: 'move-to-trash-action'
25621 });
25622 } else {
25623 // If there was at least one failure.
25624 let errorMessage;
25625 // If we were trying to delete a single item.
25626 if (promiseResult.length === 1) {
25627 if (promiseResult[0].reason?.message) {
25628 errorMessage = promiseResult[0].reason.message;
25629 } else {
25630 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving to trash the item.');
25631 }
25632 // If we were trying to delete multiple items.
25633 } else {
25634 const errorMessages = new Set();
25635 const failedPromises = promiseResult.filter(({
25636 status
25637 }) => status === 'rejected');
25638 for (const failedPromise of failedPromises) {
25639 if (failedPromise.reason?.message) {
25640 errorMessages.add(failedPromise.reason.message);
25641 }
25642 }
25643 if (errorMessages.size === 0) {
25644 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving to trash the items.');
25645 } else if (errorMessages.size === 1) {
25646 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
25647 (0,external_wp_i18n_namespaceObject.__)('An error occurred while moving to trash the item: %s'), [...errorMessages][0]);
25648 } else {
25649 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
25650 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while moving to trash the items: %s'), [...errorMessages].join(','));
25651 }
25652 }
25653 createErrorNotice(errorMessage, {
25654 type: 'snackbar'
25655 });
25656 }
25657 if (onActionPerformed) {
25658 onActionPerformed(items);
25659 }
25660 setIsBusy(false);
25661 closeModal();
25662 },
25663 isBusy: isBusy,
25664 disabled: isBusy,
25665 accessibleWhenDisabled: true,
25666 children: (0,external_wp_i18n_namespaceObject.__)('Trash')
25667 })]
25668 })]
25669 });
25670 }
25671 };
25672 function useCanUserEligibilityCheckPostType(capability, postType, action) {
25673 const registry = (0,external_wp_data_namespaceObject.useRegistry)();
25674 return (0,external_wp_element_namespaceObject.useMemo)(() => ({
25675 ...action,
25676 isEligible(item) {
25677 return action.isEligible(item) && registry.select(external_wp_coreData_namespaceObject.store).canUser(capability, {
25678 kind: 'postType',
25679 name: postType,
25680 id: item.id
25681 });
25682 }
25683 }), [action, registry, capability, postType]);
25684 }
25685 function useTrashPostAction(postType) {
25686 return useCanUserEligibilityCheckPostType('delete', postType, trashPostAction);
25687 }
25688 const permanentlyDeletePostAction = {
25689 id: 'permanently-delete',
25690 label: (0,external_wp_i18n_namespaceObject.__)('Permanently delete'),
25691 supportsBulk: true,
25692 isEligible({
25693 status
25694 }) {
25695 return status === 'trash';
25696 },
25697 async callback(posts, {
25698 registry,
25699 onActionPerformed
25700 }) {
25701 const {
25702 createSuccessNotice,
25703 createErrorNotice
25704 } = registry.dispatch(external_wp_notices_namespaceObject.store);
25705 const {
25706 deleteEntityRecord
25707 } = registry.dispatch(external_wp_coreData_namespaceObject.store);
25708 const promiseResult = await Promise.allSettled(posts.map(post => {
25709 return deleteEntityRecord('postType', post.type, post.id, {
25710 force: true
25711 }, {
25712 throwOnError: true
25713 });
25714 }));
25715 // If all the promises were fulfilled with success.
25716 if (promiseResult.every(({
25717 status
25718 }) => status === 'fulfilled')) {
25719 let successMessage;
25720 if (promiseResult.length === 1) {
25721 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The posts's title. */
25722 (0,external_wp_i18n_namespaceObject.__)('"%s" permanently deleted.'), getItemTitle(posts[0]));
25723 } else {
25724 successMessage = (0,external_wp_i18n_namespaceObject.__)('The posts were permanently deleted.');
25725 }
25726 createSuccessNotice(successMessage, {
25727 type: 'snackbar',
25728 id: 'permanently-delete-post-action'
25729 });
25730 onActionPerformed?.(posts);
25731 } else {
25732 // If there was at lease one failure.
25733 let errorMessage;
25734 // If we were trying to permanently delete a single post.
25735 if (promiseResult.length === 1) {
25736 if (promiseResult[0].reason?.message) {
25737 errorMessage = promiseResult[0].reason.message;
25738 } else {
25739 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the post.');
25740 }
25741 // If we were trying to permanently delete multiple posts
25742 } else {
25743 const errorMessages = new Set();
25744 const failedPromises = promiseResult.filter(({
25745 status
25746 }) => status === 'rejected');
25747 for (const failedPromise of failedPromises) {
25748 if (failedPromise.reason?.message) {
25749 errorMessages.add(failedPromise.reason.message);
25750 }
25751 }
25752 if (errorMessages.size === 0) {
25753 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the posts.');
25754 } else if (errorMessages.size === 1) {
25755 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
25756 (0,external_wp_i18n_namespaceObject.__)('An error occurred while permanently deleting the posts: %s'), [...errorMessages][0]);
25757 } else {
25758 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
25759 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while permanently deleting the posts: %s'), [...errorMessages].join(','));
25760 }
25761 }
25762 createErrorNotice(errorMessage, {
25763 type: 'snackbar'
25764 });
25765 }
25766 }
25767 };
25768 function usePermanentlyDeletePostAction(postType) {
25769 return useCanUserEligibilityCheckPostType('delete', postType, permanentlyDeletePostAction);
25770 }
25771 const restorePostAction = {
25772 id: 'restore',
25773 label: (0,external_wp_i18n_namespaceObject.__)('Restore'),
25774 isPrimary: true,
25775 icon: library_backup,
25776 supportsBulk: true,
25777 isEligible({
25778 status
25779 }) {
25780 return status === 'trash';
25781 },
25782 async callback(posts, {
25783 registry,
25784 onActionPerformed
25785 }) {
25786 const {
25787 createSuccessNotice,
25788 createErrorNotice
25789 } = registry.dispatch(external_wp_notices_namespaceObject.store);
25790 const {
25791 editEntityRecord,
25792 saveEditedEntityRecord
25793 } = registry.dispatch(external_wp_coreData_namespaceObject.store);
25794 await Promise.allSettled(posts.map(post => {
25795 return editEntityRecord('postType', post.type, post.id, {
25796 status: 'draft'
25797 });
25798 }));
25799 const promiseResult = await Promise.allSettled(posts.map(post => {
25800 return saveEditedEntityRecord('postType', post.type, post.id, {
25801 throwOnError: true
25802 });
25803 }));
25804 if (promiseResult.every(({
25805 status
25806 }) => status === 'fulfilled')) {
25807 let successMessage;
25808 if (posts.length === 1) {
25809 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */
25810 (0,external_wp_i18n_namespaceObject.__)('"%s" has been restored.'), getItemTitle(posts[0]));
25811 } else if (posts[0].type === 'page') {
25812 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */
25813 (0,external_wp_i18n_namespaceObject.__)('%d pages have been restored.'), posts.length);
25814 } else {
25815 successMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of posts. */
25816 (0,external_wp_i18n_namespaceObject.__)('%d posts have been restored.'), posts.length);
25817 }
25818 createSuccessNotice(successMessage, {
25819 type: 'snackbar',
25820 id: 'restore-post-action'
25821 });
25822 if (onActionPerformed) {
25823 onActionPerformed(posts);
25824 }
25825 } else {
25826 // If there was at lease one failure.
25827 let errorMessage;
25828 // If we were trying to move a single post to the trash.
25829 if (promiseResult.length === 1) {
25830 if (promiseResult[0].reason?.message) {
25831 errorMessage = promiseResult[0].reason.message;
25832 } else {
25833 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the post.');
25834 }
25835 // If we were trying to move multiple posts to the trash
25836 } else {
25837 const errorMessages = new Set();
25838 const failedPromises = promiseResult.filter(({
25839 status
25840 }) => status === 'rejected');
25841 for (const failedPromise of failedPromises) {
25842 if (failedPromise.reason?.message) {
25843 errorMessages.add(failedPromise.reason.message);
25844 }
25845 }
25846 if (errorMessages.size === 0) {
25847 errorMessage = (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the posts.');
25848 } else if (errorMessages.size === 1) {
25849 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: an error message */
25850 (0,external_wp_i18n_namespaceObject.__)('An error occurred while restoring the posts: %s'), [...errorMessages][0]);
25851 } else {
25852 errorMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: a list of comma separated error messages */
25853 (0,external_wp_i18n_namespaceObject.__)('Some errors occurred while restoring the posts: %s'), [...errorMessages].join(','));
25854 }
25855 }
25856 createErrorNotice(errorMessage, {
25857 type: 'snackbar'
25858 });
25859 }
25860 }
25861 };
25862 function useRestorePostAction(postType) {
25863 return useCanUserEligibilityCheckPostType('update', postType, restorePostAction);
25864 }
25865 const viewPostAction = {
25866 id: 'view-post',
25867 label: (0,external_wp_i18n_namespaceObject.__)('View'),
25868 isPrimary: true,
25869 icon: library_external,
25870 isEligible(post) {
25871 return post.status !== 'trash';
25872 },
25873 callback(posts, {
25874 onActionPerformed
25875 }) {
25876 const post = posts[0];
25877 window.open(post.link, '_blank');
25878 if (onActionPerformed) {
25879 onActionPerformed(posts);
25880 }
25881 }
25882 };
25883 const postRevisionsAction = {
25884 id: 'view-post-revisions',
25885 context: 'list',
25886 label(items) {
25887 var _items$0$_links$versi;
25888 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;
25889 return (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: number of revisions */
25890 (0,external_wp_i18n_namespaceObject.__)('View revisions (%s)'), revisionsCount);
25891 },
25892 isEligible: post => {
25893 var _post$_links$predeces, _post$_links$version;
25894 if (post.status === 'trash') {
25895 return false;
25896 }
25897 const lastRevisionId = (_post$_links$predeces = post?._links?.['predecessor-version']?.[0]?.id) !== null && _post$_links$predeces !== void 0 ? _post$_links$predeces : null;
25898 const revisionsCount = (_post$_links$version = post?._links?.['version-history']?.[0]?.count) !== null && _post$_links$version !== void 0 ? _post$_links$version : 0;
25899 return lastRevisionId && revisionsCount > 1;
25900 },
25901 callback(posts, {
25902 onActionPerformed
25903 }) {
25904 const post = posts[0];
25905 const href = (0,external_wp_url_namespaceObject.addQueryArgs)('revision.php', {
25906 revision: post?._links?.['predecessor-version']?.[0]?.id
25907 });
25908 document.location.href = href;
25909 if (onActionPerformed) {
25910 onActionPerformed(posts);
25911 }
25912 }
25913 };
25914 const renamePostAction = {
25915 id: 'rename-post',
25916 label: (0,external_wp_i18n_namespaceObject.__)('Rename'),
25917 isEligible(post) {
25918 if (post.status === 'trash') {
25919 return false;
25920 }
25921 // Templates, template parts and patterns have special checks for renaming.
25922 if (![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, ...Object.values(actions_PATTERN_TYPES)].includes(post.type)) {
25923 return true;
25924 }
25925 // In the case of templates, we can only rename custom templates.
25926 if (post.type === TEMPLATE_POST_TYPE) {
25927 return actions_isTemplateRemovable(post) && post.is_custom;
25928 }
25929 // Make necessary checks for template parts and patterns.
25930 const isTemplatePart = post.type === TEMPLATE_PART_POST_TYPE;
25931 const isUserPattern = post.type === actions_PATTERN_TYPES.user;
25932 // In patterns list page we map the templates parts to a different object
25933 // than the one returned from the endpoint. This is why we need to check for
25934 // two props whether is custom or has a theme file.
25935 const isCustomPattern = isUserPattern || isTemplatePart && post.source === TEMPLATE_ORIGINS.custom;
25936 const hasThemeFile = post?.has_theme_file;
25937 return isCustomPattern && !hasThemeFile;
25938 },
25939 RenderModal: ({
25940 items,
25941 closeModal,
25942 onActionPerformed
25943 }) => {
25944 const [item] = items;
25945 const [title, setTitle] = (0,external_wp_element_namespaceObject.useState)(() => getItemTitle(item));
25946 const {
25947 editEntityRecord,
25948 saveEditedEntityRecord
25949 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
25950 const {
25951 createSuccessNotice,
25952 createErrorNotice
25953 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
25954 async function onRename(event) {
25955 event.preventDefault();
25956 try {
25957 await editEntityRecord('postType', item.type, item.id, {
25958 title
25959 });
25960 // Update state before saving rerenders the list.
25961 setTitle('');
25962 closeModal();
25963 // Persist edited entity.
25964 await saveEditedEntityRecord('postType', item.type, item.id, {
25965 throwOnError: true
25966 });
25967 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Name updated'), {
25968 type: 'snackbar'
25969 });
25970 onActionPerformed?.(items);
25971 } catch (error) {
25972 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while updating the name');
25973 createErrorNotice(errorMessage, {
25974 type: 'snackbar'
25975 });
25976 }
25977 }
25978 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
25979 onSubmit: onRename,
25980 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
25981 spacing: "5",
25982 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.TextControl, {
25983 __nextHasNoMarginBottom: true,
25984 __next40pxDefaultSize: true,
25985 label: (0,external_wp_i18n_namespaceObject.__)('Name'),
25986 value: title,
25987 onChange: setTitle,
25988 required: true
25989 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
25990 justify: "right",
25991 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25992 __next40pxDefaultSize: true,
25993 variant: "tertiary",
25994 onClick: () => {
25995 closeModal();
25996 },
25997 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
25998 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
25999 __next40pxDefaultSize: true,
26000 variant: "primary",
26001 type: "submit",
26002 children: (0,external_wp_i18n_namespaceObject.__)('Save')
26003 })]
26004 })]
26005 })
26006 });
26007 }
26008 };
26009 function useRenamePostAction(postType) {
26010 return useCanUserEligibilityCheckPostType('update', postType, renamePostAction);
26011 }
26012 function ReorderModal({
26013 items,
26014 closeModal,
26015 onActionPerformed
26016 }) {
26017 const [item] = items;
26018 const {
26019 editEntityRecord,
26020 saveEditedEntityRecord
26021 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
26022 const {
26023 createSuccessNotice,
26024 createErrorNotice
26025 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
26026 const [orderInput, setOrderInput] = (0,external_wp_element_namespaceObject.useState)(item.menu_order);
26027 async function onOrder(event) {
26028 event.preventDefault();
26029 if (!Number.isInteger(Number(orderInput)) || orderInput?.trim?.() === '') {
26030 return;
26031 }
26032 try {
26033 await editEntityRecord('postType', item.type, item.id, {
26034 menu_order: orderInput
26035 });
26036 closeModal();
26037 // Persist edited entity.
26038 await saveEditedEntityRecord('postType', item.type, item.id, {
26039 throwOnError: true
26040 });
26041 createSuccessNotice((0,external_wp_i18n_namespaceObject.__)('Order updated'), {
26042 type: 'snackbar'
26043 });
26044 onActionPerformed?.(items);
26045 } catch (error) {
26046 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while updating the order');
26047 createErrorNotice(errorMessage, {
26048 type: 'snackbar'
26049 });
26050 }
26051 }
26052 const saveIsDisabled = !Number.isInteger(Number(orderInput)) || orderInput?.trim?.() === '';
26053 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
26054 onSubmit: onOrder,
26055 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
26056 spacing: "5",
26057 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
26058 children: (0,external_wp_i18n_namespaceObject.__)('Determines the order of pages. Pages with the same order value are sorted alphabetically. Negative order values are supported.')
26059 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNumberControl, {
26060 __next40pxDefaultSize: true,
26061 label: (0,external_wp_i18n_namespaceObject.__)('Order'),
26062 help: (0,external_wp_i18n_namespaceObject.__)('Set the page order.'),
26063 value: orderInput,
26064 onChange: setOrderInput
26065 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
26066 justify: "right",
26067 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26068 __next40pxDefaultSize: true,
26069 variant: "tertiary",
26070 onClick: () => {
26071 closeModal();
26072 },
26073 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
26074 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26075 __next40pxDefaultSize: true,
26076 variant: "primary",
26077 type: "submit",
26078 accessibleWhenDisabled: true,
26079 disabled: saveIsDisabled,
26080 __experimentalIsFocusable: true,
26081 children: (0,external_wp_i18n_namespaceObject.__)('Save')
26082 })]
26083 })]
26084 })
26085 });
26086 }
26087 function useReorderPagesAction(postType) {
26088 const supportsPageAttributes = (0,external_wp_data_namespaceObject.useSelect)(select => {
26089 const {
26090 getPostType
26091 } = select(external_wp_coreData_namespaceObject.store);
26092 const postTypeObject = getPostType(postType);
26093 return !!postTypeObject?.supports?.['page-attributes'];
26094 }, [postType]);
26095 return (0,external_wp_element_namespaceObject.useMemo)(() => supportsPageAttributes && {
26096 id: 'order-pages',
26097 label: (0,external_wp_i18n_namespaceObject.__)('Order'),
26098 isEligible({
26099 status
26100 }) {
26101 return status !== 'trash';
26102 },
26103 RenderModal: ReorderModal
26104 }, [supportsPageAttributes]);
26105 }
26106 const useDuplicatePostAction = postType => {
26107 const userCanCreatePost = (0,external_wp_data_namespaceObject.useSelect)(select => {
26108 return select(external_wp_coreData_namespaceObject.store).canUser('create', {
26109 kind: 'postType',
26110 name: postType
26111 });
26112 }, [postType]);
26113 return (0,external_wp_element_namespaceObject.useMemo)(() => userCanCreatePost && {
26114 id: 'duplicate-post',
26115 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
26116 isEligible({
26117 status
26118 }) {
26119 return status !== 'trash';
26120 },
26121 RenderModal: ({
26122 items,
26123 closeModal,
26124 onActionPerformed
26125 }) => {
26126 const [item, setItem] = (0,external_wp_element_namespaceObject.useState)({
26127 ...items[0],
26128 title: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Existing template title */
26129 (0,external_wp_i18n_namespaceObject.__)('%s (Copy)'), getItemTitle(items[0]))
26130 });
26131 const [isCreatingPage, setIsCreatingPage] = (0,external_wp_element_namespaceObject.useState)(false);
26132 const {
26133 saveEntityRecord
26134 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
26135 const {
26136 createSuccessNotice,
26137 createErrorNotice
26138 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
26139 async function createPage(event) {
26140 event.preventDefault();
26141 if (isCreatingPage) {
26142 return;
26143 }
26144 const newItemOject = {
26145 status: 'draft',
26146 title: item.title,
26147 slug: item.title || (0,external_wp_i18n_namespaceObject.__)('No title'),
26148 comment_status: item.comment_status,
26149 content: typeof item.content === 'string' ? item.content : item.content.raw,
26150 excerpt: item.excerpt.raw,
26151 meta: item.meta,
26152 parent: item.parent,
26153 password: item.password,
26154 template: item.template,
26155 format: item.format,
26156 featured_media: item.featured_media,
26157 menu_order: item.menu_order,
26158 ping_status: item.ping_status
26159 };
26160 const assignablePropertiesPrefix = 'wp:action-assign-';
26161 // Get all the properties that the current user is able to assign normally author, categories, tags,
26162 // and custom taxonomies.
26163 const assignableProperties = Object.keys(item?._links || {}).filter(property => property.startsWith(assignablePropertiesPrefix)).map(property => property.slice(assignablePropertiesPrefix.length));
26164 assignableProperties.forEach(property => {
26165 if (item[property]) {
26166 newItemOject[property] = item[property];
26167 }
26168 });
26169 setIsCreatingPage(true);
26170 try {
26171 const newItem = await saveEntityRecord('postType', item.type, newItemOject, {
26172 throwOnError: true
26173 });
26174 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
26175 // translators: %s: Title of the created template e.g: "Category".
26176 (0,external_wp_i18n_namespaceObject.__)('"%s" successfully created.'), (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(newItem.title?.rendered || item.title)), {
26177 id: 'duplicate-post-action',
26178 type: 'snackbar'
26179 });
26180 if (onActionPerformed) {
26181 onActionPerformed([newItem]);
26182 }
26183 } catch (error) {
26184 const errorMessage = error.message && error.code !== 'unknown_error' ? error.message : (0,external_wp_i18n_namespaceObject.__)('An error occurred while duplicating the page.');
26185 createErrorNotice(errorMessage, {
26186 type: 'snackbar'
26187 });
26188 } finally {
26189 setIsCreatingPage(false);
26190 closeModal();
26191 }
26192 }
26193 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("form", {
26194 onSubmit: createPage,
26195 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
26196 spacing: 3,
26197 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DataForm, {
26198 data: item,
26199 fields: fields,
26200 form: actions_form,
26201 onChange: setItem
26202 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
26203 spacing: 2,
26204 justify: "end",
26205 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26206 variant: "tertiary",
26207 onClick: closeModal,
26208 __next40pxDefaultSize: true,
26209 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
26210 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26211 variant: "primary",
26212 type: "submit",
26213 isBusy: isCreatingPage,
26214 "aria-disabled": isCreatingPage,
26215 __next40pxDefaultSize: true,
26216 children: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label')
26217 })]
26218 })]
26219 })
26220 });
26221 }
26222 }, [userCanCreatePost]);
26223 };
26224 const duplicatePatternAction = {
26225 id: 'duplicate-pattern',
26226 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
26227 isEligible: item => item.type !== TEMPLATE_PART_POST_TYPE,
26228 modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate pattern', 'action label'),
26229 RenderModal: ({
26230 items,
26231 closeModal
26232 }) => {
26233 const [item] = items;
26234 const duplicatedProps = useDuplicatePatternProps({
26235 pattern: item,
26236 onSuccess: () => closeModal()
26237 });
26238 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreatePatternModalContents, {
26239 onClose: closeModal,
26240 confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
26241 ...duplicatedProps
26242 });
26243 }
26244 };
26245 const duplicateTemplatePartAction = {
26246 id: 'duplicate-template-part',
26247 label: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label'),
26248 isEligible: item => item.type === TEMPLATE_PART_POST_TYPE,
26249 modalHeader: (0,external_wp_i18n_namespaceObject._x)('Duplicate template part', 'action label'),
26250 RenderModal: ({
26251 items,
26252 closeModal
26253 }) => {
26254 const [item] = items;
26255 const blocks = (0,external_wp_element_namespaceObject.useMemo)(() => {
26256 var _item$blocks;
26257 return (_item$blocks = item.blocks) !== null && _item$blocks !== void 0 ? _item$blocks : (0,external_wp_blocks_namespaceObject.parse)(typeof item.content === 'string' ? item.content : item.content.raw, {
26258 __unstableSkipMigrationLogs: true
26259 });
26260 }, [item.content, item.blocks]);
26261 const {
26262 createSuccessNotice
26263 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
26264 function onTemplatePartSuccess() {
26265 createSuccessNotice((0,external_wp_i18n_namespaceObject.sprintf)(
26266 // translators: %s: The new template part's title e.g. 'Call to action (copy)'.
26267 (0,external_wp_i18n_namespaceObject.__)('"%s" duplicated.'), getItemTitle(item)), {
26268 type: 'snackbar',
26269 id: 'edit-site-patterns-success'
26270 });
26271 closeModal();
26272 }
26273 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(CreateTemplatePartModalContents, {
26274 blocks: blocks,
26275 defaultArea: item.area,
26276 defaultTitle: (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %s: Existing template part title */
26277 (0,external_wp_i18n_namespaceObject.__)('%s (Copy)'), getItemTitle(item)),
26278 onCreate: onTemplatePartSuccess,
26279 onError: closeModal,
26280 confirmLabel: (0,external_wp_i18n_namespaceObject._x)('Duplicate', 'action label')
26281 });
26282 }
26283 };
26284 function usePostActions({
26285 postType,
26286 onActionPerformed,
26287 context
26288 }) {
26289 const {
26290 defaultActions,
26291 postTypeObject,
26292 userCanCreatePostType,
26293 cachedCanUserResolvers
26294 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26295 const {
26296 getPostType,
26297 canUser,
26298 getCachedResolvers
26299 } = select(external_wp_coreData_namespaceObject.store);
26300 const {
26301 getEntityActions
26302 } = unlock(select(store_store));
26303 const _postTypeObject = getPostType(postType);
26304 return {
26305 postTypeObject: _postTypeObject,
26306 defaultActions: getEntityActions('postType', postType),
26307 userCanCreatePostType: canUser('create', {
26308 kind: 'postType',
26309 name: postType
26310 }),
26311 cachedCanUserResolvers: getCachedResolvers()?.canUser
26312 };
26313 }, [postType]);
26314 const duplicatePostAction = useDuplicatePostAction(postType);
26315 const trashPostActionForPostType = useTrashPostAction(postType);
26316 const permanentlyDeletePostActionForPostType = usePermanentlyDeletePostAction(postType);
26317 const renamePostActionForPostType = useRenamePostAction(postType);
26318 const restorePostActionForPostType = useRestorePostAction(postType);
26319 const reorderPagesAction = useReorderPagesAction(postType);
26320 const isTemplateOrTemplatePart = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(postType);
26321 const isPattern = postType === PATTERN_POST_TYPE;
26322 const isLoaded = !!postTypeObject;
26323 const supportsRevisions = !!postTypeObject?.supports?.revisions;
26324 const supportsTitle = !!postTypeObject?.supports?.title;
26325 return (0,external_wp_element_namespaceObject.useMemo)(() => {
26326 if (!isLoaded) {
26327 return [];
26328 }
26329 let actions = [postTypeObject?.viewable && viewPostAction, supportsRevisions && postRevisionsAction, true ? !isTemplateOrTemplatePart && !isPattern && duplicatePostAction : 0, isTemplateOrTemplatePart && userCanCreatePostType && duplicateTemplatePartAction, isPattern && userCanCreatePostType && duplicatePatternAction, supportsTitle && renamePostActionForPostType, reorderPagesAction, !isTemplateOrTemplatePart && restorePostActionForPostType, !isTemplateOrTemplatePart && !isPattern && trashPostActionForPostType, !isTemplateOrTemplatePart && permanentlyDeletePostActionForPostType, ...defaultActions].filter(Boolean);
26330 // Filter actions based on provided context. If not provided
26331 // all actions are returned. We'll have a single entry for getting the actions
26332 // and the consumer should provide the context to filter the actions, if needed.
26333 // Actions should also provide the `context` they support, if it's specific, to
26334 // compare with the provided context to get all the actions.
26335 // Right now the only supported context is `list`.
26336 actions = actions.filter(action => {
26337 if (!action.context) {
26338 return true;
26339 }
26340 return action.context === context;
26341 });
26342 if (onActionPerformed) {
26343 for (let i = 0; i < actions.length; ++i) {
26344 if (actions[i].callback) {
26345 const existingCallback = actions[i].callback;
26346 actions[i] = {
26347 ...actions[i],
26348 callback: (items, argsObject) => {
26349 existingCallback(items, {
26350 ...argsObject,
26351 onActionPerformed: _items => {
26352 if (argsObject?.onActionPerformed) {
26353 argsObject.onActionPerformed(_items);
26354 }
26355 onActionPerformed(actions[i].id, _items);
26356 }
26357 });
26358 }
26359 };
26360 }
26361 if (actions[i].RenderModal) {
26362 const ExistingRenderModal = actions[i].RenderModal;
26363 actions[i] = {
26364 ...actions[i],
26365 RenderModal: props => {
26366 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ExistingRenderModal, {
26367 ...props,
26368 onActionPerformed: _items => {
26369 if (props.onActionPerformed) {
26370 props.onActionPerformed(_items);
26371 }
26372 onActionPerformed(actions[i].id, _items);
26373 }
26374 });
26375 }
26376 };
26377 }
26378 }
26379 }
26380 return actions;
26381 // We are making this use memo depend on cachedCanUserResolvers as a way to make the component using this hook re-render
26382 // when user capabilities are resolved. This makes sure the isEligible functions of actions dependent on capabilities are re-evaluated.
26383 // eslint-disable-next-line react-hooks/exhaustive-deps
26384 }, [defaultActions, userCanCreatePostType, isTemplateOrTemplatePart, isPattern, postTypeObject?.viewable, duplicatePostAction, reorderPagesAction, trashPostActionForPostType, restorePostActionForPostType, renamePostActionForPostType, permanentlyDeletePostActionForPostType, onActionPerformed, isLoaded, supportsRevisions, supportsTitle, context, cachedCanUserResolvers]);
26385 }
26386
26387 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-actions/index.js
26388 /**
26389 * WordPress dependencies
26390 */
26391
26392
26393
26394
26395
26396
26397
26398 /**
26399 * Internal dependencies
26400 */
26401
26402
26403
26404
26405
26406
26407 const {
26408 DropdownMenuV2: DropdownMenu,
26409 DropdownMenuGroupV2: DropdownMenuGroup,
26410 DropdownMenuItemV2: DropdownMenuItem,
26411 DropdownMenuItemLabelV2: DropdownMenuItemLabel,
26412 kebabCase
26413 } = unlock(external_wp_components_namespaceObject.privateApis);
26414 function PostActions({
26415 onActionPerformed,
26416 buttonProps
26417 }) {
26418 const [isActionsMenuOpen, setIsActionsMenuOpen] = (0,external_wp_element_namespaceObject.useState)(false);
26419 const {
26420 item,
26421 postType
26422 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26423 const {
26424 getCurrentPostType,
26425 getCurrentPostId
26426 } = select(store_store);
26427 const {
26428 getEditedEntityRecord
26429 } = select(external_wp_coreData_namespaceObject.store);
26430 const _postType = getCurrentPostType();
26431 return {
26432 item: getEditedEntityRecord('postType', _postType, getCurrentPostId()),
26433 postType: _postType
26434 };
26435 }, []);
26436 const allActions = usePostActions({
26437 postType,
26438 onActionPerformed
26439 });
26440 const actions = (0,external_wp_element_namespaceObject.useMemo)(() => {
26441 return allActions.filter(action => {
26442 return !action.isEligible || action.isEligible(item);
26443 });
26444 }, [allActions, item]);
26445 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenu, {
26446 open: isActionsMenuOpen,
26447 trigger: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26448 size: "small",
26449 icon: more_vertical,
26450 label: (0,external_wp_i18n_namespaceObject.__)('Actions'),
26451 disabled: !actions.length,
26452 accessibleWhenDisabled: true,
26453 className: "editor-all-actions-button",
26454 onClick: () => setIsActionsMenuOpen(!isActionsMenuOpen),
26455 ...buttonProps
26456 }),
26457 onOpenChange: setIsActionsMenuOpen,
26458 placement: "bottom-end",
26459 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ActionsDropdownMenuGroup, {
26460 actions: actions,
26461 item: item,
26462 onClose: () => {
26463 setIsActionsMenuOpen(false);
26464 }
26465 })
26466 });
26467 }
26468
26469 // From now on all the functions on this file are copied as from the dataviews packages,
26470 // The editor packages should not be using the dataviews packages directly,
26471 // and the dataviews package should not be using the editor packages directly,
26472 // so duplicating the code here seems like the least bad option.
26473
26474 // Copied as is from packages/dataviews/src/item-actions.js
26475 function DropdownMenuItemTrigger({
26476 action,
26477 onClick,
26478 items
26479 }) {
26480 const label = typeof action.label === 'string' ? action.label : action.label(items);
26481 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenuItem, {
26482 onClick: onClick,
26483 hideOnClick: !action.RenderModal,
26484 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenuItemLabel, {
26485 children: label
26486 })
26487 });
26488 }
26489
26490 // Copied as is from packages/dataviews/src/item-actions.js
26491 // With an added onClose prop.
26492 function ActionWithModal({
26493 action,
26494 item,
26495 ActionTrigger,
26496 onClose
26497 }) {
26498 const [isModalOpen, setIsModalOpen] = (0,external_wp_element_namespaceObject.useState)(false);
26499 const actionTriggerProps = {
26500 action,
26501 onClick: () => setIsModalOpen(true),
26502 items: [item]
26503 };
26504 const {
26505 RenderModal,
26506 hideModalHeader
26507 } = action;
26508 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26509 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ActionTrigger, {
26510 ...actionTriggerProps
26511 }), isModalOpen && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Modal, {
26512 title: action.modalHeader || action.label,
26513 __experimentalHideHeader: !!hideModalHeader,
26514 onRequestClose: () => {
26515 setIsModalOpen(false);
26516 },
26517 overlayClassName: `editor-action-modal editor-action-modal__${kebabCase(action.id)}`,
26518 focusOnMount: "firstContentElement",
26519 size: "small",
26520 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(RenderModal, {
26521 items: [item],
26522 closeModal: () => {
26523 setIsModalOpen(false);
26524 onClose();
26525 }
26526 })
26527 })]
26528 });
26529 }
26530
26531 // Copied as is from packages/dataviews/src/item-actions.js
26532 // With an added onClose prop.
26533 function ActionsDropdownMenuGroup({
26534 actions,
26535 item,
26536 onClose
26537 }) {
26538 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenuGroup, {
26539 children: actions.map(action => {
26540 if (action.RenderModal) {
26541 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(ActionWithModal, {
26542 action: action,
26543 item: item,
26544 ActionTrigger: DropdownMenuItemTrigger,
26545 onClose: onClose
26546 }, action.id);
26547 }
26548 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(DropdownMenuItemTrigger, {
26549 action: action,
26550 onClick: () => action.callback([item]),
26551 items: [item]
26552 }, action.id);
26553 })
26554 });
26555 }
26556
26557 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-card-panel/index.js
26558 /**
26559 * External dependencies
26560 */
26561
26562 /**
26563 * WordPress dependencies
26564 */
26565
26566
26567
26568
26569
26570
26571 /**
26572 * Internal dependencies
26573 */
26574
26575
26576
26577
26578
26579 function PostCardPanel({
26580 actions
26581 }) {
26582 const {
26583 isFrontPage,
26584 isPostsPage,
26585 title,
26586 icon,
26587 isSync
26588 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26589 const {
26590 getEditedPostAttribute,
26591 getCurrentPostType,
26592 getCurrentPostId,
26593 __experimentalGetTemplateInfo
26594 } = select(store_store);
26595 const {
26596 canUser
26597 } = select(external_wp_coreData_namespaceObject.store);
26598 const {
26599 getEditedEntityRecord
26600 } = select(external_wp_coreData_namespaceObject.store);
26601 const siteSettings = canUser('read', {
26602 kind: 'root',
26603 name: 'site'
26604 }) ? getEditedEntityRecord('root', 'site') : undefined;
26605 const _type = getCurrentPostType();
26606 const _id = getCurrentPostId();
26607 const _record = getEditedEntityRecord('postType', _type, _id);
26608 const _templateInfo = [TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(_type) && __experimentalGetTemplateInfo(_record);
26609 let _isSync = false;
26610 if (GLOBAL_POST_TYPES.includes(_type)) {
26611 if (PATTERN_POST_TYPE === _type) {
26612 // When the post is first created, the top level wp_pattern_sync_status is not set so get meta value instead.
26613 const currentSyncStatus = getEditedPostAttribute('meta')?.wp_pattern_sync_status === 'unsynced' ? 'unsynced' : getEditedPostAttribute('wp_pattern_sync_status');
26614 _isSync = currentSyncStatus !== 'unsynced';
26615 } else {
26616 _isSync = true;
26617 }
26618 }
26619 return {
26620 title: _templateInfo?.title || getEditedPostAttribute('title'),
26621 icon: unlock(select(store_store)).getPostIcon(_type, {
26622 area: _record?.area
26623 }),
26624 isSync: _isSync,
26625 isFrontPage: siteSettings?.page_on_front === _id,
26626 isPostsPage: siteSettings?.page_for_posts === _id
26627 };
26628 }, []);
26629 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
26630 className: "editor-post-card-panel",
26631 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
26632 spacing: 2,
26633 className: "editor-post-card-panel__header",
26634 align: "flex-start",
26635 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Icon, {
26636 className: dist_clsx('editor-post-card-panel__icon', {
26637 'is-sync': isSync
26638 }),
26639 icon: icon
26640 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalText, {
26641 numberOfLines: 2,
26642 truncate: true,
26643 className: "editor-post-card-panel__title",
26644 weight: 500,
26645 as: "h2",
26646 lineHeight: "20px",
26647 children: [title ? (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(title) : (0,external_wp_i18n_namespaceObject.__)('No Title'), isFrontPage && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
26648 className: "editor-post-card-panel__title-badge",
26649 children: (0,external_wp_i18n_namespaceObject.__)('Homepage')
26650 }), isPostsPage && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
26651 className: "editor-post-card-panel__title-badge",
26652 children: (0,external_wp_i18n_namespaceObject.__)('Posts Page')
26653 })]
26654 }), actions]
26655 })
26656 });
26657 }
26658
26659 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-content-information/index.js
26660 /**
26661 * WordPress dependencies
26662 */
26663
26664
26665
26666
26667
26668
26669
26670 /**
26671 * Internal dependencies
26672 */
26673
26674
26675
26676 // Taken from packages/editor/src/components/time-to-read/index.js.
26677
26678 const post_content_information_AVERAGE_READING_RATE = 189;
26679
26680 // This component renders the wordcount and reading time for the post.
26681 function PostContentInformation() {
26682 const {
26683 postContent
26684 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26685 const {
26686 getEditedPostAttribute,
26687 getCurrentPostType,
26688 getCurrentPostId
26689 } = select(store_store);
26690 const {
26691 canUser
26692 } = select(external_wp_coreData_namespaceObject.store);
26693 const {
26694 getEntityRecord
26695 } = select(external_wp_coreData_namespaceObject.store);
26696 const siteSettings = canUser('read', {
26697 kind: 'root',
26698 name: 'site'
26699 }) ? getEntityRecord('root', 'site') : undefined;
26700 const postType = getCurrentPostType();
26701 const _id = getCurrentPostId();
26702 const isPostsPage = +_id === siteSettings?.page_for_posts;
26703 const showPostContentInfo = !isPostsPage && ![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE].includes(postType);
26704 return {
26705 postContent: showPostContentInfo && getEditedPostAttribute('content')
26706 };
26707 }, []);
26708
26709 /*
26710 * translators: If your word count is based on single characters (e.g. East Asian characters),
26711 * enter 'characters_excluding_spaces' or 'characters_including_spaces'. Otherwise, enter 'words'.
26712 * Do not translate into your own language.
26713 */
26714 const wordCountType = (0,external_wp_i18n_namespaceObject._x)('words', 'Word count type. Do not translate!');
26715 const wordsCounted = (0,external_wp_element_namespaceObject.useMemo)(() => postContent ? (0,external_wp_wordcount_namespaceObject.count)(postContent, wordCountType) : 0, [postContent, wordCountType]);
26716 if (!wordsCounted) {
26717 return null;
26718 }
26719 const readingTime = Math.round(wordsCounted / post_content_information_AVERAGE_READING_RATE);
26720 const wordsCountText = (0,external_wp_i18n_namespaceObject.sprintf)(
26721 // translators: %s: the number of words in the post.
26722 (0,external_wp_i18n_namespaceObject._n)('%s word', '%s words', wordsCounted), wordsCounted.toLocaleString());
26723 const minutesText = readingTime <= 1 ? (0,external_wp_i18n_namespaceObject.__)('1 minute') : (0,external_wp_i18n_namespaceObject.sprintf)(
26724 // translators: %s: the number of minutes to read the post.
26725 (0,external_wp_i18n_namespaceObject._n)('%s minute', '%s minutes', readingTime), readingTime.toLocaleString());
26726 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
26727 className: "editor-post-content-information",
26728 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26729 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.) */
26730 (0,external_wp_i18n_namespaceObject.__)('%1$s, %2$s read time.'), wordsCountText, minutesText)
26731 })
26732 });
26733 }
26734
26735 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-format/panel.js
26736 /**
26737 * WordPress dependencies
26738 */
26739
26740
26741
26742
26743
26744
26745 /**
26746 * Internal dependencies
26747 */
26748
26749
26750
26751
26752
26753 /**
26754 * Renders the Post Author Panel component.
26755 *
26756 * @return {Component} The component to be rendered.
26757 */
26758
26759
26760 function panel_PostFormat() {
26761 const {
26762 postFormat
26763 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26764 const {
26765 getEditedPostAttribute
26766 } = select(store_store);
26767 const _postFormat = getEditedPostAttribute('format');
26768 return {
26769 postFormat: _postFormat !== null && _postFormat !== void 0 ? _postFormat : 'standard'
26770 };
26771 }, []);
26772 const activeFormat = POST_FORMATS.find(format => format.id === postFormat);
26773
26774 // Use internal state instead of a ref to make sure that the component
26775 // re-renders when the popover's anchor updates.
26776 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
26777 // Memoize popoverProps to avoid returning a new object every time.
26778 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
26779 // Anchor the popover to the middle of the entire row so that it doesn't
26780 // move around when the label changes.
26781 anchor: popoverAnchor,
26782 placement: 'left-start',
26783 offset: 36,
26784 shift: true
26785 }), [popoverAnchor]);
26786 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_format_check, {
26787 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
26788 label: (0,external_wp_i18n_namespaceObject.__)('Format'),
26789 ref: setPopoverAnchor,
26790 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
26791 popoverProps: popoverProps,
26792 contentClassName: "editor-post-format__dialog",
26793 focusOnMount: true,
26794 renderToggle: ({
26795 isOpen,
26796 onToggle
26797 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26798 size: "compact",
26799 variant: "tertiary",
26800 "aria-expanded": isOpen,
26801 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
26802 // translators: %s: Current post format.
26803 (0,external_wp_i18n_namespaceObject.__)('Change format: %s'), activeFormat?.caption),
26804 onClick: onToggle,
26805 children: activeFormat?.caption
26806 }),
26807 renderContent: ({
26808 onClose
26809 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
26810 className: "editor-post-format__dialog-content",
26811 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
26812 title: (0,external_wp_i18n_namespaceObject.__)('Format'),
26813 onClose: onClose
26814 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFormat, {})]
26815 })
26816 })
26817 })
26818 });
26819 }
26820 /* harmony default export */ const post_format_panel = (panel_PostFormat);
26821
26822 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-last-edited-panel/index.js
26823 /**
26824 * WordPress dependencies
26825 */
26826
26827
26828
26829
26830
26831 /**
26832 * Internal dependencies
26833 */
26834
26835
26836 function PostLastEditedPanel() {
26837 const modified = (0,external_wp_data_namespaceObject.useSelect)(select => select(store_store).getEditedPostAttribute('modified'), []);
26838 const lastEditedText = modified && (0,external_wp_i18n_namespaceObject.sprintf)(
26839 // translators: %s: Human-readable time difference, e.g. "2 days ago".
26840 (0,external_wp_i18n_namespaceObject.__)('Last edited %s.'), (0,external_wp_date_namespaceObject.humanTimeDiff)(modified));
26841 if (!lastEditedText) {
26842 return null;
26843 }
26844 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("div", {
26845 className: "editor-post-last-edited-panel",
26846 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
26847 children: lastEditedText
26848 })
26849 });
26850 }
26851
26852 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-panel-section/index.js
26853 /**
26854 * External dependencies
26855 */
26856
26857
26858 /**
26859 * WordPress dependencies
26860 */
26861
26862
26863 function PostPanelSection({
26864 className,
26865 children
26866 }) {
26867 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalVStack, {
26868 className: dist_clsx('editor-post-panel__section', className),
26869 children: children
26870 });
26871 }
26872 /* harmony default export */ const post_panel_section = (PostPanelSection);
26873
26874 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/blog-title/index.js
26875 /**
26876 * WordPress dependencies
26877 */
26878
26879
26880
26881
26882
26883
26884
26885
26886
26887 /**
26888 * Internal dependencies
26889 */
26890
26891
26892
26893
26894
26895
26896 const blog_title_EMPTY_OBJECT = {};
26897 function BlogTitle() {
26898 const {
26899 editEntityRecord
26900 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
26901 const {
26902 postsPageTitle,
26903 postsPageId,
26904 isTemplate,
26905 postSlug
26906 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
26907 const {
26908 getEntityRecord,
26909 getEditedEntityRecord,
26910 canUser
26911 } = select(external_wp_coreData_namespaceObject.store);
26912 const siteSettings = canUser('read', {
26913 kind: 'root',
26914 name: 'site'
26915 }) ? getEntityRecord('root', 'site') : undefined;
26916 const _postsPageRecord = siteSettings?.page_for_posts ? getEditedEntityRecord('postType', 'page', siteSettings?.page_for_posts) : blog_title_EMPTY_OBJECT;
26917 const {
26918 getEditedPostAttribute,
26919 getCurrentPostType
26920 } = select(store_store);
26921 return {
26922 postsPageId: _postsPageRecord?.id,
26923 postsPageTitle: _postsPageRecord?.title,
26924 isTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,
26925 postSlug: getEditedPostAttribute('slug')
26926 };
26927 }, []);
26928 // Use internal state instead of a ref to make sure that the component
26929 // re-renders when the popover's anchor updates.
26930 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
26931 // Memoize popoverProps to avoid returning a new object every time.
26932 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
26933 // Anchor the popover to the middle of the entire row so that it doesn't
26934 // move around when the label changes.
26935 anchor: popoverAnchor,
26936 placement: 'left-start',
26937 offset: 36,
26938 shift: true
26939 }), [popoverAnchor]);
26940 if (!isTemplate || !['home', 'index'].includes(postSlug) || !postsPageId) {
26941 return null;
26942 }
26943 const setPostsPageTitle = newValue => {
26944 editEntityRecord('postType', 'page', postsPageId, {
26945 title: newValue
26946 });
26947 };
26948 const decodedTitle = (0,external_wp_htmlEntities_namespaceObject.decodeEntities)(postsPageTitle);
26949 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
26950 label: (0,external_wp_i18n_namespaceObject.__)('Blog title'),
26951 ref: setPopoverAnchor,
26952 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
26953 popoverProps: popoverProps,
26954 contentClassName: "editor-blog-title-dropdown__content",
26955 focusOnMount: true,
26956 renderToggle: ({
26957 isOpen,
26958 onToggle
26959 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
26960 size: "compact",
26961 variant: "tertiary",
26962 "aria-expanded": isOpen,
26963 "aria-label": (0,external_wp_i18n_namespaceObject.sprintf)(
26964 // translators: %s: Current post link.
26965 (0,external_wp_i18n_namespaceObject.__)('Change blog title: %s'), decodedTitle),
26966 onClick: onToggle,
26967 children: decodedTitle
26968 }),
26969 renderContent: ({
26970 onClose
26971 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
26972 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
26973 title: (0,external_wp_i18n_namespaceObject.__)('Blog title'),
26974 onClose: onClose
26975 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalInputControl, {
26976 placeholder: (0,external_wp_i18n_namespaceObject.__)('No Title'),
26977 size: "__unstable-large",
26978 value: postsPageTitle,
26979 onChange: (0,external_wp_compose_namespaceObject.debounce)(setPostsPageTitle, 300),
26980 label: (0,external_wp_i18n_namespaceObject.__)('Blog title'),
26981 help: (0,external_wp_i18n_namespaceObject.__)('Set the Posts Page title. Appears in search results, and when the page is shared on social media.'),
26982 hideLabelFromVision: true
26983 })]
26984 })
26985 })
26986 });
26987 }
26988
26989 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/posts-per-page/index.js
26990 /**
26991 * WordPress dependencies
26992 */
26993
26994
26995
26996
26997
26998
26999
27000 /**
27001 * Internal dependencies
27002 */
27003
27004
27005
27006
27007
27008
27009 function PostsPerPage() {
27010 const {
27011 editEntityRecord
27012 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
27013 const {
27014 postsPerPage,
27015 isTemplate,
27016 postSlug
27017 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27018 const {
27019 getEditedPostAttribute,
27020 getCurrentPostType
27021 } = select(store_store);
27022 const {
27023 getEditedEntityRecord,
27024 canUser
27025 } = select(external_wp_coreData_namespaceObject.store);
27026 const siteSettings = canUser('read', {
27027 kind: 'root',
27028 name: 'site'
27029 }) ? getEditedEntityRecord('root', 'site') : undefined;
27030 return {
27031 isTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,
27032 postSlug: getEditedPostAttribute('slug'),
27033 postsPerPage: siteSettings?.posts_per_page || 1
27034 };
27035 }, []);
27036 // Use internal state instead of a ref to make sure that the component
27037 // re-renders when the popover's anchor updates.
27038 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
27039 // Memoize popoverProps to avoid returning a new object every time.
27040 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
27041 // Anchor the popover to the middle of the entire row so that it doesn't
27042 // move around when the label changes.
27043 anchor: popoverAnchor,
27044 placement: 'left-start',
27045 offset: 36,
27046 shift: true
27047 }), [popoverAnchor]);
27048 if (!isTemplate || !['home', 'index'].includes(postSlug)) {
27049 return null;
27050 }
27051 const setPostsPerPage = newValue => {
27052 editEntityRecord('root', 'site', undefined, {
27053 posts_per_page: newValue
27054 });
27055 };
27056 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
27057 label: (0,external_wp_i18n_namespaceObject.__)('Posts per page'),
27058 ref: setPopoverAnchor,
27059 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
27060 popoverProps: popoverProps,
27061 contentClassName: "editor-posts-per-page-dropdown__content",
27062 focusOnMount: true,
27063 renderToggle: ({
27064 isOpen,
27065 onToggle
27066 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
27067 size: "compact",
27068 variant: "tertiary",
27069 "aria-expanded": isOpen,
27070 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Change posts per page'),
27071 onClick: onToggle,
27072 children: postsPerPage
27073 }),
27074 renderContent: ({
27075 onClose
27076 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27077 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
27078 title: (0,external_wp_i18n_namespaceObject.__)('Posts per page'),
27079 onClose: onClose
27080 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalNumberControl, {
27081 placeholder: 0,
27082 value: postsPerPage,
27083 size: "__unstable-large",
27084 spinControls: "custom",
27085 step: "1",
27086 min: "1",
27087 onChange: setPostsPerPage,
27088 label: (0,external_wp_i18n_namespaceObject.__)('Posts per page'),
27089 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.'),
27090 hideLabelFromVision: true
27091 })]
27092 })
27093 })
27094 });
27095 }
27096
27097 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/site-discussion/index.js
27098 /**
27099 * WordPress dependencies
27100 */
27101
27102
27103
27104
27105
27106
27107
27108 /**
27109 * Internal dependencies
27110 */
27111
27112
27113
27114
27115
27116
27117 const site_discussion_COMMENT_OPTIONS = [{
27118 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27119 children: [(0,external_wp_i18n_namespaceObject._x)('Open', 'Adjective: e.g. "Comments are open"'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27120 variant: "muted",
27121 size: 12,
27122 children: (0,external_wp_i18n_namespaceObject.__)('Visitors can add new comments and replies.')
27123 })]
27124 }),
27125 value: 'open'
27126 }, {
27127 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27128 children: [(0,external_wp_i18n_namespaceObject.__)('Closed'), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27129 variant: "muted",
27130 size: 12,
27131 children: (0,external_wp_i18n_namespaceObject.__)('Visitors cannot add new comments or replies.')
27132 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27133 variant: "muted",
27134 size: 12,
27135 children: (0,external_wp_i18n_namespaceObject.__)('Existing comments remain visible.')
27136 })]
27137 }),
27138 value: ''
27139 }];
27140 function SiteDiscussion() {
27141 const {
27142 editEntityRecord
27143 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
27144 const {
27145 allowCommentsOnNewPosts,
27146 isTemplate,
27147 postSlug
27148 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27149 const {
27150 getEditedPostAttribute,
27151 getCurrentPostType
27152 } = select(store_store);
27153 const {
27154 getEditedEntityRecord,
27155 canUser
27156 } = select(external_wp_coreData_namespaceObject.store);
27157 const siteSettings = canUser('read', {
27158 kind: 'root',
27159 name: 'site'
27160 }) ? getEditedEntityRecord('root', 'site') : undefined;
27161 return {
27162 isTemplate: getCurrentPostType() === TEMPLATE_POST_TYPE,
27163 postSlug: getEditedPostAttribute('slug'),
27164 allowCommentsOnNewPosts: siteSettings?.default_comment_status || ''
27165 };
27166 }, []);
27167 // Use internal state instead of a ref to make sure that the component
27168 // re-renders when the popover's anchor updates.
27169 const [popoverAnchor, setPopoverAnchor] = (0,external_wp_element_namespaceObject.useState)(null);
27170 // Memoize popoverProps to avoid returning a new object every time.
27171 const popoverProps = (0,external_wp_element_namespaceObject.useMemo)(() => ({
27172 // Anchor the popover to the middle of the entire row so that it doesn't
27173 // move around when the label changes.
27174 anchor: popoverAnchor,
27175 placement: 'left-start',
27176 offset: 36,
27177 shift: true
27178 }), [popoverAnchor]);
27179 if (!isTemplate || !['home', 'index'].includes(postSlug)) {
27180 return null;
27181 }
27182 const setAllowCommentsOnNewPosts = newValue => {
27183 editEntityRecord('root', 'site', undefined, {
27184 default_comment_status: newValue ? 'open' : null
27185 });
27186 };
27187 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_row, {
27188 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
27189 ref: setPopoverAnchor,
27190 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Dropdown, {
27191 popoverProps: popoverProps,
27192 contentClassName: "editor-site-discussion-dropdown__content",
27193 focusOnMount: true,
27194 renderToggle: ({
27195 isOpen,
27196 onToggle
27197 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
27198 size: "compact",
27199 variant: "tertiary",
27200 "aria-expanded": isOpen,
27201 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Change discussion settings'),
27202 onClick: onToggle,
27203 children: allowCommentsOnNewPosts ? (0,external_wp_i18n_namespaceObject.__)('Comments open') : (0,external_wp_i18n_namespaceObject.__)('Comments closed')
27204 }),
27205 renderContent: ({
27206 onClose
27207 }) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27208 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalInspectorPopoverHeader, {
27209 title: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
27210 onClose: onClose
27211 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27212 spacing: 3,
27213 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
27214 children: (0,external_wp_i18n_namespaceObject.__)('Changes will apply to new posts only. Individual posts may override these settings.')
27215 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.RadioControl, {
27216 className: "editor-site-discussion__options",
27217 hideLabelFromVision: true,
27218 label: (0,external_wp_i18n_namespaceObject.__)('Comment status'),
27219 options: site_discussion_COMMENT_OPTIONS,
27220 onChange: setAllowCommentsOnNewPosts,
27221 selected: allowCommentsOnNewPosts
27222 })]
27223 })]
27224 })
27225 })
27226 });
27227 }
27228
27229 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/sidebar/post-summary.js
27230 /**
27231 * WordPress dependencies
27232 */
27233
27234
27235
27236 /**
27237 * Internal dependencies
27238 */
27239
27240
27241
27242
27243
27244
27245
27246
27247
27248
27249
27250
27251
27252
27253
27254
27255
27256
27257
27258
27259
27260
27261
27262 /**
27263 * Module Constants
27264 */
27265
27266
27267
27268 const post_summary_PANEL_NAME = 'post-status';
27269 function PostSummary({
27270 onActionPerformed
27271 }) {
27272 const {
27273 isRemovedPostStatusPanel
27274 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27275 // We use isEditorPanelRemoved to hide the panel if it was programatically removed. We do
27276 // not use isEditorPanelEnabled since this panel should not be disabled through the UI.
27277 const {
27278 isEditorPanelRemoved,
27279 getCurrentPostType
27280 } = select(store_store);
27281 return {
27282 isRemovedPostStatusPanel: isEditorPanelRemoved(post_summary_PANEL_NAME),
27283 postType: getCurrentPostType()
27284 };
27285 }, []);
27286 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_panel_section, {
27287 className: "editor-post-summary",
27288 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_post_status_info.Slot, {
27289 children: fills => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27290 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27291 spacing: 4,
27292 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostCardPanel, {
27293 actions: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostActions, {
27294 onActionPerformed: onActionPerformed
27295 })
27296 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostFeaturedImagePanel, {
27297 withPanelBody: false
27298 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PrivatePostExcerptPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27299 spacing: 1,
27300 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostContentInformation, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostLastEditedPanel, {})]
27301 }), !isRemovedPostStatusPanel && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27302 spacing: 4,
27303 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
27304 spacing: 1,
27305 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)(PrivatePostLastRevision, {}), /*#__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, {})]
27306 }), fills]
27307 })]
27308 })
27309 })
27310 })
27311 });
27312 }
27313
27314 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-transform-panel/hooks.js
27315 /**
27316 * WordPress dependencies
27317 */
27318
27319
27320
27321
27322
27323
27324 /**
27325 * Internal dependencies
27326 */
27327
27328
27329 const {
27330 EXCLUDED_PATTERN_SOURCES,
27331 PATTERN_TYPES: hooks_PATTERN_TYPES
27332 } = unlock(external_wp_patterns_namespaceObject.privateApis);
27333 function injectThemeAttributeInBlockTemplateContent(block, currentThemeStylesheet) {
27334 block.innerBlocks = block.innerBlocks.map(innerBlock => {
27335 return injectThemeAttributeInBlockTemplateContent(innerBlock, currentThemeStylesheet);
27336 });
27337 if (block.name === 'core/template-part' && block.attributes.theme === undefined) {
27338 block.attributes.theme = currentThemeStylesheet;
27339 }
27340 return block;
27341 }
27342
27343 /**
27344 * Filter all patterns and return only the ones that are compatible with the current template.
27345 *
27346 * @param {Array} patterns An array of patterns.
27347 * @param {Object} template The current template.
27348 * @return {Array} Array of patterns that are compatible with the current template.
27349 */
27350 function filterPatterns(patterns, template) {
27351 // Filter out duplicates.
27352 const filterOutDuplicatesByName = (currentItem, index, items) => index === items.findIndex(item => currentItem.name === item.name);
27353
27354 // Filter out core/directory patterns not included in theme.json.
27355 const filterOutExcludedPatternSources = pattern => !EXCLUDED_PATTERN_SOURCES.includes(pattern.source);
27356
27357 // Looks for patterns that have the same template type as the current template,
27358 // or have a block type that matches the current template area.
27359 const filterCompatiblePatterns = pattern => pattern.templateTypes?.includes(template.slug) || pattern.blockTypes?.includes('core/template-part/' + template.area);
27360 return patterns.filter((pattern, index, items) => {
27361 return filterOutDuplicatesByName(pattern, index, items) && filterOutExcludedPatternSources(pattern) && filterCompatiblePatterns(pattern);
27362 });
27363 }
27364 function preparePatterns(patterns, currentThemeStylesheet) {
27365 return patterns.map(pattern => ({
27366 ...pattern,
27367 keywords: pattern.keywords || [],
27368 type: hooks_PATTERN_TYPES.theme,
27369 blocks: (0,external_wp_blocks_namespaceObject.parse)(pattern.content, {
27370 __unstableSkipMigrationLogs: true
27371 }).map(block => injectThemeAttributeInBlockTemplateContent(block, currentThemeStylesheet))
27372 }));
27373 }
27374 function useAvailablePatterns(template) {
27375 const {
27376 blockPatterns,
27377 restBlockPatterns,
27378 currentThemeStylesheet
27379 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27380 var _settings$__experimen;
27381 const {
27382 getEditorSettings
27383 } = select(store_store);
27384 const settings = getEditorSettings();
27385 return {
27386 blockPatterns: (_settings$__experimen = settings.__experimentalAdditionalBlockPatterns) !== null && _settings$__experimen !== void 0 ? _settings$__experimen : settings.__experimentalBlockPatterns,
27387 restBlockPatterns: select(external_wp_coreData_namespaceObject.store).getBlockPatterns(),
27388 currentThemeStylesheet: select(external_wp_coreData_namespaceObject.store).getCurrentTheme().stylesheet
27389 };
27390 }, []);
27391 return (0,external_wp_element_namespaceObject.useMemo)(() => {
27392 const mergedPatterns = [...(blockPatterns || []), ...(restBlockPatterns || [])];
27393 const filteredPatterns = filterPatterns(mergedPatterns, template);
27394 return preparePatterns(filteredPatterns, template, currentThemeStylesheet);
27395 }, [blockPatterns, restBlockPatterns, template, currentThemeStylesheet]);
27396 }
27397
27398 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/post-transform-panel/index.js
27399 /**
27400 * WordPress dependencies
27401 */
27402
27403
27404
27405
27406
27407
27408
27409
27410 /**
27411 * Internal dependencies
27412 */
27413
27414
27415
27416
27417 function post_transform_panel_TemplatesList({
27418 availableTemplates,
27419 onSelect
27420 }) {
27421 const shownTemplates = (0,external_wp_compose_namespaceObject.useAsyncList)(availableTemplates);
27422 if (!availableTemplates || availableTemplates?.length === 0) {
27423 return null;
27424 }
27425 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.__experimentalBlockPatternsList, {
27426 label: (0,external_wp_i18n_namespaceObject.__)('Templates'),
27427 blockPatterns: availableTemplates,
27428 shownPatterns: shownTemplates,
27429 onClickPattern: onSelect,
27430 showTitlesAsTooltip: true
27431 });
27432 }
27433 function PostTransform() {
27434 const {
27435 record,
27436 postType,
27437 postId
27438 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27439 const {
27440 getCurrentPostType,
27441 getCurrentPostId
27442 } = select(store_store);
27443 const {
27444 getEditedEntityRecord
27445 } = select(external_wp_coreData_namespaceObject.store);
27446 const type = getCurrentPostType();
27447 const id = getCurrentPostId();
27448 return {
27449 postType: type,
27450 postId: id,
27451 record: getEditedEntityRecord('postType', type, id)
27452 };
27453 }, []);
27454 const {
27455 editEntityRecord
27456 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
27457 const availablePatterns = useAvailablePatterns(record);
27458 const onTemplateSelect = async selectedTemplate => {
27459 await editEntityRecord('postType', postType, postId, {
27460 blocks: selectedTemplate.blocks,
27461 content: (0,external_wp_blocks_namespaceObject.serialize)(selectedTemplate.blocks)
27462 });
27463 };
27464 if (!availablePatterns?.length) {
27465 return null;
27466 }
27467 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
27468 title: (0,external_wp_i18n_namespaceObject.__)('Design'),
27469 initialOpen: record.type === TEMPLATE_PART_POST_TYPE,
27470 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_transform_panel_TemplatesList, {
27471 availableTemplates: availablePatterns,
27472 onSelect: onTemplateSelect
27473 })
27474 });
27475 }
27476 function PostTransformPanel() {
27477 const {
27478 postType
27479 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27480 const {
27481 getCurrentPostType
27482 } = select(store_store);
27483 return {
27484 postType: getCurrentPostType()
27485 };
27486 }, []);
27487 if (![TEMPLATE_PART_POST_TYPE, TEMPLATE_POST_TYPE].includes(postType)) {
27488 return null;
27489 }
27490 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTransform, {});
27491 }
27492
27493 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/sidebar/constants.js
27494 const sidebars = {
27495 document: 'edit-post/document',
27496 block: 'edit-post/block'
27497 };
27498
27499 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/sidebar/header.js
27500 /**
27501 * WordPress dependencies
27502 */
27503
27504
27505
27506
27507
27508 /**
27509 * Internal dependencies
27510 */
27511
27512
27513
27514
27515
27516 const {
27517 Tabs
27518 } = unlock(external_wp_components_namespaceObject.privateApis);
27519 const SidebarHeader = (_, ref) => {
27520 const {
27521 documentLabel
27522 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27523 const {
27524 getPostTypeLabel
27525 } = select(store_store);
27526 return {
27527 // translators: Default label for the Document sidebar tab, not selected.
27528 documentLabel: getPostTypeLabel() || (0,external_wp_i18n_namespaceObject._x)('Document', 'noun')
27529 };
27530 }, []);
27531 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(Tabs.TabList, {
27532 ref: ref,
27533 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.Tab, {
27534 tabId: sidebars.document
27535 // Used for focus management in the SettingsSidebar component.
27536 ,
27537 "data-tab-id": sidebars.document,
27538 children: documentLabel
27539 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(Tabs.Tab, {
27540 tabId: sidebars.block
27541 // Used for focus management in the SettingsSidebar component.
27542 ,
27543 "data-tab-id": sidebars.block,
27544 children: (0,external_wp_i18n_namespaceObject.__)('Block')
27545 })]
27546 });
27547 };
27548 /* harmony default export */ const sidebar_header = ((0,external_wp_element_namespaceObject.forwardRef)(SidebarHeader));
27549
27550 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-content-panel/index.js
27551 /**
27552 * WordPress dependencies
27553 */
27554
27555
27556
27557
27558
27559
27560 /**
27561 * Internal dependencies
27562 */
27563
27564
27565
27566
27567 const {
27568 BlockQuickNavigation
27569 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
27570 const PAGE_CONTENT_BLOCKS = ['core/post-content', 'core/post-featured-image', 'core/post-title'];
27571 const TEMPLATE_PART_BLOCK = 'core/template-part';
27572 function TemplateContentPanel() {
27573 const {
27574 enableComplementaryArea
27575 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
27576 const {
27577 clientIds,
27578 postType,
27579 renderingMode
27580 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27581 const {
27582 getBlocksByName
27583 } = select(external_wp_blockEditor_namespaceObject.store);
27584 const {
27585 getCurrentPostType
27586 } = select(store_store);
27587 const _postType = getCurrentPostType();
27588 return {
27589 postType: _postType,
27590 clientIds: getBlocksByName(TEMPLATE_POST_TYPE === _postType ? TEMPLATE_PART_BLOCK : PAGE_CONTENT_BLOCKS),
27591 renderingMode: select(store_store).getRenderingMode()
27592 };
27593 }, []);
27594 if (renderingMode === 'post-only' && postType !== TEMPLATE_POST_TYPE) {
27595 return null;
27596 }
27597 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
27598 title: (0,external_wp_i18n_namespaceObject.__)('Content'),
27599 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(BlockQuickNavigation, {
27600 clientIds: clientIds,
27601 onSelect: () => {
27602 enableComplementaryArea('core', 'edit-post/document');
27603 }
27604 })
27605 });
27606 }
27607
27608 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/template-part-content-panel/index.js
27609 /**
27610 * WordPress dependencies
27611 */
27612
27613
27614
27615
27616
27617
27618
27619 /**
27620 * Internal dependencies
27621 */
27622
27623
27624
27625
27626 const {
27627 BlockQuickNavigation: template_part_content_panel_BlockQuickNavigation
27628 } = unlock(external_wp_blockEditor_namespaceObject.privateApis);
27629 function TemplatePartContentPanelInner() {
27630 const blockTypes = (0,external_wp_data_namespaceObject.useSelect)(select => {
27631 const {
27632 getBlockTypes
27633 } = select(external_wp_blocks_namespaceObject.store);
27634 return getBlockTypes();
27635 }, []);
27636 const themeBlockNames = (0,external_wp_element_namespaceObject.useMemo)(() => {
27637 return blockTypes.filter(blockType => {
27638 return blockType.category === 'theme';
27639 }).map(({
27640 name
27641 }) => name);
27642 }, [blockTypes]);
27643 const themeBlocks = (0,external_wp_data_namespaceObject.useSelect)(select => {
27644 const {
27645 getBlocksByName
27646 } = select(external_wp_blockEditor_namespaceObject.store);
27647 return getBlocksByName(themeBlockNames);
27648 }, [themeBlockNames]);
27649 if (themeBlocks.length === 0) {
27650 return null;
27651 }
27652 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.PanelBody, {
27653 title: (0,external_wp_i18n_namespaceObject.__)('Content'),
27654 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(template_part_content_panel_BlockQuickNavigation, {
27655 clientIds: themeBlocks
27656 })
27657 });
27658 }
27659 function TemplatePartContentPanel() {
27660 const postType = (0,external_wp_data_namespaceObject.useSelect)(select => {
27661 const {
27662 getCurrentPostType
27663 } = select(store_store);
27664 return getCurrentPostType();
27665 }, []);
27666 if (postType !== TEMPLATE_PART_POST_TYPE) {
27667 return null;
27668 }
27669 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatePartContentPanelInner, {});
27670 }
27671
27672 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/provider/use-auto-switch-editor-sidebars.js
27673 /**
27674 * WordPress dependencies
27675 */
27676
27677
27678
27679
27680
27681
27682 /**
27683 * This listener hook monitors for block selection and triggers the appropriate
27684 * sidebar state.
27685 */
27686 function useAutoSwitchEditorSidebars() {
27687 const {
27688 hasBlockSelection
27689 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27690 return {
27691 hasBlockSelection: !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart()
27692 };
27693 }, []);
27694 const {
27695 getActiveComplementaryArea
27696 } = (0,external_wp_data_namespaceObject.useSelect)(store);
27697 const {
27698 enableComplementaryArea
27699 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
27700 const {
27701 get: getPreference
27702 } = (0,external_wp_data_namespaceObject.useSelect)(external_wp_preferences_namespaceObject.store);
27703 (0,external_wp_element_namespaceObject.useEffect)(() => {
27704 const activeGeneralSidebar = getActiveComplementaryArea('core');
27705 const isEditorSidebarOpened = ['edit-post/document', 'edit-post/block'].includes(activeGeneralSidebar);
27706 const isDistractionFree = getPreference('core', 'distractionFree');
27707 if (!isEditorSidebarOpened || isDistractionFree) {
27708 return;
27709 }
27710 if (hasBlockSelection) {
27711 enableComplementaryArea('core', 'edit-post/block');
27712 } else {
27713 enableComplementaryArea('core', 'edit-post/document');
27714 }
27715 }, [hasBlockSelection, getActiveComplementaryArea, enableComplementaryArea, getPreference]);
27716 }
27717 /* harmony default export */ const use_auto_switch_editor_sidebars = (useAutoSwitchEditorSidebars);
27718
27719 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/sidebar/index.js
27720 /**
27721 * WordPress dependencies
27722 */
27723
27724
27725
27726
27727
27728
27729
27730
27731
27732 /**
27733 * Internal dependencies
27734 */
27735
27736
27737
27738
27739
27740
27741
27742
27743
27744
27745
27746
27747
27748
27749
27750
27751 const {
27752 Tabs: sidebar_Tabs
27753 } = unlock(external_wp_components_namespaceObject.privateApis);
27754 const SIDEBAR_ACTIVE_BY_DEFAULT = external_wp_element_namespaceObject.Platform.select({
27755 web: true,
27756 native: false
27757 });
27758 const SidebarContent = ({
27759 tabName,
27760 keyboardShortcut,
27761 onActionPerformed,
27762 extraPanels
27763 }) => {
27764 const tabListRef = (0,external_wp_element_namespaceObject.useRef)(null);
27765 // Because `PluginSidebar` renders a `ComplementaryArea`, we
27766 // need to forward the `Tabs` context so it can be passed through the
27767 // underlying slot/fill.
27768 const tabsContextValue = (0,external_wp_element_namespaceObject.useContext)(sidebar_Tabs.Context);
27769
27770 // This effect addresses a race condition caused by tabbing from the last
27771 // block in the editor into the settings sidebar. Without this effect, the
27772 // selected tab and browser focus can become separated in an unexpected way
27773 // (e.g the "block" tab is focused, but the "post" tab is selected).
27774 (0,external_wp_element_namespaceObject.useEffect)(() => {
27775 const tabsElements = Array.from(tabListRef.current?.querySelectorAll('[role="tab"]') || []);
27776 const selectedTabElement = tabsElements.find(
27777 // We are purposefully using a custom `data-tab-id` attribute here
27778 // because we don't want rely on any assumptions about `Tabs`
27779 // component internals.
27780 element => element.getAttribute('data-tab-id') === tabName);
27781 const activeElement = selectedTabElement?.ownerDocument.activeElement;
27782 const tabsHasFocus = tabsElements.some(element => {
27783 return activeElement && activeElement.id === element.id;
27784 });
27785 if (tabsHasFocus && selectedTabElement && selectedTabElement.id !== activeElement?.id) {
27786 selectedTabElement?.focus();
27787 }
27788 }, [tabName]);
27789 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PluginSidebar, {
27790 identifier: tabName,
27791 header: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_Tabs.Context.Provider, {
27792 value: tabsContextValue,
27793 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_header, {
27794 ref: tabListRef
27795 })
27796 }),
27797 closeLabel: (0,external_wp_i18n_namespaceObject.__)('Close Settings')
27798 // This classname is added so we can apply a corrective negative
27799 // margin to the panel.
27800 // see https://github.com/WordPress/gutenberg/pull/55360#pullrequestreview-1737671049
27801 ,
27802 className: "editor-sidebar__panel",
27803 headerClassName: "editor-sidebar__panel-tabs"
27804 /* translators: button label text should, if possible, be under 16 characters. */,
27805 title: (0,external_wp_i18n_namespaceObject.__)('Settings'),
27806 toggleShortcut: keyboardShortcut,
27807 icon: (0,external_wp_i18n_namespaceObject.isRTL)() ? drawer_left : drawer_right,
27808 isActiveByDefault: SIDEBAR_ACTIVE_BY_DEFAULT,
27809 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(sidebar_Tabs.Context.Provider, {
27810 value: tabsContextValue,
27811 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(sidebar_Tabs.TabPanel, {
27812 tabId: sidebars.document,
27813 focusable: false,
27814 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostSummary, {
27815 onActionPerformed: onActionPerformed
27816 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(plugin_document_setting_panel.Slot, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplateContentPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(TemplatePartContentPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PostTransformPanel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_taxonomies_panel, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PatternOverridesPanel, {}), extraPanels]
27817 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_Tabs.TabPanel, {
27818 tabId: sidebars.block,
27819 focusable: false,
27820 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockInspector, {})
27821 })]
27822 })
27823 });
27824 };
27825 const Sidebar = ({
27826 extraPanels,
27827 onActionPerformed
27828 }) => {
27829 use_auto_switch_editor_sidebars();
27830 const {
27831 tabName,
27832 keyboardShortcut,
27833 showSummary
27834 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27835 const shortcut = select(external_wp_keyboardShortcuts_namespaceObject.store).getShortcutRepresentation('core/editor/toggle-sidebar');
27836 const sidebar = select(store).getActiveComplementaryArea('core');
27837 const _isEditorSidebarOpened = [sidebars.block, sidebars.document].includes(sidebar);
27838 let _tabName = sidebar;
27839 if (!_isEditorSidebarOpened) {
27840 _tabName = !!select(external_wp_blockEditor_namespaceObject.store).getBlockSelectionStart() ? sidebars.block : sidebars.document;
27841 }
27842 return {
27843 tabName: _tabName,
27844 keyboardShortcut: shortcut,
27845 showSummary: ![TEMPLATE_POST_TYPE, TEMPLATE_PART_POST_TYPE, NAVIGATION_POST_TYPE].includes(select(store_store).getCurrentPostType())
27846 };
27847 }, []);
27848 const {
27849 enableComplementaryArea
27850 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
27851 const onTabSelect = (0,external_wp_element_namespaceObject.useCallback)(newSelectedTabId => {
27852 if (!!newSelectedTabId) {
27853 enableComplementaryArea('core', newSelectedTabId);
27854 }
27855 }, [enableComplementaryArea]);
27856 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(sidebar_Tabs, {
27857 selectedTabId: tabName,
27858 onSelect: onTabSelect,
27859 selectOnMove: false,
27860 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(SidebarContent, {
27861 tabName: tabName,
27862 keyboardShortcut: keyboardShortcut,
27863 showSummary: showSummary,
27864 onActionPerformed: onActionPerformed,
27865 extraPanels: extraPanels
27866 })
27867 });
27868 };
27869 /* harmony default export */ const components_sidebar = (Sidebar);
27870
27871 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/editor/index.js
27872 /**
27873 * WordPress dependencies
27874 */
27875
27876
27877
27878
27879
27880 /**
27881 * Internal dependencies
27882 */
27883
27884
27885
27886
27887
27888
27889
27890 function Editor({
27891 postType,
27892 postId,
27893 templateId,
27894 settings,
27895 children,
27896 initialEdits,
27897 // This could be part of the settings.
27898 onActionPerformed,
27899 // The following abstractions are not ideal but necessary
27900 // to account for site editor and post editor differences for now.
27901 extraContent,
27902 extraSidebarPanels,
27903 ...props
27904 }) {
27905 const {
27906 post,
27907 template,
27908 hasLoadedPost
27909 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
27910 const {
27911 getEntityRecord,
27912 hasFinishedResolution
27913 } = select(external_wp_coreData_namespaceObject.store);
27914 return {
27915 post: getEntityRecord('postType', postType, postId),
27916 template: templateId ? getEntityRecord('postType', TEMPLATE_POST_TYPE, templateId) : undefined,
27917 hasLoadedPost: hasFinishedResolution('getEntityRecord', ['postType', postType, postId])
27918 };
27919 }, [postType, postId, templateId]);
27920 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
27921 children: [hasLoadedPost && !post && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Notice, {
27922 status: "warning",
27923 isDismissible: false,
27924 children: (0,external_wp_i18n_namespaceObject.__)("You attempted to edit an item that doesn't exist. Perhaps it was deleted?")
27925 }), !!post && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(ExperimentalEditorProvider, {
27926 post: post,
27927 __unstableTemplate: template,
27928 settings: settings,
27929 initialEdits: initialEdits,
27930 useSubRegistry: false,
27931 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(EditorInterface, {
27932 ...props,
27933 children: extraContent
27934 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(components_sidebar, {
27935 onActionPerformed: onActionPerformed,
27936 extraPanels: extraSidebarPanels
27937 }), children]
27938 })]
27939 });
27940 }
27941 /* harmony default export */ const editor = (Editor);
27942
27943 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/preferences-modal/enable-publish-sidebar.js
27944 /**
27945 * WordPress dependencies
27946 */
27947
27948
27949
27950
27951 /**
27952 * Internal dependencies
27953 */
27954
27955
27956 const {
27957 PreferenceBaseOption: enable_publish_sidebar_PreferenceBaseOption
27958 } = unlock(external_wp_preferences_namespaceObject.privateApis);
27959 /* harmony default export */ const enable_publish_sidebar = ((0,external_wp_compose_namespaceObject.compose)((0,external_wp_data_namespaceObject.withSelect)(select => ({
27960 isChecked: select(store_store).isPublishSidebarEnabled()
27961 })), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
27962 const {
27963 enablePublishSidebar,
27964 disablePublishSidebar
27965 } = dispatch(store_store);
27966 return {
27967 onChange: isEnabled => isEnabled ? enablePublishSidebar() : disablePublishSidebar()
27968 };
27969 }))(enable_publish_sidebar_PreferenceBaseOption));
27970
27971 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-manager/checklist.js
27972 /**
27973 * WordPress dependencies
27974 */
27975
27976
27977
27978
27979 function BlockTypesChecklist({
27980 blockTypes,
27981 value,
27982 onItemChange
27983 }) {
27984 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("ul", {
27985 className: "editor-block-manager__checklist",
27986 children: blockTypes.map(blockType => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("li", {
27987 className: "editor-block-manager__checklist-item",
27988 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
27989 __nextHasNoMarginBottom: true,
27990 label: blockType.title,
27991 checked: value.includes(blockType.name),
27992 onChange: (...args) => onItemChange(blockType.name, ...args)
27993 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_blockEditor_namespaceObject.BlockIcon, {
27994 icon: blockType.icon
27995 })]
27996 }, blockType.name))
27997 });
27998 }
27999 /* harmony default export */ const checklist = (BlockTypesChecklist);
28000
28001 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-manager/category.js
28002 /**
28003 * WordPress dependencies
28004 */
28005
28006
28007
28008
28009
28010
28011 /**
28012 * Internal dependencies
28013 */
28014
28015
28016
28017
28018
28019 function BlockManagerCategory({
28020 title,
28021 blockTypes
28022 }) {
28023 const instanceId = (0,external_wp_compose_namespaceObject.useInstanceId)(BlockManagerCategory);
28024 const {
28025 allowedBlockTypes,
28026 hiddenBlockTypes
28027 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28028 const {
28029 getEditorSettings
28030 } = select(store_store);
28031 const {
28032 get
28033 } = select(external_wp_preferences_namespaceObject.store);
28034 return {
28035 allowedBlockTypes: getEditorSettings().allowedBlockTypes,
28036 hiddenBlockTypes: get('core', 'hiddenBlockTypes')
28037 };
28038 }, []);
28039 const filteredBlockTypes = (0,external_wp_element_namespaceObject.useMemo)(() => {
28040 if (allowedBlockTypes === true) {
28041 return blockTypes;
28042 }
28043 return blockTypes.filter(({
28044 name
28045 }) => {
28046 return allowedBlockTypes?.includes(name);
28047 });
28048 }, [allowedBlockTypes, blockTypes]);
28049 const {
28050 showBlockTypes,
28051 hideBlockTypes
28052 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
28053 const toggleVisible = (0,external_wp_element_namespaceObject.useCallback)((blockName, nextIsChecked) => {
28054 if (nextIsChecked) {
28055 showBlockTypes(blockName);
28056 } else {
28057 hideBlockTypes(blockName);
28058 }
28059 }, [showBlockTypes, hideBlockTypes]);
28060 const toggleAllVisible = (0,external_wp_element_namespaceObject.useCallback)(nextIsChecked => {
28061 const blockNames = blockTypes.map(({
28062 name
28063 }) => name);
28064 if (nextIsChecked) {
28065 showBlockTypes(blockNames);
28066 } else {
28067 hideBlockTypes(blockNames);
28068 }
28069 }, [blockTypes, showBlockTypes, hideBlockTypes]);
28070 if (!filteredBlockTypes.length) {
28071 return null;
28072 }
28073 const checkedBlockNames = filteredBlockTypes.map(({
28074 name
28075 }) => name).filter(type => !(hiddenBlockTypes !== null && hiddenBlockTypes !== void 0 ? hiddenBlockTypes : []).includes(type));
28076 const titleId = 'editor-block-manager__category-title-' + instanceId;
28077 const isAllChecked = checkedBlockNames.length === filteredBlockTypes.length;
28078 const isIndeterminate = !isAllChecked && checkedBlockNames.length > 0;
28079 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
28080 role: "group",
28081 "aria-labelledby": titleId,
28082 className: "editor-block-manager__category",
28083 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.CheckboxControl, {
28084 __nextHasNoMarginBottom: true,
28085 checked: isAllChecked,
28086 onChange: toggleAllVisible,
28087 className: "editor-block-manager__category-title",
28088 indeterminate: isIndeterminate,
28089 label: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("span", {
28090 id: titleId,
28091 children: title
28092 })
28093 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(checklist, {
28094 blockTypes: filteredBlockTypes,
28095 value: checkedBlockNames,
28096 onItemChange: toggleVisible
28097 })]
28098 });
28099 }
28100 /* harmony default export */ const block_manager_category = (BlockManagerCategory);
28101
28102 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/block-manager/index.js
28103 /**
28104 * WordPress dependencies
28105 */
28106
28107
28108
28109
28110
28111
28112
28113
28114
28115 /**
28116 * Internal dependencies
28117 */
28118
28119
28120
28121
28122
28123 function BlockManager({
28124 blockTypes,
28125 categories,
28126 hasBlockSupport,
28127 isMatchingSearchTerm,
28128 numberOfHiddenBlocks,
28129 enableAllBlockTypes
28130 }) {
28131 const debouncedSpeak = (0,external_wp_compose_namespaceObject.useDebounce)(external_wp_a11y_namespaceObject.speak, 500);
28132 const [search, setSearch] = (0,external_wp_element_namespaceObject.useState)('');
28133
28134 // Filtering occurs here (as opposed to `withSelect`) to avoid
28135 // wasted renders by consequence of `Array#filter` producing
28136 // a new value reference on each call.
28137 blockTypes = blockTypes.filter(blockType => hasBlockSupport(blockType, 'inserter', true) && (!search || isMatchingSearchTerm(blockType, search)) && (!blockType.parent || blockType.parent.includes('core/post-content')));
28138
28139 // Announce search results on change
28140 (0,external_wp_element_namespaceObject.useEffect)(() => {
28141 if (!search) {
28142 return;
28143 }
28144 const count = blockTypes.length;
28145 const resultsFoundMessage = (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of results. */
28146 (0,external_wp_i18n_namespaceObject._n)('%d result found.', '%d results found.', count), count);
28147 debouncedSpeak(resultsFoundMessage);
28148 }, [blockTypes.length, search, debouncedSpeak]);
28149 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
28150 className: "editor-block-manager__content",
28151 children: [!!numberOfHiddenBlocks && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
28152 className: "editor-block-manager__disabled-blocks-count",
28153 children: [(0,external_wp_i18n_namespaceObject.sprintf)( /* translators: %d: number of blocks. */
28154 (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, {
28155 variant: "link",
28156 onClick: () => enableAllBlockTypes(blockTypes),
28157 children: (0,external_wp_i18n_namespaceObject.__)('Reset')
28158 })]
28159 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.SearchControl, {
28160 __nextHasNoMarginBottom: true,
28161 label: (0,external_wp_i18n_namespaceObject.__)('Search for a block'),
28162 placeholder: (0,external_wp_i18n_namespaceObject.__)('Search for a block'),
28163 value: search,
28164 onChange: nextSearch => setSearch(nextSearch),
28165 className: "editor-block-manager__search"
28166 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)("div", {
28167 tabIndex: "0",
28168 role: "region",
28169 "aria-label": (0,external_wp_i18n_namespaceObject.__)('Available block types'),
28170 className: "editor-block-manager__results",
28171 children: [blockTypes.length === 0 && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)("p", {
28172 className: "editor-block-manager__no-results",
28173 children: (0,external_wp_i18n_namespaceObject.__)('No blocks found.')
28174 }), categories.map(category => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_manager_category, {
28175 title: category.title,
28176 blockTypes: blockTypes.filter(blockType => blockType.category === category.slug)
28177 }, category.slug)), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_manager_category, {
28178 title: (0,external_wp_i18n_namespaceObject.__)('Uncategorized'),
28179 blockTypes: blockTypes.filter(({
28180 category
28181 }) => !category)
28182 })]
28183 })]
28184 });
28185 }
28186 /* harmony default export */ const block_manager = ((0,external_wp_compose_namespaceObject.compose)([(0,external_wp_data_namespaceObject.withSelect)(select => {
28187 var _get;
28188 const {
28189 getBlockTypes,
28190 getCategories,
28191 hasBlockSupport,
28192 isMatchingSearchTerm
28193 } = select(external_wp_blocks_namespaceObject.store);
28194 const {
28195 get
28196 } = select(external_wp_preferences_namespaceObject.store);
28197
28198 // Some hidden blocks become unregistered
28199 // by removing for instance the plugin that registered them, yet
28200 // they're still remain as hidden by the user's action.
28201 // We consider "hidden", blocks which were hidden and
28202 // are still registered.
28203 const blockTypes = getBlockTypes();
28204 const hiddenBlockTypes = ((_get = get('core', 'hiddenBlockTypes')) !== null && _get !== void 0 ? _get : []).filter(hiddenBlock => {
28205 return blockTypes.some(registeredBlock => registeredBlock.name === hiddenBlock);
28206 });
28207 const numberOfHiddenBlocks = Array.isArray(hiddenBlockTypes) && hiddenBlockTypes.length;
28208 return {
28209 blockTypes,
28210 categories: getCategories(),
28211 hasBlockSupport,
28212 isMatchingSearchTerm,
28213 numberOfHiddenBlocks
28214 };
28215 }), (0,external_wp_data_namespaceObject.withDispatch)(dispatch => {
28216 const {
28217 showBlockTypes
28218 } = unlock(dispatch(store_store));
28219 return {
28220 enableAllBlockTypes: blockTypes => {
28221 const blockNames = blockTypes.map(({
28222 name
28223 }) => name);
28224 showBlockTypes(blockNames);
28225 }
28226 };
28227 })])(BlockManager));
28228
28229 ;// CONCATENATED MODULE: ./packages/editor/build-module/components/preferences-modal/index.js
28230 /**
28231 * WordPress dependencies
28232 */
28233
28234
28235
28236
28237
28238
28239
28240
28241 /**
28242 * Internal dependencies
28243 */
28244
28245
28246
28247
28248
28249
28250
28251
28252
28253
28254
28255
28256
28257
28258 const {
28259 PreferencesModal,
28260 PreferencesModalTabs,
28261 PreferencesModalSection,
28262 PreferenceToggleControl
28263 } = unlock(external_wp_preferences_namespaceObject.privateApis);
28264 function EditorPreferencesModal({
28265 extraSections = {}
28266 }) {
28267 const isLargeViewport = (0,external_wp_compose_namespaceObject.useViewportMatch)('medium');
28268 const {
28269 isActive,
28270 showBlockBreadcrumbsOption
28271 } = (0,external_wp_data_namespaceObject.useSelect)(select => {
28272 const {
28273 getEditorSettings
28274 } = select(store_store);
28275 const {
28276 get
28277 } = select(external_wp_preferences_namespaceObject.store);
28278 const {
28279 isModalActive
28280 } = select(store);
28281 const isRichEditingEnabled = getEditorSettings().richEditingEnabled;
28282 const isDistractionFreeEnabled = get('core', 'distractionFree');
28283 return {
28284 showBlockBreadcrumbsOption: !isDistractionFreeEnabled && isLargeViewport && isRichEditingEnabled,
28285 isActive: isModalActive('editor/preferences')
28286 };
28287 }, [isLargeViewport]);
28288 const {
28289 closeModal
28290 } = (0,external_wp_data_namespaceObject.useDispatch)(store);
28291 const {
28292 setIsListViewOpened,
28293 setIsInserterOpened
28294 } = (0,external_wp_data_namespaceObject.useDispatch)(store_store);
28295 const {
28296 set: setPreference
28297 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_preferences_namespaceObject.store);
28298 const sections = (0,external_wp_element_namespaceObject.useMemo)(() => [{
28299 name: 'general',
28300 tabLabel: (0,external_wp_i18n_namespaceObject.__)('General'),
28301 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28302 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
28303 title: (0,external_wp_i18n_namespaceObject.__)('Interface'),
28304 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28305 scope: "core",
28306 featureName: "showListViewByDefault",
28307 help: (0,external_wp_i18n_namespaceObject.__)('Opens the List View sidebar by default.'),
28308 label: (0,external_wp_i18n_namespaceObject.__)('Always open List View')
28309 }), showBlockBreadcrumbsOption && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28310 scope: "core",
28311 featureName: "showBlockBreadcrumbs",
28312 help: (0,external_wp_i18n_namespaceObject.__)('Display the block hierarchy trail at the bottom of the editor.'),
28313 label: (0,external_wp_i18n_namespaceObject.__)('Show block breadcrumbs')
28314 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28315 scope: "core",
28316 featureName: "allowRightClickOverrides",
28317 help: (0,external_wp_i18n_namespaceObject.__)('Allows contextual List View menus via right-click, overriding browser defaults.'),
28318 label: (0,external_wp_i18n_namespaceObject.__)('Allow right-click contextual menus')
28319 })]
28320 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
28321 title: (0,external_wp_i18n_namespaceObject.__)('Document settings'),
28322 description: (0,external_wp_i18n_namespaceObject.__)('Select what settings are shown in the document panel.'),
28323 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_plugin_document_setting_panel.Slot, {}), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_taxonomies, {
28324 taxonomyWrapper: (content, taxonomy) => /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
28325 label: taxonomy.labels.menu_name,
28326 panelName: `taxonomy-panel-${taxonomy.slug}`
28327 })
28328 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_featured_image_check, {
28329 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
28330 label: (0,external_wp_i18n_namespaceObject.__)('Featured image'),
28331 panelName: "featured-image"
28332 })
28333 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_excerpt_check, {
28334 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
28335 label: (0,external_wp_i18n_namespaceObject.__)('Excerpt'),
28336 panelName: "post-excerpt"
28337 })
28338 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(post_type_support_check, {
28339 supportKeys: ['comments', 'trackbacks'],
28340 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
28341 label: (0,external_wp_i18n_namespaceObject.__)('Discussion'),
28342 panelName: "discussion-panel"
28343 })
28344 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(page_attributes_check, {
28345 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_panel, {
28346 label: (0,external_wp_i18n_namespaceObject.__)('Page attributes'),
28347 panelName: "page-attributes"
28348 })
28349 })]
28350 }), isLargeViewport && /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
28351 title: (0,external_wp_i18n_namespaceObject.__)('Publishing'),
28352 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(enable_publish_sidebar, {
28353 help: (0,external_wp_i18n_namespaceObject.__)('Review settings, such as visibility and tags.'),
28354 label: (0,external_wp_i18n_namespaceObject.__)('Enable pre-publish checks')
28355 })
28356 }), extraSections?.general]
28357 })
28358 }, {
28359 name: 'appearance',
28360 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Appearance'),
28361 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(PreferencesModalSection, {
28362 title: (0,external_wp_i18n_namespaceObject.__)('Appearance'),
28363 description: (0,external_wp_i18n_namespaceObject.__)('Customize the editor interface to suit your needs.'),
28364 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28365 scope: "core",
28366 featureName: "fixedToolbar",
28367 onToggle: () => setPreference('core', 'distractionFree', false),
28368 help: (0,external_wp_i18n_namespaceObject.__)('Access all block and document tools in a single place.'),
28369 label: (0,external_wp_i18n_namespaceObject.__)('Top toolbar')
28370 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28371 scope: "core",
28372 featureName: "distractionFree",
28373 onToggle: () => {
28374 setPreference('core', 'fixedToolbar', true);
28375 setIsInserterOpened(false);
28376 setIsListViewOpened(false);
28377 },
28378 help: (0,external_wp_i18n_namespaceObject.__)('Reduce visual distractions by hiding the toolbar and other elements to focus on writing.'),
28379 label: (0,external_wp_i18n_namespaceObject.__)('Distraction free')
28380 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28381 scope: "core",
28382 featureName: "focusMode",
28383 help: (0,external_wp_i18n_namespaceObject.__)('Highlights the current block and fades other content.'),
28384 label: (0,external_wp_i18n_namespaceObject.__)('Spotlight mode')
28385 }), extraSections?.appearance]
28386 })
28387 }, {
28388 name: 'accessibility',
28389 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Accessibility'),
28390 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28391 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
28392 title: (0,external_wp_i18n_namespaceObject.__)('Navigation'),
28393 description: (0,external_wp_i18n_namespaceObject.__)('Optimize the editing experience for enhanced control.'),
28394 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28395 scope: "core",
28396 featureName: "keepCaretInsideBlock",
28397 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.'),
28398 label: (0,external_wp_i18n_namespaceObject.__)('Contain text cursor inside block')
28399 })
28400 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
28401 title: (0,external_wp_i18n_namespaceObject.__)('Interface'),
28402 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28403 scope: "core",
28404 featureName: "showIconLabels",
28405 label: (0,external_wp_i18n_namespaceObject.__)('Show button text labels'),
28406 help: (0,external_wp_i18n_namespaceObject.__)('Show text instead of icons on buttons across the interface.')
28407 })
28408 })]
28409 })
28410 }, {
28411 name: 'blocks',
28412 tabLabel: (0,external_wp_i18n_namespaceObject.__)('Blocks'),
28413 content: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_ReactJSXRuntime_namespaceObject.Fragment, {
28414 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
28415 title: (0,external_wp_i18n_namespaceObject.__)('Inserter'),
28416 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferenceToggleControl, {
28417 scope: "core",
28418 featureName: "mostUsedBlocks",
28419 help: (0,external_wp_i18n_namespaceObject.__)('Adds a category with the most frequently used blocks in the inserter.'),
28420 label: (0,external_wp_i18n_namespaceObject.__)('Show most used blocks')
28421 })
28422 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalSection, {
28423 title: (0,external_wp_i18n_namespaceObject.__)('Manage block visibility'),
28424 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."),
28425 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(block_manager, {})
28426 })]
28427 })
28428 }], [showBlockBreadcrumbsOption, extraSections, setIsInserterOpened, setIsListViewOpened, setPreference, isLargeViewport]);
28429 if (!isActive) {
28430 return null;
28431 }
28432 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModal, {
28433 closeModal: closeModal,
28434 children: /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(PreferencesModalTabs, {
28435 sections: sections
28436 })
28437 });
28438 }
28439
28440 ;// CONCATENATED MODULE: ./packages/editor/build-module/dataviews/actions/delete-post.js
28441 /**
28442 * WordPress dependencies
28443 */
28444
28445
28446
28447
28448
28449 // @ts-ignore
28450
28451 /**
28452 * Internal dependencies
28453 */
28454
28455 // @ts-ignore
28456
28457
28458
28459
28460 const {
28461 PATTERN_TYPES: delete_post_PATTERN_TYPES
28462 } = unlock(external_wp_patterns_namespaceObject.privateApis);
28463
28464 // This action is used for templates, patterns and template parts.
28465 // Every other post type uses the similar `trashPostAction` which
28466 // moves the post to trash.
28467 const deletePostAction = {
28468 id: 'delete-post',
28469 label: (0,external_wp_i18n_namespaceObject.__)('Delete'),
28470 isPrimary: true,
28471 icon: library_trash,
28472 isEligible(post) {
28473 if (isTemplateOrTemplatePart(post)) {
28474 return isTemplateRemovable(post);
28475 }
28476 // We can only remove user patterns.
28477 return post.type === delete_post_PATTERN_TYPES.user;
28478 },
28479 supportsBulk: true,
28480 hideModalHeader: true,
28481 RenderModal: ({
28482 items,
28483 closeModal,
28484 onActionPerformed
28485 }) => {
28486 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
28487 const {
28488 removeTemplates
28489 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
28490 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
28491 spacing: "5",
28492 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
28493 children: items.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)(
28494 // translators: %d: number of items to delete.
28495 (0,external_wp_i18n_namespaceObject._n)('Delete %d item?', 'Delete %d items?', items.length), items.length) : (0,external_wp_i18n_namespaceObject.sprintf)(
28496 // translators: %s: The template or template part's titles
28497 (0,external_wp_i18n_namespaceObject.__)('Delete "%s"?'), getItemTitle(items[0]))
28498 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
28499 justify: "right",
28500 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
28501 variant: "tertiary",
28502 onClick: closeModal,
28503 disabled: isBusy,
28504 accessibleWhenDisabled: true,
28505 __next40pxDefaultSize: true,
28506 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
28507 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
28508 variant: "primary",
28509 onClick: async () => {
28510 setIsBusy(true);
28511 await removeTemplates(items, {
28512 allowUndo: false
28513 });
28514 onActionPerformed?.(items);
28515 setIsBusy(false);
28516 closeModal?.();
28517 },
28518 isBusy: isBusy,
28519 disabled: isBusy,
28520 accessibleWhenDisabled: true,
28521 __next40pxDefaultSize: true,
28522 children: (0,external_wp_i18n_namespaceObject.__)('Delete')
28523 })]
28524 })]
28525 });
28526 }
28527 };
28528 /* harmony default export */ const delete_post = (deletePostAction);
28529
28530 ;// CONCATENATED MODULE: ./node_modules/client-zip/index.js
28531 "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)}
28532 ;// CONCATENATED MODULE: ./packages/editor/build-module/dataviews/actions/export-pattern.js
28533 /**
28534 * External dependencies
28535 */
28536
28537
28538
28539 /**
28540 * WordPress dependencies
28541 */
28542
28543
28544
28545 /**
28546 * Internal dependencies
28547 */
28548
28549
28550 function getJsonFromItem(item) {
28551 return JSON.stringify({
28552 __file: item.type,
28553 title: getItemTitle(item),
28554 content: typeof item.content === 'string' ? item.content : item.content?.raw,
28555 syncStatus: item.wp_pattern_sync_status
28556 }, null, 2);
28557 }
28558 const exportPattern = {
28559 id: 'export-pattern',
28560 label: (0,external_wp_i18n_namespaceObject.__)('Export as JSON'),
28561 supportsBulk: true,
28562 isEligible: item => item.type === 'wp_block',
28563 callback: async items => {
28564 if (items.length === 1) {
28565 return (0,external_wp_blob_namespaceObject.downloadBlob)(`${paramCase(getItemTitle(items[0]) || items[0].slug)}.json`, getJsonFromItem(items[0]), 'application/json');
28566 }
28567 const nameCount = {};
28568 const filesToZip = items.map(item => {
28569 const name = paramCase(getItemTitle(item) || item.slug);
28570 nameCount[name] = (nameCount[name] || 0) + 1;
28571 return {
28572 name: `${name + (nameCount[name] > 1 ? '-' + (nameCount[name] - 1) : '')}.json`,
28573 lastModified: new Date(),
28574 input: getJsonFromItem(item)
28575 };
28576 });
28577 return (0,external_wp_blob_namespaceObject.downloadBlob)((0,external_wp_i18n_namespaceObject.__)('patterns-export') + '.zip', await A(filesToZip).blob(), 'application/zip');
28578 }
28579 };
28580 /* harmony default export */ const export_pattern = (exportPattern);
28581
28582 ;// CONCATENATED MODULE: ./packages/editor/build-module/dataviews/actions/reset-post.js
28583 /**
28584 * WordPress dependencies
28585 */
28586
28587
28588
28589
28590
28591
28592
28593 /**
28594 * Internal dependencies
28595 */
28596
28597
28598
28599
28600
28601
28602 const reset_post_resetPost = {
28603 id: 'reset-post',
28604 label: (0,external_wp_i18n_namespaceObject.__)('Reset'),
28605 isEligible: item => {
28606 return isTemplateOrTemplatePart(item) && item?.source === TEMPLATE_ORIGINS.custom && item?.has_theme_file;
28607 },
28608 icon: library_backup,
28609 supportsBulk: true,
28610 hideModalHeader: true,
28611 RenderModal: ({
28612 items,
28613 closeModal,
28614 onActionPerformed
28615 }) => {
28616 const [isBusy, setIsBusy] = (0,external_wp_element_namespaceObject.useState)(false);
28617 const {
28618 revertTemplate
28619 } = unlock((0,external_wp_data_namespaceObject.useDispatch)(store_store));
28620 const {
28621 saveEditedEntityRecord
28622 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_coreData_namespaceObject.store);
28623 const {
28624 createSuccessNotice,
28625 createErrorNotice
28626 } = (0,external_wp_data_namespaceObject.useDispatch)(external_wp_notices_namespaceObject.store);
28627 const onConfirm = async () => {
28628 try {
28629 for (const template of items) {
28630 await revertTemplate(template, {
28631 allowUndo: false
28632 });
28633 await saveEditedEntityRecord('postType', template.type, template.id);
28634 }
28635 createSuccessNotice(items.length > 1 ? (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The number of items. */
28636 (0,external_wp_i18n_namespaceObject.__)('%s items reset.'), items.length) : (0,external_wp_i18n_namespaceObject.sprintf)( /* translators: The template/part's name. */
28637 (0,external_wp_i18n_namespaceObject.__)('"%s" reset.'), getItemTitle(items[0])), {
28638 type: 'snackbar',
28639 id: 'revert-template-action'
28640 });
28641 } catch (error) {
28642 let fallbackErrorMessage;
28643 if (items[0].type === TEMPLATE_POST_TYPE) {
28644 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.');
28645 } else {
28646 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.');
28647 }
28648 const typedError = error;
28649 const errorMessage = typedError.message && typedError.code !== 'unknown_error' ? typedError.message : fallbackErrorMessage;
28650 createErrorNotice(errorMessage, {
28651 type: 'snackbar'
28652 });
28653 }
28654 };
28655 return /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalVStack, {
28656 spacing: "5",
28657 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.__experimentalText, {
28658 children: (0,external_wp_i18n_namespaceObject.__)('Reset to default and clear all customizations?')
28659 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsxs)(external_wp_components_namespaceObject.__experimentalHStack, {
28660 justify: "right",
28661 children: [/*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
28662 variant: "tertiary",
28663 onClick: closeModal,
28664 disabled: isBusy,
28665 accessibleWhenDisabled: true,
28666 children: (0,external_wp_i18n_namespaceObject.__)('Cancel')
28667 }), /*#__PURE__*/(0,external_ReactJSXRuntime_namespaceObject.jsx)(external_wp_components_namespaceObject.Button, {
28668 variant: "primary",
28669 onClick: async () => {
28670 setIsBusy(true);
28671 await onConfirm();
28672 onActionPerformed?.(items);
28673 setIsBusy(false);
28674 closeModal?.();
28675 },
28676 isBusy: isBusy,
28677 disabled: isBusy,
28678 accessibleWhenDisabled: true,
28679 children: (0,external_wp_i18n_namespaceObject.__)('Reset')
28680 })]
28681 })]
28682 });
28683 }
28684 };
28685 /* harmony default export */ const reset_post = (reset_post_resetPost);
28686
28687 ;// CONCATENATED MODULE: ./packages/editor/build-module/dataviews/actions/index.js
28688 /**
28689 * WordPress dependencies
28690 */
28691
28692
28693 /**
28694 * Internal dependencies
28695 */
28696
28697
28698
28699
28700 // @ts-ignore
28701
28702
28703 function registerDefaultActions() {
28704 const {
28705 registerEntityAction
28706 } = unlock((0,external_wp_data_namespaceObject.dispatch)(store_store));
28707 registerEntityAction('postType', 'wp_block', export_pattern);
28708 registerEntityAction('postType', '*', reset_post);
28709 registerEntityAction('postType', '*', delete_post);
28710 }
28711
28712 ;// CONCATENATED MODULE: ./packages/editor/build-module/bindings/pattern-overrides.js
28713 /**
28714 * WordPress dependencies
28715 */
28716
28717 const CONTENT = 'content';
28718 /* harmony default export */ const pattern_overrides = ({
28719 name: 'core/pattern-overrides',
28720 getValues({
28721 registry,
28722 clientId,
28723 context,
28724 bindings
28725 }) {
28726 const patternOverridesContent = context['pattern/overrides'];
28727 const {
28728 getBlockAttributes
28729 } = registry.select(external_wp_blockEditor_namespaceObject.store);
28730 const currentBlockAttributes = getBlockAttributes(clientId);
28731 const overridesValues = {};
28732 for (const attributeName of Object.keys(bindings)) {
28733 const overridableValue = patternOverridesContent?.[currentBlockAttributes?.metadata?.name]?.[attributeName];
28734
28735 // If it has not been overriden, return the original value.
28736 // Check undefined because empty string is a valid value.
28737 if (overridableValue === undefined) {
28738 overridesValues[attributeName] = currentBlockAttributes[attributeName];
28739 continue;
28740 } else {
28741 overridesValues[attributeName] = overridableValue === '' ? undefined : overridableValue;
28742 }
28743 }
28744 return overridesValues;
28745 },
28746 setValues({
28747 registry,
28748 clientId,
28749 bindings
28750 }) {
28751 const {
28752 getBlockAttributes,
28753 getBlockParentsByBlockName,
28754 getBlocks
28755 } = registry.select(external_wp_blockEditor_namespaceObject.store);
28756 const currentBlockAttributes = getBlockAttributes(clientId);
28757 const blockName = currentBlockAttributes?.metadata?.name;
28758 if (!blockName) {
28759 return;
28760 }
28761 const [patternClientId] = getBlockParentsByBlockName(clientId, 'core/block', true);
28762
28763 // Extract the updated attributes from the source bindings.
28764 const attributes = Object.entries(bindings).reduce((attrs, [key, {
28765 newValue
28766 }]) => {
28767 attrs[key] = newValue;
28768 return attrs;
28769 }, {});
28770
28771 // If there is no pattern client ID, sync blocks with the same name and same attributes.
28772 if (!patternClientId) {
28773 const syncBlocksWithSameName = blocks => {
28774 for (const block of blocks) {
28775 if (block.attributes?.metadata?.name === blockName) {
28776 registry.dispatch(external_wp_blockEditor_namespaceObject.store).updateBlockAttributes(block.clientId, attributes);
28777 }
28778 syncBlocksWithSameName(block.innerBlocks);
28779 }
28780 };
28781 syncBlocksWithSameName(getBlocks());
28782 return;
28783 }
28784 const currentBindingValue = getBlockAttributes(patternClientId)?.[CONTENT];
28785 registry.dispatch(external_wp_blockEditor_namespaceObject.store).updateBlockAttributes(patternClientId, {
28786 [CONTENT]: {
28787 ...currentBindingValue,
28788 [blockName]: {
28789 ...currentBindingValue?.[blockName],
28790 ...Object.entries(attributes).reduce((acc, [key, value]) => {
28791 // TODO: We need a way to represent `undefined` in the serialized overrides.
28792 // Also see: https://github.com/WordPress/gutenberg/pull/57249#discussion_r1452987871
28793 // We use an empty string to represent undefined for now until
28794 // we support a richer format for overrides and the block bindings API.
28795 acc[key] = value === undefined ? '' : value;
28796 return acc;
28797 }, {})
28798 }
28799 }
28800 });
28801 },
28802 canUserEditValue: () => true
28803 });
28804
28805 ;// CONCATENATED MODULE: ./packages/editor/build-module/bindings/post-meta.js
28806 /**
28807 * WordPress dependencies
28808 */
28809
28810
28811 /**
28812 * Internal dependencies
28813 */
28814
28815 /* harmony default export */ const post_meta = ({
28816 name: 'core/post-meta',
28817 getPlaceholder({
28818 args
28819 }) {
28820 return args.key;
28821 },
28822 getValues({
28823 registry,
28824 context,
28825 bindings
28826 }) {
28827 const meta = registry.select(external_wp_coreData_namespaceObject.store).getEditedEntityRecord('postType', context?.postType, context?.postId)?.meta;
28828 const newValues = {};
28829 for (const [attributeName, source] of Object.entries(bindings)) {
28830 newValues[attributeName] = meta?.[source.args.key];
28831 }
28832 return newValues;
28833 },
28834 setValues({
28835 registry,
28836 context,
28837 bindings
28838 }) {
28839 const newMeta = {};
28840 Object.values(bindings).forEach(({
28841 args,
28842 newValue
28843 }) => {
28844 newMeta[args.key] = newValue;
28845 });
28846 registry.dispatch(external_wp_coreData_namespaceObject.store).editEntityRecord('postType', context?.postType, context?.postId, {
28847 meta: newMeta
28848 });
28849 },
28850 canUserEditValue({
28851 select,
28852 context,
28853 args
28854 }) {
28855 // Lock editing in query loop.
28856 if (context?.query || context?.queryId) {
28857 return false;
28858 }
28859 const postType = context?.postType || select(store_store).getCurrentPostType();
28860
28861 // Check that editing is happening in the post editor and not a template.
28862 if (postType === 'wp_template') {
28863 return false;
28864 }
28865
28866 // Check that the custom field is not protected and available in the REST API.
28867 const isFieldExposed = !!select(external_wp_coreData_namespaceObject.store).getEntityRecord('postType', postType, context?.postId)?.meta?.[args.key];
28868 if (!isFieldExposed) {
28869 return false;
28870 }
28871
28872 // Check that the user has the capability to edit post meta.
28873 const canUserEdit = select(external_wp_coreData_namespaceObject.store).canUser('update', {
28874 kind: 'postType',
28875 name: context?.postType,
28876 id: context?.postId
28877 });
28878 if (!canUserEdit) {
28879 return false;
28880 }
28881 return true;
28882 }
28883 });
28884
28885 ;// CONCATENATED MODULE: ./packages/editor/build-module/bindings/api.js
28886 /**
28887 * WordPress dependencies
28888 */
28889
28890
28891
28892 /**
28893 * Internal dependencies
28894 */
28895
28896
28897
28898
28899 /**
28900 * Function to register core block bindings sources provided by the editor.
28901 *
28902 * @example
28903 * ```js
28904 * import { registerCoreBlockBindingsSources } from '@wordpress/editor';
28905 *
28906 * registerCoreBlockBindingsSources();
28907 * ```
28908 */
28909 function registerCoreBlockBindingsSources() {
28910 const {
28911 registerBlockBindingsSource
28912 } = unlock(external_wp_blocks_namespaceObject.privateApis);
28913 registerBlockBindingsSource(pattern_overrides);
28914 registerBlockBindingsSource(post_meta);
28915 }
28916
28917 /**
28918 * Function to bootstrap core block bindings sources defined in the server.
28919 *
28920 * @param {Object} sources Object containing the sources to bootstrap.
28921 *
28922 * @example
28923 * ```js
28924 * import { bootstrapBlockBindingsSourcesFromServer } from '@wordpress/editor';
28925 *
28926 * bootstrapBlockBindingsSourcesFromServer( sources );
28927 * ```
28928 */
28929 function bootstrapBlockBindingsSourcesFromServer(sources) {
28930 if (sources) {
28931 const {
28932 addBootstrappedBlockBindingsSource
28933 } = unlock((0,external_wp_data_namespaceObject.dispatch)(external_wp_blocks_namespaceObject.store));
28934 for (const [name, args] of Object.entries(sources)) {
28935 addBootstrappedBlockBindingsSource({
28936 name,
28937 ...args
28938 });
28939 }
28940 }
28941 }
28942
28943 ;// CONCATENATED MODULE: ./packages/editor/build-module/private-apis.js
28944 /**
28945 * WordPress dependencies
28946 */
28947
28948
28949 /**
28950 * Internal dependencies
28951 */
28952
28953
28954
28955
28956
28957
28958
28959
28960
28961
28962
28963
28964
28965
28966
28967
28968 const {
28969 store: interfaceStore,
28970 ...remainingInterfaceApis
28971 } = build_module_namespaceObject;
28972 const privateApis = {};
28973 lock(privateApis, {
28974 CreateTemplatePartModal: CreateTemplatePartModal,
28975 BackButton: back_button,
28976 EntitiesSavedStatesExtensible: EntitiesSavedStatesExtensible,
28977 Editor: editor,
28978 EditorContentSlotFill: content_slot_fill,
28979 GlobalStylesProvider: GlobalStylesProvider,
28980 mergeBaseAndUserConfigs: mergeBaseAndUserConfigs,
28981 PluginPostExcerpt: post_excerpt_plugin,
28982 PreferencesModal: EditorPreferencesModal,
28983 usePostActions: usePostActions,
28984 ToolsMoreMenuGroup: tools_more_menu_group,
28985 ViewMoreMenuGroup: view_more_menu_group,
28986 ResizableEditor: resizable_editor,
28987 registerDefaultActions: registerDefaultActions,
28988 registerCoreBlockBindingsSources: registerCoreBlockBindingsSources,
28989 bootstrapBlockBindingsSourcesFromServer: bootstrapBlockBindingsSourcesFromServer,
28990 // This is a temporary private API while we're updating the site editor to use EditorProvider.
28991 useBlockEditorSettings: use_block_editor_settings,
28992 interfaceStore,
28993 ...remainingInterfaceApis
28994 });
28995
28996 ;// CONCATENATED MODULE: ./packages/editor/build-module/dataviews/api.js
28997 /**
28998 * WordPress dependencies
28999 */
29000
29001
29002 /**
29003 * Internal dependencies
29004 */
29005
29006
29007
29008 /**
29009 * @typedef {import('@wordpress/dataviews').Action} Action
29010 */
29011
29012 /**
29013 * Registers a new DataViews action.
29014 *
29015 * This is an experimental API and is subject to change.
29016 * it's only available in the Gutenberg plugin for now.
29017 *
29018 * @param {string} kind Entity kind.
29019 * @param {string} name Entity name.
29020 * @param {Action} config Action configuration.
29021 */
29022
29023 function api_registerEntityAction(kind, name, config) {
29024 const {
29025 registerEntityAction: _registerEntityAction
29026 } = unlock((0,external_wp_data_namespaceObject.dispatch)(store_store));
29027 if (true) {
29028 _registerEntityAction(kind, name, config);
29029 }
29030 }
29031
29032 /**
29033 * Unregisters a DataViews action.
29034 *
29035 * This is an experimental API and is subject to change.
29036 * it's only available in the Gutenberg plugin for now.
29037 *
29038 * @param {string} kind Entity kind.
29039 * @param {string} name Entity name.
29040 * @param {string} actionId Action ID.
29041 */
29042 function api_unregisterEntityAction(kind, name, actionId) {
29043 const {
29044 unregisterEntityAction: _unregisterEntityAction
29045 } = unlock((0,external_wp_data_namespaceObject.dispatch)(store_store));
29046 if (true) {
29047 _unregisterEntityAction(kind, name, actionId);
29048 }
29049 }
29050
29051 ;// CONCATENATED MODULE: ./packages/editor/build-module/index.js
29052 /**
29053 * Internal dependencies
29054 */
29055
29056
29057
29058
29059
29060
29061
29062 /*
29063 * Backward compatibility
29064 */
29065
29066
29067 })();
29068
29069 (window.wp = window.wp || {}).editor = __webpack_exports__;
29070 /******/ })()
29071 ;